@namzu/cli 4.1.0 → 4.3.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.
@@ -22,6 +22,27 @@ export interface ProviderChainCheckOptions {
22
22
  * is the worst moment to find out the key was never set. So every member's
23
23
  * credential is resolved here, on a day when nothing is broken.
24
24
  *
25
+ * ## Two ways a chain is unusable, and this reports both
26
+ *
27
+ * A credential is the obvious one. The other is a capability DISAGREEMENT: a
28
+ * run negotiates tools, vision and documents once, against the primary, and
29
+ * keeps that answer across a swap — so a chain whose members declare different
30
+ * abilities would land a run on a member holding a request shaped for someone
31
+ * else. `createAgentSession` refuses such a chain outright, which means an
32
+ * operator who has one learns about it by trying to start a session.
33
+ *
34
+ * That check used to be unreachable from here. Reading what a provider declares
35
+ * requires its package to be registered, and the only registration path lived
36
+ * inside the interactive session module — so `doctor` could report which
37
+ * members had keys and not whether the chain it was describing could run at
38
+ * all. A diagnostic that cannot see what the thing it diagnoses sees is
39
+ * checking the wrong thing. `ensureRegistered` now lives beside the registry
40
+ * (`integrations/providers/register.ts`) and both reach it.
41
+ *
42
+ * The cost is real and worth naming: this check dynamically imports the driver
43
+ * package of every member in the chain. That is the price of reading a
44
+ * declaration, and it is paid on a command whose entire job is to look.
45
+ *
25
46
  * Exported separately from the `DoctorCheck` so it can be driven with an
26
47
  * explicit home and environment. The check itself is still exercised through
27
48
  * `providerChainCheck.run`, because a helper proven in isolation says nothing
@@ -1 +1 @@
1
- {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/doctor/checks/chain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEhE,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,0CAA0C,CAAA;AAIlG,MAAM,WAAW,yBAAyB;IACzC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,CAAA;IACrC,uFAAuF;IACvF,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,GAAE,yBAA8B,GACrC,OAAO,CAAC,iBAAiB,CAAC,CA+F5B;AAED,eAAO,MAAM,kBAAkB,EAAE,WAIhC,CAAA"}
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/doctor/checks/chain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAMhE,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,0CAA0C,CAAA;AAKlG,MAAM,WAAW,yBAAyB;IACzC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,KAAK,CAAC,CAAA;IACrC,uFAAuF;IACvF,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,GAAE,yBAA8B,GACrC,OAAO,CAAC,iBAAiB,CAAC,CAoJ5B;AAED,eAAO,MAAM,kBAAkB,EAAE,WAIhC,CAAA"}
@@ -1,6 +1,8 @@
1
1
  import { homedir } from 'node:os';
2
+ import { chainCapabilityDisagreements, unresolvedMembers, } from '../../integrations/providers/chain-capabilities.js';
2
3
  import { discoverProviders } from '../../integrations/providers/discover.js';
3
4
  import { preferencesPath, readPreferences } from '../../integrations/providers/preferences.js';
5
+ import { resolveChainCapabilities } from '../../integrations/providers/register.js';
4
6
  import { PROVIDER_REGISTRY } from '../../integrations/providers/registry.js';
5
7
  /**
6
8
  * The configured provider chain, in the operator's declared order.
@@ -17,6 +19,27 @@ import { PROVIDER_REGISTRY } from '../../integrations/providers/registry.js';
17
19
  * is the worst moment to find out the key was never set. So every member's
18
20
  * credential is resolved here, on a day when nothing is broken.
19
21
  *
22
+ * ## Two ways a chain is unusable, and this reports both
23
+ *
24
+ * A credential is the obvious one. The other is a capability DISAGREEMENT: a
25
+ * run negotiates tools, vision and documents once, against the primary, and
26
+ * keeps that answer across a swap — so a chain whose members declare different
27
+ * abilities would land a run on a member holding a request shaped for someone
28
+ * else. `createAgentSession` refuses such a chain outright, which means an
29
+ * operator who has one learns about it by trying to start a session.
30
+ *
31
+ * That check used to be unreachable from here. Reading what a provider declares
32
+ * requires its package to be registered, and the only registration path lived
33
+ * inside the interactive session module — so `doctor` could report which
34
+ * members had keys and not whether the chain it was describing could run at
35
+ * all. A diagnostic that cannot see what the thing it diagnoses sees is
36
+ * checking the wrong thing. `ensureRegistered` now lives beside the registry
37
+ * (`integrations/providers/register.ts`) and both reach it.
38
+ *
39
+ * The cost is real and worth naming: this check dynamically imports the driver
40
+ * package of every member in the chain. That is the price of reading a
41
+ * declaration, and it is paid on a command whose entire job is to look.
42
+ *
20
43
  * Exported separately from the `DoctorCheck` so it can be driven with an
21
44
  * explicit home and environment. The check itself is still exercised through
22
45
  * `providerChainCheck.run`, because a helper proven in isolation says nothing
@@ -91,23 +114,65 @@ export async function describeProviderChain(options = {}) {
91
114
  lines.push(`${index + 1}. ${position} · ${entry.label} · ${model} · ${state}`);
92
115
  }
93
116
  const chain = lines.join('\n');
94
- if (unusable === 0) {
117
+ // What each member DECLARES. Type-level, so no credential is needed — which
118
+ // is what makes it answerable about the fallback nobody has configured yet,
119
+ // the member most worth asking about.
120
+ const resolved = await resolveChainCapabilities(members);
121
+ const disagreements = chainCapabilityDisagreements(members, resolved);
122
+ const accepted = read.prefs.allowCapabilityMismatch === true;
123
+ const unreadable = unresolvedMembers(members, resolved);
124
+ const primaryUnreadable = resolved[0]?.kind === 'unresolved';
125
+ const sections = [chain];
126
+ if (disagreements.length > 0) {
127
+ sections.push(accepted
128
+ ? 'The members declare different capabilities, and you have accepted that:'
129
+ : 'The members declare different capabilities, so a session will be REFUSED:', ...disagreements.map((d) => ` - ${d.sentence}`));
130
+ }
131
+ if (unreadable.length > 0) {
132
+ // Kept separate from the disagreements above, for the reason the session
133
+ // keeps them separate: a member whose declaration could not be read is not
134
+ // a member that disagrees, and reporting it as one would name a conflict
135
+ // nobody established.
136
+ sections.push('Could not read what these members declare:', ...unreadable.map((line) => ` - ${line}`));
137
+ }
138
+ const message = sections.join('\n');
139
+ // Ordered by what stops a run. An unaccepted disagreement and an unusable
140
+ // primary both mean no session starts at all; everything else leaves namzu
141
+ // working with less than the operator declared.
142
+ if (disagreements.length > 0 && !accepted) {
143
+ return {
144
+ status: 'fail',
145
+ message: `provider chain cannot be honoured as written:\n${message}`,
146
+ remediation: 'Drop the member that disagrees, or set "allowCapabilityMismatch": true in your preferences to accept the limitation. namzu will not choose between advertising abilities a fallback lacks and costing your primary a capability on every run.',
147
+ };
148
+ }
149
+ if (primaryUnusable || primaryUnreadable) {
150
+ return {
151
+ status: 'fail',
152
+ message: `${unusable} of ${members.length} chain member(s) cannot be used:\n${message}`,
153
+ remediation: primaryUnusable
154
+ ? 'The primary provider has no usable credential, so no run can start. Set its key, or run `namzu` to pick a provider that has one.'
155
+ : 'The primary provider could not be loaded, so no run can start. Run `namzu` to pick a provider that can.',
156
+ };
157
+ }
158
+ if (unusable > 0 || unreadable.length > 0 || disagreements.length > 0) {
95
159
  return {
96
- status: 'pass',
97
- message: members.length === 1
98
- ? `1 provider configured (no fallback):\n${chain}`
99
- : `${members.length} providers configured, in order:\n${chain}`,
160
+ // `warn`, not `fail`: the primary still runs, so namzu is usable and the
161
+ // operator is not blocked by a degraded spare.
162
+ status: 'warn',
163
+ message: unusable > 0
164
+ ? `${unusable} of ${members.length} chain member(s) cannot be used:\n${message}`
165
+ : `provider chain usable, with limitations:\n${message}`,
166
+ remediation: unusable > 0
167
+ ? 'The primary still works, so runs will start. But a fallback with no credential is not a fallback — set its key, or take it out of the chain.'
168
+ : 'The primary still works. A fallback that declares less than your primary will serve shorter or less capable turns if the chain ever falls over to it.',
100
169
  };
101
170
  }
102
171
  return {
103
- // `warn`, not `fail`, when only a fallback is broken: the primary still
104
- // runs, so namzu is usable and the operator is not blocked by a
105
- // degraded spare. A broken PRIMARY stops every run, and reads as such.
106
- status: primaryUnusable ? 'fail' : 'warn',
107
- message: `${unusable} of ${members.length} chain member(s) cannot be used:\n${chain}`,
108
- remediation: primaryUnusable
109
- ? 'The primary provider has no usable credential, so no run can start. Set its key, or run `namzu` to pick a provider that has one.'
110
- : 'The primary still works, so runs will start. But a fallback with no credential is not a fallback — set its key, or take it out of the chain.',
172
+ status: 'pass',
173
+ message: members.length === 1
174
+ ? `1 provider configured (no fallback):\n${message}`
175
+ : `${members.length} providers configured, in order:\n${message}`,
111
176
  };
112
177
  }
113
178
  export const providerChainCheck = {
@@ -1 +1 @@
1
- {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/doctor/checks/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAIjC,OAAO,EAAwB,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAClG,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAC9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAU5E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,UAAqC,EAAE;IAEvC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,EAAE,CAAA;IACtC,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IAElC,IAAI,IAAwC,CAAA;IAC5C,IAAI,CAAC;QACJ,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;IAAC,O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G,CAAC;gBACX,CAAC,CAAC,8IAA8I;gBAChJ,CAAC,CAAC,uJAAuJ;SAC3J,CAAA;IACF,CAAC;IAED,OAAO;QACN,MAAM,EAAE,MAAM;QACd,OAAO,EACN,OAAO,CAAC,MAAM,KAAK,CAAC;YACnB,CAAC,CAAC,yCAAyC,OAAO,EAAE;YACpD,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,qCAAqC,OAAO,EAAE;KACnE,CAAA;AACF,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC9C,EAAE,EAAE,iBAAiB;IACrB,QAAQ,EAAE,WAAW;IACrB,GAAG,EAAE,CAAC,GAAG,EAA8B,EAAE,CAAC,qBAAqB,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;CACjF,CAAA"}
@@ -30,12 +30,16 @@
30
30
  *
31
31
  * ## And it is a property of the CHAIN, not of a run
32
32
  *
33
- * Only the primary runs today; nothing falls over yet. So no sentence here
34
- * claims a run is degraded — each says what becomes unavailable IF the chain
35
- * falls over. When failover lands the run-level statement becomes true and can
36
- * be made then. Making it now would be a confident claim about a degradation
37
- * that has not happened, which is the failure this line of work exists to
38
- * remove.
33
+ * Every sentence here says what becomes unavailable IF the chain falls over,
34
+ * and that stays the right tense now that it does. A run negotiates
35
+ * capabilities once, against the primary, and keeps that answer across a swap —
36
+ * so at the moment this check runs, no degradation has happened and claiming
37
+ * one would be a confident statement about a turn that may never come.
38
+ *
39
+ * The conditional is also what makes the refusal worth having. Because the
40
+ * negotiated answer does NOT follow the swap, a chain that disagrees would put
41
+ * a run on a member holding a request shaped for someone else. Catching that
42
+ * here, before a run starts, is cheaper than discovering it during one.
39
43
  */
40
44
  import type { ResolvedProviderCapabilities } from '@namzu/sdk';
41
45
  import { type ProviderChoice } from './preferences.js';
@@ -1 +1 @@
1
- {"version":3,"file":"chain-capabilities.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/chain-capabilities.ts"],"names":[],"mappings":"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  *
33
- * Only the primary runs today; nothing falls over yet. So no sentence here
34
- * claims a run is degraded — each says what becomes unavailable IF the chain
35
- * falls over. When failover lands the run-level statement becomes true and can
36
- * be made then. Making it now would be a confident claim about a degradation
37
- * that has not happened, which is the failure this line of work exists to
38
- * remove.
33
+ * Every sentence here says what becomes unavailable IF the chain falls over,
34
+ * and that stays the right tense now that it does. A run negotiates
35
+ * capabilities once, against the primary, and keeps that answer across a swap —
36
+ * so at the moment this check runs, no degradation has happened and claiming
37
+ * one would be a confident statement about a turn that may never come.
38
+ *
39
+ * The conditional is also what makes the refusal worth having. Because the
40
+ * negotiated answer does NOT follow the swap, a chain that disagrees would put
41
+ * a run on a member holding a request shaped for someone else. Catching that
42
+ * here, before a run starts, is cheaper than discovering it during one.
39
43
  */
40
44
  import { chainPositionName } from './preferences.js';
41
45
  import { PROVIDER_REGISTRY } from './registry.js';
@@ -1 +1 @@
1
- {"version":3,"file":"chain-capabilities.js","sourceRoot":"","sources":["../../../src/integrations/providers/chain-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,EAAuB,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAgBjD;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAUrB;IACJ;QACC,GAAG,EAAE,eAAe;QACpB,GAAG,EAAE,mBAAmB;QACxB,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,0BAA0B;KACvC;IACD;QACC,GAAG,EAAE,yBAAyB;QAC9B,GAAG,EAAE,8BAA8B;QACnC,KAAK,EAAE,sCAAsC;QAC7C,WAAW,EAAE,sCAAsC;KACnD;IACD;QACC,GAAG,EAAE,mBAAmB;QACxB,GAAG,EAAE,uBAAuB;QAC5B,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,wBAAwB;KACrC;IACD;QACC,GAAG,EAAE,gBA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MAAM,EAAE,CAAC,CAAA;IACxD,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACxC,aAAgD;IAEhD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3C,OAAO;QACN,0GAA0G;QAC1G,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,EAAE;QACF,kOAAkO;QAClO,sKAAsK;KACtK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACb,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,wBAAwB,CACvC,aAAgD;IAEhD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3C,OAAO;QACN,yFAAyF;QACzF,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;KAChD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACb,CAAC"}
1
+ {"version":3,"file":"chain-capabilities.js","sourceRoot":"","sources":["../../../src/integrations/providers/chain-capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAIH,OAAO,EAAuB,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAgBjD;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAUrB;IACJ;QACC,GAAG,EAAE,eAAe;QACpB,GAAG,EAAE,mBAAmB;QACxB,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,0BAA0B;KACvC;IACD;QACC,GAAG,EAAE,yBAAyB;QAC9B,GAAG,EAAE,8BAA8B;QACnC,KAAK,EAAE,sCAAsC;QAC7C,W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;QAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,CAAC,MAAM;YAAE,SAAQ;QACpD,GAAG,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACxD,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACxC,aAAgD;IAEhD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3C,OAAO;QACN,0GAA0G;QAC1G,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,EAAE;QACF,kOAAkO;QAClO,sKAAsK;KACtK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACb,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,wBAAwB,CACvC,aAAgD;IAEhD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3C,OAAO;QACN,yFAAyF;QACzF,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;KAChD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACb,CAAC"}
@@ -4,4 +4,5 @@ export { ensureFreshAnthropicToken, type OAuthMetadata, refreshAgentOAuthToken,
4
4
  export { type CapabilityDisagreement, chainCapabilityDisagreements, describeAcceptedMismatch, describeCapabilityRefusal, type MemberCapabilities, unresolvedMembers, } from './chain-capabilities.js';
5
5
  export { chainPositionName, type Preferences, PREFERENCES_FILE_VERSION, PreferencesError, preferencesPath, primaryProvider, type ProviderChoice, type ReadResult, readPreferences, writePreferences, } from './preferences.js';
6
6
  export { ALL_PROVIDER_IDS, PROVIDER_REGISTRY, type ProviderId, type ProviderRegistryEntry, type SdkProviderType, } from './registry.js';
7
+ export { ensureRegistered, isRegistered, resolveChainCapabilities } from './register.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,iBAAiB,EACjB,YAAY,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,yBAAyB,EACzB,KAAK,aAAa,EAClB,sBAAsB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,iBAAiB,GACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,iBAAiB,EACjB,KAAK,WAAW,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,eAAe,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACpB,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,iBAAiB,EACjB,YAAY,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,yBAAyB,EACzB,KAAK,aAAa,EAClB,sBAAsB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,KAAK,sBAAsB,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,iBAAiB,GACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,iBAAiB,EACjB,KAAK,WAAW,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,eAAe,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA"}
@@ -4,4 +4,5 @@ export { ensureFreshAnthropicToken, refreshAgentOAuthToken, } from './oauth.js';
4
4
  export { chainCapabilityDisagreements, describeAcceptedMismatch, describeCapabilityRefusal, unresolvedMembers, } from './chain-capabilities.js';
5
5
  export { chainPositionName, PREFERENCES_FILE_VERSION, PreferencesError, preferencesPath, primaryProvider, readPreferences, writePreferences, } from './preferences.js';
6
6
  export { ALL_PROVIDER_IDS, PROVIDER_REGISTRY, } from './registry.js';
7
+ export { ensureRegistered, isRegistered, resolveChainCapabilities } from './register.js';
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,iBAAiB,EACjB,YAAY,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAEN,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,yBAAyB,EAEzB,sBAAsB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EAEN,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EAEzB,iBAAiB,GACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,iBAAiB,EAEjB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,eAAe,EAGf,eAAe,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,gBAAgB,EAChB,iBAAiB,GAIjB,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,iBAAiB,EACjB,YAAY,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAEN,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,yBAAyB,EAEzB,sBAAsB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EAEN,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EAEzB,iBAAiB,GACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,iBAAiB,EAEjB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,eAAe,EAGf,eAAe,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,gBAAgB,EAChB,iBAAiB,GAIjB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA"}
@@ -16,11 +16,11 @@
16
16
  * the order has to be legible and editable without launching the TUI, which a
17
17
  * value only reachable through an interactive picker is not.
18
18
  *
19
- * **Only `providers[0]` runs today.** The rest are validated and reported (see
20
- * `readPreferences` and the `providers.chain` doctor check) but nothing falls
21
- * over to them yet. That is the point of shipping this first: a chain you can
22
- * declare, read back, and have checked is useful before failover exists, and it
23
- * is what failover will consume.
19
+ * `providers[0]` serves; the rest are fallen over to, in order, when it cannot.
20
+ * The tail is still validated and reported ahead of any failure (see
21
+ * `readPreferences` and the `providers.chain` doctor check), because a fallback
22
+ * is invisible by construction — nothing exercises it until the primary is
23
+ * already down, which is the worst moment to discover the key was never set.
24
24
  *
25
25
  * ## Versions
26
26
  *
@@ -16,11 +16,11 @@
16
16
  * the order has to be legible and editable without launching the TUI, which a
17
17
  * value only reachable through an interactive picker is not.
18
18
  *
19
- * **Only `providers[0]` runs today.** The rest are validated and reported (see
20
- * `readPreferences` and the `providers.chain` doctor check) but nothing falls
21
- * over to them yet. That is the point of shipping this first: a chain you can
22
- * declare, read back, and have checked is useful before failover exists, and it
23
- * is what failover will consume.
19
+ * `providers[0]` serves; the rest are fallen over to, in order, when it cannot.
20
+ * The tail is still validated and reported ahead of any failure (see
21
+ * `readPreferences` and the `providers.chain` doctor check), because a fallback
22
+ * is invisible by construction — nothing exercises it until the primary is
23
+ * already down, which is the worst moment to discover the key was never set.
24
24
  *
25
25
  * ## Versions
26
26
  *
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Put a driver package into the SDK's `ProviderRegistry`, once per process.
3
+ *
4
+ * This is the only place the wired driver packages are imported, so it decides
5
+ * what a `namzu` invocation actually pulls in and when. The imports are dynamic
6
+ * for that reason: a run on one provider does not load the other three, and a
7
+ * command that never touches a model loads none.
8
+ *
9
+ * ## Why it lives here rather than in the session module
10
+ *
11
+ * It used to be module-private inside the interactive session, which made
12
+ * reading what a provider DECLARES a privilege of having started a session.
13
+ * Registration is a precondition of that read — the SDK cannot report the
14
+ * capabilities of a package nobody imported — so `namzu doctor`, whose whole
15
+ * job is to answer questions about the setup before a session exists, could not
16
+ * ask. The alternative was for the diagnostic to import the session module and
17
+ * with it the query runtime, the subagent runtime, MCP, memory and skills, for
18
+ * one map lookup.
19
+ *
20
+ * So it sits beside `PROVIDER_REGISTRY`, which is the data it switches over,
21
+ * and both the session and the doctor reach it without either importing the
22
+ * other.
23
+ *
24
+ * ## One set, and that is load-bearing
25
+ *
26
+ * `registered` makes registration idempotent. It must exist exactly once: two
27
+ * copies would each believe a provider was unregistered and register it twice,
28
+ * and the SDK's registry rejects that with a duplicate-provider error. That is
29
+ * the whole reason this is a module rather than a function anyone may copy —
30
+ * the state is the API as much as the function is.
31
+ */
32
+ import type { MemberCapabilities } from './chain-capabilities.js';
33
+ import type { ProviderChoice } from './preferences.js';
34
+ import { type ProviderId } from './registry.js';
35
+ /**
36
+ * Import and register the driver for `id`, unless it is already registered.
37
+ *
38
+ * Throws for a provider that has a registry entry but no wiring here. That
39
+ * asymmetry is a known defect, not a design: the entry, the label, the default
40
+ * model and the discovery probe all cooperate to advertise a provider that
41
+ * cannot be built. See issue #257.
42
+ */
43
+ export declare function ensureRegistered(id: ProviderId): Promise<void>;
44
+ /**
45
+ * Has this provider's driver been registered in THIS process?
46
+ *
47
+ * Read by the chain builder to skip a member whose registration failed, so the
48
+ * failure is reported once — as an unresolved capability — rather than twice in
49
+ * different words.
50
+ */
51
+ export declare function isRegistered(id: ProviderId): boolean;
52
+ /**
53
+ * What each member of the chain DECLARES it can do.
54
+ *
55
+ * Type-level, via the registry, so nothing is constructed and no credential is
56
+ * needed — which is the whole point: the member most worth checking is the
57
+ * fallback nobody has set up yet, and a check that demanded a key would be
58
+ * unusable in exactly that case.
59
+ *
60
+ * A member that cannot be registered is reported as unresolved rather than
61
+ * assumed to agree. Registration is also why this cannot be a pure function: a
62
+ * provider package is only imported when something needs it.
63
+ */
64
+ export declare function resolveChainCapabilities(members: readonly ProviderChoice[]): Promise<readonly MemberCapabilities[]>;
65
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAIlE;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BpE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAEpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,SAAS,cAAc,EAAE,GAChC,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC,CAuBxC"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Put a driver package into the SDK's `ProviderRegistry`, once per process.
3
+ *
4
+ * This is the only place the wired driver packages are imported, so it decides
5
+ * what a `namzu` invocation actually pulls in and when. The imports are dynamic
6
+ * for that reason: a run on one provider does not load the other three, and a
7
+ * command that never touches a model loads none.
8
+ *
9
+ * ## Why it lives here rather than in the session module
10
+ *
11
+ * It used to be module-private inside the interactive session, which made
12
+ * reading what a provider DECLARES a privilege of having started a session.
13
+ * Registration is a precondition of that read — the SDK cannot report the
14
+ * capabilities of a package nobody imported — so `namzu doctor`, whose whole
15
+ * job is to answer questions about the setup before a session exists, could not
16
+ * ask. The alternative was for the diagnostic to import the session module and
17
+ * with it the query runtime, the subagent runtime, MCP, memory and skills, for
18
+ * one map lookup.
19
+ *
20
+ * So it sits beside `PROVIDER_REGISTRY`, which is the data it switches over,
21
+ * and both the session and the doctor reach it without either importing the
22
+ * other.
23
+ *
24
+ * ## One set, and that is load-bearing
25
+ *
26
+ * `registered` makes registration idempotent. It must exist exactly once: two
27
+ * copies would each believe a provider was unregistered and register it twice,
28
+ * and the SDK's registry rejects that with a duplicate-provider error. That is
29
+ * the whole reason this is a module rather than a function anyone may copy —
30
+ * the state is the API as much as the function is.
31
+ */
32
+ import { ProviderRegistry } from '@namzu/sdk';
33
+ import { resolveProviderCapabilities } from '@namzu/sdk';
34
+ import { PROVIDER_REGISTRY } from './registry.js';
35
+ const registered = new Set();
36
+ /**
37
+ * Import and register the driver for `id`, unless it is already registered.
38
+ *
39
+ * Throws for a provider that has a registry entry but no wiring here. That
40
+ * asymmetry is a known defect, not a design: the entry, the label, the default
41
+ * model and the discovery probe all cooperate to advertise a provider that
42
+ * cannot be built. See issue #257.
43
+ */
44
+ export async function ensureRegistered(id) {
45
+ if (registered.has(id))
46
+ return;
47
+ switch (id) {
48
+ case 'anthropic': {
49
+ const mod = await import('@namzu/anthropic');
50
+ mod.registerAnthropic();
51
+ break;
52
+ }
53
+ case 'openai': {
54
+ const mod = await import('@namzu/openai');
55
+ mod.registerOpenAI();
56
+ break;
57
+ }
58
+ case 'openrouter': {
59
+ const mod = await import('@namzu/openrouter');
60
+ mod.registerOpenRouter();
61
+ break;
62
+ }
63
+ case 'ollama': {
64
+ const mod = await import('@namzu/ollama');
65
+ mod.registerOllama();
66
+ break;
67
+ }
68
+ default:
69
+ throw new Error(`provider "${id}" is not wired yet; pick another or wait for support`);
70
+ }
71
+ registered.add(id);
72
+ }
73
+ /**
74
+ * Has this provider's driver been registered in THIS process?
75
+ *
76
+ * Read by the chain builder to skip a member whose registration failed, so the
77
+ * failure is reported once — as an unresolved capability — rather than twice in
78
+ * different words.
79
+ */
80
+ export function isRegistered(id) {
81
+ return registered.has(id);
82
+ }
83
+ /**
84
+ * What each member of the chain DECLARES it can do.
85
+ *
86
+ * Type-level, via the registry, so nothing is constructed and no credential is
87
+ * needed — which is the whole point: the member most worth checking is the
88
+ * fallback nobody has set up yet, and a check that demanded a key would be
89
+ * unusable in exactly that case.
90
+ *
91
+ * A member that cannot be registered is reported as unresolved rather than
92
+ * assumed to agree. Registration is also why this cannot be a pure function: a
93
+ * provider package is only imported when something needs it.
94
+ */
95
+ export async function resolveChainCapabilities(members) {
96
+ const out = [];
97
+ for (const member of members) {
98
+ if (!(member.id in PROVIDER_REGISTRY)) {
99
+ out.push({ kind: 'unresolved', reason: `"${member.id}" is not a provider namzu knows` });
100
+ continue;
101
+ }
102
+ try {
103
+ await ensureRegistered(member.id);
104
+ out.push({
105
+ kind: 'known',
106
+ capabilities: resolveProviderCapabilities({
107
+ capabilities: ProviderRegistry.getCapabilities(member.id),
108
+ }),
109
+ });
110
+ }
111
+ catch (err) {
112
+ out.push({
113
+ kind: 'unresolved',
114
+ reason: err instanceof Error ? err.message : String(err),
115
+ });
116
+ }
117
+ }
118
+ return out;
119
+ }
120
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/integrations/providers/register.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAA;AAIxD,OAAO,EAAE,iBAAiB,EAAmB,MAAM,eAAe,CAAA;AAElE,MAAM,UAAU,GAAG,IAAI,GAAG,EAAc,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EAAc;IACpD,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,OAAM;IAC9B,QAAQ,EAAE,EAAE,CAAC;QACZ,KAAK,WAAW,CAAC,CAAC,CAAC;YAClB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAA;YAC5C,GAAG,CAAC,iBAAiB,EAAE,CAAA;YACvB,MAAK;QACN,CAAC;QACD,KAAK,QAAQ,CAAC,CAAC,CAAC;YACf,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAA;YACzC,GAAG,CAAC,cAAc,EAAE,CAAA;YACpB,MAAK;QACN,CAAC;QACD,KAAK,YAAY,CAAC,CAAC,CAAC;YACnB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAA;YAC7C,GAAG,CAAC,kBAAkB,EAAE,CAAA;Y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AAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACxD,CAAC,CAAA;QACH,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/tui/App.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA0DH,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,YAAY,CAAA;AAE/D,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;CACxB;AAWD,wBAAgB,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,2CA67BpC"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/tui/App.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA0DH,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,YAAY,CAAA;AAE/D,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;CACxB;AAWD,wBAAgB,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,2CAq/BpC"}