@sema-agent/settings-schema 2.1.0 → 3.0.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.
Files changed (203) hide show
  1. package/CHANGELOG.md +253 -1
  2. package/README.md +45 -10
  3. package/conformance/VERSION +1 -0
  4. package/conformance/baseline.json +55 -0
  5. package/conformance/cases/c01-entry-salvage-then-typo/expected.json +105 -0
  6. package/conformance/cases/c01-entry-salvage-then-typo/input.json +22 -0
  7. package/conformance/cases/c01-entry-salvage-then-typo/meta.json +10 -0
  8. package/conformance/cases/c02-hosts-clamp-stacked/expected.json +96 -0
  9. package/conformance/cases/c02-hosts-clamp-stacked/input.json +21 -0
  10. package/conformance/cases/c02-hosts-clamp-stacked/meta.json +10 -0
  11. package/conformance/cases/c03-literal-dotted-top-key/expected.json +112 -0
  12. package/conformance/cases/c03-literal-dotted-top-key/input.json +26 -0
  13. package/conformance/cases/c03-literal-dotted-top-key/meta.json +5 -0
  14. package/conformance/cases/c04-all-bad-collection-not-salvaged/expected.json +77 -0
  15. package/conformance/cases/c04-all-bad-collection-not-salvaged/input.json +18 -0
  16. package/conformance/cases/c04-all-bad-collection-not-salvaged/meta.json +5 -0
  17. package/conformance/cases/c05-gate-domain-bad-entry-throws/expected.json +16 -0
  18. package/conformance/cases/c05-gate-domain-bad-entry-throws/input.json +18 -0
  19. package/conformance/cases/c05-gate-domain-bad-entry-throws/meta.json +5 -0
  20. package/conformance/cases/c06-legacy-governance-lift/expected.json +99 -0
  21. package/conformance/cases/c06-legacy-governance-lift/input.json +20 -0
  22. package/conformance/cases/c06-legacy-governance-lift/meta.json +9 -0
  23. package/conformance/cases/c07-hooks-is-not-a-config-domain/expected.json +72 -0
  24. package/conformance/cases/c07-hooks-is-not-a-config-domain/input.json +43 -0
  25. package/conformance/cases/c07-hooks-is-not-a-config-domain/meta.json +6 -0
  26. package/conformance/cases/c08-limits-unknown-carried-64/expected.json +336 -0
  27. package/conformance/cases/c08-limits-unknown-carried-64/input.json +74 -0
  28. package/conformance/cases/c08-limits-unknown-carried-64/meta.json +5 -0
  29. package/conformance/cases/c09-limits-unknown-carried-65/expected.json +338 -0
  30. package/conformance/cases/c09-limits-unknown-carried-65/input.json +75 -0
  31. package/conformance/cases/c09-limits-unknown-carried-65/meta.json +7 -0
  32. package/conformance/cases/c10-record-key-secret-redacted-twice/expected.json +106 -0
  33. package/conformance/cases/c10-record-key-secret-redacted-twice/input.json +29 -0
  34. package/conformance/cases/c10-record-key-secret-redacted-twice/meta.json +13 -0
  35. package/conformance/cases/c11-unicode-unknown-keys/expected.json +88 -0
  36. package/conformance/cases/c11-unicode-unknown-keys/input.json +13 -0
  37. package/conformance/cases/c11-unicode-unknown-keys/meta.json +5 -0
  38. package/conformance/cases/c12-prototype-name-top-keys/expected.json +72 -0
  39. package/conformance/cases/c12-prototype-name-top-keys/input.json +20 -0
  40. package/conformance/cases/c12-prototype-name-top-keys/meta.json +11 -0
  41. package/conformance/cases/c13-models-field-null/expected.json +77 -0
  42. package/conformance/cases/c13-models-field-null/input.json +11 -0
  43. package/conformance/cases/c13-models-field-null/meta.json +5 -0
  44. package/conformance/cases/c14-models-field-empty-array/expected.json +72 -0
  45. package/conformance/cases/c14-models-field-empty-array/input.json +11 -0
  46. package/conformance/cases/c14-models-field-empty-array/meta.json +5 -0
  47. package/conformance/cases/c15-models-field-number/expected.json +77 -0
  48. package/conformance/cases/c15-models-field-number/input.json +11 -0
  49. package/conformance/cases/c15-models-field-number/meta.json +5 -0
  50. package/conformance/cases/c16-deep-nesting-205/expected.json +83 -0
  51. package/conformance/cases/c16-deep-nesting-205/input.json +421 -0
  52. package/conformance/cases/c16-deep-nesting-205/meta.json +5 -0
  53. package/conformance/cases/c17-empty-domain-file/expected.json +73 -0
  54. package/conformance/cases/c17-empty-domain-file/input.json +10 -0
  55. package/conformance/cases/c17-empty-domain-file/meta.json +5 -0
  56. package/conformance/cases/c18-wire-envelope-not-an-object/expected.json +74 -0
  57. package/conformance/cases/c18-wire-envelope-not-an-object/input.json +8 -0
  58. package/conformance/cases/c18-wire-envelope-not-an-object/meta.json +5 -0
  59. package/conformance/cases/c19-wire-envelope-no-version/expected.json +74 -0
  60. package/conformance/cases/c19-wire-envelope-no-version/input.json +13 -0
  61. package/conformance/cases/c19-wire-envelope-no-version/meta.json +5 -0
  62. package/conformance/cases/c20-governance-absent-lifts/expected.json +84 -0
  63. package/conformance/cases/c20-governance-absent-lifts/input.json +11 -0
  64. package/conformance/cases/c20-governance-absent-lifts/meta.json +9 -0
  65. package/conformance/cases/c21-governance-empty-object-wins/expected.json +72 -0
  66. package/conformance/cases/c21-governance-empty-object-wins/input.json +12 -0
  67. package/conformance/cases/c21-governance-empty-object-wins/meta.json +5 -0
  68. package/conformance/cases/c22-governance-null-throws/expected.json +16 -0
  69. package/conformance/cases/c22-governance-null-throws/input.json +9 -0
  70. package/conformance/cases/c22-governance-null-throws/meta.json +5 -0
  71. package/conformance/cases/c23-mixed-validity-models/expected.json +106 -0
  72. package/conformance/cases/c23-mixed-validity-models/input.json +27 -0
  73. package/conformance/cases/c23-mixed-validity-models/meta.json +9 -0
  74. package/conformance/cases/c24-valid-entries-with-unknown-keys/expected.json +100 -0
  75. package/conformance/cases/c24-valid-entries-with-unknown-keys/input.json +25 -0
  76. package/conformance/cases/c24-valid-entries-with-unknown-keys/meta.json +5 -0
  77. package/conformance/cases/c25-published-roundtrip-zero-warnings/expected.json +89 -0
  78. package/conformance/cases/c25-published-roundtrip-zero-warnings/input.json +24 -0
  79. package/conformance/cases/c25-published-roundtrip-zero-warnings/meta.json +5 -0
  80. package/conformance/cases/c26-hosts-array-1024/expected.json +7241 -0
  81. package/conformance/cases/c26-hosts-array-1024/input.json +3084 -0
  82. package/conformance/cases/c26-hosts-array-1024/meta.json +5 -0
  83. package/conformance/cases/c27-hosts-array-1025/expected.json +7248 -0
  84. package/conformance/cases/c27-hosts-array-1025/input.json +3087 -0
  85. package/conformance/cases/c27-hosts-array-1025/meta.json +5 -0
  86. package/conformance/cases/c28-large-document-over-1mb/expected.json +82 -0
  87. package/conformance/cases/c28-large-document-over-1mb/input.json +11 -0
  88. package/conformance/cases/c28-large-document-over-1mb/meta.json +5 -0
  89. package/conformance/cases/c29-salvage-then-domain-refine-fails/expected.json +77 -0
  90. package/conformance/cases/c29-salvage-then-domain-refine-fails/input.json +27 -0
  91. package/conformance/cases/c29-salvage-then-domain-refine-fails/meta.json +5 -0
  92. package/conformance/cases/c30-version-triple-a-first/expected.json +85 -0
  93. package/conformance/cases/c30-version-triple-a-first/input.json +18 -0
  94. package/conformance/cases/c30-version-triple-a-first/meta.json +5 -0
  95. package/conformance/cases/c31-version-triple-b-changed/expected.json +85 -0
  96. package/conformance/cases/c31-version-triple-b-changed/input.json +18 -0
  97. package/conformance/cases/c31-version-triple-b-changed/meta.json +5 -0
  98. package/conformance/cases/c32-version-triple-a-restored/expected.json +85 -0
  99. package/conformance/cases/c32-version-triple-a-restored/input.json +18 -0
  100. package/conformance/cases/c32-version-triple-a-restored/meta.json +5 -0
  101. package/conformance/cases/c33-limits-nested-carried-key/expected.json +91 -0
  102. package/conformance/cases/c33-limits-nested-carried-key/input.json +14 -0
  103. package/conformance/cases/c33-limits-nested-carried-key/meta.json +5 -0
  104. package/conformance/cases/c34-skills-content-vs-manifest/expected.json +160 -0
  105. package/conformance/cases/c34-skills-content-vs-manifest/input.json +18 -0
  106. package/conformance/cases/c34-skills-content-vs-manifest/meta.json +5 -0
  107. package/conformance/cases/c35-portable-domain-file-is-null/expected.json +76 -0
  108. package/conformance/cases/c35-portable-domain-file-is-null/input.json +9 -0
  109. package/conformance/cases/c35-portable-domain-file-is-null/meta.json +5 -0
  110. package/conformance/cases/c36-skills-entry-without-content/expected.json +144 -0
  111. package/conformance/cases/c36-skills-entry-without-content/input.json +16 -0
  112. package/conformance/cases/c36-skills-entry-without-content/meta.json +5 -0
  113. package/conformance/cases/c37-skills-field-null/expected.json +134 -0
  114. package/conformance/cases/c37-skills-field-null/input.json +9 -0
  115. package/conformance/cases/c37-skills-field-null/meta.json +5 -0
  116. package/conformance/cases/c38-remote-exec-is-a-non-domain-file/expected.json +72 -0
  117. package/conformance/cases/c38-remote-exec-is-a-non-domain-file/input.json +11 -0
  118. package/conformance/cases/c38-remote-exec-is-a-non-domain-file/meta.json +5 -0
  119. package/conformance/cases/c39-hidden-file-in-config-d/expected.json +72 -0
  120. package/conformance/cases/c39-hidden-file-in-config-d/input.json +11 -0
  121. package/conformance/cases/c39-hidden-file-in-config-d/meta.json +5 -0
  122. package/conformance/cases/cc01-mcp-toolfaces-non-object/expected.json +112 -0
  123. package/conformance/cases/cc01-mcp-toolfaces-non-object/input.json +39 -0
  124. package/conformance/cases/cc01-mcp-toolfaces-non-object/meta.json +8 -0
  125. package/conformance/cases/cc02-mcp-source-key-is-transported/expected.json +85 -0
  126. package/conformance/cases/cc02-mcp-source-key-is-transported/input.json +20 -0
  127. package/conformance/cases/cc02-mcp-source-key-is-transported/meta.json +8 -0
  128. package/conformance/cases/cc03-model-compat-unknown-subkey/expected.json +89 -0
  129. package/conformance/cases/cc03-model-compat-unknown-subkey/input.json +22 -0
  130. package/conformance/cases/cc03-model-compat-unknown-subkey/meta.json +8 -0
  131. package/conformance/cases/cli01-model-name-nfc-vs-nfd/expected.json +102 -0
  132. package/conformance/cases/cli01-model-name-nfc-vs-nfd/input.json +30 -0
  133. package/conformance/cases/cli01-model-name-nfc-vs-nfd/meta.json +9 -0
  134. package/conformance/cases/cli02-control-and-zero-width-chars/expected.json +115 -0
  135. package/conformance/cases/cli02-control-and-zero-width-chars/input.json +42 -0
  136. package/conformance/cases/cli02-control-and-zero-width-chars/meta.json +9 -0
  137. package/conformance/cases/cli03-credential-pasted-into-unknown-key/expected.json +92 -0
  138. package/conformance/cases/cli03-credential-pasted-into-unknown-key/input.json +16 -0
  139. package/conformance/cases/cli03-credential-pasted-into-unknown-key/meta.json +9 -0
  140. package/conformance/cases/cli04-env-value-with-newline/expected.json +93 -0
  141. package/conformance/cases/cli04-env-value-with-newline/input.json +23 -0
  142. package/conformance/cases/cli04-env-value-with-newline/meta.json +5 -0
  143. package/conformance/cases/cli05-long-and-prefix-colliding-names/expected.json +109 -0
  144. package/conformance/cases/cli05-long-and-prefix-colliding-names/input.json +30 -0
  145. package/conformance/cases/cli05-long-and-prefix-colliding-names/meta.json +5 -0
  146. package/conformance/cases/t01-absent-domain-key-not-null/expected.json +93 -0
  147. package/conformance/cases/t01-absent-domain-key-not-null/input.json +29 -0
  148. package/conformance/cases/t01-absent-domain-key-not-null/meta.json +6 -0
  149. package/conformance/cases/t02-entry-salvage-vs-whole-domain-refusal/expected.json +16 -0
  150. package/conformance/cases/t02-entry-salvage-vs-whole-domain-refusal/input.json +32 -0
  151. package/conformance/cases/t02-entry-salvage-vs-whole-domain-refusal/meta.json +6 -0
  152. package/conformance/cases/t03-prototype-name-key-not-swallowed/expected.json +107 -0
  153. package/conformance/cases/t03-prototype-name-key-not-swallowed/input.json +25 -0
  154. package/conformance/cases/t03-prototype-name-key-not-swallowed/meta.json +6 -0
  155. package/conformance/cases/t04-secret-literal-never-in-warning-value/expected.json +105 -0
  156. package/conformance/cases/t04-secret-literal-never-in-warning-value/input.json +25 -0
  157. package/conformance/cases/t04-secret-literal-never-in-warning-value/meta.json +14 -0
  158. package/conformance/cases/z01-every-domain-empty-object/expected.json +72 -0
  159. package/conformance/cases/z01-every-domain-empty-object/input.json +25 -0
  160. package/conformance/cases/z01-every-domain-empty-object/meta.json +5 -0
  161. package/conformance/cases/z02-every-domain-unknown-key/expected.json +228 -0
  162. package/conformance/cases/z02-every-domain-unknown-key/input.json +59 -0
  163. package/conformance/cases/z02-every-domain-unknown-key/meta.json +5 -0
  164. package/conformance/historical/settings-schema@1.0.0.json +1080 -0
  165. package/conformance/historical/settings-schema@1.10.0.json +1080 -0
  166. package/conformance/historical/settings-schema@1.5.0.json +1080 -0
  167. package/conformance/historical/settings-schema@2.0.0.json +1080 -0
  168. package/conformance/historical/settings-schema@2.1.0.json +1080 -0
  169. package/dist/api/auth.d.ts +42 -1
  170. package/dist/api/auth.js +71 -4
  171. package/dist/api/scopes.d.ts +9 -1
  172. package/dist/api/scopes.js +8 -2
  173. package/dist/config-fns.d.ts +60 -28
  174. package/dist/config-fns.js +94 -77
  175. package/dist/conformance/canonical.d.ts +36 -0
  176. package/dist/conformance/canonical.js +114 -0
  177. package/dist/conformance/contract-adapter.d.ts +20 -0
  178. package/dist/conformance/contract-adapter.js +74 -0
  179. package/dist/conformance/corpus.d.ts +73 -0
  180. package/dist/conformance/corpus.js +99 -0
  181. package/dist/conformance/derive.d.ts +48 -0
  182. package/dist/conformance/derive.js +136 -0
  183. package/dist/conformance/index.d.ts +22 -0
  184. package/dist/conformance/index.js +22 -0
  185. package/dist/conformance/run.d.ts +27 -0
  186. package/dist/conformance/run.js +424 -0
  187. package/dist/conformance/types.d.ts +288 -0
  188. package/dist/conformance/types.js +4 -0
  189. package/dist/conformance/warnings.d.ts +88 -0
  190. package/dist/conformance/warnings.js +144 -0
  191. package/dist/cross-domain.d.ts +1 -1
  192. package/dist/cross-domain.js +1 -1
  193. package/dist/file-store.d.ts +7 -0
  194. package/dist/file-store.js +6 -2
  195. package/dist/hooks.d.ts +2 -2
  196. package/dist/hooks.js +2 -2
  197. package/dist/scheduler-store.d.ts +1 -1
  198. package/dist/scheduler-store.js +1 -1
  199. package/dist/types.d.ts +2 -2
  200. package/dist/types.js +3 -3
  201. package/package.json +7 -5
  202. package/dist/api/wire.d.ts +0 -60
  203. package/dist/api/wire.js +0 -89
