@seriousgaming/sdk-tools 1.11.0 → 1.12.0

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.
Files changed (192) hide show
  1. package/dist/agent/guidance.md +4 -0
  2. package/dist/{cli-F2D4GGUA.js → cli-2BKEIIA3.js} +66 -0
  3. package/dist/{cli-ZGCG6C22.js → cli-2QGTDHRX.js} +21 -21
  4. package/dist/{cli-SRXDLMXY.js → cli-2SDG3SZ7.js} +21 -21
  5. package/dist/{cli-DH35TZ2Q.js → cli-2VXP34R5.js} +2 -2
  6. package/dist/{cli-P3NUTOPK.js → cli-2W4B6PD5.js} +1 -1
  7. package/dist/{cli-WJVPSVF2.js → cli-2X7DKSXN.js} +24 -24
  8. package/dist/{cli-ATAJSIXH.js → cli-2ZP4N7HK.js} +19 -19
  9. package/dist/{cli-5O7XENQY.js → cli-3GJYZH4C.js} +5 -5
  10. package/dist/{cli-H6PP2MZT.js → cli-3GO3M2MX.js} +17 -13
  11. package/dist/{cli-HMDYG6PS.js → cli-3LDLUNME.js} +17 -17
  12. package/dist/{cli-BZOKZ7LP.js → cli-3WY6L2WP.js} +27 -27
  13. package/dist/{cli-REAM7LSC.js → cli-44MBABRD.js} +25 -25
  14. package/dist/{cli-5TTJWM2R.js → cli-4IO7MKLR.js} +20 -20
  15. package/dist/{cli-HNDFANQG.js → cli-4U2PY7W3.js} +1 -1
  16. package/dist/{cli-WQ7JBZNW.js → cli-4WI4LTBI.js} +2 -2
  17. package/dist/{cli-OTBCA54D.js → cli-55EIGGZK.js} +1 -1
  18. package/dist/{cli-FYPW25VD.js → cli-5AQV6FTL.js} +18 -18
  19. package/dist/{cli-RKPQLB7J.js → cli-5CW7BEU7.js} +3 -3
  20. package/dist/{cli-27TQVLVF.js → cli-5JUVHNZF.js} +12 -12
  21. package/dist/{cli-F3YJKP6D.js → cli-5KERL6HV.js} +9 -4
  22. package/dist/{cli-MSNSXVGF.js → cli-5KSA24NQ.js} +24 -24
  23. package/dist/{cli-5VZBFMCK.js → cli-5PIFO3EN.js} +8 -0
  24. package/dist/{cli-FT3X3D4P.js → cli-5QN2Z43X.js} +20 -20
  25. package/dist/cli-5XSPAA5X.js +69 -0
  26. package/dist/{cli-B2QAJ5RQ.js → cli-62KAYGXO.js} +20 -20
  27. package/dist/{cli-QPV3TYOM.js → cli-6IMV5ZZU.js} +26 -26
  28. package/dist/{cli-UULZSQBV.js → cli-6KWCIAN2.js} +764 -66
  29. package/dist/{cli-DQE7ITIR.js → cli-6NWETIX5.js} +20 -20
  30. package/dist/{cli-L7F4XKCB.js → cli-774W3MN5.js} +26 -26
  31. package/dist/cli-7BUD3VAD.js +16 -0
  32. package/dist/{cli-XNOAO6DY.js → cli-7KEP57S7.js} +12 -12
  33. package/dist/{cli-5UKWX3IU.js → cli-7OYFJMA6.js} +18 -18
  34. package/dist/{cli-WNHMJM3Z.js → cli-7ZNEDQ3G.js} +20 -20
  35. package/dist/{cli-5RRPUL6V.js → cli-AFK6OUID.js} +12 -12
  36. package/dist/{cli-6P6V2EHY.js → cli-AIYQFWXN.js} +25 -25
  37. package/dist/{cli-ERJNDBDH.js → cli-ARAAEWIQ.js} +2 -2
  38. package/dist/cli-AVQYV3N4.js +36 -0
  39. package/dist/{cli-TI2FOFPA.js → cli-B54Z6CXH.js} +16 -16
  40. package/dist/{cli-EEO5ZPAZ.js → cli-B5TC4MEL.js} +5 -5
  41. package/dist/{cli-5Z4D3F6Y.js → cli-BCXGOLU3.js} +3 -3
  42. package/dist/{cli-G2GLW5Z4.js → cli-BHAODVTZ.js} +1 -1
  43. package/dist/{cli-4F24FUW6.js → cli-BPS2JG74.js} +20 -20
  44. package/dist/{cli-W3RG2MRI.js → cli-BVO55SR2.js} +2 -2
  45. package/dist/{cli-R5SNTPND.js → cli-CFH3JZP5.js} +21 -21
  46. package/dist/{cli-Q7QSWNY2.js → cli-CTK2OIK6.js} +20 -20
  47. package/dist/{cli-ATWJCB2G.js → cli-CW5MV4VX.js} +4 -4
  48. package/dist/{cli-TCQJL2GY.js → cli-D5VOSJZ7.js} +1 -1
  49. package/dist/{cli-KIZTASLL.js → cli-DAEPMK7A.js} +5 -5
  50. package/dist/{cli-44CM2AH2.js → cli-DAHR7PKB.js} +1 -1
  51. package/dist/{cli-XW3JLRSA.js → cli-DWDSBTYL.js} +1 -1
  52. package/dist/cli-DYSDPGXW.js +95 -0
  53. package/dist/{cli-QEFYDXMH.js → cli-DZCLRZXJ.js} +1 -1
  54. package/dist/{cli-77T4LJQF.js → cli-EJ47IE45.js} +24 -24
  55. package/dist/{cli-QDBYFITU.js → cli-EK4OSJHA.js} +2 -2
  56. package/dist/{cli-GO64NABP.js → cli-FCJHNXDA.js} +1 -1
  57. package/dist/{cli-ZNQBF4Z3.js → cli-FNESSE3L.js} +1 -1
  58. package/dist/{cli-D3S7NJZ3.js → cli-FTLH4WCE.js} +17 -17
  59. package/dist/{cli-JHLWBRXB.js → cli-FYV77YS2.js} +18 -18
  60. package/dist/cli-GMJX6Q4Q.js +36 -0
  61. package/dist/{cli-7JUNA74L.js → cli-GRBVNGDW.js} +1 -1
  62. package/dist/{cli-XKAIDYIE.js → cli-HAFCFY77.js} +33 -19
  63. package/dist/{cli-OXLOGXT3.js → cli-HCJLYI24.js} +3 -3
  64. package/dist/{cli-XOYUTNER.js → cli-HCXS5EXU.js} +25 -25
  65. package/dist/cli-HEUNNHDH.js +36 -0
  66. package/dist/{cli-G3TU6CP6.js → cli-HNUTIWDZ.js} +19 -19
  67. package/dist/{cli-JXQLHJO2.js → cli-HXT25ETJ.js} +244 -243
  68. package/dist/{cli-5EH4WTH4.js → cli-IGEL7UJQ.js} +5 -5
  69. package/dist/{cli-TLSTSZAC.js → cli-IO32YA5N.js} +26 -26
  70. package/dist/cli-IPTGZDBB.js +36 -0
  71. package/dist/{cli-OBLEROSC.js → cli-J25TYFKB.js} +19 -19
  72. package/dist/{cli-5ATO27Z4.js → cli-J7XYMEMX.js} +20 -20
  73. package/dist/{cli-X3TSTTYI.js → cli-JC5OJRID.js} +2 -2
  74. package/dist/{cli-25SJZI7N.js → cli-JD563OF4.js} +126 -27
  75. package/dist/{cli-VXLHOZSO.js → cli-JRJF2WHU.js} +20 -20
  76. package/dist/{cli-UQC46YSV.js → cli-JTFLIMIG.js} +3 -3
  77. package/dist/{cli-K4HSQWXC.js → cli-K2BSJ2PK.js} +2 -2
  78. package/dist/{cli-OM32UURE.js → cli-K4QTYMN2.js} +25 -25
  79. package/dist/{cli-BJFYGVJV.js → cli-KFJDD4C4.js} +20 -20
  80. package/dist/{cli-WW54THXN.js → cli-KVQ2JPVD.js} +1 -1
  81. package/dist/{cli-LHMRUJVN.js → cli-L6AHMW2Z.js} +1 -1
  82. package/dist/{cli-IKSLPAZN.js → cli-LCYUBCVY.js} +4 -4
  83. package/dist/{cli-HGCOEL5T.js → cli-LEWSCDH5.js} +4 -4
  84. package/dist/{cli-XJ7JESC2.js → cli-LI6G7GND.js} +27 -27
  85. package/dist/{cli-OMTHTWYJ.js → cli-LU2GCWIU.js} +21 -21
  86. package/dist/{cli-UEQMK4WX.js → cli-M3Z2KOEB.js} +1 -1
  87. package/dist/{cli-226ZJ72R.js → cli-M6E3E3I2.js} +170 -3
  88. package/dist/{cli-NKKCDO6K.js → cli-MCRPA4Z6.js} +20 -20
  89. package/dist/{cli-BQ36DV5C.js → cli-MI2DEDMA.js} +3 -3
  90. package/dist/{cli-6O7YCK2M.js → cli-MITZ6SE7.js} +3 -3
  91. package/dist/{cli-LPFSJ625.js → cli-MTIYD3BX.js} +26 -26
  92. package/dist/{cli-5M6KDNVX.js → cli-MTZUJGBK.js} +2 -2
  93. package/dist/{cli-GSOV26O5.js → cli-NCLMUXLC.js} +14 -14
  94. package/dist/{cli-X52TXCNF.js → cli-NLS3DKWH.js} +26 -26
  95. package/dist/{cli-AH6AMAIB.js → cli-NMDGS7IE.js} +1 -1
  96. package/dist/cli-O3DJO2CS.js +30 -0
  97. package/dist/{cli-BC67QHD5.js → cli-O47D5BFN.js} +2 -2
  98. package/dist/{cli-MDVC5ZNM.js → cli-OBRZ36VP.js} +14 -14
  99. package/dist/{cli-UVIURDZC.js → cli-OMG4E53H.js} +20 -20
  100. package/dist/{cli-C32Q5E5I.js → cli-P6V3NSU4.js} +1 -1
  101. package/dist/{cli-RMD5WSUQ.js → cli-PAMQMTHK.js} +21 -21
  102. package/dist/{cli-WNBP3LOD.js → cli-PKTHOCT3.js} +26 -26
  103. package/dist/{cli-S3NHXAJM.js → cli-QK7QAP5H.js} +18 -18
  104. package/dist/cli-QQ432JEN.js +36 -0
  105. package/dist/{cli-YYXAGJQR.js → cli-QVNDPTBU.js} +20 -20
  106. package/dist/{cli-KJA6GLZI.js → cli-R2DFD6ZZ.js} +15 -15
  107. package/dist/{cli-6BLVI2JM.js → cli-RMVJMOWU.js} +111 -7
  108. package/dist/{cli-TEBV2OIW.js → cli-RQISHMJF.js} +83 -21
  109. package/dist/{cli-X64BNBQH.js → cli-RVZH462G.js} +585 -8
  110. package/dist/{cli-6AMK3DYS.js → cli-SEEOQVUL.js} +12 -12
  111. package/dist/{cli-QTCTWYCM.js → cli-SO354HPI.js} +3 -3
  112. package/dist/{cli-RHL4B4H7.js → cli-T76HDH7F.js} +88 -4
  113. package/dist/{cli-ZJW6HQ6N.js → cli-TIS7DWRR.js} +7 -7
  114. package/dist/{cli-6JWDFCUV.js → cli-TY3B6XS7.js} +21 -21
  115. package/dist/{cli-4FJL3KQZ.js → cli-UKEZJFIT.js} +2 -2
  116. package/dist/cli-VQAMW4RF.js +95 -0
  117. package/dist/{cli-ATHATKI5.js → cli-W4LMRVZT.js} +78 -47
  118. package/dist/cli-W7I5KGIB.js +84 -0
  119. package/dist/{cli-B3EFE7ZF.js → cli-WXGJFA4F.js} +1 -1
  120. package/dist/{cli-PNS4KWWC.js → cli-XCG33I77.js} +24 -24
  121. package/dist/{cli-DBMEH4Y5.js → cli-YHLSG5HB.js} +26 -26
  122. package/dist/cli-YNH5DTHY.js +36 -0
  123. package/dist/cli-YPMJWPDA.js +69 -0
  124. package/dist/{cli-PXQYY6KM.js → cli-YSXIR7EM.js} +0 -0
  125. package/dist/cli-ZPFWO4VW.js +85 -0
  126. package/dist/cli.js +53 -53
  127. package/dist/client.js +1918 -283
  128. package/dist/core/assessment-moves.d.ts +32 -0
  129. package/dist/core/assessment-reports.d.ts +38 -0
  130. package/dist/core/assessment-settings.d.ts +15 -0
  131. package/dist/core/benchmark-samples.d.ts +28 -0
  132. package/dist/core/session-host.d.ts +4 -0
  133. package/dist/core/session-roster.d.ts +6 -0
  134. package/dist/core/session-timers.d.ts +40 -0
  135. package/dist/core/session.d.ts +14 -1
  136. package/dist/core/tick-timer.d.ts +18 -0
  137. package/dist/dev/console/assets/{index-Ch6HHb2T.js → index-zd--5H1f.js} +26 -26
  138. package/dist/dev/console/index.html +1 -1
  139. package/dist/dev/shell.d.ts +8 -0
  140. package/dist/dev/view/commands.d.ts +3 -1
  141. package/dist/docs/api/index.md +1 -1
  142. package/dist/docs/api/sdk-commands.md +29 -0
  143. package/dist/docs/api/sdk-e2e.md +30 -0
  144. package/dist/docs/api/sdk-projection.md +5 -0
  145. package/dist/docs/api/sdk-tools-client.md +30 -0
  146. package/dist/docs/api/sdk-ui.md +7 -0
  147. package/dist/docs/api/sdk.md +834 -19
  148. package/dist/docs/changelog.md +28 -0
  149. package/dist/docs/cli-error-codes.md +5 -1
  150. package/dist/docs/cli-reference.md +76 -2
  151. package/dist/docs/concepts/index.md +2 -0
  152. package/dist/docs/concepts/terminology.md +12 -0
  153. package/dist/docs/guides/assessments.md +248 -0
  154. package/dist/docs/guides/benchmarks.md +241 -0
  155. package/dist/docs/guides/engine.md +8 -0
  156. package/dist/docs/guides/index.md +2 -0
  157. package/dist/docs/guides/presentation.md +11 -9
  158. package/dist/docs/guides/session-hooks.md +24 -22
  159. package/dist/docs/guides/tick-controller.md +22 -1
  160. package/dist/docs/guides/ui.md +24 -0
  161. package/dist/docs/guides/upgrading.md +21 -0
  162. package/dist/docs/page-index.md +16 -12
  163. package/dist/docs/recipes/create-assessment.md +124 -0
  164. package/dist/docs/recipes/create-benchmark.md +115 -0
  165. package/dist/docs/recipes/index.md +2 -0
  166. package/dist/execution/context-composition.d.ts +39 -4
  167. package/dist/execution/engine-state.d.ts +13 -0
  168. package/dist/execution/executor.d.ts +16 -0
  169. package/dist/execution/logic-result.d.ts +13 -2
  170. package/dist/help-examples.d.ts +12 -0
  171. package/dist/host/adapter.d.ts +24 -1
  172. package/dist/host/protocol.d.ts +115 -1
  173. package/dist/host.js +29 -1
  174. package/dist/playwright.js +1912 -277
  175. package/dist/runtime/index.d.ts +3 -1
  176. package/dist/runtime/manifest-version.d.ts +1 -1
  177. package/dist/runtime.js +298 -16
  178. package/dist/schema.json +189 -0
  179. package/dist/templating/resource-metadata.d.ts +1 -1
  180. package/dist/utils/error-codes.d.ts +9 -1
  181. package/dist/validation/assessment-validation.d.ts +34 -0
  182. package/dist/validation/benchmark-validation.d.ts +20 -0
  183. package/dist/validation/schema-validation.d.ts +4 -0
  184. package/package.json +3 -3
  185. package/dist/cli-27Z5T52R.js +0 -30
  186. package/dist/cli-3VLBFWHN.js +0 -36
  187. package/dist/cli-BINVO5R7.js +0 -36
  188. package/dist/cli-HLI5UEKX.js +0 -36
  189. package/dist/cli-OF36EA62.js +0 -36
  190. package/dist/cli-OVIJRBFI.js +0 -36
  191. package/dist/cli-UIYKPSIY.js +0 -36
  192. package/dist/cli-WZNIW6ZO.js +0 -16
