@deepraxis/cli 0.3.0-dev.3aab976 → 0.3.0-dev.3ab122a
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 +11 -2
- package/dist/praxis.js +1935 -214
- package/package.json +1 -1
package/dist/praxis.js
CHANGED
|
@@ -13983,10 +13983,21 @@ 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
|
+
"agent-process-mode-base": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2365, expires: "2026-12-16", system: "devops" },
|
|
13987
|
+
"cognition-per-agent": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2506, expires: "2026-11-30", system: "devops" },
|
|
13986
13988
|
"cognition-weight-driven": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-bd", ticket: 1760, expires: "2026-12-05", system: "devops" },
|
|
13989
|
+
"computer-archive-volume": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2419, expires: "2026-11-30", system: "devops" },
|
|
13990
|
+
crm: { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_rv860m7z9h8szkgma56cd14n", ticket: 2179, expires: "2026-12-31", system: "devops" },
|
|
13987
13991
|
"delivery-rules-v2": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2048, expires: "2026-11-28", system: "devops" },
|
|
13992
|
+
"end-users": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2312, expires: "2026-12-15", system: "devops" },
|
|
13993
|
+
"letters-email-delivery": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2150, expires: "2026-11-29", system: "devops" },
|
|
13988
13994
|
"model-access-gate": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 1933, expires: "2026-12-15", system: "devops" },
|
|
13989
13995
|
"open-project": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-51", ticket: 1488, expires: "2026-11-25", system: "devops" },
|
|
13996
|
+
"requests-never-hold": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2119, expires: "2026-11-29", system: "devops" },
|
|
13997
|
+
"requests-v1": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2057, expires: "2026-11-28", system: "devops" },
|
|
13998
|
+
"resource-library": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "agent_97823517-ae48-422d-8abc-fa4d8bacd5cc", ticket: 2546, expires: "2026-11-30", system: "devops" },
|
|
13999
|
+
"router-precommit-hedge": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2052, expires: "2026-11-28", system: "devops" },
|
|
14000
|
+
"router-responses-hedge": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2149, expires: "2026-11-28", system: "devops" },
|
|
13990
14001
|
"search-provider-routing": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-98", ticket: 716, expires: "2026-12-31", system: "devops" },
|
|
13991
14002
|
"unit-live-probe": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: null, expires: "2026-11-19", system: "devops" }
|
|
13992
14003
|
};
|
|
@@ -14013,7 +14024,7 @@ function checkFlags(files, registry, today = new Date().toISOString().slice(0, 1
|
|
|
14013
14024
|
}
|
|
14014
14025
|
const registryFile = production.find((f) => f.path.endsWith("flag-registry.generated.ts"));
|
|
14015
14026
|
const registryLine = (key) => registryFile ? lineOf(registryFile.text, Math.max(0, registryFile.text.indexOf(`"${key}":`))) : 1;
|
|
14016
|
-
const add = (file, offset,
|
|
14027
|
+
const add = (file, offset, message2) => issues.push({ file: file.path, line: lineOf(file.text, offset), message: message2 });
|
|
14017
14028
|
const referencedKeysIn = (file) => {
|
|
14018
14029
|
for (const key of registered) {
|
|
14019
14030
|
const literal = new RegExp(`(?:"|')${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:"|')`);
|
|
@@ -14032,6 +14043,8 @@ function checkFlags(files, registry, today = new Date().toISOString().slice(0, 1
|
|
|
14032
14043
|
add(f, browserList.index + entry.index, `unregistered browser flag key "${entry[1]}"`);
|
|
14033
14044
|
}
|
|
14034
14045
|
}
|
|
14046
|
+
if (/\.generated\.[cm]?[jt]sx?$/.test(f.path))
|
|
14047
|
+
continue;
|
|
14035
14048
|
const calls = /(\.bool|\breadBrowserFlag|\buseBrowserFlag)\s*\(\s*([^,)\n]+)/g;
|
|
14036
14049
|
for (const m of f.text.matchAll(calls)) {
|
|
14037
14050
|
if (/function\s*$/.test(f.text.slice(Math.max(0, m.index - 20), m.index)))
|
|
@@ -14100,7 +14113,7 @@ async function main() {
|
|
|
14100
14113
|
else
|
|
14101
14114
|
console.log(`Feature flag registry check passed (${Object.keys(FLAGS).length} registered flags).`);
|
|
14102
14115
|
}
|
|
14103
|
-
var isTest = (path) => /(^|\/)(spec|__tests__)(\/|$)|\.(test|spec)\.[cm]?[jt]sx?$/.test(path), lineOf = (
|
|
14116
|
+
var isTest = (path) => /(^|\/)(spec|__tests__)(\/|$)|\.(test|spec)\.[cm]?[jt]sx?$/.test(path), lineOf = (text3, offset) => text3.slice(0, offset).split(`
|
|
14104
14117
|
`).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;
|
|
14105
14118
|
var init_check_flags = __esm(() => {
|
|
14106
14119
|
init_flag_registry_generated();
|
|
@@ -14298,7 +14311,7 @@ async function checkRegistrySync(ports = {}) {
|
|
|
14298
14311
|
}
|
|
14299
14312
|
async function syncFlags(ports = {}) {
|
|
14300
14313
|
const registry = ports.registry ?? registryUrl;
|
|
14301
|
-
const write = ports.write ?? ((target,
|
|
14314
|
+
const write = ports.write ?? ((target, text3) => writeFile4(target, text3));
|
|
14302
14315
|
const log = ports.log ?? console.log;
|
|
14303
14316
|
const error = ports.error ?? console.error;
|
|
14304
14317
|
const devops = await (ports.devops ?? readDevopsFlags)();
|
|
@@ -14535,12 +14548,13 @@ async function runEngineDelegation(delegation, options) {
|
|
|
14535
14548
|
}
|
|
14536
14549
|
|
|
14537
14550
|
// src/main.ts
|
|
14538
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
14551
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, unlinkSync } from "node:fs";
|
|
14539
14552
|
import { mkdir as mkdir4, readFile as readFile7, readdir as readdir3, writeFile as writeFile5 } from "node:fs/promises";
|
|
14540
|
-
import { resolve as resolve11 } from "node:path";
|
|
14553
|
+
import { dirname as dirname10, join as join12, resolve as resolve11 } from "node:path";
|
|
14554
|
+
import { homedir as homedir3 } from "node:os";
|
|
14541
14555
|
import { pathToFileURL } from "node:url";
|
|
14542
14556
|
import { createHash as createHash5 } from "node:crypto";
|
|
14543
|
-
import { spawn as
|
|
14557
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
14544
14558
|
import { createInterface } from "node:readline";
|
|
14545
14559
|
|
|
14546
14560
|
// ../../packages/sdk/typescript/src/operations.generated.ts
|
|
@@ -15595,8 +15609,8 @@ Idempotent. Access tokens revoked while the customer was blocked stay revoked; s
|
|
|
15595
15609
|
{
|
|
15596
15610
|
resource: "agent.agents.events",
|
|
15597
15611
|
method: "stream",
|
|
15598
|
-
summary: "Follow
|
|
15599
|
-
description: "Follow
|
|
15612
|
+
summary: "Follow an agent live",
|
|
15613
|
+
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.",
|
|
15600
15614
|
http: "GET",
|
|
15601
15615
|
path: "/agent/v1/agents/{agent_id}/events/stream",
|
|
15602
15616
|
streaming: "always",
|
|
@@ -15622,6 +15636,40 @@ Idempotent. Access tokens revoked while the customer was blocked stay revoked; s
|
|
|
15622
15636
|
}
|
|
15623
15637
|
]
|
|
15624
15638
|
},
|
|
15639
|
+
{
|
|
15640
|
+
resource: "agent.agents.inbox.letters",
|
|
15641
|
+
method: "list",
|
|
15642
|
+
summary: "List an assume agent's waiting letters",
|
|
15643
|
+
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.",
|
|
15644
|
+
http: "GET",
|
|
15645
|
+
path: "/agent/v1/agents/{agent_id}/inbox/letters",
|
|
15646
|
+
streaming: "no",
|
|
15647
|
+
pagination: false,
|
|
15648
|
+
pathParams: [
|
|
15649
|
+
{
|
|
15650
|
+
name: "agent_id",
|
|
15651
|
+
sdkName: "agent_id",
|
|
15652
|
+
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_…."
|
|
15653
|
+
}
|
|
15654
|
+
],
|
|
15655
|
+
query: [
|
|
15656
|
+
{
|
|
15657
|
+
name: "unread",
|
|
15658
|
+
type: "boolean",
|
|
15659
|
+
enum: [
|
|
15660
|
+
true
|
|
15661
|
+
],
|
|
15662
|
+
required: false,
|
|
15663
|
+
description: "Only true is accepted, which is also the default; this read lists waiting (unread) letters and nothing else."
|
|
15664
|
+
},
|
|
15665
|
+
{
|
|
15666
|
+
name: "limit",
|
|
15667
|
+
type: "integer",
|
|
15668
|
+
required: false,
|
|
15669
|
+
description: "How many of the newest unread letters to return, 1 to 50 (default 20); unread always counts every waiting letter."
|
|
15670
|
+
}
|
|
15671
|
+
]
|
|
15672
|
+
},
|
|
15625
15673
|
{
|
|
15626
15674
|
resource: "agent.agents.unarchive",
|
|
15627
15675
|
method: "create",
|
|
@@ -16989,7 +17037,7 @@ delete it. Omit the field to preserve.`
|
|
|
16989
17037
|
summary: "List Session Artifacts (Extension)",
|
|
16990
17038
|
description: `List the files this session delivered; an end-customer token reads its own session.
|
|
16991
17039
|
|
|
16992
|
-
Own-face extension. Returns { data: Artifact[] } ordered by create_time. Each artifact is one file in the session outputs directory 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.`,
|
|
17040
|
+
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.`,
|
|
16993
17041
|
http: "GET",
|
|
16994
17042
|
path: "/agent/v1/sessions/{session_id}/artifacts",
|
|
16995
17043
|
streaming: "no",
|
|
@@ -17009,7 +17057,7 @@ Own-face extension. Returns { data: Artifact[] } ordered by create_time. Each ar
|
|
|
17009
17057
|
summary: "Create Artifact Content URL (Extension)",
|
|
17010
17058
|
description: `Mint a short-lived download address for one file of an artifact.
|
|
17011
17059
|
|
|
17012
|
-
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. 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.`,
|
|
17060
|
+
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.`,
|
|
17013
17061
|
http: "POST",
|
|
17014
17062
|
path: "/agent/v1/sessions/{session_id}/artifacts/{artifact_id}/content_url",
|
|
17015
17063
|
streaming: "no",
|
|
@@ -17228,7 +17276,7 @@ Praxis extension available only on /agent/v1, following Claude Agent SDK getCont
|
|
|
17228
17276
|
resource: "agent.sessions.events",
|
|
17229
17277
|
method: "list",
|
|
17230
17278
|
summary: "List session events",
|
|
17231
|
-
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.",
|
|
17279
|
+
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.",
|
|
17232
17280
|
http: "GET",
|
|
17233
17281
|
path: "/agent/v1/sessions/{session_id}/events",
|
|
17234
17282
|
streaming: "no",
|
|
@@ -17387,6 +17435,26 @@ Available only on /agent/v1. Use the message_id field from own-face events, not
|
|
|
17387
17435
|
]
|
|
17388
17436
|
}
|
|
17389
17437
|
},
|
|
17438
|
+
{
|
|
17439
|
+
resource: "agent.sessions.requests",
|
|
17440
|
+
method: "list",
|
|
17441
|
+
summary: "List Session Requests (Extension)",
|
|
17442
|
+
description: `List the requests a session is waiting on; an end-customer token reads its own session.
|
|
17443
|
+
|
|
17444
|
+
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.`,
|
|
17445
|
+
http: "GET",
|
|
17446
|
+
path: "/agent/v1/sessions/{session_id}/requests",
|
|
17447
|
+
streaming: "no",
|
|
17448
|
+
pagination: false,
|
|
17449
|
+
pathParams: [
|
|
17450
|
+
{
|
|
17451
|
+
name: "session_id",
|
|
17452
|
+
sdkName: "session_id",
|
|
17453
|
+
description: "Session id from session creation or listing."
|
|
17454
|
+
}
|
|
17455
|
+
],
|
|
17456
|
+
query: []
|
|
17457
|
+
},
|
|
17390
17458
|
{
|
|
17391
17459
|
resource: "agent.sessions.resources",
|
|
17392
17460
|
method: "list",
|
|
@@ -25439,6 +25507,12 @@ Published at https://docs.deepraxis.com/docs/developers/cut/script-reference wit
|
|
|
25439
25507
|
- \`RippleDeleteRange\` — Cut a time range and close the gap.
|
|
25440
25508
|
- \`DeleteWords\` — Cut transcript words and ripple every track, keeping a breath.
|
|
25441
25509
|
- \`RemoveFillers\` — List and delete filler words by media's own labels; dryRun first.
|
|
25510
|
+
- \`Matte\` — Replace the clip's background with media's matte of its source, read as a luma mask.
|
|
25511
|
+
- \`EnhanceVoice\` — Replace a clip's sound with media's enhanced speech on its own audio track.
|
|
25512
|
+
- \`AlignByAudio\` — Line two recordings of the same sound up by media's measurement of their offset.
|
|
25513
|
+
- \`Reframe\` — Swap the clip's media for media's reframed take at the aspect you ask for.
|
|
25514
|
+
- \`Upscale\` — Swap the clip's media for media's upscaled take at the height you ask for.
|
|
25515
|
+
- \`Redact\` — Pixelate the faces, QR codes or text media marks, leaving the rest of the frame plain.
|
|
25442
25516
|
- \`AddTrack\` — Add a video, audio or caption track.
|
|
25443
25517
|
- \`MoveTrack\` — Move a track between layers; 0 is the topmost.
|
|
25444
25518
|
- \`UpdateTrack\` — Change a track's name, lock, gain or role.
|
|
@@ -25542,6 +25616,9 @@ Published at https://docs.deepraxis.com/docs/developers/cut/script-reference wit
|
|
|
25542
25616
|
- \`MEDIA_OFFLINE\` — The asset cannot be fetched right now.
|
|
25543
25617
|
- \`MEDIA_UNAVAILABLE\` — The asset is not usable for rendering.
|
|
25544
25618
|
- \`MEDIA_IMPORT_FAILED\` — Importing media failed.
|
|
25619
|
+
- \`MEDIA_PROCESSING\` — Media is still processing the clip; wait for the job and rerun.
|
|
25620
|
+
- \`MEDIA_PROCESSING_FAILED\` — Media's processing job failed; nothing changed.
|
|
25621
|
+
- \`ALIGNMENT_UNCERTAIN\` — \`AlignByAudio\` confidence too low; nothing changed.
|
|
25545
25622
|
- \`FRAME_OUT_OF_RANGE\` — The preview time is outside the project.
|
|
25546
25623
|
- \`PROJECT_TOO_LARGE\` — The project exceeds the size limit.
|
|
25547
25624
|
- \`RESPONSE_TOO_LARGE\` — The response would exceed its budget.
|
|
@@ -29901,7 +29978,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
29901
29978
|
resource: "devops.units",
|
|
29902
29979
|
method: "push",
|
|
29903
29980
|
summary: "Push a unit's branch",
|
|
29904
|
-
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
|
|
29981
|
+
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.",
|
|
29905
29982
|
http: "POST",
|
|
29906
29983
|
path: "/devops/v1/units/{id}:push",
|
|
29907
29984
|
streaming: "no",
|
|
@@ -30237,7 +30314,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
30237
30314
|
resource: "file.uploads",
|
|
30238
30315
|
method: "createSigned",
|
|
30239
30316
|
summary: "Create a one-time upload URL",
|
|
30240
|
-
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
|
|
30317
|
+
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\"}.",
|
|
30241
30318
|
http: "POST",
|
|
30242
30319
|
path: "/file/v1/uploads/signed",
|
|
30243
30320
|
streaming: "no",
|
|
@@ -31807,11 +31884,57 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
31807
31884
|
]
|
|
31808
31885
|
}
|
|
31809
31886
|
},
|
|
31887
|
+
{
|
|
31888
|
+
resource: "media.libraries.assets.align",
|
|
31889
|
+
method: "create",
|
|
31890
|
+
summary: "Align asset",
|
|
31891
|
+
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}.",
|
|
31892
|
+
http: "POST",
|
|
31893
|
+
path: "/media/v1/libraries/{library_id}/assets/{asset_id}/align",
|
|
31894
|
+
streaming: "no",
|
|
31895
|
+
pagination: false,
|
|
31896
|
+
pathParams: [
|
|
31897
|
+
{
|
|
31898
|
+
name: "library_id",
|
|
31899
|
+
sdkName: "library_id",
|
|
31900
|
+
description: "Library ID returned by creation."
|
|
31901
|
+
},
|
|
31902
|
+
{
|
|
31903
|
+
name: "asset_id",
|
|
31904
|
+
sdkName: "asset_id",
|
|
31905
|
+
description: "32-character asset ID."
|
|
31906
|
+
}
|
|
31907
|
+
],
|
|
31908
|
+
query: [],
|
|
31909
|
+
body: {
|
|
31910
|
+
required: true,
|
|
31911
|
+
fields: [
|
|
31912
|
+
{
|
|
31913
|
+
name: "reference_asset_id",
|
|
31914
|
+
type: "string",
|
|
31915
|
+
required: true,
|
|
31916
|
+
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."
|
|
31917
|
+
},
|
|
31918
|
+
{
|
|
31919
|
+
name: "max_offset_seconds",
|
|
31920
|
+
type: "number",
|
|
31921
|
+
required: false,
|
|
31922
|
+
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."
|
|
31923
|
+
},
|
|
31924
|
+
{
|
|
31925
|
+
name: "idempotency_key",
|
|
31926
|
+
type: "string",
|
|
31927
|
+
required: false,
|
|
31928
|
+
description: "Stable key so a retried request reuses the same job instead of analysing and charging again; reusing it with different content is rejected."
|
|
31929
|
+
}
|
|
31930
|
+
]
|
|
31931
|
+
}
|
|
31932
|
+
},
|
|
31810
31933
|
{
|
|
31811
31934
|
resource: "media.assets",
|
|
31812
31935
|
method: "edit",
|
|
31813
31936
|
summary: "Edit asset",
|
|
31814
|
-
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 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\"}}.",
|
|
31937
|
+
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\"}}.",
|
|
31815
31938
|
http: "POST",
|
|
31816
31939
|
path: "/media/v1/libraries/{library_id}/assets/{asset_id}/edits",
|
|
31817
31940
|
streaming: "no",
|
|
@@ -31836,7 +31959,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
31836
31959
|
name: "operation",
|
|
31837
31960
|
type: "object",
|
|
31838
31961
|
required: true,
|
|
31839
|
-
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."
|
|
31962
|
+
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."
|
|
31840
31963
|
},
|
|
31841
31964
|
{
|
|
31842
31965
|
name: "model",
|
|
@@ -31915,6 +32038,69 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
31915
32038
|
]
|
|
31916
32039
|
}
|
|
31917
32040
|
},
|
|
32041
|
+
{
|
|
32042
|
+
resource: "media.libraries.assets.hls",
|
|
32043
|
+
method: "list",
|
|
32044
|
+
summary: "Get HLS renditions",
|
|
32045
|
+
description: "Read how ready a video asset’s on-demand ladder is, rung by rung, without building anything. Use library_id and asset_id as everywhere else. The answer names the asset, its current version, the asset’s own facts (resource_type, is_audio and duration) and one entry per recorded rung — name, height, the first indexed piece’s width, the rung’s bitrate and stored bytes, and its state (processing while pieces run, ready when every piece is ready, failed when a piece gave up). A ladder that was never requested, and an asset that is not a video, answer an empty renditions rather than an error. This read mints no capability and signs nothing, so play the ladder through the content service, which issues the short-lived play address for the current version. Example: GET /media/v1/libraries/lib_example/assets/9dfa312ef9bc4b00816339b598b1152c/hls.",
|
|
32046
|
+
http: "GET",
|
|
32047
|
+
path: "/media/v1/libraries/{library_id}/assets/{asset_id}/hls",
|
|
32048
|
+
streaming: "no",
|
|
32049
|
+
pagination: false,
|
|
32050
|
+
pathParams: [
|
|
32051
|
+
{
|
|
32052
|
+
name: "library_id",
|
|
32053
|
+
sdkName: "library_id",
|
|
32054
|
+
description: "Library ID returned by creation."
|
|
32055
|
+
},
|
|
32056
|
+
{
|
|
32057
|
+
name: "asset_id",
|
|
32058
|
+
sdkName: "asset_id",
|
|
32059
|
+
description: "32-character asset ID."
|
|
32060
|
+
}
|
|
32061
|
+
],
|
|
32062
|
+
query: []
|
|
32063
|
+
},
|
|
32064
|
+
{
|
|
32065
|
+
resource: "media.libraries.assets.hls",
|
|
32066
|
+
method: "create",
|
|
32067
|
+
summary: "Request HLS renditions",
|
|
32068
|
+
description: "Build a video asset’s adaptive HLS ladder for its current version, so one asset plays at several clarities on an ordinary player. Use library_id from creation or listing and the asset_id of a video asset; the ladder belongs to the version the asset has now, and a later version gets its own. heights names the rungs to build: a non-empty subset of 480, 720 and 1080 with no repeats, or omitted to build all three. The ladder never upscales — a rung above the source’s short side is dropped, and a list entirely above it keeps its lowest rung. The call is asynchronous and starts paid transcoding: the work runs as the video-transcode-hls model, one piece per rung per ten minutes of source, and it is charged per output minute at that model’s published price to the organization that owns the asset (ADR-146 §5) — a rung the source cannot carry, and a failed rung, are not charged. A source longer than eight hours (28800 seconds) is refused with SOURCE_TOO_LONG before anything is planned. Repeating the call is safe: a rung already processing, ready or failed is left as it is and is never encoded twice. The response is 202 with the asset_id, its current version and one entry per rung — name, height, width, bitrate, bytes and state, where processing means the rung is still being encoded, ready means it plays and failed means it gave up and can be retried by asking again. Poll GET /media/v1/libraries/{library_id}/assets/{asset_id}/hls until every rung is ready, then play the ladder through the content service, which mints the short-lived play address. Example: POST /media/v1/libraries/lib_example/assets/9dfa312ef9bc4b00816339b598b1152c/hls with {\"heights\":[480,720,1080]}.",
|
|
32069
|
+
http: "POST",
|
|
32070
|
+
path: "/media/v1/libraries/{library_id}/assets/{asset_id}/hls",
|
|
32071
|
+
streaming: "no",
|
|
32072
|
+
pagination: false,
|
|
32073
|
+
pathParams: [
|
|
32074
|
+
{
|
|
32075
|
+
name: "library_id",
|
|
32076
|
+
sdkName: "library_id",
|
|
32077
|
+
description: "Library ID returned by creation."
|
|
32078
|
+
},
|
|
32079
|
+
{
|
|
32080
|
+
name: "asset_id",
|
|
32081
|
+
sdkName: "asset_id",
|
|
32082
|
+
description: "32-character asset ID."
|
|
32083
|
+
}
|
|
32084
|
+
],
|
|
32085
|
+
query: [],
|
|
32086
|
+
body: {
|
|
32087
|
+
required: true,
|
|
32088
|
+
fields: [
|
|
32089
|
+
{
|
|
32090
|
+
name: "heights",
|
|
32091
|
+
type: "array",
|
|
32092
|
+
itemType: "integer",
|
|
32093
|
+
enum: [
|
|
32094
|
+
480,
|
|
32095
|
+
720,
|
|
32096
|
+
1080
|
|
32097
|
+
],
|
|
32098
|
+
required: false,
|
|
32099
|
+
description: "The clarity rungs to build: a non-empty subset of 480, 720 and 1080 with no repeats. Omitted or empty builds all three. The ladder never upscales, so a rung above the source’s short side is dropped."
|
|
32100
|
+
}
|
|
32101
|
+
]
|
|
32102
|
+
}
|
|
32103
|
+
},
|
|
31918
32104
|
{
|
|
31919
32105
|
resource: "media.assets",
|
|
31920
32106
|
method: "lineage",
|
|
@@ -34869,6 +35055,7 @@ for more details.`
|
|
|
34869
35055
|
"openai.images.generations",
|
|
34870
35056
|
"openai.responses",
|
|
34871
35057
|
"openai.videos",
|
|
35058
|
+
"praxis.media.process",
|
|
34872
35059
|
"praxis.video.matting",
|
|
34873
35060
|
"typesafe.systemone",
|
|
34874
35061
|
"volcengine.music",
|
|
@@ -40544,6 +40731,131 @@ for more details.`
|
|
|
40544
40731
|
]
|
|
40545
40732
|
}
|
|
40546
40733
|
},
|
|
40734
|
+
{
|
|
40735
|
+
resource: "share.permissions",
|
|
40736
|
+
method: "list",
|
|
40737
|
+
summary: "List shares",
|
|
40738
|
+
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.",
|
|
40739
|
+
http: "GET",
|
|
40740
|
+
path: "/share/v1/permissions",
|
|
40741
|
+
streaming: "no",
|
|
40742
|
+
pagination: false,
|
|
40743
|
+
pathParams: [],
|
|
40744
|
+
query: [
|
|
40745
|
+
{
|
|
40746
|
+
name: "resource_type",
|
|
40747
|
+
type: "string",
|
|
40748
|
+
enum: [
|
|
40749
|
+
"file",
|
|
40750
|
+
"artifact",
|
|
40751
|
+
"canvas",
|
|
40752
|
+
"media_asset"
|
|
40753
|
+
],
|
|
40754
|
+
required: false,
|
|
40755
|
+
description: "Only shares of this object type; file, canvas and media_asset create today."
|
|
40756
|
+
},
|
|
40757
|
+
{
|
|
40758
|
+
name: "resource_id",
|
|
40759
|
+
type: "string",
|
|
40760
|
+
required: false,
|
|
40761
|
+
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."
|
|
40762
|
+
},
|
|
40763
|
+
{
|
|
40764
|
+
name: "status",
|
|
40765
|
+
type: "string",
|
|
40766
|
+
enum: [
|
|
40767
|
+
"active",
|
|
40768
|
+
"expired",
|
|
40769
|
+
"revoked"
|
|
40770
|
+
],
|
|
40771
|
+
required: false,
|
|
40772
|
+
description: "Only shares in this state; omit to list every state."
|
|
40773
|
+
},
|
|
40774
|
+
{
|
|
40775
|
+
name: "page_size",
|
|
40776
|
+
type: "integer",
|
|
40777
|
+
required: false,
|
|
40778
|
+
description: "Maximum shares in one page, from 1 to 100; defaults to 50."
|
|
40779
|
+
},
|
|
40780
|
+
{
|
|
40781
|
+
name: "page_token",
|
|
40782
|
+
type: "string",
|
|
40783
|
+
required: false,
|
|
40784
|
+
description: "Opaque next_page_token from the preceding page with the same filters; omit on the first request."
|
|
40785
|
+
}
|
|
40786
|
+
]
|
|
40787
|
+
},
|
|
40788
|
+
{
|
|
40789
|
+
resource: "share.permissions",
|
|
40790
|
+
method: "create",
|
|
40791
|
+
summary: "Create share",
|
|
40792
|
+
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.",
|
|
40793
|
+
http: "POST",
|
|
40794
|
+
path: "/share/v1/permissions",
|
|
40795
|
+
streaming: "no",
|
|
40796
|
+
pagination: false,
|
|
40797
|
+
pathParams: [],
|
|
40798
|
+
query: [],
|
|
40799
|
+
body: {
|
|
40800
|
+
required: true,
|
|
40801
|
+
fields: [
|
|
40802
|
+
{
|
|
40803
|
+
name: "resource",
|
|
40804
|
+
type: "object",
|
|
40805
|
+
required: true,
|
|
40806
|
+
description: "The object a share exposes, named by a type and an id."
|
|
40807
|
+
},
|
|
40808
|
+
{
|
|
40809
|
+
name: "expire_time",
|
|
40810
|
+
type: "string",
|
|
40811
|
+
required: false,
|
|
40812
|
+
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."
|
|
40813
|
+
},
|
|
40814
|
+
{
|
|
40815
|
+
name: "prevents_download",
|
|
40816
|
+
type: "boolean",
|
|
40817
|
+
required: false,
|
|
40818
|
+
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."
|
|
40819
|
+
}
|
|
40820
|
+
]
|
|
40821
|
+
}
|
|
40822
|
+
},
|
|
40823
|
+
{
|
|
40824
|
+
resource: "share.permissions",
|
|
40825
|
+
method: "delete",
|
|
40826
|
+
summary: "Delete share",
|
|
40827
|
+
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.",
|
|
40828
|
+
http: "DELETE",
|
|
40829
|
+
path: "/share/v1/permissions/{id}",
|
|
40830
|
+
streaming: "no",
|
|
40831
|
+
pagination: false,
|
|
40832
|
+
pathParams: [
|
|
40833
|
+
{
|
|
40834
|
+
name: "id",
|
|
40835
|
+
sdkName: "id",
|
|
40836
|
+
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."
|
|
40837
|
+
}
|
|
40838
|
+
],
|
|
40839
|
+
query: []
|
|
40840
|
+
},
|
|
40841
|
+
{
|
|
40842
|
+
resource: "share.permissions",
|
|
40843
|
+
method: "retrieve",
|
|
40844
|
+
summary: "Retrieve share",
|
|
40845
|
+
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.",
|
|
40846
|
+
http: "GET",
|
|
40847
|
+
path: "/share/v1/permissions/{id}",
|
|
40848
|
+
streaming: "no",
|
|
40849
|
+
pagination: false,
|
|
40850
|
+
pathParams: [
|
|
40851
|
+
{
|
|
40852
|
+
name: "id",
|
|
40853
|
+
sdkName: "id",
|
|
40854
|
+
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."
|
|
40855
|
+
}
|
|
40856
|
+
],
|
|
40857
|
+
query: []
|
|
40858
|
+
},
|
|
40547
40859
|
{
|
|
40548
40860
|
resource: "studio.codexes",
|
|
40549
40861
|
method: "list",
|
|
@@ -47018,6 +47330,19 @@ var getAgentConsolidation = (options) => (options.client ?? client).get({
|
|
|
47018
47330
|
url: "/agent/v1/agents/{agent_id}/consolidations/{consolidation_id}",
|
|
47019
47331
|
...options
|
|
47020
47332
|
});
|
|
47333
|
+
var listAgentInboxLetters = (options) => (options.client ?? client).get({
|
|
47334
|
+
security: [{
|
|
47335
|
+
key: "BearerAuth",
|
|
47336
|
+
scheme: "bearer",
|
|
47337
|
+
type: "http"
|
|
47338
|
+
}, {
|
|
47339
|
+
key: "ApiKeyAuth",
|
|
47340
|
+
name: "X-API-Key",
|
|
47341
|
+
type: "apiKey"
|
|
47342
|
+
}],
|
|
47343
|
+
url: "/agent/v1/agents/{agent_id}/inbox/letters",
|
|
47344
|
+
...options
|
|
47345
|
+
});
|
|
47021
47346
|
var applyAgentVersion = (options) => (options.client ?? client).post({
|
|
47022
47347
|
security: [{
|
|
47023
47348
|
key: "BearerAuth",
|
|
@@ -47488,6 +47813,19 @@ var createSessionArtifactContentUrl = (options) => (options.client ?? client).po
|
|
|
47488
47813
|
...options.headers
|
|
47489
47814
|
}
|
|
47490
47815
|
});
|
|
47816
|
+
var listSessionRequests = (options) => (options.client ?? client).get({
|
|
47817
|
+
security: [{
|
|
47818
|
+
key: "BearerAuth",
|
|
47819
|
+
scheme: "bearer",
|
|
47820
|
+
type: "http"
|
|
47821
|
+
}, {
|
|
47822
|
+
key: "ApiKeyAuth",
|
|
47823
|
+
name: "X-API-Key",
|
|
47824
|
+
type: "apiKey"
|
|
47825
|
+
}],
|
|
47826
|
+
url: "/agent/v1/sessions/{session_id}/requests",
|
|
47827
|
+
...options
|
|
47828
|
+
});
|
|
47491
47829
|
var listSessionBackgroundTasks = (options) => (options.client ?? client).get({
|
|
47492
47830
|
security: [{
|
|
47493
47831
|
key: "BearerAuth",
|
|
@@ -54598,6 +54936,41 @@ var mediaGetGenerationCapabilities = (options) => (options?.client ?? client).ge
|
|
|
54598
54936
|
url: "/media/v1/generation/capabilities",
|
|
54599
54937
|
...options
|
|
54600
54938
|
});
|
|
54939
|
+
var mediaAlignAsset = (options) => (options.client ?? client).post({
|
|
54940
|
+
security: [{
|
|
54941
|
+
key: "media-BearerAuth",
|
|
54942
|
+
scheme: "bearer",
|
|
54943
|
+
type: "http"
|
|
54944
|
+
}],
|
|
54945
|
+
url: "/media/v1/libraries/{library_id}/assets/{asset_id}/align",
|
|
54946
|
+
...options,
|
|
54947
|
+
headers: {
|
|
54948
|
+
"Content-Type": "application/json",
|
|
54949
|
+
...options.headers
|
|
54950
|
+
}
|
|
54951
|
+
});
|
|
54952
|
+
var mediaGetHlsRenditions = (options) => (options.client ?? client).get({
|
|
54953
|
+
security: [{
|
|
54954
|
+
key: "media-BearerAuth",
|
|
54955
|
+
scheme: "bearer",
|
|
54956
|
+
type: "http"
|
|
54957
|
+
}],
|
|
54958
|
+
url: "/media/v1/libraries/{library_id}/assets/{asset_id}/hls",
|
|
54959
|
+
...options
|
|
54960
|
+
});
|
|
54961
|
+
var mediaRequestHlsRenditions = (options) => (options.client ?? client).post({
|
|
54962
|
+
security: [{
|
|
54963
|
+
key: "media-BearerAuth",
|
|
54964
|
+
scheme: "bearer",
|
|
54965
|
+
type: "http"
|
|
54966
|
+
}],
|
|
54967
|
+
url: "/media/v1/libraries/{library_id}/assets/{asset_id}/hls",
|
|
54968
|
+
...options,
|
|
54969
|
+
headers: {
|
|
54970
|
+
"Content-Type": "application/json",
|
|
54971
|
+
...options.headers
|
|
54972
|
+
}
|
|
54973
|
+
});
|
|
54601
54974
|
var ontologyListTypes = (options) => (options?.client ?? client).get({
|
|
54602
54975
|
security: [{
|
|
54603
54976
|
key: "ontology-bearerAuth",
|
|
@@ -55730,6 +56103,46 @@ var searchMap = (options) => (options.client ?? client).post({
|
|
|
55730
56103
|
...options.headers
|
|
55731
56104
|
}
|
|
55732
56105
|
});
|
|
56106
|
+
var shareListPermissions = (options) => (options?.client ?? client).get({
|
|
56107
|
+
security: [{
|
|
56108
|
+
key: "share-bearerAuth",
|
|
56109
|
+
scheme: "bearer",
|
|
56110
|
+
type: "http"
|
|
56111
|
+
}],
|
|
56112
|
+
url: "/share/v1/permissions",
|
|
56113
|
+
...options
|
|
56114
|
+
});
|
|
56115
|
+
var shareCreatePermission = (options) => (options.client ?? client).post({
|
|
56116
|
+
security: [{
|
|
56117
|
+
key: "share-bearerAuth",
|
|
56118
|
+
scheme: "bearer",
|
|
56119
|
+
type: "http"
|
|
56120
|
+
}],
|
|
56121
|
+
url: "/share/v1/permissions",
|
|
56122
|
+
...options,
|
|
56123
|
+
headers: {
|
|
56124
|
+
"Content-Type": "application/json",
|
|
56125
|
+
...options.headers
|
|
56126
|
+
}
|
|
56127
|
+
});
|
|
56128
|
+
var shareDeletePermission = (options) => (options.client ?? client).delete({
|
|
56129
|
+
security: [{
|
|
56130
|
+
key: "share-bearerAuth",
|
|
56131
|
+
scheme: "bearer",
|
|
56132
|
+
type: "http"
|
|
56133
|
+
}],
|
|
56134
|
+
url: "/share/v1/permissions/{id}",
|
|
56135
|
+
...options
|
|
56136
|
+
});
|
|
56137
|
+
var shareRetrievePermission = (options) => (options.client ?? client).get({
|
|
56138
|
+
security: [{
|
|
56139
|
+
key: "share-bearerAuth",
|
|
56140
|
+
scheme: "bearer",
|
|
56141
|
+
type: "http"
|
|
56142
|
+
}],
|
|
56143
|
+
url: "/share/v1/permissions/{id}",
|
|
56144
|
+
...options
|
|
56145
|
+
});
|
|
55733
56146
|
var studioGenresList = (options) => (options?.client ?? client).get({
|
|
55734
56147
|
security: [{
|
|
55735
56148
|
key: "BearerAuth",
|
|
@@ -57766,6 +58179,11 @@ function createAgent(transport) {
|
|
|
57766
58179
|
send: bind(transport, sendAgentEvents),
|
|
57767
58180
|
stream: bindStream(transport, streamAgentEvents)
|
|
57768
58181
|
},
|
|
58182
|
+
inbox: {
|
|
58183
|
+
letters: {
|
|
58184
|
+
list: bind(transport, listAgentInboxLetters)
|
|
58185
|
+
}
|
|
58186
|
+
},
|
|
57769
58187
|
list: bind(transport, agentsList),
|
|
57770
58188
|
retrieve: bind(transport, agentsRetrieve),
|
|
57771
58189
|
retrieveAppearance: bind(transport, getAgentAppearance),
|
|
@@ -57854,6 +58272,9 @@ function createAgent(transport) {
|
|
|
57854
58272
|
},
|
|
57855
58273
|
fork: bind(transport, forkSession),
|
|
57856
58274
|
list: bind(transport, sessionsList),
|
|
58275
|
+
requests: {
|
|
58276
|
+
list: bind(transport, listSessionRequests)
|
|
58277
|
+
},
|
|
57857
58278
|
resources: {
|
|
57858
58279
|
create: bind(transport, sessionsResourcesAdd),
|
|
57859
58280
|
delete: bind(transport, aliasOperation(sessionsResourcesDelete, { query: { session_id: "query_session_id" } })),
|
|
@@ -58571,12 +58992,19 @@ function createMedia(transport) {
|
|
|
58571
58992
|
},
|
|
58572
58993
|
libraries: {
|
|
58573
58994
|
assets: {
|
|
58995
|
+
align: {
|
|
58996
|
+
create: bind(transport, mediaAlignAsset)
|
|
58997
|
+
},
|
|
58574
58998
|
batch: bind(transport, mediaBatchAssets),
|
|
58575
58999
|
create: bind(transport, (options) => mediaUploadAsset({ ...options, bodySerializer: multipartBodySerializer, headers: { "Content-Type": null, ...options.headers } })),
|
|
58576
59000
|
delete: bind(transport, mediaDeleteAsset),
|
|
58577
59001
|
frames: {
|
|
58578
59002
|
create: bind(transport, mediaCreateFrameUrls)
|
|
58579
59003
|
},
|
|
59004
|
+
hls: {
|
|
59005
|
+
create: bind(transport, mediaRequestHlsRenditions),
|
|
59006
|
+
list: bind(transport, mediaGetHlsRenditions)
|
|
59007
|
+
},
|
|
58580
59008
|
import: {
|
|
58581
59009
|
create: bind(transport, mediaImportAsset)
|
|
58582
59010
|
},
|
|
@@ -59012,6 +59440,16 @@ function createSearch(transport) {
|
|
|
59012
59440
|
}
|
|
59013
59441
|
};
|
|
59014
59442
|
}
|
|
59443
|
+
function createShare(transport) {
|
|
59444
|
+
return {
|
|
59445
|
+
permissions: {
|
|
59446
|
+
create: bind(transport, shareCreatePermission),
|
|
59447
|
+
delete: bind(transport, shareDeletePermission),
|
|
59448
|
+
list: bind(transport, shareListPermissions),
|
|
59449
|
+
retrieve: bind(transport, shareRetrievePermission)
|
|
59450
|
+
}
|
|
59451
|
+
};
|
|
59452
|
+
}
|
|
59015
59453
|
function createStudio(transport) {
|
|
59016
59454
|
return {
|
|
59017
59455
|
codexes: {
|
|
@@ -59282,6 +59720,7 @@ var resourceFactories = {
|
|
|
59282
59720
|
organization: createOrganization,
|
|
59283
59721
|
sandbox: createSandbox,
|
|
59284
59722
|
search: createSearch,
|
|
59723
|
+
share: createShare,
|
|
59285
59724
|
studio: createStudio,
|
|
59286
59725
|
ticket: createTicket,
|
|
59287
59726
|
vault: createVault
|
|
@@ -61099,7 +61538,7 @@ function help(commands, prefix, command) {
|
|
|
61099
61538
|
...[...operationOptions(command.op), ...bodyDataOption(command.op), ...globalOptions].map((s) => ` ${describeOption(s, s.required && fieldRequired(command.op, s, s.location ?? "query"))}`),
|
|
61100
61539
|
...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" : ""})`) ?? [],
|
|
61101
61540
|
" -h is an alias of --help",
|
|
61102
|
-
"PRAXIS_ENV=develop
|
|
61541
|
+
"PRAXIS_ENV=production|develop (default: production; develop must be named); no --env option.",
|
|
61103
61542
|
"",
|
|
61104
61543
|
"Examples:",
|
|
61105
61544
|
` ${example(command)}`
|
|
@@ -61111,7 +61550,7 @@ function help(commands, prefix, command) {
|
|
|
61111
61550
|
"Global options:",
|
|
61112
61551
|
...globalOptions.map((s) => ` ${describeOption(s)}`),
|
|
61113
61552
|
" -h is an alias of --help",
|
|
61114
|
-
"PRAXIS_ENV=develop
|
|
61553
|
+
"PRAXIS_ENV=production|develop (default: production; develop must be named); no --env option.",
|
|
61115
61554
|
""
|
|
61116
61555
|
];
|
|
61117
61556
|
const sample = matching.find((c) => c.words.at(-1) === "list") ?? matching[0];
|
|
@@ -61599,6 +62038,41 @@ var workflows = [
|
|
|
61599
62038
|
platform: "praxis api devops project change create — the platform creates and names a Change; the CLI only lands its branch (ADR-125 §5).",
|
|
61600
62039
|
docs: "https://docs.deepraxis.com/docs/cli"
|
|
61601
62040
|
},
|
|
62041
|
+
{
|
|
62042
|
+
words: ["agent", "events", "wait"],
|
|
62043
|
+
usage: "agent events wait [--timeout <seconds>]",
|
|
62044
|
+
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.",
|
|
62045
|
+
example: "PRAXIS_ASSUME_AGENT=R1M9TQ2X praxis agent events wait",
|
|
62046
|
+
network: "online"
|
|
62047
|
+
},
|
|
62048
|
+
{
|
|
62049
|
+
words: ["agent", "memory"],
|
|
62050
|
+
usage: "agent memory [--hook SessionStart|UserPromptSubmit]",
|
|
62051
|
+
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.",
|
|
62052
|
+
example: "praxis agent memory",
|
|
62053
|
+
network: "online"
|
|
62054
|
+
},
|
|
62055
|
+
{
|
|
62056
|
+
words: ["agent", "recall"],
|
|
62057
|
+
usage: "agent recall [--words <w,w>] [--handles <id,id>]",
|
|
62058
|
+
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.",
|
|
62059
|
+
example: "praxis agent recall --words 章程,运维部",
|
|
62060
|
+
network: "online"
|
|
62061
|
+
},
|
|
62062
|
+
{
|
|
62063
|
+
words: ["agent", "remember"],
|
|
62064
|
+
usage: "agent remember --text <experience> [--about <id,id>]",
|
|
62065
|
+
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.",
|
|
62066
|
+
example: 'praxis agent remember --text "Sean 定了副总裁用钩子载入认知"',
|
|
62067
|
+
network: "online"
|
|
62068
|
+
},
|
|
62069
|
+
{
|
|
62070
|
+
words: ["agent", "events", "channel"],
|
|
62071
|
+
usage: "agent events channel",
|
|
62072
|
+
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.",
|
|
62073
|
+
example: "claude --dangerously-load-development-channels plugin:assume-agent@deepraxis",
|
|
62074
|
+
network: "online"
|
|
62075
|
+
},
|
|
61602
62076
|
{ 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"' },
|
|
61603
62077
|
{ words: ["skill"], usage: "skill [--install <dir>]", summary: "Print the AI skill, or write <dir>/praxis-cli/SKILL.md." },
|
|
61604
62078
|
{
|
|
@@ -61668,7 +62142,7 @@ function workflowHelp(workflow, options) {
|
|
|
61668
62142
|
"Options:",
|
|
61669
62143
|
...[...options, ...globalOptions].map((s) => ` ${describeOption(s)}`),
|
|
61670
62144
|
" -h is an alias of --help",
|
|
61671
|
-
"PRAXIS_ENV=develop
|
|
62145
|
+
"PRAXIS_ENV=production|develop (default: production; develop must be named); no --env option.",
|
|
61672
62146
|
...workflow.requires === "checkout" ? [`Requires: ${CHECKOUT_REQUIREMENT}`] : [],
|
|
61673
62147
|
...workflow.notes?.length ? ["", ...workflow.notes] : [],
|
|
61674
62148
|
...workflow.network ? ["", `Network: ${workflow.network}`] : [],
|
|
@@ -63191,54 +63665,68 @@ function wranglerEdges(nodes) {
|
|
|
63191
63665
|
}
|
|
63192
63666
|
return edges;
|
|
63193
63667
|
}
|
|
63194
|
-
// ../../packages/praxis/deploy-core/src/
|
|
63195
|
-
|
|
63196
|
-
|
|
63197
|
-
|
|
63198
|
-
|
|
63199
|
-
|
|
63200
|
-
|
|
63201
|
-
|
|
63202
|
-
|
|
63203
|
-
|
|
63204
|
-
|
|
63205
|
-
|
|
63206
|
-
|
|
63207
|
-
if (typeof version !== "string" || !version.startsWith("workspace:") || dependencies.has(dependency))
|
|
63208
|
-
continue;
|
|
63209
|
-
dependencies.add(dependency);
|
|
63210
|
-
if (field === "devDependencies")
|
|
63211
|
-
devOnly.add(dependency);
|
|
63212
|
-
}
|
|
63668
|
+
// ../../packages/praxis/deploy-core/src/job-events.ts
|
|
63669
|
+
var DEFAULT_EXPIRE_MINUTES = 60;
|
|
63670
|
+
var DEFAULT_PHASE_ID = "stable";
|
|
63671
|
+
function jobStatesOf(outcome) {
|
|
63672
|
+
switch (outcome.kind) {
|
|
63673
|
+
case "succeeded":
|
|
63674
|
+
return { jobState: "succeeded", jobRunState: "succeeded" };
|
|
63675
|
+
case "failed":
|
|
63676
|
+
return { jobState: "failed", jobRunState: "failed" };
|
|
63677
|
+
case "disabled":
|
|
63678
|
+
return { jobState: "disabled", jobRunState: "unspecified" };
|
|
63679
|
+
case "skipped":
|
|
63680
|
+
return { jobState: "skipped", jobRunState: "unspecified" };
|
|
63213
63681
|
}
|
|
63214
|
-
return {
|
|
63215
|
-
...typeof name === "string" && name !== "" ? { name } : {},
|
|
63216
|
-
workspaceDependencies: [...dependencies].sort(),
|
|
63217
|
-
devOnlyWorkspaceDependencies: [...devOnly].sort()
|
|
63218
|
-
};
|
|
63219
63682
|
}
|
|
63220
|
-
function
|
|
63221
|
-
|
|
63222
|
-
|
|
63223
|
-
return null;
|
|
63224
|
-
const deepracticex = parsed.deepracticex;
|
|
63225
|
-
if (deepracticex === null || typeof deepracticex !== "object")
|
|
63226
|
-
return null;
|
|
63227
|
-
const lifecycle = deepracticex.lifecycle;
|
|
63228
|
-
return lifecycle !== null && typeof lifecycle === "object" ? lifecycle : null;
|
|
63683
|
+
function formatDeployEvent(event) {
|
|
63684
|
+
return `${JSON.stringify(event)}
|
|
63685
|
+
`;
|
|
63229
63686
|
}
|
|
63230
|
-
function
|
|
63231
|
-
|
|
63232
|
-
|
|
63233
|
-
|
|
63234
|
-
|
|
63687
|
+
function expireTimeOf(startedAt, expireMinutes = DEFAULT_EXPIRE_MINUTES) {
|
|
63688
|
+
const start = Date.parse(startedAt);
|
|
63689
|
+
if (Number.isNaN(start))
|
|
63690
|
+
throw new Error(`--events-file needs a parseable start time, got ${JSON.stringify(startedAt)}`);
|
|
63691
|
+
const minutes = Number(expireMinutes);
|
|
63692
|
+
if (!Number.isFinite(minutes) || minutes <= 0)
|
|
63693
|
+
throw new Error(`--expire-minutes must be a positive number, got ${JSON.stringify(expireMinutes)}`);
|
|
63694
|
+
return new Date(start + minutes * 60000).toISOString();
|
|
63235
63695
|
}
|
|
63236
|
-
function
|
|
63237
|
-
|
|
63238
|
-
|
|
63239
|
-
|
|
63240
|
-
|
|
63241
|
-
|
|
63696
|
+
function decidePhaseState(states) {
|
|
63697
|
+
if (states.length === 0)
|
|
63698
|
+
return "unspecified";
|
|
63699
|
+
if (states.some((state) => state === "failed" || state === "aborted"))
|
|
63700
|
+
return "failed";
|
|
63701
|
+
if (states.some((state) => state === "in_progress" || state === "pending"))
|
|
63702
|
+
return "in_progress";
|
|
63703
|
+
const neverRan = states.every((state) => state === "skipped" || state === "disabled");
|
|
63704
|
+
return neverRan ? "skipped" : "succeeded";
|
|
63705
|
+
}
|
|
63706
|
+
function decideRolloutState(jobs, options = {}) {
|
|
63707
|
+
const states = [...jobs.values()];
|
|
63708
|
+
if (states.some((state) => state === "failed" || state === "aborted"))
|
|
63709
|
+
return "failed";
|
|
63710
|
+
const deploy = jobs.get("deploy");
|
|
63711
|
+
if (deploy === undefined || deploy === "pending" || deploy === "in_progress" || deploy === "disabled")
|
|
63712
|
+
return "pending";
|
|
63713
|
+
if (deploy === "skipped" && options.artifactIdentical !== true)
|
|
63714
|
+
return "pending";
|
|
63715
|
+
if (states.every((state) => state === "succeeded" || state === "skipped" || state === "disabled" || state === "ignored")) {
|
|
63716
|
+
return options.artifactIdentical === true ? "skipped" : "succeeded";
|
|
63717
|
+
}
|
|
63718
|
+
return "pending";
|
|
63719
|
+
}
|
|
63720
|
+
function decideFinishedState(rollouts) {
|
|
63721
|
+
if (rollouts.length === 0)
|
|
63722
|
+
return "failed";
|
|
63723
|
+
const count3 = (wanted) => rollouts.filter((state) => wanted.includes(state)).length;
|
|
63724
|
+
const succeeded = count3(["succeeded", "skipped"]);
|
|
63725
|
+
const failed = count3(["failed"]);
|
|
63726
|
+
const waiting = count3(["pending"]);
|
|
63727
|
+
if (failed === 0)
|
|
63728
|
+
return succeeded === rollouts.length ? "succeeded" : "failed";
|
|
63729
|
+
return succeeded > 0 && waiting > 0 ? "halted" : "failed";
|
|
63242
63730
|
}
|
|
63243
63731
|
// ../../packages/praxis/deploy-core/node_modules/yaml/dist/index.js
|
|
63244
63732
|
var composer = require_composer2();
|
|
@@ -63286,6 +63774,259 @@ var $stringify = publicApi.stringify;
|
|
|
63286
63774
|
var $visit = visit.visit;
|
|
63287
63775
|
var $visitAsync = visit.visitAsync;
|
|
63288
63776
|
|
|
63777
|
+
// ../../packages/praxis/deploy-core/src/lambda-function.ts
|
|
63778
|
+
var LAMBDA_FUNCTIONS_ROOT = "services/lambda/functions";
|
|
63779
|
+
var UPSTREAM = "aliyun-fc";
|
|
63780
|
+
var PROJECT_FILE = "praxis.yaml";
|
|
63781
|
+
function lambdaFunctionRootOwner(root) {
|
|
63782
|
+
return root.split("/").filter((segment) => segment !== "").slice(0, -1).join("/");
|
|
63783
|
+
}
|
|
63784
|
+
function normalizeRoot(root) {
|
|
63785
|
+
return root.replace(/^\.\//, "").split("/").filter((segment) => segment !== "" && segment !== ".").join("/");
|
|
63786
|
+
}
|
|
63787
|
+
var DEFAULT_ROOTS = [
|
|
63788
|
+
{ root: LAMBDA_FUNCTIONS_ROOT, owner: lambdaFunctionRootOwner(LAMBDA_FUNCTIONS_ROOT) }
|
|
63789
|
+
];
|
|
63790
|
+
var isText = (value) => typeof value === "string" && value !== "";
|
|
63791
|
+
function lambdaFunctionRootsOf(text) {
|
|
63792
|
+
if (text === null)
|
|
63793
|
+
return { roots: DEFAULT_ROOTS, warnings: [] };
|
|
63794
|
+
let parsed;
|
|
63795
|
+
try {
|
|
63796
|
+
parsed = $parse(text);
|
|
63797
|
+
} catch (cause) {
|
|
63798
|
+
return {
|
|
63799
|
+
roots: DEFAULT_ROOTS,
|
|
63800
|
+
warnings: [`${PROJECT_FILE}: does not parse, so its recipe roots are not read`]
|
|
63801
|
+
};
|
|
63802
|
+
}
|
|
63803
|
+
const declared = readPath(parsed, ["devops", "deploy", "recipes"]);
|
|
63804
|
+
if (declared === undefined)
|
|
63805
|
+
return { roots: DEFAULT_ROOTS, warnings: [] };
|
|
63806
|
+
if (!Array.isArray(declared)) {
|
|
63807
|
+
return {
|
|
63808
|
+
roots: DEFAULT_ROOTS,
|
|
63809
|
+
warnings: [
|
|
63810
|
+
`${PROJECT_FILE}: devops.deploy.recipes is not a list, so its recipe roots are not read`
|
|
63811
|
+
]
|
|
63812
|
+
};
|
|
63813
|
+
}
|
|
63814
|
+
const roots = [];
|
|
63815
|
+
const warnings = [];
|
|
63816
|
+
declared.forEach((entry, index) => {
|
|
63817
|
+
const root = typeof entry === "string" ? entry : typeof entry === "object" && entry !== null ? entry.root : undefined;
|
|
63818
|
+
if (!isText(root)) {
|
|
63819
|
+
warnings.push(`${PROJECT_FILE}: devops.deploy.recipes[${index}] names no root`);
|
|
63820
|
+
return;
|
|
63821
|
+
}
|
|
63822
|
+
const declaredOwner = typeof entry === "object" && entry !== null ? entry.owner : undefined;
|
|
63823
|
+
if (declaredOwner !== undefined && !isText(declaredOwner)) {
|
|
63824
|
+
warnings.push(`${PROJECT_FILE}: devops.deploy.recipes[${index}] names no owner`);
|
|
63825
|
+
return;
|
|
63826
|
+
}
|
|
63827
|
+
const normalized = normalizeRoot(root);
|
|
63828
|
+
if (normalized === "") {
|
|
63829
|
+
warnings.push(`${PROJECT_FILE}: devops.deploy.recipes[${index}] names no root`);
|
|
63830
|
+
return;
|
|
63831
|
+
}
|
|
63832
|
+
if (roots.some((known) => known.root === normalized))
|
|
63833
|
+
return;
|
|
63834
|
+
roots.push({
|
|
63835
|
+
root: normalized,
|
|
63836
|
+
owner: declaredOwner === undefined ? lambdaFunctionRootOwner(normalized) : normalizeRoot(declaredOwner)
|
|
63837
|
+
});
|
|
63838
|
+
});
|
|
63839
|
+
if (roots.length === 0 && warnings.length === 0) {
|
|
63840
|
+
warnings.push(`${PROJECT_FILE}: devops.deploy.recipes declares no root, so no function recipe is a target`);
|
|
63841
|
+
}
|
|
63842
|
+
return { roots, warnings };
|
|
63843
|
+
}
|
|
63844
|
+
function readPath(value, segments) {
|
|
63845
|
+
let current = value;
|
|
63846
|
+
for (const segment of segments) {
|
|
63847
|
+
if (current === null || typeof current !== "object" || Array.isArray(current))
|
|
63848
|
+
return;
|
|
63849
|
+
current = current[segment];
|
|
63850
|
+
}
|
|
63851
|
+
return current;
|
|
63852
|
+
}
|
|
63853
|
+
var isCount = (value, min, max) => typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
63854
|
+
function lambdaFunctionCodeOf(value) {
|
|
63855
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
63856
|
+
return null;
|
|
63857
|
+
const declared = value;
|
|
63858
|
+
if (!isText(declared.entry) || !isText(declared.artifact))
|
|
63859
|
+
return null;
|
|
63860
|
+
if (!isText(declared.runtime) || !isText(declared.handler))
|
|
63861
|
+
return null;
|
|
63862
|
+
if (!Array.isArray(declared.layers) || !declared.layers.every(isText))
|
|
63863
|
+
return null;
|
|
63864
|
+
if (!Array.isArray(declared.command) || declared.command.length === 0 || !declared.command.every(isText))
|
|
63865
|
+
return null;
|
|
63866
|
+
if (!isCount(declared.port, 1, 65535))
|
|
63867
|
+
return null;
|
|
63868
|
+
return {
|
|
63869
|
+
entry: declared.entry,
|
|
63870
|
+
artifact: declared.artifact,
|
|
63871
|
+
runtime: declared.runtime,
|
|
63872
|
+
handler: declared.handler,
|
|
63873
|
+
layers: [...declared.layers],
|
|
63874
|
+
command: [...declared.command],
|
|
63875
|
+
port: declared.port
|
|
63876
|
+
};
|
|
63877
|
+
}
|
|
63878
|
+
function lambdaFunctionOf(text) {
|
|
63879
|
+
const parsed = text === null ? null : parseJsonc2(text);
|
|
63880
|
+
if (parsed === null)
|
|
63881
|
+
return null;
|
|
63882
|
+
if (!isText(parsed.name) || !isText(parsed.upstream))
|
|
63883
|
+
return null;
|
|
63884
|
+
if (!Array.isArray(parsed.regions) || parsed.regions.length === 0 || !parsed.regions.every(isText))
|
|
63885
|
+
return null;
|
|
63886
|
+
if (parsed.gpu !== undefined && !isText(parsed.gpu))
|
|
63887
|
+
return null;
|
|
63888
|
+
if (!isCount(parsed.cpu, 1, 256))
|
|
63889
|
+
return null;
|
|
63890
|
+
if (!isCount(parsed.memoryMb, 128, 32 * 1024))
|
|
63891
|
+
return null;
|
|
63892
|
+
if (!isCount(parsed.timeoutSeconds, 1, 24 * 3600))
|
|
63893
|
+
return null;
|
|
63894
|
+
if (!isCount(parsed.concurrency, 1, 1024))
|
|
63895
|
+
return null;
|
|
63896
|
+
if (parsed.diskSizeMb !== undefined && !isCount(parsed.diskSizeMb, 512, 10240))
|
|
63897
|
+
return null;
|
|
63898
|
+
let code;
|
|
63899
|
+
if (parsed.code !== undefined) {
|
|
63900
|
+
const declared = lambdaFunctionCodeOf(parsed.code);
|
|
63901
|
+
if (declared === null)
|
|
63902
|
+
return null;
|
|
63903
|
+
code = declared;
|
|
63904
|
+
}
|
|
63905
|
+
return {
|
|
63906
|
+
name: parsed.name,
|
|
63907
|
+
upstream: parsed.upstream,
|
|
63908
|
+
regions: [...parsed.regions],
|
|
63909
|
+
...parsed.gpu === undefined ? {} : { gpu: parsed.gpu },
|
|
63910
|
+
cpu: parsed.cpu,
|
|
63911
|
+
memoryMb: parsed.memoryMb,
|
|
63912
|
+
timeoutSeconds: parsed.timeoutSeconds,
|
|
63913
|
+
concurrency: parsed.concurrency,
|
|
63914
|
+
...parsed.diskSizeMb === undefined ? {} : { diskSizeMb: parsed.diskSizeMb },
|
|
63915
|
+
...code === undefined ? {} : { code }
|
|
63916
|
+
};
|
|
63917
|
+
}
|
|
63918
|
+
var escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
63919
|
+
async function scanRecipes(facts) {
|
|
63920
|
+
const declared = lambdaFunctionRootsOf(await facts.read(PROJECT_FILE));
|
|
63921
|
+
const found = [];
|
|
63922
|
+
const warnings = [...declared.warnings];
|
|
63923
|
+
const matchers = declared.roots.map((root) => ({
|
|
63924
|
+
root,
|
|
63925
|
+
pattern: new RegExp(`^${escapeRegExp(root.root)}/([^/]+)/function\\.json$`)
|
|
63926
|
+
}));
|
|
63927
|
+
for (const path of [...facts.tree].sort()) {
|
|
63928
|
+
for (const { root, pattern } of matchers) {
|
|
63929
|
+
const match = pattern.exec(path);
|
|
63930
|
+
if (match === null)
|
|
63931
|
+
continue;
|
|
63932
|
+
const dir = path.slice(0, -"/function.json".length);
|
|
63933
|
+
const recipe = lambdaFunctionOf(await facts.read(path));
|
|
63934
|
+
if (recipe === null) {
|
|
63935
|
+
warnings.push(`${dir}: function.json is not a recipe`);
|
|
63936
|
+
continue;
|
|
63937
|
+
}
|
|
63938
|
+
if (recipe.upstream !== UPSTREAM)
|
|
63939
|
+
continue;
|
|
63940
|
+
if (recipe.name !== match[1]) {
|
|
63941
|
+
warnings.push(`${dir}: function.json names ${JSON.stringify(recipe.name)}, not the directory name`);
|
|
63942
|
+
continue;
|
|
63943
|
+
}
|
|
63944
|
+
found.push({ recipe, path: dir, root });
|
|
63945
|
+
}
|
|
63946
|
+
}
|
|
63947
|
+
return { found, warnings };
|
|
63948
|
+
}
|
|
63949
|
+
function lambdaFunctionProvider(_options = {}) {
|
|
63950
|
+
return {
|
|
63951
|
+
id: "lambda-function",
|
|
63952
|
+
async detect(facts) {
|
|
63953
|
+
return (await scanRecipes(facts)).found.length > 0 ? "certain" : "none";
|
|
63954
|
+
},
|
|
63955
|
+
async plan(facts, partial) {
|
|
63956
|
+
const claimed = new Set(partial.targets.map((target) => target.path));
|
|
63957
|
+
const scan = await scanRecipes(facts);
|
|
63958
|
+
const targets = [];
|
|
63959
|
+
const byOwner = new Map;
|
|
63960
|
+
for (const { recipe, path, root } of scan.found) {
|
|
63961
|
+
const name = `lambda-${recipe.name}`;
|
|
63962
|
+
if (claimed.has(path))
|
|
63963
|
+
continue;
|
|
63964
|
+
targets.push({ path, name, destination: "aliyun-fc", production: true, onTrain: true });
|
|
63965
|
+
if (root.owner === "")
|
|
63966
|
+
continue;
|
|
63967
|
+
byOwner.set(root.owner, [...byOwner.get(root.owner) ?? [], path]);
|
|
63968
|
+
}
|
|
63969
|
+
const refined = partial.targets.map((target) => {
|
|
63970
|
+
const paths = byOwner.get(target.path);
|
|
63971
|
+
return paths === undefined ? target : { ...target, dependsOn: [...new Set([...target.dependsOn ?? [], ...paths])] };
|
|
63972
|
+
});
|
|
63973
|
+
return {
|
|
63974
|
+
targets: [...refined, ...targets],
|
|
63975
|
+
...scan.warnings.length === 0 ? {} : { warnings: [...partial.warnings ?? [], ...scan.warnings] }
|
|
63976
|
+
};
|
|
63977
|
+
}
|
|
63978
|
+
};
|
|
63979
|
+
}
|
|
63980
|
+
var lambdaFunction = lambdaFunctionProvider();
|
|
63981
|
+
// ../../packages/praxis/deploy-core/src/package-manifest.ts
|
|
63982
|
+
function packageManifestOf(text) {
|
|
63983
|
+
const parsed = text === null ? null : parseJsonc2(text);
|
|
63984
|
+
if (parsed === null)
|
|
63985
|
+
return null;
|
|
63986
|
+
const name = parsed.name;
|
|
63987
|
+
const dependencies = new Set;
|
|
63988
|
+
const devOnly = new Set;
|
|
63989
|
+
for (const field of ["dependencies", "peerDependencies", "optionalDependencies", "devDependencies"]) {
|
|
63990
|
+
const block = parsed[field];
|
|
63991
|
+
if (block === null || typeof block !== "object" || Array.isArray(block))
|
|
63992
|
+
continue;
|
|
63993
|
+
for (const [dependency, version] of Object.entries(block)) {
|
|
63994
|
+
if (typeof version !== "string" || !version.startsWith("workspace:") || dependencies.has(dependency))
|
|
63995
|
+
continue;
|
|
63996
|
+
dependencies.add(dependency);
|
|
63997
|
+
if (field === "devDependencies")
|
|
63998
|
+
devOnly.add(dependency);
|
|
63999
|
+
}
|
|
64000
|
+
}
|
|
64001
|
+
return {
|
|
64002
|
+
...typeof name === "string" && name !== "" ? { name } : {},
|
|
64003
|
+
workspaceDependencies: [...dependencies].sort(),
|
|
64004
|
+
devOnlyWorkspaceDependencies: [...devOnly].sort()
|
|
64005
|
+
};
|
|
64006
|
+
}
|
|
64007
|
+
function lifecycleOf(text) {
|
|
64008
|
+
const parsed = text === null ? null : parseJsonc2(text);
|
|
64009
|
+
if (parsed === null)
|
|
64010
|
+
return null;
|
|
64011
|
+
const deepracticex = parsed.deepracticex;
|
|
64012
|
+
if (deepracticex === null || typeof deepracticex !== "object")
|
|
64013
|
+
return null;
|
|
64014
|
+
const lifecycle = deepracticex.lifecycle;
|
|
64015
|
+
return lifecycle !== null && typeof lifecycle === "object" ? lifecycle : null;
|
|
64016
|
+
}
|
|
64017
|
+
function isDeployable(lifecycle) {
|
|
64018
|
+
if (lifecycle?.deploy === false)
|
|
64019
|
+
return false;
|
|
64020
|
+
const environments = lifecycle?.deployEnvironments;
|
|
64021
|
+
return !(Array.isArray(environments) && environments.length === 0);
|
|
64022
|
+
}
|
|
64023
|
+
function environmentsOf(lifecycle) {
|
|
64024
|
+
const environments = lifecycle?.deployEnvironments;
|
|
64025
|
+
if (!Array.isArray(environments))
|
|
64026
|
+
return;
|
|
64027
|
+
const named = environments.filter((entry) => typeof entry === "string");
|
|
64028
|
+
return named.length === 0 ? undefined : named;
|
|
64029
|
+
}
|
|
63289
64030
|
// ../../packages/praxis/deploy-core/src/workspace.ts
|
|
63290
64031
|
function packageJsonIn(dir) {
|
|
63291
64032
|
return dir === "." ? "package.json" : `${dir}/package.json`;
|
|
@@ -63297,6 +64038,16 @@ function dirOfPackageJson(path) {
|
|
|
63297
64038
|
return;
|
|
63298
64039
|
return path.slice(0, -"/package.json".length);
|
|
63299
64040
|
}
|
|
64041
|
+
function packageDirOf(path, dirs) {
|
|
64042
|
+
let found = null;
|
|
64043
|
+
for (const dir of dirs) {
|
|
64044
|
+
if (path !== dir && !path.startsWith(`${dir}/`))
|
|
64045
|
+
continue;
|
|
64046
|
+
if (found === null || dir.length > found.length)
|
|
64047
|
+
found = dir;
|
|
64048
|
+
}
|
|
64049
|
+
return found;
|
|
64050
|
+
}
|
|
63300
64051
|
function dirOfManifest(path) {
|
|
63301
64052
|
for (const name of BUILD_MANIFESTS) {
|
|
63302
64053
|
if (path === name)
|
|
@@ -63525,7 +64276,11 @@ function workspaceCloudflareProvider(options = {}) {
|
|
|
63525
64276
|
};
|
|
63526
64277
|
}
|
|
63527
64278
|
var workspaceCloudflare = workspaceCloudflareProvider();
|
|
63528
|
-
var BUILTIN_PROVIDERS = [
|
|
64279
|
+
var BUILTIN_PROVIDERS = [
|
|
64280
|
+
workspaceCloudflare,
|
|
64281
|
+
workspaceNpmProvider(),
|
|
64282
|
+
lambdaFunctionProvider()
|
|
64283
|
+
];
|
|
63529
64284
|
function directoriesOfPackageNames(workspaces) {
|
|
63530
64285
|
const byName = new Map;
|
|
63531
64286
|
for (const workspace of workspaces)
|
|
@@ -63552,15 +64307,23 @@ function workspaceClosureOf(target, byName, dependenciesOf) {
|
|
|
63552
64307
|
// ../../packages/praxis/deploy-core/src/plan.ts
|
|
63553
64308
|
async function planRepository(facts, providers = BUILTIN_PROVIDERS, options = {}) {
|
|
63554
64309
|
let partial = { targets: [] };
|
|
64310
|
+
const warnings = [];
|
|
63555
64311
|
for (const provider of providers) {
|
|
63556
64312
|
const confidence = await provider.detect(facts);
|
|
63557
64313
|
if (confidence === "none")
|
|
63558
64314
|
continue;
|
|
63559
64315
|
partial = await provider.plan(facts, partial);
|
|
64316
|
+
for (const warning of partial.warnings ?? [])
|
|
64317
|
+
if (!warnings.includes(warning))
|
|
64318
|
+
warnings.push(warning);
|
|
63560
64319
|
}
|
|
63561
64320
|
const drafts = partial.targets.filter((draft) => draft.deploy !== false);
|
|
63562
64321
|
const workspaces = await readWorkspaces(facts, options);
|
|
63563
|
-
return {
|
|
64322
|
+
return {
|
|
64323
|
+
commit: facts.commit,
|
|
64324
|
+
targets: closePlan(drafts, workspaces),
|
|
64325
|
+
...warnings.length === 0 ? {} : { warnings }
|
|
64326
|
+
};
|
|
63564
64327
|
}
|
|
63565
64328
|
function closePlan(drafts, workspaces) {
|
|
63566
64329
|
const configOf = new Map(workspaces.map((workspace) => [workspace.dir, workspace.config]));
|
|
@@ -63582,7 +64345,7 @@ function closePlan(drafts, workspaces) {
|
|
|
63582
64345
|
path: draft.path,
|
|
63583
64346
|
name: draft.name,
|
|
63584
64347
|
destination: draft.destination,
|
|
63585
|
-
dependsOn: edges.get(draft.path) ?? [],
|
|
64348
|
+
dependsOn: [...new Set([...edges.get(draft.path) ?? [], ...draft.dependsOn ?? []])],
|
|
63586
64349
|
...draft.environments === undefined ? {} : { environments: draft.environments },
|
|
63587
64350
|
production: draft.production === true,
|
|
63588
64351
|
onTrain: draft.onTrain !== false,
|
|
@@ -63692,68 +64455,216 @@ function stronglyConnected(count3, edges) {
|
|
|
63692
64455
|
visit2(node2);
|
|
63693
64456
|
return components;
|
|
63694
64457
|
}
|
|
63695
|
-
// ../../packages/praxis/deploy-core/src/
|
|
63696
|
-
var
|
|
63697
|
-
var
|
|
63698
|
-
function
|
|
63699
|
-
|
|
63700
|
-
|
|
63701
|
-
|
|
63702
|
-
|
|
63703
|
-
|
|
63704
|
-
|
|
63705
|
-
|
|
63706
|
-
|
|
63707
|
-
return { jobState: "skipped", jobRunState: "unspecified" };
|
|
64458
|
+
// ../../packages/praxis/deploy-core/src/root-ownership.ts
|
|
64459
|
+
var ROOT_OWNERSHIP_FILE = "root-ownership.yaml";
|
|
64460
|
+
var ROOT_OWNERSHIP_DEFAULT = "widen";
|
|
64461
|
+
function rootPatternMatches(match, path) {
|
|
64462
|
+
const directory = match.endsWith("/");
|
|
64463
|
+
const pattern = match.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
64464
|
+
if (!directory)
|
|
64465
|
+
return matchesPattern(pattern, path);
|
|
64466
|
+
const segments = path.split("/");
|
|
64467
|
+
for (let take = 1;take <= segments.length; take += 1) {
|
|
64468
|
+
if (matchesPattern(pattern, segments.slice(0, take).join("/")))
|
|
64469
|
+
return true;
|
|
63708
64470
|
}
|
|
64471
|
+
return false;
|
|
63709
64472
|
}
|
|
63710
|
-
function
|
|
63711
|
-
|
|
63712
|
-
|
|
63713
|
-
|
|
63714
|
-
|
|
63715
|
-
|
|
63716
|
-
|
|
63717
|
-
|
|
63718
|
-
|
|
63719
|
-
if (!Number.isFinite(minutes) || minutes <= 0)
|
|
63720
|
-
throw new Error(`--expire-minutes must be a positive number, got ${JSON.stringify(expireMinutes)}`);
|
|
63721
|
-
return new Date(start + minutes * 60000).toISOString();
|
|
63722
|
-
}
|
|
63723
|
-
function decidePhaseState(states) {
|
|
63724
|
-
if (states.length === 0)
|
|
63725
|
-
return "unspecified";
|
|
63726
|
-
if (states.some((state) => state === "failed" || state === "aborted"))
|
|
63727
|
-
return "failed";
|
|
63728
|
-
if (states.some((state) => state === "in_progress" || state === "pending"))
|
|
63729
|
-
return "in_progress";
|
|
63730
|
-
const neverRan = states.every((state) => state === "skipped" || state === "disabled");
|
|
63731
|
-
return neverRan ? "skipped" : "succeeded";
|
|
63732
|
-
}
|
|
63733
|
-
function decideRolloutState(jobs, options = {}) {
|
|
63734
|
-
const states = [...jobs.values()];
|
|
63735
|
-
if (states.some((state) => state === "failed" || state === "aborted"))
|
|
63736
|
-
return "failed";
|
|
63737
|
-
const deploy = jobs.get("deploy");
|
|
63738
|
-
if (deploy === undefined || deploy === "pending" || deploy === "in_progress" || deploy === "disabled")
|
|
63739
|
-
return "pending";
|
|
63740
|
-
if (deploy === "skipped" && options.artifactIdentical !== true)
|
|
63741
|
-
return "pending";
|
|
63742
|
-
if (states.every((state) => state === "succeeded" || state === "skipped" || state === "disabled" || state === "ignored")) {
|
|
63743
|
-
return options.artifactIdentical === true ? "skipped" : "succeeded";
|
|
64473
|
+
function rootOwnershipMatchOf(path, table) {
|
|
64474
|
+
if (table === null)
|
|
64475
|
+
return { kind: "unknown" };
|
|
64476
|
+
for (const rule of table.rules) {
|
|
64477
|
+
if (!rootPatternMatches(rule.match, path))
|
|
64478
|
+
continue;
|
|
64479
|
+
if (rule.kind === "package")
|
|
64480
|
+
return { kind: "package", package: rule.package ?? "" };
|
|
64481
|
+
return { kind: rule.kind };
|
|
63744
64482
|
}
|
|
63745
|
-
return "
|
|
64483
|
+
return { kind: "unknown" };
|
|
63746
64484
|
}
|
|
63747
|
-
|
|
63748
|
-
|
|
63749
|
-
|
|
63750
|
-
|
|
63751
|
-
|
|
63752
|
-
|
|
63753
|
-
|
|
63754
|
-
|
|
63755
|
-
|
|
63756
|
-
|
|
64485
|
+
var KINDS = ["resolving", "package", "none"];
|
|
64486
|
+
function parseRootOwnership(text, options) {
|
|
64487
|
+
if (text === null) {
|
|
64488
|
+
return {
|
|
64489
|
+
kind: "invalid",
|
|
64490
|
+
problems: [
|
|
64491
|
+
{
|
|
64492
|
+
rule: -1,
|
|
64493
|
+
match: ROOT_OWNERSHIP_FILE,
|
|
64494
|
+
problem: `${ROOT_OWNERSHIP_FILE} is missing at this commit`
|
|
64495
|
+
}
|
|
64496
|
+
]
|
|
64497
|
+
};
|
|
64498
|
+
}
|
|
64499
|
+
let parsed;
|
|
64500
|
+
try {
|
|
64501
|
+
parsed = $parse(text);
|
|
64502
|
+
} catch (error) {
|
|
64503
|
+
return {
|
|
64504
|
+
kind: "invalid",
|
|
64505
|
+
problems: [
|
|
64506
|
+
{ rule: -1, match: ROOT_OWNERSHIP_FILE, problem: `not YAML: ${error.message}` }
|
|
64507
|
+
]
|
|
64508
|
+
};
|
|
64509
|
+
}
|
|
64510
|
+
const problems = [];
|
|
64511
|
+
const document2 = parsed ?? null;
|
|
64512
|
+
if (document2 === null || typeof document2 !== "object" || Array.isArray(document2)) {
|
|
64513
|
+
return {
|
|
64514
|
+
kind: "invalid",
|
|
64515
|
+
problems: [
|
|
64516
|
+
{ rule: -1, match: ROOT_OWNERSHIP_FILE, problem: "the document is not a mapping" }
|
|
64517
|
+
]
|
|
64518
|
+
};
|
|
64519
|
+
}
|
|
64520
|
+
if (document2.version !== 1) {
|
|
64521
|
+
problems.push({
|
|
64522
|
+
rule: -1,
|
|
64523
|
+
match: "version",
|
|
64524
|
+
problem: `version must be 1, found ${JSON.stringify(document2.version)}`
|
|
64525
|
+
});
|
|
64526
|
+
}
|
|
64527
|
+
if (document2.default !== ROOT_OWNERSHIP_DEFAULT) {
|
|
64528
|
+
problems.push({
|
|
64529
|
+
rule: -1,
|
|
64530
|
+
match: "default",
|
|
64531
|
+
problem: `default must be "${ROOT_OWNERSHIP_DEFAULT}" — a path no rule claims may never narrow the run`
|
|
64532
|
+
});
|
|
64533
|
+
}
|
|
64534
|
+
if (!Array.isArray(document2.rules)) {
|
|
64535
|
+
problems.push({ rule: -1, match: "rules", problem: "rules must be a list" });
|
|
64536
|
+
return { kind: "invalid", problems };
|
|
64537
|
+
}
|
|
64538
|
+
const workspace = new Set(options.workspaceDirs);
|
|
64539
|
+
const rules = [];
|
|
64540
|
+
document2.rules.forEach((entry, index) => {
|
|
64541
|
+
const rule = entry ?? null;
|
|
64542
|
+
if (rule === null || typeof rule !== "object" || Array.isArray(rule)) {
|
|
64543
|
+
problems.push({
|
|
64544
|
+
rule: index,
|
|
64545
|
+
match: "",
|
|
64546
|
+
problem: "a rule must be a mapping with match and kind"
|
|
64547
|
+
});
|
|
64548
|
+
return;
|
|
64549
|
+
}
|
|
64550
|
+
const match = typeof rule.match === "string" ? rule.match.trim() : "";
|
|
64551
|
+
const kind = typeof rule.kind === "string" ? rule.kind : "";
|
|
64552
|
+
if (match === "") {
|
|
64553
|
+
problems.push({ rule: index, match: "", problem: "match must be a non-empty string" });
|
|
64554
|
+
return;
|
|
64555
|
+
}
|
|
64556
|
+
if (!KINDS.includes(kind)) {
|
|
64557
|
+
problems.push({
|
|
64558
|
+
rule: index,
|
|
64559
|
+
match,
|
|
64560
|
+
problem: `kind must be one of ${KINDS.join(" / ")}, found ${JSON.stringify(rule.kind)}`
|
|
64561
|
+
});
|
|
64562
|
+
return;
|
|
64563
|
+
}
|
|
64564
|
+
const evidence = typeof rule.evidence === "string" ? rule.evidence.trim() : "";
|
|
64565
|
+
const why = typeof rule.why === "string" ? rule.why.trim() : "";
|
|
64566
|
+
if (kind === "package") {
|
|
64567
|
+
const owner = typeof rule.package === "string" ? rule.package.trim() : "";
|
|
64568
|
+
if (owner === "") {
|
|
64569
|
+
problems.push({
|
|
64570
|
+
rule: index,
|
|
64571
|
+
match,
|
|
64572
|
+
problem: "kind: package needs the workspace directory it belongs to"
|
|
64573
|
+
});
|
|
64574
|
+
return;
|
|
64575
|
+
}
|
|
64576
|
+
if (!workspace.has(owner)) {
|
|
64577
|
+
problems.push({
|
|
64578
|
+
rule: index,
|
|
64579
|
+
match,
|
|
64580
|
+
problem: `package "${owner}" is not a workspace package directory at this commit`
|
|
64581
|
+
});
|
|
64582
|
+
return;
|
|
64583
|
+
}
|
|
64584
|
+
if (evidence === "") {
|
|
64585
|
+
rules.push({ match, kind: "resolving", evidenceMissing: true, ...why === "" ? {} : { why } });
|
|
64586
|
+
return;
|
|
64587
|
+
}
|
|
64588
|
+
rules.push({ match, kind: "package", package: owner, evidence, ...why === "" ? {} : { why } });
|
|
64589
|
+
return;
|
|
64590
|
+
}
|
|
64591
|
+
if (rule.package !== undefined) {
|
|
64592
|
+
problems.push({
|
|
64593
|
+
rule: index,
|
|
64594
|
+
match,
|
|
64595
|
+
problem: `package is only allowed on kind: package (this rule is ${kind})`
|
|
64596
|
+
});
|
|
64597
|
+
return;
|
|
64598
|
+
}
|
|
64599
|
+
if (kind === "none" && evidence === "") {
|
|
64600
|
+
rules.push({ match, kind: "resolving", evidenceMissing: true, ...why === "" ? {} : { why } });
|
|
64601
|
+
return;
|
|
64602
|
+
}
|
|
64603
|
+
rules.push({
|
|
64604
|
+
match,
|
|
64605
|
+
kind,
|
|
64606
|
+
...evidence === "" ? {} : { evidence },
|
|
64607
|
+
...why === "" ? {} : { why }
|
|
64608
|
+
});
|
|
64609
|
+
});
|
|
64610
|
+
if (problems.length > 0)
|
|
64611
|
+
return { kind: "invalid", problems };
|
|
64612
|
+
const table = { version: 1, rules, default: ROOT_OWNERSHIP_DEFAULT };
|
|
64613
|
+
if (rootOwnershipMatchOf(ROOT_OWNERSHIP_FILE, table).kind !== "resolving") {
|
|
64614
|
+
return {
|
|
64615
|
+
kind: "invalid",
|
|
64616
|
+
problems: [
|
|
64617
|
+
{
|
|
64618
|
+
rule: -1,
|
|
64619
|
+
match: ROOT_OWNERSHIP_FILE,
|
|
64620
|
+
problem: `${ROOT_OWNERSHIP_FILE} must classify itself as resolving: a change to the table can change every package's inputs`
|
|
64621
|
+
}
|
|
64622
|
+
]
|
|
64623
|
+
};
|
|
64624
|
+
}
|
|
64625
|
+
return { kind: "table", table };
|
|
64626
|
+
}
|
|
64627
|
+
function namedPackagesOf(input) {
|
|
64628
|
+
const named = new Set;
|
|
64629
|
+
for (const path of input.changedPaths) {
|
|
64630
|
+
const dir = packageDirOf(path, input.workspaceDirs);
|
|
64631
|
+
if (dir !== null)
|
|
64632
|
+
named.add(dir);
|
|
64633
|
+
}
|
|
64634
|
+
const roots = rootOwnershipDecisionOf(input);
|
|
64635
|
+
for (const dir of roots.packages)
|
|
64636
|
+
if (input.workspaceDirs.includes(dir))
|
|
64637
|
+
named.add(dir);
|
|
64638
|
+
return { packages: roots.widened ? [] : [...named].sort(), roots };
|
|
64639
|
+
}
|
|
64640
|
+
function rootOwnershipDecisionOf(input) {
|
|
64641
|
+
const unclaimed = input.changedPaths.filter((path) => packageDirOf(path, input.workspaceDirs) === null);
|
|
64642
|
+
const named = new Set;
|
|
64643
|
+
const traces = [];
|
|
64644
|
+
let widened = false;
|
|
64645
|
+
for (const path of unclaimed) {
|
|
64646
|
+
if (input.table === null) {
|
|
64647
|
+
widened = true;
|
|
64648
|
+
traces.push({ path, reason: "table-unreadable" });
|
|
64649
|
+
continue;
|
|
64650
|
+
}
|
|
64651
|
+
const match = rootOwnershipMatchOf(path, input.table);
|
|
64652
|
+
if (match.kind === "package")
|
|
64653
|
+
named.add(match.package);
|
|
64654
|
+
else if (match.kind === "none")
|
|
64655
|
+
continue;
|
|
64656
|
+
else {
|
|
64657
|
+
widened = true;
|
|
64658
|
+
traces.push({ path, reason: match.kind });
|
|
64659
|
+
}
|
|
64660
|
+
}
|
|
64661
|
+
return {
|
|
64662
|
+
unclaimed,
|
|
64663
|
+
widened,
|
|
64664
|
+
traces,
|
|
64665
|
+
packages: widened ? [] : [...named].sort(),
|
|
64666
|
+
allNone: !widened && unclaimed.length > 0 && named.size === 0
|
|
64667
|
+
};
|
|
63757
64668
|
}
|
|
63758
64669
|
// ../../packages/praxis/deploy-core/src/job-events-file.ts
|
|
63759
64670
|
import { appendFileSync, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
@@ -63872,7 +64783,7 @@ function reportBlockedTarget(events, target, message) {
|
|
|
63872
64783
|
}
|
|
63873
64784
|
|
|
63874
64785
|
// src/commands/devops.ts
|
|
63875
|
-
var
|
|
64786
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
63876
64787
|
|
|
63877
64788
|
// src/commands/devops-deploy-plan.ts
|
|
63878
64789
|
import { resolve as resolve3 } from "node:path";
|
|
@@ -65257,7 +66168,7 @@ async function devopsDeployTofu(flags, ports) {
|
|
|
65257
66168
|
const projectYaml = await ports.readFile(join5(ports.cwd, "praxis.yaml"));
|
|
65258
66169
|
let parsedYaml;
|
|
65259
66170
|
try {
|
|
65260
|
-
parsedYaml = projectYaml === null ? undefined :
|
|
66171
|
+
parsedYaml = projectYaml === null ? undefined : import_yaml4.parse(projectYaml);
|
|
65261
66172
|
} catch (error) {
|
|
65262
66173
|
throw new UsageError(`praxis.yaml is not valid YAML: ${error.message}`);
|
|
65263
66174
|
}
|
|
@@ -65507,17 +66418,6 @@ function selectAffected(input) {
|
|
|
65507
66418
|
reasons[spelled.get(relative2)] = reason;
|
|
65508
66419
|
return { tests: selected.map(({ relative: relative2 }) => spelled.get(relative2)), features, reasons, openIssues: [...AFFECTED_OPEN_ISSUES] };
|
|
65509
66420
|
}
|
|
65510
|
-
function nearestPackage(path, packages) {
|
|
65511
|
-
let found = null;
|
|
65512
|
-
for (const candidate of packages) {
|
|
65513
|
-
const root = candidate.replace(/\/+$/, "");
|
|
65514
|
-
if (!root || !(path === root || path.startsWith(`${root}/`)))
|
|
65515
|
-
continue;
|
|
65516
|
-
if (found === null || root.length > found.length)
|
|
65517
|
-
found = root;
|
|
65518
|
-
}
|
|
65519
|
-
return found;
|
|
65520
|
-
}
|
|
65521
66421
|
var BUN_FILE_HEADER = /^(\S.*\.(?:test|spec)\.(?:ts|tsx|js|mjs)):$/;
|
|
65522
66422
|
var BUN_COUNT = /^\s*(\d+)\s+(pass|fail|skip|todo)\b/;
|
|
65523
66423
|
var BUN_RAN = /^Ran (\d+) tests? across/;
|
|
@@ -65578,6 +66478,30 @@ function bunTestRun(packagePath, code, output) {
|
|
|
65578
66478
|
}
|
|
65579
66479
|
|
|
65580
66480
|
// src/commands/devops-test.ts
|
|
66481
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
66482
|
+
var CACHE_OFF_REEXEC_ENV = "PRAXIS_DEVOPS_TEST_CACHE_OFF";
|
|
66483
|
+
function needsCacheOffReexec(env) {
|
|
66484
|
+
return env.BUN_RUNTIME_TRANSPILER_CACHE_PATH !== "0" && !env[CACHE_OFF_REEXEC_ENV];
|
|
66485
|
+
}
|
|
66486
|
+
function isDevopsTestRun(words) {
|
|
66487
|
+
return words.join(" ") === "devops test";
|
|
66488
|
+
}
|
|
66489
|
+
function spawnInherit(cmd, args, options) {
|
|
66490
|
+
return new Promise((resolveCode) => {
|
|
66491
|
+
const child = spawn4(cmd, [...args], { cwd: options.cwd, env: options.env, stdio: "inherit" });
|
|
66492
|
+
child.once("error", (error) => {
|
|
66493
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
66494
|
+
resolveCode(1);
|
|
66495
|
+
});
|
|
66496
|
+
child.once("close", (code) => resolveCode(code ?? 1));
|
|
66497
|
+
});
|
|
66498
|
+
}
|
|
66499
|
+
function reexecWithCacheOff(options = {}) {
|
|
66500
|
+
return (options.spawn ?? spawnInherit)(process.execPath, options.argv ?? process.argv.slice(1), {
|
|
66501
|
+
cwd: options.cwd ?? process.cwd(),
|
|
66502
|
+
env: { ...options.env ?? process.env, BUN_RUNTIME_TRANSPILER_CACHE_PATH: "0", [CACHE_OFF_REEXEC_ENV]: "1" }
|
|
66503
|
+
});
|
|
66504
|
+
}
|
|
65581
66505
|
async function devopsTest(flags, paths, ports) {
|
|
65582
66506
|
const plan = planTest(flags, paths);
|
|
65583
66507
|
if (plan.mode.kind === "affected")
|
|
@@ -65620,38 +66544,69 @@ async function changedSelection(since, ports) {
|
|
|
65620
66544
|
const roots = await ports.checkout.roots();
|
|
65621
66545
|
const grouped = new Map;
|
|
65622
66546
|
for (const file of files) {
|
|
65623
|
-
const owner =
|
|
66547
|
+
const owner = packageDirOf(file, roots);
|
|
65624
66548
|
if (owner === null)
|
|
65625
66549
|
continue;
|
|
65626
66550
|
grouped.set(owner, [...grouped.get(owner) ?? [], file]);
|
|
65627
66551
|
}
|
|
66552
|
+
const parsed = parseRootOwnership(await ports.checkout.read(ROOT_OWNERSHIP_FILE), { workspaceDirs: roots });
|
|
66553
|
+
const named = namedPackagesOf({ changedPaths: files, workspaceDirs: roots, table: parsed.kind === "table" ? parsed.table : null });
|
|
66554
|
+
const widen = named.roots.widened ? { paths: named.roots.traces.map((trace) => trace.path), reason: widenReason(named.roots.traces.map((trace) => trace.reason)) } : null;
|
|
66555
|
+
const failed = widen === null && files.length > 0 && named.packages.length === 0 && !named.roots.allNone ? { paths: [...named.roots.unclaimed].sort() } : null;
|
|
66556
|
+
const namedByTable = new Set(named.packages.filter((dir) => !grouped.has(dir)));
|
|
66557
|
+
const selectedRoots = widen !== null ? [...roots].sort((a, b) => a.localeCompare(b, "en")) : [...new Set([...grouped.keys(), ...namedByTable])].sort((a, b) => a.localeCompare(b, "en"));
|
|
65628
66558
|
const groups = [];
|
|
65629
|
-
for (const root of
|
|
66559
|
+
for (const root of selectedRoots) {
|
|
65630
66560
|
const packagePath = join6(ports.checkout.root, root);
|
|
65631
|
-
groups.push({
|
|
66561
|
+
groups.push({
|
|
66562
|
+
root,
|
|
66563
|
+
path: packagePath,
|
|
66564
|
+
whole: widen !== null || namedByTable.has(root),
|
|
66565
|
+
selection: selectAffected({ changed: grouped.get(root) ?? [], files: await ports.checkout.sources(packagePath), packageRoot: root })
|
|
66566
|
+
});
|
|
65632
66567
|
}
|
|
65633
66568
|
const owned = new Set([...grouped.values()].flat());
|
|
65634
|
-
return { base, files, groups, unowned: files.filter((file) => !owned.has(file)) };
|
|
66569
|
+
return { base, files, groups, unowned: files.filter((file) => !owned.has(file)), widen, failed };
|
|
66570
|
+
}
|
|
66571
|
+
function widenReason(reasons) {
|
|
66572
|
+
if (reasons.includes("table-unreadable"))
|
|
66573
|
+
return `${ROOT_OWNERSHIP_FILE} 读不出来(缺失或不合法),按整仓跑`;
|
|
66574
|
+
if (reasons.includes("unknown"))
|
|
66575
|
+
return "有仓库根路径没被表判定,按整仓跑";
|
|
66576
|
+
return "改到了仓库根的解析类文件(整仓都可能受影响)";
|
|
65635
66577
|
}
|
|
65636
66578
|
async function runAffected(list, since, ports) {
|
|
65637
|
-
const { base, files, groups, unowned } = await changedSelection(since, ports);
|
|
66579
|
+
const { base, files, groups, unowned, widen, failed } = await changedSelection(since, ports);
|
|
65638
66580
|
const view = {
|
|
65639
66581
|
since: base,
|
|
65640
66582
|
packages: groups.map((group) => ({
|
|
65641
66583
|
path: group.root,
|
|
65642
66584
|
tests: group.selection.tests.map((file) => ({ file, reason: group.selection.reasons[file] })),
|
|
65643
|
-
features: group.selection.features
|
|
66585
|
+
features: group.selection.features,
|
|
66586
|
+
...group.whole ? { whole: true } : {}
|
|
65644
66587
|
})),
|
|
65645
66588
|
tests: groups.flatMap((group) => group.selection.tests),
|
|
65646
66589
|
features: groups.flatMap((group) => group.selection.features),
|
|
65647
66590
|
unowned,
|
|
66591
|
+
widen,
|
|
66592
|
+
failed,
|
|
65648
66593
|
openIssues: [...selectAffected({ changed: [], files: new Map, packageRoot: "" }).openIssues]
|
|
65649
66594
|
};
|
|
65650
|
-
const lines = [
|
|
65651
|
-
...
|
|
65652
|
-
...
|
|
65653
|
-
|
|
65654
|
-
|
|
66595
|
+
const lines = [
|
|
66596
|
+
...widen === null ? [] : [`${widen.reason}:${widen.paths.join("、")} → 每个包整套测试`],
|
|
66597
|
+
...view.packages.flatMap((entry) => [
|
|
66598
|
+
...entry.tests.map(({ file, reason }) => `${file} (${reason})`),
|
|
66599
|
+
...entry.features.map((feature) => `${feature.file} (feature: ${feature.title})`)
|
|
66600
|
+
]),
|
|
66601
|
+
...view.openIssues.map((issue) => `note: ${issue}`)
|
|
66602
|
+
];
|
|
66603
|
+
if (failed !== null) {
|
|
66604
|
+
ports.emit({ kind: "object", data: view });
|
|
66605
|
+
ports.human([`选包塌成 0 个包:这些仓库根路径没有对应的包,也不在 ${ROOT_OWNERSHIP_FILE} 里被判成 none——先补表,别让它静默少跑:`, ...failed.paths].join(`
|
|
66606
|
+
`));
|
|
66607
|
+
return 1;
|
|
66608
|
+
}
|
|
66609
|
+
if (list || !groups.some((group) => group.whole) && view.tests.length === 0 && view.features.length === 0) {
|
|
65655
66610
|
ports.emit({ kind: "object", data: view });
|
|
65656
66611
|
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(`
|
|
65657
66612
|
`));
|
|
@@ -65659,9 +66614,9 @@ async function runAffected(list, since, ports) {
|
|
|
65659
66614
|
}
|
|
65660
66615
|
const runs = [];
|
|
65661
66616
|
for (const group of groups) {
|
|
65662
|
-
const
|
|
65663
|
-
if (
|
|
65664
|
-
const result = await ports.checkout.runTests(group.path,
|
|
66617
|
+
const selected = group.whole ? [] : group.selection.tests.map((file) => stripRoot(file, group.root));
|
|
66618
|
+
if (group.whole || selected.length) {
|
|
66619
|
+
const result = await ports.checkout.runTests(group.path, selected);
|
|
65665
66620
|
runs.push(bunTestRun(group.root, result.code, result.output));
|
|
65666
66621
|
}
|
|
65667
66622
|
for (const feature of group.selection.features)
|
|
@@ -65848,8 +66803,8 @@ async function localEngine(cwd) {
|
|
|
65848
66803
|
})
|
|
65849
66804
|
};
|
|
65850
66805
|
}
|
|
65851
|
-
async function localCheckout(cwd,
|
|
65852
|
-
const git2 = (args) =>
|
|
66806
|
+
async function localCheckout(cwd, spawn5) {
|
|
66807
|
+
const git2 = (args) => spawn5("git", [...args], { cwd });
|
|
65853
66808
|
const required = async (args) => {
|
|
65854
66809
|
const result = await git2(args);
|
|
65855
66810
|
if (result.code !== 0)
|
|
@@ -65900,7 +66855,16 @@ async function localCheckout(cwd, spawn4) {
|
|
|
65900
66855
|
await walk(packagePath);
|
|
65901
66856
|
return files;
|
|
65902
66857
|
},
|
|
65903
|
-
runTests: (packagePath, files) =>
|
|
66858
|
+
runTests: (packagePath, files) => spawn5("nice", ["-n", "10", "bun", "test", ...files], { cwd: packagePath }),
|
|
66859
|
+
read: async (path) => {
|
|
66860
|
+
try {
|
|
66861
|
+
return await readFile4(join6(root, path), "utf8");
|
|
66862
|
+
} catch (error) {
|
|
66863
|
+
if (error.code === "ENOENT")
|
|
66864
|
+
return null;
|
|
66865
|
+
throw error;
|
|
66866
|
+
}
|
|
66867
|
+
}
|
|
65904
66868
|
};
|
|
65905
66869
|
}
|
|
65906
66870
|
async function withEngineStdoutOnStderr(body) {
|
|
@@ -68858,6 +69822,7 @@ var FILE_ID = /^file-/;
|
|
|
68858
69822
|
var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
68859
69823
|
var isImage = (node2) => node2.type === "image" && typeof node2.url === "string";
|
|
68860
69824
|
var isRef = (node2) => node2.type === "ref" && typeof node2.ref === "string";
|
|
69825
|
+
var NODE_TYPES = new Set(Object.keys(KNOWN_PROPS));
|
|
68861
69826
|
function visit2(value, nodeId, fn) {
|
|
68862
69827
|
if (Array.isArray(value)) {
|
|
68863
69828
|
for (const item of value)
|
|
@@ -69051,6 +70016,8 @@ var warningLine = (warning) => {
|
|
|
69051
70016
|
return `${warning.code}: ${warning.ref} at ${warning.nodeId}`;
|
|
69052
70017
|
case "FRAME_NOT_FOUND":
|
|
69053
70018
|
return `${warning.code}: ${warning.id}`;
|
|
70019
|
+
case "IMAGE_FILE_NOT_FOUND":
|
|
70020
|
+
return `${warning.code}: ${warning.url} (the platform holds no such file) at ${warning.nodeId}`;
|
|
69054
70021
|
default:
|
|
69055
70022
|
return `${warning.code}: ${warning.url}`;
|
|
69056
70023
|
}
|
|
@@ -69158,6 +70125,537 @@ async function canvasImport(args, ports) {
|
|
|
69158
70125
|
return 0;
|
|
69159
70126
|
}
|
|
69160
70127
|
|
|
70128
|
+
// src/commands/events-wait.ts
|
|
70129
|
+
var DEFAULT_AGENT = "R1M9TQ2X";
|
|
70130
|
+
var BASE_BACKOFF_MS = 1000;
|
|
70131
|
+
var MAX_BACKOFF_MS = 60000;
|
|
70132
|
+
var NOTICE_NAMED = 5;
|
|
70133
|
+
var ANNOUNCED_KEEP = 500;
|
|
70134
|
+
function assumeAgentOf(env) {
|
|
70135
|
+
return env.PRAXIS_ASSUME_AGENT?.trim() || DEFAULT_AGENT;
|
|
70136
|
+
}
|
|
70137
|
+
function sessionOf(raw) {
|
|
70138
|
+
if (raw === undefined)
|
|
70139
|
+
return null;
|
|
70140
|
+
const session = raw.trim();
|
|
70141
|
+
if (!/^[A-Za-z0-9_-]{1,128}$/.test(session))
|
|
70142
|
+
throw new Error("--session takes the Claude Code session id (letters, digits, - and _)");
|
|
70143
|
+
return session;
|
|
70144
|
+
}
|
|
70145
|
+
var keyPart = (part) => part.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
70146
|
+
function waitKeyOf(env, agent, session) {
|
|
70147
|
+
return [env, agent, ...session === null ? [] : [session]].map(keyPart).join("-");
|
|
70148
|
+
}
|
|
70149
|
+
function pidOf(raw) {
|
|
70150
|
+
const pid = raw === null ? NaN : Number(raw.trim());
|
|
70151
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
70152
|
+
}
|
|
70153
|
+
function lockDecision(recorded, self, probe) {
|
|
70154
|
+
if (recorded === null || recorded === self || probe === null || !probe.alive)
|
|
70155
|
+
return { kind: "take" };
|
|
70156
|
+
if (!/events\s+wait/.test(probe.command))
|
|
70157
|
+
return { kind: "take" };
|
|
70158
|
+
if (probe.ppid === 1)
|
|
70159
|
+
return { kind: "replace", pid: recorded };
|
|
70160
|
+
return { kind: "refuse", pid: recorded };
|
|
70161
|
+
}
|
|
70162
|
+
function alreadyWaitingNotice(pid) {
|
|
70163
|
+
return `本会话已有 praxis agent events wait 在后台等待(pid ${pid}),不用再启动。`;
|
|
70164
|
+
}
|
|
70165
|
+
async function acquireWaitLock(ports) {
|
|
70166
|
+
for (let attempt = 0;attempt < 3; attempt++) {
|
|
70167
|
+
const recorded = pidOf(await ports.readPid());
|
|
70168
|
+
if (recorded === null) {
|
|
70169
|
+
if (await ports.createPid(String(ports.self)))
|
|
70170
|
+
return null;
|
|
70171
|
+
continue;
|
|
70172
|
+
}
|
|
70173
|
+
const decision = lockDecision(recorded, ports.self, await ports.probe(recorded));
|
|
70174
|
+
if (decision.kind === "refuse")
|
|
70175
|
+
return decision.pid;
|
|
70176
|
+
if (decision.kind === "replace")
|
|
70177
|
+
ports.terminate(decision.pid);
|
|
70178
|
+
await ports.replacePid(String(ports.self));
|
|
70179
|
+
const holder = pidOf(await ports.readPid());
|
|
70180
|
+
return holder === ports.self || holder === null ? null : holder;
|
|
70181
|
+
}
|
|
70182
|
+
return pidOf(await ports.readPid());
|
|
70183
|
+
}
|
|
70184
|
+
function timeoutMsOf(raw) {
|
|
70185
|
+
if (raw === undefined)
|
|
70186
|
+
return null;
|
|
70187
|
+
const seconds = Number(raw);
|
|
70188
|
+
if (!/^\d+(\.\d+)?$/.test(raw.trim()) || !Number.isFinite(seconds) || seconds <= 0)
|
|
70189
|
+
throw new Error("--timeout takes a positive number of seconds");
|
|
70190
|
+
return Math.round(seconds * 1000);
|
|
70191
|
+
}
|
|
70192
|
+
function backoffMs(failures) {
|
|
70193
|
+
if (failures <= 0)
|
|
70194
|
+
return 0;
|
|
70195
|
+
return Math.min(MAX_BACKOFF_MS, BASE_BACKOFF_MS * 2 ** Math.min(failures - 1, 16));
|
|
70196
|
+
}
|
|
70197
|
+
function inboxLettersUrl(apiUrl, agent) {
|
|
70198
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/inbox/letters?unread=true&limit=20`;
|
|
70199
|
+
}
|
|
70200
|
+
function eventsStreamUrl(apiUrl, agent) {
|
|
70201
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/events/stream`;
|
|
70202
|
+
}
|
|
70203
|
+
function streamHeaders(auth, lastEventId) {
|
|
70204
|
+
return { ...auth, Accept: "text/event-stream", ...lastEventId === null ? {} : { "Last-Event-ID": lastEventId } };
|
|
70205
|
+
}
|
|
70206
|
+
function lettersOf(body) {
|
|
70207
|
+
const value = body;
|
|
70208
|
+
if (!value || typeof value.unread !== "number" || !Array.isArray(value.letters))
|
|
70209
|
+
throw new Error("letters answer is not { unread, letters }");
|
|
70210
|
+
const letters = value.letters.filter((letter) => typeof letter === "object" && letter !== null && typeof letter.id === "string" && typeof letter.summary === "string");
|
|
70211
|
+
return { unread: value.unread, letters };
|
|
70212
|
+
}
|
|
70213
|
+
function feedSse(buffer, chunk) {
|
|
70214
|
+
const text2 = (buffer + chunk).replace(/\r\n?/g, `
|
|
70215
|
+
`);
|
|
70216
|
+
const blocks = text2.split(`
|
|
70217
|
+
|
|
70218
|
+
`);
|
|
70219
|
+
const rest = blocks.pop() ?? "";
|
|
70220
|
+
const frames = [];
|
|
70221
|
+
for (const block of blocks) {
|
|
70222
|
+
let event, id;
|
|
70223
|
+
const data = [];
|
|
70224
|
+
for (const line of block.split(`
|
|
70225
|
+
`)) {
|
|
70226
|
+
if (line === "" || line.startsWith(":"))
|
|
70227
|
+
continue;
|
|
70228
|
+
const colon = line.indexOf(":");
|
|
70229
|
+
const field = colon < 0 ? line : line.slice(0, colon);
|
|
70230
|
+
const value = colon < 0 ? "" : line.slice(colon + 1).replace(/^ /, "");
|
|
70231
|
+
if (field === "data")
|
|
70232
|
+
data.push(value);
|
|
70233
|
+
else if (field === "event")
|
|
70234
|
+
event = value;
|
|
70235
|
+
else if (field === "id")
|
|
70236
|
+
id = value;
|
|
70237
|
+
}
|
|
70238
|
+
if (data.length)
|
|
70239
|
+
frames.push({ ...event === undefined ? {} : { event }, ...id === undefined ? {} : { id }, data: data.join(`
|
|
70240
|
+
`) });
|
|
70241
|
+
}
|
|
70242
|
+
return { buffer: rest, frames };
|
|
70243
|
+
}
|
|
70244
|
+
var text2 = (value) => typeof value === "string" && value !== "";
|
|
70245
|
+
function wakeOf(frame) {
|
|
70246
|
+
let event;
|
|
70247
|
+
try {
|
|
70248
|
+
event = JSON.parse(frame.data);
|
|
70249
|
+
} catch {
|
|
70250
|
+
return null;
|
|
70251
|
+
}
|
|
70252
|
+
if (typeof event !== "object" || event === null)
|
|
70253
|
+
return null;
|
|
70254
|
+
if (event.type === "inbox.letter_delivered" && text2(event.letter_id) && typeof event.summary === "string")
|
|
70255
|
+
return { kind: "letter", letter: {
|
|
70256
|
+
id: event.letter_id,
|
|
70257
|
+
sender: typeof event.sender === "string" ? event.sender : "",
|
|
70258
|
+
...text2(event.sender_name) ? { sender_name: event.sender_name } : {},
|
|
70259
|
+
summary: event.summary,
|
|
70260
|
+
thread: typeof event.thread === "string" ? event.thread : null,
|
|
70261
|
+
create_time: typeof event.create_time === "string" ? event.create_time : ""
|
|
70262
|
+
} };
|
|
70263
|
+
if (event.type === "cognition.ritual_held" && text2(event.title))
|
|
70264
|
+
return { kind: "ritual", ritual: {
|
|
70265
|
+
ritual: text2(event.ritual) ? event.ritual : "",
|
|
70266
|
+
owner: text2(event.owner) ? event.owner : "",
|
|
70267
|
+
title: event.title,
|
|
70268
|
+
engram: text2(event.engram) ? event.engram : ""
|
|
70269
|
+
} };
|
|
70270
|
+
return null;
|
|
70271
|
+
}
|
|
70272
|
+
function ritualNotice(ritual) {
|
|
70273
|
+
const origin = [ritual.owner, ritual.ritual].filter(Boolean).join(" 的仪式 ");
|
|
70274
|
+
return `你获得了一段新记忆:「${ritual.title}」${origin ? `(${origin}${ritual.engram ? `,${ritual.engram}` : ""})` : ""}。处理完再在后台运行 praxis agent events wait。`;
|
|
70275
|
+
}
|
|
70276
|
+
function retryableStatus(status) {
|
|
70277
|
+
return status >= 500 || status === 408 || status === 429;
|
|
70278
|
+
}
|
|
70279
|
+
function planNotice(page, announced) {
|
|
70280
|
+
const seen = new Set(announced);
|
|
70281
|
+
const fresh = page.letters.filter((letter) => !seen.has(letter.id));
|
|
70282
|
+
if (!fresh.length)
|
|
70283
|
+
return { announced };
|
|
70284
|
+
const named = fresh.slice(0, NOTICE_NAMED).map((letter) => `${letter.sender_name || letter.sender}:${letter.summary}(${letter.id})`);
|
|
70285
|
+
const more = fresh.length > NOTICE_NAMED ? `;另有 ${fresh.length - NOTICE_NAMED} 封` : "";
|
|
70286
|
+
const notice = `你有 ${fresh.length} 封新信:${named.join(";")}${more}。用 praxis_assume_inbox(action "read")读取并处理,处理完再在后台运行 praxis agent events wait。`;
|
|
70287
|
+
const next = [...announced, ...fresh.map((letter) => letter.id)];
|
|
70288
|
+
return { notice, announced: next.length > ANNOUNCED_KEEP ? next.slice(next.length - ANNOUNCED_KEEP) : next };
|
|
70289
|
+
}
|
|
70290
|
+
function waitStateOf(raw) {
|
|
70291
|
+
if (raw === null)
|
|
70292
|
+
return { announced: [], lastEventId: null };
|
|
70293
|
+
try {
|
|
70294
|
+
const value = JSON.parse(raw);
|
|
70295
|
+
return {
|
|
70296
|
+
announced: Array.isArray(value.announced) ? value.announced.filter((id) => typeof id === "string") : [],
|
|
70297
|
+
lastEventId: typeof value.last_event_id === "string" && /^\d+$/.test(value.last_event_id) ? value.last_event_id : null
|
|
70298
|
+
};
|
|
70299
|
+
} catch {
|
|
70300
|
+
return { announced: [], lastEventId: null };
|
|
70301
|
+
}
|
|
70302
|
+
}
|
|
70303
|
+
function waitStateText(state) {
|
|
70304
|
+
return JSON.stringify({ announced: state.announced, ...state.lastEventId === null ? {} : { last_event_id: state.lastEventId } });
|
|
70305
|
+
}
|
|
70306
|
+
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
70307
|
+
async function runEventsWait(ports) {
|
|
70308
|
+
const stop = new AbortController;
|
|
70309
|
+
let timedOut = false;
|
|
70310
|
+
const timer = ports.timeoutMs === null ? undefined : setTimeout(() => {
|
|
70311
|
+
timedOut = true;
|
|
70312
|
+
stop.abort();
|
|
70313
|
+
}, ports.timeoutMs);
|
|
70314
|
+
const state = await ports.readState();
|
|
70315
|
+
let announced = state.announced;
|
|
70316
|
+
let lastEventId = state.lastEventId;
|
|
70317
|
+
const announceLetters = async (page) => {
|
|
70318
|
+
const planned = planNotice(page, announced);
|
|
70319
|
+
if (!planned.notice)
|
|
70320
|
+
return false;
|
|
70321
|
+
announced = planned.announced;
|
|
70322
|
+
await ports.writeState({ announced, lastEventId });
|
|
70323
|
+
ports.print(planned.notice);
|
|
70324
|
+
return true;
|
|
70325
|
+
};
|
|
70326
|
+
const announce = async () => announceLetters(await ports.fetchLetters());
|
|
70327
|
+
try {
|
|
70328
|
+
try {
|
|
70329
|
+
if (await announce())
|
|
70330
|
+
return 0;
|
|
70331
|
+
} catch (error) {
|
|
70332
|
+
ports.log(`praxis agent events wait: reading letters failed: ${message(error)}`);
|
|
70333
|
+
}
|
|
70334
|
+
ports.log(`praxis agent events wait: waiting for letters to assume agent ${ports.agent}`);
|
|
70335
|
+
let failures = 0;
|
|
70336
|
+
while (!stop.signal.aborted) {
|
|
70337
|
+
if (failures)
|
|
70338
|
+
await ports.sleep(backoffMs(failures), stop.signal);
|
|
70339
|
+
if (stop.signal.aborted)
|
|
70340
|
+
break;
|
|
70341
|
+
try {
|
|
70342
|
+
const opened = await ports.openStream(stop.signal, lastEventId);
|
|
70343
|
+
if (opened.status < 200 || opened.status >= 300 || !opened.chunks) {
|
|
70344
|
+
if (!retryableStatus(opened.status)) {
|
|
70345
|
+
ports.log(`praxis agent events wait: the event stream was refused (HTTP ${opened.status}${opened.reason ? `: ${opened.reason}` : ""})`);
|
|
70346
|
+
return 1;
|
|
70347
|
+
}
|
|
70348
|
+
throw new Error(`HTTP ${opened.status}`);
|
|
70349
|
+
}
|
|
70350
|
+
if (await announce())
|
|
70351
|
+
return 0;
|
|
70352
|
+
if (failures)
|
|
70353
|
+
ports.log("praxis agent events wait: event stream reconnected");
|
|
70354
|
+
failures = 0;
|
|
70355
|
+
let buffer = "";
|
|
70356
|
+
for await (const chunk of opened.chunks) {
|
|
70357
|
+
const fed = feedSse(buffer, chunk);
|
|
70358
|
+
buffer = fed.buffer;
|
|
70359
|
+
for (const frame of fed.frames) {
|
|
70360
|
+
const wake = wakeOf(frame);
|
|
70361
|
+
if (wake !== null && frame.id !== undefined)
|
|
70362
|
+
lastEventId = frame.id;
|
|
70363
|
+
if (wake?.kind === "letter" && await announceLetters({ unread: 1, letters: [wake.letter] }))
|
|
70364
|
+
return 0;
|
|
70365
|
+
if (wake?.kind === "ritual") {
|
|
70366
|
+
await ports.writeState({ announced, lastEventId });
|
|
70367
|
+
ports.print(ritualNotice(wake.ritual));
|
|
70368
|
+
return 0;
|
|
70369
|
+
}
|
|
70370
|
+
}
|
|
70371
|
+
}
|
|
70372
|
+
throw new Error("the event stream ended");
|
|
70373
|
+
} catch (error) {
|
|
70374
|
+
if (stop.signal.aborted)
|
|
70375
|
+
break;
|
|
70376
|
+
failures += 1;
|
|
70377
|
+
ports.log(`praxis agent events wait: ${message(error)} (${failures} in a row, reconnecting in ${backoffMs(failures) / 1000}s)`);
|
|
70378
|
+
}
|
|
70379
|
+
}
|
|
70380
|
+
if (timedOut)
|
|
70381
|
+
ports.print(`${(ports.timeoutMs ?? 0) / 1000} 秒内没有新信。需要继续等待时再在后台运行 praxis agent events wait。`);
|
|
70382
|
+
return 0;
|
|
70383
|
+
} finally {
|
|
70384
|
+
if (timer)
|
|
70385
|
+
clearTimeout(timer);
|
|
70386
|
+
stop.abort();
|
|
70387
|
+
}
|
|
70388
|
+
}
|
|
70389
|
+
|
|
70390
|
+
// src/commands/events-channel.ts
|
|
70391
|
+
var CHANNEL_SOURCE = "assume-agent";
|
|
70392
|
+
var SERVER_NAME = "assume-channel";
|
|
70393
|
+
var DEFAULT_PROTOCOL_VERSION = "2025-06-18";
|
|
70394
|
+
var BACKLOG_NAMED = 5;
|
|
70395
|
+
function channelInstructions(agent) {
|
|
70396
|
+
return [
|
|
70397
|
+
`Events from your Praxis assume agent ${agent} arrive as <channel source="${CHANNEL_SOURCE}" kind="letter" letter_id="…" sender="…">.`,
|
|
70398
|
+
'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.',
|
|
70399
|
+
'kind="ritual": the agent was given a new memory (a ritual was held); its knowledge is refreshed, nothing to reply to.',
|
|
70400
|
+
"The channel is one-way: answer through the praxis_assume_* tools, not back through the channel."
|
|
70401
|
+
].join(`
|
|
70402
|
+
`);
|
|
70403
|
+
}
|
|
70404
|
+
function initializeResult(params, agent) {
|
|
70405
|
+
const asked = params?.protocolVersion;
|
|
70406
|
+
return {
|
|
70407
|
+
protocolVersion: typeof asked === "string" ? asked : DEFAULT_PROTOCOL_VERSION,
|
|
70408
|
+
capabilities: { experimental: { "claude/channel": {} } },
|
|
70409
|
+
serverInfo: { name: SERVER_NAME, version: "0.1.0" },
|
|
70410
|
+
instructions: channelInstructions(agent)
|
|
70411
|
+
};
|
|
70412
|
+
}
|
|
70413
|
+
function replyTo(message2, agent) {
|
|
70414
|
+
if (message2.id === undefined || message2.id === null || typeof message2.method !== "string")
|
|
70415
|
+
return null;
|
|
70416
|
+
const reply = (body) => ({ jsonrpc: "2.0", id: message2.id, ...body });
|
|
70417
|
+
switch (message2.method) {
|
|
70418
|
+
case "initialize":
|
|
70419
|
+
return reply({ result: initializeResult(message2.params, agent) });
|
|
70420
|
+
case "ping":
|
|
70421
|
+
return reply({ result: {} });
|
|
70422
|
+
default:
|
|
70423
|
+
return reply({ error: { code: -32601, message: `Method not found: ${message2.method}` } });
|
|
70424
|
+
}
|
|
70425
|
+
}
|
|
70426
|
+
var sender = (letter) => letter.sender_name || letter.sender;
|
|
70427
|
+
var readHint = 'Read it with praxis_assume_inbox (action "read").';
|
|
70428
|
+
var frame = (content, meta) => ({ jsonrpc: "2.0", method: "notifications/claude/channel", params: { content, meta } });
|
|
70429
|
+
function letterNotification(letter) {
|
|
70430
|
+
return frame(`${sender(letter)}: ${letter.summary}
|
|
70431
|
+
${readHint}`, { kind: "letter", letter_id: letter.id, sender: letter.sender, ...letter.sender_name ? { sender_name: letter.sender_name } : {} });
|
|
70432
|
+
}
|
|
70433
|
+
function backlogNotification(letters) {
|
|
70434
|
+
const named = letters.slice(0, BACKLOG_NAMED).map((letter) => `${sender(letter)}: ${letter.summary} (${letter.id})`);
|
|
70435
|
+
const more = letters.length > BACKLOG_NAMED ? `; ${letters.length - BACKLOG_NAMED} more` : "";
|
|
70436
|
+
return frame(`${letters.length} unread letter(s) waiting: ${named.join("; ")}${more}
|
|
70437
|
+
${readHint}`, { kind: "letter", letter_id: letters[0].id, sender: letters[0].sender, count: String(letters.length) });
|
|
70438
|
+
}
|
|
70439
|
+
function ritualNotification(ritual) {
|
|
70440
|
+
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 } : {} });
|
|
70441
|
+
}
|
|
70442
|
+
async function runChannel(ports) {
|
|
70443
|
+
const stop = new AbortController;
|
|
70444
|
+
const seen = new Set;
|
|
70445
|
+
let lastEventId = null;
|
|
70446
|
+
let follower = null;
|
|
70447
|
+
const fresh = (letters) => letters.filter((letter) => !seen.has(letter.id) && (seen.add(letter.id), true));
|
|
70448
|
+
const catchUp = async () => {
|
|
70449
|
+
const letters = fresh((await ports.fetchLetters()).letters);
|
|
70450
|
+
if (letters.length)
|
|
70451
|
+
ports.send(backlogNotification(letters));
|
|
70452
|
+
};
|
|
70453
|
+
const follow = async () => {
|
|
70454
|
+
let failures = 0;
|
|
70455
|
+
while (!stop.signal.aborted) {
|
|
70456
|
+
if (failures)
|
|
70457
|
+
await ports.sleep(backoffMs(failures), stop.signal);
|
|
70458
|
+
if (stop.signal.aborted)
|
|
70459
|
+
break;
|
|
70460
|
+
try {
|
|
70461
|
+
const opened = await ports.openStream(stop.signal, lastEventId);
|
|
70462
|
+
if (opened.status < 200 || opened.status >= 300 || !opened.chunks) {
|
|
70463
|
+
if (!retryableStatus(opened.status)) {
|
|
70464
|
+
ports.log(`assume-channel: the event stream was refused (HTTP ${opened.status}${opened.reason ? `: ${opened.reason}` : ""})`);
|
|
70465
|
+
return;
|
|
70466
|
+
}
|
|
70467
|
+
throw new Error(`HTTP ${opened.status}`);
|
|
70468
|
+
}
|
|
70469
|
+
try {
|
|
70470
|
+
await catchUp();
|
|
70471
|
+
} catch (error) {
|
|
70472
|
+
ports.log(`assume-channel: reading letters failed: ${error instanceof Error ? error.message : error}`);
|
|
70473
|
+
}
|
|
70474
|
+
if (failures)
|
|
70475
|
+
ports.log("assume-channel: event stream reconnected");
|
|
70476
|
+
failures = 0;
|
|
70477
|
+
let buffer2 = "";
|
|
70478
|
+
for await (const chunk of opened.chunks) {
|
|
70479
|
+
const fed = feedSse(buffer2, chunk);
|
|
70480
|
+
buffer2 = fed.buffer;
|
|
70481
|
+
for (const raw of fed.frames) {
|
|
70482
|
+
const wake = wakeOf(raw);
|
|
70483
|
+
if (wake === null)
|
|
70484
|
+
continue;
|
|
70485
|
+
if (raw.id !== undefined)
|
|
70486
|
+
lastEventId = raw.id;
|
|
70487
|
+
if (wake.kind === "letter") {
|
|
70488
|
+
if (fresh([wake.letter]).length)
|
|
70489
|
+
ports.send(letterNotification(wake.letter));
|
|
70490
|
+
} else
|
|
70491
|
+
ports.send(ritualNotification(wake.ritual));
|
|
70492
|
+
}
|
|
70493
|
+
}
|
|
70494
|
+
throw new Error("the event stream ended");
|
|
70495
|
+
} catch (error) {
|
|
70496
|
+
if (stop.signal.aborted)
|
|
70497
|
+
break;
|
|
70498
|
+
failures += 1;
|
|
70499
|
+
ports.log(`assume-channel: ${error instanceof Error ? error.message : error} (${failures} in a row, reconnecting in ${backoffMs(failures) / 1000}s)`);
|
|
70500
|
+
}
|
|
70501
|
+
}
|
|
70502
|
+
};
|
|
70503
|
+
let buffer = "";
|
|
70504
|
+
const handle = (line) => {
|
|
70505
|
+
if (!line.trim())
|
|
70506
|
+
return;
|
|
70507
|
+
let message2;
|
|
70508
|
+
try {
|
|
70509
|
+
message2 = JSON.parse(line);
|
|
70510
|
+
} catch {
|
|
70511
|
+
ports.log("assume-channel: ignored a line that is not JSON");
|
|
70512
|
+
return;
|
|
70513
|
+
}
|
|
70514
|
+
const reply = replyTo(message2, ports.agent);
|
|
70515
|
+
if (reply)
|
|
70516
|
+
ports.send(reply);
|
|
70517
|
+
if (message2.method === "notifications/initialized" && follower === null)
|
|
70518
|
+
follower = follow();
|
|
70519
|
+
};
|
|
70520
|
+
for await (const chunk of ports.input) {
|
|
70521
|
+
buffer += chunk;
|
|
70522
|
+
const lines = buffer.split(`
|
|
70523
|
+
`);
|
|
70524
|
+
buffer = lines.pop() ?? "";
|
|
70525
|
+
for (const line of lines)
|
|
70526
|
+
handle(line);
|
|
70527
|
+
}
|
|
70528
|
+
handle(buffer);
|
|
70529
|
+
stop.abort();
|
|
70530
|
+
await follower;
|
|
70531
|
+
return 0;
|
|
70532
|
+
}
|
|
70533
|
+
|
|
70534
|
+
// src/commands/agent-memory.ts
|
|
70535
|
+
var MEMORY_TOOL = "praxis_assume_memory";
|
|
70536
|
+
var RECALL_TOOL = "praxis_assume_recall";
|
|
70537
|
+
var REMEMBER_TOOL = "praxis_assume_remember";
|
|
70538
|
+
function mcpUrl(apiUrl, agent) {
|
|
70539
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/mcp`;
|
|
70540
|
+
}
|
|
70541
|
+
function rpcAnswerOf(body, id) {
|
|
70542
|
+
const candidates2 = body.trimStart().startsWith("{") ? [body] : body.split(`
|
|
70543
|
+
`).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim());
|
|
70544
|
+
for (const candidate of candidates2) {
|
|
70545
|
+
try {
|
|
70546
|
+
const parsed = JSON.parse(candidate);
|
|
70547
|
+
if (parsed.id === id)
|
|
70548
|
+
return parsed;
|
|
70549
|
+
} catch {}
|
|
70550
|
+
}
|
|
70551
|
+
return null;
|
|
70552
|
+
}
|
|
70553
|
+
function toolTextOf(result) {
|
|
70554
|
+
const value = result;
|
|
70555
|
+
const text3 = (value?.content ?? []).filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join(`
|
|
70556
|
+
`).trim();
|
|
70557
|
+
return value?.isError === true ? { ok: false, reason: text3 || "the tool refused" } : { ok: true, text: text3 };
|
|
70558
|
+
}
|
|
70559
|
+
async function callAgentTool(ports, url, name, args, signal) {
|
|
70560
|
+
const base = { ...await ports.headers(), "Content-Type": "application/json", Accept: "application/json, text/event-stream" };
|
|
70561
|
+
const post = (body, session2) => ports.fetch(url, {
|
|
70562
|
+
method: "POST",
|
|
70563
|
+
headers: { ...base, ...session2 === undefined ? {} : { "Mcp-Session-Id": session2 } },
|
|
70564
|
+
body: JSON.stringify(body),
|
|
70565
|
+
...signal === undefined ? {} : { signal },
|
|
70566
|
+
redirect: "error"
|
|
70567
|
+
});
|
|
70568
|
+
const init = await post({ jsonrpc: "2.0", id: 1, method: "initialize", params: {
|
|
70569
|
+
protocolVersion: "2025-06-18",
|
|
70570
|
+
capabilities: {},
|
|
70571
|
+
clientInfo: { name: "praxis-cli-memory", version: "1" }
|
|
70572
|
+
} });
|
|
70573
|
+
const initBody = await init.text();
|
|
70574
|
+
if (!init.ok)
|
|
70575
|
+
throw new Error(`HTTP ${init.status} on initialize`);
|
|
70576
|
+
const session = init.headers.get("Mcp-Session-Id") ?? undefined;
|
|
70577
|
+
const initAnswer = rpcAnswerOf(initBody, 1);
|
|
70578
|
+
if (initAnswer?.error)
|
|
70579
|
+
throw new Error(initAnswer.error.message ?? "initialize failed");
|
|
70580
|
+
await post({ jsonrpc: "2.0", method: "notifications/initialized" }, session).then((r) => r.text()).catch(() => "");
|
|
70581
|
+
const call3 = await post({ jsonrpc: "2.0", id: 2, method: "tools/call", params: { name, arguments: args } }, session);
|
|
70582
|
+
const callBody = await call3.text();
|
|
70583
|
+
if (!call3.ok)
|
|
70584
|
+
throw new Error(`HTTP ${call3.status} on ${name}`);
|
|
70585
|
+
const answer = rpcAnswerOf(callBody, 2);
|
|
70586
|
+
if (answer === null)
|
|
70587
|
+
throw new Error(`no answer from ${name}`);
|
|
70588
|
+
if (answer.error)
|
|
70589
|
+
throw new Error(answer.error.message ?? `${name} failed`);
|
|
70590
|
+
const text3 = toolTextOf(answer.result);
|
|
70591
|
+
if (!text3.ok)
|
|
70592
|
+
throw new Error(text3.reason);
|
|
70593
|
+
return text3.text;
|
|
70594
|
+
}
|
|
70595
|
+
function memoryBodyOf(text3) {
|
|
70596
|
+
return text3.split(`
|
|
70597
|
+
`).filter((line) => {
|
|
70598
|
+
const trimmed = line.trim();
|
|
70599
|
+
return !/^shell: acon_/.test(trimmed) && !/^你有 \d+ 封未读信/.test(trimmed) && !/^You have \d+ unread letter/.test(trimmed);
|
|
70600
|
+
}).join(`
|
|
70601
|
+
`).trim();
|
|
70602
|
+
}
|
|
70603
|
+
function paragraphKey(paragraph) {
|
|
70604
|
+
return paragraph.replace(/\s*\[n\d+\]/g, "").replace(/\s+/g, " ").trim();
|
|
70605
|
+
}
|
|
70606
|
+
function newParagraphs(memory, seen) {
|
|
70607
|
+
const seenKeys = new Set([...seen].map(paragraphKey));
|
|
70608
|
+
return memory.split(/\n{2,}/).map((part) => part.trim()).filter((part) => part !== "" && !seenKeys.has(paragraphKey(part)));
|
|
70609
|
+
}
|
|
70610
|
+
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">
|
|
70611
|
+
${body}
|
|
70612
|
+
</memory>`;
|
|
70613
|
+
var MEMORY_CHANGED_FRAME = (body) => `<memory_since_start source="praxis-assume" note="what came to mind since this conversation last read your memory">
|
|
70614
|
+
${body}
|
|
70615
|
+
</memory_since_start>`;
|
|
70616
|
+
function hookOutput(event, context) {
|
|
70617
|
+
if (context === null || context.trim() === "")
|
|
70618
|
+
return null;
|
|
70619
|
+
return JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext: context } });
|
|
70620
|
+
}
|
|
70621
|
+
function hookInputOf(raw) {
|
|
70622
|
+
try {
|
|
70623
|
+
const parsed = JSON.parse(raw);
|
|
70624
|
+
const sessionId = typeof parsed.session_id === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(parsed.session_id) ? parsed.session_id : null;
|
|
70625
|
+
return { sessionId, source: typeof parsed.source === "string" ? parsed.source : null };
|
|
70626
|
+
} catch {
|
|
70627
|
+
return { sessionId: null, source: null };
|
|
70628
|
+
}
|
|
70629
|
+
}
|
|
70630
|
+
async function runMemoryHook(event, input, ports) {
|
|
70631
|
+
try {
|
|
70632
|
+
const memory = memoryBodyOf(await callAgentTool(ports, ports.url, MEMORY_TOOL, {}, AbortSignal.timeout(ports.timeoutMs)));
|
|
70633
|
+
if (memory === "")
|
|
70634
|
+
return null;
|
|
70635
|
+
const all = newParagraphs(memory, new Set);
|
|
70636
|
+
if (event === "SessionStart") {
|
|
70637
|
+
if (input.sessionId !== null)
|
|
70638
|
+
await ports.writeSeen(input.sessionId, all).catch(() => {
|
|
70639
|
+
return;
|
|
70640
|
+
});
|
|
70641
|
+
return hookOutput(event, MEMORY_FRAME(memory));
|
|
70642
|
+
}
|
|
70643
|
+
const seen = input.sessionId === null ? [] : await ports.readSeen(input.sessionId).catch(() => []);
|
|
70644
|
+
const fresh = newParagraphs(memory, new Set(seen));
|
|
70645
|
+
if (fresh.length === 0)
|
|
70646
|
+
return null;
|
|
70647
|
+
if (input.sessionId !== null)
|
|
70648
|
+
await ports.writeSeen(input.sessionId, [...seen, ...fresh]).catch(() => {
|
|
70649
|
+
return;
|
|
70650
|
+
});
|
|
70651
|
+
return hookOutput(event, MEMORY_CHANGED_FRAME(fresh.join(`
|
|
70652
|
+
|
|
70653
|
+
`)));
|
|
70654
|
+
} catch {
|
|
70655
|
+
return null;
|
|
70656
|
+
}
|
|
70657
|
+
}
|
|
70658
|
+
|
|
69161
70659
|
// src/main.ts
|
|
69162
70660
|
import { spawnSync } from "node:child_process";
|
|
69163
70661
|
|
|
@@ -69275,15 +70773,15 @@ class ModelStream {
|
|
|
69275
70773
|
finishReason = "unknown";
|
|
69276
70774
|
usage;
|
|
69277
70775
|
add(event) {
|
|
69278
|
-
const data = streamData(event),
|
|
70776
|
+
const data = streamData(event), message2 = record(data.message), response = record(data.response);
|
|
69279
70777
|
this.chunks.push(streamText(event));
|
|
69280
70778
|
const choices = Array.isArray(data.choices) ? data.choices : [];
|
|
69281
|
-
const reason2 = choices.map((c) => record(c).finish_reason).find((r) => typeof r === "string" && r) ?? record(data.delta).stop_reason ??
|
|
70779
|
+
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;
|
|
69282
70780
|
if (typeof reason2 === "string" && reason2)
|
|
69283
70781
|
this.finishReason = reason2;
|
|
69284
70782
|
else if (["response.completed", "response.incomplete", "response.failed"].includes(String(data.type)))
|
|
69285
70783
|
this.finishReason = String(data.type).slice("response.".length);
|
|
69286
|
-
for (const usage of [
|
|
70784
|
+
for (const usage of [message2.usage, data.usage, response.usage]) {
|
|
69287
70785
|
if (usage !== null && typeof usage === "object" && !Array.isArray(usage))
|
|
69288
70786
|
this.usage = { ...this.usage, ...record(usage) };
|
|
69289
70787
|
}
|
|
@@ -69348,8 +70846,8 @@ function isSuccess(verb, ctx) {
|
|
|
69348
70846
|
}
|
|
69349
70847
|
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" };
|
|
69350
70848
|
var deleted = (verb) => /^(delete|remove|purge)(-|$)/.test(verb);
|
|
69351
|
-
function width(
|
|
69352
|
-
return [...
|
|
70849
|
+
function width(text3) {
|
|
70850
|
+
return [...text3].reduce((sum, ch) => {
|
|
69353
70851
|
const cp = ch.codePointAt(0);
|
|
69354
70852
|
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);
|
|
69355
70853
|
}, 0);
|
|
@@ -69357,13 +70855,13 @@ function width(text2) {
|
|
|
69357
70855
|
function truncate(value, size) {
|
|
69358
70856
|
if (width(value) <= size)
|
|
69359
70857
|
return value;
|
|
69360
|
-
let
|
|
70858
|
+
let text3 = "";
|
|
69361
70859
|
for (const ch of value) {
|
|
69362
|
-
if (width(
|
|
70860
|
+
if (width(text3 + ch) > size - 1)
|
|
69363
70861
|
break;
|
|
69364
|
-
|
|
70862
|
+
text3 += ch;
|
|
69365
70863
|
}
|
|
69366
|
-
return
|
|
70864
|
+
return text3 + "…";
|
|
69367
70865
|
}
|
|
69368
70866
|
function table(items, ctx, paint) {
|
|
69369
70867
|
const columns = columnsFor(items);
|
|
@@ -69396,13 +70894,13 @@ function table(items, ctx, paint) {
|
|
|
69396
70894
|
sizes[index]--;
|
|
69397
70895
|
}
|
|
69398
70896
|
const line = (row, header) => row.map((v, i) => {
|
|
69399
|
-
const
|
|
69400
|
-
let styled = header ? paint.dim(
|
|
70897
|
+
const text3 = truncate(v, sizes[i]);
|
|
70898
|
+
let styled = header ? paint.dim(text3) : text3;
|
|
69401
70899
|
if (!header && ["status", "state"].includes(columns[i])) {
|
|
69402
70900
|
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;
|
|
69403
|
-
styled = color(
|
|
70901
|
+
styled = color(text3);
|
|
69404
70902
|
}
|
|
69405
|
-
return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(
|
|
70903
|
+
return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(text3))));
|
|
69406
70904
|
}).join(" ");
|
|
69407
70905
|
return [line(headers, true), ...rows.map((row) => line(row, false))].join(`
|
|
69408
70906
|
`) + `
|
|
@@ -69501,9 +70999,9 @@ function renderHuman(result, ctx) {
|
|
|
69501
70999
|
}
|
|
69502
71000
|
|
|
69503
71001
|
// src/output/agent.ts
|
|
69504
|
-
function cell(
|
|
69505
|
-
const chars = [...
|
|
69506
|
-
const limited = chars.length > 500 ? chars.slice(0, 500).join("") + `…[+${chars.length - 500} chars, use --json]` :
|
|
71002
|
+
function cell(text3) {
|
|
71003
|
+
const chars = [...text3];
|
|
71004
|
+
const limited = chars.length > 500 ? chars.slice(0, 500).join("") + `…[+${chars.length - 500} chars, use --json]` : text3;
|
|
69507
71005
|
return limited.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>").replace(/\r/g, "<br>");
|
|
69508
71006
|
}
|
|
69509
71007
|
function renderAgent(result, ctx) {
|
|
@@ -69514,9 +71012,9 @@ function renderAgent(result, ctx) {
|
|
|
69514
71012
|
if (modelStream(result.op)) {
|
|
69515
71013
|
if (!result.summary)
|
|
69516
71014
|
return {};
|
|
69517
|
-
const { text:
|
|
69518
|
-
return { stdout: `${
|
|
69519
|
-
`) || !
|
|
71015
|
+
const { text: text3, finish_reason, usage } = result.summary;
|
|
71016
|
+
return { stdout: `${text3}${text3.endsWith(`
|
|
71017
|
+
`) || !text3 ? "" : `
|
|
69520
71018
|
`}finish_reason: ${finish_reason}
|
|
69521
71019
|
${usage ? `usage: ${JSON.stringify(usage)}
|
|
69522
71020
|
` : ""}` };
|
|
@@ -69735,18 +71233,18 @@ function errorInput(error, ctx) {
|
|
|
69735
71233
|
const details = candidate !== null && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : undefined;
|
|
69736
71234
|
const problem = serverProblem(Object.keys(nested).length ? nested : raw);
|
|
69737
71235
|
const serverText = (value) => typeof value === "string" && value.trim() ? value : undefined;
|
|
69738
|
-
let
|
|
69739
|
-
const prefix =
|
|
71236
|
+
let message2 = error instanceof Error ? error.message : "Unexpected error";
|
|
71237
|
+
const prefix = message2.match(/^([A-Z][A-Z0-9_]+):\s*/)?.[1];
|
|
69740
71238
|
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");
|
|
69741
71239
|
let stripped = false;
|
|
69742
|
-
while (
|
|
69743
|
-
|
|
71240
|
+
while (message2.startsWith(`${code}:`)) {
|
|
71241
|
+
message2 = message2.slice(code.length + 1).trimStart();
|
|
69744
71242
|
stripped = true;
|
|
69745
71243
|
}
|
|
69746
71244
|
if (stripped)
|
|
69747
|
-
|
|
71245
|
+
message2 = `${humanize(code)}${message2 ? `: ${message2}` : ""}`;
|
|
69748
71246
|
const status = sdk?.status, request_id = sdk?.requestId;
|
|
69749
|
-
|
|
71247
|
+
message2 = serverText(problem?.detail) ?? serverText(problem?.title) ?? message2;
|
|
69750
71248
|
const authFailure = status === 401 || ["NOT_LOGGED_IN", "UNAUTHENTICATED", "TOKEN_REVOKED", "LOGIN_FAILED", "MANAGED_LOGIN_EXPIRED"].includes(code);
|
|
69751
71249
|
const source = ctx.credentialSource ?? "login";
|
|
69752
71250
|
let hint3 = genericHint;
|
|
@@ -69764,19 +71262,19 @@ function errorInput(error, ctx) {
|
|
|
69764
71262
|
hint3 = "Rate limited; retry later.";
|
|
69765
71263
|
else if (status !== undefined && status >= 500)
|
|
69766
71264
|
hint3 = `Server error; retry later.${request_id ? ` Request id: ${request_id}.` : ""}`;
|
|
69767
|
-
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 } : {} };
|
|
71265
|
+
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 } : {} };
|
|
69768
71266
|
}
|
|
69769
71267
|
|
|
69770
71268
|
// src/output/progress.ts
|
|
69771
|
-
function startProgress(ctx, write = (
|
|
71269
|
+
function startProgress(ctx, write = (text3) => writeOutput({ stderr: text3 })) {
|
|
69772
71270
|
if (ctx.mode !== "human" || !ctx.stderrIsTTY)
|
|
69773
71271
|
return () => {};
|
|
69774
71272
|
let interval;
|
|
69775
|
-
let shown = false,
|
|
71273
|
+
let shown = false, frame2 = 0;
|
|
69776
71274
|
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
69777
71275
|
const tick = () => {
|
|
69778
71276
|
shown = true;
|
|
69779
|
-
write(`\r${frames[
|
|
71277
|
+
write(`\r${frames[frame2++ % frames.length]} Loading…`);
|
|
69780
71278
|
};
|
|
69781
71279
|
const timer = setTimeout(() => {
|
|
69782
71280
|
tick();
|
|
@@ -69794,7 +71292,7 @@ function startProgress(ctx, write = (text2) => writeOutput({ stderr: text2 })) {
|
|
|
69794
71292
|
}
|
|
69795
71293
|
|
|
69796
71294
|
// src/main.ts
|
|
69797
|
-
var version = "0.3.0-dev.
|
|
71295
|
+
var version = "0.3.0-dev.3ab122a";
|
|
69798
71296
|
var commands = commandTree(operations);
|
|
69799
71297
|
var manual = [...workflows.map((w) => w.words), [API_WORD]];
|
|
69800
71298
|
function route(argv) {
|
|
@@ -69876,7 +71374,7 @@ var defaults = {
|
|
|
69876
71374
|
return;
|
|
69877
71375
|
const cmd = process.platform === "darwin" ? ["open", url] : process.platform === "win32" ? ["rundll32", "url.dll,FileProtocolHandler", url] : ["xdg-open", url];
|
|
69878
71376
|
await new Promise((resolve12, reject) => {
|
|
69879
|
-
const child =
|
|
71377
|
+
const child = spawn5(cmd[0], cmd.slice(1), { stdio: "ignore" });
|
|
69880
71378
|
child.once("error", reject);
|
|
69881
71379
|
child.once("close", () => resolve12());
|
|
69882
71380
|
});
|
|
@@ -69885,12 +71383,12 @@ var defaults = {
|
|
|
69885
71383
|
wait: (ms) => new Promise((resolve12) => setTimeout(resolve12, ms)),
|
|
69886
71384
|
render,
|
|
69887
71385
|
spawn: (cmd, args, options) => new Promise((resolve12, reject) => {
|
|
69888
|
-
const child =
|
|
71386
|
+
const child = spawn5(cmd, args, { cwd: options.cwd, stdio: ["ignore", 2, 2] });
|
|
69889
71387
|
child.once("error", reject);
|
|
69890
71388
|
child.once("close", (code) => resolve12(code ?? 1));
|
|
69891
71389
|
}),
|
|
69892
71390
|
spawnCapture: (cmd, args, options) => new Promise((resolve12, reject) => {
|
|
69893
|
-
const child =
|
|
71391
|
+
const child = spawn5(cmd, args, { cwd: options.cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
69894
71392
|
const chunks = [];
|
|
69895
71393
|
child.stdout.on("data", (c) => chunks.push(c));
|
|
69896
71394
|
child.stderr.on("data", (c) => chunks.push(c));
|
|
@@ -69973,6 +71471,21 @@ var appOptions = {
|
|
|
69973
71471
|
{ 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)." },
|
|
69974
71472
|
{ name: "project", type: "string", description: "With --report: the DevOps project id (dvp_…) whose flags the scan is reported into. Required." }
|
|
69975
71473
|
],
|
|
71474
|
+
"agent memory": [
|
|
71475
|
+
{ 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." }
|
|
71476
|
+
],
|
|
71477
|
+
"agent recall": [
|
|
71478
|
+
{ name: "words", type: "string", repeated: true, description: "Distinctive words to recall by, comma-separated or repeated." },
|
|
71479
|
+
{ name: "handles", type: "string", repeated: true, description: "Entry handles or ids from memory to recall, comma-separated or repeated." }
|
|
71480
|
+
],
|
|
71481
|
+
"agent remember": [
|
|
71482
|
+
{ name: "text", type: "string", description: "The experience, in your own words: what happened, who, what was decided and why, what is still open." },
|
|
71483
|
+
{ name: "about", type: "string", repeated: true, description: "Ids of entities it is about, comma-separated or repeated." }
|
|
71484
|
+
],
|
|
71485
|
+
"agent events wait": [
|
|
71486
|
+
{ name: "timeout", type: "string", description: "Give up after this many seconds, print that nothing arrived and exit 0 (default: wait until a letter arrives)." },
|
|
71487
|
+
{ 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)." }
|
|
71488
|
+
],
|
|
69976
71489
|
"canvas import": [
|
|
69977
71490
|
{ name: "name", type: "string", description: "Name for the new canvas (default: the file name without .pen)." },
|
|
69978
71491
|
{ 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." },
|
|
@@ -69991,15 +71504,15 @@ function flagPortsFor(ports, context, emit, connect) {
|
|
|
69991
71504
|
return {
|
|
69992
71505
|
mode: context.mode,
|
|
69993
71506
|
emit,
|
|
69994
|
-
human: (
|
|
71507
|
+
human: (text3) => {
|
|
69995
71508
|
if (context.mode === "human")
|
|
69996
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71509
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
69997
71510
|
},
|
|
69998
71511
|
cwd: ports.cwd,
|
|
69999
71512
|
readFile: ports.readFile,
|
|
70000
71513
|
git: async (args) => (await ports.spawnCapture("git", [...args], { cwd: ports.cwd })).output,
|
|
70001
71514
|
client: connect,
|
|
70002
|
-
writeFile: (path,
|
|
71515
|
+
writeFile: (path, text3) => writeFile5(path, text3, "utf8"),
|
|
70003
71516
|
mkdir: async (path) => {
|
|
70004
71517
|
await mkdir4(path, { recursive: true });
|
|
70005
71518
|
},
|
|
@@ -70023,9 +71536,9 @@ function toolPortsFor(ports, context, emit) {
|
|
|
70023
71536
|
return {
|
|
70024
71537
|
mode: context.mode,
|
|
70025
71538
|
emit,
|
|
70026
|
-
human: (
|
|
71539
|
+
human: (text3) => {
|
|
70027
71540
|
if (context.mode === "human")
|
|
70028
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71541
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70029
71542
|
},
|
|
70030
71543
|
cwd: ports.cwd,
|
|
70031
71544
|
readFile: ports.readFile,
|
|
@@ -70040,7 +71553,7 @@ function toolPortsFor(ports, context, emit) {
|
|
|
70040
71553
|
},
|
|
70041
71554
|
git: (args, cwd) => ports.spawnCapture("git", args, { cwd }),
|
|
70042
71555
|
run: (cmd, args, cwd) => new Promise((resolve12, reject) => {
|
|
70043
|
-
const child =
|
|
71556
|
+
const child = spawn5(cmd, args, { cwd, stdio: "inherit" });
|
|
70044
71557
|
child.once("error", reject);
|
|
70045
71558
|
child.once("close", (code) => resolve12(code ?? 1));
|
|
70046
71559
|
}),
|
|
@@ -70065,7 +71578,7 @@ async function main3(argv, injected = {}) {
|
|
|
70065
71578
|
columns: ports.columns,
|
|
70066
71579
|
now: ports.now(),
|
|
70067
71580
|
envVars: { NO_COLOR: ports.env.NO_COLOR, FORCE_COLOR: ports.env.FORCE_COLOR, TERM: ports.env.TERM },
|
|
70068
|
-
env: ports.env.PRAXIS_ENV ??
|
|
71581
|
+
env: ports.env.PRAXIS_ENV ?? DEFAULT_ENV
|
|
70069
71582
|
};
|
|
70070
71583
|
let stopProgress = () => {};
|
|
70071
71584
|
let quiet = false;
|
|
@@ -70335,9 +71848,9 @@ Examples:
|
|
|
70335
71848
|
},
|
|
70336
71849
|
mode: ctx.mode,
|
|
70337
71850
|
emit,
|
|
70338
|
-
human: (
|
|
71851
|
+
human: (text3) => {
|
|
70339
71852
|
if (ctx.mode === "human")
|
|
70340
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71853
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70341
71854
|
},
|
|
70342
71855
|
cwd: ports.cwd
|
|
70343
71856
|
});
|
|
@@ -70364,14 +71877,14 @@ Examples:
|
|
|
70364
71877
|
}, {
|
|
70365
71878
|
mode: ctx.mode,
|
|
70366
71879
|
emit,
|
|
70367
|
-
human: (
|
|
71880
|
+
human: (text3) => {
|
|
70368
71881
|
if (ctx.mode === "human")
|
|
70369
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71882
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70370
71883
|
},
|
|
70371
71884
|
engine: codeRefactorEngine(),
|
|
70372
71885
|
hasFile: (path2) => existsSync4(path2),
|
|
70373
71886
|
readFile: ports.readFile,
|
|
70374
|
-
writeFile: (path2,
|
|
71887
|
+
writeFile: (path2, text3) => writeFile5(path2, text3, "utf8"),
|
|
70375
71888
|
mkdir: async (path2) => {
|
|
70376
71889
|
await mkdir4(path2, { recursive: true });
|
|
70377
71890
|
},
|
|
@@ -70388,9 +71901,9 @@ Examples:
|
|
|
70388
71901
|
const shellPorts = {
|
|
70389
71902
|
mode: ctx.mode,
|
|
70390
71903
|
emit,
|
|
70391
|
-
human: (
|
|
71904
|
+
human: (text3) => {
|
|
70392
71905
|
if (ctx.mode === "human")
|
|
70393
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71906
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70394
71907
|
},
|
|
70395
71908
|
engine: await repositoryEngine(name, () => localEngine(ports.cwd)),
|
|
70396
71909
|
...localFilePorts(ports.cwd)
|
|
@@ -70403,9 +71916,9 @@ Examples:
|
|
|
70403
71916
|
const testPorts = {
|
|
70404
71917
|
mode: ctx.mode,
|
|
70405
71918
|
emit,
|
|
70406
|
-
human: (
|
|
71919
|
+
human: (text3) => {
|
|
70407
71920
|
if (ctx.mode === "human")
|
|
70408
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71921
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70409
71922
|
},
|
|
70410
71923
|
engine: await repositoryEngine(name, () => localEngine(ports.cwd)),
|
|
70411
71924
|
checkout: await localCheckout(ports.cwd, (cmd, args, options) => ports.spawnCapture(cmd, args, options))
|
|
@@ -70414,9 +71927,9 @@ Examples:
|
|
|
70414
71927
|
return await devopsTestReport({ path: parsed.positional[0], id: parsed.flags.id?.[0], upload: Boolean(parsed.flags.upload), project: parsed.flags.project?.[0] }, testPorts, {
|
|
70415
71928
|
mode: ctx.mode,
|
|
70416
71929
|
emit,
|
|
70417
|
-
human: (
|
|
71930
|
+
human: (text3) => {
|
|
70418
71931
|
if (ctx.mode === "human")
|
|
70419
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71932
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70420
71933
|
},
|
|
70421
71934
|
root: async () => await checkoutRoot(ports.cwd, ports.readFile),
|
|
70422
71935
|
readFile: ports.readFile,
|
|
@@ -70446,9 +71959,9 @@ Examples:
|
|
|
70446
71959
|
git: (args) => ports.spawnCapture("git", args, { cwd: ports.cwd }),
|
|
70447
71960
|
mode: ctx.mode,
|
|
70448
71961
|
emit,
|
|
70449
|
-
human: (
|
|
71962
|
+
human: (text3) => {
|
|
70450
71963
|
if (ctx.mode === "human")
|
|
70451
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71964
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70452
71965
|
}
|
|
70453
71966
|
});
|
|
70454
71967
|
}
|
|
@@ -70498,9 +72011,9 @@ Examples:
|
|
|
70498
72011
|
emit({ kind: "object", data: await auth.switchOrganization(parsed.positional[0]) });
|
|
70499
72012
|
break;
|
|
70500
72013
|
case "app create": {
|
|
70501
|
-
const appPorts = { ...ports, mode: ctx.mode, emit, human: (
|
|
72014
|
+
const appPorts = { ...ports, mode: ctx.mode, emit, human: (text3) => {
|
|
70502
72015
|
if (ctx.mode === "human")
|
|
70503
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
72016
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70504
72017
|
}, random: randomSecret };
|
|
70505
72018
|
await appCreate({ name: parsed.positional[0], dir: parsed.flags.dir?.[0], template: parsed.flags.template?.[0], install: !parsed.flags["no-install"] }, config.env, appPorts);
|
|
70506
72019
|
break;
|
|
@@ -70529,13 +72042,220 @@ Examples:
|
|
|
70529
72042
|
wait: ports.wait,
|
|
70530
72043
|
mode: ctx.mode,
|
|
70531
72044
|
emit,
|
|
70532
|
-
human: (
|
|
72045
|
+
human: (text3) => {
|
|
70533
72046
|
if (ctx.mode === "human")
|
|
70534
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
72047
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70535
72048
|
},
|
|
70536
72049
|
cwd: ports.cwd
|
|
70537
72050
|
});
|
|
70538
72051
|
}
|
|
72052
|
+
case "agent events channel": {
|
|
72053
|
+
const agent = assumeAgentOf(ports.env);
|
|
72054
|
+
const headers = async () => {
|
|
72055
|
+
const credential = await auth.get(org);
|
|
72056
|
+
return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
|
|
72057
|
+
};
|
|
72058
|
+
const failure2 = (status, body) => `HTTP ${status}${body?.error?.code ? ` ${body.error.code}` : ""}${body?.error?.message ? `: ${String(redact(body.error.message, secrets))}` : ""}`;
|
|
72059
|
+
process.stdin.setEncoding("utf8");
|
|
72060
|
+
return await runChannel({
|
|
72061
|
+
agent,
|
|
72062
|
+
input: process.stdin,
|
|
72063
|
+
send: (frame2) => {
|
|
72064
|
+
process.stdout.write(JSON.stringify(frame2) + `
|
|
72065
|
+
`);
|
|
72066
|
+
},
|
|
72067
|
+
fetchLetters: async () => {
|
|
72068
|
+
const response = await wireFetch(inboxLettersUrl(config.apiUrl, agent), { headers: await headers(), signal: AbortSignal.timeout(30000), redirect: "error" });
|
|
72069
|
+
const body = await response.json().catch(() => null);
|
|
72070
|
+
if (!response.ok)
|
|
72071
|
+
throw new Error(failure2(response.status, body));
|
|
72072
|
+
return lettersOf(body);
|
|
72073
|
+
},
|
|
72074
|
+
openStream: async (signal, lastEventId) => {
|
|
72075
|
+
const response = await wireFetch(eventsStreamUrl(config.apiUrl, agent), { headers: streamHeaders(await headers(), lastEventId), signal, redirect: "error" });
|
|
72076
|
+
if (!response.ok || !response.body) {
|
|
72077
|
+
const body = await response.json().catch(() => null);
|
|
72078
|
+
return { status: response.status, reason: failure2(response.status, body) };
|
|
72079
|
+
}
|
|
72080
|
+
return { status: response.status, chunks: response.body.pipeThrough(new TextDecoderStream) };
|
|
72081
|
+
},
|
|
72082
|
+
sleep: (ms, signal) => new Promise((resolve12) => {
|
|
72083
|
+
const timer = setTimeout(resolve12, ms);
|
|
72084
|
+
signal.addEventListener("abort", () => {
|
|
72085
|
+
clearTimeout(timer);
|
|
72086
|
+
resolve12();
|
|
72087
|
+
}, { once: true });
|
|
72088
|
+
}),
|
|
72089
|
+
log: (line) => {
|
|
72090
|
+
process.stderr.write(String(redact(line, secrets)) + `
|
|
72091
|
+
`);
|
|
72092
|
+
}
|
|
72093
|
+
});
|
|
72094
|
+
}
|
|
72095
|
+
case "agent memory":
|
|
72096
|
+
case "agent recall":
|
|
72097
|
+
case "agent remember": {
|
|
72098
|
+
const agent = assumeAgentOf(ports.env);
|
|
72099
|
+
const mcpPorts = {
|
|
72100
|
+
fetch: (url2, init) => wireFetch(url2, init),
|
|
72101
|
+
headers: async () => {
|
|
72102
|
+
const credential = await auth.get(org);
|
|
72103
|
+
return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
|
|
72104
|
+
}
|
|
72105
|
+
};
|
|
72106
|
+
const url = mcpUrl(config.apiUrl, agent);
|
|
72107
|
+
const hook = parsed.flags.hook?.[0];
|
|
72108
|
+
if (name === "agent memory" && hook !== undefined) {
|
|
72109
|
+
if (hook !== "SessionStart" && hook !== "UserPromptSubmit")
|
|
72110
|
+
throw new UsageError(`--hook takes SessionStart or UserPromptSubmit, not ${hook}`, "Example: praxis agent memory --hook SessionStart");
|
|
72111
|
+
process.stdin.setEncoding("utf8");
|
|
72112
|
+
let raw = "";
|
|
72113
|
+
if (!process.stdin.isTTY)
|
|
72114
|
+
for await (const chunk of process.stdin)
|
|
72115
|
+
raw += chunk;
|
|
72116
|
+
const input = hookInputOf(raw);
|
|
72117
|
+
const seenDir = join12(ports.env.HOME || homedir3(), ".praxis", "cli", "memory-seen");
|
|
72118
|
+
const out = await runMemoryHook(hook, input, {
|
|
72119
|
+
...mcpPorts,
|
|
72120
|
+
url,
|
|
72121
|
+
timeoutMs: 25000,
|
|
72122
|
+
readSeen: async (id) => JSON.parse(await readFile7(join12(seenDir, `${id}.json`), "utf8")),
|
|
72123
|
+
writeSeen: async (id, paragraphs) => {
|
|
72124
|
+
await mkdir4(seenDir, { recursive: true, mode: 448 });
|
|
72125
|
+
await writeFile5(join12(seenDir, `${id}.json`), JSON.stringify(paragraphs), { mode: 384 });
|
|
72126
|
+
}
|
|
72127
|
+
});
|
|
72128
|
+
if (out !== null)
|
|
72129
|
+
process.stdout.write(out + `
|
|
72130
|
+
`);
|
|
72131
|
+
return 0;
|
|
72132
|
+
}
|
|
72133
|
+
const list = (flag) => (parsed.flags[flag] ?? []).flatMap((value) => value.split(",")).map((value) => value.trim()).filter(Boolean);
|
|
72134
|
+
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") } : {} } : {};
|
|
72135
|
+
if (name === "agent remember" && String(args.text).trim() === "")
|
|
72136
|
+
throw new UsageError("--text is required", 'Example: praxis agent remember --text "今天定了……"');
|
|
72137
|
+
const tool = name === "agent memory" ? MEMORY_TOOL : name === "agent recall" ? RECALL_TOOL : REMEMBER_TOOL;
|
|
72138
|
+
const text3 = memoryBodyOf(await callAgentTool(mcpPorts, url, tool, args, AbortSignal.timeout(60000)));
|
|
72139
|
+
process.stdout.write(text3 + `
|
|
72140
|
+
`);
|
|
72141
|
+
return 0;
|
|
72142
|
+
}
|
|
72143
|
+
case "agent events wait": {
|
|
72144
|
+
const agent = assumeAgentOf(ports.env);
|
|
72145
|
+
const timeoutMs = (() => {
|
|
72146
|
+
try {
|
|
72147
|
+
return timeoutMsOf(parsed.flags.timeout?.[0]);
|
|
72148
|
+
} catch (error) {
|
|
72149
|
+
throw new UsageError(error.message, "Example: praxis agent events wait --timeout 3600");
|
|
72150
|
+
}
|
|
72151
|
+
})();
|
|
72152
|
+
const headers = async () => {
|
|
72153
|
+
const credential = await auth.get(org);
|
|
72154
|
+
return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
|
|
72155
|
+
};
|
|
72156
|
+
const failure2 = (status, body) => `HTTP ${status}${body?.error?.code ? ` ${body.error.code}` : ""}${body?.error?.message ? `: ${String(redact(body.error.message, secrets))}` : ""}`;
|
|
72157
|
+
const session = (() => {
|
|
72158
|
+
try {
|
|
72159
|
+
return sessionOf(parsed.flags.session?.[0]);
|
|
72160
|
+
} catch (error) {
|
|
72161
|
+
throw new UsageError(error.message, "Example: praxis agent events wait --session 0f6c…");
|
|
72162
|
+
}
|
|
72163
|
+
})();
|
|
72164
|
+
const key = waitKeyOf(config.env, agent, session);
|
|
72165
|
+
const waitDir = join12(ports.env.HOME || homedir3(), ".praxis", "cli", "events-wait");
|
|
72166
|
+
const statePath = join12(waitDir, `${key}.json`);
|
|
72167
|
+
const pidPath = join12(waitDir, `${key}.pid`);
|
|
72168
|
+
await mkdir4(waitDir, { recursive: true, mode: 448 });
|
|
72169
|
+
const holder = await acquireWaitLock({
|
|
72170
|
+
self: process.pid,
|
|
72171
|
+
readPid: () => readFile7(pidPath, "utf8").catch(() => null),
|
|
72172
|
+
createPid: (text3) => writeFile5(pidPath, text3, { mode: 384, flag: "wx" }).then(() => true, () => false),
|
|
72173
|
+
replacePid: (text3) => writeFile5(pidPath, text3, { mode: 384 }),
|
|
72174
|
+
probe: async (pid) => {
|
|
72175
|
+
try {
|
|
72176
|
+
process.kill(pid, 0);
|
|
72177
|
+
} catch (error) {
|
|
72178
|
+
if (error.code !== "EPERM")
|
|
72179
|
+
return { alive: false };
|
|
72180
|
+
}
|
|
72181
|
+
const ps = spawnSync("ps", ["-o", "ppid=,command=", "-p", String(pid)], { encoding: "utf8" });
|
|
72182
|
+
const line = ps.stdout?.trim() ?? "";
|
|
72183
|
+
const match = /^(\d+)\s+(.*)$/.exec(line);
|
|
72184
|
+
return match ? { alive: true, ppid: Number(match[1]), command: match[2] } : { alive: false };
|
|
72185
|
+
},
|
|
72186
|
+
terminate: (pid) => {
|
|
72187
|
+
try {
|
|
72188
|
+
process.kill(pid, "SIGTERM");
|
|
72189
|
+
} catch {}
|
|
72190
|
+
}
|
|
72191
|
+
});
|
|
72192
|
+
if (holder !== null) {
|
|
72193
|
+
process.stdout.write(alreadyWaitingNotice(holder) + `
|
|
72194
|
+
`);
|
|
72195
|
+
return 0;
|
|
72196
|
+
}
|
|
72197
|
+
const release = () => {
|
|
72198
|
+
try {
|
|
72199
|
+
if (pidOf(readFileSync3(pidPath, "utf8")) === process.pid)
|
|
72200
|
+
unlinkSync(pidPath);
|
|
72201
|
+
} catch {}
|
|
72202
|
+
};
|
|
72203
|
+
const onSignal = (signal) => {
|
|
72204
|
+
release();
|
|
72205
|
+
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
72206
|
+
};
|
|
72207
|
+
for (const signal of ["SIGTERM", "SIGINT", "SIGHUP"])
|
|
72208
|
+
process.once(signal, onSignal);
|
|
72209
|
+
try {
|
|
72210
|
+
return await runEventsWait({
|
|
72211
|
+
agent,
|
|
72212
|
+
timeoutMs,
|
|
72213
|
+
fetchLetters: async () => {
|
|
72214
|
+
const response = await wireFetch(inboxLettersUrl(config.apiUrl, agent), { headers: await headers(), signal: AbortSignal.timeout(30000), redirect: "error" });
|
|
72215
|
+
const body = await response.json().catch(() => null);
|
|
72216
|
+
if (!response.ok)
|
|
72217
|
+
throw new Error(failure2(response.status, body));
|
|
72218
|
+
return lettersOf(body);
|
|
72219
|
+
},
|
|
72220
|
+
openStream: async (signal, lastEventId) => {
|
|
72221
|
+
const response = await wireFetch(eventsStreamUrl(config.apiUrl, agent), {
|
|
72222
|
+
headers: streamHeaders(await headers(), lastEventId),
|
|
72223
|
+
signal,
|
|
72224
|
+
redirect: "error"
|
|
72225
|
+
});
|
|
72226
|
+
if (!response.ok || !response.body) {
|
|
72227
|
+
const body = await response.json().catch(() => null);
|
|
72228
|
+
return { status: response.status, reason: failure2(response.status, body) };
|
|
72229
|
+
}
|
|
72230
|
+
return { status: response.status, chunks: response.body.pipeThrough(new TextDecoderStream) };
|
|
72231
|
+
},
|
|
72232
|
+
readState: async () => waitStateOf(await readFile7(statePath, "utf8").catch(() => null)),
|
|
72233
|
+
writeState: async (next) => {
|
|
72234
|
+
await mkdir4(dirname10(statePath), { recursive: true, mode: 448 });
|
|
72235
|
+
await writeFile5(statePath, waitStateText(next), { mode: 384 });
|
|
72236
|
+
},
|
|
72237
|
+
print: (line) => {
|
|
72238
|
+
process.stdout.write(line + `
|
|
72239
|
+
`);
|
|
72240
|
+
},
|
|
72241
|
+
log: (line) => {
|
|
72242
|
+
process.stderr.write(String(redact(line, secrets)) + `
|
|
72243
|
+
`);
|
|
72244
|
+
},
|
|
72245
|
+
sleep: (ms, signal) => new Promise((resolve12) => {
|
|
72246
|
+
const timer = setTimeout(resolve12, ms);
|
|
72247
|
+
signal.addEventListener("abort", () => {
|
|
72248
|
+
clearTimeout(timer);
|
|
72249
|
+
resolve12();
|
|
72250
|
+
}, { once: true });
|
|
72251
|
+
})
|
|
72252
|
+
});
|
|
72253
|
+
} finally {
|
|
72254
|
+
release();
|
|
72255
|
+
for (const signal of ["SIGTERM", "SIGINT", "SIGHUP"])
|
|
72256
|
+
process.removeListener(signal, onSignal);
|
|
72257
|
+
}
|
|
72258
|
+
}
|
|
70539
72259
|
case "canvas import": {
|
|
70540
72260
|
const authorize = async () => {
|
|
70541
72261
|
const credential = await auth.get(org);
|
|
@@ -70577,7 +72297,7 @@ Examples:
|
|
|
70577
72297
|
file: parsed.positional[0],
|
|
70578
72298
|
name: parsed.flags.name?.[0],
|
|
70579
72299
|
canvas: parsed.flags.canvas?.[0],
|
|
70580
|
-
frames: typeof parsed.flags.frames?.[0] === "string" ? parsed.flags.frames[0].split(",").map((
|
|
72300
|
+
frames: typeof parsed.flags.frames?.[0] === "string" ? parsed.flags.frames[0].split(",").map((frame2) => frame2.trim()).filter(Boolean) : undefined,
|
|
70581
72301
|
imageRoots: parsed.flags["image-root"],
|
|
70582
72302
|
dryRun: Boolean(parsed.flags["dry-run"]?.[0]),
|
|
70583
72303
|
yes: Boolean(flags.yes)
|
|
@@ -70591,9 +72311,9 @@ Examples:
|
|
|
70591
72311
|
cwd: ports.cwd,
|
|
70592
72312
|
rpc,
|
|
70593
72313
|
upload,
|
|
70594
|
-
human: (
|
|
72314
|
+
human: (text3) => {
|
|
70595
72315
|
if (ctx.mode === "human")
|
|
70596
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
72316
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70597
72317
|
}
|
|
70598
72318
|
});
|
|
70599
72319
|
}
|
|
@@ -70625,7 +72345,8 @@ if (true) {
|
|
|
70625
72345
|
process.exit(0);
|
|
70626
72346
|
throw error;
|
|
70627
72347
|
});
|
|
70628
|
-
|
|
72348
|
+
const argv = process.argv.slice(2);
|
|
72349
|
+
process.exitCode = isDevopsTestRun(route(argv).words) && needsCacheOffReexec(process.env) ? await reexecWithCacheOff() : await main3(argv);
|
|
70629
72350
|
}
|
|
70630
72351
|
export {
|
|
70631
72352
|
main3 as main
|