@cortexkit/opencode-anthropic-auth 1.23.0 → 2.0.1

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 (88) hide show
  1. package/README.md +239 -195
  2. package/dist/cli-failure.d.ts +69 -0
  3. package/dist/cli.d.ts +14 -9
  4. package/dist/cli.js +103 -80
  5. package/dist/custody-dimensions.d.ts +7 -24
  6. package/dist/custody-mode.d.ts +29 -169
  7. package/dist/effort-history.d.ts +6 -1
  8. package/dist/{index-xzbhzz0a.js → index-04syas8a.js} +2 -2
  9. package/dist/index-1jkyhgyr.js +2 -0
  10. package/dist/{index-8y2t4mwz.js → index-2arfb1y3.js} +1 -1
  11. package/dist/index-3xqv3rw3.js +2 -0
  12. package/dist/{index-0jfsxyn9.js → index-52r2e1h9.js} +1 -1
  13. package/dist/index-b3mxpp4w.js +2 -0
  14. package/dist/index-p4wvcwhh.js +3 -0
  15. package/dist/{index-1gr8v4fn.js → index-rqync0pc.js} +1 -1
  16. package/dist/index-ynq181e8.js +42 -0
  17. package/dist/index-yxtdke11.js +449 -0
  18. package/dist/index-zdgceztz.js +1 -0
  19. package/dist/index.js +1 -38
  20. package/dist/native-command.d.ts +19 -0
  21. package/dist/rpc/notifications.d.ts +2 -1
  22. package/dist/rpc/port-file.js +1 -1
  23. package/dist/rpc/protocol.d.ts +8 -4
  24. package/dist/rpc/protocol.js +1 -1
  25. package/dist/rpc/rpc-client.d.ts +2 -0
  26. package/dist/rpc/rpc-client.js +1 -1
  27. package/dist/rpc/rpc-dir.js +1 -1
  28. package/dist/rpc/rpc-server.d.ts +5 -1
  29. package/dist/setup/command.d.ts +12 -0
  30. package/dist/setup/command.test.d.ts +1 -0
  31. package/dist/setup/detect.d.ts +7 -4
  32. package/dist/setup/host-executable.d.ts +3 -0
  33. package/dist/setup/native-activation.d.ts +29 -0
  34. package/dist/setup/native-enrollment.d.ts +26 -0
  35. package/dist/setup/native-enrollment.test.d.ts +1 -0
  36. package/dist/setup/native-local.d.ts +20 -0
  37. package/dist/setup/native-login.d.ts +3 -0
  38. package/dist/setup/native-paths.d.ts +15 -0
  39. package/dist/setup/native-paths.test.d.ts +1 -0
  40. package/dist/setup/paths.d.ts +3 -2
  41. package/dist/setup/pi.d.ts +14 -4
  42. package/dist/setup/process-fence.d.ts +7 -1
  43. package/dist/setup/process-fence.test.d.ts +1 -0
  44. package/dist/sidebar-state.js +1 -1
  45. package/dist/tui/command-dialogs.d.ts +5 -0
  46. package/dist/tui-preferences.js +2 -2
  47. package/dist/v2/activation.d.ts +7 -0
  48. package/dist/v2/adapter.d.ts +276 -0
  49. package/dist/v2/install.d.ts +13 -0
  50. package/dist/v2/lifecycle.d.ts +8 -0
  51. package/dist/v2/menu-contract.d.ts +8 -0
  52. package/dist/v2/menu.d.ts +10 -0
  53. package/dist/v2/models.d.ts +6 -0
  54. package/dist/v2/ownership.d.ts +11 -0
  55. package/dist/v2/prime.d.ts +12 -0
  56. package/dist/v2/rpc.d.ts +50 -0
  57. package/dist/v2/server.d.ts +8 -0
  58. package/dist/v2/server.js +4 -0
  59. package/dist/v2/setup.d.ts +58 -0
  60. package/dist/v2/source.d.ts +41 -0
  61. package/dist/v2/tui.d.ts +13 -0
  62. package/dist/v2/tui.js +2 -0
  63. package/dist/v2/wire.d.ts +36 -0
  64. package/package.json +20 -5
  65. package/src/rpc/notifications.ts +9 -2
  66. package/src/rpc/protocol.ts +8 -7
  67. package/src/rpc/rpc-client.ts +17 -0
  68. package/src/rpc/rpc-server.ts +20 -3
  69. package/src/tui/command-dialogs.tsx +264 -0
  70. package/src/tui/entry.mjs +44 -18
  71. package/src/tui-compiled/rpc/protocol.ts +8 -7
  72. package/src/tui-compiled/rpc/rpc-client.ts +17 -0
  73. package/src/tui-compiled/tui/command-dialogs.tsx +315 -76
  74. package/src/tui-compiled/tui.tsx +24 -7
  75. package/src/tui.tsx +37 -9
  76. package/dist/claustrum-enrollment-registry.d.ts +0 -4
  77. package/dist/custody-enrollment.d.ts +0 -14
  78. package/dist/custody-live.d.ts +0 -111
  79. package/dist/custody-manifest-watcher.d.ts +0 -16
  80. package/dist/index-1fq7h6yd.js +0 -430
  81. package/dist/index-797pmamn.js +0 -2
  82. package/dist/index-a5d6v3ba.js +0 -5
  83. package/dist/index-n96q8pks.js +0 -2
  84. package/dist/index-xxhyhp98.js +0 -2
  85. package/dist/index-z7gfdyv3.js +0 -1
  86. package/dist/local-login.d.ts +0 -64
  87. package/dist/logger-kk9vyem9.js +0 -1
  88. package/dist/setup/claustrum.d.ts +0 -26
