@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.
package/lib/schema.js ADDED
@@ -0,0 +1,55 @@
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
+ /** A target that only names a model id (provider inherits the parent route). */
24
+ const MODEL_ONLY = z.string().min(1);
25
+ /**
26
+ * A target that pins an explicit route: `model` is required; `provider` is
27
+ * optional (inherit the parent provider) but must be non-empty when present;
28
+ * `reasoningEffort` is an optional opaque non-empty string whose legal
29
+ * spellings belong to the target model's adapter.
30
+ */
31
+ const EXPLICIT_ROUTE = z.object({
32
+ provider: z.string().min(1),
33
+ model: z.string().min(1),
34
+ reasoningEffort: z.string().min(1),
35
+ });
36
+ /**
37
+ * Schema for a deployment `config` alias value: a model id or an explicit
38
+ * route, but never `null` (config cannot delete an alias; only the settings
39
+ * overlay can).
40
+ */
41
+ export const ConfigAliasSchema = z.union([MODEL_ONLY, EXPLICIT_ROUTE]);
42
+ /**
43
+ * Schema for a settings `model-aliases` value: a model id, an explicit route,
44
+ * or `null` meaning "delete a same-named config-default entry".
45
+ */
46
+ export const SettingsAliasSchema = z.union([MODEL_ONLY, EXPLICIT_ROUTE, z.const(null)]);
47
+ /**
48
+ * Schema for the whole config `modelAliases` record.
49
+ */
50
+ export const ConfigAliasesSchema = z.dict(ConfigAliasSchema);
51
+ /**
52
+ * Schema for the whole settings `model-aliases` section.
53
+ */
54
+ export const SettingsAliasesSchema = z.dict(SettingsAliasSchema);
55
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAGxC,gFAAgF;AAChF,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACnC,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAA;AAEtE;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAEvF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The `ccModelRoutes` host service: the single owner of the `model-aliases`
3
+ * settings namespace registration.
4
+ *
5
+ * CC frontmatter names models by alias (`model: opus`); this package maps an
6
+ * alias to a dsh `{provider, model}` route. Consumers (the cc-shell glue's
7
+ * `AgentProvider` and the Task tool) `ctx.get('ccModelRoutes')` lazily on
8
+ * every spawn — the resolver re-reads the live settings scope each call, so a
9
+ * settings write applies to the next spawn without re-registration.
10
+ *
11
+ * When no settings provider is mounted the resolver degrades to the config
12
+ * defaults plus the builtin fallback (an unconfigured builtin alias inherits
13
+ * the parent route), so a settings-less host still resolves.
14
+ *
15
+ * @module @dsh-cc/model-aliases/service
16
+ */
17
+ import z from '@deepseek-ai/schemastery';
18
+ import type { Context } from '@deepseek-ai/cordis';
19
+ import type { AliasInspection, AliasTarget, DetailedRoute, ResolvedRoute } from './types.ts';
20
+ /** Plugin configuration: deployment-default alias map. */
21
+ export interface Config {
22
+ /** Deployment defaults (alias name → model id or `{provider, model}` route). */
23
+ modelAliases?: Record<string, Exclude<AliasTarget, null>>;
24
+ }
25
+ /** Runtime config schema (config-layer aliases never hold null). */
26
+ export declare const Config: z<Config>;
27
+ /** The settings namespace carrying the live `model-aliases` overlay. */
28
+ export declare const MODEL_ALIASES_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
29
+ /** The shape consumers resolve through. */
30
+ export interface ModelRoutes {
31
+ /** Resolve one frontmatter `model` to a dsh route, or undefined to inherit. */
32
+ resolve(model: string | undefined): ResolvedRoute | undefined;
33
+ /**
34
+ * Atomic detailed resolution: `{selector, via, route}` from ONE settings
35
+ * snapshot — `via` records how the selector was classified (alias / literal
36
+ * / inherit) so callers can capture provenance without a second, racy lookup.
37
+ */
38
+ resolveDetailed(model: string | undefined): DetailedRoute;
39
+ /** Inspect one frontmatter `model` with provenance (for `/doctor` reporting). */
40
+ inspect(model: string | undefined): AliasInspection;
41
+ }
42
+ /** Cordis plugin id. */
43
+ export declare const name = "cc-model-routes";
44
+ /**
45
+ * Register the `model-aliases` settings namespace (when a settings provider is
46
+ * mounted) and expose the spawn-time resolver as the `ccModelRoutes` value.
47
+ * @param ctx - the plug context.
48
+ * @param config - deployment defaults.
49
+ */
50
+ export declare function apply(ctx: Context, config?: Config): void;
51
+ /**
52
+ * Host-plane alias read WITHOUT owning the namespace: resolve through the
53
+ * `ccModelRoutes` service when one is mounted, otherwise read the live
54
+ * `model-aliases` settings overlay directly. Never re-registers the namespace
55
+ * — the isolated `cc-model-routes` plugin row already owns that registration,
56
+ * and `settings.register` throws on a duplicate namespace.
57
+ * @param ctx - the host context (no plugin instance required).
58
+ * @param alias - frontmatter model alias, or undefined to inherit.
59
+ * @returns the resolved route, or undefined to inherit the parent route.
60
+ */
61
+ export declare function resolveAlias(ctx: Context, alias: string | undefined): ResolvedRoute | undefined;
62
+ /**
63
+ * Host-plane DETAILED alias read: the provenance-carrying counterpart of
64
+ * {@link resolveAlias}, with the same service-then-overlay fallback and the
65
+ * same single-snapshot guarantee (classification and route from one map).
66
+ * @param ctx - the host context (no plugin instance required).
67
+ * @param alias - frontmatter model alias, or undefined to inherit.
68
+ * @returns the atomic detailed resolution for the alias.
69
+ */
70
+ export declare function resolveDetailedAlias(ctx: Context, alias: string | undefined): DetailedRoute;
71
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AASlD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE5F,0DAA0D;AAC1D,MAAM,WAAW,MAAM;IACrB,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAA;CAC1D;AAED,oEAAoE;AACpE,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAAmD,CAAA;AAEhF,wEAAwE;AACxE,eAAO,MAAM,uBAAuB,uDAAqC,CAAA;AAEzE,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAAA;IAC7D;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,CAAA;IACzD,iFAAiF;IACjF,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,eAAe,CAAA;CACpD;AAED,wBAAwB;AACxB,eAAO,MAAM,IAAI,oBAAoB,CAAA;AAErC;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CA2C7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAS/F;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,CAS3F"}
package/lib/service.js ADDED
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The `ccModelRoutes` host service: the single owner of the `model-aliases`
3
+ * settings namespace registration.
4
+ *
5
+ * CC frontmatter names models by alias (`model: opus`); this package maps an
6
+ * alias to a dsh `{provider, model}` route. Consumers (the cc-shell glue's
7
+ * `AgentProvider` and the Task tool) `ctx.get('ccModelRoutes')` lazily on
8
+ * every spawn — the resolver re-reads the live settings scope each call, so a
9
+ * settings write applies to the next spawn without re-registration.
10
+ *
11
+ * When no settings provider is mounted the resolver degrades to the config
12
+ * defaults plus the builtin fallback (an unconfigured builtin alias inherits
13
+ * the parent route), so a settings-less host still resolves.
14
+ *
15
+ * @module @dsh-cc/model-aliases/service
16
+ */
17
+ import z from '@deepseek-ai/schemastery';
18
+ import { settingsNamespace } from '@deepseek-ai/dsh-settings';
19
+ import { ConfigAliasesSchema, SettingsAliasesSchema } from "./schema.js";
20
+ import { createModelInspector, createModelResolver, mergeAliasMaps } from "./resolver.js";
21
+ import { overlayStampedEffort, stampedEffortOf } from "./effort.js";
22
+ /** Runtime config schema (config-layer aliases never hold null). */
23
+ export const Config = z.object({ modelAliases: ConfigAliasesSchema });
24
+ /** The settings namespace carrying the live `model-aliases` overlay. */
25
+ export const MODEL_ALIASES_NAMESPACE = settingsNamespace('model-aliases');
26
+ /** Cordis plugin id. */
27
+ export const name = 'cc-model-routes';
28
+ /**
29
+ * Register the `model-aliases` settings namespace (when a settings provider is
30
+ * mounted) and expose the spawn-time resolver as the `ccModelRoutes` value.
31
+ * @param ctx - the plug context.
32
+ * @param config - deployment defaults.
33
+ */
34
+ export function apply(ctx, config = {}) {
35
+ const settings = ctx.get('settings');
36
+ const scope = settings?.register(MODEL_ALIASES_NAMESPACE, SettingsAliasesSchema, {
37
+ // Reject a half-written object route at write time (the dict schema cannot
38
+ // express a non-empty cross-field check).
39
+ validate: (value) => {
40
+ for (const [alias, target] of Object.entries(value)) {
41
+ if (target !== null && typeof target === 'object') {
42
+ if (typeof target.model !== 'string' || target.model.trim().length === 0) {
43
+ throw new Error(`cc-model-aliases: model alias "${alias}" must specify a non-empty model`);
44
+ }
45
+ if (target.provider !== undefined && target.provider.trim().length === 0) {
46
+ throw new Error(`cc-model-aliases: model alias "${alias}" must specify a non-empty provider when present`);
47
+ }
48
+ }
49
+ }
50
+ },
51
+ });
52
+ const aliasSources = () => mergeAliasMaps(config.modelAliases, scope?.get?.());
53
+ const warnOptions = { warn: (message) => ctx.logger.warn(message) };
54
+ const resolver = createModelResolver(aliasSources, warnOptions);
55
+ const inspect = createModelInspector(aliasSources, warnOptions);
56
+ const resolveDetailed = resolver.resolveDetailed;
57
+ // Both consumption shapes must be published: the Task tool's resume-pin
58
+ // capture calls `resolveDetailed` — publishing only `resolve` makes every
59
+ // captured background spawn throw TypeError at spawn time. `inspect` keeps
60
+ // the upstream provenance form (`/doctor`) available alongside.
61
+ ctx.provide('ccModelRoutes', { resolve: resolver, resolveDetailed, inspect });
62
+ // Host-side effort overlay: a child spawned through an alias whose route
63
+ // declared `reasoningEffort` carries it on its options as an undeclared
64
+ // runtime extra key (stamped by the Task tool / plugin-loader). buildRequest
65
+ // deep-freezes its seed config and may restore an explicit parent /effort
66
+ // from a fork seed's request/header — the alias contract wins, so overlay
67
+ // AFTER `next()` with a shallow copy (never in place). Root agents carry no
68
+ // stamp on options, so this is a no-op for them.
69
+ ctx.on('agent/request', async ({ agent }, next) => {
70
+ const resolved = await next();
71
+ return overlayStampedEffort(resolved, stampedEffortOf(agent.options));
72
+ });
73
+ }
74
+ /**
75
+ * Host-plane alias read WITHOUT owning the namespace: resolve through the
76
+ * `ccModelRoutes` service when one is mounted, otherwise read the live
77
+ * `model-aliases` settings overlay directly. Never re-registers the namespace
78
+ * — the isolated `cc-model-routes` plugin row already owns that registration,
79
+ * and `settings.register` throws on a duplicate namespace.
80
+ * @param ctx - the host context (no plugin instance required).
81
+ * @param alias - frontmatter model alias, or undefined to inherit.
82
+ * @returns the resolved route, or undefined to inherit the parent route.
83
+ */
84
+ export function resolveAlias(ctx, alias) {
85
+ const routes = ctx.get('ccModelRoutes');
86
+ if (routes !== undefined)
87
+ return routes.resolve(alias);
88
+ const settings = ctx.get('settings');
89
+ const overlay = settings?.get?.(MODEL_ALIASES_NAMESPACE);
90
+ return createModelResolver(() => mergeAliasMaps(undefined, overlay), { warn: message => ctx.logger.warn(message) })(alias);
91
+ }
92
+ /**
93
+ * Host-plane DETAILED alias read: the provenance-carrying counterpart of
94
+ * {@link resolveAlias}, with the same service-then-overlay fallback and the
95
+ * same single-snapshot guarantee (classification and route from one map).
96
+ * @param ctx - the host context (no plugin instance required).
97
+ * @param alias - frontmatter model alias, or undefined to inherit.
98
+ * @returns the atomic detailed resolution for the alias.
99
+ */
100
+ export function resolveDetailedAlias(ctx, alias) {
101
+ const routes = ctx.get('ccModelRoutes');
102
+ if (routes !== undefined)
103
+ return routes.resolveDetailed(alias);
104
+ const settings = ctx.get('settings');
105
+ const overlay = settings?.get?.(MODEL_ALIASES_NAMESPACE);
106
+ return createModelResolver(() => mergeAliasMaps(undefined, overlay), { warn: message => ctx.logger.warn(message) }).resolveDetailed(alias);
107
+ }
108
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAMxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACzF,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AASnE,oEAAoE;AACpE,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC,CAAA;AAEhF,wEAAwE;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAA;AAgBzE,wBAAwB;AACxB,MAAM,CAAC,MAAM,IAAI,GAAG,iBAAiB,CAAA;AAErC;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY,EAAE,SA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;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAY,EAAE,KAAyB;IAC1E,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,eAAe,CAA4B,CAAA;IAClE,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IAC9D,MAAM,QAAQ,GAAG,GAAG,CAAC,GAAG,CAAC,UAAU,CAAiC,CAAA;IACpE,MAAM,OAAO,GAAG,QAAQ,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAmD,CAAA;IAC1G,OAAO,mBAAmB,CACxB,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,EACxC,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAC9C,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Shared vocabulary for Claude Code-compatible model alias resolution.
3
+ *
4
+ * Claude Code frontmatter (`model: opus`, `model: sonnet`) names aliases rather
5
+ * than literal provider model IDs. This package layers those aliases onto the
6
+ * harness: it maps an alias to a dsh `{provider, model}` route, or leaves the
7
+ * frontmatter untouched so the child inherits its parent's route. The types
8
+ * here are the pure record shapes the resolution functions consume and emit;
9
+ * the merge and lookup semantics live in `resolver.ts` and the configuration
10
+ * schemas in `schema.ts`.
11
+ *
12
+ * @module @dsh-cc/model-aliases/types
13
+ */
14
+ /**
15
+ * A resolved dsh model route for one spawn.
16
+ *
17
+ * When `start()` passes this on as `agentOptions`, only the fields that are
18
+ * present (`provider` and/or `model`) override the delegation; a route omitting
19
+ * `provider` inherits the parent's provider, and one omitting `model` inherits
20
+ * the parent's model. `reasoningEffort`, when present, is stamped onto the
21
+ * child's options (a runtime extra key) and applied to every child request by
22
+ * the host `agent/request` listener in the routes service. `undefined` means
23
+ * "no override" — the child inherits the parent route wholesale (the `inherit`
24
+ * sentinel and the builtin fallback both resolve to this).
25
+ */
26
+ export interface ResolvedRoute {
27
+ /** The provider to route to; omit to inherit the parent's provider. */
28
+ readonly provider?: string | undefined;
29
+ /** The model id (or resolved alias model) to use; omit to inherit. */
30
+ readonly model?: string | undefined;
31
+ /**
32
+ * Reasoning effort stamped from the alias target (object form only); an
33
+ * opaque non-empty string whose legal spellings belong to the target model's
34
+ * adapter (`max`, `xhigh`, `high`, …). Absent → no effort stamp.
35
+ */
36
+ readonly reasoningEffort?: string | undefined;
37
+ }
38
+ /**
39
+ * What an alias lookup resolved to, for provenance reporting (`/doctor`).
40
+ *
41
+ * - `route`: a concrete route was produced (configured object, or a followed
42
+ * string/peer target).
43
+ * - `inherit`: no override — the child inherits the parent route.
44
+ * - `literal`: the alias name is passed through verbatim as a model id.
45
+ */
46
+ export type AliasInspectKind = 'route' | 'inherit' | 'literal';
47
+ /**
48
+ * Where the classification came from: a directly configured entry, a peer
49
+ * lane's entry, a one-hop string target, or the builtin fallback.
50
+ */
51
+ export type AliasInspectVia = 'configured' | 'peer' | 'one-hop' | 'builtin';
52
+ /**
53
+ * Provenance of one alias resolution. `route` is exactly what
54
+ * `resolve()` returned for the same input; `via`/`hop` are omitted when not
55
+ * meaningful (e.g. the literal passthrough and the bare inherit cases).
56
+ */
57
+ export interface AliasInspection {
58
+ readonly kind: AliasInspectKind;
59
+ readonly route?: ResolvedRoute;
60
+ readonly via?: AliasInspectVia;
61
+ readonly hop?: string;
62
+ }
63
+ /**
64
+ * One atomic resolution result: the effective route PLUS its provenance,
65
+ * captured from a single settings snapshot (never re-derived later). `via`
66
+ * records how `selector` was classified:
67
+ * - `inherit`: no override (`undefined`, blank, the `inherit` sentinel, an
68
+ * unconfigured builtin, or an unresolvable lane peer) — the parent route
69
+ * stands and `route` is undefined.
70
+ * - `alias`: a configured alias (or a lane peer sharing a configured peer's
71
+ * route) — `route` is the alias's resolved route.
72
+ * - `literal`: passed through verbatim as a model id — `route` is
73
+ * `{ model: selector }` with `provider` absent.
74
+ */
75
+ export interface DetailedRoute {
76
+ /** The trimmed selector that was resolved (undefined for blank/undefined input). */
77
+ readonly selector: string | undefined;
78
+ /** How the selector was classified, from the same snapshot as `route`. */
79
+ readonly via: 'alias' | 'literal' | 'inherit';
80
+ /** The resolved route (undefined exactly when `via` is `inherit`). */
81
+ readonly route: ResolvedRoute | undefined;
82
+ }
83
+ /**
84
+ * One alias target as authored in config or settings.
85
+ *
86
+ * A string form names only a model id (`sonnet: deepseek-chat`); the provider
87
+ * inherits the parent route. An object form additionally pins a provider
88
+ * (`opus: { provider: ..., model: ... }`) — `provider` is optional so an alias
89
+ * can inherit the parent provider while still pinning a model and effort — and
90
+ * may carry a `reasoningEffort` stamped onto spawns of this alias. In the
91
+ * settings layer a configured entry may instead be `null`, which deletes a
92
+ * same-named config-default entry (see {@link mergeAliasMaps}).
93
+ */
94
+ export type AliasTarget = string | {
95
+ readonly provider?: string;
96
+ readonly model: string;
97
+ readonly reasoningEffort?: string;
98
+ } | null;
99
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,sEAAsE;IACtE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9C;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;AAE9D;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;AAE3E;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAA;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,eAAe,CAAA;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;IAC7C,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAAA;CAC1C;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,GACjB,MAAM,GACN;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GACzF,IAAI,CAAA"}
package/lib/types.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shared vocabulary for Claude Code-compatible model alias resolution.
3
+ *
4
+ * Claude Code frontmatter (`model: opus`, `model: sonnet`) names aliases rather
5
+ * than literal provider model IDs. This package layers those aliases onto the
6
+ * harness: it maps an alias to a dsh `{provider, model}` route, or leaves the
7
+ * frontmatter untouched so the child inherits its parent's route. The types
8
+ * here are the pure record shapes the resolution functions consume and emit;
9
+ * the merge and lookup semantics live in `resolver.ts` and the configuration
10
+ * schemas in `schema.ts`.
11
+ *
12
+ * @module @dsh-cc/model-aliases/types
13
+ */
14
+ export {};
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@dsh-cc/model-aliases",
3
+ "description": "Claude Code-compatible model alias resolution for the DeepSeek Harness",
4
+ "version": "0.5.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/dsh-cc/dsh-cc.git",
8
+ "directory": "packages/compat/cc-model-aliases"
9
+ },
10
+ "type": "module",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./lib/index.d.ts",
14
+ "default": "./lib/index.js"
15
+ },
16
+ "./types": {
17
+ "types": "./lib/types.d.ts",
18
+ "default": "./lib/types.js"
19
+ },
20
+ "./schema": {
21
+ "types": "./lib/schema.d.ts",
22
+ "default": "./lib/schema.js"
23
+ },
24
+ "./resolver": {
25
+ "types": "./lib/resolver.d.ts",
26
+ "default": "./lib/resolver.js"
27
+ },
28
+ "./src/*": "./src/*",
29
+ "./package.json": "./package.json"
30
+ },
31
+ "files": [
32
+ "lib"
33
+ ],
34
+ "license": "Apache-2.0",
35
+ "peerDependencies": {
36
+ "@deepseek-ai/cordis": ">=0.1.1-rc.2",
37
+ "@deepseek-ai/dsh-agent": ">=0.1.1-rc.2",
38
+ "@deepseek-ai/dsh-settings": ">=0.1.1-rc.2",
39
+ "@deepseek-ai/schemastery": "^3.18.1"
40
+ },
41
+ "devDependencies": {
42
+ "@deepseek-ai/schemastery": "link:../../../../deepseek-harness/vendor/schemastery",
43
+ "@deepseek-ai/cordis": "link:../../../../deepseek-harness/vendor/cordis",
44
+ "@deepseek-ai/dsh-settings": "link:../../../../deepseek-harness/packages/settings/settings",
45
+ "@deepseek-ai/dsh-agent": "link:../../../../deepseek-harness/packages/core/agent",
46
+ "@deepseek-ai/dsh-agent-loop": "link:../../../../deepseek-harness/packages/core/agent-loop",
47
+ "@deepseek-ai/dsh-agent-loop-testkit": "link:../../../../deepseek-harness/packages/test-support/agent-loop-testkit",
48
+ "@deepseek-ai/dsh-llm": "link:../../../../deepseek-harness/packages/llm/llm",
49
+ "@deepseek-ai/dsh-session": "link:../../../../deepseek-harness/packages/core/session",
50
+ "@deepseek-ai/dsh-session-persistence-jsonl": "link:../../../../deepseek-harness/packages/session/session-persistence-jsonl",
51
+ "@deepseek-ai/dsh-session-projection": "link:../../../../deepseek-harness/packages/session/session-projection",
52
+ "@deepseek-ai/dsh-subagent": "link:../../../../deepseek-harness/packages/subagent/subagent",
53
+ "@deepseek-ai/dsh-subagent-spawn-in-process": "link:../../../../deepseek-harness/packages/subagent/subagent-spawn-in-process",
54
+ "@deepseek-ai/dsh-subagent-fork-in-process": "link:../../../../deepseek-harness/packages/subagent/subagent-fork-in-process",
55
+ "@dsh-cc/agent-loop-mock": "^0.1.0"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ }
60
+ }