@ap3x/cli 0.1.0 → 0.2.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.
package/README.md CHANGED
@@ -1,33 +1,40 @@
1
1
  # @ap3x/cli
2
2
 
3
- The `ap3x` command line: an interactive coding agent with tool use, sessions, slash commands, hooks, and a durable job scheduler.
3
+ The `ap3x` command line provides interactive and single-shot coding sessions, tools, session storage, slash commands, hooks and scheduled tasks through cadence.
4
4
 
5
- Part of [AP3X](https://github.com/AP3X-Dev/AP3X) — a TypeScript multi-agent framework.
5
+ ## Run from source
6
6
 
7
- ## Install
7
+ Follow the [getting-started guide](../../docs/getting-started.md) and root [source setup](../../README.md#quick-start-from-source). From a built repository root:
8
8
 
9
9
  ```bash
10
- npm install @ap3x/cli
10
+ node packages/cli/dist/bin.js --help
11
+ node packages/cli/dist/bin.js --version
11
12
  ```
12
13
 
13
- ## Install
14
+ These informational commands were originally exercised on Windows with Node 20.18.2 and npm 11.5.1. Current setup targets Node 24.20.0 / bundled npm 11.19.0 by default and Node 22.23.2 / bundled npm 10.9.8 for compatibility. The root range `^22.23.2 || ^24.20.0` does not qualify every patch or npm combination and does not guarantee rejection of unsupported Node 20. See [Windows preflight](../../docs/plans/baseline/toolchain-preflight.md) for installed-dependency evidence; clean installation and registry artifacts remain unqualified. The [production profile](../../docs/adr/0008-supported-deployment-profile.md) remains Proposed.
15
+
16
+ ## Authenticate and run
17
+
18
+ The following paths are source-supported and were not executed for this guide. The default settings select `anthropic` and `claude-sonnet-4-5`. Supply an `ANTHROPIC_API_KEY` outside tracked files, or use the Anthropic OAuth login path:
14
19
 
15
20
  ```bash
16
- npm install -g @ap3x/cli
17
- ap3x --help
21
+ node packages/cli/dist/bin.js login --provider anthropic
22
+ node packages/cli/dist/bin.js --provider anthropic --model claude-sonnet-4-5 -p "Describe the packages in this repository"
18
23
  ```
19
24
 
20
- ## What's inside
25
+ Use `node packages/cli/dist/bin.js` for an interactive session after authentication. Choose matching provider/model identifiers with `--provider` and `--model`; a provider change alone does not ensure a valid pairing.
26
+
27
+ [Login dispatch](src/auth/login-dispatch.ts) routes `anthropic` to Anthropic OAuth, `openai-codex` to ChatGPT/Codex OAuth, and `github-copilot` to GitHub device authentication. Copilot requires an explicitly configured OAuth application client ID; the shipped placeholder is not usable credentials. For providers without OAuth configuration, login checks whether an API key resolves and does not store a new credential. These source paths are not live authentication proof.
28
+
29
+ ## Execution and scheduling boundaries
30
+
31
+ The local coding agent runs with the user's OS privileges. Its tools and optional write restrictions do not provide a qualified sandbox. Read [capabilities](../../docs/concepts/capabilities.md) and the [security architecture](../../docs/architecture/security.md) before granting tool access.
21
32
 
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`.
33
+ `ap3x cron` exposes cadence scheduling. Cadence's file store persists schedules and attempts, with claims held in process memory. Use one engine per file-store directory. Slot advancement, attempt creation and external effects are not one transaction; crash windows and retries prevent a general loss-free or exactly-once delivery claim. See the [cadence guide](../cadence/README.md) and [run concepts](../../docs/concepts/runs.md).
27
34
 
28
35
  ## Documentation
29
36
 
30
- See the [AP3X repository](https://github.com/AP3X-Dev/AP3X) for architecture notes, the full package map, and examples.
37
+ Start with [agents](../../docs/concepts/agents.md), [backends](../../docs/concepts/backends.md), [swarms](../../docs/concepts/swarms.md) and [evals](../../docs/concepts/evals.md). The [architecture overview](../../docs/architecture/overview.md) maps component ownership and current limitations.
31
38
 
32
39
  ## License
33
40
 
@@ -45,6 +45,7 @@ export interface AgentSessionOptions {
45
45
  enforceBlocklist?: boolean;
46
46
  /** A persistent session tree to record the conversation into. */
47
47
  session?: Session;
48
+ incrementalPersistence?: boolean;
48
49
  /**
49
50
  * The store {@link AgentSessionRuntime}'s lifecycle methods (new/switch/fork/
50
51
  * import) create and read sessions from. Defaults to a `JsonlSessionRepo` at
@@ -90,6 +91,7 @@ export interface AgentSessionServices {
90
91
  model: Model<string>;
91
92
  tools: AnyAgentTool[];
92
93
  session?: Session;
94
+ incrementalPersistence?: boolean;
93
95
  sessionId: string;
94
96
  /**
95
97
  * The hooks threaded into the backend, kept here (not just inside the
@@ -116,6 +118,7 @@ export declare class AgentSession {
116
118
  private readonly listeners;
117
119
  private readonly backendUnsubscribe?;
118
120
  private running;
121
+ private recorder?;
119
122
  /**
120
123
  * The LAST mid-run compaction event of the current run (a later swap's counts
121
124
  * supersede an earlier one's). Captured so persist() can record a durable
@@ -1 +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,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpC,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC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AmF;AACnF,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CAElF"}
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  main
4
- } from "./chunk-3WSVGI7R.js";
4
+ } from "./chunk-GLUT55EG.js";
5
5
 
6
6
  // src/bin.ts
7
7
  main(process.argv.slice(2)).then((code) => {
@@ -7634,6 +7634,9 @@ async function dispatchSlashCommand(line, ctx) {
7634
7634
  }
7635
7635
 
7636
7636
  // src/modes/render.ts
7637
+ import {
7638
+ runCompletion
7639
+ } from "@ap3x/agent-core";
7637
7640
  function assistantText(message) {
7638
7641
  return message.content.filter((b) => b.type === "text").map((b) => b.text).join("");
7639
7642
  }
@@ -7667,7 +7670,9 @@ function renderUsage(usage) {
7667
7670
  }
7668
7671
  function toPrintJson(result) {
7669
7672
  return {
7670
- ok: result.stopReason !== "error",
7673
+ ok: runCompletion(result).outcome === "succeeded",
7674
+ ...runCompletion(result),
7675
+ ...result.aggregateUsage ? { aggregateUsage: result.aggregateUsage } : {},
7671
7676
  finalText: result.finalText,
7672
7677
  stopReason: result.stopReason,
7673
7678
  usage: result.usage,
@@ -7744,6 +7749,7 @@ async function InteractiveMode(options) {
7744
7749
  }
7745
7750
 
7746
7751
  // src/modes/print.ts
7752
+ import { runCompletion as runCompletion2 } from "@ap3x/agent-core";
7747
7753
  async function runPrintMode(options) {
7748
7754
  const { runtime, prompt, io } = options;
7749
7755
  const format = options.format ?? "text";
@@ -7755,10 +7761,10 @@ async function runPrintMode(options) {
7755
7761
  } else {
7756
7762
  io.out(result.finalText.endsWith("\n") ? result.finalText : `${result.finalText}
7757
7763
  `);
7758
- if (options.showUsage) io.err(`${renderUsage(result.usage)}
7764
+ if (options.showUsage) io.err(`${renderUsage(result.aggregateUsage ?? result.usage)}
7759
7765
  `);
7760
7766
  }
7761
- return result.stopReason === "error" ? 1 : 0;
7767
+ return runCompletion2(result).outcome === "succeeded" ? 0 : 1;
7762
7768
  } catch (error) {
7763
7769
  const message = error instanceof Error ? error.message : String(error);
7764
7770
  if (format === "json") {
@@ -9002,6 +9008,7 @@ function withFileMutationQueue(tools) {
9002
9008
 
9003
9009
  // src/agent-session.ts
9004
9010
  import {
9011
+ SessionAttemptRecorder,
9005
9012
  SessionError as SessionError2,
9006
9013
  createRuntimeBackend,
9007
9014
  createSessionId,
@@ -9051,13 +9058,22 @@ function createAgentSessionServices(options = {}) {
9051
9058
  },
9052
9059
  ephemeral: false
9053
9060
  });
9054
- return { backend, model, tools, session: options.session, sessionId, hooks: options.hooks };
9061
+ return {
9062
+ backend,
9063
+ model,
9064
+ tools,
9065
+ session: options.session,
9066
+ sessionId,
9067
+ hooks: options.hooks,
9068
+ incrementalPersistence: options.incrementalPersistence
9069
+ };
9055
9070
  }
9056
9071
  var AgentSession = class {
9057
9072
  services;
9058
9073
  listeners = /* @__PURE__ */ new Set();
9059
9074
  backendUnsubscribe;
9060
9075
  running = false;
9076
+ recorder;
9061
9077
  /**
9062
9078
  * The LAST mid-run compaction event of the current run (a later swap's counts
9063
9079
  * supersede an earlier one's). Captured so persist() can record a durable
@@ -9071,6 +9087,7 @@ var AgentSession = class {
9071
9087
  this.services = services;
9072
9088
  if (services.backend.subscribe) {
9073
9089
  this.backendUnsubscribe = services.backend.subscribe((event) => {
9090
+ this.recorder?.observe(event);
9074
9091
  if (event.type === "compaction") this.lastCompaction = event;
9075
9092
  return this.emit({ type: "agent_event", event });
9076
9093
  });
@@ -9123,17 +9140,22 @@ var AgentSession = class {
9123
9140
  async runPrompt(prompt, opts) {
9124
9141
  this.running = true;
9125
9142
  this.lastCompaction = void 0;
9126
- await this.emit({ type: "prompt_start", prompt });
9127
9143
  try {
9144
+ if (this.services.incrementalPersistence && this.services.session)
9145
+ this.recorder = new SessionAttemptRecorder(this.services.session);
9146
+ await this.emit({ type: "prompt_start", prompt });
9128
9147
  const result = await this.services.backend.run(prompt, { signal: opts?.signal });
9129
- this.persist(result.messages);
9148
+ if (this.recorder) this.recorder.finish(result);
9149
+ else this.persist(result.messages);
9130
9150
  await this.emit({ type: "prompt_end", result });
9131
9151
  return result;
9132
9152
  } catch (error) {
9153
+ this.recorder?.fail(error);
9133
9154
  const err = error instanceof Error ? error : new Error(String(error));
9134
9155
  await this.emit({ type: "error", error: err });
9135
9156
  throw err;
9136
9157
  } finally {
9158
+ this.recorder = void 0;
9137
9159
  this.running = false;
9138
9160
  this.services.hooks?.reset?.();
9139
9161
  void this.drainQueue();
package/dist/index.js CHANGED
@@ -105,7 +105,7 @@ import {
105
105
  toPrintJson,
106
106
  welcomeBanner,
107
107
  withFileMutationQueue
108
- } from "./chunk-3WSVGI7R.js";
108
+ } from "./chunk-GLUT55EG.js";
109
109
 
110
110
  // src/utils/resume.ts
111
111
  function formatResumeCommand(sessionId) {
@@ -1 +1 @@
1
- {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../src/modes/print.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlD,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,OAAO,EAAE,mBAAmB,CAAC;IAC7B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,0CAA0C;IAC1C,EAAE,EAAE,KAAK,CAAC;IACV,sEAAsE;IACtE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B7E"}
1
+ {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../src/modes/print.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlD,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,OAAO,EAAE,mBAAmB,CAAC;IAC7B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,0CAA0C;IAC1C,EAAE,EAAE,KAAK,CAAC;IACV,sEAAsE;IACtE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B7E"}
@@ -1,4 +1,4 @@
1
- import type { AgentEvent, AgentRunResult } from "@ap3x/agent-core";
1
+ import { type AgentEvent, type AgentRunResult, type RunOutcome, type RunReasonCode } from "@ap3x/agent-core";
2
2
  import type { AssistantMessage, Usage } from "@ap3x/ai";
3
3
  /**
4
4
  * Pure projection of agent events into terminal-renderable strings. Keeping this
@@ -23,6 +23,9 @@ export interface PrintJsonResult {
23
23
  stopReason: string;
24
24
  usage: Usage;
25
25
  errorMessage?: string;
26
+ outcome?: RunOutcome;
27
+ reasonCode?: RunReasonCode;
28
+ aggregateUsage?: Usage;
26
29
  }
27
30
  /** Build the stable JSON payload for `--json` print mode. */
28
31
  export declare function toPrintJson(result: AgentRunResult): PrintJsonResult;
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/modes/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAe,KAAK,EAAE,MAAM,UAAU,CAAC;AAErE;;;;GAIG;AAEH,gFAA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tB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB;AAED,6DAA6D;AAC7D,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe,CAUnE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ap3x/cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Interactive coding-agent CLI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,12 +30,12 @@
30
30
  "test": "vitest run"
31
31
  },
32
32
  "dependencies": {
33
- "@ap3x/a2a": "2.0.0",
34
- "@ap3x/agent-core": "0.1.0",
35
- "@ap3x/ai": "0.1.0",
36
- "@ap3x/cadence": "0.1.0",
37
- "@ap3x/observe": "0.1.0",
38
- "@ap3x/swarms": "0.1.0",
33
+ "@ap3x/a2a": "2.1.0",
34
+ "@ap3x/agent-core": "0.2.0",
35
+ "@ap3x/ai": "0.2.0",
36
+ "@ap3x/cadence": "0.2.0",
37
+ "@ap3x/observe": "0.2.0",
38
+ "@ap3x/swarms": "0.2.0",
39
39
  "@ap3x/tui": "0.1.0",
40
40
  "zod": "^3.23.8"
41
41
  },