@vincemakes/kiso-core 0.26.3 → 0.27.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/index.d.ts CHANGED
@@ -4,7 +4,6 @@ export * from "./tools/registry.js";
4
4
  export * from "./errors.js";
5
5
  export * from "./kernel/event-log.js";
6
6
  export * from "./kernel/hooks.js";
7
- export * from "./kernel/mode.js";
8
7
  export * from "./kernel/permission.js";
9
8
  export * from "./kernel/loop.js";
10
9
  export * from "./kernel/compaction.js";
package/dist/index.js CHANGED
@@ -4,7 +4,6 @@ export * from "./tools/registry.js";
4
4
  export * from "./errors.js";
5
5
  export * from "./kernel/event-log.js";
6
6
  export * from "./kernel/hooks.js";
7
- export * from "./kernel/mode.js";
8
7
  export * from "./kernel/permission.js";
9
8
  export * from "./kernel/loop.js";
10
9
  export * from "./kernel/compaction.js";
@@ -13,7 +13,7 @@
13
13
  * compile-time fact instead of a written rule).
14
14
  */
15
15
  import type { Event } from "../protocol/events.js";
16
- import type { Message, UserMessage } from "../protocol/messages.js";
16
+ import type { UserMessage } from "../protocol/messages.js";
17
17
  import type { ToolResult } from "../tools/tool.js";
18
18
  import type { PermissionDecision } from "./permission.js";
