@code-yeongyu/senpi 2026.7.17-4 → 2026.7.17
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 +0 -47
- package/dist/core/dynamic-prompt/build.d.ts +0 -7
- package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
- package/dist/core/dynamic-prompt/build.js +0 -5
- package/dist/core/dynamic-prompt/build.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/policy.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/policy.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/status.js +1 -1
- package/dist/core/extensions/builtin/mcp/expose/status.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts +3 -3
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js +10 -10
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts +3 -3
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js +14 -14
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.js +5 -5
- package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts +2 -2
- package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js +2 -2
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js +1 -5
- package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +7 -5
- package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
- package/dist/core/extensions/builtin/websearch/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/websearch/index.js +3 -20
- package/dist/core/extensions/builtin/websearch/index.js.map +1 -1
- package/docs/mcp.md +5 -5
- package/examples/AGENTS.md +0 -3
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +0 -35
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +19 -59
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +2 -68
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +0 -6
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +1 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +1 -25
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +21 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +6 -6
- package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +21 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +25 -7
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +0 -5
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +6 -6
- package/dist/core/dynamic-prompt/workstation.d.ts +0 -35
- package/dist/core/dynamic-prompt/workstation.d.ts.map +0 -1
- package/dist/core/dynamic-prompt/workstation.js +0 -81
- package/dist/core/dynamic-prompt/workstation.js.map +0 -1
- package/docs/AGENTS.md +0 -70
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts +0 -19
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js +0 -215
- package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js.map +0 -1
|
@@ -14,35 +14,6 @@ export interface EvalPromptParts {
|
|
|
14
14
|
export interface EvalPromptOptions {
|
|
15
15
|
readonly spawns: boolean;
|
|
16
16
|
readonly spawnDefaultAgent?: string;
|
|
17
|
-
/** Active model id; selects the emphasis dialect of the batching guidance. */
|
|
18
|
-
readonly modelId?: string;
|
|
19
|
-
/** Preformatted host line (e.g. "darwin arm64 · Apple M5 Max · 18 cores"); enables the host-sizing note. */
|
|
20
|
-
readonly hostLine?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Prompt dialect for the eval-first batching emphasis. */
|
|
24
|
-
export type EvalEmphasisStyle = "default" | "claude" | "codex" | "kimi";
|
|
25
|
-
|
|
26
|
-
const CLAUDE_MODEL_RE = /(^|[/.:])claude[-.]/i;
|
|
27
|
-
const GLM_MODEL_RE = /(^|[/.:@-])glm[-.]?\d/i;
|
|
28
|
-
const KIMI_MODEL_RE = /(^|[/.:])kimi[-.]/i;
|
|
29
|
-
const OPENAI_MODEL_RE = /(^|[/.:])(gpt|chatgpt|codex)[-.]|(^|[/.:])o[134](?:[-.]|$)/i;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Selects the eval-first batching dialect for a model id:
|
|
33
|
-
* - `claude`: Claude/GLM — direct imperatives; both are steered most reliably
|
|
34
|
-
* by explicit tagged directives (GLM prompting guidance routes to Claude's).
|
|
35
|
-
* - `codex`: OpenAI reasoning families — terse bounded rules, no emphasis spam.
|
|
36
|
-
* - `kimi`: Kimi K-series — positive operational constraints; all-caps NEVER
|
|
37
|
-
* directives make K2.x overthink instead of comply.
|
|
38
|
-
* - `default`: everything else (and no model) — maximum-emphasis fallback.
|
|
39
|
-
*/
|
|
40
|
-
export function evalEmphasisStyle(modelId: string | undefined): EvalEmphasisStyle {
|
|
41
|
-
if (!modelId) return "default";
|
|
42
|
-
if (CLAUDE_MODEL_RE.test(modelId) || GLM_MODEL_RE.test(modelId)) return "claude";
|
|
43
|
-
if (KIMI_MODEL_RE.test(modelId)) return "kimi";
|
|
44
|
-
if (OPENAI_MODEL_RE.test(modelId)) return "codex";
|
|
45
|
-
return "default";
|
|
46
17
|
}
|
|
47
18
|
|
|
48
19
|
type ContextValue = string | boolean;
|
|
@@ -86,24 +57,7 @@ const EVAL_PROMPT_TEMPLATE = `Run one step of code in a persistent kernel.
|
|
|
86
57
|
|
|
87
58
|
Work incrementally: imports in one call, define in the next, test, then use — each its own eval call. Re-run setup ONLY after \`reset\`, a kernel crash, or a \`NameError\`/\`ReferenceError\` proving the state is gone.
|
|
88
59
|
|
|
89
|
-
|
|
90
|
-
\`eval\` is your default execution surface: if a step needs more than one tool call, write ONE cell that performs the whole step — never issue the calls one at a time.
|
|
91
|
-
- Enumerate every lookup the step needs, then run all independent ones simultaneously with \`parallel(thunks)\` inside the cell; keep calls sequential only when one result feeds the next.
|
|
92
|
-
- Write real code around the calls: loop or comprehend over file sets with \`read()\`/stdlib, branch per case, and wrap risky calls in try/except so one failure degrades only its item — recover or retry inside the cell, keep the batch alive.
|
|
93
|
-
- Post-process \`tool.<name>()\` results programmatically and return distilled facts, not raw dumps.
|
|
94
|
-
</eval_first_batching>{{/if}}{{#if styleCodex}}Route multi-call steps through eval: one cell per step, independent lookups dispatched together via \`parallel(thunks)\`; keep work sequential only when one result determines the next action.
|
|
95
|
-
- Loop or comprehend over file sets with \`read()\`/stdlib instead of reading files one call at a time; post-process \`tool.<name>()\` results programmatically.
|
|
96
|
-
- Wrap failable calls in try/except inside the cell; a failed item degrades only itself. After two distinct failed strategies for the same fact, fall back to direct tool calls.
|
|
97
|
-
- Reduce large results in-kernel to the facts the task needs before returning.{{/if}}{{#if styleKimi}}Treat eval as the standard way to execute any step involving several tool calls: write one cell that performs the whole step.
|
|
98
|
-
- When lookups are independent, run them together with \`parallel(thunks)\` in that cell; when one result feeds the next, keep them sequential inside the same cell.
|
|
99
|
-
- Loop or comprehend over file sets with \`read()\`/stdlib, post-process \`tool.<name>()\` results programmatically, and put try/except around each risky call so the rest of the batch completes.
|
|
100
|
-
- Filter and aggregate results in the kernel, then return the distilled facts.{{/if}}{{#if styleDefault}}**EVAL IS YOUR PRIMARY EXECUTION SURFACE.** Any step that needs MORE THAN ONE tool call MUST be written as ONE cell — NEVER as a chain of single tool calls.
|
|
101
|
-
- **PLAN THE WHOLE STEP, THEN BATCH IT.** Enumerate every read/search/lookup the step needs and dispatch ALL independent ones through \`parallel(thunks)\` in one cell.
|
|
102
|
-
- **WRITE REAL CODE, NOT CALL LISTS.** Loop or comprehend over file sets with \`read()\`/stdlib, branch \`if\`/\`else\` per case, post-process \`tool.<name>()\` results programmatically, and wrap EVERY risky call in try/except so ONE failure NEVER kills the batch.
|
|
103
|
-
- **DISTILL IN-KERNEL.** Filter, diff, and aggregate in code before returning; return facts, NOT dumps.{{/if}}
|
|
104
|
-
{{#if hostLine}}
|
|
105
|
-
Host: {{hostLine}} — cells execute here. Size \`parallel(thunks)\` pools to its cores; \`tool.<name>()\` shell commands must fit this platform, even when the code you are writing targets another machine.
|
|
106
|
-
{{/if}}
|
|
60
|
+
**Batch through eval.** One cell replaces many one-shot tool calls: loop or comprehend over file sets with \`read()\`/stdlib instead of reading files one call at a time, post-process \`tool.<name>()\` results programmatically, and fan independent calls through \`parallel(thunks)\` within the cell — never one call per turn.
|
|
107
61
|
|
|
108
62
|
Fields:
|
|
109
63
|
|
|
@@ -175,7 +129,6 @@ export function buildEvalPrompt(
|
|
|
175
129
|
throw new Error("no kernels enabled for eval prompt");
|
|
176
130
|
}
|
|
177
131
|
const spawnDefaultAgent = options.spawnDefaultAgent ?? "task";
|
|
178
|
-
const style = evalEmphasisStyle(options.modelId);
|
|
179
132
|
const context: Context = {
|
|
180
133
|
py: enabled.py,
|
|
181
134
|
js: enabled.js,
|
|
@@ -183,11 +136,6 @@ export function buildEvalPrompt(
|
|
|
183
136
|
jl: enabled.jl,
|
|
184
137
|
spawns: options.spawns,
|
|
185
138
|
spawnDefaultAgent,
|
|
186
|
-
styleClaude: style === "claude",
|
|
187
|
-
styleCodex: style === "codex",
|
|
188
|
-
styleKimi: style === "kimi",
|
|
189
|
-
styleDefault: style === "default",
|
|
190
|
-
hostLine: options.hostLine ?? "",
|
|
191
139
|
};
|
|
192
140
|
const examples = REUSE_CHAIN_EXAMPLES.filter((example) => enabled[example.language])
|
|
193
141
|
.map((example) => {
|
|
@@ -207,26 +155,12 @@ export function buildEvalPrompt(
|
|
|
207
155
|
description,
|
|
208
156
|
promptSnippet: "Run one incremental code cell in a persistent language kernel.",
|
|
209
157
|
promptGuidelines: [
|
|
210
|
-
|
|
158
|
+
"Use eval for incremental code execution when a persistent JS, Python, Ruby, or Julia kernel is available.",
|
|
211
159
|
"Use eval reset only when a language kernel must be wiped; reset is scoped to the selected language.",
|
|
212
160
|
],
|
|
213
161
|
};
|
|
214
162
|
}
|
|
215
163
|
|
|
216
|
-
/**
|
|
217
|
-
* System-prompt guideline per emphasis dialect. The default dialect carries
|
|
218
|
-
* maximum emphasis so unmapped models still batch through eval; the others are
|
|
219
|
-
* tuned to what steers that family reliably.
|
|
220
|
-
*/
|
|
221
|
-
const BATCHING_GUIDELINES: Record<EvalEmphasisStyle, string> = {
|
|
222
|
-
default:
|
|
223
|
-
"**EVAL FIRST.** Any step needing MORE THAN ONE tool call MUST be ONE eval cell: run independent calls in parallel, wrap risky calls in try/except, and return distilled facts — NEVER a chain of single tool calls.",
|
|
224
|
-
claude:
|
|
225
|
-
"Prefer eval for any step needing more than one tool call: one cell that runs independent calls in parallel, handles per-call failures in code, and returns distilled facts.",
|
|
226
|
-
codex: "Route multi-call steps through eval: one cell per step, independent calls dispatched in parallel; fall back to direct tool calls when one call is sufficient or each result changes the next decision.",
|
|
227
|
-
kimi: "Treat eval as the standard way to execute multi-call steps: one cell that runs independent calls in parallel, handles failures per item, and returns distilled facts.",
|
|
228
|
-
};
|
|
229
|
-
|
|
230
164
|
function renderTemplate(template: string, context: Context): string {
|
|
231
165
|
let index = 0;
|
|
232
166
|
const [rendered, nextIndex] = renderUntil(template, context, index, []);
|
|
@@ -39,10 +39,6 @@ export interface CreateEvalToolOptions {
|
|
|
39
39
|
readonly spawns?: boolean;
|
|
40
40
|
/** Default agent name surfaced in the agent() helper docs when spawns are enabled. */
|
|
41
41
|
readonly spawnDefaultAgent?: string;
|
|
42
|
-
/** Active model id; selects the emphasis dialect of the eval prompt. */
|
|
43
|
-
readonly modelId?: string;
|
|
44
|
-
/** Preformatted host line rendered into the prompt's host-sizing note. */
|
|
45
|
-
readonly hostLine?: string;
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
interface EvalCellInvocation {
|
|
@@ -156,8 +152,6 @@ export function createEvalTool(options: CreateEvalToolOptions): ToolDefinition<E
|
|
|
156
152
|
const prompt = buildEvalPrompt(options.enabledLanguages, {
|
|
157
153
|
spawns: options.spawns ?? false,
|
|
158
154
|
...(options.spawnDefaultAgent === undefined ? {} : { spawnDefaultAgent: options.spawnDefaultAgent }),
|
|
159
|
-
...(options.modelId === undefined ? {} : { modelId: options.modelId }),
|
|
160
|
-
...(options.hostLine === undefined ? {} : { hostLine: options.hostLine }),
|
|
161
155
|
});
|
|
162
156
|
const languages = enabledLanguageList(options.enabledLanguages);
|
|
163
157
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@earendil-works/pi-agent-core",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "2026.7.17
|
|
4
|
+
"version": "2026.7.17",
|
|
5
5
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"prepublishOnly": "npm run clean && npm run build"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@earendil-works/pi-ai": "^2026.7.17
|
|
33
|
+
"@earendil-works/pi-ai": "^2026.7.17",
|
|
34
34
|
"ignore": "7.0.5",
|
|
35
35
|
"typebox": "1.1.38",
|
|
36
36
|
"yaml": "2.9.0"
|
|
@@ -9,11 +9,10 @@ export interface OpenAICompletionsOptions extends StreamOptions {
|
|
|
9
9
|
};
|
|
10
10
|
reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
11
11
|
}
|
|
12
|
-
type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat" | "toolCallFormat" | "deferredToolsMode"
|
|
12
|
+
type ResolvedOpenAICompletionsCompat = Omit<Required<OpenAICompletionsCompat>, "cacheControlFormat" | "toolCallFormat" | "deferredToolsMode"> & {
|
|
13
13
|
cacheControlFormat?: OpenAICompletionsCompat["cacheControlFormat"];
|
|
14
14
|
toolCallFormat?: OpenAICompletionsCompat["toolCallFormat"];
|
|
15
15
|
deferredToolsMode?: OpenAICompletionsCompat["deferredToolsMode"];
|
|
16
|
-
toolSchemaFlavor?: OpenAICompletionsCompat["toolSchemaFlavor"];
|
|
17
16
|
};
|
|
18
17
|
export declare const stream: StreamFunction<"openai-completions", OpenAICompletionsOptions>;
|
|
19
18
|
export declare const streamSimple: StreamFunction<"openai-completions", SimpleStreamOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-completions.d.ts","sourceRoot":"","sources":["../../src/api/openai-completions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAOX,0BAA0B,EAG1B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAIX,OAAO,EAGP,KAAK,EACL,uBAAuB,EAGvB,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAMb,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-completions.d.ts","sourceRoot":"","sources":["../../src/api/openai-completions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAOX,0BAA0B,EAG1B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,KAAK,EAIX,OAAO,EAGP,KAAK,EACL,uBAAuB,EAGvB,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAMb,MAAM,aAAa,CAAC;AAuIrB,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAC7F,eAAe,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;CAC1E;AAOD,KAAK,+BAA+B,GAAG,IAAI,CAC1C,QAAQ,CAAC,uBAAuB,CAAC,EACjC,oBAAoB,GAAG,gBAAgB,GAAG,mBAAmB,CAC7D,GAAG;IACH,kBAAkB,CAAC,EAAE,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;IACnE,cAAc,CAAC,EAAE,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAC3D,iBAAiB,CAAC,EAAE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;CACjE,CAAC;AAmCF,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,wBAAwB,CA0VjF,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CAsBlF,CAAC;AAyWF,wBAAgB,eAAe,CAC9B,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,EAClC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,+BAA+B,EACvC,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1C,0BAA0B,EAAE,CAwQ9B"}
|
|
@@ -7,7 +7,6 @@ import { parseStreamingJson } from "../utils/json-parse.js";
|
|
|
7
7
|
import { getProviderEnvValue } from "../utils/provider-env.js";
|
|
8
8
|
import { sanitizeSurrogates } from "../utils/sanitize-unicode.js";
|
|
9
9
|
import { isForcedToolChoiceUnsupportedError, omitToolChoiceParam } from "../utils/tool-choice-fallback.js";
|
|
10
|
-
import { normalizeToolParametersForMoonshot, normalizeToolParametersForOpenAICompat, } from "../utils/tool-schema-compat.js";
|
|
11
10
|
import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./github-copilot-headers.js";
|
|
12
11
|
import { clampOpenAIPromptCacheKey } from "./openai-prompt-cache.js";
|
|
13
12
|
import { applyExtraBody, buildBaseOptions, clampMaxForOpenAI, OPENAI_COMPLETIONS_RESERVED_BODY_KEYS, } from "./simple-options.js";
|
|
@@ -141,7 +140,6 @@ export const stream = (model, context, options) => {
|
|
|
141
140
|
if (nextParams !== undefined) {
|
|
142
141
|
params = nextParams;
|
|
143
142
|
}
|
|
144
|
-
params = normalizeRequestToolSchemas(params, compat);
|
|
145
143
|
const requestOptions = {
|
|
146
144
|
...(options?.signal ? { signal: options.signal } : {}),
|
|
147
145
|
...(options?.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {}),
|
|
@@ -978,39 +976,18 @@ function convertTools(tools, compat) {
|
|
|
978
976
|
if (tool.freeform) {
|
|
979
977
|
throw new Error("Freeform tools cannot be sent to OpenAI Chat Completions; use Responses API");
|
|
980
978
|
}
|
|
981
|
-
const normalizedParameters = compat.toolSchemaFlavor === "moonshot-mfjs"
|
|
982
|
-
? normalizeToolParametersForMoonshot(tool.parameters)
|
|
983
|
-
: normalizeToolParametersForOpenAICompat(tool.parameters);
|
|
984
979
|
return {
|
|
985
980
|
type: "function",
|
|
986
981
|
function: {
|
|
987
982
|
name: tool.name,
|
|
988
983
|
description: tool.description,
|
|
989
|
-
parameters:
|
|
984
|
+
parameters: tool.parameters,
|
|
990
985
|
// Only include strict if provider supports it. Some reject unknown fields.
|
|
991
986
|
...(compat.supportsStrictMode !== false && { strict: false }),
|
|
992
987
|
},
|
|
993
988
|
};
|
|
994
989
|
});
|
|
995
990
|
}
|
|
996
|
-
function normalizeRequestToolSchemas(params, compat) {
|
|
997
|
-
if (!params.tools)
|
|
998
|
-
return params;
|
|
999
|
-
return {
|
|
1000
|
-
...params,
|
|
1001
|
-
tools: params.tools.map((tool) => {
|
|
1002
|
-
if (tool.type !== "function" || !tool.function.parameters)
|
|
1003
|
-
return tool;
|
|
1004
|
-
const parameters = compat.toolSchemaFlavor === "moonshot-mfjs"
|
|
1005
|
-
? normalizeToolParametersForMoonshot(tool.function.parameters)
|
|
1006
|
-
: normalizeToolParametersForOpenAICompat(tool.function.parameters);
|
|
1007
|
-
return {
|
|
1008
|
-
...tool,
|
|
1009
|
-
function: { ...tool.function, parameters },
|
|
1010
|
-
};
|
|
1011
|
-
}),
|
|
1012
|
-
};
|
|
1013
|
-
}
|
|
1014
991
|
function parseChunkUsage(rawUsage, model) {
|
|
1015
992
|
const promptTokens = rawUsage.prompt_tokens || 0;
|
|
1016
993
|
const cacheReadTokens = rawUsage.prompt_tokens_details?.cached_tokens ?? rawUsage.prompt_cache_hit_tokens ?? 0;
|
|
@@ -1126,7 +1103,6 @@ function detectCompat(model) {
|
|
|
1126
1103
|
chatTemplateKwargs: {},
|
|
1127
1104
|
zaiToolStream: false,
|
|
1128
1105
|
supportsStrictMode: !isMoonshot && !isTogether && !isCloudflareAiGateway && !isNvidia,
|
|
1129
|
-
toolSchemaFlavor: isMoonshot ? "moonshot-mfjs" : undefined,
|
|
1130
1106
|
supportsDisabledThinking: true,
|
|
1131
1107
|
toolCallFormat: undefined,
|
|
1132
1108
|
cacheControlFormat,
|