@claudexor/cli 3.5.0 → 3.8.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.
Files changed (157) hide show
  1. package/dist/accounts-projection.d.ts +22 -14
  2. package/dist/accounts-projection.d.ts.map +1 -1
  3. package/dist/accounts-projection.js +112 -60
  4. package/dist/accounts-projection.js.map +1 -1
  5. package/dist/accounts-services.d.ts +140 -128
  6. package/dist/accounts-services.d.ts.map +1 -1
  7. package/dist/accounts-services.js +22 -9
  8. package/dist/accounts-services.js.map +1 -1
  9. package/dist/accounts-unified-migration.d.ts +110 -0
  10. package/dist/accounts-unified-migration.d.ts.map +1 -0
  11. package/dist/accounts-unified-migration.js +422 -0
  12. package/dist/accounts-unified-migration.js.map +1 -0
  13. package/dist/agy-quota-source.d.ts +1 -0
  14. package/dist/agy-quota-source.d.ts.map +1 -1
  15. package/dist/agy-quota-source.js +61 -108
  16. package/dist/agy-quota-source.js.map +1 -1
  17. package/dist/auth-login-harnesses.d.ts +7 -5
  18. package/dist/auth-login-harnesses.d.ts.map +1 -1
  19. package/dist/auth-login-harnesses.js +10 -9
  20. package/dist/auth-login-harnesses.js.map +1 -1
  21. package/dist/capabilities.d.ts.map +1 -1
  22. package/dist/capabilities.js +6 -1
  23. package/dist/capabilities.js.map +1 -1
  24. package/dist/claude-oauth-usage.d.ts.map +1 -1
  25. package/dist/claude-oauth-usage.js +9 -3
  26. package/dist/claude-oauth-usage.js.map +1 -1
  27. package/dist/claude-statusline.d.ts.map +1 -1
  28. package/dist/claude-statusline.js +14 -1
  29. package/dist/claude-statusline.js.map +1 -1
  30. package/dist/claudexord-entry.d.ts +7 -2
  31. package/dist/claudexord-entry.d.ts.map +1 -1
  32. package/dist/claudexord-entry.js +33 -11
  33. package/dist/claudexord-entry.js.map +1 -1
  34. package/dist/claudexord.d.ts.map +1 -1
  35. package/dist/claudexord.js +25 -37
  36. package/dist/claudexord.js.map +1 -1
  37. package/dist/cli.js +2 -1
  38. package/dist/cli.js.map +1 -1
  39. package/dist/codex-quota-source.d.ts.map +1 -1
  40. package/dist/codex-quota-source.js +8 -3
  41. package/dist/codex-quota-source.js.map +1 -1
  42. package/dist/command-flags.d.ts.map +1 -1
  43. package/dist/command-flags.js +1 -0
  44. package/dist/command-flags.js.map +1 -1
  45. package/dist/control-services.d.ts +206 -188
  46. package/dist/control-services.d.ts.map +1 -1
  47. package/dist/control-services.js +54 -122
  48. package/dist/control-services.js.map +1 -1
  49. package/dist/credential-commands.d.ts +16 -0
  50. package/dist/credential-commands.d.ts.map +1 -1
  51. package/dist/credential-commands.js +93 -39
  52. package/dist/credential-commands.js.map +1 -1
  53. package/dist/credential-profile-mutations.d.ts +70 -0
  54. package/dist/credential-profile-mutations.d.ts.map +1 -0
  55. package/dist/credential-profile-mutations.js +219 -0
  56. package/dist/credential-profile-mutations.js.map +1 -0
  57. package/dist/credential-status-invalidation.d.ts +11 -0
  58. package/dist/credential-status-invalidation.d.ts.map +1 -0
  59. package/dist/credential-status-invalidation.js +36 -0
  60. package/dist/credential-status-invalidation.js.map +1 -0
  61. package/dist/daemon-admission-runtime.d.ts +5 -0
  62. package/dist/daemon-admission-runtime.d.ts.map +1 -1
  63. package/dist/daemon-admission-runtime.js +1 -0
  64. package/dist/daemon-admission-runtime.js.map +1 -1
  65. package/dist/delegation-belt-descriptor.d.ts +2 -1
  66. package/dist/delegation-belt-descriptor.d.ts.map +1 -1
  67. package/dist/delegation-belt-descriptor.js +2 -1
  68. package/dist/delegation-belt-descriptor.js.map +1 -1
  69. package/dist/harness-command-specs.d.ts.map +1 -1
  70. package/dist/harness-command-specs.js +4 -4
  71. package/dist/harness-command-specs.js.map +1 -1
  72. package/dist/harness-command.d.ts +5 -3
  73. package/dist/harness-command.d.ts.map +1 -1
  74. package/dist/harness-command.js +5 -3
  75. package/dist/harness-command.js.map +1 -1
  76. package/dist/harness-install-lease.d.ts +11 -0
  77. package/dist/harness-install-lease.d.ts.map +1 -0
  78. package/dist/harness-install-lease.js +98 -0
  79. package/dist/harness-install-lease.js.map +1 -0
  80. package/dist/harness-install-proof.d.ts +36 -0
  81. package/dist/harness-install-proof.d.ts.map +1 -0
  82. package/dist/harness-install-proof.js +148 -0
  83. package/dist/harness-install-proof.js.map +1 -0
  84. package/dist/harness-install-recipes.d.ts +80 -0
  85. package/dist/harness-install-recipes.d.ts.map +1 -0
  86. package/dist/harness-install-recipes.js +130 -0
  87. package/dist/harness-install-recipes.js.map +1 -0
  88. package/dist/harness-installer.d.ts +45 -46
  89. package/dist/harness-installer.d.ts.map +1 -1
  90. package/dist/harness-installer.js +248 -156
  91. package/dist/harness-installer.js.map +1 -1
  92. package/dist/mcp-run-projections.d.ts +1 -1
  93. package/dist/native-login.d.ts +7 -0
  94. package/dist/native-login.d.ts.map +1 -1
  95. package/dist/native-login.js +40 -17
  96. package/dist/native-login.js.map +1 -1
  97. package/dist/profile-registration.d.ts +15 -1
  98. package/dist/profile-registration.d.ts.map +1 -1
  99. package/dist/profile-registration.js +124 -7
  100. package/dist/profile-registration.js.map +1 -1
  101. package/dist/quota-services.d.ts +4 -4
  102. package/dist/quota-subject-universe.d.ts.map +1 -1
  103. package/dist/quota-subject-universe.js +6 -0
  104. package/dist/quota-subject-universe.js.map +1 -1
  105. package/dist/remote-command.d.ts +0 -2
  106. package/dist/remote-command.d.ts.map +1 -1
  107. package/dist/remote-command.js +3 -74
  108. package/dist/remote-command.js.map +1 -1
  109. package/dist/run-orchestrator.d.ts +28 -0
  110. package/dist/run-orchestrator.d.ts.map +1 -0
  111. package/dist/run-orchestrator.js +43 -0
  112. package/dist/run-orchestrator.js.map +1 -0
  113. package/dist/settings-service.d.ts +1 -1
  114. package/dist/settings-service.js +3 -3
  115. package/dist/settings-service.js.map +1 -1
  116. package/dist/setup-attach-command.d.ts +30 -0
  117. package/dist/setup-attach-command.d.ts.map +1 -0
  118. package/dist/setup-attach-command.js +118 -0
  119. package/dist/setup-attach-command.js.map +1 -0
  120. package/dist/setup-job-store.d.ts +2 -2
  121. package/dist/setup-job-support.d.ts +36 -9
  122. package/dist/setup-job-support.d.ts.map +1 -1
  123. package/dist/setup-job-support.js +81 -10
  124. package/dist/setup-job-support.js.map +1 -1
  125. package/dist/setup-jobs.d.ts +4 -4
  126. package/dist/setup-jobs.d.ts.map +1 -1
  127. package/dist/setup-jobs.js +50 -47
  128. package/dist/setup-jobs.js.map +1 -1
  129. package/dist/setup-login-capability.d.ts +37 -0
  130. package/dist/setup-login-capability.d.ts.map +1 -0
  131. package/dist/setup-login-capability.js +96 -0
  132. package/dist/setup-login-capability.js.map +1 -0
  133. package/dist/setup-login-io.d.ts +4 -1
  134. package/dist/setup-login-io.d.ts.map +1 -1
  135. package/dist/setup-login-io.js +22 -3
  136. package/dist/setup-login-io.js.map +1 -1
  137. package/dist/setup-login-pty.d.ts +64 -22
  138. package/dist/setup-login-pty.d.ts.map +1 -1
  139. package/dist/setup-login-pty.js +289 -48
  140. package/dist/setup-login-pty.js.map +1 -1
  141. package/dist/setup-login-runner-support.d.ts +12 -0
  142. package/dist/setup-login-runner-support.d.ts.map +1 -0
  143. package/dist/setup-login-runner-support.js +65 -0
  144. package/dist/setup-login-runner-support.js.map +1 -0
  145. package/dist/setup-login-runner.d.ts +2 -0
  146. package/dist/setup-login-runner.d.ts.map +1 -1
  147. package/dist/setup-login-runner.js +119 -116
  148. package/dist/setup-login-runner.js.map +1 -1
  149. package/dist/setup-runner-outcome.d.ts +10 -0
  150. package/dist/setup-runner-outcome.d.ts.map +1 -0
  151. package/dist/setup-runner-outcome.js +49 -0
  152. package/dist/setup-runner-outcome.js.map +1 -0
  153. package/dist/thread-continuity-context.d.ts +24 -0
  154. package/dist/thread-continuity-context.d.ts.map +1 -1
  155. package/dist/thread-continuity-context.js +17 -0
  156. package/dist/thread-continuity-context.js.map +1 -1
  157. package/package.json +24 -24
