@sema-agent/mods-kernel 7.60.0 → 7.62.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/dist/dispatch.d.ts +2 -2
- package/dist/dispatch.js +4 -4
- package/dist/events.d.ts +4 -1
- package/dist/events.js +18 -15
- package/dist/registration.d.ts +1 -0
- package/dist/registration.js +5 -0
- package/dist/site-rules.d.ts +2 -1
- package/dist/site-rules.js +10 -2
- package/package.json +2 -2
package/dist/dispatch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ModBusSide, type ModEventName, type ModSeat } from "./events.js";
|
|
2
2
|
import { type ModAdmissionRecord, type ModDollarBase, type ModOrigin, type ModSeats } from "./registration.js";
|
|
3
|
-
import { type ModAnswerCheck, type ModAnswerRanks, type ModEventPayload, type ModFailureCause, type ModMatcher, type ModSkip, type ProxyProbe } from "./site-rules.js";
|
|
3
|
+
import { type ModAnswerCheck, type ModAnswerer, type ModAnswerRanks, type ModEventPayload, type ModFailureCause, type ModMatcher, type ModSkip, type ProxyProbe } from "./site-rules.js";
|
|
4
4
|
export type ModFrame = {
|
|
5
5
|
readonly kind: "dollar";
|
|
6
6
|
readonly plugin: string;
|
|
@@ -49,7 +49,7 @@ export interface ModDispatchOptions {
|
|
|
49
49
|
readonly frames?: readonly ModFrame[];
|
|
50
50
|
readonly origin?: ModOrigin;
|
|
51
51
|
readonly checkAnswer?: ModAnswerCheck;
|
|
52
|
-
readonly checkHandOn?: (payload: ModEventPayload) => string | undefined;
|
|
52
|
+
readonly checkHandOn?: (payload: ModEventPayload, by: ModAnswerer) => string | undefined;
|
|
53
53
|
readonly ranks?: ModAnswerRanks;
|
|
54
54
|
readonly participant?: (p: ModParticipant) => boolean;
|
|
55
55
|
}
|
package/dist/dispatch.js
CHANGED
|
@@ -371,13 +371,13 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
371
371
|
let found;
|
|
372
372
|
return () => (found ??= sealedObjects([e0]));
|
|
373
373
|
})();
|
|
374
|
-
const handOn = (passed) => {
|
|
374
|
+
const handOn = (passed, h) => {
|
|
375
375
|
if (passed === e0)
|
|
376
376
|
return { snap: e0 };
|
|
377
377
|
const handed = handedOn(st.pinned, e0, passed, engines(), isProxy);
|
|
378
378
|
if ("violation" in handed)
|
|
379
379
|
return handed;
|
|
380
|
-
const why = handOnViolation(handed.payload, options.checkHandOn);
|
|
380
|
+
const why = handOnViolation(handed.payload, options.checkHandOn, answererOf(h));
|
|
381
381
|
return why !== undefined ? { violation: why } : { snap: handed.payload };
|
|
382
382
|
};
|
|
383
383
|
const trustFloors = new Map();
|
|
@@ -516,7 +516,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
516
516
|
state.violated ??= "next() already called (a handler calls next once; its first run's answer stands)";
|
|
517
517
|
return Promise.reject(new Error(`${name}: next() already called`));
|
|
518
518
|
}
|
|
519
|
-
const handed = handOn(passed);
|
|
519
|
+
const handed = handOn(passed, h);
|
|
520
520
|
if ("violation" in handed) {
|
|
521
521
|
state.violated ??= handed.violation;
|
|
522
522
|
return Promise.reject(new Error(`${name}: ${state.violated}`));
|
|
@@ -634,7 +634,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
634
634
|
running.then(resume, resume);
|
|
635
635
|
return running;
|
|
636
636
|
}
|
|
637
|
-
const handed = handOn(passed);
|
|
637
|
+
const handed = handOn(passed, h);
|
|
638
638
|
if ("violation" in handed) {
|
|
639
639
|
violated ??= handed.violation;
|
|
640
640
|
return Promise.reject(new Error(`${h.reg.name}: ${violated}`));
|
package/dist/events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const KERNEL_CONTRACT_VERSION =
|
|
1
|
+
export declare const KERNEL_CONTRACT_VERSION = 8;
|
|
2
2
|
export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
|
|
3
3
|
export type ModTier = (typeof MOD_TIERS)[number];
|
|
4
4
|
export type ModRegistrationTier = Exclude<ModTier, "builtin" | "core">;
|
|
@@ -97,6 +97,7 @@ export declare const MOD_EVENT_TABLE: Readonly<{
|
|
|
97
97
|
"prompt.fill": ModEventRow;
|
|
98
98
|
"prompt.suggest": ModEventRow;
|
|
99
99
|
"prompt.edit": ModEventRow;
|
|
100
|
+
"prompt.change": ModEventRow;
|
|
100
101
|
"prompt.autocomplete": ModEventRow;
|
|
101
102
|
"prompt.section": ModEventRow;
|
|
102
103
|
"prompt.context": ModEventRow;
|
|
@@ -146,6 +147,7 @@ export declare const MOD_EVENT_TABLE: Readonly<{
|
|
|
146
147
|
"session.surface": ModEventRow;
|
|
147
148
|
"session.surfaces": ModEventRow;
|
|
148
149
|
"session.authorize": ModEventRow;
|
|
150
|
+
"session.identity": ModEventRow;
|
|
149
151
|
"session.usage": ModEventRow;
|
|
150
152
|
"session.version": ModEventRow;
|
|
151
153
|
"turn.abort": ModEventRow;
|
|
@@ -168,6 +170,7 @@ export declare const MOD_EVENT_TABLE: Readonly<{
|
|
|
168
170
|
"ui.panes": ModEventRow;
|
|
169
171
|
"ui.selection": ModEventRow;
|
|
170
172
|
"ui.copy": ModEventRow;
|
|
173
|
+
"ui.view": ModEventRow;
|
|
171
174
|
"ui.notify": ModEventRow;
|
|
172
175
|
"ui.blit": ModEventRow;
|
|
173
176
|
"fs.read": ModEventRow;
|
package/dist/events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const KERNEL_CONTRACT_VERSION =
|
|
1
|
+
export const KERNEL_CONTRACT_VERSION = 8;
|
|
2
2
|
export const MOD_TIERS = Object.freeze(["prepend", "user", "append", "builtin", "core"]);
|
|
3
3
|
export const MOD_SEATS = Object.freeze(["deployment", "task"]);
|
|
4
4
|
export const MOD_EVENT_SIDES = Object.freeze(["engine", "surface", "both"]);
|
|
@@ -55,8 +55,8 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
55
55
|
"classic.Notification": engine(),
|
|
56
56
|
"classic.UserPromptSubmit": engine(station("refuse", "immediate", ["source", "inputId", "actor", "prompt"])),
|
|
57
57
|
"classic.UserPromptExpansion": engine(),
|
|
58
|
-
"classic.SessionStart": engine(),
|
|
59
|
-
"classic.SessionEnd": engine(),
|
|
58
|
+
"classic.SessionStart": engine(station("skip", "grace")),
|
|
59
|
+
"classic.SessionEnd": engine(station("skip", "grace")),
|
|
60
60
|
"classic.Stop": engine(station("skip", "immediate")),
|
|
61
61
|
"classic.StopFailure": engine(station("skip", "grace")),
|
|
62
62
|
"classic.SubagentStart": engine(station("skip", "immediate", ["agentId", "agentType"])),
|
|
@@ -93,11 +93,12 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
93
93
|
"ui.scroll": surface(station("skip", "grace", ["component", "requestId", "by", "bodyRows", "contentRows", "origin", "pointer"], { call: true })),
|
|
94
94
|
"ui.focus": surface(station("skip", "grace", ["component", "requestId", "plugin", "origin", "element"], { call: true })),
|
|
95
95
|
"agent.offer": engine(station("skip", "grace", ["agent", "provider"])),
|
|
96
|
-
"agent.spawn": engine(station("refuse_until_run", "immediate", AGENT_SPAWN_PINNED)),
|
|
97
|
-
"prompt.submit": engine(),
|
|
96
|
+
"agent.spawn": engine(station("refuse_until_run", "immediate", AGENT_SPAWN_PINNED, { call: true })),
|
|
97
|
+
"prompt.submit": engine(station("refuse", "immediate", ["source", "inputId", "actor"])),
|
|
98
98
|
"prompt.fill": surface(station("skip", "grace", ["origin", "mode"], { call: true })),
|
|
99
99
|
"prompt.suggest": surface(station("skip", "grace", ["origin"], { call: true })),
|
|
100
100
|
"prompt.edit": surface(station("skip", "grace", ["origin", "key"], { budgetMs: PROMPT_EDIT_BUDGET_MS })),
|
|
101
|
+
"prompt.change": surface(),
|
|
101
102
|
"prompt.autocomplete": surface(),
|
|
102
103
|
"prompt.section": engine(station("skip", "grace", ["name", "key", "mountedTools"])),
|
|
103
104
|
"prompt.context": engine(),
|
|
@@ -113,17 +114,17 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
113
114
|
"telemetry.mark": engine(),
|
|
114
115
|
"skill.prompt": engine(),
|
|
115
116
|
"attribution.text": engine(),
|
|
116
|
-
"session.start": engine(),
|
|
117
|
-
"session.receive": engine(),
|
|
118
|
-
"session.append": engine(),
|
|
119
|
-
"session.send": engine(),
|
|
120
|
-
"session.compact": engine(),
|
|
117
|
+
"session.start": engine(station("skip", "grace", ["cwd", "sessionId", "agentId"])),
|
|
118
|
+
"session.receive": engine(station("refuse", "immediate", ["origin", "event", "agentId"])),
|
|
119
|
+
"session.append": engine(station("skip", "grace", ["door", "origin", "agentId"], { call: true })),
|
|
120
|
+
"session.send": engine(station("refuse_until_run", "immediate", ["origin", "agentId", "to", "text"], { call: true })),
|
|
121
|
+
"session.compact": engine(station("refuse_until_run", "immediate", ["trigger", "agentId", "instructions"], { call: true })),
|
|
121
122
|
"session.attach": engine(),
|
|
122
123
|
"session.detach": engine(),
|
|
123
|
-
"session.measure": engine(),
|
|
124
|
+
"session.measure": engine(station("skip", "grace", ["context", "changed", "agentId"])),
|
|
124
125
|
"session.end": engine(station("skip", "grace", ["reason", "sessionId", "agentId"])),
|
|
125
126
|
"plugin.register": Object.freeze({ side: "both", station: station("refuse", "immediate", ["name", "seat", "tier", "uses"]) }),
|
|
126
|
-
"turn.start": engine(),
|
|
127
|
+
"turn.start": engine(station("skip", "grace", ["turn", "agentId"])),
|
|
127
128
|
"turn.step": engine(),
|
|
128
129
|
"turn.complete": engine(station("skip", "grace", ["answer", "agentId", "turn"])),
|
|
129
130
|
"engine.create": engine(),
|
|
@@ -137,15 +138,16 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
137
138
|
"session.cwd": engine(method(true)),
|
|
138
139
|
"session.root": engine(method(true)),
|
|
139
140
|
"session.model": engine(method(true)),
|
|
140
|
-
"session.turns": engine(),
|
|
141
|
+
"session.turns": engine(method(true)),
|
|
141
142
|
"session.id": engine(method(true)),
|
|
142
143
|
"session.messages": engine(method(true)),
|
|
143
144
|
"session.repo": engine(),
|
|
144
145
|
"session.surface": engine(),
|
|
145
146
|
"session.surfaces": engine(),
|
|
146
147
|
"session.authorize": engine(),
|
|
147
|
-
"session.
|
|
148
|
-
"session.
|
|
148
|
+
"session.identity": engine(),
|
|
149
|
+
"session.usage": engine(method(true)),
|
|
150
|
+
"session.version": engine(method(true)),
|
|
149
151
|
"turn.abort": engine(),
|
|
150
152
|
"prompt.read": surface(method(true)),
|
|
151
153
|
"flag.value": engine(),
|
|
@@ -166,6 +168,7 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
166
168
|
"ui.panes": surface(),
|
|
167
169
|
"ui.selection": surface(method(true)),
|
|
168
170
|
"ui.copy": surface(method(true)),
|
|
171
|
+
"ui.view": surface(),
|
|
169
172
|
"ui.notify": surface(),
|
|
170
173
|
"ui.blit": surface(),
|
|
171
174
|
"fs.read": engine(),
|
package/dist/registration.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface ModOrigin {
|
|
|
12
12
|
readonly tier: ModTier;
|
|
13
13
|
}
|
|
14
14
|
export declare const ENGINE_ORIGIN: ModOrigin;
|
|
15
|
+
export declare const MOD_REGISTRATION_NAME: RegExp;
|
|
15
16
|
export declare function namedRegistration(registration: string | undefined): string | undefined;
|
|
16
17
|
export interface ModPluginFacts {
|
|
17
18
|
readonly name: string;
|
package/dist/registration.js
CHANGED
|
@@ -3,6 +3,7 @@ import { resolveModBudgetMs } from "./budget.js";
|
|
|
3
3
|
export const MODS_INVALID_CODE = "config.mods_invalid";
|
|
4
4
|
export const MODS_REGISTRATION_REFUSED_CODE = "mods.registration_refused";
|
|
5
5
|
export const ENGINE_ORIGIN = Object.freeze({ plugin: "engine", tier: "core" });
|
|
6
|
+
export const MOD_REGISTRATION_NAME = /^[A-Za-z0-9._:-]{1,64}$/;
|
|
6
7
|
export function namedRegistration(registration) {
|
|
7
8
|
return registration === undefined || registration === ENGINE_ORIGIN.plugin ? undefined : registration;
|
|
8
9
|
}
|
|
@@ -37,8 +38,12 @@ function screenOne(item, seat, side, report) {
|
|
|
37
38
|
if (!isRegistration(item))
|
|
38
39
|
throw modsInvalid(`a ${seat} mods entry is ${describe(item)}; a registration has a name and a register function`);
|
|
39
40
|
const name = item.name;
|
|
41
|
+
if (typeof name !== "string")
|
|
42
|
+
throw modsInvalid(`a ${seat} registration's name is ${describe(name)}; a registration name is a string`);
|
|
40
43
|
if (name === "")
|
|
41
44
|
throw modsInvalid(`a ${seat} registration has an empty name`);
|
|
45
|
+
if (!MOD_REGISTRATION_NAME.test(name))
|
|
46
|
+
throw modsInvalid(`a ${seat} registration's name (${name.length} characters) is outside the form of a registration name — 1 to 64 of letters, digits, ".", "_", ":" and "-"`);
|
|
42
47
|
if (name === ENGINE_ORIGIN.plugin)
|
|
43
48
|
throw modsInvalid(`a ${seat} registration is named "${name}", the engine's own origin word — choose another name`);
|
|
44
49
|
const tier = tierOf(item.tier, seat, name);
|
package/dist/site-rules.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface PinnedKeyBreak {
|
|
|
32
32
|
readonly unproven?: string;
|
|
33
33
|
}
|
|
34
34
|
export declare function pinnedKeyChanged(pinned: readonly string[], received: ModEventPayload, passed: ModEventPayload): PinnedKeyBreak | undefined;
|
|
35
|
+
export declare function sameModData(a: unknown, b: unknown): boolean;
|
|
35
36
|
export declare function engineObjectsOnce(held: ModEventPayload): () => ReadonlySet<object>;
|
|
36
37
|
export declare function handedOn(pinned: readonly string[], held: ModEventPayload, passed: unknown, engines: ReadonlySet<object>, isProxy?: ProxyProbe): {
|
|
37
38
|
readonly payload: ModEventPayload;
|
|
@@ -44,7 +45,7 @@ export declare function pinnedHandOn(pinned: readonly string[], held: ModEventPa
|
|
|
44
45
|
readonly violation: string;
|
|
45
46
|
};
|
|
46
47
|
export declare function answerViolation(answer: unknown, check: ModAnswerCheck | undefined, e: ModEventPayload, by: ModAnswerer, below: readonly unknown[], run: ModDispatchRun): string | undefined;
|
|
47
|
-
export declare function handOnViolation(payload: ModEventPayload, check: ((payload: ModEventPayload) => string | undefined) | undefined): string | undefined;
|
|
48
|
+
export declare function handOnViolation(payload: ModEventPayload, check: ((payload: ModEventPayload, by: ModAnswerer) => string | undefined) | undefined, by: ModAnswerer): string | undefined;
|
|
48
49
|
export declare function methodAnswerViolation(answer: unknown, _e?: ModEventPayload, _by?: ModAnswerer, below?: readonly unknown[]): string | undefined;
|
|
49
50
|
export declare function matcherViolation(m: unknown): string | undefined;
|
|
50
51
|
export declare function matcherMatches(m: ModMatcher | undefined, e: ModEventPayload): boolean;
|
package/dist/site-rules.js
CHANGED
|
@@ -81,6 +81,14 @@ export function pinnedKeyChanged(pinned, received, passed) {
|
|
|
81
81
|
const compared = comparePinned(pinned, received, passed);
|
|
82
82
|
return "broke" in compared ? compared.broke : undefined;
|
|
83
83
|
}
|
|
84
|
+
export function sameModData(a, b) {
|
|
85
|
+
try {
|
|
86
|
+
return sameModValue(a, b, new Map(), 1, new Map()) !== false;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
84
92
|
function comparePinned(pinned, received, passed) {
|
|
85
93
|
const paired = new Map();
|
|
86
94
|
const homes = new Map();
|
|
@@ -203,11 +211,11 @@ export function answerViolation(answer, check, e, by, below, run) {
|
|
|
203
211
|
return "returned an answer the station cannot read";
|
|
204
212
|
}
|
|
205
213
|
}
|
|
206
|
-
export function handOnViolation(payload, check) {
|
|
214
|
+
export function handOnViolation(payload, check, by) {
|
|
207
215
|
if (check === undefined)
|
|
208
216
|
return undefined;
|
|
209
217
|
try {
|
|
210
|
-
return check(payload);
|
|
218
|
+
return check(payload, by);
|
|
211
219
|
}
|
|
212
220
|
catch {
|
|
213
221
|
return "handed on an event the station cannot read";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/mods-kernel",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.62.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The sema mods kernel: one extension bus (registration, admission, chain, failure and budget law) shared by the engine and the shell. Zero dependencies.",
|
|
6
6
|
"type": "module",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc -p tsconfig.json"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "146310a6a53a10cdb03a4f42718cf7e51b0ae509"
|
|
35
35
|
}
|