19
19
  export interface HookContext {
@@ -39,14 +39,6 @@ export interface HookHost {
39
39
  onPreTool?(call: ToolCallPayload, ctx: HookContext): Promise<PermissionDecision>;
40
40
  /** Execute: rewrite the result a tool returns. */
41
41
  onPostTool?(call: ToolCallPayload, result: ToolResult, ctx: HookContext): Promise<ToolResult>;
42
- /**
43
- * DEPRECATED (ADR-0044): the classic auto-compaction path is retired —
44
- * the loop never fires these (the microcompact boundary replaced it).
45
- * Kept so the extension contract type-checks; inert. Removed at 1.0.
46
- */
47
- onPreCompact?(messages: readonly Message[], ctx: HookContext): Promise<void>;
48
- /** DEPRECATED (ADR-0044): see onPreCompact — never invoked. */
49
- onPostCompact?(messages: readonly Message[], ctx: HookContext): Promise<void>;
50
42
  /** Lifecycle: the loop paused (human decision pending). */
51
43
  onPause?(reason: string, ctx: HookContext): Promise<void>;
52
44
  /** Lifecycle: the loop is about to stop. */
@@ -40,7 +40,6 @@ import type { EventInput } from "./event-log.js";
40
40
  import type { AssistantBlock, AssistantMessage, Message, ToolResultMessage } from "../protocol/messages.js";
41
41
  import { ToolRegistry } from "../tools/registry.js";
42
42
  import type { HookHost } from "./hooks.js";
43
- import type { ModeProfile } from "./mode.js";
44
43
  import { type PermissionDecision } from "./permission.js";
45
44
  export interface LoopConfig {
46
45
  readonly adapter: Adapter;
@@ -48,9 +47,6 @@ export interface LoopConfig {
48
47
  readonly systemPrompt?: string;
49
48
  readonly registry: ToolRegistry;
50
49
  readonly hooks?: HookHost;
51
- readonly modes?: readonly ModeProfile[];
52
- /** Active mode name; applies visibleToolNames structurally. */
53
- readonly mode?: string;
54
50
  readonly maxTurns?: number;
55
51
  readonly maxRetries?: number;
56
52
  /**
@@ -73,16 +69,6 @@ export interface LoopConfig {
73
69
  readonly messages?: readonly Message[];
74
70
  /** The run's event log. Pass the session's log to make this run durable. */
75
71
  readonly log?: EventLog;
76
- /**
77
- * DEPRECATED (ADR-0044): the classic auto-compaction path is retired —
78
- * the loop no longer produces `compacted` events; the microcompact
79
- * boundary (below) absorbed the responsibility. Kept so old configs
80
- * type-check; IGNORED. Old sessions' `compacted` events still replay
81
- * verbatim (the projection). Removed at 1.0.
82
- */
83
- readonly compaction?: {
84
- readonly thresholdTokens: number;
85
- };
86
72
  /**
87
73
  * C area: MICROCOMPACT — when the projected context exceeds the threshold,
88
74
  * append ONE durable `microcompacted` boundary (clearing compactable tool
@@ -112,25 +98,6 @@ export interface LoopConfig {
112
98
  * human's decision outranks the abort.
113
99
  */
114
100
  readonly approvalVerdict?: (decisionId: string) => boolean | undefined;
115
- /**
116
- * DEAD — accepted by the type, never read by this loop.
117
- *
118
- * It was the C group channel for the failed-receipt pause: the loop
119
- * persisted `uncertain_pending` and awaited a human verdict. ADR-0038
120
- * removed that pause (a complete receipt IS the outcome), and with it
121
- * every read of this field — a failure is now simply recorded failed and
122
- * the siblings run on. The runtime still passes both callbacks
123
- * (runtime/run.ts), so supplying them is harmless and changes nothing.
124
- *
125
- * The crash window — started, no receipt — is the ONLY uncertainty left,
126
- * and the runtime's recovery driver owns it (RESOLVE_UNCERTAIN in
127
- * runtime/recovery-plan.ts), not the loop. Both fields are kept because
128
- * the surface is frozen (ADR-0051); do not read them as live wiring.
129
- */
130
- readonly resolveUncertainty?: (executionId: string) => Promise<"rerun" | "abandoned">;
131
- /** DEAD, as above — the uncertainty twin of `approvalVerdict`
132
- * (round 4, adversarial). Never read by the loop since ADR-0038. */
133
- readonly uncertaintyVerdict?: (executionId: string) => "rerun" | "abandoned" | undefined;
134
101
  /**
135
102
  * E1: the COMPOSED approval chain — the runtime composes the
136
103
  * extensions' policies (deny > allow > ask, the R3 ruling) into ONE
@@ -38,7 +38,6 @@ import { EventLog } from "./event-log.js";
38
38
  import { ToolRegistry } from "../tools/registry.js";
39
39
  import { validateArgs } from "../tools/validate.js";
40
40
  import { NoOpHooks } from "./hooks.js";
41
- import { resolveModeProfile } from "./mode.js";
42
41
  import { denialResult } from "./permission.js";
43
42
  import { messagesToEvents, MICROCOMPACTABLE, DO_NOT_COMPACT, projectMessages } from "./project.js";
44
43
  /**
@@ -72,17 +71,13 @@ export async function* loop(config) {
72
71
  const maxTurns = config.maxTurns ?? DEFAULT_MAX_TURNS;
73
72
  const maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
74
73
  const signal = config.signal;
75
- const mode = resolveModeProfile(config.modes, config.mode);
76
- const registry = mode?.visibleToolNames !== undefined
77
- ? config.registry.subset(mode.visibleToolNames)
78
- : config.registry;
79
74
  // CX-1 F7b (audit F7): ONE tool table per request — captured at
80
75
  // assembly, dispatched from until the next assembly. The definition
81
76
  // the model saw, the schema the arguments are validated against, the
82
77
  // execute that runs and the effects the scheduler reads are the same
83
78
  // captured values; a live source that changes mid-request reaches the
84
79
  // NEXT request.
85
- let table = registry.snapshot();
80
+ let table = config.registry.snapshot();
86
81
  // Seed: a fresh log encodes the seed history as events so the projection
87
82
  // (and any later replay) contains it. A non-empty log (session resume)
88
83
  // is never re-seeded — the log already holds everything.
@@ -559,7 +554,7 @@ export async function* loop(config) {
559
554
  messages,
560
555
  ...(config.reasoning !== undefined ? { reasoning: config.reasoning } : {}),
561
556
  ...(config.systemPrompt !== undefined ? { systemPrompt: config.systemPrompt } : {}),
562
- tools: (table = registry.snapshot()).specs,
557
+ tools: (table = config.registry.snapshot()).specs,
563
558
  ...(config.maxTokens !== undefined ? { maxTokens: config.maxTokens } : {}),
564
559
  ...(config.temperature !== undefined ? { temperature: config.temperature } : {}),
565
560
  ...(signal !== undefined ? { signal } : {}),
@@ -7,11 +7,6 @@
7
7
  * implementation's hand-maintained agent-tool sets and its six copies of the
8
8
  * default tool list — see ADR-0001).
9
9
  *
10
- * `subset()` is the structural tool filter: a mode or a subagent gets a
11
- * registry whose tool table PHYSICALLY lacks the tools it must not see. The
12
- * model cannot call a tool that is not in its registry — no prompt can
13
- * achieve that guarantee.
14
- *
15
10
  * `registerLive()` adds a LIVE tool source — a function returning an
16
11
  * extension's CURRENT tools array. Any extension whose tool table settles
17
12
  * after load is such a source (the runtime registers every extension's
@@ -52,9 +47,6 @@ export declare class ToolRegistry {
52
47
  get(name: string): Tool<any> | undefined;
53
48
  list(): readonly Tool[];
54
49
  has(name: string): boolean;
55
- /** A registry restricted to the named tools. Unknown names are dropped
56
- * loudly (the kernel never silently shrinks a tool set). */
57
- subset(names: readonly string[]): ToolRegistry;
58
50
  /** The minimal projection an adapter may see (never the handlers). */
59
51
  toSpecs(): readonly ToolSpec[];
60
52
  }
@@ -7,11 +7,6 @@
7
7
  * implementation's hand-maintained agent-tool sets and its six copies of the
8
8
  * default tool list — see ADR-0001).
9
9
  *
10
- * `subset()` is the structural tool filter: a mode or a subagent gets a
11
- * registry whose tool table PHYSICALLY lacks the tools it must not see. The
12
- * model cannot call a tool that is not in its registry — no prompt can
13
- * achieve that guarantee.
14
- *
15
10
  * `registerLive()` adds a LIVE tool source — a function returning an
16
11
  * extension's CURRENT tools array. Any extension whose tool table settles
17
12
  * after load is such a source (the runtime registers every extension's
@@ -108,19 +103,6 @@ export class ToolRegistry {
108
103
  return true;
109
104
  return this.#live.some(({ source }) => source().some((x) => x.name === name));
110
105
  }
111
- /** A registry restricted to the named tools. Unknown names are dropped
112
- * loudly (the kernel never silently shrinks a tool set). */
113
- subset(names) {
114
- const out = new ToolRegistry();
115
- for (const name of names) {
116
- const tool = this.get(name);
117
- if (tool === undefined) {
118
- throw new Error(`subset(): unknown tool '${name}'`);
119
- }
120
- out.register(tool);
121
- }
122
- return out;
123
- }
124
106
  /** The minimal projection an adapter may see (never the handlers). */
125
107
  toSpecs() {
126
108
  return this.list().map((t) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincemakes/kiso-core",
3
- "version": "0.26.3",
3
+ "version": "0.27.0",
4
4
  "description": "kiso (foundation) core — protocol, event log, loop, hooks, modes, permissions, compaction, delivery truth. The 2,000-line kernel at the bottom of the kiso framework.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "openai"
34
34
  ],
35
35
  "devDependencies": {
36
- "@vincemakes/kiso-evals": "0.26.3",
36
+ "@vincemakes/kiso-evals": "0.27.0",
37
37
  "@types/node": "^26.1.2",
38
38
  "typescript": "^5.7.2",
39
39
  "vitest": "^3.0.0"
@@ -1,24 +0,0 @@
1
- /**
2
- * L2 — ModeProfile: a mode is a cross-layer behavior switch (mauri ADR-0011),
3
- * not a kernel feature. The kernel knows ONE mode at a time and applies it
4
- * structurally:
5
- *
6
- * - `visibleToolNames` — physical removal: the registry is subset() to these
7
- * tools BEFORE the adapter is called. The model cannot call what it cannot
8
- * see; no system-prompt overlay can make that guarantee.
9
- *
10
- * That is the whole profile. SC-1b: `systemOverlay`, `permissionDefault`,
11
- * `compactionKeepExtra`, and `stopPredicate` were REMOVED at 0.12.0 by the
12
- * SC-1 memo's adjudication — all four were declared here and read by
13
- * nothing, in the kernel or above it. Two of them ("reserved, read by the
14
- * harness when the semantics land") had been waiting since mauri ADR-0011
15
- * for semantics that never landed. A field that describes an intention
16
- * rather than a behavior is a promise the type system makes on the
17
- * kernel's behalf and the kernel does not keep; the honest profile is the
18
- * one member that is actually applied.
19
- */
20
- export interface ModeProfile {
21
- readonly name: string;
22
- readonly visibleToolNames?: readonly string[];
23
- }
24
- export declare function resolveModeProfile(modes: readonly ModeProfile[] | undefined, name: string | undefined): ModeProfile | undefined;
@@ -1,24 +0,0 @@
1
- /**
2
- * L2 — ModeProfile: a mode is a cross-layer behavior switch (mauri ADR-0011),
3
- * not a kernel feature. The kernel knows ONE mode at a time and applies it
4
- * structurally:
5
- *
6
- * - `visibleToolNames` — physical removal: the registry is subset() to these
7
- * tools BEFORE the adapter is called. The model cannot call what it cannot
8
- * see; no system-prompt overlay can make that guarantee.
9
- *
10
- * That is the whole profile. SC-1b: `systemOverlay`, `permissionDefault`,
11
- * `compactionKeepExtra`, and `stopPredicate` were REMOVED at 0.12.0 by the
12
- * SC-1 memo's adjudication — all four were declared here and read by
13
- * nothing, in the kernel or above it. Two of them ("reserved, read by the
14
- * harness when the semantics land") had been waiting since mauri ADR-0011
15
- * for semantics that never landed. A field that describes an intention
16
- * rather than a behavior is a promise the type system makes on the
17
- * kernel's behalf and the kernel does not keep; the honest profile is the
18
- * one member that is actually applied.
19
- */
20
- export function resolveModeProfile(modes, name) {
21
- if (!name || !modes)
22
- return undefined;
23
- return modes.find((m) => m.name === name);
24
- }