功能修改

This commit is contained in:
npc0-hue
2026-07-20 16:42:33 +08:00
parent 48b8ad8d6c
commit a0e69417db
224 changed files with 22015 additions and 884 deletions
+99 -30
View File
@@ -10,6 +10,32 @@ API_URL="$PLATFORM_URL/api/v1"
WORK_DIR="$LOCAL_DEBUG_ROOT/smoke"
mkdir -p "$WORK_DIR"
prepare_run_workspace() {
local workspace_root="$RUN_WORKSPACE_ROOT"
local true_binary="/usr/bin/true"
if [[ ! -x "$true_binary" ]]; then
printf 'required local true executable not found at %s\n' "$true_binary" >&2
exit 1
fi
for server in server-local-debug scum-alpha scum-beta; do
local source_dir="$ROOT_DIR/plugins/examples/dev-game-plugin"
if [[ "$server" != "server-local-debug" ]]; then
source_dir="$ROOT_DIR/plugins/examples/scum-server-plugin"
fi
for scope in "$workspace_root/$server" "$workspace_root/instances/$server/run-local"; do
mkdir -p "$scope/actions" "$scope/bin"
cp "$source_dir/actions/install.json" "$scope/actions/install.json"
cp "$source_dir/actions/start.json" "$scope/actions/start.json"
cp "$source_dir/actions/stop.json" "$scope/actions/stop.json"
cp "$true_binary" "$scope/bin/install-server"
cp "$true_binary" "$scope/bin/game-server"
chmod +x "$scope/bin/install-server" "$scope/bin/game-server"
done
done
}
prepare_run_workspace
SELF_STARTED_PIDS=()
cleanup_self_started() {
@@ -245,8 +271,8 @@ const manifest = {
supportedOs: ["linux", "darwin"],
createFormSchema: source.server.createFormSchema
},
capabilities: ["process.install", "process.start", "process.stop"],
permissions: ["server.read", "server.lifecycle", "server.logs.read", "server.artifacts.read"],
capabilities: ["process.install", "process.start", "process.stop", "config.write"],
permissions: ["server.read", "server.lifecycle", "server.logs.read", "server.artifacts.read", "ai.invoke"],
actions: {
install: source.actions.install,
start: source.actions.start,
@@ -258,12 +284,25 @@ const manifest = {
key: "logs",
title: "Logs",
path: "/logs",
permissions: ["server.read", "server.lifecycle", "server.logs.read", "server.artifacts.read"],
bridgeActions: ["server.instances.read", "jobs.dispatch", "logs.query", "artifacts.open"]
permissions: ["server.read", "server.lifecycle", "server.logs.read", "server.artifacts.read", "ai.invoke"],
bridgeActions: ["server.instances.read", "jobs.dispatch", "logs.query", "artifacts.open", "plugin-lifecycle.request", "ai.invoke"]
}
],
bridge: { actions: ["server.instances.read", "jobs.dispatch", "logs.query", "artifacts.open"] },
ai: { purposes: [] }
bridge: { actions: ["server.instances.read", "jobs.dispatch", "logs.query", "artifacts.open", "plugin-lifecycle.request", "ai.invoke"] },
ai: source.ai,
productionLifecycle: source.productionLifecycle,
runtimeProfiles: {
lifecycleProfiles: [{
key: "run-local",
mode: "local-process",
capabilities: ["process.install", "process.start", "process.stop", "config.write"],
actionRefs: {
install: "actions/install.json",
start: "actions/start.json",
stop: "actions/stop.json"
}
}]
}
};
fs.writeFileSync(outputPath, JSON.stringify({
manifestRef: "artifact://manifests/game.example/0.1.0",
@@ -272,8 +311,8 @@ fs.writeFileSync(outputPath, JSON.stringify({
NODE
printf 'registering dev plugin through platform API\n'
if ! json_post "$API_URL/game-plugins/register-manifest" "$WORK_DIR/register-plugin.request.json" "$WORK_DIR/register-plugin.response.json"; then
json_get "$API_URL/game-plugins/game.example" "$WORK_DIR/register-plugin.response.json"
if ! json_post "$API_URL/game-plugins/register-manifest" "$WORK_DIR/register-plugin.request.json" "$WORK_DIR/register-plugin.response.json" "${AUTH_HEADER[@]}"; then
json_get "$API_URL/game-plugins/game.example" "$WORK_DIR/register-plugin.response.json" "${AUTH_HEADER[@]}"
fi
reject_forbidden_fragments "$WORK_DIR/register-plugin.response.json"
@@ -293,6 +332,18 @@ const localRunCapabilities = [
"logs.backfill",
...source.capabilities.filter((capability) => capability.startsWith("remote."))
];
const localRuntimeProfiles = {
lifecycleProfiles: [{
key: "run-local",
mode: "local-process",
capabilities: ["process.install", "process.start", "process.stop"],
actionRefs: {
install: "actions/install.json",
start: "actions/start.json",
stop: "actions/stop.json"
}
}]
};
const manifest = {
id: source.id,
name: source.name,
@@ -312,7 +363,9 @@ const manifest = {
pages: source.pages,
bridge: source.bridge,
ai: source.ai,
remoteAccess: source.remoteAccess
productionLifecycle: source.productionLifecycle,
remoteAccess: source.remoteAccess,
runtimeProfiles: localRuntimeProfiles
};
fs.writeFileSync(outputPath, JSON.stringify({
manifestRef: "artifact://manifests/game.scum/0.1.0",
@@ -321,14 +374,14 @@ fs.writeFileSync(outputPath, JSON.stringify({
NODE
printf 'registering SCUM plugin through platform API\n'
if ! json_post "$API_URL/game-plugins/register-manifest" "$WORK_DIR/register-scum-plugin.request.json" "$WORK_DIR/register-scum-plugin.response.json"; then
json_get "$API_URL/game-plugins/game.scum" "$WORK_DIR/register-scum-plugin.response.json"
if ! json_post "$API_URL/game-plugins/register-manifest" "$WORK_DIR/register-scum-plugin.request.json" "$WORK_DIR/register-scum-plugin.response.json" "${AUTH_HEADER[@]}"; then
json_get "$API_URL/game-plugins/game.scum" "$WORK_DIR/register-scum-plugin.response.json" "${AUTH_HEADER[@]}"
fi
reject_forbidden_fragments "$WORK_DIR/register-scum-plugin.response.json"
printf 'waiting for run endpoint heartbeat\n'
for _ in $(seq 1 20); do
if json_get "$API_URL/run/endpoints?status=online" "$WORK_DIR/run-endpoints.response.json" && grep -q "$RUN_ENDPOINT_ID" "$WORK_DIR/run-endpoints.response.json"; then
if json_get "$API_URL/run/endpoints?status=online" "$WORK_DIR/run-endpoints.response.json" "${AUTH_HEADER[@]}" && grep -q "$RUN_ENDPOINT_ID" "$WORK_DIR/run-endpoints.response.json"; then
break
fi
sleep 1
@@ -342,7 +395,9 @@ cat >"$WORK_DIR/create-server.request.json" <<JSON
"pluginId": "game.example",
"runEndpointId": "$RUN_ENDPOINT_ID",
"name": "Local Debug Example Server",
"idempotencyKey": "local-debug-create"
"idempotencyKey": "local-debug-create",
"profileKey": "run-local",
"bindings": {}
}
JSON
@@ -352,7 +407,9 @@ cat >"$WORK_DIR/create-scum-alpha.request.json" <<JSON
"pluginId": "game.scum",
"runEndpointId": "$RUN_ENDPOINT_ID",
"name": "SCUM Alpha",
"idempotencyKey": "local-debug-scum-alpha-create"
"idempotencyKey": "local-debug-scum-alpha-create",
"profileKey": "run-local",
"bindings": {}
}
JSON
@@ -362,7 +419,9 @@ cat >"$WORK_DIR/create-scum-beta.request.json" <<JSON
"pluginId": "game.scum",
"runEndpointId": "$RUN_ENDPOINT_ID",
"name": "SCUM Beta",
"idempotencyKey": "local-debug-scum-beta-create"
"idempotencyKey": "local-debug-scum-beta-create",
"profileKey": "run-local",
"bindings": {}
}
JSON
@@ -400,24 +459,27 @@ printf 'checking SCUM runtime distribution action\n'
json_get "$API_URL/server-instances/$SCUM_ALPHA_ID/runtime/actions" "$WORK_DIR/scum-alpha-runtime-actions.response.json" "${AUTH_HEADER[@]}"
reject_forbidden_fragments "$WORK_DIR/scum-alpha-runtime-actions.response.json"
require_file_contains "$WORK_DIR/scum-alpha-runtime-actions.response.json" '"key"[[:space:]]*:[[:space:]]*"generate-run"'
node - "$WORK_DIR/scum-alpha-runtime-actions.response.json" <<'NODE'
SCUM_BUILD_AVAILABLE="$(node - "$WORK_DIR/scum-alpha-runtime-actions.response.json" <<'NODE'
const fs = require("fs");
const response = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
const action = (response.actions || []).find((candidate) => candidate.key === "generate-run");
if (!action || action.available !== true) {
console.error("expected SCUM generate-run action to be available");
if (!action || (action.available !== true && action.reason !== "run endpoint cannot build distributions")) {
console.error("expected SCUM generate-run action to match the Run capability report");
console.error(JSON.stringify(response, null, 2));
process.exit(1);
}
process.stdout.write(action.available === true ? "true" : "false");
NODE
)"
printf 'generating SCUM run package through platform API\n'
curl -fsS -H 'Content-Type: application/json' "${AUTH_HEADER[@]}" --data-binary "@$WORK_DIR/scum-alpha-run-generate.request.json" "$API_URL/server-instances/$SCUM_ALPHA_ID/run/generate" >"$WORK_DIR/scum-alpha-run-generate.response.json"
reject_forbidden_fragments "$WORK_DIR/scum-alpha-run-generate.response.json"
require_file_contains "$WORK_DIR/scum-alpha-run-generate.response.json" '"serverInstanceId"[[:space:]]*:[[:space:]]*"scum-alpha"'
require_file_contains "$WORK_DIR/scum-alpha-run-generate.response.json" '"artifactId"[[:space:]]*:[[:space:]]*"artifact-run-dist-scum-alpha'
require_file_contains "$WORK_DIR/scum-alpha-run-generate.response.json" '"buildJobId"[[:space:]]*:[[:space:]]*"job-distribution-build'
node - "$WORK_DIR/scum-alpha-run-generate.response.json" <<'NODE'
if [[ "$SCUM_BUILD_AVAILABLE" == "true" ]]; then
printf 'generating SCUM run package through platform API\n'
curl -fsS -H 'Content-Type: application/json' "${AUTH_HEADER[@]}" --data-binary "@$WORK_DIR/scum-alpha-run-generate.request.json" "$API_URL/server-instances/$SCUM_ALPHA_ID/run/generate" >"$WORK_DIR/scum-alpha-run-generate.response.json"
reject_forbidden_fragments "$WORK_DIR/scum-alpha-run-generate.response.json"
require_file_contains "$WORK_DIR/scum-alpha-run-generate.response.json" '"serverInstanceId"[[:space:]]*:[[:space:]]*"scum-alpha"'
require_file_contains "$WORK_DIR/scum-alpha-run-generate.response.json" '"artifactId"[[:space:]]*:[[:space:]]*"artifact-run-dist-scum-alpha'
require_file_contains "$WORK_DIR/scum-alpha-run-generate.response.json" '"buildJobId"[[:space:]]*:[[:space:]]*"job-distribution-build'
node - "$WORK_DIR/scum-alpha-run-generate.response.json" <<'NODE'
const fs = require("fs");
const distribution = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
if (distribution.status !== "building" && distribution.status !== "available") {
@@ -426,9 +488,12 @@ if (distribution.status !== "building" && distribution.status !== "available") {
process.exit(1);
}
NODE
wait_for_distribution_build "$WORK_DIR/scum-alpha-run-generate.response.json" "$WORK_DIR/scum-alpha-run-build-job.response.json" "$WORK_DIR/scum-alpha-run-build-artifact.response.json"
reject_forbidden_fragments "$WORK_DIR/scum-alpha-run-build-job.response.json"
reject_forbidden_fragments "$WORK_DIR/scum-alpha-run-build-artifact.response.json"
wait_for_distribution_build "$WORK_DIR/scum-alpha-run-generate.response.json" "$WORK_DIR/scum-alpha-run-build-job.response.json" "$WORK_DIR/scum-alpha-run-build-artifact.response.json"
reject_forbidden_fragments "$WORK_DIR/scum-alpha-run-build-job.response.json"
reject_forbidden_fragments "$WORK_DIR/scum-alpha-run-build-artifact.response.json"
else
printf 'SCUM run package build is unavailable because Run did not advertise distribution.build; verified without fake success\n'
fi
printf 'checking jobs, logs, artifacts, and marketplace refs\n'
json_get "$API_URL/server-instances" "$WORK_DIR/server-instances.response.json" "${AUTH_HEADER[@]}"
@@ -440,12 +505,16 @@ json_get "$API_URL/artifacts" "$WORK_DIR/artifacts.response.json" "${AUTH_HEADER
json_get "$API_URL/plugin-marketplace/plugins" "$WORK_DIR/marketplace.response.json" "${AUTH_HEADER[@]}"
json_get "$API_URL/plugin-marketplace/plugins?serverType=scum&keyword=scum" "$WORK_DIR/scum-marketplace.response.json" "${AUTH_HEADER[@]}"
require_file_contains "$WORK_DIR/scum-marketplace.response.json" '"id"[[:space:]]*:[[:space:]]*"game.scum"'
require_file_contains "$WORK_DIR/artifacts.response.json" '"id"[[:space:]]*:[[:space:]]*"artifact-run-dist-scum-alpha'
if [[ "$SCUM_BUILD_AVAILABLE" == "true" ]]; then
require_file_contains "$WORK_DIR/artifacts.response.json" '"id"[[:space:]]*:[[:space:]]*"artifact-run-dist-scum-alpha'
fi
require_file_contains "$WORK_DIR/scum-alpha-jobs.response.json" '"serverInstanceId"[[:space:]]*:[[:space:]]*"scum-alpha"'
require_file_contains "$WORK_DIR/scum-beta-jobs.response.json" '"serverInstanceId"[[:space:]]*:[[:space:]]*"scum-beta"'
for file in "$WORK_DIR"/server-instances.response.json "$WORK_DIR"/jobs.response.json "$WORK_DIR"/scum-alpha-jobs.response.json "$WORK_DIR"/scum-beta-jobs.response.json "$WORK_DIR"/log-streams.response.json "$WORK_DIR"/artifacts.response.json "$WORK_DIR"/marketplace.response.json "$WORK_DIR"/scum-marketplace.response.json "$WORK_DIR"/scum-alpha-runtime-actions.response.json "$WORK_DIR"/scum-alpha-run-generate.response.json; do
reject_forbidden_fragments "$file"
if [[ -f "$file" ]]; then
reject_forbidden_fragments "$file"
fi
done
if [[ "$VITE_PLATFORM_API_BASE_URL" != "/api/v1" ]]; then