@@ -4,12 +4,6 @@ import {
4
4
  formatPlatformErrors,
5
5
  normalisePlatformHost
6
6
  } from "./cli-25RWY5BQ.js";
7
- import {
8
- describeAssetByReference,
9
- describeBlob,
10
- readAssetByReference,
11
- storeBlob
12
- } from "./cli-QWQMPCL6.js";
13
7
  import {
14
8
  DeniedError,
15
9
  SCENARIO_GATE_READ_LIMIT_BYTES,
@@ -21,243 +15,13 @@ import {
21
15
  settingsSchemas,
22
16
  validateSessionOverrides,
23
17
  validateSettingsOverrides
24
- } from "./cli-X64BNBQH.js";
25
-
26
- // cli/execution/logic-failure.ts
27
- import { SourceMap } from "node:module";
28
- import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
29
-
30
- // cli/utils/llm-client.ts
31
- var TOOL_NAME_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/;
32
- var STOP_REASONS = ["endTurn", "toolUse", "maxTokens", "refusal"];
33
- var CONTENT_BLOCK_TYPES = ["text", "toolUse", "toolResult"];
34
- var LLM_NOT_CONFIGURED = "LLM_NOT_CONFIGURED";
35
- var LLM_NOT_CONFIGURED_HINT = "Set SERIOUSGAMING_API_KEY in the environment or in .env, or run `seriousgaming-sdk config set platform.apiKey <key>`, or pass `sdk dev --api-key <key>`, then restart the dev server. Issue a key from your organisation settings on the platform.";
36
- var LLMClientError = class extends Error {
37
- constructor(message, code) {
38
- super(message);
39
- this.code = code;
40
- this.name = "LLMClientError";
41
- }
42
- code;
43
- };
44
- var LLMClient = class {
45
- apiKey;
46
- apiHost;
47
- constructor(config) {
48
- this.apiKey = config.apiKey;
49
- this.apiHost = normalisePlatformHost(config.apiHost ?? DEFAULT_PLATFORM_HOST);
50
- }
51
- /**
52
- * Generate text through the platform LLM API.
53
- * Supports both simple string prompts and complex options.
54
- */
55
- async generateText(optionsOrPrompt) {
56
- if (!this.apiKey) {
57
- throw new LLMClientError(
58
- "generateText needs a Serious Gaming platform API key, and none is configured.",
59
- LLM_NOT_CONFIGURED
60
- );
61
- }
62
- const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
63
- if (options.tools) {
64
- for (const tool of options.tools) {
65
- if (!TOOL_NAME_PATTERN.test(tool.name)) {
66
- throw new LLMClientError(
67
- `Invalid tool name "${tool.name}": must match ^[a-zA-Z0-9_-]{1,64}$`
68
- );
69
- }
70
- }
71
- }
72
- if (!options.prompt && (!options.messages || options.messages.length === 0)) {
73
- throw new LLMClientError("No prompt or messages provided to generateText");
74
- }
75
- const endpoint = `${this.apiHost}/api/v0/llm/generate`;
76
- const body = {};
77
- if (options.prompt !== void 0) body.prompt = options.prompt;
78
- if (options.messages !== void 0) body.messages = options.messages;
79
- if (options.systemPrompt !== void 0) body.systemPrompt = options.systemPrompt;
80
- if (options.jsonSchema !== void 0) body.jsonSchema = options.jsonSchema;
81
- if (options.tier !== void 0) body.tier = options.tier;
82
- if (options.tools !== void 0) body.tools = options.tools;
83
- let response;
84
- try {
85
- response = await fetch(endpoint, {
86
- method: "POST",
87
- headers: {
88
- Authorization: `Bearer ${this.apiKey}`,
89
- "Content-Type": "application/json"
90
- },
91
- body: JSON.stringify(body)
92
- });
93
- } catch (error) {
94
- const message = error instanceof Error ? error.message : "Unknown error";
95
- throw new LLMClientError(`Network error contacting ${endpoint}: ${message}`);
96
- }
97
- const rawBody = await response.text();
98
- let parsedBody = null;
99
- if (rawBody) {
100
- try {
101
- parsedBody = JSON.parse(rawBody);
102
- } catch {
103
- parsedBody = null;
104
- }
105
- }
106
- if (!response.ok) {
107
- throw new LLMClientError(
108
- this.mapErrorMessage(response.status, parsedBody)
109
- );
110
- }
111
- return translateResponse(parsedBody);
112
- }
113
- mapErrorMessage(status, parsedBody) {
114
- switch (status) {
115
- case 400: {
116
- const detail = parsedBody ? formatPlatformErrors(parsedBody) : "";
117
- return detail ? `LLM request rejected (400): ${detail}` : "LLM request rejected (400). The server did not return an errors array.";
118
- }
119
- case 401:
120
- return "Invalid API key. Check $SERIOUSGAMING_API_KEY and that it has not been revoked.";
121
- case 403:
122
- return "The account that created this API key does not have access to the platform LLM API. Ask Serious Gaming support to grant it.";
123
- default: {
124
- const detail = parsedBody ? formatPlatformErrors(parsedBody) : "";
125
- return detail ? `LLM request failed (${status}): ${detail}` : `LLM request failed with HTTP ${status}.`;
126
- }
127
- }
128
- }
129
- };
130
- function translateResponse(parsedBody) {
131
- if (parsedBody === null || typeof parsedBody !== "object") {
132
- throw new LLMClientError("Unexpected response format from the platform LLM API");
133
- }
134
- const { content, stopReason, usage } = parsedBody;
135
- if (!Array.isArray(content) || content.length === 0) {
136
- throw new LLMClientError("Empty response from the platform LLM API");
137
- }
138
- if (typeof stopReason !== "string") {
139
- throw new LLMClientError("Unexpected response format from the platform LLM API");
140
- }
141
- const response = {
142
- content: content.filter(isKnownContentBlock),
143
- stopReason: STOP_REASONS.includes(stopReason) ? stopReason : "endTurn"
144
- };
145
- if (usage && typeof usage === "object") {
146
- const { inputTokens, outputTokens } = usage;
147
- if (typeof inputTokens === "number" && typeof outputTokens === "number") {
148
- response.usage = { inputTokens, outputTokens };
149
- }
150
- }
151
- return response;
152
- }
153
- function isKnownContentBlock(block) {
154
- if (block === null || typeof block !== "object") return false;
155
- const { type } = block;
156
- return typeof type === "string" && CONTENT_BLOCK_TYPES.includes(type);
157
- }
158
-
159
- // cli/execution/logic-failure.ts
160
- var failures = /* @__PURE__ */ new WeakMap();
161
- function markLogicFailure(error, failure) {
162
- const carrier = typeof error === "object" && error !== null ? error : new Error(String(error));
163
- if (!failures.has(carrier)) failures.set(carrier, failure);
164
- return carrier;
165
- }
166
- function logicFailureOf(error) {
167
- return typeof error === "object" && error !== null ? failures.get(error) : void 0;
168
- }
169
- function carryLogicFailure(from, to) {
170
- const failure = logicFailureOf(from);
171
- if (failure && typeof to === "object" && to !== null) failures.set(to, failure);
172
- return to;
173
- }
174
- function logicErrorOf(result) {
175
- return typeof result === "object" && result !== null && "logicError" in result ? result.logicError : void 0;
176
- }
177
- function thrownMessage(error) {
178
- if (typeof error === "object" && error !== null && "message" in error) {
179
- return String(error.message);
180
- }
181
- return String(error);
182
- }
183
- function thrownStack(error) {
184
- if (typeof error === "object" && error !== null && "stack" in error) {
185
- const stack = error.stack;
186
- return typeof stack === "string" ? stack : void 0;
187
- }
188
- return void 0;
189
- }
190
- var INLINE_MAP = /\n\/\/# sourceMappingURL=data:application\/json;base64,([A-Za-z0-9+/=]+)\s*$/;
191
- var FRAME = /^\s*at (?:.*? \()?(.+?):(\d+):(\d+)\)?\s*$/;
192
- var SourceMapRegistry = class {
193
- maps = /* @__PURE__ */ new Map();
194
- /**
195
- * Remember the inline source map at the end of `code`, compiled under
196
- * `filename`. Its sources are relative to the bundle's directory, which is
197
- * the directory of the entrypoint (see `Transpile`).
198
- */
199
- register(filename, code) {
200
- const match = INLINE_MAP.exec(code);
201
- if (!match?.[1]) {
202
- this.maps.delete(filename);
203
- return;
204
- }
205
- try {
206
- const payload = JSON.parse(Buffer.from(match[1], "base64").toString("utf-8"));
207
- this.maps.set(filename, { map: new SourceMap(payload), base: dirname(filename) });
208
- } catch {
209
- this.maps.delete(filename);
210
- }
211
- }
212
- clear() {
213
- this.maps.clear();
214
- }
215
- /**
216
- * Where `error` was thrown in source: the first stack frame inside a
217
- * registered bundle that maps to the author's own code, or failing that to
218
- * anything (such as a bundled dependency). Undefined when no frame is in a
219
- * bundle, or the error carries no stack.
220
- */
221
- locate(error) {
222
- const stack = thrownStack(error);
223
- if (!stack) return void 0;
224
- let fallback;
225
- for (const line of stack.split("\n")) {
226
- const frame = FRAME.exec(line);
227
- if (!frame?.[1] || !frame[2] || !frame[3]) continue;
228
- const entry = this.maps.get(frame[1]);
229
- if (!entry) continue;
230
- const origin = entry.map.findOrigin(Number(frame[2]), Number(frame[3]));
231
- if (!("fileName" in origin) || !origin.fileName) continue;
232
- const located = {
233
- file: isAbsolute(origin.fileName) ? origin.fileName : resolve(entry.base, origin.fileName),
234
- line: origin.lineNumber,
235
- column: origin.columnNumber
236
- };
237
- if (!located.file.split(sep).includes("node_modules")) return located;
238
- fallback ??= located;
239
- }
240
- return fallback;
241
- }
242
- };
243
- function describeLogicFailure(error, origin, maps, packagePath) {
244
- const location = maps.locate(error);
245
- const code = typeof error === "object" && error !== null ? error.code : void 0;
246
- return {
247
- ...origin,
248
- message: thrownMessage(error),
249
- ...code === LLM_NOT_CONFIGURED ? { errorCode: code } : {},
250
- ...location ? {
251
- file: relative(realPath(packagePath), realPath(location.file)).split(sep).join("/"),
252
- line: location.line,
253
- column: location.column
254
- } : {}
255
- };
256
- }
257
-
258
- // cli/execution/scenario-gates.ts
259
- import { existsSync } from "fs";
260
- import { readFile } from "fs/promises";
18
+ } from "./cli-RVZH462G.js";
19
+ import {
20
+ describeAssetByReference,
21
+ describeBlob,
22
+ readAssetByReference,
23
+ storeBlob
24
+ } from "./cli-QWQMPCL6.js";
261
25
 
