@deepraxis/cli 0.3.0-dev.fc91058 → 0.3.0-dev.ff9de03

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/COMMANDS.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Generated by `bun run commands`. DO NOT EDIT.
4
4
 
5
- 796 HTTP operations; 798 commands including aliases.
5
+ 797 HTTP operations; 799 commands including aliases.
6
6
 
7
7
  Environment: `PRAXIS_ENV=develop|production` (dev package defaults to `develop`; stable package defaults to `production`). No `--env` option.
8
8
 
@@ -16,7 +16,7 @@ Other lists use global `--limit` only for client-side display truncation, even i
16
16
 
17
17
  Every generated command below is typed after `praxis api` (the `Command` column shows the full path); the word after `api` decides the form: an uppercase HTTP method is a raw request, anything else a generated command path.
18
18
 
19
- Handwritten commands: `help [command…] [--json]`, `login`, `logout`, `whoami`, `org list`, `org switch <organization_id>`, `app create <name> [--dir <path>] [--template <dir>] [--no-install]`, `app publish [--dir <path>] [--no-build]`, `app rollback [--dir <path>] [--to <version_id>]`, `devops deploy plan [--env <name>] [--since <commit>]`, `devops engine deploy --env <develop|production> --environment-id <dve_…> [--project <dvp_…>] --commit <sha> [--targets a,b] [--plan-only] [--plan-dir <dir>] [--apply-plans <dir>] [--events-file <path>] [--engine-root <dir>] [--order callers-first]`, `devops deploy --env <develop|production> --environment-id <dve_…> [--project <dvp_…>] --commit <sha> [--targets a,b] [--plan-only] [--plan-dir <dir>] [--apply-plans <dir>] [--events-file <path>] [--engine-root <dir>] [--order callers-first]`, `devops test run --remote [--project <dvp_…>] [--no-wait] [--repeat <n>] [--select <kind:value>]`, `devops test [path…] [--size <small|medium|large|all>] [--tags <@tag…>] [--feature <title>] [--case <title>] [--e2e] [--all] [--affected [--since <commit>]] [--list] [--dry-run] [--retries <n>] [--ctrf <file>]`, `devops test report [path…] [--id <run>] [--upload [--project <dvp_…>]]`, `devops test new <file> [--e2e] [--port <n>]`, `devops test inspect <feature title> [--headed]`, `devops check [path] [--targets <a,b>]`, `devops check migrations [path]`, `devops check deprecations [path]`, `devops context [path] [--feature <topic>]`, `devops context topology [path]`, `devops context impact`, `devops context deps <path>`, `devops plan [--env <name>] [--since <commit>]`, `devops fmt [paths…] [--all]`, `devops install`, `devops build [path]`, `devops scaffold <package path>`, `devops refactor rename|check|apply`, `devops refactor rename --at <file:line:column> --to <identifier>`, `devops refactor check <digest>`, `devops refactor apply <digest>`, `devops flag sync [--check]`, `devops flag check`, `devops flag scaffold <key> [--out <dir>]`, `devops flag refs [key] [--report --project <dvp_…>]`, `devops flag remove <key>`, `devops change checkout <change>`, `canvas import <file.pen> [--name <name>] [--canvas <cvs_…> --yes] [--frames <id,id>] [--image-root <dir>] [--dry-run]`, `skill [--install <dir>]`, `completion <bash|zsh|fish>`, `api <METHOD> <path> [--data …]`.
19
+ Handwritten commands: `help [command…] [--json]`, `login`, `logout`, `whoami`, `org list`, `org switch <organization_id>`, `app create <name> [--dir <path>] [--template <dir>] [--no-install]`, `app publish [--dir <path>] [--no-build]`, `app rollback [--dir <path>] [--to <version_id>]`, `devops deploy plan [--env <name>] [--since <commit>]`, `devops engine deploy --env <develop|production> --environment-id <dve_…> [--project <dvp_…>] --commit <sha> [--targets a,b] [--plan-only] [--plan-dir <dir>] [--apply-plans <dir>] [--events-file <path>] [--engine-root <dir>] [--order callers-first]`, `devops deploy --env <develop|production> --environment-id <dve_…> [--project <dvp_…>] --commit <sha> [--targets a,b] [--plan-only] [--plan-dir <dir>] [--apply-plans <dir>] [--events-file <path>] [--engine-root <dir>] [--order callers-first]`, `devops test run --remote [--project <dvp_…>] [--no-wait] [--repeat <n>] [--select <kind:value>]`, `devops test [path…] [--size <small|medium|large|all>] [--tags <@tag…>] [--feature <title>] [--case <title>] [--e2e] [--all] [--affected [--since <commit>]] [--list] [--dry-run] [--retries <n>] [--ctrf <file>]`, `devops test report [path…] [--id <run>] [--upload [--project <dvp_…>]]`, `devops test new <file> [--e2e] [--port <n>]`, `devops test inspect <feature title> [--headed]`, `devops check [path] [--targets <a,b>]`, `devops check migrations [path]`, `devops check deprecations [path]`, `devops context [path] [--feature <topic>]`, `devops context topology [path]`, `devops context impact`, `devops context deps <path>`, `devops plan [--env <name>] [--since <commit>]`, `devops fmt [paths…] [--all]`, `devops install`, `devops build [path]`, `devops scaffold <package path>`, `devops refactor rename|check|apply`, `devops refactor rename --at <file:line:column> --to <identifier>`, `devops refactor check <digest>`, `devops refactor apply <digest>`, `devops flag sync [--check]`, `devops flag check`, `devops flag scaffold <key> [--out <dir>]`, `devops flag refs [key] [--report --project <dvp_…>]`, `devops flag remove <key>`, `devops change checkout <change>`, `agent events wait [--timeout <seconds>]`, `canvas import <file.pen> [--name <name>] [--canvas <cvs_…> --yes] [--frames <id,id>] [--image-root <dir>] [--dry-run]`, `skill [--install <dir>]`, `completion <bash|zsh|fish>`, `api <METHOD> <path> [--data …]`.
20
20
 
21
21
  | Command | SDK method | HTTP | Parameter options |
22
22
  |---|---|---|---|
@@ -68,6 +68,7 @@ Handwritten commands: `help [command…] [--json]`, `login`, `logout`, `whoami`,
68
68
  | `praxis api agent event stream` | `agent.agents.events.stream` | GET `/agent/v1/agents/{agent_id}/events/stream` | `--agent`, `--event-deltas` |
69
69
  | `praxis api agent get <agent_id>` | `agent.agents.retrieve` | GET `/agent/v1/agents/{agent_id}` | `--param-version` |
70
70
  | `praxis api agent get-appearance <agent_id>` | `agent.agents.retrieveAppearance` | GET `/agent/v1/agents/{agent_id}/appearance` | |
71
+ | `praxis api agent inbox letter list` | `agent.agents.inbox.letters.list` | GET `/agent/v1/agents/{agent_id}/inbox/letters` | `--agent`, `--unread`, `--param-limit` |
71
72
  | `praxis api agent list` | `agent.agents.list` | GET `/agent/v1/agents` | `--created-at-gte`, `--created-at-lte`, `--include-archived`, `--param-limit`, `--page`, `--kind` |
72
73
  | `praxis api agent session archive <session_id>` | `agent.sessions.archive` | POST `/agent/v1/sessions/{session_id}/archive` | |
