@seriousgaming/sdk-tools 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/guidance.md +350 -0
- package/dist/bundling/ui-bundler.d.ts +12 -0
- package/dist/cli-25RWY5BQ.js +41 -0
- package/dist/cli-2BH7FX27.js +52 -0
- package/dist/cli-2GZYGRVL.js +36 -0
- package/dist/cli-2NU2LPEE.js +97 -0
- package/dist/cli-3BRC32CP.js +132 -0
- package/dist/cli-3D3ZXWOV.js +111 -0
- package/dist/cli-3ZKWV3PN.js +96 -0
- package/dist/cli-45OCBG53.js +60 -0
- package/dist/cli-4LKXZQ2B.js +48 -0
- package/dist/cli-4PXNOJQX.js +81 -0
- package/dist/cli-4SIWLHQO.js +717 -0
- package/dist/cli-4UWFQNGF.js +54 -0
- package/dist/cli-4VFZHLDG.js +202 -0
- package/dist/cli-4YB3ROVR.js +78 -0
- package/dist/cli-5ACDPCXI.js +21 -0
- package/dist/cli-5IAW3LIF.js +38 -0
- package/dist/cli-5SM367K7.js +30 -0
- package/dist/cli-64AB62PM.js +25 -0
- package/dist/cli-6K3VQQUS.js +307 -0
- package/dist/cli-6QB2VFPY.js +80 -0
- package/dist/cli-6SGCYEEC.js +649 -0
- package/dist/cli-6UTPHWRQ.js +207 -0
- package/dist/cli-6VNKQ3OX.js +391 -0
- package/dist/cli-72XDEFU3.js +61 -0
- package/dist/cli-7A6MKCUJ.js +463 -0
- package/dist/cli-7XLHO2FE.js +226 -0
- package/dist/cli-AV2FYC5G.js +225 -0
- package/dist/cli-B6YHEKIJ.js +248 -0
- package/dist/cli-BJMS3VX3.js +1837 -0
- package/dist/cli-BUQI5UU4.js +43 -0
- package/dist/cli-BWX5E7TQ.js +23 -0
- package/dist/cli-BYCHKSSH.js +1331 -0
- package/dist/cli-C3CMJSNL.js +89 -0
- package/dist/cli-C47GJATR.js +42 -0
- package/dist/cli-C5QOJJWX.js +46 -0
- package/dist/cli-C6ZLPK2U.js +124 -0
- package/dist/cli-CD5CIJZI.js +72 -0
- package/dist/cli-DDJYUKQG.js +36 -0
- package/dist/cli-DFBTZEBX.js +167 -0
- package/dist/cli-DOXRQ3S5.js +60 -0
- package/dist/cli-EVI36HEM.js +79 -0
- package/dist/cli-F2D4GGUA.js +549 -0
- package/dist/cli-FQRVFGN6.js +0 -0
- package/dist/cli-FWFRKQNE.js +11 -0
- package/dist/cli-G6CANSPL.js +88 -0
- package/dist/cli-GFNDW2DL.js +124 -0
- package/dist/cli-HCRTYQQS.js +16 -0
- package/dist/cli-HFX3YPUL.js +76 -0
- package/dist/cli-HKORECAG.js +53 -0
- package/dist/cli-HOE3WLFH.js +73 -0
- package/dist/cli-HSIHDN6K.js +187 -0
- package/dist/cli-HW53ICZC.js +89 -0
- package/dist/cli-IDVUHGKG.js +218 -0
- package/dist/cli-IEMKI7J7.js +1387 -0
- package/dist/cli-ILFDANBR.js +101 -0
- package/dist/cli-ILKCQNM6.js +8 -0
- package/dist/cli-IP4RXGHM.js +2847 -0
- package/dist/cli-IUS2YCD3.js +31 -0
- package/dist/cli-J4DKUUTK.js +138 -0
- package/dist/cli-J4UBELKF.js +37 -0
- package/dist/cli-JJSWBW4H.js +89 -0
- package/dist/cli-JVI24FI6.js +68 -0
- package/dist/cli-JZCLIT3O.js +135 -0
- package/dist/cli-JZOZOEZM.js +131 -0
- package/dist/cli-KGM6RRQW.js +185 -0
- package/dist/cli-KGT5L7VZ.js +13641 -0
- package/dist/cli-KOGRWFN7.js +89 -0
- package/dist/cli-KSGB2ZLK.js +101 -0
- package/dist/cli-L7VYSXQK.js +243 -0
- package/dist/cli-LK3V4RI5.js +36 -0
- package/dist/cli-LQOHATY2.js +126 -0
- package/dist/cli-MJUYJIEP.js +13 -0
- package/dist/cli-MJV47HKI.js +143 -0
- package/dist/cli-MMN4BPO4.js +145 -0
- package/dist/cli-MOPSZ3CS.js +88 -0
- package/dist/cli-MU5LB43S.js +136 -0
- package/dist/cli-MYJGMA6U.js +40 -0
- package/dist/cli-N24OHSAN.js +36 -0
- package/dist/cli-N45DREM4.js +99 -0
- package/dist/cli-N6H6T2E2.js +616 -0
- package/dist/cli-NROTDF5Y.js +182 -0
- package/dist/cli-O5ABH2WK.js +226 -0
- package/dist/cli-OMWC75CC.js +256 -0
- package/dist/cli-OXAUOWCN.js +50 -0
- package/dist/cli-PGCIHPU7.js +143 -0
- package/dist/cli-Q6ZBZYK2.js +35 -0
- package/dist/cli-QUNIRH7A.js +57 -0
- package/dist/cli-QUSCIUOM.js +142 -0
- package/dist/cli-QVASWX2A.js +187 -0
- package/dist/cli-QWQMPCL6.js +253 -0
- package/dist/cli-QY5NZAR7.js +97 -0
- package/dist/cli-R2MUZQE2.js +62 -0
- package/dist/cli-RCIWBCXD.js +36 -0
- package/dist/cli-RLEGRWFM.js +81 -0
- package/dist/cli-RSW6EBBD.js +89 -0
- package/dist/cli-RZITKPJX.js +367 -0
- package/dist/cli-S5IVGDDD.js +32 -0
- package/dist/cli-SRHBXZCN.js +159 -0
- package/dist/cli-TDSQSCX4.js +131 -0
- package/dist/cli-TIDQ4WUE.js +257 -0
- package/dist/cli-TT36JCU5.js +370 -0
- package/dist/cli-TTKICM5P.js +100 -0
- package/dist/cli-TTMBBEJC.js +131 -0
- package/dist/cli-UMEBPAZQ.js +16 -0
- package/dist/cli-UNAJ2OTE.js +15 -0
- package/dist/cli-UZZFNXRX.js +226 -0
- package/dist/cli-VDBW23SS.js +81 -0
- package/dist/cli-VL2P354N.js +46 -0
- package/dist/cli-VPRRICZA.js +304 -0
- package/dist/cli-VQ6HVQW4.js +4010 -0
- package/dist/cli-WR3NOY74.js +36 -0
- package/dist/cli-WU43JT4T.js +52 -0
- package/dist/cli-XAT25PRU.js +117 -0
- package/dist/cli-XOTNXEJA.js +124 -0
- package/dist/cli-XSLNH5PR.js +6417 -0
- package/dist/cli-XSVGKI3R.js +39 -0
- package/dist/cli-XZCJIKIV.js +124 -0
- package/dist/cli-Y3DDNMPX.js +97 -0
- package/dist/cli-Y3O5F4JN.js +90 -0
- package/dist/cli-YOTGR3NB.js +82 -0
- package/dist/cli-Z56ZIVA6.js +97 -0
- package/dist/cli-ZBN5KAIB.js +59 -0
- package/dist/cli-ZDOTXEKL.js +31 -0
- package/dist/cli-ZDUADFBY.js +88 -0
- package/dist/cli-ZJFQ7EEA.js +131 -0
- package/dist/cli-ZTWOE3ZT.js +65 -0
- package/dist/cli.js +148 -43093
- package/dist/client/build-surfaces.d.ts +33 -0
- package/dist/client/dev-server.d.ts +6 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/playwright.d.ts +62 -0
- package/dist/client.js +228 -48
- package/dist/core/session.d.ts +15 -1
- package/dist/dev/console/assets/{index-BVF8exas.js → index-CuMOOH9m.js} +1 -1
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/shell.d.ts +19 -0
- package/dist/dev/surfaces.d.ts +7 -0
- package/dist/docs/ai-agents.md +1 -1
- package/dist/docs/api/index.md +14 -12
- package/dist/docs/api/sdk-tools-client.md +29 -0
- package/dist/docs/api/sdk-tools-playwright.md +104 -0
- package/dist/docs/changelog.md +34 -0
- package/dist/docs/cli-and-dev-server.md +21 -0
- package/dist/docs/cli-reference.md +45 -31
- package/dist/docs/environment-variables.md +6 -0
- package/dist/docs/getting-started.md +1 -1
- package/dist/docs/guides/designing-a-game.md +29 -4
- package/dist/docs/guides/starter-game.md +3 -3
- package/dist/docs/guides/testing.md +33 -18
- package/dist/docs/guides/upgrading.md +19 -2
- package/dist/docs/page-index.md +10 -9
- package/dist/docs/recipes/e2e-testing.md +19 -20
- package/dist/playwright.js +32232 -0
- package/dist/templates/package/CLAUDE.md.template +7 -346
- package/dist/templates/package/claude/rules/workflow-create-engine.md +2 -2
- package/dist/templates/package/claude/rules/workflow-create-guide.md +2 -2
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
- package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +3 -3
- package/dist/templates/package/global-setup.ts.template +7 -18
- package/dist/templates/package/playwright.config.ts.liquid +8 -11
- package/dist/templates/starter-game/playwright.config.ts +8 -11
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
- package/dist/utils/prompt.d.ts +5 -5
- package/dist/utils/resource-scan.d.ts +39 -0
- package/package.json +7 -3
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
guessMimeType
|
|
4
|
+
} from "./cli-2BH7FX27.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveSession
|
|
7
|
+
} from "./cli-6K3VQQUS.js";
|
|
8
|
+
import "./cli-WU43JT4T.js";
|
|
9
|
+
import {
|
|
10
|
+
blobLinks
|
|
11
|
+
} from "./cli-BWX5E7TQ.js";
|
|
12
|
+
import {
|
|
13
|
+
OUTCOME_CODES,
|
|
14
|
+
emit,
|
|
15
|
+
environmentHint,
|
|
16
|
+
logicDiagnostic,
|
|
17
|
+
staleError,
|
|
18
|
+
staleOf,
|
|
19
|
+
teamIndexFromArgument
|
|
20
|
+
} from "./cli-L7VYSXQK.js";
|
|
21
|
+
import "./cli-FQRVFGN6.js";
|
|
22
|
+
import "./cli-XSLNH5PR.js";
|
|
23
|
+
import "./cli-TDSQSCX4.js";
|
|
24
|
+
import "./cli-SRHBXZCN.js";
|
|
25
|
+
import "./cli-KGT5L7VZ.js";
|
|
26
|
+
import "./cli-4LKXZQ2B.js";
|
|
27
|
+
import "./cli-MMN4BPO4.js";
|
|
28
|
+
import {
|
|
29
|
+
resolveInputSource
|
|
30
|
+
} from "./cli-4UWFQNGF.js";
|
|
31
|
+
import "./cli-QUNIRH7A.js";
|
|
32
|
+
import {
|
|
33
|
+
logicErrorOf
|
|
34
|
+
} from "./cli-BYCHKSSH.js";
|
|
35
|
+
import "./cli-25RWY5BQ.js";
|
|
36
|
+
import {
|
|
37
|
+
readBlob
|
|
38
|
+
} from "./cli-QWQMPCL6.js";
|
|
39
|
+
import "./cli-VQ6HVQW4.js";
|
|
40
|
+
import "./cli-F2D4GGUA.js";
|
|
41
|
+
import "./cli-4YB3ROVR.js";
|
|
42
|
+
import {
|
|
43
|
+
CliError
|
|
44
|
+
} from "./cli-N6H6T2E2.js";
|
|
45
|
+
|
|
46
|
+
// cli/commands/endpoint-call.ts
|
|
47
|
+
import { existsSync } from "fs";
|
|
48
|
+
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
49
|
+
import { basename, join, resolve } from "path";
|
|
50
|
+
function describeStep(step) {
|
|
51
|
+
switch (step.kind) {
|
|
52
|
+
case "capabilities":
|
|
53
|
+
return "its write";
|
|
54
|
+
case "teams":
|
|
55
|
+
return `its write to team "${step.teamId}"`;
|
|
56
|
+
case "action":
|
|
57
|
+
return `action ${step.index} ("${step.type}")`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function describeEndpointFailure(identifier, failure) {
|
|
61
|
+
const { outcome, applied, failedStep } = failure;
|
|
62
|
+
const message = "message" in outcome && outcome.message ? `: ${outcome.message}` : "";
|
|
63
|
+
const lines = [`Endpoint "${identifier}" failed (${outcome.kind})${message}`];
|
|
64
|
+
lines.push(
|
|
65
|
+
applied.length === 0 ? "Nothing was applied." : `Applied before the failure: ${applied.map(describeStep).join(", ")}`
|
|
66
|
+
);
|
|
67
|
+
if (failedStep) lines.push(`Failed at: ${describeStep(failedStep)}`);
|
|
68
|
+
return lines.join("\n");
|
|
69
|
+
}
|
|
70
|
+
var ENDPOINT_CODES = {
|
|
71
|
+
"invalid-request": "INVALID_REQUEST",
|
|
72
|
+
"handler-error": "HANDLER_ERROR",
|
|
73
|
+
"invalid-response": "INVALID_RESPONSE"
|
|
74
|
+
};
|
|
75
|
+
function endpointFailureCode(failure) {
|
|
76
|
+
const kind = failure.outcome.kind;
|
|
77
|
+
return kind in ENDPOINT_CODES ? ENDPOINT_CODES[kind] : OUTCOME_CODES[kind];
|
|
78
|
+
}
|
|
79
|
+
function parsePrincipal(value) {
|
|
80
|
+
const [kind, id, ...rest] = value.split(":");
|
|
81
|
+
if (!kind || !id) {
|
|
82
|
+
throw new CliError(
|
|
83
|
+
"USAGE_BAD_FLAG",
|
|
84
|
+
`--principal takes kind:id or kind:id:name, e.g. agent:claude-7:Claude (got "${value}")`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return { kind, id, ...rest.length > 0 ? { name: rest.join(":") } : {} };
|
|
88
|
+
}
|
|
89
|
+
async function attachFiles(request, attachments, workingDir) {
|
|
90
|
+
if (attachments.length === 0) return request;
|
|
91
|
+
if (typeof request !== "object" || request === null || Array.isArray(request)) {
|
|
92
|
+
throw new CliError("INPUT_INVALID", "--attach needs the request to be a JSON object");
|
|
93
|
+
}
|
|
94
|
+
const result = structuredClone(request);
|
|
95
|
+
for (const attachment of attachments) {
|
|
96
|
+
const split = attachment.indexOf("=");
|
|
97
|
+
if (split <= 0) {
|
|
98
|
+
throw new CliError("USAGE_BAD_FLAG", `--attach takes field=path (got "${attachment}")`);
|
|
99
|
+
}
|
|
100
|
+
const field = attachment.slice(0, split);
|
|
101
|
+
const path = resolve(workingDir, attachment.slice(split + 1));
|
|
102
|
+
if (!existsSync(path))
|
|
103
|
+
throw new CliError("FILE_NOT_FOUND", `--attach: file not found: ${path}`);
|
|
104
|
+
const name = basename(path);
|
|
105
|
+
const uri = `data:${guessMimeType(name)};name=${encodeURIComponent(name)};base64,` + (await readFile(path)).toString("base64");
|
|
106
|
+
const keys = field.split(".");
|
|
107
|
+
let target = result;
|
|
108
|
+
for (const key of keys.slice(0, -1)) {
|
|
109
|
+
const next = target[key];
|
|
110
|
+
target[key] = typeof next === "object" && next !== null ? next : {};
|
|
111
|
+
target = target[key];
|
|
112
|
+
}
|
|
113
|
+
target[keys[keys.length - 1]] = uri;
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
async function saveBlobs(response, dir, workingDir) {
|
|
118
|
+
const references = Object.keys(blobLinks(response, (id) => id));
|
|
119
|
+
if (references.length === 0) {
|
|
120
|
+
console.error("The response names no blobs to save.");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const target = resolve(workingDir, dir);
|
|
124
|
+
await mkdir(target, { recursive: true });
|
|
125
|
+
const taken = /* @__PURE__ */ new Set();
|
|
126
|
+
for (const reference of references) {
|
|
127
|
+
const blob = await readBlob(workingDir, reference.slice("blob:".length));
|
|
128
|
+
let name = basename(blob.name) || "blob";
|
|
129
|
+
for (let n = 2; taken.has(name); n += 1) name = `${n}-${basename(blob.name)}`;
|
|
130
|
+
taken.add(name);
|
|
131
|
+
await writeFile(join(target, name), blob.data);
|
|
132
|
+
console.error(`Saved ${reference} to ${join(target, name)}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function endpointCallCommand(identifier, options) {
|
|
136
|
+
const source = await resolveInputSource(options.request, options.file);
|
|
137
|
+
let request = {};
|
|
138
|
+
if (source.kind === "json") {
|
|
139
|
+
try {
|
|
140
|
+
request = JSON.parse(source.json);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
throw new CliError(
|
|
143
|
+
"INPUT_INVALID",
|
|
144
|
+
`The request is not valid JSON
|
|
145
|
+
` + (error instanceof Error ? error.message : "Unknown error")
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (options.principal !== void 0 && !options.external) {
|
|
150
|
+
throw new CliError(
|
|
151
|
+
"USAGE_BAD_FLAG",
|
|
152
|
+
"--principal stands in for the identity a platform vouches for on a call from outside the game, so it needs --external"
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
const principal = options.principal === void 0 ? void 0 : parsePrincipal(options.principal);
|
|
156
|
+
if (options.draft !== void 0 && options.team !== void 0) {
|
|
157
|
+
throw new CliError(
|
|
158
|
+
"USAGE_BAD_FLAG",
|
|
159
|
+
"--team names a team in the session, and a scenario draft has none, so it cannot go with --draft"
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
const scenarioId = options.draft === void 0 || options.draft === false ? void 0 : options.draft === true ? null : options.draft;
|
|
163
|
+
request = await attachFiles(request, options.attach ?? [], options.workingDir);
|
|
164
|
+
const session = await resolveSession({
|
|
165
|
+
packagePath: options.workingDir,
|
|
166
|
+
...options.walkthrough ? { runKind: "walkthrough" } : {},
|
|
167
|
+
...options.server === false ? { noServer: true } : {}
|
|
168
|
+
});
|
|
169
|
+
try {
|
|
170
|
+
const state = await session.state();
|
|
171
|
+
const teamIndex = teamIndexFromArgument(state, options.team);
|
|
172
|
+
const result = await session.send({
|
|
173
|
+
type: "callEndpoint",
|
|
174
|
+
endpointIdentifier: identifier,
|
|
175
|
+
request,
|
|
176
|
+
// Unless it stands in for an outside caller, the caller is the
|
|
177
|
+
// terminal, not a surface, so it names none (§6.12).
|
|
178
|
+
...options.external ? { external: true } : {},
|
|
179
|
+
...principal ? { principal } : {},
|
|
180
|
+
...teamIndex === void 0 ? {} : { teamIndex },
|
|
181
|
+
...scenarioId === void 0 ? {} : { scenarioId }
|
|
182
|
+
});
|
|
183
|
+
if ("type" in result && result.type === "endpointFailure") {
|
|
184
|
+
const stale = staleOf(result);
|
|
185
|
+
if (stale) throw staleError(stale);
|
|
186
|
+
const logicError = logicErrorOf(result);
|
|
187
|
+
throw new CliError(
|
|
188
|
+
logicError?.errorCode ?? endpointFailureCode(result.failure),
|
|
189
|
+
describeEndpointFailure(identifier, result.failure),
|
|
190
|
+
{
|
|
191
|
+
...environmentHint(logicError),
|
|
192
|
+
details: { ...result.failure },
|
|
193
|
+
diagnostics: logicError ? [logicDiagnostic(logicError)] : []
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
if (!("type" in result) || result.type !== "endpoint") {
|
|
198
|
+
throw new CliError(
|
|
199
|
+
"DEV_SERVER_OUTDATED",
|
|
200
|
+
`Endpoint "${identifier}" returned no response`
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
emit(result.response);
|
|
204
|
+
for (const [reference, url] of Object.entries(result.blobs ?? {})) {
|
|
205
|
+
console.error(`${reference} ${url}`);
|
|
206
|
+
}
|
|
207
|
+
if (options.saveBlobs !== void 0) {
|
|
208
|
+
await saveBlobs(result.response, options.saveBlobs, options.workingDir);
|
|
209
|
+
}
|
|
210
|
+
} finally {
|
|
211
|
+
await session.close();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
export {
|
|
215
|
+
describeEndpointFailure,
|
|
216
|
+
endpointCallCommand,
|
|
217
|
+
endpointFailureCode
|
|
218
|
+
};
|