@sema-ai/registry-core 0.10.3
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/CHANGELOG.md +131 -0
- package/README.md +84 -0
- package/dist/api/auth-bridge.d.ts +332 -0
- package/dist/api/auth-bridge.d.ts.map +1 -0
- package/dist/api/auth-bridge.js +211 -0
- package/dist/api/auth-bridge.js.map +1 -0
- package/dist/api/auth.d.ts +258 -0
- package/dist/api/auth.d.ts.map +1 -0
- package/dist/api/auth.js +204 -0
- package/dist/api/auth.js.map +1 -0
- package/dist/api/scopes.d.ts +353 -0
- package/dist/api/scopes.d.ts.map +1 -0
- package/dist/api/scopes.js +229 -0
- package/dist/api/scopes.js.map +1 -0
- package/dist/bundle.d.ts +14 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +68 -0
- package/dist/bundle.js.map +1 -0
- package/dist/config-fns.d.ts +236 -0
- package/dist/config-fns.d.ts.map +1 -0
- package/dist/config-fns.js +272 -0
- package/dist/config-fns.js.map +1 -0
- package/dist/cross-domain.d.ts +35 -0
- package/dist/cross-domain.d.ts.map +1 -0
- package/dist/cross-domain.js +119 -0
- package/dist/cross-domain.js.map +1 -0
- package/dist/file-edit.d.ts +37 -0
- package/dist/file-edit.d.ts.map +1 -0
- package/dist/file-edit.js +126 -0
- package/dist/file-edit.js.map +1 -0
- package/dist/file-store.d.ts +39 -0
- package/dist/file-store.d.ts.map +1 -0
- package/dist/file-store.js +142 -0
- package/dist/file-store.js.map +1 -0
- package/dist/fleet.d.ts +479 -0
- package/dist/fleet.d.ts.map +1 -0
- package/dist/fleet.js +303 -0
- package/dist/fleet.js.map +1 -0
- package/dist/hash.d.ts +33 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +60 -0
- package/dist/hash.js.map +1 -0
- package/dist/hooks.d.ts +5478 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +628 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/local-load.d.ts +33 -0
- package/dist/local-load.d.ts.map +1 -0
- package/dist/local-load.js +164 -0
- package/dist/local-load.js.map +1 -0
- package/dist/migrate.d.ts +245 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +543 -0
- package/dist/migrate.js.map +1 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +12 -0
- package/dist/node.js.map +1 -0
- package/dist/reader.d.ts +19 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +2 -0
- package/dist/reader.js.map +1 -0
- package/dist/remote-exec.d.ts +275 -0
- package/dist/remote-exec.d.ts.map +1 -0
- package/dist/remote-exec.js +183 -0
- package/dist/remote-exec.js.map +1 -0
- package/dist/resolve-roster.d.ts +29 -0
- package/dist/resolve-roster.d.ts.map +1 -0
- package/dist/resolve-roster.js +105 -0
- package/dist/resolve-roster.js.map +1 -0
- package/dist/safety-merge-spec.d.ts +328 -0
- package/dist/safety-merge-spec.d.ts.map +1 -0
- package/dist/safety-merge-spec.js +65 -0
- package/dist/safety-merge-spec.js.map +1 -0
- package/dist/scheduler-store-node.d.ts +15 -0
- package/dist/scheduler-store-node.d.ts.map +1 -0
- package/dist/scheduler-store-node.js +43 -0
- package/dist/scheduler-store-node.js.map +1 -0
- package/dist/scheduler-store.d.ts +65 -0
- package/dist/scheduler-store.d.ts.map +1 -0
- package/dist/scheduler-store.js +59 -0
- package/dist/scheduler-store.js.map +1 -0
- package/dist/secret-refs.d.ts +34 -0
- package/dist/secret-refs.d.ts.map +1 -0
- package/dist/secret-refs.js +49 -0
- package/dist/secret-refs.js.map +1 -0
- package/dist/sha256.d.ts +17 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +115 -0
- package/dist/sha256.js.map +1 -0
- package/dist/skills-manifest.d.ts +13 -0
- package/dist/skills-manifest.d.ts.map +1 -0
- package/dist/skills-manifest.js +55 -0
- package/dist/skills-manifest.js.map +1 -0
- package/dist/types.d.ts +9911 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1727 -0
- package/dist/types.js.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-roster.js","sourceRoot":"","sources":["../src/resolve-roster.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,4EAA4E;AAC5E,4FAA4F;AAC5F,wEAAwE;AACxE,sBAAsB;AAEtB,sCAAsC;AACtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAyC,CAAC;AAC9G,oCAAoC;AACpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAAU,EAAE,WAAW,CAAyC,CAAC;AAEpG;;qEAEqE;AACrE,MAAM,UAAU,iBAAiB,CAAC,CAAmD;IACnF,MAAM,GAAG,GAA2C,EAAE,CAAC;IACvD,IAAI,CAAC,CAAC,YAAY;QAAE,KAAK,MAAM,IAAI,IAAI,oBAAoB;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC;IACnG,IAAI,CAAC,CAAC,UAAU;QAAE,KAAK,MAAM,IAAI,IAAI,kBAAkB;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;IAC7F,OAAO,GAAG,CAAC;AACb,CAAC;AAYD;+EAC+E;AAC/E,SAAS,SAAS,CAAmC,KAAU,EAAE,UAAyB;IACxF,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAC9B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAA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AY,CAAC,CAAC,CAAC,aAAa;QACvI,UAAU;QACV,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,eAAe;KAC5C,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC;IAC1D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #14 SAFETY MERGE-SPEC — the ONE machine-readable per-category merge/enforcement table that every settings
|
|
3
|
+
* resolver (TOC shell-adapter + TOB center/service) reads, so they never re-implement (and drift on) the merge
|
|
4
|
+
* law. This formalizes settings-core's v2-design §3 merge-spec into a published-data contract; the SEMANTIC
|
|
5
|
+
* author is settings-core, center maintains the formalized artifact here (registry-core), the axis VALUE domains
|
|
6
|
+
* are core's (@sema-ai/core SAFETY_AXIS_VOCABULARY — validated by a dev-only conformance test, never a runtime
|
|
7
|
+
* import). Each consumer keeps its OWN key→category map (client's SemaSettings KEY_CONTRACTS, center's
|
|
8
|
+
* config-field→category map); THIS file is only the shared category spec they all cite — no third copy of the law.
|
|
9
|
+
*
|
|
10
|
+
* Per-category behavior is fully determined by `mergeShape` + `minTrust` + `tighten` + `enforcement`; a resolver
|
|
11
|
+
* reads this table and has NO per-key special-casing.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
/** How values from different layers/principals combine for a category. */
|
|
15
|
+
export declare const MergeShape: z.ZodEnum<["denyFirst", "replace", "runAll", "overrideByName", "concat"]>;
|
|
16
|
+
export type MergeShape = z.infer<typeof MergeShape>;
|
|
17
|
+
/** The MINIMUM trust tier a layer/principal must have to set this category (ascending trust). */
|
|
18
|
+
export declare const MinTrust: z.ZodEnum<["local", "session", "project", "global", "managed"]>;
|
|
19
|
+
export type MinTrust = z.infer<typeof MinTrust>;
|
|
20
|
+
/** WHERE the category is enforced (STRENGTH) — MUST stay in lockstep with `EffectiveKey.enforcement` (types.ts).
|
|
21
|
+
* gate=data-plane engine, server=control-plane/TOB boundary, resolver=merger correctness, client=UI only. */
|
|
22
|
+
export declare const SpecEnforcement: z.ZodEnum<["gate", "server", "resolver", "client"]>;
|
|
23
|
+
export type SpecEnforcement = z.infer<typeof SpecEnforcement>;
|
|
24
|
+
/** Fail direction when enforcement can't be evaluated. fail-OPEN is allowed for `client` OR `resolver`
|
|
25
|
+
* enforcement on NON-secret keys (additive merges like mcpServers/rules/env); `gate`/`server`/secret → CLOSED. */
|
|
26
|
+
export declare const FailMode: z.ZodEnum<["closed", "open"]>;
|
|
27
|
+
export type FailMode = z.infer<typeof FailMode>;
|
|
28
|
+
/** The monotone tighten-only direction for a category (which way is "stricter"). `enumRank.order` lists values
|
|
29
|
+
* from LOOSEST→STRICTEST; `boolStricter.strict` is the bool value that is the tighter one; `setNarrower` = a
|
|
30
|
+
* subset is tighter; `policyDenyWins` = deny beats allow; `none` = not rank-tightenable (replace / conflict-reject). */
|
|
31
|
+
export declare const TightenRule: z.ZodDiscriminatedUnion<"rule", [z.ZodObject<{
|
|
32
|
+
rule: z.ZodLiteral<"none">;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
rule: "none";
|
|
35
|
+
}, {
|
|
36
|
+
rule: "none";
|
|
37
|
+
}>, z.ZodObject<{
|
|
38
|
+
rule: z.ZodLiteral<"policyDenyWins">;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
rule: "policyDenyWins";
|
|
41
|
+
}, {
|
|
42
|
+
rule: "policyDenyWins";
|
|
43
|
+
}>, z.ZodObject<{
|
|
44
|
+
rule: z.ZodLiteral<"setNarrower">;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
rule: "setNarrower";
|
|
47
|
+
}, {
|
|
48
|
+
rule: "setNarrower";
|
|
49
|
+
}>, z.ZodObject<{
|
|
50
|
+
rule: z.ZodLiteral<"boolStricter">;
|
|
51
|
+
strict: z.ZodBoolean;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
strict: boolean;
|
|
54
|
+
rule: "boolStricter";
|
|
55
|
+
}, {
|
|
56
|
+
strict: boolean;
|
|
57
|
+
rule: "boolStricter";
|
|
58
|
+
}>, z.ZodObject<{
|
|
59
|
+
rule: z.ZodLiteral<"enumRank">;
|
|
60
|
+
order: z.ZodArray<z.ZodString, "many">;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
rule: "enumRank";
|
|
63
|
+
order: string[];
|
|
64
|
+
}, {
|
|
65
|
+
rule: "enumRank";
|
|
66
|
+
order: string[];
|
|
67
|
+
}>]>;
|
|
68
|
+
export type TightenRule = z.infer<typeof TightenRule>;
|
|
69
|
+
export declare const MergeCategorySpec: z.ZodObject<{
|
|
70
|
+
mergeShape: z.ZodEnum<["denyFirst", "replace", "runAll", "overrideByName", "concat"]>;
|
|
71
|
+
minTrust: z.ZodEnum<["local", "session", "project", "global", "managed"]>;
|
|
72
|
+
tighten: z.ZodDiscriminatedUnion<"rule", [z.ZodObject<{
|
|
73
|
+
rule: z.ZodLiteral<"none">;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
rule: "none";
|
|
76
|
+
}, {
|
|
77
|
+
rule: "none";
|
|
78
|
+
}>, z.ZodObject<{
|
|
79
|
+
rule: z.ZodLiteral<"policyDenyWins">;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
rule: "policyDenyWins";
|
|
82
|
+
}, {
|
|
83
|
+
rule: "policyDenyWins";
|
|
84
|
+
}>, z.ZodObject<{
|
|
85
|
+
rule: z.ZodLiteral<"setNarrower">;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
rule: "setNarrower";
|
|
88
|
+
}, {
|
|
89
|
+
rule: "setNarrower";
|
|
90
|
+
}>, z.ZodObject<{
|
|
91
|
+
rule: z.ZodLiteral<"boolStricter">;
|
|
92
|
+
strict: z.ZodBoolean;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
strict: boolean;
|
|
95
|
+
rule: "boolStricter";
|
|
96
|
+
}, {
|
|
97
|
+
strict: boolean;
|
|
98
|
+
rule: "boolStricter";
|
|
99
|
+
}>, z.ZodObject<{
|
|
100
|
+
rule: z.ZodLiteral<"enumRank">;
|
|
101
|
+
order: z.ZodArray<z.ZodString, "many">;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
rule: "enumRank";
|
|
104
|
+
order: string[];
|
|
105
|
+
}, {
|
|
106
|
+
rule: "enumRank";
|
|
107
|
+
order: string[];
|
|
108
|
+
}>]>;
|
|
109
|
+
enforcement: z.ZodEnum<["gate", "server", "resolver", "client"]>;
|
|
110
|
+
fail: z.ZodEnum<["closed", "open"]>;
|
|
111
|
+
/** The compile target / seam this category lands on (free text, for traceability). */
|
|
112
|
+
seam: z.ZodString;
|
|
113
|
+
/** When the category's VALUE domain is core's, the cited `SAFETY_AXIS_VOCABULARY` dimension (conformance-checked). */
|
|
114
|
+
coreAxis: z.ZodOptional<z.ZodEnum<["toolEffect", "egress", "irreversibility", "safetyAxis", "severity", "shellGate", "permissionDecision"]>>;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
enforcement: "gate" | "server" | "resolver" | "client";
|
|
117
|
+
mergeShape: "concat" | "replace" | "denyFirst" | "runAll" | "overrideByName";
|
|
118
|
+
minTrust: "local" | "session" | "global" | "project" | "managed";
|
|
119
|
+
tighten: {
|
|
120
|
+
rule: "none";
|
|
121
|
+
} | {
|
|
122
|
+
rule: "policyDenyWins";
|
|
123
|
+
} | {
|
|
124
|
+
rule: "setNarrower";
|
|
125
|
+
} | {
|
|
126
|
+
strict: boolean;
|
|
127
|
+
rule: "boolStricter";
|
|
128
|
+
} | {
|
|
129
|
+
rule: "enumRank";
|
|
130
|
+
order: string[];
|
|
131
|
+
};
|
|
132
|
+
fail: "closed" | "open";
|
|
133
|
+
seam: string;
|
|
134
|
+
coreAxis?: "permissionDecision" | "toolEffect" | "egress" | "irreversibility" | "safetyAxis" | "severity" | "shellGate" | undefined;
|
|
135
|
+
}, {
|
|
136
|
+
enforcement: "gate" | "server" | "resolver" | "client";
|
|
137
|
+
mergeShape: "concat" | "replace" | "denyFirst" | "runAll" | "overrideByName";
|
|
138
|
+
minTrust: "local" | "session" | "global" | "project" | "managed";
|
|
139
|
+
tighten: {
|
|
140
|
+
rule: "none";
|
|
141
|
+
} | {
|
|
142
|
+
rule: "policyDenyWins";
|
|
143
|
+
} | {
|
|
144
|
+
rule: "setNarrower";
|
|
145
|
+
} | {
|
|
146
|
+
strict: boolean;
|
|
147
|
+
rule: "boolStricter";
|
|
148
|
+
} | {
|
|
149
|
+
rule: "enumRank";
|
|
150
|
+
order: string[];
|
|
151
|
+
};
|
|
152
|
+
fail: "closed" | "open";
|
|
153
|
+
seam: string;
|
|
154
|
+
coreAxis?: "permissionDecision" | "toolEffect" | "egress" | "irreversibility" | "safetyAxis" | "severity" | "shellGate" | undefined;
|
|
155
|
+
}>;
|
|
156
|
+
export type MergeCategorySpec = z.infer<typeof MergeCategorySpec>;
|
|
157
|
+
/** The category spec. Keys = the unified settings categories both seats map their concrete keys/fields into.
|
|
158
|
+
* Faithful to settings-core v2-design §3 (the semantic source of record). */
|
|
159
|
+
export declare const SAFETY_MERGE_SPEC: {
|
|
160
|
+
readonly permissions: {
|
|
161
|
+
readonly mergeShape: "denyFirst";
|
|
162
|
+
readonly minTrust: "global";
|
|
163
|
+
readonly tighten: {
|
|
164
|
+
readonly rule: "policyDenyWins";
|
|
165
|
+
};
|
|
166
|
+
readonly enforcement: "gate";
|
|
167
|
+
readonly fail: "closed";
|
|
168
|
+
readonly seam: "toolPolicy + deny-narrowing (SessionPolicyStore)";
|
|
169
|
+
readonly coreAxis: "permissionDecision";
|
|
170
|
+
};
|
|
171
|
+
readonly permissionMode: {
|
|
172
|
+
readonly mergeShape: "replace";
|
|
173
|
+
readonly minTrust: "global";
|
|
174
|
+
readonly tighten: {
|
|
175
|
+
readonly rule: "enumRank";
|
|
176
|
+
readonly order: ["bypassPermissions", "acceptEdits", "default", "plan"];
|
|
177
|
+
};
|
|
178
|
+
readonly enforcement: "gate";
|
|
179
|
+
readonly fail: "closed";
|
|
180
|
+
readonly seam: "derive → toolPolicy / onAsk / handsReadOnly (§6.4); bypass = launch-flag only + MANAGED kill-switch";
|
|
181
|
+
};
|
|
182
|
+
readonly handsReadOnly: {
|
|
183
|
+
readonly mergeShape: "replace";
|
|
184
|
+
readonly minTrust: "global";
|
|
185
|
+
readonly tighten: {
|
|
186
|
+
readonly rule: "boolStricter";
|
|
187
|
+
readonly strict: true;
|
|
188
|
+
};
|
|
189
|
+
readonly enforcement: "gate";
|
|
190
|
+
readonly fail: "closed";
|
|
191
|
+
readonly seam: "handsReadOnly";
|
|
192
|
+
};
|
|
193
|
+
readonly shellGate: {
|
|
194
|
+
readonly mergeShape: "replace";
|
|
195
|
+
readonly minTrust: "global";
|
|
196
|
+
readonly tighten: {
|
|
197
|
+
readonly rule: "enumRank";
|
|
198
|
+
readonly order: ["off", "classify", "always"];
|
|
199
|
+
};
|
|
200
|
+
readonly enforcement: "gate";
|
|
201
|
+
readonly fail: "closed";
|
|
202
|
+
readonly seam: "shellGate";
|
|
203
|
+
readonly coreAxis: "shellGate";
|
|
204
|
+
};
|
|
205
|
+
readonly approver: {
|
|
206
|
+
readonly mergeShape: "replace";
|
|
207
|
+
readonly minTrust: "global";
|
|
208
|
+
readonly tighten: {
|
|
209
|
+
readonly rule: "none";
|
|
210
|
+
};
|
|
211
|
+
readonly enforcement: "gate";
|
|
212
|
+
readonly fail: "closed";
|
|
213
|
+
readonly seam: "onAsk (conflict → reject)";
|
|
214
|
+
};
|
|
215
|
+
readonly sandboxNetwork: {
|
|
216
|
+
readonly mergeShape: "denyFirst";
|
|
217
|
+
readonly minTrust: "global";
|
|
218
|
+
readonly tighten: {
|
|
219
|
+
readonly rule: "setNarrower";
|
|
220
|
+
};
|
|
221
|
+
readonly enforcement: "gate";
|
|
222
|
+
readonly fail: "closed";
|
|
223
|
+
readonly seam: "ExecutionEnv (fs+net) + sensitive-path";
|
|
224
|
+
readonly coreAxis: "egress";
|
|
225
|
+
};
|
|
226
|
+
readonly hooks: {
|
|
227
|
+
readonly mergeShape: "runAll";
|
|
228
|
+
readonly minTrust: "project";
|
|
229
|
+
readonly tighten: {
|
|
230
|
+
readonly rule: "none";
|
|
231
|
+
};
|
|
232
|
+
readonly enforcement: "gate";
|
|
233
|
+
readonly fail: "closed";
|
|
234
|
+
readonly seam: "hooks (single source or adapter-composed)";
|
|
235
|
+
};
|
|
236
|
+
readonly mcpServers: {
|
|
237
|
+
readonly mergeShape: "overrideByName";
|
|
238
|
+
readonly minTrust: "project";
|
|
239
|
+
readonly tighten: {
|
|
240
|
+
readonly rule: "none";
|
|
241
|
+
};
|
|
242
|
+
readonly enforcement: "resolver";
|
|
243
|
+
readonly fail: "open";
|
|
244
|
+
readonly seam: "spec.mcp + allowTools";
|
|
245
|
+
};
|
|
246
|
+
readonly rulesInstructions: {
|
|
247
|
+
readonly mergeShape: "concat";
|
|
248
|
+
readonly minTrust: "project";
|
|
249
|
+
readonly tighten: {
|
|
250
|
+
readonly rule: "none";
|
|
251
|
+
};
|
|
252
|
+
readonly enforcement: "resolver";
|
|
253
|
+
readonly fail: "open";
|
|
254
|
+
readonly seam: "appendSystemPrompt / memory (GLOBAL→PROJECT→SESSION)";
|
|
255
|
+
};
|
|
256
|
+
readonly model: {
|
|
257
|
+
readonly mergeShape: "replace";
|
|
258
|
+
readonly minTrust: "session";
|
|
259
|
+
readonly tighten: {
|
|
260
|
+
readonly rule: "none";
|
|
261
|
+
};
|
|
262
|
+
readonly enforcement: "client";
|
|
263
|
+
readonly fail: "open";
|
|
264
|
+
readonly seam: "RoleSpec / TaskSpec.{model,thinking}";
|
|
265
|
+
};
|
|
266
|
+
readonly env: {
|
|
267
|
+
readonly mergeShape: "concat";
|
|
268
|
+
readonly minTrust: "project";
|
|
269
|
+
readonly tighten: {
|
|
270
|
+
readonly rule: "none";
|
|
271
|
+
};
|
|
272
|
+
readonly enforcement: "resolver";
|
|
273
|
+
readonly fail: "open";
|
|
274
|
+
readonly seam: "NodeExecutionEnv.shellEnv (later layer overrides same name)";
|
|
275
|
+
};
|
|
276
|
+
readonly envSecret: {
|
|
277
|
+
readonly mergeShape: "replace";
|
|
278
|
+
readonly minTrust: "global";
|
|
279
|
+
readonly tighten: {
|
|
280
|
+
readonly rule: "none";
|
|
281
|
+
};
|
|
282
|
+
readonly enforcement: "resolver";
|
|
283
|
+
readonly fail: "closed";
|
|
284
|
+
readonly seam: "§7 secret-ref resolution";
|
|
285
|
+
};
|
|
286
|
+
readonly memoryScopes: {
|
|
287
|
+
readonly mergeShape: "concat";
|
|
288
|
+
readonly minTrust: "global";
|
|
289
|
+
readonly tighten: {
|
|
290
|
+
readonly rule: "none";
|
|
291
|
+
};
|
|
292
|
+
readonly enforcement: "client";
|
|
293
|
+
readonly fail: "open";
|
|
294
|
+
readonly seam: "MemoryStore";
|
|
295
|
+
};
|
|
296
|
+
readonly autoCompaction: {
|
|
297
|
+
readonly mergeShape: "replace";
|
|
298
|
+
readonly minTrust: "session";
|
|
299
|
+
readonly tighten: {
|
|
300
|
+
readonly rule: "none";
|
|
301
|
+
};
|
|
302
|
+
readonly enforcement: "client";
|
|
303
|
+
readonly fail: "open";
|
|
304
|
+
readonly seam: "compaction config";
|
|
305
|
+
};
|
|
306
|
+
readonly ui: {
|
|
307
|
+
readonly mergeShape: "replace";
|
|
308
|
+
readonly minTrust: "local";
|
|
309
|
+
readonly tighten: {
|
|
310
|
+
readonly rule: "none";
|
|
311
|
+
};
|
|
312
|
+
readonly enforcement: "client";
|
|
313
|
+
readonly fail: "open";
|
|
314
|
+
readonly seam: "shell-only (theme/keybindings/statusLine) — never touches the engine";
|
|
315
|
+
};
|
|
316
|
+
readonly org: {
|
|
317
|
+
readonly mergeShape: "replace";
|
|
318
|
+
readonly minTrust: "managed";
|
|
319
|
+
readonly tighten: {
|
|
320
|
+
readonly rule: "none";
|
|
321
|
+
};
|
|
322
|
+
readonly enforcement: "server";
|
|
323
|
+
readonly fail: "closed";
|
|
324
|
+
readonly seam: "config-center → governanceBaseline (SSO/SCIM/audit/budget, TOB-only)";
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
export type SafetyMergeCategory = keyof typeof SAFETY_MERGE_SPEC;
|
|
328
|
+
//# sourceMappingURL=safety-merge-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety-merge-spec.d.ts","sourceRoot":"","sources":["../src/safety-merge-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0EAA0E;AAC1E,eAAO,MAAM,UAAU,2EAAyE,CAAC;AACjG,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,iGAAiG;AACjG,eAAO,MAAM,QAAQ,iEAA+D,CAAC;AACrF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;8GAC8G;AAC9G,eAAO,MAAM,eAAe,qDAAmD,CAAC;AAChF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D;mHACmH;AACnH,eAAO,MAAM,QAAQ,+BAA6B,CAAC;AACnD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD;;yHAEyH;AACzH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAM5B,sFAAsF;;IAEtF,sHAAsH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEtH,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE;8EAC8E;AAC9E,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBwB,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #14 SAFETY MERGE-SPEC — the ONE machine-readable per-category merge/enforcement table that every settings
|
|
3
|
+
* resolver (TOC shell-adapter + TOB center/service) reads, so they never re-implement (and drift on) the merge
|
|
4
|
+
* law. This formalizes settings-core's v2-design §3 merge-spec into a published-data contract; the SEMANTIC
|
|
5
|
+
* author is settings-core, center maintains the formalized artifact here (registry-core), the axis VALUE domains
|
|
6
|
+
* are core's (@sema-ai/core SAFETY_AXIS_VOCABULARY — validated by a dev-only conformance test, never a runtime
|
|
7
|
+
* import). Each consumer keeps its OWN key→category map (client's SemaSettings KEY_CONTRACTS, center's
|
|
8
|
+
* config-field→category map); THIS file is only the shared category spec they all cite — no third copy of the law.
|
|
9
|
+
*
|
|
10
|
+
* Per-category behavior is fully determined by `mergeShape` + `minTrust` + `tighten` + `enforcement`; a resolver
|
|
11
|
+
* reads this table and has NO per-key special-casing.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
/** How values from different layers/principals combine for a category. */
|
|
15
|
+
export const MergeShape = z.enum(["denyFirst", "replace", "runAll", "overrideByName", "concat"]);
|
|
16
|
+
/** The MINIMUM trust tier a layer/principal must have to set this category (ascending trust). */
|
|
17
|
+
export const MinTrust = z.enum(["local", "session", "project", "global", "managed"]);
|
|
18
|
+
/** WHERE the category is enforced (STRENGTH) — MUST stay in lockstep with `EffectiveKey.enforcement` (types.ts).
|
|
19
|
+
* gate=data-plane engine, server=control-plane/TOB boundary, resolver=merger correctness, client=UI only. */
|
|
20
|
+
export const SpecEnforcement = z.enum(["gate", "server", "resolver", "client"]);
|
|
21
|
+
/** Fail direction when enforcement can't be evaluated. fail-OPEN is allowed for `client` OR `resolver`
|
|
22
|
+
* enforcement on NON-secret keys (additive merges like mcpServers/rules/env); `gate`/`server`/secret → CLOSED. */
|
|
23
|
+
export const FailMode = z.enum(["closed", "open"]);
|
|
24
|
+
/** The monotone tighten-only direction for a category (which way is "stricter"). `enumRank.order` lists values
|
|
25
|
+
* from LOOSEST→STRICTEST; `boolStricter.strict` is the bool value that is the tighter one; `setNarrower` = a
|
|
26
|
+
* subset is tighter; `policyDenyWins` = deny beats allow; `none` = not rank-tightenable (replace / conflict-reject). */
|
|
27
|
+
export const TightenRule = z.discriminatedUnion("rule", [
|
|
28
|
+
z.object({ rule: z.literal("none") }),
|
|
29
|
+
z.object({ rule: z.literal("policyDenyWins") }),
|
|
30
|
+
z.object({ rule: z.literal("setNarrower") }),
|
|
31
|
+
z.object({ rule: z.literal("boolStricter"), strict: z.boolean() }),
|
|
32
|
+
z.object({ rule: z.literal("enumRank"), order: z.array(z.string()).min(2) }),
|
|
33
|
+
]);
|
|
34
|
+
export const MergeCategorySpec = z.object({
|
|
35
|
+
mergeShape: MergeShape,
|
|
36
|
+
minTrust: MinTrust,
|
|
37
|
+
tighten: TightenRule,
|
|
38
|
+
enforcement: SpecEnforcement,
|
|
39
|
+
fail: FailMode,
|
|
40
|
+
/** The compile target / seam this category lands on (free text, for traceability). */
|
|
41
|
+
seam: z.string(),
|
|
42
|
+
/** When the category's VALUE domain is core's, the cited `SAFETY_AXIS_VOCABULARY` dimension (conformance-checked). */
|
|
43
|
+
coreAxis: z.enum(["toolEffect", "egress", "irreversibility", "safetyAxis", "severity", "shellGate", "permissionDecision"]).optional(),
|
|
44
|
+
});
|
|
45
|
+
/** The category spec. Keys = the unified settings categories both seats map their concrete keys/fields into.
|
|
46
|
+
* Faithful to settings-core v2-design §3 (the semantic source of record). */
|
|
47
|
+
export const SAFETY_MERGE_SPEC = {
|
|
48
|
+
permissions: { mergeShape: "denyFirst", minTrust: "global", tighten: { rule: "policyDenyWins" }, enforcement: "gate", fail: "closed", seam: "toolPolicy + deny-narrowing (SessionPolicyStore)", coreAxis: "permissionDecision" },
|
|
49
|
+
permissionMode: { mergeShape: "replace", minTrust: "global", tighten: { rule: "enumRank", order: ["bypassPermissions", "acceptEdits", "default", "plan"] }, enforcement: "gate", fail: "closed", seam: "derive → toolPolicy / onAsk / handsReadOnly (§6.4); bypass = launch-flag only + MANAGED kill-switch" },
|
|
50
|
+
handsReadOnly: { mergeShape: "replace", minTrust: "global", tighten: { rule: "boolStricter", strict: true }, enforcement: "gate", fail: "closed", seam: "handsReadOnly" },
|
|
51
|
+
shellGate: { mergeShape: "replace", minTrust: "global", tighten: { rule: "enumRank", order: ["off", "classify", "always"] }, enforcement: "gate", fail: "closed", seam: "shellGate", coreAxis: "shellGate" },
|
|
52
|
+
approver: { mergeShape: "replace", minTrust: "global", tighten: { rule: "none" }, enforcement: "gate", fail: "closed", seam: "onAsk (conflict → reject)" },
|
|
53
|
+
sandboxNetwork: { mergeShape: "denyFirst", minTrust: "global", tighten: { rule: "setNarrower" }, enforcement: "gate", fail: "closed", seam: "ExecutionEnv (fs+net) + sensitive-path", coreAxis: "egress" },
|
|
54
|
+
hooks: { mergeShape: "runAll", minTrust: "project", tighten: { rule: "none" }, enforcement: "gate", fail: "closed", seam: "hooks (single source or adapter-composed)" },
|
|
55
|
+
mcpServers: { mergeShape: "overrideByName", minTrust: "project", tighten: { rule: "none" }, enforcement: "resolver", fail: "open", seam: "spec.mcp + allowTools" },
|
|
56
|
+
rulesInstructions: { mergeShape: "concat", minTrust: "project", tighten: { rule: "none" }, enforcement: "resolver", fail: "open", seam: "appendSystemPrompt / memory (GLOBAL→PROJECT→SESSION)" },
|
|
57
|
+
model: { mergeShape: "replace", minTrust: "session", tighten: { rule: "none" }, enforcement: "client", fail: "open", seam: "RoleSpec / TaskSpec.{model,thinking}" },
|
|
58
|
+
env: { mergeShape: "concat", minTrust: "project", tighten: { rule: "none" }, enforcement: "resolver", fail: "open", seam: "NodeExecutionEnv.shellEnv (later layer overrides same name)" },
|
|
59
|
+
envSecret: { mergeShape: "replace", minTrust: "global", tighten: { rule: "none" }, enforcement: "resolver", fail: "closed", seam: "§7 secret-ref resolution" },
|
|
60
|
+
memoryScopes: { mergeShape: "concat", minTrust: "global", tighten: { rule: "none" }, enforcement: "client", fail: "open", seam: "MemoryStore" },
|
|
61
|
+
autoCompaction: { mergeShape: "replace", minTrust: "session", tighten: { rule: "none" }, enforcement: "client", fail: "open", seam: "compaction config" },
|
|
62
|
+
ui: { mergeShape: "replace", minTrust: "local", tighten: { rule: "none" }, enforcement: "client", fail: "open", seam: "shell-only (theme/keybindings/statusLine) — never touches the engine" },
|
|
63
|
+
org: { mergeShape: "replace", minTrust: "managed", tighten: { rule: "none" }, enforcement: "server", fail: "closed", seam: "config-center → governanceBaseline (SSO/SCIM/audit/budget, TOB-only)" },
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=safety-merge-spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety-merge-spec.js","source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AAI,EAAE,mBAAmB,EAAE;IACzJ,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sEAAsE,EAAE;IAC9L,GAAG,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,sEAAsE,EAAE;CAC/I,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type SchedulerRecord, type SchedulerStore } from './scheduler-store.js';
|
|
2
|
+
/**
|
|
3
|
+
* Load the durable store. A MISSING file OR unreadable content ⇒ `[]` (fail-soft); the pure parser drops corrupt
|
|
4
|
+
* records and preserves well-formed ones (forward-compatible).
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadSchedulerStore(path: string): SchedulerRecord[];
|
|
7
|
+
/**
|
|
8
|
+
* Persist ATOMICALLY: `mkdir -p` the parent, write a uniquely-named `.tmp` sibling (mode 0o600 — owner-only, the
|
|
9
|
+
* records may carry principal/session identifiers), then `rename` over the target (atomic on POSIX, so a
|
|
10
|
+
* concurrent reader never sees a partial file). Throws on IO failure (caller maps to a domain error).
|
|
11
|
+
*/
|
|
12
|
+
export declare function saveSchedulerStore(path: string, records: SchedulerRecord[]): void;
|
|
13
|
+
/** A filesystem-backed {@link SchedulerStore} bound to a path (convenience for the daemon/backend constructors). */
|
|
14
|
+
export declare function fileSchedulerStore(path: string): SchedulerStore;
|
|
15
|
+
//# sourceMappingURL=scheduler-store-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-store-node.d.ts","sourceRoot":"","sources":["../src/scheduler-store-node.ts"],"names":[],"mappings":"AAWA,OAAO,EAAgD,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE9H;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,CAMlE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,CAKjF;AAED,oHAAoH;AACpH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAK/D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sema-ai/registry-core/node — the Node filesystem BINDING of the scheduler-store contract. Split out of the
|
|
3
|
+
* pure barrel (it pulls `node:fs`/`node:path`/`node:crypto`) per registry-core's browser-safe discipline. Both
|
|
4
|
+
* the server-side writer and the TOC shell daemon import THIS for the on-disk store; the FORMAT lives in the
|
|
5
|
+
* pure `./scheduler-store` contract, so there is one shape and no drift.
|
|
6
|
+
*
|
|
7
|
+
* Store path = caller-supplied; both sides agree on `SEMA_CONFIG_DIR` → `~/.sema/scheduled_tasks.json`.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdirSync, readFileSync, writeFileSync, renameSync } from 'node:fs';
|
|
10
|
+
import { dirname } from 'node:path';
|
|
11
|
+
import { randomBytes } from 'node:crypto';
|
|
12
|
+
import { parseSchedulerStore, serializeSchedulerStore } from './scheduler-store.js';
|
|
13
|
+
/**
|
|
14
|
+
* Load the durable store. A MISSING file OR unreadable content ⇒ `[]` (fail-soft); the pure parser drops corrupt
|
|
15
|
+
* records and preserves well-formed ones (forward-compatible).
|
|
16
|
+
*/
|
|
17
|
+
export function loadSchedulerStore(path) {
|
|
18
|
+
try {
|
|
19
|
+
return parseSchedulerStore(readFileSync(path, 'utf-8'));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Persist ATOMICALLY: `mkdir -p` the parent, write a uniquely-named `.tmp` sibling (mode 0o600 — owner-only, the
|
|
27
|
+
* records may carry principal/session identifiers), then `rename` over the target (atomic on POSIX, so a
|
|
28
|
+
* concurrent reader never sees a partial file). Throws on IO failure (caller maps to a domain error).
|
|
29
|
+
*/
|
|
30
|
+
export function saveSchedulerStore(path, records) {
|
|
31
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
32
|
+
const tmp = `${path}.${randomBytes(6).toString('hex')}.tmp`;
|
|
33
|
+
writeFileSync(tmp, serializeSchedulerStore(records), { mode: 0o600 });
|
|
34
|
+
renameSync(tmp, path); // atomic over the target
|
|
35
|
+
}
|
|
36
|
+
/** A filesystem-backed {@link SchedulerStore} bound to a path (convenience for the daemon/backend constructors). */
|
|
37
|
+
export function fileSchedulerStore(path) {
|
|
38
|
+
return {
|
|
39
|
+
load: () => loadSchedulerStore(path),
|
|
40
|
+
save: (records) => saveSchedulerStore(path, records),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=scheduler-store-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-store-node.js","sourceRoot":"","sources":["../src/scheduler-store-node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAA6C,MAAM,sBAAsB,CAAA;AAE9H;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,IAAI,CAAC;QACH,OAAO,mBAAmB,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,OAA0B;IACzE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,MAAM,GAAG,GAAG,GAAG,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAA;IAC3D,aAAa,CAAC,GAAG,EAAE,uBAAuB,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACrE,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA,CAAC,yBAAyB;AACjD,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO;QACL,IAAI,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACpC,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC;KACrD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sema-ai/registry-core/scheduler-store — the PURE, dep-free CONTRACT for the self-wake scheduler store
|
|
3
|
+
* (R7 自唤醒). The shared seam between the WRITER (server-side `SchedulerCapability`, persists the model's
|
|
4
|
+
* CronCreate/Sleep intents) and the READER (TOC shell `SchedulerDaemon`, fires due intents). One canonical
|
|
5
|
+
* on-disk SHAPE + parse/serialize ⇒ the two independently-built sides never drift on the format.
|
|
6
|
+
*
|
|
7
|
+
* 🔴 Contract discipline (this is a third-party contract lib, not an impl dump):
|
|
8
|
+
* - ABSTRACT: this module is the type + the parse/serialize FORMAT + the `SchedulerStore` interface. It has
|
|
9
|
+
* ZERO runtime IO and ZERO deps (no `@sema-ai/*`, no `node:*`) so it lives in the browser-safe barrel.
|
|
10
|
+
* The concrete filesystem binding is `@sema-ai/registry-core/node` (`loadSchedulerStore`/`saveSchedulerStore`).
|
|
11
|
+
* - EXTENSIBLE: `parseSchedulerStore` is FORWARD-COMPATIBLE — it validates only the required shape and
|
|
12
|
+
* PRESERVES unknown fields, so a newer writer can add fields without an older reader dropping them on
|
|
13
|
+
* round-trip. New optional `SchedulerRecord` fields are additive (no breaking change).
|
|
14
|
+
* - CONTRACTUAL: `when` is an inlined structural union kept byte-compatible with core `ScheduledIntent['when']`
|
|
15
|
+
* but NOT imported — the contract stands alone, independent of the engine.
|
|
16
|
+
*
|
|
17
|
+
* 🔴 `principal` is pinned by the writer from Runner-held ctx (never the model); persisted opaquely, passed
|
|
18
|
+
* through to `runTask` unchanged by the daemon (no privilege escalation).
|
|
19
|
+
*/
|
|
20
|
+
/** A scheduled `when` — structurally identical to core `ScheduledIntent['when']`, inlined (contract stands alone). */
|
|
21
|
+
export type SchedulerWhen = {
|
|
22
|
+
kind: 'cron';
|
|
23
|
+
expr: string;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'at';
|
|
26
|
+
atMs: number;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'delay';
|
|
29
|
+
delaySec: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A persisted scheduled record (durable across restarts). Required: id/scope/prompt/when/createdMs. Optional
|
|
33
|
+
* fields are additive — a future field is a non-breaking extension (readers preserve unknown fields on round-trip).
|
|
34
|
+
*/
|
|
35
|
+
export interface SchedulerRecord {
|
|
36
|
+
id: string;
|
|
37
|
+
scope: string;
|
|
38
|
+
/** 🔴 pinned from ctx (Runner-held), never the model; passed through to runTask unchanged. */
|
|
39
|
+
principal?: string;
|
|
40
|
+
sessionId?: string;
|
|
41
|
+
prompt: string;
|
|
42
|
+
when: SchedulerWhen;
|
|
43
|
+
label?: string;
|
|
44
|
+
createdMs: number;
|
|
45
|
+
nextRunMs?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The store ABSTRACTION the two sides depend on (writer saves, reader loads). The `@sema-ai/registry-core/node`
|
|
49
|
+
* file binding implements it; a server with a DB backend could implement it differently against the same shape.
|
|
50
|
+
*/
|
|
51
|
+
export interface SchedulerStore {
|
|
52
|
+
load(): SchedulerRecord[];
|
|
53
|
+
save(records: SchedulerRecord[]): void;
|
|
54
|
+
}
|
|
55
|
+
/** Structural validation of one record (required fields + a well-formed `when`). Unknown fields are allowed. */
|
|
56
|
+
export declare function isSchedulerRecord(v: unknown): v is SchedulerRecord;
|
|
57
|
+
/**
|
|
58
|
+
* Parse the durable store from its serialized form. FAIL-SOFT + FORWARD-COMPATIBLE: corrupt/non-array/non-JSON
|
|
59
|
+
* ⇒ `[]`; malformed individual records are dropped (the store self-heals on next save); well-formed records keep
|
|
60
|
+
* ALL their fields (incl. unknown future ones) so a newer writer's data survives an older reader's round-trip.
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseSchedulerStore(text: string): SchedulerRecord[];
|
|
63
|
+
/** Serialize the store to its canonical on-disk form (stable, pretty JSON). The WRITE half of the format contract. */
|
|
64
|
+
export declare function serializeSchedulerStore(records: SchedulerRecord[]): string;
|
|
65
|
+
//# sourceMappingURL=scheduler-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-store.d.ts","sourceRoot":"","sources":["../src/scheduler-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,sHAAsH;AACtH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvC;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,8FAA8F;IAC9F,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,IAAI,eAAe,EAAE,CAAA;IACzB,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,CAAA;CACvC;AAED,gHAAgH;AAChH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,eAAe,CAUlE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,CASnE;AAED,sHAAsH;AACtH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,CAE1E"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @sema-ai/registry-core/scheduler-store — the PURE, dep-free CONTRACT for the self-wake scheduler store
|
|
3
|
+
* (R7 自唤醒). The shared seam between the WRITER (server-side `SchedulerCapability`, persists the model's
|
|
4
|
+
* CronCreate/Sleep intents) and the READER (TOC shell `SchedulerDaemon`, fires due intents). One canonical
|
|
5
|
+
* on-disk SHAPE + parse/serialize ⇒ the two independently-built sides never drift on the format.
|
|
6
|
+
*
|
|
7
|
+
* 🔴 Contract discipline (this is a third-party contract lib, not an impl dump):
|
|
8
|
+
* - ABSTRACT: this module is the type + the parse/serialize FORMAT + the `SchedulerStore` interface. It has
|
|
9
|
+
* ZERO runtime IO and ZERO deps (no `@sema-ai/*`, no `node:*`) so it lives in the browser-safe barrel.
|
|
10
|
+
* The concrete filesystem binding is `@sema-ai/registry-core/node` (`loadSchedulerStore`/`saveSchedulerStore`).
|
|
11
|
+
* - EXTENSIBLE: `parseSchedulerStore` is FORWARD-COMPATIBLE — it validates only the required shape and
|
|
12
|
+
* PRESERVES unknown fields, so a newer writer can add fields without an older reader dropping them on
|
|
13
|
+
* round-trip. New optional `SchedulerRecord` fields are additive (no breaking change).
|
|
14
|
+
* - CONTRACTUAL: `when` is an inlined structural union kept byte-compatible with core `ScheduledIntent['when']`
|
|
15
|
+
* but NOT imported — the contract stands alone, independent of the engine.
|
|
16
|
+
*
|
|
17
|
+
* 🔴 `principal` is pinned by the writer from Runner-held ctx (never the model); persisted opaquely, passed
|
|
18
|
+
* through to `runTask` unchanged by the daemon (no privilege escalation).
|
|
19
|
+
*/
|
|
20
|
+
/** Structural validation of one record (required fields + a well-formed `when`). Unknown fields are allowed. */
|
|
21
|
+
export function isSchedulerRecord(v) {
|
|
22
|
+
if (typeof v !== 'object' || v === null)
|
|
23
|
+
return false;
|
|
24
|
+
const r = v;
|
|
25
|
+
if (typeof r.id !== 'string' || typeof r.scope !== 'string' || typeof r.prompt !== 'string' || typeof r.createdMs !== 'number')
|
|
26
|
+
return false;
|
|
27
|
+
const w = r.when;
|
|
28
|
+
if (typeof w !== 'object' || w === null)
|
|
29
|
+
return false;
|
|
30
|
+
if (w.kind === 'cron')
|
|
31
|
+
return typeof w.expr === 'string';
|
|
32
|
+
if (w.kind === 'at')
|
|
33
|
+
return typeof w.atMs === 'number';
|
|
34
|
+
if (w.kind === 'delay')
|
|
35
|
+
return typeof w.delaySec === 'number';
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parse the durable store from its serialized form. FAIL-SOFT + FORWARD-COMPATIBLE: corrupt/non-array/non-JSON
|
|
40
|
+
* ⇒ `[]`; malformed individual records are dropped (the store self-heals on next save); well-formed records keep
|
|
41
|
+
* ALL their fields (incl. unknown future ones) so a newer writer's data survives an older reader's round-trip.
|
|
42
|
+
*/
|
|
43
|
+
export function parseSchedulerStore(text) {
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = JSON.parse(text);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
if (!Array.isArray(parsed))
|
|
52
|
+
return [];
|
|
53
|
+
return parsed.filter(isSchedulerRecord);
|
|
54
|
+
}
|
|
55
|
+
/** Serialize the store to its canonical on-disk form (stable, pretty JSON). The WRITE half of the format contract. */
|
|
56
|
+
export function serializeSchedulerStore(records) {
|
|
57
|
+
return JSON.stringify(records, null, 2);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=scheduler-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler-store.js","sourceRoot":"","sources":["../src/scheduler-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAkCH,gHAAgH;AAChH,MAAM,UAAU,iBAAiB,CAAC,CAAU;IAC1C,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IACrD,MAAM,CAAC,GAAG,CAA4B,CAAA;IACtC,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC5I,MAAM,CAAC,GAAG,CAAC,CAAC,IAA2C,CAAA;IACvD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IACrD,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAA;IACxD,IAA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