@@ -0,0 +1,69 @@
1
+ import { type ProviderErrorRedactor } from '@cortexkit/anthropic-auth-core';
2
+ declare const STAGE_LABELS: {
3
+ readonly 'setup-activation': 'Vault custody setup';
4
+ readonly 'setup-opencode-config': 'OpenCode configuration';
5
+ readonly 'setup-pi-install': 'Pi extension installation';
6
+ readonly 'setup-pi': 'Pi setup';
7
+ readonly 'setup-process-check': 'Host process check';
8
+ readonly 'cli-setup': 'Setup';
9
+ readonly 'cli-login': 'Login';
10
+ readonly 'cli-api-add': 'API route setup';
11
+ readonly 'cli-list': 'Account listing';
12
+ readonly 'cli-relay-setup': 'Relay setup';
13
+ readonly 'cli-relay-workers-dev': 'Workers.dev enablement';
14
+ readonly 'cli-command': 'Command';
15
+ };
16
+ export type CliFailureStage = keyof typeof STAGE_LABELS;
17
+ /** UTF-8 bytes of redacted detail kept per diagnostics file. */
18
+ export declare const CLI_FAILURE_DETAIL_MAX_BYTES: number;
19
+ export declare const CLI_FAILURE_OMITTED = "[output beyond the diagnostic limit omitted]";
20
+ export declare const CLI_FAILURE_WITHHELD = "[output withheld: no line break within the inspected window]";
21
+ export declare const CLI_FAILURE_SECRETS_UNREADABLE = "[detail withheld: the known credentials could not be read safely]";
22
+ /**
23
+ * The text to show for a known failure, or undefined when the thrown value is
24
+ * not one. A message counts only when it equals a text in CLOSED_MESSAGES,
25
+ * equals "OAuth metadata read failed: <status>" for its own integer HTTP
26
+ * `status`, or equals what `new ProcessFenceViolationError(activeHosts)`
27
+ * produces from its own validated `activeHosts`.
28
+ */
29
+ export declare function knownFailureMessage(error: unknown): string | undefined;
30
+ /**
31
+ * Exact credentials a failing command may echo: the strings in `submitted`
32
+ * (the API key, OAuth code and tokens, or Cloudflare and relay tokens the CLI
33
+ * command handled) plus every environment value whose name Core's
34
+ * `isSecretKey` treats as secret (for example `*_TOKEN`, `*_API_KEY`,
35
+ * `*_SECRET`), since child processes receive that environment. Empty values are
36
+ * skipped; every other value counts, however short. Returns undefined when
37
+ * either input is a proxy, has accessors or non-string credentials, or is too
38
+ * large to inspect, so the caller can withhold detail instead of logging it
39
+ * with a credential left out.
40
+ */
41
+ export declare function collectKnownSecrets(env: unknown, submitted?: unknown): string[] | undefined;
42
+ /**
43
+ * Redact first, bound second. Raw text is only ever cut at a line break and
44
+ * the partial line is dropped, so a credential is never split before the
45
+ * redactor sees it whole. The redacted lines are then kept up to the byte
46
+ * limit; cutting already-redacted text cannot reveal anything new.
47
+ */
48
+ export declare function boundRedactedDetail(text: string, redactor: Pick<ProviderErrorRedactor, 'redactText'>, keep: 'head' | 'tail'): string[];
49
+ /**
50
+ * Private per-user directory for failure details:
51
+ * `$XDG_STATE_HOME/cortexkit/anthropic-auth/diagnostics`, falling back to
52
+ * `~/.local/state`, which also holds host enrollment files. Undefined when
53
+ * reading the environment would invoke caller code.
54
+ */
55
+ export declare function cliDiagnosticsDirectory(env: unknown): string | undefined;
56
+ /**
57
+ * Screen text for a thrown failure. A known failure is returned word for word
58
+ * and not recorded; anything else is recorded in a private diagnostics file
59
+ * and replaced by a fixed line naming that file. `env` supplies both the
60
+ * secret-named values to scrub and the diagnostics location; `submitted`
61
+ * holds the credentials the failing command handled.
62
+ */
63
+ export declare function reportThrownFailure(stage: CliFailureStage, error: unknown, env: unknown, submitted?: unknown): Promise<string>;
64
+ /** Screen text for a child process that exited unsuccessfully; its stderr tail goes to the diagnostics file. */
65
+ export declare function reportInstallerFailure(stage: CliFailureStage, result: {
66
+ exitCode: number;
67
+ stderr: string;
68
+ }, env: unknown): Promise<string>;
69
+ export {};
package/dist/cli.d.ts CHANGED
@@ -15,29 +15,34 @@ type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<
15
15
  export interface RelaySetupDeps {
16
16
  fetchImpl?: FetchLike;
17
17
  prompt?: (message: string) => Promise<string>;
18
+ /** Receives each credential this command handles, for redacting failure detail. */
19
+ secrets?: string[];
20
+ /** Prints a non-fatal warning; defaults to console.warn. */
21
+ warn?: (message: string) => void;
18
22
  }