73
74
  | `praxis api agent session artifact content-url create` | `agent.sessions.artifacts.contentUrl.create` | POST `/agent/v1/sessions/{session_id}/artifacts/{artifact_id}/content_url` | `--session`, `--artifact`, `--part`, `--ttl-seconds` |
package/dist/praxis.js CHANGED
@@ -13987,8 +13987,10 @@ var init_flag_registry_generated = __esm(() => {
13987
13987
  "delivery-rules-v2": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2048, expires: "2026-11-28", system: "devops" },
13988
13988
  "model-access-gate": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 1933, expires: "2026-12-15", system: "devops" },
13989
13989
  "open-project": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-51", ticket: 1488, expires: "2026-11-25", system: "devops" },
13990
+ "requests-never-hold": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2119, expires: "2026-11-29", system: "devops" },
13990
13991
  "requests-v1": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2057, expires: "2026-11-28", system: "devops" },
13991
13992
  "router-precommit-hedge": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2052, expires: "2026-11-28", system: "devops" },
13993
+ "router-responses-hedge": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2149, expires: "2026-11-28", system: "devops" },
13992
13994
  "search-provider-routing": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-98", ticket: 716, expires: "2026-12-31", system: "devops" },
13993
13995
  "unit-live-probe": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: null, expires: "2026-11-19", system: "devops" }
13994
13996
  };
