@sema-agent/server 7.137.0 → 7.138.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 +328 -139
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/USAGE.md +67 -20
- package/dist/approval-card.d.ts +21 -14
- package/dist/approval-card.js +1 -0
- package/dist/audit.js +1 -0
- package/dist/background-agent-name.d.ts +5 -0
- package/dist/background-agent-name.js +5 -0
- package/dist/boot/budget-tracing.d.ts +1 -12
- package/dist/boot/deployment-mods.d.ts +46 -16
- package/dist/boot/deployment-mods.js +82 -6
- package/dist/boot/governance-seams.d.ts +10 -17
- package/dist/boot/governance-seams.js +5 -17
- package/dist/boot/leader.d.ts +3 -0
- package/dist/boot/leader.js +1 -0
- package/dist/boot/org-delivery.js +15 -2
- package/dist/boot/resolve-spec.d.ts +3 -0
- package/dist/boot/resolve-spec.js +23 -12
- package/dist/boot/retention-lane.d.ts +11 -5
- package/dist/boot/retention-lane.js +2 -2
- package/dist/boot/runner-deps.d.ts +7 -3
- package/dist/boot/runner-deps.js +1 -0
- package/dist/boot/stage-04-stores.d.ts +1 -12
- package/dist/boot/stage-05-execution-env.d.ts +3 -12
- package/dist/boot/stage-05-execution-env.js +7 -4
- package/dist/boot/stage-06-runners.d.ts +3 -12
- package/dist/boot/stage-06-runners.js +5 -2
- package/dist/boot/stage-07-capability-layer.d.ts +3 -12
- package/dist/boot/stage-07-capability-layer.js +2 -2
- package/dist/boot/stage-08-reapers.d.ts +3 -12
- package/dist/boot/stage-09-leader.d.ts +3 -12
- package/dist/boot/stage-09-leader.js +2 -2
- package/dist/boot/stage-10-http-server.d.ts +3 -12
- package/dist/boot/stage-10-http-server.js +4 -2
- package/dist/boot/web-admin.d.ts +5 -2
- package/dist/boot/web-admin.js +3 -3
- package/dist/brain.js +5 -5
- package/dist/budget.d.ts +17 -15
- package/dist/budget.js +2 -2
- package/dist/capabilities/mcp-probe.d.ts +36 -11
- package/dist/capabilities/mcp-probe.js +44 -5
- package/dist/capability-facts.d.ts +6 -0
- package/dist/capability-facts.js +5 -0
- package/dist/checkpoint-identity.d.ts +13 -6
- package/dist/config-catalog.js +7 -1
- package/dist/config-types.d.ts +15 -7
- package/dist/config.js +8 -5
- package/dist/deployment-shape.d.ts +6 -6
- package/dist/gate-settlement.d.ts +71 -0
- package/dist/gate-settlement.js +40 -0
- package/dist/hooks/classic-stations.d.ts +1 -0
- package/dist/hooks/classic-stations.js +1 -0
- package/dist/hooks/command-spawn.d.ts +2 -2
- package/dist/hooks/hook-runner.js +14 -14
- package/dist/http/admission.js +4 -2
- package/dist/http/dispatch.d.ts +4 -0
- package/dist/http/dispatch.js +3 -0
- package/dist/http/durable-run-leg.js +4 -2
- package/dist/http/memory-compliance-failure-reply.js +3 -0
- package/dist/http/resume-legs.d.ts +5 -11
- package/dist/http/resume-legs.js +136 -91
- package/dist/http/route-ctx.d.ts +30 -51
- package/dist/http/route-ctx.js +2 -5
- package/dist/http/routes/a2a-serve.js +10 -4
- package/dist/http/routes/agents-roster.d.ts +1 -1
- package/dist/http/routes/agents-roster.js +5 -1
- package/dist/http/routes/approvals-assistant.js +6 -6
- package/dist/http/routes/capabilities.js +12 -10
- package/dist/http/routes/mcp-reconnect.d.ts +3 -2
- package/dist/http/routes/mcp-reconnect.js +7 -5
- package/dist/http/routes/memory-consolidation.d.ts +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/rules.js +3 -3
- package/dist/http/routes/runs.js +11 -7
- package/dist/http/routes/sessions.js +6 -4
- package/dist/http/routes/side-query.js +2 -3
- package/dist/http/routes/tasks.js +792 -780
- package/dist/http/server.d.ts +31 -25
- package/dist/http/wire-types.d.ts +14 -6
- package/dist/identity-source.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/leader/wire.d.ts +7 -0
- package/dist/leader/wire.js +5 -4
- package/dist/mcp-assertion-header.d.ts +51 -40
- package/dist/mcp-assertion-header.js +10 -11
- package/dist/mcp-authorization-face.d.ts +27 -0
- package/dist/mcp-authorization-face.js +15 -0
- package/dist/memory-operator-faces.d.ts +13 -4
- package/dist/memory-operator-faces.js +1 -17
- package/dist/memory-sync-client.js +72 -57
- package/dist/memory-sync.d.ts +1 -1
- package/dist/model-route-gap.d.ts +6 -22
- package/dist/model-route-gap.js +7 -5
- package/dist/mods-declaration.d.ts +110 -0
- package/dist/mods-declaration.js +109 -0
- package/dist/observability/err-text.d.ts +5 -0
- package/dist/observability/err-text.js +9 -0
- package/dist/observability/fail-open.d.ts +5 -1
- package/dist/observability/fail-open.js +5 -1
- package/dist/observability/secret-env-scrub.d.ts +1 -1
- package/dist/observability/secret-env-scrub.js +1 -1
- package/dist/parked-decide.d.ts +15 -2
- package/dist/parked-decide.js +14 -8
- package/dist/peer-seat.d.ts +150 -0
- package/dist/peer-seat.js +239 -0
- package/dist/permission-rule-vocab.d.ts +7 -7
- package/dist/permission-rule-vocab.js +3 -3
- package/dist/plain-string-record.d.ts +38 -0
- package/dist/plain-string-record.js +38 -0
- package/dist/plugins/background-agent-store-sql.js +6 -3
- package/dist/plugins/caching-session-store.d.ts +5 -0
- package/dist/plugins/caching-session-store.js +6 -0
- package/dist/plugins/checkpoint-store-sql.d.ts +15 -20
- package/dist/plugins/checkpoint-store-sql.js +8 -8
- package/dist/plugins/file-history-store-sql.js +3 -2
- package/dist/plugins/k8s-pod-reaper.d.ts +2 -8
- package/dist/plugins/k8s-pod-reaper.js +3 -3
- package/dist/plugins/local-checkpoint-store.d.ts +1 -11
- package/dist/plugins/local-checkpoint-store.js +0 -1
- package/dist/plugins/local-session-store.d.ts +66 -27
- package/dist/plugins/local-session-store.js +60 -28
- package/dist/plugins/mailbox-store-sql.d.ts +11 -3
- package/dist/plugins/mailbox-store-sql.js +103 -15
- package/dist/plugins/memory-sync-store-pg.d.ts +16 -5
- package/dist/plugins/memory-sync-store-tidb.d.ts +3 -3
- package/dist/plugins/one-time-migrations.d.ts +6 -3
- package/dist/plugins/one-time-migrations.js +3 -4
- package/dist/plugins/permission-rule-store-sql.js +21 -13
- package/dist/plugins/pg-session-storage.d.ts +10 -2
- package/dist/plugins/pg-session-storage.js +18 -5
- package/dist/plugins/remote-env-adb.d.ts +3 -1
- package/dist/plugins/remote-env-adb.js +1 -1
- package/dist/plugins/remote-env-device.d.ts +3 -1
- package/dist/plugins/remote-env-device.js +1 -1
- package/dist/plugins/remote-env-e2b.d.ts +2 -0
- package/dist/plugins/remote-env-e2b.js +1 -1
- package/dist/plugins/remote-env-host.d.ts +3 -1
- package/dist/plugins/remote-env-host.js +1 -1
- package/dist/plugins/remote-env-k8s.d.ts +3 -1
- package/dist/plugins/remote-env-k8s.js +1 -1
- package/dist/plugins/remote-env-local-docker.d.ts +2 -0
- package/dist/plugins/remote-env-local-docker.js +1 -1
- package/dist/plugins/remote-env-ssh.d.ts +3 -1
- package/dist/plugins/remote-env-ssh.js +1 -1
- package/dist/plugins/retention-store-sql.d.ts +14 -2
- package/dist/plugins/retention-store-sql.js +6 -0
- package/dist/plugins/session-fork.d.ts +10 -13
- package/dist/plugins/session-fork.js +5 -25
- package/dist/plugins/session-ownership.d.ts +7 -0
- package/dist/plugins/session-ownership.js +5 -0
- package/dist/plugins/session-workspace-cell.d.ts +17 -0
- package/dist/plugins/session-workspace-cell.js +38 -0
- package/dist/plugins/store-backend.js +7 -7
- package/dist/plugins/tidb-pool.js +6 -0
- package/dist/plugins/tidb-session-store.d.ts +17 -2
- package/dist/plugins/tidb-session-store.js +16 -5
- package/dist/plugins/tool-result-store-sql.d.ts +13 -6
- package/dist/plugins/tool-result-store-sql.js +8 -7
- package/dist/plugins/worktree-isolation.d.ts +3 -2
- package/dist/plugins/worktree-isolation.js +1 -7
- package/dist/project-identity.d.ts +1 -14
- package/dist/project-identity.js +0 -4
- package/dist/rules-consent.js +6 -4
- package/dist/run-local.js +12 -6
- package/dist/runs.d.ts +7 -1
- package/dist/runs.js +6 -1
- package/dist/sandbox-git-plane.d.ts +2 -2
- package/dist/server-secret-env.d.ts +6 -3
- package/dist/server-secret-env.js +4 -2
- package/dist/session-incarnation.d.ts +4 -5
- package/dist/session-incarnation.js +2 -2
- package/dist/session-workspace.d.ts +130 -0
- package/dist/session-workspace.js +83 -0
- package/dist/spec-fields.d.ts +1 -1
- package/dist/standing-answer-grant.d.ts +2 -13
- package/dist/standing-answer-grant.js +0 -7
- package/dist/task-a2a.d.ts +44 -14
- package/dist/task-a2a.js +46 -20
- package/dist/task-mcp.d.ts +33 -20
- package/dist/task-mcp.js +46 -22
- package/dist/tool-approval.d.ts +32 -8
- package/dist/tool-approval.js +49 -12
- package/dist/trace/core-keyset-guard.d.ts +33 -18
- package/dist/trace/engine-notice-wire.d.ts +1 -1
- package/dist/trace/engine-notice-wire.js +2 -0
- package/dist/trace/exit-seat.d.ts +20 -1
- package/dist/trace/exit-seat.js +3 -0
- package/dist/trace/extension-call-face.d.ts +33 -0
- package/dist/trace/extension-call-face.js +39 -0
- package/dist/trace/project.d.ts +25 -7
- package/dist/trace/project.js +29 -3
- package/dist/trace/redact.js +42 -13
- package/dist/trace/self-minted-wire.d.ts +129 -10
- package/dist/trace/self-minted-wire.js +62 -3
- package/dist/trace/wire-projection-faces.d.ts +6 -6
- package/dist/trace/wire-projection-faces.js +6 -5
- package/dist/user-authored-text.d.ts +2 -2
- package/dist/user-authored-text.js +16 -1
- package/dist/web-admin-client/center-request.d.ts +3 -2
- package/dist/web-admin-client/center-request.js +2 -3
- package/dist/web-admin-client/skills-mcp.d.ts +8 -4
- package/dist/web-admin-client/skills-mcp.js +31 -18
- package/dist/web-admin-client/types.d.ts +5 -0
- package/package.json +3 -3
- package/wire-changes/server@7.138.0.json +446 -0
- package/dist/http/mcp-remote-text.d.ts +0 -5
- package/dist/http/mcp-remote-text.js +0 -7
package/dist/tool-approval.d.ts
CHANGED
|
@@ -10,8 +10,9 @@ import { type AskRowEndingCause, type SettleCause, type SettleOutcome } from "./
|
|
|
10
10
|
import type { ParkCommitWatch } from "./plugins/park-commit-watch.js";
|
|
11
11
|
import { type GovernanceAskMarks } from "./governance-ask-marks.js";
|
|
12
12
|
import { type GovernancePosture } from "./runtime-governance.js";
|
|
13
|
-
import { type GrantBinding, type
|
|
13
|
+
import { type GrantBinding, type StandingAnswerCard } from "./standing-answer-grant.js";
|
|
14
14
|
import { type ApprovalExemptionStore } from "./plugins/approval-exemption-store.js";
|
|
15
|
+
import { type ExtensionRequesterFace } from "./trace/extension-call-face.js";
|
|
15
16
|
/** {@link ToolApprovalCoordinator.adoptOpenAsks} 的读数(装配点进启动日志)。 */
|
|
16
17
|
interface OpenAskAdoption {
|
|
17
18
|
/** 本次接管进活集合的问数。 */
|
|
@@ -214,10 +215,10 @@ export declare function carriesDeploymentListQuestion(deploymentListAsks: boolea
|
|
|
214
215
|
* (`task-settings.ts`,`false`)—— 它们在交出这一问之前先读按工具名记的耐久豁免店(「本会话不再询问」在本层兑现,继承链上的同一问才够得着;审批席依约不退役
|
|
215
216
|
* 继承问),而**能不能读**与审批席 / 回决写侧是同一只判据({@link standingAnswerDurablyRecordable}):记得下的才代答,记不下的(带授予绑定的问 ……)不代答,
|
|
216
217
|
* 存量行也不例外 —— 一事一读。事实取自**这一问本身**:类集经 core 包根唯一的类派生 `classifyAsk`({@link noGateFacts},调用坐标取 `req`);`requiresRealApproval` /
|
|
217
|
-
* `mandated` 读这一问自报的成员;治理位恒假(本层不是治理层)
|
|
218
|
-
* `
|
|
218
|
+
* `mandated` 读这一问自报的成员;治理位恒假(本层不是治理层);授予绑定读**请求上引擎的词**(core 7.59.0 起 Runner 交给策略的 `ToolCallRequest`
|
|
219
|
+
* 带与卡同一组词;宿主不经 Runner 自建的请求两者都不说 ⇒ `unreadable` ⇒ 不读店,fail-closed —— 见 `standing-answer-grant.ts` 头注)。
|
|
219
220
|
*/
|
|
220
|
-
export declare function policyAskStandingAnswerFacts(req:
|
|
221
|
+
export declare function policyAskStandingAnswerFacts(req: StandingAnswerCard & {
|
|
221
222
|
readonly toolCallId: string;
|
|
222
223
|
readonly toolName: string;
|
|
223
224
|
}, ask: Extract<PermissionResult, {
|
|
@@ -242,8 +243,8 @@ export interface StandingAnswerFacts {
|
|
|
242
243
|
readonly mandated: boolean;
|
|
243
244
|
/** 这一问的应答**授不授予**这一次调用之外的东西、授予的话绑定是什么(批准引擎的 `Skill` = 激活技能 + 本 run 内清单免问)。
|
|
244
245
|
* `bound` ⇒ 站着的答案按「工具 + 绑定」记、只代答绑定相同的问(core 7.43.0 [ref] / [ref]:活的问与停驻行同带 `boundGrantDigest`);
|
|
245
|
-
* `unreadable` ⇒ 不可记、不被代答(fail-closed)。读者一律经 `standing-answer-grant.ts`
|
|
246
|
-
*
|
|
246
|
+
* `unreadable` ⇒ 不可记、不被代答(fail-closed)。读者一律经 `standing-answer-grant.ts` 的唯一读口 `grantBindingOf` 折这一位:只读载体上引擎的词,
|
|
247
|
+
* 载体不论(卡、停驻行、队列行、策略层的请求)。 */
|
|
247
248
|
readonly grantBinding: GrantBinding;
|
|
248
249
|
/** 引擎盖在这一问上的**类集**(`AskRequest.classes` / 停驻行孪生座;经 core 的屏 `screenAskClassMembers` 读)。`undefined` = 卡上没有类
|
|
249
250
|
* (老引擎 / 不盖类的站)或屏拒 —— 读不出的类不是「无类」。 */
|
|
@@ -474,6 +475,14 @@ export interface ToolApprovalFrame {
|
|
|
474
475
|
* ask」,治理策略产的与普通策略产的在这一个词上同形 ⇒ 顶替不了(逐字论证见 `governance-ask-marks.ts` 顶注)。
|
|
475
476
|
*/
|
|
476
477
|
origin?: string;
|
|
478
|
+
/**
|
|
479
|
+
* **ADDITIVE,`"tool_approval"` only** —— 这一问的调用是**一张扩展注册自己发起**的(`$.tool.call`,core 7.56.0 `AskRequest.requestedBy`):
|
|
480
|
+
* `{ kind: "extension", name }`,卡上「扩展 X 想跑 …」那一行的出处。模型消息带来的调用上缺席。display 事实,不是裁决输入。
|
|
481
|
+
* 读法与 `tool_start` / `tool_end` 上的同名键是同一只(`trace/extension-call-face.ts`:注册名过注册方文本的出口纪律,与 `wiring_manifest.mods[]` 的 `name`
|
|
482
|
+
* 逐字节同;形不对 ⇒ 丢 + 计一次)。呈卡腿上它是 `approval_request` 顶层的卡外座之一(`APPROVAL_REQUEST_LIVE_FACT_KEYS`,同一只帧对象的值);
|
|
483
|
+
* ⚠️ `card_json` 卡面不带本键(卡的键集属主在契约包),断连重放帧上它恒缺席(与其余卡外座同)。
|
|
484
|
+
*/
|
|
485
|
+
requestedBy?: ExtensionRequesterFace;
|
|
477
486
|
/**
|
|
478
487
|
* **[ref] ②(core 7.37.0 [ref];ADDITIVE,`"tool_approval"` only)** —— 这一问的**类**:`classes` 的首员(core `ASK_CLASSES` 序),
|
|
479
488
|
* `MODE_ARBITRATION` 的行键(权限模式读的就是它 / 它们)。引擎在每一个铸 `origin` 的站盖章(策略自报的值在盖章处被替换),本仓经
|
|
@@ -499,7 +508,7 @@ export interface ToolApprovalFrame {
|
|
|
499
508
|
/** [ref](core 7.51.0 [ref],**ADDITIVE**,`"tool_approval"` only):这张卡为什么没有 {@link boundGrantDigest} —— 引擎铸的每张卡恰带两者之一:
|
|
500
509
|
* `not_bindable`(这一问不是引擎 `Skill` 工具的激活,不绑任何授予 ⇒ 应答可按工具记)/ `unreadable`(绑着却读不出;活卡上引擎恒给摘要,这一词
|
|
501
510
|
* 只出现在读存量行的面上)。闭集经 `readClosedWordSeat(req, "boundGrantAbsence")` 窄读(筛 = core `BOUND_GRANT_ABSENCES`),集外 ⇒ 缺席 + 计一次。
|
|
502
|
-
* 与停驻行 / 运维队列行 / inbox
|
|
511
|
+
* 与停驻行 / 运维队列行 / inbox 行的同名位同值;站着的答案的授予绑定读它(`standing-answer-grant.ts` `grantBindingOf`,问是谁的都同读)。display。 */
|
|
503
512
|
boundGrantAbsence?: BoundGrantAbsence;
|
|
504
513
|
/** core 7.43.0 [ref]:分类器没给判词的成因词(`error` / `timeout` / `parse_error`;只在类 `classifier_no_ruling` 的卡上)。闭集经 core 的
|
|
505
514
|
* `readClosedWordSeat(req, "classifierNoRuling")` 窄读(筛 = core `isAutoModeFallbackCause`),集外 ⇒ 缺席 + 计一次。display:本仓不按它裁决。 */
|
|
@@ -1601,7 +1610,7 @@ export declare class ToolApprovalCoordinator {
|
|
|
1601
1610
|
* ⇒ 截一个字就恒 `rule_not_offered`,所以**绝不截**;真超尺(= core 放宽了自己的 512 或本仓与 core
|
|
1602
1611
|
* 版本不同步)⇒ **整条车道撤回**(返回 `undefined`),与本文件既有的治理撤回 / 漂移撤回逐字同形:
|
|
1603
1612
|
* 少渲一格是安全方向,渲一格按不动的才是 wire 谎言。今天这条臂不可达(每个座都是解析器产物),
|
|
1604
|
-
* 它守的是版本不同步那一形 —— 与 `
|
|
1613
|
+
* 它守的是版本不同步那一形 —— 与 `isCommandRuleMatch` 的运行期 `default` 同族。
|
|
1605
1614
|
*
|
|
1606
1615
|
* 位置在**素材铸点**(与基数帽同一处):两族帧 + `card_json` + 回决口的等式左边从此拿的是**同一份**
|
|
1607
1616
|
* 已截素材,而不是两处各截一遍。
|
|
@@ -1611,7 +1620,22 @@ export declare class ToolApprovalCoordinator {
|
|
|
1611
1620
|
private static ruleOfferTextsOverSize;
|
|
1612
1621
|
/** codex r1 [high]([ref]):offer 的自称座与 `parseRuleText(rule, "allow")` 派生的三元组逐字一致?(理由见调用点) */
|
|
1613
1622
|
private static ruleOfferDerivedFactsAgree;
|
|
1623
|
+
/**
|
|
1624
|
+
* 一只 single 候选的工具与它的匹配词对得上吗(卡上的 single 只有两族):命令形(exact / prefix / wildcard / pattern)⇒ 规则是 shell 的;
|
|
1625
|
+
* 整工具(`tool`,core 7.57.0:没有规则词替它说话的工具的卡铸「这只工具不再问」)⇒ 工具必须是一键整工具同意落得下的那一族
|
|
1626
|
+
* ({@link cardTakesWholeToolConsent}:没有自己的规则文法、不在 shell 面上 —— 一张 shell 卡上的整工具候选 = 一键放行每一个程序,引擎不铸,兑付时也兑不动)。
|
|
1627
|
+
* 其余匹配词(路径 / 名字 / 主机)不是本服务卡面的 single 候选 ⇒ 丢(那些卡今天没有本服务的规则车道)。穷举 `switch`:core 给匹配词加员时这里编译红。
|
|
1628
|
+
*/
|
|
1629
|
+
private static singleOfferToolAgrees;
|
|
1614
1630
|
private static boundRuleOfferTexts;
|
|
1631
|
+
/**
|
|
1632
|
+
* 这张卡的**绑定值**(`prepareCardApproval` 的 `command`,也是耐久行的 `rule_command`)= 引擎为这张卡铸的候选所说的那一形(core 只按卡的规则形铸候选):
|
|
1633
|
+
* · 候选全是整工具候选(`match: "tool"`,core 7.57.0;至少一只)⇒ `""` —— 整只工具不绑任何值;core 恰在 `command` 是 `""` 时为这类工具铸卡;
|
|
1634
|
+
* · 其余(命令形候选,或读者把候选丢光了)⇒ 被裁决的命令原字节 `args.command`(非空串;读不出 ⇒ 没有素材)。空候选表不说「整工具」:
|
|
1635
|
+
* 它什么形都没说,绑定值回到调用自己的命令(编辑面兑的就是它)。
|
|
1636
|
+
* 两形混在一张卡上 = 不是 core 铸得出的卡 ⇒ 没有素材(整条车道撤回,与本文件其余撤回臂同形)。`req.args` 窄读,禁裸 as-cast。
|
|
1637
|
+
*/
|
|
1638
|
+
private static cardBindingOf;
|
|
1615
1639
|
private buildRuleLaneMaterial;
|
|
1616
1640
|
/** [ref]([ref]/[ref] 双属主裁定):把某 wire run 的**流内未决 ask** 立即转 durable park——断连支专用。
|
|
1617
1641
|
* 匹配键=`ctxTaskId`(wire run id)。该字段的顶注说它「不是清扫判据」——那是因为清扫要判**连接**的
|
package/dist/tool-approval.js
CHANGED
|
@@ -3,6 +3,7 @@ import { heldAskOf, liveSettledBy, readDecidedBy, retiredDecisionKeyFacts, DECID
|
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { uuidv7, classifyAsk, foldArbitrationRow, policyCannotAnswer, screenAskClassMembers, MAX_RULE_TEXT_CHARS, READ_ROOT_CANDIDATE_DIR_MAX, parseRuleText, pathConfinableWriteToolNames } from "@sema-agent/core";
|
|
5
5
|
import { precheckCardRuleText } from "./rules-consent.js";
|
|
6
|
+
import { cardTakesWholeToolConsent } from "./permission-rule-vocab.js";
|
|
6
7
|
import { redactDeep, redactSecrets, redactSecretsWithArms } from "./trace/redact.js";
|
|
7
8
|
import { seatText } from "./trace/exit-seat.js";
|
|
8
9
|
import { hasBidiControls } from "./text-bidi.js";
|
|
@@ -18,10 +19,12 @@ import { APPROVAL_ENDING_CAUSES, SETTLE_OUTCOME, causeOfAskRow } from "./approva
|
|
|
18
19
|
import { settleByPolicy } from "./approval-policy-settlement.js";
|
|
19
20
|
import { governanceAskMarksFor, runWithGovernanceAskScope } from "./governance-ask-marks.js";
|
|
20
21
|
import { governanceOriginOf } from "./runtime-governance.js";
|
|
21
|
-
import {
|
|
22
|
+
import { grantBindingOf } from "./standing-answer-grant.js";
|
|
22
23
|
import { operatorAsk } from "./operator-ask.js";
|
|
23
24
|
import { APPROVAL_EXEMPTED_EVENT } from "./plugins/approval-exemption-store.js";
|
|
24
25
|
import { refusalBody } from "./http/refusal-body.js";
|
|
26
|
+
import { withoutSettlementEvidence } from "./gate-settlement.js";
|
|
27
|
+
import { extensionRequesterOf } from "./trace/extension-call-face.js";
|
|
25
28
|
const defaultLogger = createLogger();
|
|
26
29
|
const MAX_APPROVAL_ARGS_BYTES = 16384;
|
|
27
30
|
const DEFAULT_APPROVAL_TTL_MS = 5 * 60_000;
|
|
@@ -118,7 +121,7 @@ function askStandingAnswerFacts(req, governanceForced, deploymentListAsks) {
|
|
|
118
121
|
governanceForced,
|
|
119
122
|
requiresRealApproval: req.requiresRealApproval === true,
|
|
120
123
|
mandated: req.mandated === true,
|
|
121
|
-
grantBinding:
|
|
124
|
+
grantBinding: grantBindingOf(req),
|
|
122
125
|
classes,
|
|
123
126
|
deploymentListQuestion,
|
|
124
127
|
};
|
|
@@ -135,7 +138,7 @@ export function policyAskStandingAnswerFacts(req, ask, deploymentListQuestion) {
|
|
|
135
138
|
governanceForced: false,
|
|
136
139
|
requiresRealApproval: ask.requiresRealApproval === true,
|
|
137
140
|
mandated: ask.mandated === true,
|
|
138
|
-
grantBinding:
|
|
141
|
+
grantBinding: grantBindingOf(req),
|
|
139
142
|
classes: [...classifyAsk(ask, noGateFacts({ toolCallId: req.toolCallId, toolName: req.toolName })).classes],
|
|
140
143
|
deploymentListQuestion,
|
|
141
144
|
};
|
|
@@ -172,7 +175,7 @@ export function parkRowStandingAnswerFacts(stored, gate, governance, deploymentL
|
|
|
172
175
|
governanceForced: governanceOriginOf({ riskDescriptor }, governance) === true,
|
|
173
176
|
requiresRealApproval: readParkRowTrueSeat(pending, "requiresRealApproval"),
|
|
174
177
|
mandated: readParkRowTrueSeat(pending, "mandated") || mandatedFromSeat(readRuleOffersAbsenceSeat(pending)),
|
|
175
|
-
grantBinding:
|
|
178
|
+
grantBinding: grantBindingOf(pending),
|
|
176
179
|
classes,
|
|
177
180
|
deploymentListQuestion,
|
|
178
181
|
};
|
|
@@ -750,7 +753,7 @@ export class ToolApprovalCoordinator {
|
|
|
750
753
|
};
|
|
751
754
|
if (offer.kind === "single") {
|
|
752
755
|
const d = derive(offer.rule);
|
|
753
|
-
return d !== undefined && d.rule === offer.rule && d.
|
|
756
|
+
return d !== undefined && d.rule === offer.rule && d.match === offer.match && d.command === offer.command && ToolApprovalCoordinator.singleOfferToolAgrees(d.match, d.tool);
|
|
754
757
|
}
|
|
755
758
|
return offer.rules.every((m) => {
|
|
756
759
|
const d = derive(m.rule);
|
|
@@ -766,6 +769,29 @@ export class ToolApprovalCoordinator {
|
|
|
766
769
|
}
|
|
767
770
|
});
|
|
768
771
|
}
|
|
772
|
+
static singleOfferToolAgrees(match, tool) {
|
|
773
|
+
switch (match) {
|
|
774
|
+
case "exact":
|
|
775
|
+
case "prefix":
|
|
776
|
+
case "wildcard":
|
|
777
|
+
case "pattern":
|
|
778
|
+
return tool === "Bash";
|
|
779
|
+
case "tool":
|
|
780
|
+
return cardTakesWholeToolConsent(tool);
|
|
781
|
+
case "subpath":
|
|
782
|
+
case "path":
|
|
783
|
+
case "name":
|
|
784
|
+
case "name_prefix":
|
|
785
|
+
case "host":
|
|
786
|
+
case "subdomain":
|
|
787
|
+
return false;
|
|
788
|
+
default: {
|
|
789
|
+
const unknown = match;
|
|
790
|
+
void unknown;
|
|
791
|
+
return false;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
769
795
|
static boundRuleOfferTexts(offers) {
|
|
770
796
|
const over = (s) => s.length > MAX_RULE_TEXT_CHARS;
|
|
771
797
|
const clipSegment = (s) => (over(s) ? s.slice(0, MAX_RULE_TEXT_CHARS) : s);
|
|
@@ -812,6 +838,17 @@ export class ToolApprovalCoordinator {
|
|
|
812
838
|
}
|
|
813
839
|
return out;
|
|
814
840
|
}
|
|
841
|
+
static cardBindingOf(args, offers) {
|
|
842
|
+
const isWholeTool = (o) => o.kind === "single" && o.match === "tool";
|
|
843
|
+
if (offers.length > 0 && offers.every(isWholeTool))
|
|
844
|
+
return "";
|
|
845
|
+
if (offers.some(isWholeTool))
|
|
846
|
+
return undefined;
|
|
847
|
+
if (args === null || typeof args !== "object" || Array.isArray(args))
|
|
848
|
+
return undefined;
|
|
849
|
+
const command = args.command;
|
|
850
|
+
return typeof command === "string" && command !== "" ? command : undefined;
|
|
851
|
+
}
|
|
815
852
|
buildRuleLaneMaterial(req, owner, governanceForced, sessionId) {
|
|
816
853
|
if (this.ruleConsent === undefined)
|
|
817
854
|
return undefined;
|
|
@@ -826,11 +863,8 @@ export class ToolApprovalCoordinator {
|
|
|
826
863
|
const offers = ToolApprovalCoordinator.boundRuleOfferTexts(capped);
|
|
827
864
|
if (offers === undefined)
|
|
828
865
|
return undefined;
|
|
829
|
-
const
|
|
830
|
-
if (
|
|
831
|
-
return undefined;
|
|
832
|
-
const command = args.command;
|
|
833
|
-
if (typeof command !== "string" || command === "")
|
|
866
|
+
const command = ToolApprovalCoordinator.cardBindingOf(req.args, offers);
|
|
867
|
+
if (command === undefined)
|
|
834
868
|
return undefined;
|
|
835
869
|
const boundInputHash = readBoundInputHash(req);
|
|
836
870
|
const scopeRoot = this.ruleScopeRootFor?.(sessionId);
|
|
@@ -1295,6 +1329,7 @@ export class ToolApprovalCoordinator {
|
|
|
1295
1329
|
const cardWord = readApprovalCard(req.approvalCard);
|
|
1296
1330
|
const originWord = typeof req.origin === "string" && req.origin.length > 0 ? req.origin : undefined;
|
|
1297
1331
|
const askClassPair = readAskClassPair(req);
|
|
1332
|
+
const requester = extensionRequesterOf(req.requestedBy, "tool_approval");
|
|
1298
1333
|
const frame = {
|
|
1299
1334
|
type: "tool_approval",
|
|
1300
1335
|
approvalId: id,
|
|
@@ -1328,6 +1363,7 @@ export class ToolApprovalCoordinator {
|
|
|
1328
1363
|
...(mandateWord !== undefined ? { mandate: mandateWord } : {}),
|
|
1329
1364
|
...(originWord !== undefined ? { origin: originWord } : {}),
|
|
1330
1365
|
...(askClassPair ?? {}),
|
|
1366
|
+
...(requester !== undefined ? { requestedBy: requester } : {}),
|
|
1331
1367
|
...((d) => (d !== undefined ? { allowRuleShadowed: d } : {}))(readAllowRuleShadowed(req)),
|
|
1332
1368
|
...(ruleLaneMaterial !== undefined ? { ruleOffers: ruleLaneMaterial.offers } : {}),
|
|
1333
1369
|
...((a) => (a !== undefined ? { ruleOffersAbsence: a } : {}))(readRuleOffersAbsence(req)),
|
|
@@ -1861,7 +1897,7 @@ export class ToolApprovalCoordinator {
|
|
|
1861
1897
|
}
|
|
1862
1898
|
const entryClasses = askClassPair?.classes;
|
|
1863
1899
|
const entryDeploymentListQuestion = carriesDeploymentListQuestion(deploymentListAsks, entryClasses);
|
|
1864
|
-
const entryGrantBinding =
|
|
1900
|
+
const entryGrantBinding = grantBindingOf(req);
|
|
1865
1901
|
const rememberRefused = standingAnswerHome(pendingEntryStandingAnswerFacts({
|
|
1866
1902
|
...(effectiveGovernanceForced ? { governanceForced: true } : {}),
|
|
1867
1903
|
...(req.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
|
|
@@ -2586,10 +2622,11 @@ export class ToolApprovalCoordinator {
|
|
|
2586
2622
|
if (fresh?.terminal === true && memo.redeemed !== undefined)
|
|
2587
2623
|
memo.redeemed.rule = fresh.body;
|
|
2588
2624
|
}
|
|
2625
|
+
const sameDecision = (parsed.value === "deny") === (receipt.decision === "deny");
|
|
2589
2626
|
return {
|
|
2590
2627
|
status: 200,
|
|
2591
2628
|
body: {
|
|
2592
|
-
...receipt.body,
|
|
2629
|
+
...(sameDecision ? receipt.body : withoutSettlementEvidence(receipt.body)),
|
|
2593
2630
|
approvalId: id,
|
|
2594
2631
|
askId: row.askId,
|
|
2595
2632
|
accepted: "parked_redeemed",
|
|
@@ -44,8 +44,8 @@ type _GuardBgNotifReverse = AssertAllKeysHandled<Exclude<BgNotifProjected | BgNo
|
|
|
44
44
|
type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner" | "scope" | "sessionScoped" | "rootSessionId" | "model" | "modelFallback" | "createdAt";
|
|
45
45
|
type _GuardRoster = AssertAllKeysHandled<Exclude<keyof RosterEntry, RosterProjected>>;
|
|
46
46
|
type _GuardRosterReverse = AssertAllKeysHandled<Exclude<RosterProjected, keyof RosterEntry>>;
|
|
47
|
-
type AskProjected = "toolName" | "toolCallId" | "args" | "message" | "sourceTaskId" | "fromSubagent" | "sourceAgentName" | "delegation" | "ruleOffers" | "ruleOffersAbsence" | "allowRuleShadowed" | "probeCause" | "probeReason" | "ruleEvidence" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "readRootCandidate" | "mandated" | "mandate" | "askClass" | "classes" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "approvalCard" | "boundGrantAbsence";
|
|
48
|
-
type AskExcluded = "preview" | "principal" | "riskAxes" | "boundInputHash" | "isDelegatedChild" | "hasBidiControls" | "previewWithheld" | "execCwd" | "authoredBy" | "
|
|
47
|
+
type AskProjected = "toolName" | "toolCallId" | "args" | "message" | "sourceTaskId" | "fromSubagent" | "sourceAgentName" | "delegation" | "ruleOffers" | "ruleOffersAbsence" | "allowRuleShadowed" | "probeCause" | "probeReason" | "ruleEvidence" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "readRootCandidate" | "mandated" | "mandate" | "askClass" | "classes" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "approvalCard" | "boundGrantAbsence" | "requestedBy";
|
|
48
|
+
type AskExcluded = "preview" | "principal" | "riskAxes" | "boundInputHash" | "isDelegatedChild" | "hasBidiControls" | "previewWithheld" | "execCwd" | "authoredBy" | "editRewritten";
|
|
49
49
|
type _GuardAsk = AssertAllKeysHandled<Exclude<keyof AskRequest, AskProjected | AskExcluded>>;
|
|
50
50
|
type _GuardAskReverse = AssertAllKeysHandled<Exclude<AskProjected | AskExcluded, keyof AskRequest>>;
|
|
51
51
|
type AskFrameServerMinted = "type" | "approvalId" | "argsOmitted" | "outcome" | "governanceForced" | "expiresAtMs" | "expiresInMs" | "serverNowMs" | "parked" | "cause" | "inputHasBidi" | "rememberRefused";
|
|
@@ -54,10 +54,10 @@ type _GuardAskFrameReverse = AssertAllKeysHandled<Exclude<AskProjected | AskFram
|
|
|
54
54
|
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" | "compaction_started";
|
|
55
55
|
type _GuardTaskEvent = AssertAllKeysHandled<Exclude<TaskEvent["type"], TaskEventHandled>>;
|
|
56
56
|
type _GuardTaskEventReverse = AssertAllKeysHandled<Exclude<TaskEventHandled, TaskEvent["type"]>>;
|
|
57
|
-
type MailboxProjected = "seq" | "from" | "content" | "sentAt" | "hopChain" | "peerMeta";
|
|
57
|
+
type MailboxProjected = "seq" | "from" | "content" | "sentAt" | "hopChain" | "peerMeta" | "decision" | "id";
|
|
58
58
|
type _GuardMailbox = AssertAllKeysHandled<Exclude<keyof MailboxMessage, MailboxProjected>>;
|
|
59
59
|
type _GuardMailboxReverse = AssertAllKeysHandled<Exclude<MailboxProjected, keyof MailboxMessage>>;
|
|
60
|
-
type MailboxAppendProjected = "from" | "content" | "sentAt" | "hopChain" | "peerMeta";
|
|
60
|
+
type MailboxAppendProjected = "from" | "content" | "sentAt" | "hopChain" | "peerMeta" | "id";
|
|
61
61
|
type _GuardMailboxAppend = AssertAllKeysHandled<Exclude<keyof MailboxAppendMessage, MailboxAppendProjected>>;
|
|
62
62
|
type _GuardMailboxAppendReverse = AssertAllKeysHandled<Exclude<MailboxAppendProjected, keyof MailboxAppendMessage>>;
|
|
63
63
|
type WiringSectionProjected = "schemaVersion" | "leg" | "ask" | "question" | "interaction" | "elicit" | "parkLane" | "session" | "fleet" | "permissionRules" | "modelGate" | "autoMode" | "mcp" | "tools" | "mods" | "lsp" | "hands" | "writeProtection" | "teamRole" | "fileHistory" | "permissionMode" | "sessionRules" | "projectMemory";
|
|
@@ -66,10 +66,11 @@ type _GuardWiringSections = AssertAllKeysHandled<Exclude<keyof WiringManifest, W
|
|
|
66
66
|
type _GuardWiringSectionsReverse = AssertAllKeysHandled<Exclude<WiringSectionProjected | WiringSectionExcluded, keyof WiringManifest>>;
|
|
67
67
|
type WiringSection<K extends keyof WiringManifest> = NonNullable<WiringManifest[K]>;
|
|
68
68
|
type WiringLegHandled = "kind";
|
|
69
|
-
type
|
|
70
|
-
type
|
|
69
|
+
type WiringLegExcluded = "runOrigin";
|
|
70
|
+
type _GuardWiringLeg = AssertAllKeysHandled<Exclude<keyof WiringSection<"leg">, WiringLegHandled | WiringLegExcluded>>;
|
|
71
|
+
type _GuardWiringLegReverse = AssertAllKeysHandled<Exclude<WiringLegHandled | WiringLegExcluded, keyof WiringSection<"leg">>>;
|
|
71
72
|
type WiringModRowKeys = WiringSection<"mods">[number] extends infer R ? (R extends unknown ? keyof R : never) : never;
|
|
72
|
-
type WiringModRowHandled = "name" | "seat" | "tier" | "events" | "observe" | "skipped" | "refusedBy" | "reason";
|
|
73
|
+
type WiringModRowHandled = "name" | "seat" | "tier" | "provenance" | "events" | "observe" | "skipped" | "refusedBy" | "reason";
|
|
73
74
|
type _GuardWiringModRow = AssertAllKeysHandled<Exclude<WiringModRowKeys, WiringModRowHandled>>;
|
|
74
75
|
type _GuardWiringModRowReverse = AssertAllKeysHandled<Exclude<WiringModRowHandled, WiringModRowKeys>>;
|
|
75
76
|
type WiringModSkipKeys = keyof NonNullable<Extract<WiringSection<"mods">[number], {
|
|
@@ -108,7 +109,11 @@ type _GuardSubagentTranscriptTierWords = AssertAllKeysHandled<Exclude<SubagentTr
|
|
|
108
109
|
type _GuardSubagentTranscriptTierWordsReverse = AssertAllKeysHandled<Exclude<SubagentTranscriptTierWords, SubagentTranscriptTier>>;
|
|
109
110
|
type WiringMcpEntry = WiringSection<"mcp">[number];
|
|
110
111
|
type WiringMcpExcluded = "error";
|
|
111
|
-
type WiringMcpHandled = "name" | "source" | "status" | "errorCode" | "delivered" | "httpStatus" | "toolCount" | "liveness" | WiringMcpExcluded;
|
|
112
|
+
type WiringMcpHandled = "name" | "source" | "status" | "errorCode" | "delivered" | "httpStatus" | "toolCount" | "liveness" | "authorization" | WiringMcpExcluded;
|
|
113
|
+
type McpAuthorizationRecord = NonNullable<WiringMcpEntry["authorization"]>;
|
|
114
|
+
type McpAuthorizationTables = typeof import("../mcp-authorization-face.js");
|
|
115
|
+
type _GuardMcpAuthorization = AssertAllKeysHandled<Exclude<keyof McpAuthorizationRecord, TableCoreKeys<McpAuthorizationTables["MCP_AUTHORIZATION_DISPOSITIONS"]>>>;
|
|
116
|
+
type _GuardMcpAuthorizationReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<McpAuthorizationTables["MCP_AUTHORIZATION_DISPOSITIONS"]>, keyof McpAuthorizationRecord>>;
|
|
112
117
|
type _GuardWiringMcp = AssertAllKeysHandled<Exclude<keyof WiringMcpEntry, WiringMcpHandled>>;
|
|
113
118
|
type _GuardWiringMcpReverse = AssertAllKeysHandled<Exclude<WiringMcpHandled, keyof WiringMcpEntry>>;
|
|
114
119
|
type WiringMcpLiveness = NonNullable<WiringMcpEntry["liveness"]>;
|
|
@@ -212,27 +217,27 @@ type _GuardPromptManifestKeysNonEmpty = AssertAllKeysHandled<{
|
|
|
212
217
|
[L in keyof ManifestCore]: [ManifestDeclared<ManifestFaces, L>] extends [never] ? L : never;
|
|
213
218
|
}[keyof ManifestCore]>;
|
|
214
219
|
type SummaryProjected = "sessionId" | "scope" | "createdAt" | "gateKind" | "severity" | "spentMicroUsd" | "deadline" | "hasBidiControls" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "mandated" | "mandate" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "boundGrantAbsence" | "checkpointId";
|
|
215
|
-
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "sourceTaskId" | "approvalCard" | "restoreMode" | "previewWithheld" | "authoredBy";
|
|
220
|
+
type SummaryExcluded = "token" | "toolInput" | "toolName" | "toolCallId" | "preview" | "principal" | "sourceTaskId" | "approvalCard" | "restoreMode" | "previewWithheld" | "authoredBy" | "runOrigin" | "requestedByCallId";
|
|
216
221
|
type _GuardInboxSummary = AssertAllKeysHandled<Exclude<keyof CheckpointSummary, SummaryProjected | SummaryExcluded>>;
|
|
217
222
|
type _GuardInboxSummaryReverse = AssertAllKeysHandled<Exclude<SummaryProjected | SummaryExcluded, keyof CheckpointSummary>>;
|
|
218
223
|
type ParkArmKeys = keyof Extract<PendingAction, {
|
|
219
224
|
kind: "tool_approval";
|
|
220
225
|
}>;
|
|
221
226
|
type ParkArmQueueProjected = "toolName" | "toolCallId" | "boundInputHash" | "ruleOffers" | "hasBidiControls" | keyof import("../approval-card.js").ParkRowFacts | keyof import("../approval-card.js").SkillCardFacts;
|
|
222
|
-
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "hostTarget" | "targets" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "engineMounted";
|
|
227
|
+
type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "hostTarget" | "targets" | "targetReads" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "engineMounted" | "declarationDigest";
|
|
223
228
|
type _GuardParkArmQueue = AssertAllKeysHandled<Exclude<ParkArmKeys, ParkArmQueueProjected | ParkArmQueueExcluded>>;
|
|
224
229
|
type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjected | ParkArmQueueExcluded, ParkArmKeys>>;
|
|
225
230
|
type _NoDoubleBookParkArmQueue = AssertAllKeysHandled<Extract<ParkArmQueueProjected, ParkArmQueueExcluded>>;
|
|
226
|
-
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptLean" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "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" | "projectMemory" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies";
|
|
231
|
+
type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptLean" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "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" | "projectMemory" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies" | "projectId";
|
|
227
232
|
/** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
|
|
228
|
-
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel";
|
|
233
|
+
export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel" | "runOrigin" | "planFile" | "classifyAllShell";
|
|
229
234
|
type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
|
|
230
235
|
type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
|
|
231
236
|
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" | "resultEntryIds";
|
|
232
237
|
type TaskResultStripped = never;
|
|
233
238
|
type _GuardTaskResult = AssertAllKeysHandled<Exclude<keyof TaskResult, TaskResultForwarded | TaskResultStripped>>;
|
|
234
239
|
type _GuardTaskResultReverse = AssertAllKeysHandled<Exclude<TaskResultForwarded | TaskResultStripped, keyof TaskResult>>;
|
|
235
|
-
type PausedCauseForwarded = "kind" | "gate" | "checkpointId" | "restoreMode";
|
|
240
|
+
type PausedCauseForwarded = "kind" | "gate" | "checkpointId" | "restoreMode" | "requestedByCallId";
|
|
236
241
|
type PausedCauseStripped = "token";
|
|
237
242
|
type _GuardPausedCause = AssertAllKeysHandled<Exclude<keyof PausedCause, PausedCauseForwarded | PausedCauseStripped>>;
|
|
238
243
|
type _GuardPausedCauseReverse = AssertAllKeysHandled<Exclude<PausedCauseForwarded | PausedCauseStripped, keyof PausedCause>>;
|
|
@@ -247,7 +252,7 @@ type SessionMemoryStatusProjected = "captureOptedOut" | "committedCount" | "fold
|
|
|
247
252
|
type SessionMemoryStatusExcluded = "writeHome";
|
|
248
253
|
type _GuardSessionMemoryStatus = AssertAllKeysHandled<Exclude<keyof SessionMemoryStatus, SessionMemoryStatusProjected | SessionMemoryStatusExcluded>>;
|
|
249
254
|
type _GuardSessionMemoryStatusReverse = AssertAllKeysHandled<Exclude<SessionMemoryStatusProjected | SessionMemoryStatusExcluded, keyof SessionMemoryStatus>>;
|
|
250
|
-
type SideQueryResultForwarded = "text" | "toolCalls" | "model" | "servedModel" | "degraded" | "responseModel" | "usage" | "usageMissing" | "stopReason" | "errorMessage" | "errorCode" | "errorKind" | "inputTooLongRuledOut";
|
|
255
|
+
type SideQueryResultForwarded = "text" | "toolCalls" | "model" | "servedModel" | "degraded" | "responseModel" | "usage" | "usageMissing" | "stopReason" | "errorMessage" | "errorCode" | "errorKind" | "inputTooLongRuledOut" | "account";
|
|
251
256
|
type SideQueryResultStripped = never;
|
|
252
257
|
type _GuardSideQueryResult = AssertAllKeysHandled<Exclude<keyof SideQueryResult, SideQueryResultForwarded | SideQueryResultStripped>>;
|
|
253
258
|
type _GuardSideQueryResultReverse = AssertAllKeysHandled<Exclude<SideQueryResultForwarded | SideQueryResultStripped, keyof SideQueryResult>>;
|
|
@@ -261,7 +266,7 @@ type GateOutcomeProjected = "disposition" | "settlement" | "origin";
|
|
|
261
266
|
type _GuardGateOutcome = AssertAllKeysHandled<Exclude<keyof GateOutcome, GateOutcomeProjected>>;
|
|
262
267
|
type _GuardGateOutcomeReverse = AssertAllKeysHandled<Exclude<GateOutcomeProjected, keyof GateOutcome>>;
|
|
263
268
|
type GateDispositionKeys = GateDisposition extends infer D ? (D extends object ? keyof D : never) : never;
|
|
264
|
-
type GateDispositionProjected = "kind" | "deniedBy" | "cause" | "classifier" | "released" | "clearedBy" | "mode" | "askClass" | "classes";
|
|
269
|
+
type GateDispositionProjected = "kind" | "deniedBy" | "cause" | "classifier" | "released" | "clearedBy" | "mode" | "askClass" | "classes" | "extension";
|
|
265
270
|
type _GuardGateDisposition = AssertAllKeysHandled<Exclude<GateDispositionKeys, GateDispositionProjected>>;
|
|
266
271
|
type _GuardGateDispositionReverse = AssertAllKeysHandled<Exclude<GateDispositionProjected, GateDispositionKeys>>;
|
|
267
272
|
type SettlementProjected = "kind" | "who" | "when" | "note";
|
|
@@ -301,12 +306,12 @@ type McpReconnectWithheld = "axes" | "dropped" | "warnings";
|
|
|
301
306
|
type _GuardMcpReconnect = AssertAllKeysHandled<Exclude<keyof McpReconnectResult, McpReconnectProjected | McpReconnectWithheld>>;
|
|
302
307
|
type _NoDoubleBookMcpReconnect = AssertAllKeysHandled<Extract<McpReconnectProjected, McpReconnectWithheld>>;
|
|
303
308
|
type _GuardMcpReconnectReverse = AssertAllKeysHandled<Exclude<McpReconnectProjected | McpReconnectWithheld, keyof McpReconnectResult>>;
|
|
304
|
-
type McpRedialStatusProjected = "name" | "status" | "errorCode" | "httpStatus" | "delivered" | "serverInfo" | "error" | "transportClosed";
|
|
309
|
+
type McpRedialStatusProjected = "name" | "status" | "errorCode" | "httpStatus" | "delivered" | "authorization" | "serverInfo" | "error" | "transportClosed";
|
|
305
310
|
type McpRedialStatusWithheld = "toolNames" | "liveness";
|
|
306
311
|
type _GuardMcpRedialStatus = AssertAllKeysHandled<Exclude<keyof McpServerStatus, McpRedialStatusProjected | McpRedialStatusWithheld>>;
|
|
307
312
|
type _NoDoubleBookMcpRedialStatus = AssertAllKeysHandled<Extract<McpRedialStatusProjected, McpRedialStatusWithheld>>;
|
|
308
313
|
type _GuardMcpRedialStatusReverse = AssertAllKeysHandled<Exclude<McpRedialStatusProjected | McpRedialStatusWithheld, keyof McpServerStatus>>;
|
|
309
|
-
type McpPanelStatusProjected = "name" | "status" | "serverInfo" | "toolNames" | "error";
|
|
314
|
+
type McpPanelStatusProjected = "name" | "status" | "serverInfo" | "toolNames" | "error" | "authorization";
|
|
310
315
|
type McpPanelStatusWithheld = "errorCode" | "httpStatus" | "delivered" | "transportClosed" | "liveness";
|
|
311
316
|
type _GuardMcpPanelStatus = AssertAllKeysHandled<Exclude<keyof McpServerStatus, McpPanelStatusProjected | McpPanelStatusWithheld>>;
|
|
312
317
|
type _NoDoubleBookMcpPanelStatus = AssertAllKeysHandled<Extract<McpPanelStatusProjected, McpPanelStatusWithheld>>;
|
|
@@ -323,6 +328,12 @@ type _NoDoubleBookLspOptions = AssertAllKeysHandled<Extract<LspOptionsWired, Lsp
|
|
|
323
328
|
/** ⑯ 账上记过、已接线的 `RunnerDeps` 席([ref] 起 `fileHistoryCapture`)。反向钉:core 改名 / 退役 ⇒ 红。 */
|
|
324
329
|
type RunnerDepsLedgerWired = "fileHistoryCapture";
|
|
325
330
|
type _GuardLedgerRunnerDepsReverse = AssertAllKeysHandled<Exclude<RunnerDepsLedgerWired, keyof RunnerDeps>>;
|
|
331
|
+
type SessionWorkspaceTables = typeof import("../session-workspace.js");
|
|
332
|
+
type WorkspaceChangedArm = Extract<TaskEvent, {
|
|
333
|
+
type: "workspace_changed";
|
|
334
|
+
}>;
|
|
335
|
+
type _GuardSessionWorkspace = AssertAllKeysHandled<Exclude<keyof WorkspaceChangedArm, TableCoreKeys<SessionWorkspaceTables["SESSION_WORKSPACE_DISPOSITIONS"]>>>;
|
|
336
|
+
type _GuardSessionWorkspaceReverse = AssertAllKeysHandled<Exclude<TableCoreKeys<SessionWorkspaceTables["SESSION_WORKSPACE_DISPOSITIONS"]>, keyof WorkspaceChangedArm>>;
|
|
326
337
|
export type CoreKeysetGuards = [
|
|
327
338
|
_GuardNotification,
|
|
328
339
|
_GuardTerminalArm,
|
|
@@ -384,6 +395,8 @@ export type CoreKeysetGuards = [
|
|
|
384
395
|
_GuardWiringModSkipReverse,
|
|
385
396
|
_GuardWiringMcp,
|
|
386
397
|
_GuardWiringMcpReverse,
|
|
398
|
+
_GuardMcpAuthorization,
|
|
399
|
+
_GuardMcpAuthorizationReverse,
|
|
387
400
|
_GuardWiringRules,
|
|
388
401
|
_GuardWiringRulesReverse,
|
|
389
402
|
_GuardWiringModelGate,
|
|
@@ -463,7 +476,9 @@ export type CoreKeysetGuards = [
|
|
|
463
476
|
_GuardLspOptions,
|
|
464
477
|
_NoDoubleBookLspOptions,
|
|
465
478
|
_GuardLspOptionsReverse,
|
|
466
|
-
_GuardLedgerRunnerDepsReverse
|
|
479
|
+
_GuardLedgerRunnerDepsReverse,
|
|
480
|
+
_GuardSessionWorkspace,
|
|
481
|
+
_GuardSessionWorkspaceReverse
|
|
467
482
|
];
|
|
468
483
|
export {};
|
|
469
484
|
//# sourceMappingURL=core-keyset-guard.d.ts.map
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* 同文件 G1 e2e 的全码扇出夹具、以及契约文档附录 D.3 那张表(含**小节标题里的码数** —— 那道门本批
|
|
17
17
|
* 刚立,立完就在下一次加码时自己咬住了)。
|
|
18
18
|
*/
|
|
19
|
-
export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached", "inherit_env.names_withheld", "model.capability_downgraded"];
|
|
19
|
+
export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached", "inherit_env.names_withheld", "model.capability_downgraded", "context.image_removed", "mcp.authorization_required"];
|
|
20
20
|
export type EngineNoticeWireCode = (typeof ENGINE_NOTICE_WIRE_CODES)[number];
|
|
21
21
|
/** 白名单谓词(单点):路由与门都读这一个,不许第二处手抄码串。 */
|
|
22
22
|
export declare function isEngineNoticeWireCode(code: string): code is EngineNoticeWireCode;
|
|
@@ -46,6 +46,8 @@ export const ENGINE_NOTICE_WIRE_CODES = [
|
|
|
46
46
|
"advisor.not_attached",
|
|
47
47
|
"inherit_env.names_withheld",
|
|
48
48
|
"model.capability_downgraded",
|
|
49
|
+
"context.image_removed",
|
|
50
|
+
"mcp.authorization_required",
|
|
49
51
|
];
|
|
50
52
|
const WIRE_CODES = new Set(ENGINE_NOTICE_WIRE_CODES);
|
|
51
53
|
export function isEngineNoticeWireCode(code) {
|
|
@@ -13,7 +13,14 @@ export type SafeText = string & {
|
|
|
13
13
|
* · `operator-log-arg`:运维日志字段里模型写的工具入参(`tool_trace` 的 `arg.*`:路径 / 命令 / 模式 / 非对象入参的串形);界 120 码元(含截断记号);
|
|
14
14
|
* · `operator-log-error`:运维日志字段里 hook 一侧的报错 —— hook 命令的 stderr、prompt 条目的载体失败句、起子进程 / 读会话分支抛出的句子;界 300 码元(含截断记号);
|
|
15
15
|
* · `operator-log-message`:运维日志字段里写给人看的一段话 —— hook 输出的 `systemMessage`、Stop 评估者判「做不到」的理由;界 500 码元(含截断记号);
|
|
16
|
-
* · `session-title`:自动标题器落行的会话标题(落库 / 列表面 / `session_titled` 帧同一份);界 80 码元(含截断记号),在 `title`
|
|
16
|
+
* · `session-title`:自动标题器落行的会话标题(落库 / 列表面 / `session_titled` 帧同一份);界 80 码元(含截断记号),在 `title` 列宽之内;
|
|
17
|
+
* · `mcp-remote-text`:MCP 远端失败句(远端可控自由文本,租户面)—— `GET /v1/sessions/:id/mcp` 面板的 `servers[].error` 与 `POST /v1/sessions/:id/mcp/reconnect`
|
|
18
|
+
* 的 `reason` / `status.error` / `listingIncomplete.error`;引擎铸点已抹过请求回显与同主体词表(记号 `[redacted]`),这一行读同一个脱敏器(引擎记号 = 已抹的值,
|
|
19
|
+
* 引擎放过的形照抹);界 200 码元,原样出门(JSON 串值,消费方自己渲染)。
|
|
20
|
+
* · `peer-declaration-sentence`:引擎判官对一份 MCP / A2A 对端声明说的句子(`toolAxes` / `toolFaces` / `sessionMetaKey` / 启动界的原因句,逐字带着声明方写的工具名、键名),
|
|
21
|
+
* 进请求面 400 拒句、续跑重放的丢弃行与重读行、名册的跳过行 —— 读者是调用方与运维,句子已是一行;不设界(拒句要说全判官的话),原样出门。
|
|
22
|
+
* · `boot-refusal-line`:起服拒启的一行拒句 —— 部署座装配的拒句(`mods-declaration.ts`:声明的席名、包名、读包者 / 引擎准入交回的话);它经进程级 fatal 出口原样多行进 stderr,
|
|
23
|
+
* 所以必须在这里先压成一行(一句拒因里的换行会在运维的终端里伪造出第二条日志行);界 512 码元(含截断记号)。
|
|
17
24
|
*/
|
|
18
25
|
declare const EXIT_SEATS: {
|
|
19
26
|
readonly "trace-frame-text": {
|
|
@@ -48,6 +55,18 @@ declare const EXIT_SEATS: {
|
|
|
48
55
|
readonly maxChars: 80;
|
|
49
56
|
readonly emit: "title-line";
|
|
50
57
|
};
|
|
58
|
+
readonly "mcp-remote-text": {
|
|
59
|
+
readonly scope: "free-text";
|
|
60
|
+
readonly maxChars: 200;
|
|
61
|
+
};
|
|
62
|
+
readonly "peer-declaration-sentence": {
|
|
63
|
+
readonly scope: "free-text";
|
|
64
|
+
};
|
|
65
|
+
readonly "boot-refusal-line": {
|
|
66
|
+
readonly scope: "free-text";
|
|
67
|
+
readonly maxChars: 512;
|
|
68
|
+
readonly emit: "log-line";
|
|
69
|
+
};
|
|
51
70
|
};
|
|
52
71
|
export type ExitSeat = keyof typeof EXIT_SEATS;
|
|
53
72
|
/** 设了界的座名。 */
|
package/dist/trace/exit-seat.js
CHANGED
|
@@ -12,6 +12,9 @@ const EXIT_SEATS = {
|
|
|
12
12
|
"operator-log-error": { scope: "free-text", maxChars: 300, emit: "log-line" },
|
|
13
13
|
"operator-log-message": { scope: "free-text", maxChars: 500, emit: "log-line" },
|
|
14
14
|
"session-title": { scope: "free-text", maxChars: 80, emit: "title-line" },
|
|
15
|
+
"mcp-remote-text": { scope: "free-text", maxChars: 200 },
|
|
16
|
+
"peer-declaration-sentence": { scope: "free-text" },
|
|
17
|
+
"boot-refusal-line": { scope: "free-text", maxChars: 512, emit: "log-line" },
|
|
15
18
|
};
|
|
16
19
|
export function seatMaxChars(seat) {
|
|
17
20
|
return EXIT_SEATS[seat].maxChars;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 扩展自己发起 / 代答 / 改写的工具调用在 wire 上的三位 —— `requestedBy`(谁要的这只调用)、`answeredBy`(哪张注册在 `tool.call` 上代替工具体作答)与
|
|
3
|
+
* `tool_end.rewrite`(门放行时交给工具体的参数不是它收进来的那份:放行的那份 + 谁改的)的**唯一读法**。
|
|
4
|
+
*
|
|
5
|
+
* 引擎的事实(core `ExtensionRequester` / `tool_end.answeredBy`):一张注册经 `$.tool.call` 发起的调用,`tool_start` / `tool_end` 与审批卡都带
|
|
6
|
+
* `requestedBy: { kind: "extension", name }`(模型消息带来的调用上缺席);注册在 `tool.call` 站上以自己的结果或拒答代替工具体时,`tool_end` 带
|
|
7
|
+
* `answeredBy: <注册名>`(旁边恒有 `notExecuted: true`)。本仓的部署座装上运维声明的包之后,这两位真能到达 —— 投影它们。
|
|
8
|
+
*
|
|
9
|
+
* 读法(写腿与读腿、帧与卡同一只):
|
|
10
|
+
* · 注册名是**注册方定的串** ⇒ 过 {@link sanitizeWireText}(与 `wiring_manifest.mods[]` 的 `name`、通告 `mods.registration_refused` 同一只出口纪律),
|
|
11
|
+
* 同一张注册在三处的名逐字节相等;
|
|
12
|
+
* · 形不对(`kind` 不是 `"extension"`、`name` 不是非空串、`answeredBy` 不是非空串)⇒ 丢这一位、计一次 `server.trace.projection-input-malformed`
|
|
13
|
+
* (纯归因位:半张归因比没有更坏,不修补);缺席 = 没有这件事(正面事实),不计;
|
|
14
|
+
* · `rewrite`(引擎 7.58.0 `ToolInputRewrite`)整只一位:`by` 每项是改写者(扩展项的注册名同上过出口纪律;`policy` / `approver` 两项无成员),`input` 是工具参数
|
|
15
|
+
* (模型 / 扩展 / 审批人写的)⇒ 经调用方交进来的工具参数投影 —— 与 `tool_start.args` 同一只(`trace/project.ts` 的那一只;本文件不自己答脱敏);
|
|
16
|
+
* `by` 不是非空数组、有一项不在三形里、缺 `input` ⇒ 整只丢 + 计一次。
|
|
17
|
+
* 续跑腿的帧引擎不带它(引擎的未覆盖面),本读法不补。
|
|
18
|
+
*/
|
|
19
|
+
import type { ExtensionRequester, RewriteAuthor } from "@sema-agent/core";
|
|
20
|
+
/** wire 上的发起者位 = 引擎的 `ExtensionRequester` 同形(`name` 已过出口纪律);引擎加一类发起者 ⇒ 这里的形随之,读法下面一处判。 */
|
|
21
|
+
export type ExtensionRequesterFace = Readonly<ExtensionRequester>;
|
|
22
|
+
/** `requestedBy` 的投影(缺席 ⇒ 缺席;形不对 ⇒ 丢 + 计一次)。`where` 进留痕句(哪一面:`tool_start` / `tool_end` / `tool_approval` / 读腿)。 */
|
|
23
|
+
export declare function extensionRequesterOf(v: unknown, where: string): ExtensionRequesterFace | undefined;
|
|
24
|
+
/** `answeredBy` 的投影(缺席 ⇒ 缺席;形不对 ⇒ 丢 + 计一次)。 */
|
|
25
|
+
export declare function extensionAnswererOf(v: unknown, where: string): string | undefined;
|
|
26
|
+
/** wire 上的改写记录 = 引擎的 `ToolInputRewrite` 同形(扩展项的 `name` 已过出口纪律、`input` 已脱敏)。 */
|
|
27
|
+
export interface ToolInputRewriteFace {
|
|
28
|
+
readonly by: readonly Readonly<RewriteAuthor>[];
|
|
29
|
+
readonly input: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** `tool_end.rewrite` 的投影(缺席 ⇒ 缺席;形不对 ⇒ 整只丢 + 计一次)。`argsOnWire` = 工具参数上 wire 的那一只投影(与 `tool_start.args` 同一只,调用方交进来)。 */
|
|
32
|
+
export declare function toolInputRewriteOf(v: unknown, where: string, argsOnWire: (args: unknown) => unknown): ToolInputRewriteFace | undefined;
|
|
33
|
+
//# sourceMappingURL=extension-call-face.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { sanitizeWireText } from "./engine-notice-wire.js";
|
|
2
|
+
import { dropProjectedFace } from "./projection-drop.js";
|
|
3
|
+
export function extensionRequesterOf(v, where) {
|
|
4
|
+
if (v === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
if (typeof v === "object" && v !== null && "kind" in v && "name" in v && v.kind === "extension" && typeof v.name === "string" && v.name !== "")
|
|
7
|
+
return { kind: "extension", name: sanitizeWireText(v.name) };
|
|
8
|
+
return dropProjectedFace("extension_call.requestedBy is not { kind: extension, name: <non-empty string> } on " + where);
|
|
9
|
+
}
|
|
10
|
+
export function extensionAnswererOf(v, where) {
|
|
11
|
+
if (v === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
if (typeof v === "string" && v !== "")
|
|
14
|
+
return sanitizeWireText(v);
|
|
15
|
+
return dropProjectedFace("extension_call.answeredBy is not a non-empty string on " + where);
|
|
16
|
+
}
|
|
17
|
+
const REWRITE_AUTHOR_READERS = {
|
|
18
|
+
extension: (v) => ("name" in v && typeof v.name === "string" && v.name !== "" ? { kind: "extension", name: sanitizeWireText(v.name) } : undefined),
|
|
19
|
+
policy: () => ({ kind: "policy" }),
|
|
20
|
+
approver: () => ({ kind: "approver" }),
|
|
21
|
+
};
|
|
22
|
+
const isRewriteAuthorKind = (kind) => typeof kind === "string" && Object.hasOwn(REWRITE_AUTHOR_READERS, kind);
|
|
23
|
+
function rewriteAuthorOf(v) {
|
|
24
|
+
if (typeof v !== "object" || v === null || !("kind" in v))
|
|
25
|
+
return undefined;
|
|
26
|
+
const kind = v.kind;
|
|
27
|
+
return isRewriteAuthorKind(kind) ? REWRITE_AUTHOR_READERS[kind](v) : undefined;
|
|
28
|
+
}
|
|
29
|
+
export function toolInputRewriteOf(v, where, argsOnWire) {
|
|
30
|
+
if (v === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (typeof v === "object" && v !== null && "by" in v && "input" in v && Array.isArray(v.by) && v.by.length > 0) {
|
|
33
|
+
const by = Array.from(v.by, rewriteAuthorOf);
|
|
34
|
+
if (by.every((a) => a !== undefined))
|
|
35
|
+
return { by, input: argsOnWire(v.input) };
|
|
36
|
+
}
|
|
37
|
+
return dropProjectedFace("tool_end.rewrite is not { by: <non-empty list of extension / policy / approver>, input } on " + where);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=extension-call-face.js.map
|