@@ -1,15 +1,16 @@
1
1
  /**
2
- * Per-harness ACCOUNTS AUTHORITY projection (INV-135): the native "CLI login"
3
- * pseudo-row state and the informational `next_up` identity (who an UNPINNED
4
- * run would route to next), built ONCE on the server so no surface (CLI, macOS)
5
- * re-derives the accounts symmetry. Native-login detection reads the cached
6
- * doctor status (a `native_session` source reported available); a probe failure
7
- * is an honest "not detected", never a thrown listing. `next_up` is computed by
8
- * the routing owner (`nextUpIdentity`) from enabled profiles + native readiness
9
- * + quota, so it can never disagree with run-time admission.
2
+ * Per-harness POOL AUTHORITY projection of the unified account model
3
+ * (INV-135): every account is a named registry row; `accountPools` carries
4
+ * the routing facts (who an UNPINNED run routes to next), computed ONCE on
5
+ * the server by the same pool owner run admission uses so no surface
6
+ * re-derives it. The legacy `harnessAccounts` carrier stays on the wire as
7
+ * `[]` for strict old clients; its native "CLI login" pseudo-row is gone
8
+ * detected default-store logins are auto-registered as ordinary rows at
9
+ * daemon start.
10
10
  */
11
- import type { AccountIdentity, ControlHarnessAccounts, CredentialProfile, CredentialProfileStatus, QuotaSnapshot } from "@claudexor/schema";
11
+ import type { AccountIdentity, ControlHarnessAccountPool, CredentialProfile, CredentialProfileStatus, QuotaSnapshot } from "@claudexor/schema";
12
12
  import type { HarnessStatus } from "@claudexor/gateway";
