@dsh-cc/model-aliases 0.5.0

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,48 @@
1
+ /**
2
+ * Convert a resolved alias route into spawn `agentOptions` (`toAgentOptions`)
3
+ * or a complete `{provider, model}` pair for an independent one-shot stream
4
+ * (`toOneShotRoute`). Spawn drops `undefined` fields so per-field inheritance
5
+ * survives; one-shots fill missing fields from a parent route and return
6
+ * `undefined` when the pair is still incomplete.
7
+ *
8
+ * @module @dsh-cc/model-aliases/agentOptions
9
+ */
10
+ /**
11
+ * Drop `undefined` fields from a resolved route so per-field inheritance
12
+ * survives (never set a field to `undefined` on the child request).
13
+ * `undefined` in → `undefined` out; an all-`undefined` route → `undefined`.
14
+ * @param route - the resolved route (or `undefined` for no override).
15
+ * @returns the `agentOptions` record, or `undefined` for no override.
16
+ */
17
+ export function toAgentOptions(route) {
18
+ if (route === undefined)
19
+ return undefined;
20
+ const out = {};
21
+ if (route.provider !== undefined)
22
+ out['provider'] = route.provider;
23
+ if (route.model !== undefined)
24
+ out['model'] = route.model;
25
+ if (route.reasoningEffort !== undefined)
26
+ out['reasoningEffort'] = route.reasoningEffort;
27
+ if (Object.keys(out).length === 0)
28
+ return undefined;
29
+ return out;
30
+ }
31
+ /**
32
+ * Fill a resolved alias into a complete `{provider, model}` pair for an
33
+ * independent `ctx.llm.stream` one-shot. Alias fields win; missing fields
34
+ * inherit from `parent`. Returns undefined when the resulting pair is
35
+ * incomplete (no model after inherit) — callers treat that as "unconfigured".
36
+ */
37
+ export function toOneShotRoute(route, parent) {
38
+ if (route === undefined)
39
+ return undefined;
40
+ const provider = route.provider ?? parent?.provider;
41
+ const model = route.model ?? parent?.model;
42
+ if (provider === undefined || model === undefined)
43
+ return undefined;
44
+ if (provider.length === 0 || model.length === 0)
45
+ return undefined;
46
+ return { provider, model };
47
+ }
48
+ //# sourceMappingURL=agentOptions.js.map
@@ -0,0 +1 @@
1
+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Host-side application of an alias-stamped reasoning effort.
3
+ *
4
+ * Named CC subagents carry `reasoningEffort` on their child options as an
5
+ * undeclared runtime extra key (stamped by the Task tool / plugin-loader when
6
+ * the spawn's alias resolved with one). `buildRequest` deep-freezes its seed
7
+ * config and the fork may have restored an explicit parent `/effort` from the
8
+ * seed `request/header` — the alias contract must win — so the host
9
+ * `agent/request` listener in the routes service overlays the stamp AFTER
10
+ * `next()` via this helper.
11
+ *
12
+ * The overlay is a shallow copy: assigning onto the resolved config in place
13
+ * throws on the frozen seed or is invisible. Any absent/blank/non-string
14
+ * stamp is a no-op returning the input unchanged.
15
+ *
16
+ * @module @dsh-cc/model-aliases/effort
17
+ */
18
+ /**
19
+ * Overlay an alias-stamped reasoning effort onto one resolved request config.
20
+ * @param resolved - the config produced by the `agent/request` waterfall.
21
+ * @param stamped - the effort read off the child agent's options (any type;
22
+ * only a non-empty string applies).
23
+ * @returns a shallow copy carrying the stamp, or the input unchanged when the
24
+ * stamp is absent/blank/non-string.
25
+ */
26
+ export declare function overlayStampedEffort<T extends {
27
+ reasoningEffort?: unknown;
28
+ }>(resolved: T, stamped: unknown): T;
29
+ /**
30
+ * Read the effort stamp off a child agent's options. The stamp is an
31
+ * undeclared runtime extra key (`AgentOptions` is merge-extensible and the
32
+ * harness only copies provider/model/maxTokens into `child.options` through
33
+ * its own spread — extra keys survive). Treats the options as unknown: a
34
+ * non-string or absent value yields `undefined`.
35
+ * @param options - the agent's `options` object (untyped on purpose).
36
+ * @returns the stamped effort string, or undefined.
37
+ */
38
+ export declare function stampedEffortOf(options: unknown): string | undefined;
39
+ //# sourceMappingURL=effort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effort.d.ts","sourceRoot":"","sources":["../src/effort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,CAK9G;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAIpE"}
package/lib/effort.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Host-side application of an alias-stamped reasoning effort.
3
+ *
4
+ * Named CC subagents carry `reasoningEffort` on their child options as an
5
+ * undeclared runtime extra key (stamped by the Task tool / plugin-loader when
6
+ * the spawn's alias resolved with one). `buildRequest` deep-freezes its seed
7
+ * config and the fork may have restored an explicit parent `/effort` from the
8
+ * seed `request/header` — the alias contract must win — so the host
9
+ * `agent/request` listener in the routes service overlays the stamp AFTER
10
+ * `next()` via this helper.
11
+ *
12
+ * The overlay is a shallow copy: assigning onto the resolved config in place
13
+ * throws on the frozen seed or is invisible. Any absent/blank/non-string
14
+ * stamp is a no-op returning the input unchanged.
15
+ *
16
+ * @module @dsh-cc/model-aliases/effort
17
+ */
18
+ /**
19
+ * Overlay an alias-stamped reasoning effort onto one resolved request config.
20
+ * @param resolved - the config produced by the `agent/request` waterfall.
21
+ * @param stamped - the effort read off the child agent's options (any type;
22
+ * only a non-empty string applies).
23
+ * @returns a shallow copy carrying the stamp, or the input unchanged when the
24
+ * stamp is absent/blank/non-string.
25
+ */
26
+ export function overlayStampedEffort(resolved, stamped) {
27
+ if (typeof stamped !== 'string' || stamped.length === 0)
28
+ return resolved;
29
+ // Stamp is an opaque adapter spelling; the branded `ReasoningEffortId` on
30
+ // LlmCallConfig is applied at prepareCall, not here.
31
+ return { ...resolved, reasoningEffort: stamped };
32
+ }
33
+ /**
34
+ * Read the effort stamp off a child agent's options. The stamp is an
35
+ * undeclared runtime extra key (`AgentOptions` is merge-extensible and the
36
+ * harness only copies provider/model/maxTokens into `child.options` through
37
+ * its own spread — extra keys survive). Treats the options as unknown: a
38
+ * non-string or absent value yields `undefined`.
39
+ * @param options - the agent's `options` object (untyped on purpose).
40
+ * @returns the stamped effort string, or undefined.
41
+ */
42
+ export function stampedEffortOf(options) {
43
+ if (typeof options !== 'object' || options === null)
44
+ return undefined;
45
+ const effort = options.reasoningEffort;
46
+ return typeof effort === 'string' && effort.length > 0 ? effort : undefined;
47
+ }
48
+ //# sourceMappingURL=effort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effort.js","sourceRoot":"","sources":["../src/effort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAA0C,QAAW,EAAE,OAAgB;IACzG,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAA;IACxE,0EAA0E;IAC1E,qDAAqD;IACrD,OAAO,EAAE,GAAG,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAO,CAAA;AACvD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IACrE,MAAM,MAAM,GAAI,OAAyC,CAAC,eAAe,CAAA;IACzE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;AAC7E,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Claude Code-compatible model alias resolution for the DeepSeek Harness.
3
+ *
4
+ * Two consumption shapes:
5
+ * - **Service** (`ccModelRoutes`): the plugin entry (`apply`) owns the
6
+ * `model-aliases` settings namespace registration and provides a spawn-time
7
+ * resolver over it; consumers `ctx.get('ccModelRoutes')` lazily.
8
+ * - **Pure helpers**: `mergeAliasMaps` / `createModelResolver` for embedding
9
+ * the resolution semantics without mounting the service.
10
+ *
11
+ * See the README for configuration, merge, and fallback semantics.
12
+ *
13
+ * @module @dsh-cc/model-aliases
14
+ */
15
+ export { BUILTIN_ALIASES, CC_ALIASES, LANE_ALIASES, LANE_PEERS, mergeAliasMaps, createModelResolver, createModelInspector, type ModelResolver } from './resolver.ts';
16
+ export { toAgentOptions, toOneShotRoute, type OneShotParentRoute } from './agentOptions.ts';
17
+ export { overlayStampedEffort, stampedEffortOf } from './effort.ts';
18
+ export { ConfigAliasSchema, ConfigAliasesSchema, SettingsAliasSchema, SettingsAliasesSchema, type ConfigAliasEntry, type SettingsAliasEntry, } from './schema.ts';
19
+ export type { AliasTarget, DetailedRoute, ResolvedRoute, AliasInspectKind, AliasInspectVia, AliasInspection } from './types.ts';
20
+ export { apply as applyRoutes, name as routesPluginName, MODEL_ALIASES_NAMESPACE, resolveAlias, resolveDetailedAlias, type ModelRoutes } from './service.ts';
21
+ export { apply, name } from './service.ts';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAA;AACpK,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3F,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC/H,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,IAAI,IAAI,gBAAgB,EAAE,uBAAuB,EAAE,YAAY,EAAE,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAC5J,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA"}
package/lib/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Claude Code-compatible model alias resolution for the DeepSeek Harness.
3
+ *
4
+ * Two consumption shapes:
5
+ * - **Service** (`ccModelRoutes`): the plugin entry (`apply`) owns the
6
+ * `model-aliases` settings namespace registration and provides a spawn-time
7
+ * resolver over it; consumers `ctx.get('ccModelRoutes')` lazily.
8
+ * - **Pure helpers**: `mergeAliasMaps` / `createModelResolver` for embedding
9
+ * the resolution semantics without mounting the service.
10
+ *
11
+ * See the README for configuration, merge, and fallback semantics.
12
+ *
13
+ * @module @dsh-cc/model-aliases
14
+ */
15
+ export { BUILTIN_ALIASES, CC_ALIASES, LANE_ALIASES, LANE_PEERS, mergeAliasMaps, createModelResolver, createModelInspector } from "./resolver.js";
16
+ export { toAgentOptions, toOneShotRoute } from "./agentOptions.js";
17
+ export { overlayStampedEffort, stampedEffortOf } from "./effort.js";
18
+ export { ConfigAliasSchema, ConfigAliasesSchema, SettingsAliasSchema, SettingsAliasesSchema, } from "./schema.js";
19
+ export { apply as applyRoutes, name as routesPluginName, MODEL_ALIASES_NAMESPACE, resolveAlias, resolveDetailedAlias } from "./service.js";
20
+ export { apply, name } from "./service.js";
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAsB,MAAM,eAAe,CAAA;AACpK,OAAO,EAAE,cAAc,EAAE,cAAc,EAA2B,MAAM,mBAAmB,CAAA;AAC3F,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACnE,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,GAGtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,IAAI,IAAI,gBAAgB,EAAE,uBAAuB,EAAE,YAAY,EAAE,oBAAoB,EAAoB,MAAM,cAAc,CAAA;AAC5J,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Claude Code model-alias merge and resolution.
3
+ *
4
+ * `mergeAliasMaps` folds the deployment `config` defaults and the live
5
+ * `settings` overlay into one effective alias map — entry-shallow, so a
6
+ * settings value replaces a same-named config value wholesale rather than
7
+ * field-merging `{provider, model}` objects, with a settings `null` deleting
8
+ * the config entry. `createModelResolver` turns a per-invocation alias source
9
+ * into the `resolveModel` closure an agent provider calls at spawn time, so
10
+ * live settings edits take effect on the next spawn without re-registering
11
+ * anything.
12
+ *
13
+ * Builtin alias names (Claude Code family plus the dsh-cc lane names) have a
14
+ * fallback when they are unconfigured — they resolve to "inherit the parent
15
+ * route" (`undefined`), matching the deployment decision that a zero-config
16
+ * `model: sonnet` / `model: draft` agent silently uses the parent's current
17
+ * model. A custom (open-set) alias that is unconfigured has no fallback: it
18
+ * passes through verbatim as a literal model id, with a warning when it looks
19
+ * like an intended alias.
20
+ *
21
+ * @module @dsh-cc/model-aliases/resolver
22
+ */
23
+ import type { AliasInspection, AliasTarget, DetailedRoute, ResolvedRoute } from './types.ts';
24
+ /**
25
+ * Claude Code family aliases. Unconfigured → inherit the parent route.
26
+ * Case-insensitive; a configured value still wins over this fallback.
27
+ */
28
+ export declare const CC_ALIASES: readonly string[];
29
+ /**
30
+ * dsh-cc lane aliases. Unconfigured, a lane follows its CC peer
31
+ * ({@link LANE_PEERS}) so `model: sketch` shares a configured `haiku`
32
+ * route without a second settings entry. `architect` has no peer and
33
+ * inherits the parent (main-thread) route. A configured string-form
34
+ * target that names another alias is followed one hop.
35
+ *
36
+ * | lane | role | CC peer when unconfigured |
37
+ * |---|---|---|
38
+ * | `sketch` | fast, lightweight execution | haiku |
39
+ * | `draft` | balanced everyday coding | sonnet |
40
+ * | `blueprint` | deep reasoning | opus |
41
+ * | `masterplan` | maximum reasoning | fable |
42
+ * | `architect` | planning / orchestration | inherit (main thread) |
43
+ */
44
+ export declare const LANE_ALIASES: readonly string[];
45
+ /** Unconfigured lane → CC family alias it shares a route with. */
46
+ export declare const LANE_PEERS: Readonly<Record<string, string>>;
47
+ /**
48
+ * The builtin alias names that fall back to "inherit the parent route" when
49
+ * unconfigured. Case-insensitive; a configured value still wins over this
50
+ * fallback.
51
+ */
52
+ export declare const BUILTIN_ALIASES: readonly string[];
53
+ /**
54
+ * Merge the deployment `config` defaults and the settings overlay into one
55
+ * effective alias map (aliases keyed by lowercased name). Entry-shallow:
56
+ * a settings value replaces a config value wholesale and never field-merges a
57
+ * `{provider, model}` object; a settings `null` deletes the config entry.
58
+ * @param config - deployment config `modelAliases` (values never `null` at the
59
+ * schema level), or `undefined`.
60
+ * @param settings - live settings `model-aliases` section (values may be `null`
61
+ * to delete), or `undefined`.
62
+ * @returns a fresh map of only the configured aliases, keyed lowercased.
63
+ */
64
+ export declare function mergeAliasMaps(config: Readonly<Record<string, AliasTarget>> | undefined, settings: Readonly<Record<string, AliasTarget | null>> | undefined): ReadonlyMap<string, AliasTarget>;
65
+ /**
66
+ * Build a `resolveModel` closure for an agent provider. The alias source is a
67
+ * thunk evaluated on every invocation, so the closure reads the live settings
68
+ * and merges fresh each spawn (see the plan's liveness requirement).
69
+ * @param getAliases - returns the effective alias map for this invocation (the
70
+ * caller composes config + live settings via {@link mergeAliasMaps}).
71
+ * @param options - optional warning hook for unsigned custom aliases; the
72
+ * message is emitted (defaulting to `console.warn`) when a model that is not
73
+ * a configured alias and not a builtin looks like an intended alias (a bare
74
+ * lowercase alphabetic word) and is passed through verbatim.
75
+ * @returns the resolution function mapping a frontmatter `model` to a route, or
76
+ * `undefined` for no override. The returned function also carries
77
+ * `resolveDetailed`, the atomic provenance-carrying form it is derived from.
78
+ */
79
+ export interface ModelResolver {
80
+ (model: string | undefined): ResolvedRoute | undefined;
81
+ /** Atomic detailed resolution — one settings snapshot classifies AND routes. */
82
+ resolveDetailed(model: string | undefined): DetailedRoute;
83
+ }
84
+ export declare function createModelResolver(getAliases: () => ReadonlyMap<string, AliasTarget>, options?: {
85
+ warn?: (message: string) => void;
86
+ }): ModelResolver;
87
+ /**
88
+ * Build an inspector that classifies one frontmatter `model` the same way
89
+ * {@link createModelResolver} resolves it, additionally reporting provenance
90
+ * (kind / via / hop) for tooling like `/doctor`. The `route` field is exactly
91
+ * what `resolve()` returns for the same input.
92
+ * @param getAliases - returns the effective alias map for this invocation.
93
+ * @param options - same warning hook as {@link createModelResolver}.
94
+ * @returns the inspection function mapping a frontmatter `model` to an
95
+ * {@link AliasInspection}.
96
+ */
97
+ export declare function createModelInspector(getAliases: () => ReadonlyMap<string, AliasTarget>, options?: {
98
+ warn?: (message: string) => void;
99
+ }): (model: string | undefined) => AliasInspection;
100
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE5F;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAyC,CAAA;AAEjF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAAgE,CAAA;AAE1G,kEAAkE;AAClE,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKvD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAAqC,CAAA;AAKlF;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,GAAG,SAAS,EACzD,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC,GAAG,SAAS,GACjE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAalC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAAA;IACtD,gFAAgF;IAChF,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,CAAA;CAC1D;AAED,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EAClD,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAC7C,aAAa,CAwBf;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EAClD,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAC7C,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,eAAe,CAwDhD"}
@@ -0,0 +1,224 @@
1
+ /**
2
+ * Claude Code model-alias merge and resolution.
3
+ *
4
+ * `mergeAliasMaps` folds the deployment `config` defaults and the live
5
+ * `settings` overlay into one effective alias map — entry-shallow, so a
6
+ * settings value replaces a same-named config value wholesale rather than
7
+ * field-merging `{provider, model}` objects, with a settings `null` deleting
8
+ * the config entry. `createModelResolver` turns a per-invocation alias source
9
+ * into the `resolveModel` closure an agent provider calls at spawn time, so
10
+ * live settings edits take effect on the next spawn without re-registering
11
+ * anything.
12
+ *
13
+ * Builtin alias names (Claude Code family plus the dsh-cc lane names) have a
14
+ * fallback when they are unconfigured — they resolve to "inherit the parent
15
+ * route" (`undefined`), matching the deployment decision that a zero-config
16
+ * `model: sonnet` / `model: draft` agent silently uses the parent's current
17
+ * model. A custom (open-set) alias that is unconfigured has no fallback: it
18
+ * passes through verbatim as a literal model id, with a warning when it looks
19
+ * like an intended alias.
20
+ *
21
+ * @module @dsh-cc/model-aliases/resolver
22
+ */
23
+ /**
24
+ * Claude Code family aliases. Unconfigured → inherit the parent route.
25
+ * Case-insensitive; a configured value still wins over this fallback.
26
+ */
27
+ export const CC_ALIASES = ['fable', 'opus', 'sonnet', 'haiku'];
28
+ /**
29
+ * dsh-cc lane aliases. Unconfigured, a lane follows its CC peer
30
+ * ({@link LANE_PEERS}) so `model: sketch` shares a configured `haiku`
31
+ * route without a second settings entry. `architect` has no peer and
32
+ * inherits the parent (main-thread) route. A configured string-form
33
+ * target that names another alias is followed one hop.
34
+ *
35
+ * | lane | role | CC peer when unconfigured |
36
+ * |---|---|---|
37
+ * | `sketch` | fast, lightweight execution | haiku |
38
+ * | `draft` | balanced everyday coding | sonnet |
39
+ * | `blueprint` | deep reasoning | opus |
40
+ * | `masterplan` | maximum reasoning | fable |
41
+ * | `architect` | planning / orchestration | inherit (main thread) |
42
+ */
43
+ export const LANE_ALIASES = ['sketch', 'draft', 'blueprint', 'masterplan', 'architect'];
44
+ /** Unconfigured lane → CC family alias it shares a route with. */
45
+ export const LANE_PEERS = {
46
+ sketch: 'haiku',
47
+ draft: 'sonnet',
48
+ blueprint: 'opus',
49
+ masterplan: 'fable',
50
+ };
51
+ /**
52
+ * The builtin alias names that fall back to "inherit the parent route" when
53
+ * unconfigured. Case-insensitive; a configured value still wins over this
54
+ * fallback.
55
+ */
56
+ export const BUILTIN_ALIASES = [...CC_ALIASES, ...LANE_ALIASES];
57
+ /** The set of builtin names, lowercased, for O(1) membership checks. */
58
+ const BUILTIN_SET = new Set(BUILTIN_ALIASES);
59
+ /**
60
+ * Merge the deployment `config` defaults and the settings overlay into one
61
+ * effective alias map (aliases keyed by lowercased name). Entry-shallow:
62
+ * a settings value replaces a config value wholesale and never field-merges a
63
+ * `{provider, model}` object; a settings `null` deletes the config entry.
64
+ * @param config - deployment config `modelAliases` (values never `null` at the
65
+ * schema level), or `undefined`.
66
+ * @param settings - live settings `model-aliases` section (values may be `null`
67
+ * to delete), or `undefined`.
68
+ * @returns a fresh map of only the configured aliases, keyed lowercased.
69
+ */
70
+ export function mergeAliasMaps(config, settings) {
71
+ const merged = new Map();
72
+ for (const [key, value] of foldKeys(config)) {
73
+ // Config never carries `null` at the schema level, but schemastery dicts are
74
+ // lenient about stored values; silently treat a stray config `null` as
75
+ // absent so it can never reach the resolver as a route.
76
+ if (value !== null)
77
+ merged.set(key, value);
78
+ }
79
+ for (const [key, value] of foldKeys(settings)) {
80
+ if (value === null)
81
+ merged.delete(key);
82
+ else
83
+ merged.set(key, value);
84
+ }
85
+ return merged;
86
+ }
87
+ export function createModelResolver(getAliases, options) {
88
+ const inspect = createModelInspector(getAliases, options);
89
+ const resolveDetailed = (model) => {
90
+ const verdict = inspect(model);
91
+ if (verdict.kind === 'inherit') {
92
+ return { selector: model === undefined || model.trim().length === 0 ? undefined : model.trim(), via: 'inherit', route: undefined };
93
+ }
94
+ const selector = model?.trim();
95
+ if (verdict.kind === 'route') {
96
+ return { selector, via: 'alias', route: verdict.route };
97
+ }
98
+ // Upstream's inspector reports the literal passthrough for BOTH a custom
99
+ // alias name and a followed string-form target; our `DetailedRoute` keeps
100
+ // the finer split: when the literal route's model differs from the
101
+ // selector, the selector was a CONFIGURED alias followed to its target,
102
+ // so the provenance is `alias`, not `literal`.
103
+ const followed = verdict.route !== undefined && verdict.route.model !== undefined && verdict.route.model !== selector;
104
+ return { selector: followed ? selector : verdict.route?.model, via: followed ? 'alias' : 'literal', route: verdict.route };
105
+ };
106
+ // `resolve` is derived from `resolveDetailed` so the classification and the
107
+ // route always come from the SAME merged map — no double lookup, and the
108
+ // legacy route behavior stays byte-identical by construction.
109
+ const resolve = (model) => resolveDetailed(model).route;
110
+ return Object.assign(resolve, { resolveDetailed });
111
+ }
112
+ /**
113
+ * Build an inspector that classifies one frontmatter `model` the same way
114
+ * {@link createModelResolver} resolves it, additionally reporting provenance
115
+ * (kind / via / hop) for tooling like `/doctor`. The `route` field is exactly
116
+ * what `resolve()` returns for the same input.
117
+ * @param getAliases - returns the effective alias map for this invocation.
118
+ * @param options - same warning hook as {@link createModelResolver}.
119
+ * @returns the inspection function mapping a frontmatter `model` to an
120
+ * {@link AliasInspection}.
121
+ */
122
+ export function createModelInspector(getAliases, options) {
123
+ const warn = options?.warn ?? ((message) => console.warn(message));
124
+ return (model) => {
125
+ if (model === undefined || model.trim().length === 0)
126
+ return { kind: 'inherit' };
127
+ const trimmed = model.trim();
128
+ const folded = trimmed.toLowerCase();
129
+ if (folded === 'inherit')
130
+ return { kind: 'inherit' };
131
+ const aliases = getAliases();
132
+ const hit = aliases.get(folded);
133
+ if (hit !== undefined && hit !== null) {
134
+ if (typeof hit === 'string') {
135
+ const followed = followStringTarget(hit, aliases, folded);
136
+ const foldedTarget = hit.trim().toLowerCase();
137
+ if (followed.kind === 'route')
138
+ return { kind: 'route', via: 'one-hop', hop: foldedTarget, route: followed.route };
139
+ if (followed.kind === 'inherit')
140
+ return { kind: 'inherit', via: 'one-hop', hop: foldedTarget };
141
+ return { kind: 'literal', route: { model: hit } };
142
+ }
143
+ // Object form: forward the route fields that are present. `provider` and
144
+ // `reasoningEffort` are optional (absent = inherit / no stamp); `model`
145
+ // is always set on a schema-valid object entry. Object targets are
146
+ // concrete routes — they are not followed as alias names.
147
+ return {
148
+ kind: 'route',
149
+ via: 'configured',
150
+ route: {
151
+ ...(hit.provider === undefined ? {} : { provider: hit.provider }),
152
+ ...(hit.model === undefined ? {} : { model: hit.model }),
153
+ ...(hit.reasoningEffort === undefined ? {} : { reasoningEffort: hit.reasoningEffort }),
154
+ },
155
+ };
156
+ }
157
+ // Unconfigured lane → follow its CC peer (`sketch` → `haiku`, …).
158
+ // `architect` has no peer and falls through to inherit. Choice: when the
159
+ // peer resolves to a configured route we report `via: 'alias'` (the lane
160
+ // shares the peer alias's route); when the peer is itself unconfigured the
161
+ // lane inherits, so `via: 'inherit'` — matching today's `resolve()`.
162
+ const peer = LANE_PEERS[folded];
163
+ if (peer !== undefined) {
164
+ const followed = followStringTarget(peer, aliases, folded);
165
+ if (followed.kind === 'route')
166
+ return { kind: 'route', via: 'peer', hop: peer, route: followed.route };
167
+ return { kind: 'inherit', via: 'peer', hop: peer };
168
+ }
169
+ // Unconfigured builtin alias → inherit the parent route ("current model").
170
+ if (BUILTIN_SET.has(folded))
171
+ return { kind: 'inherit', via: 'builtin' };
172
+ // Custom alias that is unconfigured: warn when it looks like an intended
173
+ // alias, then pass through verbatim as a literal model id (no regression
174
+ // for literal ids such as `deepseek-chat`).
175
+ if (/^[a-z]+$/.test(folded)) {
176
+ warn(`cc-model-aliases: model "${trimmed}" is not a configured alias and is not builtin; passing through verbatim as a literal model id`);
177
+ }
178
+ return { kind: 'literal', route: { model: trimmed } };
179
+ };
180
+ }
181
+ /**
182
+ * Follow a string-form target one hop when it names another alias.
183
+ *
184
+ * - `sketch: haiku` with haiku configured → haiku's route
185
+ * - `sketch: haiku` with haiku unconfigured (builtin) → inherit
186
+ * - `sketch: inherit` → inherit
187
+ * - `sketch: deepseek-chat` (not an alias) → literal, caller keeps the string
188
+ *
189
+ * A second hop is not followed (`sketch: draft` + `draft: haiku` stops at
190
+ * the literal `"haiku"`), which keeps cycles from looping. Object-form
191
+ * targets are never followed as names.
192
+ */
193
+ function followStringTarget(target, aliases, from) {
194
+ const folded = target.trim().toLowerCase();
195
+ if (folded.length === 0 || folded === from || folded === 'inherit')
196
+ return { kind: 'inherit' };
197
+ const next = aliases.get(folded);
198
+ if (next !== undefined && next !== null) {
199
+ if (typeof next === 'string')
200
+ return { kind: 'route', route: { model: next } };
201
+ return {
202
+ kind: 'route',
203
+ route: {
204
+ ...(next.provider === undefined ? {} : { provider: next.provider }),
205
+ ...(next.model === undefined ? {} : { model: next.model }),
206
+ ...(next.reasoningEffort === undefined ? {} : { reasoningEffort: next.reasoningEffort }),
207
+ },
208
+ };
209
+ }
210
+ if (BUILTIN_SET.has(folded))
211
+ return { kind: 'inherit' };
212
+ return { kind: 'literal' };
213
+ }
214
+ /** Compact-fill a record's own string keys, folding each to lowercase. */
215
+ function foldKeys(record) {
216
+ const out = new Map();
217
+ if (record === undefined)
218
+ return out;
219
+ for (const [key, value] of Object.entries(record)) {
220
+ out.set(key.toLowerCase(), value);
221
+ }
222
+ return out;
223
+ }
224
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;AAEjF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,YAAY,GAAsB,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,CAAC,CAAA;AAE1G,kEAAkE;AAClE,MAAM,CAAC,MAAM,UAAU,GAAqC;IAC1D,MAAM,EAAE,OAAO;IACf,KAAK,EAAE,QAAQ;IACf,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,OAAO;CACpB,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAsB,CAAC,GAAG,UAAU,EAAE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AAC,eAAe,EAAE,CAAC;aACzF;SACF,CAAA;IACH,CAAC;IACD,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IACvD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;AAC5B,CAAC;AAED,0EAA0E;AAC1E,SAAS,QAAQ,CAAC,MAAgE;IAChF,MAAM,GAAG,GAAG,IAAI,GAAG,EAA8B,CAAA;IACjD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,GAAG,CAAA;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAA;IACnC,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Configuration schemas for the CC model-alias layer.
3
+ *
4
+ * Two schemas exist because the two configuration layers differ in what they
5
+ * may express. The deployment `config` layer (cc-shell `modelAliases`) cannot
6
+ * delete an alias — values are a model id or an explicit `{provider, model}`
7
+ * route. The settings overlay (`model-aliases` namespace) may additionally be
8
+ * `null` for a key, which deletes a same-named config-default entry during
9
+ * merge. Object-form targets require a non-empty `model`; `provider` is
10
+ * optional (inherit the parent provider) but must be non-empty when present.
11
+ * A half-written route is rejected at the service write-time validate rather
12
+ * than surfacing as an empty-field override at spawn.
13
+ *
14
+ * The settings overlay is a shallow record keyed by alias name; the 5-cascade
15
+ * layer merge inside settings is recursively deep (existing cascade
16
+ * behaviour), so an object-form alias must be written whole or not at all
17
+ * across layers to avoid `{provider, model}` field blending — see the package
18
+ * README.
19
+ *
20
+ * @module @dsh-cc/model-aliases/schema
21
+ */
22
+ import z from '@deepseek-ai/schemastery';
23
+ import type { AliasTarget } from './types.ts';
24
+ /**
25
+ * Schema for a deployment `config` alias value: a model id or an explicit
26
+ * route, but never `null` (config cannot delete an alias; only the settings
27
+ * overlay can).
28
+ */
29
+ export declare const ConfigAliasSchema: z<string | ({
30
+ provider?: string | null;
31
+ model?: string | null;
32
+ reasoningEffort?: string | null;
33
+ } & import("@deepseek-ai/cosmokit").Dict), string | Schemastery.ObjectT<{
34
+ provider: z<string, string>;
35
+ model: z<string, string>;
36
+ reasoningEffort: z<string, string>;
37
+ }>>;
38
+ /**
39
+ * Schema for a settings `model-aliases` value: a model id, an explicit route,
40
+ * or `null` meaning "delete a same-named config-default entry".
41
+ */
42
+ export declare const SettingsAliasSchema: z<string | ({
43
+ provider?: string | null;
44
+ model?: string | null;
45
+ reasoningEffort?: string | null;
46
+ } & import("@deepseek-ai/cosmokit").Dict) | null, string | Schemastery.ObjectT<{
47
+ provider: z<string, string>;
48
+ model: z<string, string>;
49
+ reasoningEffort: z<string, string>;
50
+ }> | null>;
51
+ /**
52
+ * Schema for the whole config `modelAliases` record.
53
+ */
54
+ export declare const ConfigAliasesSchema: z<import("@deepseek-ai/cosmokit").Dict<string | ({
55
+ provider?: string | null;
56
+ model?: string | null;
57
+ reasoningEffort?: string | null;
58
+ } & import("@deepseek-ai/cosmokit").Dict), string>, import("@deepseek-ai/cosmokit").Dict<string | Schemastery.ObjectT<{
59
+ provider: z<string, string>;
60
+ model: z<string, string>;
61
+ reasoningEffort: z<string, string>;
62
+ }>, string>>;
63
+ /**
64
+ * Schema for the whole settings `model-aliases` section.
65
+ */
66
+ export declare const SettingsAliasesSchema: z<import("@deepseek-ai/cosmokit").Dict<string | ({
67
+ provider?: string | null;
68
+ model?: string | null;
69
+ reasoningEffort?: string | null;
70
+ } & import("@deepseek-ai/cosmokit").Dict) | null, string>, import("@deepseek-ai/cosmokit").Dict<string | Schemastery.ObjectT<{
71
+ provider: z<string, string>;
72
+ model: z<string, string>;
73
+ reasoningEffort: z<string, string>;
74
+ }> | null, string>>;
75
+ /** The validated shape of one config entry (modelled on the schema). */
76
+ export type ConfigAliasEntry = Exclude<AliasTarget, null>;
77
+ /** The validated shape of one settings entry (may be `null` to delete). */
78
+ export type SettingsAliasEntry = AliasTarget;
79
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAiB7C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;GAAwC,CAAA;AAEtE;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;UAAuD,CAAA;AAEvF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;YAA4B,CAAA;AAE5D;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;mBAA8B,CAAA;AAEhE,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AACzD,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAA"}