@bolt-foundry/gambit 0.8.6 → 1.0.0-rc.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/CHANGELOG.md +25 -2
- package/README.md +22 -10
- package/esm/mod.d.ts +11 -3
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +7 -1
- package/esm/src/codex_app_server_debug.d.ts +3 -2
- package/esm/src/codex_app_server_debug.d.ts.map +1 -1
- package/esm/src/codex_app_server_debug.js +5 -3
- package/esm/src/codex_auth.d.ts +2 -1
- package/esm/src/codex_auth.d.ts.map +1 -1
- package/esm/src/codex_auth.js +4 -2
- package/esm/src/default_runtime.d.ts +5 -1
- package/esm/src/default_runtime.d.ts.map +1 -1
- package/esm/src/default_runtime.js +48 -29
- package/esm/src/openai_compat.d.ts.map +1 -1
- package/esm/src/openai_compat.js +111 -11
- package/esm/src/providers/claude_code.d.ts.map +1 -1
- package/esm/src/providers/claude_code.js +3 -3
- package/esm/src/providers/codex.d.ts +2 -1
- package/esm/src/providers/codex.d.ts.map +1 -1
- package/esm/src/providers/codex.js +50 -22
- package/esm/src/providers/google.d.ts.map +1 -1
- package/esm/src/providers/google.js +7 -114
- package/esm/src/providers/manifest.d.ts +2 -2
- package/esm/src/providers/manifest.d.ts.map +1 -1
- package/esm/src/providers/manifest.js +5 -5
- package/esm/src/providers/ollama.d.ts.map +1 -1
- package/esm/src/providers/ollama.js +0 -112
- package/esm/src/providers/openrouter.d.ts.map +1 -1
- package/esm/src/providers/openrouter.js +0 -264
- package/esm/src/providers/requirements.js +1 -1
- package/package.json +1 -1
- package/script/mod.d.ts +11 -3
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +15 -6
- package/script/src/codex_app_server_debug.d.ts +3 -2
- package/script/src/codex_app_server_debug.d.ts.map +1 -1
- package/script/src/codex_app_server_debug.js +6 -3
- package/script/src/codex_auth.d.ts +2 -1
- package/script/src/codex_auth.d.ts.map +1 -1
- package/script/src/codex_auth.js +5 -3
- package/script/src/default_runtime.d.ts +5 -1
- package/script/src/default_runtime.d.ts.map +1 -1
- package/script/src/default_runtime.js +48 -28
- package/script/src/openai_compat.d.ts.map +1 -1
- package/script/src/openai_compat.js +110 -10
- package/script/src/providers/claude_code.d.ts.map +1 -1
- package/script/src/providers/claude_code.js +3 -3
- package/script/src/providers/codex.d.ts +2 -1
- package/script/src/providers/codex.d.ts.map +1 -1
- package/script/src/providers/codex.js +49 -21
- package/script/src/providers/google.d.ts.map +1 -1
- package/script/src/providers/google.js +7 -114
- package/script/src/providers/manifest.d.ts +2 -2
- package/script/src/providers/manifest.d.ts.map +1 -1
- package/script/src/providers/manifest.js +5 -5
- package/script/src/providers/ollama.d.ts.map +1 -1
- package/script/src/providers/ollama.js +0 -112
- package/script/src/providers/openrouter.d.ts.map +1 -1
- package/script/src/providers/openrouter.js +0 -264
- package/script/src/providers/requirements.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,39 @@
|
|
|
1
1
|
+++
|
|
2
2
|
[release]
|
|
3
|
-
since = "
|
|
3
|
+
since = "b6ed5a3a8d6a9b272ce520d885d3953d27c2c0d4"
|
|
4
4
|
+++
|
|
5
5
|
|
|
6
6
|
# Changelog
|
|
7
7
|
|
|
8
|
-
## Unreleased
|
|
8
|
+
## Unreleased
|
|
9
|
+
|
|
10
|
+
- TBD
|
|
11
|
+
|
|
12
|
+
## v1.0.0-rc.1
|
|
13
|
+
|
|
14
|
+
- BREAKING: make Gambit runtime execution Responses-only.
|
|
15
|
+
- BREAKING: remove provider `chat` and provider-owned `resolveModel` from the
|
|
16
|
+
public `ModelProvider` contract.
|
|
17
|
+
- feat(gambit): add `runDeckResponses` as the canonical structured runtime
|
|
18
|
+
entrypoint with response output items, trace evidence, saved state, usage,
|
|
19
|
+
finish reason, effects, and a legacy fallback result.
|
|
20
|
+
- feat(gambit): add separate `ModelResolver` plumbing for model alias and
|
|
21
|
+
provider fallback resolution.
|
|
22
|
+
- feat(gambit): migrate core runtime, action recursion, MCP, OpenAI
|
|
23
|
+
compatibility, CLI/TUI, simulator workspace flows, website FAQ chat, and
|
|
24
|
+
Workloop completion projection to Responses-shaped execution.
|
|
25
|
+
|
|
26
|
+
## v0.8.7
|
|
9
27
|
|
|
10
28
|
- TBD
|
|
11
29
|
|
|
12
30
|
## v0.8.6
|
|
13
31
|
|
|
32
|
+
- fix(gambit): preserve spaces when flattening structured text parts
|
|
33
|
+
- fix(gambit-release): repair local compile preflight for nested core packages
|
|
34
|
+
|
|
35
|
+
## v0.8.6-rc.7
|
|
36
|
+
|
|
14
37
|
- TBD
|
|
15
38
|
|
|
16
39
|
## v0.8.6-rc.6
|
package/README.md
CHANGED
|
@@ -221,20 +221,26 @@ Define `contextSchema`/`responseSchema` with Zod to validate IO, and implement\
|
|
|
221
221
|
`ctx.spawnAndWait({ path, input })`. Emit structured trace events with\
|
|
222
222
|
`ctx.log(...)`.
|
|
223
223
|
|
|
224
|
-
### Runtime defaults for programmatic `
|
|
224
|
+
### Runtime defaults for programmatic `runDeckResponses`
|
|
225
225
|
|
|
226
|
-
`
|
|
227
|
-
|
|
226
|
+
`runDeckResponses` from `@bolt-foundry/gambit` is the canonical Gambit 1.0
|
|
227
|
+
runtime entrypoint. It uses CLI-equivalent provider/model defaults (alias
|
|
228
|
+
expansion, provider routing, fallback behavior) and returns structured Responses
|
|
229
|
+
output. Single-string assistant text is a presentation projection, not runtime
|
|
230
|
+
state.
|
|
228
231
|
|
|
229
232
|
Before (direct-provider setup in each caller):
|
|
230
233
|
|
|
231
234
|
```ts
|
|
232
|
-
import {
|
|
235
|
+
import {
|
|
236
|
+
createOpenRouterProvider,
|
|
237
|
+
runDeckResponses,
|
|
238
|
+
} from "jsr:@bolt-foundry/gambit";
|
|
233
239
|
|
|
234
240
|
const provider = createOpenRouterProvider({
|
|
235
241
|
apiKey: Deno.env.get("OPENROUTER_API_KEY")!,
|
|
236
242
|
});
|
|
237
|
-
await
|
|
243
|
+
await runDeckResponses({
|
|
238
244
|
path: "./root.deck.md",
|
|
239
245
|
input: { message: "hi" },
|
|
240
246
|
modelProvider: provider,
|
|
@@ -244,24 +250,29 @@ await runDeck({
|
|
|
244
250
|
After (defaulted wrapper):
|
|
245
251
|
|
|
246
252
|
```ts
|
|
247
|
-
import {
|
|
253
|
+
import { runDeckResponses } from "jsr:@bolt-foundry/gambit";
|
|
248
254
|
|
|
249
|
-
await
|
|
255
|
+
const result = await runDeckResponses({
|
|
250
256
|
path: "./root.deck.md",
|
|
251
257
|
input: { message: "hi" },
|
|
252
258
|
});
|
|
259
|
+
|
|
260
|
+
console.log(result.output);
|
|
253
261
|
```
|
|
254
262
|
|
|
255
263
|
Per-runtime override (shared runtime object):
|
|
256
264
|
|
|
257
265
|
```ts
|
|
258
|
-
import {
|
|
266
|
+
import {
|
|
267
|
+
createDefaultedRuntime,
|
|
268
|
+
runDeckResponses,
|
|
269
|
+
} from "jsr:@bolt-foundry/gambit";
|
|
259
270
|
|
|
260
271
|
const runtime = await createDefaultedRuntime({
|
|
261
272
|
fallbackProvider: "codex-cli",
|
|
262
273
|
});
|
|
263
274
|
|
|
264
|
-
await
|
|
275
|
+
await runDeckResponses({
|
|
265
276
|
runtime,
|
|
266
277
|
path: "./root.deck.md",
|
|
267
278
|
input: { message: "hi" },
|
|
@@ -271,7 +282,8 @@ await runDeck({
|
|
|
271
282
|
Replacement mapping:
|
|
272
283
|
|
|
273
284
|
- Legacy direct core passthrough export: `runDeck` -> `runDeckCore`
|
|
274
|
-
-
|
|
285
|
+
- Canonical structured defaulted export: `runDeckResponses`
|
|
286
|
+
- Legacy defaulted compatibility export: `runDeck`
|
|
275
287
|
- Runtime builder: `createDefaultedRuntime`
|
|
276
288
|
|
|
277
289
|
---
|
package/esm/mod.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export type { GraderDeckDefinition } from "@bolt-foundry/gambit-core";
|
|
|
24
24
|
export type { Guardrails } from "@bolt-foundry/gambit-core";
|
|
25
25
|
/** JSON-serializable value type used throughout Gambit. */
|
|
26
26
|
export type { JSONValue } from "@bolt-foundry/gambit-core";
|
|
27
|
-
/** Model provider
|
|
28
|
-
export type { ModelProvider } from "@bolt-foundry/gambit-core";
|
|
27
|
+
/** Model provider and resolver interfaces for LLM backends. */
|
|
28
|
+
export type { ModelProvider, ModelResolver } from "@bolt-foundry/gambit-core";
|
|
29
29
|
/** Scenario deck definition shape. */
|
|
30
30
|
export type { TestDeckDefinition } from "@bolt-foundry/gambit-core";
|
|
31
31
|
/** Check if a value is an explicit end-of-run signal. */
|
|
@@ -36,10 +36,18 @@ export { isRunCanceledError } from "@bolt-foundry/gambit-core";
|
|
|
36
36
|
export { createDefaultedRuntime } from "./src/default_runtime.js";
|
|
37
37
|
/** Runtime defaults/options for the `runDeck` wrapper. */
|
|
38
38
|
export type { CreateDefaultedRuntimeOptions, DefaultedRuntime, DefaultedRuntimeRunOptions, RunDeckWithDefaultsOptions, SessionArtifactsConfig, } from "./src/default_runtime.js";
|
|
39
|
-
/**
|
|
39
|
+
/** Legacy compatibility wrapper with default provider/model/runtime behavior. */
|
|
40
40
|
export { runDeck } from "./src/default_runtime.js";
|
|
41
|
+
/** Run a deck with defaults and return the structured Responses result. */
|
|
42
|
+
export { runDeckResponses } from "./src/default_runtime.js";
|
|
43
|
+
/** Project assistant output text from Responses items for presentation. */
|
|
44
|
+
export { stringifyResponseOutput } from "@bolt-foundry/gambit-core";
|
|
41
45
|
/** Run a deck directly through gambit-core without gambit defaults. */
|
|
42
46
|
export { runDeck as runDeckCore } from "@bolt-foundry/gambit-core";
|
|
47
|
+
/** Run a deck directly through gambit-core and return structured Responses. */
|
|
48
|
+
export { runDeckResponses as runDeckResponsesCore } from "@bolt-foundry/gambit-core";
|
|
49
|
+
/** Structured Responses runtime result. */
|
|
50
|
+
export type { StructuredRuntimeEffect, StructuredRuntimeResult, StructuredRuntimeStatus, } from "@bolt-foundry/gambit-core";
|
|
43
51
|
/** Signal for explicitly ending a Gambit run. */
|
|
44
52
|
export type { GambitEndSignal } from "@bolt-foundry/gambit-core";
|
|
45
53
|
/** OpenAI Chat Completions compatibility helper for a deck. */
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,yEAAyE;AACzE,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,oDAAoD;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,oCAAoC;AACpC,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,6BAA6B;AAC7B,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,6BAA6B;AAC7B,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,iCAAiC;AACjC,YAAY,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,yCAAyC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,oCAAoC;AACpC,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,uCAAuC;AACvC,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,2DAA2D;AAC3D,YAAY,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,yEAAyE;AACzE,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,oDAAoD;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,oCAAoC;AACpC,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACt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AA4C;AAC5C,YAAY,EACV,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -14,10 +14,16 @@ export { isGambitEndSignal } from "@bolt-foundry/gambit-core";
|
|
|
14
14
|
export { isRunCanceledError } from "@bolt-foundry/gambit-core";
|
|
15
15
|
/** Build a runtime with CLI-equivalent provider defaults and routing. */
|
|
16
16
|
export { createDefaultedRuntime } from "./src/default_runtime.js";
|
|
17
|
-
/**
|
|
17
|
+
/** Legacy compatibility wrapper with default provider/model/runtime behavior. */
|
|
18
18
|
export { runDeck } from "./src/default_runtime.js";
|
|
19
|
+
/** Run a deck with defaults and return the structured Responses result. */
|
|
20
|
+
export { runDeckResponses } from "./src/default_runtime.js";
|
|
21
|
+
/** Project assistant output text from Responses items for presentation. */
|
|
22
|
+
export { stringifyResponseOutput } from "@bolt-foundry/gambit-core";
|
|
19
23
|
/** Run a deck directly through gambit-core without gambit defaults. */
|
|
20
24
|
export { runDeck as runDeckCore } from "@bolt-foundry/gambit-core";
|
|
25
|
+
/** Run a deck directly through gambit-core and return structured Responses. */
|
|
26
|
+
export { runDeckResponses as runDeckResponsesCore } from "@bolt-foundry/gambit-core";
|
|
21
27
|
/** OpenAI Chat Completions compatibility helper for a deck. */
|
|
22
28
|
export { chatCompletionsWithDeck } from "./src/openai_compat.js";
|
|
23
29
|
/** Render a deck to a human-readable outline or debug view. */
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
declare const CODEX_APP_SERVER_DEBUG_ENV = "
|
|
1
|
+
declare const CODEX_APP_SERVER_DEBUG_ENV = "WORKLOOP_CHIEF_RUNTIME_DEBUG_CODEX_APP_SERVER";
|
|
2
|
+
declare const LEGACY_CODEX_APP_SERVER_DEBUG_ENV = "BOLT_FOUNDRY_DESKTOP_CHIEF_RUNTIME_DEBUG_CODEX_APP_SERVER";
|
|
2
3
|
type DebugValue = null | boolean | number | string | Array<DebugValue> | {
|
|
3
4
|
[key: string]: DebugValue;
|
|
4
5
|
};
|
|
5
6
|
export declare function shouldDebugCodexAppServer(): boolean;
|
|
6
7
|
export declare function logCodexAppServerDebug(event: string, details?: Record<string, unknown>): void;
|
|
7
8
|
export declare function summarizeCodexAppServerDebugValue(value: unknown): DebugValue;
|
|
8
|
-
export { CODEX_APP_SERVER_DEBUG_ENV };
|
|
9
|
+
export { CODEX_APP_SERVER_DEBUG_ENV, LEGACY_CODEX_APP_SERVER_DEBUG_ENV };
|
|
9
10
|
//# sourceMappingURL=codex_app_server_debug.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex_app_server_debug.d.ts","sourceRoot":"","sources":["../../src/src/codex_app_server_debug.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"codex_app_server_debug.d.ts","sourceRoot":"","sources":["../../src/src/codex_app_server_debug.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,0BAA0B,kDACiB,CAAC;AAClD,QAAA,MAAM,iCAAiC,8DACsB,CAAC;AAe9D,KAAK,UAAU,GACX,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,KAAK,CAAC,UAAU,CAAC,GACjB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC;AA+DlC,wBAAgB,yBAAyB,IAAI,OAAO,CAGnD;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI,CAIN;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAE5E;AAED,OAAO,EAAE,0BAA0B,EAAE,iCAAiC,EAAE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
const CODEX_APP_SERVER_DEBUG_ENV = "
|
|
2
|
+
const CODEX_APP_SERVER_DEBUG_ENV = "WORKLOOP_CHIEF_RUNTIME_DEBUG_CODEX_APP_SERVER";
|
|
3
|
+
const LEGACY_CODEX_APP_SERVER_DEBUG_ENV = "BOLT_FOUNDRY_DESKTOP_CHIEF_RUNTIME_DEBUG_CODEX_APP_SERVER";
|
|
3
4
|
const STRUCTURAL_STRING_KEYS = new Set([
|
|
4
5
|
"error",
|
|
5
6
|
"method",
|
|
@@ -58,7 +59,8 @@ function summarizeDebugValue(value, key, depth = 0) {
|
|
|
58
59
|
return summarized;
|
|
59
60
|
}
|
|
60
61
|
export function shouldDebugCodexAppServer() {
|
|
61
|
-
return parseTruthy(dntShim.Deno.env.get(CODEX_APP_SERVER_DEBUG_ENV))
|
|
62
|
+
return parseTruthy(dntShim.Deno.env.get(CODEX_APP_SERVER_DEBUG_ENV)) ||
|
|
63
|
+
parseTruthy(dntShim.Deno.env.get(LEGACY_CODEX_APP_SERVER_DEBUG_ENV));
|
|
62
64
|
}
|
|
63
65
|
export function logCodexAppServerDebug(event, details) {
|
|
64
66
|
if (!shouldDebugCodexAppServer())
|
|
@@ -69,4 +71,4 @@ export function logCodexAppServerDebug(event, details) {
|
|
|
69
71
|
export function summarizeCodexAppServerDebugValue(value) {
|
|
70
72
|
return summarizeDebugValue(value);
|
|
71
73
|
}
|
|
72
|
-
export { CODEX_APP_SERVER_DEBUG_ENV };
|
|
74
|
+
export { CODEX_APP_SERVER_DEBUG_ENV, LEGACY_CODEX_APP_SERVER_DEBUG_ENV };
|
package/esm/src/codex_auth.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare const CODEX_HOST_AUTH_BUNDLE_ENV = "
|
|
1
|
+
export declare const CODEX_HOST_AUTH_BUNDLE_ENV = "WORKLOOP_CODEX_AUTH_BUNDLE";
|
|
2
|
+
export declare const LEGACY_CODEX_HOST_AUTH_BUNDLE_ENV = "BOLT_FOUNDRY_DESKTOP_CODEX_AUTH_BUNDLE";
|
|
2
3
|
export type CodexChatgptAuthTokens = {
|
|
3
4
|
accessToken: string;
|
|
4
5
|
chatgptAccountId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex_auth.d.ts","sourceRoot":"","sources":["../../src/src/codex_auth.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"codex_auth.d.ts","sourceRoot":"","sources":["../../src/src/codex_auth.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AACvE,eAAO,MAAM,iCAAiC,2CACJ,CAAC;AAE3C,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAkFF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,sBAAsB,GAAG,IAAI,GAAG,SAAS,GAChD;IACD,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CASA;AAED,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,GACV,sBAAsB,CAuBxB;AAED,wBAAgB,uCAAuC,CACrD,GAAG,EAAE,MAAM,GACV,sBAAsB,CAuBxB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,sBAAsB,GAC7B,MAAM,CAER;AAED,wBAAgB,0BAA0B,IAAI,sBAAsB,GAAG,IAAI,CAK1E;AAED,wBAAsB,6BAA6B,CAAC,KAAK,EAAE;IACzD,MAAM,EAAE,sBAAsB,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAkDlC"}
|
package/esm/src/codex_auth.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
2
|
const CODEX_AUTH0_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
3
3
|
const CODEX_AUTH0_TOKEN_URL = "https://auth.openai.com/oauth/token";
|
|
4
|
-
export const CODEX_HOST_AUTH_BUNDLE_ENV = "
|
|
4
|
+
export const CODEX_HOST_AUTH_BUNDLE_ENV = "WORKLOOP_CODEX_AUTH_BUNDLE";
|
|
5
|
+
export const LEGACY_CODEX_HOST_AUTH_BUNDLE_ENV = "BOLT_FOUNDRY_DESKTOP_CODEX_AUTH_BUNDLE";
|
|
5
6
|
function normalizeNonEmptyString(value) {
|
|
6
7
|
return typeof value === "string" && value.trim().length > 0
|
|
7
8
|
? value.trim()
|
|
@@ -122,7 +123,8 @@ export function serializeCodexAuthBundle(bundle) {
|
|
|
122
123
|
return JSON.stringify(bundle);
|
|
123
124
|
}
|
|
124
125
|
export function readCodexAuthBundleFromEnv() {
|
|
125
|
-
const raw = dntShim.Deno.env.get(CODEX_HOST_AUTH_BUNDLE_ENV)?.trim()
|
|
126
|
+
const raw = dntShim.Deno.env.get(CODEX_HOST_AUTH_BUNDLE_ENV)?.trim() ||
|
|
127
|
+
dntShim.Deno.env.get(LEGACY_CODEX_HOST_AUTH_BUNDLE_ENV)?.trim();
|
|
126
128
|
if (!raw)
|
|
127
129
|
return null;
|
|
128
130
|
return parseCodexAuthBundle(raw);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { runDeck as runDeckCore } from "@bolt-foundry/gambit-core";
|
|
2
|
-
import type { ModelProvider } from "@bolt-foundry/gambit-core";
|
|
2
|
+
import type { ModelProvider, ModelResolver, StructuredRuntimeResult } from "@bolt-foundry/gambit-core";
|
|
3
3
|
import { type LoadedProjectConfig, type ModelAliasResolver } from "./project_config.js";
|
|
4
4
|
import { type ProviderKey } from "./providers/router.js";
|
|
5
5
|
export type SessionArtifactsConfig = {
|
|
@@ -21,6 +21,7 @@ export type CreateDefaultedRuntimeOptions = {
|
|
|
21
21
|
configHint?: string;
|
|
22
22
|
projectConfig?: LoadedProjectConfig | null;
|
|
23
23
|
modelProvider?: ModelProvider;
|
|
24
|
+
modelResolver?: ModelResolver;
|
|
24
25
|
defaultModel?: string;
|
|
25
26
|
modelOverride?: string;
|
|
26
27
|
responsesMode?: boolean;
|
|
@@ -34,12 +35,14 @@ export type DefaultedRuntime = {
|
|
|
34
35
|
configuredFallbackProvider: ProviderKey | null | undefined;
|
|
35
36
|
effectiveFallbackProvider: ProviderKey | null;
|
|
36
37
|
modelProvider: ModelProvider;
|
|
38
|
+
modelResolver: ModelResolver;
|
|
37
39
|
defaultModel?: string;
|
|
38
40
|
modelOverride?: string;
|
|
39
41
|
responsesMode: boolean;
|
|
40
42
|
sessionArtifacts?: SessionArtifactsConfig;
|
|
41
43
|
resolveRunOptions: (opts: DefaultedRuntimeRunOptions) => CoreRunDeckOptions;
|
|
42
44
|
runDeck: (opts: DefaultedRuntimeRunOptions) => Promise<unknown>;
|
|
45
|
+
runDeckResponses: (opts: DefaultedRuntimeRunOptions) => Promise<StructuredRuntimeResult>;
|
|
43
46
|
};
|
|
44
47
|
export type RunDeckWithDefaultsOptions = DefaultedRuntimeRunOptions & {
|
|
45
48
|
runtime?: DefaultedRuntime;
|
|
@@ -47,5 +50,6 @@ export type RunDeckWithDefaultsOptions = DefaultedRuntimeRunOptions & {
|
|
|
47
50
|
};
|
|
48
51
|
export declare function createDefaultedRuntime(opts?: CreateDefaultedRuntimeOptions): Promise<DefaultedRuntime>;
|
|
49
52
|
export declare function runDeck(opts: RunDeckWithDefaultsOptions): Promise<unknown>;
|
|
53
|
+
export declare function runDeckResponses(opts: RunDeckWithDefaultsOptions): Promise<StructuredRuntimeResult>;
|
|
50
54
|
export {};
|
|
51
55
|
//# sourceMappingURL=default_runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default_runtime.d.ts","sourceRoot":"","sources":["../../src/src/default_runtime.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"default_runtime.d.ts","sourceRoot":"","sources":["../../src/src/default_runtime.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,IAAI,WAAW,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAEV,aAAa,EACb,aAAa,EAGb,uBAAuB,EACxB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAGL,KAAK,mBAAmB,EAExB,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAG/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAIF,KAAK,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAoBxC,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAG5D,MAAM,MAAM,0BAA0B,GAClC,IAAI,CACJ,kBAAkB,EAChB,eAAe,GACf,cAAc,GACd,eAAe,GACf,eAAe,CAClB,GACC;IACA,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,E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,gBAAgB,CAAC;IAC3B,cAAc,CAAC,EAAE,6BAA6B,CAAC;CAChD,CAAC;AAgYF,wBAAsB,sBAAsB,CAC1C,IAAI,GAAE,6BAAkC,GACvC,OAAO,CAAC,gBAAgB,CAAC,CAqF3B;AAED,wBAAsB,OAAO,CAC3B,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,OAAO,CAAC,CAclB;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,uBAAuB,CAAC,CAclC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { runDeck as runDeckCore } from "@bolt-foundry/gambit-core";
|
|
2
|
+
import { runDeck as runDeckCore, runDeckResponses as runDeckResponsesCore, } from "@bolt-foundry/gambit-core";
|
|
3
3
|
import { createProviderMatchers } from "./model_matchers.js";
|
|
4
4
|
import { createModelAliasResolver, loadProjectConfig, } from "./project_config.js";
|
|
5
5
|
import { CODEX_PREFIX, createCodexProvider } from "./providers/codex.js";
|
|
@@ -15,6 +15,12 @@ function mergeParams(aliasParams, baseParams) {
|
|
|
15
15
|
}
|
|
16
16
|
return baseParams ?? aliasParams;
|
|
17
17
|
}
|
|
18
|
+
const passthroughModelResolver = {
|
|
19
|
+
resolveModel: (input) => Promise.resolve({
|
|
20
|
+
model: Array.isArray(input.model) ? input.model[0] ?? "" : input.model,
|
|
21
|
+
params: input.params,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
18
24
|
function parseFallbackProviderFromConfig(fallbackProviderRaw, logger) {
|
|
19
25
|
if (typeof fallbackProviderRaw !== "string") {
|
|
20
26
|
return undefined;
|
|
@@ -53,7 +59,7 @@ function resolveSessionArtifactsConfig(opts) {
|
|
|
53
59
|
return undefined;
|
|
54
60
|
throw new Error("sessionArtifacts persistence has been removed. Use sqlite-backed workspace flows instead.");
|
|
55
61
|
}
|
|
56
|
-
function
|
|
62
|
+
function buildDefaultModelProviderAndResolver(opts) {
|
|
57
63
|
const openRouterApiKey = dntShim.Deno.env.get("OPENROUTER_API_KEY")?.trim();
|
|
58
64
|
const googleApiKey = (dntShim.Deno.env.get("GOOGLE_API_KEY") ??
|
|
59
65
|
dntShim.Deno.env.get("GEMINI_API_KEY"))?.trim();
|
|
@@ -277,8 +283,10 @@ function buildDefaultModelProvider(opts) {
|
|
|
277
283
|
const resolution = opts.modelAliasResolver(model);
|
|
278
284
|
return Boolean(resolution.applied || resolution.missingAlias);
|
|
279
285
|
};
|
|
280
|
-
|
|
286
|
+
const modelResolver = {
|
|
281
287
|
resolveModel: async (input) => await resolveModelSelection(input.model, input.params, input.deckPath),
|
|
288
|
+
};
|
|
289
|
+
const modelProvider = {
|
|
282
290
|
responses: async (input) => {
|
|
283
291
|
const applied = shouldResolveModel(input.request.model)
|
|
284
292
|
? await resolveModelSelection(input.request.model, input.request.params, input.deckPath)
|
|
@@ -304,25 +312,8 @@ function buildDefaultModelProvider(opts) {
|
|
|
304
312
|
},
|
|
305
313
|
});
|
|
306
314
|
},
|
|
307
|
-
chat: async (input) => {
|
|
308
|
-
const applied = shouldResolveModel(input.model)
|
|
309
|
-
? await resolveModelSelection(input.model, input.params, input.deckPath)
|
|
310
|
-
: { model: input.model, params: input.params };
|
|
311
|
-
const request = {
|
|
312
|
-
...input,
|
|
313
|
-
model: applied.model ?? input.model,
|
|
314
|
-
params: applied.params,
|
|
315
|
-
};
|
|
316
|
-
if (typeof request.model !== "string" || !request.model) {
|
|
317
|
-
throw new Error("Model is required.");
|
|
318
|
-
}
|
|
319
|
-
const selection = providerRouter.resolve({ model: request.model });
|
|
320
|
-
return await selection.provider.chat({
|
|
321
|
-
...request,
|
|
322
|
-
model: selection.model,
|
|
323
|
-
});
|
|
324
|
-
},
|
|
325
315
|
};
|
|
316
|
+
return { modelProvider, modelResolver };
|
|
326
317
|
}
|
|
327
318
|
export async function createDefaultedRuntime(opts = {}) {
|
|
328
319
|
const logger = opts.logger ?? console;
|
|
@@ -339,14 +330,16 @@ export async function createDefaultedRuntime(opts = {}) {
|
|
|
339
330
|
? "openrouter"
|
|
340
331
|
: configuredFallbackProvider;
|
|
341
332
|
const responsesMode = opts.responsesMode ?? resolveDefaultResponsesMode();
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
333
|
+
const defaults = buildDefaultModelProviderAndResolver({
|
|
334
|
+
modelAliasResolver,
|
|
335
|
+
configuredFallbackProvider,
|
|
336
|
+
effectiveFallbackProvider,
|
|
337
|
+
responsesMode,
|
|
338
|
+
logger,
|
|
339
|
+
});
|
|
340
|
+
const modelProvider = opts.modelProvider ?? defaults.modelProvider;
|
|
341
|
+
const modelResolver = opts.modelResolver ??
|
|
342
|
+
(opts.modelProvider ? passthroughModelResolver : defaults.modelResolver);
|
|
350
343
|
const defaultModel = opts.defaultModel;
|
|
351
344
|
const modelOverride = opts.modelOverride;
|
|
352
345
|
const runtimeSessionArtifacts = opts.sessionArtifacts;
|
|
@@ -355,6 +348,8 @@ export async function createDefaultedRuntime(opts = {}) {
|
|
|
355
348
|
return {
|
|
356
349
|
...coreRunOpts,
|
|
357
350
|
modelProvider: runOpts.modelProvider ?? modelProvider,
|
|
351
|
+
modelResolver: runOpts.modelResolver ??
|
|
352
|
+
(runOpts.modelProvider ? undefined : modelResolver),
|
|
358
353
|
defaultModel: runOpts.defaultModel ?? defaultModel,
|
|
359
354
|
modelOverride: runOpts.modelOverride ?? modelOverride,
|
|
360
355
|
responsesMode: runOpts.responsesMode ?? responsesMode,
|
|
@@ -366,6 +361,7 @@ export async function createDefaultedRuntime(opts = {}) {
|
|
|
366
361
|
configuredFallbackProvider,
|
|
367
362
|
effectiveFallbackProvider,
|
|
368
363
|
modelProvider,
|
|
364
|
+
modelResolver,
|
|
369
365
|
defaultModel,
|
|
370
366
|
modelOverride,
|
|
371
367
|
responsesMode,
|
|
@@ -382,6 +378,17 @@ export async function createDefaultedRuntime(opts = {}) {
|
|
|
382
378
|
}
|
|
383
379
|
throw new Error("sessionArtifacts persistence has been removed. Use sqlite-backed workspace flows instead.");
|
|
384
380
|
},
|
|
381
|
+
runDeckResponses: async (runOpts) => {
|
|
382
|
+
const resolved = resolveRunOptions(runOpts);
|
|
383
|
+
const effectiveSessionArtifacts = resolveSessionArtifactsConfig({
|
|
384
|
+
runtimeConfig: runtimeSessionArtifacts,
|
|
385
|
+
runConfig: runOpts.sessionArtifacts,
|
|
386
|
+
});
|
|
387
|
+
if (!effectiveSessionArtifacts) {
|
|
388
|
+
return await runDeckResponsesCore(resolved);
|
|
389
|
+
}
|
|
390
|
+
throw new Error("sessionArtifacts persistence has been removed. Use sqlite-backed workspace flows instead.");
|
|
391
|
+
},
|
|
385
392
|
};
|
|
386
393
|
}
|
|
387
394
|
export async function runDeck(opts) {
|
|
@@ -396,3 +403,15 @@ export async function runDeck(opts) {
|
|
|
396
403
|
const { runtime: _runtime, runtimeOptions: _runtimeOptions, ...runOpts } = opts;
|
|
397
404
|
return await runtime.runDeck(runOpts);
|
|
398
405
|
}
|
|
406
|
+
export async function runDeckResponses(opts) {
|
|
407
|
+
if (opts.runtime && opts.runtimeOptions) {
|
|
408
|
+
throw new Error("runDeckResponses received both runtime and runtimeOptions. Pass only one.");
|
|
409
|
+
}
|
|
410
|
+
const runtime = opts.runtime ??
|
|
411
|
+
await createDefaultedRuntime({
|
|
412
|
+
...opts.runtimeOptions,
|
|
413
|
+
configHint: opts.runtimeOptions?.configHint ?? opts.path,
|
|
414
|
+
});
|
|
415
|
+
const { runtime: _runtime, runtimeOptions: _runtimeOptions, ...runOpts } = opts;
|
|
416
|
+
return await runtime.runDeckResponses(runOpts);
|
|
417
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai_compat.d.ts","sourceRoot":"","sources":["../../src/src/openai_compat.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"openai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1E,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAoNnC"}
|
package/esm/src/openai_compat.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
2
|
import * as path from "../deps/jsr.io/@std/path/1.1.4/mod.js";
|
|
3
|
-
import { assertZodSchema, DEFAULT_GUARDRAILS, loadDeck, RESERVED_TOOL_PREFIX, resolveEffectivePermissions,
|
|
3
|
+
import { assertZodSchema, DEFAULT_GUARDRAILS, joinTextParts, loadDeck, RESERVED_TOOL_PREFIX, resolveEffectivePermissions, runDeckResponses, stringifyResponseOutput, toJsonSchema, } from "@bolt-foundry/gambit-core";
|
|
4
4
|
export const logger = console;
|
|
5
5
|
function randomId(prefix) {
|
|
6
6
|
const suffix = crypto.randomUUID().replace(/-/g, "").slice(0, 24);
|
|
@@ -13,9 +13,9 @@ function normalizeContent(content) {
|
|
|
13
13
|
return content;
|
|
14
14
|
if (!Array.isArray(content))
|
|
15
15
|
return String(content);
|
|
16
|
-
return content
|
|
16
|
+
return joinTextParts(content
|
|
17
17
|
.map((c) => (typeof c === "string" ? c : (c.text ?? "")))
|
|
18
|
-
.
|
|
18
|
+
.filter(Boolean));
|
|
19
19
|
}
|
|
20
20
|
function normalizeMessages(input) {
|
|
21
21
|
return input.map((m) => ({
|
|
@@ -28,6 +28,88 @@ function normalizeMessages(input) {
|
|
|
28
28
|
: undefined,
|
|
29
29
|
}));
|
|
30
30
|
}
|
|
31
|
+
function responseItemsFromMessages(messages) {
|
|
32
|
+
return messages.flatMap((message) => {
|
|
33
|
+
if (message.role === "tool") {
|
|
34
|
+
return [{
|
|
35
|
+
type: "function_call_output",
|
|
36
|
+
call_id: message.tool_call_id ?? randomId("tool"),
|
|
37
|
+
output: message.content ?? "",
|
|
38
|
+
}];
|
|
39
|
+
}
|
|
40
|
+
const items = [];
|
|
41
|
+
if (message.content) {
|
|
42
|
+
items.push({
|
|
43
|
+
type: "message",
|
|
44
|
+
role: message.role,
|
|
45
|
+
content: [{
|
|
46
|
+
type: message.role === "assistant" ? "output_text" : "input_text",
|
|
47
|
+
text: message.content,
|
|
48
|
+
}],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (message.role === "assistant" && message.tool_calls?.length) {
|
|
52
|
+
for (const toolCall of message.tool_calls) {
|
|
53
|
+
items.push({
|
|
54
|
+
type: "function_call",
|
|
55
|
+
call_id: toolCall.id,
|
|
56
|
+
name: toolCall.function.name,
|
|
57
|
+
arguments: toolCall.function.arguments,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (items.length)
|
|
62
|
+
return items;
|
|
63
|
+
return {
|
|
64
|
+
type: "message",
|
|
65
|
+
role: message.role,
|
|
66
|
+
content: [],
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function responseOutputToChatResult(output) {
|
|
71
|
+
const textParts = [];
|
|
72
|
+
const toolCalls = [];
|
|
73
|
+
for (const item of output) {
|
|
74
|
+
if (item.type === "message" && item.role === "assistant") {
|
|
75
|
+
for (const part of item.content) {
|
|
76
|
+
if (part.type === "output_text" || part.type === "summary_text" ||
|
|
77
|
+
part.type === "reasoning_text") {
|
|
78
|
+
textParts.push(part.text);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (item.type === "function_call") {
|
|
83
|
+
let args = {};
|
|
84
|
+
try {
|
|
85
|
+
const parsed = JSON.parse(item.arguments || "{}");
|
|
86
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
87
|
+
args = parsed;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
args = {};
|
|
92
|
+
}
|
|
93
|
+
toolCalls.push({ id: item.call_id, name: item.name, args });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const message = {
|
|
97
|
+
role: "assistant",
|
|
98
|
+
content: textParts.length ? joinTextParts(textParts) : null,
|
|
99
|
+
tool_calls: toolCalls.length
|
|
100
|
+
? toolCalls.map((call) => ({
|
|
101
|
+
id: call.id,
|
|
102
|
+
type: "function",
|
|
103
|
+
function: { name: call.name, arguments: JSON.stringify(call.args) },
|
|
104
|
+
}))
|
|
105
|
+
: undefined,
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
message,
|
|
109
|
+
finishReason: toolCalls.length ? "tool_calls" : "stop",
|
|
110
|
+
toolCalls: toolCalls.length ? toolCalls : undefined,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
31
113
|
function providerParamsFromRequest(req) {
|
|
32
114
|
const out = {};
|
|
33
115
|
if (req.temperature !== undefined)
|
|
@@ -131,6 +213,14 @@ function warnIfSystemMismatch(args) {
|
|
|
131
213
|
logger.warn(`[gambit] chatCompletionsWithDeck: request includes a system message that does not match the deck prompt (${args.deckPath})`);
|
|
132
214
|
}
|
|
133
215
|
function toolResultContent(result) {
|
|
216
|
+
if (result && typeof result === "object" &&
|
|
217
|
+
"legacyResult" in result &&
|
|
218
|
+
"output" in result) {
|
|
219
|
+
const text = stringifyResponseOutput(result.output);
|
|
220
|
+
if (text)
|
|
221
|
+
return text;
|
|
222
|
+
return toolResultContent(result.legacyResult);
|
|
223
|
+
}
|
|
134
224
|
if (typeof result === "string")
|
|
135
225
|
return result;
|
|
136
226
|
try {
|
|
@@ -203,15 +293,25 @@ export async function chatCompletionsWithDeck(args) {
|
|
|
203
293
|
(() => {
|
|
204
294
|
throw new Error("No model provided");
|
|
205
295
|
})();
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
296
|
+
const response = await args.modelProvider.responses({
|
|
297
|
+
request: {
|
|
298
|
+
model,
|
|
299
|
+
input: responseItemsFromMessages(messages),
|
|
300
|
+
tools: tools.length ? tools : undefined,
|
|
301
|
+
stream: Boolean(args.request.stream),
|
|
302
|
+
params: providerParamsFromRequest(args.request),
|
|
303
|
+
},
|
|
211
304
|
deckPath: deck.path,
|
|
212
|
-
|
|
213
|
-
|
|
305
|
+
onStreamEvent: (event) => {
|
|
306
|
+
if (event.type === "response.output_text.delta") {
|
|
307
|
+
args.onStreamText?.(event.delta);
|
|
308
|
+
}
|
|
309
|
+
},
|
|
214
310
|
});
|
|
311
|
+
const result = {
|
|
312
|
+
...responseOutputToChatResult(response.output),
|
|
313
|
+
usage: response.usage,
|
|
314
|
+
};
|
|
215
315
|
messages.push(result.message);
|
|
216
316
|
if (result.toolCalls && result.toolCalls.length > 0) {
|
|
217
317
|
const gambitCalls = result.toolCalls.filter((c) => gambit.toolNameSet.has(c.name));
|
|
@@ -259,7 +359,7 @@ export async function chatCompletionsWithDeck(args) {
|
|
|
259
359
|
type: "openai_compat.action.permissions",
|
|
260
360
|
permissions: actionPermissions.trace,
|
|
261
361
|
});
|
|
262
|
-
const childResult = await
|
|
362
|
+
const childResult = await runDeckResponses({
|
|
263
363
|
path: actionPath,
|
|
264
364
|
input: call.args,
|
|
265
365
|
modelProvider: args.modelProvider,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude_code.d.ts","sourceRoot":"","sources":["../../../src/src/providers/claude_code.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,YAAY,EACZ,aAAa,EAKb,UAAU,EACX,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"claude_code.d.ts","sourceRoot":"","sources":["../../../src/src/providers/claude_code.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,YAAY,EACZ,aAAa,EAKb,UAAU,EACX,MAAM,2BAA2B,CAAC;AAGnC,eAAO,MAAM,kBAAkB,qBAAqB,CAAC;AACrD,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAMnD,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;A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