@@ -14015,7 +14017,7 @@ function checkFlags(files, registry, today = new Date().toISOString().slice(0, 1
14015
14017
  }
14016
14018
  const registryFile = production.find((f) => f.path.endsWith("flag-registry.generated.ts"));
14017
14019
  const registryLine = (key) => registryFile ? lineOf(registryFile.text, Math.max(0, registryFile.text.indexOf(`"${key}":`))) : 1;
14018
- const add = (file, offset, message) => issues.push({ file: file.path, line: lineOf(file.text, offset), message });
14020
+ const add = (file, offset, message2) => issues.push({ file: file.path, line: lineOf(file.text, offset), message: message2 });
14019
14021
  const referencedKeysIn = (file) => {
14020
14022
  for (const key of registered) {
14021
14023
  const literal = new RegExp(`(?:"|')${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:"|')`);
@@ -14104,7 +14106,7 @@ async function main() {
14104
14106
  else
14105
14107
  console.log(`Feature flag registry check passed (${Object.keys(FLAGS).length} registered flags).`);
14106
14108
  }
14107
- var isTest = (path) => /(^|\/)(spec|__tests__)(\/|$)|\.(test|spec)\.[cm]?[jt]sx?$/.test(path), lineOf = (text2, offset) => text2.slice(0, offset).split(`
14109
+ var isTest = (path) => /(^|\/)(spec|__tests__)(\/|$)|\.(test|spec)\.[cm]?[jt]sx?$/.test(path), lineOf = (text3, offset) => text3.slice(0, offset).split(`
14108
14110
  `).length, isCalendarDate = (value) => /^\d{4}-\d{2}-\d{2}$/.test(value) && !Number.isNaN(new Date(`${value}T00:00:00.000Z`).valueOf()) && new Date(`${value}T00:00:00.000Z`).toISOString().slice(0, 10) === value;
14109
14111
  var init_check_flags = __esm(() => {
14110
14112
  init_flag_registry_generated();
@@ -14302,7 +14304,7 @@ async function checkRegistrySync(ports = {}) {
14302
14304
  }
14303
14305
  async function syncFlags(ports = {}) {
14304
14306
  const registry = ports.registry ?? registryUrl;
14305
- const write = ports.write ?? ((target, text2) => writeFile4(target, text2));
14307
+ const write = ports.write ?? ((target, text3) => writeFile4(target, text3));
14306
14308
  const log = ports.log ?? console.log;
14307
14309
  const error = ports.error ?? console.error;
14308
14310
  const devops = await (ports.devops ?? readDevopsFlags)();
@@ -14541,7 +14543,8 @@ async function runEngineDelegation(delegation, options) {
14541
14543
  // src/main.ts
14542
14544
  import { existsSync as existsSync4 } from "node:fs";
14543
14545
  import { mkdir as mkdir4, readFile as readFile7, readdir as readdir3, writeFile as writeFile5 } from "node:fs/promises";
14544
- import { resolve as resolve11 } from "node:path";
14546
+ import { dirname as dirname10, join as join12, resolve as resolve11 } from "node:path";
14547
+ import { homedir as homedir3 } from "node:os";
14545
14548
  import { pathToFileURL } from "node:url";
14546
14549
  import { createHash as createHash5 } from "node:crypto";
14547
14550
  import { spawn as spawn5 } from "node:child_process";
@@ -15599,8 +15602,8 @@ Idempotent. Access tokens revoked while the customer was blocked stay revoked; s
15599
15602
  {
15600
15603
  resource: "agent.agents.events",
15601
15604
  method: "stream",
15602
- summary: "Follow your conversation with an agent live",
15603
- description: "Follow your conversation with a personal or general agent live over Server-Sent Events: the stream of your own main session with that agent, the same stream sessions.events.stream opens, event_deltas[] previews included. {agent_id} takes the agent_… id, the eight character identity number or the handle; a service or assume agent answers 400. Closing the stream only drops your subscription and does not stop the agent; read past events with agents.events.list.",
15605
+ summary: "Follow an agent live",
15606
+ description: "Follow an agent live over Server-Sent Events. For a personal or general agent it is the stream of your own main session with that agent, the same stream sessions.events.stream opens, event_deltas[] previews included; read past events with agents.events.list. An assume agent has no main session: its body is its MCP connections, and this stream is its broadcast point, which every live connection of the agent hears at once. It carries two events, each with an SSE id: inbox.letter_delivered { letter_id, sender, sender_name, summary, thread, create_time } when a letter arrives (the letter stays unread; take it with the agent's inbox tool, the body is not in the event), and cognition.ritual_held { ritual, owner, title, engram, create_time } when a domain gives the agent a memory. Reconnect with the Last-Event-ID header to receive what you missed from a short recent buffer (about an hour); a first connection replays nothing, so read agents.inbox.letters.list for mail already waiting. {agent_id} takes the agent_… id, the eight character identity number or the handle; a service agent answers 400. Closing the stream only drops your subscription and does not stop the agent.",
15604
15607
  http: "GET",
15605
15608
  path: "/agent/v1/agents/{agent_id}/events/stream",
15606
15609
  streaming: "always",
@@ -15626,6 +15629,40 @@ Idempotent. Access tokens revoked while the customer was blocked stay revoked; s
15626
15629
  }
15627
15630
  ]
15628
15631
  },
15632
+ {
15633
+ resource: "agent.agents.inbox.letters",
15634
+ method: "list",
15635
+ summary: "List an assume agent's waiting letters",
15636
+ description: "Check whether mail waits for an assume agent without taking it: answers unread, the count of delivered letters the agent has not read, and letters, the newest unread ones (id, sender address, summary, thread, create_time; never the body). Nothing is marked read, so calling it again answers the same until the agent reads its mail with its own inbox tool (praxis_assume_inbox, action \"read\"). Use it when something outside the agent has to learn that mail arrived: the local `praxis agent events wait` reads it once on start and after every reconnect to its agent's event stream, so no letter that arrived while nothing listened is missed. {agent_id} takes the agent_… id, the eight character identity number or the handle of an assume agent in your organization; any other kind answers 400 ASSUME_AGENT_REQUIRED. To read or answer the letters, use the agent's inbox tool, not this read. Example: GET /agent/v1/agents/R1M9TQ2X/inbox/letters?unread=true&limit=5.",
15637
+ http: "GET",
15638
+ path: "/agent/v1/agents/{agent_id}/inbox/letters",
15639
+ streaming: "no",
15640
+ pagination: false,
15641
+ pathParams: [
15642
+ {
15643
+ name: "agent_id",
15644
+ sdkName: "agent_id",
15645
+ description: "The assume agent: its agent_… id, eight character identity number or handle, from agents.list or the praxis-assume MCP URL; resolved in your organization. Also accepts an 8-character identity number (0–9, A–Z); malformed, absent and foreign references return 404, and response ids always use agent_…."
15646
+ }
15647
+ ],
15648
+ query: [
15649
+ {
15650
+ name: "unread",
15651
+ type: "boolean",
15652
+ enum: [
15653
+ true
15654
+ ],
15655
+ required: false,
15656
+ description: "Only true is accepted, which is also the default; this read lists waiting (unread) letters and nothing else."
15657
+ },
15658
+ {
15659
+ name: "limit",
15660
+ type: "integer",
15661
+ required: false,
15662
+ description: "How many of the newest unread letters to return, 1 to 50 (default 20); unread always counts every waiting letter."
15663
+ }
15664
+ ]
15665
+ },
15629
15666
  {
15630
15667
  resource: "agent.agents.unarchive",
15631
15668
  method: "create",
@@ -17232,7 +17269,7 @@ Praxis extension available only on /agent/v1, following Claude Agent SDK getCont
17232
17269
  resource: "agent.sessions.events",
17233
17270
  method: "list",
17234
17271
  summary: "List session events",
17235
- description: "Read the event history of a session as a page of events, oldest first by default (order=desc for newest first). Use it after sending a message to collect the reply, to find tool calls that wait for approval or client custom tool results (session.status_idle with stop_reason requires_action lists their event_ids; a request nobody answered within 24 hours is settled as unanswered and the session goes idle with stop_reason request_expired, which the /anthropic/v1 face shows as end_turn), or to audit a run; to follow a running session live use sessions.events.stream instead. Filter by types and by a created_at range on processed_at; pages hold at most 100 events (default 20) and next_page continues. A failed run emits session.error before session.status_terminated. Native history also includes user.steer, user.withdraw, system.notification, session.forked, session.goal_changed and session.goal_verification; these are not accepted by the /anthropic/v1 event-type filter. This operation addresses one session — normally a worker session an agent dispatched; to talk to a personal or general agent itself, use agents.events.list instead. In the path, session_id may also be `main` (your own main session with that agent) or a short session name, and either alias then requires agent_id with the agent_… id, the eight character identity number or the handle; only the own face /agent/v1 accepts an alias, /anthropic/v1 requires a real sesn_… id.",
17272
+ description: "Read the event history of a session as a page of events, oldest first by default (order=desc for newest first). Use it after sending a message to collect the reply, to find tool calls that wait for approval or client custom tool results (session.status_idle with stop_reason requires_action lists their event_ids; a request nobody answered within 24 hours is settled as unanswered and the session goes idle with stop_reason request_expired, which the /anthropic/v1 face shows as end_turn), or to audit a run; to follow a running session live use sessions.events.stream instead. Filter by types and by a created_at range on processed_at; pages hold at most 100 events (default 20) and next_page continues. A failed run emits session.error before session.status_terminated. Native history also includes user.steer, user.withdraw, system.notification, system.notification_suppressed (pending background notifications that hit the wake quota and started no run), system.notification_recorded, session.forked, session.goal_changed and session.goal_verification; these are not accepted by the /anthropic/v1 event-type filter. This operation addresses one session — normally a worker session an agent dispatched; to talk to a personal or general agent itself, use agents.events.list instead. In the path, session_id may also be `main` (your own main session with that agent) or a short session name, and either alias then requires agent_id with the agent_… id, the eight character identity number or the handle; only the own face /agent/v1 accepts an alias, /anthropic/v1 requires a real sesn_… id.",
17236
17273
  http: "GET",
17237
17274
  path: "/agent/v1/sessions/{session_id}/events",
17238
17275
  streaming: "no",
@@ -29934,7 +29971,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
29934
29971
  resource: "devops.units",
29935
29972
  method: "push",
29936
29973
  summary: "Push a unit's branch",
29937
- description: "Publish the unit's local commits to the remote for the change: the machine itself holds no git credential and cannot reach the remote, so this verb is the way work done on a unit lands. ref says what to push — branch for the change's own branch, wip for this unit's own refs/praxis/wip/<change>, or a full ref name; anything else (the default branch, another change's branch, a tag, another unit's wip ref) is refused with 400 PUSH_REF_FORBIDDEN and nothing is pushed. expectedHead is the commit you believe the remote branch is at now; DevOps checks it before signing anything, and a remote that has moved since answers 409 HEAD_MOVED with nothing pushed, so fetch first when unsure, reconcile, and send the new head. For branch the call also takes a lease on that head, so the push cannot silently overwrite work that landed in between; wip is this change's own ref and is force-pushed. On success the answer is pushedSha, the commit that landed. Commit inside the machine first, through the sandbox instance API — this verb pushes commits, it does not create them. The unit must be available with a machine and a checkout, or the call answers 409 UNIT_INVALID_STATE; a push that fails inside the machine answers 500 EXECUTION_FAILED and the machine's own words are in the unit's transitions.",
29974
+ description: "Publish the unit's local commits to the remote for the change: the machine itself holds no git credential and cannot reach the remote, so this verb is the way work done on a unit lands. ref says what to push — branch for the change's own branch, wip for this unit's own refs/praxis/wip/<change>, or a full ref name; anything else (the default branch, another change's branch, a tag, another unit's wip ref) is refused with 400 PUSH_REF_FORBIDDEN and nothing is pushed. expectedHead is the commit you believe the remote branch is at now; DevOps checks it before signing anything, and a remote that has moved since answers 409 HEAD_MOVED with nothing pushed, so fetch first when unsure, reconcile, and send the new head. For branch the call also takes a lease on that head, so the push cannot silently overwrite work that landed in between; wip is this change's own ref and is force-pushed. On success the answer is pushedSha, the commit that landed. Commit inside the machine first, through the sandbox instance API — this verb pushes commits, it does not create them. The unit must be available with a machine and a checkout, or the call answers 409 UNIT_INVALID_STATE; a push that git refuses inside the machine answers with the cause in the error message and in details.detail (the last 4000 characters of git's output, credentials redacted) and details.exitCode (git's exit code): 409 PUSH_REJECTED_BY_HOOK when a pre-push hook such as lefthook rejected it, so read the hook output, fix the content and push again, 409 PUSH_REJECTED_NON_FAST_FORWARD when the remote moved ahead, so fetch and reconcile, 409 HEAD_MOVED when the lease on expectedHead no longer holds, and 500 PUSH_FAILED for anything else. Do not retry the same push unchanged.",
29938
29975
  http: "POST",
29939
29976
  path: "/devops/v1/units/{id}:push",
29940
29977
  streaming: "no",
@@ -47221,6 +47258,19 @@ var getAgentConsolidation = (options) => (options.client ?? client).get({
47221
47258
  url: "/agent/v1/agents/{agent_id}/consolidations/{consolidation_id}",
47222
47259
  ...options
47223
47260
  });
47261
+ var listAgentInboxLetters = (options) => (options.client ?? client).get({
47262
+ security: [{
47263
+ key: "BearerAuth",
47264
+ scheme: "bearer",
47265
+ type: "http"
47266
+ }, {
47267
+ key: "ApiKeyAuth",
47268
+ name: "X-API-Key",
47269
+ type: "apiKey"
47270
+ }],
47271
+ url: "/agent/v1/agents/{agent_id}/inbox/letters",
47272
+ ...options
47273
+ });
47224
47274
  var applyAgentVersion = (options) => (options.client ?? client).post({
47225
47275
  security: [{
47226
47276
  key: "BearerAuth",
@@ -58035,6 +58085,11 @@ function createAgent(transport) {
58035
58085
  send: bind(transport, sendAgentEvents),
58036
58086
  stream: bindStream(transport, streamAgentEvents)
58037
58087
  },
58088
+ inbox: {
58089
+ letters: {
58090
+ list: bind(transport, listAgentInboxLetters)
58091
+ }
58092
+ },
58038
58093
  list: bind(transport, agentsList),
58039
58094
  retrieve: bind(transport, agentsRetrieve),
58040
58095
  retrieveAppearance: bind(transport, getAgentAppearance),
@@ -61885,6 +61940,13 @@ var workflows = [
61885
61940
  platform: "praxis api devops project change create — the platform creates and names a Change; the CLI only lands its branch (ADR-125 §5).",
61886
61941
  docs: "https://docs.deepraxis.com/docs/cli"
61887
61942
  },
61943
+ {
61944
+ words: ["agent", "events", "wait"],
61945
+ usage: "agent events wait [--timeout <seconds>]",
61946
+ summary: "Wait until a new letter arrives for your assume agent (PRAXIS_ASSUME_AGENT, default R1M9TQ2X), print who wrote and how to read it, and exit 0. It first checks the waiting letters once, so mail that arrived while nothing waited is reported at once; then it follows the agent's event stream, reconnecting with backoff. Nothing is marked read. Run it as a background task in Claude Code: its exit wakes the idle session; read the mail with praxis_assume_inbox and start it again.",
61947
+ example: "PRAXIS_ASSUME_AGENT=R1M9TQ2X praxis agent events wait",
61948
+ network: "online"
61949
+ },
61888
61950
  { words: ["canvas", "import"], usage: "canvas import <file.pen> [--name <name>] [--canvas <cvs_…> --yes] [--frames <id,id>] [--image-root <dir>] [--dry-run]", summary: "Import a Pencil .pen file as a canvas, uploading the images it references first.", example: 'praxis canvas import design.pen --name "Landing page"' },
61889
61951
  { words: ["skill"], usage: "skill [--install <dir>]", summary: "Print the AI skill, or write <dir>/praxis-cli/SKILL.md." },
61890
61952
  {
@@ -69469,6 +69531,8 @@ var warningLine = (warning) => {
69469
69531
  return `${warning.code}: ${warning.ref} at ${warning.nodeId}`;
69470
69532
  case "FRAME_NOT_FOUND":
69471
69533
  return `${warning.code}: ${warning.id}`;
69534
+ case "IMAGE_FILE_NOT_FOUND":
69535
+ return `${warning.code}: ${warning.url} (the platform holds no such file) at ${warning.nodeId}`;
69472
69536
  default:
69473
69537
  return `${warning.code}: ${warning.url}`;
69474
69538
  }
@@ -69576,6 +69640,221 @@ async function canvasImport(args, ports) {
69576
69640
  return 0;
69577
69641
  }
69578
69642
 
69643
+ // src/commands/events-wait.ts
69644
+ var DEFAULT_AGENT = "R1M9TQ2X";
69645
+ var BASE_BACKOFF_MS = 1000;
69646
+ var MAX_BACKOFF_MS = 60000;
69647
+ var NOTICE_NAMED = 5;
69648
+ var ANNOUNCED_KEEP = 500;
69649
+ function assumeAgentOf(env) {
69650
+ return env.PRAXIS_ASSUME_AGENT?.trim() || DEFAULT_AGENT;
69651
+ }
69652
+ function timeoutMsOf(raw) {
69653
+ if (raw === undefined)
69654
+ return null;
69655
+ const seconds = Number(raw);
69656
+ if (!/^\d+(\.\d+)?$/.test(raw.trim()) || !Number.isFinite(seconds) || seconds <= 0)
69657
+ throw new Error("--timeout takes a positive number of seconds");
69658
+ return Math.round(seconds * 1000);
69659
+ }
69660
+ function backoffMs(failures) {
69661
+ if (failures <= 0)
69662
+ return 0;
69663
+ return Math.min(MAX_BACKOFF_MS, BASE_BACKOFF_MS * 2 ** Math.min(failures - 1, 16));
69664
+ }
69665
+ function inboxLettersUrl(apiUrl, agent) {
69666
+ return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/inbox/letters?unread=true&limit=20`;
69667
+ }
69668
+ function eventsStreamUrl(apiUrl, agent) {
69669
+ return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/events/stream`;
69670
+ }
69671
+ function streamHeaders(auth, lastEventId) {
69672
+ return { ...auth, Accept: "text/event-stream", ...lastEventId === null ? {} : { "Last-Event-ID": lastEventId } };
69673
+ }
69674
+ function lettersOf(body) {
69675
+ const value = body;
69676
+ if (!value || typeof value.unread !== "number" || !Array.isArray(value.letters))
69677
+ throw new Error("letters answer is not { unread, letters }");
69678
+ const letters = value.letters.filter((letter) => typeof letter === "object" && letter !== null && typeof letter.id === "string" && typeof letter.summary === "string");
69679
+ return { unread: value.unread, letters };
69680
+ }
69681
+ function feedSse(buffer, chunk) {
69682
+ const text2 = (buffer + chunk).replace(/\r\n?/g, `
69683
+ `);
69684
+ const blocks = text2.split(`
69685
+
69686
+ `);
69687
+ const rest = blocks.pop() ?? "";
69688
+ const frames = [];
69689
+ for (const block of blocks) {
69690
+ let event, id;
69691
+ const data = [];
69692
+ for (const line of block.split(`
69693
+ `)) {
69694
+ if (line === "" || line.startsWith(":"))
69695
+ continue;
69696
+ const colon = line.indexOf(":");
69697
+ const field = colon < 0 ? line : line.slice(0, colon);
69698
+ const value = colon < 0 ? "" : line.slice(colon + 1).replace(/^ /, "");
69699
+ if (field === "data")
69700
+ data.push(value);
69701
+ else if (field === "event")
69702
+ event = value;
69703
+ else if (field === "id")
69704
+ id = value;
69705
+ }
69706
+ if (data.length)
69707
+ frames.push({ ...event === undefined ? {} : { event }, ...id === undefined ? {} : { id }, data: data.join(`
69708
+ `) });
69709
+ }
69710
+ return { buffer: rest, frames };
69711
+ }
69712
+ var text2 = (value) => typeof value === "string" && value !== "";
69713
+ function wakeOf(frame) {
69714
+ let event;
69715
+ try {
69716
+ event = JSON.parse(frame.data);
69717
+ } catch {
69718
+ return null;
69719
+ }
69720
+ if (typeof event !== "object" || event === null)
69721
+ return null;
69722
+ if (event.type === "inbox.letter_delivered" && text2(event.letter_id) && typeof event.summary === "string")
69723
+ return { kind: "letter", letter: {
69724
+ id: event.letter_id,
69725
+ sender: typeof event.sender === "string" ? event.sender : "",
69726
+ ...text2(event.sender_name) ? { sender_name: event.sender_name } : {},
69727
+ summary: event.summary,
69728
+ thread: typeof event.thread === "string" ? event.thread : null,
69729
+ create_time: typeof event.create_time === "string" ? event.create_time : ""
69730
+ } };
69731
+ if (event.type === "cognition.ritual_held" && text2(event.title))
69732
+ return { kind: "ritual", ritual: {
69733
+ ritual: text2(event.ritual) ? event.ritual : "",
69734
+ owner: text2(event.owner) ? event.owner : "",
69735
+ title: event.title,
69736
+ engram: text2(event.engram) ? event.engram : ""
69737
+ } };
69738
+ return null;
69739
+ }
69740
+ function ritualNotice(ritual) {
69741
+ const origin = [ritual.owner, ritual.ritual].filter(Boolean).join(" 的仪式 ");
69742
+ return `你获得了一段新记忆:「${ritual.title}」${origin ? `(${origin}${ritual.engram ? `,${ritual.engram}` : ""})` : ""}。处理完再在后台运行 praxis agent events wait。`;
69743
+ }
69744
+ function retryableStatus(status) {
69745
+ return status >= 500 || status === 408 || status === 429;
69746
+ }
69747
+ function planNotice(page, announced) {
69748
+ const seen = new Set(announced);
69749
+ const fresh = page.letters.filter((letter) => !seen.has(letter.id));
69750
+ if (!fresh.length)
69751
+ return { announced };
69752
+ const named = fresh.slice(0, NOTICE_NAMED).map((letter) => `${letter.sender_name || letter.sender}:${letter.summary}(${letter.id})`);
69753
+ const more = fresh.length > NOTICE_NAMED ? `;另有 ${fresh.length - NOTICE_NAMED} 封` : "";
69754
+ const notice = `你有 ${fresh.length} 封新信:${named.join(";")}${more}。用 praxis_assume_inbox(action "read")读取并处理,处理完再在后台运行 praxis agent events wait。`;
69755
+ const next = [...announced, ...fresh.map((letter) => letter.id)];
69756
+ return { notice, announced: next.length > ANNOUNCED_KEEP ? next.slice(next.length - ANNOUNCED_KEEP) : next };
69757
+ }
69758
+ function waitStateOf(raw) {
69759
+ if (raw === null)
69760
+ return { announced: [], lastEventId: null };
69761
+ try {
69762
+ const value = JSON.parse(raw);
69763
+ return {
69764
+ announced: Array.isArray(value.announced) ? value.announced.filter((id) => typeof id === "string") : [],
69765
+ lastEventId: typeof value.last_event_id === "string" && /^\d+$/.test(value.last_event_id) ? value.last_event_id : null
69766
+ };
69767
+ } catch {
69768
+ return { announced: [], lastEventId: null };
69769
+ }
69770
+ }
69771
+ function waitStateText(state) {
69772
+ return JSON.stringify({ announced: state.announced, ...state.lastEventId === null ? {} : { last_event_id: state.lastEventId } });
69773
+ }
69774
+ var message = (error) => error instanceof Error ? error.message : String(error);
69775
+ async function runEventsWait(ports) {
69776
+ const stop = new AbortController;
69777
+ let timedOut = false;
69778
+ const timer = ports.timeoutMs === null ? undefined : setTimeout(() => {
69779
+ timedOut = true;
69780
+ stop.abort();
69781
+ }, ports.timeoutMs);
69782
+ const state = await ports.readState();
69783
+ let announced = state.announced;
69784
+ let lastEventId = state.lastEventId;
69785
+ const announceLetters = async (page) => {
69786
+ const planned = planNotice(page, announced);
69787
+ if (!planned.notice)
69788
+ return false;
69789
+ announced = planned.announced;
69790
+ await ports.writeState({ announced, lastEventId });
69791
+ ports.print(planned.notice);
69792
+ return true;
69793
+ };
69794
+ const announce = async () => announceLetters(await ports.fetchLetters());
69795
+ try {
69796
+ try {
69797
+ if (await announce())
69798
+ return 0;
69799
+ } catch (error) {
69800
+ ports.log(`praxis agent events wait: reading letters failed: ${message(error)}`);
69801
+ }
69802
+ ports.log(`praxis agent events wait: waiting for letters to assume agent ${ports.agent}`);
69803
+ let failures = 0;
69804
+ while (!stop.signal.aborted) {
69805
+ if (failures)
69806
+ await ports.sleep(backoffMs(failures), stop.signal);
69807
+ if (stop.signal.aborted)
69808
+ break;
69809
+ try {
69810
+ const opened = await ports.openStream(stop.signal, lastEventId);
69811
+ if (opened.status < 200 || opened.status >= 300 || !opened.chunks) {
69812
+ if (!retryableStatus(opened.status)) {
69813
+ ports.log(`praxis agent events wait: the event stream was refused (HTTP ${opened.status}${opened.reason ? `: ${opened.reason}` : ""})`);
69814
+ return 1;
69815
+ }
69816
+ throw new Error(`HTTP ${opened.status}`);
69817
+ }
69818
+ if (await announce())
69819
+ return 0;
69820
+ if (failures)
69821
+ ports.log("praxis agent events wait: event stream reconnected");
69822
+ failures = 0;
69823
+ let buffer = "";
69824
+ for await (const chunk of opened.chunks) {
69825
+ const fed = feedSse(buffer, chunk);
69826
+ buffer = fed.buffer;
69827
+ for (const frame of fed.frames) {
69828
+ const wake = wakeOf(frame);
69829
+ if (wake !== null && frame.id !== undefined)
69830
+ lastEventId = frame.id;
69831
+ if (wake?.kind === "letter" && await announceLetters({ unread: 1, letters: [wake.letter] }))
69832
+ return 0;
69833
+ if (wake?.kind === "ritual") {
69834
+ await ports.writeState({ announced, lastEventId });
69835
+ ports.print(ritualNotice(wake.ritual));
69836
+ return 0;
69837
+ }
69838
+ }
69839
+ }
69840
+ throw new Error("the event stream ended");
69841
+ } catch (error) {
69842
+ if (stop.signal.aborted)
69843
+ break;
69844
+ failures += 1;
69845
+ ports.log(`praxis agent events wait: ${message(error)} (${failures} in a row, reconnecting in ${backoffMs(failures) / 1000}s)`);
69846
+ }
69847
+ }
69848
+ if (timedOut)
69849
+ ports.print(`${(ports.timeoutMs ?? 0) / 1000} 秒内没有新信。需要继续等待时再在后台运行 praxis agent events wait。`);
69850
+ return 0;
69851
+ } finally {
69852
+ if (timer)
69853
+ clearTimeout(timer);
69854
+ stop.abort();
69855
+ }
69856
+ }
69857
+
69579
69858
  // src/main.ts
69580
69859
  import { spawnSync } from "node:child_process";
69581
69860
 
@@ -69693,15 +69972,15 @@ class ModelStream {
69693
69972
  finishReason = "unknown";
69694
69973
  usage;
69695
69974
  add(event) {
69696
- const data = streamData(event), message = record(data.message), response = record(data.response);
69975
+ const data = streamData(event), message2 = record(data.message), response = record(data.response);
69697
69976
  this.chunks.push(streamText(event));
69698
69977
  const choices = Array.isArray(data.choices) ? data.choices : [];
69699
- const reason2 = choices.map((c) => record(c).finish_reason).find((r) => typeof r === "string" && r) ?? record(data.delta).stop_reason ?? message.stop_reason ?? data.stop_reason ?? record(response.incomplete_details).reason ?? response.status;
69978
+ const reason2 = choices.map((c) => record(c).finish_reason).find((r) => typeof r === "string" && r) ?? record(data.delta).stop_reason ?? message2.stop_reason ?? data.stop_reason ?? record(response.incomplete_details).reason ?? response.status;
69700
69979
  if (typeof reason2 === "string" && reason2)
69701
69980
  this.finishReason = reason2;
69702
69981
  else if (["response.completed", "response.incomplete", "response.failed"].includes(String(data.type)))
69703
69982
  this.finishReason = String(data.type).slice("response.".length);
69704
- for (const usage of [message.usage, data.usage, response.usage]) {
69983
+ for (const usage of [message2.usage, data.usage, response.usage]) {
69705
69984
  if (usage !== null && typeof usage === "object" && !Array.isArray(usage))
69706
69985
  this.usage = { ...this.usage, ...record(usage) };
69707
69986
  }
@@ -69766,8 +70045,8 @@ function isSuccess(verb, ctx) {
69766
70045
  }
69767
70046
  var past = { create: "Created", update: "Updated", delete: "Deleted", remove: "Deleted", purge: "Deleted", pause: "Paused", unpause: "Unpaused", resume: "Resumed", start: "Started", stop: "Stopped", cancel: "Cancelled", enable: "Enabled", disable: "Disabled", connect: "Connected", extend: "Extended", fork: "Forked", upload: "Uploaded", run: "Started" };
69768
70047
  var deleted = (verb) => /^(delete|remove|purge)(-|$)/.test(verb);
69769
- function width(text2) {
69770
- return [...text2].reduce((sum, ch) => {
70048
+ function width(text3) {
70049
+ return [...text3].reduce((sum, ch) => {
69771
70050
  const cp = ch.codePointAt(0);
69772
70051
  return sum + (/\p{Mark}/u.test(ch) || cp === 8205 ? 0 : cp >= 4352 && (cp <= 4447 || cp >= 11904 && cp <= 42191 || cp >= 44032 && cp <= 55203 || cp >= 63744 && cp <= 64255 || cp >= 65040 && cp <= 65135 || cp >= 65281 && cp <= 65376 || cp >= 127744) ? 2 : 1);
69773
70052
  }, 0);
@@ -69775,13 +70054,13 @@ function width(text2) {
69775
70054
  function truncate(value, size) {
69776
70055
  if (width(value) <= size)
69777
70056
  return value;
69778
- let text2 = "";
70057
+ let text3 = "";
69779
70058
  for (const ch of value) {
69780
- if (width(text2 + ch) > size - 1)
70059
+ if (width(text3 + ch) > size - 1)
69781
70060
  break;
69782
- text2 += ch;
70061
+ text3 += ch;
69783
70062
  }
69784
- return text2 + "…";
70063
+ return text3 + "…";
69785
70064
  }
69786
70065
  function table(items, ctx, paint) {
69787
70066
  const columns = columnsFor(items);
@@ -69814,13 +70093,13 @@ function table(items, ctx, paint) {
69814
70093
  sizes[index]--;
69815
70094
  }
69816
70095
  const line = (row, header) => row.map((v, i) => {
69817
- const text2 = truncate(v, sizes[i]);
69818
- let styled = header ? paint.dim(text2) : text2;
70096
+ const text3 = truncate(v, sizes[i]);
70097
+ let styled = header ? paint.dim(text3) : text3;
69819
70098
  if (!header && ["status", "state"].includes(columns[i])) {
69820
70099
  const color = /^(running|active|ready|succeeded|completed|enabled)$/i.test(v) ? paint.green : /^(pending|queued|starting|creating|paused)$/i.test(v) ? paint.yellow : /^(failed|error|cancelled|expired|disabled|deleted|purging|purged|suspended)$/i.test(v) ? paint.red : (s) => s;
69821
- styled = color(text2);
70100
+ styled = color(text3);
69822
70101
  }
69823
- return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(text2))));
70102
+ return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(text3))));
69824
70103
  }).join(" ");
69825
70104
  return [line(headers, true), ...rows.map((row) => line(row, false))].join(`
69826
70105
  `) + `
@@ -69919,9 +70198,9 @@ function renderHuman(result, ctx) {
69919
70198
  }
69920
70199
 
69921
70200
  // src/output/agent.ts
69922
- function cell(text2) {
69923
- const chars = [...text2];
69924
- const limited = chars.length > 500 ? chars.slice(0, 500).join("") + `…[+${chars.length - 500} chars, use --json]` : text2;
70201
+ function cell(text3) {
70202
+ const chars = [...text3];
70203
+ const limited = chars.length > 500 ? chars.slice(0, 500).join("") + `…[+${chars.length - 500} chars, use --json]` : text3;
69925
70204
  return limited.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>").replace(/\r/g, "<br>");
69926
70205
  }
69927
70206
  function renderAgent(result, ctx) {
@@ -69932,9 +70211,9 @@ function renderAgent(result, ctx) {
69932
70211
  if (modelStream(result.op)) {
69933
70212
  if (!result.summary)
69934
70213
  return {};
69935
- const { text: text2, finish_reason, usage } = result.summary;
69936
- return { stdout: `${text2}${text2.endsWith(`
69937
- `) || !text2 ? "" : `
70214
+ const { text: text3, finish_reason, usage } = result.summary;
70215
+ return { stdout: `${text3}${text3.endsWith(`
70216
+ `) || !text3 ? "" : `
69938
70217
  `}finish_reason: ${finish_reason}
69939
70218
  ${usage ? `usage: ${JSON.stringify(usage)}
69940
70219
  ` : ""}` };
@@ -70153,18 +70432,18 @@ function errorInput(error, ctx) {
70153
70432
  const details = candidate !== null && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : undefined;
70154
70433
  const problem = serverProblem(Object.keys(nested).length ? nested : raw);
70155
70434
  const serverText = (value) => typeof value === "string" && value.trim() ? value : undefined;
70156
- let message = error instanceof Error ? error.message : "Unexpected error";
70157
- const prefix = message.match(/^([A-Z][A-Z0-9_]+):\s*/)?.[1];
70435
+ let message2 = error instanceof Error ? error.message : "Unexpected error";
70436
+ const prefix = message2.match(/^([A-Z][A-Z0-9_]+):\s*/)?.[1];
70158
70437
  const code = error instanceof UsageError ? error.code : businessCode(raw.code) ?? businessCode(nested.code) ?? businessCode(raw.error_code) ?? prefix ?? businessCode(sdk?.code) ?? (sdk?.status ? `HTTP_${sdk.status}` : sdk ? "API_ERROR" : "RUNTIME_ERROR");
70159
70438
  let stripped = false;
70160
- while (message.startsWith(`${code}:`)) {
70161
- message = message.slice(code.length + 1).trimStart();
70439
+ while (message2.startsWith(`${code}:`)) {
70440
+ message2 = message2.slice(code.length + 1).trimStart();
70162
70441
  stripped = true;
70163
70442
  }
70164
70443
  if (stripped)
70165
- message = `${humanize(code)}${message ? `: ${message}` : ""}`;
70444
+ message2 = `${humanize(code)}${message2 ? `: ${message2}` : ""}`;
70166
70445
  const status = sdk?.status, request_id = sdk?.requestId;
70167
- message = serverText(problem?.detail) ?? serverText(problem?.title) ?? message;
70446
+ message2 = serverText(problem?.detail) ?? serverText(problem?.title) ?? message2;
70168
70447
  const authFailure = status === 401 || ["NOT_LOGGED_IN", "UNAUTHENTICATED", "TOKEN_REVOKED", "LOGIN_FAILED", "MANAGED_LOGIN_EXPIRED"].includes(code);
70169
70448
  const source = ctx.credentialSource ?? "login";
70170
70449
  let hint3 = genericHint;
@@ -70182,11 +70461,11 @@ function errorInput(error, ctx) {
70182
70461
  hint3 = "Rate limited; retry later.";
70183
70462
  else if (status !== undefined && status >= 500)
70184
70463
  hint3 = `Server error; retry later.${request_id ? ` Request id: ${request_id}.` : ""}`;
70185
- return { kind: "error", code, message, hint: hint3, ...details !== undefined ? { details } : {}, ...problem !== undefined ? { problem } : {}, env: ctx.env, ...authFailure ? { credential_source: source } : {}, ...status !== undefined ? { status } : {}, ...request_id ? { request_id } : {} };
70464
+ return { kind: "error", code, message: message2, hint: hint3, ...details !== undefined ? { details } : {}, ...problem !== undefined ? { problem } : {}, env: ctx.env, ...authFailure ? { credential_source: source } : {}, ...status !== undefined ? { status } : {}, ...request_id ? { request_id } : {} };
70186
70465
  }
70187
70466
 
70188
70467
  // src/output/progress.ts
70189
- function startProgress(ctx, write = (text2) => writeOutput({ stderr: text2 })) {
70468
+ function startProgress(ctx, write = (text3) => writeOutput({ stderr: text3 })) {
70190
70469
  if (ctx.mode !== "human" || !ctx.stderrIsTTY)
70191
70470
  return () => {};
70192
70471
  let interval;
@@ -70212,7 +70491,7 @@ function startProgress(ctx, write = (text2) => writeOutput({ stderr: text2 })) {
70212
70491
  }
70213
70492
 
70214
70493
  // src/main.ts
70215
- var version = "0.3.0-dev.fc91058";
70494
+ var version = "0.3.0-dev.ff9de03";
70216
70495
  var commands = commandTree(operations);
70217
70496
  var manual = [...workflows.map((w) => w.words), [API_WORD]];
70218
70497
  function route(argv) {
@@ -70391,6 +70670,9 @@ var appOptions = {
70391
70670
  { name: "report", type: "boolean", description: "Post this checkout's scan to the platform, so archiving a flag is refused while code still names it (ADR-125 §4)." },
70392
70671
  { name: "project", type: "string", description: "With --report: the DevOps project id (dvp_…) whose flags the scan is reported into. Required." }
70393
70672
  ],
70673
+ "agent events wait": [
70674
+ { name: "timeout", type: "string", description: "Give up after this many seconds, print that nothing arrived and exit 0 (default: wait until a letter arrives)." }
70675
+ ],
70394
70676
  "canvas import": [
70395
70677
  { name: "name", type: "string", description: "Name for the new canvas (default: the file name without .pen)." },
70396
70678
  { name: "canvas", type: "string", description: "Import into this existing canvas instead of a new one. Whole-canvas replacement: it clears what is already there and requires --yes." },
@@ -70409,15 +70691,15 @@ function flagPortsFor(ports, context, emit, connect) {
70409
70691
  return {
70410
70692
  mode: context.mode,
70411
70693
  emit,
70412
- human: (text2) => {
70694
+ human: (text3) => {
70413
70695
  if (context.mode === "human")
70414
- emit({ kind: "message", channel: "stdout", text: text2 });
70696
+ emit({ kind: "message", channel: "stdout", text: text3 });
70415
70697
  },
70416
70698
  cwd: ports.cwd,
70417
70699
  readFile: ports.readFile,
70418
70700
  git: async (args) => (await ports.spawnCapture("git", [...args], { cwd: ports.cwd })).output,
70419
70701
  client: connect,
70420
- writeFile: (path, text2) => writeFile5(path, text2, "utf8"),
70702
+ writeFile: (path, text3) => writeFile5(path, text3, "utf8"),
70421
70703
  mkdir: async (path) => {
70422
70704
  await mkdir4(path, { recursive: true });
70423
70705
  },
@@ -70441,9 +70723,9 @@ function toolPortsFor(ports, context, emit) {
70441
70723
  return {
70442
70724
  mode: context.mode,
70443
70725
  emit,
70444
- human: (text2) => {
70726
+ human: (text3) => {
70445
70727
  if (context.mode === "human")
70446
- emit({ kind: "message", channel: "stdout", text: text2 });
70728
+ emit({ kind: "message", channel: "stdout", text: text3 });
70447
70729
  },
70448
70730
  cwd: ports.cwd,
70449
70731
  readFile: ports.readFile,
@@ -70753,9 +71035,9 @@ Examples:
70753
71035
  },
70754
71036
  mode: ctx.mode,
70755
71037
  emit,
70756
- human: (text2) => {
71038
+ human: (text3) => {
70757
71039
  if (ctx.mode === "human")
70758
- emit({ kind: "message", channel: "stdout", text: text2 });
71040
+ emit({ kind: "message", channel: "stdout", text: text3 });
70759
71041
  },
70760
71042
  cwd: ports.cwd
70761
71043
  });
@@ -70782,14 +71064,14 @@ Examples:
70782
71064
  }, {
70783
71065
  mode: ctx.mode,
70784
71066
  emit,
70785
- human: (text2) => {
71067
+ human: (text3) => {
70786
71068
  if (ctx.mode === "human")
70787
- emit({ kind: "message", channel: "stdout", text: text2 });
71069
+ emit({ kind: "message", channel: "stdout", text: text3 });
70788
71070
  },
70789
71071
  engine: codeRefactorEngine(),
70790
71072
  hasFile: (path2) => existsSync4(path2),
70791
71073
  readFile: ports.readFile,
70792
- writeFile: (path2, text2) => writeFile5(path2, text2, "utf8"),
71074
+ writeFile: (path2, text3) => writeFile5(path2, text3, "utf8"),
70793
71075
  mkdir: async (path2) => {
70794
71076
  await mkdir4(path2, { recursive: true });
70795
71077
  },
@@ -70806,9 +71088,9 @@ Examples:
70806
71088
  const shellPorts = {
70807
71089
  mode: ctx.mode,
70808
71090
  emit,
70809
- human: (text2) => {
71091
+ human: (text3) => {
70810
71092
  if (ctx.mode === "human")
70811
- emit({ kind: "message", channel: "stdout", text: text2 });
71093
+ emit({ kind: "message", channel: "stdout", text: text3 });
70812
71094
  },
70813
71095
  engine: await repositoryEngine(name, () => localEngine(ports.cwd)),
70814
71096
  ...localFilePorts(ports.cwd)
@@ -70821,9 +71103,9 @@ Examples:
70821
71103
  const testPorts = {
70822
71104
  mode: ctx.mode,
70823
71105
  emit,
70824
- human: (text2) => {
71106
+ human: (text3) => {
70825
71107
  if (ctx.mode === "human")
70826
- emit({ kind: "message", channel: "stdout", text: text2 });
71108
+ emit({ kind: "message", channel: "stdout", text: text3 });
70827
71109
  },
70828
71110
  engine: await repositoryEngine(name, () => localEngine(ports.cwd)),
70829
71111
  checkout: await localCheckout(ports.cwd, (cmd, args, options) => ports.spawnCapture(cmd, args, options))
@@ -70832,9 +71114,9 @@ Examples:
70832
71114
  return await devopsTestReport({ path: parsed.positional[0], id: parsed.flags.id?.[0], upload: Boolean(parsed.flags.upload), project: parsed.flags.project?.[0] }, testPorts, {
70833
71115
  mode: ctx.mode,
70834
71116
  emit,
70835
- human: (text2) => {
71117
+ human: (text3) => {
70836
71118
  if (ctx.mode === "human")
70837
- emit({ kind: "message", channel: "stdout", text: text2 });
71119
+ emit({ kind: "message", channel: "stdout", text: text3 });
70838
71120
  },
70839
71121
  root: async () => await checkoutRoot(ports.cwd, ports.readFile),
70840
71122
  readFile: ports.readFile,
@@ -70864,9 +71146,9 @@ Examples:
70864
71146
  git: (args) => ports.spawnCapture("git", args, { cwd: ports.cwd }),
70865
71147
  mode: ctx.mode,
70866
71148
  emit,
70867
- human: (text2) => {
71149
+ human: (text3) => {
70868
71150
  if (ctx.mode === "human")
70869
- emit({ kind: "message", channel: "stdout", text: text2 });
71151
+ emit({ kind: "message", channel: "stdout", text: text3 });
70870
71152
  }
70871
71153
  });
70872
71154
  }
@@ -70916,9 +71198,9 @@ Examples:
70916
71198
  emit({ kind: "object", data: await auth.switchOrganization(parsed.positional[0]) });
70917
71199
  break;
70918
71200
  case "app create": {
70919
- const appPorts = { ...ports, mode: ctx.mode, emit, human: (text2) => {
71201
+ const appPorts = { ...ports, mode: ctx.mode, emit, human: (text3) => {
70920
71202
  if (ctx.mode === "human")
70921
- emit({ kind: "message", channel: "stdout", text: text2 });
71203
+ emit({ kind: "message", channel: "stdout", text: text3 });
70922
71204
  }, random: randomSecret };
70923
71205
  await appCreate({ name: parsed.positional[0], dir: parsed.flags.dir?.[0], template: parsed.flags.template?.[0], install: !parsed.flags["no-install"] }, config.env, appPorts);
70924
71206
  break;
@@ -70947,13 +71229,72 @@ Examples:
70947
71229
  wait: ports.wait,
70948
71230
  mode: ctx.mode,
70949
71231
  emit,
70950
- human: (text2) => {
71232
+ human: (text3) => {
70951
71233
  if (ctx.mode === "human")
70952
- emit({ kind: "message", channel: "stdout", text: text2 });
71234
+ emit({ kind: "message", channel: "stdout", text: text3 });
70953
71235
  },
70954
71236
  cwd: ports.cwd
70955
71237
  });
70956
71238
  }
71239
+ case "agent events wait": {
71240
+ const agent = assumeAgentOf(ports.env);
71241
+ const timeoutMs = (() => {
71242
+ try {
71243
+ return timeoutMsOf(parsed.flags.timeout?.[0]);
71244
+ } catch (error) {
71245
+ throw new UsageError(error.message, "Example: praxis agent events wait --timeout 3600");
71246
+ }
71247
+ })();
71248
+ const headers = async () => {
71249
+ const credential = await auth.get(org);
71250
+ return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
71251
+ };
71252
+ const failure2 = (status, body) => `HTTP ${status}${body?.error?.code ? ` ${body.error.code}` : ""}${body?.error?.message ? `: ${String(redact(body.error.message, secrets))}` : ""}`;
71253
+ const statePath = join12(ports.env.HOME || homedir3(), ".praxis", "cli", "events-wait", `${config.env}-${agent.replace(/[^A-Za-z0-9_-]/g, "_")}.json`);
71254
+ return await runEventsWait({
71255
+ agent,
71256
+ timeoutMs,
71257
+ fetchLetters: async () => {
71258
+ const response = await wireFetch(inboxLettersUrl(config.apiUrl, agent), { headers: await headers(), signal: AbortSignal.timeout(30000), redirect: "error" });
71259
+ const body = await response.json().catch(() => null);
71260
+ if (!response.ok)
71261
+ throw new Error(failure2(response.status, body));
71262
+ return lettersOf(body);
71263
+ },
71264
+ openStream: async (signal, lastEventId) => {
71265
+ const response = await wireFetch(eventsStreamUrl(config.apiUrl, agent), {
71266
+ headers: streamHeaders(await headers(), lastEventId),
71267
+ signal,
71268
+ redirect: "error"
71269
+ });
71270
+ if (!response.ok || !response.body) {
71271
+ const body = await response.json().catch(() => null);
71272
+ return { status: response.status, reason: failure2(response.status, body) };
71273
+ }
71274
+ return { status: response.status, chunks: response.body.pipeThrough(new TextDecoderStream) };
71275
+ },
71276
+ readState: async () => waitStateOf(await readFile7(statePath, "utf8").catch(() => null)),
71277
+ writeState: async (next) => {
71278
+ await mkdir4(dirname10(statePath), { recursive: true, mode: 448 });
71279
+ await writeFile5(statePath, waitStateText(next), { mode: 384 });
71280
+ },
71281
+ print: (line) => {
71282
+ process.stdout.write(line + `
71283
+ `);
71284
+ },
71285
+ log: (line) => {
71286
+ process.stderr.write(String(redact(line, secrets)) + `
71287
+ `);
71288
+ },
71289
+ sleep: (ms, signal) => new Promise((resolve12) => {
71290
+ const timer = setTimeout(resolve12, ms);
71291
+ signal.addEventListener("abort", () => {
71292
+ clearTimeout(timer);
71293
+ resolve12();
71294
+ }, { once: true });
71295
+ })
71296
+ });
71297
+ }
70957
71298
  case "canvas import": {
70958
71299
  const authorize = async () => {
70959
71300
  const credential = await auth.get(org);
@@ -71009,9 +71350,9 @@ Examples:
71009
71350
  cwd: ports.cwd,
71010
71351
  rpc,
71011
71352
  upload,
71012
- human: (text2) => {
71353
+ human: (text3) => {
71013
71354
  if (ctx.mode === "human")
71014
- emit({ kind: "message", channel: "stdout", text: text2 });
71355
+ emit({ kind: "message", channel: "stdout", text: text3 });
71015
71356
  }
71016
71357
  });
71017
71358
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepraxis/cli",
3
- "version": "0.3.0-dev.fc91058",
3
+ "version": "0.3.0-dev.ff9de03",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "praxis": "dist/praxis.js"