13
+ import { credentialProfilePolicyState } from "@claudexor/core";
13
14
  /**
14
15
  * Non-secret {email, plan} of a config_dir_login PROFILE, read daemon-side from
15
16
  * the profile's OWN isolation-locator store (INV-067) — never the ordinary
@@ -22,24 +23,31 @@ export declare function profileAccountIdentity(profile: CredentialProfile): Acco
22
23
  * live probe the accounts response and the profile mutation receipts share.
23
24
  * Adapters without profile support report an honest unknown.
24
25
  */
25
- export declare function profileDoctorStatus(profile: CredentialProfile): Promise<CredentialProfileStatus>;
26
+ export declare function profileDoctorStatus(profile: CredentialProfile, platform?: NodeJS.Platform): Promise<CredentialProfileStatus>;
27
+ export declare function disabledProfileSharesOsUserCredential(state: ReturnType<typeof credentialProfilePolicyState>): boolean;
26
28
  /**
27
29
  * Accounts projection for one named profile. A rich adapter owns readiness and
28
30
  * identity in ONE call; adapters without it keep the existing doctor + owned-
29
31
  * store identity path. A malformed rich receipt loses identity and fails
30
32
  * closed through the shared readiness wrapper.
31
33
  */
32
- export declare function profileAccountProjection(profile: CredentialProfile): Promise<{
34
+ export declare function profileAccountProjection(profile: CredentialProfile, registry?: readonly CredentialProfile[], platform?: NodeJS.Platform): Promise<{
33
35
  profile: CredentialProfile;
34
36
  status: CredentialProfileStatus;
35
37
  identity: AccountIdentity | null;
36
38
  }>;
37
- export declare function harnessAccountsProjection(repoRoot: string, quotaSnapshots?: readonly QuotaSnapshot[], snapshot?: {
39
+ /**
40
+ * The per-harness pool routing verdict (`GET /v2/account-pools` and the
41
+ * additive `accountPools` key of the credential-profiles response). Routing
42
+ * facts ONLY — account facts live on the profile rows. The API-key ROUTE
43
+ * appears exclusively here (`api_key_route`) so legacy strict `next_up`
44
+ * decoders never see an unknown kind.
45
+ */
46
+ export declare function accountPoolsProjection(repoRoot: string, quotaSnapshots?: readonly QuotaSnapshot[], snapshot?: {
38
47
  statuses?: readonly HarnessStatus[];
39
48
  profiles?: readonly {
40
49
  profile: CredentialProfile;
41
50
  status: CredentialProfileStatus;
42
51
  }[];
43
- accountIdentities?: ReadonlyMap<string, AccountIdentity | null>;
44
- }): Promise<ControlHarnessAccounts[]>;
52
+ }): Promise<ControlHarnessAccountPool[]>;
45
53
  //# sourceMappingURL=accounts-projection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-projection.d.ts","sourceRoot":"","sources":["../src/accounts-projection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAU3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiBxD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI,CAKzF;AAED;;;;GAIG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AO,CAAC,uBAAuB,CAAC,CAOlC;AAiBD,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,GACrD,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,GAAE,SAAS,iBAAiB,EAAc,EAClD,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,OAAO,CAAC;IACT,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,uBAAuB,CAAC;IAChC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CAClC,CAAC,CA2CD;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,SAAS,aAAa,EAAO,EAC7C,QAAQ,CAAC,EAAE;IACT,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,SAAS;QAAE,OAAO,EAAE,iBAAiB,CAAC;QAAC,MAAM,EAAE,uBAAuB,CAAA;KAAE,EAAE,CAAC;CACvF,GACA,OAAO,CAAC,yBAAyB,EAAE,CAAC,CA6FtC"}
@@ -1,22 +1,10 @@
1
- import { AccountIdentity as AccountIdentitySchema } from "@claudexor/schema";
1
+ import { AccountIdentity as AccountIdentitySchema, estimateEffectiveAuthRoute, } from "@claudexor/schema";
2
2
  import { loadConfig } from "@claudexor/config";
3
- import { defaultCredentialRoute, effectiveAuthPreference, nextUpIdentity, probeCredentialProfileStatus, profileStatusAdmits, } from "@claudexor/orchestrator";
4
- import { codexAccountIdentity, defaultNativeCodexHome } from "@claudexor/harness-codex";
5
- import { claudeAccountIdentity, defaultNativeClaudeConfigDir } from "@claudexor/harness-claude";
3
+ import { effectiveAuthPreference, probeCredentialProfileStatus, profileStatusAdmits, selectFromAccountPool, } from "@claudexor/orchestrator";
4
+ import { credentialProfilePolicyState } from "@claudexor/core";
5
+ import { codexAccountIdentity } from "@claudexor/harness-codex";
6
+ import { claudeAccountIdentity } from "@claudexor/harness-claude";
6
7
  import { buildGateway, buildRegistry } from "./registry.js";
7
- /**
8
- * Non-secret {email, plan} of a harness's NATIVE/CLI login, read daemon-side
9
- * from the Claudexor-owned native store (never the ordinary vendor home).
10
- * Cursor's CLI-reported identity arrives through the Accounts-only doctor
11
- * receipt instead; this helper remains the static-store owner for codex/claude.
12
- */
13
- function nativeAccountIdentity(harnessId) {
14
- if (harnessId === "codex")
15
- return codexAccountIdentity(defaultNativeCodexHome());
16
- if (harnessId === "claude")
17
- return claudeAccountIdentity(defaultNativeClaudeConfigDir());
18
- return null;
19
- }
20
8
  /**
21
9
  * Non-secret {email, plan} of a config_dir_login PROFILE, read daemon-side from
22
10
  * the profile's OWN isolation-locator store (INV-067) — never the ordinary
@@ -37,18 +25,51 @@ export function profileAccountIdentity(profile) {
37
25
  * live probe the accounts response and the profile mutation receipts share.
38
26
  * Adapters without profile support report an honest unknown.
39
27
  */
40
- export async function profileDoctorStatus(profile) {
28
+ export async function profileDoctorStatus(profile, platform = process.platform) {
41
29
  const adapter = buildRegistry().get(profile.harness_id);
30
+ const policy = credentialProfilePolicyState({ adapter, registry: [profile], platform });
31
+ if (!profile.enabled && disabledProfileSharesOsUserCredential(policy)) {
32
+ return inactiveProfileStatus(profile, "This profile is disabled and was not probed.");
33
+ }
42
34
  return probeCredentialProfileStatus(profile, adapter?.probeCredentialProfile?.bind(adapter));
43
35
  }
36
+ function inactiveProfileStatus(profile, detail) {
37
+ return {
38
+ profile_id: profile.profile_id,
39
+ harness_id: profile.harness_id,
40
+ availability: "unavailable",
41
+ verification: "not_run",
42
+ verification_source: "local_store",
43
+ detail,
44
+ last_verified_at: null,
45
+ };
46
+ }
47
+ export function disabledProfileSharesOsUserCredential(state) {
48
+ return state.policy.identity_scope === "os_user";
49
+ }
44
50
  /**
45
51
  * Accounts projection for one named profile. A rich adapter owns readiness and
46
52
  * identity in ONE call; adapters without it keep the existing doctor + owned-
47
53
  * store identity path. A malformed rich receipt loses identity and fails
48
54
  * closed through the shared readiness wrapper.
49
55
  */
50
- export async function profileAccountProjection(profile) {
56
+ export async function profileAccountProjection(profile, registry = [profile], platform = process.platform) {
51
57
  const adapter = buildRegistry().get(profile.harness_id);
58
+ const cardinality = credentialProfilePolicyState({ adapter, registry, platform });
59
+ if (!profile.enabled && disabledProfileSharesOsUserCredential(cardinality)) {
60
+ return {
61
+ profile,
62
+ status: inactiveProfileStatus(profile, "This profile is disabled and was not probed."),
63
+ identity: profileAccountIdentity(profile),
64
+ };
65
+ }
66
+ if (profile.enabled && cardinality.ambiguous) {
67
+ return {
68
+ profile,
69
+ status: inactiveProfileStatus(profile, `${profile.harness_id} has ${cardinality.enabledProfileCount} enabled bindings on ${cardinality.platform}; disable extra profiles before this OS-user-scoped credential can be selected or probed.`),
70
+ identity: profileAccountIdentity(profile),
71
+ };
72
+ }
52
73
  if (!adapter?.probeCredentialAccount) {
53
74
  return {
54
75
  profile,
@@ -68,34 +89,26 @@ export async function profileAccountProjection(profile) {
68
89
  });
69
90
  return { profile, status, identity };
70
91
  }
71
- export async function harnessAccountsProjection(repoRoot, quotaSnapshots = [], snapshot) {
92
+ /**
93
+ * The per-harness pool routing verdict (`GET /v2/account-pools` and the
94
+ * additive `accountPools` key of the credential-profiles response). Routing
95
+ * facts ONLY — account facts live on the profile rows. The API-key ROUTE
96
+ * appears exclusively here (`api_key_route`) so legacy strict `next_up`
97
+ * decoders never see an unknown kind.
98
+ */
99
+ export async function accountPoolsProjection(repoRoot, quotaSnapshots = [], snapshot) {
72
100
  const cfg = loadConfig(repoRoot).global;
73
101
  const harnessIds = [...buildRegistry({ includeFakes: false }).keys()].sort();
74
- const nativeDetected = new Map();
75
102
  let statuses = snapshot?.statuses ?? [];
76
- const accountIdentities = new Map(snapshot?.accountIdentities ?? []);
77
103
  if (!snapshot?.statuses) {
78
104
  try {
79
- const receipts = await buildGateway({ includeFakes: false }).statusAllForAccounts({ cwd: repoRoot, fresh: true }, harnessIds);
80
- statuses = receipts.map((receipt) => receipt.status);
81
- for (const receipt of receipts) {
82
- accountIdentities.set(receipt.status.id, receipt.identity);
83
- }
105
+ statuses = await buildGateway({ includeFakes: false }).statusAll({ cwd: repoRoot }, harnessIds);
84
106
  }
85
107
  catch {
86
108
  statuses = [];
87
109
  }
88
110
  }
89
- const defaultRoutes = new Map();
90
- for (const s of statuses) {
91
- const native = s.authSources.find((source) => source.source === "native_session");
92
- const detected = native?.availability === "available";
93
- nativeDetected.set(s.id, detected);
94
- const harness = cfg.harnesses[s.id];
95
- const route = defaultCredentialRoute(s, effectiveAuthPreference(harness?.auth_preference, cfg.routing.auth_preference));
96
- if (route)
97
- defaultRoutes.set(s.id, route);
98
- }
111
+ const statusById = new Map(statuses.map((status) => [status.id, status]));
99
112
  const readyProfiles = new Map();
100
113
  for (const entry of snapshot?.profiles ?? []) {
101
114
  if (!entry.profile.enabled || !profileStatusAdmits(entry.profile, entry.status))
@@ -106,31 +119,70 @@ export async function harnessAccountsProjection(repoRoot, quotaSnapshots = [], s
106
119
  }
107
120
  return harnessIds.map((harnessId) => {
108
121
  const h = cfg.harnesses[harnessId];
109
- const nativeEnabled = h?.native_credentials_enabled ?? true;
110
- const defaultEnabled = (h?.enabled ?? true) && nativeEnabled;
111
- const defaultRoute = defaultRoutes.get(harnessId) ?? null;
122
+ if (h?.enabled === false) {
123
+ return {
124
+ harness_id: harnessId,
125
+ next_up: {
126
+ kind: "none",
127
+ reason: `harness is disabled in settings (harnesses.${harnessId}.enabled=false)`,
128
+ },
129
+ };
130
+ }
131
+ const cardinality = credentialProfilePolicyState({
132
+ adapter: buildRegistry({ includeFakes: false }).get(harnessId),
133
+ registry: cfg.credential_profiles,
134
+ });
135
+ if (cardinality.ambiguous) {
136
+ return {
137
+ harness_id: harnessId,
138
+ next_up: {
139
+ kind: "none",
140
+ reason: `${harnessId} has an ambiguous enabled profile set; disable extra profiles before routing`,
141
+ },
142
+ };
143
+ }
144
+ // next_up must never advertise a row the runtime would not select: a
145
+ // NON-EMPTY rotation_eligible list restricts the runtime's candidates
146
+ // (staticRotationCandidates), so the projection applies the same filter.
147
+ const rotationEligible = h?.profile_policy?.rotation_eligible ?? [];
148
+ const ready = readyProfiles.get(harnessId) ?? new Set();
149
+ const eligibleReady = rotationEligible.length > 0
150
+ ? new Set([...ready].filter((id) => rotationEligible.includes(id)))
151
+ : ready;
152
+ const selection = selectFromAccountPool({
153
+ registry: cfg.credential_profiles,
154
+ harnessId,
155
+ snapshots: quotaSnapshots,
156
+ readyProfileIds: eligibleReady,
157
+ headroomThreshold: h?.profile_policy?.headroom_threshold ?? 0.9,
158
+ model: h?.default_model ?? null,
159
+ });
160
+ if (selection.outcome === "selected") {
161
+ return {
162
+ harness_id: harnessId,
163
+ next_up: { kind: "profile", profileId: selection.candidate.profile.profile_id },
164
+ };
165
+ }
166
+ // Pool exhaustion is the typed `credential_pool_exhausted` terminal at
167
+ // run time (owner Q3=A): the paid API-key ROUTE serves it ONLY under the
168
+ // EXPLICIT api_key preference — never silently under auto — so next_up
169
+ // advertises the paid route exactly when the runtime would take it.
170
+ const preference = effectiveAuthPreference(h?.auth_preference, cfg.routing.auth_preference);
171
+ const status = statusById.get(harnessId);
172
+ const keyRouteReady = preference === "api_key" &&
173
+ status !== undefined &&
174
+ estimateEffectiveAuthRoute("api_key", status.authSources) === "api_key";
175
+ if (keyRouteReady) {
176
+ return { harness_id: harnessId, next_up: { kind: "api_key_route" } };
177
+ }
112
178
  return {
113
179
  harness_id: harnessId,
114
- native_credentials_enabled: nativeEnabled,
115
- native_login_detected: nativeDetected.get(harnessId) ?? false,
116
- identity: accountIdentities.get(harnessId) ?? nativeAccountIdentity(harnessId),
117
- // The routing owner computes who an unpinned run routes to next the
118
- // accounts projection never re-derives it (INV-135).
119
- next_up: nextUpIdentity({
120
- registry: cfg.credential_profiles,
121
- harnessId,
122
- policy: h?.profile_policy ?? {
123
- limit_action: "fail",
124
- rotation_eligible: [],
125
- headroom_threshold: 0.9,
126
- },
127
- snapshots: quotaSnapshots,
128
- defaultEnabled,
129
- defaultReady: defaultRoute !== null,
130
- defaultRoute,
131
- readyProfileIds: readyProfiles.get(harnessId) ?? new Set(),
132
- model: h?.default_model ?? null,
133
- }),
180
+ next_up: {
181
+ kind: "none",
182
+ reason: selection.outcome === "exhausted"
183
+ ? `every enabled account is over its quota window${selection.resets_at ? ` (earliest reset ${selection.resets_at})` : ""}; unpinned runs wait for the reset (the paid API-key route requires the explicit api_key preference)`
184
+ : "no enabled account is signed in for this harness; connect an account or pin one per-run (--profile)",
185
+ },
134
186
  };
135
187
  });
136
188
  }
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-projection.js","sourceRoot":"","sources":["../src/accounts-projection.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,IAAI,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE5D;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,SAAiB;IAC9C,IAAI,SAAS,KAAK,OAAO;QAAE,OAAO,oBAAoB,CAAC,sBAAsB,EAAE,CAAC,CAAC;IACjF,IAAI,SAAS,KAAK,QAAQ;QAAE,OAAO,qBAAqB,CAAC,4BAA4B,EAAE,CAAC,CAAC;IACzF,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAA0B;IAC/D,IAAI,C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MAAM,EACJ,SAAS,CAAC,OAAO,KAAK,WAAW;oBAC/B,CAAC,CAAC,iDAAiD,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB,SAAS,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,sGAAsG;oBAC9N,CAAC,CAAC,qGAAqG;aAC5G;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -28,6 +28,9 @@ export declare function projectHarnessStatuses(statuses: readonly HarnessStatus[
28
28
  remediation: string | null;
29
29
  requiresFullAccess: boolean;
30
30
  };
31
+ setupLogin: {
32
+ mode: "external_terminal" | "in_app";
33
+ } | null;
31
34
  readiness: {
32
35
  id: string;
33
36
  kind: "auth" | "binary" | "model" | "probe" | "smoke";
@@ -38,140 +41,149 @@ export declare function projectHarnessStatuses(statuses: readonly HarnessStatus[
38
41
  }[]>;
39
42
  /** One server-owned Accounts response builder. The opt-in form refreshes quota
40
43
  * first and then derives next_up from that exact returned response; no client
41
- * can accidentally pair a newer quota card with an older routing identity. */
42
- export declare function createCredentialProfilesService(quotaRegistry: () => QuotaRegistry): (input?: {
43
- snapshot?: boolean;
44
- }) => Promise<{
45
- profiles: {
46
- profile: CredentialProfile;
47
- status: CredentialProfileStatus;
48
- identity: import("@claudexor/schema").AccountIdentity | null;
49
- }[];
50
- harnessAccounts: {
51
- harness_id: string;
52
- native_credentials_enabled: boolean;
53
- native_login_detected: boolean;
54
- identity: {
55
- email?: string | undefined;
56
- plan?: string | undefined;
57
- } | null;
58
- next_up: {
59
- kind: "profile";
60
- profileId: string;
61
- } | {
62
- kind: "native";
63
- route?: "api_key" | "local_session" | undefined;
64
- } | {
65
- kind: "none";
66
- reason: string;
67
- };
68
- }[];
69
- } | {
70
- profiles: {
71
- profile: CredentialProfile;
72
- status: CredentialProfileStatus;
73
- identity: import("@claudexor/schema").AccountIdentity | null;
74
- }[];
75
- harnessAccounts: {
76
- harness_id: string;
77
- native_credentials_enabled: boolean;
78
- native_login_detected: boolean;
79
- identity: {
80
- email?: string | undefined;
81
- plan?: string | undefined;
82
- } | null;
83
- next_up: {
84
- kind: "profile";
85
- profileId: string;
86
- } | {
87
- kind: "native";
88
- route?: "api_key" | "local_session" | undefined;
89
- } | {
90
- kind: "none";
91
- reason: string;
92
- };
93
- }[];
94
- harnesses: {
95
- id: string;
96
- available: boolean;
97
- status: "ok" | "degraded" | "unavailable";
98
- manifest: import("@claudexor/schema").HarnessManifest | null;
99
- enabledIntents: import("@claudexor/schema").Intent[];
100
- routableIntents: import("@claudexor/schema").Intent[];
101
- disabledIntents: import("@claudexor/schema").Intent[];
102
- checks: import("@claudexor/schema").ConformanceCheck[];
103
- reasons: string[];
104
- authSources: import("@claudexor/schema").AuthSourceReadiness[];
105
- configuredModel: string | null;
106
- configuredModelCheck: {
107
- status: "ok" | "rejected";
108
- message?: string | null;
109
- } | null;
110
- delegation: {
111
- available: boolean;
112
- reason: "manifest_unsupported" | "ready" | "runtime_unavailable";
113
- remediation: string | null;
114
- requiresFullAccess: boolean;
115
- };
116
- readiness: {
117
- id: string;
118
- kind: "auth" | "binary" | "model" | "probe" | "smoke";
119
- title: string;
120
- status: "fail" | "pass" | "skip";
121
- detail: string | null;
44
+ * can accidentally pair a newer quota card with an older routing identity.
45
+ * Returns the listing service plus the pool-authority read
46
+ * (`GET /v2/account-pools`) so both share one cached projection. */
47
+ export declare function createCredentialProfilesService(quotaRegistry: () => QuotaRegistry): {
48
+ credentialProfiles: (input?: {
49
+ snapshot?: boolean;
50
+ }) => Promise<{
51
+ profiles: {
52
+ profile: CredentialProfile;
53
+ status: CredentialProfileStatus;
54
+ identity: import("@claudexor/schema").AccountIdentity | null;
122
55
  }[];
123
- }[];
124
- git: {
125
- status: "available" | "developer_tools_stub" | "failed" | "missing";
126
- version: string | null;
127
- detail: string | null;
128
- remediation: string | null;
129
- };
130
- quota: {
131
- snapshots: {
132
- subject: {
133
- harness: string;
134
- credential_route: "local" | "managed_api_key" | "vendor_native";
135
- plan_label: string | null;
136
- subject_id: string | null;
56
+ harnessAccounts: never[];
57
+ accountPools: {
58
+ harness_id: string;
59
+ next_up: {
60
+ kind: "profile";
61
+ profileId: string;
62
+ } | {
63
+ kind: "api_key_route";
64
+ } | {
65
+ kind: "none";
66
+ reason: string;
137
67
  };
138
- constraints: {
68
+ }[];
69
+ } | {
70
+ profiles: {
71
+ profile: CredentialProfile;
72
+ status: CredentialProfileStatus;
73
+ identity: import("@claudexor/schema").AccountIdentity | null;
74
+ }[];
75
+ harnessAccounts: never[];
76
+ accountPools: {
77
+ harness_id: string;
78
+ next_up: {
79
+ kind: "profile";
80
+ profileId: string;
81
+ } | {
82
+ kind: "api_key_route";
83
+ } | {
84
+ kind: "none";
85
+ reason: string;
86
+ };
87
+ }[];
88
+ harnesses: {
89
+ id: string;
90
+ available: boolean;
91
+ status: "ok" | "degraded" | "unavailable";
92
+ manifest: import("@claudexor/schema").HarnessManifest | null;
93
+ enabledIntents: import("@claudexor/schema").Intent[];
94
+ routableIntents: import("@claudexor/schema").Intent[];
95
+ disabledIntents: import("@claudexor/schema").Intent[];
96
+ checks: import("@claudexor/schema").ConformanceCheck[];
97
+ reasons: string[];
98
+ authSources: import("@claudexor/schema").AuthSourceReadiness[];
99
+ configuredModel: string | null;
100
+ configuredModelCheck: {
101
+ status: "ok" | "rejected";
102
+ message?: string | null;
103
+ } | null;
104
+ delegation: {
105
+ available: boolean;
106
+ reason: "manifest_unsupported" | "ready" | "runtime_unavailable";
107
+ remediation: string | null;
108
+ requiresFullAccess: boolean;
109
+ };
110
+ setupLogin: {
111
+ mode: "external_terminal" | "in_app";
112
+ } | null;
113
+ readiness: {
139
114
  id: string;
140
- label: string;
141
- applies_to_models?: string[] | null | undefined;
142
- applies_to_unspecified_model?: boolean | undefined;
143
- used_ratio: number | null;
144
- window_seconds: number | null;
145
- resets_at: string | null;
146
- cooldown_until: string | null;
115
+ kind: "auth" | "binary" | "model" | "probe" | "smoke";
116
+ title: string;
117
+ status: "fail" | "pass" | "skip";
118
+ detail: string | null;
147
119
  }[];
148
- source: "agy_command_usage" | "claude_api_retry" | "claude_oauth_usage" | "claude_statusline" | "codex_app_server" | "codex_rollout";
149
- observed_at: string;
150
- freshness: "fresh" | "stale" | "unknown";
151
- availability?: {
152
- state: "available" | "cooldown" | "exhausted";
153
- blocking_constraints: string[];
154
- resets_at: string | null;
155
- model_scoped_exhaustions: {
156
- constraint_id: string;
157
- applies_to_models: string[];
120
+ }[];
121
+ git: {
122
+ status: "available" | "developer_tools_stub" | "failed" | "missing";
123
+ version: string | null;
124
+ detail: string | null;
125
+ remediation: string | null;
126
+ };
127
+ quota: {
128
+ snapshots: {
129
+ subject: {
130
+ harness: string;
131
+ credential_route: "local" | "managed_api_key" | "vendor_native";
132
+ plan_label: string | null;
133
+ subject_id: string | null;
134
+ };
135
+ constraints: {
136
+ id: string;
137
+ label: string;
138
+ applies_to_models?: string[] | null | undefined;
139
+ applies_to_unspecified_model?: boolean | undefined;
140
+ used_ratio: number | null;
141
+ window_seconds: number | null;
158
142
  resets_at: string | null;
143
+ cooldown_until: string | null;
159
144
  }[];
160
- } | undefined;
161
- }[];
162
- absences: {
163
- subject: {
164
- harness: string;
165
- credential_route: "local" | "managed_api_key" | "vendor_native";
166
- plan_label: string | null;
167
- subject_id: string | null;
145
+ source: "agy_command_usage" | "claude_api_retry" | "claude_oauth_usage" | "claude_statusline" | "codex_app_server" | "codex_rollout" | "cursor_rate_limit";
146
+ observed_at: string;
147
+ freshness: "fresh" | "stale" | "unknown";
148
+ availability?: {
149
+ state: "available" | "cooldown" | "exhausted";
150
+ blocking_constraints: string[];
151
+ resets_at: string | null;
152
+ model_scoped_exhaustions: {
153
+ constraint_id: string;
154
+ applies_to_models: string[];
155
+ resets_at: string | null;
156
+ }[];
157
+ } | undefined;
158
+ }[];
159
+ absences: {
160
+ subject: {
161
+ harness: string;
162
+ credential_route: "local" | "managed_api_key" | "vendor_native";
163
+ plan_label: string | null;
164
+ subject_id: string | null;
165
+ };
166
+ reason: "auth_revoked" | "credential_profile_ambiguous" | "no_source" | "not_logged_in" | "platform_unsupported" | "refresh_failed" | "transport_unavailable";
167
+ detail: string | null;
168
+ observed_at: string;
169
+ }[];
170
+ refreshed_at: string | null;
171
+ };
172
+ quotaEventCursor: string;
173
+ }>;
174
+ accountPools: () => Promise<{
175
+ accountPools: {
176
+ harness_id: string;
177
+ next_up: {
178
+ kind: "profile";
179
+ profileId: string;
180
+ } | {
181
+ kind: "api_key_route";
182
+ } | {
183
+ kind: "none";
184
+ reason: string;
168
185
  };
169
- reason: "auth_revoked" | "no_source" | "not_logged_in" | "platform_unsupported" | "refresh_failed" | "transport_unavailable";
170
- detail: string | null;
171
- observed_at: string;
172
186
  }[];
173
- refreshed_at: string | null;
174
- };
175
- quotaEventCursor: string;
176
- }>;
187
+ }>;
188
+ };
177
189
  //# sourceMappingURL=accounts-services.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accounts-services.d.ts","sourceRoot":"","sources":["../src/accounts-services.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAI5E,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EAGxB,MAAM,mBAAmB,CAAC;AAS3B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE;;;;;;;;;;;;;gBAKpD,IAAI,GAAG,UAAU;kBAAY,MAAM,GAAG,IAAI;;;;;;;;;;;;;;;KAuBpE;AAED;;8EAE8E;AAC9E,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,aAAa,YAyB1D;IAAE,QAAQ,C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