@cjhyy/code-shell 0.1.0-alpha.0 → 0.1.0-alpha.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 +39 -0
- package/README.md +8 -0
- package/dist/anthropic-P5VETAFI.cjs +10 -0
- package/dist/{anthropic-NENYS535.js → anthropic-W2GU3D76.js} +3 -2
- package/dist/arena/context/context-tools.d.ts +1 -1
- package/dist/arena/index.cjs +4 -4
- package/dist/arena/index.js +3 -3
- package/dist/arena/providers/index.d.ts +19 -3
- package/dist/arena/strategies/utils.d.ts +6 -1
- package/dist/arena/types.d.ts +10 -1
- package/dist/{arena-46QQ6BZQ.js → arena-ENHBHB2W.js} +5 -7
- package/dist/{arena-HZZZ2GJH.cjs → arena-HHDYYVHJ.cjs} +19 -21
- package/dist/{chunk-BE6IPRDM.js → chunk-2EUAE7AY.js} +1 -1
- package/dist/{chunk-WFQF3RT4.cjs → chunk-3CAZIWUA.cjs} +11 -8
- package/dist/{chunk-J5XW6UYL.js → chunk-5C5HIOML.js} +63 -4
- package/dist/chunk-75E4BBFC.js +224 -0
- package/dist/{chunk-ZJV3YSY3.cjs → chunk-BUJ5KYCI.cjs} +53 -11
- package/dist/{chunk-BMH65OVB.cjs → chunk-C7C7ZZY4.cjs} +8 -8
- package/dist/{chunk-KO2FPF7G.js → chunk-F5BS3GUC.js} +20 -2
- package/dist/chunk-FA5KD34T.js +54 -0
- package/dist/chunk-FV2ARONZ.cjs +224 -0
- package/dist/chunk-G76E5FOB.cjs +54 -0
- package/dist/{chunk-DICG4AB7.cjs → chunk-GZBD6QRS.cjs} +42 -3
- package/dist/{chunk-FVP7XJGS.cjs → chunk-HOXQLX5R.cjs} +406 -196
- package/dist/{chunk-4PKZPFCD.js → chunk-I57ZD5IQ.js} +47 -14
- package/dist/{chunk-7RMAR2Y3.js → chunk-ID6EJUHP.js} +1959 -473
- package/dist/chunk-JHNCK7JP.cjs +202 -0
- package/dist/{chunk-R32DJSJE.cjs → chunk-JHXNOB5G.cjs} +8 -5
- package/dist/{chunk-UK2SU23S.cjs → chunk-KOGV6PDQ.cjs} +20 -2
- package/dist/{chunk-VKGNCYRL.js → chunk-LMEKCQX4.js} +95 -13
- package/dist/{chunk-3EAEC566.cjs → chunk-M2QI5X3X.cjs} +51 -18
- package/dist/{chunk-YZ25SSWJ.js → chunk-M2SVOKC6.js} +46 -4
- package/dist/chunk-OMRGA6TI.js +4753 -0
- package/dist/{chunk-NG73UR3L.cjs → chunk-OP57WUWQ.cjs} +23 -1
- package/dist/{chunk-ZXYDDJEJ.js → chunk-OUC2DFA7.js} +2 -2
- package/dist/{chunk-6JOOLG6F.js → chunk-REFCCVDM.js} +5 -2
- package/dist/{chunk-O6F2EF2Z.js → chunk-SCDKLTN3.js} +41 -2
- package/dist/{chunk-BHGIJ2DJ.js → chunk-SW3L7HIM.js} +6 -3
- package/dist/chunk-TATCTZSB.cjs +4753 -0
- package/dist/{chunk-QHDYFC5U.cjs → chunk-VWFET3MG.cjs} +2132 -646
- package/dist/{chunk-3EUDE77E.cjs → chunk-X2DNIMPC.cjs} +19 -19
- package/dist/{chunk-SQZHPD3S.js → chunk-Y7TSCDF6.js} +297 -87
- package/dist/{chunk-WHRTARDJ.cjs → chunk-YAFCN7ZW.cjs} +112 -30
- package/dist/{chunk-LRAY5IYC.cjs → chunk-YD7XTI7T.cjs} +65 -6
- package/dist/{chunk-S74VVJBF.js → chunk-ZLPJJZUW.js} +23 -1
- package/dist/chunk-ZRVPCXI7.js +202 -0
- package/dist/cli/commands/builtin/advanced-commands.d.ts +1 -1
- package/dist/cli/commands/builtin/extra-commands.d.ts +2 -2
- package/dist/cli/commands/builtin/more-commands.d.ts +1 -3
- package/dist/cli/commands/registry.d.ts +8 -0
- package/dist/cli/cost-tracker.d.ts +6 -0
- package/dist/cli/main.cjs +3576 -2036
- package/dist/cli/main.js +3613 -2073
- package/dist/cli/onboarding.d.ts +67 -14
- package/dist/client-base-TOVE25FA.js +9 -0
- package/dist/client-base-VDDIADAC.cjs +9 -0
- package/dist/compaction-D3KV2NWY.cjs +31 -0
- package/dist/{compaction-CCHWA4G6.js → compaction-YNWCEF7B.js} +1 -2
- package/dist/context/manager.d.ts +9 -0
- package/dist/data/openrouter-models.d.ts +35 -0
- package/dist/data/openrouter-sync.d.ts +16 -0
- package/dist/{devtools-KIY3LWQJ.js → devtools-IRQQPIRY.js} +1 -1
- package/dist/{devtools-LRP47DDV.cjs → devtools-WTC3NFNE.cjs} +1 -1
- package/dist/engine/engine.d.ts +39 -4
- package/dist/engine/turn-loop.d.ts +13 -4
- package/dist/engine/turn-state.d.ts +6 -0
- package/dist/index.cjs +19 -28
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -37
- package/dist/llm/client-base.d.ts +7 -0
- package/dist/llm/model-pool.d.ts +4 -0
- package/dist/logging/logger.d.ts +69 -8
- package/dist/manager-FWLOVEEK.cjs +7 -0
- package/dist/manager-GEXJLOIS.js +7 -0
- package/dist/{mcp-manager-OKXHHWYR.js → mcp-manager-37GQLFGX.js} +2 -2
- package/dist/mcp-manager-U77NEXBY.cjs +8 -0
- package/dist/memory-ADGOWADP.cjs +9 -0
- package/dist/memory-EPFDBPII.js +9 -0
- package/dist/native-ts/yoga-layout/index.d.ts +2 -2
- package/dist/{openai-5HQGBL4L.js → openai-RXU5URYI.js} +3 -2
- package/dist/openai-SQW4H2K4.cjs +10 -0
- package/dist/openrouter-models-OL725CL6.js +15 -0
- package/dist/openrouter-models-UM3AOGZ4.cjs +15 -0
- package/dist/openrouter-sync-CWD5VNW2.js +11 -0
- package/dist/openrouter-sync-HYZZC6RX.cjs +11 -0
- package/dist/product/index.cjs +12 -16
- package/dist/product/index.js +11 -15
- package/dist/product/types.d.ts +2 -7
- package/dist/protocol/types.d.ts +11 -3
- package/dist/{ink → render}/hooks/use-input.d.ts +1 -1
- package/dist/run/EngineRunner.d.ts +3 -1
- package/dist/run/RunManager.d.ts +6 -0
- package/dist/run/factory.d.ts +7 -1
- package/dist/run/index.cjs +12 -16
- package/dist/run/index.js +11 -15
- package/dist/session/memory.d.ts +23 -3
- package/dist/session/session-manager.d.ts +4 -1
- package/dist/{session-manager-UQKB564H.cjs → session-manager-HRSKENKB.cjs} +2 -2
- package/dist/{session-manager-JIIBCFTC.js → session-manager-NEKFEHF3.js} +1 -1
- package/dist/settings/manager.d.ts +9 -0
- package/dist/settings/schema.d.ts +48 -39
- package/dist/{tool-summary-J2ICNMWP.js → tool-summary-2RUFL5QK.js} +1 -1
- package/dist/{tool-summary-5P2GKRA4.cjs → tool-summary-RYNR4DDB.cjs} +2 -2
- package/dist/tool-system/builtin/agent-registry.d.ts +36 -0
- package/dist/tool-system/builtin/agent.d.ts +7 -26
- package/dist/tool-system/builtin/apply-patch/applier.d.ts +26 -0
- package/dist/tool-system/builtin/apply-patch/index.d.ts +19 -0
- package/dist/tool-system/builtin/apply-patch/parser.d.ts +17 -0
- package/dist/tool-system/builtin/apply-patch/seek-sequence.d.ts +18 -0
- package/dist/tool-system/builtin/apply-patch/types.d.ts +49 -0
- package/dist/tool-system/builtin/arena.d.ts +18 -5
- package/dist/tool-system/builtin/ask-user.d.ts +6 -6
- package/dist/tool-system/builtin/index.d.ts +11 -1
- package/dist/tool-system/builtin/tool-search.d.ts +2 -3
- package/dist/tool-system/context.d.ts +74 -0
- package/dist/tool-system/executor.d.ts +16 -0
- package/dist/tool-system/permission.d.ts +40 -5
- package/dist/tool-system/registry.d.ts +8 -0
- package/dist/types.d.ts +34 -1
- package/dist/ui/App.d.ts +1 -1
- package/dist/ui/components/AgentBlock.d.ts +1 -1
- package/dist/ui/components/AskUserPrompt.d.ts +7 -0
- package/dist/ui/components/MessageContent.d.ts +7 -3
- package/dist/ui/components/ModelManager.d.ts +35 -0
- package/dist/ui/components/ModelSelector.d.ts +10 -0
- package/dist/ui/components/OnboardingPrompt.d.ts +7 -0
- package/dist/ui/components/PermissionPrompt.d.ts +5 -2
- package/dist/ui/components/SessionPicker.d.ts +14 -0
- package/dist/ui/components/StatusLine.d.ts +4 -2
- package/dist/ui/components/ThemedBox.d.ts +1 -1
- package/dist/ui/components/ToolCall.d.ts +8 -1
- package/dist/ui/components/WelcomeTips.d.ts +5 -0
- package/dist/ui/onboarding-runner.d.ts +2 -0
- package/dist/ui/store.d.ts +1 -0
- package/dist/{updater-URVNPDPW.cjs → updater-M7L42ASZ.cjs} +4 -4
- package/dist/{updater-AVD4LKTQ.js → updater-ZRTONIR4.js} +4 -4
- package/dist/utils/debug.d.ts +17 -33
- package/package.json +4 -4
- package/dist/anthropic-XMTTVNSH.cjs +0 -9
- package/dist/bridge-4ZRXVWBN.js +0 -98
- package/dist/bridge-W476QDFH.cjs +0 -98
- package/dist/chunk-4RRUP4MM.js +0 -86
- package/dist/chunk-4SFPFHMG.js +0 -132
- package/dist/chunk-5LHVI777.cjs +0 -246
- package/dist/chunk-6ZIROYXX.js +0 -207
- package/dist/chunk-C7JBCO5V.js +0 -80
- package/dist/chunk-CSO5EOEP.cjs +0 -132
- package/dist/chunk-FGZGCFJX.cjs +0 -207
- package/dist/chunk-HD7MT5XU.cjs +0 -86
- package/dist/chunk-IMMTBZ33.cjs +0 -63
- package/dist/chunk-JT2WSQSR.cjs +0 -335
- package/dist/chunk-NZ4DQ72D.cjs +0 -664
- package/dist/chunk-OG4MIQJ6.js +0 -335
- package/dist/chunk-WRZJUQ5Z.js +0 -664
- package/dist/chunk-X4HAERTQ.js +0 -63
- package/dist/chunk-XHC2JMEC.cjs +0 -80
- package/dist/chunk-ZRSSGYA5.js +0 -246
- package/dist/compaction-44I55TLI.cjs +0 -32
- package/dist/coordinator-5HY7ALO2.js +0 -7
- package/dist/coordinator-INDLPVMF.cjs +0 -7
- package/dist/cost-tracker-IWYAUPXH.js +0 -9
- package/dist/cost-tracker-JXTJQQWE.cjs +0 -9
- package/dist/loader-DXFSUB4R.cjs +0 -91
- package/dist/loader-J5UID6CV.js +0 -91
- package/dist/manager-ETWDOCHN.cjs +0 -9
- package/dist/manager-HGMQNEJB.cjs +0 -11
- package/dist/manager-HUAQOORS.js +0 -9
- package/dist/manager-VJIZ2CQC.js +0 -11
- package/dist/mcp-manager-G4G2QASE.cjs +0 -8
- package/dist/memory-AP747G5H.js +0 -7
- package/dist/memory-BH3BYUN5.cjs +0 -7
- package/dist/onboarding-6WEPV7C2.js +0 -11
- package/dist/onboarding-QM5DY2TU.cjs +0 -11
- package/dist/openai-656VWUQW.cjs +0 -9
- package/dist/skills-63RBYQRX.js +0 -13
- package/dist/skills-V3BPLW3D.cjs +0 -13
- package/dist/token-counter-CHAXW5O7.cjs +0 -13
- package/dist/token-counter-DSOZGZ5Q.js +0 -13
- package/dist/utils/log.d.ts +0 -56
- package/dist/voice-KTZ7PAGO.js +0 -80
- package/dist/voice-KZE25GKB.cjs +0 -80
- /package/dist/{ink → render}/Ansi.d.ts +0 -0
- /package/dist/{ink → render}/bidi.d.ts +0 -0
- /package/dist/{ink → render}/clearTerminal.d.ts +0 -0
- /package/dist/{ink → render}/colorize.d.ts +0 -0
- /package/dist/{ink → render}/components/AlternateScreen.d.ts +0 -0
- /package/dist/{ink → render}/components/App.d.ts +0 -0
- /package/dist/{ink → render}/components/AppContext.d.ts +0 -0
- /package/dist/{ink → render}/components/Box.d.ts +0 -0
- /package/dist/{ink → render}/components/Button.d.ts +0 -0
- /package/dist/{ink → render}/components/ClockContext.d.ts +0 -0
- /package/dist/{ink → render}/components/CursorDeclarationContext.d.ts +0 -0
- /package/dist/{ink → render}/components/ErrorOverview.d.ts +0 -0
- /package/dist/{ink → render}/components/Link.d.ts +0 -0
- /package/dist/{ink → render}/components/Newline.d.ts +0 -0
- /package/dist/{ink → render}/components/NoSelect.d.ts +0 -0
- /package/dist/{ink → render}/components/RawAnsi.d.ts +0 -0
- /package/dist/{ink → render}/components/ScrollBox.d.ts +0 -0
- /package/dist/{ink → render}/components/Spacer.d.ts +0 -0
- /package/dist/{ink → render}/components/StdinContext.d.ts +0 -0
- /package/dist/{ink → render}/components/TerminalFocusContext.d.ts +0 -0
- /package/dist/{ink → render}/components/TerminalSizeContext.d.ts +0 -0
- /package/dist/{ink → render}/components/Text.d.ts +0 -0
- /package/dist/{ink → render}/constants.d.ts +0 -0
- /package/dist/{ink → render}/cursor.d.ts +0 -0
- /package/dist/{ink → render}/devtools.d.ts +0 -0
- /package/dist/{ink → render}/dom.d.ts +0 -0
- /package/dist/{ink → render}/events/click-event.d.ts +0 -0
- /package/dist/{ink → render}/events/dispatcher.d.ts +0 -0
- /package/dist/{ink → render}/events/emitter.d.ts +0 -0
- /package/dist/{ink → render}/events/event-handlers.d.ts +0 -0
- /package/dist/{ink → render}/events/event.d.ts +0 -0
- /package/dist/{ink → render}/events/focus-event.d.ts +0 -0
- /package/dist/{ink → render}/events/input-event.d.ts +0 -0
- /package/dist/{ink → render}/events/keyboard-event.d.ts +0 -0
- /package/dist/{ink → render}/events/paste-event.d.ts +0 -0
- /package/dist/{ink → render}/events/resize-event.d.ts +0 -0
- /package/dist/{ink → render}/events/terminal-event.d.ts +0 -0
- /package/dist/{ink → render}/events/terminal-focus-event.d.ts +0 -0
- /package/dist/{ink → render}/focus.d.ts +0 -0
- /package/dist/{ink → render}/frame.d.ts +0 -0
- /package/dist/{ink → render}/get-max-width.d.ts +0 -0
- /package/dist/{ink → render}/hit-test.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-animation-frame.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-app.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-declared-cursor.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-interval.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-search-highlight.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-selection.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-stdin.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-tab-status.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-terminal-focus.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-terminal-title.d.ts +0 -0
- /package/dist/{ink → render}/hooks/use-terminal-viewport.d.ts +0 -0
- /package/dist/{ink → render}/index.d.ts +0 -0
- /package/dist/{ink → render}/ink.d.ts +0 -0
- /package/dist/{ink → render}/instances.d.ts +0 -0
- /package/dist/{ink → render}/layout/engine.d.ts +0 -0
- /package/dist/{ink → render}/layout/geometry.d.ts +0 -0
- /package/dist/{ink → render}/layout/node.d.ts +0 -0
- /package/dist/{ink → render}/layout/yoga.d.ts +0 -0
- /package/dist/{ink → render}/line-width-cache.d.ts +0 -0
- /package/dist/{ink → render}/log-update.d.ts +0 -0
- /package/dist/{ink → render}/measure-element.d.ts +0 -0
- /package/dist/{ink → render}/measure-text.d.ts +0 -0
- /package/dist/{ink → render}/node-cache.d.ts +0 -0
- /package/dist/{ink → render}/optimizer.d.ts +0 -0
- /package/dist/{ink → render}/output.d.ts +0 -0
- /package/dist/{ink → render}/parse-keypress.d.ts +0 -0
- /package/dist/{ink → render}/reconciler.d.ts +0 -0
- /package/dist/{ink → render}/render-border.d.ts +0 -0
- /package/dist/{ink → render}/render-node-to-output.d.ts +0 -0
- /package/dist/{ink → render}/render-to-screen.d.ts +0 -0
- /package/dist/{ink → render}/renderer.d.ts +0 -0
- /package/dist/{ink → render}/root.d.ts +0 -0
- /package/dist/{ink → render}/screen.d.ts +0 -0
- /package/dist/{ink → render}/searchHighlight.d.ts +0 -0
- /package/dist/{ink → render}/selection.d.ts +0 -0
- /package/dist/{ink → render}/squash-text-nodes.d.ts +0 -0
- /package/dist/{ink → render}/stringWidth.d.ts +0 -0
- /package/dist/{ink → render}/styles.d.ts +0 -0
- /package/dist/{ink → render}/supports-hyperlinks.d.ts +0 -0
- /package/dist/{ink → render}/tabstops.d.ts +0 -0
- /package/dist/{ink → render}/terminal-focus-state.d.ts +0 -0
- /package/dist/{ink → render}/terminal-querier.d.ts +0 -0
- /package/dist/{ink → render}/terminal.d.ts +0 -0
- /package/dist/{ink → render}/termio/ansi.d.ts +0 -0
- /package/dist/{ink → render}/termio/csi.d.ts +0 -0
- /package/dist/{ink → render}/termio/dec.d.ts +0 -0
- /package/dist/{ink → render}/termio/esc.d.ts +0 -0
- /package/dist/{ink → render}/termio/osc.d.ts +0 -0
- /package/dist/{ink → render}/termio/parser.d.ts +0 -0
- /package/dist/{ink → render}/termio/sgr.d.ts +0 -0
- /package/dist/{ink → render}/termio/tokenize.d.ts +0 -0
- /package/dist/{ink → render}/termio/types.d.ts +0 -0
- /package/dist/{ink → render}/termio.d.ts +0 -0
- /package/dist/{ink → render}/useTerminalNotification.d.ts +0 -0
- /package/dist/{ink → render}/warn.d.ts +0 -0
- /package/dist/{ink → render}/widest-line.d.ts +0 -0
- /package/dist/{ink → render}/wrap-text.d.ts +0 -0
- /package/dist/{ink → render}/wrapAnsi.d.ts +0 -0
|
@@ -271,13 +271,35 @@ var SessionManager = class {
|
|
|
271
271
|
if (!_fs.existsSync.call(void 0, stateFile)) continue;
|
|
272
272
|
try {
|
|
273
273
|
const state = JSON.parse(_fs.readFileSync.call(void 0, stateFile, "utf-8"));
|
|
274
|
-
|
|
274
|
+
const transcriptFile = _path.join.call(void 0, this.sessionsDir, dir, "transcript.jsonl");
|
|
275
|
+
const preview = readFirstUserMessage(transcriptFile);
|
|
276
|
+
sessions.push({ ...state, preview });
|
|
275
277
|
} catch (e4) {
|
|
276
278
|
}
|
|
277
279
|
}
|
|
278
280
|
return sessions.sort((a, b) => b.startedAt - a.startedAt).slice(0, limit);
|
|
279
281
|
}
|
|
280
282
|
};
|
|
283
|
+
function readFirstUserMessage(transcriptFile) {
|
|
284
|
+
if (!_fs.existsSync.call(void 0, transcriptFile)) return void 0;
|
|
285
|
+
const raw = _fs.readFileSync.call(void 0, transcriptFile, "utf-8");
|
|
286
|
+
for (const line of raw.split("\n")) {
|
|
287
|
+
if (!line) continue;
|
|
288
|
+
let event;
|
|
289
|
+
try {
|
|
290
|
+
event = JSON.parse(line);
|
|
291
|
+
} catch (e5) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (event.type !== "message") continue;
|
|
295
|
+
if (_optionalChain([event, 'access', _8 => _8.data, 'optionalAccess', _9 => _9.role]) !== "user") continue;
|
|
296
|
+
const content = event.data.content;
|
|
297
|
+
const text = typeof content === "string" ? content : Array.isArray(content) ? _nullishCoalesce(_optionalChain([content, 'access', _10 => _10.find, 'call', _11 => _11((b) => b.type === "text"), 'optionalAccess', _12 => _12.text]), () => ( "")) : "";
|
|
298
|
+
if (!text.trim()) continue;
|
|
299
|
+
return text.replace(/\s+/g, " ").trim();
|
|
300
|
+
}
|
|
301
|
+
return void 0;
|
|
302
|
+
}
|
|
281
303
|
|
|
282
304
|
|
|
283
305
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
NoopEvaluator,
|
|
5
5
|
RunManager,
|
|
6
6
|
registerPreset
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ID6EJUHP.js";
|
|
8
8
|
import {
|
|
9
9
|
init_esm_shims
|
|
10
10
|
} from "./chunk-DI7RDLOS.js";
|
|
@@ -90,11 +90,14 @@ function defineProduct(definition, runtime) {
|
|
|
90
90
|
disabledBuiltinTools: adapter?.disableTools,
|
|
91
91
|
customSystemPrompt: presetDef.customPrompt,
|
|
92
92
|
appendSystemPrompt: presetDef.appendPrompt,
|
|
93
|
+
hooks: adapter?.hooks,
|
|
93
94
|
customTools: customToolEntries.length > 0 ? customToolEntries : void 0
|
|
94
95
|
},
|
|
95
96
|
concurrency: contract?.concurrency ?? 1,
|
|
96
97
|
runsDir,
|
|
97
|
-
evaluator
|
|
98
|
+
evaluator,
|
|
99
|
+
defaultTags: contract?.defaultTags,
|
|
100
|
+
defaultMetadata: contract?.defaultMetadata
|
|
98
101
|
});
|
|
99
102
|
return { manager, preset: agentPreset, customTools };
|
|
100
103
|
}
|
|
@@ -3,13 +3,16 @@ import {
|
|
|
3
3
|
LLMError,
|
|
4
4
|
LLMRateLimitError
|
|
5
5
|
} from "./chunk-FUOKLKR2.js";
|
|
6
|
+
import {
|
|
7
|
+
logger
|
|
8
|
+
} from "./chunk-ZRVPCXI7.js";
|
|
6
9
|
import {
|
|
7
10
|
init_esm_shims
|
|
8
11
|
} from "./chunk-DI7RDLOS.js";
|
|
9
12
|
|
|
10
13
|
// src/llm/client-base.ts
|
|
11
14
|
init_esm_shims();
|
|
12
|
-
var LLMClientBase = class {
|
|
15
|
+
var LLMClientBase = class _LLMClientBase {
|
|
13
16
|
constructor(config) {
|
|
14
17
|
this.config = config;
|
|
15
18
|
this.provider = config.provider;
|
|
@@ -28,6 +31,13 @@ var LLMClientBase = class {
|
|
|
28
31
|
timeout;
|
|
29
32
|
retryMaxAttempts;
|
|
30
33
|
enableStreaming;
|
|
34
|
+
/**
|
|
35
|
+
* Process-wide hook fired on every LLM response. The CLI installs this in
|
|
36
|
+
* main.ts to feed the cost tracker; lives on the base class so every code
|
|
37
|
+
* path (REPL, run, arena, sub-agents) reports through one funnel without
|
|
38
|
+
* each call site needing to remember.
|
|
39
|
+
*/
|
|
40
|
+
static onUsage;
|
|
31
41
|
usage = {
|
|
32
42
|
records: [],
|
|
33
43
|
totalPromptTokens: 0,
|
|
@@ -41,6 +51,7 @@ var LLMClientBase = class {
|
|
|
41
51
|
this.usage.totalCompletionTokens += usage.completionTokens;
|
|
42
52
|
this.usage.totalTokens += usage.totalTokens;
|
|
43
53
|
this.usage.requestCount++;
|
|
54
|
+
_LLMClientBase.onUsage?.(this.model, usage);
|
|
44
55
|
}
|
|
45
56
|
getUsage() {
|
|
46
57
|
return { ...this.usage };
|
|
@@ -56,11 +67,39 @@ var LLMClientBase = class {
|
|
|
56
67
|
if (err instanceof ContextLimitError) throw err;
|
|
57
68
|
if (err instanceof LLMRateLimitError) {
|
|
58
69
|
const waitMs = (err.retryAfter ?? attempt * 2) * 1e3;
|
|
70
|
+
logger.warn("llm.retry", {
|
|
71
|
+
cat: "llm",
|
|
72
|
+
provider: this.provider,
|
|
73
|
+
model: this.model,
|
|
74
|
+
attempt,
|
|
75
|
+
of: attempts,
|
|
76
|
+
reason: "rate_limit",
|
|
77
|
+
waitMs
|
|
78
|
+
});
|
|
59
79
|
await new Promise((r) => setTimeout(r, waitMs));
|
|
60
80
|
continue;
|
|
61
81
|
}
|
|
62
|
-
if (attempt === attempts)
|
|
82
|
+
if (attempt === attempts) {
|
|
83
|
+
logger.error("llm.exhausted", {
|
|
84
|
+
cat: "llm",
|
|
85
|
+
provider: this.provider,
|
|
86
|
+
model: this.model,
|
|
87
|
+
attempts,
|
|
88
|
+
error: err.message
|
|
89
|
+
});
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
63
92
|
const backoff = Math.min(1e3 * Math.pow(2, attempt - 1), 3e4);
|
|
93
|
+
logger.warn("llm.retry", {
|
|
94
|
+
cat: "llm",
|
|
95
|
+
provider: this.provider,
|
|
96
|
+
model: this.model,
|
|
97
|
+
attempt,
|
|
98
|
+
of: attempts,
|
|
99
|
+
reason: "error",
|
|
100
|
+
error: err.message,
|
|
101
|
+
backoffMs: backoff
|
|
102
|
+
});
|
|
64
103
|
await new Promise((r) => setTimeout(r, backoff));
|
|
65
104
|
}
|
|
66
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FileRunStore,
|
|
3
3
|
RunManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ID6EJUHP.js";
|
|
5
5
|
import {
|
|
6
6
|
init_esm_shims
|
|
7
7
|
} from "./chunk-DI7RDLOS.js";
|
|
@@ -28,11 +28,14 @@ function createRunManager(options) {
|
|
|
28
28
|
enabledBuiltinTools: options.enabledBuiltinTools,
|
|
29
29
|
disabledBuiltinTools: options.disabledBuiltinTools,
|
|
30
30
|
customSystemPrompt: options.customSystemPrompt,
|
|
31
|
-
appendSystemPrompt: options.appendSystemPrompt
|
|
31
|
+
appendSystemPrompt: options.appendSystemPrompt,
|
|
32
|
+
hooks: options.hooks
|
|
32
33
|
},
|
|
33
34
|
concurrency: options.concurrency ?? 1,
|
|
34
35
|
runsDir,
|
|
35
|
-
evaluator: options.evaluator
|
|
36
|
+
evaluator: options.evaluator,
|
|
37
|
+
defaultTags: options.defaultTags,
|
|
38
|
+
defaultMetadata: options.defaultMetadata
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
|