package/dist/types.d.ts CHANGED
@@ -125,7 +125,7 @@ export interface ParseTransparentKey {
125
125
  * 五行同义散文 ×3,没有任何一处能回答「一共有几个这样的键、分别归谁校验」。那正是「修法给每个新键加一条
126
126
  * 特判」的形。这张表把那段理由收成一处:键在这里登记,JSDoc 只留一行指过来。
127
127
  *
128
- * 1.11.0 起整域 all-or-nothing 已按类改成逐条容错(坏条目逐条丢、同域其余条目存活),所以「设形判据
128
+ * 2.0.0 起整域 all-or-nothing 已按类改成逐条容错(坏条目逐条丢、同域其余条目存活),所以「设形判据
129
129
  * 会抹掉整域」这条**理由本身已经弱化** —— 但登记表要回答的问题没变:这些键的形归谁校验。新键要不要
130
130
  * 解析透明,按「本包是不是那张形表的属主」判,不再按「怕连坐」判。
131
131
  *
@@ -4812,7 +4812,7 @@ export type ExecutionPolicy = z.infer<typeof ExecutionPolicy>;
4812
4812
  * center mint 端点)统一产 **uuidv7**。36 字符,天然满足 design/142 §1.2 段编码 64 上限。
4813
4813
  * SINGLE-SOURCE 纪律:本常量是引擎那条正则的**自持镜像**(本仓不带引擎运行时依赖轴),对拍走 dev-only
