@deepraxis/cli 0.3.0-dev.11911e3 → 0.3.0-dev.131725
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 +13 -3
- package/dist/praxis.js +1863 -150
- package/package.json +1 -1
package/dist/praxis.js
CHANGED
|
@@ -13983,9 +13983,18 @@ var FLAGS;
|
|
|
13983
13983
|
var init_flag_registry_generated = __esm(() => {
|
|
13984
13984
|
FLAGS = {
|
|
13985
13985
|
"agent-cognition-idle-wake": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "genius", ticket: 540, expires: "2026-11-30", system: "flagship" },
|
|
13986
|
+
"cognition-per-agent": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2506, expires: "2026-11-30", system: "devops" },
|
|
13986
13987
|
"cognition-weight-driven": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-bd", ticket: 1760, expires: "2026-12-05", system: "devops" },
|
|
13988
|
+
"computer-archive-volume": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2419, expires: "2026-11-30", system: "devops" },
|
|
13989
|
+
crm: { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_rv860m7z9h8szkgma56cd14n", ticket: 2179, expires: "2026-12-31", system: "devops" },
|
|
13990
|
+
"delivery-rules-v2": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2048, expires: "2026-11-28", system: "devops" },
|
|
13991
|
+
"end-users": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2312, expires: "2026-12-15", system: "devops" },
|
|
13987
13992
|
"model-access-gate": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 1933, expires: "2026-12-15", system: "devops" },
|
|
13988
13993
|
"open-project": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-51", ticket: 1488, expires: "2026-11-25", system: "devops" },
|
|
13994
|
+
"requests-never-hold": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2119, expires: "2026-11-29", system: "devops" },
|
|
13995
|
+
"requests-v1": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2057, expires: "2026-11-28", system: "devops" },
|
|
13996
|
+
"router-precommit-hedge": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2052, expires: "2026-11-28", system: "devops" },
|
|
13997
|
+
"router-responses-hedge": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2149, expires: "2026-11-28", system: "devops" },
|
|
13989
13998
|
"search-provider-routing": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-98", ticket: 716, expires: "2026-12-31", system: "devops" },
|
|
13990
13999
|
"unit-live-probe": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: null, expires: "2026-11-19", system: "devops" }
|
|
13991
14000
|
};
|
|
@@ -14012,7 +14021,7 @@ function checkFlags(files, registry, today = new Date().toISOString().slice(0, 1
|
|
|
14012
14021
|
}
|
|
14013
14022
|
const registryFile = production.find((f) => f.path.endsWith("flag-registry.generated.ts"));
|
|
14014
14023
|
const registryLine = (key) => registryFile ? lineOf(registryFile.text, Math.max(0, registryFile.text.indexOf(`"${key}":`))) : 1;
|
|
14015
|
-
const add = (file, offset,
|
|
14024
|
+
const add = (file, offset, message2) => issues.push({ file: file.path, line: lineOf(file.text, offset), message: message2 });
|
|
14016
14025
|
const referencedKeysIn = (file) => {
|
|
14017
14026
|
for (const key of registered) {
|
|
14018
14027
|
const literal = new RegExp(`(?:"|')${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:"|')`);
|
|
@@ -14031,6 +14040,8 @@ function checkFlags(files, registry, today = new Date().toISOString().slice(0, 1
|
|
|
14031
14040
|
add(f, browserList.index + entry.index, `unregistered browser flag key "${entry[1]}"`);
|
|
14032
14041
|
}
|
|
14033
14042
|
}
|
|
14043
|
+
if (/\.generated\.[cm]?[jt]sx?$/.test(f.path))
|
|
14044
|
+
continue;
|
|
14034
14045
|
const calls = /(\.bool|\breadBrowserFlag|\buseBrowserFlag)\s*\(\s*([^,)\n]+)/g;
|
|
14035
14046
|
for (const m of f.text.matchAll(calls)) {
|
|
14036
14047
|
if (/function\s*$/.test(f.text.slice(Math.max(0, m.index - 20), m.index)))
|
|
@@ -14099,7 +14110,7 @@ async function main() {
|
|
|
14099
14110
|
else
|
|
14100
14111
|
console.log(`Feature flag registry check passed (${Object.keys(FLAGS).length} registered flags).`);
|
|
14101
14112
|
}
|
|
14102
|
-
var isTest = (path) => /(^|\/)(spec|__tests__)(\/|$)|\.(test|spec)\.[cm]?[jt]sx?$/.test(path), lineOf = (
|
|
14113
|
+
var isTest = (path) => /(^|\/)(spec|__tests__)(\/|$)|\.(test|spec)\.[cm]?[jt]sx?$/.test(path), lineOf = (text3, offset) => text3.slice(0, offset).split(`
|
|
14103
14114
|
`).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;
|
|
14104
14115
|
var init_check_flags = __esm(() => {
|
|
14105
14116
|
init_flag_registry_generated();
|
|
@@ -14297,7 +14308,7 @@ async function checkRegistrySync(ports = {}) {
|
|
|
14297
14308
|
}
|
|
14298
14309
|
async function syncFlags(ports = {}) {
|
|
14299
14310
|
const registry = ports.registry ?? registryUrl;
|
|
14300
|
-
const write = ports.write ?? ((target,
|
|
14311
|
+
const write = ports.write ?? ((target, text3) => writeFile4(target, text3));
|
|
14301
14312
|
const log = ports.log ?? console.log;
|
|
14302
14313
|
const error = ports.error ?? console.error;
|
|
14303
14314
|
const devops = await (ports.devops ?? readDevopsFlags)();
|
|
@@ -14534,12 +14545,13 @@ async function runEngineDelegation(delegation, options) {
|
|
|
14534
14545
|
}
|
|
14535
14546
|
|
|
14536
14547
|
// src/main.ts
|
|
14537
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
14548
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, unlinkSync } from "node:fs";
|
|
14538
14549
|
import { mkdir as mkdir4, readFile as readFile7, readdir as readdir3, writeFile as writeFile5 } from "node:fs/promises";
|
|
14539
|
-
import { resolve as resolve11 } from "node:path";
|
|
14550
|
+
import { dirname as dirname10, join as join12, resolve as resolve11 } from "node:path";
|
|
14551
|
+
import { homedir as homedir3 } from "node:os";
|
|
14540
14552
|
import { pathToFileURL } from "node:url";
|
|
14541
14553
|
import { createHash as createHash5 } from "node:crypto";
|
|
14542
|
-
import { spawn as
|
|
14554
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
14543
14555
|
import { createInterface } from "node:readline";
|
|
14544
14556
|
|
|
14545
14557
|
// ../../packages/sdk/typescript/src/operations.generated.ts
|
|
@@ -15594,8 +15606,8 @@ Idempotent. Access tokens revoked while the customer was blocked stay revoked; s
|
|
|
15594
15606
|
{
|
|
15595
15607
|
resource: "agent.agents.events",
|
|
15596
15608
|
method: "stream",
|
|
15597
|
-
summary: "Follow
|
|
15598
|
-
description: "Follow
|
|
15609
|
+
summary: "Follow an agent live",
|
|
15610
|
+
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.",
|
|
15599
15611
|
http: "GET",
|
|
15600
15612
|
path: "/agent/v1/agents/{agent_id}/events/stream",
|
|
15601
15613
|
streaming: "always",
|
|
@@ -15621,6 +15633,40 @@ Idempotent. Access tokens revoked while the customer was blocked stay revoked; s
|
|
|
15621
15633
|
}
|
|
15622
15634
|
]
|
|
15623
15635
|
},
|
|
15636
|
+
{
|
|
15637
|
+
resource: "agent.agents.inbox.letters",
|
|
15638
|
+
method: "list",
|
|
15639
|
+
summary: "List an assume agent's waiting letters",
|
|
15640
|
+
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.",
|
|
15641
|
+
http: "GET",
|
|
15642
|
+
path: "/agent/v1/agents/{agent_id}/inbox/letters",
|
|
15643
|
+
streaming: "no",
|
|
15644
|
+
pagination: false,
|
|
15645
|
+
pathParams: [
|
|
15646
|
+
{
|
|
15647
|
+
name: "agent_id",
|
|
15648
|
+
sdkName: "agent_id",
|
|
15649
|
+
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_…."
|
|
15650
|
+
}
|
|
15651
|
+
],
|
|
15652
|
+
query: [
|
|
15653
|
+
{
|
|
15654
|
+
name: "unread",
|
|
15655
|
+
type: "boolean",
|
|
15656
|
+
enum: [
|
|
15657
|
+
true
|
|
15658
|
+
],
|
|
15659
|
+
required: false,
|
|
15660
|
+
description: "Only true is accepted, which is also the default; this read lists waiting (unread) letters and nothing else."
|
|
15661
|
+
},
|
|
15662
|
+
{
|
|
15663
|
+
name: "limit",
|
|
15664
|
+
type: "integer",
|
|
15665
|
+
required: false,
|
|
15666
|
+
description: "How many of the newest unread letters to return, 1 to 50 (default 20); unread always counts every waiting letter."
|
|
15667
|
+
}
|
|
15668
|
+
]
|
|
15669
|
+
},
|
|
15624
15670
|
{
|
|
15625
15671
|
resource: "agent.agents.unarchive",
|
|
15626
15672
|
method: "create",
|
|
@@ -15983,18 +16029,14 @@ Praxis extension: the preview conversion endpoint. The browser never parses an u
|
|
|
15983
16029
|
description: "Computer id (cmp_...), as returned by computers.create or computers.list."
|
|
15984
16030
|
}
|
|
15985
16031
|
],
|
|
15986
|
-
query: [
|
|
15987
|
-
|
|
15988
|
-
|
|
15989
|
-
|
|
15990
|
-
|
|
15991
|
-
|
|
15992
|
-
|
|
15993
|
-
|
|
15994
|
-
description: "Name of the entry or object."
|
|
15995
|
-
}
|
|
15996
|
-
]
|
|
15997
|
-
}
|
|
16032
|
+
query: [
|
|
16033
|
+
{
|
|
16034
|
+
name: "path",
|
|
16035
|
+
type: "string",
|
|
16036
|
+
required: true,
|
|
16037
|
+
description: "Absolute path of the document on the computer, for example /home/user/workspace/deck.pptx. The request has no body."
|
|
16038
|
+
}
|
|
16039
|
+
]
|
|
15998
16040
|
},
|
|
15999
16041
|
{
|
|
16000
16042
|
resource: "agent.computers.leases",
|
|
@@ -16986,6 +17028,68 @@ delete it. Omit the field to preserve.`
|
|
|
16986
17028
|
],
|
|
16987
17029
|
query: []
|
|
16988
17030
|
},
|
|
17031
|
+
{
|
|
17032
|
+
resource: "agent.sessions.artifacts",
|
|
17033
|
+
method: "list",
|
|
17034
|
+
summary: "List Session Artifacts (Extension)",
|
|
17035
|
+
description: `List the files this session delivered; an end-customer token reads its own session.
|
|
17036
|
+
|
|
17037
|
+
Own-face extension. Returns { data: Artifact[] } ordered by create_time. Each artifact is one file in the session outputs directory, or one canvas or media asset the reply pointed at (a part with kind object carrying object_type, object_id and href; one artifact per object, pointing at it again adds no version), with id, name, version, parts, source_hrefs, create_time and update_time. Delivering the same path again keeps the id and adds one to version. Files are captured seconds after the turn ends, so artifacts appear after session.status_idle; also watch the agent.artifact_delivered event. Whoever may read the session may read its artifacts; a session that is missing or not yours returns 404.`,
|
|
17038
|
+
http: "GET",
|
|
17039
|
+
path: "/agent/v1/sessions/{session_id}/artifacts",
|
|
17040
|
+
streaming: "no",
|
|
17041
|
+
pagination: false,
|
|
17042
|
+
pathParams: [
|
|
17043
|
+
{
|
|
17044
|
+
name: "session_id",
|
|
17045
|
+
sdkName: "session_id",
|
|
17046
|
+
description: "Session id from session creation or listing."
|
|
17047
|
+
}
|
|
17048
|
+
],
|
|
17049
|
+
query: []
|
|
17050
|
+
},
|
|
17051
|
+
{
|
|
17052
|
+
resource: "agent.sessions.artifacts.contentUrl",
|
|
17053
|
+
method: "create",
|
|
17054
|
+
summary: "Create Artifact Content URL (Extension)",
|
|
17055
|
+
description: `Mint a short-lived download address for one file of an artifact.
|
|
17056
|
+
|
|
17057
|
+
Own-face extension. The body is optional: part (index into the artifact parts, default 0) and ttl_seconds (60 to 300, default 300). Returns { url, expire_time }. The address works for minutes; do not store or log it. For an object part the address serves a snapshot picture of a canvas or the own bytes of the asset; an object that no longer exists returns 404 ARTIFACT_NOT_FOUND and a failing share service returns 502. An unknown artifact or an out-of-range part returns 404 ARTIFACT_NOT_FOUND, a session that is missing or not yours returns 404, and a ttl_seconds outside 60 to 300 returns 400.`,
|
|
17058
|
+
http: "POST",
|
|
17059
|
+
path: "/agent/v1/sessions/{session_id}/artifacts/{artifact_id}/content_url",
|
|
17060
|
+
streaming: "no",
|
|
17061
|
+
pagination: false,
|
|
17062
|
+
pathParams: [
|
|
17063
|
+
{
|
|
17064
|
+
name: "session_id",
|
|
17065
|
+
sdkName: "session_id",
|
|
17066
|
+
description: "Session id from session creation or listing."
|
|
17067
|
+
},
|
|
17068
|
+
{
|
|
17069
|
+
name: "artifact_id",
|
|
17070
|
+
sdkName: "artifact_id",
|
|
17071
|
+
description: "Artifact id (art_...) from the artifact list or an agent.artifact_delivered event."
|
|
17072
|
+
}
|
|
17073
|
+
],
|
|
17074
|
+
query: [],
|
|
17075
|
+
body: {
|
|
17076
|
+
required: false,
|
|
17077
|
+
fields: [
|
|
17078
|
+
{
|
|
17079
|
+
name: "part",
|
|
17080
|
+
type: "integer",
|
|
17081
|
+
required: false,
|
|
17082
|
+
description: "Index into the artifact's parts; defaults to 0."
|
|
17083
|
+
},
|
|
17084
|
+
{
|
|
17085
|
+
name: "ttl_seconds",
|
|
17086
|
+
type: "integer",
|
|
17087
|
+
required: false,
|
|
17088
|
+
description: "How long the address works, 60 to 300 seconds; defaults to 300."
|
|
17089
|
+
}
|
|
17090
|
+
]
|
|
17091
|
+
}
|
|
17092
|
+
},
|
|
16989
17093
|
{
|
|
16990
17094
|
resource: "agent.sessions.backgroundTasks",
|
|
16991
17095
|
method: "list",
|
|
@@ -17169,7 +17273,7 @@ Praxis extension available only on /agent/v1, following Claude Agent SDK getCont
|
|
|
17169
17273
|
resource: "agent.sessions.events",
|
|
17170
17274
|
method: "list",
|
|
17171
17275
|
summary: "List session events",
|
|
17172
|
-
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), 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.",
|
|
17276
|
+
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.",
|
|
17173
17277
|
http: "GET",
|
|
17174
17278
|
path: "/agent/v1/sessions/{session_id}/events",
|
|
17175
17279
|
streaming: "no",
|
|
@@ -17328,6 +17432,26 @@ Available only on /agent/v1. Use the message_id field from own-face events, not
|
|
|
17328
17432
|
]
|
|
17329
17433
|
}
|
|
17330
17434
|
},
|
|
17435
|
+
{
|
|
17436
|
+
resource: "agent.sessions.requests",
|
|
17437
|
+
method: "list",
|
|
17438
|
+
summary: "List Session Requests (Extension)",
|
|
17439
|
+
description: `List the requests a session is waiting on; an end-customer token reads its own session.
|
|
17440
|
+
|
|
17441
|
+
Own-face extension. When a session stops at session.status_idle with stop_reason requires_action, read what it waits on here instead of replaying events. Returns { data: Request[] } ordered by create_time, an empty array when nothing is pending, not paginated. Each request has id (the pending tool call id), object (request), kind (question for the ask_user_question tool, approval for any other tool that waits for permission), status (pending), tool_name, input (the same input the agent.tool_use event shows), create_time and expire_time. Answer a request as before: send a user.tool_confirmation event for its id. expire_time is set only for a session with no collaboration mode while the requests-v1 release is on (create_time plus 24 hours; an expired request counts as declined), otherwise null. Answered, expired and superseded requests are not listed, and neither are pending custom tool results (user.custom_tool_result). Whoever may read the session may read its requests; a session that is missing or not yours returns 404.`,
|
|
17442
|
+
http: "GET",
|
|
17443
|
+
path: "/agent/v1/sessions/{session_id}/requests",
|
|
17444
|
+
streaming: "no",
|
|
17445
|
+
pagination: false,
|
|
17446
|
+
pathParams: [
|
|
17447
|
+
{
|
|
17448
|
+
name: "session_id",
|
|
17449
|
+
sdkName: "session_id",
|
|
17450
|
+
description: "Session id from session creation or listing."
|
|
17451
|
+
}
|
|
17452
|
+
],
|
|
17453
|
+
query: []
|
|
17454
|
+
},
|
|
17331
17455
|
{
|
|
17332
17456
|
resource: "agent.sessions.resources",
|
|
17333
17457
|
method: "list",
|
|
@@ -25380,6 +25504,12 @@ Published at https://docs.deepraxis.com/docs/developers/cut/script-reference wit
|
|
|
25380
25504
|
- \`RippleDeleteRange\` — Cut a time range and close the gap.
|
|
25381
25505
|
- \`DeleteWords\` — Cut transcript words and ripple every track, keeping a breath.
|
|
25382
25506
|
- \`RemoveFillers\` — List and delete filler words by media's own labels; dryRun first.
|
|
25507
|
+
- \`Matte\` — Replace the clip's background with media's matte of its source, read as a luma mask.
|
|
25508
|
+
- \`EnhanceVoice\` — Replace a clip's sound with media's enhanced speech on its own audio track.
|
|
25509
|
+
- \`AlignByAudio\` — Line two recordings of the same sound up by media's measurement of their offset.
|
|
25510
|
+
- \`Reframe\` — Swap the clip's media for media's reframed take at the aspect you ask for.
|
|
25511
|
+
- \`Upscale\` — Swap the clip's media for media's upscaled take at the height you ask for.
|
|
25512
|
+
- \`Redact\` — Pixelate the faces, QR codes or text media marks, leaving the rest of the frame plain.
|
|
25383
25513
|
- \`AddTrack\` — Add a video, audio or caption track.
|
|
25384
25514
|
- \`MoveTrack\` — Move a track between layers; 0 is the topmost.
|
|
25385
25515
|
- \`UpdateTrack\` — Change a track's name, lock, gain or role.
|
|
@@ -25483,6 +25613,9 @@ Published at https://docs.deepraxis.com/docs/developers/cut/script-reference wit
|
|
|
25483
25613
|
- \`MEDIA_OFFLINE\` — The asset cannot be fetched right now.
|
|
25484
25614
|
- \`MEDIA_UNAVAILABLE\` — The asset is not usable for rendering.
|
|
25485
25615
|
- \`MEDIA_IMPORT_FAILED\` — Importing media failed.
|
|
25616
|
+
- \`MEDIA_PROCESSING\` — Media is still processing the clip; wait for the job and rerun.
|
|
25617
|
+
- \`MEDIA_PROCESSING_FAILED\` — Media's processing job failed; nothing changed.
|
|
25618
|
+
- \`ALIGNMENT_UNCERTAIN\` — \`AlignByAudio\` confidence too low; nothing changed.
|
|
25486
25619
|
- \`FRAME_OUT_OF_RANGE\` — The preview time is outside the project.
|
|
25487
25620
|
- \`PROJECT_TOO_LARGE\` — The project exceeds the size limit.
|
|
25488
25621
|
- \`RESPONSE_TOO_LARGE\` — The response would exceed its budget.
|
|
@@ -27006,7 +27139,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
27006
27139
|
resource: "devops.flags",
|
|
27007
27140
|
method: "archive",
|
|
27008
27141
|
summary: "Archive a flag",
|
|
27009
|
-
description: "Archive a flag whose code is gone: it stops evaluating in every environment, leaves the ordinary flag list and keeps its key and history. Archiving
|
|
27142
|
+
description: "Archive a flag whose code is gone: it stops evaluating in every environment, leaves the ordinary flag list and keeps its key and history. Archiving is the delete, and the platform refuses it while the last reported scan still finds the key in code or while the flag is on in an environment: a flag whose codeRefs.count is above zero is refused with FLAG_STILL_REFERENCED, and a flag whose on state is true in any environment is refused with FLAG_HAS_LIVE_RULES, so archiving succeeds only once the code that names the key is deployed away and every environment is off. The gate reads the stored scan as it stands — an out-of-date scannedCommit is not corrected for — and there is no force flag. It is irreversible through the API: there is no unarchive call, an archived flag cannot be updated or configured, and its key stays reserved, so a later create with the same key is refused; archiving an archived flag just answers it again. A flag that may come back is turned off in its environment instead. The order is: open the flag fully (`praxis api devops flag environment update`), delete the code that names the key and deploy that, run `praxis devops flag remove <key>` (local, lists the references still naming the key), then `praxis api devops flag archive <id>`, then `praxis devops flag sync` so the local registry drops it. There is no separate delete call.",
|
|
27010
27143
|
http: "POST",
|
|
27011
27144
|
path: "/devops/v1/flags/{id}:archive",
|
|
27012
27145
|
streaming: "no",
|
|
@@ -27870,6 +28003,42 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
27870
28003
|
}
|
|
27871
28004
|
}
|
|
27872
28005
|
},
|
|
28006
|
+
{
|
|
28007
|
+
resource: "devops.projects.flags",
|
|
28008
|
+
method: "reportCodeRefs",
|
|
28009
|
+
summary: "Report a project's flag code references",
|
|
28010
|
+
description: "Store one code-reference scan for a project in a single call: send the commit the scan read (scannedCommit, the checkout's `git rev-parse HEAD`) and, for every flag key the scan knows, the places code reads it ({path, line, snippet}). Send every key the checkout still expects to be referenced, including the ones found nowhere: a project flag with no entry in refs is stored with zero references, and zero is what lets `archive` see the code that named the flag is gone. A key that matches no live flag of the project — one already archived, or from another project — is returned in unknownKeys and stores nothing; reporting it is not an error. updated is how many flags were written, which is every live flag of the project because each gets a row. This is the write side of the archive gate: `POST /v1/flags/{id}:archive` refuses with FLAG_STILL_REFERENCED while the stored count is above zero, and the count it reads is exactly the one stored here. Staleness is not corrected for — the stored scannedCommit and count are used as they stand. At most 500 references are stored per flag; a longer list is truncated for storage while count still reports the true number. Reporting changes no flag's runtime behaviour.",
|
|
28011
|
+
http: "POST",
|
|
28012
|
+
path: "/devops/v1/projects/{project}/flags/code-refs",
|
|
28013
|
+
streaming: "no",
|
|
28014
|
+
pagination: false,
|
|
28015
|
+
pathParams: [
|
|
28016
|
+
{
|
|
28017
|
+
name: "project",
|
|
28018
|
+
sdkName: "project",
|
|
28019
|
+
description: "Identifies the project whose data you are reading, from the project list or create answer."
|
|
28020
|
+
}
|
|
28021
|
+
],
|
|
28022
|
+
query: [],
|
|
28023
|
+
body: {
|
|
28024
|
+
required: true,
|
|
28025
|
+
fields: [
|
|
28026
|
+
{
|
|
28027
|
+
name: "scannedCommit",
|
|
28028
|
+
type: "string",
|
|
28029
|
+
required: true,
|
|
28030
|
+
description: "The commit this scan read, from `git rev-parse HEAD` in the reporting checkout; it is stored as each flag's codeRefs.scannedCommit, so a value older than the current head means the count describes the code as it was then."
|
|
28031
|
+
},
|
|
28032
|
+
{
|
|
28033
|
+
name: "refs",
|
|
28034
|
+
type: "array",
|
|
28035
|
+
itemType: "object",
|
|
28036
|
+
required: true,
|
|
28037
|
+
description: "One entry per flag key this scan judged. Send every key the checkout still expects to be referenced, including the ones found nowhere: a project flag with no entry here is stored with zero references, which is what later lets `archive` refuse only flags code still names."
|
|
28038
|
+
}
|
|
28039
|
+
]
|
|
28040
|
+
}
|
|
28041
|
+
},
|
|
27873
28042
|
{
|
|
27874
28043
|
resource: "devops.projects.promotions",
|
|
27875
28044
|
method: "list",
|
|
@@ -29806,7 +29975,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
29806
29975
|
resource: "devops.units",
|
|
29807
29976
|
method: "push",
|
|
29808
29977
|
summary: "Push a unit's branch",
|
|
29809
|
-
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
|
|
29978
|
+
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.",
|
|
29810
29979
|
http: "POST",
|
|
29811
29980
|
path: "/devops/v1/units/{id}:push",
|
|
29812
29981
|
streaming: "no",
|
|
@@ -30142,7 +30311,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
30142
30311
|
resource: "file.uploads",
|
|
30143
30312
|
method: "createSigned",
|
|
30144
30313
|
summary: "Create a one-time upload URL",
|
|
30145
|
-
description: "Upload a local file of up to 20 GiB from a coding agent without sending bytes through the model. Provide filename (the stored basename), exact byte count and MIME type. Up to 104857600 bytes, PUT the file to url with curl -T photo.png -H 'Content-Type: image/png' '<url>'; success returns 201 with the file object, and reuse returns 410 CAPABILITY_USED. Above that threshold, split the file into part_size chunks (default 64000000 bytes) and PUT each chunk to its numbered parts[].url in any order; an interrupted client GETs status_url to see the received parts and resends only what is missing, then POSTs complete_url without a body. Part PUTs return 200; completion returns 201 with the file object, including its state, or 400 if a part is missing. A processing file can be polled with files.retrieve until active. Identical part bytes may be retried; changed bytes at the same number return 400. Completion reuse returns 410 CAPABILITY_USED. Each PUT requires the exact signed Content-Length; single-PUT Content-Type must match content_type or be omitted. Expired, revoked, invalid
|
|
30314
|
+
description: "Upload a local file of up to 20 GiB from a coding agent without sending bytes through the model. Provide filename (the stored basename), exact byte count and MIME type. Up to 104857600 bytes, PUT the file to url with curl -T photo.png -H 'Content-Type: image/png' '<url>'; success returns 201 with the file object, and reuse returns 410 CAPABILITY_USED. Above that threshold, split the file into part_size chunks (default 64000000 bytes) and PUT each chunk to its numbered parts[].url in any order; an interrupted client GETs status_url to see the received parts and resends only what is missing, then POSTs complete_url without a body. Part PUTs return 200; completion returns 201 with the file object, including its state, or 400 if a part is missing. A processing file can be polled with files.retrieve until active. Identical part bytes may be retried; changed bytes at the same number return 400. Completion reuse returns 410 CAPABILITY_USED. Each PUT requires the exact signed Content-Length; single-PUT Content-Type must match content_type or be omitted. Expired, revoked, invalid or cross-organization URLs return 404, and so does a link whose upload record no longer exists. A URL that is authentic but names another action returns 403 CAPABILITY_MISMATCH: a status link posted to complete_url answers it, and so does a completion link fetched as status_url. URL lifetime defaults to 900 seconds for single PUT or 604800 (7 days) for multipart, at most 604800; all multipart URLs, including status_url, share an expiry. Multipart creation reserves storage quota. Issuance requires the same unscoped credential as direct file creation. Each issuance creates a new upload and is not idempotent. Example body: {\"filename\":\"photo.png\",\"bytes\":2048,\"content_type\":\"image/png\"}.",
|
|
30146
30315
|
http: "POST",
|
|
30147
30316
|
path: "/file/v1/uploads/signed",
|
|
30148
30317
|
streaming: "no",
|
|
@@ -31712,11 +31881,57 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
31712
31881
|
]
|
|
31713
31882
|
}
|
|
31714
31883
|
},
|
|
31884
|
+
{
|
|
31885
|
+
resource: "media.libraries.assets.align",
|
|
31886
|
+
method: "create",
|
|
31887
|
+
summary: "Align asset",
|
|
31888
|
+
description: "Align two recordings by their sound and learn how they line up, without producing an asset. The route names the source asset; the body names the reference to compare against it. Both must be audio or a video, of the same library; anything else is refused with REFERENCE_TYPE_MISMATCH before a job exists. The call is an analysis: it decides and charges nothing else, bills per second of input, and stores no asset — the completed job carries the answer in result, offset_seconds saying how many seconds later the reference starts (so a caller holding both recordings knows which one to slide) and confidence how sure the correlation is. The analysis is idempotent on the source, the reference and the parameters: asking again with the same pair answers the completed job and its result instead of analysing and charging again. A max_offset_seconds caps how far apart the two may be; alignment needs an alignment model from the platform model catalogue, and with none published the request is refused with OPERATION_NOT_SUPPORTED, 尚未上架. Send Idempotency-Key, or idempotency_key in the body, to retry without analysing twice. The response is 202 with a queued Job whose operation is align; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until it is completed or failed, then read result. Example: POST /media/v1/libraries/lib_example/assets/9dfa312ef9bc4b00816339b598b1152c/align with {\"reference_asset_id\":\"3f2a9c1e5b7d4e6f8a0b1c2d3e4f5a6b\",\"max_offset_seconds\":30}.",
|
|
31889
|
+
http: "POST",
|
|
31890
|
+
path: "/media/v1/libraries/{library_id}/assets/{asset_id}/align",
|
|
31891
|
+
streaming: "no",
|
|
31892
|
+
pagination: false,
|
|
31893
|
+
pathParams: [
|
|
31894
|
+
{
|
|
31895
|
+
name: "library_id",
|
|
31896
|
+
sdkName: "library_id",
|
|
31897
|
+
description: "Library ID returned by creation."
|
|
31898
|
+
},
|
|
31899
|
+
{
|
|
31900
|
+
name: "asset_id",
|
|
31901
|
+
sdkName: "asset_id",
|
|
31902
|
+
description: "32-character asset ID."
|
|
31903
|
+
}
|
|
31904
|
+
],
|
|
31905
|
+
query: [],
|
|
31906
|
+
body: {
|
|
31907
|
+
required: true,
|
|
31908
|
+
fields: [
|
|
31909
|
+
{
|
|
31910
|
+
name: "reference_asset_id",
|
|
31911
|
+
type: "string",
|
|
31912
|
+
required: true,
|
|
31913
|
+
description: "Asset to align against the one the route names. It must be an audio or video asset of the same library, otherwise the request is refused with REFERENCE_TYPE_MISMATCH before a job exists."
|
|
31914
|
+
},
|
|
31915
|
+
{
|
|
31916
|
+
name: "max_offset_seconds",
|
|
31917
|
+
type: "number",
|
|
31918
|
+
required: false,
|
|
31919
|
+
description: "Largest offset to search for, in seconds; omit it to let the model search its full range. Zero and negative values are refused with INVALID_PARAMS."
|
|
31920
|
+
},
|
|
31921
|
+
{
|
|
31922
|
+
name: "idempotency_key",
|
|
31923
|
+
type: "string",
|
|
31924
|
+
required: false,
|
|
31925
|
+
description: "Stable key so a retried request reuses the same job instead of analysing and charging again; reusing it with different content is rejected."
|
|
31926
|
+
}
|
|
31927
|
+
]
|
|
31928
|
+
}
|
|
31929
|
+
},
|
|
31715
31930
|
{
|
|
31716
31931
|
resource: "media.assets",
|
|
31717
31932
|
method: "edit",
|
|
31718
31933
|
summary: "Edit asset",
|
|
31719
|
-
description: "Edit an existing asset and store the result as a new asset. Use library_id from creation or listing and asset_id from asset creation or listing; library_id also accepts the literal default, which resolves to the organization’s default library before the credential check. The source asset is never overwritten: the new asset hangs under it in the edit chain, records it in derived_from, and reads back with assets.lineage, so earlier steps stay reachable. The body is operation plus the optional model, asset_folder, understanding and idempotency_key; operation.type selects the edit and carries that operation’s own fields. This release performs variations, inpaint, erase, replace_object, recolor and replace_background on images, remove_background on an image or a video, and to_video, frame and resynthesize on the material each takes; every other type in the operation vocabulary is refused with OPERATION_NOT_SUPPORTED. remove_background on a video produces a portrait matte video for compositing without a green screen: output picks
|
|
31934
|
+
description: "Edit an existing asset and store the result as a new asset. Use library_id from creation or listing and asset_id from asset creation or listing; library_id also accepts the literal default, which resolves to the organization’s default library before the credential check. The source asset is never overwritten: the new asset hangs under it in the edit chain, records it in derived_from, and reads back with assets.lineage, so earlier steps stay reachable. The body is operation plus the optional model, asset_folder, understanding and idempotency_key; operation.type selects the edit and carries that operation’s own fields. This release performs variations, inpaint, erase, replace_object, recolor and replace_background on images, remove_background on an image or a video, upscale, enhance_voice, reframe and redact through Media’s processing lane (upscale on a picture or a video; enhance_voice on a recording or a video, whose audio is used; reframe and redact on a video), and to_video, frame and resynthesize on the material each takes; every other type in the operation vocabulary is refused with OPERATION_NOT_SUPPORTED. The processing lane takes its model from the platform model catalogue, judged by the operation’s capability and overridable with operation.model, and bills per second of input; each edit is idempotent on the source, the operation and the parameters, so a second request that would make the same asset answers the asset already made instead of paying again, and an operation whose catalogue list is empty is refused with OPERATION_NOT_SUPPORTED, 尚未上架. remove_background on a video produces a portrait matte video for compositing without a green screen: output picks mask (a black-and-white matte as a small H.264 video, person white and background black: use it as a Cut track mask with channel luma under the original video to lay a lecturer over slides — the choice for compositing) or alpha (the default: the person on a transparent background as ProRes 4444, which is very large, about 870 MB per 15 seconds of 1080p, so ask for it only when a transparent file itself is the deliverable), and model picks the matting model from types.matting.models of the generation capabilities — read it first, because a request that names none takes the first available matting model and a video is refused with OPERATION_NOT_SUPPORTED, in the model field, when the platform has published none. output and model mean nothing for an image source and are refused with INVALID_PARAMS naming the field rather than ignored. inpaint takes mask, a PNG File identifier beginning with file- whose transparent area marks the region to replace, plus the prompt describing what belongs there. Aspects beyond the source asset’s material type return REFERENCE_TYPE_MISMATCH. Editing is billed by the model usage it consumes, at the same prices as the model API, and the job reports the charge in usage (US dollars, six decimals) and the new asset carries it in provenance.cost; when the job is done, tell the person the usage amount and give them the output’s viewer_url. The response is 202 with a queued Job whose type is image, whose operation is the edit applied, and whose source_asset_id is the asset edited; poll GET /media/v1/libraries/{library_id}/jobs/{job_id} until it is completed or failed, then read the produced asset. Example: POST /media/v1/libraries/lib_example/assets/9dfa312ef9bc4b00816339b598b1152c/edits with {\"operation\":{\"type\":\"variations\",\"strength\":\"subtle\"}}.",
|
|
31720
31935
|
http: "POST",
|
|
31721
31936
|
path: "/media/v1/libraries/{library_id}/assets/{asset_id}/edits",
|
|
31722
31937
|
streaming: "no",
|
|
@@ -31741,7 +31956,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
31741
31956
|
name: "operation",
|
|
31742
31957
|
type: "object",
|
|
31743
31958
|
required: true,
|
|
31744
|
-
description: "One edit to apply to the source asset. type selects the operation and the discriminating branch carries that operation’s fields. This release performs variations, inpaint, erase, replace_object, recolor and replace_background on images, remove_background on an image or a video, and to_video, frame and resynthesize on the material each takes; every other type here describes the operation vocabulary and is refused with OPERATION_NOT_SUPPORTED."
|
|
31959
|
+
description: "One edit to apply to the source asset. type selects the operation and the discriminating branch carries that operation’s fields. This release performs variations, inpaint, erase, replace_object, recolor and replace_background on images, remove_background on an image or a video, upscale, enhance_voice, reframe and redact through Media’s processing lane (upscale on a picture or a video; enhance_voice on a recording or a video, whose audio is used; reframe and redact on a video), and to_video, frame and resynthesize on the material each takes; every other type here describes the operation vocabulary and is refused with OPERATION_NOT_SUPPORTED. align is not an edit — it compares two assets and has its own endpoint, POST /media/v1/libraries/{library_id}/assets/{asset_id}/align."
|
|
31745
31960
|
},
|
|
31746
31961
|
{
|
|
31747
31962
|
name: "model",
|
|
@@ -34774,6 +34989,7 @@ for more details.`
|
|
|
34774
34989
|
"openai.images.generations",
|
|
34775
34990
|
"openai.responses",
|
|
34776
34991
|
"openai.videos",
|
|
34992
|
+
"praxis.media.process",
|
|
34777
34993
|
"praxis.video.matting",
|
|
34778
34994
|
"typesafe.systemone",
|
|
34779
34995
|
"volcengine.music",
|
|
@@ -40449,6 +40665,131 @@ for more details.`
|
|
|
40449
40665
|
]
|
|
40450
40666
|
}
|
|
40451
40667
|
},
|
|
40668
|
+
{
|
|
40669
|
+
resource: "share.permissions",
|
|
40670
|
+
method: "list",
|
|
40671
|
+
summary: "List shares",
|
|
40672
|
+
description: "Find the shares of this organization, newest first, for example every link that exposes one file before you decide which to revoke. Filter by resource_type, resource_id and status; filters combine with AND. Continue with next_page_token as page_token until next_page_token is null. Records never include link.web_url. A credential bound to specific files must pass resource_type and resource_id of a bound file, and an unbound file answers 404.",
|
|
40673
|
+
http: "GET",
|
|
40674
|
+
path: "/share/v1/permissions",
|
|
40675
|
+
streaming: "no",
|
|
40676
|
+
pagination: false,
|
|
40677
|
+
pathParams: [],
|
|
40678
|
+
query: [
|
|
40679
|
+
{
|
|
40680
|
+
name: "resource_type",
|
|
40681
|
+
type: "string",
|
|
40682
|
+
enum: [
|
|
40683
|
+
"file",
|
|
40684
|
+
"artifact",
|
|
40685
|
+
"canvas",
|
|
40686
|
+
"media_asset"
|
|
40687
|
+
],
|
|
40688
|
+
required: false,
|
|
40689
|
+
description: "Only shares of this object type; file, canvas and media_asset create today."
|
|
40690
|
+
},
|
|
40691
|
+
{
|
|
40692
|
+
name: "resource_id",
|
|
40693
|
+
type: "string",
|
|
40694
|
+
required: false,
|
|
40695
|
+
description: "Only shares of the object with this id, for example a file id from the File API or a media asset's library_id/asset_id; combine with resource_type."
|
|
40696
|
+
},
|
|
40697
|
+
{
|
|
40698
|
+
name: "status",
|
|
40699
|
+
type: "string",
|
|
40700
|
+
enum: [
|
|
40701
|
+
"active",
|
|
40702
|
+
"expired",
|
|
40703
|
+
"revoked"
|
|
40704
|
+
],
|
|
40705
|
+
required: false,
|
|
40706
|
+
description: "Only shares in this state; omit to list every state."
|
|
40707
|
+
},
|
|
40708
|
+
{
|
|
40709
|
+
name: "page_size",
|
|
40710
|
+
type: "integer",
|
|
40711
|
+
required: false,
|
|
40712
|
+
description: "Maximum shares in one page, from 1 to 100; defaults to 50."
|
|
40713
|
+
},
|
|
40714
|
+
{
|
|
40715
|
+
name: "page_token",
|
|
40716
|
+
type: "string",
|
|
40717
|
+
required: false,
|
|
40718
|
+
description: "Opaque next_page_token from the preceding page with the same filters; omit on the first request."
|
|
40719
|
+
}
|
|
40720
|
+
]
|
|
40721
|
+
},
|
|
40722
|
+
{
|
|
40723
|
+
resource: "share.permissions",
|
|
40724
|
+
method: "create",
|
|
40725
|
+
summary: "Create share",
|
|
40726
|
+
description: "Make one file readable by anyone holding a link, before sending the link to a person or embedding it. Name the object as resource {type, id}, with the file id from the File API. The response is 201 and is the only time link.web_url is returned; store it, because later reads omit it and a lost address means creating another share (the old one keeps working until you delete it). The link is anonymous and read-only. A type other than file answers 400 RESOURCE_TYPE_UNSUPPORTED, and a file that is missing or outside your organization answers 404 RESOURCE_NOT_FOUND.",
|
|
40727
|
+
http: "POST",
|
|
40728
|
+
path: "/share/v1/permissions",
|
|
40729
|
+
streaming: "no",
|
|
40730
|
+
pagination: false,
|
|
40731
|
+
pathParams: [],
|
|
40732
|
+
query: [],
|
|
40733
|
+
body: {
|
|
40734
|
+
required: true,
|
|
40735
|
+
fields: [
|
|
40736
|
+
{
|
|
40737
|
+
name: "resource",
|
|
40738
|
+
type: "object",
|
|
40739
|
+
required: true,
|
|
40740
|
+
description: "The object a share exposes, named by a type and an id."
|
|
40741
|
+
},
|
|
40742
|
+
{
|
|
40743
|
+
name: "expire_time",
|
|
40744
|
+
type: "string",
|
|
40745
|
+
required: false,
|
|
40746
|
+
description: "ISO 8601 instant after which the link answers 410; omit or null for a link that never expires, and it must be in the future."
|
|
40747
|
+
},
|
|
40748
|
+
{
|
|
40749
|
+
name: "prevents_download",
|
|
40750
|
+
type: "boolean",
|
|
40751
|
+
required: false,
|
|
40752
|
+
description: "Ask viewers to open the content without a download prompt; a limit, not a guarantee, because anyone who can read it can save it. Defaults to false."
|
|
40753
|
+
}
|
|
40754
|
+
]
|
|
40755
|
+
}
|
|
40756
|
+
},
|
|
40757
|
+
{
|
|
40758
|
+
resource: "share.permissions",
|
|
40759
|
+
method: "delete",
|
|
40760
|
+
summary: "Delete share",
|
|
40761
|
+
description: "Take a link back so nobody can open it again. This revokes the share, the record stays readable with status revoked, and opening the link answers 410. Repeating the call on a revoked share is harmless and answers 204 again. Content addresses already signed when the link was opened expire on their own within five minutes. Take the id from shares.create or shares.list.",
|
|
40762
|
+
http: "DELETE",
|
|
40763
|
+
path: "/share/v1/permissions/{id}",
|
|
40764
|
+
streaming: "no",
|
|
40765
|
+
pagination: false,
|
|
40766
|
+
pathParams: [
|
|
40767
|
+
{
|
|
40768
|
+
name: "id",
|
|
40769
|
+
sdkName: "id",
|
|
40770
|
+
description: "Share id returned by shares.create or shares.list, in the form shr_ followed by 32 lowercase letters or digits; a link address is not accepted."
|
|
40771
|
+
}
|
|
40772
|
+
],
|
|
40773
|
+
query: []
|
|
40774
|
+
},
|
|
40775
|
+
{
|
|
40776
|
+
resource: "share.permissions",
|
|
40777
|
+
method: "retrieve",
|
|
40778
|
+
summary: "Retrieve share",
|
|
40779
|
+
description: "Read one share to see whether its link is still active, when it expires, and how many times it was opened. Take the id from shares.create or shares.list. The record never includes link.web_url, because the address is shown once at creation. A share that does not exist or belongs to another organization answers 404 PERMISSION_NOT_FOUND.",
|
|
40780
|
+
http: "GET",
|
|
40781
|
+
path: "/share/v1/permissions/{id}",
|
|
40782
|
+
streaming: "no",
|
|
40783
|
+
pagination: false,
|
|
40784
|
+
pathParams: [
|
|
40785
|
+
{
|
|
40786
|
+
name: "id",
|
|
40787
|
+
sdkName: "id",
|
|
40788
|
+
description: "Share id returned by shares.create or shares.list, in the form shr_ followed by 32 lowercase letters or digits; a link address is not accepted."
|
|
40789
|
+
}
|
|
40790
|
+
],
|
|
40791
|
+
query: []
|
|
40792
|
+
},
|
|
40452
40793
|
{
|
|
40453
40794
|
resource: "studio.codexes",
|
|
40454
40795
|
method: "list",
|
|
@@ -46923,6 +47264,19 @@ var getAgentConsolidation = (options) => (options.client ?? client).get({
|
|
|
46923
47264
|
url: "/agent/v1/agents/{agent_id}/consolidations/{consolidation_id}",
|
|
46924
47265
|
...options
|
|
46925
47266
|
});
|
|
47267
|
+
var listAgentInboxLetters = (options) => (options.client ?? client).get({
|
|
47268
|
+
security: [{
|
|
47269
|
+
key: "BearerAuth",
|
|
47270
|
+
scheme: "bearer",
|
|
47271
|
+
type: "http"
|
|
47272
|
+
}, {
|
|
47273
|
+
key: "ApiKeyAuth",
|
|
47274
|
+
name: "X-API-Key",
|
|
47275
|
+
type: "apiKey"
|
|
47276
|
+
}],
|
|
47277
|
+
url: "/agent/v1/agents/{agent_id}/inbox/letters",
|
|
47278
|
+
...options
|
|
47279
|
+
});
|
|
46926
47280
|
var applyAgentVersion = (options) => (options.client ?? client).post({
|
|
46927
47281
|
security: [{
|
|
46928
47282
|
key: "BearerAuth",
|
|
@@ -47275,11 +47629,7 @@ var computersFilesConvert = (options) => (options.client ?? client).post({
|
|
|
47275
47629
|
type: "apiKey"
|
|
47276
47630
|
}],
|
|
47277
47631
|
url: "/agent/v1/computers/{computer_id}/files/convert",
|
|
47278
|
-
...options
|
|
47279
|
-
headers: {
|
|
47280
|
-
"Content-Type": "application/json",
|
|
47281
|
-
...options.headers
|
|
47282
|
-
}
|
|
47632
|
+
...options
|
|
47283
47633
|
});
|
|
47284
47634
|
var connectComputer = (options) => (options.client ?? client).post({
|
|
47285
47635
|
security: [{
|
|
@@ -47367,6 +47717,49 @@ var forkSession = (options) => (options.client ?? client).post({
|
|
|
47367
47717
|
...options.headers
|
|
47368
47718
|
}
|
|
47369
47719
|
});
|
|
47720
|
+
var listSessionArtifacts = (options) => (options.client ?? client).get({
|
|
47721
|
+
security: [{
|
|
47722
|
+
key: "BearerAuth",
|
|
47723
|
+
scheme: "bearer",
|
|
47724
|
+
type: "http"
|
|
47725
|
+
}, {
|
|
47726
|
+
key: "ApiKeyAuth",
|
|
47727
|
+
name: "X-API-Key",
|
|
47728
|
+
type: "apiKey"
|
|
47729
|
+
}],
|
|
47730
|
+
url: "/agent/v1/sessions/{session_id}/artifacts",
|
|
47731
|
+
...options
|
|
47732
|
+
});
|
|
47733
|
+
var createSessionArtifactContentUrl = (options) => (options.client ?? client).post({
|
|
47734
|
+
security: [{
|
|
47735
|
+
key: "BearerAuth",
|
|
47736
|
+
scheme: "bearer",
|
|
47737
|
+
type: "http"
|
|
47738
|
+
}, {
|
|
47739
|
+
key: "ApiKeyAuth",
|
|
47740
|
+
name: "X-API-Key",
|
|
47741
|
+
type: "apiKey"
|
|
47742
|
+
}],
|
|
47743
|
+
url: "/agent/v1/sessions/{session_id}/artifacts/{artifact_id}/content_url",
|
|
47744
|
+
...options,
|
|
47745
|
+
headers: {
|
|
47746
|
+
"Content-Type": "application/json",
|
|
47747
|
+
...options.headers
|
|
47748
|
+
}
|
|
47749
|
+
});
|
|
47750
|
+
var listSessionRequests = (options) => (options.client ?? client).get({
|
|
47751
|
+
security: [{
|
|
47752
|
+
key: "BearerAuth",
|
|
47753
|
+
scheme: "bearer",
|
|
47754
|
+
type: "http"
|
|
47755
|
+
}, {
|
|
47756
|
+
key: "ApiKeyAuth",
|
|
47757
|
+
name: "X-API-Key",
|
|
47758
|
+
type: "apiKey"
|
|
47759
|
+
}],
|
|
47760
|
+
url: "/agent/v1/sessions/{session_id}/requests",
|
|
47761
|
+
...options
|
|
47762
|
+
});
|
|
47370
47763
|
var listSessionBackgroundTasks = (options) => (options.client ?? client).get({
|
|
47371
47764
|
security: [{
|
|
47372
47765
|
key: "BearerAuth",
|
|
@@ -53251,6 +53644,19 @@ var devopsFlagsCreate = (options) => (options.client ?? client).post({
|
|
|
53251
53644
|
...options.headers
|
|
53252
53645
|
}
|
|
53253
53646
|
});
|
|
53647
|
+
var devopsFlagsReportCodeRefs = (options) => (options.client ?? client).post({
|
|
53648
|
+
security: [{
|
|
53649
|
+
key: "devops-bearerAuth",
|
|
53650
|
+
scheme: "bearer",
|
|
53651
|
+
type: "http"
|
|
53652
|
+
}],
|
|
53653
|
+
url: "/devops/v1/projects/{project}/flags/code-refs",
|
|
53654
|
+
...options,
|
|
53655
|
+
headers: {
|
|
53656
|
+
"Content-Type": "application/json",
|
|
53657
|
+
...options.headers
|
|
53658
|
+
}
|
|
53659
|
+
});
|
|
53254
53660
|
var devopsFlagsGet = (options) => (options.client ?? client).get({
|
|
53255
53661
|
security: [{
|
|
53256
53662
|
key: "devops-bearerAuth",
|
|
@@ -54464,6 +54870,19 @@ var mediaGetGenerationCapabilities = (options) => (options?.client ?? client).ge
|
|
|
54464
54870
|
url: "/media/v1/generation/capabilities",
|
|
54465
54871
|
...options
|
|
54466
54872
|
});
|
|
54873
|
+
var mediaAlignAsset = (options) => (options.client ?? client).post({
|
|
54874
|
+
security: [{
|
|
54875
|
+
key: "media-BearerAuth",
|
|
54876
|
+
scheme: "bearer",
|
|
54877
|
+
type: "http"
|
|
54878
|
+
}],
|
|
54879
|
+
url: "/media/v1/libraries/{library_id}/assets/{asset_id}/align",
|
|
54880
|
+
...options,
|
|
54881
|
+
headers: {
|
|
54882
|
+
"Content-Type": "application/json",
|
|
54883
|
+
...options.headers
|
|
54884
|
+
}
|
|
54885
|
+
});
|
|
54467
54886
|
var ontologyListTypes = (options) => (options?.client ?? client).get({
|
|
54468
54887
|
security: [{
|
|
54469
54888
|
key: "ontology-bearerAuth",
|
|
@@ -55596,6 +56015,46 @@ var searchMap = (options) => (options.client ?? client).post({
|
|
|
55596
56015
|
...options.headers
|
|
55597
56016
|
}
|
|
55598
56017
|
});
|
|
56018
|
+
var shareListPermissions = (options) => (options?.client ?? client).get({
|
|
56019
|
+
security: [{
|
|
56020
|
+
key: "share-bearerAuth",
|
|
56021
|
+
scheme: "bearer",
|
|
56022
|
+
type: "http"
|
|
56023
|
+
}],
|
|
56024
|
+
url: "/share/v1/permissions",
|
|
56025
|
+
...options
|
|
56026
|
+
});
|
|
56027
|
+
var shareCreatePermission = (options) => (options.client ?? client).post({
|
|
56028
|
+
security: [{
|
|
56029
|
+
key: "share-bearerAuth",
|
|
56030
|
+
scheme: "bearer",
|
|
56031
|
+
type: "http"
|
|
56032
|
+
}],
|
|
56033
|
+
url: "/share/v1/permissions",
|
|
56034
|
+
...options,
|
|
56035
|
+
headers: {
|
|
56036
|
+
"Content-Type": "application/json",
|
|
56037
|
+
...options.headers
|
|
56038
|
+
}
|
|
56039
|
+
});
|
|
56040
|
+
var shareDeletePermission = (options) => (options.client ?? client).delete({
|
|
56041
|
+
security: [{
|
|
56042
|
+
key: "share-bearerAuth",
|
|
56043
|
+
scheme: "bearer",
|
|
56044
|
+
type: "http"
|
|
56045
|
+
}],
|
|
56046
|
+
url: "/share/v1/permissions/{id}",
|
|
56047
|
+
...options
|
|
56048
|
+
});
|
|
56049
|
+
var shareRetrievePermission = (options) => (options.client ?? client).get({
|
|
56050
|
+
security: [{
|
|
56051
|
+
key: "share-bearerAuth",
|
|
56052
|
+
scheme: "bearer",
|
|
56053
|
+
type: "http"
|
|
56054
|
+
}],
|
|
56055
|
+
url: "/share/v1/permissions/{id}",
|
|
56056
|
+
...options
|
|
56057
|
+
});
|
|
55599
56058
|
var studioGenresList = (options) => (options?.client ?? client).get({
|
|
55600
56059
|
security: [{
|
|
55601
56060
|
key: "BearerAuth",
|
|
@@ -57632,6 +58091,11 @@ function createAgent(transport) {
|
|
|
57632
58091
|
send: bind(transport, sendAgentEvents),
|
|
57633
58092
|
stream: bindStream(transport, streamAgentEvents)
|
|
57634
58093
|
},
|
|
58094
|
+
inbox: {
|
|
58095
|
+
letters: {
|
|
58096
|
+
list: bind(transport, listAgentInboxLetters)
|
|
58097
|
+
}
|
|
58098
|
+
},
|
|
57635
58099
|
list: bind(transport, agentsList),
|
|
57636
58100
|
retrieve: bind(transport, agentsRetrieve),
|
|
57637
58101
|
retrieveAppearance: bind(transport, getAgentAppearance),
|
|
@@ -57696,6 +58160,12 @@ function createAgent(transport) {
|
|
|
57696
58160
|
},
|
|
57697
58161
|
sessions: {
|
|
57698
58162
|
archive: bind(transport, sessionsArchive),
|
|
58163
|
+
artifacts: {
|
|
58164
|
+
contentUrl: {
|
|
58165
|
+
create: bind(transport, createSessionArtifactContentUrl)
|
|
58166
|
+
},
|
|
58167
|
+
list: bind(transport, listSessionArtifacts)
|
|
58168
|
+
},
|
|
57699
58169
|
backgroundTasks: {
|
|
57700
58170
|
list: bind(transport, listSessionBackgroundTasks),
|
|
57701
58171
|
retrieveOutput: bind(transport, getSessionBackgroundTaskOutput),
|
|
@@ -57714,6 +58184,9 @@ function createAgent(transport) {
|
|
|
57714
58184
|
},
|
|
57715
58185
|
fork: bind(transport, forkSession),
|
|
57716
58186
|
list: bind(transport, sessionsList),
|
|
58187
|
+
requests: {
|
|
58188
|
+
list: bind(transport, listSessionRequests)
|
|
58189
|
+
},
|
|
57717
58190
|
resources: {
|
|
57718
58191
|
create: bind(transport, sessionsResourcesAdd),
|
|
57719
58192
|
delete: bind(transport, aliasOperation(sessionsResourcesDelete, { query: { session_id: "query_session_id" } })),
|
|
@@ -58226,7 +58699,8 @@ function createDevops(transport) {
|
|
|
58226
58699
|
},
|
|
58227
58700
|
flags: {
|
|
58228
58701
|
create: bind(transport, devopsFlagsCreate),
|
|
58229
|
-
list: bind(transport, devopsFlagsList)
|
|
58702
|
+
list: bind(transport, devopsFlagsList),
|
|
58703
|
+
reportCodeRefs: bind(transport, devopsFlagsReportCodeRefs)
|
|
58230
58704
|
},
|
|
58231
58705
|
list: bind(transport, devopsProjectsList),
|
|
58232
58706
|
promotions: {
|
|
@@ -58430,6 +58904,9 @@ function createMedia(transport) {
|
|
|
58430
58904
|
},
|
|
58431
58905
|
libraries: {
|
|
58432
58906
|
assets: {
|
|
58907
|
+
align: {
|
|
58908
|
+
create: bind(transport, mediaAlignAsset)
|
|
58909
|
+
},
|
|
58433
58910
|
batch: bind(transport, mediaBatchAssets),
|
|
58434
58911
|
create: bind(transport, (options) => mediaUploadAsset({ ...options, bodySerializer: multipartBodySerializer, headers: { "Content-Type": null, ...options.headers } })),
|
|
58435
58912
|
delete: bind(transport, mediaDeleteAsset),
|
|
@@ -58871,6 +59348,16 @@ function createSearch(transport) {
|
|
|
58871
59348
|
}
|
|
58872
59349
|
};
|
|
58873
59350
|
}
|
|
59351
|
+
function createShare(transport) {
|
|
59352
|
+
return {
|
|
59353
|
+
permissions: {
|
|
59354
|
+
create: bind(transport, shareCreatePermission),
|
|
59355
|
+
delete: bind(transport, shareDeletePermission),
|
|
59356
|
+
list: bind(transport, shareListPermissions),
|
|
59357
|
+
retrieve: bind(transport, shareRetrievePermission)
|
|
59358
|
+
}
|
|
59359
|
+
};
|
|
59360
|
+
}
|
|
58874
59361
|
function createStudio(transport) {
|
|
58875
59362
|
return {
|
|
58876
59363
|
codexes: {
|
|
@@ -59141,6 +59628,7 @@ var resourceFactories = {
|
|
|
59141
59628
|
organization: createOrganization,
|
|
59142
59629
|
sandbox: createSandbox,
|
|
59143
59630
|
search: createSearch,
|
|
59631
|
+
share: createShare,
|
|
59144
59632
|
studio: createStudio,
|
|
59145
59633
|
ticket: createTicket,
|
|
59146
59634
|
vault: createVault
|
|
@@ -60958,7 +61446,7 @@ function help(commands, prefix, command) {
|
|
|
60958
61446
|
...[...operationOptions(command.op), ...bodyDataOption(command.op), ...globalOptions].map((s) => ` ${describeOption(s, s.required && fieldRequired(command.op, s, s.location ?? "query"))}`),
|
|
60959
61447
|
...command.op.body?.fields.filter((f) => !operationOptions(command.op).some((s) => s.location === "body" && s.field === f) && (f.type === "object" || f.type === "array" && !["string", "number", "integer", "boolean"].includes(f.itemType ?? ""))).map((f) => ` --data: ${f.name} (${f.type}${f.required ? ", required" : ""})`) ?? [],
|
|
60960
61448
|
" -h is an alias of --help",
|
|
60961
|
-
"PRAXIS_ENV=develop
|
|
61449
|
+
"PRAXIS_ENV=production|develop (default: production; develop must be named); no --env option.",
|
|
60962
61450
|
"",
|
|
60963
61451
|
"Examples:",
|
|
60964
61452
|
` ${example(command)}`
|
|
@@ -60970,7 +61458,7 @@ function help(commands, prefix, command) {
|
|
|
60970
61458
|
"Global options:",
|
|
60971
61459
|
...globalOptions.map((s) => ` ${describeOption(s)}`),
|
|
60972
61460
|
" -h is an alias of --help",
|
|
60973
|
-
"PRAXIS_ENV=develop
|
|
61461
|
+
"PRAXIS_ENV=production|develop (default: production; develop must be named); no --env option.",
|
|
60974
61462
|
""
|
|
60975
61463
|
];
|
|
60976
61464
|
const sample = matching.find((c) => c.words.at(-1) === "list") ?? matching[0];
|
|
@@ -61417,30 +61905,31 @@ var workflows = [
|
|
|
61417
61905
|
{
|
|
61418
61906
|
words: ["devops", "flag", "refs"],
|
|
61419
61907
|
requires: "checkout",
|
|
61420
|
-
usage: "devops flag refs [key]",
|
|
61421
|
-
summary: "Where each flag key is referenced in this checkout: file and line, for every registered key or one named key.",
|
|
61422
|
-
example: "praxis devops flag refs",
|
|
61908
|
+
usage: "devops flag refs [key] [--report --project <dvp_…>]",
|
|
61909
|
+
summary: "Where each flag key is referenced in this checkout: file and line, for every registered key or one named key. With --report the whole scan of every registered key is posted to the platform, which is what lets archiving a flag be refused while code still names it.",
|
|
61910
|
+
example: "praxis devops flag refs --report --project dvp_…",
|
|
61423
61911
|
examples: [
|
|
61424
61912
|
"praxis devops flag refs",
|
|
61425
|
-
"praxis devops flag refs run-page-v2"
|
|
61913
|
+
"praxis devops flag refs run-page-v2",
|
|
61914
|
+
"praxis devops flag refs --report --project dvp_…"
|
|
61426
61915
|
],
|
|
61427
61916
|
group: "local",
|
|
61428
|
-
network: "
|
|
61429
|
-
platform: "
|
|
61917
|
+
network: "Offline. --report: needs a login and sends this checkout's references to the platform",
|
|
61918
|
+
platform: "the platform half of the scan: `devops.flags.reportCodeRefs` stores the references on each flag of the project (0 for a key this scan no longer finds), `devops.flags.listCodeRefs` reads them back, and `praxis api devops flag archive <flg_…>` refuses while a flag still has references or is still on in an environment (ADR-125 §4).",
|
|
61430
61919
|
docs: "https://docs.deepraxis.com/docs/cli"
|
|
61431
61920
|
},
|
|
61432
61921
|
{
|
|
61433
61922
|
words: ["devops", "flag", "remove"],
|
|
61434
61923
|
requires: "checkout",
|
|
61435
61924
|
usage: "devops flag remove <key>",
|
|
61436
|
-
summary: "The local step of removing a flag: list the remaining references, or the steps that follow once none remain. Order:
|
|
61925
|
+
summary: "The local step of removing a flag: list the remaining references, or the steps that follow once none remain. Order: turn the flag off in every environment (praxis api devops flag environment update), delete the code that names the key and deploy it, run this command, report the scan with praxis devops flag refs --report, then retire the flag on the platform with praxis api devops flag archive <flg_…> (irreversible; it is refused while references remain or an environment still has it on), then regenerate the registry with praxis devops flag sync.",
|
|
61437
61926
|
example: "praxis devops flag remove run-page-v2",
|
|
61438
61927
|
examples: [
|
|
61439
61928
|
"praxis devops flag remove run-page-v2"
|
|
61440
61929
|
],
|
|
61441
61930
|
group: "local",
|
|
61442
61931
|
network: "offline",
|
|
61443
|
-
platform: "praxis api devops flag archive — retires the flag on the platform after the code that named it is deployed away
|
|
61932
|
+
platform: "praxis api devops flag archive — retires the flag on the platform after the code that named it is deployed away, and keeps the key reserved; it is refused, not forced, while the references the last `praxis devops flag refs --report` wrote remain or the flag is still on in an environment (ADR-050 §7, ADR-125 §4).",
|
|
61444
61933
|
docs: "https://docs.deepraxis.com/docs/cli"
|
|
61445
61934
|
},
|
|
61446
61935
|
{
|
|
@@ -61457,6 +61946,41 @@ var workflows = [
|
|
|
61457
61946
|
platform: "praxis api devops project change create — the platform creates and names a Change; the CLI only lands its branch (ADR-125 §5).",
|
|
61458
61947
|
docs: "https://docs.deepraxis.com/docs/cli"
|
|
61459
61948
|
},
|
|
61949
|
+
{
|
|
61950
|
+
words: ["agent", "events", "wait"],
|
|
61951
|
+
usage: "agent events wait [--timeout <seconds>]",
|
|
61952
|
+
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.",
|
|
61953
|
+
example: "PRAXIS_ASSUME_AGENT=R1M9TQ2X praxis agent events wait",
|
|
61954
|
+
network: "online"
|
|
61955
|
+
},
|
|
61956
|
+
{
|
|
61957
|
+
words: ["agent", "memory"],
|
|
61958
|
+
usage: "agent memory [--hook SessionStart|UserPromptSubmit]",
|
|
61959
|
+
summary: "Print your assume agent's memory as it stands now (PRAXIS_ASSUME_AGENT): who it is, its post, manager, duties and the charters it works under, drawn from its organization. With --hook it reads the Claude Code hook input on stdin and prints the hook's JSON: the whole memory at SessionStart, only what is new since that session last read it at UserPromptSubmit; it never fails the hook.",
|
|
61960
|
+
example: "praxis agent memory",
|
|
61961
|
+
network: "online"
|
|
61962
|
+
},
|
|
61963
|
+
{
|
|
61964
|
+
words: ["agent", "recall"],
|
|
61965
|
+
usage: "agent recall [--words <w,w>] [--handles <id,id>]",
|
|
61966
|
+
summary: "Recall from your assume agent's memory: with no flags, what else comes to mind; with words, what was filed under them; with handles, that entry and its original.",
|
|
61967
|
+
example: "praxis agent recall --words 章程,运维部",
|
|
61968
|
+
network: "online"
|
|
61969
|
+
},
|
|
61970
|
+
{
|
|
61971
|
+
words: ["agent", "remember"],
|
|
61972
|
+
usage: "agent remember --text <experience> [--about <id,id>]",
|
|
61973
|
+
summary: "Keep an experience in your assume agent's memory: it is consolidated in the background like a lived conversation, and recall finds it afterwards.",
|
|
61974
|
+
example: 'praxis agent remember --text "Sean 定了副总裁用钩子载入认知"',
|
|
61975
|
+
network: "online"
|
|
61976
|
+
},
|
|
61977
|
+
{
|
|
61978
|
+
words: ["agent", "events", "channel"],
|
|
61979
|
+
usage: "agent events channel",
|
|
61980
|
+
summary: "Run as a Claude Code channel (a stdio MCP server declaring claude/channel, no tools): pushes the waiting letters once, then every new letter and new memory of your assume agent (PRAXIS_ASSUME_AGENT, default R1M9TQ2X) into the running session. Started by the assume-agent plugin, not by hand; stdout carries MCP frames only, logs go to stderr.",
|
|
61981
|
+
example: "claude --dangerously-load-development-channels plugin:assume-agent@deepraxis",
|
|
61982
|
+
network: "online"
|
|
61983
|
+
},
|
|
61460
61984
|
{ 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"' },
|
|
61461
61985
|
{ words: ["skill"], usage: "skill [--install <dir>]", summary: "Print the AI skill, or write <dir>/praxis-cli/SKILL.md." },
|
|
61462
61986
|
{
|
|
@@ -61526,7 +62050,7 @@ function workflowHelp(workflow, options) {
|
|
|
61526
62050
|
"Options:",
|
|
61527
62051
|
...[...options, ...globalOptions].map((s) => ` ${describeOption(s)}`),
|
|
61528
62052
|
" -h is an alias of --help",
|
|
61529
|
-
"PRAXIS_ENV=develop
|
|
62053
|
+
"PRAXIS_ENV=production|develop (default: production; develop must be named); no --env option.",
|
|
61530
62054
|
...workflow.requires === "checkout" ? [`Requires: ${CHECKOUT_REQUIREMENT}`] : [],
|
|
61531
62055
|
...workflow.notes?.length ? ["", ...workflow.notes] : [],
|
|
61532
62056
|
...workflow.network ? ["", `Network: ${workflow.network}`] : [],
|
|
@@ -63049,6 +63573,101 @@ function wranglerEdges(nodes) {
|
|
|
63049
63573
|
}
|
|
63050
63574
|
return edges;
|
|
63051
63575
|
}
|
|
63576
|
+
// ../../packages/praxis/deploy-core/src/lambda-function.ts
|
|
63577
|
+
var LAMBDA_FUNCTIONS_ROOT = "services/lambda/functions";
|
|
63578
|
+
var UPSTREAM = "aliyun-fc";
|
|
63579
|
+
var RECIPE_PATH = /^services\/lambda\/functions\/([^/]+)\/function\.json$/;
|
|
63580
|
+
var isText = (value) => typeof value === "string" && value !== "";
|
|
63581
|
+
var isCount = (value, min, max) => typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
63582
|
+
function lambdaFunctionOf(text) {
|
|
63583
|
+
const parsed = text === null ? null : parseJsonc2(text);
|
|
63584
|
+
if (parsed === null)
|
|
63585
|
+
return null;
|
|
63586
|
+
if (!isText(parsed.name) || !isText(parsed.upstream))
|
|
63587
|
+
return null;
|
|
63588
|
+
if (!Array.isArray(parsed.regions) || parsed.regions.length === 0 || !parsed.regions.every(isText))
|
|
63589
|
+
return null;
|
|
63590
|
+
if (parsed.gpu !== undefined && !isText(parsed.gpu))
|
|
63591
|
+
return null;
|
|
63592
|
+
if (!isCount(parsed.cpu, 1, 256))
|
|
63593
|
+
return null;
|
|
63594
|
+
if (!isCount(parsed.memoryMb, 128, 32 * 1024))
|
|
63595
|
+
return null;
|
|
63596
|
+
if (!isCount(parsed.timeoutSeconds, 1, 24 * 3600))
|
|
63597
|
+
return null;
|
|
63598
|
+
if (!isCount(parsed.concurrency, 1, 1024))
|
|
63599
|
+
return null;
|
|
63600
|
+
return {
|
|
63601
|
+
name: parsed.name,
|
|
63602
|
+
upstream: parsed.upstream,
|
|
63603
|
+
regions: [...parsed.regions],
|
|
63604
|
+
...parsed.gpu === undefined ? {} : { gpu: parsed.gpu },
|
|
63605
|
+
cpu: parsed.cpu,
|
|
63606
|
+
memoryMb: parsed.memoryMb,
|
|
63607
|
+
timeoutSeconds: parsed.timeoutSeconds,
|
|
63608
|
+
concurrency: parsed.concurrency
|
|
63609
|
+
};
|
|
63610
|
+
}
|
|
63611
|
+
function lambdaFunctionTarget(recipe) {
|
|
63612
|
+
return { path: `${LAMBDA_FUNCTIONS_ROOT}/${recipe.name}`, name: `lambda-${recipe.name}` };
|
|
63613
|
+
}
|
|
63614
|
+
function lambdaFunctionOwner(path) {
|
|
63615
|
+
return path.split("/").slice(0, -2).join("/");
|
|
63616
|
+
}
|
|
63617
|
+
async function scanRecipes(facts) {
|
|
63618
|
+
const found = [];
|
|
63619
|
+
const warnings = [];
|
|
63620
|
+
for (const path of [...facts.tree].sort()) {
|
|
63621
|
+
const match = RECIPE_PATH.exec(path);
|
|
63622
|
+
if (match === null)
|
|
63623
|
+
continue;
|
|
63624
|
+
const dir = path.slice(0, -"/function.json".length);
|
|
63625
|
+
const recipe = lambdaFunctionOf(await facts.read(path));
|
|
63626
|
+
if (recipe === null) {
|
|
63627
|
+
warnings.push(`${dir}: function.json is not a recipe`);
|
|
63628
|
+
continue;
|
|
63629
|
+
}
|
|
63630
|
+
if (recipe.upstream !== UPSTREAM)
|
|
63631
|
+
continue;
|
|
63632
|
+
if (recipe.name !== match[1]) {
|
|
63633
|
+
warnings.push(`${dir}: function.json names ${JSON.stringify(recipe.name)}, not the directory name`);
|
|
63634
|
+
continue;
|
|
63635
|
+
}
|
|
63636
|
+
found.push(recipe);
|
|
63637
|
+
}
|
|
63638
|
+
return { found, warnings };
|
|
63639
|
+
}
|
|
63640
|
+
function lambdaFunctionProvider(_options = {}) {
|
|
63641
|
+
return {
|
|
63642
|
+
id: "lambda-function",
|
|
63643
|
+
async detect(facts) {
|
|
63644
|
+
return (await scanRecipes(facts)).found.length > 0 ? "certain" : "none";
|
|
63645
|
+
},
|
|
63646
|
+
async plan(facts, partial) {
|
|
63647
|
+
const claimed = new Set(partial.targets.map((target) => target.path));
|
|
63648
|
+
const scan = await scanRecipes(facts);
|
|
63649
|
+
const targets = [];
|
|
63650
|
+
const byOwner = new Map;
|
|
63651
|
+
for (const recipe of scan.found) {
|
|
63652
|
+
const { path, name } = lambdaFunctionTarget(recipe);
|
|
63653
|
+
if (claimed.has(path))
|
|
63654
|
+
continue;
|
|
63655
|
+
targets.push({ path, name, destination: "aliyun-fc", production: true, onTrain: true });
|
|
63656
|
+
const owner = lambdaFunctionOwner(path);
|
|
63657
|
+
byOwner.set(owner, [...byOwner.get(owner) ?? [], path]);
|
|
63658
|
+
}
|
|
63659
|
+
const refined = partial.targets.map((target) => {
|
|
63660
|
+
const paths = byOwner.get(target.path);
|
|
63661
|
+
return paths === undefined ? target : { ...target, dependsOn: [...new Set([...target.dependsOn ?? [], ...paths])] };
|
|
63662
|
+
});
|
|
63663
|
+
return {
|
|
63664
|
+
targets: [...refined, ...targets],
|
|
63665
|
+
...scan.warnings.length === 0 ? {} : { warnings: [...partial.warnings ?? [], ...scan.warnings] }
|
|
63666
|
+
};
|
|
63667
|
+
}
|
|
63668
|
+
};
|
|
63669
|
+
}
|
|
63670
|
+
var lambdaFunction = lambdaFunctionProvider();
|
|
63052
63671
|
// ../../packages/praxis/deploy-core/src/package-manifest.ts
|
|
63053
63672
|
function packageManifestOf(text) {
|
|
63054
63673
|
const parsed = text === null ? null : parseJsonc2(text);
|
|
@@ -63155,6 +63774,16 @@ function dirOfPackageJson(path) {
|
|
|
63155
63774
|
return;
|
|
63156
63775
|
return path.slice(0, -"/package.json".length);
|
|
63157
63776
|
}
|
|
63777
|
+
function packageDirOf(path, dirs) {
|
|
63778
|
+
let found = null;
|
|
63779
|
+
for (const dir of dirs) {
|
|
63780
|
+
if (path !== dir && !path.startsWith(`${dir}/`))
|
|
63781
|
+
continue;
|
|
63782
|
+
if (found === null || dir.length > found.length)
|
|
63783
|
+
found = dir;
|
|
63784
|
+
}
|
|
63785
|
+
return found;
|
|
63786
|
+
}
|
|
63158
63787
|
function dirOfManifest(path) {
|
|
63159
63788
|
for (const name of BUILD_MANIFESTS) {
|
|
63160
63789
|
if (path === name)
|
|
@@ -63206,13 +63835,21 @@ function matchesPattern(pattern, path) {
|
|
|
63206
63835
|
}
|
|
63207
63836
|
async function workspaceIndexOf(facts, options = {}) {
|
|
63208
63837
|
const tree = new Set(facts.tree);
|
|
63209
|
-
|
|
63838
|
+
return workspaceIndexOfSync({
|
|
63839
|
+
tree: facts.tree,
|
|
63210
63840
|
packageJson: tree.has("package.json") ? await facts.read("package.json") : null,
|
|
63211
63841
|
pnpmWorkspace: tree.has("pnpm-workspace.yaml") ? await facts.read("pnpm-workspace.yaml") : null
|
|
63842
|
+
}, options);
|
|
63843
|
+
}
|
|
63844
|
+
function workspaceIndexOfSync(input, options = {}) {
|
|
63845
|
+
const tree = new Set(input.tree);
|
|
63846
|
+
const declared = workspacePatternsOf({
|
|
63847
|
+
packageJson: input.packageJson,
|
|
63848
|
+
pnpmWorkspace: input.pnpmWorkspace
|
|
63212
63849
|
});
|
|
63213
63850
|
const patterns = declared.length > 0 ? declared : options.defaultPatterns ?? [];
|
|
63214
63851
|
const candidates2 = new Set;
|
|
63215
|
-
for (const path of
|
|
63852
|
+
for (const path of input.tree) {
|
|
63216
63853
|
const dir = dirOfPackageJson(path) ?? dirOfManifest(path);
|
|
63217
63854
|
if (dir === undefined || dir === ".")
|
|
63218
63855
|
continue;
|
|
@@ -63375,7 +64012,11 @@ function workspaceCloudflareProvider(options = {}) {
|
|
|
63375
64012
|
};
|
|
63376
64013
|
}
|
|
63377
64014
|
var workspaceCloudflare = workspaceCloudflareProvider();
|
|
63378
|
-
var BUILTIN_PROVIDERS = [
|
|
64015
|
+
var BUILTIN_PROVIDERS = [
|
|
64016
|
+
workspaceCloudflare,
|
|
64017
|
+
workspaceNpmProvider(),
|
|
64018
|
+
lambdaFunctionProvider()
|
|
64019
|
+
];
|
|
63379
64020
|
function directoriesOfPackageNames(workspaces) {
|
|
63380
64021
|
const byName = new Map;
|
|
63381
64022
|
for (const workspace of workspaces)
|
|
@@ -63402,15 +64043,23 @@ function workspaceClosureOf(target, byName, dependenciesOf) {
|
|
|
63402
64043
|
// ../../packages/praxis/deploy-core/src/plan.ts
|
|
63403
64044
|
async function planRepository(facts, providers = BUILTIN_PROVIDERS, options = {}) {
|
|
63404
64045
|
let partial = { targets: [] };
|
|
64046
|
+
const warnings = [];
|
|
63405
64047
|
for (const provider of providers) {
|
|
63406
64048
|
const confidence = await provider.detect(facts);
|
|
63407
64049
|
if (confidence === "none")
|
|
63408
64050
|
continue;
|
|
63409
64051
|
partial = await provider.plan(facts, partial);
|
|
64052
|
+
for (const warning of partial.warnings ?? [])
|
|
64053
|
+
if (!warnings.includes(warning))
|
|
64054
|
+
warnings.push(warning);
|
|
63410
64055
|
}
|
|
63411
64056
|
const drafts = partial.targets.filter((draft) => draft.deploy !== false);
|
|
63412
64057
|
const workspaces = await readWorkspaces(facts, options);
|
|
63413
|
-
return {
|
|
64058
|
+
return {
|
|
64059
|
+
commit: facts.commit,
|
|
64060
|
+
targets: closePlan(drafts, workspaces),
|
|
64061
|
+
...warnings.length === 0 ? {} : { warnings }
|
|
64062
|
+
};
|
|
63414
64063
|
}
|
|
63415
64064
|
function closePlan(drafts, workspaces) {
|
|
63416
64065
|
const configOf = new Map(workspaces.map((workspace) => [workspace.dir, workspace.config]));
|
|
@@ -63432,7 +64081,7 @@ function closePlan(drafts, workspaces) {
|
|
|
63432
64081
|
path: draft.path,
|
|
63433
64082
|
name: draft.name,
|
|
63434
64083
|
destination: draft.destination,
|
|
63435
|
-
dependsOn: edges.get(draft.path) ?? [],
|
|
64084
|
+
dependsOn: [...new Set([...edges.get(draft.path) ?? [], ...draft.dependsOn ?? []])],
|
|
63436
64085
|
...draft.environments === undefined ? {} : { environments: draft.environments },
|
|
63437
64086
|
production: draft.production === true,
|
|
63438
64087
|
onTrain: draft.onTrain !== false,
|
|
@@ -63605,6 +64254,217 @@ function decideFinishedState(rollouts) {
|
|
|
63605
64254
|
return succeeded === rollouts.length ? "succeeded" : "failed";
|
|
63606
64255
|
return succeeded > 0 && waiting > 0 ? "halted" : "failed";
|
|
63607
64256
|
}
|
|
64257
|
+
// ../../packages/praxis/deploy-core/src/root-ownership.ts
|
|
64258
|
+
var ROOT_OWNERSHIP_FILE = "root-ownership.yaml";
|
|
64259
|
+
var ROOT_OWNERSHIP_DEFAULT = "widen";
|
|
64260
|
+
function rootPatternMatches(match, path) {
|
|
64261
|
+
const directory = match.endsWith("/");
|
|
64262
|
+
const pattern = match.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
64263
|
+
if (!directory)
|
|
64264
|
+
return matchesPattern(pattern, path);
|
|
64265
|
+
const segments = path.split("/");
|
|
64266
|
+
for (let take = 1;take <= segments.length; take += 1) {
|
|
64267
|
+
if (matchesPattern(pattern, segments.slice(0, take).join("/")))
|
|
64268
|
+
return true;
|
|
64269
|
+
}
|
|
64270
|
+
return false;
|
|
64271
|
+
}
|
|
64272
|
+
function rootOwnershipMatchOf(path, table) {
|
|
64273
|
+
if (table === null)
|
|
64274
|
+
return { kind: "unknown" };
|
|
64275
|
+
for (const rule of table.rules) {
|
|
64276
|
+
if (!rootPatternMatches(rule.match, path))
|
|
64277
|
+
continue;
|
|
64278
|
+
if (rule.kind === "package")
|
|
64279
|
+
return { kind: "package", package: rule.package ?? "" };
|
|
64280
|
+
return { kind: rule.kind };
|
|
64281
|
+
}
|
|
64282
|
+
return { kind: "unknown" };
|
|
64283
|
+
}
|
|
64284
|
+
var KINDS = ["resolving", "package", "none"];
|
|
64285
|
+
function parseRootOwnership(text, options) {
|
|
64286
|
+
if (text === null) {
|
|
64287
|
+
return {
|
|
64288
|
+
kind: "invalid",
|
|
64289
|
+
problems: [
|
|
64290
|
+
{
|
|
64291
|
+
rule: -1,
|
|
64292
|
+
match: ROOT_OWNERSHIP_FILE,
|
|
64293
|
+
problem: `${ROOT_OWNERSHIP_FILE} is missing at this commit`
|
|
64294
|
+
}
|
|
64295
|
+
]
|
|
64296
|
+
};
|
|
64297
|
+
}
|
|
64298
|
+
let parsed;
|
|
64299
|
+
try {
|
|
64300
|
+
parsed = $parse(text);
|
|
64301
|
+
} catch (error) {
|
|
64302
|
+
return {
|
|
64303
|
+
kind: "invalid",
|
|
64304
|
+
problems: [
|
|
64305
|
+
{ rule: -1, match: ROOT_OWNERSHIP_FILE, problem: `not YAML: ${error.message}` }
|
|
64306
|
+
]
|
|
64307
|
+
};
|
|
64308
|
+
}
|
|
64309
|
+
const problems = [];
|
|
64310
|
+
const document2 = parsed ?? null;
|
|
64311
|
+
if (document2 === null || typeof document2 !== "object" || Array.isArray(document2)) {
|
|
64312
|
+
return {
|
|
64313
|
+
kind: "invalid",
|
|
64314
|
+
problems: [
|
|
64315
|
+
{ rule: -1, match: ROOT_OWNERSHIP_FILE, problem: "the document is not a mapping" }
|
|
64316
|
+
]
|
|
64317
|
+
};
|
|
64318
|
+
}
|
|
64319
|
+
if (document2.version !== 1) {
|
|
64320
|
+
problems.push({
|
|
64321
|
+
rule: -1,
|
|
64322
|
+
match: "version",
|
|
64323
|
+
problem: `version must be 1, found ${JSON.stringify(document2.version)}`
|
|
64324
|
+
});
|
|
64325
|
+
}
|
|
64326
|
+
if (document2.default !== ROOT_OWNERSHIP_DEFAULT) {
|
|
64327
|
+
problems.push({
|
|
64328
|
+
rule: -1,
|
|
64329
|
+
match: "default",
|
|
64330
|
+
problem: `default must be "${ROOT_OWNERSHIP_DEFAULT}" — a path no rule claims may never narrow the run`
|
|
64331
|
+
});
|
|
64332
|
+
}
|
|
64333
|
+
if (!Array.isArray(document2.rules)) {
|
|
64334
|
+
problems.push({ rule: -1, match: "rules", problem: "rules must be a list" });
|
|
64335
|
+
return { kind: "invalid", problems };
|
|
64336
|
+
}
|
|
64337
|
+
const workspace = new Set(options.workspaceDirs);
|
|
64338
|
+
const rules = [];
|
|
64339
|
+
document2.rules.forEach((entry, index) => {
|
|
64340
|
+
const rule = entry ?? null;
|
|
64341
|
+
if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
|
|
64342
|
+
problems.push({
|
|
64343
|
+
rule: index,
|
|
64344
|
+
match: "",
|
|
64345
|
+
problem: "a rule must be a mapping with match and kind"
|
|
64346
|
+
});
|
|
64347
|
+
return;
|
|
64348
|
+
}
|
|
64349
|
+
const match = typeof rule.match === "string" ? rule.match.trim() : "";
|
|
64350
|
+
const kind = typeof rule.kind === "string" ? rule.kind : "";
|
|
64351
|
+
if (match === "") {
|
|
64352
|
+
problems.push({ rule: index, match: "", problem: "match must be a non-empty string" });
|
|
64353
|
+
return;
|
|
64354
|
+
}
|
|
64355
|
+
if (!KINDS.includes(kind)) {
|
|
64356
|
+
problems.push({
|
|
64357
|
+
rule: index,
|
|
64358
|
+
match,
|
|
64359
|
+
problem: `kind must be one of ${KINDS.join(" / ")}, found ${JSON.stringify(rule.kind)}`
|
|
64360
|
+
});
|
|
64361
|
+
return;
|
|
64362
|
+
}
|
|
64363
|
+
const evidence = typeof rule.evidence === "string" ? rule.evidence.trim() : "";
|
|
64364
|
+
const why = typeof rule.why === "string" ? rule.why.trim() : "";
|
|
64365
|
+
if (kind === "package") {
|
|
64366
|
+
const owner = typeof rule.package === "string" ? rule.package.trim() : "";
|
|
64367
|
+
if (owner === "") {
|
|
64368
|
+
problems.push({
|
|
64369
|
+
rule: index,
|
|
64370
|
+
match,
|
|
64371
|
+
problem: "kind: package needs the workspace directory it belongs to"
|
|
64372
|
+
});
|
|
64373
|
+
return;
|
|
64374
|
+
}
|
|
64375
|
+
if (!workspace.has(owner)) {
|
|
64376
|
+
problems.push({
|
|
64377
|
+
rule: index,
|
|
64378
|
+
match,
|
|
64379
|
+
problem: `package "${owner}" is not a workspace package directory at this commit`
|
|
64380
|
+
});
|
|
64381
|
+
return;
|
|
64382
|
+
}
|
|
64383
|
+
if (evidence === "") {
|
|
64384
|
+
rules.push({ match, kind: "resolving", evidenceMissing: true, ...why === "" ? {} : { why } });
|
|
64385
|
+
return;
|
|
64386
|
+
}
|
|
64387
|
+
rules.push({ match, kind: "package", package: owner, evidence, ...why === "" ? {} : { why } });
|
|
64388
|
+
return;
|
|
64389
|
+
}
|
|
64390
|
+
if (rule.package !== undefined) {
|
|
64391
|
+
problems.push({
|
|
64392
|
+
rule: index,
|
|
64393
|
+
match,
|
|
64394
|
+
problem: `package is only allowed on kind: package (this rule is ${kind})`
|
|
64395
|
+
});
|
|
64396
|
+
return;
|
|
64397
|
+
}
|
|
64398
|
+
if (kind === "none" && evidence === "") {
|
|
64399
|
+
rules.push({ match, kind: "resolving", evidenceMissing: true, ...why === "" ? {} : { why } });
|
|
64400
|
+
return;
|
|
64401
|
+
}
|
|
64402
|
+
rules.push({
|
|
64403
|
+
match,
|
|
64404
|
+
kind,
|
|
64405
|
+
...evidence === "" ? {} : { evidence },
|
|
64406
|
+
...why === "" ? {} : { why }
|
|
64407
|
+
});
|
|
64408
|
+
});
|
|
64409
|
+
if (problems.length > 0)
|
|
64410
|
+
return { kind: "invalid", problems };
|
|
64411
|
+
const table = { version: 1, rules, default: ROOT_OWNERSHIP_DEFAULT };
|
|
64412
|
+
if (rootOwnershipMatchOf(ROOT_OWNERSHIP_FILE, table).kind !== "resolving") {
|
|
64413
|
+
return {
|
|
64414
|
+
kind: "invalid",
|
|
64415
|
+
problems: [
|
|
64416
|
+
{
|
|
64417
|
+
rule: -1,
|
|
64418
|
+
match: ROOT_OWNERSHIP_FILE,
|
|
64419
|
+
problem: `${ROOT_OWNERSHIP_FILE} must classify itself as resolving: a change to the table can change every package's inputs`
|
|
64420
|
+
}
|
|
64421
|
+
]
|
|
64422
|
+
};
|
|
64423
|
+
}
|
|
64424
|
+
return { kind: "table", table };
|
|
64425
|
+
}
|
|
64426
|
+
function namedPackagesOf(input) {
|
|
64427
|
+
const named = new Set;
|
|
64428
|
+
for (const path of input.changedPaths) {
|
|
64429
|
+
const dir = packageDirOf(path, input.workspaceDirs);
|
|
64430
|
+
if (dir !== null)
|
|
64431
|
+
named.add(dir);
|
|
64432
|
+
}
|
|
64433
|
+
const roots = rootOwnershipDecisionOf(input);
|
|
64434
|
+
for (const dir of roots.packages)
|
|
64435
|
+
if (input.workspaceDirs.includes(dir))
|
|
64436
|
+
named.add(dir);
|
|
64437
|
+
return { packages: roots.widened ? [] : [...named].sort(), roots };
|
|
64438
|
+
}
|
|
64439
|
+
function rootOwnershipDecisionOf(input) {
|
|
64440
|
+
const unclaimed = input.changedPaths.filter((path) => packageDirOf(path, input.workspaceDirs) === null);
|
|
64441
|
+
const named = new Set;
|
|
64442
|
+
const traces = [];
|
|
64443
|
+
let widened = false;
|
|
64444
|
+
for (const path of unclaimed) {
|
|
64445
|
+
if (input.table === null) {
|
|
64446
|
+
widened = true;
|
|
64447
|
+
traces.push({ path, reason: "table-unreadable" });
|
|
64448
|
+
continue;
|
|
64449
|
+
}
|
|
64450
|
+
const match = rootOwnershipMatchOf(path, input.table);
|
|
64451
|
+
if (match.kind === "package")
|
|
64452
|
+
named.add(match.package);
|
|
64453
|
+
else if (match.kind === "none")
|
|
64454
|
+
continue;
|
|
64455
|
+
else {
|
|
64456
|
+
widened = true;
|
|
64457
|
+
traces.push({ path, reason: match.kind });
|
|
64458
|
+
}
|
|
64459
|
+
}
|
|
64460
|
+
return {
|
|
64461
|
+
unclaimed,
|
|
64462
|
+
widened,
|
|
64463
|
+
traces,
|
|
64464
|
+
packages: widened ? [] : [...named].sort(),
|
|
64465
|
+
allNone: !widened && unclaimed.length > 0 && named.size === 0
|
|
64466
|
+
};
|
|
64467
|
+
}
|
|
63608
64468
|
// ../../packages/praxis/deploy-core/src/job-events-file.ts
|
|
63609
64469
|
import { appendFileSync, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
63610
64470
|
import { dirname as dirname3 } from "node:path";
|
|
@@ -63722,7 +64582,7 @@ function reportBlockedTarget(events, target, message) {
|
|
|
63722
64582
|
}
|
|
63723
64583
|
|
|
63724
64584
|
// src/commands/devops.ts
|
|
63725
|
-
var
|
|
64585
|
+
var import_yaml3 = __toESM(require_dist(), 1);
|
|
63726
64586
|
|
|
63727
64587
|
// src/commands/devops-deploy-plan.ts
|
|
63728
64588
|
import { resolve as resolve3 } from "node:path";
|
|
@@ -65107,7 +65967,7 @@ async function devopsDeployTofu(flags, ports) {
|
|
|
65107
65967
|
const projectYaml = await ports.readFile(join5(ports.cwd, "praxis.yaml"));
|
|
65108
65968
|
let parsedYaml;
|
|
65109
65969
|
try {
|
|
65110
|
-
parsedYaml = projectYaml === null ? undefined :
|
|
65970
|
+
parsedYaml = projectYaml === null ? undefined : import_yaml3.parse(projectYaml);
|
|
65111
65971
|
} catch (error) {
|
|
65112
65972
|
throw new UsageError(`praxis.yaml is not valid YAML: ${error.message}`);
|
|
65113
65973
|
}
|
|
@@ -65193,7 +66053,7 @@ function planTest(flags, paths) {
|
|
|
65193
66053
|
}
|
|
65194
66054
|
function requireSingleCtrfTarget(targets) {
|
|
65195
66055
|
if (targets > 1)
|
|
65196
|
-
throw new UsageError("--ctrf names one report file but this selection covers several packages", "Run one package at a time with --ctrf, or drop --ctrf and read each run's own .
|
|
66056
|
+
throw new UsageError("--ctrf names one report file but this selection covers several packages", "Run one package at a time with --ctrf, or drop --ctrf and read each run's own .praxis/ctrf/<run>.json.");
|
|
65197
66057
|
}
|
|
65198
66058
|
var FAILURE_LIMIT2 = 20;
|
|
65199
66059
|
var member3 = (value, key) => typeof value === "object" && value !== null ? value[key] : undefined;
|
|
@@ -65357,17 +66217,6 @@ function selectAffected(input) {
|
|
|
65357
66217
|
reasons[spelled.get(relative2)] = reason;
|
|
65358
66218
|
return { tests: selected.map(({ relative: relative2 }) => spelled.get(relative2)), features, reasons, openIssues: [...AFFECTED_OPEN_ISSUES] };
|
|
65359
66219
|
}
|
|
65360
|
-
function nearestPackage(path, packages) {
|
|
65361
|
-
let found = null;
|
|
65362
|
-
for (const candidate of packages) {
|
|
65363
|
-
const root = candidate.replace(/\/+$/, "");
|
|
65364
|
-
if (!root || !(path === root || path.startsWith(`${root}/`)))
|
|
65365
|
-
continue;
|
|
65366
|
-
if (found === null || root.length > found.length)
|
|
65367
|
-
found = root;
|
|
65368
|
-
}
|
|
65369
|
-
return found;
|
|
65370
|
-
}
|
|
65371
66220
|
var BUN_FILE_HEADER = /^(\S.*\.(?:test|spec)\.(?:ts|tsx|js|mjs)):$/;
|
|
65372
66221
|
var BUN_COUNT = /^\s*(\d+)\s+(pass|fail|skip|todo)\b/;
|
|
65373
66222
|
var BUN_RAN = /^Ran (\d+) tests? across/;
|
|
@@ -65428,6 +66277,30 @@ function bunTestRun(packagePath, code, output) {
|
|
|
65428
66277
|
}
|
|
65429
66278
|
|
|
65430
66279
|
// src/commands/devops-test.ts
|
|
66280
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
66281
|
+
var CACHE_OFF_REEXEC_ENV = "PRAXIS_DEVOPS_TEST_CACHE_OFF";
|
|
66282
|
+
function needsCacheOffReexec(env) {
|
|
66283
|
+
return env.BUN_RUNTIME_TRANSPILER_CACHE_PATH !== "0" && !env[CACHE_OFF_REEXEC_ENV];
|
|
66284
|
+
}
|
|
66285
|
+
function isDevopsTestRun(words) {
|
|
66286
|
+
return words.join(" ") === "devops test";
|
|
66287
|
+
}
|
|
66288
|
+
function spawnInherit(cmd, args, options) {
|
|
66289
|
+
return new Promise((resolveCode) => {
|
|
66290
|
+
const child = spawn4(cmd, [...args], { cwd: options.cwd, env: options.env, stdio: "inherit" });
|
|
66291
|
+
child.once("error", (error) => {
|
|
66292
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
66293
|
+
resolveCode(1);
|
|
66294
|
+
});
|
|
66295
|
+
child.once("close", (code) => resolveCode(code ?? 1));
|
|
66296
|
+
});
|
|
66297
|
+
}
|
|
66298
|
+
function reexecWithCacheOff(options = {}) {
|
|
66299
|
+
return (options.spawn ?? spawnInherit)(process.execPath, options.argv ?? process.argv.slice(1), {
|
|
66300
|
+
cwd: options.cwd ?? process.cwd(),
|
|
66301
|
+
env: { ...options.env ?? process.env, BUN_RUNTIME_TRANSPILER_CACHE_PATH: "0", [CACHE_OFF_REEXEC_ENV]: "1" }
|
|
66302
|
+
});
|
|
66303
|
+
}
|
|
65431
66304
|
async function devopsTest(flags, paths, ports) {
|
|
65432
66305
|
const plan = planTest(flags, paths);
|
|
65433
66306
|
if (plan.mode.kind === "affected")
|
|
@@ -65470,38 +66343,69 @@ async function changedSelection(since, ports) {
|
|
|
65470
66343
|
const roots = await ports.checkout.roots();
|
|
65471
66344
|
const grouped = new Map;
|
|
65472
66345
|
for (const file of files) {
|
|
65473
|
-
const owner =
|
|
66346
|
+
const owner = packageDirOf(file, roots);
|
|
65474
66347
|
if (owner === null)
|
|
65475
66348
|
continue;
|
|
65476
66349
|
grouped.set(owner, [...grouped.get(owner) ?? [], file]);
|
|
65477
66350
|
}
|
|
66351
|
+
const parsed = parseRootOwnership(await ports.checkout.read(ROOT_OWNERSHIP_FILE), { workspaceDirs: roots });
|
|
66352
|
+
const named = namedPackagesOf({ changedPaths: files, workspaceDirs: roots, table: parsed.kind === "table" ? parsed.table : null });
|
|
66353
|
+
const widen = named.roots.widened ? { paths: named.roots.traces.map((trace) => trace.path), reason: widenReason(named.roots.traces.map((trace) => trace.reason)) } : null;
|
|
66354
|
+
const failed = widen === null && files.length > 0 && named.packages.length === 0 && !named.roots.allNone ? { paths: [...named.roots.unclaimed].sort() } : null;
|
|
66355
|
+
const namedByTable = new Set(named.packages.filter((dir) => !grouped.has(dir)));
|
|
66356
|
+
const selectedRoots = widen !== null ? [...roots].sort((a, b) => a.localeCompare(b, "en")) : [...new Set([...grouped.keys(), ...namedByTable])].sort((a, b) => a.localeCompare(b, "en"));
|
|
65478
66357
|
const groups = [];
|
|
65479
|
-
for (const root of
|
|
66358
|
+
for (const root of selectedRoots) {
|
|
65480
66359
|
const packagePath = join6(ports.checkout.root, root);
|
|
65481
|
-
groups.push({
|
|
66360
|
+
groups.push({
|
|
66361
|
+
root,
|
|
66362
|
+
path: packagePath,
|
|
66363
|
+
whole: widen !== null || namedByTable.has(root),
|
|
66364
|
+
selection: selectAffected({ changed: grouped.get(root) ?? [], files: await ports.checkout.sources(packagePath), packageRoot: root })
|
|
66365
|
+
});
|
|
65482
66366
|
}
|
|
65483
66367
|
const owned = new Set([...grouped.values()].flat());
|
|
65484
|
-
return { base, files, groups, unowned: files.filter((file) => !owned.has(file)) };
|
|
66368
|
+
return { base, files, groups, unowned: files.filter((file) => !owned.has(file)), widen, failed };
|
|
66369
|
+
}
|
|
66370
|
+
function widenReason(reasons) {
|
|
66371
|
+
if (reasons.includes("table-unreadable"))
|
|
66372
|
+
return `${ROOT_OWNERSHIP_FILE} 读不出来(缺失或不合法),按整仓跑`;
|
|
66373
|
+
if (reasons.includes("unknown"))
|
|
66374
|
+
return "有仓库根路径没被表判定,按整仓跑";
|
|
66375
|
+
return "改到了仓库根的解析类文件(整仓都可能受影响)";
|
|
65485
66376
|
}
|
|
65486
66377
|
async function runAffected(list, since, ports) {
|
|
65487
|
-
const { base, files, groups, unowned } = await changedSelection(since, ports);
|
|
66378
|
+
const { base, files, groups, unowned, widen, failed } = await changedSelection(since, ports);
|
|
65488
66379
|
const view = {
|
|
65489
66380
|
since: base,
|
|
65490
66381
|
packages: groups.map((group) => ({
|
|
65491
66382
|
path: group.root,
|
|
65492
66383
|
tests: group.selection.tests.map((file) => ({ file, reason: group.selection.reasons[file] })),
|
|
65493
|
-
features: group.selection.features
|
|
66384
|
+
features: group.selection.features,
|
|
66385
|
+
...group.whole ? { whole: true } : {}
|
|
65494
66386
|
})),
|
|
65495
66387
|
tests: groups.flatMap((group) => group.selection.tests),
|
|
65496
66388
|
features: groups.flatMap((group) => group.selection.features),
|
|
65497
66389
|
unowned,
|
|
66390
|
+
widen,
|
|
66391
|
+
failed,
|
|
65498
66392
|
openIssues: [...selectAffected({ changed: [], files: new Map, packageRoot: "" }).openIssues]
|
|
65499
66393
|
};
|
|
65500
|
-
const lines = [
|
|
65501
|
-
...
|
|
65502
|
-
...
|
|
65503
|
-
|
|
65504
|
-
|
|
66394
|
+
const lines = [
|
|
66395
|
+
...widen === null ? [] : [`${widen.reason}:${widen.paths.join("、")} → 每个包整套测试`],
|
|
66396
|
+
...view.packages.flatMap((entry) => [
|
|
66397
|
+
...entry.tests.map(({ file, reason }) => `${file} (${reason})`),
|
|
66398
|
+
...entry.features.map((feature) => `${feature.file} (feature: ${feature.title})`)
|
|
66399
|
+
]),
|
|
66400
|
+
...view.openIssues.map((issue) => `note: ${issue}`)
|
|
66401
|
+
];
|
|
66402
|
+
if (failed !== null) {
|
|
66403
|
+
ports.emit({ kind: "object", data: view });
|
|
66404
|
+
ports.human([`选包塌成 0 个包:这些仓库根路径没有对应的包,也不在 ${ROOT_OWNERSHIP_FILE} 里被判成 none——先补表,别让它静默少跑:`, ...failed.paths].join(`
|
|
66405
|
+
`));
|
|
66406
|
+
return 1;
|
|
66407
|
+
}
|
|
66408
|
+
if (list || !groups.some((group) => group.whole) && view.tests.length === 0 && view.features.length === 0) {
|
|
65505
66409
|
ports.emit({ kind: "object", data: view });
|
|
65506
66410
|
ports.human([files.length === 0 ? `nothing changed since ${base}` : `${view.tests.length} test file(s) and ${view.features.length} feature(s) affected since ${base}:`, ...lines].join(`
|
|
65507
66411
|
`));
|
|
@@ -65509,9 +66413,9 @@ async function runAffected(list, since, ports) {
|
|
|
65509
66413
|
}
|
|
65510
66414
|
const runs = [];
|
|
65511
66415
|
for (const group of groups) {
|
|
65512
|
-
const
|
|
65513
|
-
if (
|
|
65514
|
-
const result = await ports.checkout.runTests(group.path,
|
|
66416
|
+
const selected = group.whole ? [] : group.selection.tests.map((file) => stripRoot(file, group.root));
|
|
66417
|
+
if (group.whole || selected.length) {
|
|
66418
|
+
const result = await ports.checkout.runTests(group.path, selected);
|
|
65515
66419
|
runs.push(bunTestRun(group.root, result.code, result.output));
|
|
65516
66420
|
}
|
|
65517
66421
|
for (const feature of group.selection.features)
|
|
@@ -65552,7 +66456,7 @@ async function devopsTestReportUpload(args, ports) {
|
|
|
65552
66456
|
if (id === undefined || id === "")
|
|
65553
66457
|
throw new UsageError("--upload needs --id", "Run `praxis devops test report` first to list this machine's runs, then pass one with --id.");
|
|
65554
66458
|
const root = await ports.root();
|
|
65555
|
-
const file = join6(root, ".
|
|
66459
|
+
const file = join6(root, ".praxis", "ctrf", `${id}.json`);
|
|
65556
66460
|
let report;
|
|
65557
66461
|
try {
|
|
65558
66462
|
report = await ports.readFile(file);
|
|
@@ -65698,8 +66602,8 @@ async function localEngine(cwd) {
|
|
|
65698
66602
|
})
|
|
65699
66603
|
};
|
|
65700
66604
|
}
|
|
65701
|
-
async function localCheckout(cwd,
|
|
65702
|
-
const git2 = (args) =>
|
|
66605
|
+
async function localCheckout(cwd, spawn5) {
|
|
66606
|
+
const git2 = (args) => spawn5("git", [...args], { cwd });
|
|
65703
66607
|
const required = async (args) => {
|
|
65704
66608
|
const result = await git2(args);
|
|
65705
66609
|
if (result.code !== 0)
|
|
@@ -65735,7 +66639,7 @@ async function localCheckout(cwd, spawn4) {
|
|
|
65735
66639
|
const files = new Map;
|
|
65736
66640
|
const walk = async (dir) => {
|
|
65737
66641
|
for (const entry of await readdir2(dir, { withFileTypes: true })) {
|
|
65738
|
-
if (["node_modules", ".git", "dist", ".
|
|
66642
|
+
if (["node_modules", ".git", "dist", ".praxis"].includes(entry.name))
|
|
65739
66643
|
continue;
|
|
65740
66644
|
const full = join6(dir, entry.name);
|
|
65741
66645
|
if (entry.isDirectory()) {
|
|
@@ -65750,7 +66654,16 @@ async function localCheckout(cwd, spawn4) {
|
|
|
65750
66654
|
await walk(packagePath);
|
|
65751
66655
|
return files;
|
|
65752
66656
|
},
|
|
65753
|
-
runTests: (packagePath, files) =>
|
|
66657
|
+
runTests: (packagePath, files) => spawn5("nice", ["-n", "10", "bun", "test", ...files], { cwd: packagePath }),
|
|
66658
|
+
read: async (path) => {
|
|
66659
|
+
try {
|
|
66660
|
+
return await readFile4(join6(root, path), "utf8");
|
|
66661
|
+
} catch (error) {
|
|
66662
|
+
if (error.code === "ENOENT")
|
|
66663
|
+
return null;
|
|
66664
|
+
throw error;
|
|
66665
|
+
}
|
|
66666
|
+
}
|
|
65754
66667
|
};
|
|
65755
66668
|
}
|
|
65756
66669
|
async function withEngineStdoutOnStderr(body) {
|
|
@@ -65927,7 +66840,7 @@ function removalSteps(key) {
|
|
|
65927
66840
|
`No code references ${key}. The rest is not this command's to do:`,
|
|
65928
66841
|
` 1. Deploy the code that removed the references (deploy never writes the trunk).`,
|
|
65929
66842
|
` 2. Retire the flag on the platform: praxis api devops flag archive <flg_…> — the terminal state.`,
|
|
65930
|
-
` Archiving keeps the key reserved and
|
|
66843
|
+
` Archiving keeps the key reserved, and is refused while reported references remain or an environment still has it on; there is no separate delete call (ADR-125 §4).`,
|
|
65931
66844
|
` 3. Regenerate the registry: praxis devops flag sync`
|
|
65932
66845
|
].join(`
|
|
65933
66846
|
`);
|
|
@@ -65957,6 +66870,25 @@ async function repositoryRoot(cwd, read) {
|
|
|
65957
66870
|
dir = parent;
|
|
65958
66871
|
}
|
|
65959
66872
|
}
|
|
66873
|
+
var SNIPPET_LIMIT = 200;
|
|
66874
|
+
function snippetOf(text2, line) {
|
|
66875
|
+
const trimmed = (text2.split(`
|
|
66876
|
+
`)[line - 1] ?? "").trim();
|
|
66877
|
+
return trimmed.length > SNIPPET_LIMIT ? trimmed.slice(0, SNIPPET_LIMIT) : trimmed;
|
|
66878
|
+
}
|
|
66879
|
+
function reportedKeys(keys, sources, refs) {
|
|
66880
|
+
const texts = new Map(sources.map((file) => [file.path, file.text]));
|
|
66881
|
+
return keys.map((flagKey) => ({
|
|
66882
|
+
flagKey,
|
|
66883
|
+
items: refs.filter((ref) => ref.key === flagKey).map((ref) => ({ path: ref.file, line: ref.line, snippet: snippetOf(texts.get(ref.file) ?? "", ref.line) }))
|
|
66884
|
+
}));
|
|
66885
|
+
}
|
|
66886
|
+
function reportNeedsProject() {
|
|
66887
|
+
return new UsageError("praxis devops flag refs --report needs the project to report into: --project <dvp_…>", "Pass the DevOps project id the flags belong to — `praxis api devops project list` lists them, or read devops.project from praxis.jsonc.");
|
|
66888
|
+
}
|
|
66889
|
+
function reportClientMissing() {
|
|
66890
|
+
return new UsageError("this CLI build has no client method for devops.flags.reportCodeRefs yet", "The route is declared in the protocol but the public /devops/v1 spec (and the SDK generated from it) does not carry it yet (#1881); the reference report cannot be sent until that is regenerated.");
|
|
66891
|
+
}
|
|
65960
66892
|
async function codeSources(ports, registry) {
|
|
65961
66893
|
const suffix = registry.replace(/^\.\//, "");
|
|
65962
66894
|
return (await ports.sources()).filter((file) => !file.path.replace(/^\.\//, "").endsWith(suffix));
|
|
@@ -66013,15 +66945,33 @@ async function devopsFlagScaffold(key, args, ports) {
|
|
|
66013
66945
|
ports.emit({ kind: "object", data: { key, registry, file, call: scaffoldCall(key) } });
|
|
66014
66946
|
return 0;
|
|
66015
66947
|
}
|
|
66016
|
-
async function devopsFlagRefs(key, ports) {
|
|
66948
|
+
async function devopsFlagRefs(key, args, ports) {
|
|
66017
66949
|
const registry = await registryOf(ports);
|
|
66018
66950
|
const flags = await ports.loadRegistry(registry);
|
|
66019
66951
|
const keys = key !== undefined ? [key] : Object.keys(flags).sort();
|
|
66020
|
-
const
|
|
66952
|
+
const sources = await codeSources(ports, registry);
|
|
66953
|
+
const refs = flagReferences(sources, keys);
|
|
66021
66954
|
for (const ref of refs)
|
|
66022
66955
|
ports.human(`${ref.file}:${ref.line}: ${ref.key}`);
|
|
66023
66956
|
ports.human(refs.length ? `${refs.length} reference(s) in ${new Set(refs.map((r) => r.file)).size} file(s).` : `No references to ${key ?? "any registered flag"} in this checkout.`);
|
|
66024
|
-
|
|
66957
|
+
if (!args.report) {
|
|
66958
|
+
ports.emit({ kind: "object", data: { refs, reported: false } });
|
|
66959
|
+
return 0;
|
|
66960
|
+
}
|
|
66961
|
+
const project = args.project;
|
|
66962
|
+
if (project === undefined || project === "")
|
|
66963
|
+
throw reportNeedsProject();
|
|
66964
|
+
const scannedCommit = (await ports.git(["rev-parse", "HEAD"])).trim();
|
|
66965
|
+
if (scannedCommit === "")
|
|
66966
|
+
throw new UsageError("git rev-parse HEAD answered no commit", "Run this command inside a git repository.");
|
|
66967
|
+
const payload = reportedKeys(Object.keys(flags).sort(), sources, refs);
|
|
66968
|
+
const client2 = await ports.client();
|
|
66969
|
+
const report = client2.devops?.projects?.flags?.reportCodeRefs;
|
|
66970
|
+
if (typeof report !== "function")
|
|
66971
|
+
throw reportClientMissing();
|
|
66972
|
+
const answer = await report.call(client2.devops.projects.flags, { path: { project }, body: { scannedCommit, refs: payload } });
|
|
66973
|
+
ports.human(`Reported ${refs.length} reference(s) over ${payload.length} key(s) to ${project} at ${scannedCommit}: ${answer.updated} flag(s) updated${answer.unknownKeys.length ? `; unknown key(s): ${answer.unknownKeys.join(", ")}` : ""}.`);
|
|
66974
|
+
ports.emit({ kind: "object", data: { refs, reported: true, project, scannedCommit, updated: answer.updated, unknownKeys: answer.unknownKeys } });
|
|
66025
66975
|
return 0;
|
|
66026
66976
|
}
|
|
66027
66977
|
async function devopsFlagRemove(key, ports) {
|
|
@@ -68671,6 +69621,7 @@ var FILE_ID = /^file-/;
|
|
|
68671
69621
|
var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
68672
69622
|
var isImage = (node2) => node2.type === "image" && typeof node2.url === "string";
|
|
68673
69623
|
var isRef = (node2) => node2.type === "ref" && typeof node2.ref === "string";
|
|
69624
|
+
var NODE_TYPES = new Set(Object.keys(KNOWN_PROPS));
|
|
68674
69625
|
function visit2(value, nodeId, fn) {
|
|
68675
69626
|
if (Array.isArray(value)) {
|
|
68676
69627
|
for (const item of value)
|
|
@@ -68864,6 +69815,8 @@ var warningLine = (warning) => {
|
|
|
68864
69815
|
return `${warning.code}: ${warning.ref} at ${warning.nodeId}`;
|
|
68865
69816
|
case "FRAME_NOT_FOUND":
|
|
68866
69817
|
return `${warning.code}: ${warning.id}`;
|
|
69818
|
+
case "IMAGE_FILE_NOT_FOUND":
|
|
69819
|
+
return `${warning.code}: ${warning.url} (the platform holds no such file) at ${warning.nodeId}`;
|
|
68867
69820
|
default:
|
|
68868
69821
|
return `${warning.code}: ${warning.url}`;
|
|
68869
69822
|
}
|
|
@@ -68971,6 +69924,537 @@ async function canvasImport(args, ports) {
|
|
|
68971
69924
|
return 0;
|
|
68972
69925
|
}
|
|
68973
69926
|
|
|
69927
|
+
// src/commands/events-wait.ts
|
|
69928
|
+
var DEFAULT_AGENT = "R1M9TQ2X";
|
|
69929
|
+
var BASE_BACKOFF_MS = 1000;
|
|
69930
|
+
var MAX_BACKOFF_MS = 60000;
|
|
69931
|
+
var NOTICE_NAMED = 5;
|
|
69932
|
+
var ANNOUNCED_KEEP = 500;
|
|
69933
|
+
function assumeAgentOf(env) {
|
|
69934
|
+
return env.PRAXIS_ASSUME_AGENT?.trim() || DEFAULT_AGENT;
|
|
69935
|
+
}
|
|
69936
|
+
function sessionOf(raw) {
|
|
69937
|
+
if (raw === undefined)
|
|
69938
|
+
return null;
|
|
69939
|
+
const session = raw.trim();
|
|
69940
|
+
if (!/^[A-Za-z0-9_-]{1,128}$/.test(session))
|
|
69941
|
+
throw new Error("--session takes the Claude Code session id (letters, digits, - and _)");
|
|
69942
|
+
return session;
|
|
69943
|
+
}
|
|
69944
|
+
var keyPart = (part) => part.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
69945
|
+
function waitKeyOf(env, agent, session) {
|
|
69946
|
+
return [env, agent, ...session === null ? [] : [session]].map(keyPart).join("-");
|
|
69947
|
+
}
|
|
69948
|
+
function pidOf(raw) {
|
|
69949
|
+
const pid = raw === null ? NaN : Number(raw.trim());
|
|
69950
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
69951
|
+
}
|
|
69952
|
+
function lockDecision(recorded, self, probe) {
|
|
69953
|
+
if (recorded === null || recorded === self || probe === null || !probe.alive)
|
|
69954
|
+
return { kind: "take" };
|
|
69955
|
+
if (!/events\s+wait/.test(probe.command))
|
|
69956
|
+
return { kind: "take" };
|
|
69957
|
+
if (probe.ppid === 1)
|
|
69958
|
+
return { kind: "replace", pid: recorded };
|
|
69959
|
+
return { kind: "refuse", pid: recorded };
|
|
69960
|
+
}
|
|
69961
|
+
function alreadyWaitingNotice(pid) {
|
|
69962
|
+
return `本会话已有 praxis agent events wait 在后台等待(pid ${pid}),不用再启动。`;
|
|
69963
|
+
}
|
|
69964
|
+
async function acquireWaitLock(ports) {
|
|
69965
|
+
for (let attempt = 0;attempt < 3; attempt++) {
|
|
69966
|
+
const recorded = pidOf(await ports.readPid());
|
|
69967
|
+
if (recorded === null) {
|
|
69968
|
+
if (await ports.createPid(String(ports.self)))
|
|
69969
|
+
return null;
|
|
69970
|
+
continue;
|
|
69971
|
+
}
|
|
69972
|
+
const decision = lockDecision(recorded, ports.self, await ports.probe(recorded));
|
|
69973
|
+
if (decision.kind === "refuse")
|
|
69974
|
+
return decision.pid;
|
|
69975
|
+
if (decision.kind === "replace")
|
|
69976
|
+
ports.terminate(decision.pid);
|
|
69977
|
+
await ports.replacePid(String(ports.self));
|
|
69978
|
+
const holder = pidOf(await ports.readPid());
|
|
69979
|
+
return holder === ports.self || holder === null ? null : holder;
|
|
69980
|
+
}
|
|
69981
|
+
return pidOf(await ports.readPid());
|
|
69982
|
+
}
|
|
69983
|
+
function timeoutMsOf(raw) {
|
|
69984
|
+
if (raw === undefined)
|
|
69985
|
+
return null;
|
|
69986
|
+
const seconds = Number(raw);
|
|
69987
|
+
if (!/^\d+(\.\d+)?$/.test(raw.trim()) || !Number.isFinite(seconds) || seconds <= 0)
|
|
69988
|
+
throw new Error("--timeout takes a positive number of seconds");
|
|
69989
|
+
return Math.round(seconds * 1000);
|
|
69990
|
+
}
|
|
69991
|
+
function backoffMs(failures) {
|
|
69992
|
+
if (failures <= 0)
|
|
69993
|
+
return 0;
|
|
69994
|
+
return Math.min(MAX_BACKOFF_MS, BASE_BACKOFF_MS * 2 ** Math.min(failures - 1, 16));
|
|
69995
|
+
}
|
|
69996
|
+
function inboxLettersUrl(apiUrl, agent) {
|
|
69997
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/inbox/letters?unread=true&limit=20`;
|
|
69998
|
+
}
|
|
69999
|
+
function eventsStreamUrl(apiUrl, agent) {
|
|
70000
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/events/stream`;
|
|
70001
|
+
}
|
|
70002
|
+
function streamHeaders(auth, lastEventId) {
|
|
70003
|
+
return { ...auth, Accept: "text/event-stream", ...lastEventId === null ? {} : { "Last-Event-ID": lastEventId } };
|
|
70004
|
+
}
|
|
70005
|
+
function lettersOf(body) {
|
|
70006
|
+
const value = body;
|
|
70007
|
+
if (!value || typeof value.unread !== "number" || !Array.isArray(value.letters))
|
|
70008
|
+
throw new Error("letters answer is not { unread, letters }");
|
|
70009
|
+
const letters = value.letters.filter((letter) => typeof letter === "object" && letter !== null && typeof letter.id === "string" && typeof letter.summary === "string");
|
|
70010
|
+
return { unread: value.unread, letters };
|
|
70011
|
+
}
|
|
70012
|
+
function feedSse(buffer, chunk) {
|
|
70013
|
+
const text2 = (buffer + chunk).replace(/\r\n?/g, `
|
|
70014
|
+
`);
|
|
70015
|
+
const blocks = text2.split(`
|
|
70016
|
+
|
|
70017
|
+
`);
|
|
70018
|
+
const rest = blocks.pop() ?? "";
|
|
70019
|
+
const frames = [];
|
|
70020
|
+
for (const block of blocks) {
|
|
70021
|
+
let event, id;
|
|
70022
|
+
const data = [];
|
|
70023
|
+
for (const line of block.split(`
|
|
70024
|
+
`)) {
|
|
70025
|
+
if (line === "" || line.startsWith(":"))
|
|
70026
|
+
continue;
|
|
70027
|
+
const colon = line.indexOf(":");
|
|
70028
|
+
const field = colon < 0 ? line : line.slice(0, colon);
|
|
70029
|
+
const value = colon < 0 ? "" : line.slice(colon + 1).replace(/^ /, "");
|
|
70030
|
+
if (field === "data")
|
|
70031
|
+
data.push(value);
|
|
70032
|
+
else if (field === "event")
|
|
70033
|
+
event = value;
|
|
70034
|
+
else if (field === "id")
|
|
70035
|
+
id = value;
|
|
70036
|
+
}
|
|
70037
|
+
if (data.length)
|
|
70038
|
+
frames.push({ ...event === undefined ? {} : { event }, ...id === undefined ? {} : { id }, data: data.join(`
|
|
70039
|
+
`) });
|
|
70040
|
+
}
|
|
70041
|
+
return { buffer: rest, frames };
|
|
70042
|
+
}
|
|
70043
|
+
var text2 = (value) => typeof value === "string" && value !== "";
|
|
70044
|
+
function wakeOf(frame) {
|
|
70045
|
+
let event;
|
|
70046
|
+
try {
|
|
70047
|
+
event = JSON.parse(frame.data);
|
|
70048
|
+
} catch {
|
|
70049
|
+
return null;
|
|
70050
|
+
}
|
|
70051
|
+
if (typeof event !== "object" || event === null)
|
|
70052
|
+
return null;
|
|
70053
|
+
if (event.type === "inbox.letter_delivered" && text2(event.letter_id) && typeof event.summary === "string")
|
|
70054
|
+
return { kind: "letter", letter: {
|
|
70055
|
+
id: event.letter_id,
|
|
70056
|
+
sender: typeof event.sender === "string" ? event.sender : "",
|
|
70057
|
+
...text2(event.sender_name) ? { sender_name: event.sender_name } : {},
|
|
70058
|
+
summary: event.summary,
|
|
70059
|
+
thread: typeof event.thread === "string" ? event.thread : null,
|
|
70060
|
+
create_time: typeof event.create_time === "string" ? event.create_time : ""
|
|
70061
|
+
} };
|
|
70062
|
+
if (event.type === "cognition.ritual_held" && text2(event.title))
|
|
70063
|
+
return { kind: "ritual", ritual: {
|
|
70064
|
+
ritual: text2(event.ritual) ? event.ritual : "",
|
|
70065
|
+
owner: text2(event.owner) ? event.owner : "",
|
|
70066
|
+
title: event.title,
|
|
70067
|
+
engram: text2(event.engram) ? event.engram : ""
|
|
70068
|
+
} };
|
|
70069
|
+
return null;
|
|
70070
|
+
}
|
|
70071
|
+
function ritualNotice(ritual) {
|
|
70072
|
+
const origin = [ritual.owner, ritual.ritual].filter(Boolean).join(" 的仪式 ");
|
|
70073
|
+
return `你获得了一段新记忆:「${ritual.title}」${origin ? `(${origin}${ritual.engram ? `,${ritual.engram}` : ""})` : ""}。处理完再在后台运行 praxis agent events wait。`;
|
|
70074
|
+
}
|
|
70075
|
+
function retryableStatus(status) {
|
|
70076
|
+
return status >= 500 || status === 408 || status === 429;
|
|
70077
|
+
}
|
|
70078
|
+
function planNotice(page, announced) {
|
|
70079
|
+
const seen = new Set(announced);
|
|
70080
|
+
const fresh = page.letters.filter((letter) => !seen.has(letter.id));
|
|
70081
|
+
if (!fresh.length)
|
|
70082
|
+
return { announced };
|
|
70083
|
+
const named = fresh.slice(0, NOTICE_NAMED).map((letter) => `${letter.sender_name || letter.sender}:${letter.summary}(${letter.id})`);
|
|
70084
|
+
const more = fresh.length > NOTICE_NAMED ? `;另有 ${fresh.length - NOTICE_NAMED} 封` : "";
|
|
70085
|
+
const notice = `你有 ${fresh.length} 封新信:${named.join(";")}${more}。用 praxis_assume_inbox(action "read")读取并处理,处理完再在后台运行 praxis agent events wait。`;
|
|
70086
|
+
const next = [...announced, ...fresh.map((letter) => letter.id)];
|
|
70087
|
+
return { notice, announced: next.length > ANNOUNCED_KEEP ? next.slice(next.length - ANNOUNCED_KEEP) : next };
|
|
70088
|
+
}
|
|
70089
|
+
function waitStateOf(raw) {
|
|
70090
|
+
if (raw === null)
|
|
70091
|
+
return { announced: [], lastEventId: null };
|
|
70092
|
+
try {
|
|
70093
|
+
const value = JSON.parse(raw);
|
|
70094
|
+
return {
|
|
70095
|
+
announced: Array.isArray(value.announced) ? value.announced.filter((id) => typeof id === "string") : [],
|
|
70096
|
+
lastEventId: typeof value.last_event_id === "string" && /^\d+$/.test(value.last_event_id) ? value.last_event_id : null
|
|
70097
|
+
};
|
|
70098
|
+
} catch {
|
|
70099
|
+
return { announced: [], lastEventId: null };
|
|
70100
|
+
}
|
|
70101
|
+
}
|
|
70102
|
+
function waitStateText(state) {
|
|
70103
|
+
return JSON.stringify({ announced: state.announced, ...state.lastEventId === null ? {} : { last_event_id: state.lastEventId } });
|
|
70104
|
+
}
|
|
70105
|
+
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
70106
|
+
async function runEventsWait(ports) {
|
|
70107
|
+
const stop = new AbortController;
|
|
70108
|
+
let timedOut = false;
|
|
70109
|
+
const timer = ports.timeoutMs === null ? undefined : setTimeout(() => {
|
|
70110
|
+
timedOut = true;
|
|
70111
|
+
stop.abort();
|
|
70112
|
+
}, ports.timeoutMs);
|
|
70113
|
+
const state = await ports.readState();
|
|
70114
|
+
let announced = state.announced;
|
|
70115
|
+
let lastEventId = state.lastEventId;
|
|
70116
|
+
const announceLetters = async (page) => {
|
|
70117
|
+
const planned = planNotice(page, announced);
|
|
70118
|
+
if (!planned.notice)
|
|
70119
|
+
return false;
|
|
70120
|
+
announced = planned.announced;
|
|
70121
|
+
await ports.writeState({ announced, lastEventId });
|
|
70122
|
+
ports.print(planned.notice);
|
|
70123
|
+
return true;
|
|
70124
|
+
};
|
|
70125
|
+
const announce = async () => announceLetters(await ports.fetchLetters());
|
|
70126
|
+
try {
|
|
70127
|
+
try {
|
|
70128
|
+
if (await announce())
|
|
70129
|
+
return 0;
|
|
70130
|
+
} catch (error) {
|
|
70131
|
+
ports.log(`praxis agent events wait: reading letters failed: ${message(error)}`);
|
|
70132
|
+
}
|
|
70133
|
+
ports.log(`praxis agent events wait: waiting for letters to assume agent ${ports.agent}`);
|
|
70134
|
+
let failures = 0;
|
|
70135
|
+
while (!stop.signal.aborted) {
|
|
70136
|
+
if (failures)
|
|
70137
|
+
await ports.sleep(backoffMs(failures), stop.signal);
|
|
70138
|
+
if (stop.signal.aborted)
|
|
70139
|
+
break;
|
|
70140
|
+
try {
|
|
70141
|
+
const opened = await ports.openStream(stop.signal, lastEventId);
|
|
70142
|
+
if (opened.status < 200 || opened.status >= 300 || !opened.chunks) {
|
|
70143
|
+
if (!retryableStatus(opened.status)) {
|
|
70144
|
+
ports.log(`praxis agent events wait: the event stream was refused (HTTP ${opened.status}${opened.reason ? `: ${opened.reason}` : ""})`);
|
|
70145
|
+
return 1;
|
|
70146
|
+
}
|
|
70147
|
+
throw new Error(`HTTP ${opened.status}`);
|
|
70148
|
+
}
|
|
70149
|
+
if (await announce())
|
|
70150
|
+
return 0;
|
|
70151
|
+
if (failures)
|
|
70152
|
+
ports.log("praxis agent events wait: event stream reconnected");
|
|
70153
|
+
failures = 0;
|
|
70154
|
+
let buffer = "";
|
|
70155
|
+
for await (const chunk of opened.chunks) {
|
|
70156
|
+
const fed = feedSse(buffer, chunk);
|
|
70157
|
+
buffer = fed.buffer;
|
|
70158
|
+
for (const frame of fed.frames) {
|
|
70159
|
+
const wake = wakeOf(frame);
|
|
70160
|
+
if (wake !== null && frame.id !== undefined)
|
|
70161
|
+
lastEventId = frame.id;
|
|
70162
|
+
if (wake?.kind === "letter" && await announceLetters({ unread: 1, letters: [wake.letter] }))
|
|
70163
|
+
return 0;
|
|
70164
|
+
if (wake?.kind === "ritual") {
|
|
70165
|
+
await ports.writeState({ announced, lastEventId });
|
|
70166
|
+
ports.print(ritualNotice(wake.ritual));
|
|
70167
|
+
return 0;
|
|
70168
|
+
}
|
|
70169
|
+
}
|
|
70170
|
+
}
|
|
70171
|
+
throw new Error("the event stream ended");
|
|
70172
|
+
} catch (error) {
|
|
70173
|
+
if (stop.signal.aborted)
|
|
70174
|
+
break;
|
|
70175
|
+
failures += 1;
|
|
70176
|
+
ports.log(`praxis agent events wait: ${message(error)} (${failures} in a row, reconnecting in ${backoffMs(failures) / 1000}s)`);
|
|
70177
|
+
}
|
|
70178
|
+
}
|
|
70179
|
+
if (timedOut)
|
|
70180
|
+
ports.print(`${(ports.timeoutMs ?? 0) / 1000} 秒内没有新信。需要继续等待时再在后台运行 praxis agent events wait。`);
|
|
70181
|
+
return 0;
|
|
70182
|
+
} finally {
|
|
70183
|
+
if (timer)
|
|
70184
|
+
clearTimeout(timer);
|
|
70185
|
+
stop.abort();
|
|
70186
|
+
}
|
|
70187
|
+
}
|
|
70188
|
+
|
|
70189
|
+
// src/commands/events-channel.ts
|
|
70190
|
+
var CHANNEL_SOURCE = "assume-agent";
|
|
70191
|
+
var SERVER_NAME = "assume-channel";
|
|
70192
|
+
var DEFAULT_PROTOCOL_VERSION = "2025-06-18";
|
|
70193
|
+
var BACKLOG_NAMED = 5;
|
|
70194
|
+
function channelInstructions(agent) {
|
|
70195
|
+
return [
|
|
70196
|
+
`Events from your Praxis assume agent ${agent} arrive as <channel source="${CHANNEL_SOURCE}" kind="letter" letter_id="…" sender="…">.`,
|
|
70197
|
+
'kind="letter": a letter reached the agent. The content names the sender and the summary; read the letters with the praxis_assume_inbox tool (action "read") and handle them.',
|
|
70198
|
+
'kind="ritual": the agent was given a new memory (a ritual was held); its knowledge is refreshed, nothing to reply to.',
|
|
70199
|
+
"The channel is one-way: answer through the praxis_assume_* tools, not back through the channel."
|
|
70200
|
+
].join(`
|
|
70201
|
+
`);
|
|
70202
|
+
}
|
|
70203
|
+
function initializeResult(params, agent) {
|
|
70204
|
+
const asked = params?.protocolVersion;
|
|
70205
|
+
return {
|
|
70206
|
+
protocolVersion: typeof asked === "string" ? asked : DEFAULT_PROTOCOL_VERSION,
|
|
70207
|
+
capabilities: { experimental: { "claude/channel": {} } },
|
|
70208
|
+
serverInfo: { name: SERVER_NAME, version: "0.1.0" },
|
|
70209
|
+
instructions: channelInstructions(agent)
|
|
70210
|
+
};
|
|
70211
|
+
}
|
|
70212
|
+
function replyTo(message2, agent) {
|
|
70213
|
+
if (message2.id === undefined || message2.id === null || typeof message2.method !== "string")
|
|
70214
|
+
return null;
|
|
70215
|
+
const reply = (body) => ({ jsonrpc: "2.0", id: message2.id, ...body });
|
|
70216
|
+
switch (message2.method) {
|
|
70217
|
+
case "initialize":
|
|
70218
|
+
return reply({ result: initializeResult(message2.params, agent) });
|
|
70219
|
+
case "ping":
|
|
70220
|
+
return reply({ result: {} });
|
|
70221
|
+
default:
|
|
70222
|
+
return reply({ error: { code: -32601, message: `Method not found: ${message2.method}` } });
|
|
70223
|
+
}
|
|
70224
|
+
}
|
|
70225
|
+
var sender = (letter) => letter.sender_name || letter.sender;
|
|
70226
|
+
var readHint = 'Read it with praxis_assume_inbox (action "read").';
|
|
70227
|
+
var frame = (content, meta) => ({ jsonrpc: "2.0", method: "notifications/claude/channel", params: { content, meta } });
|
|
70228
|
+
function letterNotification(letter) {
|
|
70229
|
+
return frame(`${sender(letter)}: ${letter.summary}
|
|
70230
|
+
${readHint}`, { kind: "letter", letter_id: letter.id, sender: letter.sender, ...letter.sender_name ? { sender_name: letter.sender_name } : {} });
|
|
70231
|
+
}
|
|
70232
|
+
function backlogNotification(letters) {
|
|
70233
|
+
const named = letters.slice(0, BACKLOG_NAMED).map((letter) => `${sender(letter)}: ${letter.summary} (${letter.id})`);
|
|
70234
|
+
const more = letters.length > BACKLOG_NAMED ? `; ${letters.length - BACKLOG_NAMED} more` : "";
|
|
70235
|
+
return frame(`${letters.length} unread letter(s) waiting: ${named.join("; ")}${more}
|
|
70236
|
+
${readHint}`, { kind: "letter", letter_id: letters[0].id, sender: letters[0].sender, count: String(letters.length) });
|
|
70237
|
+
}
|
|
70238
|
+
function ritualNotification(ritual) {
|
|
70239
|
+
return frame(`New memory: "${ritual.title}"${ritual.owner ? ` (${ritual.owner}${ritual.ritual ? ` ${ritual.ritual}` : ""})` : ""}. Your knowledge is refreshed.`, { kind: "ritual", ...ritual.ritual ? { ritual: ritual.ritual } : {}, ...ritual.engram ? { engram: ritual.engram } : {} });
|
|
70240
|
+
}
|
|
70241
|
+
async function runChannel(ports) {
|
|
70242
|
+
const stop = new AbortController;
|
|
70243
|
+
const seen = new Set;
|
|
70244
|
+
let lastEventId = null;
|
|
70245
|
+
let follower = null;
|
|
70246
|
+
const fresh = (letters) => letters.filter((letter) => !seen.has(letter.id) && (seen.add(letter.id), true));
|
|
70247
|
+
const catchUp = async () => {
|
|
70248
|
+
const letters = fresh((await ports.fetchLetters()).letters);
|
|
70249
|
+
if (letters.length)
|
|
70250
|
+
ports.send(backlogNotification(letters));
|
|
70251
|
+
};
|
|
70252
|
+
const follow = async () => {
|
|
70253
|
+
let failures = 0;
|
|
70254
|
+
while (!stop.signal.aborted) {
|
|
70255
|
+
if (failures)
|
|
70256
|
+
await ports.sleep(backoffMs(failures), stop.signal);
|
|
70257
|
+
if (stop.signal.aborted)
|
|
70258
|
+
break;
|
|
70259
|
+
try {
|
|
70260
|
+
const opened = await ports.openStream(stop.signal, lastEventId);
|
|
70261
|
+
if (opened.status < 200 || opened.status >= 300 || !opened.chunks) {
|
|
70262
|
+
if (!retryableStatus(opened.status)) {
|
|
70263
|
+
ports.log(`assume-channel: the event stream was refused (HTTP ${opened.status}${opened.reason ? `: ${opened.reason}` : ""})`);
|
|
70264
|
+
return;
|
|
70265
|
+
}
|
|
70266
|
+
throw new Error(`HTTP ${opened.status}`);
|
|
70267
|
+
}
|
|
70268
|
+
try {
|
|
70269
|
+
await catchUp();
|
|
70270
|
+
} catch (error) {
|
|
70271
|
+
ports.log(`assume-channel: reading letters failed: ${error instanceof Error ? error.message : error}`);
|
|
70272
|
+
}
|
|
70273
|
+
if (failures)
|
|
70274
|
+
ports.log("assume-channel: event stream reconnected");
|
|
70275
|
+
failures = 0;
|
|
70276
|
+
let buffer2 = "";
|
|
70277
|
+
for await (const chunk of opened.chunks) {
|
|
70278
|
+
const fed = feedSse(buffer2, chunk);
|
|
70279
|
+
buffer2 = fed.buffer;
|
|
70280
|
+
for (const raw of fed.frames) {
|
|
70281
|
+
const wake = wakeOf(raw);
|
|
70282
|
+
if (wake === null)
|
|
70283
|
+
continue;
|
|
70284
|
+
if (raw.id !== undefined)
|
|
70285
|
+
lastEventId = raw.id;
|
|
70286
|
+
if (wake.kind === "letter") {
|
|
70287
|
+
if (fresh([wake.letter]).length)
|
|
70288
|
+
ports.send(letterNotification(wake.letter));
|
|
70289
|
+
} else
|
|
70290
|
+
ports.send(ritualNotification(wake.ritual));
|
|
70291
|
+
}
|
|
70292
|
+
}
|
|
70293
|
+
throw new Error("the event stream ended");
|
|
70294
|
+
} catch (error) {
|
|
70295
|
+
if (stop.signal.aborted)
|
|
70296
|
+
break;
|
|
70297
|
+
failures += 1;
|
|
70298
|
+
ports.log(`assume-channel: ${error instanceof Error ? error.message : error} (${failures} in a row, reconnecting in ${backoffMs(failures) / 1000}s)`);
|
|
70299
|
+
}
|
|
70300
|
+
}
|
|
70301
|
+
};
|
|
70302
|
+
let buffer = "";
|
|
70303
|
+
const handle = (line) => {
|
|
70304
|
+
if (!line.trim())
|
|
70305
|
+
return;
|
|
70306
|
+
let message2;
|
|
70307
|
+
try {
|
|
70308
|
+
message2 = JSON.parse(line);
|
|
70309
|
+
} catch {
|
|
70310
|
+
ports.log("assume-channel: ignored a line that is not JSON");
|
|
70311
|
+
return;
|
|
70312
|
+
}
|
|
70313
|
+
const reply = replyTo(message2, ports.agent);
|
|
70314
|
+
if (reply)
|
|
70315
|
+
ports.send(reply);
|
|
70316
|
+
if (message2.method === "notifications/initialized" && follower === null)
|
|
70317
|
+
follower = follow();
|
|
70318
|
+
};
|
|
70319
|
+
for await (const chunk of ports.input) {
|
|
70320
|
+
buffer += chunk;
|
|
70321
|
+
const lines = buffer.split(`
|
|
70322
|
+
`);
|
|
70323
|
+
buffer = lines.pop() ?? "";
|
|
70324
|
+
for (const line of lines)
|
|
70325
|
+
handle(line);
|
|
70326
|
+
}
|
|
70327
|
+
handle(buffer);
|
|
70328
|
+
stop.abort();
|
|
70329
|
+
await follower;
|
|
70330
|
+
return 0;
|
|
70331
|
+
}
|
|
70332
|
+
|
|
70333
|
+
// src/commands/agent-memory.ts
|
|
70334
|
+
var MEMORY_TOOL = "praxis_assume_memory";
|
|
70335
|
+
var RECALL_TOOL = "praxis_assume_recall";
|
|
70336
|
+
var REMEMBER_TOOL = "praxis_assume_remember";
|
|
70337
|
+
function mcpUrl(apiUrl, agent) {
|
|
70338
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/mcp`;
|
|
70339
|
+
}
|
|
70340
|
+
function rpcAnswerOf(body, id) {
|
|
70341
|
+
const candidates2 = body.trimStart().startsWith("{") ? [body] : body.split(`
|
|
70342
|
+
`).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim());
|
|
70343
|
+
for (const candidate of candidates2) {
|
|
70344
|
+
try {
|
|
70345
|
+
const parsed = JSON.parse(candidate);
|
|
70346
|
+
if (parsed.id === id)
|
|
70347
|
+
return parsed;
|
|
70348
|
+
} catch {}
|
|
70349
|
+
}
|
|
70350
|
+
return null;
|
|
70351
|
+
}
|
|
70352
|
+
function toolTextOf(result) {
|
|
70353
|
+
const value = result;
|
|
70354
|
+
const text3 = (value?.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join(`
|
|
70355
|
+
`).trim();
|
|
70356
|
+
return value?.isError === true ? { ok: false, reason: text3 || "the tool refused" } : { ok: true, text: text3 };
|
|
70357
|
+
}
|
|
70358
|
+
async function callAgentTool(ports, url, name, args, signal) {
|
|
70359
|
+
const base = { ...await ports.headers(), "Content-Type": "application/json", Accept: "application/json, text/event-stream" };
|
|
70360
|
+
const post = (body, session2) => ports.fetch(url, {
|
|
70361
|
+
method: "POST",
|
|
70362
|
+
headers: { ...base, ...session2 === undefined ? {} : { "Mcp-Session-Id": session2 } },
|
|
70363
|
+
body: JSON.stringify(body),
|
|
70364
|
+
...signal === undefined ? {} : { signal },
|
|
70365
|
+
redirect: "error"
|
|
70366
|
+
});
|
|
70367
|
+
const init = await post({ jsonrpc: "2.0", id: 1, method: "initialize", params: {
|
|
70368
|
+
protocolVersion: "2025-06-18",
|
|
70369
|
+
capabilities: {},
|
|
70370
|
+
clientInfo: { name: "praxis-cli-memory", version: "1" }
|
|
70371
|
+
} });
|
|
70372
|
+
const initBody = await init.text();
|
|
70373
|
+
if (!init.ok)
|
|
70374
|
+
throw new Error(`HTTP ${init.status} on initialize`);
|
|
70375
|
+
const session = init.headers.get("Mcp-Session-Id") ?? undefined;
|
|
70376
|
+
const initAnswer = rpcAnswerOf(initBody, 1);
|
|
70377
|
+
if (initAnswer?.error)
|
|
70378
|
+
throw new Error(initAnswer.error.message ?? "initialize failed");
|
|
70379
|
+
await post({ jsonrpc: "2.0", method: "notifications/initialized" }, session).then((r) => r.text()).catch(() => "");
|
|
70380
|
+
const call3 = await post({ jsonrpc: "2.0", id: 2, method: "tools/call", params: { name, arguments: args } }, session);
|
|
70381
|
+
const callBody = await call3.text();
|
|
70382
|
+
if (!call3.ok)
|
|
70383
|
+
throw new Error(`HTTP ${call3.status} on ${name}`);
|
|
70384
|
+
const answer = rpcAnswerOf(callBody, 2);
|
|
70385
|
+
if (answer === null)
|
|
70386
|
+
throw new Error(`no answer from ${name}`);
|
|
70387
|
+
if (answer.error)
|
|
70388
|
+
throw new Error(answer.error.message ?? `${name} failed`);
|
|
70389
|
+
const text3 = toolTextOf(answer.result);
|
|
70390
|
+
if (!text3.ok)
|
|
70391
|
+
throw new Error(text3.reason);
|
|
70392
|
+
return text3.text;
|
|
70393
|
+
}
|
|
70394
|
+
function memoryBodyOf(text3) {
|
|
70395
|
+
return text3.split(`
|
|
70396
|
+
`).filter((line) => {
|
|
70397
|
+
const trimmed = line.trim();
|
|
70398
|
+
return !/^shell: acon_/.test(trimmed) && !/^你有 \d+ 封未读信/.test(trimmed) && !/^You have \d+ unread letter/.test(trimmed);
|
|
70399
|
+
}).join(`
|
|
70400
|
+
`).trim();
|
|
70401
|
+
}
|
|
70402
|
+
function paragraphKey(paragraph) {
|
|
70403
|
+
return paragraph.replace(/\s*\[n\d+\]/g, "").replace(/\s+/g, " ").trim();
|
|
70404
|
+
}
|
|
70405
|
+
function newParagraphs(memory, seen) {
|
|
70406
|
+
const seenKeys = new Set([...seen].map(paragraphKey));
|
|
70407
|
+
return memory.split(/\n{2,}/).map((part) => part.trim()).filter((part) => part !== "" && !seenKeys.has(paragraphKey(part)));
|
|
70408
|
+
}
|
|
70409
|
+
var MEMORY_FRAME = (body) => `<memory source="praxis-assume" note="your memory as this agent, drawn from your organization just now; recall with praxis_assume_recall">
|
|
70410
|
+
${body}
|
|
70411
|
+
</memory>`;
|
|
70412
|
+
var MEMORY_CHANGED_FRAME = (body) => `<memory_since_start source="praxis-assume" note="what came to mind since this conversation last read your memory">
|
|
70413
|
+
${body}
|
|
70414
|
+
</memory_since_start>`;
|
|
70415
|
+
function hookOutput(event, context) {
|
|
70416
|
+
if (context === null || context.trim() === "")
|
|
70417
|
+
return null;
|
|
70418
|
+
return JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext: context } });
|
|
70419
|
+
}
|
|
70420
|
+
function hookInputOf(raw) {
|
|
70421
|
+
try {
|
|
70422
|
+
const parsed = JSON.parse(raw);
|
|
70423
|
+
const sessionId = typeof parsed.session_id === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(parsed.session_id) ? parsed.session_id : null;
|
|
70424
|
+
return { sessionId, source: typeof parsed.source === "string" ? parsed.source : null };
|
|
70425
|
+
} catch {
|
|
70426
|
+
return { sessionId: null, source: null };
|
|
70427
|
+
}
|
|
70428
|
+
}
|
|
70429
|
+
async function runMemoryHook(event, input, ports) {
|
|
70430
|
+
try {
|
|
70431
|
+
const memory = memoryBodyOf(await callAgentTool(ports, ports.url, MEMORY_TOOL, {}, AbortSignal.timeout(ports.timeoutMs)));
|
|
70432
|
+
if (memory === "")
|
|
70433
|
+
return null;
|
|
70434
|
+
const all = newParagraphs(memory, new Set);
|
|
70435
|
+
if (event === "SessionStart") {
|
|
70436
|
+
if (input.sessionId !== null)
|
|
70437
|
+
await ports.writeSeen(input.sessionId, all).catch(() => {
|
|
70438
|
+
return;
|
|
70439
|
+
});
|
|
70440
|
+
return hookOutput(event, MEMORY_FRAME(memory));
|
|
70441
|
+
}
|
|
70442
|
+
const seen = input.sessionId === null ? [] : await ports.readSeen(input.sessionId).catch(() => []);
|
|
70443
|
+
const fresh = newParagraphs(memory, new Set(seen));
|
|
70444
|
+
if (fresh.length === 0)
|
|
70445
|
+
return null;
|
|
70446
|
+
if (input.sessionId !== null)
|
|
70447
|
+
await ports.writeSeen(input.sessionId, [...seen, ...fresh]).catch(() => {
|
|
70448
|
+
return;
|
|
70449
|
+
});
|
|
70450
|
+
return hookOutput(event, MEMORY_CHANGED_FRAME(fresh.join(`
|
|
70451
|
+
|
|
70452
|
+
`)));
|
|
70453
|
+
} catch {
|
|
70454
|
+
return null;
|
|
70455
|
+
}
|
|
70456
|
+
}
|
|
70457
|
+
|
|
68974
70458
|
// src/main.ts
|
|
68975
70459
|
import { spawnSync } from "node:child_process";
|
|
68976
70460
|
|
|
@@ -69088,15 +70572,15 @@ class ModelStream {
|
|
|
69088
70572
|
finishReason = "unknown";
|
|
69089
70573
|
usage;
|
|
69090
70574
|
add(event) {
|
|
69091
|
-
const data = streamData(event),
|
|
70575
|
+
const data = streamData(event), message2 = record(data.message), response = record(data.response);
|
|
69092
70576
|
this.chunks.push(streamText(event));
|
|
69093
70577
|
const choices = Array.isArray(data.choices) ? data.choices : [];
|
|
69094
|
-
const reason2 = choices.map((c) => record(c).finish_reason).find((r) => typeof r === "string" && r) ?? record(data.delta).stop_reason ??
|
|
70578
|
+
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;
|
|
69095
70579
|
if (typeof reason2 === "string" && reason2)
|
|
69096
70580
|
this.finishReason = reason2;
|
|
69097
70581
|
else if (["response.completed", "response.incomplete", "response.failed"].includes(String(data.type)))
|
|
69098
70582
|
this.finishReason = String(data.type).slice("response.".length);
|
|
69099
|
-
for (const usage of [
|
|
70583
|
+
for (const usage of [message2.usage, data.usage, response.usage]) {
|
|
69100
70584
|
if (usage !== null && typeof usage === "object" && !Array.isArray(usage))
|
|
69101
70585
|
this.usage = { ...this.usage, ...record(usage) };
|
|
69102
70586
|
}
|
|
@@ -69161,8 +70645,8 @@ function isSuccess(verb, ctx) {
|
|
|
69161
70645
|
}
|
|
69162
70646
|
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" };
|
|
69163
70647
|
var deleted = (verb) => /^(delete|remove|purge)(-|$)/.test(verb);
|
|
69164
|
-
function width(
|
|
69165
|
-
return [...
|
|
70648
|
+
function width(text3) {
|
|
70649
|
+
return [...text3].reduce((sum, ch) => {
|
|
69166
70650
|
const cp = ch.codePointAt(0);
|
|
69167
70651
|
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);
|
|
69168
70652
|
}, 0);
|
|
@@ -69170,13 +70654,13 @@ function width(text2) {
|
|
|
69170
70654
|
function truncate(value, size) {
|
|
69171
70655
|
if (width(value) <= size)
|
|
69172
70656
|
return value;
|
|
69173
|
-
let
|
|
70657
|
+
let text3 = "";
|
|
69174
70658
|
for (const ch of value) {
|
|
69175
|
-
if (width(
|
|
70659
|
+
if (width(text3 + ch) > size - 1)
|
|
69176
70660
|
break;
|
|
69177
|
-
|
|
70661
|
+
text3 += ch;
|
|
69178
70662
|
}
|
|
69179
|
-
return
|
|
70663
|
+
return text3 + "…";
|
|
69180
70664
|
}
|
|
69181
70665
|
function table(items, ctx, paint) {
|
|
69182
70666
|
const columns = columnsFor(items);
|
|
@@ -69209,13 +70693,13 @@ function table(items, ctx, paint) {
|
|
|
69209
70693
|
sizes[index]--;
|
|
69210
70694
|
}
|
|
69211
70695
|
const line = (row, header) => row.map((v, i) => {
|
|
69212
|
-
const
|
|
69213
|
-
let styled = header ? paint.dim(
|
|
70696
|
+
const text3 = truncate(v, sizes[i]);
|
|
70697
|
+
let styled = header ? paint.dim(text3) : text3;
|
|
69214
70698
|
if (!header && ["status", "state"].includes(columns[i])) {
|
|
69215
70699
|
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;
|
|
69216
|
-
styled = color(
|
|
70700
|
+
styled = color(text3);
|
|
69217
70701
|
}
|
|
69218
|
-
return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(
|
|
70702
|
+
return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(text3))));
|
|
69219
70703
|
}).join(" ");
|
|
69220
70704
|
return [line(headers, true), ...rows.map((row) => line(row, false))].join(`
|
|
69221
70705
|
`) + `
|
|
@@ -69314,9 +70798,9 @@ function renderHuman(result, ctx) {
|
|
|
69314
70798
|
}
|
|
69315
70799
|
|
|
69316
70800
|
// src/output/agent.ts
|
|
69317
|
-
function cell(
|
|
69318
|
-
const chars = [...
|
|
69319
|
-
const limited = chars.length > 500 ? chars.slice(0, 500).join("") + `…[+${chars.length - 500} chars, use --json]` :
|
|
70801
|
+
function cell(text3) {
|
|
70802
|
+
const chars = [...text3];
|
|
70803
|
+
const limited = chars.length > 500 ? chars.slice(0, 500).join("") + `…[+${chars.length - 500} chars, use --json]` : text3;
|
|
69320
70804
|
return limited.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>").replace(/\r/g, "<br>");
|
|
69321
70805
|
}
|
|
69322
70806
|
function renderAgent(result, ctx) {
|
|
@@ -69327,9 +70811,9 @@ function renderAgent(result, ctx) {
|
|
|
69327
70811
|
if (modelStream(result.op)) {
|
|
69328
70812
|
if (!result.summary)
|
|
69329
70813
|
return {};
|
|
69330
|
-
const { text:
|
|
69331
|
-
return { stdout: `${
|
|
69332
|
-
`) || !
|
|
70814
|
+
const { text: text3, finish_reason, usage } = result.summary;
|
|
70815
|
+
return { stdout: `${text3}${text3.endsWith(`
|
|
70816
|
+
`) || !text3 ? "" : `
|
|
69333
70817
|
`}finish_reason: ${finish_reason}
|
|
69334
70818
|
${usage ? `usage: ${JSON.stringify(usage)}
|
|
69335
70819
|
` : ""}` };
|
|
@@ -69548,18 +71032,18 @@ function errorInput(error, ctx) {
|
|
|
69548
71032
|
const details = candidate !== null && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : undefined;
|
|
69549
71033
|
const problem = serverProblem(Object.keys(nested).length ? nested : raw);
|
|
69550
71034
|
const serverText = (value) => typeof value === "string" && value.trim() ? value : undefined;
|
|
69551
|
-
let
|
|
69552
|
-
const prefix =
|
|
71035
|
+
let message2 = error instanceof Error ? error.message : "Unexpected error";
|
|
71036
|
+
const prefix = message2.match(/^([A-Z][A-Z0-9_]+):\s*/)?.[1];
|
|
69553
71037
|
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");
|
|
69554
71038
|
let stripped = false;
|
|
69555
|
-
while (
|
|
69556
|
-
|
|
71039
|
+
while (message2.startsWith(`${code}:`)) {
|
|
71040
|
+
message2 = message2.slice(code.length + 1).trimStart();
|
|
69557
71041
|
stripped = true;
|
|
69558
71042
|
}
|
|
69559
71043
|
if (stripped)
|
|
69560
|
-
|
|
71044
|
+
message2 = `${humanize(code)}${message2 ? `: ${message2}` : ""}`;
|
|
69561
71045
|
const status = sdk?.status, request_id = sdk?.requestId;
|
|
69562
|
-
|
|
71046
|
+
message2 = serverText(problem?.detail) ?? serverText(problem?.title) ?? message2;
|
|
69563
71047
|
const authFailure = status === 401 || ["NOT_LOGGED_IN", "UNAUTHENTICATED", "TOKEN_REVOKED", "LOGIN_FAILED", "MANAGED_LOGIN_EXPIRED"].includes(code);
|
|
69564
71048
|
const source = ctx.credentialSource ?? "login";
|
|
69565
71049
|
let hint3 = genericHint;
|
|
@@ -69577,19 +71061,19 @@ function errorInput(error, ctx) {
|
|
|
69577
71061
|
hint3 = "Rate limited; retry later.";
|
|
69578
71062
|
else if (status !== undefined && status >= 500)
|
|
69579
71063
|
hint3 = `Server error; retry later.${request_id ? ` Request id: ${request_id}.` : ""}`;
|
|
69580
|
-
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 } : {} };
|
|
71064
|
+
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 } : {} };
|
|
69581
71065
|
}
|
|
69582
71066
|
|
|
69583
71067
|
// src/output/progress.ts
|
|
69584
|
-
function startProgress(ctx, write = (
|
|
71068
|
+
function startProgress(ctx, write = (text3) => writeOutput({ stderr: text3 })) {
|
|
69585
71069
|
if (ctx.mode !== "human" || !ctx.stderrIsTTY)
|
|
69586
71070
|
return () => {};
|
|
69587
71071
|
let interval;
|
|
69588
|
-
let shown = false,
|
|
71072
|
+
let shown = false, frame2 = 0;
|
|
69589
71073
|
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
69590
71074
|
const tick = () => {
|
|
69591
71075
|
shown = true;
|
|
69592
|
-
write(`\r${frames[
|
|
71076
|
+
write(`\r${frames[frame2++ % frames.length]} Loading…`);
|
|
69593
71077
|
};
|
|
69594
71078
|
const timer = setTimeout(() => {
|
|
69595
71079
|
tick();
|
|
@@ -69607,7 +71091,7 @@ function startProgress(ctx, write = (text2) => writeOutput({ stderr: text2 })) {
|
|
|
69607
71091
|
}
|
|
69608
71092
|
|
|
69609
71093
|
// src/main.ts
|
|
69610
|
-
var version = "0.3.0-dev.
|
|
71094
|
+
var version = "0.3.0-dev.0131725";
|
|
69611
71095
|
var commands = commandTree(operations);
|
|
69612
71096
|
var manual = [...workflows.map((w) => w.words), [API_WORD]];
|
|
69613
71097
|
function route(argv) {
|
|
@@ -69689,7 +71173,7 @@ var defaults = {
|
|
|
69689
71173
|
return;
|
|
69690
71174
|
const cmd = process.platform === "darwin" ? ["open", url] : process.platform === "win32" ? ["rundll32", "url.dll,FileProtocolHandler", url] : ["xdg-open", url];
|
|
69691
71175
|
await new Promise((resolve12, reject) => {
|
|
69692
|
-
const child =
|
|
71176
|
+
const child = spawn5(cmd[0], cmd.slice(1), { stdio: "ignore" });
|
|
69693
71177
|
child.once("error", reject);
|
|
69694
71178
|
child.once("close", () => resolve12());
|
|
69695
71179
|
});
|
|
@@ -69698,12 +71182,12 @@ var defaults = {
|
|
|
69698
71182
|
wait: (ms) => new Promise((resolve12) => setTimeout(resolve12, ms)),
|
|
69699
71183
|
render,
|
|
69700
71184
|
spawn: (cmd, args, options) => new Promise((resolve12, reject) => {
|
|
69701
|
-
const child =
|
|
71185
|
+
const child = spawn5(cmd, args, { cwd: options.cwd, stdio: ["ignore", 2, 2] });
|
|
69702
71186
|
child.once("error", reject);
|
|
69703
71187
|
child.once("close", (code) => resolve12(code ?? 1));
|
|
69704
71188
|
}),
|
|
69705
71189
|
spawnCapture: (cmd, args, options) => new Promise((resolve12, reject) => {
|
|
69706
|
-
const child =
|
|
71190
|
+
const child = spawn5(cmd, args, { cwd: options.cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
69707
71191
|
const chunks = [];
|
|
69708
71192
|
child.stdout.on("data", (c) => chunks.push(c));
|
|
69709
71193
|
child.stderr.on("data", (c) => chunks.push(c));
|
|
@@ -69762,7 +71246,7 @@ var appOptions = {
|
|
|
69762
71246
|
{ name: "case", type: "string", description: "Scenario title substring; the engine's `scenario` (case ids are a later slice)." },
|
|
69763
71247
|
{ name: "e2e", type: "boolean", description: "The large end-to-end tests; exactly --size large, so the two cannot be combined." },
|
|
69764
71248
|
{ name: "retries", type: "string", description: "Retries after a failing scenario (default: 0)." },
|
|
69765
|
-
{ name: "ctrf", type: "string", description: "Write the CTRF report here (default: <cwd>/.
|
|
71249
|
+
{ name: "ctrf", type: "string", description: "Write the CTRF report here (default: <cwd>/.praxis/ctrf/<run>.json)." }
|
|
69766
71250
|
],
|
|
69767
71251
|
"devops test report": [
|
|
69768
71252
|
{ name: "id", type: "string", description: "Show one run's detail instead of the recent list." },
|
|
@@ -69782,6 +71266,25 @@ var appOptions = {
|
|
|
69782
71266
|
"devops flag scaffold": [
|
|
69783
71267
|
{ name: "out", type: "string", description: "Directory the paired on/off scenario stubs are written to (default: the current directory)." }
|
|
69784
71268
|
],
|
|
71269
|
+
"devops flag refs": [
|
|
71270
|
+
{ 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)." },
|
|
71271
|
+
{ name: "project", type: "string", description: "With --report: the DevOps project id (dvp_…) whose flags the scan is reported into. Required." }
|
|
71272
|
+
],
|
|
71273
|
+
"agent memory": [
|
|
71274
|
+
{ name: "hook", type: "string", description: "Run as a Claude Code hook (SessionStart or UserPromptSubmit): read the hook input on stdin, print the hook JSON or nothing, always exit 0." }
|
|
71275
|
+
],
|
|
71276
|
+
"agent recall": [
|
|
71277
|
+
{ name: "words", type: "string", repeated: true, description: "Distinctive words to recall by, comma-separated or repeated." },
|
|
71278
|
+
{ name: "handles", type: "string", repeated: true, description: "Entry handles or ids from memory to recall, comma-separated or repeated." }
|
|
71279
|
+
],
|
|
71280
|
+
"agent remember": [
|
|
71281
|
+
{ name: "text", type: "string", description: "The experience, in your own words: what happened, who, what was decided and why, what is still open." },
|
|
71282
|
+
{ name: "about", type: "string", repeated: true, description: "Ids of entities it is about, comma-separated or repeated." }
|
|
71283
|
+
],
|
|
71284
|
+
"agent events wait": [
|
|
71285
|
+
{ name: "timeout", type: "string", description: "Give up after this many seconds, print that nothing arrived and exit 0 (default: wait until a letter arrives)." },
|
|
71286
|
+
{ name: "session", type: "string", description: "The Claude Code session this waiter wakes: its announced letters and pid file are kept per session, and a second waiter for the same session exits at once (default: one waiter per agent)." }
|
|
71287
|
+
],
|
|
69785
71288
|
"canvas import": [
|
|
69786
71289
|
{ name: "name", type: "string", description: "Name for the new canvas (default: the file name without .pen)." },
|
|
69787
71290
|
{ 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." },
|
|
@@ -69796,17 +71299,19 @@ var appOptions = {
|
|
|
69796
71299
|
};
|
|
69797
71300
|
appOptions["devops engine deploy"] = appOptions["devops deploy"];
|
|
69798
71301
|
var workflowOptions = (words) => words[0] === "skill" ? [{ name: "install", type: "string" }] : appOptions[words.join(" ")] ?? [];
|
|
69799
|
-
function flagPortsFor(ports, context, emit) {
|
|
71302
|
+
function flagPortsFor(ports, context, emit, connect) {
|
|
69800
71303
|
return {
|
|
69801
71304
|
mode: context.mode,
|
|
69802
71305
|
emit,
|
|
69803
|
-
human: (
|
|
71306
|
+
human: (text3) => {
|
|
69804
71307
|
if (context.mode === "human")
|
|
69805
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71308
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
69806
71309
|
},
|
|
69807
71310
|
cwd: ports.cwd,
|
|
69808
71311
|
readFile: ports.readFile,
|
|
69809
|
-
|
|
71312
|
+
git: async (args) => (await ports.spawnCapture("git", [...args], { cwd: ports.cwd })).output,
|
|
71313
|
+
client: connect,
|
|
71314
|
+
writeFile: (path, text3) => writeFile5(path, text3, "utf8"),
|
|
69810
71315
|
mkdir: async (path) => {
|
|
69811
71316
|
await mkdir4(path, { recursive: true });
|
|
69812
71317
|
},
|
|
@@ -69830,9 +71335,9 @@ function toolPortsFor(ports, context, emit) {
|
|
|
69830
71335
|
return {
|
|
69831
71336
|
mode: context.mode,
|
|
69832
71337
|
emit,
|
|
69833
|
-
human: (
|
|
71338
|
+
human: (text3) => {
|
|
69834
71339
|
if (context.mode === "human")
|
|
69835
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71340
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
69836
71341
|
},
|
|
69837
71342
|
cwd: ports.cwd,
|
|
69838
71343
|
readFile: ports.readFile,
|
|
@@ -69847,7 +71352,7 @@ function toolPortsFor(ports, context, emit) {
|
|
|
69847
71352
|
},
|
|
69848
71353
|
git: (args, cwd) => ports.spawnCapture("git", args, { cwd }),
|
|
69849
71354
|
run: (cmd, args, cwd) => new Promise((resolve12, reject) => {
|
|
69850
|
-
const child =
|
|
71355
|
+
const child = spawn5(cmd, args, { cwd, stdio: "inherit" });
|
|
69851
71356
|
child.once("error", reject);
|
|
69852
71357
|
child.once("close", (code) => resolve12(code ?? 1));
|
|
69853
71358
|
}),
|
|
@@ -69872,7 +71377,7 @@ async function main3(argv, injected = {}) {
|
|
|
69872
71377
|
columns: ports.columns,
|
|
69873
71378
|
now: ports.now(),
|
|
69874
71379
|
envVars: { NO_COLOR: ports.env.NO_COLOR, FORCE_COLOR: ports.env.FORCE_COLOR, TERM: ports.env.TERM },
|
|
69875
|
-
env: ports.env.PRAXIS_ENV ??
|
|
71380
|
+
env: ports.env.PRAXIS_ENV ?? DEFAULT_ENV
|
|
69876
71381
|
};
|
|
69877
71382
|
let stopProgress = () => {};
|
|
69878
71383
|
let quiet = false;
|
|
@@ -70142,9 +71647,9 @@ Examples:
|
|
|
70142
71647
|
},
|
|
70143
71648
|
mode: ctx.mode,
|
|
70144
71649
|
emit,
|
|
70145
|
-
human: (
|
|
71650
|
+
human: (text3) => {
|
|
70146
71651
|
if (ctx.mode === "human")
|
|
70147
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71652
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70148
71653
|
},
|
|
70149
71654
|
cwd: ports.cwd
|
|
70150
71655
|
});
|
|
@@ -70171,14 +71676,14 @@ Examples:
|
|
|
70171
71676
|
}, {
|
|
70172
71677
|
mode: ctx.mode,
|
|
70173
71678
|
emit,
|
|
70174
|
-
human: (
|
|
71679
|
+
human: (text3) => {
|
|
70175
71680
|
if (ctx.mode === "human")
|
|
70176
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71681
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70177
71682
|
},
|
|
70178
71683
|
engine: codeRefactorEngine(),
|
|
70179
71684
|
hasFile: (path2) => existsSync4(path2),
|
|
70180
71685
|
readFile: ports.readFile,
|
|
70181
|
-
writeFile: (path2,
|
|
71686
|
+
writeFile: (path2, text3) => writeFile5(path2, text3, "utf8"),
|
|
70182
71687
|
mkdir: async (path2) => {
|
|
70183
71688
|
await mkdir4(path2, { recursive: true });
|
|
70184
71689
|
},
|
|
@@ -70195,9 +71700,9 @@ Examples:
|
|
|
70195
71700
|
const shellPorts = {
|
|
70196
71701
|
mode: ctx.mode,
|
|
70197
71702
|
emit,
|
|
70198
|
-
human: (
|
|
71703
|
+
human: (text3) => {
|
|
70199
71704
|
if (ctx.mode === "human")
|
|
70200
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71705
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70201
71706
|
},
|
|
70202
71707
|
engine: await repositoryEngine(name, () => localEngine(ports.cwd)),
|
|
70203
71708
|
...localFilePorts(ports.cwd)
|
|
@@ -70210,9 +71715,9 @@ Examples:
|
|
|
70210
71715
|
const testPorts = {
|
|
70211
71716
|
mode: ctx.mode,
|
|
70212
71717
|
emit,
|
|
70213
|
-
human: (
|
|
71718
|
+
human: (text3) => {
|
|
70214
71719
|
if (ctx.mode === "human")
|
|
70215
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71720
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70216
71721
|
},
|
|
70217
71722
|
engine: await repositoryEngine(name, () => localEngine(ports.cwd)),
|
|
70218
71723
|
checkout: await localCheckout(ports.cwd, (cmd, args, options) => ports.spawnCapture(cmd, args, options))
|
|
@@ -70221,9 +71726,9 @@ Examples:
|
|
|
70221
71726
|
return await devopsTestReport({ path: parsed.positional[0], id: parsed.flags.id?.[0], upload: Boolean(parsed.flags.upload), project: parsed.flags.project?.[0] }, testPorts, {
|
|
70222
71727
|
mode: ctx.mode,
|
|
70223
71728
|
emit,
|
|
70224
|
-
human: (
|
|
71729
|
+
human: (text3) => {
|
|
70225
71730
|
if (ctx.mode === "human")
|
|
70226
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71731
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70227
71732
|
},
|
|
70228
71733
|
root: async () => await checkoutRoot(ports.cwd, ports.readFile),
|
|
70229
71734
|
readFile: ports.readFile,
|
|
@@ -70253,13 +71758,13 @@ Examples:
|
|
|
70253
71758
|
git: (args) => ports.spawnCapture("git", args, { cwd: ports.cwd }),
|
|
70254
71759
|
mode: ctx.mode,
|
|
70255
71760
|
emit,
|
|
70256
|
-
human: (
|
|
71761
|
+
human: (text3) => {
|
|
70257
71762
|
if (ctx.mode === "human")
|
|
70258
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71763
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70259
71764
|
}
|
|
70260
71765
|
});
|
|
70261
71766
|
}
|
|
70262
|
-
const flagPorts = flagPortsFor(ports, ctx, emit);
|
|
71767
|
+
const flagPorts = flagPortsFor(ports, ctx, emit, async () => await auth.client(org));
|
|
70263
71768
|
if (name === "devops flag sync")
|
|
70264
71769
|
return await devopsFlagSync({ check: Boolean(parsed.flags.check) }, flagPorts);
|
|
70265
71770
|
if (name === "devops flag check")
|
|
@@ -70267,7 +71772,7 @@ Examples:
|
|
|
70267
71772
|
if (name === "devops flag scaffold")
|
|
70268
71773
|
return await devopsFlagScaffold(parsed.positional[0], { out: parsed.flags.out?.[0] }, flagPorts);
|
|
70269
71774
|
if (name === "devops flag refs")
|
|
70270
|
-
return await devopsFlagRefs(parsed.positional[0], flagPorts);
|
|
71775
|
+
return await devopsFlagRefs(parsed.positional[0], { report: Boolean(parsed.flags.report), project: parsed.flags.project?.[0] }, flagPorts);
|
|
70271
71776
|
return await devopsFlagRemove(parsed.positional[0], flagPorts);
|
|
70272
71777
|
}
|
|
70273
71778
|
if (!quiet)
|
|
@@ -70305,9 +71810,9 @@ Examples:
|
|
|
70305
71810
|
emit({ kind: "object", data: await auth.switchOrganization(parsed.positional[0]) });
|
|
70306
71811
|
break;
|
|
70307
71812
|
case "app create": {
|
|
70308
|
-
const appPorts = { ...ports, mode: ctx.mode, emit, human: (
|
|
71813
|
+
const appPorts = { ...ports, mode: ctx.mode, emit, human: (text3) => {
|
|
70309
71814
|
if (ctx.mode === "human")
|
|
70310
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71815
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70311
71816
|
}, random: randomSecret };
|
|
70312
71817
|
await appCreate({ name: parsed.positional[0], dir: parsed.flags.dir?.[0], template: parsed.flags.template?.[0], install: !parsed.flags["no-install"] }, config.env, appPorts);
|
|
70313
71818
|
break;
|
|
@@ -70336,13 +71841,220 @@ Examples:
|
|
|
70336
71841
|
wait: ports.wait,
|
|
70337
71842
|
mode: ctx.mode,
|
|
70338
71843
|
emit,
|
|
70339
|
-
human: (
|
|
71844
|
+
human: (text3) => {
|
|
70340
71845
|
if (ctx.mode === "human")
|
|
70341
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71846
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70342
71847
|
},
|
|
70343
71848
|
cwd: ports.cwd
|
|
70344
71849
|
});
|
|
70345
71850
|
}
|
|
71851
|
+
case "agent events channel": {
|
|
71852
|
+
const agent = assumeAgentOf(ports.env);
|
|
71853
|
+
const headers = async () => {
|
|
71854
|
+
const credential = await auth.get(org);
|
|
71855
|
+
return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
|
|
71856
|
+
};
|
|
71857
|
+
const failure2 = (status, body) => `HTTP ${status}${body?.error?.code ? ` ${body.error.code}` : ""}${body?.error?.message ? `: ${String(redact(body.error.message, secrets))}` : ""}`;
|
|
71858
|
+
process.stdin.setEncoding("utf8");
|
|
71859
|
+
return await runChannel({
|
|
71860
|
+
agent,
|
|
71861
|
+
input: process.stdin,
|
|
71862
|
+
send: (frame2) => {
|
|
71863
|
+
process.stdout.write(JSON.stringify(frame2) + `
|
|
71864
|
+
`);
|
|
71865
|
+
},
|
|
71866
|
+
fetchLetters: async () => {
|
|
71867
|
+
const response = await wireFetch(inboxLettersUrl(config.apiUrl, agent), { headers: await headers(), signal: AbortSignal.timeout(30000), redirect: "error" });
|
|
71868
|
+
const body = await response.json().catch(() => null);
|
|
71869
|
+
if (!response.ok)
|
|
71870
|
+
throw new Error(failure2(response.status, body));
|
|
71871
|
+
return lettersOf(body);
|
|
71872
|
+
},
|
|
71873
|
+
openStream: async (signal, lastEventId) => {
|
|
71874
|
+
const response = await wireFetch(eventsStreamUrl(config.apiUrl, agent), { headers: streamHeaders(await headers(), lastEventId), signal, redirect: "error" });
|
|
71875
|
+
if (!response.ok || !response.body) {
|
|
71876
|
+
const body = await response.json().catch(() => null);
|
|
71877
|
+
return { status: response.status, reason: failure2(response.status, body) };
|
|
71878
|
+
}
|
|
71879
|
+
return { status: response.status, chunks: response.body.pipeThrough(new TextDecoderStream) };
|
|
71880
|
+
},
|
|
71881
|
+
sleep: (ms, signal) => new Promise((resolve12) => {
|
|
71882
|
+
const timer = setTimeout(resolve12, ms);
|
|
71883
|
+
signal.addEventListener("abort", () => {
|
|
71884
|
+
clearTimeout(timer);
|
|
71885
|
+
resolve12();
|
|
71886
|
+
}, { once: true });
|
|
71887
|
+
}),
|
|
71888
|
+
log: (line) => {
|
|
71889
|
+
process.stderr.write(String(redact(line, secrets)) + `
|
|
71890
|
+
`);
|
|
71891
|
+
}
|
|
71892
|
+
});
|
|
71893
|
+
}
|
|
71894
|
+
case "agent memory":
|
|
71895
|
+
case "agent recall":
|
|
71896
|
+
case "agent remember": {
|
|
71897
|
+
const agent = assumeAgentOf(ports.env);
|
|
71898
|
+
const mcpPorts = {
|
|
71899
|
+
fetch: (url2, init) => wireFetch(url2, init),
|
|
71900
|
+
headers: async () => {
|
|
71901
|
+
const credential = await auth.get(org);
|
|
71902
|
+
return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
|
|
71903
|
+
}
|
|
71904
|
+
};
|
|
71905
|
+
const url = mcpUrl(config.apiUrl, agent);
|
|
71906
|
+
const hook = parsed.flags.hook?.[0];
|
|
71907
|
+
if (name === "agent memory" && hook !== undefined) {
|
|
71908
|
+
if (hook !== "SessionStart" && hook !== "UserPromptSubmit")
|
|
71909
|
+
throw new UsageError(`--hook takes SessionStart or UserPromptSubmit, not ${hook}`, "Example: praxis agent memory --hook SessionStart");
|
|
71910
|
+
process.stdin.setEncoding("utf8");
|
|
71911
|
+
let raw = "";
|
|
71912
|
+
if (!process.stdin.isTTY)
|
|
71913
|
+
for await (const chunk of process.stdin)
|
|
71914
|
+
raw += chunk;
|
|
71915
|
+
const input = hookInputOf(raw);
|
|
71916
|
+
const seenDir = join12(ports.env.HOME || homedir3(), ".praxis", "cli", "memory-seen");
|
|
71917
|
+
const out = await runMemoryHook(hook, input, {
|
|
71918
|
+
...mcpPorts,
|
|
71919
|
+
url,
|
|
71920
|
+
timeoutMs: 25000,
|
|
71921
|
+
readSeen: async (id) => JSON.parse(await readFile7(join12(seenDir, `${id}.json`), "utf8")),
|
|
71922
|
+
writeSeen: async (id, paragraphs) => {
|
|
71923
|
+
await mkdir4(seenDir, { recursive: true, mode: 448 });
|
|
71924
|
+
await writeFile5(join12(seenDir, `${id}.json`), JSON.stringify(paragraphs), { mode: 384 });
|
|
71925
|
+
}
|
|
71926
|
+
});
|
|
71927
|
+
if (out !== null)
|
|
71928
|
+
process.stdout.write(out + `
|
|
71929
|
+
`);
|
|
71930
|
+
return 0;
|
|
71931
|
+
}
|
|
71932
|
+
const list = (flag) => (parsed.flags[flag] ?? []).flatMap((value) => value.split(",")).map((value) => value.trim()).filter(Boolean);
|
|
71933
|
+
const args = name === "agent recall" ? { ...list("handles").length ? { handles: list("handles") } : {}, ...list("words").length ? { words: list("words") } : {} } : name === "agent remember" ? { text: parsed.flags.text?.[0] ?? "", ...list("about").length ? { about: list("about") } : {} } : {};
|
|
71934
|
+
if (name === "agent remember" && String(args.text).trim() === "")
|
|
71935
|
+
throw new UsageError("--text is required", 'Example: praxis agent remember --text "今天定了……"');
|
|
71936
|
+
const tool = name === "agent memory" ? MEMORY_TOOL : name === "agent recall" ? RECALL_TOOL : REMEMBER_TOOL;
|
|
71937
|
+
const text3 = memoryBodyOf(await callAgentTool(mcpPorts, url, tool, args, AbortSignal.timeout(60000)));
|
|
71938
|
+
process.stdout.write(text3 + `
|
|
71939
|
+
`);
|
|
71940
|
+
return 0;
|
|
71941
|
+
}
|
|
71942
|
+
case "agent events wait": {
|
|
71943
|
+
const agent = assumeAgentOf(ports.env);
|
|
71944
|
+
const timeoutMs = (() => {
|
|
71945
|
+
try {
|
|
71946
|
+
return timeoutMsOf(parsed.flags.timeout?.[0]);
|
|
71947
|
+
} catch (error) {
|
|
71948
|
+
throw new UsageError(error.message, "Example: praxis agent events wait --timeout 3600");
|
|
71949
|
+
}
|
|
71950
|
+
})();
|
|
71951
|
+
const headers = async () => {
|
|
71952
|
+
const credential = await auth.get(org);
|
|
71953
|
+
return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
|
|
71954
|
+
};
|
|
71955
|
+
const failure2 = (status, body) => `HTTP ${status}${body?.error?.code ? ` ${body.error.code}` : ""}${body?.error?.message ? `: ${String(redact(body.error.message, secrets))}` : ""}`;
|
|
71956
|
+
const session = (() => {
|
|
71957
|
+
try {
|
|
71958
|
+
return sessionOf(parsed.flags.session?.[0]);
|
|
71959
|
+
} catch (error) {
|
|
71960
|
+
throw new UsageError(error.message, "Example: praxis agent events wait --session 0f6c…");
|
|
71961
|
+
}
|
|
71962
|
+
})();
|
|
71963
|
+
const key = waitKeyOf(config.env, agent, session);
|
|
71964
|
+
const waitDir = join12(ports.env.HOME || homedir3(), ".praxis", "cli", "events-wait");
|
|
71965
|
+
const statePath = join12(waitDir, `${key}.json`);
|
|
71966
|
+
const pidPath = join12(waitDir, `${key}.pid`);
|
|
71967
|
+
await mkdir4(waitDir, { recursive: true, mode: 448 });
|
|
71968
|
+
const holder = await acquireWaitLock({
|
|
71969
|
+
self: process.pid,
|
|
71970
|
+
readPid: () => readFile7(pidPath, "utf8").catch(() => null),
|
|
71971
|
+
createPid: (text3) => writeFile5(pidPath, text3, { mode: 384, flag: "wx" }).then(() => true, () => false),
|
|
71972
|
+
replacePid: (text3) => writeFile5(pidPath, text3, { mode: 384 }),
|
|
71973
|
+
probe: async (pid) => {
|
|
71974
|
+
try {
|
|
71975
|
+
process.kill(pid, 0);
|
|
71976
|
+
} catch (error) {
|
|
71977
|
+
if (error.code !== "EPERM")
|
|
71978
|
+
return { alive: false };
|
|
71979
|
+
}
|
|
71980
|
+
const ps = spawnSync("ps", ["-o", "ppid=,command=", "-p", String(pid)], { encoding: "utf8" });
|
|
71981
|
+
const line = ps.stdout?.trim() ?? "";
|
|
71982
|
+
const match = /^(\d+)\s+(.*)$/.exec(line);
|
|
71983
|
+
return match ? { alive: true, ppid: Number(match[1]), command: match[2] } : { alive: false };
|
|
71984
|
+
},
|
|
71985
|
+
terminate: (pid) => {
|
|
71986
|
+
try {
|
|
71987
|
+
process.kill(pid, "SIGTERM");
|
|
71988
|
+
} catch {}
|
|
71989
|
+
}
|
|
71990
|
+
});
|
|
71991
|
+
if (holder !== null) {
|
|
71992
|
+
process.stdout.write(alreadyWaitingNotice(holder) + `
|
|
71993
|
+
`);
|
|
71994
|
+
return 0;
|
|
71995
|
+
}
|
|
71996
|
+
const release = () => {
|
|
71997
|
+
try {
|
|
71998
|
+
if (pidOf(readFileSync3(pidPath, "utf8")) === process.pid)
|
|
71999
|
+
unlinkSync(pidPath);
|
|
72000
|
+
} catch {}
|
|
72001
|
+
};
|
|
72002
|
+
const onSignal = (signal) => {
|
|
72003
|
+
release();
|
|
72004
|
+
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
72005
|
+
};
|
|
72006
|
+
for (const signal of ["SIGTERM", "SIGINT", "SIGHUP"])
|
|
72007
|
+
process.once(signal, onSignal);
|
|
72008
|
+
try {
|
|
72009
|
+
return await runEventsWait({
|
|
72010
|
+
agent,
|
|
72011
|
+
timeoutMs,
|
|
72012
|
+
fetchLetters: async () => {
|
|
72013
|
+
const response = await wireFetch(inboxLettersUrl(config.apiUrl, agent), { headers: await headers(), signal: AbortSignal.timeout(30000), redirect: "error" });
|
|
72014
|
+
const body = await response.json().catch(() => null);
|
|
72015
|
+
if (!response.ok)
|
|
72016
|
+
throw new Error(failure2(response.status, body));
|
|
72017
|
+
return lettersOf(body);
|
|
72018
|
+
},
|
|
72019
|
+
openStream: async (signal, lastEventId) => {
|
|
72020
|
+
const response = await wireFetch(eventsStreamUrl(config.apiUrl, agent), {
|
|
72021
|
+
headers: streamHeaders(await headers(), lastEventId),
|
|
72022
|
+
signal,
|
|
72023
|
+
redirect: "error"
|
|
72024
|
+
});
|
|
72025
|
+
if (!response.ok || !response.body) {
|
|
72026
|
+
const body = await response.json().catch(() => null);
|
|
72027
|
+
return { status: response.status, reason: failure2(response.status, body) };
|
|
72028
|
+
}
|
|
72029
|
+
return { status: response.status, chunks: response.body.pipeThrough(new TextDecoderStream) };
|
|
72030
|
+
},
|
|
72031
|
+
readState: async () => waitStateOf(await readFile7(statePath, "utf8").catch(() => null)),
|
|
72032
|
+
writeState: async (next) => {
|
|
72033
|
+
await mkdir4(dirname10(statePath), { recursive: true, mode: 448 });
|
|
72034
|
+
await writeFile5(statePath, waitStateText(next), { mode: 384 });
|
|
72035
|
+
},
|
|
72036
|
+
print: (line) => {
|
|
72037
|
+
process.stdout.write(line + `
|
|
72038
|
+
`);
|
|
72039
|
+
},
|
|
72040
|
+
log: (line) => {
|
|
72041
|
+
process.stderr.write(String(redact(line, secrets)) + `
|
|
72042
|
+
`);
|
|
72043
|
+
},
|
|
72044
|
+
sleep: (ms, signal) => new Promise((resolve12) => {
|
|
72045
|
+
const timer = setTimeout(resolve12, ms);
|
|
72046
|
+
signal.addEventListener("abort", () => {
|
|
72047
|
+
clearTimeout(timer);
|
|
72048
|
+
resolve12();
|
|
72049
|
+
}, { once: true });
|
|
72050
|
+
})
|
|
72051
|
+
});
|
|
72052
|
+
} finally {
|
|
72053
|
+
release();
|
|
72054
|
+
for (const signal of ["SIGTERM", "SIGINT", "SIGHUP"])
|
|
72055
|
+
process.removeListener(signal, onSignal);
|
|
72056
|
+
}
|
|
72057
|
+
}
|
|
70346
72058
|
case "canvas import": {
|
|
70347
72059
|
const authorize = async () => {
|
|
70348
72060
|
const credential = await auth.get(org);
|
|
@@ -70384,7 +72096,7 @@ Examples:
|
|
|
70384
72096
|
file: parsed.positional[0],
|
|
70385
72097
|
name: parsed.flags.name?.[0],
|
|
70386
72098
|
canvas: parsed.flags.canvas?.[0],
|
|
70387
|
-
frames: typeof parsed.flags.frames?.[0] === "string" ? parsed.flags.frames[0].split(",").map((
|
|
72099
|
+
frames: typeof parsed.flags.frames?.[0] === "string" ? parsed.flags.frames[0].split(",").map((frame2) => frame2.trim()).filter(Boolean) : undefined,
|
|
70388
72100
|
imageRoots: parsed.flags["image-root"],
|
|
70389
72101
|
dryRun: Boolean(parsed.flags["dry-run"]?.[0]),
|
|
70390
72102
|
yes: Boolean(flags.yes)
|
|
@@ -70398,9 +72110,9 @@ Examples:
|
|
|
70398
72110
|
cwd: ports.cwd,
|
|
70399
72111
|
rpc,
|
|
70400
72112
|
upload,
|
|
70401
|
-
human: (
|
|
72113
|
+
human: (text3) => {
|
|
70402
72114
|
if (ctx.mode === "human")
|
|
70403
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
72115
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70404
72116
|
}
|
|
70405
72117
|
});
|
|
70406
72118
|
}
|
|
@@ -70432,7 +72144,8 @@ if (true) {
|
|
|
70432
72144
|
process.exit(0);
|
|
70433
72145
|
throw error;
|
|
70434
72146
|
});
|
|
70435
|
-
|
|
72147
|
+
const argv = process.argv.slice(2);
|
|
72148
|
+
process.exitCode = isDevopsTestRun(route(argv).words) && needsCacheOffReexec(process.env) ? await reexecWithCacheOff() : await main3(argv);
|
|
70436
72149
|
}
|
|
70437
72150
|
export {
|
|
70438
72151
|
main3 as main
|