@sema-agent/server 7.79.0 → 7.79.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/file-history-disclosure.d.ts +53 -0
- package/dist/file-history-disclosure.js +89 -0
- package/dist/http/admission.d.ts +56 -0
- package/dist/http/admission.js +560 -0
- package/dist/http/approval-sweeps.d.ts +21 -0
- package/dist/http/approval-sweeps.js +138 -0
- package/dist/http/dispatch.d.ts +96 -0
- package/dist/http/dispatch.js +499 -0
- package/dist/http/request-guards.d.ts +51 -0
- package/dist/http/request-guards.js +205 -0
- package/dist/http/resume-legs.d.ts +80 -0
- package/dist/http/resume-legs.js +1230 -0
- package/dist/http/server.d.ts +19 -104
- package/dist/http/server.js +23 -2589
- package/dist/main.js +2 -0
- package/dist/observability/metrics.js +1 -1
- package/dist/plugins/file-history-store-sql.js +12 -11
- package/package.json +1 -1
package/dist/http/server.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ import { cascadeConfig } from "./run-meta.js";
|
|
|
34
34
|
export { cascadeConfig };
|
|
35
35
|
import { coarseStatusForState, errorCodeForExit } from "./routes/images.js";
|
|
36
36
|
export { coarseStatusForState, errorCodeForExit };
|
|
37
|
+
import { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills } from "./admission.js";
|
|
38
|
+
import { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, hasServiceAuth } from "./dispatch.js";
|
|
39
|
+
export { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, hasServiceAuth };
|
|
40
|
+
export { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills };
|
|
37
41
|
import { explicitOperatorOk, isOperator } from "./principal-gate.js";
|
|
38
42
|
export { explicitOperatorOk, isOperator };
|
|
39
43
|
/** Per-request authorization context resolved before building the spec (identity, owned session). */
|
|
@@ -730,43 +734,15 @@ export type FlatServiceDeps = ServiceCoreDeps & Partial<ServiceStoreDeps & Servi
|
|
|
730
734
|
export type ServiceDeps = FlatServiceDeps & ServiceDepGroups;
|
|
731
735
|
/** 分组入参 → 平铺视图(createHttpServer 的第一件事)。一组都没给 ⇒ 原样返回(存量调用零开销、零形变)。 */
|
|
732
736
|
export declare function flattenServiceDeps(deps: ServiceDeps): FlatServiceDeps;
|
|
733
|
-
/**
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
|
|
742
|
-
export declare const MAX_SYSTEM_PROMPT_CHARS = 16384;
|
|
743
|
-
/** Cap on a request's `outputSchema` (JSON-serialized) — an uncapped schema bloats the prompt + the per-turn
|
|
744
|
-
* validation cost. 32KB comfortably holds a rich nested schema while bounding the abuse surface. */
|
|
745
|
-
export declare const MAX_OUTPUT_SCHEMA_CHARS = 32768;
|
|
746
|
-
/**
|
|
747
|
-
* Validate `body.skills` —— **形**校验 + 一条引擎孪生门。返回错误串(→ 400)或 null。
|
|
748
|
-
*
|
|
749
|
-
* 🔴 **[ref](7.77.0,硬 BREAKING;零别名零双读)**:此前这里有三条本仓自造的拒绝臂,全部退役 ——
|
|
750
|
-
* · `at most 10 skills per request`(条数帽);
|
|
751
|
-
* · `skill.description must be a string of at most 1024 characters`(描述长度帽);
|
|
752
|
-
* · `skill.name must be a non-empty string of at most 64 characters` 里的 **长度**那一半。
|
|
753
|
-
*
|
|
754
|
-
* 退役的判据是**上游两侧都没有同形门**:CC 2.1.259 的技能清单渲染(`cli259.js:23195` 的预算算法)
|
|
755
|
-
* 在超预算时把**描述裁短**、再不够就退成 name-only,**从不**因为条数多或描述长而拒掉一条技能;
|
|
756
|
-
* 它的 `Ir()` 名字校验也只判非空 / 无配对代理 / 无首尾空白 / 无括号逗号控制字符,没有长度帽。
|
|
757
|
-
* 引擎侧同理:唯一整拒的是 1 MiB 的单技能加载门。于是那三条帽是「装了 11 个技能就 400」这种
|
|
758
|
-
* 纯本仓面的伤——收益是零(预算由渲染侧按字节兜),代价是用户装不进自己的技能库。
|
|
759
|
-
*
|
|
760
|
-
* **补偿**(三问的第三问):`settings.skillListingBudgetFraction` / `settings.skillListingMaxDescChars`
|
|
761
|
-
* 两个旋钮直达引擎的渲染预算(per-turn 成本的真属主)。
|
|
762
|
-
* ⚠️ **fraction 是**单向**的**:引擎的预算 = `min(窗口 × fraction, 8 000 字节)`,8 000 是**投递车道的结构
|
|
763
|
-
* 上限**(清单帧与同 turn 的其它附件共用一份完整送达额度)⇒ **调低生效、调高被夹**;调高唯一的用处是让
|
|
764
|
-
* 一个声明窗口小于 200 000 token 的模型把清单预算拿回大窗口的水平。别把这句读成「调用方可以随便加大」。
|
|
765
|
-
* 体积面照旧由**非技能专属**的 8 MiB 请求体上限兜住(`MAX_BODY`),那是一条一直都在的门。
|
|
766
|
-
*
|
|
767
|
-
* 🔴 **server 侧禁裁列表 / 禁截描述**:渲染归引擎(单一属主)。本函数只判「这一条技能的形能不能用」。
|
|
768
|
-
*/
|
|
769
|
-
export declare function validateUserSkills(skills: unknown): string | null;
|
|
737
|
+
/** The TRUSTED end-user principal for an owner-gated / per-tenant request. On a direct-door worker the
|
|
738
|
+
* trusted-header path is OFF (x-agent-principal is client-self-asserted), so identity comes from the crypto-VERIFIED
|
|
739
|
+
* principal JWT (`x-approval-principal-token`, principal-only proof — no cnf.bnd action binding); otherwise the
|
|
740
|
+
* BFF-minted trusted header. undefined when absent/invalid (fail-closed → callers map to 401 / scope "__none__").
|
|
741
|
+
* 🔴 Use this for ANY endpoint that reads or gates PER-TENANT data — NOT `principalFrom` directly, which trusts
|
|
742
|
+
* the self-asserted header on a direct door (/v1/usage + the trace owner-gate
|
|
743
|
+
* had drifted to a bare principalFrom, unlike the leader/images/approvals identity paths). One source of truth
|
|
744
|
+
* so a future per-tenant endpoint can't re-introduce the bypass. The action-BOUND decide/answer paths keep their
|
|
745
|
+
* own verifyDirectDoorProof (cnf.bnd) — this is the identity-only twin. */
|
|
770
746
|
/**
|
|
771
747
|
* Managed-Agents-style HTTP/SSE service surface.
|
|
772
748
|
* GET /health
|
|
@@ -791,73 +767,12 @@ export declare function createHttpServer(rawDeps: ServiceDeps): http.Server & {
|
|
|
791
767
|
/** [ref]:live 回决腿的 PARKED 赎回席(装配层把它接进协调器的晚绑座,见 {@link redeemParkedAsk})。 */
|
|
792
768
|
redeemParkedAsk: ParkedAskRedeem;
|
|
793
769
|
};
|
|
794
|
-
/**
|
|
795
|
-
* guard's inline list had drifted from the handlers and missed `/v1/approvals/:id/decide`, which resumes a run
|
|
796
|
-
* via resumeCheckpoint/store.decide → paid tokens). Keep this in sync when adding a billable POST route. */
|
|
770
|
+
/** SSE: replay durable events after Last-Event-ID, then tail until the run is terminal (or stale). */
|
|
797
771
|
/**
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
* 本谓词让 `handle()` 对这条 url **跳过**那两道,改由域模块在 `message/send` 分支里施加同样的两道
|
|
804
|
-
* (`routes/a2a-serve.ts` 的 `submitUnavailable`,文案逐字同源)。
|
|
805
|
-
*
|
|
806
|
-
* 🔴 **只豁免那两道,不豁免安全轴**:`isBillableSubmitPath` 本身**不变**(它仍答 true),所以
|
|
807
|
-
* ① 无 service token 的部署上那道 fail-closed 503 照旧罩着这条 url —— 它判的是「这台机能不能收写」,
|
|
808
|
-
* 与方法无关,而且门必须在解析请求体**之前**;
|
|
809
|
-
* ② billable 申明门钉的仍是那只纯谓词(表里 `/v1/a2a` 依旧 billable=true)。
|
|
810
|
-
* 新成员进本表 = 承诺「该域在自己的方法分支里补齐那两道」,漏补就是一条静默旁路;所以本表只该有
|
|
811
|
-
* 「单 URL 多方法」这一种成员,加一条要连同它的域内补门一起过评审。
|
|
812
|
-
*/
|
|
813
|
-
export declare function isMethodDispatchedSubmitPath(url: string): boolean;
|
|
814
|
-
/** 「这台部署配了任何一把 service 凭证吗」—— fail-closed 写门族的真值源。**单一属主**:`handle()` 的
|
|
815
|
-
* 凭证门、[ref] 的 parked 赎回席、以及 [ref] 的 consolidation 阀门启动期告警读同一句(手抄迟早
|
|
816
|
-
* 只改一处,而这条判据决定的是「无凭证部署上写口开不开」)。导出仅为最后一个消费点(main.ts)。 */
|
|
817
|
-
export declare function hasServiceAuth(config: ServiceConfig): boolean;
|
|
818
|
-
export declare function isBillableSubmitPath(url: string): boolean;
|
|
819
|
-
/**
|
|
820
|
-
* [ref]([ref] 件5)—— **改写门**:不烧模型、但在**没有任何 service credential** 的部署形下必须与
|
|
821
|
-
* billable / bake 两族一样 fail-closed 的写门。谓词与 `isBillableSubmitPath` **刻意分开**:这几扇门
|
|
822
|
-
* `billable=false`(零模型工作),塞进那张名单会让它们连带吃 drain 与 model-roster-pending 两道 503 ——
|
|
823
|
-
* 而收编与规则读写在排空期/roster 未落时做完全无害。
|
|
824
|
-
*
|
|
825
|
-
* 判据(两个合取项,缺一不进本表)= 「授权的唯一输入是 principal 头」∧「动作是**持久改写**」:
|
|
826
|
-
* · `POST /v1/adoption` —— operator-only 的一次性部署级动作,把一个 principal 名下**每一行**重写到另一个
|
|
827
|
-
* 身份;授权判据 `explicitOperatorOk(gatedPrincipal(...))`。
|
|
828
|
-
* · `POST /v1/rules/cc-import/*` —— principal lane 的**持久 allow 规则**铸造口;一条持久 allow 规则对后续
|
|
829
|
-
* 同命令的 classify 档 ask 常驻消音(core [ref] 之后仍然如此,只是不再消 mandated 的那些)。
|
|
830
|
-
* · `DELETE /v1/rules` —— 同一个规则店的**撤销**口。方向相反(收紧)但同样是持久改写,而且它多一条
|
|
831
|
-
* operator 超范围域(`?principal=` / body 的 `principal` 让 operator 收回**任一**租户的规则)⇒ 自造一个
|
|
832
|
-
* 列在 `OPERATOR_PRINCIPALS` 里的头,就能把每一位租户的规则一次清空。
|
|
833
|
-
* 无 service token 的部署上 `verifiedPrincipal` 走的是「BFF/gated:头已由上游验过」那一支,而这一形恰恰
|
|
834
|
-
* 是**没有**那个上游 —— 于是自造一个头就能收编别人、替任意租户种下常驻放行、或替他们全删。bake 门当年
|
|
835
|
-
* 补的就是同一句话,`isDestructiveSessionWrite` 从逐条路由白名单改成族判定也是同一句话(那次的措辞逐字是
|
|
836
|
-
* 「a forged principal header alone could **tighten/DoS** a session's tools」——撤销口落的正是 DoS 那一半)。
|
|
837
|
-
*
|
|
838
|
-
* 🔴 **方法感知**(codex 交叉复审 R2-[high],验真后修):撤销走的是 `DELETE`,而本门最初只挂在 `POST` 的
|
|
839
|
-
* 合取里 —— 于是一个自称「持久改写」的谓词把爆炸半径最大的那条动词漏在门外,正是 `isDestructiveSessionWrite`
|
|
840
|
-
* 当年被抓到的同一形。签名因此收方法,与那只谓词逐字同形。
|
|
841
|
-
* 🔴 读面**原则上**不进本表:`GET /v1/adoption/:id` 与 `GET /v1/rules` 各有自己的**属主门**兜底,本门只拦写。
|
|
842
|
-
*
|
|
843
|
-
* 🔴 **第二个合取项的加宽**(codex 交叉复审 [high],[ref] 提货批,验真后修)——判据现在是
|
|
844
|
-
* 「持久改写 **或** 授权唯一输入是 principal 头的**跨租户治理读**」。加宽是为了收进 [ref] v2-c 的两口:
|
|
845
|
-
* · `POST /v1/memory/import` —— 直接落在**原**判据上,而且是本仓最深的那一种持久改写:它把别处铸的
|
|
846
|
-
* 条目 / 挑战 / 污染标记 / 托管链落进本部署的记忆平面。自造一个在册 operator 头 ⇒ 一份**不当调用方自制的
|
|
847
|
-
* 治理史**成为本店的账;而记忆是模型**每次挂载都读**的面,比种一条常驻 allow 规则更深(那条只影响
|
|
848
|
-
* ask 会不会问,这条影响模型相信什么)。
|
|
849
|
-
* · `POST /v1/memory/export` —— 是**读**,按原措辞本不该进。但被点名豁免的那两条读各有属主门兜底,
|
|
850
|
-
* 而本条**没有**:它的授权判据就是 `explicitOperatorOk`,过了就是**全库**——一次调用取走每个 scope 的
|
|
851
|
-
* 条目正文 + 托管链 + 跨会话污染标记 + lineage。把一次全租户记忆外泄留在门外、只为守住「本门只拦写」
|
|
852
|
-
* 这句措辞,是把措辞看得比它要保护的东西更重。加宽后的判据仍然是**闭**的(不是「写门以外都进」):
|
|
853
|
-
* 它要求「授权的唯一输入是那个头」∧「一次调用的爆炸半径跨租户」,`GET /v1/rules` 那种属主门读不满足。
|
|
854
|
-
* 行为面钉:`test/rewrite-door-service-token-gate.test.ts`(六扇门各一正一反 + 逃生口格 + 读面负控)。
|
|
772
|
+
* The differences a concrete log (task_run | image_bake) feeds the ONE resumable SSE reader (P2.8). Everything
|
|
773
|
+
* the reader does — Last-Event-ID/`?from=` resume, the 416 retention boundary, the per-poll concurrent
|
|
774
|
+
* status+events read, the terminal re-fetch (the terminal event lands in the gap before the status flips), the
|
|
775
|
+
* stale fallback, the 15-min cap, the 15s idle heartbeat — is provider-agnostic and lives in `streamSseLog`.
|
|
776
|
+
* 🔴 The task_run provider MUST keep the existing wire bytes EXACTLY (center's relay + 730+ tests depend on it).
|
|
855
777
|
*/
|
|
856
|
-
export declare function isCredentialGatedRewrite(method: string, url: string): boolean;
|
|
857
|
-
/** Stable, low-cardinality route label for metrics/logs (ids collapsed to `:id`).
|
|
858
|
-
* [[ref]] 字面量**先于**模式:此前模式先查,五条精确路由被形状桶吞掉(`/v1/approvals/stream`
|
|
859
|
-
* 落 ":id"、`/v1/images/{bakes,select,register}` 落 ":profile"、`/v1/images/bakes/claim` 落
|
|
860
|
-
* "bakes/:id")——长连接 stream 的 duration 混进 :id 桶正是 fleet/stream 案的同族错桶病。
|
|
861
|
-
* 精确匹配恒比形状匹配更对,序修零反例(billable-route-declaration 门逐样本钉)。 */
|
|
862
|
-
export declare function routeLabel(_method: string, url: string): string;
|
|
863
778
|
//# sourceMappingURL=server.d.ts.map
|