@sema-agent/sdk 40.0.0 → 41.1.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/README.md +112 -4
- package/dist/bitless-surfaces.d.ts +36 -0
- package/dist/bitless-surfaces.d.ts.map +1 -0
- package/dist/bitless-surfaces.js +68 -0
- package/dist/bitless-surfaces.js.map +1 -0
- package/dist/client.d.ts +15 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +14 -6
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +27 -16
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +21 -12
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +12 -27
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +2 -4
- package/dist/events.js.map +1 -1
- package/dist/health.d.ts +5 -11
- package/dist/health.d.ts.map +1 -1
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/resources/approvals.d.ts +12 -8
- package/dist/resources/approvals.d.ts.map +1 -1
- package/dist/resources/approvals.js +4 -5
- package/dist/resources/approvals.js.map +1 -1
- package/dist/resources/rules.d.ts +1 -1
- package/dist/resources/rules.js +1 -1
- package/dist/resources/sessions.d.ts +19 -5
- package/dist/resources/sessions.d.ts.map +1 -1
- package/dist/resources/sessions.js +19 -5
- package/dist/resources/sessions.js.map +1 -1
- package/dist/resources/tool-approvals.d.ts +393 -789
- package/dist/resources/tool-approvals.d.ts.map +1 -1
- package/dist/resources/tool-approvals.js +67 -195
- package/dist/resources/tool-approvals.js.map +1 -1
- package/dist/server-version.d.ts +16 -0
- package/dist/server-version.d.ts.map +1 -0
- package/dist/server-version.js +61 -0
- package/dist/server-version.js.map +1 -0
- package/dist/settings.d.ts +2 -2
- package/dist/types.d.ts +138 -88
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +24 -0
- package/dist/types.js.map +1 -1
- package/openapi.yaml +591 -921
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server version strings — the one parser and the one comparison this package uses.
|
|
3
|
+
*
|
|
4
|
+
* A server reports its own version as a bare `x.y.z` (optionally with a `-pre` suffix) in `GET /health` and
|
|
5
|
+
* `GET /v1/capabilities`. This module reads that string without guessing: anything that is not exactly that
|
|
6
|
+
* shape parses to `null` and is never coerced into a number. Callers decide what an unreadable version means
|
|
7
|
+
* for them; this module only refuses to invent one.
|
|
8
|
+
*
|
|
9
|
+
* Internal (not re-exported from the package root): consumers reach it through the readers that use it,
|
|
10
|
+
* for example {@link serverHasBitlessSurface}.
|
|
11
|
+
*/
|
|
12
|
+
/** `x.y.z[-pre]` → `[major, minor, patch, pre]` (`pre` is `""` for a release); anything that is not a string of exactly that shape ⇒ `null` — it never guesses and never coerces a non-string. Surrounding whitespace is ignored. */
|
|
13
|
+
export declare function parseSemver(v: string | null | undefined): [number, number, number, string] | null;
|
|
14
|
+
/** Semver comparison (`-1` / `0` / `1`); a pre-release orders below its release, and two pre-releases of the same release order by semver §11. Two unreadable sides compare equal and a lone unreadable side compares lowest, so call {@link parseSemver} first when "unreadable" must be its own answer. */
|
|
15
|
+
export declare function cmpSemver(a: string | null | undefined, b: string | null | undefined): number;
|
|
16
|
+
//# sourceMappingURL=server-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-version.d.ts","sourceRoot":"","sources":["../src/server-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,qOAAqO;AACrO,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAIjG;AAmBD,6SAA6S;AAC7S,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAW5F"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server version strings — the one parser and the one comparison this package uses.
|
|
3
|
+
*
|
|
4
|
+
* A server reports its own version as a bare `x.y.z` (optionally with a `-pre` suffix) in `GET /health` and
|
|
5
|
+
* `GET /v1/capabilities`. This module reads that string without guessing: anything that is not exactly that
|
|
6
|
+
* shape parses to `null` and is never coerced into a number. Callers decide what an unreadable version means
|
|
7
|
+
* for them; this module only refuses to invent one.
|
|
8
|
+
*
|
|
9
|
+
* Internal (not re-exported from the package root): consumers reach it through the readers that use it,
|
|
10
|
+
* for example {@link serverHasBitlessSurface}.
|
|
11
|
+
*/
|
|
12
|
+
/** Strict semver grammar without build metadata: no leading zeros in the three numbers, and a pre-release is dot-separated non-empty identifiers (a numeric identifier has no leading zero). */
|
|
13
|
+
const SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?$/;
|
|
14
|
+
/** `x.y.z[-pre]` → `[major, minor, patch, pre]` (`pre` is `""` for a release); anything that is not a string of exactly that shape ⇒ `null` — it never guesses and never coerces a non-string. Surrounding whitespace is ignored. */
|
|
15
|
+
export function parseSemver(v) {
|
|
16
|
+
if (typeof v !== "string")
|
|
17
|
+
return null;
|
|
18
|
+
const m = SEMVER.exec(v.trim());
|
|
19
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3]), m[4] ?? ""] : null;
|
|
20
|
+
}
|
|
21
|
+
/** Pre-release precedence (semver §11): identifiers are compared left to right; two numeric identifiers compare as numbers (`rc.2` is below `rc.10`), a numeric identifier orders below an alphanumeric one, two alphanumeric identifiers compare in ASCII order, and when every shared identifier is equal the shorter list orders lower. */
|
|
22
|
+
function cmpPreRelease(a, b) {
|
|
23
|
+
const xs = a.split(".");
|
|
24
|
+
const ys = b.split(".");
|
|
25
|
+
for (let i = 0; i < Math.min(xs.length, ys.length); i++) {
|
|
26
|
+
const x = xs[i];
|
|
27
|
+
const y = ys[i];
|
|
28
|
+
if (x === y)
|
|
29
|
+
continue;
|
|
30
|
+
const xn = /^\d+$/.test(x);
|
|
31
|
+
const yn = /^\d+$/.test(y);
|
|
32
|
+
if (xn && yn)
|
|
33
|
+
return Number(x) < Number(y) ? -1 : 1;
|
|
34
|
+
if (xn !== yn)
|
|
35
|
+
return xn ? -1 : 1;
|
|
36
|
+
return x < y ? -1 : 1;
|
|
37
|
+
}
|
|
38
|
+
return xs.length === ys.length ? 0 : xs.length < ys.length ? -1 : 1;
|
|
39
|
+
}
|
|
40
|
+
/** Semver comparison (`-1` / `0` / `1`); a pre-release orders below its release, and two pre-releases of the same release order by semver §11. Two unreadable sides compare equal and a lone unreadable side compares lowest, so call {@link parseSemver} first when "unreadable" must be its own answer. */
|
|
41
|
+
export function cmpSemver(a, b) {
|
|
42
|
+
const pa = parseSemver(a);
|
|
43
|
+
const pb = parseSemver(b);
|
|
44
|
+
if (!pa && !pb)
|
|
45
|
+
return 0;
|
|
46
|
+
if (!pa)
|
|
47
|
+
return -1;
|
|
48
|
+
if (!pb)
|
|
49
|
+
return 1;
|
|
50
|
+
for (let i = 0; i < 3; i++)
|
|
51
|
+
if (pa[i] !== pb[i])
|
|
52
|
+
return pa[i] < pb[i] ? -1 : 1;
|
|
53
|
+
if (pa[3] === pb[3])
|
|
54
|
+
return 0;
|
|
55
|
+
if (!pa[3])
|
|
56
|
+
return 1;
|
|
57
|
+
if (!pb[3])
|
|
58
|
+
return -1;
|
|
59
|
+
return cmpPreRelease(pa[3], pb[3]);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=server-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-version.js","sourceRoot":"","sources":["../src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AE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACrB,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACtB,OAAO,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/settings.d.ts
CHANGED
|
@@ -162,7 +162,7 @@ export interface SettingsPermissions {
|
|
|
162
162
|
* (与参照实现(CC)的 `permissions.allow` 同读:`allow: ["Edit"]` 起文件写不再问)。**内容形受理**(`Bash(git:*)`、`Read(//dir/<glob>)` 常设放行);引擎读成空的条目
|
|
163
163
|
* (`*`、写路径形 `Edit(<path-glob>)` / 域名形 / 带空白的名字 / `Read(~/…)`)**不拒**,开跑时收 `engine_notice` `permission.allowed_tool_not_granted`(user 受众)—— 写错了看通告,不靠 422。
|
|
164
164
|
* 清不掉的:任何一层的 deny / ask 规则(`deny` / `ask` 桶、运维 `APPROVAL_DENY` / `APPROVAL_REQUIRE`)、`APPROVAL_NEVER_AUTO`、`MANUAL_MODE_SHELL_GATE=always`、写保护 / 敏感写路径、治理、hook 的问、plan 模式的问;
|
|
165
|
-
* 命中却清不掉时卡上带 `allowRuleShadowed`({@link import("./resources/tool-approvals.js").
|
|
165
|
+
* 命中却清不掉时卡上带 `allowRuleShadowed`({@link import("./resources/tool-approvals.js").ApprovalCard.allowRuleShadowed},`member:"request"`)。要「某只工具必须到人」用 deny / ask 桶或运维逐工具旋钮。
|
|
166
166
|
* 受理口只判两件:字符串数组(**≤1000 条**,超了 400 `over_cap`;帽是引擎逐条准备的开销界)与**名字**(与 deny / ask 两桶同一只判官、同一句 422):退役名(`Task`)/ 无协议前缀的短名(`figma__x`)/ 协议名服务器段铸不出 / 缺段 / 写通配(`mcp__*`)⇒ **整请求 422**;内容不判。
|
|
167
167
|
* 🔴 **这条 422 的读法(7.117.0 起)**:`error` 句首是 `request settings cannot be applied as written: `(≤7.116.x 是另一句、带「tighten-only」字样的旧句首;三只桶共用这一个出口,旧句首对写收紧规则的调用方是误导、对 allow 桶是假话,所以换成不带方向的一句)——
|
|
168
168
|
* **别按句子分派,读 `errorCode`**:它不带自有码,落状态派生粗码 `request.unprocessable`(sdk 落 `BadRequestError`,`status` 422;不自动重试)。
|
|
@@ -310,7 +310,7 @@ export interface SemaSettings {
|
|
|
310
310
|
* 却对这只键答 `400 request.body_shape`(`unknownKeys: ["settings.approvalFrameFamilies"]`)。坏声明(非数组 / 词表外 / 重复)⇒ `400 request.field_invalid`,
|
|
311
311
|
* `field: "settings.approvalFrameFamilies"` + `reason: "bad_entry"` + `index`(非数组无 `index`)。
|
|
312
312
|
* 🔴 **server ≥7.134.0 的行为(BREAKING,wire)**:声明里**不含**本 worker 呈卡用的那一族(顶层 `capabilities.approvalFrameFamilies` 的词)的 run 上零审批帧 ——
|
|
313
|
-
* 不呈卡(
|
|
313
|
+
* 不呈卡(不发、不回退)、同步流与 `GET /v1/runs/:id/events` 的开流前言都不重放;每只问当场交无人值守政策:这台 worker **有耐久店**
|
|
314
314
|
* (`capabilities.approvals`)⇒ 按运维政策停驻(缺省;卡经 `POST /v1/approvals/:sessionId/decide` 作答,流上只有停驻终局)或当场拒(拒因点名缺的族);
|
|
315
315
|
* **没有耐久店** ⇒ 受门工具当场拒、run 照常收尾,无卡也无 `/decide`。会话里已记住的放行先兑现。⇒ 渲得了卡的客户端在见位时**总是**带上这只键。
|
|
316
316
|
*/
|