@livx.cc/agentx 0.99.12 → 0.99.14
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/dist/{Agent-DYMSg21f.d.ts → Agent-CsVuR2O0.d.ts} +10 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +30 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +73 -1
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +42 -0
- package/dist/models.js +45 -0
- package/dist/models.js.map +1 -0
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-
|
|
2
|
-
export { C as ChatFragment, D as DEFAULT_MUTATING, b as Decision, P as PermissionOptions, c as PermissionPolicy, d as PermissionRule, e as PreToolUseDecision, R as ReasoningEffort, f as RecordingHooks, g as RecordingLifecycle, T as ToolUse, i as ToolUseMeta, j as composeHooks, p as planMode, r as reasoningToChatFragment } from './Agent-
|
|
1
|
+
import { a as AgentOptions, H as Hooks, h as RunResult, A as Agent } from './Agent-CsVuR2O0.js';
|
|
2
|
+
export { C as ChatFragment, D as DEFAULT_MUTATING, b as Decision, P as PermissionOptions, c as PermissionPolicy, d as PermissionRule, e as PreToolUseDecision, R as ReasoningEffort, f as RecordingHooks, g as RecordingLifecycle, T as ToolUse, i as ToolUseMeta, j as composeHooks, p as planMode, r as reasoningToChatFragment } from './Agent-CsVuR2O0.js';
|
|
3
|
+
export { MODEL_ALIASES, ModelSwitch, ResolveModelSwitchOpts, modelShortLabel, resolveModelAlias, resolveModelSwitch } from './models.js';
|
|
3
4
|
import { IFilesystem, FileMetadata } from '@livx.cc/wcli/core';
|
|
4
5
|
export { CommandExecutor, FileMetadata, IFilesystem, IndexedDbFilesystem, MemFilesystem, registerHeadlessCommands } from '@livx.cc/wcli/core';
|
|
5
6
|
import { BodDB } from '@bod.ee/db';
|
package/dist/index.js
CHANGED
|
@@ -3280,7 +3280,34 @@ var AgentOptions = class {
|
|
|
3280
3280
|
* `'off'`/undefined = none; `'low'|'medium'|'high'` or a raw token budget. Mapped to the
|
|
3281
3281
|
* provider-specific request shape via {@link reasoningToChatFragment}; explicit `providerOptions` wins. */
|
|
3282
3282
|
reasoning;
|
|
3283
|
+
/** Seed a fresh `run()` with prior conversation turns (real role/content messages) so the model
|
|
3284
|
+
* sees history as structured turns instead of a flattened text blob. They are inserted AFTER the
|
|
3285
|
+
* stable system prompt and BEFORE the current user turn — so the cached system(+tools) prefix never
|
|
3286
|
+
* shifts. Turns are normalized before sending (empties dropped, adjacent same-role coalesced, and the
|
|
3287
|
+
* first tail turn forced to `user`) so the transcript is always a valid Anthropic alternation ending
|
|
3288
|
+
* at the current user prompt. Unset/empty ⇒ current behavior, byte-for-byte. */
|
|
3289
|
+
priorMessages;
|
|
3283
3290
|
};
|
|
3291
|
+
function seedTranscriptTail(prior, current) {
|
|
3292
|
+
const seq = (prior ?? []).filter((m) => contentText(m.content).trim().length > 0).map((m) => ({ role: m.role, content: m.content }));
|
|
3293
|
+
seq.push({ role: "user", content: current });
|
|
3294
|
+
const out = [];
|
|
3295
|
+
for (const m of seq) {
|
|
3296
|
+
const last = out[out.length - 1];
|
|
3297
|
+
if (last && last.role === m.role) {
|
|
3298
|
+
if (typeof last.content === "string" && typeof m.content === "string") {
|
|
3299
|
+
last.content = `${last.content}
|
|
3300
|
+
|
|
3301
|
+
${m.content}`;
|
|
3302
|
+
continue;
|
|
3303
|
+
}
|
|
3304
|
+
out.push({ role: m.role === "user" ? "assistant" : "user", content: "(continuing)" });
|
|
3305
|
+
}
|
|
3306
|
+
out.push({ role: m.role, content: m.content });
|
|
3307
|
+
}
|
|
3308
|
+
if (out.length && out[0].role !== "user") out.unshift({ role: "user", content: "(Earlier conversation)" });
|
|
3309
|
+
return out;
|
|
3310
|
+
}
|
|
3284
3311
|
var Agent = class _Agent {
|
|
3285
3312
|
options;
|
|
3286
3313
|
transcript = [];
|
|
@@ -3448,7 +3475,9 @@ var Agent = class _Agent {
|
|
|
3448
3475
|
const userContent = await this.applyPromptSubmit(task);
|
|
3449
3476
|
this.transcript = [
|
|
3450
3477
|
{ role: "system", content: systemPrompt + (startCtx ? "\n\n" + startCtx : "") },
|
|
3451
|
-
|
|
3478
|
+
// Prior turns (if any) sit between the stable system prefix and the live user turn — the cached
|
|
3479
|
+
// system(+tools) prefix is unaffected; normalization keeps the alternation valid.
|
|
3480
|
+
...seedTranscriptTail(this.options.priorMessages, userContent)
|
|
3452
3481
|
];
|
|
3453
3482
|
return this.runLoop();
|
|
3454
3483
|
}
|
|
@@ -3894,6 +3923,45 @@ function lastAssistantText(messages) {
|
|
|
3894
3923
|
return "";
|
|
3895
3924
|
}
|
|
3896
3925
|
|
|
3926
|
+
// src/models.ts
|
|
3927
|
+
var MODEL_ALIASES = {
|
|
3928
|
+
fable: "claude-fable-5",
|
|
3929
|
+
"fable-5": "claude-fable-5",
|
|
3930
|
+
opus: "claude-opus-4-8",
|
|
3931
|
+
"opus-4-8": "claude-opus-4-8",
|
|
3932
|
+
"opus-4-7": "claude-opus-4-7",
|
|
3933
|
+
"opus-4-6": "claude-opus-4-6",
|
|
3934
|
+
sonnet: "claude-sonnet-4-6",
|
|
3935
|
+
haiku: "claude-haiku-4-5-20251001"
|
|
3936
|
+
};
|
|
3937
|
+
function resolveModelAlias(input) {
|
|
3938
|
+
const slash = input.indexOf("/");
|
|
3939
|
+
const prefix = slash === -1 ? "" : input.slice(0, slash + 1);
|
|
3940
|
+
const rest = slash === -1 ? input : input.slice(slash + 1);
|
|
3941
|
+
return prefix + (MODEL_ALIASES[rest.toLowerCase()] ?? rest);
|
|
3942
|
+
}
|
|
3943
|
+
function modelShortLabel(model) {
|
|
3944
|
+
if (!model) return "default";
|
|
3945
|
+
const id = model.split("/").pop();
|
|
3946
|
+
return id.replace(/^claude-/, "").replace(/-\d.*$/, "");
|
|
3947
|
+
}
|
|
3948
|
+
function resolveModelSwitch(opts) {
|
|
3949
|
+
const { requested, current, prior, allowed } = opts;
|
|
3950
|
+
if (!requested) return { model: current, denied: false };
|
|
3951
|
+
if (allowed && !allowed.some((a) => modelShortLabel(a) === modelShortLabel(requested))) {
|
|
3952
|
+
return { model: current, denied: true };
|
|
3953
|
+
}
|
|
3954
|
+
const fmt = opts.format ?? ((from, to) => `_[switching from ${from} to ${to}]_
|
|
3955
|
+
|
|
3956
|
+
`);
|
|
3957
|
+
const changed = prior !== void 0 && modelShortLabel(prior) !== modelShortLabel(requested);
|
|
3958
|
+
return {
|
|
3959
|
+
model: requested,
|
|
3960
|
+
denied: false,
|
|
3961
|
+
notice: changed ? fmt(modelShortLabel(prior), modelShortLabel(requested)) : void 0
|
|
3962
|
+
};
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3897
3965
|
// src/index.ts
|
|
3898
3966
|
init_NodeDiskFilesystem();
|
|
3899
3967
|
|
|
@@ -7610,6 +7678,7 @@ export {
|
|
|
7610
7678
|
JailedFilesystem,
|
|
7611
7679
|
LessonOptionsDefaults,
|
|
7612
7680
|
MEMORY_PROMPT,
|
|
7681
|
+
MODEL_ALIASES,
|
|
7613
7682
|
MemFilesystem3 as MemFilesystem,
|
|
7614
7683
|
MountFilesystem,
|
|
7615
7684
|
NodeDiskFilesystem,
|
|
@@ -7684,6 +7753,7 @@ export {
|
|
|
7684
7753
|
mcpToolToAgentTool,
|
|
7685
7754
|
mcpToolsToAgentTools,
|
|
7686
7755
|
mkdirp,
|
|
7756
|
+
modelShortLabel,
|
|
7687
7757
|
multiEditTool,
|
|
7688
7758
|
nextCronAfter,
|
|
7689
7759
|
parseCron,
|
|
@@ -7698,6 +7768,8 @@ export {
|
|
|
7698
7768
|
repoIndex,
|
|
7699
7769
|
repoMapTool,
|
|
7700
7770
|
resolveAuth,
|
|
7771
|
+
resolveModelAlias,
|
|
7772
|
+
resolveModelSwitch,
|
|
7701
7773
|
rollbackTool,
|
|
7702
7774
|
sandboxAgentOptions,
|
|
7703
7775
|
scanCommands,
|