@zenera/neo 1.3.2 → 1.3.4

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 CHANGED
@@ -93,7 +93,7 @@ const getWeather = tool<{ city: string }>({
93
93
  execute: ({ city }) => ({ city, tempC: 21, sky: 'clear' }),
94
94
  });
95
95
 
96
- const runner = new AgentRunner({ model: createModel('openai:gpt-5.4-mini') });
96
+ const runner = new AgentRunner({ model: createModel('openai/gpt-5.4-mini') });
97
97
 
98
98
  const planner = runner.agent({
99
99
  name: 'planner',
@@ -141,7 +141,7 @@ The whole system is an `agents.yaml`:
141
141
 
142
142
  ```yaml
143
143
  default: intake
144
- model: anthropic:claude-sonnet-4-5
144
+ model: anthropic/claude-sonnet-4-5
145
145
  skills: agents/skills
146
146
 
147
147
  agents:
@@ -154,7 +154,7 @@ agents:
154
154
  - name: adjuster
155
155
  description: Weighs the written policy against the case and explains the outcome.
156
156
  system: agents/prompts/adjuster.md
157
- model: openai:gpt-5.4
157
+ model: openai/gpt-5.4
158
158
  tools: [files:*, sandbox:*]
159
159
  skills:
160
160
  discovery: index # the model loads what the case needs
package/dist/kernel.d.ts CHANGED
@@ -117,6 +117,8 @@ export interface LlmCallOptions<TCtx = unknown> {
117
117
  request?: ModelRequest;
118
118
  /** needed to validate a `fork` call against the agent's declaration */
119
119
  registry?: AgentRegistry<TCtx>;
120
+ /** the model's `ref`, recorded beside its wire id */
121
+ ref?: string;
120
122
  }
121
123
  /**
122
124
  * Appends the `llm_call` node (plus the nodes its tool calls imply) and moves
package/dist/kernel.js CHANGED
@@ -446,6 +446,7 @@ export async function applyLlmResponse(state, res, model, env, opts = {}) {
446
446
  b.add({
447
447
  type: 'llm_call',
448
448
  model,
449
+ ...(opts.ref ? { ref: opts.ref } : {}),
449
450
  requestDigest: opts.digest ?? (opts.request ? requestDigest(opts.request) : ''),
450
451
  request: opts.request ? await put(env, serializeRequest(opts.request)) : undefined,
451
452
  text: await put(env, res.text),
package/dist/model.d.ts CHANGED
@@ -18,6 +18,12 @@ export interface ModelResponse {
18
18
  }
19
19
  export interface Model {
20
20
  readonly id: string;
21
+ /**
22
+ * The ref that names this model again — `openai/gpt-5-mini` — when it was
23
+ * built from one. `id` is only what goes on the wire, and has lost which
24
+ * provider that was.
25
+ */
26
+ readonly ref?: string;
21
27
  generate(req: ModelRequest): Promise<ModelResponse>;
22
28
  /** optional: non-streaming models simply never produce deltas */
23
29
  stream?(req: ModelRequest, onDelta: (d: StreamDelta) => void): Promise<ModelResponse>;
@@ -104,15 +104,31 @@ export interface ModelSpec extends Credentials, OpenAIResponsesModelOptions, Ant
104
104
  client?: ProviderClient;
105
105
  }
106
106
  /**
107
- * Shorthand: `[provider[/api]:]model`, e.g. `gpt-4o`, `openai:gpt-4o`,
108
- * `openai/responses:o3`, `gemini-eu:gemini-2.5-pro`.
109
- *
110
- * Only the *first* colon separates, so a fine-tuned id keeps its own — it just
111
- * has to name its provider: `openai:ft:gpt-4o:acme::a1b2`. Anything the
112
- * shorthand cannot express (keys, base urls, reasoning knobs) needs the object
113
- * form.
107
+ * Shorthand: `provider/id`, e.g. `openai/gpt-5-mini`,
108
+ * `vertex/anthropic/claude-opus-5`, `openrouter/anthropic/claude-sonnet-5` —
109
+ * see `ref.ts`. The older `[provider[/api]:]id` (`openai:gpt-4o`,
110
+ * `openai/responses:o3`, `openai:ft:gpt-4o:acme::a1b2`) and a bare id on the
111
+ * default provider are still read. Anything the shorthand cannot express
112
+ * (keys, base urls, reasoning knobs) needs the object form.
114
113
  */
115
114
  export type ModelRef = ModelSpec | string;
115
+ /**
116
+ * How a ref is written, against how it would be written today.
117
+ *
118
+ * - `bare` — no provider: it goes to the default one
119
+ * - `colon` — the older `provider:id`
120
+ * - `ambiguous` — `anthropic/claude-…` on an OpenRouter-style default, which
121
+ * still means the default provider's id, as it always has; written out, it
122
+ * says so
123
+ * - `publisher` — Claude on Vertex without its `anthropic/`
124
+ *
125
+ * `canonical` keeps the meaning. A colon ref naming an api is already as
126
+ * written as it gets: no other shorthand carries one.
127
+ */
128
+ export interface ModelRefStyle {
129
+ issue: 'bare' | 'colon' | 'ambiguous' | 'publisher';
130
+ canonical: string;
131
+ }
116
132
  /**
117
133
  * The same idea one layer down: which vectoriser, and of whom.
118
134
  *
@@ -128,7 +144,7 @@ export interface EmbeddingSpec extends Credentials, OpenAIEmbedderOptions, Gemin
128
144
  /** pre-built client — bypasses provider resolution entirely */
129
145
  client?: ProviderClient;
130
146
  }
131
- /** Shorthand: `[provider:]model`, e.g. `text-embedding-3-small`, `google:gemini-embedding-001`. */
147
+ /** Shorthand: `provider/model`, e.g. `google/gemini-embedding-001` — read as `ModelRef` is, minus an api. */
132
148
  export type EmbeddingRef = EmbeddingSpec | string;
133
149
  /**
134
150
  * What a ref *would* connect with. `model()` answers the same question by
@@ -241,10 +257,22 @@ export declare class ModelRegistry {
241
257
  * credential, and the two want different words.
242
258
  */
243
259
  requirement(ref: ModelRef | EmbeddingRef): ModelRequirement;
244
- /** `[provider[/api]:]model` → spec. Exposed so a caller can validate a ref. */
260
+ /** A shorthand → spec; see `ModelRef`. Exposed so a caller can validate a ref. */
245
261
  parse(ref: string): ModelSpec;
246
262
  /**
247
- * Splits `[provider:]model` into the spec it stands for, so a caller holding
263
+ * The ref a spec is written as: `provider/id`, with Claude on Vertex under
264
+ * its publisher. The colon form when that is the only one that reads back
265
+ * the same — an api to carry, or an id the slash would split differently.
266
+ */
267
+ refOf(spec: {
268
+ provider?: string;
269
+ api?: string;
270
+ model: string;
271
+ }): string;
272
+ /** How `ref` is written, when that is not the way it would be written today. */
273
+ refStyle(ref: string): ModelRefStyle | undefined;
274
+ /**
275
+ * Splits a shorthand into the spec it stands for, so a caller holding
248
276
  * a shorthand can still set the knobs a shorthand has no room for.
249
277
  */
250
278
  parseEmbedding(ref: string): EmbeddingSpec;
@@ -11,6 +11,7 @@ import { GeminiModel } from "./gemini.js";
11
11
  import { OpenAIModel } from "./openai-chat.js";
12
12
  import { OpenAIResponsesModel } from "./openai-responses.js";
13
13
  import { OpenRouterModel } from "./openrouter.js";
14
+ import { MODEL_APIS, splitModelRef } from "./ref.js";
14
15
  // ---------------------------------------------------------------------------
15
16
  // The vendor SDKs
16
17
  //
@@ -348,6 +349,13 @@ export class ModelRegistry {
348
349
  /** Turns a shorthand or a spec into a `Model`. */
349
350
  model(ref) {
350
351
  const spec = typeof ref === 'string' ? this.parse(ref) : ref;
352
+ const built = this.#build(spec);
353
+ // What the trace records beside the wire id: the id alone has lost
354
+ // which provider it went to.
355
+ Object.defineProperty(built, 'ref', { value: this.refOf(spec), enumerable: false });
356
+ return built;
357
+ }
358
+ #build(spec) {
351
359
  const name = spec.provider ?? this.#default;
352
360
  const provider = this.#spec(name);
353
361
  const kind = this.kindOf(name);
@@ -481,30 +489,90 @@ export class ModelRegistry {
481
489
  keyOptional: Boolean(defaults.keyOptional),
482
490
  };
483
491
  }
484
- /** `[provider[/api]:]model` → spec. Exposed so a caller can validate a ref. */
492
+ /** A shorthand → spec; see `ModelRef`. Exposed so a caller can validate a ref. */
485
493
  parse(ref) {
486
- // Only the first colon separates the prefix: model ids may contain colons.
487
- const colon = ref.indexOf(':');
488
- if (colon < 0) {
489
- return { model: ref };
494
+ return this.#read(ref).spec;
495
+ }
496
+ /**
497
+ * The ref a spec is written as: `provider/id`, with Claude on Vertex under
498
+ * its publisher. The colon form when that is the only one that reads back
499
+ * the same — an api to carry, or an id the slash would split differently.
500
+ */
501
+ refOf(spec) {
502
+ const name = spec.provider ?? this.#default;
503
+ if (spec.api) {
504
+ return `${name}/${spec.api}:${spec.model}`;
505
+ }
506
+ const model = this.kindOf(name) === 'vertex' && /^claude-/.test(spec.model)
507
+ ? `anthropic/${spec.model}`
508
+ : spec.model;
509
+ const slash = `${name}/${model}`;
510
+ try {
511
+ const back = this.parse(slash);
512
+ if ((back.provider ?? this.#default) === name && back.model === model && !back.api) {
513
+ return slash;
514
+ }
515
+ }
516
+ catch {
517
+ // falls through to the form that always reads back
490
518
  }
491
- const [provider, api] = ref.slice(0, colon).split('/');
492
- const model = ref.slice(colon + 1);
519
+ return `${name}:${model}`;
520
+ }
521
+ /** How `ref` is written, when that is not the way it would be written today. */
522
+ refStyle(ref) {
523
+ const { spec, form } = this.#read(ref);
524
+ const canonical = this.refOf(spec);
525
+ if (canonical === ref) {
526
+ return undefined;
527
+ }
528
+ return { issue: form === 'slash' ? 'publisher' : form, canonical };
529
+ }
530
+ #read(ref) {
531
+ const parts = splitModelRef(ref, (name) => this.has(name));
532
+ if (parts.form === 'bare') {
533
+ return { spec: { model: ref }, form: 'bare' };
534
+ }
535
+ const { provider, api, model } = parts;
493
536
  if (!model) {
494
537
  throw new TypeError(`missing model id in "${ref}"`);
495
538
  }
496
- if (!provider || !this.has(provider)) {
497
- throw new TypeError(`unknown provider "${provider}" in "${ref}" ` +
498
- `(known: ${this.names().join(', ')}; a model id that itself contains a ` +
499
- `colon must name its provider, e.g. "openai:${ref}")`);
539
+ if (parts.form === 'colon') {
540
+ if (!provider || !this.has(provider)) {
541
+ throw new TypeError(`unknown provider "${provider}" in "${ref}" ` +
542
+ `(known: ${this.names().join(', ')}; a model id that itself contains a ` +
543
+ `colon must name its provider, e.g. "openai:${ref}")`);
544
+ }
545
+ if (api !== undefined && !MODEL_APIS.includes(api)) {
546
+ throw new TypeError(`unknown api "${api}" in "${ref}" (expected chat or responses; an id ` +
547
+ 'with a colon in it goes in the object form)');
548
+ }
549
+ return { spec: { provider, api: api, model }, form: 'colon' };
500
550
  }
501
- if (api !== undefined && api !== 'chat' && api !== 'responses') {
502
- throw new TypeError(`unknown api "${api}" in "${ref}" (expected chat or responses)`);
551
+ // Before a slash named a provider, it was part of an id on the default
552
+ // one — and on a default whose own ids have slashes (OpenRouter's
553
+ // `anthropic/claude-…`, an endpoint of somebody's) that reading may be
554
+ // the one that was meant. It is kept; `refStyle` asks for it written out.
555
+ const fallback = this.#default;
556
+ if (this.#slashIds(fallback) && (provider !== fallback || this.#repointed(fallback))) {
557
+ return { spec: { model: ref }, form: 'ambiguous' };
503
558
  }
504
- return { provider, api, model };
559
+ return { spec: { provider, model }, form: 'slash' };
560
+ }
561
+ /** A provider whose own model ids may contain a slash. */
562
+ #slashIds(name) {
563
+ const kind = this.kindOf(name);
564
+ return (kind === 'openrouter' ||
565
+ kind === 'vertex' ||
566
+ kind === 'openai-compatible' ||
567
+ this.#repointed(name));
568
+ }
569
+ /** Declared at a base url of its own: a proxy may name its models any way it likes. */
570
+ #repointed(name) {
571
+ const spec = this.#providers.get(name);
572
+ return Boolean(spec?.baseURL || spec?.baseURLEnv);
505
573
  }
506
574
  /**
507
- * Splits `[provider:]model` into the spec it stands for, so a caller holding
575
+ * Splits a shorthand into the spec it stands for, so a caller holding
508
576
  * a shorthand can still set the knobs a shorthand has no room for.
509
577
  */
510
578
  parseEmbedding(ref) {
@@ -5,4 +5,5 @@ export * from './gemini.ts';
5
5
  export * from './openai-chat.ts';
6
6
  export * from './openai-responses.ts';
7
7
  export * from './openrouter.ts';
8
+ export * from './ref.ts';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -5,4 +5,5 @@ export * from "./gemini.js";
5
5
  export * from "./openai-chat.js";
6
6
  export * from "./openai-responses.js";
7
7
  export * from "./openrouter.js";
8
+ export * from "./ref.js";
8
9
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,25 @@
1
+ export declare const MODEL_APIS: readonly ["chat", "responses"];
2
+ export type ModelRefForm = 'slash' | 'colon' | 'bare';
3
+ export interface ModelRefParts {
4
+ provider?: string;
5
+ /** colon form only: `openai/responses:o3` */
6
+ api?: string;
7
+ model: string;
8
+ form: ModelRefForm;
9
+ }
10
+ /**
11
+ * The syntax of a ref, without deciding whether its provider exists.
12
+ *
13
+ * `isProvider` decides whether a leading `name/` is a provider or the start of
14
+ * an id: `openai/gpt-5-mini` splits, `meta-llama/Llama-3-8B` does not. The colon
15
+ * form is recognised by its shape alone, so a typo in it still reaches the
16
+ * caller as an unknown provider rather than as a strange model id.
17
+ */
18
+ export declare function splitModelRef(ref: string, isProvider: (name: string) => boolean): ModelRefParts;
19
+ /**
20
+ * `provider/id`, unless that would read back as something else — a fine-tuned
21
+ * `ft:gpt-4o:acme::a1b2` would, its `ft:` looking like an api — in which case
22
+ * the colon form, which carries any id.
23
+ */
24
+ export declare function formatModelRef(provider: string, model: string, isProvider: (name: string) => boolean): string;
25
+ //# sourceMappingURL=ref.d.ts.map
@@ -0,0 +1,60 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Model references
3
+ //
4
+ // One grammar, read the same way by the library, the CLI and the meta agent:
5
+ //
6
+ // provider/id openai/gpt-5-mini
7
+ // vertex/anthropic/claude-opus-5
8
+ // openrouter/anthropic/claude-sonnet-5
9
+ //
10
+ // The first segment is always a provider name and everything after the first
11
+ // slash is the id as that provider spells it — slashes and colons included. It
12
+ // is also how Bifrost names a model, so the string in `agents.yaml`, the trace
13
+ // and the gateway's logs is the same one.
14
+ //
15
+ // Two older spellings are still read:
16
+ //
17
+ // provider[/api]:id openai:gpt-4o, openai/responses:o3
18
+ // id gpt-4o — the registry's default provider
19
+ //
20
+ // The colon form stays the way to write an id the slash form cannot carry back
21
+ // (`openai:ft:gpt-4o:acme::a1b2`), and the only shorthand that names an api.
22
+ // ---------------------------------------------------------------------------
23
+ export const MODEL_APIS = ['chat', 'responses'];
24
+ /** What an api selector looks like, as opposed to a model name: `responses`, not `llama3`. */
25
+ const API_LIKE = /^[a-z]+$/;
26
+ /**
27
+ * The syntax of a ref, without deciding whether its provider exists.
28
+ *
29
+ * `isProvider` decides whether a leading `name/` is a provider or the start of
30
+ * an id: `openai/gpt-5-mini` splits, `meta-llama/Llama-3-8B` does not. The colon
31
+ * form is recognised by its shape alone, so a typo in it still reaches the
32
+ * caller as an unknown provider rather than as a strange model id.
33
+ */
34
+ export function splitModelRef(ref, isProvider) {
35
+ const colon = ref.indexOf(':');
36
+ if (colon > 0) {
37
+ const head = ref.slice(0, colon).split('/');
38
+ if (head.length === 1 || (head.length === 2 && API_LIKE.test(head[1]))) {
39
+ return { provider: head[0], api: head[1], model: ref.slice(colon + 1), form: 'colon' };
40
+ }
41
+ }
42
+ const slash = ref.indexOf('/');
43
+ if (slash > 0 && isProvider(ref.slice(0, slash))) {
44
+ return { provider: ref.slice(0, slash), model: ref.slice(slash + 1), form: 'slash' };
45
+ }
46
+ return { model: ref, form: 'bare' };
47
+ }
48
+ /**
49
+ * `provider/id`, unless that would read back as something else — a fine-tuned
50
+ * `ft:gpt-4o:acme::a1b2` would, its `ft:` looking like an api — in which case
51
+ * the colon form, which carries any id.
52
+ */
53
+ export function formatModelRef(provider, model, isProvider) {
54
+ const slash = `${provider}/${model}`;
55
+ const back = splitModelRef(slash, isProvider);
56
+ return back.form === 'slash' && back.provider === provider && back.model === model
57
+ ? slash
58
+ : `${provider}:${model}`;
59
+ }
60
+ //# sourceMappingURL=ref.js.map
package/dist/runner.js CHANGED
@@ -242,6 +242,7 @@ export class AgentRunner {
242
242
  digest,
243
243
  request: this.#recordRequests ? req : undefined,
244
244
  registry: this.registry,
245
+ ref: model.ref,
245
246
  });
246
247
  const node = appended(before, state).find((n) => n.type === 'llm_call');
247
248
  if (node) {
@@ -82,6 +82,11 @@ export interface LlmCallNode extends NodeBase {
82
82
  type: 'llm_call';
83
83
  /** exact model id used */
84
84
  model: string;
85
+ /**
86
+ * The ref that names the model again, `provider/id` — absent from runs
87
+ * recorded before it was, and for models not built by a registry.
88
+ */
89
+ ref?: string;
85
90
  /** sha256 of the projected request, for replay checks */
86
91
  requestDigest: string;
87
92
  request?: Payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenera/neo",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "A multi-agent runtime for Node.js: agents, models, tools, skills, memory and an append-only trajectory.",
5
5
  "keywords": [
6
6
  "agents",
@@ -62,7 +62,7 @@
62
62
  "prepack": "tsc -b"
63
63
  },
64
64
  "dependencies": {
65
- "@zenera/sandbox": "^1.3.2",
65
+ "@zenera/sandbox": "^1.3.4",
66
66
  "graphology": "^0.26.0",
67
67
  "yaml": "^2.9.1",
68
68
  "zod": "^4.6.7"