@ap3x/cli 0.1.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 (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/dist/agent-session.d.ts +163 -0
  4. package/dist/agent-session.d.ts.map +1 -0
  5. package/dist/auth/anthropic-login.d.ts +98 -0
  6. package/dist/auth/anthropic-login.d.ts.map +1 -0
  7. package/dist/auth/codex-login.d.ts +80 -0
  8. package/dist/auth/codex-login.d.ts.map +1 -0
  9. package/dist/auth/copilot-login.d.ts +36 -0
  10. package/dist/auth/copilot-login.d.ts.map +1 -0
  11. package/dist/auth/login-dispatch.d.ts +76 -0
  12. package/dist/auth/login-dispatch.d.ts.map +1 -0
  13. package/dist/bin.d.ts +3 -0
  14. package/dist/bin.d.ts.map +1 -0
  15. package/dist/bin.js +15 -0
  16. package/dist/branding.d.ts +89 -0
  17. package/dist/branding.d.ts.map +1 -0
  18. package/dist/chunk-3WSVGI7R.js +10522 -0
  19. package/dist/cli.d.ts +135 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cron/agent-executor.d.ts +45 -0
  22. package/dist/cron/agent-executor.d.ts.map +1 -0
  23. package/dist/cron/cron-cli.d.ts +27 -0
  24. package/dist/cron/cron-cli.d.ts.map +1 -0
  25. package/dist/cron/schedule-file.d.ts +7 -0
  26. package/dist/cron/schedule-file.d.ts.map +1 -0
  27. package/dist/glob.d.ts +12 -0
  28. package/dist/glob.d.ts.map +1 -0
  29. package/dist/hooks/hooks-cli.d.ts +11 -0
  30. package/dist/hooks/hooks-cli.d.ts.map +1 -0
  31. package/dist/index.d.ts +26 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +462 -0
  34. package/dist/modes/index.d.ts +5 -0
  35. package/dist/modes/index.d.ts.map +1 -0
  36. package/dist/modes/interactive.d.ts +44 -0
  37. package/dist/modes/interactive.d.ts.map +1 -0
  38. package/dist/modes/print.d.ts +24 -0
  39. package/dist/modes/print.d.ts.map +1 -0
  40. package/dist/modes/render.d.ts +29 -0
  41. package/dist/modes/render.d.ts.map +1 -0
  42. package/dist/modes/rpc.d.ts +149 -0
  43. package/dist/modes/rpc.d.ts.map +1 -0
  44. package/dist/sdk.d.ts +95 -0
  45. package/dist/sdk.d.ts.map +1 -0
  46. package/dist/settings.d.ts +109 -0
  47. package/dist/settings.d.ts.map +1 -0
  48. package/dist/skills.d.ts +27 -0
  49. package/dist/skills.d.ts.map +1 -0
  50. package/dist/slash-commands.d.ts +79 -0
  51. package/dist/slash-commands.d.ts.map +1 -0
  52. package/dist/system-prompt.d.ts +21 -0
  53. package/dist/system-prompt.d.ts.map +1 -0
  54. package/dist/tools/a2a.d.ts +11 -0
  55. package/dist/tools/a2a.d.ts.map +1 -0
  56. package/dist/tools/bash.d.ts +4 -0
  57. package/dist/tools/bash.d.ts.map +1 -0
  58. package/dist/tools/context.d.ts +42 -0
  59. package/dist/tools/context.d.ts.map +1 -0
  60. package/dist/tools/edit.d.ts +16 -0
  61. package/dist/tools/edit.d.ts.map +1 -0
  62. package/dist/tools/find.d.ts +9 -0
  63. package/dist/tools/find.d.ts.map +1 -0
  64. package/dist/tools/grep.d.ts +9 -0
  65. package/dist/tools/grep.d.ts.map +1 -0
  66. package/dist/tools/index.d.ts +35 -0
  67. package/dist/tools/index.d.ts.map +1 -0
  68. package/dist/tools/ls.d.ts +5 -0
  69. package/dist/tools/ls.d.ts.map +1 -0
  70. package/dist/tools/read.d.ts +9 -0
  71. package/dist/tools/read.d.ts.map +1 -0
  72. package/dist/tools/swarm.d.ts +42 -0
  73. package/dist/tools/swarm.d.ts.map +1 -0
  74. package/dist/tools/walk.d.ts +48 -0
  75. package/dist/tools/walk.d.ts.map +1 -0
  76. package/dist/tools/write.d.ts +9 -0
  77. package/dist/tools/write.d.ts.map +1 -0
  78. package/dist/trace/trace-cli.d.ts +9 -0
  79. package/dist/trace/trace-cli.d.ts.map +1 -0
  80. package/dist/utils/clipboard.d.ts +23 -0
  81. package/dist/utils/clipboard.d.ts.map +1 -0
  82. package/dist/utils/git.d.ts +13 -0
  83. package/dist/utils/git.d.ts.map +1 -0
  84. package/dist/utils/highlight.d.ts +23 -0
  85. package/dist/utils/highlight.d.ts.map +1 -0
  86. package/dist/utils/index.d.ts +6 -0
  87. package/dist/utils/index.d.ts.map +1 -0
  88. package/dist/utils/resume.d.ts +9 -0
  89. package/dist/utils/resume.d.ts.map +1 -0
  90. package/dist/utils/version-check.d.ts +34 -0
  91. package/dist/utils/version-check.d.ts.map +1 -0
  92. package/package.json +45 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AP3X
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # @ap3x/cli
2
+
3
+ The `ap3x` command line: an interactive coding agent with tool use, sessions, slash commands, hooks, and a durable job scheduler.
4
+
5
+ Part of [AP3X](https://github.com/AP3X-Dev/AP3X) — a TypeScript multi-agent framework.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @ap3x/cli
11
+ ```
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install -g @ap3x/cli
17
+ ap3x --help
18
+ ```
19
+
20
+ ## What's inside
21
+
22
+ - **Interactive + single-shot modes** — a full TUI session, or `ap3x -p "…"` to print an answer and exit.
23
+ - **Auth** — browser OAuth for subscription backends, or API keys from the environment.
24
+ - **Slash commands** — a curated command set operating over an injected context, so they are testable without a terminal.
25
+ - **Hooks** — lifecycle hooks around tool use and delegation, configurable and dry-runnable.
26
+ - **`ap3x cron`** — durable scheduled jobs hosted on `@ap3x/cadence`.
27
+
28
+ ## Documentation
29
+
30
+ See the [AP3X repository](https://github.com/AP3X-Dev/AP3X) for architecture notes, the full package map, and examples.
31
+
32
+ ## License
33
+
34
+ MIT
@@ -0,0 +1,163 @@
1
+ import { type AgentBackend, type AgentEvent, type AgentHooks, type AgentRunResult, type AnyAgentTool, type Session, type SessionRepo, type StreamFn, type ThinkingLevel } from "@ap3x/agent-core";
2
+ import { type Model } from "@ap3x/ai";
3
+ /**
4
+ * Typed surface emitted by an {@link AgentSession}. F2 (interactive/print/rpc)
5
+ * subscribes to these to render output; the orchestration layer (swarms)
6
+ * consumes the higher-level AgentSession rather than this raw event surface.
7
+ */
8
+ export type AgentSessionEvent = {
9
+ type: "prompt_start";
10
+ prompt: string;
11
+ } | {
12
+ type: "agent_event";
13
+ event: AgentEvent;
14
+ } | {
15
+ type: "prompt_end";
16
+ result: AgentRunResult;
17
+ } | {
18
+ type: "error";
19
+ error: Error;
20
+ };
21
+ /** Listener registered via {@link AgentSession.on}. */
22
+ export type AgentSessionListener = (event: AgentSessionEvent) => void | Promise<void>;
23
+ /** Options accepted by {@link createAgentSession}. */
24
+ export interface AgentSessionOptions {
25
+ /** The model to drive the agent. Either a {@link Model} or a provider+id. */
26
+ model?: Model<string>;
27
+ /** Provider slug used with {@link modelId} when {@link model} is omitted. */
28
+ provider?: string;
29
+ /** Model id used with {@link provider} when {@link model} is omitted. */
30
+ modelId?: string;
31
+ systemPrompt?: string;
32
+ /** Reasoning intensity (excluding "off", which simply omits reasoning). */
33
+ thinking?: ThinkingLevel;
34
+ /** Tools the agent may call. Defaults to the standard coding tool set. */
35
+ tools?: AnyAgentTool[];
36
+ maxLoops?: number;
37
+ toolExecution?: "sequential" | "parallel";
38
+ /** Auto-compact context when it nears the window. Default: enabled. */
39
+ autoCompact?: boolean;
40
+ /** Working directory for the default tool environment. */
41
+ cwd?: string;
42
+ /** Custom shell for the bash tool; undefined = auto-detect. */
43
+ shellPath?: string;
44
+ /** Enforce the destructive-command blocklist in the default env. */
45
+ enforceBlocklist?: boolean;
46
+ /** A persistent session tree to record the conversation into. */
47
+ session?: Session;
48
+ /**
49
+ * The store {@link AgentSessionRuntime}'s lifecycle methods (new/switch/fork/
50
+ * import) create and read sessions from. Defaults to a `JsonlSessionRepo` at
51
+ * `~/.ap3x/sessions`; inject a repo over a temp dir in tests. Ignored by the
52
+ * bare session — it only governs the runtime wrapper.
53
+ */
54
+ sessionRepo?: SessionRepo;
55
+ /** A pre-built backend; when given, model/tools/etc. wiring is skipped. */
56
+ backend?: AgentBackend;
57
+ /**
58
+ * Custom provider stream function threaded into the backend
59
+ * (`AgentOptions.streamFn`) — the injection seam for tests / alternate
60
+ * transports. Ignored when {@link backend} is injected.
61
+ */
62
+ streamFn?: StreamFn;
63
+ /** Stable id used for prompt-cache affinity and logging. */
64
+ sessionId?: string;
65
+ /**
66
+ * Resolved API key / bearer token for the provider (from the unified auth
67
+ * seam). Threaded into the backend's stream options so an OAuth access token
68
+ * or API key reaches the provider call.
69
+ */
70
+ apiKey?: string;
71
+ /**
72
+ * Extra request headers (e.g. `chatgpt-account-id`) from the unified auth
73
+ * seam. Merged onto the provider request via stream options.
74
+ */
75
+ headers?: Record<string, string>;
76
+ /**
77
+ * Loop hooks threaded into the runtime backend (`AgentOptions.hooks`) — the
78
+ * seam the CLI uses to install the discovered hook engine. Ignored when
79
+ * {@link backend} is injected.
80
+ */
81
+ hooks?: AgentHooks;
82
+ }
83
+ /**
84
+ * The resolved services an {@link AgentSession} composes over. Splitting this
85
+ * out lets F2 and tests inject a faux backend / model without touching the
86
+ * factory wiring. See {@link createAgentSessionServices}.
87
+ */
88
+ export interface AgentSessionServices {
89
+ backend: AgentBackend;
90
+ model: Model<string>;
91
+ tools: AnyAgentTool[];
92
+ session?: Session;
93
+ sessionId: string;
94
+ /**
95
+ * The hooks threaded into the backend, kept here (not just inside the
96
+ * backend) so {@link AgentSession} can re-arm a {@link HookAgentHooks}'
97
+ * `reset()` between runs — the backend has no seam for that itself.
98
+ */
99
+ hooks?: AgentHooks;
100
+ }
101
+ /**
102
+ * Build the runtime services for a session from high-level options. This is the
103
+ * injection seam: callers (F2, tests) can construct services with a faux
104
+ * backend and hand them to {@link createAgentSessionFromServices}.
105
+ */
106
+ export declare function createAgentSessionServices(options?: AgentSessionOptions): AgentSessionServices;
107
+ /**
108
+ * The central coding-agent session. It composes the agent-core backend
109
+ * (#36: the default backend wraps an Agent; a multi-turn tool loop maps to one
110
+ * run()) and exposes a prompt queue, model selection, a typed event surface,
111
+ * and optional session-tree persistence. F2 layers the interactive / print /
112
+ * rpc run modes on top of this; orchestration consumes it directly.
113
+ */
114
+ export declare class AgentSession {
115
+ private readonly services;
116
+ private readonly listeners;
117
+ private readonly backendUnsubscribe?;
118
+ private running;
119
+ /**
120
+ * The LAST mid-run compaction event of the current run (a later swap's counts
121
+ * supersede an earlier one's). Captured so persist() can record a durable
122
+ * CompactionEntry — without it the swap lives only in loop memory and a
123
+ * --resume replays the raw uncompacted history.
124
+ */
125
+ private lastCompaction?;
126
+ /** Pending prompts queued while a run is in progress. */
127
+ private readonly queue;
128
+ constructor(services: AgentSessionServices);
129
+ /** The active model. */
130
+ get model(): Model<string>;
131
+ /** The session id used for cache affinity / logging. */
132
+ get sessionId(): string;
133
+ /** The persistent session tree, if one was provided. */
134
+ get session(): Session | undefined;
135
+ /** The tools the agent may call. */
136
+ get tools(): AnyAgentTool[];
137
+ /** Whether a prompt is currently being processed. */
138
+ get isRunning(): boolean;
139
+ /** Subscribe to session events. Returns an unsubscribe function. */
140
+ on(listener: AgentSessionListener): () => void;
141
+ /** Abort the active run, if the backend supports it. */
142
+ abort(): void;
143
+ /**
144
+ * Submit a prompt. Runs immediately when idle, otherwise queues behind the
145
+ * in-flight prompt so callers can fire-and-forget. Resolves with the run
146
+ * result (final assistant text + usage + stop reason).
147
+ */
148
+ prompt(prompt: string, opts?: {
149
+ signal?: AbortSignal;
150
+ }): Promise<AgentRunResult>;
151
+ private runPrompt;
152
+ private drainQueue;
153
+ /** Persist produced messages into the session tree, when one is attached. */
154
+ private persist;
155
+ private emit;
156
+ /** Release backend subscriptions. Safe to call multiple times. */
157
+ dispose(): void;
158
+ }
159
+ /** Build an {@link AgentSession} from pre-resolved services (injection seam). */
160
+ export declare function createAgentSessionFromServices(services: AgentSessionServices): AgentSession;
161
+ /** The high-level factory: resolve services from options, then build a session. */
162
+ export declare function createAgentSession(options?: AgentSessionOptions): AgentSession;
163
+ //# sourceMappingURL=agent-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-session.d.ts","sourceRoot":"","sources":["../src/agent-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,UAAU,EAEf,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,OAAO,EAEZ,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,aAAa,EAInB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,KAAK,EAAwB,MAAM,UAAU,CAAC;AAG5D;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE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E,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,IAAI;IAO9C,wDAAwD;IACxD,KAAK,IAAI,IAAI;IAIb;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;YASlE,SAAS;YA2BT,UAAU;IAWxB,6EAA6E;IAC7E,OAAO,CAAC,OAAO;YA0CD,IAAI;IAMlB,kEAAkE;IAClE,OAAO,IAAI,IAAI;CAIhB;AAED,iFAAiF;AACjF,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,oBAAoB,GAAG,YAAY,CAE3F;AAED,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CAElF"}
@@ -0,0 +1,98 @@
1
+ import { AuthStorage, type FetchLike, type OAuthToken } from "@ap3x/ai";
2
+ /** Loopback callback ports tried, in order. Mirrors the Claude Code default. */
3
+ export declare const DEFAULT_ANTHROPIC_CALLBACK_PORTS: number[];
4
+ /** The query a successful callback delivers. */
5
+ export interface AnthropicCallbackParams {
6
+ code?: string;
7
+ state?: string;
8
+ error?: string;
9
+ }
10
+ /**
11
+ * A running loopback callback listener. `port` is the bound port (used to build
12
+ * the redirect URI); `waitForCallback` resolves once the browser hits the
13
+ * redirect; `close` tears the listener down. Abstracted so tests can inject a
14
+ * fake that fires a simulated callback with no real socket bind.
15
+ */
16
+ export interface AnthropicLoopbackServer {
17
+ port: number;
18
+ waitForCallback: () => Promise<AnthropicCallbackParams>;
19
+ close: () => void;
20
+ }
21
+ /** Starts an {@link AnthropicLoopbackServer} on the first usable port. */
22
+ export type StartAnthropicLoopbackServer = (ports: number[]) => Promise<AnthropicLoopbackServer>;
23
+ /**
24
+ * Default loopback server: binds a real `node:http` server on the Claude Code
25
+ * `/callback` path. Tries each port in order; the first that binds wins. The
26
+ * single callback request resolves the pending promise, replies with a small
27
+ * confirmation page, and the server is closed by the caller.
28
+ */
29
+ export declare const startRealAnthropicLoopbackServer: StartAnthropicLoopbackServer;
30
+ /**
31
+ * Parse a manually pasted authorization value. Accepts a full redirect URL, a
32
+ * bare code, a `code#state` fragment, or a `code=...&state=...` query fragment
33
+ * (the remote-browser paste fallback where the loopback cannot be reached).
34
+ */
35
+ export declare function parseAuthorizationInput(input: string): {
36
+ code?: string;
37
+ state?: string;
38
+ };
39
+ /** Options for {@link loginAnthropic}; every IO seam is injectable. */
40
+ export interface LoginAnthropicOptions {
41
+ /** Token storage; defaults to the on-disk {@link AuthStorage}. */
42
+ storage?: AuthStorage;
43
+ /** Open the authorization URL in a browser. Default: cross-platform open. */
44
+ openBrowser?: (url: string) => void;
45
+ /** Injectable fetch for the token exchange. */
46
+ fetchImpl?: FetchLike;
47
+ /** Candidate loopback ports. Default: {@link DEFAULT_ANTHROPIC_CALLBACK_PORTS}. */
48
+ ports?: number[];
49
+ /** Abort the wait (e.g. user cancelled). */
50
+ signal?: AbortSignal;
51
+ /** Print a line (e.g. the URL for headless users). Default: console.log. */
52
+ print?: (text: string) => void;
53
+ /** Start the loopback server. Default: a real node:http bind. Tests inject. */
54
+ startServer?: StartAnthropicLoopbackServer;
55
+ /** Override the callback wait timeout (ms). */
56
+ timeoutMs?: number;
57
+ /** Explicit client id override (else env / vendor default). */
58
+ clientId?: string;
59
+ /**
60
+ * Remote-browser fallback: resolve with a pasted code / redirect URL. When
61
+ * provided, it races the loopback callback — whichever completes first wins.
62
+ */
63
+ promptManualCode?: (signal: AbortSignal) => Promise<string>;
64
+ }
65
+ /** The outcome of a successful Anthropic subscription sign-in. */
66
+ export interface AnthropicLoginResult {
67
+ mode: "oauth";
68
+ }
69
+ /**
70
+ * Run the native Anthropic (Claude Pro/Max) loopback OAuth flow:
71
+ *
72
+ * 1. Bind a loopback server and derive the exact redirect URI from its port.
73
+ * 2. Build the authorize URL (PKCE + state + the Claude Code client id).
74
+ * 3. Open the URL in a browser (and print it for headless use).
75
+ * 4. Await the loopback callback (or a manually pasted code / redirect URL),
76
+ * verify `state`, then exchange the code at platform.claude.com.
77
+ * 5. Persist the token set under the `anthropic` provider slug.
78
+ *
79
+ * Every external interaction (browser, HTTP, server bind, manual input) is
80
+ * injectable, so a test drives the whole flow with no real IO.
81
+ */
82
+ export declare function loginAnthropic(options?: LoginAnthropicOptions): Promise<AnthropicLoginResult>;
83
+ /** Options for {@link refreshAnthropic}; injectable for tests. */
84
+ export interface RefreshAnthropicOptions {
85
+ fetchImpl?: FetchLike;
86
+ clientId?: string;
87
+ signal?: AbortSignal;
88
+ }
89
+ /**
90
+ * Exchange an Anthropic refresh token for a fresh access token. Delegates to the
91
+ * shared {@link refreshAccessToken} flow so the manual and auto-refresh paths
92
+ * post an identical JSON body (Anthropic's token endpoint rejects form-encoding).
93
+ * The shared flow carries the refresh token forward when the endpoint omits it.
94
+ */
95
+ export declare function refreshAnthropic(refreshToken: string, options?: RefreshAnthropicOptions): Promise<OAuthToken>;
96
+ /** Clear stored Anthropic (Claude Pro/Max) credentials. */
97
+ export declare function logoutAnthropic(storage?: AuthStorage): Promise<void>;
98
+ //# sourceMappingURL=anthropic-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-login.d.ts","sourceRoot":"","sources":["../../src/auth/anthropic-login.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EAEd,KAAK,UAAU,EAIhB,MAAM,UAAU,CAAC;AAMlB,gFAAgF;AAChF,eAAO,MAAM,gCAAgC,UAAiB,CAAC;AAK/D,gDAAgD;AAChD,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,OAAO,C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ClC,OAAO,CAAC,oBAAoB,CAAC,CAmD/B;AAuHD,kEAAkE;AAClE,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED,2DAA2D;AAC3D,wBAAsB,eAAe,CAAC,OAAO,GAAE,WAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F"}
@@ -0,0 +1,80 @@
1
+ import { AuthStorage, type FetchLike } from "@ap3x/ai";
2
+ /** Ports tried, in order, for the loopback OAuth callback server. */
3
+ export declare const DEFAULT_CALLBACK_PORTS: number[];
4
+ /** The query a successful callback delivers. */
5
+ export interface CallbackParams {
6
+ code?: string;
7
+ state?: string;
8
+ error?: string;
9
+ }
10
+ /**
11
+ * A running loopback callback listener. `port` is the bound port (used to build
12
+ * the redirect URI); `waitForCallback` resolves once the browser hits the
13
+ * redirect; `close` tears the listener down. Abstracted so tests can inject a
14
+ * fake that fires a simulated callback with no real socket bind.
15
+ */
16
+ export interface LoopbackServer {
17
+ port: number;
18
+ waitForCallback: () => Promise<CallbackParams>;
19
+ close: () => void;
20
+ }
21
+ /** Starts a {@link LoopbackServer} on the first usable port from `ports`. */
22
+ export type StartLoopbackServer = (ports: number[]) => Promise<LoopbackServer>;
23
+ /**
24
+ * Default loopback server: binds a real `node:http` server. Tries each port in
25
+ * order; the first that binds wins. The single `/auth/callback` request resolves
26
+ * the pending promise, replies with a small confirmation page, and the server is
27
+ * closed by the caller.
28
+ */
29
+ export declare const startRealLoopbackServer: StartLoopbackServer;
30
+ /** Open a URL in the user's default browser (best-effort, cross-platform). */
31
+ export declare function defaultOpenBrowser(url: string): void;
32
+ /** Options for {@link loginWithChatGPT}; every IO seam is injectable. */
33
+ export interface LoginWithChatGPTOptions {
34
+ /** Token storage; defaults to the on-disk {@link AuthStorage}. */
35
+ storage?: AuthStorage;
36
+ /** Open the authorization URL in a browser. Default: cross-platform open. */
37
+ openBrowser?: (url: string) => void;
38
+ /** Injectable fetch for the token exchange. */
39
+ fetchImpl?: FetchLike;
40
+ /** Candidate loopback ports. Default: {@link DEFAULT_CALLBACK_PORTS}. */
41
+ ports?: number[];
42
+ /** Abort the wait (e.g. user cancelled). */
43
+ signal?: AbortSignal;
44
+ /** Print a line (e.g. the URL for headless users). Default: console.log. */
45
+ print?: (text: string) => void;
46
+ /** Start the loopback server. Default: a real node:http bind. Tests inject. */
47
+ startServer?: StartLoopbackServer;
48
+ /** Override the callback wait timeout (ms). */
49
+ timeoutMs?: number;
50
+ /**
51
+ * Remote-browser / headless fallback: resolve with a pasted authorization code
52
+ * or full redirect URL. When provided it races the loopback callback —
53
+ * whichever completes first wins — so sign-in works on a machine with no local
54
+ * browser (the user authorizes elsewhere and pastes the redirect URL back).
55
+ */
56
+ promptManualCode?: (signal: AbortSignal) => Promise<string>;
57
+ }
58
+ /** The outcome of a successful ChatGPT sign-in. */
59
+ export interface LoginResult {
60
+ mode: "oauth";
61
+ accountId?: string;
62
+ }
63
+ /**
64
+ * Run the native "Sign in with ChatGPT" loopback OAuth flow:
65
+ *
66
+ * 1. Bind a loopback server and derive the exact redirect URI from its port.
67
+ * 2. Build the authorize URL (PKCE + state + ChatGPT extra params).
68
+ * 3. Open the URL in a browser (and print it for headless use).
69
+ * 4. Await the loopback callback — or a manually pasted code / redirect URL
70
+ * when `promptManualCode` is supplied (remote-browser / headless) — verify
71
+ * `state`, then exchange the code.
72
+ * 5. Persist the token set (incl. account id) under the `openai-codex` slug.
73
+ *
74
+ * Every external interaction (browser, HTTP, server bind, manual input) is
75
+ * injectable, so a test drives the whole flow with no real IO.
76
+ */
77
+ export declare function loginWithChatGPT(options?: LoginWithChatGPTOptions): Promise<LoginResult>;
78
+ /** Clear stored ChatGPT/Codex credentials. */
79
+ export declare function logoutCodex(storage?: AuthStorage): Promise<void>;
80
+ //# sourceMappingURL=codex-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-login.d.ts","sourceRoot":"","sources":["../../src/auth/codex-login.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EAKf,MAAM,UAAU,CAAC;AAKlB,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,UAAe,CAAC;AAKnD,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/C,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;AAQ/E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,mBAarC,CAAC;AAuCF,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAoBpD;AAED,yEAAyE;AACzE,MAAM,WAAW,uBAAuB;IACtC,kEAAkE;IAClE,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,+EAA+E;IAC/E,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7D;AAED,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,WAAW,CAAC,CA+CtB;AAqHD,8CAA8C;AAC9C,wBAAsB,WAAW,CAAC,OAAO,GAAE,WAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzF"}
@@ -0,0 +1,36 @@
1
+ import { AuthStorage, type FetchLike } from "@ap3x/ai";
2
+ /** Options for {@link loginGitHubCopilot}; every IO seam is injectable. */
3
+ export interface LoginGitHubCopilotOptions {
4
+ /** Token storage; defaults to the on-disk {@link AuthStorage}. */
5
+ storage?: AuthStorage;
6
+ /** Print a line (the user code + verification URL). Default: console.log. */
7
+ print?: (text: string) => void;
8
+ /** Open the verification URL in a browser. Default: cross-platform open. */
9
+ openBrowser?: (url: string) => void;
10
+ /** Injectable fetch for the device-authorization + token polling requests. */
11
+ fetchImpl?: FetchLike;
12
+ /** Abort the flow (e.g. user cancelled). */
13
+ signal?: AbortSignal;
14
+ /** Sleep between token polls (ms). Injectable for tests. */
15
+ sleep?: (ms: number) => Promise<void>;
16
+ }
17
+ /** The outcome of a successful GitHub Copilot sign-in. */
18
+ export interface CopilotLoginResult {
19
+ mode: "oauth";
20
+ }
21
+ /**
22
+ * Run the GitHub device-code OAuth flow for Copilot:
23
+ *
24
+ * 1. Request a device + user code from GitHub's device-authorization endpoint.
25
+ * 2. Show the user code and verification URL (and open the browser to it).
26
+ * 3. Poll the token endpoint until the user authorizes (honoring
27
+ * `authorization_pending` / `slow_down` per RFC 8628).
28
+ * 4. Persist the durable GitHub OAuth token under the `github-copilot` slug —
29
+ * the runtime's unified auth exchanges it for the short-lived Copilot API
30
+ * bearer on first use.
31
+ *
32
+ * Every external interaction (browser, HTTP, sleep) is injectable, so a test
33
+ * drives the whole flow with no real IO.
34
+ */
35
+ export declare function loginGitHubCopilot(options?: LoginGitHubCopilotOptions): Promise<CopilotLoginResult>;
36
+ //# sourceMappingURL=copilot-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copilot-login.d.ts","sourceRoot":"","sources":["../../src/auth/copilot-login.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EAMf,MAAM,UAAU,CAAC;AAMlB,2EAA2E;AAC3E,MAAM,WAAW,yBAAyB;IACxC,kEAAkE;IAClE,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,4EAA4E;IAC5E,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,8EAA8E;IAC9E,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,kBAAkB,CAAC,CA4C7B"}
@@ -0,0 +1,76 @@
1
+ import { type Api, type AuthStorage, type Model, type Provider } from "@ap3x/ai";
2
+ import { type AnthropicLoginResult, type LoginAnthropicOptions } from "./anthropic-login";
3
+ import { type LoginResult, type LoginWithChatGPTOptions } from "./codex-login";
4
+ import { type CopilotLoginResult, type LoginGitHubCopilotOptions } from "./copilot-login";
5
+ /**
6
+ * The ONE login/logout provider dispatch, shared by the `ap3x login`/`logout`
7
+ * subcommands and the `/login`/`/logout` slash commands so the two consumers
8
+ * cannot diverge again (the pre-A3 bug: the subcommand was a binary
9
+ * anthropic-vs-ChatGPT split that ran the ChatGPT OAuth flow for API-key
10
+ * providers like `openai`).
11
+ *
12
+ * Routing — each OAuth provider reaches ITS OWN flow, never another's (the
13
+ * pre-B15 bug: github-copilot fell through to the ChatGPT flow and persisted
14
+ * under the wrong slug):
15
+ * - `anthropic` → Anthropic (Claude Pro/Max) authorization-code OAuth flow.
16
+ * - `github-copilot` → GitHub device-code OAuth flow.
17
+ * - `openai-codex` → ChatGPT/Codex authorization-code OAuth flow.
18
+ * - Any other provider WITH an OAuth config → an actionable error (a future
19
+ * provider must get its own flow, not silently borrow one).
20
+ * - No OAuth config → API-key probe via {@link getApiKeyAndHeaders}; nothing
21
+ * is stored, the outcome just reports whether a credential resolved.
22
+ */
23
+ /** What {@link performLogin} did; the caller renders its own success output. */
24
+ export type LoginOutcome = {
25
+ flow: "anthropic-oauth";
26
+ } | {
27
+ flow: "codex-oauth";
28
+ accountId?: string;
29
+ } | {
30
+ flow: "copilot-oauth";
31
+ } | {
32
+ flow: "api-key";
33
+ mode: "oauth" | "api-key" | "none";
34
+ };
35
+ export interface PerformLoginOptions {
36
+ /** The resolved provider slug the dispatch routes on. */
37
+ provider: Provider;
38
+ /** Token storage (inject in-memory for tests; on-disk by default). */
39
+ storage: AuthStorage;
40
+ /** Line printer the OAuth flows use (URL for headless users, etc.). */
41
+ print: (text: string) => void;
42
+ /**
43
+ * The concrete model, when the caller has one (the slash command does). The
44
+ * API-key probe reads only `model.provider`, so callers without a resolved
45
+ * model (the `ap3x login` subcommand) may omit it.
46
+ */
47
+ model?: Model<Api>;
48
+ /** Injectable Anthropic OAuth flow (tests). Defaults to {@link loginAnthropic}. */
49
+ loginAnthropic?: (options?: LoginAnthropicOptions) => Promise<AnthropicLoginResult>;
50
+ /** Injectable ChatGPT/Codex OAuth flow (tests). Defaults to {@link loginWithChatGPT}. */
51
+ loginCodex?: (options?: LoginWithChatGPTOptions) => Promise<LoginResult>;
52
+ /** Injectable GitHub Copilot device-code flow (tests). Defaults to {@link loginGitHubCopilot}. */
53
+ loginCopilot?: (options?: LoginGitHubCopilotOptions) => Promise<CopilotLoginResult>;
54
+ }
55
+ /**
56
+ * Authenticate `provider` via the routing above. OAuth flow errors propagate
57
+ * to the caller (both consumers catch and render them); the API-key path never
58
+ * signs anything in — a `mode: "none"` outcome means no credential was found.
59
+ */
60
+ export declare function performLogin(options: PerformLoginOptions): Promise<LoginOutcome>;
61
+ export interface PerformLogoutOptions {
62
+ /** The resolved provider slug whose credentials are cleared — ONLY this one. */
63
+ provider: Provider;
64
+ /** Token storage (inject in-memory for tests; on-disk by default). */
65
+ storage: AuthStorage;
66
+ }
67
+ /**
68
+ * Clear exactly the resolved provider's stored credentials. Reports whether a
69
+ * token was actually stored so callers never print a sign-out that did not
70
+ * happen (the pre-A3 subcommand cleared the CODEX token for every non-anthropic
71
+ * provider and claimed success).
72
+ */
73
+ export declare function performLogout(options: PerformLogoutOptions): Promise<{
74
+ cleared: boolean;
75
+ }>;
76
+ //# sourceMappingURL=login-dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-dispatch.d.ts","sourceRoot":"","sources":["../../src/auth/login-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,QAAQ,EAGd,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,E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AW,oBAAoB;IACnC,gFAAgF;IAChF,QAAQ,EAAE,QAAQ,CAAC;IACnB,sEAAsE;IACtE,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAKhG"}
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ main
4
+ } from "./chunk-3WSVGI7R.js";
5
+
6
+ // src/bin.ts
7
+ main(process.argv.slice(2)).then((code) => {
8
+ process.exitCode = code;
9
+ }).catch((error) => {
10
+ process.stderr.write(
11
+ `${error instanceof Error ? error.stack ?? error.message : String(error)}
12
+ `
13
+ );
14
+ process.exitCode = 1;
15
+ });
@@ -0,0 +1,89 @@
1
+ /**
2
+ * AP3X CLI branding + path resolution. Every identifier here is AP3X-native:
3
+ * binary `ap3x`, config dir `~/.ap3x/`, env prefix `AP3X_` — Hard Constraint 2.
4
+ * No third-party brand appears anywhere in this module.
5
+ */
6
+ /** The CLI binary / application name. */
7
+ export declare const APP_NAME = "ap3x";
8
+ /** Human-facing display name used in help text and banners. */
9
+ export declare const DISPLAY_NAME = "AP3X";
10
+ /** The per-user config directory name (under the home directory). */
11
+ export declare const CONFIG_DIR_NAME = ".ap3x";
12
+ /** Environment-variable prefix for every AP3X-honored variable. */
13
+ export declare const ENV_PREFIX = "AP3X_";
14
+ /** Env var that overrides the resolved config directory wholesale. */
15
+ export declare const ENV_CONFIG_DIR = "AP3X_CONFIG_DIR";
16
+ /** The package version, sourced from the CLI package.json. */
17
+ export declare const VERSION = "0.1.0";
18
+ /** The npm package name for this CLI. */
19
+ export declare const PACKAGE = "@ap3x/cli";
20
+ /** The settings file name written inside the config directory. */
21
+ export declare const SETTINGS_FILE_NAME = "settings.json";
22
+ /** The sessions sub-directory inside the config directory. */
23
+ export declare const SESSIONS_DIR_NAME = "sessions";
24
+ /** The logs sub-directory inside the config directory. */
25
+ export declare const LOGS_DIR_NAME = "logs";
26
+ /** The skills sub-directory inside the config directory. */
27
+ export declare const SKILLS_DIR_NAME = "skills";
28
+ /** The cron-scheduler state sub-directory inside the config directory. */
29
+ export declare const CRON_DIR_NAME = "cron";
30
+ /**
31
+ * The fully-resolved AP3X config directory. Precedence:
32
+ * 1. explicit `override`
33
+ * 2. `AP3X_CONFIG_DIR` env var
34
+ * 3. `~/.ap3x`
35
+ *
36
+ * `env` is injectable so tests don't depend on the ambient process env.
37
+ */
38
+ export declare function resolveConfigDir(options?: {
39
+ override?: string;
40
+ env?: NodeJS.ProcessEnv;
41
+ home?: string;
42
+ }): string;
43
+ /** Absolute path to the settings file inside the resolved config dir. */
44
+ export declare function resolveSettingsPath(options?: {
45
+ override?: string;
46
+ env?: NodeJS.ProcessEnv;
47
+ home?: string;
48
+ }): string;
49
+ /** Absolute path to the sessions directory inside the resolved config dir. */
50
+ export declare function resolveSessionsDir(options?: {
51
+ override?: string;
52
+ env?: NodeJS.ProcessEnv;
53
+ home?: string;
54
+ }): string;
55
+ /** Absolute path to the logs directory inside the resolved config dir. */
56
+ export declare function resolveLogsDir(options?: {
57
+ override?: string;
58
+ env?: NodeJS.ProcessEnv;
59
+ home?: string;
60
+ }): string;
61
+ /** Absolute path to the skills directory inside the resolved config dir. */
62
+ export declare function resolveSkillsDir(options?: {
63
+ override?: string;
64
+ env?: NodeJS.ProcessEnv;
65
+ home?: string;
66
+ }): string;
67
+ /** Absolute path to the cron state directory inside the resolved config dir. */
68
+ export declare function resolveCronDir(options?: {
69
+ override?: string;
70
+ env?: NodeJS.ProcessEnv;
71
+ home?: string;
72
+ }): string;
73
+ /** The hooks config file name inside the config directory (and project `.ap3x/`). */
74
+ export declare const HOOKS_FILE_NAME = "hooks.json";
75
+ /** Absolute path to the user hooks file inside the resolved config dir. */
76
+ export declare function resolveHooksPath(options?: {
77
+ override?: string;
78
+ env?: NodeJS.ProcessEnv;
79
+ home?: string;
80
+ }): string;
81
+ /** The traces sub-directory inside the config directory (TraceWriter's default). */
82
+ export declare const TRACES_DIR_NAME = "traces";
83
+ /** Absolute path to the traces directory inside the resolved config dir. */
84
+ export declare function resolveTracesDir(options?: {
85
+ override?: string;
86
+ env?: NodeJS.ProcessEnv;
87
+ home?: string;
88
+ }): string;
89
+ //# sourceMappingURL=branding.d.ts.map