@namzu/cli 12.1.0 → 14.0.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 (237) hide show
  1. package/README.md +35 -2
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +119 -60
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/acp.d.ts +24 -8
  6. package/dist/commands/acp.d.ts.map +1 -1
  7. package/dist/commands/acp.js +221 -80
  8. package/dist/commands/acp.js.map +1 -1
  9. package/dist/commands/drain.d.ts.map +1 -1
  10. package/dist/commands/drain.js +45 -9
  11. package/dist/commands/drain.js.map +1 -1
  12. package/dist/commands/login.d.ts +2 -0
  13. package/dist/commands/login.d.ts.map +1 -1
  14. package/dist/commands/login.js +79 -21
  15. package/dist/commands/login.js.map +1 -1
  16. package/dist/commands/prior-messages.d.ts +11 -0
  17. package/dist/commands/prior-messages.d.ts.map +1 -0
  18. package/dist/commands/prior-messages.js +280 -0
  19. package/dist/commands/prior-messages.js.map +1 -0
  20. package/dist/commands/resume.d.ts.map +1 -1
  21. package/dist/commands/resume.js +21 -19
  22. package/dist/commands/resume.js.map +1 -1
  23. package/dist/commands/run-stream.d.ts +5 -3
  24. package/dist/commands/run-stream.d.ts.map +1 -1
  25. package/dist/commands/run-stream.js +66 -62
  26. package/dist/commands/run-stream.js.map +1 -1
  27. package/dist/commands/run.d.ts.map +1 -1
  28. package/dist/commands/run.js +50 -37
  29. package/dist/commands/run.js.map +1 -1
  30. package/dist/config/debug.d.ts +55 -0
  31. package/dist/config/debug.d.ts.map +1 -0
  32. package/dist/config/debug.js +126 -0
  33. package/dist/config/debug.js.map +1 -0
  34. package/dist/config/load.d.ts +88 -4
  35. package/dist/config/load.d.ts.map +1 -1
  36. package/dist/config/load.js +386 -56
  37. package/dist/config/load.js.map +1 -1
  38. package/dist/config/schema.d.ts +87 -5
  39. package/dist/config/schema.d.ts.map +1 -1
  40. package/dist/config/schema.js +5 -5
  41. package/dist/config/schema.js.map +1 -1
  42. package/dist/config/trusted-project-context.d.ts +11 -0
  43. package/dist/config/trusted-project-context.d.ts.map +1 -0
  44. package/dist/config/trusted-project-context.js +28 -0
  45. package/dist/config/trusted-project-context.js.map +1 -0
  46. package/dist/context/project-path.d.ts +3 -0
  47. package/dist/context/project-path.d.ts.map +1 -0
  48. package/dist/context/project-path.js +16 -0
  49. package/dist/context/project-path.js.map +1 -0
  50. package/dist/context/project-tracker.d.ts +30 -0
  51. package/dist/context/project-tracker.d.ts.map +1 -0
  52. package/dist/context/project-tracker.js +217 -0
  53. package/dist/context/project-tracker.js.map +1 -0
  54. package/dist/context/sandbox.d.ts +29 -9
  55. package/dist/context/sandbox.d.ts.map +1 -1
  56. package/dist/context/sandbox.js +8 -0
  57. package/dist/context/sandbox.js.map +1 -1
  58. package/dist/doctor/checks/credentials.d.ts.map +1 -1
  59. package/dist/doctor/checks/credentials.js +7 -1
  60. package/dist/doctor/checks/credentials.js.map +1 -1
  61. package/dist/exit-codes.d.ts +5 -4
  62. package/dist/exit-codes.d.ts.map +1 -1
  63. package/dist/exit-codes.js +5 -4
  64. package/dist/exit-codes.js.map +1 -1
  65. package/dist/index.d.ts +2 -2
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +2 -2
  68. package/dist/index.js.map +1 -1
  69. package/dist/integrations/clipboard/text.d.ts +43 -0
  70. package/dist/integrations/clipboard/text.d.ts.map +1 -0
  71. package/dist/integrations/clipboard/text.js +43 -0
  72. package/dist/integrations/clipboard/text.js.map +1 -0
  73. package/dist/integrations/mcp/servers.d.ts +9 -0
  74. package/dist/integrations/mcp/servers.d.ts.map +1 -1
  75. package/dist/integrations/mcp/servers.js +11 -4
  76. package/dist/integrations/mcp/servers.js.map +1 -1
  77. package/dist/integrations/notifications/terminal.d.ts +32 -0
  78. package/dist/integrations/notifications/terminal.d.ts.map +1 -0
  79. package/dist/integrations/notifications/terminal.js +46 -0
  80. package/dist/integrations/notifications/terminal.js.map +1 -0
  81. package/dist/integrations/plugins/runtime.d.ts +17 -0
  82. package/dist/integrations/plugins/runtime.d.ts.map +1 -0
  83. package/dist/integrations/plugins/runtime.js +100 -0
  84. package/dist/integrations/plugins/runtime.js.map +1 -0
  85. package/dist/integrations/providers/codex-device-login.d.ts +27 -0
  86. package/dist/integrations/providers/codex-device-login.d.ts.map +1 -0
  87. package/dist/integrations/providers/codex-device-login.js +195 -0
  88. package/dist/integrations/providers/codex-device-login.js.map +1 -0
  89. package/dist/integrations/providers/codex-oauth.d.ts +10 -0
  90. package/dist/integrations/providers/codex-oauth.d.ts.map +1 -0
  91. package/dist/integrations/providers/codex-oauth.js +95 -0
  92. package/dist/integrations/providers/codex-oauth.js.map +1 -0
  93. package/dist/integrations/providers/credential-store.d.ts +40 -4
  94. package/dist/integrations/providers/credential-store.d.ts.map +1 -1
  95. package/dist/integrations/providers/credential-store.js +236 -18
  96. package/dist/integrations/providers/credential-store.js.map +1 -1
  97. package/dist/integrations/providers/discover.d.ts +25 -13
  98. package/dist/integrations/providers/discover.d.ts.map +1 -1
  99. package/dist/integrations/providers/discover.js +98 -44
  100. package/dist/integrations/providers/discover.js.map +1 -1
  101. package/dist/integrations/providers/harness-credentials.d.ts +36 -0
  102. package/dist/integrations/providers/harness-credentials.d.ts.map +1 -0
  103. package/dist/integrations/providers/harness-credentials.js +146 -0
  104. package/dist/integrations/providers/harness-credentials.js.map +1 -0
  105. package/dist/integrations/providers/identity.d.ts +8 -15
  106. package/dist/integrations/providers/identity.d.ts.map +1 -1
  107. package/dist/integrations/providers/identity.js +8 -15
  108. package/dist/integrations/providers/identity.js.map +1 -1
  109. package/dist/integrations/providers/index.d.ts +7 -4
  110. package/dist/integrations/providers/index.d.ts.map +1 -1
  111. package/dist/integrations/providers/index.js +6 -3
  112. package/dist/integrations/providers/index.js.map +1 -1
  113. package/dist/integrations/providers/keychain.d.ts +0 -13
  114. package/dist/integrations/providers/keychain.d.ts.map +1 -1
  115. package/dist/integrations/providers/keychain.js +0 -76
  116. package/dist/integrations/providers/keychain.js.map +1 -1
  117. package/dist/integrations/providers/oauth.d.ts +46 -17
  118. package/dist/integrations/providers/oauth.d.ts.map +1 -1
  119. package/dist/integrations/providers/oauth.js +175 -45
  120. package/dist/integrations/providers/oauth.js.map +1 -1
  121. package/dist/integrations/providers/register.d.ts.map +1 -1
  122. package/dist/integrations/providers/register.js +9 -1
  123. package/dist/integrations/providers/register.js.map +1 -1
  124. package/dist/integrations/providers/registry.d.ts +8 -1
  125. package/dist/integrations/providers/registry.d.ts.map +1 -1
  126. package/dist/integrations/providers/registry.js +29 -0
  127. package/dist/integrations/providers/registry.js.map +1 -1
  128. package/dist/integrations/providers/subscription-login.d.ts +2 -0
  129. package/dist/integrations/providers/subscription-login.d.ts.map +1 -1
  130. package/dist/integrations/providers/subscription-login.js +117 -14
  131. package/dist/integrations/providers/subscription-login.js.map +1 -1
  132. package/dist/integrations/sessions/store.d.ts +111 -1
  133. package/dist/integrations/sessions/store.d.ts.map +1 -1
  134. package/dist/integrations/sessions/store.js +400 -7
  135. package/dist/integrations/sessions/store.js.map +1 -1
  136. package/dist/integrations/sessions/transcript-export.d.ts +25 -0
  137. package/dist/integrations/sessions/transcript-export.d.ts.map +1 -0
  138. package/dist/integrations/sessions/transcript-export.js +441 -0
  139. package/dist/integrations/sessions/transcript-export.js.map +1 -0
  140. package/dist/integrations/sessions/turn-evidence.d.ts +138 -0
  141. package/dist/integrations/sessions/turn-evidence.d.ts.map +1 -0
  142. package/dist/integrations/sessions/turn-evidence.js +506 -0
  143. package/dist/integrations/sessions/turn-evidence.js.map +1 -0
  144. package/dist/integrations/subagents/runtime.d.ts +7 -12
  145. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  146. package/dist/integrations/subagents/runtime.js +19 -10
  147. package/dist/integrations/subagents/runtime.js.map +1 -1
  148. package/dist/integrations/trust/store.d.ts.map +1 -1
  149. package/dist/integrations/trust/store.js +27 -13
  150. package/dist/integrations/trust/store.js.map +1 -1
  151. package/dist/permissions/canonical-project.d.ts +9 -0
  152. package/dist/permissions/canonical-project.d.ts.map +1 -0
  153. package/dist/permissions/canonical-project.js +13 -0
  154. package/dist/permissions/canonical-project.js.map +1 -0
  155. package/dist/permissions/checks.d.ts +65 -0
  156. package/dist/permissions/checks.d.ts.map +1 -0
  157. package/dist/permissions/checks.js +122 -0
  158. package/dist/permissions/checks.js.map +1 -0
  159. package/dist/permissions/headless-trust.d.ts +9 -5
  160. package/dist/permissions/headless-trust.d.ts.map +1 -1
  161. package/dist/permissions/headless-trust.js +18 -4
  162. package/dist/permissions/headless-trust.js.map +1 -1
  163. package/dist/permissions/rules.d.ts +16 -7
  164. package/dist/permissions/rules.d.ts.map +1 -1
  165. package/dist/permissions/rules.js +78 -13
  166. package/dist/permissions/rules.js.map +1 -1
  167. package/dist/tui/App.d.ts +5 -2
  168. package/dist/tui/App.d.ts.map +1 -1
  169. package/dist/tui/App.js +1621 -196
  170. package/dist/tui/App.js.map +1 -1
  171. package/dist/tui/Composer.d.ts +14 -3
  172. package/dist/tui/Composer.d.ts.map +1 -1
  173. package/dist/tui/Composer.js +53 -15
  174. package/dist/tui/Composer.js.map +1 -1
  175. package/dist/tui/EditPromptPicker.d.ts +8 -0
  176. package/dist/tui/EditPromptPicker.d.ts.map +1 -0
  177. package/dist/tui/EditPromptPicker.js +18 -0
  178. package/dist/tui/EditPromptPicker.js.map +1 -0
  179. package/dist/tui/LiveActivity.d.ts.map +1 -1
  180. package/dist/tui/LiveActivity.js +2 -1
  181. package/dist/tui/LiveActivity.js.map +1 -1
  182. package/dist/tui/Markdown.d.ts.map +1 -1
  183. package/dist/tui/Markdown.js +2 -1
  184. package/dist/tui/Markdown.js.map +1 -1
  185. package/dist/tui/PermissionOverlay.d.ts.map +1 -1
  186. package/dist/tui/PermissionOverlay.js +7 -1
  187. package/dist/tui/PermissionOverlay.js.map +1 -1
  188. package/dist/tui/Picker.d.ts +8 -6
  189. package/dist/tui/Picker.d.ts.map +1 -1
  190. package/dist/tui/Picker.js +145 -18
  191. package/dist/tui/Picker.js.map +1 -1
  192. package/dist/tui/ResumePicker.d.ts.map +1 -1
  193. package/dist/tui/ResumePicker.js +1 -1
  194. package/dist/tui/ResumePicker.js.map +1 -1
  195. package/dist/tui/Transcript.d.ts +4 -2
  196. package/dist/tui/Transcript.d.ts.map +1 -1
  197. package/dist/tui/Transcript.js +31 -5
  198. package/dist/tui/Transcript.js.map +1 -1
  199. package/dist/tui/agent.d.ts +123 -19
  200. package/dist/tui/agent.d.ts.map +1 -1
  201. package/dist/tui/agent.js +757 -144
  202. package/dist/tui/agent.js.map +1 -1
  203. package/dist/tui/compact-transcript.d.ts +24 -0
  204. package/dist/tui/compact-transcript.d.ts.map +1 -0
  205. package/dist/tui/compact-transcript.js +46 -0
  206. package/dist/tui/compact-transcript.js.map +1 -0
  207. package/dist/tui/conversation-history.d.ts +33 -0
  208. package/dist/tui/conversation-history.d.ts.map +1 -0
  209. package/dist/tui/conversation-history.js +42 -0
  210. package/dist/tui/conversation-history.js.map +1 -0
  211. package/dist/tui/edit-prompts.d.ts +23 -0
  212. package/dist/tui/edit-prompts.d.ts.map +1 -0
  213. package/dist/tui/edit-prompts.js +35 -0
  214. package/dist/tui/edit-prompts.js.map +1 -0
  215. package/dist/tui/live-window.d.ts +3 -1
  216. package/dist/tui/live-window.d.ts.map +1 -1
  217. package/dist/tui/live-window.js +20 -8
  218. package/dist/tui/live-window.js.map +1 -1
  219. package/dist/tui/login-prompt.d.ts +5 -0
  220. package/dist/tui/login-prompt.d.ts.map +1 -1
  221. package/dist/tui/login-prompt.js +14 -0
  222. package/dist/tui/login-prompt.js.map +1 -1
  223. package/dist/tui/slashCommands.d.ts +178 -9
  224. package/dist/tui/slashCommands.d.ts.map +1 -1
  225. package/dist/tui/slashCommands.js +340 -16
  226. package/dist/tui/slashCommands.js.map +1 -1
  227. package/dist/tui/terminal-display.d.ts +12 -0
  228. package/dist/tui/terminal-display.d.ts.map +1 -0
  229. package/dist/tui/terminal-display.js +65 -0
  230. package/dist/tui/terminal-display.js.map +1 -0
  231. package/dist/tui/types.d.ts +14 -2
  232. package/dist/tui/types.d.ts.map +1 -1
  233. package/dist/tui/workspace-diff.d.ts +40 -0
  234. package/dist/tui/workspace-diff.d.ts.map +1 -0
  235. package/dist/tui/workspace-diff.js +101 -0
  236. package/dist/tui/workspace-diff.js.map +1 -0
  237. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"discover.js","sourceRoot":"","sources":["../../../src/integrations/providers/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAA;AACzF,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA;AAE7E,OAAO,EAAE,iBAAiB,EAA+C,MAAM,eAAe,CAAA;AAkE9F,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAEpC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,OAAwB,EAAE;IAE1B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAA;IACnC,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,mEAAmE;IACnE,0EAA0E;IAC1E,MAAM,WAAW,GAAG,IAAI,qBAAqB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACpE,MAAM,QAAQ,GAAuB,EAAE,CAAA;IAEvC,sEAAsE;IACtE,2CAA2C;IAC3C,EAAE;IACF,+DAA+D;IAC/D,EAAE;IACF,yEAAyE;IACzE,0EAA0E;IAC1E,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,mCAAmC;IACnC,EAAE;IACF,gDAAgD;IAChD,EA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,EACjC,EAAc;IAEd,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAA;AACnD,CAAC"}
