@sema-agent/sdk 0.0.75 → 0.0.76
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/dist/client.d.ts +48 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +55 -2
- package/dist/client.js.map +1 -1
- package/dist/control-client.d.ts +21 -0
- package/dist/control-client.d.ts.map +1 -1
- package/dist/control-client.js +42 -1
- package/dist/control-client.js.map +1 -1
- package/dist/control-types.d.ts +108 -0
- package/dist/control-types.d.ts.map +1 -1
- package/dist/control-types.js +15 -0
- package/dist/control-types.js.map +1 -1
- package/dist/errors.d.ts +88 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +105 -8
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +154 -16
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +1 -0
- package/dist/events.js.map +1 -1
- package/dist/health.d.ts +44 -0
- package/dist/health.d.ts.map +1 -1
- package/dist/health.js +32 -0
- package/dist/health.js.map +1 -1
- package/dist/idempotency.d.ts +8 -0
- package/dist/idempotency.d.ts.map +1 -1
- package/dist/idempotency.js +8 -0
- package/dist/idempotency.js.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/approvals.d.ts +43 -0
- package/dist/resources/approvals.d.ts.map +1 -1
- package/dist/resources/approvals.js +23 -3
- package/dist/resources/approvals.js.map +1 -1
- package/dist/resources/assistant.d.ts +23 -0
- package/dist/resources/assistant.d.ts.map +1 -1
- package/dist/resources/assistant.js +22 -0
- package/dist/resources/assistant.js.map +1 -1
- package/dist/resources/control/auth-providers.d.ts +17 -0
- package/dist/resources/control/auth-providers.d.ts.map +1 -1
- package/dist/resources/control/auth-providers.js +6 -0
- package/dist/resources/control/auth-providers.js.map +1 -1
- package/dist/resources/control/config.d.ts +22 -0
- package/dist/resources/control/config.d.ts.map +1 -1
- package/dist/resources/control/config.js +12 -0
- package/dist/resources/control/config.js.map +1 -1
- package/dist/resources/control/fleet.d.ts +15 -0
- package/dist/resources/control/fleet.d.ts.map +1 -1
- package/dist/resources/control/fleet.js +8 -0
- package/dist/resources/control/fleet.js.map +1 -1
- package/dist/resources/control/images.d.ts +20 -0
- package/dist/resources/control/images.d.ts.map +1 -1
- package/dist/resources/control/images.js +10 -0
- package/dist/resources/control/images.js.map +1 -1
- package/dist/resources/control/lifecycle.d.ts +8 -0
- package/dist/resources/control/lifecycle.d.ts.map +1 -1
- package/dist/resources/control/lifecycle.js +3 -0
- package/dist/resources/control/lifecycle.js.map +1 -1
- package/dist/resources/control/publish.d.ts +12 -0
- package/dist/resources/control/publish.d.ts.map +1 -1
- package/dist/resources/control/publish.js +6 -0
- package/dist/resources/control/publish.js.map +1 -1
- package/dist/resources/control/secrets.d.ts +28 -0
- package/dist/resources/control/secrets.d.ts.map +1 -1
- package/dist/resources/control/secrets.js +16 -0
- package/dist/resources/control/secrets.js.map +1 -1
- package/dist/resources/control/users.d.ts +22 -0
- package/dist/resources/control/users.d.ts.map +1 -1
- package/dist/resources/control/users.js +12 -0
- package/dist/resources/control/users.js.map +1 -1
- package/dist/resources/control/versioning.d.ts +12 -0
- package/dist/resources/control/versioning.d.ts.map +1 -1
- package/dist/resources/control/versioning.js +6 -0
- package/dist/resources/control/versioning.js.map +1 -1
- package/dist/resources/control/workers.d.ts +14 -0
- package/dist/resources/control/workers.d.ts.map +1 -1
- package/dist/resources/control/workers.js +7 -0
- package/dist/resources/control/workers.js.map +1 -1
- package/dist/resources/elicitations.d.ts +43 -0
- package/dist/resources/elicitations.d.ts.map +1 -1
- package/dist/resources/elicitations.js +8 -0
- package/dist/resources/elicitations.js.map +1 -1
- package/dist/resources/fleet.d.ts +90 -0
- package/dist/resources/fleet.d.ts.map +1 -1
- package/dist/resources/fleet.js +27 -4
- package/dist/resources/fleet.js.map +1 -1
- package/dist/resources/images.d.ts +34 -0
- package/dist/resources/images.d.ts.map +1 -1
- package/dist/resources/images.js +29 -3
- package/dist/resources/images.js.map +1 -1
- package/dist/resources/leader.d.ts +10 -0
- package/dist/resources/leader.d.ts.map +1 -1
- package/dist/resources/leader.js +4 -0
- package/dist/resources/leader.js.map +1 -1
- package/dist/resources/memory.d.ts +37 -0
- package/dist/resources/memory.d.ts.map +1 -1
- package/dist/resources/memory.js +28 -0
- package/dist/resources/memory.js.map +1 -1
- package/dist/resources/models.d.ts +12 -0
- package/dist/resources/models.d.ts.map +1 -1
- package/dist/resources/models.js +4 -0
- package/dist/resources/models.js.map +1 -1
- package/dist/resources/ops.d.ts +16 -0
- package/dist/resources/ops.d.ts.map +1 -1
- package/dist/resources/ops.js +6 -0
- package/dist/resources/ops.js.map +1 -1
- package/dist/resources/policy.d.ts +8 -0
- package/dist/resources/policy.d.ts.map +1 -1
- package/dist/resources/policy.js +1 -0
- package/dist/resources/policy.js.map +1 -1
- package/dist/resources/questions.d.ts +57 -0
- package/dist/resources/questions.d.ts.map +1 -1
- package/dist/resources/questions.js +9 -0
- package/dist/resources/questions.js.map +1 -1
- package/dist/resources/runs.d.ts +143 -0
- package/dist/resources/runs.d.ts.map +1 -1
- package/dist/resources/runs.js +129 -2
- package/dist/resources/runs.js.map +1 -1
- package/dist/resources/session-sync.d.ts +61 -0
- package/dist/resources/session-sync.d.ts.map +1 -1
- package/dist/resources/session-sync.js +54 -1
- package/dist/resources/session-sync.js.map +1 -1
- package/dist/resources/sessions.d.ts +74 -0
- package/dist/resources/sessions.d.ts.map +1 -1
- package/dist/resources/sessions.js +64 -2
- package/dist/resources/sessions.js.map +1 -1
- package/dist/resources/side-query.d.ts +18 -0
- package/dist/resources/side-query.d.ts.map +1 -1
- package/dist/resources/side-query.js +1 -0
- package/dist/resources/side-query.js.map +1 -1
- package/dist/resources/tasks.d.ts +19 -0
- package/dist/resources/tasks.d.ts.map +1 -1
- package/dist/resources/tasks.js +21 -2
- package/dist/resources/tasks.js.map +1 -1
- package/dist/resources/tool-approvals.d.ts +53 -0
- package/dist/resources/tool-approvals.d.ts.map +1 -1
- package/dist/resources/tool-approvals.js +10 -0
- package/dist/resources/tool-approvals.js.map +1 -1
- package/dist/resources/trace.d.ts +23 -0
- package/dist/resources/trace.d.ts.map +1 -1
- package/dist/resources/trace.js +27 -2
- package/dist/resources/trace.js.map +1 -1
- package/dist/resources/usage.d.ts +21 -0
- package/dist/resources/usage.d.ts.map +1 -1
- package/dist/resources/usage.js +8 -0
- package/dist/resources/usage.js.map +1 -1
- package/dist/resources/workflows.d.ts +48 -0
- package/dist/resources/workflows.d.ts.map +1 -1
- package/dist/resources/workflows.js +40 -3
- package/dist/resources/workflows.js.map +1 -1
- package/dist/settings.d.ts +90 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +24 -0
- package/dist/settings.js.map +1 -1
- package/dist/sse.d.ts +36 -0
- package/dist/sse.d.ts.map +1 -1
- package/dist/sse.js +53 -8
- package/dist/sse.js.map +1 -1
- package/dist/sync.d.ts +56 -0
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +48 -4
- package/dist/sync.js.map +1 -1
- package/dist/transport.d.ts +32 -0
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +40 -8
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +691 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,27 +1,80 @@
|
|
|
1
|
+
/** tool-approvals — [830]① live-stream TOOL-APPROVAL HITL (server 1.191+ `ToolApprovalCoordinator`, gated on
|
|
2
|
+
* `TOOL_APPROVAL_ENABLED`; server 1.214 tool-approval.js:113 `respond`). The THIRD sibling of
|
|
3
|
+
* {@link import("./questions.js").QuestionsResource} / {@link import("./elicitations.js").ElicitationsResource}:
|
|
4
|
+
* elicitation = an inbound-MCP-server ask, question = the agent's own AskUserQuestion, THIS = the ENGINE's
|
|
5
|
+
* permission gate ("may I run this tool?") surfaced to a live human — the suspended↔overlay bridge's decide面.
|
|
6
|
+
*
|
|
7
|
+
* 🔴 LIVE-ONLY + SAME-REPLICA (the `steer()`-class of HITL, NOT the durable approvals/checkpoint class —
|
|
8
|
+
* that is {@link import("./approvals.js").ApprovalsResource}): the parked ask is an in-memory promise with a
|
|
9
|
+
* 5-min TTL (server DEFAULT_APPROVAL_TTL_MS), so a respond that lands after settle / after the TTL / on
|
|
10
|
+
* another replica finds nothing → 404. An unanswered ask fail-closes to DENY engine-side (the run proceeds;
|
|
11
|
+
* it never hangs).
|
|
12
|
+
*
|
|
13
|
+
* 🔴 The `tool_approval` / `tool_approval_complete` FRAMES are NOT `AgentEvent` arms — they interleave on the
|
|
14
|
+
* live token stream exactly like `question`/`elicitation` frames. Tail them off `tasks.streamRaw`, dispatch on
|
|
15
|
+
* the SSE `event:` name (the payload echoes `type`), parse with {@link ToolApprovalFrame}, then decide via
|
|
16
|
+
* {@link ToolApprovalsResource.respond}.
|
|
17
|
+
*
|
|
18
|
+
* 🔴 UNTRUSTED for display: `message`/`args` are service secret-redacted (+ args size-bounded, >16 KiB →
|
|
19
|
+
* `argsOmitted:true`) but remain model/tool-authored — render only, never re-feed to a model. */
|
|
1
20
|
import type { Transport } from "../transport.js";
|
|
21
|
+
/** The human's decision (server `parseToolApprovalDecision`, tool-approval.js:15 — closed 3-word set; anything
|
|
22
|
+
* else is a 400). `allow_session` = allow AND remember for this session's category (fs-write tools share ONE
|
|
23
|
+
* category: approving Write covers Edit/NotebookEdit; other tools are per-tool) — the CC "don't ask again this
|
|
24
|
+
* session" semantic. */
|
|
2
25
|
export type ToolApprovalDecision = "allow" | "allow_session" | "deny";
|
|
26
|
+
/** A live tool-approval frame interleaved on the run's `tasks.streamRaw` connection (server `ToolApprovalFrame`,
|
|
27
|
+
* tool-approval.d.ts). `type` IS the SSE `event:` name AND is echoed in the payload. The shell renders the
|
|
28
|
+
* `tool_approval` frame as an allow/deny dialog and dismisses it on `tool_approval_complete`. */
|
|
3
29
|
export interface ToolApprovalFrame {
|
|
4
30
|
type: "tool_approval" | "tool_approval_complete";
|
|
31
|
+
/** The id to echo back to {@link ToolApprovalsResource.respond}. */
|
|
5
32
|
approvalId: string;
|
|
33
|
+
/** "tool_approval" only: the tool awaiting permission. */
|
|
6
34
|
toolName?: string;
|
|
35
|
+
/** "tool_approval" only: the engine's ask text, secret-redacted. UNTRUSTED — display only. */
|
|
7
36
|
message?: string;
|
|
37
|
+
/** "tool_approval" only: the pending call's args, redacted + size-bounded. Absent when `argsOmitted`. */
|
|
8
38
|
args?: unknown;
|
|
39
|
+
/** "tool_approval" only: args exceeded the 16 KiB bound (or failed to serialize) → omitted, render a stub. */
|
|
9
40
|
argsOmitted?: boolean;
|
|
41
|
+
/** "tool_approval_complete" only: how it settled (dialog dismiss reason). `expired` = TTL / abort / emit
|
|
42
|
+
* failure — the engine got the fail-closed deny. Cosmetic. */
|
|
10
43
|
outcome?: "allowed" | "denied" | "expired";
|
|
11
44
|
[k: string]: unknown;
|
|
12
45
|
}
|
|
46
|
+
/** The 200 ack from a successful respond (server tool-approval.js:133 — exact shape, `decision` echoed). */
|
|
13
47
|
export interface ToolApprovalRespondAck {
|
|
14
48
|
approvalId: string;
|
|
15
49
|
delivery: "applied";
|
|
16
50
|
decision: ToolApprovalDecision;
|
|
51
|
+
/** server 1.239([1392]②):allow_session 时诚实回显 remember 是否**真记了**(true=grant 落桥内店;
|
|
52
|
+
* false=无 sessionId 记不了,壳不得渲染「本 session 全放行」)。非 allow_session 决策=字段省略;
|
|
53
|
+
* 旧 server=恒缺席(tolerate-absent)。 */
|
|
17
54
|
rememberApplied?: boolean;
|
|
55
|
+
/** server 1.241([1458] ctrl+g 编辑放行):allow 族带 `updatedInput` 时=server 已把编辑后的 args 透传给
|
|
56
|
+
* 引擎(是否被消费取决于 core OnAsk 对象臂是否到位——诚实措辞:forwarded≠applied)。deny/未带编辑/
|
|
57
|
+
* 旧 server=字段省略(tolerate-absent)。 */
|
|
18
58
|
updatedInputForwarded?: boolean;
|
|
19
59
|
}
|
|
20
60
|
export declare class ToolApprovalsResource {
|
|
21
61
|
private readonly t;
|
|
22
62
|
constructor(t: Transport);
|
|
63
|
+
/** POST /v1/tool-approvals/:id/respond — settle a parked LIVE tool-approval gate with the human's decision.
|
|
64
|
+
* The engine's suspended tool call resumes (allow) or is refused (deny) on the still-open task connection.
|
|
65
|
+
*
|
|
66
|
+
* 🔴 OWNER-GATED with a 404 (NO existence oracle, server tool-approval.js:118): a non-owner AND an
|
|
67
|
+
* unknown/settled/expired/wrong-replica id both get the same 404 — never branch existence off the status.
|
|
68
|
+
* A malformed body (`decision` outside the 3-word set) is a 400 (existence-independent). A worker without
|
|
69
|
+
* `TOOL_APPROVAL_ENABLED` → 501 (probe `capabilities.toolApproval` instead of trial-by-501); missing
|
|
70
|
+
* principal on a require-principal worker → 401.
|
|
71
|
+
*
|
|
72
|
+
* Not a submit / not idempotent (it settles an in-flight promise exactly once) → NO SDK retry. */
|
|
23
73
|
respond(id: string, body: {
|
|
24
74
|
decision: ToolApprovalDecision;
|
|
75
|
+
/** server 1.241([1458] ctrl+g「edit script in $EDITOR」):allow 族可带编辑后的 tool args(**整体替换**形,
|
|
76
|
+
* 非 patch)。deny 上 server 静默忽略;旧 server 同样忽略未知键(前向兼容)。透传与否看 ack 的
|
|
77
|
+
* `updatedInputForwarded`。 */
|
|
25
78
|
updatedInput?: unknown;
|
|
26
79
|
}, opts?: {
|
|
27
80
|
signal?: AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-approvals.d.ts","sourceRoot":"","sources":["../../src/resources/tool-approvals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-approvals.d.ts","sourceRoot":"","sources":["../../src/resources/tool-approvals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;kGAkBkG;AAClG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;yBAGyB;AACzB,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,eAA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/:id/respond — settle a parked LIVE tool-approval gate with the human's decision.
|
|
7
|
+
* The engine's suspended tool call resumes (allow) or is refused (deny) on the still-open task connection.
|
|
8
|
+
*
|
|
9
|
+
* 🔴 OWNER-GATED with a 404 (NO existence oracle, server tool-approval.js:118): a non-owner AND an
|
|
10
|
+
* unknown/settled/expired/wrong-replica id both get the same 404 — never branch existence off the status.
|
|
11
|
+
* A malformed body (`decision` outside the 3-word set) is a 400 (existence-independent). A worker without
|
|
12
|
+
* `TOOL_APPROVAL_ENABLED` → 501 (probe `capabilities.toolApproval` instead of trial-by-501); missing
|
|
13
|
+
* principal on a require-principal worker → 401.
|
|
14
|
+
*
|
|
15
|
+
* Not a submit / not idempotent (it settles an in-flight promise exactly once) → NO SDK retry. */
|
|
6
16
|
async respond(id, body, opts) {
|
|
7
17
|
return this.t.request({
|
|
8
18
|
method: "POST",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-approvals.js","sourceRoot":"","sources":["../../src/resources/tool-approvals.ts"],"names":[],"mappings":"AA+DA,MAAM,OAAO,qBAAqB;IACH;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-approvals.js","sourceRoot":"","sources":["../../src/resources/tool-approvals.ts"],"names":[],"mappings":"AA+DA,MAAM,OAAO,qBAAqB;IACH;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;IAE7C;;;;;;;;;uGASmG;IACnG,KAAK,CAAC,OAAO,CACX,EAAU,EACV,IAMC,EACD,IAA+B;QAE/B,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAyB;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,sBAAsB,kBAAkB,CAAC,EAAE,CAAC,UAAU;YAC5D,IAAI;YACJ,MAAM,EAAE,IAAI,EAAE,MAAM;SACrB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
/** trace — the "工作区" data source (SERVICE-CORE-CONTEXT §3.5): full per-task turn trace = the action
|
|
2
|
+
* timeline; artifacts (diff/files/git-push) = the deliverable. Needs a SESSION_BACKEND=tidb worker.
|
|
3
|
+
* A web workspace view is built ENTIRELY from this — keep it the SHARED model for all doors. */
|
|
1
4
|
import type { Transport } from "../transport.js";
|
|
2
5
|
import type { Artifact, TaskSummary, TraceStreamEvent, TraceTurn } from "../types.js";
|
|
3
6
|
export declare class TraceResource {
|
|
4
7
|
private readonly t;
|
|
5
8
|
constructor(t: Transport);
|
|
9
|
+
/** GET /v1/tasks — list runs. Envelope `{ tasks, nextCursor? }` (key `tasks`, pinned). `?jobId=`
|
|
10
|
+
* groups one logical job's runs (LIVE, [6]); `?source=` filters by credential-derived system ([40]);
|
|
11
|
+
* also `?status=`, `?limit=` (default 50, max 100). */
|
|
6
12
|
list(opts?: {
|
|
7
13
|
jobId?: string;
|
|
8
14
|
status?: string;
|
|
@@ -15,6 +21,8 @@ export declare class TraceResource {
|
|
|
15
21
|
tasks: TaskSummary[];
|
|
16
22
|
nextCursor?: string;
|
|
17
23
|
}>;
|
|
24
|
+
/** GET /v1/tasks/source-summary?sinceSec= — per-door usage rollup `{rows:[{source,status,count}]}`
|
|
25
|
+
* (the pinned wire contract; trace-auth surface). The web usage overview's data source. */
|
|
18
26
|
sourceSummary(opts?: {
|
|
19
27
|
sinceSec?: number;
|
|
20
28
|
signal?: AbortSignal;
|
|
@@ -25,6 +33,8 @@ export declare class TraceResource {
|
|
|
25
33
|
count: number;
|
|
26
34
|
}[];
|
|
27
35
|
}>;
|
|
36
|
+
/** GET /v1/tasks/:id/turns — the full turn trace (the workspace action timeline). Envelope
|
|
37
|
+
* `{ turns, nextCursor?, retainedFrom }` (pinned wire contract); turn item shape draft. */
|
|
28
38
|
turns(taskId: string, opts?: {
|
|
29
39
|
signal?: AbortSignal;
|
|
30
40
|
}): Promise<{
|
|
@@ -32,9 +42,22 @@ export declare class TraceResource {
|
|
|
32
42
|
nextCursor?: string;
|
|
33
43
|
retainedFrom?: number;
|
|
34
44
|
}>;
|
|
45
|
+
/** GET /v1/tasks/:id/artifacts — workspace artifacts (projection of the persisted trace; co-signed
|
|
46
|
+
* the pinned wire contract). Job-level aggregation = list by jobId then fetch per run (each carries taskId+jobId). */
|
|
35
47
|
artifacts(taskId: string, opts?: {
|
|
36
48
|
signal?: AbortSignal;
|
|
37
49
|
}): Promise<Artifact[]>;
|
|
50
|
+
/** GET /v1/tasks/:id/stream — the workspace LIVE timeline (`streamTaskTrace` + `mapTraceEvent`, server.ts).
|
|
51
|
+
* RESUMABLE SSE with a DISTINCT vocabulary from `runs.events`/AgentEvent: the durable log is BLOCK-grained,
|
|
52
|
+
* so each frame is a `block-content-delta` / `block-thinking-delta` / `tool-call` / `tool-result` / `turn` /
|
|
53
|
+
* `done` / `error` delta the client appends (see `TraceStreamEvent`). The FIRST frame is `meta`
|
|
54
|
+
* `{version, mode, resumeFrom}`. Each frame's `id:` = the durable `task_event.seq`; on a window eviction the
|
|
55
|
+
* server returns 416 (`{retainedFrom}`) and this reader transparently resumes from `retainedFrom` (the
|
|
56
|
+
* consumer should full-sync the gap via `trace.turns`). `heartbeat` keep-alives are swallowed (never yielded).
|
|
57
|
+
*
|
|
58
|
+
* ⚠️ This is NOT `runs.events` (which yields the typed `AgentEvent` union from `/v1/runs/:id/events`). Use this
|
|
59
|
+
* for the workspace/trace VIEW; use `runs.events` for the durable run lifecycle stream. A `done` with
|
|
60
|
+
* `data.suspended === true` means the run PAUSED on HITL (not completed). */
|
|
38
61
|
stream(taskId: string, opts?: {
|
|
39
62
|
signal?: AbortSignal;
|
|
40
63
|
lastEventId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/resources/trace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/resources/trace.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2HACuH;IACjH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IASrF;;;;;;;;;;kFAU8E;IACvE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc,CAAC,gBAAgB,CAAC;CA6BvH"}
|
package/dist/resources/trace.js
CHANGED
|
@@ -4,6 +4,9 @@ export class TraceResource {
|
|
|
4
4
|
constructor(t) {
|
|
5
5
|
this.t = t;
|
|
6
6
|
}
|
|
7
|
+
/** GET /v1/tasks — list runs. Envelope `{ tasks, nextCursor? }` (key `tasks`, pinned). `?jobId=`
|
|
8
|
+
* groups one logical job's runs (LIVE, [6]); `?source=` filters by credential-derived system ([40]);
|
|
9
|
+
* also `?status=`, `?limit=` (default 50, max 100). */
|
|
7
10
|
async list(opts) {
|
|
8
11
|
const q = new URLSearchParams();
|
|
9
12
|
if (opts?.jobId)
|
|
@@ -21,13 +24,19 @@ export class TraceResource {
|
|
|
21
24
|
const qs = q.toString();
|
|
22
25
|
return this.t.request({ method: "GET", path: `/v1/tasks${qs ? `?${qs}` : ""}`, signal: opts?.signal });
|
|
23
26
|
}
|
|
27
|
+
/** GET /v1/tasks/source-summary?sinceSec= — per-door usage rollup `{rows:[{source,status,count}]}`
|
|
28
|
+
* (the pinned wire contract; trace-auth surface). The web usage overview's data source. */
|
|
24
29
|
async sourceSummary(opts) {
|
|
25
30
|
const qs = opts?.sinceSec ? `?sinceSec=${opts.sinceSec}` : "";
|
|
26
31
|
return this.t.request({ method: "GET", path: `/v1/tasks/source-summary${qs}`, signal: opts?.signal });
|
|
27
32
|
}
|
|
33
|
+
/** GET /v1/tasks/:id/turns — the full turn trace (the workspace action timeline). Envelope
|
|
34
|
+
* `{ turns, nextCursor?, retainedFrom }` (pinned wire contract); turn item shape draft. */
|
|
28
35
|
async turns(taskId, opts) {
|
|
29
36
|
return this.t.request({ method: "GET", path: `/v1/tasks/${encodeURIComponent(taskId)}/turns`, signal: opts?.signal });
|
|
30
37
|
}
|
|
38
|
+
/** GET /v1/tasks/:id/artifacts — workspace artifacts (projection of the persisted trace; co-signed
|
|
39
|
+
* the pinned wire contract). Job-level aggregation = list by jobId then fetch per run (each carries taskId+jobId). */
|
|
31
40
|
async artifacts(taskId, opts) {
|
|
32
41
|
const r = await this.t.request({
|
|
33
42
|
method: "GET",
|
|
@@ -36,6 +45,17 @@ export class TraceResource {
|
|
|
36
45
|
});
|
|
37
46
|
return r.artifacts;
|
|
38
47
|
}
|
|
48
|
+
/** GET /v1/tasks/:id/stream — the workspace LIVE timeline (`streamTaskTrace` + `mapTraceEvent`, server.ts).
|
|
49
|
+
* RESUMABLE SSE with a DISTINCT vocabulary from `runs.events`/AgentEvent: the durable log is BLOCK-grained,
|
|
50
|
+
* so each frame is a `block-content-delta` / `block-thinking-delta` / `tool-call` / `tool-result` / `turn` /
|
|
51
|
+
* `done` / `error` delta the client appends (see `TraceStreamEvent`). The FIRST frame is `meta`
|
|
52
|
+
* `{version, mode, resumeFrom}`. Each frame's `id:` = the durable `task_event.seq`; on a window eviction the
|
|
53
|
+
* server returns 416 (`{retainedFrom}`) and this reader transparently resumes from `retainedFrom` (the
|
|
54
|
+
* consumer should full-sync the gap via `trace.turns`). `heartbeat` keep-alives are swallowed (never yielded).
|
|
55
|
+
*
|
|
56
|
+
* ⚠️ This is NOT `runs.events` (which yields the typed `AgentEvent` union from `/v1/runs/:id/events`). Use this
|
|
57
|
+
* for the workspace/trace VIEW; use `runs.events` for the durable run lifecycle stream. A `done` with
|
|
58
|
+
* `data.suspended === true` means the run PAUSED on HITL (not completed). */
|
|
39
59
|
async *stream(taskId, opts) {
|
|
40
60
|
let first = opts?.lastEventId;
|
|
41
61
|
const frames = parseFrameStream((lastEventId) => {
|
|
@@ -50,11 +70,16 @@ export class TraceResource {
|
|
|
50
70
|
if (opts?.signal)
|
|
51
71
|
o.signal = opts.signal;
|
|
52
72
|
return this.t.openStream(o);
|
|
53
|
-
},
|
|
73
|
+
},
|
|
74
|
+
// terminal frames: the run ended (`done`) or hard-failed (`error`). A `done{suspended:true}` (HITL pause)
|
|
75
|
+
// is ALSO terminal for THIS stream — the run is no longer producing trace deltas until resumed.
|
|
76
|
+
(f) => f.event === "done" || f.event === "error", opts?.signal ? { signal: opts.signal } : undefined);
|
|
54
77
|
for await (const f of frames) {
|
|
78
|
+
// server keep-alives are `event: heartbeat\ndata: {}` (a real data line, NOT a bare `:` comment) — swallow
|
|
79
|
+
// by NAME; also drop any genuinely data-less frame (a bare `:` comment beat).
|
|
55
80
|
if (f.event === "heartbeat" || !f.data)
|
|
56
81
|
continue;
|
|
57
|
-
const data = JSON.parse(f.data);
|
|
82
|
+
const data = JSON.parse(f.data); // SyntaxError = contract breach → rethrown by reader
|
|
58
83
|
const ev = { event: (f.event ?? "message"), data };
|
|
59
84
|
if (f.id)
|
|
60
85
|
ev.id = f.id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/resources/trace.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/resources/trace.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;IAE7C;;4DAEwD;IACxD,KAAK,CAAC,IAAI,CAAC,IAAkI;QAC3I,MA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C,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9B,CAAC;QACD,0GAA0G;QAC1G,gGAAgG;QAChG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,IAAI,CAAC,CAAC,KAAK,KAAK,OAAO,EAChD,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CACnD,CAAC;QACF,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YAC7B,2GAA2G;YAC3G,8EAA8E;YAC9E,IAAI,CAAC,CAAC,KAAK,KAAK,WAAW,IAAI,CAAC,CAAC,CAAC,IAAI;gBAAE,SAAS;YACjD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAA4B,CAAC,CAAC,qDAAqD;YACjH,MAAM,EAAE,GAAqB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,SAAS,CAA8B,EAAE,IAAI,EAAE,CAAC;YAClG,IAAI,CAAC,CAAC,EAAE;gBAAE,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,31 +1,52 @@
|
|
|
1
|
+
/** usage — §cost/usage 面板的**只读**数据源(service `GET /v1/usage`,实测形态 the pinned wire contract)。
|
|
2
|
+
*
|
|
3
|
+
* `get` = `GET /v1/usage` → `UsageInfo`(per-principal 成本配额 + 单任务上限,worker 据 request principal 自算)。
|
|
4
|
+
* CLI `/cost` `/usage` 面板 + 门B 用量条渲它显真实「已用/剩余/上限」(取代静态占位)。
|
|
5
|
+
*
|
|
6
|
+
* 🔴 owner-scoped:用量按 request principal(BFF 注)算,client 不传 scope。失败由 caller fail-safe
|
|
7
|
+
* (`{enabled:false,...}` → 面板降级显「无配额数据」,同 models 范式;绝不阻断)。
|
|
8
|
+
* 🔴 只读 inspect:client 不据此放行/拦截(配额 enforcement 100% 在 worker;面板只展示)。 */
|
|
1
9
|
import type { Transport } from "../transport.js";
|
|
2
10
|
import type { UsageInfo } from "../types.js";
|
|
3
11
|
export declare class UsageResource {
|
|
4
12
|
private readonly t;
|
|
5
13
|
constructor(t: Transport);
|
|
14
|
+
/** GET /v1/usage — per-principal 成本配额 + 单任务上限。无配额时 `{enabled:false, windowSec?, maxTask*}`。 */
|
|
6
15
|
get(opts?: {
|
|
7
16
|
signal?: AbortSignal;
|
|
8
17
|
}): Promise<UsageInfo>;
|
|
18
|
+
/** GET /v1/usage/summary — 窗内用量总账(server ≥1.20x usage-analytics 面,server.ts /v1/usage/ 分发实拆)。
|
|
19
|
+
* `from`/`to` = ISO-8601 或 epoch-ms(缺省近 7 天);JWT 主体强制 owner=本人,fleet 凭证可传 `principal`。
|
|
20
|
+
* 501 = 无 run store;`truncated:true` = 扫描窗被截。 */
|
|
9
21
|
summary(opts?: UsageAnalyticsParams & {
|
|
10
22
|
signal?: AbortSignal;
|
|
11
23
|
}): Promise<UsageSummary>;
|
|
24
|
+
/** GET /v1/usage/series — 时序(UTC 桶,空桶不发行——消费方按需补零)。metric=tasks|tokensIn|tokensOut|costUsd
|
|
25
|
+
* (缺省 costUsd),granularity=hour|day(缺省 day)。 */
|
|
12
26
|
series(opts?: UsageAnalyticsParams & {
|
|
13
27
|
metric?: UsageMetric;
|
|
14
28
|
granularity?: UsageGranularity;
|
|
15
29
|
signal?: AbortSignal;
|
|
16
30
|
}): Promise<UsageSeries>;
|
|
31
|
+
/** GET /v1/usage/breakdown — 维度分桶。dimension=principal|model(缺省 principal;JWT 主体的 principal 桶
|
|
32
|
+
* 只会是本人一桶——owner 已强制,语义自然成立)。 */
|
|
17
33
|
breakdown(opts?: UsageAnalyticsParams & {
|
|
18
34
|
dimension?: UsageDimension;
|
|
19
35
|
signal?: AbortSignal;
|
|
20
36
|
}): Promise<UsageBreakdown>;
|
|
21
37
|
}
|
|
38
|
+
/** usage-analytics 公共窗口参数(server 校验 from<to,坏形 400)。 */
|
|
22
39
|
export interface UsageAnalyticsParams {
|
|
40
|
+
/** ISO-8601 或 epoch-ms;缺省 = now-7d。 */
|
|
23
41
|
from?: string | number;
|
|
42
|
+
/** ISO-8601 或 epoch-ms;缺省 = now。 */
|
|
24
43
|
to?: string | number;
|
|
44
|
+
/** fleet 凭证专用(JWT 主体被强制 owner=本人,该参数被忽略)。 */
|
|
25
45
|
principal?: string;
|
|
26
46
|
}
|
|
27
47
|
export type UsageMetric = "tasks" | "tokensIn" | "tokensOut" | "costUsd";
|
|
28
48
|
export type UsageGranularity = "hour" | "day";
|
|
49
|
+
/** 窗内总账(server usage-analytics.ts UsageTotals 实拆;estimated=有旧行走了 tokens fallback,token 口径部分估算)。 */
|
|
29
50
|
export interface UsageTotals {
|
|
30
51
|
tasks: number;
|
|
31
52
|
tokensIn: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;yEAOyE;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAAD,CAAC,EAAE,SAAS;IAEzC,+FAA+F;IACzF,GAAG,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAI9D;;sDAEkD;IAC5C,OAAO,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAA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AG,WAAW,CAAC;AACzD,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC;AAC5I,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,WAAW,CAAC,CAAA;CAAE,CAAC;AAC9H,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,OAAO,CAAC"}
|
package/dist/resources/usage.js
CHANGED
|
@@ -3,12 +3,18 @@ export class UsageResource {
|
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.t = t;
|
|
5
5
|
}
|
|
6
|
+
/** GET /v1/usage — per-principal 成本配额 + 单任务上限。无配额时 `{enabled:false, windowSec?, maxTask*}`。 */
|
|
6
7
|
async get(opts) {
|
|
7
8
|
return this.t.request({ method: "GET", path: "/v1/usage", signal: opts?.signal });
|
|
8
9
|
}
|
|
10
|
+
/** GET /v1/usage/summary — 窗内用量总账(server ≥1.20x usage-analytics 面,server.ts /v1/usage/ 分发实拆)。
|
|
11
|
+
* `from`/`to` = ISO-8601 或 epoch-ms(缺省近 7 天);JWT 主体强制 owner=本人,fleet 凭证可传 `principal`。
|
|
12
|
+
* 501 = 无 run store;`truncated:true` = 扫描窗被截。 */
|
|
9
13
|
async summary(opts) {
|
|
10
14
|
return this.t.request({ method: "GET", path: `/v1/usage/summary${analyticsQuery(opts)}`, signal: opts?.signal });
|
|
11
15
|
}
|
|
16
|
+
/** GET /v1/usage/series — 时序(UTC 桶,空桶不发行——消费方按需补零)。metric=tasks|tokensIn|tokensOut|costUsd
|
|
17
|
+
* (缺省 costUsd),granularity=hour|day(缺省 day)。 */
|
|
12
18
|
async series(opts) {
|
|
13
19
|
const extra = new URLSearchParams();
|
|
14
20
|
if (opts?.metric)
|
|
@@ -17,6 +23,8 @@ export class UsageResource {
|
|
|
17
23
|
extra.set("granularity", opts.granularity);
|
|
18
24
|
return this.t.request({ method: "GET", path: `/v1/usage/series${analyticsQuery(opts, extra)}`, signal: opts?.signal });
|
|
19
25
|
}
|
|
26
|
+
/** GET /v1/usage/breakdown — 维度分桶。dimension=principal|model(缺省 principal;JWT 主体的 principal 桶
|
|
27
|
+
* 只会是本人一桶——owner 已强制,语义自然成立)。 */
|
|
20
28
|
async breakdown(opts) {
|
|
21
29
|
const extra = new URLSearchParams();
|
|
22
30
|
if (opts?.dimension)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;IAE7C,+FAA+F;IAC/F,KAAK,CAAC,GAAG,CAAC,IAA+B;QACvC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACpF,CAAC;IAED;;sDAEkD;IAClD,KAAK,CAAC,OAAO,CAAC,IAAsD;QAClE,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,oBAAoB,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,M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AK,SAAS;QAAE,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,IAAI,IAAI,EAAE,SAAS;QAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACxD,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxB,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
/** workflows — §workflow 可观测(core 1.116 design/97 observe API;service `GET /v1/workflows*`)。
|
|
2
|
+
*
|
|
3
|
+
* `list` = `GET /v1/workflows?status=&limit=` → `{workflows: WorkflowRunSummary[]}`(**owner-scoped**:只返调用方 principal 自己的 run)。
|
|
4
|
+
* `get` = `GET /v1/workflows/:id` → 完整 `WorkflowRun`(phases/agents/stats)。**非 owner → 404**(无 existence oracle)。
|
|
5
|
+
*
|
|
6
|
+
* 🔴 S8(LLM 自助编排)现 flag-gated off → 端点回 **501**;enable 后即活。按契约消费,caller fail-safe 501/空。
|
|
7
|
+
* 🔴 in-process replica-local:list 只见**本副本**的 run(同 worker 亲和;durable 跨副本历史是 service follow-on)。
|
|
8
|
+
* 🔴 实时进度 `GET /v1/workflows/:id/stream`(SSE,首帧 `event:meta`,后续 `event:<type> data:<JSON>`,replica-local 无 resume)
|
|
9
|
+
* 不复用 `parseSse`(其硬编码 AgentEvent + 自动重连,与 workflow 帧/无-resume 语义冲突)→ 留**专用 reader follow-on**。 */
|
|
1
10
|
import type { Transport } from "../transport.js";
|
|
2
11
|
import type { WorkflowRunSummary, WorkflowRun, WorkflowStreamEvent } from "../types.js";
|
|
12
|
+
/** workflow-agent steer 200 receipt (server 1.214 server.js:1755 — exact literal: `status:"running"`,
|
|
13
|
+
* `delivery:"applied"`, `marker` = the engine-minted delivery marker; NO `note`, unlike the run-subagent verb). */
|
|
3
14
|
export interface WorkflowAgentSteerReceipt {
|
|
4
15
|
runId: string;
|
|
5
16
|
label: string;
|
|
@@ -10,7 +21,18 @@ export interface WorkflowAgentSteerReceipt {
|
|
|
10
21
|
export declare class WorkflowsResource {
|
|
11
22
|
private readonly t;
|
|
12
23
|
constructor(t: Transport);
|
|
24
|
+
/** server 1.247 ([1508]) — `?session=` on the workflow per-id faces (accept-phase, run-face sibling):
|
|
25
|
+
* pass your conversation's sessionId on get/journal/stream/steerAgent. Today a MISMATCH against the run's
|
|
26
|
+
* `originatingSessionId` → 404 (absence passes; a run without the field is principal-only); the
|
|
27
|
+
* enforcement train will 404 absence too — new code should always send it. Send a real sessionId or
|
|
28
|
+
* nothing (an EMPTY string counts as present-and-mismatched). On `list` the param is accepted but not yet
|
|
29
|
+
* filtering (summary rows lack the field — pending a core addition); harmless forward-compat. */
|
|
13
30
|
private sessionQs;
|
|
31
|
+
/** GET /v1/workflows — owner-scoped run 列表(summary 投影)。filter:status/limit。信封 `{workflows}`。 */
|
|
32
|
+
/** GET /v1/workflows/:runId/journal — the per-agent journal read face(server 1.239,[1402]/[1400]④:
|
|
33
|
+
* workflow 失败诊断的模型/面板可见读面,云本地同构)。Entries ride ordinal-ordered:
|
|
34
|
+
* `{callKey, ordinal, status, error?(首行), result?(bounded+redacted), tokens?, turns?}`。
|
|
35
|
+
* 404 = run 不存在/非 owner(无存在性 oracle);501 = journal store 未接(self-orchestration off)。 */
|
|
14
36
|
journal(runId: string, opts?: {
|
|
15
37
|
session?: string;
|
|
16
38
|
signal?: AbortSignal;
|
|
@@ -26,6 +48,10 @@ export declare class WorkflowsResource {
|
|
|
26
48
|
turns?: number;
|
|
27
49
|
}>;
|
|
28
50
|
}>;
|
|
51
|
+
/** `session` filter semantics(distinct from the per-id accept-phase): present = strict-equality filter
|
|
52
|
+
* on the run's `originatingSessionId` (fieldless pre-core-1.210 rows are dropped); absent = full list.
|
|
53
|
+
* server 1.249 filtered the returned newest-`limit` page; server 1.250+ pushes the filter into the store
|
|
54
|
+
* (applied BEFORE limit — a busy scope no longer hides this session's older runs). */
|
|
29
55
|
list(opts?: {
|
|
30
56
|
status?: string;
|
|
31
57
|
limit?: number;
|
|
@@ -34,16 +60,38 @@ export declare class WorkflowsResource {
|
|
|
34
60
|
}): Promise<{
|
|
35
61
|
workflows: WorkflowRunSummary[];
|
|
36
62
|
}>;
|
|
63
|
+
/** GET /v1/workflows/:id — 完整 run。非 owner / 不存在 / session 不匹配 → 404(不暴露 existence)。 */
|
|
37
64
|
get(id: string, opts?: {
|
|
38
65
|
session?: string;
|
|
39
66
|
signal?: AbortSignal;
|
|
40
67
|
}): Promise<WorkflowRun>;
|
|
68
|
+
/** server 1.214 (server.js:1706 WORKFLOW_AGENT_STEER_RE region) — STEER a RUNNING AGENT of a WORKFLOW run
|
|
69
|
+
* (the S8 self-orchestration sibling of `runs.steerSubagent`): inject `content` into the labelled live agent;
|
|
70
|
+
* it drains at the agent's next tool round. `label` = the workflow-graph agent label (NOT a toolCallId);
|
|
71
|
+
* a label shared by >1 live agents → 409 `steering.ambiguous_label`. Body `{ content }` (non-empty, else 400).
|
|
72
|
+
* 200 {@link WorkflowAgentSteerReceipt} (`marker`, no `note`).
|
|
73
|
+
*
|
|
74
|
+
* 🔴 REPLICA-LOCAL live handle: 409 `steering.not_running` = agent settled / workflow not running / live on
|
|
75
|
+
* another replica (cross-replica live-steer unsupported). 501 = worker without SELF_ORCHESTRATION_ENABLED
|
|
76
|
+
* (gate on `capabilities.workflows`). Owner-scoped 404 (operator principals bypass). AT-MOST-ONCE (no retry). */
|
|
41
77
|
steerAgent(runId: string, label: string, message: {
|
|
42
78
|
content: string;
|
|
43
79
|
}, opts?: {
|
|
44
80
|
session?: string;
|
|
45
81
|
signal?: AbortSignal;
|
|
46
82
|
}): Promise<WorkflowAgentSteerReceipt>;
|
|
83
|
+
/** GET /v1/workflows/:id/stream — LIVE S8 self-orchestration progress (`streamWorkflowRun` +
|
|
84
|
+
* core `subscribeWorkflow`, server.ts). SSE; FIRST frame is `meta` `{version, runId}`, then each subsequent
|
|
85
|
+
* frame carries a core `WorkflowEvent` (its `type` becomes the SSE `event` name; see `WorkflowStreamEvent`).
|
|
86
|
+
*
|
|
87
|
+
* 🔴 NOT RESUMABLE (unlike `runs.events`/`trace.stream`): the source is REPLICA-LOCAL + in-process — there is
|
|
88
|
+
* NO durable seq / Last-Event-ID, so a drop is a FULL restart (re-`get()` for the snapshot), not a resume.
|
|
89
|
+
* Deliberately does NOT reuse `parseSse`/`parseFrameStream` (those auto-reconnect with Last-Event-ID, which
|
|
90
|
+
* would silently lose/duplicate frames here). TRANSIENT: a disconnect just ends the iterator. S8 flag-gated
|
|
91
|
+
* off → the route returns 501 (typed error) before any frame; owner-gated (non-owner → 404).
|
|
92
|
+
*
|
|
93
|
+
* No explicit terminal frame is guaranteed (the core subscription simply ends) — the generator returns when the
|
|
94
|
+
* server closes the stream; `get()` for the authoritative terminal `status`. */
|
|
47
95
|
stream(id: string, opts?: {
|
|
48
96
|
session?: string;
|
|
49
97
|
signal?: AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/resources/workflows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/resources/workflows.ts"],"names":[],"mappings":"AAAA;;;;;;;;sGAQsG;AACtG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIxF;oHACoH;AACpH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC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,EAAE,MAAM,CAAA;KAAE,EAC5B,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAChD,OAAO,CAAC,yBAAyB,CAAC;IASrC;;;;;;;;;;;qFAWiF;IAC1E,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,cAAc,CAAC,mBAAmB,CAAC;CAkBlH"}
|
|
@@ -5,12 +5,27 @@ export class WorkflowsResource {
|
|
|
5
5
|
constructor(t) {
|
|
6
6
|
this.t = t;
|
|
7
7
|
}
|
|
8
|
+
/** server 1.247 ([1508]) — `?session=` on the workflow per-id faces (accept-phase, run-face sibling):
|
|
9
|
+
* pass your conversation's sessionId on get/journal/stream/steerAgent. Today a MISMATCH against the run's
|
|
10
|
+
* `originatingSessionId` → 404 (absence passes; a run without the field is principal-only); the
|
|
11
|
+
* enforcement train will 404 absence too — new code should always send it. Send a real sessionId or
|
|
12
|
+
* nothing (an EMPTY string counts as present-and-mismatched). On `list` the param is accepted but not yet
|
|
13
|
+
* filtering (summary rows lack the field — pending a core addition); harmless forward-compat. */
|
|
8
14
|
sessionQs(session) {
|
|
9
15
|
return session !== undefined ? `?session=${encodeURIComponent(session)}` : "";
|
|
10
16
|
}
|
|
17
|
+
/** GET /v1/workflows — owner-scoped run 列表(summary 投影)。filter:status/limit。信封 `{workflows}`。 */
|
|
18
|
+
/** GET /v1/workflows/:runId/journal — the per-agent journal read face(server 1.239,[1402]/[1400]④:
|
|
19
|
+
* workflow 失败诊断的模型/面板可见读面,云本地同构)。Entries ride ordinal-ordered:
|
|
20
|
+
* `{callKey, ordinal, status, error?(首行), result?(bounded+redacted), tokens?, turns?}`。
|
|
21
|
+
* 404 = run 不存在/非 owner(无存在性 oracle);501 = journal store 未接(self-orchestration off)。 */
|
|
11
22
|
async journal(runId, opts) {
|
|
12
23
|
return this.t.request({ method: "GET", path: `/v1/workflows/${encodeURIComponent(runId)}/journal${this.sessionQs(opts?.session)}`, signal: opts?.signal });
|
|
13
24
|
}
|
|
25
|
+
/** `session` filter semantics(distinct from the per-id accept-phase): present = strict-equality filter
|
|
26
|
+
* on the run's `originatingSessionId` (fieldless pre-core-1.210 rows are dropped); absent = full list.
|
|
27
|
+
* server 1.249 filtered the returned newest-`limit` page; server 1.250+ pushes the filter into the store
|
|
28
|
+
* (applied BEFORE limit — a busy scope no longer hides this session's older runs). */
|
|
14
29
|
async list(opts) {
|
|
15
30
|
const q = new URLSearchParams();
|
|
16
31
|
if (opts?.status)
|
|
@@ -22,9 +37,19 @@ export class WorkflowsResource {
|
|
|
22
37
|
const qs = q.toString();
|
|
23
38
|
return this.t.request({ method: "GET", path: `/v1/workflows${qs ? `?${qs}` : ""}`, signal: opts?.signal });
|
|
24
39
|
}
|
|
40
|
+
/** GET /v1/workflows/:id — 完整 run。非 owner / 不存在 / session 不匹配 → 404(不暴露 existence)。 */
|
|
25
41
|
async get(id, opts) {
|
|
26
42
|
return this.t.request({ method: "GET", path: `/v1/workflows/${encodeURIComponent(id)}${this.sessionQs(opts?.session)}`, signal: opts?.signal });
|
|
27
43
|
}
|
|
44
|
+
/** server 1.214 (server.js:1706 WORKFLOW_AGENT_STEER_RE region) — STEER a RUNNING AGENT of a WORKFLOW run
|
|
45
|
+
* (the S8 self-orchestration sibling of `runs.steerSubagent`): inject `content` into the labelled live agent;
|
|
46
|
+
* it drains at the agent's next tool round. `label` = the workflow-graph agent label (NOT a toolCallId);
|
|
47
|
+
* a label shared by >1 live agents → 409 `steering.ambiguous_label`. Body `{ content }` (non-empty, else 400).
|
|
48
|
+
* 200 {@link WorkflowAgentSteerReceipt} (`marker`, no `note`).
|
|
49
|
+
*
|
|
50
|
+
* 🔴 REPLICA-LOCAL live handle: 409 `steering.not_running` = agent settled / workflow not running / live on
|
|
51
|
+
* another replica (cross-replica live-steer unsupported). 501 = worker without SELF_ORCHESTRATION_ENABLED
|
|
52
|
+
* (gate on `capabilities.workflows`). Owner-scoped 404 (operator principals bypass). AT-MOST-ONCE (no retry). */
|
|
28
53
|
async steerAgent(runId, label, message, opts) {
|
|
29
54
|
return this.t.request({
|
|
30
55
|
method: "POST",
|
|
@@ -33,6 +58,18 @@ export class WorkflowsResource {
|
|
|
33
58
|
signal: opts?.signal,
|
|
34
59
|
});
|
|
35
60
|
}
|
|
61
|
+
/** GET /v1/workflows/:id/stream — LIVE S8 self-orchestration progress (`streamWorkflowRun` +
|
|
62
|
+
* core `subscribeWorkflow`, server.ts). SSE; FIRST frame is `meta` `{version, runId}`, then each subsequent
|
|
63
|
+
* frame carries a core `WorkflowEvent` (its `type` becomes the SSE `event` name; see `WorkflowStreamEvent`).
|
|
64
|
+
*
|
|
65
|
+
* 🔴 NOT RESUMABLE (unlike `runs.events`/`trace.stream`): the source is REPLICA-LOCAL + in-process — there is
|
|
66
|
+
* NO durable seq / Last-Event-ID, so a drop is a FULL restart (re-`get()` for the snapshot), not a resume.
|
|
67
|
+
* Deliberately does NOT reuse `parseSse`/`parseFrameStream` (those auto-reconnect with Last-Event-ID, which
|
|
68
|
+
* would silently lose/duplicate frames here). TRANSIENT: a disconnect just ends the iterator. S8 flag-gated
|
|
69
|
+
* off → the route returns 501 (typed error) before any frame; owner-gated (non-owner → 404).
|
|
70
|
+
*
|
|
71
|
+
* No explicit terminal frame is guaranteed (the core subscription simply ends) — the generator returns when the
|
|
72
|
+
* server closes the stream; `get()` for the authoritative terminal `status`. */
|
|
36
73
|
async *stream(id, opts) {
|
|
37
74
|
const o = {
|
|
38
75
|
method: "GET",
|
|
@@ -42,17 +79,17 @@ export class WorkflowsResource {
|
|
|
42
79
|
o.signal = opts.signal;
|
|
43
80
|
const res = await this.t.openStream(o);
|
|
44
81
|
if (!res.ok)
|
|
45
|
-
throw toApiError(res.status, await res.json().catch(() => ({})));
|
|
82
|
+
throw toApiError(res.status, await res.json().catch(() => ({}))); // 501 (S8 off) / 404 (non-owner) — before any frame
|
|
46
83
|
try {
|
|
47
84
|
for await (const frame of readSseFrames(res, undefined, opts?.signal)) {
|
|
48
85
|
if (!frame.data)
|
|
49
|
-
continue;
|
|
86
|
+
continue; // heartbeat / comment
|
|
50
87
|
const data = JSON.parse(frame.data);
|
|
51
88
|
yield { event: (frame.event ?? "message"), data };
|
|
52
89
|
}
|
|
53
90
|
}
|
|
54
91
|
finally {
|
|
55
|
-
res.body?.cancel().catch(() => { });
|
|
92
|
+
res.body?.cancel().catch(() => { }); // disconnect = stop the in-process subscription
|
|
56
93
|
}
|
|
57
94
|
}
|
|
58
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/resources/workflows.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY1C,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/resources/workflows.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY1C,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;IAE7C;;;;;sGAKkG;IAC1F,SAAS,CAAC,OAAgB;QAChC,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,CAAC;IAED,gGAAgG;IAChG;;;6FAGyF;IACzF,KAAK,CAAC,OAAO,CAAC,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