@sema-agent/sdk 0.0.75 → 0.0.77
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 +214 -20
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +5 -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 +101 -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 +147 -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 +60 -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 +709 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
/** sessions — the "对话框" continuity is sessionId on TaskRequest; this resource is the AUDIT read + the
|
|
2
|
+
* E16/E17/E21 lifecycle (list / fork / delete) + E6 per-session policy (permissionMode) + E9 MCP status panel.
|
|
3
|
+
* All owner-scoped: a non-owner read/fork/delete/policy returns 404 (no existence oracle), parity with runs.
|
|
4
|
+
* The durable surfaces (list/fork/delete/policy) 501 when no durable session store is wired (SESSION_BACKEND=tidb)
|
|
5
|
+
* — gate UI off `capabilities()` instead of trial-by-501. */
|
|
1
6
|
import type { Transport } from "../transport.js";
|
|
2
7
|
import { SessionSyncResource } from "./session-sync.js";
|
|
3
8
|
import type { SessionRecord, SessionListPage, SessionMessageEnvelope, StoredSessionRules, SessionPermissionRules, McpStatusPanel } from "../types.js";
|
|
9
|
+
/** Window params of `GET /v1/sessions/:id` (server ≥1.162 four-face, board [611]).
|
|
10
|
+
* `tail=N` → last N messages + `window {offset,total}`; `before=<off>&limit=N` → the page
|
|
11
|
+
* `[max(0,before-N), before)` (offset stable within one floorEntryId generation); `blobCap=<bytes>`
|
|
12
|
+
* → over-limit string bodies truncated to a preview + message-level `truncated:true`.
|
|
13
|
+
* Values must be non-negative integers — anything else is dropped client-side (the server ignores
|
|
14
|
+
* malformed values anyway; the SDK just never sends junk). No params → the legacy full read,
|
|
15
|
+
* byte-identical to before. Old engine (<1.162) ignores the query and returns the full record
|
|
16
|
+
* with NO `window` field — probe that for honest degradation. */
|
|
4
17
|
export interface SessionGetParams {
|
|
5
18
|
tail?: number;
|
|
6
19
|
before?: number;
|
|
@@ -9,11 +22,22 @@ export interface SessionGetParams {
|
|
|
9
22
|
}
|
|
10
23
|
export declare class SessionsResource {
|
|
11
24
|
private readonly t;
|
|
25
|
+
/** 2c session-sync (P1d) — `client.sessions.sync.*`: PULL a cloud session's whole state (manifest + NDJSON entry
|
|
26
|
+
* stream + content-addressed blobs) or PUSH the local peer's into the cloud (PUT blobs → two-phase staged import).
|
|
27
|
+
* Gate off `capabilities().sessionSync`. See SessionSyncResource. */
|
|
12
28
|
readonly sync: SessionSyncResource;
|
|
13
29
|
constructor(t: Transport);
|
|
30
|
+
/** GET /v1/sessions/:id — owner-checked (non-owner → 404). True shape; `messages` is the
|
|
31
|
+
* current model context and can be LARGE — lazy-expand in UIs, or pass window params
|
|
32
|
+
* (`tail`/`before`+`limit`/`blobCap`, server ≥1.162 — see SessionGetParams) to pull a slice:
|
|
33
|
+
* the windowed response adds `window {offset,total}` (absent on an old engine = honest
|
|
34
|
+
* degradation probe). No params ⇒ legacy full read, byte-identical to before. */
|
|
14
35
|
get(sessionId: string, opts?: SessionGetParams & {
|
|
15
36
|
signal?: AbortSignal;
|
|
16
37
|
}): Promise<SessionRecord>;
|
|
38
|
+
/** GET /v1/sessions/:id/head — 会话追随轻探针(server ≥1.225,[1075]②):`{ sessionId, leafId }` +
|
|
39
|
+
* ETag(=leafId)。leafId 每次 append 都变=版本号——空闲期轮询判增量;传 `etag`(上次值)命中即
|
|
40
|
+
* `changed:false` 零 body(HTTP 304)。501=无 durable session store。 */
|
|
17
41
|
head(sessionId: string, opts?: {
|
|
18
42
|
etag?: string;
|
|
19
43
|
signal?: AbortSignal;
|
|
@@ -22,6 +46,11 @@ export declare class SessionsResource {
|
|
|
22
46
|
etag: string;
|
|
23
47
|
leafId?: string | null;
|
|
24
48
|
}>;
|
|
49
|
+
/** GET /v1/sessions/:id/events — session 级 SSE 真订阅(server ≥1.230,[1196] S1):`event: head`
|
|
50
|
+
* 帧流(latest-wins;server 侧 25s 心跳)。轮询→订阅的换轨面:每帧=`{ sessionId, leafId }` 新水位,
|
|
51
|
+
* 拿到即拉 tail 增量(内容职责仍在 tail/turns 面)。`lastLeafId` 传上次水位=命中现值时无首帧
|
|
52
|
+
* (304 同义);断线自动重连并以最近水位续(重复帧被服务端抑制)。503=帽满(消费方回落 head 轮询,
|
|
53
|
+
* `capabilities.sessionEvents` 预判);会话被删/换主时 server 主动断流,重连将 404 → 迭代器抛出。 */
|
|
25
54
|
watch(sessionId: string, opts?: {
|
|
26
55
|
lastLeafId?: string | null;
|
|
27
56
|
signal?: AbortSignal;
|
|
@@ -30,6 +59,8 @@ export declare class SessionsResource {
|
|
|
30
59
|
sessionId: string;
|
|
31
60
|
leafId: string | null;
|
|
32
61
|
}>;
|
|
62
|
+
/** GET /v1/sessions/:id/init — 壳启动一次性 banner bundle(E11;server.ts:4683 实拆):
|
|
63
|
+
* `{ sessionId, model:{provider,modelId}, mode? }`。worker-global 配置面(REQUIRE_PRINCIPAL 下需主体)。 */
|
|
33
64
|
init(sessionId: string, opts?: {
|
|
34
65
|
signal?: AbortSignal;
|
|
35
66
|
}): Promise<{
|
|
@@ -41,6 +72,9 @@ export declare class SessionsResource {
|
|
|
41
72
|
mode?: string;
|
|
42
73
|
[k: string]: unknown;
|
|
43
74
|
}>;
|
|
75
|
+
/** GET /v1/sessions/:id/settings — 有效合并设置只读视图(E24 读半场;server.ts:4705 实拆):
|
|
76
|
+
* `{ effective:{model,mode?,approvalRequire,commandPolicy,limits}, applied:{model} }`。写半场(PATCH)
|
|
77
|
+
* 需 core seam,当前诚实缺席——capabilities 不宣告 settings 写能力。 */
|
|
44
78
|
settings(sessionId: string, opts?: {
|
|
45
79
|
signal?: AbortSignal;
|
|
46
80
|
}): Promise<{
|
|
@@ -62,6 +96,9 @@ export declare class SessionsResource {
|
|
|
62
96
|
};
|
|
63
97
|
[k: string]: unknown;
|
|
64
98
|
}>;
|
|
99
|
+
/** POST /v1/sessions/:id/notify — 会话外事件注入(daemon 终态回报等;server.ts:5398 实拆)。
|
|
100
|
+
* body: `{ task_id, status: completed|failed|killed|cancelled|event, summary, result?, seq?, source? }`;
|
|
101
|
+
* 坏形 400 typed;owner 门 fail-closed(未知/他人 session=404 无 oracle;env-only 无 ownerOf=501)。 */
|
|
65
102
|
notify(sessionId: string, body: {
|
|
66
103
|
task_id: string;
|
|
67
104
|
status: "completed" | "failed" | "killed" | "cancelled" | "event";
|
|
@@ -74,6 +111,9 @@ export declare class SessionsResource {
|
|
|
74
111
|
}): Promise<{
|
|
75
112
|
[k: string]: unknown;
|
|
76
113
|
}>;
|
|
114
|
+
/** POST /v1/sessions/:id/wake — 唤醒 task_done 纯 park 的会话续跑(design/144 §3,core 1.283 wake 臂;
|
|
115
|
+
* server.ts:5472 实拆)。非门决策:绝不 allow/deny 任何 pending 动作——有未决门=core `wake.gate_pending`
|
|
116
|
+
* 拒;空 park 且无 message=`wake.nothing_to_deliver` 拒。`message` 作续跑首轮输入(可省=送 pendingSteer)。 */
|
|
77
117
|
wake(sessionId: string, body?: {
|
|
78
118
|
message?: string;
|
|
79
119
|
}, opts?: {
|
|
@@ -81,9 +121,18 @@ export declare class SessionsResource {
|
|
|
81
121
|
}): Promise<{
|
|
82
122
|
[k: string]: unknown;
|
|
83
123
|
}>;
|
|
124
|
+
/** GET /v1/sessions/:id?message=<index> — the single-message expand leg (server ≥1.162,
|
|
125
|
+
* the companion of a `blobCap`-truncated windowed read): full body of ONE message by its
|
|
126
|
+
* stable index within the current floorEntryId generation. Out-of-range → 404 (typed
|
|
127
|
+
* NotFoundError; wire body carries `total`). Owner-checked like `get`. */
|
|
84
128
|
getMessage(sessionId: string, index: number, opts?: {
|
|
85
129
|
signal?: AbortSignal;
|
|
86
130
|
}): Promise<SessionMessageEnvelope>;
|
|
131
|
+
/** E16 — GET /v1/sessions?limit&cursor&owner → `{ sessions, nextCursor? }` (service `6cbf61e`). Owner-scoped
|
|
132
|
+
* keyset page of the caller's sessions (each row aggregates a session's run ledger). `cursor` is the opaque
|
|
133
|
+
* `nextCursor` from the previous page (echo verbatim). `owner` is honored only for a fleet-wide credential;
|
|
134
|
+
* a principal caller is force-scoped to itself server-side. 501 without a durable session store. Backs the
|
|
135
|
+
* shell's session/conversation picker (MF-15/16/17). */
|
|
87
136
|
list(params?: {
|
|
88
137
|
limit?: number;
|
|
89
138
|
cursor?: string;
|
|
@@ -92,21 +141,41 @@ export declare class SessionsResource {
|
|
|
92
141
|
}, opts?: {
|
|
93
142
|
signal?: AbortSignal;
|
|
94
143
|
}): Promise<SessionListPage>;
|
|
144
|
+
/** E17 — POST /v1/sessions/:id/fork → `{ sessionId }` (the NEW branched session id). Branches a fresh session
|
|
145
|
+
* off the source's WHOLE history (a "branch this conversation" / regenerate-from-here). Owner-scoped (non-owner
|
|
146
|
+
* → 404; the fork is owned by the caller). 400 on a non-uuidv7 id; 501 without a durable session store.
|
|
147
|
+
* Not a submit (creates a distinct resource, not retry-equivalent) → no SDK retry. */
|
|
95
148
|
fork(sessionId: string, opts?: {
|
|
96
149
|
signal?: AbortSignal;
|
|
97
150
|
}): Promise<{
|
|
98
151
|
sessionId: string;
|
|
99
152
|
}>;
|
|
153
|
+
/** E21 — DELETE /v1/sessions/:id → `{ deleted }` (idempotent: `false` when nothing existed). Purges the
|
|
154
|
+
* session's conversation history + the service-owned run-ledger/checkpoint/tool-result rows. Owner-scoped
|
|
155
|
+
* (non-owner → 404). 🔴 409 (typed ConflictError, body `activeTaskId`) while a run is LIVE on the session —
|
|
156
|
+
* cancel it first (don't orphan the session lock). 501 without a durable session store. Server-idempotent;
|
|
157
|
+
* not a submit → no SDK retry. */
|
|
100
158
|
delete(sessionId: string, opts?: {
|
|
101
159
|
signal?: AbortSignal;
|
|
102
160
|
}): Promise<{
|
|
103
161
|
deleted: boolean;
|
|
104
162
|
}>;
|
|
163
|
+
/** E6 — GET /v1/sessions/:id/policy → `{ rules }` (StoredSessionRules incl. the OCC `rev`). The operator-tightened
|
|
164
|
+
* per-session tool-permission rules core reads at prepare-time (SUBTRACT-only). Owner-scoped (non-owner → 404);
|
|
165
|
+
* ownerless session → 409; 501 without a session-policy store. Read-only snapshot — the renderer shows the
|
|
166
|
+
* effective narrowing, never re-decides (enforcement is 100% core-side). Backs the shell's permissionMode panel
|
|
167
|
+
* (MF-22). */
|
|
105
168
|
getPolicy(sessionId: string, opts?: {
|
|
106
169
|
signal?: AbortSignal;
|
|
107
170
|
}): Promise<{
|
|
108
171
|
rules: StoredSessionRules;
|
|
109
172
|
}>;
|
|
173
|
+
/** E6 — PUT /v1/sessions/:id/policy → `{ rules }` (the stored rules with the new `rev`). Write the per-session
|
|
174
|
+
* rules. 🔴 TIGHTEN-ONLY for a normal principal: removing a deny / widening an allowlist or allowDirs → 403
|
|
175
|
+
* `loosen_forbidden` (only an operator may loosen). Pass `expectedRev` for optimistic-concurrency (CAS) — a
|
|
176
|
+
* stale rev → 409 `conflict` (typed ConflictError). Validation: each of the 5 rule fields must be `string[]` →
|
|
177
|
+
* malformed body 400. ownerless session → 409; non-owner → 404. Not a submit (CAS, not retry-equivalent) →
|
|
178
|
+
* no SDK retry. */
|
|
110
179
|
putPolicy(sessionId: string, body: {
|
|
111
180
|
rules: SessionPermissionRules;
|
|
112
181
|
expectedRev?: number;
|
|
@@ -115,6 +184,11 @@ export declare class SessionsResource {
|
|
|
115
184
|
}): Promise<{
|
|
116
185
|
rules: StoredSessionRules;
|
|
117
186
|
}>;
|
|
187
|
+
/** E9 — GET /v1/sessions/:id/mcp → `{ asOf, servers, degraded? }` (core 1.124). Per-server MCP status for the
|
|
188
|
+
* `/mcp` panel. 🔴 MATERIALIZATION-TIME, not live session health: core never persists MCP connections, so the
|
|
189
|
+
* service fresh-connects→lists→disposes the worker's configured MCP servers on demand and projects their status
|
|
190
|
+
* (`asOf` = that moment; render "as of <asOf>"). `degraded:true` (servers empty) ⇒ materialize timed out/failed
|
|
191
|
+
* (NOT "no MCP" — a configured-but-no-servers worker returns `servers:[]` without `degraded`). Backs MF-27. */
|
|
118
192
|
mcp(sessionId: string, opts?: {
|
|
119
193
|
signal?: AbortSignal;
|
|
120
194
|
}): Promise<McpStatusPanel>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/resources/sessions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/resources/sessions.ts"],"names":[],"mappings":"AAAA;;;;8DAI8D;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACf,MAAM,aAAa,CAAC;AAErB;;;;;;;kEAOkE;AAClE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAA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KAAE,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,CAAC;IAQ3G;;;;;wBAKoB;IACd,SAAS,CACb,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE;QAAE,KAAK,EAAE,sBAAsB,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,EAC7D,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAC9B,OAAO,CAAC;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,CAAC;IASzC;;;;oHAIgH;IAC1G,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;CAOvF"}
|
|
@@ -15,11 +15,19 @@ function sessionGetQuery(params) {
|
|
|
15
15
|
}
|
|
16
16
|
export class SessionsResource {
|
|
17
17
|
t;
|
|
18
|
+
/** 2c session-sync (P1d) — `client.sessions.sync.*`: PULL a cloud session's whole state (manifest + NDJSON entry
|
|
19
|
+
* stream + content-addressed blobs) or PUSH the local peer's into the cloud (PUT blobs → two-phase staged import).
|
|
20
|
+
* Gate off `capabilities().sessionSync`. See SessionSyncResource. */
|
|
18
21
|
sync;
|
|
19
22
|
constructor(t) {
|
|
20
23
|
this.t = t;
|
|
21
24
|
this.sync = new SessionSyncResource(t);
|
|
22
25
|
}
|
|
26
|
+
/** GET /v1/sessions/:id — owner-checked (non-owner → 404). True shape; `messages` is the
|
|
27
|
+
* current model context and can be LARGE — lazy-expand in UIs, or pass window params
|
|
28
|
+
* (`tail`/`before`+`limit`/`blobCap`, server ≥1.162 — see SessionGetParams) to pull a slice:
|
|
29
|
+
* the windowed response adds `window {offset,total}` (absent on an old engine = honest
|
|
30
|
+
* degradation probe). No params ⇒ legacy full read, byte-identical to before. */
|
|
23
31
|
async get(sessionId, opts) {
|
|
24
32
|
return this.t.request({
|
|
25
33
|
method: "GET",
|
|
@@ -27,6 +35,9 @@ export class SessionsResource {
|
|
|
27
35
|
signal: opts?.signal,
|
|
28
36
|
});
|
|
29
37
|
}
|
|
38
|
+
/** GET /v1/sessions/:id/head — 会话追随轻探针(server ≥1.225,[1075]②):`{ sessionId, leafId }` +
|
|
39
|
+
* ETag(=leafId)。leafId 每次 append 都变=版本号——空闲期轮询判增量;传 `etag`(上次值)命中即
|
|
40
|
+
* `changed:false` 零 body(HTTP 304)。501=无 durable session store。 */
|
|
30
41
|
async head(sessionId, opts) {
|
|
31
42
|
const res = await this.t.openRaw({
|
|
32
43
|
method: "GET",
|
|
@@ -41,6 +52,11 @@ export class SessionsResource {
|
|
|
41
52
|
const body = (await res.json());
|
|
42
53
|
return { changed: true, etag: res.headers.get("etag") ?? `"${body.leafId ?? "empty"}"`, leafId: body.leafId };
|
|
43
54
|
}
|
|
55
|
+
/** GET /v1/sessions/:id/events — session 级 SSE 真订阅(server ≥1.230,[1196] S1):`event: head`
|
|
56
|
+
* 帧流(latest-wins;server 侧 25s 心跳)。轮询→订阅的换轨面:每帧=`{ sessionId, leafId }` 新水位,
|
|
57
|
+
* 拿到即拉 tail 增量(内容职责仍在 tail/turns 面)。`lastLeafId` 传上次水位=命中现值时无首帧
|
|
58
|
+
* (304 同义);断线自动重连并以最近水位续(重复帧被服务端抑制)。503=帽满(消费方回落 head 轮询,
|
|
59
|
+
* `capabilities.sessionEvents` 预判);会话被删/换主时 server 主动断流,重连将 404 → 迭代器抛出。 */
|
|
44
60
|
async *watch(sessionId, opts) {
|
|
45
61
|
let cursor = opts?.lastLeafId;
|
|
46
62
|
const open = () => this.t.openRaw({
|
|
@@ -50,24 +66,39 @@ export class SessionsResource {
|
|
|
50
66
|
});
|
|
51
67
|
for await (const frame of parseFrameStream(open, () => false, { ...(opts?.signal ? { signal: opts.signal } : {}), heartbeatGraceMs: opts?.heartbeatGraceMs ?? 60_000 })) {
|
|
52
68
|
if (frame.event !== "head" || frame.data === undefined)
|
|
53
|
-
continue;
|
|
69
|
+
continue; // 心跳注释帧滤除
|
|
54
70
|
const head = JSON.parse(frame.data);
|
|
55
|
-
cursor = head.leafId;
|
|
71
|
+
cursor = head.leafId; // 重连游标
|
|
56
72
|
yield head;
|
|
57
73
|
}
|
|
58
74
|
}
|
|
75
|
+
/** GET /v1/sessions/:id/init — 壳启动一次性 banner bundle(E11;server.ts:4683 实拆):
|
|
76
|
+
* `{ sessionId, model:{provider,modelId}, mode? }`。worker-global 配置面(REQUIRE_PRINCIPAL 下需主体)。 */
|
|
59
77
|
async init(sessionId, opts) {
|
|
60
78
|
return this.t.request({ method: "GET", path: `/v1/sessions/${encodeURIComponent(sessionId)}/init`, signal: opts?.signal });
|
|
61
79
|
}
|
|
80
|
+
/** GET /v1/sessions/:id/settings — 有效合并设置只读视图(E24 读半场;server.ts:4705 实拆):
|
|
81
|
+
* `{ effective:{model,mode?,approvalRequire,commandPolicy,limits}, applied:{model} }`。写半场(PATCH)
|
|
82
|
+
* 需 core seam,当前诚实缺席——capabilities 不宣告 settings 写能力。 */
|
|
62
83
|
async settings(sessionId, opts) {
|
|
63
84
|
return this.t.request({ method: "GET", path: `/v1/sessions/${encodeURIComponent(sessionId)}/settings`, signal: opts?.signal });
|
|
64
85
|
}
|
|
86
|
+
/** POST /v1/sessions/:id/notify — 会话外事件注入(daemon 终态回报等;server.ts:5398 实拆)。
|
|
87
|
+
* body: `{ task_id, status: completed|failed|killed|cancelled|event, summary, result?, seq?, source? }`;
|
|
88
|
+
* 坏形 400 typed;owner 门 fail-closed(未知/他人 session=404 无 oracle;env-only 无 ownerOf=501)。 */
|
|
65
89
|
async notify(sessionId, body, opts) {
|
|
66
90
|
return this.t.request({ method: "POST", path: `/v1/sessions/${encodeURIComponent(sessionId)}/notify`, body, signal: opts?.signal });
|
|
67
91
|
}
|
|
92
|
+
/** POST /v1/sessions/:id/wake — 唤醒 task_done 纯 park 的会话续跑(design/144 §3,core 1.283 wake 臂;
|
|
93
|
+
* server.ts:5472 实拆)。非门决策:绝不 allow/deny 任何 pending 动作——有未决门=core `wake.gate_pending`
|
|
94
|
+
* 拒;空 park 且无 message=`wake.nothing_to_deliver` 拒。`message` 作续跑首轮输入(可省=送 pendingSteer)。 */
|
|
68
95
|
async wake(sessionId, body, opts) {
|
|
69
96
|
return this.t.request({ method: "POST", path: `/v1/sessions/${encodeURIComponent(sessionId)}/wake`, body: body ?? {}, signal: opts?.signal });
|
|
70
97
|
}
|
|
98
|
+
/** GET /v1/sessions/:id?message=<index> — the single-message expand leg (server ≥1.162,
|
|
99
|
+
* the companion of a `blobCap`-truncated windowed read): full body of ONE message by its
|
|
100
|
+
* stable index within the current floorEntryId generation. Out-of-range → 404 (typed
|
|
101
|
+
* NotFoundError; wire body carries `total`). Owner-checked like `get`. */
|
|
71
102
|
async getMessage(sessionId, index, opts) {
|
|
72
103
|
return this.t.request({
|
|
73
104
|
method: "GET",
|
|
@@ -75,6 +106,11 @@ export class SessionsResource {
|
|
|
75
106
|
signal: opts?.signal,
|
|
76
107
|
});
|
|
77
108
|
}
|
|
109
|
+
/** E16 — GET /v1/sessions?limit&cursor&owner → `{ sessions, nextCursor? }` (service `6cbf61e`). Owner-scoped
|
|
110
|
+
* keyset page of the caller's sessions (each row aggregates a session's run ledger). `cursor` is the opaque
|
|
111
|
+
* `nextCursor` from the previous page (echo verbatim). `owner` is honored only for a fleet-wide credential;
|
|
112
|
+
* a principal caller is force-scoped to itself server-side. 501 without a durable session store. Backs the
|
|
113
|
+
* shell's session/conversation picker (MF-15/16/17). */
|
|
78
114
|
async list(params, opts) {
|
|
79
115
|
const q = new URLSearchParams();
|
|
80
116
|
if (params?.limit !== undefined)
|
|
@@ -83,6 +119,7 @@ export class SessionsResource {
|
|
|
83
119
|
q.set("cursor", params.cursor);
|
|
84
120
|
if (params?.owner)
|
|
85
121
|
q.set("owner", params.owner);
|
|
122
|
+
// server 1.183.0 (?q= substring search over run objectives; capabilities.sessionSearch gates support).
|
|
86
123
|
if (params?.q)
|
|
87
124
|
q.set("q", params.q);
|
|
88
125
|
const qs = q.toString();
|
|
@@ -92,6 +129,10 @@ export class SessionsResource {
|
|
|
92
129
|
signal: opts?.signal,
|
|
93
130
|
});
|
|
94
131
|
}
|
|
132
|
+
/** E17 — POST /v1/sessions/:id/fork → `{ sessionId }` (the NEW branched session id). Branches a fresh session
|
|
133
|
+
* off the source's WHOLE history (a "branch this conversation" / regenerate-from-here). Owner-scoped (non-owner
|
|
134
|
+
* → 404; the fork is owned by the caller). 400 on a non-uuidv7 id; 501 without a durable session store.
|
|
135
|
+
* Not a submit (creates a distinct resource, not retry-equivalent) → no SDK retry. */
|
|
95
136
|
async fork(sessionId, opts) {
|
|
96
137
|
return this.t.request({
|
|
97
138
|
method: "POST",
|
|
@@ -99,6 +140,11 @@ export class SessionsResource {
|
|
|
99
140
|
signal: opts?.signal,
|
|
100
141
|
});
|
|
101
142
|
}
|
|
143
|
+
/** E21 — DELETE /v1/sessions/:id → `{ deleted }` (idempotent: `false` when nothing existed). Purges the
|
|
144
|
+
* session's conversation history + the service-owned run-ledger/checkpoint/tool-result rows. Owner-scoped
|
|
145
|
+
* (non-owner → 404). 🔴 409 (typed ConflictError, body `activeTaskId`) while a run is LIVE on the session —
|
|
146
|
+
* cancel it first (don't orphan the session lock). 501 without a durable session store. Server-idempotent;
|
|
147
|
+
* not a submit → no SDK retry. */
|
|
102
148
|
async delete(sessionId, opts) {
|
|
103
149
|
return this.t.request({
|
|
104
150
|
method: "DELETE",
|
|
@@ -106,6 +152,11 @@ export class SessionsResource {
|
|
|
106
152
|
signal: opts?.signal,
|
|
107
153
|
});
|
|
108
154
|
}
|
|
155
|
+
/** E6 — GET /v1/sessions/:id/policy → `{ rules }` (StoredSessionRules incl. the OCC `rev`). The operator-tightened
|
|
156
|
+
* per-session tool-permission rules core reads at prepare-time (SUBTRACT-only). Owner-scoped (non-owner → 404);
|
|
157
|
+
* ownerless session → 409; 501 without a session-policy store. Read-only snapshot — the renderer shows the
|
|
158
|
+
* effective narrowing, never re-decides (enforcement is 100% core-side). Backs the shell's permissionMode panel
|
|
159
|
+
* (MF-22). */
|
|
109
160
|
async getPolicy(sessionId, opts) {
|
|
110
161
|
return this.t.request({
|
|
111
162
|
method: "GET",
|
|
@@ -113,6 +164,12 @@ export class SessionsResource {
|
|
|
113
164
|
signal: opts?.signal,
|
|
114
165
|
});
|
|
115
166
|
}
|
|
167
|
+
/** E6 — PUT /v1/sessions/:id/policy → `{ rules }` (the stored rules with the new `rev`). Write the per-session
|
|
168
|
+
* rules. 🔴 TIGHTEN-ONLY for a normal principal: removing a deny / widening an allowlist or allowDirs → 403
|
|
169
|
+
* `loosen_forbidden` (only an operator may loosen). Pass `expectedRev` for optimistic-concurrency (CAS) — a
|
|
170
|
+
* stale rev → 409 `conflict` (typed ConflictError). Validation: each of the 5 rule fields must be `string[]` →
|
|
171
|
+
* malformed body 400. ownerless session → 409; non-owner → 404. Not a submit (CAS, not retry-equivalent) →
|
|
172
|
+
* no SDK retry. */
|
|
116
173
|
async putPolicy(sessionId, body, opts) {
|
|
117
174
|
return this.t.request({
|
|
118
175
|
method: "PUT",
|
|
@@ -121,6 +178,11 @@ export class SessionsResource {
|
|
|
121
178
|
signal: opts?.signal,
|
|
122
179
|
});
|
|
123
180
|
}
|
|
181
|
+
/** E9 — GET /v1/sessions/:id/mcp → `{ asOf, servers, degraded? }` (core 1.124). Per-server MCP status for the
|
|
182
|
+
* `/mcp` panel. 🔴 MATERIALIZATION-TIME, not live session health: core never persists MCP connections, so the
|
|
183
|
+
* service fresh-connects→lists→disposes the worker's configured MCP servers on demand and projects their status
|
|
184
|
+
* (`asOf` = that moment; render "as of <asOf>"). `degraded:true` (servers empty) ⇒ materialize timed out/failed
|
|
185
|
+
* (NOT "no MCP" — a configured-but-no-servers worker returns `servers:[]` without `degraded`). Backs MF-27. */
|
|
124
186
|
async mcp(sessionId, opts) {
|
|
125
187
|
return this.t.request({
|
|
126
188
|
method: "GET",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/resources/sessions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAyBxD,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAU,CAAC;AAE/E,SAAS,eAAe,CAAC,MAAyB;IAChD,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,MAAM,CAAC,GAAG,IAAI,eAAe,EAAE,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,sBAAsB,EAAE,CAAC;QACzC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACpG,CAAC;IACD,MAAM,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IACxB,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,OAAO,gBAAgB;IAME;
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/resources/sessions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAyBxD,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAU,CAAC;AAE/E,SAAS,eAAe,CAAC,MAAyB;IACh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AAC,SAAiB,EAAE,IAA+B;QAChE,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAgC;YACnD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,SAAS;YAC5D,MAAM,EAAE,IAAI,EAAE,MAAM;SACrB,CAAC,CAAC;IACL,CAAC;IAED;;;;;wBAKoB;IACpB,KAAK,CAAC,SAAS,CACb,SAAiB,EACjB,IAA6D,EAC7D,IAA+B;QAE/B,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAgC;YACnD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,SAAS;YAC5D,IAAI;YACJ,MAAM,EAAE,IAAI,EAAE,MAAM;SACrB,CAAC,CAAC;IACL,CAAC;IAED;;;;oHAIgH;IAChH,KAAK,CAAC,GAAG,CAAC,SAAiB,EAAE,IAA+B;QAC1D,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAiB;YACpC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,MAAM;YACzD,MAAM,EAAE,IAAI,EAAE,MAAM;SACrB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [1469] `POST /v1/side-query` — server 1.242 的一次性 brain 路由问答(core 1.361 `Runner.sideQuery` 包装)。
|
|
3
|
+
* **无 session 副作用/无工具执行/无引擎侧 policy gate/无流式(v1)**——壳侧 utility(标题/摘要/权限解释…)
|
|
4
|
+
* 的传输层正解([1463]①):engineSideChannel 只换传输层,15+ utility 零改动升级。
|
|
5
|
+
*
|
|
6
|
+
* 鉴权同任务面(service token / requirePrincipal 部署缺 principal=401);计费面同 billable-submit 姿势
|
|
7
|
+
* (no-token 503 fail-closed、draining/model-ready 503、rate/quota/lease 三闸);server 半场把 usage 记进
|
|
8
|
+
* principal 的配额桶+fleet lease(cache-family-aware 配额轴)。探测:`capabilities.sideQuery`(恒 true
|
|
9
|
+
* on ≥1.242;旧 server=缺席,走 tolerate-absent 判缺)。
|
|
10
|
+
*/
|
|
1
11
|
import type { Transport } from "../transport.js";
|
|
12
|
+
/** 请求形(server 白名单透传 core SideQuerySpec;`signal` 为 server 属地——client 断连即弃,body 里
|
|
13
|
+
* 传了也会被丢)。messages 逐条形=core SideQueryMessage(user/assistant/toolResult 三臂;assistant
|
|
14
|
+
* 元数据全可选、string content 可折)。 */
|
|
2
15
|
export interface SideQueryRequest {
|
|
16
|
+
/** 池名/role/@mention,同任务面解析;缺省走 default role。 */
|
|
3
17
|
model?: string;
|
|
4
18
|
modelRole?: string;
|
|
5
19
|
thinking?: string;
|
|
6
20
|
systemPrompt?: string;
|
|
7
21
|
messages: Array<Record<string, unknown>>;
|
|
22
|
+
/** 工具**定义**(给模型出 toolCalls 数据用)——服务端绝不执行。 */
|
|
8
23
|
tools?: Array<{
|
|
9
24
|
name: string;
|
|
10
25
|
description: string;
|
|
@@ -12,6 +27,8 @@ export interface SideQueryRequest {
|
|
|
12
27
|
}>;
|
|
13
28
|
maxOutputTokens?: number;
|
|
14
29
|
}
|
|
30
|
+
/** 响应形(core SideQueryResult 原样):`model`=路由身份,`servedModel`=实际服务者(degrading fallback
|
|
31
|
+
* 诚实归因),stream 后错误进 `errorMessage` 不作 HTTP 错(400 仅限校验/模型解析,5xx=服务端缺陷)。 */
|
|
15
32
|
export interface SideQueryResult {
|
|
16
33
|
text: string;
|
|
17
34
|
toolCalls: Array<{
|
|
@@ -37,6 +54,7 @@ export interface SideQueryResult {
|
|
|
37
54
|
export declare class SideQueryResource {
|
|
38
55
|
private readonly t;
|
|
39
56
|
constructor(t: Transport);
|
|
57
|
+
/** POST /v1/side-query — one-shot;不 idempotent(烧一次模型)→ NO SDK retry。 */
|
|
40
58
|
query(body: SideQueryRequest, opts?: {
|
|
41
59
|
signal?: AbortSignal;
|
|
42
60
|
}): Promise<SideQueryResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-query.d.ts","sourceRoot":"","sources":["../../src/resources/side-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"side-query.d.ts","sourceRoot":"","sources":["../../src/resources/side-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;iCAEiC;AACjC,MAAM,WAAW,gBAAgB;IAC/B,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzC,6CAA6C;IAC7C,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC1F,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;2EAC2E;AAC3E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAED,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAAD,CAAC,EAAE,SAAS;IAEzC,wEAAwE;IAClE,KAAK,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;CAG/F"}
|
|
@@ -3,6 +3,7 @@ export class SideQueryResource {
|
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.t = t;
|
|
5
5
|
}
|
|
6
|
+
/** POST /v1/side-query — one-shot;不 idempotent(烧一次模型)→ NO SDK retry。 */
|
|
6
7
|
async query(body, opts) {
|
|
7
8
|
return this.t.request({ method: "POST", path: "/v1/side-query", body, signal: opts?.signal });
|
|
8
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-query.js","sourceRoot":"","sources":["../../src/resources/side-query.ts"],"names":[],"mappings":"AA2CA,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"side-query.js","sourceRoot":"","sources":["../../src/resources/side-query.ts"],"names":[],"mappings":"AA2CA,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;IAE7C,wEAAwE;IACxE,KAAK,CAAC,KAAK,CAAC,IAAsB,EAAE,IAA+B;QACjE,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACjH,CAAC;CACF"}
|
|
@@ -1,18 +1,37 @@
|
|
|
1
|
+
/** tasks — synchronous. `submit` (POST /v1/tasks, auto idempotency key) + `stream` (POST /v1/tasks/stream,
|
|
2
|
+
* live token stream; verify/cascade NOT supported here). Signatures fixed; bodies TODO(M1/M2). */
|
|
1
3
|
import type { Transport } from "../transport.js";
|
|
2
4
|
import type { TaskRequest, TaskResult } from "../types.js";
|
|
3
5
|
import type { AgentEvent } from "../events.js";
|
|
4
6
|
export declare class TasksResource {
|
|
5
7
|
private readonly t;
|
|
6
8
|
constructor(t: Transport);
|
|
9
|
+
/** Run to completion, return the TaskResult. Auto Idempotency-Key (→ retry-safe). NOTE: a budget gate is
|
|
10
|
+
* result-level — it comes back as HTTP 200 with `result.errorCode` (budget.precall/budget.exceeded), NOT a
|
|
11
|
+
* thrown error (pinned wire contract). Branch on `result.errorCode`, not a catch. */
|
|
7
12
|
submit(req: TaskRequest, opts?: {
|
|
8
13
|
idempotencyKey?: string | null;
|
|
9
14
|
signal?: AbortSignal;
|
|
10
15
|
}): Promise<TaskResult>;
|
|
16
|
+
/** Raw SSE passthrough for THIN PROXIES (e.g. OA's /api/ai/chat relays the byte stream untouched so its
|
|
17
|
+
* frontend parsing stays as-is). Returns the ok-checked Response — the caller owns the body; closing it
|
|
18
|
+
* aborts the server run (anti token-burn). Non-OK → typed error. Same restriction: no verify/cascade.
|
|
19
|
+
* `headers` = generic caller extras on the wire (e.g. a shell assembling `x-detach-on-disconnect` for the
|
|
20
|
+
* server's opt-in disconnect grace — the SDK ships NO detach semantics or constants; it is a plain pipe).
|
|
21
|
+
* Built-in headers (authorization / idempotency-key / …) always win the merge (transport.openStream). */
|
|
11
22
|
streamRaw(req: TaskRequest, opts?: {
|
|
12
23
|
signal?: AbortSignal;
|
|
13
24
|
idempotencyKey?: string | null;
|
|
14
25
|
headers?: Record<string, string>;
|
|
15
26
|
}): Promise<Response>;
|
|
27
|
+
/** Live token stream (same instance), parsed into typed AgentEvents. No verify/cascade (rejected 400 —
|
|
28
|
+
* multi-attempt, not a stream). TRANSIENT: a disconnect ABORTS the server run (anti token-burn); a drop is
|
|
29
|
+
* NOT resumed — durable resume is runs.events. `heartbeatGraceMs` tunes the silence watchdog (default 45s;
|
|
30
|
+
* engine heartbeats every 15s) — on silence a typed {@link SseIdleError} is thrown for the caller to
|
|
31
|
+
* diagnose. `idempotencyKey` lets the caller PIN the submit key (default: auto-minted per call) so a future
|
|
32
|
+
* reconnect can hit the server's in-flight replay lane with the SAME key (P0-2 S1; reconnect itself is S2,
|
|
33
|
+
* gated on the engine-side disconnect grace). `headers` = generic caller extras (see {@link streamRaw});
|
|
34
|
+
* built-ins always win the merge. */
|
|
16
35
|
stream(req: TaskRequest, opts?: {
|
|
17
36
|
signal?: AbortSignal;
|
|
18
37
|
onResponse?: (res: Response) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/resources/tasks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/resources/tasks.ts"],"names":[],"mappings":"AAAA;mGACmG;AACnG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAAD,CAAC,EAAE,SAAS;IAEzC;;0FAEsF;IAChF,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAWpH;;;;;8GAK0G;IACpG,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IAevJ;;;;;;;0CAOsC;IAC/B,MAAM,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,cAAc,CAAC,UAAU,CAAC;CAgBhO"}
|
package/dist/resources/tasks.js
CHANGED
|
@@ -5,6 +5,9 @@ export class TasksResource {
|
|
|
5
5
|
constructor(t) {
|
|
6
6
|
this.t = t;
|
|
7
7
|
}
|
|
8
|
+
/** Run to completion, return the TaskResult. Auto Idempotency-Key (→ retry-safe). NOTE: a budget gate is
|
|
9
|
+
* result-level — it comes back as HTTP 200 with `result.errorCode` (budget.precall/budget.exceeded), NOT a
|
|
10
|
+
* thrown error (pinned wire contract). Branch on `result.errorCode`, not a catch. */
|
|
8
11
|
async submit(req, opts) {
|
|
9
12
|
return this.t.request({
|
|
10
13
|
method: "POST",
|
|
@@ -15,6 +18,12 @@ export class TasksResource {
|
|
|
15
18
|
signal: opts?.signal,
|
|
16
19
|
});
|
|
17
20
|
}
|
|
21
|
+
/** Raw SSE passthrough for THIN PROXIES (e.g. OA's /api/ai/chat relays the byte stream untouched so its
|
|
22
|
+
* frontend parsing stays as-is). Returns the ok-checked Response — the caller owns the body; closing it
|
|
23
|
+
* aborts the server run (anti token-burn). Non-OK → typed error. Same restriction: no verify/cascade.
|
|
24
|
+
* `headers` = generic caller extras on the wire (e.g. a shell assembling `x-detach-on-disconnect` for the
|
|
25
|
+
* server's opt-in disconnect grace — the SDK ships NO detach semantics or constants; it is a plain pipe).
|
|
26
|
+
* Built-in headers (authorization / idempotency-key / …) always win the merge (transport.openStream). */
|
|
18
27
|
async streamRaw(req, opts) {
|
|
19
28
|
const o = {
|
|
20
29
|
method: "POST",
|
|
@@ -32,12 +41,22 @@ export class TasksResource {
|
|
|
32
41
|
throw toApiError(res.status, await res.json().catch(() => ({})));
|
|
33
42
|
return res;
|
|
34
43
|
}
|
|
44
|
+
/** Live token stream (same instance), parsed into typed AgentEvents. No verify/cascade (rejected 400 —
|
|
45
|
+
* multi-attempt, not a stream). TRANSIENT: a disconnect ABORTS the server run (anti token-burn); a drop is
|
|
46
|
+
* NOT resumed — durable resume is runs.events. `heartbeatGraceMs` tunes the silence watchdog (default 45s;
|
|
47
|
+
* engine heartbeats every 15s) — on silence a typed {@link SseIdleError} is thrown for the caller to
|
|
48
|
+
* diagnose. `idempotencyKey` lets the caller PIN the submit key (default: auto-minted per call) so a future
|
|
49
|
+
* reconnect can hit the server's in-flight replay lane with the SAME key (P0-2 S1; reconnect itself is S2,
|
|
50
|
+
* gated on the engine-side disconnect grace). `headers` = generic caller extras (see {@link streamRaw});
|
|
51
|
+
* built-ins always win the merge. */
|
|
35
52
|
async *stream(req, opts) {
|
|
36
53
|
const res = await this.streamRaw(req, opts);
|
|
54
|
+
// Additive header hook (server 1.47+ early-emits X-Task-Id on the sync leg): lets a shell bind the
|
|
55
|
+
// run id BEFORE any frame arrives (early journal / mid-flight control verbs like runs.detach).
|
|
37
56
|
try {
|
|
38
57
|
opts?.onResponse?.(res);
|
|
39
58
|
}
|
|
40
|
-
catch { }
|
|
59
|
+
catch { /* a consumer hook must never break the stream */ }
|
|
41
60
|
try {
|
|
42
61
|
for await (const frame of readSseFrames(res, opts?.heartbeatGraceMs, opts?.signal)) {
|
|
43
62
|
if (!frame.data)
|
|
@@ -49,7 +68,7 @@ export class TasksResource {
|
|
|
49
68
|
}
|
|
50
69
|
}
|
|
51
70
|
finally {
|
|
52
|
-
res.body?.cancel().catch(() => { });
|
|
71
|
+
res.body?.cancel().catch(() => { }); // disconnect = abort server-side (by design)
|
|
53
72
|
}
|
|
54
73
|
}
|
|
55
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/resources/tasks.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/resources/tasks.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,CAAY;QAAZ,MAAC,GAAD,CAAC,CAAW;IAAG,CAAC;IAE7C;;0FAEsF;IACtF,KAAK,CAAC,MAAM,CAAC,GAAgB,EAAE,IAA+D;QAC5F,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,CAAa;YAChC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,GAAG;YACT,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,IAAI,EAAE,cAAc;YACpC,MAAM,EAAE,IAAI,EAAE,MAAM;SACrB,CAAC,C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