@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.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Model aliasing + mid-conversation switch resolution — pure, dependency-free.
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. */
10
+ declare const MODEL_ALIASES: Record<string, string>;
11
+ /** Resolve an alias to a concrete id. A provider prefix ("anthropic/") is preserved; unknown ids pass through. */
12
+ declare function resolveModelAlias(input: string): string;
13
+ /** Short, human-friendly name for a resolved model id (e.g. "anthropic/claude-opus-4-8" → "opus"). */
14
+ declare function modelShortLabel(model?: string): string;
15
+ interface ResolveModelSwitchOpts {
16
+ /** Model requested for this turn (e.g. from an inline directive). Undefined = keep `current`. */
17
+ requested?: string;
18
+ /** The turn's default/current model when nothing is requested. */
19
+ current: string;
20
+ /** The session's prior resolved model — drives change detection + the notice. */
21
+ prior?: string;
22
+ /** If set, `requested` must match one of these (by short label) or it's denied and `current` is kept. */
23
+ allowed?: string[];
24
+ /** Announcement formatter. Default: `_[switching from x to y]_\n\n`. */
25
+ format?: (from: string, to: string) => string;
26
+ }
27
+ interface ModelSwitch {
28
+ /** The model to run this turn. */
29
+ model: string;
30
+ /** True when `requested` was rejected by `allowed` and `model` fell back to `current`. */
31
+ denied: boolean;
32
+ /** Inline notice to surface when the model actually changed vs `prior`, else undefined. */
33
+ notice?: string;
34
+ }
35
+ /**
36
+ * Resolve which model a turn runs, given an optional request, an allow-list, and the prior model.
37
+ * Comparisons are by short label so provider-prefixed and dated ids unify
38
+ * ("anthropic/claude-opus-4-8" ≡ "claude-opus-4-8" ≡ "opus").
39
+ */
40
+ declare function resolveModelSwitch(opts: ResolveModelSwitchOpts): ModelSwitch;
41
+
42
+ export { MODEL_ALIASES, type ModelSwitch, type ResolveModelSwitchOpts, modelShortLabel, resolveModelAlias, resolveModelSwitch };
package/dist/models.js ADDED
@@ -0,0 +1,45 @@
1
+ // src/models.ts
2
+ var MODEL_ALIASES = {
3
+ fable: "claude-fable-5",
4
+ "fable-5": "claude-fable-5",
5
+ opus: "claude-opus-4-8",
6
+ "opus-4-8": "claude-opus-4-8",
7
+ "opus-4-7": "claude-opus-4-7",
8
+ "opus-4-6": "claude-opus-4-6",
9
+ sonnet: "claude-sonnet-4-6",
10
+ haiku: "claude-haiku-4-5-20251001"
11
+ };
12
+ function resolveModelAlias(input) {
13
+ const slash = input.indexOf("/");
14
+ const prefix = slash === -1 ? "" : input.slice(0, slash + 1);
15
+ const rest = slash === -1 ? input : input.slice(slash + 1);
16
+ return prefix + (MODEL_ALIASES[rest.toLowerCase()] ?? rest);
17
+ }
18
+ function modelShortLabel(model) {
19
+ if (!model) return "default";
20
+ const id = model.split("/").pop();
21
+ return id.replace(/^claude-/, "").replace(/-\d.*$/, "");
22
+ }
23
+ function resolveModelSwitch(opts) {
24
+ const { requested, current, prior, allowed } = opts;
25
+ if (!requested) return { model: current, denied: false };
26
+ if (allowed && !allowed.some((a) => modelShortLabel(a) === modelShortLabel(requested))) {
27
+ return { model: current, denied: true };
28
+ }
29
+ const fmt = opts.format ?? ((from, to) => `_[switching from ${from} to ${to}]_
30
+
31
+ `);
32
+ const changed = prior !== void 0 && modelShortLabel(prior) !== modelShortLabel(requested);
33
+ return {
34
+ model: requested,
35
+ denied: false,
36
+ notice: changed ? fmt(modelShortLabel(prior), modelShortLabel(requested)) : void 0
37
+ };
38
+ }
39
+ export {
40
+ MODEL_ALIASES,
41
+ modelShortLabel,
42
+ resolveModelAlias,
43
+ resolveModelSwitch
44
+ };
45
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/models.ts"],"sourcesContent":["/**\n * Model aliasing + mid-conversation switch resolution — pure, dependency-free.\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 */\n\n/** Canonical short aliases → concrete Anthropic model ids. */\nexport const MODEL_ALIASES: Record<string, string> = {\n fable: 'claude-fable-5',\n 'fable-5': 'claude-fable-5',\n opus: 'claude-opus-4-8',\n 'opus-4-8': 'claude-opus-4-8',\n 'opus-4-7': 'claude-opus-4-7',\n 'opus-4-6': 'claude-opus-4-6',\n sonnet: 'claude-sonnet-4-6',\n haiku: 'claude-haiku-4-5-20251001',\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 return prefix + (MODEL_ALIASES[rest.toLowerCase()] ?? rest);\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":";AAUO,IAAM,gBAAwC;AAAA,EACnD,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,OAAO;AACT;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;AACzD,SAAO,UAAU,cAAc,KAAK,YAAY,CAAC,KAAK;AACxD;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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livx.cc/agentx",
3
- "version": "0.99.12",
3
+ "version": "0.99.14",
4
4
  "description": "Edge-native AI agent runtime — drives a virtual filesystem via any LLM (ai.libx.js). Same bytes run in node, browser, or edge.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,6 +18,10 @@
18
18
  "./tools.shell": {
19
19
  "types": "./dist/tools.shell.d.ts",
20
20
  "default": "./dist/tools.shell.js"
21
+ },
22
+ "./models": {
23
+ "types": "./dist/models.d.ts",
24
+ "default": "./dist/models.js"
21
25
  }
22
26
  },
23
27
  "license": "MIT",