262
26
  // cli/runtime/context-merge.ts
263
27
  var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
@@ -581,6 +345,242 @@ function applySchemaDefaults(configSchema) {
581
345
  return config;
582
346
  }
583
347
 
348
+ // cli/execution/logic-failure.ts
349
+ import { SourceMap } from "node:module";
350
+ import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
351
+
352
+ // cli/utils/llm-client.ts
353
+ var TOOL_NAME_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/;
354
+ var STOP_REASONS = ["endTurn", "toolUse", "maxTokens", "refusal"];
355
+ var CONTENT_BLOCK_TYPES = ["text", "toolUse", "toolResult"];
356
+ var LLM_NOT_CONFIGURED = "LLM_NOT_CONFIGURED";
357
+ var LLM_NOT_CONFIGURED_HINT = "Set SERIOUSGAMING_API_KEY in the environment or in .env, or run `seriousgaming-sdk config set platform.apiKey <key>`, or pass `sdk dev --api-key <key>`, then restart the dev server. Issue a key from your organisation settings on the platform.";
358
+ var LLMClientError = class extends Error {
359
+ constructor(message, code) {
360
+ super(message);
361
+ this.code = code;
362
+ this.name = "LLMClientError";
363
+ }
364
+ code;
365
+ };
366
+ var LLMClient = class {
367
+ apiKey;
368
+ apiHost;
369
+ constructor(config) {
370
+ this.apiKey = config.apiKey;
371
+ this.apiHost = normalisePlatformHost(config.apiHost ?? DEFAULT_PLATFORM_HOST);
372
+ }
373
+ /**
374
+ * Generate text through the platform LLM API.
375
+ * Supports both simple string prompts and complex options.
376
+ */
377
+ async generateText(optionsOrPrompt) {
378
+ if (!this.apiKey) {
379
+ throw new LLMClientError(
380
+ "generateText needs a Serious Gaming platform API key, and none is configured.",
381
+ LLM_NOT_CONFIGURED
382
+ );
383
+ }
384
+ const options = typeof optionsOrPrompt === "string" ? { prompt: optionsOrPrompt } : optionsOrPrompt;
385
+ if (options.tools) {
386
+ for (const tool of options.tools) {
387
+ if (!TOOL_NAME_PATTERN.test(tool.name)) {
388
+ throw new LLMClientError(
389
+ `Invalid tool name "${tool.name}": must match ^[a-zA-Z0-9_-]{1,64}$`
390
+ );
391
+ }
392
+ }
393
+ }
394
+ if (!options.prompt && (!options.messages || options.messages.length === 0)) {
395
+ throw new LLMClientError("No prompt or messages provided to generateText");
396
+ }
397
+ const endpoint = `${this.apiHost}/api/v0/llm/generate`;
398
+ const body = {};
399
+ if (options.prompt !== void 0) body.prompt = options.prompt;
400
+ if (options.messages !== void 0) body.messages = options.messages;
401
+ if (options.systemPrompt !== void 0) body.systemPrompt = options.systemPrompt;
402
+ if (options.jsonSchema !== void 0) body.jsonSchema = options.jsonSchema;
403
+ if (options.tier !== void 0) body.tier = options.tier;
404
+ if (options.tools !== void 0) body.tools = options.tools;
405
+ let response;
406
+ try {
407
+ response = await fetch(endpoint, {
408
+ method: "POST",
409
+ headers: {
410
+ Authorization: `Bearer ${this.apiKey}`,
411
+ "Content-Type": "application/json"
412
+ },
413
+ body: JSON.stringify(body)
414
+ });
415
+ } catch (error) {
416
+ const message = error instanceof Error ? error.message : "Unknown error";
417
+ throw new LLMClientError(`Network error contacting ${endpoint}: ${message}`);
418
+ }
419
+ const rawBody = await response.text();
420
+ let parsedBody = null;
421
+ if (rawBody) {
422
+ try {
423
+ parsedBody = JSON.parse(rawBody);
424
+ } catch {
425
+ parsedBody = null;
426
+ }
427
+ }
428
+ if (!response.ok) {
429
+ throw new LLMClientError(
430
+ this.mapErrorMessage(response.status, parsedBody)
431
+ );
432
+ }
433
+ return translateResponse(parsedBody);
434
+ }
435
+ mapErrorMessage(status, parsedBody) {
436
+ switch (status) {
437
+ case 400: {
438
+ const detail = parsedBody ? formatPlatformErrors(parsedBody) : "";
439
+ return detail ? `LLM request rejected (400): ${detail}` : "LLM request rejected (400). The server did not return an errors array.";
440
+ }
441
+ case 401:
442
+ return "Invalid API key. Check $SERIOUSGAMING_API_KEY and that it has not been revoked.";
443
+ case 403:
444
+ return "The account that created this API key does not have access to the platform LLM API. Ask Serious Gaming support to grant it.";
445
+ default: {
446
+ const detail = parsedBody ? formatPlatformErrors(parsedBody) : "";
447
+ return detail ? `LLM request failed (${status}): ${detail}` : `LLM request failed with HTTP ${status}.`;
448
+ }
449
+ }
450
+ }
451
+ };
452
+ function translateResponse(parsedBody) {
453
+ if (parsedBody === null || typeof parsedBody !== "object") {
454
+ throw new LLMClientError("Unexpected response format from the platform LLM API");
455
+ }
456
+ const { content, stopReason, usage } = parsedBody;
457
+ if (!Array.isArray(content) || content.length === 0) {
458
+ throw new LLMClientError("Empty response from the platform LLM API");
459
+ }
460
+ if (typeof stopReason !== "string") {
461
+ throw new LLMClientError("Unexpected response format from the platform LLM API");
462
+ }
463
+ const response = {
464
+ content: content.filter(isKnownContentBlock),
465
+ stopReason: STOP_REASONS.includes(stopReason) ? stopReason : "endTurn"
466
+ };
467
+ if (usage && typeof usage === "object") {
468
+ const { inputTokens, outputTokens } = usage;
469
+ if (typeof inputTokens === "number" && typeof outputTokens === "number") {
470
+ response.usage = { inputTokens, outputTokens };
471
+ }
472
+ }
473
+ return response;
474
+ }
475
+ function isKnownContentBlock(block) {
476
+ if (block === null || typeof block !== "object") return false;
477
+ const { type } = block;
478
+ return typeof type === "string" && CONTENT_BLOCK_TYPES.includes(type);
479
+ }
480
+
481
+ // cli/execution/logic-failure.ts
482
+ var failures = /* @__PURE__ */ new WeakMap();
483
+ function markLogicFailure(error, failure) {
484
+ const carrier = typeof error === "object" && error !== null ? error : new Error(String(error));
485
+ if (!failures.has(carrier)) failures.set(carrier, failure);
486
+ return carrier;
487
+ }
488
+ function logicFailureOf(error) {
489
+ return typeof error === "object" && error !== null ? failures.get(error) : void 0;
490
+ }
491
+ function carryLogicFailure(from, to) {
492
+ const failure = logicFailureOf(from);
493
+ if (failure && typeof to === "object" && to !== null) failures.set(to, failure);
494
+ return to;
495
+ }
496
+ function logicErrorOf(result) {
497
+ return typeof result === "object" && result !== null && "logicError" in result ? result.logicError : void 0;
498
+ }
499
+ function thrownMessage(error) {
500
+ if (typeof error === "object" && error !== null && "message" in error) {
501
+ return String(error.message);
502
+ }
503
+ return String(error);
504
+ }
505
+ function thrownStack(error) {
506
+ if (typeof error === "object" && error !== null && "stack" in error) {
507
+ const stack = error.stack;
508
+ return typeof stack === "string" ? stack : void 0;
509
+ }
510
+ return void 0;
511
+ }
512
+ var INLINE_MAP = /\n\/\/# sourceMappingURL=data:application\/json;base64,([A-Za-z0-9+/=]+)\s*$/;
513
+ var FRAME = /^\s*at (?:.*? \()?(.+?):(\d+):(\d+)\)?\s*$/;
514
+ var SourceMapRegistry = class {
515
+ maps = /* @__PURE__ */ new Map();
516
+ /**
517
+ * Remember the inline source map at the end of `code`, compiled under
518
+ * `filename`. Its sources are relative to the bundle's directory, which is
519
+ * the directory of the entrypoint (see `Transpile`).
520
+ */
521
+ register(filename, code) {
522
+ const match = INLINE_MAP.exec(code);
523
+ if (!match?.[1]) {
524
+ this.maps.delete(filename);
525
+ return;
526
+ }
527
+ try {
528
+ const payload = JSON.parse(Buffer.from(match[1], "base64").toString("utf-8"));
529
+ this.maps.set(filename, { map: new SourceMap(payload), base: dirname(filename) });
530
+ } catch {
531
+ this.maps.delete(filename);
532
+ }
533
+ }
534
+ clear() {
535
+ this.maps.clear();
536
+ }
537
+ /**
538
+ * Where `error` was thrown in source: the first stack frame inside a
539
+ * registered bundle that maps to the author's own code, or failing that to
540
+ * anything (such as a bundled dependency). Undefined when no frame is in a
541
+ * bundle, or the error carries no stack.
542
+ */
543
+ locate(error) {
544
+ const stack = thrownStack(error);
545
+ if (!stack) return void 0;
546
+ let fallback;
547
+ for (const line of stack.split("\n")) {
548
+ const frame = FRAME.exec(line);
549
+ if (!frame?.[1] || !frame[2] || !frame[3]) continue;
550
+ const entry = this.maps.get(frame[1]);
551
+ if (!entry) continue;
552
+ const origin = entry.map.findOrigin(Number(frame[2]), Number(frame[3]));
553
+ if (!("fileName" in origin) || !origin.fileName) continue;
554
+ const located = {
555
+ file: isAbsolute(origin.fileName) ? origin.fileName : resolve(entry.base, origin.fileName),
556
+ line: origin.lineNumber,
557
+ column: origin.columnNumber
558
+ };
559
+ if (!located.file.split(sep).includes("node_modules")) return located;
560
+ fallback ??= located;
561
+ }
562
+ return fallback;
563
+ }
564
+ };
565
+ function describeLogicFailure(error, origin, maps, packagePath) {
566
+ const location = maps.locate(error);
567
+ const code = typeof error === "object" && error !== null ? error.code : void 0;
568
+ return {
569
+ ...origin,
570
+ message: thrownMessage(error),
571
+ ...code === LLM_NOT_CONFIGURED ? { errorCode: code } : {},
572
+ ...location ? {
573
+ file: relative(realPath(packagePath), realPath(location.file)).split(sep).join("/"),
574
+ line: location.line,
575
+ column: location.column
576
+ } : {}
577
+ };
578
+ }
579
+
580
+ // cli/execution/scenario-gates.ts
581
+ import { existsSync } from "fs";
582
+ import { readFile } from "fs/promises";
583
+
584
584
  // cli/runtime/guarded-callbacks.ts
