@deepstrike/sdk 0.2.47 → 0.2.49

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.
@@ -1,3 +1,4 @@
1
+ import type { MemoryPolicy } from "../kernel.js";
1
2
  import type { RuntimeOptions } from "../runtime/runner.js";
2
3
  import type { NudgeRule } from "./nudge.js";
3
4
  export interface InstructionProfile {
@@ -21,13 +22,44 @@ export declare function composeSystemPrompt(base: string | undefined, instructio
21
22
  * The exact `RuntimeOptions` fields a manifest may drive. Derived via `Pick` so field names and types
22
23
  * track `RuntimeOptions` verbatim; anything outside this set is rejected by `applyManifest`/`applyPatch`.
23
24
  */
24
- export type HarnessRuntimePatch = Pick<RuntimeOptions, "maxTurns" | "maxTotalTokens" | "criteriaGate" | "repeatFuse" | "entropyWatch" | "knowledgeBudgetRatio" | "skillLeaseTurns">;
25
+ export type HarnessRuntimePatch = Pick<RuntimeOptions, "maxTurns" | "maxTotalTokens" | "criteriaGate" | "repeatFuse" | "entropyWatch" | "knowledgeBudgetRatio" | "skillLeaseTurns" | "allowedToolIds" | "stableCoreToolIds" | "enablePlanTool" | "skillFilter"> & Pick<MemoryPolicy, "retrievalTopK" | "promotionRecallThreshold">;
26
+ /**
27
+ * The promotion tier of an editable surface — the SECOND axis of the safety boundary (the whitelist is
28
+ * the first). Even a whitelisted surface may need a heavier gate than "typed validation passed".
29
+ */
30
+ export type SurfaceTier = "auto" | "screened" | "human";
31
+ /**
32
+ * Map an editable surface to its promotion tier. Maintained HERE beside the whitelist so a surface can
33
+ * never be whitelisted without also being assigned a tier (the spec's same-place maintenance rule):
34
+ * - "auto" (Tier A): every `runtime.*` whitelist surface. Typed validation + the capability
35
+ * ceiling invariant + the acceptance rule already guard them, so promotion is fully
36
+ * automatic — there is no free text and no injection surface.
37
+ * - "screened" (Tier B): `instructions.*` and `nudges`. Free text can smuggle instructions
38
+ * (persistent prompt-injection laundered through the evidence loop), so a screen runs
39
+ * before promotion.
40
+ * - "human" (Tier C): reserved for capability-WIDENING surfaces. None currently exist — intersection
41
+ * semantics make widening structurally inexpressible — but the enum value exists so a new
42
+ * capability-widening surface cannot be added without consciously assigning it a tier (and
43
+ * building the human gate). `surfaceTier` therefore never returns "human" today — no
44
+ * capability-widening surface is expressible.
45
+ * An unknown surface / slot / runtime key THROWS (same discipline as applySurfaceEdit): a surface with
46
+ * no tier must never fall through to auto-promotion.
47
+ */
48
+ export declare function surfaceTier(targetSurface: string): SurfaceTier;
25
49
  export interface HarnessManifest {
26
50
  manifestVersion: 1;
27
51
  /** Parent manifest digest; `null` for a seed. */
28
52
  parent: string | null;
29
53
  /** Target-model identifier (per-model profile scenarios). */
30
54
  modelProfile?: string;
55
+ /**
56
+ * Opaque isolation key — host decides its semantics (user / tenant / agent-group). Orthogonal to
57
+ * `modelProfile` (never concatenate the two — that reprises the identity-scoping bug class); absent
58
+ * ⇒ the host treats it as `"default"`. It rides canonical JSON, so digests domain-separate by scope,
59
+ * but an absent scope leaves a pre-scope manifest's digest byte-identical (canonicalJson skips
60
+ * undefined). Becomes a lineage directory name downstream, hence the path-safe character bound.
61
+ */
62
+ scope?: string;
31
63
  instructions?: InstructionProfile;
32
64
  nudges?: NudgeRule[];
33
65
  runtime?: HarnessRuntimePatch;
@@ -40,6 +72,10 @@ export interface HarnessManifest {
40
72
  rationale?: string;
41
73
  deltaHeldIn?: number;
42
74
  deltaHeldOut?: number;
75
+ /** Promotion tier of the driving edit. */
76
+ tier?: SurfaceTier;
77
+ /** Injection-screen verdict — present only for a screened (Tier B) promotion. */
78
+ screenVerdict?: "pass" | "screened_out";
43
79
  };
44
80
  }
45
81
  export interface HarnessPatch {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Self-Harness H1.1 + H1.3 — the harness face as DATA.
2
+ * Self-Harness editable surfaces — the harness face as DATA.
3
3
  *
4
4
  * A `HarnessManifest` is a versioned, hashable lineage node: the editable surfaces a fixed model may
5
5
  * rewrite about its OWN harness — instruction slots, nudge rules, and a whitelisted `RuntimeOptions`
@@ -9,12 +9,22 @@
9
9
  *
10
10
  * The whitelist is the safety boundary: governance / quota / reliability surfaces are deliberately
11
11
  * absent, so a proposer can never rewrite them (spec design principle: conservative promotion).
12
+ *
13
+ * Tool/skill surfaces add the SECOND safety invariant (spec design principle A — the capability
14
+ * ceiling): `allowedToolIds`, `stableCoreToolIds`, and `skillFilter` fold onto the host baseline by
15
+ * INTERSECTION, never assignment. A manifest can only NARROW the tools/skills the host already
16
+ * exposes — never widen. Capability expansion (naming a tool the host does not expose) is therefore
17
+ * structurally inexpressible, and the whole security audit stays O(1): read the whitelist, check the
18
+ * one invariant. (`enablePlanTool` is exempt — it toggles a kernel-owned meta-tool, attention-shaping
19
+ * not capability-granting, so it folds by plain assignment.)
12
20
  */
13
21
  import { createHash } from "node:crypto";
14
22
  import { validateNudgeRules } from "./nudge.js";
15
23
  const INSTRUCTION_SLOTS = ["bootstrap", "execution", "verification", "failureRecovery"];
16
24
  /** Per-slot upper bound enforced at load and on every `applyPatch` set. */
17
25
  const MAX_INSTRUCTION_CHARS = 4000;
26
+ /** A scope key becomes a directory segment; restrict it to a single path-safe token (no separators). */
27
+ const SCOPE_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
18
28
  /**
19
29
  * Compose the four instruction slots onto `base` in the fixed order base → bootstrap → execution →
20
30
  * verification → failureRecovery, joined with `"\n\n"`, skipping empty slots. All-empty ⇒ `base`
@@ -32,6 +42,9 @@ export function composeSystemPrompt(base, instructions) {
32
42
  }
33
43
  return parts.length === 0 ? base : parts.join("\n\n");
34
44
  }
45
+ const MEMORY_POLICY_PATCH_KEYS = ["retrievalTopK", "promotionRecallThreshold"];
46
+ /** Tool/skill surfaces whose fold is intersection-with-baseline (capability ceiling), not assignment. */
47
+ const INTERSECTION_PATCH_KEYS = ["allowedToolIds", "stableCoreToolIds", "skillFilter"];
35
48
  const RUNTIME_PATCH_KEYS = [
36
49
  "maxTurns",
37
50
  "maxTotalTokens",
@@ -40,7 +53,53 @@ const RUNTIME_PATCH_KEYS = [
40
53
  "entropyWatch",
41
54
  "knowledgeBudgetRatio",
42
55
  "skillLeaseTurns",
56
+ "allowedToolIds",
57
+ "stableCoreToolIds",
58
+ "enablePlanTool",
59
+ "skillFilter",
60
+ ...MEMORY_POLICY_PATCH_KEYS,
43
61
  ];
62
+ /** Bounds for the id-list surfaces (allowedToolIds / stableCoreToolIds / skillFilter). */
63
+ const MAX_TOOL_ID_CHARS = 128;
64
+ const MAX_TOOL_LIST_ENTRIES = 128;
65
+ /**
66
+ * Map an editable surface to its promotion tier. Maintained HERE beside the whitelist so a surface can
67
+ * never be whitelisted without also being assigned a tier (the spec's same-place maintenance rule):
68
+ * - "auto" (Tier A): every `runtime.*` whitelist surface. Typed validation + the capability
69
+ * ceiling invariant + the acceptance rule already guard them, so promotion is fully
70
+ * automatic — there is no free text and no injection surface.
71
+ * - "screened" (Tier B): `instructions.*` and `nudges`. Free text can smuggle instructions
72
+ * (persistent prompt-injection laundered through the evidence loop), so a screen runs
73
+ * before promotion.
74
+ * - "human" (Tier C): reserved for capability-WIDENING surfaces. None currently exist — intersection
75
+ * semantics make widening structurally inexpressible — but the enum value exists so a new
76
+ * capability-widening surface cannot be added without consciously assigning it a tier (and
77
+ * building the human gate). `surfaceTier` therefore never returns "human" today — no
78
+ * capability-widening surface is expressible.
79
+ * An unknown surface / slot / runtime key THROWS (same discipline as applySurfaceEdit): a surface with
80
+ * no tier must never fall through to auto-promotion.
81
+ */
82
+ export function surfaceTier(targetSurface) {
83
+ const [head, sub] = targetSurface.split(".");
84
+ if (head === "instructions") {
85
+ if (sub === undefined || !INSTRUCTION_SLOTS.includes(sub)) {
86
+ throw new RangeError(`unknown instruction slot: ${targetSurface}`);
87
+ }
88
+ return "screened";
89
+ }
90
+ if (head === "nudges") {
91
+ if (sub !== undefined)
92
+ throw new RangeError(`nudges surface takes no sub-path: ${targetSurface}`);
93
+ return "screened";
94
+ }
95
+ if (head === "runtime") {
96
+ if (sub === undefined || !RUNTIME_PATCH_KEYS.includes(sub)) {
97
+ throw new RangeError(`runtime patch key not in the editable whitelist: ${targetSurface}`);
98
+ }
99
+ return "auto";
100
+ }
101
+ throw new RangeError(`unknown surface path: ${targetSurface}`);
102
+ }
44
103
  // ── Canonical JSON + digest ──────────────────────────────────────────────────
45
104
  /** Deterministic serialization: recursive key sort, undefined-valued keys skipped, arrays ordered. */
46
105
  function canonicalJson(value) {
@@ -93,6 +152,48 @@ function validateRuntimePatch(runtime) {
93
152
  if (value !== undefined)
94
153
  validateRuntimeValue(key, value);
95
154
  }
155
+ // Same-manifest structural invariant: stable-core keeps tools exposed while a skill narrows, so it
156
+ // must never name a tool outside this manifest's OWN exposure ceiling (`allowedToolIds`). Checked
157
+ // only when both are present; either absent means the ceiling is broader (the whole registered set).
158
+ const allowed = runtime.allowedToolIds;
159
+ const stable = runtime.stableCoreToolIds;
160
+ if (Array.isArray(allowed) && Array.isArray(stable)) {
161
+ const allowedSet = new Set(allowed);
162
+ const outside = stable.filter(id => !allowedSet.has(id));
163
+ if (outside.length > 0) {
164
+ throw new RangeError(`runtime.stableCoreToolIds must be a subset of runtime.allowedToolIds; outside the ceiling: ${outside.join(", ")}`);
165
+ }
166
+ }
167
+ }
168
+ /**
169
+ * Validate an id-list surface: array of unique, non-empty strings (each ≤128 chars), ≤128 entries.
170
+ * `allowEmpty` is the load-bearing asymmetry. For the tool-id arrays it is FALSE: the runner reads an
171
+ * empty/absent `allowedToolIds` as "no gating — expose ALL registered tools", so an empty array would
172
+ * WIDEN exposure to everything if it reached the runner (and a zero-tool run is the v0.2.46 pathology).
173
+ * For `skillFilter` it is TRUE: the runner's no-gating sentinel is ONLY `undefined`, and an empty array
174
+ * legitimately means "no skills available" (a proposer may find skills are a distraction) — a narrowing.
175
+ */
176
+ function validateIdList(key, value, allowEmpty) {
177
+ if (!Array.isArray(value))
178
+ throw new TypeError(`runtime.${key} must be a string[]`);
179
+ if (value.length > MAX_TOOL_LIST_ENTRIES) {
180
+ throw new RangeError(`runtime.${key} exceeds ${MAX_TOOL_LIST_ENTRIES} entries`);
181
+ }
182
+ if (!allowEmpty && value.length === 0) {
183
+ throw new RangeError(`runtime.${key} must be a non-empty list — an empty array is read by the runner as "no gating" (expose all registered tools), which WIDENS exposure`);
184
+ }
185
+ const seen = new Set();
186
+ for (const entry of value) {
187
+ if (typeof entry !== "string" || entry.length === 0) {
188
+ throw new TypeError(`runtime.${key} entries must be non-empty strings`);
189
+ }
190
+ if (entry.length > MAX_TOOL_ID_CHARS) {
191
+ throw new RangeError(`runtime.${key} entry exceeds ${MAX_TOOL_ID_CHARS} chars: ${entry.slice(0, 16)}…`);
192
+ }
193
+ if (seen.has(entry))
194
+ throw new RangeError(`runtime.${key} entries must be unique; duplicate: ${entry}`);
195
+ seen.add(entry);
196
+ }
96
197
  }
97
198
  /** Per-key value typing for runtime patches. An LLM proposer WILL eventually put instruction prose
98
199
  * where a boolean belongs; rejecting it here turns a mid-run kernel `InvalidConfig` crash into a
@@ -103,6 +204,8 @@ function validateRuntimeValue(key, value) {
103
204
  case "maxTurns":
104
205
  case "maxTotalTokens":
105
206
  case "skillLeaseTurns":
207
+ case "retrievalTopK":
208
+ case "promotionRecallThreshold":
106
209
  if (!positiveInt(value))
107
210
  throw new TypeError(`runtime.${key} must be a positive integer`);
108
211
  return;
@@ -110,6 +213,17 @@ function validateRuntimeValue(key, value) {
110
213
  if (typeof value !== "boolean")
111
214
  throw new TypeError("runtime.criteriaGate must be a boolean");
112
215
  return;
216
+ case "enablePlanTool":
217
+ if (typeof value !== "boolean")
218
+ throw new TypeError("runtime.enablePlanTool must be a boolean");
219
+ return;
220
+ case "allowedToolIds":
221
+ case "stableCoreToolIds":
222
+ validateIdList(key, value, /* allowEmpty */ false);
223
+ return;
224
+ case "skillFilter":
225
+ validateIdList(key, value, /* allowEmpty */ true);
226
+ return;
113
227
  case "knowledgeBudgetRatio":
114
228
  if (typeof value !== "number" || !(value > 0 && value <= 1)) {
115
229
  throw new TypeError("runtime.knowledgeBudgetRatio must be a number in (0, 1]");
@@ -176,6 +290,11 @@ export function validateManifest(manifest) {
176
290
  if (!Array.isArray(manifest.editableSurfaces) || manifest.editableSurfaces.some(s => typeof s !== "string")) {
177
291
  throw new TypeError("manifest.editableSurfaces must be a string[]");
178
292
  }
293
+ if (manifest.scope !== undefined) {
294
+ if (typeof manifest.scope !== "string" || !SCOPE_PATTERN.test(manifest.scope)) {
295
+ throw new TypeError("manifest.scope must be a non-empty path-safe token matching /^[A-Za-z0-9._-]{1,64}$/");
296
+ }
297
+ }
179
298
  if (manifest.instructions !== undefined)
180
299
  validateInstructionProfile(manifest.instructions);
181
300
  if (manifest.nudges !== undefined)
@@ -198,12 +317,51 @@ export function applyManifest(manifest, base) {
198
317
  out.nudges = manifest.nudges;
199
318
  if (manifest.runtime !== undefined) {
200
319
  for (const [key, value] of Object.entries(manifest.runtime)) {
201
- if (value !== undefined)
320
+ if (value === undefined)
321
+ continue;
322
+ if (MEMORY_POLICY_PATCH_KEYS.includes(key)) {
323
+ out.memoryPolicy = { ...out.memoryPolicy, [key]: value };
324
+ }
325
+ else if (INTERSECTION_PATCH_KEYS.includes(key)) {
326
+ out[key] = foldIntersection(key, value, out[key]);
327
+ }
328
+ else {
329
+ // enablePlanTool + numeric/boolean knobs: plain assignment.
202
330
  out[key] = value;
331
+ }
203
332
  }
204
333
  }
205
334
  return out;
206
335
  }
336
+ /**
337
+ * Fold one intersection surface (capability ceiling): effective = manifest ∩ host-baseline, so a
338
+ * manifest can only NARROW. The empty-baseline meaning is surface-specific and load-bearing:
339
+ *
340
+ * - allowedToolIds / stableCoreToolIds — the runner reads an empty OR absent baseline as
341
+ * "no gating = all registered tools" (the universe), so a non-array/empty baseline yields the
342
+ * manifest list verbatim; only a NON-EMPTY baseline is a real ceiling to intersect against. An
343
+ * empty intersection THROWS: a zero-tool run reprises the v0.2.46 pathology AND the runner would
344
+ * silently reinterpret the empty result as "no gating" (full exposure) — so we turn the candidate
345
+ * into a discardable error instead.
346
+ * - skillFilter — the runner's no-gating sentinel is ONLY `undefined`; an empty-array baseline is a
347
+ * genuine, maximally-tight ceiling (no skills). So ANY present array (even `[]`) is intersected,
348
+ * and an empty result is FINE (= no skills). This mirrors the validation asymmetry exactly.
349
+ */
350
+ function foldIntersection(key, manifestList, baseList) {
351
+ const skillLike = key === "skillFilter";
352
+ // Is the host baseline a real constraining set? Tool ids: non-empty array only (empty == universe).
353
+ // skillFilter: any array (empty == the empty set).
354
+ const constrained = Array.isArray(baseList) && (skillLike || baseList.length > 0);
355
+ const effective = constrained
356
+ ? manifestList.filter(id => baseList.includes(id)) // manifest order → deterministic
357
+ : manifestList;
358
+ if (!skillLike && effective.length === 0) {
359
+ throw new RangeError(`applyManifest: runtime.${key} intersection is empty — manifest [${manifestList.join(", ")}] ∩ ` +
360
+ `host [${(baseList ?? []).join(", ")}] names no shared tool. A zero-tool run is rejected (it ` +
361
+ `reprises the v0.2.46 pathology and the runner would read empty as "no gating" = full exposure).`);
362
+ }
363
+ return effective;
364
+ }
207
365
  function validatePatchShape(patch) {
208
366
  if (typeof patch !== "object" || patch === null)
209
367
  throw new TypeError("patch must be an object");
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Self-Harness H1.2 — declarative event→note rules (the runtime control-policy surface).
2
+ * Self-Harness nudge rules — declarative event→note rules (the runtime control-policy surface).
3
3
  *
4
4
  * A `NudgeRule` says "when this session event fires, push this note to the model". It generalizes the
5
5
  * two hard-coded precedents (EntropyWatch.notify_model, the RepeatFuse STOP text) into data the
@@ -4,7 +4,7 @@ export { VerdictFnJudge, LlmEvalJudge, HybridJudge } from "./judge.js";
4
4
  export type { AttemptJudge, JudgeContext, JudgeResult, SkillCandidate } from "./judge.js";
5
5
  export { judge } from "../runtime/eval.js";
6
6
  export type { VerdictDetail, JudgeArgs } from "../runtime/eval.js";
7
- export { composeSystemPrompt, manifestDigest, applyManifest, applyPatch, validateManifest, } from "./manifest.js";
8
- export type { InstructionProfile, HarnessManifest, HarnessRuntimePatch, HarnessPatch, } from "./manifest.js";
7
+ export { composeSystemPrompt, manifestDigest, applyManifest, applyPatch, validateManifest, surfaceTier, } from "./manifest.js";
8
+ export type { InstructionProfile, HarnessManifest, HarnessRuntimePatch, HarnessPatch, SurfaceTier, } from "./manifest.js";
9
9
  export { NudgeEngine, validateNudgeRules } from "./nudge.js";
10
10
  export type { NudgeTrigger, NudgeRule, NudgeOutput } from "./nudge.js";
@@ -2,7 +2,7 @@
2
2
  export { AttemptLoop, RuntimeAttemptBody, continueSession, freshWithFeedback, freshWithDigest, } from "./harness.js";
3
3
  export { VerdictFnJudge, LlmEvalJudge, HybridJudge } from "./judge.js";
4
4
  export { judge } from "../runtime/eval.js";
5
- // Self-Harness H1: the harness face as data (manifest lineage + declarative event→note rules). The
5
+ // Self-Harness editable surfaces: the harness face as data (manifest lineage + declarative event→note rules). The
6
6
  // lab layer loads these through the compiled dist, so they live on this public barrel.
7
- export { composeSystemPrompt, manifestDigest, applyManifest, applyPatch, validateManifest, } from "./manifest.js";
7
+ export { composeSystemPrompt, manifestDigest, applyManifest, applyPatch, validateManifest, surfaceTier, } from "./manifest.js";
8
8
  export { NudgeEngine, validateNudgeRules } from "./nudge.js";
@@ -1,4 +1,7 @@
1
- const DEFAULT_META_TOOLS = new Set(["skill", "memory", "knowledge", "update_plan"]);
1
+ // Mirrors the kernel's EXPOSURE_EXEMPT_META_TOOLS invariant: kernel-owned meta surfaces are
2
+ // never narrowed away by a tool allow-list. `read_result` is runner-resolved before reaching any
3
+ // plane today, but the lists must not drift.
4
+ const DEFAULT_META_TOOLS = new Set(["skill", "memory", "knowledge", "update_plan", "read_result"]);
2
5
  /** Wraps an execution plane, allowing only manifest-permitted tool IDs (+ meta-tools). */
3
6
  export class FilteredExecutionPlane {
4
7
  inner;
@@ -144,18 +144,24 @@ export interface RuntimeOptions {
144
144
  phase?: "initial" | "renewal";
145
145
  }) => Promise<MemoryQuery[] | undefined> | MemoryQuery[] | undefined;
146
146
  systemPrompt?: string;
147
- /** Self-Harness H1.1: the four instruction slots (bootstrap/execution/verification/failureRecovery)
147
+ /** Self-Harness instruction surface: the four instruction slots (bootstrap/execution/verification/failureRecovery)
148
148
  * composed onto `systemPrompt` in fixed order at option normalization. The kernel still sees ONE
149
149
  * system prompt; this is the editable instruction surface the self-harness loop rewrites. Absent ⇒
150
150
  * `systemPrompt` is used verbatim (zero behavior difference). */
151
151
  instructions?: InstructionProfile;
152
- /** Self-Harness H1.2: declarative event→note rules. On each matching session event a rendered note
152
+ /** Self-Harness nudge surface: declarative event→note rules. On each matching session event a rendered note
153
153
  * is pushed through the `injectNote` signal channel (same path as `onToolResult`'s `{note}`).
154
154
  * ≤16 rules, validated at construction. Absent/empty ⇒ no engine, no append wrapping, zero
155
155
  * behavior difference. */
156
156
  nudges?: NudgeRule[];
157
157
  initialMemory?: string[];
158
158
  skillDir?: string;
159
+ /** Host-layer allowlist over the `skillDir` catalog by skill NAME. When set, only scanned skills
160
+ * whose name is listed are fed to the kernel via `set_available_skills` (the manifest layer
161
+ * intersects onto this host baseline in `applyManifest`). Absent ⇒ zero behavior difference (all
162
+ * scanned skills fed); empty array ⇒ no skills (a legitimate narrowing — unlike an empty
163
+ * `allowedToolIds`, which the runner reads as "no gating"). Only takes effect when `skillDir` is set. */
164
+ skillFilter?: string[];
159
165
  dreamStore?: DreamStore;
160
166
  /** M4: advisory callback when a recalled record crosses the promotion threshold. The host/model
161
167
  * decides whether to pin the record or promote its content into knowledge. */
@@ -301,7 +307,7 @@ export interface RuntimeOptions {
301
307
  /** Passed to kernel start_run for role/isolation metadata. */
302
308
  runSpec?: AgentRunSpec;
303
309
  /** P0-A tool gating: a static per-run tool profile — only these tool ids (plus the
304
- * skill/memory/knowledge/update_plan meta-tools) are exposed to the model each turn.
310
+ * skill/memory/knowledge/update_plan/read_result meta-tools) are exposed to the model each turn.
305
311
  * Sugar that lowers to the same `capability_filter` sub-agents use; byte-stable across
306
312
  * the run, so it never busts the prompt-cache prefix. Augments `runSpec`'s filter when
307
313
  * both are set; synthesizes a minimal run spec when `runSpec` is absent. Omitted/empty
@@ -1466,11 +1466,17 @@ export class RuntimeRunner {
1466
1466
  if (this.opts.skillDir) {
1467
1467
  const { scanSkillDir } = await import("../skills/loader.js");
1468
1468
  const metas = await scanSkillDir(this.opts.skillDir);
1469
+ // S2 host-layer skill allowlist: keep only scanned skills named in `skillFilter` before feeding
1470
+ // the catalog. Absent ⇒ feed all (identical to the pre-feature message); empty ⇒ feed none. The
1471
+ // `set_available_skills` message is ALWAYS sent when a skillDir exists (shape preserved) — only
1472
+ // the list narrows; the no-skillDir path stays untouched.
1473
+ const filter = this.opts.skillFilter;
1474
+ const selected = filter === undefined ? metas : metas.filter(m => filter.includes(m.name));
1469
1475
  // P1-B: pass the full SkillMetadata (incl. `allowedTools`) straight through — re-mapping it
1470
1476
  // field-by-field previously dropped `allowedTools`.
1471
1477
  await this.commitKernelApply(runtime, this.pendingObservations, {
1472
1478
  kind: "set_available_skills",
1473
- skills: metas.map(m => skillMetadataToKernel(m)),
1479
+ skills: selected.map(m => skillMetadataToKernel(m)),
1474
1480
  });
1475
1481
  }
1476
1482
  // P1-B/D: configure the stable-core tool ids (always exposed under skill gating). Empty/absent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstrike/sdk",
3
- "version": "0.2.47",
3
+ "version": "0.2.49",
4
4
  "description": "DeepStrike Node.js SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@anthropic-ai/sdk": "^0.99.0",
75
- "@deepstrike/core": "0.2.47",
75
+ "@deepstrike/core": "0.2.49",
76
76
  "@google/generative-ai": "^0.24.1",
77
77
  "openai": "^5.23.2"
78
78
  },