1
+ {"version":3,"file":"discover.js","sourceRoot":"","sources":["../../../src/integrations/providers/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,EACN,eAAe,EACf,yBAAyB,EACzB,gCAAgC,GAChC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA;AAE7E,OAAO,EAAE,iBAAiB,EAA+C,MAAM,eAAe,CAAA;AA4E9F,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAEpC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACtC,OAAwB,EAAE;IAE1B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAA;IACnC,qEAAqE;IACrE,yEAAyE;IACzE,uEAAuE;IACvE,mEAAmE;IACnE,0EAA0E;IAC1E,MAAM,WAAW,GAAG,IAAI,qBAAqB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACpE,MAAM,QAAQ,GAAuB,EAAE,CAAA;IAEvC,sEAAsE;IACtE,2CAA2C;IAC3C,EAAE;IACF,+DAA+D;IAC/D,EAAE;IACF,yEAAyE;IACzE,0EAA0E;IAC1E,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,mCAAmC;IACnC,EAAE;IACF,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,CAAC,MAAM;SACzB,CAAC,CAAA;QACF,OAAO,GAAG,CAAC,EAAE,CAAA;IACd,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAA;IACb,CAAC;YAAS,CAAC;QACV,YAAY,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC;AACF,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,YAAY,CAC3B,IAAiC,EACjC,EAAc;IAEd,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,IAAI,CAAA;AACnD,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Read-only adapters for credentials owned by co-installed agent harnesses.
3
+ *
4
+ * These files are authorities, not migration inputs. Namzu reads the whole
5
+ * record, validates only the fields its provider wire needs, and never writes
6
+ * either file. In particular, refresh tokens remain owned by the harness that
7
+ * obtained them; consuming a single-use refresh grant here would race that
8
+ * owner and could log it out.
9
+ */
10
+ import type { AgentOAuthCredential } from './keychain.js';
11
+ export interface CodexOAuthCredential extends AgentOAuthCredential {
12
+ readonly accountId: string;
13
+ }
14
+ export declare function claudeCredentialsPath(home?: string): string;
15
+ export declare function codexCredentialsPath(home?: string, env?: NodeJS.ProcessEnv): string;
16
+ export declare function readClaudeFileCredential(home?: string): AgentOAuthCredential | null;
17
+ /** Read a Claude-owned credential from the exact path discovery admitted. */
18
+ export declare function readClaudeCredentialFile(path: string): AgentOAuthCredential | null;
19
+ export declare function codexCredentialFromTokens(tokens: {
20
+ readonly accessToken: string;
21
+ readonly refreshToken?: string;
22
+ readonly accountId?: string;
23
+ }): CodexOAuthCredential | null;
24
+ /**
25
+ * Read the ChatGPT subscription record produced by Codex CLI.
26
+ *
27
+ * `OPENAI_API_KEY` is intentionally ignored: it belongs to the ordinary
28
+ * OpenAI provider. This reader admits only the `tokens` envelope used by the
29
+ * Codex Responses backend and requires the account id that backend routes on.
30
+ */
31
+ export declare function readCodexFileCredential(home?: string, env?: NodeJS.ProcessEnv): CodexOAuthCredential | null;
32
+ /** Read a Codex-owned credential from the exact path discovery admitted. */
33
+ export declare function readCodexCredentialFile(path: string): CodexOAuthCredential | null;
34
+ /** Prefer the credential whose access token remains valid for longer. */
35
+ export declare function preferFresherCredential<T extends AgentOAuthCredential>(left: T | null, right: T | null, now?: number): T | null;
36
+ //# sourceMappingURL=harness-credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-credentials.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/harness-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAIzD,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IACjE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC1B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAEtE;AAED,wBAAgB,oBAAoB,CACnC,IAAI,GAAE,MAAkB,EACxB,GAAG,GAAE,MAAM,CAAC,UAAwB,GAClC,MAAM,CAQR;AA6BD,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,MAAkB,GAAG,oBAAoB,GAAG,IAAI,CAE9F;AAED,6EAA6E;AAC7E,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAWlF;AAOD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE;IACjD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC3B,GAAG,oBAAoB,GAAG,IAAI,CAW9B;AAoBD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,GAAE,MAAkB,EACxB,GAAG,GAAE,MAAM,CAAC,UAAwB,GAClC,oBAAoB,GAAG,IAAI,CAE7B;AAED,4EAA4E;AAC5E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAkBjF;AAED,yEAAyE;AACzE,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,oBAAoB,EACrE,IAAI,EAAE,CAAC,GAAG,IAAI,EACd,KAAK,EAAE,CAAC,GAAG,IAAI,EACf,GAAG,SAAa,GACd,CAAC,GAAG,IAAI,CASV"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Read-only adapters for credentials owned by co-installed agent harnesses.
3
+ *
4
+ * These files are authorities, not migration inputs. Namzu reads the whole
5
+ * record, validates only the fields its provider wire needs, and never writes
6
+ * either file. In particular, refresh tokens remain owned by the harness that
7
+ * obtained them; consuming a single-use refresh grant here would race that
8
+ * owner and could log it out.
9
+ */
10
+ import { readFileSync, statSync } from 'node:fs';
11
+ import { homedir } from 'node:os';
12
+ import { isAbsolute, join, resolve } from 'node:path';
13
+ const MAX_CREDENTIAL_FILE_BYTES = 1024 * 1024;
14
+ export function claudeCredentialsPath(home = homedir()) {
15
+ return join(home, '.claude', '.credentials.json');
16
+ }
17
+ export function codexCredentialsPath(home = homedir(), env = process.env) {
18
+ const configured = env.CODEX_HOME?.trim();
19
+ const root = configured
20
+ ? isAbsolute(configured)
21
+ ? configured
22
+ : resolve(configured)
23
+ : join(home, '.codex');
24
+ return join(root, 'auth.json');
25
+ }
26
+ function readCredentialJson(path) {
27
+ try {
28
+ const stat = statSync(path);
29
+ if (!stat.isFile() || stat.size <= 0 || stat.size > MAX_CREDENTIAL_FILE_BYTES)
30
+ return null;
31
+ return JSON.parse(readFileSync(path, 'utf8'));
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ function record(value) {
38
+ return typeof value === 'object' && value !== null ? value : null;
39
+ }
40
+ function optionalString(value) {
41
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
42
+ }
43
+ function optionalFiniteNumber(value) {
44
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
45
+ }
46
+ function optionalStringArray(value) {
47
+ if (!Array.isArray(value) || value.some((item) => typeof item !== 'string'))
48
+ return undefined;
49
+ return value;
50
+ }
51
+ export function readClaudeFileCredential(home = homedir()) {
52
+ return readClaudeCredentialFile(claudeCredentialsPath(home));
53
+ }
54
+ /** Read a Claude-owned credential from the exact path discovery admitted. */
55
+ export function readClaudeCredentialFile(path) {
56
+ const root = record(readCredentialJson(path));
57
+ const oauth = record(root?.claudeAiOauth);
58
+ const accessToken = optionalString(oauth?.accessToken);
59
+ if (!accessToken)
60
+ return null;
61
+ return {
62
+ accessToken,
63
+ refreshToken: optionalString(oauth?.refreshToken),
64
+ expiresAt: optionalFiniteNumber(oauth?.expiresAt),
65
+ scopes: optionalStringArray(oauth?.scopes),
66
+ };
67
+ }
68
+ export function codexCredentialFromTokens(tokens) {
69
+ if (tokens.accessToken.length === 0)
70
+ return null;
71
+ const claims = jwtClaims(tokens.accessToken);
72
+ const accountId = tokens.accountId ?? claims.accountId;
73
+ if (!accountId)
74
+ return null;
75
+ return {
76
+ accessToken: tokens.accessToken,
77
+ ...(tokens.refreshToken ? { refreshToken: tokens.refreshToken } : {}),
78
+ accountId,
79
+ ...(claims.expiresAt === undefined ? {} : { expiresAt: claims.expiresAt }),
80
+ };
81
+ }
82
+ function jwtClaims(token) {
83
+ const parts = token.split('.');
84
+ if (parts.length !== 3 || !parts[1])
85
+ return {};
86
+ try {
87
+ const payload = record(JSON.parse(Buffer.from(parts[1], 'base64url').toString('utf8')));
88
+ const auth = record(payload?.['https://api.openai.com/auth']);
89
+ const exp = optionalFiniteNumber(payload?.exp);
90
+ return {
91
+ ...(exp === undefined ? {} : { expiresAt: exp * 1000 }),
92
+ ...(optionalString(auth?.chatgpt_account_id)
93
+ ? { accountId: optionalString(auth?.chatgpt_account_id) }
94
+ : {}),
95
+ };
96
+ }
97
+ catch {
98
+ return {};
99
+ }
100
+ }
101
+ /**
102
+ * Read the ChatGPT subscription record produced by Codex CLI.
103
+ *
104
+ * `OPENAI_API_KEY` is intentionally ignored: it belongs to the ordinary
105
+ * OpenAI provider. This reader admits only the `tokens` envelope used by the
106
+ * Codex Responses backend and requires the account id that backend routes on.
107
+ */
108
+ export function readCodexFileCredential(home = homedir(), env = process.env) {
109
+ return readCodexCredentialFile(codexCredentialsPath(home, env));
110
+ }
111
+ /** Read a Codex-owned credential from the exact path discovery admitted. */
112
+ export function readCodexCredentialFile(path) {
113
+ const root = record(readCredentialJson(path));
114
+ const tokens = record(root?.tokens);
115
+ const accessToken = optionalString(tokens?.access_token);
116
+ if (!accessToken)
117
+ return null;
118
+ const accessClaims = jwtClaims(accessToken);
119
+ const idToken = optionalString(tokens?.id_token);
120
+ const idClaims = idToken ? jwtClaims(idToken) : {};
121
+ const accountId = optionalString(tokens?.account_id) ?? accessClaims.accountId ?? idClaims.accountId;
122
+ if (!accountId)
123
+ return null;
124
+ return codexCredentialFromTokens({
125
+ accessToken,
126
+ ...(optionalString(tokens?.refresh_token)
127
+ ? { refreshToken: optionalString(tokens?.refresh_token) }
128
+ : {}),
129
+ accountId,
130
+ });
131
+ }
132
+ /** Prefer the credential whose access token remains valid for longer. */
133
+ export function preferFresherCredential(left, right, now = Date.now()) {
134
+ if (!left)
135
+ return right;
136
+ if (!right)
137
+ return left;
138
+ const leftExpiry = left.expiresAt ?? Number.POSITIVE_INFINITY;
139
+ const rightExpiry = right.expiresAt ?? Number.POSITIVE_INFINITY;
140
+ const leftFresh = leftExpiry > now + 60_000;
141
+ const rightFresh = rightExpiry > now + 60_000;
142
+ if (leftFresh !== rightFresh)
143
+ return leftFresh ? left : right;
144
+ return leftExpiry >= rightExpiry ? left : right;
145
+ }
146
+ //# sourceMappingURL=harness-credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-credentials.js","sourceRoot":"","sources":["../../../src/integrations/providers/harness-credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OA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CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,YAAY,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAA;IACnF,IAAI,CAAC,SAAS;QAAE,OAAO,IAAI,CAAA;IAC3B,OAAO,yBAAyB,CAAC;QAChC,WAAW;QACX,GAAG,CAAC,cAAc,CAAC,MAAM,EAAE,aAAa,CAAC;YACxC,CAAC,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE;YACzD,CAAC,CAAC,EAAE,CAAC;QACN,SAAS;KACT,CAAC,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,uBAAuB,CACtC,IAAc,EACd,KAAe,EACf,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAEhB,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAA;IACvB,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,iBAAiB,CAAA;IAC7D,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC,iBAAiB,CAAA;IAC/D,MAAM,SAAS,GAAG,UAAU,GAAG,GAAG,GAAG,MAAM,CAAA;IAC3C,MAAM,UAAU,GAAG,WAAW,GAAG,GAAG,GAAG,MAAM,CAAA;IAC7C,IAAI,SAAS,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;IAC7D,OAAO,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;AAChD,CAAC"}
@@ -55,21 +55,14 @@ export declare const AUTHORIZE_URL = "https://claude.ai/oauth/authorize";
55
55
  export declare const SUBSCRIPTION_REDIRECT_PORT = 53692;
56
56
  export declare const REDIRECT_URI = "http://localhost:53692/callback";
57
57
  /**
58
- * Asked for at sign-in.
58
+ * The smallest source-verified scope set used by the current Claude harness.
59
59
  *
60
- * This is WIDER than namzu needs, and that is a knowing compromise rather
61
- * than an oversight. Least privilege would ask for an identity and the right
62
- * to run inference, and stop; this set also admits key creation and file
63
- * upload. It is the set the client identity above is exercised with by the
64
- * implementations that are known to work, and a narrower request cannot be
65
- * tested from here — nobody on this side of the flow holds a plan-backed
66
- * account to try it against. Guessing narrow fails in the worst place: the
67
- * sign-in succeeds, and inference is refused afterwards with an error about
68
- * scope that the operator cannot act on.
69
- *
70
- * So it is recorded as debt with the measurement that would settle it: sign
71
- * in with `user:profile user:inference` alone and send one message. If that
72
- * works, this shrinks to those two.
60
+ * Do not copy every scope a historical client happened to request. Unknown
61
+ * scopes make the authorization page reject the whole request before the
62
+ * operator can sign in, and key creation is not inference authority. These
63
+ * three are the live harness contract: identify the account, run inference,
64
+ * and retain the ability to create an API key from that harness when the
65
+ * account permits it.
73
66
  */
74
- export declare const OAUTH_SCOPES = "org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";
67
+ export declare const OAUTH_SCOPES = "org:create_api_key user:profile user:inference";
75
68
  //# sourceMappingURL=identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,eAAO,MAAM,eAAe,yCAAyC,CAAA;AACrE,eAAO,MAAM,eAAe,iDAAiD,CAAA;AAC7E,eAAO,MAAM,aAAa,sCAAsC,CAAA;AAEhE,qEAAqE;AACrE,eAAO,MAAM,0BAA0B,QAAQ,CAAA;AAC/C,eAAO,MAAM,YAAY,oCAA4D,CAAA;AAErF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,+GACoF,CAAA"}
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,eAAO,MAAM,eAAe,yCAAyC,CAAA;AACrE,eAAO,MAAM,eAAe,iDAAiD,CAAA;AAC7E,eAAO,MAAM,aAAa,sCAAsC,CAAA;AAEhE,qEAAqE;AACrE,eAAO,MAAM,0BAA0B,QAAQ,CAAA;AAC/C,eAAO,MAAM,YAAY,oCAA4D,CAAA;AAErF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,mDAAmD,CAAA"}
@@ -55,21 +55,14 @@ export const AUTHORIZE_URL = 'https://claude.ai/oauth/authorize';
55
55
  export const SUBSCRIPTION_REDIRECT_PORT = 53692;
56
56
  export const REDIRECT_URI = `http://localhost:${SUBSCRIPTION_REDIRECT_PORT}/callback`;
57
57
  /**
58
- * Asked for at sign-in.
58
+ * The smallest source-verified scope set used by the current Claude harness.
59
59
  *
60
- * This is WIDER than namzu needs, and that is a knowing compromise rather
61
- * than an oversight. Least privilege would ask for an identity and the right
62
- * to run inference, and stop; this set also admits key creation and file
63
- * upload. It is the set the client identity above is exercised with by the
64
- * implementations that are known to work, and a narrower request cannot be
65
- * tested from here — nobody on this side of the flow holds a plan-backed
66
- * account to try it against. Guessing narrow fails in the worst place: the
67
- * sign-in succeeds, and inference is refused afterwards with an error about
68
- * scope that the operator cannot act on.
69
- *
70
- * So it is recorded as debt with the measurement that would settle it: sign
71
- * in with `user:profile user:inference` alone and send one message. If that
72
- * works, this shrinks to those two.
60
+ * Do not copy every scope a historical client happened to request. Unknown
61
+ * scopes make the authorization page reject the whole request before the
62
+ * operator can sign in, and key creation is not inference authority. These
63
+ * three are the live harness contract: identify the account, run inference,
64
+ * and retain the ability to create an API key from that harness when the
65
+ * account permits it.
73
66
  */
74
- export const OAUTH_SCOPES = 'org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload';
67
+ export const OAUTH_SCOPES = 'org:create_api_key user:profile user:inference';
75
68
  //# sourceMappingURL=identity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/integrations/providers/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,sCAAsC,CAAA;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,8CAA8C,CAAA;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,mCAAmC,CAAA;AAEhE,qEAAqE;AACrE,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAA;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,0BAA0B,WAAW,CAAA;AAErF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GACxB,4GAA4G,CAAA"}
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/integrations/providers/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,sCAAsC,CAAA;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,8CAA8C,CAAA;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,mCAAmC,CAAA;AAEhE,qEAAqE;AACrE,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAA;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,oBAAoB,0BAA0B,WAAW,CAAA;AAErF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,gDAAgD,CAAA"}
@@ -1,11 +1,14 @@
1
1
  export { type DetectedProvider, type DetectionSource, type DiscoverOptions, discoverProviders, findDetected, } from './discover.js';
2
+ export { type CodexOAuthCredential, claudeCredentialsPath, codexCredentialsPath, readClaudeCredentialFile, readClaudeFileCredential, readCodexCredentialFile, readCodexFileCredential, } from './harness-credentials.js';
2
3
  export { type AgentOAuthCredential, isAnthropicOAuthToken, readAgentKeychainCredential, } from './keychain.js';
3
- export { clearStoredSubscriptionCredential, CREDENTIALS_FILE_VERSION, CredentialStoreError, credentialsPath, readStoredSubscriptionCredential, writeStoredSubscriptionCredential, } from './credential-store.js';
4
+ export { beginCodexDeviceLogin, CODEX_AUTH_ORIGIN, CODEX_OAUTH_CLIENT_ID, type CodexDeviceLogin, type CodexDeviceLoginOptions, type CodexDeviceLoginOutcome, } from './codex-device-login.js';
5
+ export { clearAllStoredCredentials, clearStoredSubscriptionCredential, clearStoredCodexCredential, CREDENTIALS_FILE_VERSION, CredentialStoreError, credentialsPath, readStoredSubscriptionCredential, readStoredCodexCredential, replaceStoredCodexCredential, type StoredCodexCredential, writeStoredSubscriptionCredential, writeStoredCodexCredential, } from './credential-store.js';
6
+ export { ensureFreshStoredCodexCredential, type StoredCodexRefreshOptions, } from './codex-oauth.js';
4
7
  export { OAUTH_SCOPES, REDIRECT_URI } from './identity.js';
5
- export { type CredentialOrigin, ensureFreshAnthropicToken, type OAuthMetadata, readSubscriptionCredential, refreshAgentOAuthToken, } from './oauth.js';
8
+ export { CredentialPublicationError, CredentialRefreshRejectedError, CredentialWithdrawnError, type CredentialOrigin, ensureFreshAnthropicToken, type OAuthMetadata, readSubscriptionCredential, refreshAgentOAuthToken, sameOAuthCredential, } from './oauth.js';
6
9
  export { beginSubscriptionLogin, type LoginOutcome, parsePastedInput, type SubscriptionLogin, type SubscriptionLoginOptions, subscriptionDetectedProvider, } from './subscription-login.js';
7
10
  export { type CapabilityDisagreement, chainCapabilityDisagreements, describeAcceptedMismatch, describeCapabilityRefusal, type MemberCapabilities, unresolvedMembers, } from './chain-capabilities.js';
8
11
  export { chainPositionName, type Preferences, PREFERENCES_FILE_VERSION, PreferencesError, preferencesPath, primaryProvider, type ProviderChoice, type ReadResult, readPreferences, writePreferences, } from './preferences.js';
9
- export { ALL_PROVIDER_IDS, missingCredentialMessage, PROVIDER_REGISTRY, type ProviderId, type ProviderRegistryEntry, type SdkProviderType, unsupportedProviderMessage, } from './registry.js';
10
- export { ensureRegistered, isRegistered, resolveChainCapabilities } from './register.js';
12
+ export { ALL_PROVIDER_IDS, missingCredentialMessage, PROVIDER_REGISTRY, type ProviderId, type ProviderRegistryEntry, type SubscriptionProviderId, type SdkProviderType, unsupportedProviderMessage, } from './registry.js';
13
+ export { ensureRegistered, isRegistered, resolveChainCapabilities, } from './register.js';
11
14
  //# 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,iCAAiC,EACjC,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,gCAAgC,EAChC,iCAAiC,GACjC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EACN,KAAK,gBAAgB,EACrB,yBAAyB,EACzB,KAAK,aAAa,EAClB,0BAA0B,EAC1B,sBAAsB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,sBAAsB,EACtB,KAAK,YAAY,EACjB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,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,wBAAwB,EACxB,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,0BAA0B,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,wBAAwB,EAAE,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,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,gCAAgC,EAChC,yBAAyB,EACzB,4BAA4B,EAC5B,KAAK,qBAAqB,EAC1B,iCAAiC,EACjC,0BAA0B,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,gCAAgC,EAChC,KAAK,yBAAyB,GAC9B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,yBAAyB,EACzB,KAAK,aAAa,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,sBAAsB,EACtB,KAAK,YAAY,EACjB,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,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,wBAAwB,EACxB,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,0BAA0B,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,GACxB,MAAM,eAAe,CAAA"}
@@ -1,11 +1,14 @@
1
1
  export { discoverProviders, findDetected, } from './discover.js';
2
+ export { claudeCredentialsPath, codexCredentialsPath, readClaudeCredentialFile, readClaudeFileCredential, readCodexCredentialFile, readCodexFileCredential, } from './harness-credentials.js';
2
3
  export { isAnthropicOAuthToken, readAgentKeychainCredential, } from './keychain.js';
3
- export { clearStoredSubscriptionCredential, CREDENTIALS_FILE_VERSION, CredentialStoreError, credentialsPath, readStoredSubscriptionCredential, writeStoredSubscriptionCredential, } from './credential-store.js';
4
+ export { beginCodexDeviceLogin, CODEX_AUTH_ORIGIN, CODEX_OAUTH_CLIENT_ID, } from './codex-device-login.js';
5
+ export { clearAllStoredCredentials, clearStoredSubscriptionCredential, clearStoredCodexCredential, CREDENTIALS_FILE_VERSION, CredentialStoreError, credentialsPath, readStoredSubscriptionCredential, readStoredCodexCredential, replaceStoredCodexCredential, writeStoredSubscriptionCredential, writeStoredCodexCredential, } from './credential-store.js';
6
+ export { ensureFreshStoredCodexCredential, } from './codex-oauth.js';
4
7
  export { OAUTH_SCOPES, REDIRECT_URI } from './identity.js';
5
- export { ensureFreshAnthropicToken, readSubscriptionCredential, refreshAgentOAuthToken, } from './oauth.js';
8
+ export { CredentialPublicationError, CredentialRefreshRejectedError, CredentialWithdrawnError, ensureFreshAnthropicToken, readSubscriptionCredential, refreshAgentOAuthToken, sameOAuthCredential, } from './oauth.js';
6
9
  export { beginSubscriptionLogin, parsePastedInput, subscriptionDetectedProvider, } from './subscription-login.js';
7
10
  export { chainCapabilityDisagreements, describeAcceptedMismatch, describeCapabilityRefusal, unresolvedMembers, } from './chain-capabilities.js';
8
11
  export { chainPositionName, PREFERENCES_FILE_VERSION, PreferencesError, preferencesPath, primaryProvider, readPreferences, writePreferences, } from './preferences.js';
9
12
  export { ALL_PROVIDER_IDS, missingCredentialMessage, PROVIDER_REGISTRY, unsupportedProviderMessage, } from './registry.js';
10
- export { ensureRegistered, isRegistered, resolveChainCapabilities } from './register.js';
13
+ export { ensureRegistered, isRegistered, resolveChainCapabilities, } from './register.js';
11
14
  //# 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,iCAAiC,EACjC,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,gCAAgC,EAChC,iCAAiC,GACjC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAEN,yBAAyB,EAEzB,0BAA0B,EAC1B,sBAAsB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,sBAAsB,EAEtB,gBAAgB,EAGhB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,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,wBAAwB,EACxB,iBAAiB,EAIjB,0BAA0B,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,wBAAwB,EAAE,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,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAEN,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,GAIrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,gCAAgC,EAChC,yBAAyB,EACzB,4BAA4B,EAE5B,iCAAiC,EACjC,0BAA0B,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,gCAAgC,GAEhC,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,wBAAwB,EAExB,yBAAyB,EAEzB,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,sBAAsB,EAEtB,gBAAgB,EAGhB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,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,wBAAwB,EACxB,iBAAiB,EAKjB,0BAA0B,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,GACxB,MAAM,eAAe,CAAA"}
@@ -23,19 +23,6 @@ export interface AgentOAuthCredential {
23
23
  readonly scopes?: readonly string[];
24
24
  }
25
25
  export declare function readAgentKeychainCredential(): AgentOAuthCredential | null;
26
- /**
27
- * Persist a refreshed OAuth credential back into the same Keychain entry so
28
- * the new access token survives across launches and the other CLI stays in
29
- * sync. The full envelope is re-read and merged (only the OAuth sub-fields
30
- * change) so any extra keys it stores are preserved. Non-throwing:
31
- * returns `false` (not-darwin, no entry, missing account, write denied) and
32
- * the caller falls back to using the refreshed token only in memory.
33
- *
34
- * Note: `security` takes the secret as an argv (`-w`), so it is briefly
35
- * visible to `ps` — acceptable for a local dev CLI updating a credential that
36
- * already lives on this machine.
37
- */
38
- export declare function writeAgentKeychainCredential(cred: AgentOAuthCredential): boolean;
39
26
  /**
40
27
  * Detect whether a credential value is an OAuth-style token
41
28
  * (must be sent via `Authorization: Bearer`) vs a console API key (sent
@@ -1 +1 @@
1
- {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/keychain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,4BAA4B,CAAA;AAEzD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACnC;AAED,wBAAgB,2BAA2B,IAAI,oBAAoB,GAAG,IAAI,CAmCzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAiDhF;AAiBD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAM5D"}
1
+ {"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/keychain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,4BAA4B,CAAA;AAEzD,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACnC;AAED,wBAAgB,2BAA2B,IAAI,oBAAoB,GAAG,IAAI,CAmCzE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAM5D"}
@@ -59,82 +59,6 @@ export function readAgentKeychainCredential() {
59
59
  : undefined,
60
60
  };
61
61
  }
62
- /**
63
- * Persist a refreshed OAuth credential back into the same Keychain entry so
64
- * the new access token survives across launches and the other CLI stays in
65
- * sync. The full envelope is re-read and merged (only the OAuth sub-fields
66
- * change) so any extra keys it stores are preserved. Non-throwing:
67
- * returns `false` (not-darwin, no entry, missing account, write denied) and
68
- * the caller falls back to using the refreshed token only in memory.
69
- *
70
- * Note: `security` takes the secret as an argv (`-w`), so it is briefly
71
- * visible to `ps` — acceptable for a local dev CLI updating a credential that
72
- * already lives on this machine.
73
- */
74
- export function writeAgentKeychainCredential(cred) {
75
- if (platform() !== 'darwin')
76
- return false;
77
- // `add-generic-password -U` matches an existing item by service + account,
78
- // so we must reuse the original account or we'd create a duplicate entry.
79
- const account = readKeychainAccount();
80
- if (!account)
81
- return false;
82
- let envelope = {};
83
- try {
84
- const raw = execFileSync('security', ['find-generic-password', '-s', KEYCHAIN_SERVICE, '-w'], {
85
- encoding: 'utf8',
86
- timeout: 5_000,
87
- stdio: ['ignore', 'pipe', 'ignore'],
88
- }).trim();
89
- const parsed = JSON.parse(raw);
90
- if (typeof parsed === 'object' && parsed !== null)
91
- envelope = parsed;
92
- }
93
- catch {
94
- // Fall back to a fresh envelope below.
95
- }
96
- const prev = typeof envelope.claudeAiOauth === 'object' && envelope.claudeAiOauth !== null
97
- ? envelope.claudeAiOauth
98
- : {};
99
- envelope.claudeAiOauth = {
100
- ...prev,
101
- accessToken: cred.accessToken,
102
- ...(cred.refreshToken ? { refreshToken: cred.refreshToken } : {}),
103
- ...(cred.expiresAt ? { expiresAt: cred.expiresAt } : {}),
104
- ...(cred.scopes ? { scopes: cred.scopes } : {}),
105
- };
106
- try {
107
- execFileSync('security', [
108
- 'add-generic-password',
109
- '-U',
110
- '-s',
111
- KEYCHAIN_SERVICE,
112
- '-a',
113
- account,
114
- '-w',
115
- JSON.stringify(envelope),
116
- ], { timeout: 5_000, stdio: ['ignore', 'ignore', 'ignore'] });
117
- return true;
118
- }
119
- catch {
120
- return false;
121
- }
122
- }
123
- /** Read the account (`acct`) of the Keychain entry, for updates. */
124
- function readKeychainAccount() {
125
- try {
126
- const out = execFileSync('security', ['find-generic-password', '-s', KEYCHAIN_SERVICE], {
127
- encoding: 'utf8',
128
- timeout: 5_000,
129
- stdio: ['ignore', 'pipe', 'ignore'],
130
- });
131
- const m = out.match(/"acct"<blob>="((?:[^"\\]|\\.)*)"/);
132
- return m?.[1] ?? null;
133
- }
134
- catch {
135
- return null;
136
- }
137
- }
138
62
  /**
139
63
  * Detect whether a credential value is an OAuth-style token
140
64
  * (must be sent via `Authorization: Bearer`) vs a console API key (sent
@@ -1 +1 @@
1
- {"version":3,"file":"keychain.js","sourceRoot":"","sources":["../../../src/integrations/providers/keychain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAElC,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAAyB,CAAA;AASzD,MAAM,UAAU,2BAA2B;IAC1C,IAAI,QAAQ,EAAE,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAExC,IAAI,GAAW,CAAA;IACf,IAAI,CAAC;QACJ,GAAG,GAAG,YAAY,CAAC,UAAU,EAAE,CAAC,uBAAuB,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvF,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACnC,CAAC,CAAC,IAAI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AAC,8CAA8C;IACvF,OAAO,KAAK,CAAA;AACb,CAAC"}
@@ -7,27 +7,29 @@
7
7
  * stale token before the session starts instead of surfacing it as an
8
8
  * authentication error.
9
9
  *
10
- * Non-throwing: any failure (no refresh token, network down, endpoint error)
11
- * returns the existing token unchanged — at worst the caller hits the same
12
- * 401 it would have hit anyway, never a crash.
10
+ * Best-effort for transient refresh failures: no refresh token, a network
11
+ * failure, an ordinary endpoint refusal or the private deadline all return the
12
+ * existing token. `invalid_grant` is different: the authorization grant is no
13
+ * longer usable, so sending the expired access token or retrying the same
14
+ * refresh on every turn cannot recover. It is a typed refusal. Caller
15
+ * cancellation also escapes with its exact cause.
13
16
  *
14
17
  * ## Where a refreshed token is written back
15
18
  *
16
19
  * There are two places a subscription credential can live and they are not
17
20
  * interchangeable, so `origin` says which one this credential came from and
18
- * the refreshed value goes back to the same place:
21
+ * therefore which publication rule applies:
19
22
  *
20
23
  * - `'stored'` — namzu's own store, written by the login flow, present on
21
- * every platform.
24
+ * every platform. A refresh replaces only the exact credential it used.
22
25
  * - `'keychain'` — a co-installed tool's macOS entry, which namzu reads but
23
- * does not own.
26
+ * does not own. A refresh is session-local and never writes that entry.
24
27
  *
25
28
  * `origin` is optional and defaults to `'keychain'` because that is the only
26
- * source that existed when this file was written, and a caller compiled
27
- * against the old shape must keep behaving as it did. Every namzu-owned
28
- * caller passes it explicitly; a credential that came from the login flow and
29
- * was written back to the Keychain would be a no-op off macOS, leaving the
30
- * real store holding a token that is refreshed again on every launch.
29
+ * source that existed when this file was written. Every namzu-owned caller
30
+ * passes it explicitly; a credential from the login flow misclassified as
31
+ * Keychain-origin would remain stale on disk and refresh again on every
32
+ * launch.
31
33
  */
32
34
  import { type AgentOAuthCredential } from './keychain.js';
33
35
  /**
@@ -49,20 +51,47 @@ import { type AgentOAuthCredential } from './keychain.js';
49
51
  * at detection; everything after that is told, not asked.
50
52
  */
51
53
  export declare function readSubscriptionCredential(origin: CredentialOrigin): AgentOAuthCredential | null;
52
- /** Which store a subscription credential came from, and goes back to. */
53
- export type CredentialOrigin = 'stored' | 'keychain';
54
+ /** Which store a subscription credential came from and therefore who owns publication. */
55
+ export type CredentialOrigin = 'stored' | 'keychain' | 'claude-file';
54
56
  export interface OAuthMetadata {
55
57
  readonly refreshToken?: string;
56
58
  readonly expiresAt?: number;
59
+ readonly scopes?: readonly string[];
57
60
  /** Defaults to `'keychain'` — see the note at the top of this file. */
58
61
  readonly origin?: CredentialOrigin;
59
62
  }
63
+ /** The credential that authorized a refresh was removed before publication. */
64
+ export declare class CredentialWithdrawnError extends Error {
65
+ readonly name = "CredentialWithdrawnError";
66
+ constructor(message?: string);
67
+ }
68
+ /** The store could not prove whether the refresh still owned publication. */
69
+ export declare class CredentialPublicationError extends Error {
70
+ readonly name = "CredentialPublicationError";
71
+ constructor(options?: ErrorOptions);
72
+ }
73
+ /** The authorization server says this exact refresh grant cannot be used again. */
74
+ export declare class CredentialRefreshRejectedError extends Error {
75
+ readonly name = "CredentialRefreshRejectedError";
76
+ readonly code: "invalid_grant";
77
+ constructor();
78
+ }
60
79
  /**
61
80
  * Return a non-expired access token, refreshing first if the current one is
62
81
  * lapsed/about-to-lapse and a refresh token is available. On a successful
63
- * refresh the new credential is persisted back to its own store (best-effort).
82
+ * refresh a Namzu-owned credential is conditionally persisted. A borrowed
83
+ * Keychain credential is used only in memory because its owner cannot
84
+ * participate in our conditional-write boundary.
85
+ */
86
+ export declare function ensureFreshAnthropicToken(accessToken: string, oauth: OAuthMetadata, signal?: AbortSignal): Promise<string>;
87
+ /** Exact credential identity used by refresh publication and the live-session refusal cache. */
88
+ export declare function sameOAuthCredential(left: AgentOAuthCredential, right: AgentOAuthCredential): boolean;
89
+ /**
90
+ * Exchange a refresh token for a new credential.
91
+ *
92
+ * Transient/unclassified failures return `null`. A standards-defined
93
+ * `400 invalid_grant` throws {@link CredentialRefreshRejectedError}; retrying
94
+ * the same grant is not recovery.
64
95
  */
65
- export declare function ensureFreshAnthropicToken(accessToken: string, oauth: OAuthMetadata): Promise<string>;
66
- /** Exchange a refresh token for a new credential, or `null` on any failure. */
67
- export declare function refreshAgentOAuthToken(refreshToken: string): Promise<AgentOAuthCredential | null>;
96
+ export declare function refreshAgentOAuthToken(refreshToken: string, signal?: AbortSignal): Promise<AgentOAuthCredential | null>;
68
97
  //# sourceMappingURL=oauth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAWH,OAAO,EACN,KAAK,oBAAoB,EAGzB,MAAM,eAAe,CAAA;AAKtB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,GAAG,IAAI,CAEhG;AAED,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,UAAU,CAAA;AAEpD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAA;CAClC;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC9C,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,aAAa,GAClB,OAAO,CAAC,MAAM,CAAC,CASjB;AAgDD,+EAA+E;AAC/E,wBAAsB,sBAAsB,CAC3C,YAAY,EAAE,MAAM,GAClB,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CA2BtC"}
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAYH,OAAO,EAAE,KAAK,oBAAoB,EAA+B,MAAM,eAAe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