585
585
  var API_USE_TO_CALLBACK = {
586
586
  generateText: "generateText",
@@ -1490,6 +1490,7 @@ export {
1490
1490
  deepMergeContext,
1491
1491
  applyContextUpdate,
1492
1492
  ConfigResolver,
1493
+ resolveSettingsLayers,
1493
1494
  applySchemaDefaults,
1494
1495
  TtsClient,
1495
1496
  DocumentParserClient,
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  validateEngine
4
- } from "./cli-GO64NABP.js";
4
+ } from "./cli-FCJHNXDA.js";
5
5
  import "./cli-4LKXZQ2B.js";
6
6
  import {
7
7
  LOGIC_NODE_BUILTIN,
8
8
  Transpile,
9
9
  loadConfig
10
- } from "./cli-X64BNBQH.js";
11
- import "./cli-F2D4GGUA.js";
12
- import "./cli-TCQJL2GY.js";
10
+ } from "./cli-RVZH462G.js";
11
+ import "./cli-2BKEIIA3.js";
12
+ import "./cli-D5VOSJZ7.js";
13
13
  import {
14
14
  CliError,
15
15
  reportResult
16
- } from "./cli-5VZBFMCK.js";
16
+ } from "./cli-5PIFO3EN.js";
17
17
 
18
18
  // cli/commands/build-engine.ts
