@bolt-foundry/gambit-core 0.8.1 → 0.8.3
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/README.md +28 -32
- package/cards/context.card.md +5 -5
- package/cards/generate-test-input.card.md +12 -0
- package/esm/mod.d.ts +11 -9
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +7 -5
- package/esm/src/constants.d.ts +4 -0
- package/esm/src/constants.d.ts.map +1 -1
- package/esm/src/constants.js +5 -0
- package/esm/src/definitions.d.ts +5 -1
- package/esm/src/definitions.d.ts.map +1 -1
- package/esm/src/loader.d.ts.map +1 -1
- package/esm/src/loader.js +61 -2
- package/esm/src/markdown.d.ts.map +1 -1
- package/esm/src/markdown.js +55 -12
- package/esm/src/render.d.ts.map +1 -1
- package/esm/src/render.js +22 -8
- package/esm/src/runtime.d.ts +1 -0
- package/esm/src/runtime.d.ts.map +1 -1
- package/esm/src/runtime.js +300 -41
- package/esm/src/state.d.ts +3 -1
- package/esm/src/state.d.ts.map +1 -1
- package/esm/src/state.js +48 -2
- package/esm/src/types.d.ts +149 -1
- package/esm/src/types.d.ts.map +1 -1
- package/esm/src/types.js +102 -1
- package/package.json +1 -2
- package/schemas/graders/grader_output.ts +7 -0
- package/script/mod.d.ts +11 -9
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +14 -9
- package/script/src/constants.d.ts +4 -0
- package/script/src/constants.d.ts.map +1 -1
- package/script/src/constants.js +6 -1
- package/script/src/definitions.d.ts +5 -1
- package/script/src/definitions.d.ts.map +1 -1
- package/script/src/loader.d.ts.map +1 -1
- package/script/src/loader.js +61 -2
- package/script/src/markdown.d.ts.map +1 -1
- package/script/src/markdown.js +54 -11
- package/script/src/render.d.ts.map +1 -1
- package/script/src/render.js +22 -8
- package/script/src/runtime.d.ts +1 -0
- package/script/src/runtime.d.ts.map +1 -1
- package/script/src/runtime.js +299 -40
- package/script/src/state.d.ts +3 -1
- package/script/src/state.d.ts.map +1 -1
- package/script/src/state.js +48 -2
- package/script/src/types.d.ts +149 -1
- package/script/src/types.d.ts.map +1 -1
- package/script/src/types.js +103 -0
- package/esm/src/openai_compat.d.ts +0 -63
- package/esm/src/openai_compat.d.ts.map +0 -1
- package/esm/src/openai_compat.js +0 -272
- package/esm/src/providers/openrouter.d.ts +0 -8
- package/esm/src/providers/openrouter.d.ts.map +0 -1
- package/esm/src/providers/openrouter.js +0 -168
- package/script/src/openai_compat.d.ts +0 -63
- package/script/src/openai_compat.d.ts.map +0 -1
- package/script/src/openai_compat.js +0 -276
- package/script/src/providers/openrouter.d.ts +0 -8
- package/script/src/providers/openrouter.d.ts.map +0 -1
- package/script/src/providers/openrouter.js +0 -207
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/src/markdown.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAIV,UAAU,EACV,UAAU,EAEX,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/src/markdown.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAIV,UAAU,EACV,UAAU,EAEX,MAAM,YAAY,CAAC;AA+LpB,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,KAAK,GAAE,KAAK,CAAC,MAAM,CAAM,GACxB,OAAO,CAAC,UAAU,CAAC,CA0GrB;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC,CAgMrB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD"}
|
package/script/src/markdown.js
CHANGED
|
@@ -53,8 +53,10 @@ const LEGACY_MARKER_WARNINGS = {
|
|
|
53
53
|
init: false,
|
|
54
54
|
end: false,
|
|
55
55
|
};
|
|
56
|
+
const LEGACY_SCHEMA_WARNINGS = new Set();
|
|
57
|
+
const LEGACY_FRAGMENT_WARNINGS = new Set();
|
|
56
58
|
const INIT_TEXT = `
|
|
57
|
-
You will automatically receive a \`${constants_js_1.
|
|
59
|
+
You will automatically receive a \`${constants_js_1.GAMBIT_TOOL_CONTEXT}\` tool result at the start that provides run/context info.
|
|
58
60
|
`.trim();
|
|
59
61
|
const RESPOND_TEXT = `
|
|
60
62
|
When you are done, call the \`${constants_js_1.GAMBIT_TOOL_RESPOND}\` tool with a JSON object that includes your \`payload\` (validated output) and optional \`status\`/ \`message\`/ \`code\`/ \`meta\`. Do not end with normal assistant text; always finish by calling \`${constants_js_1.GAMBIT_TOOL_RESPOND}\`.
|
|
@@ -68,6 +70,20 @@ function warnLegacyMarker(marker, replacement) {
|
|
|
68
70
|
LEGACY_MARKER_WARNINGS[marker] = true;
|
|
69
71
|
logger.warn(`[gambit] "gambit://${marker}" is deprecated; use ${replacement} instead.`);
|
|
70
72
|
}
|
|
73
|
+
function warnLegacySchema(resolvedPath, legacy, replacement) {
|
|
74
|
+
const key = `${resolvedPath}:${legacy}`;
|
|
75
|
+
if (LEGACY_SCHEMA_WARNINGS.has(key))
|
|
76
|
+
return;
|
|
77
|
+
LEGACY_SCHEMA_WARNINGS.add(key);
|
|
78
|
+
logger.warn(`[gambit] deck at ${resolvedPath} uses deprecated "${legacy}"; rename to "${replacement}"`);
|
|
79
|
+
}
|
|
80
|
+
function warnLegacyFragment(resolvedPath, legacy, replacement) {
|
|
81
|
+
const key = `${resolvedPath}:${legacy}`;
|
|
82
|
+
if (LEGACY_FRAGMENT_WARNINGS.has(key))
|
|
83
|
+
return;
|
|
84
|
+
LEGACY_FRAGMENT_WARNINGS.add(key);
|
|
85
|
+
logger.warn(`[gambit] card at ${resolvedPath} uses deprecated "${legacy}"; rename to "${replacement}"`);
|
|
86
|
+
}
|
|
71
87
|
function toFileUrl(p) {
|
|
72
88
|
const abs = path.resolve(p);
|
|
73
89
|
return path.toFileUrl(abs).href;
|
|
@@ -206,8 +222,18 @@ async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
206
222
|
throw new Error(`Action name ${a.name} must match ${constants_js_1.TOOL_NAME_PATTERN} and be <= ${constants_js_1.MAX_TOOL_NAME_LENGTH} characters`);
|
|
207
223
|
}
|
|
208
224
|
});
|
|
209
|
-
const
|
|
210
|
-
const
|
|
225
|
+
const legacyInputSchema = attrs.inputSchema;
|
|
226
|
+
const legacyOutputSchema = attrs.outputSchema;
|
|
227
|
+
const contextFragment = await maybeLoadSchema(attrs.contextFragment ??
|
|
228
|
+
legacyInputSchema, resolved);
|
|
229
|
+
const responseFragment = await maybeLoadSchema(attrs.responseFragment ??
|
|
230
|
+
legacyOutputSchema, resolved);
|
|
231
|
+
if (legacyInputSchema !== undefined) {
|
|
232
|
+
warnLegacyFragment(resolved, "inputSchema", "contextFragment");
|
|
233
|
+
}
|
|
234
|
+
if (legacyOutputSchema !== undefined) {
|
|
235
|
+
warnLegacyFragment(resolved, "outputSchema", "responseFragment");
|
|
236
|
+
}
|
|
211
237
|
const replaced = await expandEmbedsInBody({
|
|
212
238
|
body,
|
|
213
239
|
resolvedPath: resolved,
|
|
@@ -227,8 +253,10 @@ async function loadMarkdownCard(filePath, parentPath, stack = []) {
|
|
|
227
253
|
testDecks: normalizeDeckRefs(attrs.testDecks, resolved),
|
|
228
254
|
graderDecks: normalizeDeckRefs(attrs.graderDecks, resolved),
|
|
229
255
|
cards: embeddedCards,
|
|
230
|
-
|
|
231
|
-
|
|
256
|
+
contextFragment,
|
|
257
|
+
responseFragment,
|
|
258
|
+
inputFragment: contextFragment,
|
|
259
|
+
outputFragment: responseFragment,
|
|
232
260
|
respond: respondFlag || replaced.respond,
|
|
233
261
|
};
|
|
234
262
|
}
|
|
@@ -271,8 +299,18 @@ async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
271
299
|
stack: [resolved],
|
|
272
300
|
});
|
|
273
301
|
const cards = replaced.embeds;
|
|
274
|
-
const
|
|
275
|
-
const
|
|
302
|
+
const legacyInputSchema = deckMeta.inputSchema;
|
|
303
|
+
const legacyOutputSchema = deckMeta.outputSchema;
|
|
304
|
+
const contextSchema = await maybeLoadSchema(deckMeta.contextSchema ??
|
|
305
|
+
legacyInputSchema, resolved);
|
|
306
|
+
const responseSchema = await maybeLoadSchema(deckMeta.responseSchema ??
|
|
307
|
+
legacyOutputSchema, resolved);
|
|
308
|
+
if (legacyInputSchema !== undefined) {
|
|
309
|
+
warnLegacySchema(resolved, "inputSchema", "contextSchema");
|
|
310
|
+
}
|
|
311
|
+
if (legacyOutputSchema !== undefined) {
|
|
312
|
+
warnLegacySchema(resolved, "outputSchema", "responseSchema");
|
|
313
|
+
}
|
|
276
314
|
const allCards = flattenCards(cards);
|
|
277
315
|
const cleanedBody = replaced.body;
|
|
278
316
|
const allowEnd = Boolean(deckMeta.allowEnd) ||
|
|
@@ -287,12 +325,14 @@ async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
287
325
|
for (const action of actionDecks) {
|
|
288
326
|
mergedActions[action.name] = action;
|
|
289
327
|
}
|
|
290
|
-
let
|
|
291
|
-
let
|
|
328
|
+
let mergedContextSchema = contextSchema;
|
|
329
|
+
let mergedResponseSchema = responseSchema;
|
|
292
330
|
for (const card of allCards) {
|
|
293
|
-
|
|
294
|
-
|
|
331
|
+
mergedContextSchema = (0, schema_js_1.mergeZodObjects)(mergedContextSchema, card.contextFragment);
|
|
332
|
+
mergedResponseSchema = (0, schema_js_1.mergeZodObjects)(mergedResponseSchema, card.responseFragment);
|
|
295
333
|
}
|
|
334
|
+
const mergedInputSchema = mergedContextSchema;
|
|
335
|
+
const mergedOutputSchema = mergedResponseSchema;
|
|
296
336
|
const normalizeHandler = (cfg, kind) => {
|
|
297
337
|
if (!cfg)
|
|
298
338
|
return undefined;
|
|
@@ -340,8 +380,11 @@ async function loadMarkdownDeck(filePath, parentPath) {
|
|
|
340
380
|
graderDecks: mergeDeckRefs(rootGraderDecks, embeddedGraderDecks),
|
|
341
381
|
cards: allCards,
|
|
342
382
|
label: deckMeta.label,
|
|
383
|
+
startMode: deckMeta.startMode,
|
|
343
384
|
modelParams: deckMeta.modelParams,
|
|
344
385
|
guardrails: deckMeta.guardrails,
|
|
386
|
+
contextSchema: mergedContextSchema,
|
|
387
|
+
responseSchema: mergedResponseSchema,
|
|
345
388
|
inputSchema: mergedInputSchema,
|
|
346
389
|
outputSchema: mergedOutputSchema,
|
|
347
390
|
handlers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/src/render.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/src/render.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,YAAY,EAEZ,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,MAAM,SAAU,CAAC;AAE9B,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;QAC/C,OAAO,EACH,MAAM,GACN,IAAI,GACJ,KAAK,CAAC,MAAM,GAAG;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACrD,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,UAAU,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;KACzC,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB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
|
|
64
64
|
}
|
|
65
|
+
function resolveContextSchema(deck) {
|
|
66
|
+
return deck.contextSchema ?? deck.inputSchema;
|
|
67
|
+
}
|
|
68
|
+
function resolveResponseSchema(deck) {
|
|
69
|
+
return deck.responseSchema ?? deck.outputSchema;
|
|
70
|
+
}
|
|
65
71
|
function assertNoToolNameCollisions(args) {
|
|
66
72
|
if (!args.externalTools?.length)
|
|
67
73
|
return;
|
|
@@ -84,12 +90,14 @@ async function buildDeckActionTools(deckPath) {
|
|
|
84
90
|
const actionPathsByName = {};
|
|
85
91
|
for (const action of deck.actionDecks) {
|
|
86
92
|
const child = await (0, loader_js_1.loadDeck)(action.path, deck.path);
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
const contextSchema = resolveContextSchema(child);
|
|
94
|
+
const responseSchema = resolveResponseSchema(child);
|
|
95
|
+
if (!contextSchema || !responseSchema) {
|
|
96
|
+
throw new Error(`Deck ${child.path} must declare contextSchema and responseSchema (non-root)`);
|
|
89
97
|
}
|
|
90
|
-
(0, schema_js_1.assertZodSchema)(
|
|
91
|
-
(0, schema_js_1.assertZodSchema)(
|
|
92
|
-
const params = (0, schema_js_1.toJsonSchema)(
|
|
98
|
+
(0, schema_js_1.assertZodSchema)(contextSchema, "contextSchema");
|
|
99
|
+
(0, schema_js_1.assertZodSchema)(responseSchema, "responseSchema");
|
|
100
|
+
const params = (0, schema_js_1.toJsonSchema)(contextSchema);
|
|
93
101
|
tools.push({
|
|
94
102
|
type: "function",
|
|
95
103
|
function: {
|
|
@@ -106,8 +114,11 @@ function mergeModelParams(req, deckParams) {
|
|
|
106
114
|
const out = { ...req };
|
|
107
115
|
if (!deckParams)
|
|
108
116
|
return out;
|
|
109
|
-
if (out.model === undefined && deckParams.model)
|
|
110
|
-
out.model = deckParams.model
|
|
117
|
+
if (out.model === undefined && deckParams.model) {
|
|
118
|
+
out.model = Array.isArray(deckParams.model)
|
|
119
|
+
? deckParams.model.find((entry) => typeof entry === "string" && entry.trim().length > 0)
|
|
120
|
+
: deckParams.model;
|
|
121
|
+
}
|
|
111
122
|
if (out.temperature === undefined && deckParams.temperature !== undefined) {
|
|
112
123
|
out.temperature = deckParams.temperature;
|
|
113
124
|
}
|
|
@@ -171,7 +182,10 @@ async function renderDeck(opts) {
|
|
|
171
182
|
}
|
|
172
183
|
tools = mergedReq.tools;
|
|
173
184
|
}
|
|
174
|
-
const
|
|
185
|
+
const resolvedModel = Array.isArray(mergedReq.model)
|
|
186
|
+
? mergedReq.model.find((entry) => typeof entry === "string" && entry.trim().length > 0)
|
|
187
|
+
: mergedReq.model;
|
|
188
|
+
const model = String(resolvedModel ?? "").trim();
|
|
175
189
|
if (!model) {
|
|
176
190
|
throw new Error(`renderDeck requires request.model (or deck.modelParams.model): ${deck.path}`);
|
|
177
191
|
}
|
package/script/src/runtime.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ type RunOptions = {
|
|
|
29
29
|
onStateUpdate?: (state: SavedState) => void;
|
|
30
30
|
onStreamText?: (chunk: string) => void;
|
|
31
31
|
allowRootStringInput?: boolean;
|
|
32
|
+
responsesMode?: boolean;
|
|
32
33
|
};
|
|
33
34
|
export declare function runDeck(opts: RunOptions): Promise<unknown>;
|
|
34
35
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/src/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/src/runtime.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAEV,UAAU,EAIV,aAAa,EAKd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAA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