功能修改
This commit is contained in:
@@ -24,8 +24,9 @@ export PLATFORM_ARTIFACT_DIR="${PLATFORM_ARTIFACT_DIR:-$PLATFORM_DATA_DIR/artifa
|
||||
export PLATFORM_BOOTSTRAP_ADMIN_EMAIL="${PLATFORM_BOOTSTRAP_ADMIN_EMAIL:-operator.local@example.test}"
|
||||
export PLATFORM_BOOTSTRAP_ADMIN_PASSWORD="${PLATFORM_BOOTSTRAP_ADMIN_PASSWORD:-operator-local}"
|
||||
export PLATFORM_SECRET_ENVELOPE_KEY="${PLATFORM_SECRET_ENVELOPE_KEY:-local-debug-secret-envelope-key-change-me}"
|
||||
export PLATFORM_AI_PROVIDER_MODE="${PLATFORM_AI_PROVIDER_MODE:-mock}"
|
||||
|
||||
export RUN_REPO_DIR="${RUN_REPO_DIR:-$LOCAL_DEBUG_ROOT_DIR/run}"
|
||||
export RUN_REPO_DIR="${RUN_REPO_DIR:-$(cd "$LOCAL_DEBUG_ROOT_DIR/.." && pwd)/run}"
|
||||
export RUN_MODE="${RUN_MODE:-worker}"
|
||||
export RUN_PLATFORM_URL="${RUN_PLATFORM_URL:-http://127.0.0.1:$LOCAL_DEBUG_PLATFORM_PORT}"
|
||||
export RUN_ENDPOINT_ID="${RUN_ENDPOINT_ID:-run-local-debug}"
|
||||
@@ -54,7 +55,7 @@ local_debug_web_url() {
|
||||
ensure_local_run_repo() {
|
||||
if [[ ! -f "$RUN_REPO_DIR/go.mod" ]]; then
|
||||
printf 'run repo not found at %s\n' "$RUN_REPO_DIR" >&2
|
||||
printf 'clone git@git.npc0.com:admin343/run.git into this repo as ./run or set RUN_REPO_DIR to the run checkout\n' >&2
|
||||
printf 'clone git@git.npc0.com:admin343/run.git beside this repo or set RUN_REPO_DIR to the independent run checkout\n' >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -111,6 +111,25 @@ wait_for_url() {
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_for_run_registration() {
|
||||
local attempts="${1:-45}"
|
||||
local run_pid_file="$LOCAL_DEBUG_PID_DIR/run.pid"
|
||||
printf 'waiting for run endpoint %s registration\n' "$RUN_ENDPOINT_ID"
|
||||
for _ in $(seq 1 "$attempts"); do
|
||||
if [[ -f "$PLATFORM_METADATA_PATH" ]] && grep -Fq "\"ID\": \"$RUN_ENDPOINT_ID\"" "$PLATFORM_METADATA_PATH"; then
|
||||
printf 'run endpoint %s is registered\n' "$RUN_ENDPOINT_ID"
|
||||
return 0
|
||||
fi
|
||||
if ! managed_pid_running "$run_pid_file"; then
|
||||
printf 'run exited before endpoint registration; see %s\n' "$LOCAL_DEBUG_LOG_DIR/run.log" >&2
|
||||
return 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
printf 'run endpoint %s did not register before timeout\n' "$RUN_ENDPOINT_ID" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
printf 'local debug root: %s\n' "$LOCAL_DEBUG_ROOT"
|
||||
printf 'platform: %s\n' "$(local_debug_platform_url)"
|
||||
printf 'platform_web: %s\n' "$(local_debug_web_url)"
|
||||
@@ -154,6 +173,8 @@ start_service run "$RUN_REPO_DIR" env \
|
||||
RUN_RETRY_BACKOFF_MS="$RUN_RETRY_BACKOFF_MS" \
|
||||
go run ./cmd/run
|
||||
|
||||
wait_for_run_registration
|
||||
|
||||
start_service platform_web "$ROOT_DIR" env \
|
||||
PLATFORM_API_PROXY="$PLATFORM_API_PROXY" \
|
||||
VITE_PLATFORM_API_BASE_URL="$VITE_PLATFORM_API_BASE_URL" \
|
||||
|
||||
Reference in New Issue
Block a user