@bolt-foundry/gambit 0.8.6 → 1.0.0-rc.2
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 +54 -2
- package/README.md +165 -50
- 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 +1 -1
- package/esm/src/codex_app_server_debug.d.ts.map +1 -1
- package/esm/src/codex_app_server_debug.js +1 -1
- package/esm/src/codex_auth.d.ts +1 -1
- package/esm/src/codex_auth.d.ts.map +1 -1
- package/esm/src/codex_auth.js +1 -1
- 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 +12 -1
- package/esm/src/providers/codex.d.ts.map +1 -1
- package/esm/src/providers/codex.js +94 -30
- 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 +1 -1
- package/script/src/codex_app_server_debug.d.ts.map +1 -1
- package/script/src/codex_app_server_debug.js +1 -1
- package/script/src/codex_auth.d.ts +1 -1
- package/script/src/codex_auth.d.ts.map +1 -1
- package/script/src/codex_auth.js +1 -1
- 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 +12 -1
- package/script/src/providers/codex.d.ts.map +1 -1
- package/script/src/providers/codex.js +94 -29
- 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
|
@@ -8,35 +8,6 @@ function normalizeOpenRouterModel(model) {
|
|
|
8
8
|
? model.slice(OPENROUTER_PREFIX.length)
|
|
9
9
|
: model;
|
|
10
10
|
}
|
|
11
|
-
function normalizeMessage(content) {
|
|
12
|
-
const toolCalls = content.tool_calls ??
|
|
13
|
-
undefined;
|
|
14
|
-
return {
|
|
15
|
-
role: content.role,
|
|
16
|
-
content: typeof content.content === "string"
|
|
17
|
-
? content.content
|
|
18
|
-
: Array.isArray(content.content)
|
|
19
|
-
? content.content
|
|
20
|
-
.map((c) => (typeof c === "string" ? c : ""))
|
|
21
|
-
.join("")
|
|
22
|
-
: "",
|
|
23
|
-
name: content.name,
|
|
24
|
-
tool_call_id: content.tool_call_id,
|
|
25
|
-
tool_calls: toolCalls && toolCalls.length > 0 ? toolCalls : undefined,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function safeJson(input) {
|
|
29
|
-
try {
|
|
30
|
-
const parsed = JSON.parse(input);
|
|
31
|
-
if (parsed && typeof parsed === "object") {
|
|
32
|
-
return parsed;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
// fall through
|
|
37
|
-
}
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
11
|
function toJsonValue(value) {
|
|
41
12
|
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
42
13
|
return value;
|
|
@@ -424,86 +395,6 @@ function toOpenAIInputItems(items) {
|
|
|
424
395
|
}
|
|
425
396
|
return mapped;
|
|
426
397
|
}
|
|
427
|
-
function chatMessagesToResponseItems(messages) {
|
|
428
|
-
const items = [];
|
|
429
|
-
for (const message of messages) {
|
|
430
|
-
if (message.role === "tool") {
|
|
431
|
-
if (message.tool_call_id &&
|
|
432
|
-
typeof message.content === "string") {
|
|
433
|
-
items.push({
|
|
434
|
-
type: "function_call_output",
|
|
435
|
-
call_id: message.tool_call_id,
|
|
436
|
-
output: message.content,
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
if (message.role === "system" || message.role === "user" ||
|
|
442
|
-
message.role === "assistant") {
|
|
443
|
-
const content = [];
|
|
444
|
-
if (typeof message.content === "string" && message.content.length > 0) {
|
|
445
|
-
content.push({
|
|
446
|
-
type: message.role === "assistant" ? "output_text" : "input_text",
|
|
447
|
-
text: message.content,
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
if (content.length > 0) {
|
|
451
|
-
items.push({
|
|
452
|
-
type: "message",
|
|
453
|
-
role: message.role,
|
|
454
|
-
content,
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
if (message.role === "assistant" && message.tool_calls) {
|
|
459
|
-
for (const call of message.tool_calls) {
|
|
460
|
-
items.push({
|
|
461
|
-
type: "function_call",
|
|
462
|
-
call_id: call.id,
|
|
463
|
-
name: call.function.name,
|
|
464
|
-
arguments: call.function.arguments,
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
return items;
|
|
470
|
-
}
|
|
471
|
-
function responseItemsToChat(items) {
|
|
472
|
-
const textParts = [];
|
|
473
|
-
const toolCalls = [];
|
|
474
|
-
const messageToolCalls = [];
|
|
475
|
-
for (const item of items) {
|
|
476
|
-
if (item.type === "message" && item.role === "assistant") {
|
|
477
|
-
for (const part of item.content) {
|
|
478
|
-
if (part.type === "output_text") {
|
|
479
|
-
textParts.push(part.text);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
if (item.type === "function_call") {
|
|
484
|
-
toolCalls.push({
|
|
485
|
-
id: item.call_id,
|
|
486
|
-
name: item.name,
|
|
487
|
-
args: safeJson(item.arguments),
|
|
488
|
-
});
|
|
489
|
-
messageToolCalls.push({
|
|
490
|
-
id: item.call_id,
|
|
491
|
-
type: "function",
|
|
492
|
-
function: { name: item.name, arguments: item.arguments },
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
const content = textParts.length > 0 ? textParts.join("") : null;
|
|
497
|
-
const message = {
|
|
498
|
-
role: "assistant",
|
|
499
|
-
content,
|
|
500
|
-
tool_calls: messageToolCalls.length > 0 ? messageToolCalls : undefined,
|
|
501
|
-
};
|
|
502
|
-
return {
|
|
503
|
-
message,
|
|
504
|
-
toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
398
|
async function createResponse(client, request, signal, onStreamEvent) {
|
|
508
399
|
const baseParams = {
|
|
509
400
|
model: normalizeOpenRouterModel(request.model),
|
|
@@ -738,7 +629,6 @@ async function createResponse(client, request, signal, onStreamEvent) {
|
|
|
738
629
|
return normalizeOpenAIResponse(responseOrStream);
|
|
739
630
|
}
|
|
740
631
|
export function createOpenRouterProvider(opts) {
|
|
741
|
-
const debugStream = dntShim.Deno.env.get("GAMBIT_DEBUG_STREAM") === "1";
|
|
742
632
|
const client = (opts.client ??
|
|
743
633
|
new OpenAI({
|
|
744
634
|
apiKey: opts.apiKey,
|
|
@@ -752,159 +642,5 @@ export function createOpenRouterProvider(opts) {
|
|
|
752
642
|
async responses(input) {
|
|
753
643
|
return await createResponse(client, input.request, input.signal, input.onStreamEvent);
|
|
754
644
|
},
|
|
755
|
-
async chat(input) {
|
|
756
|
-
const params = input.params ?? {};
|
|
757
|
-
if (opts.enableResponses) {
|
|
758
|
-
const response = await createResponse(client, {
|
|
759
|
-
model: normalizeOpenRouterModel(input.model),
|
|
760
|
-
input: chatMessagesToResponseItems(input.messages),
|
|
761
|
-
tools: input.tools,
|
|
762
|
-
stream: input.stream,
|
|
763
|
-
params,
|
|
764
|
-
}, input.signal, (event) => {
|
|
765
|
-
if (event.type === "response.output_text.delta") {
|
|
766
|
-
input.onStreamText?.(event.delta);
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
const mapped = responseItemsToChat(response.output);
|
|
770
|
-
return {
|
|
771
|
-
message: mapped.message,
|
|
772
|
-
finishReason: mapped.toolCalls ? "tool_calls" : "stop",
|
|
773
|
-
toolCalls: mapped.toolCalls,
|
|
774
|
-
usage: response.usage,
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
if (input.stream) {
|
|
778
|
-
if (debugStream) {
|
|
779
|
-
logger.log(`[stream-debug] requesting stream model=${input.model} messages=${input.messages.length} tools=${input.tools?.length ?? 0}`);
|
|
780
|
-
}
|
|
781
|
-
const stream = await client.chat.completions.create({
|
|
782
|
-
model: normalizeOpenRouterModel(input.model),
|
|
783
|
-
messages: input
|
|
784
|
-
.messages,
|
|
785
|
-
tools: input
|
|
786
|
-
// this predates the lint rule
|
|
787
|
-
.tools,
|
|
788
|
-
tool_choice: "auto",
|
|
789
|
-
stream: true,
|
|
790
|
-
...params,
|
|
791
|
-
}, input.signal ? { signal: input.signal } : undefined);
|
|
792
|
-
let finishReason = null;
|
|
793
|
-
const contentParts = [];
|
|
794
|
-
const toolCallMap = new Map();
|
|
795
|
-
let chunkCount = 0;
|
|
796
|
-
let streamedChars = 0;
|
|
797
|
-
for await (const chunk of stream) {
|
|
798
|
-
chunkCount++;
|
|
799
|
-
const choice = chunk.choices[0];
|
|
800
|
-
const fr = choice.finish_reason;
|
|
801
|
-
if (fr === "stop" || fr === "tool_calls" || fr === "length" ||
|
|
802
|
-
fr === null) {
|
|
803
|
-
finishReason = fr ?? finishReason;
|
|
804
|
-
}
|
|
805
|
-
const delta = choice.delta;
|
|
806
|
-
if (typeof delta.content === "string") {
|
|
807
|
-
contentParts.push(delta.content);
|
|
808
|
-
input.onStreamText?.(delta.content);
|
|
809
|
-
streamedChars += delta.content.length;
|
|
810
|
-
}
|
|
811
|
-
else if (Array.isArray(delta.content)) {
|
|
812
|
-
const chunkStr = delta.content
|
|
813
|
-
.map((c) => (typeof c === "string" ? c : ""))
|
|
814
|
-
.join("");
|
|
815
|
-
if (chunkStr) {
|
|
816
|
-
contentParts.push(chunkStr);
|
|
817
|
-
input.onStreamText?.(chunkStr);
|
|
818
|
-
streamedChars += chunkStr.length;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
for (const tc of delta.tool_calls ?? []) {
|
|
822
|
-
const idx = tc.index ?? 0;
|
|
823
|
-
const existing = toolCallMap.get(idx) ??
|
|
824
|
-
{
|
|
825
|
-
id: tc.id,
|
|
826
|
-
function: { name: tc.function?.name, arguments: "" },
|
|
827
|
-
};
|
|
828
|
-
if (tc.id)
|
|
829
|
-
existing.id = tc.id;
|
|
830
|
-
if (tc.function?.name)
|
|
831
|
-
existing.function.name = tc.function.name;
|
|
832
|
-
if (tc.function?.arguments) {
|
|
833
|
-
existing.function.arguments += tc.function.arguments;
|
|
834
|
-
}
|
|
835
|
-
toolCallMap.set(idx, existing);
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
if (debugStream) {
|
|
839
|
-
logger.log(`[stream-debug] completed stream chunks=${chunkCount} streamedChars=${streamedChars} finishReason=${finishReason}`);
|
|
840
|
-
}
|
|
841
|
-
const tool_calls = Array.from(toolCallMap.values()).map((tc) => ({
|
|
842
|
-
id: tc.id ?? crypto.randomUUID().replace(/-/g, "").slice(0, 24),
|
|
843
|
-
type: "function",
|
|
844
|
-
function: {
|
|
845
|
-
name: tc.function.name ?? "",
|
|
846
|
-
arguments: tc.function.arguments,
|
|
847
|
-
},
|
|
848
|
-
}));
|
|
849
|
-
const message = normalizeMessage({
|
|
850
|
-
role: "assistant",
|
|
851
|
-
content: contentParts.length ? contentParts.join("") : null,
|
|
852
|
-
tool_calls,
|
|
853
|
-
});
|
|
854
|
-
const toolCalls = tool_calls.length > 0
|
|
855
|
-
? tool_calls.map((tc) => ({
|
|
856
|
-
id: tc.id,
|
|
857
|
-
name: tc.function.name,
|
|
858
|
-
args: safeJson(tc.function.arguments),
|
|
859
|
-
}))
|
|
860
|
-
: undefined;
|
|
861
|
-
return {
|
|
862
|
-
message,
|
|
863
|
-
finishReason: finishReason ?? "stop",
|
|
864
|
-
toolCalls,
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
const response = await client.chat.completions.create({
|
|
868
|
-
model: normalizeOpenRouterModel(input.model),
|
|
869
|
-
messages: input
|
|
870
|
-
// this predates the lint rule
|
|
871
|
-
.messages,
|
|
872
|
-
tools: input
|
|
873
|
-
// this predates the lint rule
|
|
874
|
-
.tools,
|
|
875
|
-
tool_choice: "auto",
|
|
876
|
-
stream: false,
|
|
877
|
-
...params,
|
|
878
|
-
}, input.signal ? { signal: input.signal } : undefined);
|
|
879
|
-
const choice = response.choices[0];
|
|
880
|
-
const message = choice.message;
|
|
881
|
-
const normalizedMessage = normalizeMessage(message);
|
|
882
|
-
const toolCalls = message.tool_calls?.map((tc) => ({
|
|
883
|
-
id: tc.id,
|
|
884
|
-
name: tc.function.name,
|
|
885
|
-
args: safeJson(tc.function.arguments),
|
|
886
|
-
}));
|
|
887
|
-
return {
|
|
888
|
-
message: normalizedMessage,
|
|
889
|
-
finishReason: (choice.finish_reason ?? "stop"),
|
|
890
|
-
toolCalls,
|
|
891
|
-
usage: response.usage
|
|
892
|
-
? (() => {
|
|
893
|
-
const usage = {
|
|
894
|
-
promptTokens: response.usage.prompt_tokens ?? 0,
|
|
895
|
-
completionTokens: response.usage.completion_tokens ?? 0,
|
|
896
|
-
totalTokens: response.usage.total_tokens ?? 0,
|
|
897
|
-
};
|
|
898
|
-
const details = response.usage;
|
|
899
|
-
const value = details.completion_tokens_details
|
|
900
|
-
?.reasoning_tokens ??
|
|
901
|
-
details.output_tokens_details?.reasoning_tokens;
|
|
902
|
-
return typeof value === "number"
|
|
903
|
-
? { ...usage, reasoningTokens: value }
|
|
904
|
-
: usage;
|
|
905
|
-
})()
|
|
906
|
-
: undefined,
|
|
907
|
-
};
|
|
908
|
-
},
|
|
909
645
|
};
|
|
910
646
|
}
|
|
@@ -16,7 +16,7 @@ export function providerAuthUsesRuntimeEnvPlaceholders(requirements) {
|
|
|
16
16
|
requirements.auth.attachmentAuthority === "runtime-env-placeholder";
|
|
17
17
|
}
|
|
18
18
|
export function providerAuthUsesMitmRequestTimeAttachment(requirements) {
|
|
19
|
-
return requirements.auth.attachmentAuthority === "
|
|
19
|
+
return requirements.auth.attachmentAuthority === "workloop-mitm";
|
|
20
20
|
}
|
|
21
21
|
export function resolveProviderRequirements(input) {
|
|
22
22
|
const identity = resolveProviderIdentity(input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolt-foundry/gambit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "Agent harness framework for building, running, and verifying LLM workflows in Markdown and code.",
|
|
5
5
|
"homepage": "https://github.com/bolt-foundry/gambit",
|
|
6
6
|
"repository": {
|
package/script/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/script/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;AACtE,6BAA6B;AAC7B,YAAY,EAAE,cAAc,EAAE,MA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B,GACtB,MAAM,6BAA6B,CAAC"}
|
package/script/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProviderRegistryEntries = exports.getProviderManifests = exports.getProviderManifest = exports.resolveProviderRequirements = exports.getProviderRequirements = exports.createClaudeCodeProvider = exports.createGoogleProvider = exports.createOllamaProvider = exports.createOpenRouterProvider = exports.renderDeck = exports.chatCompletionsWithDeck = exports.runDeckCore = exports.runDeck = exports.createDefaultedRuntime = exports.isRunCanceledError = exports.isGambitEndSignal = exports.defineDeck = exports.defineCard = void 0;
|
|
3
|
+
exports.getProviderRegistryEntries = exports.getProviderManifests = exports.getProviderManifest = exports.resolveProviderRequirements = exports.getProviderRequirements = exports.createClaudeCodeProvider = exports.createGoogleProvider = exports.createOllamaProvider = exports.createOpenRouterProvider = exports.renderDeck = exports.chatCompletionsWithDeck = exports.runDeckResponsesCore = exports.runDeckCore = exports.stringifyResponseOutput = exports.runDeckResponses = exports.runDeck = exports.createDefaultedRuntime = exports.isRunCanceledError = exports.isGambitEndSignal = exports.defineDeck = exports.defineCard = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Gambit exports for authoring and running decks/cards with runtime helpers.
|
|
6
6
|
*
|
|
@@ -22,18 +22,27 @@ Object.defineProperty(exports, "isRunCanceledError", { enumerable: true, get: fu
|
|
|
22
22
|
/** Build a runtime with CLI-equivalent provider defaults and routing. */
|
|
23
23
|
var default_runtime_js_1 = require("./src/default_runtime.js");
|
|
24
24
|
Object.defineProperty(exports, "createDefaultedRuntime", { enumerable: true, get: function () { return default_runtime_js_1.createDefaultedRuntime; } });
|
|
25
|
-
/**
|
|
25
|
+
/** Legacy compatibility wrapper with default provider/model/runtime behavior. */
|
|
26
26
|
var default_runtime_js_2 = require("./src/default_runtime.js");
|
|
27
27
|
Object.defineProperty(exports, "runDeck", { enumerable: true, get: function () { return default_runtime_js_2.runDeck; } });
|
|
28
|
-
/** Run a deck
|
|
28
|
+
/** Run a deck with defaults and return the structured Responses result. */
|
|
29
|
+
var default_runtime_js_3 = require("./src/default_runtime.js");
|
|
30
|
+
Object.defineProperty(exports, "runDeckResponses", { enumerable: true, get: function () { return default_runtime_js_3.runDeckResponses; } });
|
|
31
|
+
/** Project assistant output text from Responses items for presentation. */
|
|
29
32
|
var gambit_core_5 = require("@bolt-foundry/gambit-core");
|
|
30
|
-
Object.defineProperty(exports, "
|
|
33
|
+
Object.defineProperty(exports, "stringifyResponseOutput", { enumerable: true, get: function () { return gambit_core_5.stringifyResponseOutput; } });
|
|
34
|
+
/** Run a deck directly through gambit-core without gambit defaults. */
|
|
35
|
+
var gambit_core_6 = require("@bolt-foundry/gambit-core");
|
|
36
|
+
Object.defineProperty(exports, "runDeckCore", { enumerable: true, get: function () { return gambit_core_6.runDeck; } });
|
|
37
|
+
/** Run a deck directly through gambit-core and return structured Responses. */
|
|
38
|
+
var gambit_core_7 = require("@bolt-foundry/gambit-core");
|
|
39
|
+
Object.defineProperty(exports, "runDeckResponsesCore", { enumerable: true, get: function () { return gambit_core_7.runDeckResponses; } });
|
|
31
40
|
/** OpenAI Chat Completions compatibility helper for a deck. */
|
|
32
41
|
var openai_compat_js_1 = require("./src/openai_compat.js");
|
|
33
42
|
Object.defineProperty(exports, "chatCompletionsWithDeck", { enumerable: true, get: function () { return openai_compat_js_1.chatCompletionsWithDeck; } });
|
|
34
43
|
/** Render a deck to a human-readable outline or debug view. */
|
|
35
|
-
var
|
|
36
|
-
Object.defineProperty(exports, "renderDeck", { enumerable: true, get: function () { return
|
|
44
|
+
var gambit_core_8 = require("@bolt-foundry/gambit-core");
|
|
45
|
+
Object.defineProperty(exports, "renderDeck", { enumerable: true, get: function () { return gambit_core_8.renderDeck; } });
|
|
37
46
|
/** Provider factory for OpenRouter-backed model calls. */
|
|
38
47
|
var openrouter_js_1 = require("./src/providers/openrouter.js");
|
|
39
48
|
Object.defineProperty(exports, "createOpenRouterProvider", { enumerable: true, get: function () { return openrouter_js_1.createOpenRouterProvider; } });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const CODEX_APP_SERVER_DEBUG_ENV = "
|
|
1
|
+
declare const CODEX_APP_SERVER_DEBUG_ENV = "GAMBIT_CODEX_APP_SERVER_DEBUG";
|
|
2
2
|
type DebugValue = null | boolean | number | string | Array<DebugValue> | {
|
|
3
3
|
[key: string]: DebugValue;
|
|
4
4
|
};
|
|
@@ -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,kCAAkC,CAAC;AAenE,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,CAEnD;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,CAAC"}
|
|
@@ -38,7 +38,7 @@ exports.shouldDebugCodexAppServer = shouldDebugCodexAppServer;
|
|
|
38
38
|
exports.logCodexAppServerDebug = logCodexAppServerDebug;
|
|
39
39
|
exports.summarizeCodexAppServerDebugValue = summarizeCodexAppServerDebugValue;
|
|
40
40
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
41
|
-
const CODEX_APP_SERVER_DEBUG_ENV = "
|
|
41
|
+
const CODEX_APP_SERVER_DEBUG_ENV = "GAMBIT_CODEX_APP_SERVER_DEBUG";
|
|
42
42
|
exports.CODEX_APP_SERVER_DEBUG_ENV = CODEX_APP_SERVER_DEBUG_ENV;
|
|
43
43
|
const STRUCTURAL_STRING_KEYS = new Set([
|
|
44
44
|
"error",
|
|
@@ -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,6BAA6B,CAAC;AAErE,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,CAI1E;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/script/src/codex_auth.js
CHANGED
|
@@ -43,7 +43,7 @@ exports.refreshCodexChatgptAuthTokens = refreshCodexChatgptAuthTokens;
|
|
|
43
43
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
44
44
|
const CODEX_AUTH0_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
45
45
|
const CODEX_AUTH0_TOKEN_URL = "https://auth.openai.com/oauth/token";
|
|
46
|
-
exports.CODEX_HOST_AUTH_BUNDLE_ENV = "
|
|
46
|
+
exports.CODEX_HOST_AUTH_BUNDLE_ENV = "GAMBIT_CODEX_AUTH_BUNDLE";
|
|
47
47
|
function normalizeNonEmptyString(value) {
|
|
48
48
|
return typeof value === "string" && value.trim().length > 0
|
|
49
49
|
? value.trim()
|
|
@@ -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":"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@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.createDefaultedRuntime = createDefaultedRuntime;
|
|
37
37
|
exports.runDeck = runDeck;
|
|
38
|
+
exports.runDeckResponses = runDeckResponses;
|
|
38
39
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
39
40
|
const gambit_core_1 = require("@bolt-foundry/gambit-core");
|
|
40
41
|
const model_matchers_js_1 = require("./model_matchers.js");
|
|
@@ -52,6 +53,12 @@ function mergeParams(aliasParams, baseParams) {
|
|
|
52
53
|
}
|
|
53
54
|
return baseParams ?? aliasParams;
|
|
54
55
|
}
|
|
56
|
+
const passthroughModelResolver = {
|
|
57
|
+
resolveModel: (input) => Promise.resolve({
|
|
58
|
+
model: Array.isArray(input.model) ? input.model[0] ?? "" : input.model,
|
|
59
|
+
params: input.params,
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
55
62
|
function parseFallbackProviderFromConfig(fallbackProviderRaw, logger) {
|
|
56
63
|
if (typeof fallbackProviderRaw !== "string") {
|
|
57
64
|
return undefined;
|
|
@@ -90,7 +97,7 @@ function resolveSessionArtifactsConfig(opts) {
|
|
|
90
97
|
return undefined;
|
|
91
98
|
throw new Error("sessionArtifacts persistence has been removed. Use sqlite-backed workspace flows instead.");
|
|
92
99
|
}
|
|
93
|
-
function
|
|
100
|
+
function buildDefaultModelProviderAndResolver(opts) {
|
|
94
101
|
const openRouterApiKey = dntShim.Deno.env.get("OPENROUTER_API_KEY")?.trim();
|
|
95
102
|
const googleApiKey = (dntShim.Deno.env.get("GOOGLE_API_KEY") ??
|
|
96
103
|
dntShim.Deno.env.get("GEMINI_API_KEY"))?.trim();
|
|
@@ -314,8 +321,10 @@ function buildDefaultModelProvider(opts) {
|
|
|
314
321
|
const resolution = opts.modelAliasResolver(model);
|
|
315
322
|
return Boolean(resolution.applied || resolution.missingAlias);
|
|
316
323
|
};
|
|
317
|
-
|
|
324
|
+
const modelResolver = {
|
|
318
325
|
resolveModel: async (input) => await resolveModelSelection(input.model, input.params, input.deckPath),
|
|
326
|
+
};
|
|
327
|
+
const modelProvider = {
|
|
319
328
|
responses: async (input) => {
|
|
320
329
|
const applied = shouldResolveModel(input.request.model)
|
|
321
330
|
? await resolveModelSelection(input.request.model, input.request.params, input.deckPath)
|
|
@@ -341,25 +350,8 @@ function buildDefaultModelProvider(opts) {
|
|
|
341
350
|
},
|
|
342
351
|
});
|
|
343
352
|
},
|
|
344
|
-
chat: async (input) => {
|
|
345
|
-
const applied = shouldResolveModel(input.model)
|
|
346
|
-
? await resolveModelSelection(input.model, input.params, input.deckPath)
|
|
347
|
-
: { model: input.model, params: input.params };
|
|
348
|
-
const request = {
|
|
349
|
-
...input,
|
|
350
|
-
model: applied.model ?? input.model,
|
|
351
|
-
params: applied.params,
|
|
352
|
-
};
|
|
353
|
-
if (typeof request.model !== "string" || !request.model) {
|
|
354
|
-
throw new Error("Model is required.");
|
|
355
|
-
}
|
|
356
|
-
const selection = providerRouter.resolve({ model: request.model });
|
|
357
|
-
return await selection.provider.chat({
|
|
358
|
-
...request,
|
|
359
|
-
model: selection.model,
|
|
360
|
-
});
|
|
361
|
-
},
|
|
362
353
|
};
|
|
354
|
+
return { modelProvider, modelResolver };
|
|
363
355
|
}
|
|
364
356
|
async function createDefaultedRuntime(opts = {}) {
|
|
365
357
|
const logger = opts.logger ?? console;
|
|
@@ -376,14 +368,16 @@ async function createDefaultedRuntime(opts = {}) {
|
|
|
376
368
|
? "openrouter"
|
|
377
369
|
: configuredFallbackProvider;
|
|
378
370
|
const responsesMode = opts.responsesMode ?? resolveDefaultResponsesMode();
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
371
|
+
const defaults = buildDefaultModelProviderAndResolver({
|
|
372
|
+
modelAliasResolver,
|
|
373
|
+
configuredFallbackProvider,
|
|
374
|
+
effectiveFallbackProvider,
|
|
375
|
+
responsesMode,
|
|
376
|
+
logger,
|
|
377
|
+
});
|
|
378
|
+
const modelProvider = opts.modelProvider ?? defaults.modelProvider;
|
|
379
|
+
const modelResolver = opts.modelResolver ??
|
|
380
|
+
(opts.modelProvider ? passthroughModelResolver : defaults.modelResolver);
|
|
387
381
|
const defaultModel = opts.defaultModel;
|
|
388
382
|
const modelOverride = opts.modelOverride;
|
|
389
383
|
const runtimeSessionArtifacts = opts.sessionArtifacts;
|
|
@@ -392,6 +386,8 @@ async function createDefaultedRuntime(opts = {}) {
|
|
|
392
386
|
return {
|
|
393
387
|
...coreRunOpts,
|
|
394
388
|
modelProvider: runOpts.modelProvider ?? modelProvider,
|
|
389
|
+
modelResolver: runOpts.modelResolver ??
|
|
390
|
+
(runOpts.modelProvider ? undefined : modelResolver),
|
|
395
391
|
defaultModel: runOpts.defaultModel ?? defaultModel,
|
|
396
392
|
modelOverride: runOpts.modelOverride ?? modelOverride,
|
|
397
393
|
responsesMode: runOpts.responsesMode ?? responsesMode,
|
|
@@ -403,6 +399,7 @@ async function createDefaultedRuntime(opts = {}) {
|
|
|
403
399
|
configuredFallbackProvider,
|
|
404
400
|
effectiveFallbackProvider,
|
|
405
401
|
modelProvider,
|
|
402
|
+
modelResolver,
|
|
406
403
|
defaultModel,
|
|
407
404
|
modelOverride,
|
|
408
405
|
responsesMode,
|
|
@@ -419,6 +416,17 @@ async function createDefaultedRuntime(opts = {}) {
|
|
|
419
416
|
}
|
|
420
417
|
throw new Error("sessionArtifacts persistence has been removed. Use sqlite-backed workspace flows instead.");
|
|
421
418
|
},
|
|
419
|
+
runDeckResponses: async (runOpts) => {
|
|
420
|
+
const resolved = resolveRunOptions(runOpts);
|
|
421
|
+
const effectiveSessionArtifacts = resolveSessionArtifactsConfig({
|
|
422
|
+
runtimeConfig: runtimeSessionArtifacts,
|
|
423
|
+
runConfig: runOpts.sessionArtifacts,
|
|
424
|
+
});
|
|
425
|
+
if (!effectiveSessionArtifacts) {
|
|
426
|
+
return await (0, gambit_core_1.runDeckResponses)(resolved);
|
|
427
|
+
}
|
|
428
|
+
throw new Error("sessionArtifacts persistence has been removed. Use sqlite-backed workspace flows instead.");
|
|
429
|
+
},
|
|
422
430
|
};
|
|
423
431
|
}
|
|
424
432
|
async function runDeck(opts) {
|
|
@@ -433,3 +441,15 @@ async function runDeck(opts) {
|
|
|
433
441
|
const { runtime: _runtime, runtimeOptions: _runtimeOptions, ...runOpts } = opts;
|
|
434
442
|
return await runtime.runDeck(runOpts);
|
|
435
443
|
}
|
|
444
|
+
async function runDeckResponses(opts) {
|
|
445
|
+
if (opts.runtime && opts.runtimeOptions) {
|
|
446
|
+
throw new Error("runDeckResponses received both runtime and runtimeOptions. Pass only one.");
|
|
447
|
+
}
|
|
448
|
+
const runtime = opts.runtime ??
|
|
449
|
+
await createDefaultedRuntime({
|
|
450
|
+
...opts.runtimeOptions,
|
|
451
|
+
configHint: opts.runtimeOptions?.configHint ?? opts.path,
|
|
452
|
+
});
|
|
453
|
+
const { runtime: _runtime, runtimeOptions: _runtimeOptions, ...runOpts } = opts;
|
|
454
|
+
return await runtime.runDeckResponses(runOpts);
|
|
455
|
+
}
|
|
@@ -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_compat.d.ts","sourceRoot":"","sources":["../../src/src/openai_compat.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,2BAA2B,EAI5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,UAAU,EAEV,YAAY,EACZ,aAAa,EACb,0BAA0B,EAC1B,eAAe,EAEf,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,MAAM,SAAU,CAAC;AAO9B,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QA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