19
19
  import { resolve, join } from "path";
@@ -1,53 +1,53 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  promptForSettings
4
- } from "./cli-RKPQLB7J.js";
4
+ } from "./cli-5CW7BEU7.js";
5
5
  import {
6
6
  loadResourceIdentifiers
7
- } from "./cli-EEO5ZPAZ.js";
7
+ } from "./cli-B5TC4MEL.js";
8
+ import {
9
+ checkbox,
10
+ input
11
+ } from "./cli-2W4B6PD5.js";
8
12
  import {
9
13
  readAuthoredBundle
10
- } from "./cli-6O7YCK2M.js";
14
+ } from "./cli-MITZ6SE7.js";
11
15
  import {
12
16
  resolveInputSource
13
- } from "./cli-XW3JLRSA.js";
17
+ } from "./cli-DWDSBTYL.js";
18
+ import {
19
+ loadPackageContext
20
+ } from "./cli-L6AHMW2Z.js";
14
21
  import {
15
22
  createUserInterfaceFiles
16
- } from "./cli-RHL4B4H7.js";
17
- import "./cli-WW54THXN.js";
23
+ } from "./cli-T76HDH7F.js";
24
+ import "./cli-KVQ2JPVD.js";
18
25
  import "./cli-QUNIRH7A.js";
