@sema-agent/server 7.55.0 → 7.57.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 +3 -3
- package/README.md +14 -7
- package/README.zh-CN.md +10 -6
- package/USAGE.md +207 -59
- package/deploy/sema-up/chart/values.yaml +1 -1
- package/dist/approval-ask-audit-store.d.ts +100 -1
- package/dist/approval-ask-audit-store.js +103 -2
- package/dist/approval-card.d.ts +148 -13
- package/dist/approval-card.js +82 -13
- package/dist/approval-content-kind.d.ts +22 -0
- package/dist/approval-content-kind.js +5 -0
- package/dist/approval.d.ts +31 -0
- package/dist/approval.js +18 -0
- package/dist/auto-mode-face.d.ts +111 -0
- package/dist/auto-mode-face.js +99 -0
- package/dist/bench/s1/arms.js +5 -5
- package/dist/bench/s1/live-deps.js +11 -11
- package/dist/bench/s1/run-firm.js +3 -0
- package/dist/bench/s1/runner-ctx.d.ts +4 -0
- package/dist/bench/s1/runner-ctx.js +7 -0
- package/dist/boot/config-center.js +23 -1
- package/dist/boot/coordinators.js +13 -1
- package/dist/boot/leader.d.ts +21 -0
- package/dist/boot/leader.js +6 -0
- package/dist/boot/parked-revive-gate.d.ts +7 -2
- package/dist/boot/parked-revive-gate.js +12 -1
- package/dist/boot/resolve-spec.d.ts +3 -0
- package/dist/boot/resolve-spec.js +3 -1
- package/dist/boot/runner-deps.d.ts +12 -0
- package/dist/boot/runner-deps.js +28 -3
- package/dist/boot/runtime-caps.d.ts +19 -8
- package/dist/boot/runtime-caps.js +50 -20
- package/dist/boot/session-shell-gate-registry.d.ts +39 -0
- package/dist/boot/session-shell-gate-registry.js +21 -0
- package/dist/config-catalog.js +14 -5
- package/dist/config-center/types.d.ts +2 -1
- package/dist/config-provider.js +1 -0
- package/dist/config-types.d.ts +41 -10
- package/dist/config.d.ts +21 -0
- package/dist/config.js +40 -5
- package/dist/http/route-ctx.d.ts +90 -3
- package/dist/http/routes/a2a-serve.js +5 -3
- package/dist/http/routes/approvals-assistant.js +21 -8
- package/dist/http/routes/capabilities.js +21 -4
- package/dist/http/routes/leader.js +2 -2
- package/dist/http/routes/memory-origin.d.ts +2 -2
- package/dist/http/routes/rules.js +3 -2
- package/dist/http/routes/runs.d.ts +0 -14
- package/dist/http/routes/runs.js +20 -8
- package/dist/http/routes/tasks.js +34 -8
- package/dist/http/routes/workflows.js +20 -5
- package/dist/http/server.d.ts +11 -1
- package/dist/http/server.js +220 -34
- package/dist/http/wire-types.d.ts +9 -4
- package/dist/leader/diffout.js +2 -1
- package/dist/leader/endpoint.js +49 -15
- package/dist/leader/fanout.js +6 -5
- package/dist/leader/leader.js +17 -14
- package/dist/leader/merge.js +17 -12
- package/dist/leader/planner.js +3 -2
- package/dist/leader/repair-oracle.js +6 -4
- package/dist/leader/repair-wire.js +5 -3
- package/dist/leader/wire.d.ts +80 -1
- package/dist/leader/wire.js +55 -26
- package/dist/main.js +44 -8
- package/dist/observability/err-text.d.ts +6 -0
- package/dist/observability/err-text.js +10 -0
- package/dist/observability/fail-open.d.ts +40 -0
- package/dist/observability/fail-open.js +19 -0
- package/dist/observability/metrics.js +1 -1
- package/dist/observability/run-terminal-log.d.ts +120 -0
- package/dist/observability/run-terminal-log.js +360 -0
- package/dist/orchestration/workflow-completion-inbox.d.ts +9 -0
- package/dist/orchestration/workflow-completion-inbox.js +8 -0
- package/dist/permission-rule-vocab.d.ts +40 -0
- package/dist/permission-rule-vocab.js +17 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +26 -0
- package/dist/plugins/checkpoint-store-sql.js +23 -4
- package/dist/plugins/file-run-store.d.ts +3 -34
- package/dist/plugins/file-run-store.js +21 -0
- package/dist/plugins/local-checkpoint-store.d.ts +10 -0
- package/dist/plugins/local-checkpoint-store.js +5 -0
- package/dist/plugins/local-session-store.d.ts +9 -9
- package/dist/plugins/local-session-store.js +5 -3
- package/dist/plugins/memory-run-store.d.ts +3 -15
- package/dist/plugins/memory-run-store.js +21 -0
- package/dist/plugins/permission-rule-store-file.d.ts +22 -4
- package/dist/plugins/permission-rule-store-file.js +25 -11
- package/dist/plugins/permission-rule-store-sql.d.ts +60 -30
- package/dist/plugins/permission-rule-store-sql.js +39 -23
- package/dist/plugins/pg-session-storage.js +17 -13
- package/dist/plugins/remote-scratchpad.js +3 -2
- package/dist/plugins/run-store-sql.d.ts +3 -42
- package/dist/plugins/run-store-sql.js +36 -5
- package/dist/plugins/store-backend.d.ts +1 -1
- package/dist/plugins/store-contracts.d.ts +70 -1
- package/dist/plugins/tidb-session-store.js +18 -14
- package/dist/plugins/workflow-run-store-sql.d.ts +5 -0
- package/dist/plugins/workflow-run-store-sql.js +10 -2
- package/dist/rules-consent.d.ts +5 -4
- package/dist/rules-consent.js +25 -46
- package/dist/run-cancel-context.d.ts +13 -0
- package/dist/run-cancel-context.js +15 -0
- package/dist/run-local.js +2 -2
- package/dist/runs.d.ts +4 -1
- package/dist/runs.js +41 -10
- package/dist/runtime-caps-resolver.d.ts +133 -17
- package/dist/runtime-caps-resolver.js +44 -4
- package/dist/security.d.ts +7 -0
- package/dist/task-settings.d.ts +57 -3
- package/dist/task-settings.js +78 -5
- package/dist/task-workflow.d.ts +32 -2
- package/dist/task-workflow.js +8 -3
- package/dist/tool-approval.d.ts +38 -63
- package/dist/tool-approval.js +102 -74
- package/dist/trace/core-keyset-guard.d.ts +2 -2
- package/dist/trace/ledger-sink.d.ts +13 -4
- package/dist/trace/ledger-sink.js +14 -6
- package/dist/trace/project.d.ts +13 -0
- package/dist/trace/project.js +10 -1
- package/dist/trace/redact.d.ts +22 -11
- package/dist/trace/redact.js +655 -20
- package/dist/trace/sema-provenance.d.ts +26 -0
- package/dist/trace/sema-provenance.js +11 -0
- package/dist/turn-activity.d.ts +32 -2
- package/dist/turn-activity.js +29 -4
- package/package.json +3 -3
- package/skills/find-skills.md +1 -1
- package/skills/loop.md +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [ref](a)(core 7.2.0 / [ref] 片6 d1):`task_notification` 帧上 `_sema_provenance` typed 归因侧记的
|
|
3
|
+
* **单点**投影判据——live 三腿(`trace/project.ts` 的 `taskNotificationEventData`)与 park 半场
|
|
4
|
+
* (`orchestration/workflow-completion-inbox.ts` 的 `taskNotificationInboxEntry`)共用,两腿字节同判。
|
|
5
|
+
*
|
|
6
|
+
* `kind` 是**闭集**——wire 上只许出现 core 词表里的 lane 词。两向锚([ref]/[ref] 同纪律,与
|
|
7
|
+
* routes/notify-wake.ts 的 `NOTIFY_STATUSES` 同形):`satisfies` 保「表内无词表外的词」(core 删/改词 ⇒ 编译红),
|
|
8
|
+
* 穷举断言保「词表无表外的词」(core 加 lane ⇒ 编译红,新词必须由人处置——它是 cli 渲染判别键,静默透传一个
|
|
9
|
+
* 未知 lane 等于替 core 声明一种渲染形)。运行期闭集外的值(上游漂了 / 载荷被改过)⇒ **丢整键**,与 `priority`
|
|
10
|
+
* 的闭集守卫(`trace/injection-tier.ts`)同判:消费端退回老形卡,不按未知 lane 猜;`agentMessage` 不受牵连
|
|
11
|
+
* (它是渲染判别,不是 lane 词)。
|
|
12
|
+
*/
|
|
13
|
+
import type { SemaProvenance } from "@sema-agent/core";
|
|
14
|
+
export declare const SEMA_PROVENANCE_KINDS: readonly ["agent_message"];
|
|
15
|
+
/** 本仓两条腿入参的**形**(不是 core 类型:入参是运行期载荷,`kind` 先当 string 收、经闭集才成 typed)。 */
|
|
16
|
+
export interface SemaProvenanceInput {
|
|
17
|
+
kind: string;
|
|
18
|
+
from: string;
|
|
19
|
+
taskId: string;
|
|
20
|
+
seq: number;
|
|
21
|
+
agentType?: string;
|
|
22
|
+
}
|
|
23
|
+
/** 逐成员挑取(绝不 spread —— core 给侧记加成员时必须经 keyset 门处置,见 `trace/core-keyset-guard.ts` ①);
|
|
24
|
+
* 返回 undefined = 闭集外 / 形不合 ⇒ 调用方丢整键。`agentType` 缺席不编(本 mount 恒缺席,在场即透传)。 */
|
|
25
|
+
export declare function semaProvenanceOrAbsent(p: SemaProvenanceInput): SemaProvenance | undefined;
|
|
26
|
+
//# sourceMappingURL=sema-provenance.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const SEMA_PROVENANCE_KINDS = ["agent_message"];
|
|
2
|
+
const _semaProvenanceExhaustive = true;
|
|
3
|
+
void _semaProvenanceExhaustive;
|
|
4
|
+
export function semaProvenanceOrAbsent(p) {
|
|
5
|
+
if (!SEMA_PROVENANCE_KINDS.includes(p.kind))
|
|
6
|
+
return undefined;
|
|
7
|
+
if (typeof p.from !== "string" || typeof p.taskId !== "string" || typeof p.seq !== "number")
|
|
8
|
+
return undefined;
|
|
9
|
+
return { kind: p.kind, from: p.from, taskId: p.taskId, seq: p.seq, ...(typeof p.agentType === "string" ? { agentType: p.agentType } : {}) };
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=sema-provenance.js.map
|
package/dist/turn-activity.d.ts
CHANGED
|
@@ -21,10 +21,40 @@
|
|
|
21
21
|
* 提交——不清的话新 run 首次打点前会读到旧 run 的时刻 = 假「刚有活性」证据。清点 = 三个 createRun
|
|
22
22
|
* 成功分支(routes/runs.ts + routes/tasks.ts×2,接线锚在 session-active-conflict-materials 测试)。
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
import type { RunBrainStatusSnapshot } from "./plugins/store-contracts.js";
|
|
25
|
+
/** 一次打点的读数。`kind` = 触发这次打点的 durable 事件类型;打点方拿不到类型(core 的 onActivity
|
|
26
|
+
* 第五席、resume 腿的手动打点)⇒ 缺席,**绝不铸占位词** —— [ref] 的 `cancelContext.lastEventKind`
|
|
27
|
+
* 会原样上 wire,一个编出来的 `"unknown"` 会被消费端读成「引擎真发过一条叫 unknown 的事件」。
|
|
28
|
+
*
|
|
29
|
+
* `brainStatus` = 本 run 账本尾**最后一条** `status` 帧的判别五键([ref]/[ref]:重试相位早已在
|
|
30
|
+
* wire 上,server 侧不需要 core 新钩就能回答「已重试几次 / 在等什么」)。它是 **sticky** 的 ——
|
|
31
|
+
* 后续别的事件(text/tool)打点**不清**它:问题是「上次大脑说了什么」,不是「上一条事件是不是大脑说的」。 */
|
|
32
|
+
export interface TurnActivity {
|
|
33
|
+
at: number;
|
|
34
|
+
kind?: string;
|
|
35
|
+
brainStatus?: RunBrainStatusSnapshot;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* ledger sink 每次 durable append 时打点(装配点:runs.ts / routes/tasks.ts 的 createLedgerSink)。
|
|
39
|
+
*
|
|
40
|
+
* @param kind 账本写口传得出事件类型就传([ref] 件3 的判别材料),传不出就省。
|
|
41
|
+
* @param statusData `status` 帧的**已投影**载荷(`trace/project.ts` 的 `brainStatusEventData` 产物)。
|
|
42
|
+
* 只有 `status` 那一路传;本函数从中挑出五键存起来,并 **sticky 保留**到下一条 status 帧到来。
|
|
43
|
+
* 之所以在这里挑而不是在 sink 里挑:挑法与存法同一个属主,sink 不必认识这个类型。
|
|
44
|
+
*/
|
|
45
|
+
export declare function recordTurnActivity(taskId: string, kind?: string, statusData?: Record<string, unknown>): void;
|
|
46
|
+
/**
|
|
47
|
+
* `brainStatusEventData` 的投影产物 → {@link RunBrainStatusSnapshot} 的五键子集。
|
|
48
|
+
*
|
|
49
|
+
* 逐键**按型收**(不是整只透传):投影产物是给账本行用的宽面(还带 `detail` / `retryInMs` /
|
|
50
|
+
* `eventId` / 身份键),而 `cancelContext` 是分诊便签 —— `detail` 是**模型/provider 的自由文本**
|
|
51
|
+
* (已过 redactSecrets,但仍是宽面),不进这只小快照。非期望型的值一律丢(不铸)。
|
|
52
|
+
*/
|
|
53
|
+
export declare function pickRunBrainStatus(data: Record<string, unknown> | undefined): RunBrainStatusSnapshot | undefined;
|
|
26
54
|
/** 最后活性时刻(epoch ms);无记录 ⇒ undefined(缺席语义见顶注)。 */
|
|
27
55
|
export declare function readTurnActivityMs(taskId: string): number | undefined;
|
|
56
|
+
/** 最后一次打点的完整读数(时刻 + 事件类型);无记录 ⇒ undefined。[ref] 件3 的数据源。 */
|
|
57
|
+
export declare function readTurnActivity(taskId: string): TurnActivity | undefined;
|
|
28
58
|
/** 测试隔离用(生产路径不调:终局不清的理由见顶注)。 */
|
|
29
59
|
export declare function clearTurnActivity(taskId: string): void;
|
|
30
60
|
//# sourceMappingURL=turn-activity.d.ts.map
|
package/dist/turn-activity.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const CAP = 8192;
|
|
2
2
|
const lastActivityByTask = new Map();
|
|
3
|
-
export function recordTurnActivity(taskId) {
|
|
4
|
-
|
|
3
|
+
export function recordTurnActivity(taskId, kind, statusData) {
|
|
4
|
+
const prev = lastActivityByTask.get(taskId);
|
|
5
|
+
if (prev !== undefined) {
|
|
5
6
|
lastActivityByTask.delete(taskId);
|
|
6
7
|
}
|
|
7
8
|
else if (lastActivityByTask.size >= CAP) {
|
|
@@ -9,10 +10,34 @@ export function recordTurnActivity(taskId) {
|
|
|
9
10
|
if (oldest !== undefined)
|
|
10
11
|
lastActivityByTask.delete(oldest);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
const brainStatus = pickRunBrainStatus(statusData) ?? prev?.brainStatus;
|
|
14
|
+
lastActivityByTask.set(taskId, {
|
|
15
|
+
at: Date.now(),
|
|
16
|
+
...(kind !== undefined ? { kind } : {}),
|
|
17
|
+
...(brainStatus !== undefined ? { brainStatus } : {}),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function pickRunBrainStatus(data) {
|
|
21
|
+
if (data === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
const phase = data.phase;
|
|
24
|
+
if (typeof phase !== "string" || phase.length === 0)
|
|
25
|
+
return undefined;
|
|
26
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v);
|
|
27
|
+
return {
|
|
28
|
+
phase,
|
|
29
|
+
...(num(data.attempt) ? { attempt: data.attempt } : {}),
|
|
30
|
+
...(num(data.maxRetries) ? { maxRetries: data.maxRetries } : {}),
|
|
31
|
+
...(num(data.retryAtMs) ? { retryAtMs: data.retryAtMs } : {}),
|
|
32
|
+
...(typeof data.errClass === "string" && data.errClass.length > 0 ? { errClass: data.errClass } : {}),
|
|
33
|
+
};
|
|
13
34
|
}
|
|
14
35
|
export function readTurnActivityMs(taskId) {
|
|
15
|
-
return lastActivityByTask.get(taskId);
|
|
36
|
+
return lastActivityByTask.get(taskId)?.at;
|
|
37
|
+
}
|
|
38
|
+
export function readTurnActivity(taskId) {
|
|
39
|
+
const a = lastActivityByTask.get(taskId);
|
|
40
|
+
return a === undefined ? undefined : { ...a };
|
|
16
41
|
}
|
|
17
42
|
export function clearTurnActivity(taskId) {
|
|
18
43
|
lastActivityByTask.delete(taskId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/server",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.57.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",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"build:binary:run-local:darwin-arm64": "bun build --compile --target=bun-darwin-arm64 src/run-local.ts --outfile dist/run-local-darwin-arm64"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@sema-agent/core": "7.
|
|
58
|
-
"@sema-agent/settings-schema": "1.
|
|
57
|
+
"@sema-agent/core": "7.2.0",
|
|
58
|
+
"@sema-agent/settings-schema": "1.4.0",
|
|
59
59
|
"e2b": "^2.28.0",
|
|
60
60
|
"libsodium-wrappers": "^0.8.4",
|
|
61
61
|
"mysql2": "^3.22.4",
|
package/skills/find-skills.md
CHANGED
|
@@ -141,7 +141,7 @@ npx skills init my-xyz-skill
|
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
<!--
|
|
144
|
-
TODO (
|
|
144
|
+
TODO (clay): add our own first-party skill sources here -
|
|
145
145
|
sema-registry / config-center - as a discovery+install lane alongside the open
|
|
146
146
|
skills.sh ecosystem. Not every deployment ships a config-center, so the section
|
|
147
147
|
must probe availability first and fall back to the public ecosystem cleanly.
|
package/skills/loop.md
CHANGED
|
@@ -35,7 +35,7 @@ Then briefly confirm what's scheduled (id, human cadence, how to cancel with `Cr
|
|
|
35
35
|
With no interval, run one iteration of the task now, then call `ScheduleWakeup` to schedule when you resume:
|
|
36
36
|
|
|
37
37
|
- `delaySeconds`: how long to sleep (runtime clamps to [60, 3600]).
|
|
38
|
-
- `reason`: one short, specific sentence ("watching CI run #
|
|
38
|
+
- `reason`: one short, specific sentence ("watching CI run #4521" beats "waiting") — shown to the user and telemetry.
|
|
39
39
|
- `prompt`: the same /loop input verbatim, so the next firing re-enters this skill and continues the loop. For an autonomous loop with no user prompt, pass the literal sentinel `<<autonomous-loop-dynamic>>` (never the CronCreate-mode `<<autonomous-loop>>` sentinel — ScheduleWakeup always uses the `-dynamic` variant).
|
|
40
40
|
- To END the loop: call `ScheduleWakeup` with `stop: true` and omit every other field — the loop ends immediately and no further wakeups fire.
|
|
41
41
|
|