4814
4814
  * conformance(never a runtime import,EffectiveKey/coreTypes 先例)。
4815
- * 1.11.0:drift-lock 已建(`test/upstream-drift.test.ts` ③)—— pattern 必须与引擎逐字相同,唯一成文的差是
4815
+ * 2.0.0:drift-lock 已建(`test/upstream-drift.test.ts` ③)—— pattern 必须与引擎逐字相同,唯一成文的差是
4816
4816
  * flags:本常量刻意**不带** `i`,因为它是登记簿 Record 的**键**,大小写不同的同一个 UUID 会变成两条登记行
4817
4817
  * (同一 project 双注册);引擎侧是识别语义(读 marker / 找回身份),放宽合理。 */
4818
4818
  export declare const PROJECT_ID_REGEX: RegExp;
package/dist/types.js CHANGED
@@ -301,7 +301,7 @@ export const SealedApiKey = z.object({
301
301
  * 五行同义散文 ×3,没有任何一处能回答「一共有几个这样的键、分别归谁校验」。那正是「修法给每个新键加一条
302
302
  * 特判」的形。这张表把那段理由收成一处:键在这里登记,JSDoc 只留一行指过来。
303
303
  *
304
- * 1.11.0 起整域 all-or-nothing 已按类改成逐条容错(坏条目逐条丢、同域其余条目存活),所以「设形判据
304
+ * 2.0.0 起整域 all-or-nothing 已按类改成逐条容错(坏条目逐条丢、同域其余条目存活),所以「设形判据
305
305
  * 会抹掉整域」这条**理由本身已经弱化** —— 但登记表要回答的问题没变:这些键的形归谁校验。新键要不要
306
306
  * 解析透明,按「本包是不是那张形表的属主」判,不再按「怕连坐」判。
307
307
  *
@@ -634,7 +634,7 @@ export const ScenarioEntry = z.object({
634
634
  // registry field would become an ambiguous precedence channel」):配置域 prompt 单入口=center
635
635
  // prompts binding(scenario 维度);引擎 API 层 TaskSpec.systemPrompt 保留(不同层,勿混)。
636
636
  // 现网无用户直删;z.object 非 strict ⇒ 存量数据带 prompt 被 strip,parse 不炸。
637
- // 落日(1.11.0):本条是**纯墓碑**(零代码,靠 strip 生效),没有要删的兼容码;它留在这里的唯一作用
637
+ // 落日(2.0.0):本条是**纯墓碑**(零代码,靠 strip 生效),没有要删的兼容码;它留在这里的唯一作用
638
638
  // 是让下一个读到这段 schema 的人知道 `prompt` 这个名字曾经在这里、别再铸回来。0.19.0 起存量文档带
639
639
  // 它会被 `unknown-keys-dropped` 点名,所以「还有人在写它」是可观察的,不靠记忆。
640
640
  enabled: z.boolean().default(true),
@@ -1336,7 +1336,7 @@ export const ExecutionPolicy = z.object({
1336
1336
  * center mint 端点)统一产 **uuidv7**。36 字符,天然满足 design/142 §1.2 段编码 64 上限。
1337
1337
  * SINGLE-SOURCE 纪律:本常量是引擎那条正则的**自持镜像**(本仓不带引擎运行时依赖轴),对拍走 dev-only
1338
1338
  * conformance(never a runtime import,EffectiveKey/coreTypes 先例)。
1339
- * 1.11.0:drift-lock 已建(`test/upstream-drift.test.ts` ③)—— pattern 必须与引擎逐字相同,唯一成文的差是
1339
+ * 2.0.0:drift-lock 已建(`test/upstream-drift.test.ts` ③)—— pattern 必须与引擎逐字相同,唯一成文的差是
1340
1340
  * flags:本常量刻意**不带** `i`,因为它是登记簿 Record 的**键**,大小写不同的同一个 UUID 会变成两条登记行
1341
1341
  * (同一 project 双注册);引擎侧是识别语义(读 marker / 找回身份),放宽合理。 */
1342
1342
  export const PROJECT_ID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/settings-schema",
3
- "version": "2.1.0",
3
+ "version": "3.0.1",
4
4
  "description": "Sema settings schema — pure config contract (zod domains + effective-config + roster resolution + ref-integrity + remoteExec) shared by sema-registry, sema-server, and the TOC desktop/CLI. One source of truth. (Renamed at 1.0.0 from @sema-agent/registry-core — name and docs only, no behavior change; note the range moves 0.19.0 -> 1.0.0, so a dependency must become ^1.0.0. The old names @sema-agent/registry-core <=0.19.0 and @sema-ai/registry-core remain published, frozen, for migration.)",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
@@ -51,6 +51,11 @@
51
51
  "types": "./dist/config-fns.d.ts",
52
52
  "default": "./dist/config-fns.js"
53
53
  },
54
+ "./package.json": "./package.json",
55
+ "./conformance": {
56
+ "types": "./dist/conformance/index.d.ts",
57
+ "default": "./dist/conformance/index.js"
58
+ },
54
59
  "./reader": {
55
60
  "types": "./dist/reader.d.ts",
56
61
  "default": "./dist/reader.js"
@@ -98,14 +103,11 @@
98
103
  "./api/scopes": {
99
104
  "types": "./dist/api/scopes.d.ts",
100
105
  "default": "./dist/api/scopes.js"
101
- },
102
- "./api/wire": {
103
- "types": "./dist/api/wire.d.ts",
104
- "default": "./dist/api/wire.js"
105
106
  }
106
107
  },
107
108
  "files": [
108
109
  "dist",
110
+ "conformance",
109
111
  "README.md",
110
112
  "CHANGELOG.md"
111
113
  ],
@@ -1,60 +0,0 @@
1
- /**
2
- * `api/wire` — the ZERO-DEPENDENCY wire subset of the auth/scopes contracts (server AI 接手首车,
3
- * 2026-07-27,跨仓 candidate 落地):endpoint paths, protocol constants and PURE helper functions,
4
- * with **no zod import** — so a zero-runtime-dependency client (e.g. `@sema-agent/sdk/registry`) can
5
- * import these at RUNTIME instead of value-copying them behind a same-source anchor test.
6
- *
7
- * ⚠️ 拆分纪律:这里只放**纯**件(常量/纯函数/字面量类型)。zod schema 留在 `api/auth.ts` /
8
- * `api/scopes.ts`(它们 re-export 本文件 ⇒ 既有导入面字节兼容,谁都不用改)。给本文件加东西前
9
- * 自问:它 import 了任何东西吗?——答案必须是 no(test/wire-purity 打包门盯着)。
10
- */
11
- /** The five auth endpoints, relative to the registry origin. */
12
- export declare const AUTH_V1_PATHS: {
13
- readonly deviceCode: "/api/v1/auth/device/code";
14
- readonly deviceToken: "/api/v1/auth/device/token";
15
- readonly deviceApprove: "/api/v1/auth/device/approve";
16
- readonly tokenRefresh: "/api/v1/auth/token/refresh";
17
- readonly logout: "/api/v1/auth/logout";
18
- };
19
- /** The RFC 8628 grant_type the device token endpoint requires. */
20
- export declare const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
21
- /** Minimum seconds between token-endpoint polls (RFC 8628 `interval`); polling faster → `slow_down`. */
22
- export declare const DEVICE_POLL_INTERVAL_SECONDS = 5;
23
- /** Device-code handshake lifetime (seconds) — the user has 15 minutes to open /activate and approve. */
24
- export declare const DEVICE_CODE_TTL_SECONDS: number;
25
- /** Access-token (RS256 JWT) lifetime in seconds — 1h, re-minted via refresh. */
26
- export declare const ACCESS_TOKEN_TTL_SECONDS: number;
27
- /** Refresh-grant lifetime (seconds) — 30d SLIDING: every rotation opens a fresh 30d window. */
28
- export declare const REFRESH_TOKEN_TTL_SECONDS: number;
29
- /** Every error code the /api/v1/auth/* endpoints answer (HTTP 400 unless noted). */
30
- export declare const OAUTH_ERROR_CODES: readonly ["authorization_pending", "slow_down", "expired_token", "access_denied", "invalid_request", "unsupported_grant_type", "invalid_grant", "server_error"];
31
- export type OAuthErrorCode = (typeof OAUTH_ERROR_CODES)[number];
32
- /** Handshake states a consent-screen lookup can see. (`approved` rows vanish once exchanged/consumed.)
33
- * `denied` is contract-reserved for an explicit deny button (pairs with the `access_denied` poll error);
34
- * the shipped M1 store carries pending|approved only — adding deny later is implementation, not schema. */
35
- export declare const DEVICE_AUTH_STATUSES: readonly ["pending", "approved", "denied"];
36
- export type DeviceAuthStatus = (typeof DEVICE_AUTH_STATUSES)[number];
37
- /**
38
- * Canonicalize a human-typed user code to the wire shape "XXXX-XXXX": uppercase, dashes/spaces optional.
39
- * null = not a plausible code (wrong length/charset after stripping separators). Same normalization the
40
- * server applies — run it client-side for instant feedback.
41
- */
42
- export declare function normalizeUserCode(input: unknown): string | null;
43
- /**
44
- * The RFC 8628 §3.5 poll-loop step: what interval to poll with next, and whether to keep going.
45
- * - authorization_pending → keep polling at the current interval
46
- * - slow_down → keep polling, interval + 5s (the RFC-mandated increment)
47
- * - anything else → stop (expired_token/access_denied = terminal; invalid_* = client bug)
48
- */
49
- export declare function nextPollInterval(currentIntervalSeconds: number, error: OAuthErrorCode): {
50
- continue: boolean;
51
- intervalSeconds: number;
52
- };
53
- export declare const SCOPES_V1_PATHS: {
54
- /** GET (list) + POST (create). */
55
- readonly scopes: "/api/v1/scopes";
56
- /** POST — mint a new access token bound to another scope. */
57
- readonly authScope: "/api/v1/auth/scope";
58
- };
59
- /** The JWT claim carrying the token's active scope. OPTIONAL — absent means GLOBAL_SCOPE (tokenScopeOf). */
60
- export declare const SCOPE_CLAIM = "scope";
package/dist/api/wire.js DELETED
@@ -1,89 +0,0 @@
1
- /**
2
- * `api/wire` — the ZERO-DEPENDENCY wire subset of the auth/scopes contracts (server AI 接手首车,
3
- * 2026-07-27,跨仓 candidate 落地):endpoint paths, protocol constants and PURE helper functions,
4
- * with **no zod import** — so a zero-runtime-dependency client (e.g. `@sema-agent/sdk/registry`) can
5
- * import these at RUNTIME instead of value-copying them behind a same-source anchor test.
6
- *
7
- * ⚠️ 拆分纪律:这里只放**纯**件(常量/纯函数/字面量类型)。zod schema 留在 `api/auth.ts` /
8
- * `api/scopes.ts`(它们 re-export 本文件 ⇒ 既有导入面字节兼容,谁都不用改)。给本文件加东西前
9
- * 自问:它 import 了任何东西吗?——答案必须是 no(test/wire-purity 打包门盯着)。
10
- */
11
- // ── auth: endpoint paths + protocol constants(api/auth.ts 原件,shipped values 冻结)─────────────────
12
- /** The five auth endpoints, relative to the registry origin. */
13
- export const AUTH_V1_PATHS = {
14
- deviceCode: "/api/v1/auth/device/code",
15
- deviceToken: "/api/v1/auth/device/token",
16
- deviceApprove: "/api/v1/auth/device/approve",
17
- tokenRefresh: "/api/v1/auth/token/refresh",
18
- logout: "/api/v1/auth/logout",
19
- };
20
- /** The RFC 8628 grant_type the device token endpoint requires. */
21
- export const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
22
- /** Minimum seconds between token-endpoint polls (RFC 8628 `interval`); polling faster → `slow_down`. */
23
- export const DEVICE_POLL_INTERVAL_SECONDS = 5;
24
- /** Device-code handshake lifetime (seconds) — the user has 15 minutes to open /activate and approve. */
25
- export const DEVICE_CODE_TTL_SECONDS = 15 * 60;
26
- /** Access-token (RS256 JWT) lifetime in seconds — 1h, re-minted via refresh. */
27
- export const ACCESS_TOKEN_TTL_SECONDS = 60 * 60;
28
- /** Refresh-grant lifetime (seconds) — 30d SLIDING: every rotation opens a fresh 30d window. */
29
- export const REFRESH_TOKEN_TTL_SECONDS = 30 * 24 * 60 * 60;
30
- /** Every error code the /api/v1/auth/* endpoints answer (HTTP 400 unless noted). */
31
- export const OAUTH_ERROR_CODES = [
32
- /** device/token: the user has not approved (or denied) the handshake yet — keep polling. */
33
- "authorization_pending",
34
- /** device/token: polling faster than `interval` — RFC 8628 §3.5: ADD 5 seconds to the interval. */
35
- "slow_down",
36
- /** device/token: handshake expired, unknown, or already exchanged — restart the flow.
37
- * (Deliberately covers "never existed": the server does not disclose handshake existence.) */
38
- "expired_token",
39
- /** device/token: the user explicitly denied the handshake — stop polling, do not restart silently. */
40
- "access_denied",
41
- /** any endpoint: malformed body / missing required field / wrong content type. */
42
- "invalid_request",
43
- /** device/token: grant_type is not DEVICE_GRANT_TYPE. */
44
- "unsupported_grant_type",
45
- /** token/refresh + device/approve: unknown / expired / revoked / replayed token or code — no detail. */
46
- "invalid_grant",
47
- /** SSO not configured on the registry (HTTP 503) — a deployment problem, not a client one. */
48
- "server_error",
49
- ];
50
- /** Handshake states a consent-screen lookup can see. (`approved` rows vanish once exchanged/consumed.)
51
- * `denied` is contract-reserved for an explicit deny button (pairs with the `access_denied` poll error);
52
- * the shipped M1 store carries pending|approved only — adding deny later is implementation, not schema. */
53
- export const DEVICE_AUTH_STATUSES = ["pending", "approved", "denied"];
54
- // ── auth: pure client-side helpers(api/auth.ts 原件)────────────────────────────────────────────────────
55
- /**
56
- * Canonicalize a human-typed user code to the wire shape "XXXX-XXXX": uppercase, dashes/spaces optional.
57
- * null = not a plausible code (wrong length/charset after stripping separators). Same normalization the
58
- * server applies — run it client-side for instant feedback.
59
- */
60
- export function normalizeUserCode(input) {
61
- if (typeof input !== "string")
62
- return null;
63
- const raw = input.toUpperCase().replace(/[\s-]/g, "");
64
- if (!/^[A-Z0-9]{8}$/.test(raw))
65
- return null;
66
- return `${raw.slice(0, 4)}-${raw.slice(4)}`;
67
- }
68
- /**
69
- * The RFC 8628 §3.5 poll-loop step: what interval to poll with next, and whether to keep going.
70
- * - authorization_pending → keep polling at the current interval
71
- * - slow_down → keep polling, interval + 5s (the RFC-mandated increment)
72
- * - anything else → stop (expired_token/access_denied = terminal; invalid_* = client bug)
73
- */
74
- export function nextPollInterval(currentIntervalSeconds, error) {
75
- if (error === "authorization_pending")
76
- return { continue: true, intervalSeconds: currentIntervalSeconds };
77
- if (error === "slow_down")
78
- return { continue: true, intervalSeconds: currentIntervalSeconds + 5 };
79
- return { continue: false, intervalSeconds: currentIntervalSeconds };
80
- }
81
- // ── scopes: endpoint paths + claim(api/scopes.ts 原件)─────────────────────────────────────────────────
82
- export const SCOPES_V1_PATHS = {
83
- /** GET (list) + POST (create). */
84
- scopes: "/api/v1/scopes",
85
- /** POST — mint a new access token bound to another scope. */
86
- authScope: "/api/v1/auth/scope",
87
- };
88
- /** The JWT claim carrying the token's active scope. OPTIONAL — absent means GLOBAL_SCOPE (tokenScopeOf). */
89
- export const SCOPE_CLAIM = "scope";