@livx.cc/agentx 0.99.83 → 0.99.85
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/README.md +2 -2
- package/dist/cli.js +90 -47
- package/dist/cli.js.map +1 -1
- package/dist/directives.js +2 -12
- package/dist/directives.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +63 -53
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +7 -11
- package/dist/models.js +8 -12
- package/dist/models.js.map +1 -1
- package/dist/tools.shell.js +10 -1
- package/dist/tools.shell.js.map +1 -1
- package/package.json +2 -2
package/dist/models.d.ts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Harness-level so every agentx consumer (unclaw, para-chat, …) resolves `[opus]`-style
|
|
5
|
-
* aliases, gates by an allow-list, and announces a switch the same way. Policy (which models
|
|
6
|
-
* a caller may use) and session state (the prior model) stay with the consumer; this module
|
|
7
|
-
* is the shared mechanism.
|
|
8
|
-
*/
|
|
9
|
-
/** Canonical short aliases → concrete Anthropic model ids. */
|
|
1
|
+
/** Canonical short aliases → concrete Anthropic model ids — DERIVED from ai.libx.js's catalog (newest entry per
|
|
2
|
+
* family, plus versioned `opus-5`-style aliases). Never hand-pin an id here: a new model = one catalog entry. */
|
|
10
3
|
declare const MODEL_ALIASES: Record<string, string>;
|
|
4
|
+
/** Newest catalog model of a Claude family as a provider-qualified id (`'sonnet'` → `'anthropic/claude-sonnet-5-5'`).
|
|
5
|
+
* Use this for every default/tier — a literal dated id goes stale the day the next model ships. */
|
|
6
|
+
declare function latestClaude(family: 'fable' | 'opus' | 'sonnet' | 'haiku', provider?: string): string;
|
|
11
7
|
/** Resolve an alias to a concrete id. A provider prefix ("anthropic/") is preserved; unknown ids pass through. */
|
|
12
8
|
declare function resolveModelAlias(input: string): string;
|
|
13
9
|
/** The provider of a model id ("cursor/x" -> "cursor"). Provider-specific `providerOptions` are only
|
|
14
10
|
* portable within the same provider — leaking them across is a hard 400.
|
|
15
11
|
*
|
|
16
12
|
* A BARE id is the common case, not the exception: `resolveModelAlias('haiku')` yields
|
|
17
|
-
* `claude-haiku-
|
|
13
|
+
* `claude-haiku-5-5` with no prefix (ai.libx.js resolves it fuzzily downstream), so reading
|
|
18
14
|
* only the literal "/" made every aliased child look like a provider switch and silently dropped the
|
|
19
15
|
* parent's options. The fix belongs HERE — the alias table must keep emitting the ids ai.libx.js
|
|
20
16
|
* expects, and the comparison is provider identity, not string identity.
|
|
@@ -53,4 +49,4 @@ interface ModelSwitch {
|
|
|
53
49
|
*/
|
|
54
50
|
declare function resolveModelSwitch(opts: ResolveModelSwitchOpts): ModelSwitch;
|
|
55
51
|
|
|
56
|
-
export { MODEL_ALIASES, type ModelSwitch, type ResolveModelSwitchOpts, modelProvider, modelShortLabel, resolveModelAlias, resolveModelSwitch };
|
|
52
|
+
export { MODEL_ALIASES, type ModelSwitch, type ResolveModelSwitchOpts, latestClaude, modelProvider, modelShortLabel, resolveModelAlias, resolveModelSwitch };
|
package/dist/models.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
// src/models.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"opus-4-7": "claude-opus-4-7",
|
|
10
|
-
"opus-4-6": "claude-opus-4-6",
|
|
11
|
-
sonnet: "claude-sonnet-4-6",
|
|
12
|
-
haiku: "claude-haiku-4-5-20251001"
|
|
13
|
-
};
|
|
2
|
+
import { claudeModelAliases } from "ai.libx.js";
|
|
3
|
+
var MODEL_ALIASES = { ...claudeModelAliases };
|
|
4
|
+
function latestClaude(family, provider = "anthropic") {
|
|
5
|
+
const id = MODEL_ALIASES[family];
|
|
6
|
+
if (!id) throw new Error(`ai.libx.js catalog has no Claude ${family} model`);
|
|
7
|
+
return `${provider}/${id}`;
|
|
8
|
+
}
|
|
14
9
|
function resolveModelAlias(input) {
|
|
15
10
|
const slash = input.indexOf("/");
|
|
16
11
|
const prefix = slash === -1 ? "" : input.slice(0, slash + 1);
|
|
@@ -47,6 +42,7 @@ function resolveModelSwitch(opts) {
|
|
|
47
42
|
}
|
|
48
43
|
export {
|
|
49
44
|
MODEL_ALIASES,
|
|
45
|
+
latestClaude,
|
|
50
46
|
modelProvider,
|
|
51
47
|
modelShortLabel,
|
|
52
48
|
resolveModelAlias,
|
package/dist/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/models.ts"],"sourcesContent":["/**\n * Model aliasing + mid-conversation switch resolution — pure
|
|
1
|
+
{"version":3,"sources":["../src/models.ts"],"sourcesContent":["/**\n * Model aliasing + mid-conversation switch resolution — pure; aliases come from ai.libx.js's catalog.\n *\n * Harness-level so every agentx consumer (unclaw, para-chat, …) resolves `[opus]`-style\n * aliases, gates by an allow-list, and announces a switch the same way. Policy (which models\n * a caller may use) and session state (the prior model) stay with the consumer; this module\n * is the shared mechanism.\n */\nimport { claudeModelAliases } from 'ai.libx.js';\n\n/** Canonical short aliases → concrete Anthropic model ids — DERIVED from ai.libx.js's catalog (newest entry per\n * family, plus versioned `opus-5`-style aliases). Never hand-pin an id here: a new model = one catalog entry. */\nexport const MODEL_ALIASES: Record<string, string> = { ...claudeModelAliases };\n\n/** Newest catalog model of a Claude family as a provider-qualified id (`'sonnet'` → `'anthropic/claude-sonnet-5-5'`).\n * Use this for every default/tier — a literal dated id goes stale the day the next model ships. */\nexport function latestClaude(family: 'fable' | 'opus' | 'sonnet' | 'haiku', provider = 'anthropic'): string {\n const id = MODEL_ALIASES[family];\n if (!id) throw new Error(`ai.libx.js catalog has no Claude ${family} model`);\n return `${provider}/${id}`;\n}\n\n/** Resolve an alias to a concrete id. A provider prefix (\"anthropic/\") is preserved; unknown ids pass through. */\nexport function resolveModelAlias(input: string): string {\n const slash = input.indexOf('/');\n const prefix = slash === -1 ? '' : input.slice(0, slash + 1);\n const rest = slash === -1 ? input : input.slice(slash + 1);\n // claude-code's catalogue IS the aliases (claude-code/opus); expanding them yields an unknown id.\n if (prefix === 'claude-code/') return input;\n return prefix + (MODEL_ALIASES[rest.toLowerCase()] ?? rest);\n}\n\n/** The provider of a model id (\"cursor/x\" -> \"cursor\"). Provider-specific `providerOptions` are only\n * portable within the same provider — leaking them across is a hard 400.\n *\n * A BARE id is the common case, not the exception: `resolveModelAlias('haiku')` yields\n * `claude-haiku-5-5` with no prefix (ai.libx.js resolves it fuzzily downstream), so reading\n * only the literal \"/\" made every aliased child look like a provider switch and silently dropped the\n * parent's options. The fix belongs HERE — the alias table must keep emitting the ids ai.libx.js\n * expects, and the comparison is provider identity, not string identity.\n *\n * A bare id we can't attribute is UNKNOWN, not a shared provider: it gets a per-id marker so two\n * different unknown ids never compare equal (returning \"\" for both made them look like one provider\n * and would have leaked one host's options onto the other's model). An unknown id still compares\n * equal to ITSELF, so a child staying on the parent's exact model keeps the parent's options. */\nexport function modelProvider(model: string): string {\n const i = model.indexOf('/');\n if (i !== -1) return model.slice(0, i);\n if (/^claude-/i.test(model)) return 'anthropic';\n return `?${model}`; // unknown: identity-scoped, never equal to a different unknown id\n}\n\n/** Short, human-friendly name for a resolved model id (e.g. \"anthropic/claude-opus-4-8\" → \"opus\"). */\nexport function modelShortLabel(model?: string): string {\n if (!model) return 'default';\n const id = model.split('/').pop()!;\n return id.replace(/^claude-/, '').replace(/-\\d.*$/, '');\n}\n\nexport interface ResolveModelSwitchOpts {\n /** Model requested for this turn (e.g. from an inline directive). Undefined = keep `current`. */\n requested?: string;\n /** The turn's default/current model when nothing is requested. */\n current: string;\n /** The session's prior resolved model — drives change detection + the notice. */\n prior?: string;\n /** If set, `requested` must match one of these (by short label) or it's denied and `current` is kept. */\n allowed?: string[];\n /** Announcement formatter. Default: `_[switching from x to y]_\\n\\n`. */\n format?: (from: string, to: string) => string;\n}\n\nexport interface ModelSwitch {\n /** The model to run this turn. */\n model: string;\n /** True when `requested` was rejected by `allowed` and `model` fell back to `current`. */\n denied: boolean;\n /** Inline notice to surface when the model actually changed vs `prior`, else undefined. */\n notice?: string;\n}\n\n/**\n * Resolve which model a turn runs, given an optional request, an allow-list, and the prior model.\n * Comparisons are by short label so provider-prefixed and dated ids unify\n * (\"anthropic/claude-opus-4-8\" ≡ \"claude-opus-4-8\" ≡ \"opus\").\n */\nexport function resolveModelSwitch(opts: ResolveModelSwitchOpts): ModelSwitch {\n const { requested, current, prior, allowed } = opts;\n if (!requested) return { model: current, denied: false };\n if (allowed && !allowed.some((a) => modelShortLabel(a) === modelShortLabel(requested))) {\n return { model: current, denied: true };\n }\n const fmt = opts.format ?? ((from: string, to: string) => `_[switching from ${from} to ${to}]_\\n\\n`);\n const changed = prior !== undefined && modelShortLabel(prior) !== modelShortLabel(requested);\n return {\n model: requested,\n denied: false,\n notice: changed ? fmt(modelShortLabel(prior!), modelShortLabel(requested)) : undefined,\n };\n}\n"],"mappings":";AAQA,SAAS,0BAA0B;AAI5B,IAAM,gBAAwC,EAAE,GAAG,mBAAmB;AAItE,SAAS,aAAa,QAA+C,WAAW,aAAqB;AAC1G,QAAM,KAAK,cAAc,MAAM;AAC/B,MAAI,CAAC,GAAI,OAAM,IAAI,MAAM,oCAAoC,MAAM,QAAQ;AAC3E,SAAO,GAAG,QAAQ,IAAI,EAAE;AAC1B;AAGO,SAAS,kBAAkB,OAAuB;AACvD,QAAM,QAAQ,MAAM,QAAQ,GAAG;AAC/B,QAAM,SAAS,UAAU,KAAK,KAAK,MAAM,MAAM,GAAG,QAAQ,CAAC;AAC3D,QAAM,OAAO,UAAU,KAAK,QAAQ,MAAM,MAAM,QAAQ,CAAC;AAEzD,MAAI,WAAW,eAAgB,QAAO;AACtC,SAAO,UAAU,cAAc,KAAK,YAAY,CAAC,KAAK;AACxD;AAeO,SAAS,cAAc,OAAuB;AACnD,QAAM,IAAI,MAAM,QAAQ,GAAG;AAC3B,MAAI,MAAM,GAAI,QAAO,MAAM,MAAM,GAAG,CAAC;AACrC,MAAI,YAAY,KAAK,KAAK,EAAG,QAAO;AACpC,SAAO,IAAI,KAAK;AAClB;AAGO,SAAS,gBAAgB,OAAwB;AACtD,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI;AAChC,SAAO,GAAG,QAAQ,YAAY,EAAE,EAAE,QAAQ,UAAU,EAAE;AACxD;AA6BO,SAAS,mBAAmB,MAA2C;AAC5E,QAAM,EAAE,WAAW,SAAS,OAAO,QAAQ,IAAI;AAC/C,MAAI,CAAC,UAAW,QAAO,EAAE,OAAO,SAAS,QAAQ,MAAM;AACvD,MAAI,WAAW,CAAC,QAAQ,KAAK,CAAC,MAAM,gBAAgB,CAAC,MAAM,gBAAgB,SAAS,CAAC,GAAG;AACtF,WAAO,EAAE,OAAO,SAAS,QAAQ,KAAK;AAAA,EACxC;AACA,QAAM,MAAM,KAAK,WAAW,CAAC,MAAc,OAAe,oBAAoB,IAAI,OAAO,EAAE;AAAA;AAAA;AAC3F,QAAM,UAAU,UAAU,UAAa,gBAAgB,KAAK,MAAM,gBAAgB,SAAS;AAC3F,SAAO;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ,UAAU,IAAI,gBAAgB,KAAM,GAAG,gBAAgB,SAAS,CAAC,IAAI;AAAA,EAC/E;AACF;","names":[]}
|
package/dist/tools.shell.js
CHANGED
|
@@ -231,6 +231,15 @@ function makeGrepTool(opts) {
|
|
|
231
231
|
var globTool = makeGlobTool();
|
|
232
232
|
var grepTool = makeGrepTool();
|
|
233
233
|
|
|
234
|
+
// src/models.ts
|
|
235
|
+
import { claudeModelAliases } from "ai.libx.js";
|
|
236
|
+
var MODEL_ALIASES = { ...claudeModelAliases };
|
|
237
|
+
function latestClaude(family, provider = "anthropic") {
|
|
238
|
+
const id = MODEL_ALIASES[family];
|
|
239
|
+
if (!id) throw new Error(`ai.libx.js catalog has no Claude ${family} model`);
|
|
240
|
+
return `${provider}/${id}`;
|
|
241
|
+
}
|
|
242
|
+
|
|
234
243
|
// src/tools.web.ts
|
|
235
244
|
var log4 = forComponent("web");
|
|
236
245
|
function htmlToText(html) {
|
|
@@ -454,7 +463,7 @@ function makeWebSearchTool(options = {}) {
|
|
|
454
463
|
if (provider === "anthropic") {
|
|
455
464
|
const akey = options.anthropicApiKey ?? process.env.ANTHROPIC_API_KEY;
|
|
456
465
|
if (!akey) return "Error: WebSearchAnthropic requires ANTHROPIC_API_KEY (set in env)";
|
|
457
|
-
return await anthropicSearch(q, { key: akey, model: options.model ?? "
|
|
466
|
+
return await anthropicSearch(q, { key: akey, model: options.model ?? latestClaude("haiku").slice("anthropic/".length), fetch: doFetch, signal: ctl.signal });
|
|
458
467
|
}
|
|
459
468
|
if (useFirecrawl) {
|
|
460
469
|
if (!fcKey) return "Error: Firecrawl provider selected but FIRECRAWL_API_KEY is not set";
|