@deepraxis/cli 0.3.0-dev.80dd587 → 0.3.0-dev.830431a
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 +9 -2
- package/dist/praxis.js +931 -75
- package/package.json +1 -1
package/dist/praxis.js
CHANGED
|
@@ -13984,10 +13984,14 @@ 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
13986
|
"cognition-weight-driven": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-bd", ticket: 1760, expires: "2026-12-05", system: "devops" },
|
|
13987
|
+
crm: { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_rv860m7z9h8szkgma56cd14n", ticket: 2179, expires: "2026-12-31", system: "devops" },
|
|
13987
13988
|
"delivery-rules-v2": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2048, expires: "2026-11-28", system: "devops" },
|
|
13988
13989
|
"model-access-gate": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 1933, expires: "2026-12-15", system: "devops" },
|
|
13989
13990
|
"open-project": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-51", ticket: 1488, expires: "2026-11-25", system: "devops" },
|
|
13991
|
+
"requests-never-hold": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2119, expires: "2026-11-29", system: "devops" },
|
|
13992
|
+
"requests-v1": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2057, expires: "2026-11-28", system: "devops" },
|
|
13990
13993
|
"router-precommit-hedge": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2052, expires: "2026-11-28", system: "devops" },
|
|
13994
|
+
"router-responses-hedge": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: 2149, expires: "2026-11-28", system: "devops" },
|
|
13991
13995
|
"search-provider-routing": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "praxis-98", ticket: 716, expires: "2026-12-31", system: "devops" },
|
|
13992
13996
|
"unit-live-probe": { kind: "RELEASE", type: "BOOLEAN", default: false, owner: "usr_t60d4g5z82rhbtbfrfxfbdxe", ticket: null, expires: "2026-11-19", system: "devops" }
|
|
13993
13997
|
};
|
|
@@ -14014,7 +14018,7 @@ function checkFlags(files, registry, today = new Date().toISOString().slice(0, 1
|
|
|
14014
14018
|
}
|
|
14015
14019
|
const registryFile = production.find((f) => f.path.endsWith("flag-registry.generated.ts"));
|
|
14016
14020
|
const registryLine = (key) => registryFile ? lineOf(registryFile.text, Math.max(0, registryFile.text.indexOf(`"${key}":`))) : 1;
|
|
14017
|
-
const add = (file, offset,
|
|
14021
|
+
const add = (file, offset, message2) => issues.push({ file: file.path, line: lineOf(file.text, offset), message: message2 });
|
|
14018
14022
|
const referencedKeysIn = (file) => {
|
|
14019
14023
|
for (const key of registered) {
|
|
14020
14024
|
const literal = new RegExp(`(?:"|')${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:"|')`);
|
|
@@ -14103,7 +14107,7 @@ async function main() {
|
|
|
14103
14107
|
else
|
|
14104
14108
|
console.log(`Feature flag registry check passed (${Object.keys(FLAGS).length} registered flags).`);
|
|
14105
14109
|
}
|
|
14106
|
-
var isTest = (path) => /(^|\/)(spec|__tests__)(\/|$)|\.(test|spec)\.[cm]?[jt]sx?$/.test(path), lineOf = (
|
|
14110
|
+
var isTest = (path) => /(^|\/)(spec|__tests__)(\/|$)|\.(test|spec)\.[cm]?[jt]sx?$/.test(path), lineOf = (text3, offset) => text3.slice(0, offset).split(`
|
|
14107
14111
|
`).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;
|
|
14108
14112
|
var init_check_flags = __esm(() => {
|
|
14109
14113
|
init_flag_registry_generated();
|
|
@@ -14301,7 +14305,7 @@ async function checkRegistrySync(ports = {}) {
|
|
|
14301
14305
|
}
|
|
14302
14306
|
async function syncFlags(ports = {}) {
|
|
14303
14307
|
const registry = ports.registry ?? registryUrl;
|
|
14304
|
-
const write = ports.write ?? ((target,
|
|
14308
|
+
const write = ports.write ?? ((target, text3) => writeFile4(target, text3));
|
|
14305
14309
|
const log = ports.log ?? console.log;
|
|
14306
14310
|
const error = ports.error ?? console.error;
|
|
14307
14311
|
const devops = await (ports.devops ?? readDevopsFlags)();
|
|
@@ -14538,12 +14542,13 @@ async function runEngineDelegation(delegation, options) {
|
|
|
14538
14542
|
}
|
|
14539
14543
|
|
|
14540
14544
|
// src/main.ts
|
|
14541
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
14545
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, unlinkSync } from "node:fs";
|
|
14542
14546
|
import { mkdir as mkdir4, readFile as readFile7, readdir as readdir3, writeFile as writeFile5 } from "node:fs/promises";
|
|
14543
|
-
import { resolve as resolve11 } from "node:path";
|
|
14547
|
+
import { dirname as dirname10, join as join12, resolve as resolve11 } from "node:path";
|
|
14548
|
+
import { homedir as homedir3 } from "node:os";
|
|
14544
14549
|
import { pathToFileURL } from "node:url";
|
|
14545
14550
|
import { createHash as createHash5 } from "node:crypto";
|
|
14546
|
-
import { spawn as
|
|
14551
|
+
import { spawn as spawn5 } from "node:child_process";
|
|
14547
14552
|
import { createInterface } from "node:readline";
|
|
14548
14553
|
|
|
14549
14554
|
// ../../packages/sdk/typescript/src/operations.generated.ts
|
|
@@ -15598,8 +15603,8 @@ Idempotent. Access tokens revoked while the customer was blocked stay revoked; s
|
|
|
15598
15603
|
{
|
|
15599
15604
|
resource: "agent.agents.events",
|
|
15600
15605
|
method: "stream",
|
|
15601
|
-
summary: "Follow
|
|
15602
|
-
description: "Follow
|
|
15606
|
+
summary: "Follow an agent live",
|
|
15607
|
+
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.",
|
|
15603
15608
|
http: "GET",
|
|
15604
15609
|
path: "/agent/v1/agents/{agent_id}/events/stream",
|
|
15605
15610
|
streaming: "always",
|
|
@@ -15625,6 +15630,40 @@ Idempotent. Access tokens revoked while the customer was blocked stay revoked; s
|
|
|
15625
15630
|
}
|
|
15626
15631
|
]
|
|
15627
15632
|
},
|
|
15633
|
+
{
|
|
15634
|
+
resource: "agent.agents.inbox.letters",
|
|
15635
|
+
method: "list",
|
|
15636
|
+
summary: "List an assume agent's waiting letters",
|
|
15637
|
+
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.",
|
|
15638
|
+
http: "GET",
|
|
15639
|
+
path: "/agent/v1/agents/{agent_id}/inbox/letters",
|
|
15640
|
+
streaming: "no",
|
|
15641
|
+
pagination: false,
|
|
15642
|
+
pathParams: [
|
|
15643
|
+
{
|
|
15644
|
+
name: "agent_id",
|
|
15645
|
+
sdkName: "agent_id",
|
|
15646
|
+
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_…."
|
|
15647
|
+
}
|
|
15648
|
+
],
|
|
15649
|
+
query: [
|
|
15650
|
+
{
|
|
15651
|
+
name: "unread",
|
|
15652
|
+
type: "boolean",
|
|
15653
|
+
enum: [
|
|
15654
|
+
true
|
|
15655
|
+
],
|
|
15656
|
+
required: false,
|
|
15657
|
+
description: "Only true is accepted, which is also the default; this read lists waiting (unread) letters and nothing else."
|
|
15658
|
+
},
|
|
15659
|
+
{
|
|
15660
|
+
name: "limit",
|
|
15661
|
+
type: "integer",
|
|
15662
|
+
required: false,
|
|
15663
|
+
description: "How many of the newest unread letters to return, 1 to 50 (default 20); unread always counts every waiting letter."
|
|
15664
|
+
}
|
|
15665
|
+
]
|
|
15666
|
+
},
|
|
15628
15667
|
{
|
|
15629
15668
|
resource: "agent.agents.unarchive",
|
|
15630
15669
|
method: "create",
|
|
@@ -17231,7 +17270,7 @@ Praxis extension available only on /agent/v1, following Claude Agent SDK getCont
|
|
|
17231
17270
|
resource: "agent.sessions.events",
|
|
17232
17271
|
method: "list",
|
|
17233
17272
|
summary: "List session events",
|
|
17234
|
-
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.",
|
|
17273
|
+
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.",
|
|
17235
17274
|
http: "GET",
|
|
17236
17275
|
path: "/agent/v1/sessions/{session_id}/events",
|
|
17237
17276
|
streaming: "no",
|
|
@@ -17390,6 +17429,26 @@ Available only on /agent/v1. Use the message_id field from own-face events, not
|
|
|
17390
17429
|
]
|
|
17391
17430
|
}
|
|
17392
17431
|
},
|
|
17432
|
+
{
|
|
17433
|
+
resource: "agent.sessions.requests",
|
|
17434
|
+
method: "list",
|
|
17435
|
+
summary: "List Session Requests (Extension)",
|
|
17436
|
+
description: `List the requests a session is waiting on; an end-customer token reads its own session.
|
|
17437
|
+
|
|
17438
|
+
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.`,
|
|
17439
|
+
http: "GET",
|
|
17440
|
+
path: "/agent/v1/sessions/{session_id}/requests",
|
|
17441
|
+
streaming: "no",
|
|
17442
|
+
pagination: false,
|
|
17443
|
+
pathParams: [
|
|
17444
|
+
{
|
|
17445
|
+
name: "session_id",
|
|
17446
|
+
sdkName: "session_id",
|
|
17447
|
+
description: "Session id from session creation or listing."
|
|
17448
|
+
}
|
|
17449
|
+
],
|
|
17450
|
+
query: []
|
|
17451
|
+
},
|
|
17393
17452
|
{
|
|
17394
17453
|
resource: "agent.sessions.resources",
|
|
17395
17454
|
method: "list",
|
|
@@ -29913,7 +29972,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
29913
29972
|
resource: "devops.units",
|
|
29914
29973
|
method: "push",
|
|
29915
29974
|
summary: "Push a unit's branch",
|
|
29916
|
-
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
|
|
29975
|
+
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.",
|
|
29917
29976
|
http: "POST",
|
|
29918
29977
|
path: "/devops/v1/units/{id}:push",
|
|
29919
29978
|
streaming: "no",
|
|
@@ -31819,11 +31878,57 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
31819
31878
|
]
|
|
31820
31879
|
}
|
|
31821
31880
|
},
|
|
31881
|
+
{
|
|
31882
|
+
resource: "media.libraries.assets.align",
|
|
31883
|
+
method: "create",
|
|
31884
|
+
summary: "Align asset",
|
|
31885
|
+
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}.",
|
|
31886
|
+
http: "POST",
|
|
31887
|
+
path: "/media/v1/libraries/{library_id}/assets/{asset_id}/align",
|
|
31888
|
+
streaming: "no",
|
|
31889
|
+
pagination: false,
|
|
31890
|
+
pathParams: [
|
|
31891
|
+
{
|
|
31892
|
+
name: "library_id",
|
|
31893
|
+
sdkName: "library_id",
|
|
31894
|
+
description: "Library ID returned by creation."
|
|
31895
|
+
},
|
|
31896
|
+
{
|
|
31897
|
+
name: "asset_id",
|
|
31898
|
+
sdkName: "asset_id",
|
|
31899
|
+
description: "32-character asset ID."
|
|
31900
|
+
}
|
|
31901
|
+
],
|
|
31902
|
+
query: [],
|
|
31903
|
+
body: {
|
|
31904
|
+
required: true,
|
|
31905
|
+
fields: [
|
|
31906
|
+
{
|
|
31907
|
+
name: "reference_asset_id",
|
|
31908
|
+
type: "string",
|
|
31909
|
+
required: true,
|
|
31910
|
+
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."
|
|
31911
|
+
},
|
|
31912
|
+
{
|
|
31913
|
+
name: "max_offset_seconds",
|
|
31914
|
+
type: "number",
|
|
31915
|
+
required: false,
|
|
31916
|
+
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."
|
|
31917
|
+
},
|
|
31918
|
+
{
|
|
31919
|
+
name: "idempotency_key",
|
|
31920
|
+
type: "string",
|
|
31921
|
+
required: false,
|
|
31922
|
+
description: "Stable key so a retried request reuses the same job instead of analysing and charging again; reusing it with different content is rejected."
|
|
31923
|
+
}
|
|
31924
|
+
]
|
|
31925
|
+
}
|
|
31926
|
+
},
|
|
31822
31927
|
{
|
|
31823
31928
|
resource: "media.assets",
|
|
31824
31929
|
method: "edit",
|
|
31825
31930
|
summary: "Edit asset",
|
|
31826
|
-
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\"}}.",
|
|
31931
|
+
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\"}}.",
|
|
31827
31932
|
http: "POST",
|
|
31828
31933
|
path: "/media/v1/libraries/{library_id}/assets/{asset_id}/edits",
|
|
31829
31934
|
streaming: "no",
|
|
@@ -31848,7 +31953,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
31848
31953
|
name: "operation",
|
|
31849
31954
|
type: "object",
|
|
31850
31955
|
required: true,
|
|
31851
|
-
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."
|
|
31956
|
+
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."
|
|
31852
31957
|
},
|
|
31853
31958
|
{
|
|
31854
31959
|
name: "model",
|
|
@@ -34881,6 +34986,7 @@ for more details.`
|
|
|
34881
34986
|
"openai.images.generations",
|
|
34882
34987
|
"openai.responses",
|
|
34883
34988
|
"openai.videos",
|
|
34989
|
+
"praxis.media.process",
|
|
34884
34990
|
"praxis.video.matting",
|
|
34885
34991
|
"typesafe.systemone",
|
|
34886
34992
|
"volcengine.music",
|
|
@@ -40556,6 +40662,131 @@ for more details.`
|
|
|
40556
40662
|
]
|
|
40557
40663
|
}
|
|
40558
40664
|
},
|
|
40665
|
+
{
|
|
40666
|
+
resource: "share.permissions",
|
|
40667
|
+
method: "list",
|
|
40668
|
+
summary: "List shares",
|
|
40669
|
+
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.",
|
|
40670
|
+
http: "GET",
|
|
40671
|
+
path: "/share/v1/permissions",
|
|
40672
|
+
streaming: "no",
|
|
40673
|
+
pagination: false,
|
|
40674
|
+
pathParams: [],
|
|
40675
|
+
query: [
|
|
40676
|
+
{
|
|
40677
|
+
name: "resource_type",
|
|
40678
|
+
type: "string",
|
|
40679
|
+
enum: [
|
|
40680
|
+
"file",
|
|
40681
|
+
"artifact",
|
|
40682
|
+
"canvas",
|
|
40683
|
+
"media_asset"
|
|
40684
|
+
],
|
|
40685
|
+
required: false,
|
|
40686
|
+
description: "Only shares of this object type; file, canvas and media_asset create today."
|
|
40687
|
+
},
|
|
40688
|
+
{
|
|
40689
|
+
name: "resource_id",
|
|
40690
|
+
type: "string",
|
|
40691
|
+
required: false,
|
|
40692
|
+
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."
|
|
40693
|
+
},
|
|
40694
|
+
{
|
|
40695
|
+
name: "status",
|
|
40696
|
+
type: "string",
|
|
40697
|
+
enum: [
|
|
40698
|
+
"active",
|
|
40699
|
+
"expired",
|
|
40700
|
+
"revoked"
|
|
40701
|
+
],
|
|
40702
|
+
required: false,
|
|
40703
|
+
description: "Only shares in this state; omit to list every state."
|
|
40704
|
+
},
|
|
40705
|
+
{
|
|
40706
|
+
name: "page_size",
|
|
40707
|
+
type: "integer",
|
|
40708
|
+
required: false,
|
|
40709
|
+
description: "Maximum shares in one page, from 1 to 100; defaults to 50."
|
|
40710
|
+
},
|
|
40711
|
+
{
|
|
40712
|
+
name: "page_token",
|
|
40713
|
+
type: "string",
|
|
40714
|
+
required: false,
|
|
40715
|
+
description: "Opaque next_page_token from the preceding page with the same filters; omit on the first request."
|
|
40716
|
+
}
|
|
40717
|
+
]
|
|
40718
|
+
},
|
|
40719
|
+
{
|
|
40720
|
+
resource: "share.permissions",
|
|
40721
|
+
method: "create",
|
|
40722
|
+
summary: "Create share",
|
|
40723
|
+
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.",
|
|
40724
|
+
http: "POST",
|
|
40725
|
+
path: "/share/v1/permissions",
|
|
40726
|
+
streaming: "no",
|
|
40727
|
+
pagination: false,
|
|
40728
|
+
pathParams: [],
|
|
40729
|
+
query: [],
|
|
40730
|
+
body: {
|
|
40731
|
+
required: true,
|
|
40732
|
+
fields: [
|
|
40733
|
+
{
|
|
40734
|
+
name: "resource",
|
|
40735
|
+
type: "object",
|
|
40736
|
+
required: true,
|
|
40737
|
+
description: "The object a share exposes, named by a type and an id."
|
|
40738
|
+
},
|
|
40739
|
+
{
|
|
40740
|
+
name: "expire_time",
|
|
40741
|
+
type: "string",
|
|
40742
|
+
required: false,
|
|
40743
|
+
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."
|
|
40744
|
+
},
|
|
40745
|
+
{
|
|
40746
|
+
name: "prevents_download",
|
|
40747
|
+
type: "boolean",
|
|
40748
|
+
required: false,
|
|
40749
|
+
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."
|
|
40750
|
+
}
|
|
40751
|
+
]
|
|
40752
|
+
}
|
|
40753
|
+
},
|
|
40754
|
+
{
|
|
40755
|
+
resource: "share.permissions",
|
|
40756
|
+
method: "delete",
|
|
40757
|
+
summary: "Delete share",
|
|
40758
|
+
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.",
|
|
40759
|
+
http: "DELETE",
|
|
40760
|
+
path: "/share/v1/permissions/{id}",
|
|
40761
|
+
streaming: "no",
|
|
40762
|
+
pagination: false,
|
|
40763
|
+
pathParams: [
|
|
40764
|
+
{
|
|
40765
|
+
name: "id",
|
|
40766
|
+
sdkName: "id",
|
|
40767
|
+
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."
|
|
40768
|
+
}
|
|
40769
|
+
],
|
|
40770
|
+
query: []
|
|
40771
|
+
},
|
|
40772
|
+
{
|
|
40773
|
+
resource: "share.permissions",
|
|
40774
|
+
method: "retrieve",
|
|
40775
|
+
summary: "Retrieve share",
|
|
40776
|
+
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.",
|
|
40777
|
+
http: "GET",
|
|
40778
|
+
path: "/share/v1/permissions/{id}",
|
|
40779
|
+
streaming: "no",
|
|
40780
|
+
pagination: false,
|
|
40781
|
+
pathParams: [
|
|
40782
|
+
{
|
|
40783
|
+
name: "id",
|
|
40784
|
+
sdkName: "id",
|
|
40785
|
+
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."
|
|
40786
|
+
}
|
|
40787
|
+
],
|
|
40788
|
+
query: []
|
|
40789
|
+
},
|
|
40559
40790
|
{
|
|
40560
40791
|
resource: "studio.codexes",
|
|
40561
40792
|
method: "list",
|
|
@@ -47030,6 +47261,19 @@ var getAgentConsolidation = (options) => (options.client ?? client).get({
|
|
|
47030
47261
|
url: "/agent/v1/agents/{agent_id}/consolidations/{consolidation_id}",
|
|
47031
47262
|
...options
|
|
47032
47263
|
});
|
|
47264
|
+
var listAgentInboxLetters = (options) => (options.client ?? client).get({
|
|
47265
|
+
security: [{
|
|
47266
|
+
key: "BearerAuth",
|
|
47267
|
+
scheme: "bearer",
|
|
47268
|
+
type: "http"
|
|
47269
|
+
}, {
|
|
47270
|
+
key: "ApiKeyAuth",
|
|
47271
|
+
name: "X-API-Key",
|
|
47272
|
+
type: "apiKey"
|
|
47273
|
+
}],
|
|
47274
|
+
url: "/agent/v1/agents/{agent_id}/inbox/letters",
|
|
47275
|
+
...options
|
|
47276
|
+
});
|
|
47033
47277
|
var applyAgentVersion = (options) => (options.client ?? client).post({
|
|
47034
47278
|
security: [{
|
|
47035
47279
|
key: "BearerAuth",
|
|
@@ -47500,6 +47744,19 @@ var createSessionArtifactContentUrl = (options) => (options.client ?? client).po
|
|
|
47500
47744
|
...options.headers
|
|
47501
47745
|
}
|
|
47502
47746
|
});
|
|
47747
|
+
var listSessionRequests = (options) => (options.client ?? client).get({
|
|
47748
|
+
security: [{
|
|
47749
|
+
key: "BearerAuth",
|
|
47750
|
+
scheme: "bearer",
|
|
47751
|
+
type: "http"
|
|
47752
|
+
}, {
|
|
47753
|
+
key: "ApiKeyAuth",
|
|
47754
|
+
name: "X-API-Key",
|
|
47755
|
+
type: "apiKey"
|
|
47756
|
+
}],
|
|
47757
|
+
url: "/agent/v1/sessions/{session_id}/requests",
|
|
47758
|
+
...options
|
|
47759
|
+
});
|
|
47503
47760
|
var listSessionBackgroundTasks = (options) => (options.client ?? client).get({
|
|
47504
47761
|
security: [{
|
|
47505
47762
|
key: "BearerAuth",
|
|
@@ -54610,6 +54867,19 @@ var mediaGetGenerationCapabilities = (options) => (options?.client ?? client).ge
|
|
|
54610
54867
|
url: "/media/v1/generation/capabilities",
|
|
54611
54868
|
...options
|
|
54612
54869
|
});
|
|
54870
|
+
var mediaAlignAsset = (options) => (options.client ?? client).post({
|
|
54871
|
+
security: [{
|
|
54872
|
+
key: "media-BearerAuth",
|
|
54873
|
+
scheme: "bearer",
|
|
54874
|
+
type: "http"
|
|
54875
|
+
}],
|
|
54876
|
+
url: "/media/v1/libraries/{library_id}/assets/{asset_id}/align",
|
|
54877
|
+
...options,
|
|
54878
|
+
headers: {
|
|
54879
|
+
"Content-Type": "application/json",
|
|
54880
|
+
...options.headers
|
|
54881
|
+
}
|
|
54882
|
+
});
|
|
54613
54883
|
var ontologyListTypes = (options) => (options?.client ?? client).get({
|
|
54614
54884
|
security: [{
|
|
54615
54885
|
key: "ontology-bearerAuth",
|
|
@@ -55742,6 +56012,46 @@ var searchMap = (options) => (options.client ?? client).post({
|
|
|
55742
56012
|
...options.headers
|
|
55743
56013
|
}
|
|
55744
56014
|
});
|
|
56015
|
+
var shareListPermissions = (options) => (options?.client ?? client).get({
|
|
56016
|
+
security: [{
|
|
56017
|
+
key: "share-bearerAuth",
|
|
56018
|
+
scheme: "bearer",
|
|
56019
|
+
type: "http"
|
|
56020
|
+
}],
|
|
56021
|
+
url: "/share/v1/permissions",
|
|
56022
|
+
...options
|
|
56023
|
+
});
|
|
56024
|
+
var shareCreatePermission = (options) => (options.client ?? client).post({
|
|
56025
|
+
security: [{
|
|
56026
|
+
key: "share-bearerAuth",
|
|
56027
|
+
scheme: "bearer",
|
|
56028
|
+
type: "http"
|
|
56029
|
+
}],
|
|
56030
|
+
url: "/share/v1/permissions",
|
|
56031
|
+
...options,
|
|
56032
|
+
headers: {
|
|
56033
|
+
"Content-Type": "application/json",
|
|
56034
|
+
...options.headers
|
|
56035
|
+
}
|
|
56036
|
+
});
|
|
56037
|
+
var shareDeletePermission = (options) => (options.client ?? client).delete({
|
|
56038
|
+
security: [{
|
|
56039
|
+
key: "share-bearerAuth",
|
|
56040
|
+
scheme: "bearer",
|
|
56041
|
+
type: "http"
|
|
56042
|
+
}],
|
|
56043
|
+
url: "/share/v1/permissions/{id}",
|
|
56044
|
+
...options
|
|
56045
|
+
});
|
|
56046
|
+
var shareRetrievePermission = (options) => (options.client ?? client).get({
|
|
56047
|
+
security: [{
|
|
56048
|
+
key: "share-bearerAuth",
|
|
56049
|
+
scheme: "bearer",
|
|
56050
|
+
type: "http"
|
|
56051
|
+
}],
|
|
56052
|
+
url: "/share/v1/permissions/{id}",
|
|
56053
|
+
...options
|
|
56054
|
+
});
|
|
55745
56055
|
var studioGenresList = (options) => (options?.client ?? client).get({
|
|
55746
56056
|
security: [{
|
|
55747
56057
|
key: "BearerAuth",
|
|
@@ -57778,6 +58088,11 @@ function createAgent(transport) {
|
|
|
57778
58088
|
send: bind(transport, sendAgentEvents),
|
|
57779
58089
|
stream: bindStream(transport, streamAgentEvents)
|
|
57780
58090
|
},
|
|
58091
|
+
inbox: {
|
|
58092
|
+
letters: {
|
|
58093
|
+
list: bind(transport, listAgentInboxLetters)
|
|
58094
|
+
}
|
|
58095
|
+
},
|
|
57781
58096
|
list: bind(transport, agentsList),
|
|
57782
58097
|
retrieve: bind(transport, agentsRetrieve),
|
|
57783
58098
|
retrieveAppearance: bind(transport, getAgentAppearance),
|
|
@@ -57866,6 +58181,9 @@ function createAgent(transport) {
|
|
|
57866
58181
|
},
|
|
57867
58182
|
fork: bind(transport, forkSession),
|
|
57868
58183
|
list: bind(transport, sessionsList),
|
|
58184
|
+
requests: {
|
|
58185
|
+
list: bind(transport, listSessionRequests)
|
|
58186
|
+
},
|
|
57869
58187
|
resources: {
|
|
57870
58188
|
create: bind(transport, sessionsResourcesAdd),
|
|
57871
58189
|
delete: bind(transport, aliasOperation(sessionsResourcesDelete, { query: { session_id: "query_session_id" } })),
|
|
@@ -58583,6 +58901,9 @@ function createMedia(transport) {
|
|
|
58583
58901
|
},
|
|
58584
58902
|
libraries: {
|
|
58585
58903
|
assets: {
|
|
58904
|
+
align: {
|
|
58905
|
+
create: bind(transport, mediaAlignAsset)
|
|
58906
|
+
},
|
|
58586
58907
|
batch: bind(transport, mediaBatchAssets),
|
|
58587
58908
|
create: bind(transport, (options) => mediaUploadAsset({ ...options, bodySerializer: multipartBodySerializer, headers: { "Content-Type": null, ...options.headers } })),
|
|
58588
58909
|
delete: bind(transport, mediaDeleteAsset),
|
|
@@ -59024,6 +59345,16 @@ function createSearch(transport) {
|
|
|
59024
59345
|
}
|
|
59025
59346
|
};
|
|
59026
59347
|
}
|
|
59348
|
+
function createShare(transport) {
|
|
59349
|
+
return {
|
|
59350
|
+
permissions: {
|
|
59351
|
+
create: bind(transport, shareCreatePermission),
|
|
59352
|
+
delete: bind(transport, shareDeletePermission),
|
|
59353
|
+
list: bind(transport, shareListPermissions),
|
|
59354
|
+
retrieve: bind(transport, shareRetrievePermission)
|
|
59355
|
+
}
|
|
59356
|
+
};
|
|
59357
|
+
}
|
|
59027
59358
|
function createStudio(transport) {
|
|
59028
59359
|
return {
|
|
59029
59360
|
codexes: {
|
|
@@ -59294,6 +59625,7 @@ var resourceFactories = {
|
|
|
59294
59625
|
organization: createOrganization,
|
|
59295
59626
|
sandbox: createSandbox,
|
|
59296
59627
|
search: createSearch,
|
|
59628
|
+
share: createShare,
|
|
59297
59629
|
studio: createStudio,
|
|
59298
59630
|
ticket: createTicket,
|
|
59299
59631
|
vault: createVault
|
|
@@ -61611,6 +61943,13 @@ var workflows = [
|
|
|
61611
61943
|
platform: "praxis api devops project change create — the platform creates and names a Change; the CLI only lands its branch (ADR-125 §5).",
|
|
61612
61944
|
docs: "https://docs.deepraxis.com/docs/cli"
|
|
61613
61945
|
},
|
|
61946
|
+
{
|
|
61947
|
+
words: ["agent", "events", "wait"],
|
|
61948
|
+
usage: "agent events wait [--timeout <seconds>]",
|
|
61949
|
+
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.",
|
|
61950
|
+
example: "PRAXIS_ASSUME_AGENT=R1M9TQ2X praxis agent events wait",
|
|
61951
|
+
network: "online"
|
|
61952
|
+
},
|
|
61614
61953
|
{ 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"' },
|
|
61615
61954
|
{ words: ["skill"], usage: "skill [--install <dir>]", summary: "Print the AI skill, or write <dir>/praxis-cli/SKILL.md." },
|
|
61616
61955
|
{
|
|
@@ -63203,6 +63542,101 @@ function wranglerEdges(nodes) {
|
|
|
63203
63542
|
}
|
|
63204
63543
|
return edges;
|
|
63205
63544
|
}
|
|
63545
|
+
// ../../packages/praxis/deploy-core/src/lambda-function.ts
|
|
63546
|
+
var LAMBDA_FUNCTIONS_ROOT = "services/lambda/functions";
|
|
63547
|
+
var UPSTREAM = "aliyun-fc";
|
|
63548
|
+
var RECIPE_PATH = /^services\/lambda\/functions\/([^/]+)\/function\.json$/;
|
|
63549
|
+
var isText = (value) => typeof value === "string" && value !== "";
|
|
63550
|
+
var isCount = (value, min, max) => typeof value === "number" && Number.isInteger(value) && value >= min && value <= max;
|
|
63551
|
+
function lambdaFunctionOf(text) {
|
|
63552
|
+
const parsed = text === null ? null : parseJsonc2(text);
|
|
63553
|
+
if (parsed === null)
|
|
63554
|
+
return null;
|
|
63555
|
+
if (!isText(parsed.name) || !isText(parsed.upstream))
|
|
63556
|
+
return null;
|
|
63557
|
+
if (!Array.isArray(parsed.regions) || parsed.regions.length === 0 || !parsed.regions.every(isText))
|
|
63558
|
+
return null;
|
|
63559
|
+
if (parsed.gpu !== undefined && !isText(parsed.gpu))
|
|
63560
|
+
return null;
|
|
63561
|
+
if (!isCount(parsed.cpu, 1, 256))
|
|
63562
|
+
return null;
|
|
63563
|
+
if (!isCount(parsed.memoryMb, 128, 32 * 1024))
|
|
63564
|
+
return null;
|
|
63565
|
+
if (!isCount(parsed.timeoutSeconds, 1, 24 * 3600))
|
|
63566
|
+
return null;
|
|
63567
|
+
if (!isCount(parsed.concurrency, 1, 1024))
|
|
63568
|
+
return null;
|
|
63569
|
+
return {
|
|
63570
|
+
name: parsed.name,
|
|
63571
|
+
upstream: parsed.upstream,
|
|
63572
|
+
regions: [...parsed.regions],
|
|
63573
|
+
...parsed.gpu === undefined ? {} : { gpu: parsed.gpu },
|
|
63574
|
+
cpu: parsed.cpu,
|
|
63575
|
+
memoryMb: parsed.memoryMb,
|
|
63576
|
+
timeoutSeconds: parsed.timeoutSeconds,
|
|
63577
|
+
concurrency: parsed.concurrency
|
|
63578
|
+
};
|
|
63579
|
+
}
|
|
63580
|
+
function lambdaFunctionTarget(recipe) {
|
|
63581
|
+
return { path: `${LAMBDA_FUNCTIONS_ROOT}/${recipe.name}`, name: `lambda-${recipe.name}` };
|
|
63582
|
+
}
|
|
63583
|
+
function lambdaFunctionOwner(path) {
|
|
63584
|
+
return path.split("/").slice(0, -2).join("/");
|
|
63585
|
+
}
|
|
63586
|
+
async function scanRecipes(facts) {
|
|
63587
|
+
const found = [];
|
|
63588
|
+
const warnings = [];
|
|
63589
|
+
for (const path of [...facts.tree].sort()) {
|
|
63590
|
+
const match = RECIPE_PATH.exec(path);
|
|
63591
|
+
if (match === null)
|
|
63592
|
+
continue;
|
|
63593
|
+
const dir = path.slice(0, -"/function.json".length);
|
|
63594
|
+
const recipe = lambdaFunctionOf(await facts.read(path));
|
|
63595
|
+
if (recipe === null) {
|
|
63596
|
+
warnings.push(`${dir}: function.json is not a recipe`);
|
|
63597
|
+
continue;
|
|
63598
|
+
}
|
|
63599
|
+
if (recipe.upstream !== UPSTREAM)
|
|
63600
|
+
continue;
|
|
63601
|
+
if (recipe.name !== match[1]) {
|
|
63602
|
+
warnings.push(`${dir}: function.json names ${JSON.stringify(recipe.name)}, not the directory name`);
|
|
63603
|
+
continue;
|
|
63604
|
+
}
|
|
63605
|
+
found.push(recipe);
|
|
63606
|
+
}
|
|
63607
|
+
return { found, warnings };
|
|
63608
|
+
}
|
|
63609
|
+
function lambdaFunctionProvider(_options = {}) {
|
|
63610
|
+
return {
|
|
63611
|
+
id: "lambda-function",
|
|
63612
|
+
async detect(facts) {
|
|
63613
|
+
return (await scanRecipes(facts)).found.length > 0 ? "certain" : "none";
|
|
63614
|
+
},
|
|
63615
|
+
async plan(facts, partial) {
|
|
63616
|
+
const claimed = new Set(partial.targets.map((target) => target.path));
|
|
63617
|
+
const scan = await scanRecipes(facts);
|
|
63618
|
+
const targets = [];
|
|
63619
|
+
const byOwner = new Map;
|
|
63620
|
+
for (const recipe of scan.found) {
|
|
63621
|
+
const { path, name } = lambdaFunctionTarget(recipe);
|
|
63622
|
+
if (claimed.has(path))
|
|
63623
|
+
continue;
|
|
63624
|
+
targets.push({ path, name, destination: "aliyun-fc", production: true, onTrain: true });
|
|
63625
|
+
const owner = lambdaFunctionOwner(path);
|
|
63626
|
+
byOwner.set(owner, [...byOwner.get(owner) ?? [], path]);
|
|
63627
|
+
}
|
|
63628
|
+
const refined = partial.targets.map((target) => {
|
|
63629
|
+
const paths = byOwner.get(target.path);
|
|
63630
|
+
return paths === undefined ? target : { ...target, dependsOn: [...new Set([...target.dependsOn ?? [], ...paths])] };
|
|
63631
|
+
});
|
|
63632
|
+
return {
|
|
63633
|
+
targets: [...refined, ...targets],
|
|
63634
|
+
...scan.warnings.length === 0 ? {} : { warnings: [...partial.warnings ?? [], ...scan.warnings] }
|
|
63635
|
+
};
|
|
63636
|
+
}
|
|
63637
|
+
};
|
|
63638
|
+
}
|
|
63639
|
+
var lambdaFunction = lambdaFunctionProvider();
|
|
63206
63640
|
// ../../packages/praxis/deploy-core/src/package-manifest.ts
|
|
63207
63641
|
function packageManifestOf(text) {
|
|
63208
63642
|
const parsed = text === null ? null : parseJsonc2(text);
|
|
@@ -63537,7 +63971,11 @@ function workspaceCloudflareProvider(options = {}) {
|
|
|
63537
63971
|
};
|
|
63538
63972
|
}
|
|
63539
63973
|
var workspaceCloudflare = workspaceCloudflareProvider();
|
|
63540
|
-
var BUILTIN_PROVIDERS = [
|
|
63974
|
+
var BUILTIN_PROVIDERS = [
|
|
63975
|
+
workspaceCloudflare,
|
|
63976
|
+
workspaceNpmProvider(),
|
|
63977
|
+
lambdaFunctionProvider()
|
|
63978
|
+
];
|
|
63541
63979
|
function directoriesOfPackageNames(workspaces) {
|
|
63542
63980
|
const byName = new Map;
|
|
63543
63981
|
for (const workspace of workspaces)
|
|
@@ -63564,15 +64002,23 @@ function workspaceClosureOf(target, byName, dependenciesOf) {
|
|
|
63564
64002
|
// ../../packages/praxis/deploy-core/src/plan.ts
|
|
63565
64003
|
async function planRepository(facts, providers = BUILTIN_PROVIDERS, options = {}) {
|
|
63566
64004
|
let partial = { targets: [] };
|
|
64005
|
+
const warnings = [];
|
|
63567
64006
|
for (const provider of providers) {
|
|
63568
64007
|
const confidence = await provider.detect(facts);
|
|
63569
64008
|
if (confidence === "none")
|
|
63570
64009
|
continue;
|
|
63571
64010
|
partial = await provider.plan(facts, partial);
|
|
64011
|
+
for (const warning of partial.warnings ?? [])
|
|
64012
|
+
if (!warnings.includes(warning))
|
|
64013
|
+
warnings.push(warning);
|
|
63572
64014
|
}
|
|
63573
64015
|
const drafts = partial.targets.filter((draft) => draft.deploy !== false);
|
|
63574
64016
|
const workspaces = await readWorkspaces(facts, options);
|
|
63575
|
-
return {
|
|
64017
|
+
return {
|
|
64018
|
+
commit: facts.commit,
|
|
64019
|
+
targets: closePlan(drafts, workspaces),
|
|
64020
|
+
...warnings.length === 0 ? {} : { warnings }
|
|
64021
|
+
};
|
|
63576
64022
|
}
|
|
63577
64023
|
function closePlan(drafts, workspaces) {
|
|
63578
64024
|
const configOf = new Map(workspaces.map((workspace) => [workspace.dir, workspace.config]));
|
|
@@ -63594,7 +64040,7 @@ function closePlan(drafts, workspaces) {
|
|
|
63594
64040
|
path: draft.path,
|
|
63595
64041
|
name: draft.name,
|
|
63596
64042
|
destination: draft.destination,
|
|
63597
|
-
dependsOn: edges.get(draft.path) ?? [],
|
|
64043
|
+
dependsOn: [...new Set([...edges.get(draft.path) ?? [], ...draft.dependsOn ?? []])],
|
|
63598
64044
|
...draft.environments === undefined ? {} : { environments: draft.environments },
|
|
63599
64045
|
production: draft.production === true,
|
|
63600
64046
|
onTrain: draft.onTrain !== false,
|
|
@@ -65590,6 +66036,30 @@ function bunTestRun(packagePath, code, output) {
|
|
|
65590
66036
|
}
|
|
65591
66037
|
|
|
65592
66038
|
// src/commands/devops-test.ts
|
|
66039
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
66040
|
+
var CACHE_OFF_REEXEC_ENV = "PRAXIS_DEVOPS_TEST_CACHE_OFF";
|
|
66041
|
+
function needsCacheOffReexec(env) {
|
|
66042
|
+
return env.BUN_RUNTIME_TRANSPILER_CACHE_PATH !== "0" && !env[CACHE_OFF_REEXEC_ENV];
|
|
66043
|
+
}
|
|
66044
|
+
function isDevopsTestRun(words) {
|
|
66045
|
+
return words.join(" ") === "devops test";
|
|
66046
|
+
}
|
|
66047
|
+
function spawnInherit(cmd, args, options) {
|
|
66048
|
+
return new Promise((resolveCode) => {
|
|
66049
|
+
const child = spawn4(cmd, [...args], { cwd: options.cwd, env: options.env, stdio: "inherit" });
|
|
66050
|
+
child.once("error", (error) => {
|
|
66051
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
66052
|
+
resolveCode(1);
|
|
66053
|
+
});
|
|
66054
|
+
child.once("close", (code) => resolveCode(code ?? 1));
|
|
66055
|
+
});
|
|
66056
|
+
}
|
|
66057
|
+
function reexecWithCacheOff(options = {}) {
|
|
66058
|
+
return (options.spawn ?? spawnInherit)(process.execPath, options.argv ?? process.argv.slice(1), {
|
|
66059
|
+
cwd: options.cwd ?? process.cwd(),
|
|
66060
|
+
env: { ...options.env ?? process.env, BUN_RUNTIME_TRANSPILER_CACHE_PATH: "0", [CACHE_OFF_REEXEC_ENV]: "1" }
|
|
66061
|
+
});
|
|
66062
|
+
}
|
|
65593
66063
|
async function devopsTest(flags, paths, ports) {
|
|
65594
66064
|
const plan = planTest(flags, paths);
|
|
65595
66065
|
if (plan.mode.kind === "affected")
|
|
@@ -65860,8 +66330,8 @@ async function localEngine(cwd) {
|
|
|
65860
66330
|
})
|
|
65861
66331
|
};
|
|
65862
66332
|
}
|
|
65863
|
-
async function localCheckout(cwd,
|
|
65864
|
-
const git2 = (args) =>
|
|
66333
|
+
async function localCheckout(cwd, spawn5) {
|
|
66334
|
+
const git2 = (args) => spawn5("git", [...args], { cwd });
|
|
65865
66335
|
const required = async (args) => {
|
|
65866
66336
|
const result = await git2(args);
|
|
65867
66337
|
if (result.code !== 0)
|
|
@@ -65912,7 +66382,7 @@ async function localCheckout(cwd, spawn4) {
|
|
|
65912
66382
|
await walk(packagePath);
|
|
65913
66383
|
return files;
|
|
65914
66384
|
},
|
|
65915
|
-
runTests: (packagePath, files) =>
|
|
66385
|
+
runTests: (packagePath, files) => spawn5("nice", ["-n", "10", "bun", "test", ...files], { cwd: packagePath })
|
|
65916
66386
|
};
|
|
65917
66387
|
}
|
|
65918
66388
|
async function withEngineStdoutOnStderr(body) {
|
|
@@ -68870,6 +69340,7 @@ var FILE_ID = /^file-/;
|
|
|
68870
69340
|
var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
68871
69341
|
var isImage = (node2) => node2.type === "image" && typeof node2.url === "string";
|
|
68872
69342
|
var isRef = (node2) => node2.type === "ref" && typeof node2.ref === "string";
|
|
69343
|
+
var NODE_TYPES = new Set(Object.keys(KNOWN_PROPS));
|
|
68873
69344
|
function visit2(value, nodeId, fn) {
|
|
68874
69345
|
if (Array.isArray(value)) {
|
|
68875
69346
|
for (const item of value)
|
|
@@ -69063,6 +69534,8 @@ var warningLine = (warning) => {
|
|
|
69063
69534
|
return `${warning.code}: ${warning.ref} at ${warning.nodeId}`;
|
|
69064
69535
|
case "FRAME_NOT_FOUND":
|
|
69065
69536
|
return `${warning.code}: ${warning.id}`;
|
|
69537
|
+
case "IMAGE_FILE_NOT_FOUND":
|
|
69538
|
+
return `${warning.code}: ${warning.url} (the platform holds no such file) at ${warning.nodeId}`;
|
|
69066
69539
|
default:
|
|
69067
69540
|
return `${warning.code}: ${warning.url}`;
|
|
69068
69541
|
}
|
|
@@ -69170,6 +69643,268 @@ async function canvasImport(args, ports) {
|
|
|
69170
69643
|
return 0;
|
|
69171
69644
|
}
|
|
69172
69645
|
|
|
69646
|
+
// src/commands/events-wait.ts
|
|
69647
|
+
var DEFAULT_AGENT = "R1M9TQ2X";
|
|
69648
|
+
var BASE_BACKOFF_MS = 1000;
|
|
69649
|
+
var MAX_BACKOFF_MS = 60000;
|
|
69650
|
+
var NOTICE_NAMED = 5;
|
|
69651
|
+
var ANNOUNCED_KEEP = 500;
|
|
69652
|
+
function assumeAgentOf(env) {
|
|
69653
|
+
return env.PRAXIS_ASSUME_AGENT?.trim() || DEFAULT_AGENT;
|
|
69654
|
+
}
|
|
69655
|
+
function sessionOf(raw) {
|
|
69656
|
+
if (raw === undefined)
|
|
69657
|
+
return null;
|
|
69658
|
+
const session = raw.trim();
|
|
69659
|
+
if (!/^[A-Za-z0-9_-]{1,128}$/.test(session))
|
|
69660
|
+
throw new Error("--session takes the Claude Code session id (letters, digits, - and _)");
|
|
69661
|
+
return session;
|
|
69662
|
+
}
|
|
69663
|
+
var keyPart = (part) => part.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
69664
|
+
function waitKeyOf(env, agent, session) {
|
|
69665
|
+
return [env, agent, ...session === null ? [] : [session]].map(keyPart).join("-");
|
|
69666
|
+
}
|
|
69667
|
+
function pidOf(raw) {
|
|
69668
|
+
const pid = raw === null ? NaN : Number(raw.trim());
|
|
69669
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
69670
|
+
}
|
|
69671
|
+
function lockDecision(recorded, self, probe) {
|
|
69672
|
+
if (recorded === null || recorded === self || probe === null || !probe.alive)
|
|
69673
|
+
return { kind: "take" };
|
|
69674
|
+
if (!/events\s+wait/.test(probe.command))
|
|
69675
|
+
return { kind: "take" };
|
|
69676
|
+
if (probe.ppid === 1)
|
|
69677
|
+
return { kind: "replace", pid: recorded };
|
|
69678
|
+
return { kind: "refuse", pid: recorded };
|
|
69679
|
+
}
|
|
69680
|
+
function alreadyWaitingNotice(pid) {
|
|
69681
|
+
return `本会话已有 praxis agent events wait 在后台等待(pid ${pid}),不用再启动。`;
|
|
69682
|
+
}
|
|
69683
|
+
async function acquireWaitLock(ports) {
|
|
69684
|
+
for (let attempt = 0;attempt < 3; attempt++) {
|
|
69685
|
+
const recorded = pidOf(await ports.readPid());
|
|
69686
|
+
if (recorded === null) {
|
|
69687
|
+
if (await ports.createPid(String(ports.self)))
|
|
69688
|
+
return null;
|
|
69689
|
+
continue;
|
|
69690
|
+
}
|
|
69691
|
+
const decision = lockDecision(recorded, ports.self, await ports.probe(recorded));
|
|
69692
|
+
if (decision.kind === "refuse")
|
|
69693
|
+
return decision.pid;
|
|
69694
|
+
if (decision.kind === "replace")
|
|
69695
|
+
ports.terminate(decision.pid);
|
|
69696
|
+
await ports.replacePid(String(ports.self));
|
|
69697
|
+
const holder = pidOf(await ports.readPid());
|
|
69698
|
+
return holder === ports.self || holder === null ? null : holder;
|
|
69699
|
+
}
|
|
69700
|
+
return pidOf(await ports.readPid());
|
|
69701
|
+
}
|
|
69702
|
+
function timeoutMsOf(raw) {
|
|
69703
|
+
if (raw === undefined)
|
|
69704
|
+
return null;
|
|
69705
|
+
const seconds = Number(raw);
|
|
69706
|
+
if (!/^\d+(\.\d+)?$/.test(raw.trim()) || !Number.isFinite(seconds) || seconds <= 0)
|
|
69707
|
+
throw new Error("--timeout takes a positive number of seconds");
|
|
69708
|
+
return Math.round(seconds * 1000);
|
|
69709
|
+
}
|
|
69710
|
+
function backoffMs(failures) {
|
|
69711
|
+
if (failures <= 0)
|
|
69712
|
+
return 0;
|
|
69713
|
+
return Math.min(MAX_BACKOFF_MS, BASE_BACKOFF_MS * 2 ** Math.min(failures - 1, 16));
|
|
69714
|
+
}
|
|
69715
|
+
function inboxLettersUrl(apiUrl, agent) {
|
|
69716
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/inbox/letters?unread=true&limit=20`;
|
|
69717
|
+
}
|
|
69718
|
+
function eventsStreamUrl(apiUrl, agent) {
|
|
69719
|
+
return `${apiUrl}/agent/v1/agents/${encodeURIComponent(agent)}/events/stream`;
|
|
69720
|
+
}
|
|
69721
|
+
function streamHeaders(auth, lastEventId) {
|
|
69722
|
+
return { ...auth, Accept: "text/event-stream", ...lastEventId === null ? {} : { "Last-Event-ID": lastEventId } };
|
|
69723
|
+
}
|
|
69724
|
+
function lettersOf(body) {
|
|
69725
|
+
const value = body;
|
|
69726
|
+
if (!value || typeof value.unread !== "number" || !Array.isArray(value.letters))
|
|
69727
|
+
throw new Error("letters answer is not { unread, letters }");
|
|
69728
|
+
const letters = value.letters.filter((letter) => typeof letter === "object" && letter !== null && typeof letter.id === "string" && typeof letter.summary === "string");
|
|
69729
|
+
return { unread: value.unread, letters };
|
|
69730
|
+
}
|
|
69731
|
+
function feedSse(buffer, chunk) {
|
|
69732
|
+
const text2 = (buffer + chunk).replace(/\r\n?/g, `
|
|
69733
|
+
`);
|
|
69734
|
+
const blocks = text2.split(`
|
|
69735
|
+
|
|
69736
|
+
`);
|
|
69737
|
+
const rest = blocks.pop() ?? "";
|
|
69738
|
+
const frames = [];
|
|
69739
|
+
for (const block of blocks) {
|
|
69740
|
+
let event, id;
|
|
69741
|
+
const data = [];
|
|
69742
|
+
for (const line of block.split(`
|
|
69743
|
+
`)) {
|
|
69744
|
+
if (line === "" || line.startsWith(":"))
|
|
69745
|
+
continue;
|
|
69746
|
+
const colon = line.indexOf(":");
|
|
69747
|
+
const field = colon < 0 ? line : line.slice(0, colon);
|
|
69748
|
+
const value = colon < 0 ? "" : line.slice(colon + 1).replace(/^ /, "");
|
|
69749
|
+
if (field === "data")
|
|
69750
|
+
data.push(value);
|
|
69751
|
+
else if (field === "event")
|
|
69752
|
+
event = value;
|
|
69753
|
+
else if (field === "id")
|
|
69754
|
+
id = value;
|
|
69755
|
+
}
|
|
69756
|
+
if (data.length)
|
|
69757
|
+
frames.push({ ...event === undefined ? {} : { event }, ...id === undefined ? {} : { id }, data: data.join(`
|
|
69758
|
+
`) });
|
|
69759
|
+
}
|
|
69760
|
+
return { buffer: rest, frames };
|
|
69761
|
+
}
|
|
69762
|
+
var text2 = (value) => typeof value === "string" && value !== "";
|
|
69763
|
+
function wakeOf(frame) {
|
|
69764
|
+
let event;
|
|
69765
|
+
try {
|
|
69766
|
+
event = JSON.parse(frame.data);
|
|
69767
|
+
} catch {
|
|
69768
|
+
return null;
|
|
69769
|
+
}
|
|
69770
|
+
if (typeof event !== "object" || event === null)
|
|
69771
|
+
return null;
|
|
69772
|
+
if (event.type === "inbox.letter_delivered" && text2(event.letter_id) && typeof event.summary === "string")
|
|
69773
|
+
return { kind: "letter", letter: {
|
|
69774
|
+
id: event.letter_id,
|
|
69775
|
+
sender: typeof event.sender === "string" ? event.sender : "",
|
|
69776
|
+
...text2(event.sender_name) ? { sender_name: event.sender_name } : {},
|
|
69777
|
+
summary: event.summary,
|
|
69778
|
+
thread: typeof event.thread === "string" ? event.thread : null,
|
|
69779
|
+
create_time: typeof event.create_time === "string" ? event.create_time : ""
|
|
69780
|
+
} };
|
|
69781
|
+
if (event.type === "cognition.ritual_held" && text2(event.title))
|
|
69782
|
+
return { kind: "ritual", ritual: {
|
|
69783
|
+
ritual: text2(event.ritual) ? event.ritual : "",
|
|
69784
|
+
owner: text2(event.owner) ? event.owner : "",
|
|
69785
|
+
title: event.title,
|
|
69786
|
+
engram: text2(event.engram) ? event.engram : ""
|
|
69787
|
+
} };
|
|
69788
|
+
return null;
|
|
69789
|
+
}
|
|
69790
|
+
function ritualNotice(ritual) {
|
|
69791
|
+
const origin = [ritual.owner, ritual.ritual].filter(Boolean).join(" 的仪式 ");
|
|
69792
|
+
return `你获得了一段新记忆:「${ritual.title}」${origin ? `(${origin}${ritual.engram ? `,${ritual.engram}` : ""})` : ""}。处理完再在后台运行 praxis agent events wait。`;
|
|
69793
|
+
}
|
|
69794
|
+
function retryableStatus(status) {
|
|
69795
|
+
return status >= 500 || status === 408 || status === 429;
|
|
69796
|
+
}
|
|
69797
|
+
function planNotice(page, announced) {
|
|
69798
|
+
const seen = new Set(announced);
|
|
69799
|
+
const fresh = page.letters.filter((letter) => !seen.has(letter.id));
|
|
69800
|
+
if (!fresh.length)
|
|
69801
|
+
return { announced };
|
|
69802
|
+
const named = fresh.slice(0, NOTICE_NAMED).map((letter) => `${letter.sender_name || letter.sender}:${letter.summary}(${letter.id})`);
|
|
69803
|
+
const more = fresh.length > NOTICE_NAMED ? `;另有 ${fresh.length - NOTICE_NAMED} 封` : "";
|
|
69804
|
+
const notice = `你有 ${fresh.length} 封新信:${named.join(";")}${more}。用 praxis_assume_inbox(action "read")读取并处理,处理完再在后台运行 praxis agent events wait。`;
|
|
69805
|
+
const next = [...announced, ...fresh.map((letter) => letter.id)];
|
|
69806
|
+
return { notice, announced: next.length > ANNOUNCED_KEEP ? next.slice(next.length - ANNOUNCED_KEEP) : next };
|
|
69807
|
+
}
|
|
69808
|
+
function waitStateOf(raw) {
|
|
69809
|
+
if (raw === null)
|
|
69810
|
+
return { announced: [], lastEventId: null };
|
|
69811
|
+
try {
|
|
69812
|
+
const value = JSON.parse(raw);
|
|
69813
|
+
return {
|
|
69814
|
+
announced: Array.isArray(value.announced) ? value.announced.filter((id) => typeof id === "string") : [],
|
|
69815
|
+
lastEventId: typeof value.last_event_id === "string" && /^\d+$/.test(value.last_event_id) ? value.last_event_id : null
|
|
69816
|
+
};
|
|
69817
|
+
} catch {
|
|
69818
|
+
return { announced: [], lastEventId: null };
|
|
69819
|
+
}
|
|
69820
|
+
}
|
|
69821
|
+
function waitStateText(state) {
|
|
69822
|
+
return JSON.stringify({ announced: state.announced, ...state.lastEventId === null ? {} : { last_event_id: state.lastEventId } });
|
|
69823
|
+
}
|
|
69824
|
+
var message = (error) => error instanceof Error ? error.message : String(error);
|
|
69825
|
+
async function runEventsWait(ports) {
|
|
69826
|
+
const stop = new AbortController;
|
|
69827
|
+
let timedOut = false;
|
|
69828
|
+
const timer = ports.timeoutMs === null ? undefined : setTimeout(() => {
|
|
69829
|
+
timedOut = true;
|
|
69830
|
+
stop.abort();
|
|
69831
|
+
}, ports.timeoutMs);
|
|
69832
|
+
const state = await ports.readState();
|
|
69833
|
+
let announced = state.announced;
|
|
69834
|
+
let lastEventId = state.lastEventId;
|
|
69835
|
+
const announceLetters = async (page) => {
|
|
69836
|
+
const planned = planNotice(page, announced);
|
|
69837
|
+
if (!planned.notice)
|
|
69838
|
+
return false;
|
|
69839
|
+
announced = planned.announced;
|
|
69840
|
+
await ports.writeState({ announced, lastEventId });
|
|
69841
|
+
ports.print(planned.notice);
|
|
69842
|
+
return true;
|
|
69843
|
+
};
|
|
69844
|
+
const announce = async () => announceLetters(await ports.fetchLetters());
|
|
69845
|
+
try {
|
|
69846
|
+
try {
|
|
69847
|
+
if (await announce())
|
|
69848
|
+
return 0;
|
|
69849
|
+
} catch (error) {
|
|
69850
|
+
ports.log(`praxis agent events wait: reading letters failed: ${message(error)}`);
|
|
69851
|
+
}
|
|
69852
|
+
ports.log(`praxis agent events wait: waiting for letters to assume agent ${ports.agent}`);
|
|
69853
|
+
let failures = 0;
|
|
69854
|
+
while (!stop.signal.aborted) {
|
|
69855
|
+
if (failures)
|
|
69856
|
+
await ports.sleep(backoffMs(failures), stop.signal);
|
|
69857
|
+
if (stop.signal.aborted)
|
|
69858
|
+
break;
|
|
69859
|
+
try {
|
|
69860
|
+
const opened = await ports.openStream(stop.signal, lastEventId);
|
|
69861
|
+
if (opened.status < 200 || opened.status >= 300 || !opened.chunks) {
|
|
69862
|
+
if (!retryableStatus(opened.status)) {
|
|
69863
|
+
ports.log(`praxis agent events wait: the event stream was refused (HTTP ${opened.status}${opened.reason ? `: ${opened.reason}` : ""})`);
|
|
69864
|
+
return 1;
|
|
69865
|
+
}
|
|
69866
|
+
throw new Error(`HTTP ${opened.status}`);
|
|
69867
|
+
}
|
|
69868
|
+
if (await announce())
|
|
69869
|
+
return 0;
|
|
69870
|
+
if (failures)
|
|
69871
|
+
ports.log("praxis agent events wait: event stream reconnected");
|
|
69872
|
+
failures = 0;
|
|
69873
|
+
let buffer = "";
|
|
69874
|
+
for await (const chunk of opened.chunks) {
|
|
69875
|
+
const fed = feedSse(buffer, chunk);
|
|
69876
|
+
buffer = fed.buffer;
|
|
69877
|
+
for (const frame of fed.frames) {
|
|
69878
|
+
const wake = wakeOf(frame);
|
|
69879
|
+
if (wake !== null && frame.id !== undefined)
|
|
69880
|
+
lastEventId = frame.id;
|
|
69881
|
+
if (wake?.kind === "letter" && await announceLetters({ unread: 1, letters: [wake.letter] }))
|
|
69882
|
+
return 0;
|
|
69883
|
+
if (wake?.kind === "ritual") {
|
|
69884
|
+
await ports.writeState({ announced, lastEventId });
|
|
69885
|
+
ports.print(ritualNotice(wake.ritual));
|
|
69886
|
+
return 0;
|
|
69887
|
+
}
|
|
69888
|
+
}
|
|
69889
|
+
}
|
|
69890
|
+
throw new Error("the event stream ended");
|
|
69891
|
+
} catch (error) {
|
|
69892
|
+
if (stop.signal.aborted)
|
|
69893
|
+
break;
|
|
69894
|
+
failures += 1;
|
|
69895
|
+
ports.log(`praxis agent events wait: ${message(error)} (${failures} in a row, reconnecting in ${backoffMs(failures) / 1000}s)`);
|
|
69896
|
+
}
|
|
69897
|
+
}
|
|
69898
|
+
if (timedOut)
|
|
69899
|
+
ports.print(`${(ports.timeoutMs ?? 0) / 1000} 秒内没有新信。需要继续等待时再在后台运行 praxis agent events wait。`);
|
|
69900
|
+
return 0;
|
|
69901
|
+
} finally {
|
|
69902
|
+
if (timer)
|
|
69903
|
+
clearTimeout(timer);
|
|
69904
|
+
stop.abort();
|
|
69905
|
+
}
|
|
69906
|
+
}
|
|
69907
|
+
|
|
69173
69908
|
// src/main.ts
|
|
69174
69909
|
import { spawnSync } from "node:child_process";
|
|
69175
69910
|
|
|
@@ -69287,15 +70022,15 @@ class ModelStream {
|
|
|
69287
70022
|
finishReason = "unknown";
|
|
69288
70023
|
usage;
|
|
69289
70024
|
add(event) {
|
|
69290
|
-
const data = streamData(event),
|
|
70025
|
+
const data = streamData(event), message2 = record(data.message), response = record(data.response);
|
|
69291
70026
|
this.chunks.push(streamText(event));
|
|
69292
70027
|
const choices = Array.isArray(data.choices) ? data.choices : [];
|
|
69293
|
-
const reason2 = choices.map((c) => record(c).finish_reason).find((r) => typeof r === "string" && r) ?? record(data.delta).stop_reason ??
|
|
70028
|
+
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;
|
|
69294
70029
|
if (typeof reason2 === "string" && reason2)
|
|
69295
70030
|
this.finishReason = reason2;
|
|
69296
70031
|
else if (["response.completed", "response.incomplete", "response.failed"].includes(String(data.type)))
|
|
69297
70032
|
this.finishReason = String(data.type).slice("response.".length);
|
|
69298
|
-
for (const usage of [
|
|
70033
|
+
for (const usage of [message2.usage, data.usage, response.usage]) {
|
|
69299
70034
|
if (usage !== null && typeof usage === "object" && !Array.isArray(usage))
|
|
69300
70035
|
this.usage = { ...this.usage, ...record(usage) };
|
|
69301
70036
|
}
|
|
@@ -69360,8 +70095,8 @@ function isSuccess(verb, ctx) {
|
|
|
69360
70095
|
}
|
|
69361
70096
|
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" };
|
|
69362
70097
|
var deleted = (verb) => /^(delete|remove|purge)(-|$)/.test(verb);
|
|
69363
|
-
function width(
|
|
69364
|
-
return [...
|
|
70098
|
+
function width(text3) {
|
|
70099
|
+
return [...text3].reduce((sum, ch) => {
|
|
69365
70100
|
const cp = ch.codePointAt(0);
|
|
69366
70101
|
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);
|
|
69367
70102
|
}, 0);
|
|
@@ -69369,13 +70104,13 @@ function width(text2) {
|
|
|
69369
70104
|
function truncate(value, size) {
|
|
69370
70105
|
if (width(value) <= size)
|
|
69371
70106
|
return value;
|
|
69372
|
-
let
|
|
70107
|
+
let text3 = "";
|
|
69373
70108
|
for (const ch of value) {
|
|
69374
|
-
if (width(
|
|
70109
|
+
if (width(text3 + ch) > size - 1)
|
|
69375
70110
|
break;
|
|
69376
|
-
|
|
70111
|
+
text3 += ch;
|
|
69377
70112
|
}
|
|
69378
|
-
return
|
|
70113
|
+
return text3 + "…";
|
|
69379
70114
|
}
|
|
69380
70115
|
function table(items, ctx, paint) {
|
|
69381
70116
|
const columns = columnsFor(items);
|
|
@@ -69408,13 +70143,13 @@ function table(items, ctx, paint) {
|
|
|
69408
70143
|
sizes[index]--;
|
|
69409
70144
|
}
|
|
69410
70145
|
const line = (row, header) => row.map((v, i) => {
|
|
69411
|
-
const
|
|
69412
|
-
let styled = header ? paint.dim(
|
|
70146
|
+
const text3 = truncate(v, sizes[i]);
|
|
70147
|
+
let styled = header ? paint.dim(text3) : text3;
|
|
69413
70148
|
if (!header && ["status", "state"].includes(columns[i])) {
|
|
69414
70149
|
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;
|
|
69415
|
-
styled = color(
|
|
70150
|
+
styled = color(text3);
|
|
69416
70151
|
}
|
|
69417
|
-
return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(
|
|
70152
|
+
return styled + (i === row.length - 1 ? "" : " ".repeat(Math.max(0, sizes[i] - width(text3))));
|
|
69418
70153
|
}).join(" ");
|
|
69419
70154
|
return [line(headers, true), ...rows.map((row) => line(row, false))].join(`
|
|
69420
70155
|
`) + `
|
|
@@ -69513,9 +70248,9 @@ function renderHuman(result, ctx) {
|
|
|
69513
70248
|
}
|
|
69514
70249
|
|
|
69515
70250
|
// src/output/agent.ts
|
|
69516
|
-
function cell(
|
|
69517
|
-
const chars = [...
|
|
69518
|
-
const limited = chars.length > 500 ? chars.slice(0, 500).join("") + `…[+${chars.length - 500} chars, use --json]` :
|
|
70251
|
+
function cell(text3) {
|
|
70252
|
+
const chars = [...text3];
|
|
70253
|
+
const limited = chars.length > 500 ? chars.slice(0, 500).join("") + `…[+${chars.length - 500} chars, use --json]` : text3;
|
|
69519
70254
|
return limited.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\r?\n/g, "<br>").replace(/\r/g, "<br>");
|
|
69520
70255
|
}
|
|
69521
70256
|
function renderAgent(result, ctx) {
|
|
@@ -69526,9 +70261,9 @@ function renderAgent(result, ctx) {
|
|
|
69526
70261
|
if (modelStream(result.op)) {
|
|
69527
70262
|
if (!result.summary)
|
|
69528
70263
|
return {};
|
|
69529
|
-
const { text:
|
|
69530
|
-
return { stdout: `${
|
|
69531
|
-
`) || !
|
|
70264
|
+
const { text: text3, finish_reason, usage } = result.summary;
|
|
70265
|
+
return { stdout: `${text3}${text3.endsWith(`
|
|
70266
|
+
`) || !text3 ? "" : `
|
|
69532
70267
|
`}finish_reason: ${finish_reason}
|
|
69533
70268
|
${usage ? `usage: ${JSON.stringify(usage)}
|
|
69534
70269
|
` : ""}` };
|
|
@@ -69747,18 +70482,18 @@ function errorInput(error, ctx) {
|
|
|
69747
70482
|
const details = candidate !== null && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : undefined;
|
|
69748
70483
|
const problem = serverProblem(Object.keys(nested).length ? nested : raw);
|
|
69749
70484
|
const serverText = (value) => typeof value === "string" && value.trim() ? value : undefined;
|
|
69750
|
-
let
|
|
69751
|
-
const prefix =
|
|
70485
|
+
let message2 = error instanceof Error ? error.message : "Unexpected error";
|
|
70486
|
+
const prefix = message2.match(/^([A-Z][A-Z0-9_]+):\s*/)?.[1];
|
|
69752
70487
|
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");
|
|
69753
70488
|
let stripped = false;
|
|
69754
|
-
while (
|
|
69755
|
-
|
|
70489
|
+
while (message2.startsWith(`${code}:`)) {
|
|
70490
|
+
message2 = message2.slice(code.length + 1).trimStart();
|
|
69756
70491
|
stripped = true;
|
|
69757
70492
|
}
|
|
69758
70493
|
if (stripped)
|
|
69759
|
-
|
|
70494
|
+
message2 = `${humanize(code)}${message2 ? `: ${message2}` : ""}`;
|
|
69760
70495
|
const status = sdk?.status, request_id = sdk?.requestId;
|
|
69761
|
-
|
|
70496
|
+
message2 = serverText(problem?.detail) ?? serverText(problem?.title) ?? message2;
|
|
69762
70497
|
const authFailure = status === 401 || ["NOT_LOGGED_IN", "UNAUTHENTICATED", "TOKEN_REVOKED", "LOGIN_FAILED", "MANAGED_LOGIN_EXPIRED"].includes(code);
|
|
69763
70498
|
const source = ctx.credentialSource ?? "login";
|
|
69764
70499
|
let hint3 = genericHint;
|
|
@@ -69776,11 +70511,11 @@ function errorInput(error, ctx) {
|
|
|
69776
70511
|
hint3 = "Rate limited; retry later.";
|
|
69777
70512
|
else if (status !== undefined && status >= 500)
|
|
69778
70513
|
hint3 = `Server error; retry later.${request_id ? ` Request id: ${request_id}.` : ""}`;
|
|
69779
|
-
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 } : {} };
|
|
70514
|
+
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 } : {} };
|
|
69780
70515
|
}
|
|
69781
70516
|
|
|
69782
70517
|
// src/output/progress.ts
|
|
69783
|
-
function startProgress(ctx, write = (
|
|
70518
|
+
function startProgress(ctx, write = (text3) => writeOutput({ stderr: text3 })) {
|
|
69784
70519
|
if (ctx.mode !== "human" || !ctx.stderrIsTTY)
|
|
69785
70520
|
return () => {};
|
|
69786
70521
|
let interval;
|
|
@@ -69806,7 +70541,7 @@ function startProgress(ctx, write = (text2) => writeOutput({ stderr: text2 })) {
|
|
|
69806
70541
|
}
|
|
69807
70542
|
|
|
69808
70543
|
// src/main.ts
|
|
69809
|
-
var version = "0.3.0-dev.
|
|
70544
|
+
var version = "0.3.0-dev.830431a";
|
|
69810
70545
|
var commands = commandTree(operations);
|
|
69811
70546
|
var manual = [...workflows.map((w) => w.words), [API_WORD]];
|
|
69812
70547
|
function route(argv) {
|
|
@@ -69888,7 +70623,7 @@ var defaults = {
|
|
|
69888
70623
|
return;
|
|
69889
70624
|
const cmd = process.platform === "darwin" ? ["open", url] : process.platform === "win32" ? ["rundll32", "url.dll,FileProtocolHandler", url] : ["xdg-open", url];
|
|
69890
70625
|
await new Promise((resolve12, reject) => {
|
|
69891
|
-
const child =
|
|
70626
|
+
const child = spawn5(cmd[0], cmd.slice(1), { stdio: "ignore" });
|
|
69892
70627
|
child.once("error", reject);
|
|
69893
70628
|
child.once("close", () => resolve12());
|
|
69894
70629
|
});
|
|
@@ -69897,12 +70632,12 @@ var defaults = {
|
|
|
69897
70632
|
wait: (ms) => new Promise((resolve12) => setTimeout(resolve12, ms)),
|
|
69898
70633
|
render,
|
|
69899
70634
|
spawn: (cmd, args, options) => new Promise((resolve12, reject) => {
|
|
69900
|
-
const child =
|
|
70635
|
+
const child = spawn5(cmd, args, { cwd: options.cwd, stdio: ["ignore", 2, 2] });
|
|
69901
70636
|
child.once("error", reject);
|
|
69902
70637
|
child.once("close", (code) => resolve12(code ?? 1));
|
|
69903
70638
|
}),
|
|
69904
70639
|
spawnCapture: (cmd, args, options) => new Promise((resolve12, reject) => {
|
|
69905
|
-
const child =
|
|
70640
|
+
const child = spawn5(cmd, args, { cwd: options.cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
69906
70641
|
const chunks = [];
|
|
69907
70642
|
child.stdout.on("data", (c) => chunks.push(c));
|
|
69908
70643
|
child.stderr.on("data", (c) => chunks.push(c));
|
|
@@ -69985,6 +70720,10 @@ var appOptions = {
|
|
|
69985
70720
|
{ 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)." },
|
|
69986
70721
|
{ name: "project", type: "string", description: "With --report: the DevOps project id (dvp_…) whose flags the scan is reported into. Required." }
|
|
69987
70722
|
],
|
|
70723
|
+
"agent events wait": [
|
|
70724
|
+
{ name: "timeout", type: "string", description: "Give up after this many seconds, print that nothing arrived and exit 0 (default: wait until a letter arrives)." },
|
|
70725
|
+
{ 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)." }
|
|
70726
|
+
],
|
|
69988
70727
|
"canvas import": [
|
|
69989
70728
|
{ name: "name", type: "string", description: "Name for the new canvas (default: the file name without .pen)." },
|
|
69990
70729
|
{ 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." },
|
|
@@ -70003,15 +70742,15 @@ function flagPortsFor(ports, context, emit, connect) {
|
|
|
70003
70742
|
return {
|
|
70004
70743
|
mode: context.mode,
|
|
70005
70744
|
emit,
|
|
70006
|
-
human: (
|
|
70745
|
+
human: (text3) => {
|
|
70007
70746
|
if (context.mode === "human")
|
|
70008
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
70747
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70009
70748
|
},
|
|
70010
70749
|
cwd: ports.cwd,
|
|
70011
70750
|
readFile: ports.readFile,
|
|
70012
70751
|
git: async (args) => (await ports.spawnCapture("git", [...args], { cwd: ports.cwd })).output,
|
|
70013
70752
|
client: connect,
|
|
70014
|
-
writeFile: (path,
|
|
70753
|
+
writeFile: (path, text3) => writeFile5(path, text3, "utf8"),
|
|
70015
70754
|
mkdir: async (path) => {
|
|
70016
70755
|
await mkdir4(path, { recursive: true });
|
|
70017
70756
|
},
|
|
@@ -70035,9 +70774,9 @@ function toolPortsFor(ports, context, emit) {
|
|
|
70035
70774
|
return {
|
|
70036
70775
|
mode: context.mode,
|
|
70037
70776
|
emit,
|
|
70038
|
-
human: (
|
|
70777
|
+
human: (text3) => {
|
|
70039
70778
|
if (context.mode === "human")
|
|
70040
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
70779
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70041
70780
|
},
|
|
70042
70781
|
cwd: ports.cwd,
|
|
70043
70782
|
readFile: ports.readFile,
|
|
@@ -70052,7 +70791,7 @@ function toolPortsFor(ports, context, emit) {
|
|
|
70052
70791
|
},
|
|
70053
70792
|
git: (args, cwd) => ports.spawnCapture("git", args, { cwd }),
|
|
70054
70793
|
run: (cmd, args, cwd) => new Promise((resolve12, reject) => {
|
|
70055
|
-
const child =
|
|
70794
|
+
const child = spawn5(cmd, args, { cwd, stdio: "inherit" });
|
|
70056
70795
|
child.once("error", reject);
|
|
70057
70796
|
child.once("close", (code) => resolve12(code ?? 1));
|
|
70058
70797
|
}),
|
|
@@ -70347,9 +71086,9 @@ Examples:
|
|
|
70347
71086
|
},
|
|
70348
71087
|
mode: ctx.mode,
|
|
70349
71088
|
emit,
|
|
70350
|
-
human: (
|
|
71089
|
+
human: (text3) => {
|
|
70351
71090
|
if (ctx.mode === "human")
|
|
70352
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71091
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70353
71092
|
},
|
|
70354
71093
|
cwd: ports.cwd
|
|
70355
71094
|
});
|
|
@@ -70376,14 +71115,14 @@ Examples:
|
|
|
70376
71115
|
}, {
|
|
70377
71116
|
mode: ctx.mode,
|
|
70378
71117
|
emit,
|
|
70379
|
-
human: (
|
|
71118
|
+
human: (text3) => {
|
|
70380
71119
|
if (ctx.mode === "human")
|
|
70381
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71120
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70382
71121
|
},
|
|
70383
71122
|
engine: codeRefactorEngine(),
|
|
70384
71123
|
hasFile: (path2) => existsSync4(path2),
|
|
70385
71124
|
readFile: ports.readFile,
|
|
70386
|
-
writeFile: (path2,
|
|
71125
|
+
writeFile: (path2, text3) => writeFile5(path2, text3, "utf8"),
|
|
70387
71126
|
mkdir: async (path2) => {
|
|
70388
71127
|
await mkdir4(path2, { recursive: true });
|
|
70389
71128
|
},
|
|
@@ -70400,9 +71139,9 @@ Examples:
|
|
|
70400
71139
|
const shellPorts = {
|
|
70401
71140
|
mode: ctx.mode,
|
|
70402
71141
|
emit,
|
|
70403
|
-
human: (
|
|
71142
|
+
human: (text3) => {
|
|
70404
71143
|
if (ctx.mode === "human")
|
|
70405
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71144
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70406
71145
|
},
|
|
70407
71146
|
engine: await repositoryEngine(name, () => localEngine(ports.cwd)),
|
|
70408
71147
|
...localFilePorts(ports.cwd)
|
|
@@ -70415,9 +71154,9 @@ Examples:
|
|
|
70415
71154
|
const testPorts = {
|
|
70416
71155
|
mode: ctx.mode,
|
|
70417
71156
|
emit,
|
|
70418
|
-
human: (
|
|
71157
|
+
human: (text3) => {
|
|
70419
71158
|
if (ctx.mode === "human")
|
|
70420
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71159
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70421
71160
|
},
|
|
70422
71161
|
engine: await repositoryEngine(name, () => localEngine(ports.cwd)),
|
|
70423
71162
|
checkout: await localCheckout(ports.cwd, (cmd, args, options) => ports.spawnCapture(cmd, args, options))
|
|
@@ -70426,9 +71165,9 @@ Examples:
|
|
|
70426
71165
|
return await devopsTestReport({ path: parsed.positional[0], id: parsed.flags.id?.[0], upload: Boolean(parsed.flags.upload), project: parsed.flags.project?.[0] }, testPorts, {
|
|
70427
71166
|
mode: ctx.mode,
|
|
70428
71167
|
emit,
|
|
70429
|
-
human: (
|
|
71168
|
+
human: (text3) => {
|
|
70430
71169
|
if (ctx.mode === "human")
|
|
70431
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71170
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70432
71171
|
},
|
|
70433
71172
|
root: async () => await checkoutRoot(ports.cwd, ports.readFile),
|
|
70434
71173
|
readFile: ports.readFile,
|
|
@@ -70458,9 +71197,9 @@ Examples:
|
|
|
70458
71197
|
git: (args) => ports.spawnCapture("git", args, { cwd: ports.cwd }),
|
|
70459
71198
|
mode: ctx.mode,
|
|
70460
71199
|
emit,
|
|
70461
|
-
human: (
|
|
71200
|
+
human: (text3) => {
|
|
70462
71201
|
if (ctx.mode === "human")
|
|
70463
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71202
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70464
71203
|
}
|
|
70465
71204
|
});
|
|
70466
71205
|
}
|
|
@@ -70510,9 +71249,9 @@ Examples:
|
|
|
70510
71249
|
emit({ kind: "object", data: await auth.switchOrganization(parsed.positional[0]) });
|
|
70511
71250
|
break;
|
|
70512
71251
|
case "app create": {
|
|
70513
|
-
const appPorts = { ...ports, mode: ctx.mode, emit, human: (
|
|
71252
|
+
const appPorts = { ...ports, mode: ctx.mode, emit, human: (text3) => {
|
|
70514
71253
|
if (ctx.mode === "human")
|
|
70515
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71254
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70516
71255
|
}, random: randomSecret };
|
|
70517
71256
|
await appCreate({ name: parsed.positional[0], dir: parsed.flags.dir?.[0], template: parsed.flags.template?.[0], install: !parsed.flags["no-install"] }, config.env, appPorts);
|
|
70518
71257
|
break;
|
|
@@ -70541,13 +71280,129 @@ Examples:
|
|
|
70541
71280
|
wait: ports.wait,
|
|
70542
71281
|
mode: ctx.mode,
|
|
70543
71282
|
emit,
|
|
70544
|
-
human: (
|
|
71283
|
+
human: (text3) => {
|
|
70545
71284
|
if (ctx.mode === "human")
|
|
70546
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71285
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70547
71286
|
},
|
|
70548
71287
|
cwd: ports.cwd
|
|
70549
71288
|
});
|
|
70550
71289
|
}
|
|
71290
|
+
case "agent events wait": {
|
|
71291
|
+
const agent = assumeAgentOf(ports.env);
|
|
71292
|
+
const timeoutMs = (() => {
|
|
71293
|
+
try {
|
|
71294
|
+
return timeoutMsOf(parsed.flags.timeout?.[0]);
|
|
71295
|
+
} catch (error) {
|
|
71296
|
+
throw new UsageError(error.message, "Example: praxis agent events wait --timeout 3600");
|
|
71297
|
+
}
|
|
71298
|
+
})();
|
|
71299
|
+
const headers = async () => {
|
|
71300
|
+
const credential = await auth.get(org);
|
|
71301
|
+
return { Authorization: `Bearer ${credential.token}`, ...credential.source === "api-key" ? { "X-API-Key": credential.token } : {} };
|
|
71302
|
+
};
|
|
71303
|
+
const failure2 = (status, body) => `HTTP ${status}${body?.error?.code ? ` ${body.error.code}` : ""}${body?.error?.message ? `: ${String(redact(body.error.message, secrets))}` : ""}`;
|
|
71304
|
+
const session = (() => {
|
|
71305
|
+
try {
|
|
71306
|
+
return sessionOf(parsed.flags.session?.[0]);
|
|
71307
|
+
} catch (error) {
|
|
71308
|
+
throw new UsageError(error.message, "Example: praxis agent events wait --session 0f6c…");
|
|
71309
|
+
}
|
|
71310
|
+
})();
|
|
71311
|
+
const key = waitKeyOf(config.env, agent, session);
|
|
71312
|
+
const waitDir = join12(ports.env.HOME || homedir3(), ".praxis", "cli", "events-wait");
|
|
71313
|
+
const statePath = join12(waitDir, `${key}.json`);
|
|
71314
|
+
const pidPath = join12(waitDir, `${key}.pid`);
|
|
71315
|
+
await mkdir4(waitDir, { recursive: true, mode: 448 });
|
|
71316
|
+
const holder = await acquireWaitLock({
|
|
71317
|
+
self: process.pid,
|
|
71318
|
+
readPid: () => readFile7(pidPath, "utf8").catch(() => null),
|
|
71319
|
+
createPid: (text3) => writeFile5(pidPath, text3, { mode: 384, flag: "wx" }).then(() => true, () => false),
|
|
71320
|
+
replacePid: (text3) => writeFile5(pidPath, text3, { mode: 384 }),
|
|
71321
|
+
probe: async (pid) => {
|
|
71322
|
+
try {
|
|
71323
|
+
process.kill(pid, 0);
|
|
71324
|
+
} catch (error) {
|
|
71325
|
+
if (error.code !== "EPERM")
|
|
71326
|
+
return { alive: false };
|
|
71327
|
+
}
|
|
71328
|
+
const ps = spawnSync("ps", ["-o", "ppid=,command=", "-p", String(pid)], { encoding: "utf8" });
|
|
71329
|
+
const line = ps.stdout?.trim() ?? "";
|
|
71330
|
+
const match = /^(\d+)\s+(.*)$/.exec(line);
|
|
71331
|
+
return match ? { alive: true, ppid: Number(match[1]), command: match[2] } : { alive: false };
|
|
71332
|
+
},
|
|
71333
|
+
terminate: (pid) => {
|
|
71334
|
+
try {
|
|
71335
|
+
process.kill(pid, "SIGTERM");
|
|
71336
|
+
} catch {}
|
|
71337
|
+
}
|
|
71338
|
+
});
|
|
71339
|
+
if (holder !== null) {
|
|
71340
|
+
process.stdout.write(alreadyWaitingNotice(holder) + `
|
|
71341
|
+
`);
|
|
71342
|
+
return 0;
|
|
71343
|
+
}
|
|
71344
|
+
const release = () => {
|
|
71345
|
+
try {
|
|
71346
|
+
if (pidOf(readFileSync3(pidPath, "utf8")) === process.pid)
|
|
71347
|
+
unlinkSync(pidPath);
|
|
71348
|
+
} catch {}
|
|
71349
|
+
};
|
|
71350
|
+
const onSignal = (signal) => {
|
|
71351
|
+
release();
|
|
71352
|
+
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
71353
|
+
};
|
|
71354
|
+
for (const signal of ["SIGTERM", "SIGINT", "SIGHUP"])
|
|
71355
|
+
process.once(signal, onSignal);
|
|
71356
|
+
try {
|
|
71357
|
+
return await runEventsWait({
|
|
71358
|
+
agent,
|
|
71359
|
+
timeoutMs,
|
|
71360
|
+
fetchLetters: async () => {
|
|
71361
|
+
const response = await wireFetch(inboxLettersUrl(config.apiUrl, agent), { headers: await headers(), signal: AbortSignal.timeout(30000), redirect: "error" });
|
|
71362
|
+
const body = await response.json().catch(() => null);
|
|
71363
|
+
if (!response.ok)
|
|
71364
|
+
throw new Error(failure2(response.status, body));
|
|
71365
|
+
return lettersOf(body);
|
|
71366
|
+
},
|
|
71367
|
+
openStream: async (signal, lastEventId) => {
|
|
71368
|
+
const response = await wireFetch(eventsStreamUrl(config.apiUrl, agent), {
|
|
71369
|
+
headers: streamHeaders(await headers(), lastEventId),
|
|
71370
|
+
signal,
|
|
71371
|
+
redirect: "error"
|
|
71372
|
+
});
|
|
71373
|
+
if (!response.ok || !response.body) {
|
|
71374
|
+
const body = await response.json().catch(() => null);
|
|
71375
|
+
return { status: response.status, reason: failure2(response.status, body) };
|
|
71376
|
+
}
|
|
71377
|
+
return { status: response.status, chunks: response.body.pipeThrough(new TextDecoderStream) };
|
|
71378
|
+
},
|
|
71379
|
+
readState: async () => waitStateOf(await readFile7(statePath, "utf8").catch(() => null)),
|
|
71380
|
+
writeState: async (next) => {
|
|
71381
|
+
await mkdir4(dirname10(statePath), { recursive: true, mode: 448 });
|
|
71382
|
+
await writeFile5(statePath, waitStateText(next), { mode: 384 });
|
|
71383
|
+
},
|
|
71384
|
+
print: (line) => {
|
|
71385
|
+
process.stdout.write(line + `
|
|
71386
|
+
`);
|
|
71387
|
+
},
|
|
71388
|
+
log: (line) => {
|
|
71389
|
+
process.stderr.write(String(redact(line, secrets)) + `
|
|
71390
|
+
`);
|
|
71391
|
+
},
|
|
71392
|
+
sleep: (ms, signal) => new Promise((resolve12) => {
|
|
71393
|
+
const timer = setTimeout(resolve12, ms);
|
|
71394
|
+
signal.addEventListener("abort", () => {
|
|
71395
|
+
clearTimeout(timer);
|
|
71396
|
+
resolve12();
|
|
71397
|
+
}, { once: true });
|
|
71398
|
+
})
|
|
71399
|
+
});
|
|
71400
|
+
} finally {
|
|
71401
|
+
release();
|
|
71402
|
+
for (const signal of ["SIGTERM", "SIGINT", "SIGHUP"])
|
|
71403
|
+
process.removeListener(signal, onSignal);
|
|
71404
|
+
}
|
|
71405
|
+
}
|
|
70551
71406
|
case "canvas import": {
|
|
70552
71407
|
const authorize = async () => {
|
|
70553
71408
|
const credential = await auth.get(org);
|
|
@@ -70603,9 +71458,9 @@ Examples:
|
|
|
70603
71458
|
cwd: ports.cwd,
|
|
70604
71459
|
rpc,
|
|
70605
71460
|
upload,
|
|
70606
|
-
human: (
|
|
71461
|
+
human: (text3) => {
|
|
70607
71462
|
if (ctx.mode === "human")
|
|
70608
|
-
emit({ kind: "message", channel: "stdout", text:
|
|
71463
|
+
emit({ kind: "message", channel: "stdout", text: text3 });
|
|
70609
71464
|
}
|
|
70610
71465
|
});
|
|
70611
71466
|
}
|
|
@@ -70637,7 +71492,8 @@ if (true) {
|
|
|
70637
71492
|
process.exit(0);
|
|
70638
71493
|
throw error;
|
|
70639
71494
|
});
|
|
70640
|
-
|
|
71495
|
+
const argv = process.argv.slice(2);
|
|
71496
|
+
process.exitCode = isDevopsTestRun(route(argv).words) && needsCacheOffReexec(process.env) ? await reexecWithCacheOff() : await main3(argv);
|
|
70641
71497
|
}
|
|
70642
71498
|
export {
|
|
70643
71499
|
main3 as main
|