@sema-agent/mods-kernel 7.67.3 → 7.68.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/dispatch.js +14 -6
- package/dist/events.d.ts +1 -1
- package/dist/events.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/registration.d.ts +3 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ contract; a removed or re-kinded export is named as breaking in the `@sema-agent
|
|
|
61
61
|
| Failure causes and site rules | `MOD_FAILURE_CAUSES` `ModFailureCause` `ModEventPayload` `ModAnswerCheck` `ModAnswerRanks` `ModDispatchRun` `ModAnswerer` `ModMatcher` `ModSkip` |
|
|
62
62
|
| Registration | `ENGINE_ORIGIN` `MODS_INVALID_CODE` `MODS_REGISTRATION_REFUSED_CODE` `MOD_TRACE_OUTCOMES` `ModTraceOutcome` `ModUses` `ModOrigin` `ModPluginFacts` `ModDollarBase` `ModTraceEntry` `ModCaughtError` `ModNext` `ModHandler` `ModHandlerOptions` `On` `ModRegistration` `ModAdmissionRecord` `ModSeats` |
|
|
63
63
|
| Typed event maps | `ModEventPair` `ModEventMap` `ModTypedNext` `ModTypedHandler` `MappedOn` |
|
|
64
|
-
| Admission and the bus | `admitMods` `ModFrame` `ModBottomContext` `ModMethodBottom` `ModMethodSeat` `ModMethodBottoms` `ModCallEntry` `ModCallEntries` `ModDispatchOutcome` `ModDispatchOptions` `ModBus` `ModMountedHandler` `ModBusInput` `ModTimer` |
|
|
64
|
+
| Admission and the bus | `admitMods` `ModFrame` `ModBottomContext` `ModMethodBottom` `ModMethodSeat` `ModMethodBottoms` `ModCallEntry` `ModCallEntries` `ModDispatchOutcome` `ModDispatchOptions` `ModParticipant` `ModBus` `ModMountedHandler` `ModBusInput` `ModTimer` |
|
|
65
65
|
|
|
66
66
|
## License
|
|
67
67
|
|
package/dist/dispatch.js
CHANGED
|
@@ -401,6 +401,9 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
401
401
|
}
|
|
402
402
|
const observers = all.filter((p) => !p.reentry && p.h.observe).map((p) => p.h);
|
|
403
403
|
const chain = all.filter((p) => !p.h.observe).map((p) => p.h);
|
|
404
|
+
const roster = chain.map(participantOf);
|
|
405
|
+
const belows = [];
|
|
406
|
+
const belowOf = (i) => (belows[i] ??= Object.freeze(roster.slice(i + 1)));
|
|
404
407
|
const reentered = new Set(all.filter((p) => p.reentry).map((p) => p.h));
|
|
405
408
|
const skipped = [];
|
|
406
409
|
const producers = new Map();
|
|
@@ -580,6 +583,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
580
583
|
origin: { value: origin, enumerable: true },
|
|
581
584
|
signal: { value: base.signal, enumerable: true },
|
|
582
585
|
trace: { get: base.trace, enumerable: true },
|
|
586
|
+
below: { value: base.below, enumerable: true },
|
|
583
587
|
budget: { get: () => base.budget.reading(), enumerable: true },
|
|
584
588
|
...(caught !== undefined ? { error: { value: caught.error, enumerable: true }, called: { value: caught.called, enumerable: true } } : {}),
|
|
585
589
|
});
|
|
@@ -630,7 +634,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
630
634
|
failure = { cause: "reentry", reason: "not run: the dispatch re-entered a frame it is part of" };
|
|
631
635
|
}
|
|
632
636
|
else {
|
|
633
|
-
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]) }, (x) => descend(x, floors), to);
|
|
637
|
+
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]), below: belowOf(i) }, (x) => descend(x, floors), to);
|
|
634
638
|
handlerP = runWithDollar(h.reg, myFrames, budget, ac.signal, engines, ($) => h.fn($, e, next));
|
|
635
639
|
try {
|
|
636
640
|
const raced = await Promise.race([handlerP, budget.expired]);
|
|
@@ -735,7 +739,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
735
739
|
};
|
|
736
740
|
const message = failure.cause === "threw" ? describe(failure.error) : failure.cause === "violation" ? failure.reason : undefined;
|
|
737
741
|
const error = Object.freeze({ kind: failure.cause, ...(message !== undefined ? { message } : {}), budget: catchMs });
|
|
738
|
-
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]) }, (x) => replay(x, floors), (x, tier) => {
|
|
742
|
+
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]), below: belowOf(i) }, (x) => replay(x, floors), (x, tier) => {
|
|
739
743
|
const why = nextToRefusal(h.reg.tier, tier);
|
|
740
744
|
return why !== undefined ? Promise.reject(new Error(`${h.reg.name}: ${why}`)) : replay(x, [...floors, { from: h.reg.tier, to: tier }]);
|
|
741
745
|
}, { error, called: state.called });
|
|
@@ -766,7 +770,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
766
770
|
const budget = createSelfBudget(budgetMs, () => ac.abort(new Error(`${name} ran past its ${budgetMs}ms budget`)));
|
|
767
771
|
const myFrames = handlerFrame(fr, name, h.index, event);
|
|
768
772
|
const refuse = () => Promise.reject(new Error(`${name}: an observe handler is not in the chain; next() is unavailable`));
|
|
769
|
-
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([]) }, refuse, refuse);
|
|
773
|
+
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([]), below: NOTHING_BELOW }, refuse, refuse);
|
|
770
774
|
const verdict = (r) => {
|
|
771
775
|
if (r === undefined)
|
|
772
776
|
return;
|
|
@@ -790,7 +794,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
790
794
|
live.add(cac);
|
|
791
795
|
const catchMs = ownMs(CATCH_BUDGET_MS);
|
|
792
796
|
const catchBudget = createSelfBudget(catchMs, () => cac.abort(new Error(`${name}: its .catch ran past its ${catchMs}ms budget`)));
|
|
793
|
-
const cnext = makeNext({ budget: catchBudget, signal: cac.signal, trace: () => Object.freeze([]) }, refuse, refuse, {
|
|
797
|
+
const cnext = makeNext({ budget: catchBudget, signal: cac.signal, trace: () => Object.freeze([]), below: NOTHING_BELOW }, refuse, refuse, {
|
|
794
798
|
error: Object.freeze({ kind: cause, ...(cause === "threw" ? { message: describe(err) } : {}), budget: catchMs }),
|
|
795
799
|
called: false,
|
|
796
800
|
});
|
|
@@ -847,13 +851,17 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
847
851
|
return bus;
|
|
848
852
|
}
|
|
849
853
|
function admits(participant, h) {
|
|
850
|
-
return participant === undefined || participant(
|
|
854
|
+
return participant === undefined || participant(participantOf(h));
|
|
851
855
|
}
|
|
856
|
+
function participantOf(h) {
|
|
857
|
+
return Object.freeze({ plugin: h.reg.name, seat: h.reg.seat, observe: h.observe });
|
|
858
|
+
}
|
|
859
|
+
const NOTHING_BELOW = Object.freeze([]);
|
|
852
860
|
function answererOf(h) {
|
|
853
861
|
return { plugin: h.reg.name, seat: h.reg.seat, tier: h.reg.tier };
|
|
854
862
|
}
|
|
855
863
|
function hasNextShape(f) {
|
|
856
|
-
return typeof f === "function" && "to" in f && "trace" in f && "budget" in f && "signal" in f && "origin" in f;
|
|
864
|
+
return typeof f === "function" && "to" in f && "trace" in f && "below" in f && "budget" in f && "signal" in f && "origin" in f;
|
|
857
865
|
}
|
|
858
866
|
function invokeNow(f) {
|
|
859
867
|
try {
|
package/dist/events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const KERNEL_CONTRACT_VERSION =
|
|
1
|
+
export declare const KERNEL_CONTRACT_VERSION = 11;
|
|
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">;
|
package/dist/events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const KERNEL_CONTRACT_VERSION =
|
|
1
|
+
export const KERNEL_CONTRACT_VERSION = 11;
|
|
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"]);
|
|
@@ -82,7 +82,7 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
82
82
|
"classic.FileChanged": engine(),
|
|
83
83
|
"classic.DirectoryAdded": engine(),
|
|
84
84
|
"classic.MessageDisplay": engine(station("skip", "immediate", ["messageId", "turn", "index", "final", "agentId"], { budgetMs: 10_000 })),
|
|
85
|
-
"tool.call": engine(station("
|
|
85
|
+
"tool.call": engine(station("refuse_until_run", "immediate", ["tool", "tool_use_id", "agentId", "input"], { call: true })),
|
|
86
86
|
"tool.check": engine(station("refuse", "immediate", ["tool", "input", "tool_use_id", "agentId", "ceiling"])),
|
|
87
87
|
"ui.render": surface(station("skip", "grace", RENDER_PINNED)),
|
|
88
88
|
"ui.resolve": surface(station("skip", "grace", ["surface", "component"])),
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAI
|
|
|
2
2
|
export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, clockMsRefusal, resolveModBudgetMs, type ModBudgetReading, } from "./budget.js";
|
|
3
3
|
export { MOD_FAILURE_CAUSES, type ModFailureCause, type ModEventPayload, type ModAnswerCheck, type ModAnswerRanks, type ModDispatchRun, type ModAnswerer, type ModMatcher, type ModSkip, } from "./site-rules.js";
|
|
4
4
|
export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES, type ModTraceOutcome, type ModUses, type ModOrigin, type ModPluginFacts, type ModDollarBase, type ModTraceEntry, type ModCaughtError, type ModNext, type ModHandler, type ModHandlerOptions, type ModEventPair, type ModEventMap, type ModTypedNext, type ModTypedHandler, type On, type MappedOn, type ModRegistration, type ModAdmissionRecord, type ModSeats, } from "./registration.js";
|
|
5
|
-
export { admitMods, type ModFrame, type ModBottomContext, type ModMethodBottom, type ModMethodSeat, type ModMethodBottoms, type ModCallEntry, type ModCallEntries, type ModDispatchOutcome, type ModDispatchOptions, type ModBus, type ModMountedHandler, type ModBusInput, type ModTimer, } from "./dispatch.js";
|
|
5
|
+
export { admitMods, type ModFrame, type ModBottomContext, type ModMethodBottom, type ModMethodSeat, type ModMethodBottoms, type ModCallEntry, type ModCallEntries, type ModDispatchOutcome, type ModDispatchOptions, type ModParticipant, type ModBus, type ModMountedHandler, type ModBusInput, type ModTimer, } from "./dispatch.js";
|
package/dist/registration.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ModBusSide, type ModEventName, type ModRegistrationTier, type ModSeat, type ModTier } from "./events.js";
|
|
2
2
|
import { type ModBudgetReading } from "./budget.js";
|
|
3
|
+
import type { ModParticipant } from "./dispatch.js";
|
|
3
4
|
import type { ModEventPayload, ModFailureCause, ModMatcher, ModSkip } from "./site-rules.js";
|
|
4
5
|
export declare const MODS_INVALID_CODE = "config.mods_invalid";
|
|
5
6
|
export declare const MODS_REGISTRATION_REFUSED_CODE = "mods.registration_refused";
|
|
@@ -40,6 +41,7 @@ export interface ModNext {
|
|
|
40
41
|
readonly origin: ModOrigin;
|
|
41
42
|
readonly signal: AbortSignal;
|
|
42
43
|
readonly trace: readonly ModTraceEntry[];
|
|
44
|
+
readonly below: readonly ModParticipant[];
|
|
43
45
|
readonly budget: ModBudgetReading;
|
|
44
46
|
readonly error?: ModCaughtError;
|
|
45
47
|
readonly called?: boolean;
|
|
@@ -62,6 +64,7 @@ export interface ModTypedNext<P extends ModEventPair> {
|
|
|
62
64
|
readonly origin: ModOrigin;
|
|
63
65
|
readonly signal: AbortSignal;
|
|
64
66
|
readonly trace: readonly ModTraceEntry[];
|
|
67
|
+
readonly below: readonly ModParticipant[];
|
|
65
68
|
readonly budget: ModBudgetReading;
|
|
66
69
|
readonly error?: ModCaughtError;
|
|
67
70
|
readonly called?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/mods-kernel",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.68.1",
|
|
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": "d1b75e444fcc96b605fb95122839fdf072afa855"
|
|
35
35
|
}
|