19
23
  export declare function relaySetup(deps?: RelaySetupDeps): Promise<void>;
20
24
  /**
21
- * Dependencies the `login` command talks to the outside world through. All
22
- * default to the real implementations (the readline-backed prompt, and the
23
- * core authorize/exchange helpers) so the production `login` path is
24
- * unchanged; tests inject deterministic stubs to exercise the full login flow
25
- * in-process without a subprocess, real network, or stdin.
25
+ * Tests can supply prompts and OAuth responses without opening a browser.
26
+ * Login stores exchanged tokens in the shared account pool after validating
27
+ * the account identity. It never writes OpenCode's auth.json or old sidecars.
26
28
  */
27
29
  export interface LoginDeps {
28
30
  prompt?: (message: string) => Promise<string>;
29
31
  authorize?: typeof authorize;
30
32
  exchange?: typeof exchange;
33
+ /** Receives each credential this command handles, for redacting failure detail. */
34
+ secrets?: string[];
31
35
  }
32
36
  export declare function login(labelArg?: string, deps?: LoginDeps): Promise<void>;
33
37
  /**
34
- * Dependencies the `api add` command talks to the outside world through. The
35
- * prompt defaults to the real readline-backed prompt so the production
36
- * `api add` path is unchanged; tests inject canned answers to exercise the
37
- * full route-add flow in-process without a subprocess or stdin.
38
+ * Tests can supply prompts to check API keys and proxy route settings.
39
+ * New keys go to the shared account pool after migration has committed;
40
+ * OpenCode's auth.json and the old sidecar files remain unchanged.
38
41
  */
39
42
  export interface ApiAddDeps {
40
43
  prompt?: (message: string) => Promise<string>;
44
+ /** Receives each credential this command handles, for redacting failure detail. */
45
+ secrets?: string[];
41
46
  }
42
47
  export declare function addApiRoute(labelArg?: string, deps?: ApiAddDeps): Promise<void>;
43
48
  import { runSetupCommand } from './setup/command.ts';