@sema-agent/server 7.126.0 → 7.127.0
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/MIGRATION.md +34 -0
- package/USAGE.md +86 -8
- package/deploy/sema-up/chart/templates/networkpolicy-sandbox.yaml +15 -5
- package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +28 -1
- package/deploy/sema-up/chart/templates/server-v4pro.yaml +1 -0
- package/deploy/sema-up/chart/templates/server.yaml +1 -0
- package/deploy/sema-up/chart/values.yaml +16 -6
- package/deploy/sema-up/kube-up.sh +10 -4
- package/deploy/sema-up/lib/node-addrs.sh +42 -0
- package/deploy/sema-up/stack/sema-stack-cluster.yaml +20 -1
- package/dist/audit.js +1 -0
- package/dist/boot/execution-env.js +17 -4
- package/dist/boot/leader.d.ts +2 -1
- package/dist/boot/memory-consolidation.d.ts +37 -3
- package/dist/boot/memory-consolidation.js +18 -2
- package/dist/boot/runner-deps.d.ts +2 -1
- package/dist/boot/session-faces.d.ts +2 -1
- package/dist/boot/stage-06-runners.js +5 -2
- package/dist/config-catalog.js +3 -1
- package/dist/config-types.d.ts +5 -1
- package/dist/config.js +2 -0
- package/dist/execution-lane-caps.d.ts +12 -0
- package/dist/execution-lane-caps.js +16 -2
- package/dist/fleet/subagent-tail-bus.js +15 -5
- package/dist/http/admission.js +5 -1
- package/dist/http/durable-run-leg.js +1 -3
- package/dist/http/resume-legs.js +15 -6
- package/dist/http/route-ctx.d.ts +7 -1
- package/dist/http/routes/runs.js +23 -1
- package/dist/http/routes/tasks.js +17 -8
- package/dist/http/routes/workflows.js +8 -0
- package/dist/http/server.js +1 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lsp/manager.js +1 -1
- package/dist/observability/fail-open.d.ts +16 -0
- package/dist/observability/fail-open.js +16 -0
- package/dist/observability/metrics.js +1 -1
- package/dist/observability/run-terminal.js +3 -0
- package/dist/plugins/caching-session-store.d.ts +39 -22
- package/dist/plugins/caching-session-store.js +16 -9
- package/dist/plugins/k8s-exec-protocol.js +3 -0
- package/dist/plugins/one-time-migrations.d.ts +28 -4
- package/dist/plugins/one-time-migrations.js +22 -4
- package/dist/plugins/remote-env-host.d.ts +11 -1
- package/dist/plugins/remote-env-host.js +9 -1
- package/dist/plugins/remote-env-k8s.d.ts +40 -5
- package/dist/plugins/remote-env-k8s.js +119 -25
- package/dist/plugins/session-store.d.ts +4 -3
- package/dist/plugins/session-store.js +1 -1
- package/dist/plugins/store-backend.d.ts +12 -5
- package/dist/plugins/store-backend.js +12 -3
- package/dist/plugins/store-contracts.d.ts +3 -0
- package/dist/plugins/store-open-wait.js +3 -0
- package/dist/request-key-closure.d.ts +20 -7
- package/dist/request-key-closure.js +22 -6
- package/dist/run-acceptance.d.ts +51 -0
- package/dist/run-acceptance.js +27 -0
- package/dist/runs.d.ts +7 -11
- package/dist/runs.js +5 -16
- package/dist/sandbox-egress-policy.d.ts +61 -0
- package/dist/sandbox-egress-policy.js +235 -0
- package/dist/session-error-wire.d.ts +2 -2
- package/dist/session-titler.d.ts +5 -3
- package/dist/trace/core-keyset-guard.d.ts +3 -2
- package/dist/trace/ledger-events.d.ts +9 -3
- package/dist/trace/ledger-sink.d.ts +7 -0
- package/dist/trace/ledger-sink.js +14 -4
- package/dist/trace/project.d.ts +49 -8
- package/dist/trace/project.js +39 -7
- package/dist/trace/self-minted-wire.d.ts +19 -29
- package/dist/trace/self-minted-wire.js +2 -9
- package/dist/trace/tool-output-media.d.ts +26 -0
- package/dist/trace/tool-output-media.js +57 -0
- package/dist/trace/wire-projection-faces.d.ts +7 -1
- package/dist/trace/wire-projection-faces.js +2 -1
- package/package.json +3 -3
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
* 列表里的缺席),码位各不相同,不由本表统一。
|
|
30
30
|
* · `invalid_entry` / `invalid_fork_target` / `placement_refused` —— 留白:本仓今天没有一条 wire 口把它们作为自己的
|
|
31
31
|
* 应答(它们在 core 的追加 / 分叉 / 放置面上抛,落进各站点既有的处置或通用 500)。给它们起名是另一件事、另一张票。
|
|
32
|
-
* · `storage` / `conflict` / `unknown` —— 留白:`conflict`
|
|
33
|
-
* `
|
|
32
|
+
* · `storage` / `conflict` / `unknown` —— 留白:`conflict` 是 run 的写撞上真并发写,落成那条 run 的 `failed` 终局
|
|
33
|
+
* (`terminal.code: "conflict"`),提交腿不另作处置;`storage` / `unknown` 是故障类,通用 500 就是它们今天的应答。
|
|
34
34
|
*
|
|
35
35
|
* core 给闭集加一个词 ⇒ 下面的 `switch` 编译红,由人裁定它在两面上的答复,而不是让它静默落进某个恰好存在的臂
|
|
36
36
|
* ([ref] 词表纪律;同形先例 `session-policy-wire.ts` 的 `sessionPolicyErrorHttp`)。
|
package/dist/session-titler.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-generated session titles.
|
|
3
3
|
*
|
|
4
|
-
* SHAPE: fire-and-forget
|
|
5
|
-
*
|
|
4
|
+
* SHAPE: fire-and-forget once the ENGINE ACCEPTS a submitted run whose session has NO title — the one caller is the
|
|
5
|
+
* submission's acceptance seat (`run-acceptance.ts`: the objective entered the conversation, or a result-only verify /
|
|
6
|
+
* cascade leg came back having done work). A run the engine refuses before acceptance never reaches the titler (no
|
|
7
|
+
* model call for a refused input). No need to wait for the run to finish, and the web Recents gets the title sooner. Fills a NULL title only (`setTitleIfNull`,
|
|
6
8
|
* store-side `WHERE title IS NULL`) — the user writes the SAME column unconditionally (`PATCH /v1/sessions/:id` →
|
|
7
9
|
* `patchSessionMeta`): a user-set title is never overwritten (the probe below reads "titled" and skips the model
|
|
8
10
|
* call), and a title the user cleared (`title: null` ⇒ NULL) is filled again at the next submit (law: `session-row.ts`).
|
|
@@ -25,7 +27,7 @@ export interface SessionTitlerDeps {
|
|
|
25
27
|
setTitleIfNull(sessionId: string, title: string): Promise<boolean>;
|
|
26
28
|
/** Cheap pre-LLM probe: "titled" = skip (a restart/evicted-seen/another replica
|
|
27
29
|
* already paid — don't re-spend an LLM call); "untitled" = generate; "none" = the session_meta row hasn't
|
|
28
|
-
* been REGISTERED
|
|
30
|
+
* been REGISTERED (or was deleted meanwhile) — retry after a grace window,
|
|
29
31
|
* and if still absent, release the seen slot so the NEXT submit retries (never a permanently-untitled
|
|
30
32
|
* session via a swallowed early UPDATE-0). Local lane has no row-existence dimension → never "none". */
|
|
31
33
|
probeTitle(sessionId: string): Promise<"none" | "untitled" | "titled">;
|
|
@@ -50,7 +50,7 @@ type _GuardAskReverse = AssertAllKeysHandled<Exclude<AskProjected | AskExcluded,
|
|
|
50
50
|
type AskFrameServerMinted = "type" | "approvalId" | "argsOmitted" | "outcome" | "governanceForced" | "expiresAtMs" | "expiresInMs" | "serverNowMs" | "parked" | "cause" | "inputHasBidi" | "rememberRefused";
|
|
51
51
|
type _GuardAskFrame = AssertAllKeysHandled<Exclude<keyof ToolApprovalFrame, AskProjected | AskFrameServerMinted>>;
|
|
52
52
|
type _GuardAskFrameReverse = AssertAllKeysHandled<Exclude<AskProjected | AskFrameServerMinted, keyof ToolApprovalFrame>>;
|
|
53
|
-
type TaskEventHandled = "text_delta" | "reasoning_delta" | "tool_start" | "tool_end" | "turn_end" | "compacted" | "diagnostics" | "message_committed" | "status" | "task_notification" | "task_progress" | "steering_injected" | "workspace_changed" | "done" | "context_usage" | "compaction_outcome" | "human_input" | "wiring_manifest" | "text_end" | "tool_roster_delta" | "tool_progress" | "tool_disclosure";
|
|
53
|
+
type TaskEventHandled = "text_delta" | "reasoning_delta" | "tool_start" | "tool_end" | "turn_end" | "compacted" | "diagnostics" | "message_committed" | "status" | "task_notification" | "task_progress" | "steering_injected" | "workspace_changed" | "done" | "context_usage" | "compaction_outcome" | "human_input" | "wiring_manifest" | "text_end" | "tool_roster_delta" | "tool_progress" | "tool_disclosure" | "task_started";
|
|
54
54
|
type _GuardTaskEvent = AssertAllKeysHandled<Exclude<TaskEvent["type"], TaskEventHandled>>;
|
|
55
55
|
type _GuardTaskEventReverse = AssertAllKeysHandled<Exclude<TaskEventHandled, TaskEvent["type"]>>;
|
|
56
56
|
type MailboxProjected = "seq" | "from" | "content" | "sentAt" | "hopChain" | "peerMeta";
|
|
@@ -149,7 +149,8 @@ type _GuardParkArmQueue = AssertAllKeysHandled<Exclude<ParkArmKeys, ParkArmQueue
|
|
|
149
149
|
type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjected | ParkArmQueueExcluded, ParkArmKeys>>;
|
|
150
150
|
type _NoDoubleBookParkArmQueue = AssertAllKeysHandled<Extract<ParkArmQueueProjected, ParkArmQueueExcluded>>;
|
|
151
151
|
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptProvider" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptProfile" | "toolPolicy" | "onAsk" | "onQuestion" | "hooks" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "approvalReach" | "writeFace" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "permissionMode" | "taskId" | "signal" | "preemptSignal" | "maxSuspends" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "excludeAllTools" | "fileHistory" | "userInvokedSkills" | "outputStyle" | "allowedTools" | "allowTools";
|
|
152
|
-
|
|
152
|
+
/** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
|
|
153
|
+
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "readDenyPatterns" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "writeProtectedAdditions" | "complianceAdditionalDenies" | "modelRole" | "enableBlockedReport" | "userAttachments";
|
|
153
154
|
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
154
155
|
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
155
156
|
type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction";
|
|
@@ -39,9 +39,15 @@ export type LedgerEventType = "reasoning" | "text" | "tool_start" | "tool_end" |
|
|
|
39
39
|
/** [ref](core 7.18.0):本条腿的**延迟工具普查**快照(policy / thresholdPercent? / deferred[] / activated[])。
|
|
40
40
|
* 与 `tool_roster_delta` 同判、同理由——**快照语义**(整只替换,回放零合并),而开腿那一份住在
|
|
41
41
|
* `wiring_manifest` 之后的首帧、**之后每一次激活**只活在本帧上。整帧缺席 = 这条腿什么都没延迟。
|
|
42
|
-
* 🔴 `tool_progress`([ref])
|
|
43
|
-
*
|
|
44
|
-
|
|
42
|
+
* 🔴 `tool_progress`([ref])**刻意不在本表**,理由是它自己的、不是「core 标了 LIVE ONLY」:那一条只是**引擎**的义务
|
|
43
|
+
* (不进会话树 / 检查点 / 续跑重放),本仓的账本是异步车道的活流与断线重连面,律是「EPHEMERAL 帧带着回放面没有第二来源的
|
|
44
|
+
* 事实 ⇒ 落账」(`status` / `task_progress` / `task_started` 都落)。`tool_progress` 的事实由同一只调用的 `tool_end` 推出
|
|
45
|
+
* (真源在那里;帧的缺席也从不是证据 —— 一个周期内跑完的调用零帧),所以它不落。 */
|
|
46
|
+
| "tool_disclosure" | "human_input"
|
|
47
|
+
/** core 7.50.0:委派子代**起跑**帧(每周期一只,先于子代的首个 `task_progress`)。按上面那一条律落账:
|
|
48
|
+
* `agentType` / `rootSessionId` / `parentSessionId` / `startedAt` 只骑这一帧,`task_progress` 上没有 ⇒ 不落则异步车道
|
|
49
|
+
* (`POST /v1/runs` 的活流就是 `GET /v1/runs/:id/events` 的账本 tail)永远读不到。两条 durable 腿主流 + forward 道各一处写口。 */
|
|
50
|
+
| "task_started" | "task_progress" | "task_notification" | "turn_end"
|
|
45
51
|
/** park 行名**两个**(`appendParked(kind)` 逐字取自 `result.status`)—— 运行期闭集见
|
|
46
52
|
* {@link PARK_LEDGER_EVENT_TYPES}(本联合是它的类型面,两者由下方的双向断言锁步)。 */
|
|
47
53
|
| "suspended" | "needs_review" | "done" | "failed" | "suggestions" | "model_usage" | "prompt_assembled" | "config_assembled" | "file_link"
|
|
@@ -97,6 +97,13 @@ export interface LedgerSink {
|
|
|
97
97
|
* ⚠️ 用它的前提是**这条腿的全部写口都走它**(混用一个绕开链的写口 = 病灶原样保留)。
|
|
98
98
|
*/
|
|
99
99
|
export declare function createSerialLedgerAppend(appendEvent: (seq: number, type: LedgerEventType, data: unknown) => Promise<void>, startSeq: number): (type: LedgerEventType, data: unknown) => Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* durable 腿 forward 道(fire-and-forget,同步回调里不能 await)的写失败出口 —— 一只,两处用:本汇的 `onForwardEvent`(bg 腿 +
|
|
102
|
+
* sync detach 车道 + 续跑腿的 verify 臂)与续跑腿自己的 forward 回调(`http/resume-legs.ts`,那里另有既有的逐次 warn 行)。
|
|
103
|
+
* F 类留痕 `server.ledger.forward-append-failed`:这一帧永远不在回放面(子代的起跑帧 / tick / 工具卡),run 照跑、不改任何裁决。
|
|
104
|
+
* 返回 `.catch` 用的处理器(产物是函数 ⇒ `create*`)。
|
|
105
|
+
*/
|
|
106
|
+
export declare function createForwardAppendFailedNote(type: string): (err: unknown) => void;
|
|
100
107
|
export declare function createLedgerSink(opts: {
|
|
101
108
|
/** The seq-stamped durable append — typically `(seq, type, data) => runStore.appendEvent(taskId, seq, type, data)`. */
|
|
102
109
|
appendEvent: (seq: number, type: LedgerEventType, data: unknown) => Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {} from "@sema-agent/core";
|
|
2
2
|
import { outwardPlane } from "../terminal.js";
|
|
3
|
-
import {
|
|
3
|
+
import { recordFailOpen } from "../observability/fail-open.js";
|
|
4
|
+
import { modelTextEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData } from "./project.js";
|
|
4
5
|
import { NotifiedKeys, taskNotificationStreamKeyOf } from "../orchestration/workflow-completion-inbox.js";
|
|
5
6
|
import { isParkLedgerEventType } from "./ledger-events.js";
|
|
6
7
|
import { isModelSegmentBoundary, reasoningDeltaBytes, reasoningSegmentEventId } from "./model-segment.js";
|
|
@@ -13,6 +14,9 @@ export function createSerialLedgerAppend(appendEvent, startSeq) {
|
|
|
13
14
|
return step;
|
|
14
15
|
};
|
|
15
16
|
}
|
|
17
|
+
export function createForwardAppendFailedNote(type) {
|
|
18
|
+
return (err) => recordFailOpen("server.ledger.forward-append-failed", `type=${type} err=${err instanceof Error ? err.message : String(err)}`);
|
|
19
|
+
}
|
|
16
20
|
export function createLedgerSink(opts) {
|
|
17
21
|
const keys = opts.notifiedKeys ?? new NotifiedKeys();
|
|
18
22
|
let seq = 0;
|
|
@@ -114,6 +118,9 @@ export function createLedgerSink(opts) {
|
|
|
114
118
|
case "human_input":
|
|
115
119
|
await append("human_input", humanInputEventData(ev));
|
|
116
120
|
break;
|
|
121
|
+
case "task_started":
|
|
122
|
+
await append("task_started", taskStartedEventData(ev));
|
|
123
|
+
break;
|
|
117
124
|
case "task_progress":
|
|
118
125
|
await append("task_progress", taskProgressEventData(ev));
|
|
119
126
|
break;
|
|
@@ -140,13 +147,16 @@ export function createLedgerSink(opts) {
|
|
|
140
147
|
const onForwardEvent = (e) => {
|
|
141
148
|
const t = e.type;
|
|
142
149
|
if (t === "task_progress") {
|
|
143
|
-
void append("task_progress", taskProgressEventData(e)).catch(()
|
|
150
|
+
void append("task_progress", taskProgressEventData(e)).catch(createForwardAppendFailedNote(t));
|
|
151
|
+
}
|
|
152
|
+
else if (t === "task_started") {
|
|
153
|
+
void append("task_started", taskStartedEventData(e)).catch(createForwardAppendFailedNote(t));
|
|
144
154
|
}
|
|
145
155
|
else if (t === "tool_start") {
|
|
146
|
-
void append("tool_start", toolStartEventData(e)).catch(()
|
|
156
|
+
void append("tool_start", toolStartEventData(e)).catch(createForwardAppendFailedNote(t));
|
|
147
157
|
}
|
|
148
158
|
else if (t === "tool_end") {
|
|
149
|
-
void append("tool_end", toolEndEventData(e)).catch(()
|
|
159
|
+
void append("tool_end", toolEndEventData(e)).catch(createForwardAppendFailedNote(t));
|
|
150
160
|
}
|
|
151
161
|
};
|
|
152
162
|
const appendStatus = (ev) => {
|
package/dist/trace/project.d.ts
CHANGED
|
@@ -290,14 +290,13 @@ export declare function toolEndEventData(ev: {
|
|
|
290
290
|
/**
|
|
291
291
|
* `tool_progress` 的白名单投影(core 7.18.0 [ref])—— 一只**仍在跑**的工具调用的存活 tick。
|
|
292
292
|
*
|
|
293
|
-
* ## 这一帧只上 live,不落账(
|
|
293
|
+
* ## 这一帧只上 live,不落账(判据是回放面有没有第二来源,不是「core 标了 LIVE ONLY」)
|
|
294
294
|
* core `@contract tool_progress.ephemeral` 逐字:「LIVE ONLY, like `task_progress`/`status`: core never
|
|
295
|
-
* persists this frame (no session-tree entry, no checkpoint state, no resume replay)
|
|
296
|
-
* `
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* **不等于** `tool_end` 的 duration)。
|
|
295
|
+
* persists this frame (no session-tree entry, no checkpoint state, no resume replay)」—— 那是**引擎**的义务;
|
|
296
|
+
* 本仓的律是「EPHEMERAL 帧带着回放面没有第二来源的事实 ⇒ 落账」(`status` / `task_progress` / `task_started` 都落)。
|
|
297
|
+
* 本帧的事实**有**第二来源:`@contract tool_progress.cadence` 逐字「A call that finishes inside one interval emits
|
|
298
|
+
* NO frame at all」⇒ **帧的缺席从来不是证据**;落账会让回放面凭空多出一份「这只调用跑了多久」的账,而那件事的
|
|
299
|
+
* 真源是 `tool_end`(core 明写 `elapsedTimeSeconds` **不等于** `tool_end` 的 duration)。
|
|
301
300
|
*
|
|
302
301
|
* ## 信任划线
|
|
303
302
|
* · `toolCallId` / `toolName` —— 调用 id(🔴 S-283 订正:出身是**服务商**在 tool_use / tool_calls 里给的,引擎缺席时自铸兜底、越界时折叠 ——
|
|
@@ -309,7 +308,8 @@ export declare function toolEndEventData(ev: {
|
|
|
309
308
|
* · `elapsedTimeSeconds` —— 引擎铸的整秒,单调、一 call 一个原点 ⇒ 有限数才铸键。
|
|
310
309
|
* · `output` —— 🔴 **UNTRUSTED RAW**,core 逐字「exactly as `tool_end.output`: process output that may
|
|
311
310
|
* carry secrets, paths or PII; core bounds only its SIZE, and a consumer MUST redact before persisting
|
|
312
|
-
* or displaying it」⇒ 与 `tool_end.output`
|
|
311
|
+
* or displaying it」⇒ 与 `tool_end.output` **同一只**投影 `projectToolOutput`(串形与文本块整只过 `redactDeep`;本帧只有串形,
|
|
312
|
+
* 媒体块那一臂在这里够不着),一个字节的例外都不开。
|
|
313
313
|
* · `totalLines` / `totalBytes` —— 引擎计数;core 的缺席律逐字:三者**同进同退**(在场=「观察到了输出」,
|
|
314
314
|
* 缺席=「一个字节都没观察到」,**从不是**「与上一帧相比没变」)。所以本投影按 `output` 的在场判三者:
|
|
315
315
|
* `output` 读不出 ⇒ 三键一起缺席,不单独留下两个计数(那会把「没输出」谎报成「有输出但读不出」)。
|
|
@@ -373,6 +373,47 @@ export declare function taskProgressEventData(ev: {
|
|
|
373
373
|
seq?: number;
|
|
374
374
|
model?: string;
|
|
375
375
|
}): Record<string, unknown>;
|
|
376
|
+
/**
|
|
377
|
+
* The `task_started` payload(core 7.50.0):一只委派子代**起跑**的那一帧 —— 每周期一只(首派 / 复活;耐久续跑腿不铸),
|
|
378
|
+
* 序在子代的 `wiring_manifest` 之后、它的首个 `task_progress` 与首次模型请求之前。
|
|
379
|
+
*
|
|
380
|
+
* **活面投、账本落**(与 `task_progress` / `status` 同一条律)。core 契约逐字「Live and ephemeral like `task_progress`:
|
|
381
|
+
* never persisted, never replayed on resume, absent from checkpoints」—— 那是**引擎**的义务(不进会话树、检查点、续跑重放)。
|
|
382
|
+
* 本服务的账本是异步车道的活流(`POST /v1/runs` 的观看者读的就是 `GET /v1/runs/:id/events` 的账本 tail)与断线重连面,
|
|
383
|
+
* 律是「**EPHEMERAL 帧带着回放面没有第二来源的事实 ⇒ 落账**」:`agentType` / `rootSessionId` / `parentSessionId` / `startedAt`
|
|
384
|
+
* 只骑这一帧,`task_progress` 上没有。(`tool_progress` 不落是同一条律的反面:它的事实由同一只调用的 `tool_end` 推出。)
|
|
385
|
+
* 调用点:三条 live 腿(sync 主流、sync forward 道、子代 tail 总线)+ 两条 durable 腿(账本汇、resume 腿)各自的主流臂与
|
|
386
|
+
* forward 道 —— 即 `task_progress` 的全部投影点,同一只构造器。
|
|
387
|
+
*
|
|
388
|
+
* 键的信任判与 `task_progress` 孪生**逐键同**(core 原话「every member is a value the run already speaks
|
|
389
|
+
* elsewhere — this frame introduces no new reading of any of them」⇒ 本仓也不铸第二种读法):
|
|
390
|
+
* · run / 会话 id、`seq`、`taskType`、`model`、`workflowRunId`、`agentType` —— 引擎值 verbatim(`agentType` 是解析过的子代类型名,
|
|
391
|
+
* 不是模型自由文本);`startedAt` 是有限数才上 wire;
|
|
392
|
+
* · `name` / `workflowAgentLabel` —— UNTRUSTED 展示文本 ⇒ `redactSecrets`(同 `task_progress.name` / `.workflowAgentLabel`);
|
|
393
|
+
* · `spawnName` —— 出生点校验过的队友**身份键** ⇒ verbatim(理由全文在 {@link taskProgressEventData} 的同名键注);
|
|
394
|
+
* · 身份两键经 `identityFields`(信封上的 `sourceTaskId` / `bgAgentId` 不由本族构造器投,见 `FRAME_ENVELOPE_KEYS`)。
|
|
395
|
+
* 缺席即缺席:可选键缺席不铸键(`taskType` 缺席 = 前台子代,禁读作某个默认种类;`seq` 缺席 = 无 `a*` 行,禁读作 cycle 1)。
|
|
396
|
+
*/
|
|
397
|
+
export declare function taskStartedEventData(ev: {
|
|
398
|
+
/** 判别位(入参就是那一帧;本构造器不投它 —— 帧名由调用点的 `type` 键 / 账本行名给)。 */
|
|
399
|
+
type?: "task_started";
|
|
400
|
+
taskId: string;
|
|
401
|
+
sessionId: string;
|
|
402
|
+
taskType?: string;
|
|
403
|
+
seq?: number;
|
|
404
|
+
workflowRunId?: string;
|
|
405
|
+
workflowAgentLabel?: string;
|
|
406
|
+
parentTaskId?: string;
|
|
407
|
+
parentSessionId?: string;
|
|
408
|
+
rootSessionId?: string;
|
|
409
|
+
name?: string;
|
|
410
|
+
spawnName?: string;
|
|
411
|
+
agentType?: string;
|
|
412
|
+
model: string;
|
|
413
|
+
startedAt: number;
|
|
414
|
+
eventId?: string;
|
|
415
|
+
parentToolCallId?: string;
|
|
416
|
+
}): Record<string, unknown>;
|
|
376
417
|
/** The `task_notification` payload (core 1.202 [ref] P2: a background task finished — this event is the
|
|
377
418
|
* LEDGER/display projection of the OBSERVED terminal state, emitted the moment core observes it. It does NOT
|
|
378
419
|
* attest that the `<task-notification>` XML has entered the model context: core's steer targets the NEXT TURN
|
package/dist/trace/project.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isAskClass, isAskOrigin, isModeReleaseReason, isPermissionMode, isPersi
|
|
|
3
3
|
import { Value } from "typebox/value";
|
|
4
4
|
import { recordFailOpen } from "../observability/fail-open.js";
|
|
5
5
|
import { redactSecrets, redactDeep } from "./redact.js";
|
|
6
|
+
import { projectToolOutput } from "./tool-output-media.js";
|
|
6
7
|
import { injectionTierOrAbsent } from "./injection-tier.js";
|
|
7
8
|
import { semaProvenanceOrAbsent } from "./sema-provenance.js";
|
|
8
9
|
import { resupplyFields, terminalFrameFacetFields } from "./task-notification-facets.js";
|
|
@@ -133,22 +134,34 @@ function modeLedgerDefect(d) {
|
|
|
133
134
|
return "disposition.released.origin is outside the closed set";
|
|
134
135
|
if (o.mandate !== undefined && !isPersistedRuleMandate(o.mandate))
|
|
135
136
|
return "disposition.released.mandate is outside the closed set";
|
|
136
|
-
if (o.reason !== undefined && !isModeReleaseReason(o.reason))
|
|
137
|
-
return "disposition.released.reason is outside the closed set";
|
|
138
137
|
return false;
|
|
139
138
|
}
|
|
139
|
+
function withReleaseReasonTheEngineReads(g) {
|
|
140
|
+
const d = g.disposition;
|
|
141
|
+
if (d.kind !== "allowed" || d.released === undefined)
|
|
142
|
+
return g;
|
|
143
|
+
const r = d.released;
|
|
144
|
+
if (r === null || typeof r !== "object")
|
|
145
|
+
return g;
|
|
146
|
+
const reason = d.released.reason;
|
|
147
|
+
if (typeof reason !== "string" || isModeReleaseReason(reason))
|
|
148
|
+
return g;
|
|
149
|
+
const { reason: _unread, ...kept } = d.released;
|
|
150
|
+
return { ...g, disposition: { ...d, released: kept } };
|
|
151
|
+
}
|
|
140
152
|
function screenedGateOrThrow(v) {
|
|
141
153
|
if (v === null || typeof v !== "object") {
|
|
142
154
|
if (v !== undefined)
|
|
143
155
|
recordFailOpen("server.trace.gate-outcome-defective", "gate is not an object");
|
|
144
156
|
return undefined;
|
|
145
157
|
}
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
if (d === null || typeof d !== "object" || (d.kind !== "allowed" && d.kind !== "denied")) {
|
|
158
|
+
const stored = v;
|
|
159
|
+
if (stored.disposition === null || typeof stored.disposition !== "object" || (stored.disposition.kind !== "allowed" && stored.disposition.kind !== "denied")) {
|
|
149
160
|
recordFailOpen("server.trace.gate-outcome-defective", "disposition is not one of the two arms");
|
|
150
161
|
return undefined;
|
|
151
162
|
}
|
|
163
|
+
const g = withReleaseReasonTheEngineReads(stored);
|
|
164
|
+
const d = g.disposition;
|
|
152
165
|
const classifierFallbackRaw = d.classifier !== null && typeof d.classifier === "object" ? d.classifier.fallback : undefined;
|
|
153
166
|
const shapeDefect = (d.kind === "denied" && typeof d.deniedBy !== "string" && "disposition.deniedBy is not a string") ||
|
|
154
167
|
(d.kind === "denied" && d.cause !== undefined && typeof d.cause !== "string" && "disposition.cause is not a string") ||
|
|
@@ -273,7 +286,7 @@ export function toolEndEventData(ev) {
|
|
|
273
286
|
toolName: ev.toolName,
|
|
274
287
|
...(ev.label !== undefined ? { label: ev.label } : {}),
|
|
275
288
|
isError: ev.isError,
|
|
276
|
-
...(ev.output !== undefined ? { output:
|
|
289
|
+
...(ev.output !== undefined ? { output: projectToolOutput(ev.output) } : {}),
|
|
277
290
|
...(ev.truncated ? { truncated: true } : {}),
|
|
278
291
|
...(Number.isFinite(ev.totalChars) ? { totalChars: ev.totalChars } : {}),
|
|
279
292
|
...(ev.structured !== undefined ? { structured: redactDeep(ev.structured) } : {}),
|
|
@@ -297,7 +310,7 @@ export function toolProgressEventData(ev) {
|
|
|
297
310
|
toolCallId: id,
|
|
298
311
|
toolName: name,
|
|
299
312
|
...(n(ev.elapsedTimeSeconds) !== undefined ? { elapsedTimeSeconds: n(ev.elapsedTimeSeconds) } : {}),
|
|
300
|
-
...(hasOutput ? { output:
|
|
313
|
+
...(hasOutput ? { output: projectToolOutput(ev.output) } : {}),
|
|
301
314
|
...(hasOutput && n(ev.totalLines) !== undefined ? { totalLines: n(ev.totalLines) } : {}),
|
|
302
315
|
...(hasOutput && n(ev.totalBytes) !== undefined ? { totalBytes: n(ev.totalBytes) } : {}),
|
|
303
316
|
...identityFields(ev),
|
|
@@ -336,6 +349,25 @@ export function taskProgressEventData(ev) {
|
|
|
336
349
|
...identityFields(ev),
|
|
337
350
|
};
|
|
338
351
|
}
|
|
352
|
+
export function taskStartedEventData(ev) {
|
|
353
|
+
return {
|
|
354
|
+
taskId: ev.taskId,
|
|
355
|
+
sessionId: ev.sessionId,
|
|
356
|
+
...(typeof ev.taskType === "string" && ev.taskType.length > 0 ? { taskType: ev.taskType } : {}),
|
|
357
|
+
...(typeof ev.seq === "number" ? { seq: ev.seq } : {}),
|
|
358
|
+
...(ev.workflowRunId ? { workflowRunId: ev.workflowRunId } : {}),
|
|
359
|
+
...(ev.workflowAgentLabel ? { workflowAgentLabel: redactSecrets(ev.workflowAgentLabel) } : {}),
|
|
360
|
+
...(ev.parentTaskId ? { parentTaskId: ev.parentTaskId } : {}),
|
|
361
|
+
...(ev.parentSessionId ? { parentSessionId: ev.parentSessionId } : {}),
|
|
362
|
+
...(ev.rootSessionId ? { rootSessionId: ev.rootSessionId } : {}),
|
|
363
|
+
...(ev.name ? { name: redactSecrets(ev.name) } : {}),
|
|
364
|
+
...(ev.spawnName ? { spawnName: ev.spawnName } : {}),
|
|
365
|
+
...(ev.agentType ? { agentType: ev.agentType } : {}),
|
|
366
|
+
model: ev.model,
|
|
367
|
+
...(typeof ev.startedAt === "number" && Number.isFinite(ev.startedAt) ? { startedAt: ev.startedAt } : {}),
|
|
368
|
+
...identityFields(ev),
|
|
369
|
+
};
|
|
370
|
+
}
|
|
339
371
|
export function taskNotificationEventData(ev) {
|
|
340
372
|
const n = ev.notification;
|
|
341
373
|
return {
|
|
@@ -418,13 +418,6 @@ export declare const SELF_MINTED_WIRE: {
|
|
|
418
418
|
since: string;
|
|
419
419
|
};
|
|
420
420
|
};
|
|
421
|
-
readonly retired: {
|
|
422
|
-
readonly discuss: {
|
|
423
|
-
readonly attr: "-";
|
|
424
|
-
readonly since: "7.28.0";
|
|
425
|
-
readonly until: "7.126.0";
|
|
426
|
-
};
|
|
427
|
-
};
|
|
428
421
|
};
|
|
429
422
|
/**
|
|
430
423
|
* 提交体的场景透传键(受理门放行;`ScenarioRequest` 索引签名读)。7.126.0 只喂 discuss 场景与 code-review council 腿的四键退出 wire
|
|
@@ -438,28 +431,6 @@ export declare const SELF_MINTED_WIRE: {
|
|
|
438
431
|
since: string;
|
|
439
432
|
};
|
|
440
433
|
};
|
|
441
|
-
readonly retired: {
|
|
442
|
-
readonly businessContext: {
|
|
443
|
-
readonly attr: "-";
|
|
444
|
-
readonly since: "1.214.2";
|
|
445
|
-
readonly until: "7.126.0";
|
|
446
|
-
};
|
|
447
|
-
readonly lenses: {
|
|
448
|
-
readonly attr: "-";
|
|
449
|
-
readonly since: "1.214.2";
|
|
450
|
-
readonly until: "7.126.0";
|
|
451
|
-
};
|
|
452
|
-
readonly rounds: {
|
|
453
|
-
readonly attr: "-";
|
|
454
|
-
readonly since: "1.214.2";
|
|
455
|
-
readonly until: "7.126.0";
|
|
456
|
-
};
|
|
457
|
-
readonly team: {
|
|
458
|
-
readonly attr: "-";
|
|
459
|
-
readonly since: "1.214.2";
|
|
460
|
-
readonly until: "7.126.0";
|
|
461
|
-
};
|
|
462
|
-
};
|
|
463
434
|
};
|
|
464
435
|
/**
|
|
465
436
|
* `GET /v1/models` 应答体的顶层键(闭集;`src/http/routes/capabilities.ts` 的 `sendJson(res, 200, {…})` 字面量)。属性 = 在场律:`always` 恒在场(零条也出键),`present-iff` 条件成立才出键
|
|
@@ -519,6 +490,25 @@ export declare const SELF_MINTED_WIRE: {
|
|
|
519
490
|
readonly attr: "redactListEntry";
|
|
520
491
|
readonly since: "7.120.0";
|
|
521
492
|
};
|
|
493
|
+
/**
|
|
494
|
+
* 7.127.0(引擎 7.50.0:`tool_end.output` 按块带已准入的图像 / 文档):媒体块(image / document 且 `data` 是串)的 `data` 是字节编码 ——
|
|
495
|
+
* 活面 SSE 逐字过境,不跑文本脱敏(`trace/tool-output-media.ts` `projectToolOutput`;钉 test/tool-end-media-durable.test.ts);
|
|
496
|
+
* 唯一例外 = 连接积压:本帧媒体 + 这条连接 / 订阅者未送出的字节 > 64 MiB ⇒ 本帧媒体降描述符(`liveToolEndForBacklog`;钉 test/live-media-backlog.test.ts)。
|
|
497
|
+
*/
|
|
498
|
+
readonly "SSE tool_end#output[].data(\u5A92\u4F53\u5757)": {
|
|
499
|
+
readonly attr: "verbatim-bytes;backlog>64MiB⇒descriptor+totalChars";
|
|
500
|
+
readonly since: "7.127.0";
|
|
501
|
+
};
|
|
502
|
+
/**
|
|
503
|
+
* 7.127.0:同一媒体块在**持久面**(账本行与 `GET /v1/runs/:id/events` 回放)只存描述符 `{ type, mimeType?, bytes, truncated: true }`,
|
|
504
|
+
* 帧级 `truncated` 随之为真、帧级 `totalChars` 随之在场(core 不变量「Present iff truncated」:帧上已有 core 的值 ⇒ 原样保留,
|
|
505
|
+
* 没有 ⇒ 逐块真实大小求和;活面积压降级同一只函数)(账本汇点一处剥:`observability/run-terminal.ts` `redactLedgerEventData` →
|
|
506
|
+
* `toolEndMediaAsDescriptors`;钉同上)。
|
|
507
|
+
*/
|
|
508
|
+
readonly "GET /v1/runs/:id/events#tool_end.output[](\u5A92\u4F53\u5757)": {
|
|
509
|
+
readonly attr: "durableMediaDescriptor+totalChars";
|
|
510
|
+
readonly since: "7.127.0";
|
|
511
|
+
};
|
|
522
512
|
};
|
|
523
513
|
};
|
|
524
514
|
};
|
|
@@ -145,21 +145,12 @@ export const SELF_MINTED_WIRE = {
|
|
|
145
145
|
"code-review": { attr: "-", since: "1.214.2" },
|
|
146
146
|
scan: { attr: "-", since: "1.214.2" },
|
|
147
147
|
},
|
|
148
|
-
retired: {
|
|
149
|
-
discuss: { attr: "-", since: "7.28.0", until: "7.126.0" },
|
|
150
|
-
},
|
|
151
148
|
},
|
|
152
149
|
scenarioBodyKey: {
|
|
153
150
|
at: "POST /v1/tasks|/v1/tasks/stream|/v1/runs 体的场景透传键",
|
|
154
151
|
members: {
|
|
155
152
|
repo: { attr: "-", since: "1.214.2" },
|
|
156
153
|
},
|
|
157
|
-
retired: {
|
|
158
|
-
businessContext: { attr: "-", since: "1.214.2", until: "7.126.0" },
|
|
159
|
-
lenses: { attr: "-", since: "1.214.2", until: "7.126.0" },
|
|
160
|
-
rounds: { attr: "-", since: "1.214.2", until: "7.126.0" },
|
|
161
|
-
team: { attr: "-", since: "1.214.2", until: "7.126.0" },
|
|
162
|
-
},
|
|
163
154
|
},
|
|
164
155
|
modelsResponseKey: {
|
|
165
156
|
at: "GET /v1/models 应答体顶层键(<键> → 在场律)",
|
|
@@ -178,6 +169,8 @@ export const SELF_MINTED_WIRE = {
|
|
|
178
169
|
"POST /v1/side-query#errorMessage": { attr: "redactErrorMessage", since: "7.108.0" },
|
|
179
170
|
"engine_notice permission.allowed_tool_not_granted#detail.entries[].entry": { attr: "redactListEntry", since: "7.120.0" },
|
|
180
171
|
"engine_notice permission.rule_row_dropped#detail.rows[].rule": { attr: "redactListEntry", since: "7.120.0" },
|
|
172
|
+
"SSE tool_end#output[].data(媒体块)": { attr: "verbatim-bytes;backlog>64MiB⇒descriptor+totalChars", since: "7.127.0" },
|
|
173
|
+
"GET /v1/runs/:id/events#tool_end.output[](媒体块)": { attr: "durableMediaDescriptor+totalChars", since: "7.127.0" },
|
|
181
174
|
},
|
|
182
175
|
},
|
|
183
176
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 两面共用的 `output` 投影:串 / 文本块 / 其它块整只过 `redactDeep`;媒体块逐成员过,`data` 逐字。
|
|
3
|
+
* 保键序(逐键映射),不改入参。
|
|
4
|
+
*/
|
|
5
|
+
export declare function projectToolOutput(output: unknown): unknown;
|
|
6
|
+
/**
|
|
7
|
+
* `tool_end` 载荷的媒体降级(持久面恒用;活面只在连接积压时用):带 `data` 的媒体块换成描述符,有任何一块被换 ⇒ 帧级 `truncated: true`
|
|
8
|
+
* 且帧级 `totalChars` 在场 —— core 不变量「Present iff truncated」:被界之前那个值的真实大小。帧上已有 `totalChars`(core 已截断:
|
|
9
|
+
* 文本被切而媒体留着)⇒ **原样保留**(它说的是更早的原值,本仓手里的已是切过的值,重算只会低报);没有 ⇒ 按 {@link trueSizeOf}
|
|
10
|
+
* 逐块求和(core 没截,`output` 就是原值 —— 文本块是本服务脱敏后的字节,即本服务交付的内容)。
|
|
11
|
+
* 没有媒体块 ⇒ 原样返回同一引用(纯文本 / 串形 output 一个字节不变);已是描述符的块(无 `data`)原样 ⇒ 幂等。
|
|
12
|
+
*/
|
|
13
|
+
export declare function toolEndMediaAsDescriptors(data: Record<string, unknown>): Record<string, unknown>;
|
|
14
|
+
/** 活面一条连接允许压住的待发字节上界(含本帧媒体)。一帧媒体最大约为部署媒体预算的 4/3(缺省约 40 MiB),
|
|
15
|
+
* 上界取它之上一点:空闲连接上一整帧最大的图照样整块过,第二帧起只在读者跟上之后才整块。 */
|
|
16
|
+
export declare const LIVE_MEDIA_BACKLOG_BYTES: number;
|
|
17
|
+
/** 一帧 `tool_end` 载荷里媒体块 `data` 的字节数(base64 串长;没有媒体 = 0)。 */
|
|
18
|
+
export declare function liveMediaBytesOf(frame: Record<string, unknown>): number;
|
|
19
|
+
/**
|
|
20
|
+
* 活面的积压判据(一只):`backlogBytes` = 这条连接 / 这个订阅者此刻还没送出去的字节。本帧媒体 + 积压 > 上界 ⇒ 媒体降描述符,
|
|
21
|
+
* 否则原样(同一引用)。非 `tool_end` 载荷由调用方不送进来;没有媒体的 `tool_end` 恒原样。
|
|
22
|
+
* 降级是 F 类兜底(观众少见一张图),每降一帧在**这里**记一次 `server.tool-end-media.live-backlog-degraded` —— 三处写口都经这一只函数,
|
|
23
|
+
* 留痕因此只有一处;帧上它与引擎的媒体预算降级同形,计数是运维看出「多少观众丢了图」的唯一位。
|
|
24
|
+
*/
|
|
25
|
+
export declare function liveToolEndForBacklog(frame: Record<string, unknown>, backlogBytes: number): Record<string, unknown>;
|
|
26
|
+
//# sourceMappingURL=tool-output-media.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { redactDeep } from "./redact.js";
|
|
2
|
+
import { recordFailOpen } from "../observability/fail-open.js";
|
|
3
|
+
function isMediaBlock(b) {
|
|
4
|
+
if (b === null || typeof b !== "object" || Array.isArray(b))
|
|
5
|
+
return false;
|
|
6
|
+
const block = b;
|
|
7
|
+
return (block.type === "image" || block.type === "document") && typeof block.data === "string";
|
|
8
|
+
}
|
|
9
|
+
const MIME_ECHO_MAX = 255;
|
|
10
|
+
export function projectToolOutput(output) {
|
|
11
|
+
if (!Array.isArray(output))
|
|
12
|
+
return redactDeep(output);
|
|
13
|
+
return output.map((b) => (isMediaBlock(b) ? Object.fromEntries(Object.entries(b).map(([k, v]) => [k, k === "data" ? v : redactDeep(v)])) : redactDeep(b)));
|
|
14
|
+
}
|
|
15
|
+
function trueSizeOf(b) {
|
|
16
|
+
if (isMediaBlock(b))
|
|
17
|
+
return b.data.length;
|
|
18
|
+
if (b !== null && typeof b === "object" && !Array.isArray(b) && b.type === "text" && typeof b.text === "string") {
|
|
19
|
+
const { type: _type, text, ...rest } = b;
|
|
20
|
+
return text.length + Math.max(0, (JSON.stringify(rest)?.length ?? 2) - 2);
|
|
21
|
+
}
|
|
22
|
+
return JSON.stringify(b)?.length ?? 0;
|
|
23
|
+
}
|
|
24
|
+
export function toolEndMediaAsDescriptors(data) {
|
|
25
|
+
const output = data.output;
|
|
26
|
+
if (!Array.isArray(output) || !output.some(isMediaBlock))
|
|
27
|
+
return data;
|
|
28
|
+
const totalChars = typeof data.totalChars === "number" && Number.isFinite(data.totalChars) ? data.totalChars : output.reduce((n, b) => n + trueSizeOf(b), 0);
|
|
29
|
+
const stripped = output.map((b) => isMediaBlock(b)
|
|
30
|
+
? {
|
|
31
|
+
type: b.type,
|
|
32
|
+
...(typeof b.mimeType === "string" && b.mimeType.length <= MIME_ECHO_MAX ? { mimeType: b.mimeType } : {}),
|
|
33
|
+
bytes: Math.floor((b.data.length * 3) / 4),
|
|
34
|
+
truncated: true,
|
|
35
|
+
}
|
|
36
|
+
: b);
|
|
37
|
+
return { ...data, output: stripped, truncated: true, totalChars };
|
|
38
|
+
}
|
|
39
|
+
export const LIVE_MEDIA_BACKLOG_BYTES = 64 * 1024 * 1024;
|
|
40
|
+
export function liveMediaBytesOf(frame) {
|
|
41
|
+
const output = frame.output;
|
|
42
|
+
if (!Array.isArray(output))
|
|
43
|
+
return 0;
|
|
44
|
+
let n = 0;
|
|
45
|
+
for (const b of output)
|
|
46
|
+
if (isMediaBlock(b))
|
|
47
|
+
n += b.data.length;
|
|
48
|
+
return n;
|
|
49
|
+
}
|
|
50
|
+
export function liveToolEndForBacklog(frame, backlogBytes) {
|
|
51
|
+
const media = liveMediaBytesOf(frame);
|
|
52
|
+
if (media === 0 || backlogBytes + media <= LIVE_MEDIA_BACKLOG_BYTES)
|
|
53
|
+
return frame;
|
|
54
|
+
recordFailOpen("server.tool-end-media.live-backlog-degraded", `backlog=${backlogBytes} media=${media}`);
|
|
55
|
+
return toolEndMediaAsDescriptors(frame);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=tool-output-media.js.map
|
|
@@ -74,6 +74,12 @@ export declare const WIRE_PROJECTION_FACES: {
|
|
|
74
74
|
readonly excluded: readonly [];
|
|
75
75
|
readonly minted: readonly [];
|
|
76
76
|
};
|
|
77
|
+
readonly task_started: {
|
|
78
|
+
readonly projector: "taskStartedEventData";
|
|
79
|
+
readonly coreType: string;
|
|
80
|
+
readonly excluded: readonly [];
|
|
81
|
+
readonly minted: readonly [];
|
|
82
|
+
};
|
|
77
83
|
readonly tool_start: {
|
|
78
84
|
readonly projector: "toolStartEventData";
|
|
79
85
|
readonly coreType: string;
|
|
@@ -155,7 +161,7 @@ export declare const WIRE_PROJECTION_FACES: {
|
|
|
155
161
|
readonly human_input: {
|
|
156
162
|
readonly projector: "humanInputEventData";
|
|
157
163
|
readonly coreType: string;
|
|
158
|
-
readonly excluded: readonly ["principal"];
|
|
164
|
+
readonly excluded: readonly ["principal", "attachments"];
|
|
159
165
|
readonly minted: readonly [];
|
|
160
166
|
};
|
|
161
167
|
readonly task_notification: {
|
|
@@ -16,6 +16,7 @@ function withoutSections(all, drop) {
|
|
|
16
16
|
}
|
|
17
17
|
export const WIRE_PROJECTION_FACES = {
|
|
18
18
|
task_progress: { projector: "taskProgressEventData", coreType: arm("task_progress"), excluded: [], minted: [] },
|
|
19
|
+
task_started: { projector: "taskStartedEventData", coreType: arm("task_started"), excluded: [], minted: [] },
|
|
19
20
|
tool_start: { projector: "toolStartEventData", coreType: arm("tool_start"), excluded: [], minted: [] },
|
|
20
21
|
tool_end: { projector: "toolEndEventData", coreType: arm("tool_end"), excluded: [], minted: [] },
|
|
21
22
|
tool_progress: { projector: "toolProgressEventData", coreType: arm("tool_progress"), excluded: [], minted: [] },
|
|
@@ -29,7 +30,7 @@ export const WIRE_PROJECTION_FACES = {
|
|
|
29
30
|
context_usage: { projector: "contextUsageEventData", coreType: arm("context_usage"), excluded: [], minted: [] },
|
|
30
31
|
turn_end: { projector: "turnEndEventData", coreType: arm("turn_end"), excluded: [], minted: [] },
|
|
31
32
|
compaction_outcome: { projector: "compactionOutcomeEventData", coreType: arm("compaction_outcome"), excluded: [], minted: [] },
|
|
32
|
-
human_input: { projector: "humanInputEventData", coreType: arm("human_input"), excluded: ["principal"], minted: [] },
|
|
33
|
+
human_input: { projector: "humanInputEventData", coreType: arm("human_input"), excluded: ["principal", "attachments"], minted: [] },
|
|
33
34
|
task_notification: {
|
|
34
35
|
projector: "taskNotificationEventData",
|
|
35
36
|
coreType: `TaskNotificationPayload & ${arm("task_notification")}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/server",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.127.0",
|
|
4
4
|
"description": "Sema Server — the server/API implementation layer for Sema, wiring core, registry, model providers, and cloud agent execution. Built on @sema-agent/core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"build:binary:run-local:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/run-local.ts --outfile dist/run-local-darwin-arm64"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@sema-agent/core": "7.
|
|
67
|
+
"@sema-agent/core": "7.50.2",
|
|
68
68
|
"@sema-agent/settings-schema": "12.2.1",
|
|
69
69
|
"e2b": "^2.28.0",
|
|
70
70
|
"libsodium-wrappers": "^0.8.4",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"sharp": "^0.35.3"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@sema-agent/sdk": "21.
|
|
83
|
+
"@sema-agent/sdk": "21.1.0",
|
|
84
84
|
"@types/libsodium-wrappers": "^0.7.14",
|
|
85
85
|
"@types/node": "22.10.2",
|
|
86
86
|
"@types/pg": "^8.20.0",
|