19
- import "./cli-ERJNDBDH.js";
20
- import {
21
- loadPackageContext
22
- } from "./cli-LHMRUJVN.js";
26
+ import "./cli-ARAAEWIQ.js";
23
27
  import {
24
28
  presentFields
25
- } from "./cli-X3TSTTYI.js";
26
- import "./cli-QEFYDXMH.js";
29
+ } from "./cli-JC5OJRID.js";
30
+ import "./cli-DZCLRZXJ.js";
27
31
  import {
28
32
  BUILD_COMMAND,
29
33
  generateTypes,
30
34
  operationError,
31
35
  printOperationResult
32
- } from "./cli-QTCTWYCM.js";
33
- import {
34
- checkbox,
35
- input
36
- } from "./cli-P3NUTOPK.js";
37
- import "./cli-UQC46YSV.js";
38
- import "./cli-6BLVI2JM.js";
39
- import "./cli-UEQMK4WX.js";
40
- import "./cli-JXQLHJO2.js";
36
+ } from "./cli-SO354HPI.js";
37
+ import "./cli-JTFLIMIG.js";
38
+ import "./cli-RMVJMOWU.js";
39
+ import "./cli-M3Z2KOEB.js";
40
+ import "./cli-HXT25ETJ.js";
41
41
  import "./cli-25RWY5BQ.js";
42
- import "./cli-QWQMPCL6.js";
43
42
  import {
44
43
  validateSDKUserInterface
45
- } from "./cli-X64BNBQH.js";
46
- import "./cli-F2D4GGUA.js";
44
+ } from "./cli-RVZH462G.js";
45
+ import "./cli-QWQMPCL6.js";
46
+ import "./cli-2BKEIIA3.js";
47
47
  import {
48
48
  logger
49
- } from "./cli-TCQJL2GY.js";
50
- import "./cli-5VZBFMCK.js";
49
+ } from "./cli-D5VOSJZ7.js";
50
+ import "./cli-5PIFO3EN.js";
51
51
 
52
52
  // cli/commands/resources/ui/new.ts
53
53
  async function createUserInterface(definitionInput, options) {
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ deleteSettingsEditor
4
+ } from "./cli-7OYFJMA6.js";
5
+ import "./cli-B5TC4MEL.js";
6
+ import "./cli-2W4B6PD5.js";
7
+ import "./cli-2VXP34R5.js";
8
+ import "./cli-S5IVGDDD.js";
9
+ import "./cli-MITZ6SE7.js";
10
+ import "./cli-DWDSBTYL.js";
11
+ import "./cli-L6AHMW2Z.js";
12
+ import "./cli-T76HDH7F.js";
13
+ import "./cli-KVQ2JPVD.js";
14
+ import "./cli-QUNIRH7A.js";
15
+ import "./cli-ARAAEWIQ.js";
16
+ import "./cli-JC5OJRID.js";
17
+ import "./cli-DZCLRZXJ.js";
18
+ import "./cli-SO354HPI.js";
19
+ import "./cli-JTFLIMIG.js";
20
+ import "./cli-RMVJMOWU.js";
21
+ import "./cli-M3Z2KOEB.js";
22
+ import "./cli-HXT25ETJ.js";
23
+ import "./cli-25RWY5BQ.js";
24
+ import "./cli-RVZH462G.js";
25
+ import "./cli-QWQMPCL6.js";
26
+ import "./cli-2BKEIIA3.js";
27
+ import "./cli-D5VOSJZ7.js";
28
+ import "./cli-5PIFO3EN.js";
29
+
30
+ // cli/commands/resources/scenario-editor/delete.ts
31
+ function deleteScenarioEditor(options) {
32
+ return deleteSettingsEditor("scenario_editor", options);
33
+ }
34
+ export {
35
+ deleteScenarioEditor
36
+ };