@silmaril-security/sdk 0.9.0 → 0.10.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +200 -24
  3. package/dist/adapters/deepagents.cjs +255 -42
  4. package/dist/adapters/deepagents.cjs.map +1 -1
  5. package/dist/adapters/deepagents.d.cts +9 -5
  6. package/dist/adapters/deepagents.d.ts +9 -5
  7. package/dist/adapters/deepagents.js +261 -43
  8. package/dist/adapters/deepagents.js.map +1 -1
  9. package/dist/adapters/langchain.cjs +153 -32
  10. package/dist/adapters/langchain.cjs.map +1 -1
  11. package/dist/adapters/langchain.d.cts +1 -1
  12. package/dist/adapters/langchain.d.ts +1 -1
  13. package/dist/adapters/langchain.js +153 -32
  14. package/dist/adapters/langchain.js.map +1 -1
  15. package/dist/adapters/vercel-v4.cjs +700 -0
  16. package/dist/adapters/vercel-v4.cjs.map +1 -0
  17. package/dist/adapters/vercel-v4.d.cts +79 -0
  18. package/dist/adapters/vercel-v4.d.ts +79 -0
  19. package/dist/adapters/vercel-v4.js +670 -0
  20. package/dist/adapters/vercel-v4.js.map +1 -0
  21. package/dist/adapters/vercel.cjs +41 -15
  22. package/dist/adapters/vercel.cjs.map +1 -1
  23. package/dist/adapters/vercel.d.cts +1 -1
  24. package/dist/adapters/vercel.d.ts +1 -1
  25. package/dist/adapters/vercel.js +41 -15
  26. package/dist/adapters/vercel.js.map +1 -1
  27. package/dist/{firewall-Bv5y03P0.d.cts → firewall-BXM2BWEr.d.cts} +60 -1
  28. package/dist/{firewall-Bv5y03P0.d.ts → firewall-BXM2BWEr.d.ts} +60 -1
  29. package/dist/index.cjs +451 -50
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +2 -2
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +451 -50
  34. package/dist/index.js.map +1 -1
  35. package/package.json +21 -5
@@ -74,7 +74,8 @@ var DEFAULT_HOOKS = /* @__PURE__ */ new Set([
74
74
  FirewallHook.LLM_START,
75
75
  FirewallHook.CHAT_MODEL_START,
76
76
  FirewallHook.TOOL_START,
77
- FirewallHook.TOOL_END
77
+ FirewallHook.TOOL_END,
78
+ FirewallHook.LLM_END
78
79
  ]);
79
80
  var INPUT_HOOKS = /* @__PURE__ */ new Set([
80
81
  FirewallHook.LLM_START,
@@ -110,6 +111,14 @@ function validateMode(value) {
110
111
  throw new Error("Firewall: mode must be shadow, warn, or block");
111
112
  }
112
113
 
114
+ // src/pending.ts
115
+ var import_node_async_hooks = require("async_hooks");
116
+ var retryLimit = new import_node_async_hooks.AsyncLocalStorage();
117
+ function conversationId(metadata) {
118
+ const value = metadata?.conversationId;
119
+ return typeof value === "string" && value.length > 0 ? value : void 0;
120
+ }
121
+
113
122
  // src/adapters/thread-identity.ts
114
123
  function record(value) {
115
124
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
@@ -141,6 +150,148 @@ var SAFE_OUTPUT_MESSAGE = "Silmaril Firewall blocked this response.";
141
150
  var BLOCKED_TOOL_MARKER = "silmaril-firewall:v1:blocked-tool";
142
151
  var issuedBlockedMessages = /* @__PURE__ */ new WeakSet();
143
152
  var protectedCompiledGraphs = /* @__PURE__ */ new WeakMap();
153
+ var GENERAL_PURPOSE_DEFAULT_MIDDLEWARE = /* @__PURE__ */ new Set([
154
+ "FilesystemMiddleware",
155
+ "SummarizationMiddleware",
156
+ "PatchToolCallsMiddleware"
157
+ ]);
158
+ function isCompiledMode(value) {
159
+ return value === "isolated" || value === "fork";
160
+ }
161
+ function recordValue(value) {
162
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
163
+ }
164
+ function modelCompatName(model) {
165
+ const getName = Reflect.get(model, "getName");
166
+ if (typeof getName !== "function") {
167
+ throw new Error(
168
+ "Protected Deep Agents model-object profiles require a callable getName()"
169
+ );
170
+ }
171
+ const name = Reflect.apply(getName, model, []);
172
+ if (typeof name !== "string" || !name) {
173
+ throw new Error(
174
+ "Protected Deep Agents model-object getName() must return a non-empty string"
175
+ );
176
+ }
177
+ return name;
178
+ }
179
+ function optionalModelHint(record2, key, location) {
180
+ const value = Reflect.get(record2, key);
181
+ if (value === void 0 || value === null) return void 0;
182
+ if (typeof value !== "string") {
183
+ throw new Error(
184
+ `Protected Deep Agents ${location}.${key} profile hint must be a string`
185
+ );
186
+ }
187
+ return value;
188
+ }
189
+ function configurableDefaults(model) {
190
+ const value = Reflect.get(model, "_defaultConfig");
191
+ if (value === void 0 || value === null) return void 0;
192
+ const defaults = recordValue(value);
193
+ if (defaults === void 0) {
194
+ throw new Error(
195
+ "Protected Deep Agents ConfigurableModel._defaultConfig must be an object"
196
+ );
197
+ }
198
+ return defaults;
199
+ }
200
+ function modelProviderHint(model) {
201
+ const name = modelCompatName(model);
202
+ if (name === "ConfigurableModel") {
203
+ const defaults = configurableDefaults(model);
204
+ return defaults === void 0 ? void 0 : optionalModelHint(defaults, "modelProvider", "_defaultConfig");
205
+ }
206
+ const providers = {
207
+ ChatAnthropic: "anthropic",
208
+ ChatOpenAI: "openai",
209
+ ChatGoogleGenerativeAI: "google"
210
+ };
211
+ return providers[name];
212
+ }
213
+ function modelIdentifierHint(model) {
214
+ const name = modelCompatName(model);
215
+ const configurable = name === "ConfigurableModel" ? configurableDefaults(model) : void 0;
216
+ return (configurable === void 0 ? void 0 : optionalModelHint(configurable, "model", "_defaultConfig")) ?? optionalModelHint(model, "model_name", name) ?? optionalModelHint(model, "modelName", name);
217
+ }
218
+ function resolveProtectedHarnessProfile(model) {
219
+ if (typeof model === "string") {
220
+ return (0, import_deepagents.getHarnessProfile)(model);
221
+ }
222
+ if (typeof model !== "object" && typeof model !== "function" || model === null) {
223
+ throw new Error(
224
+ "Protected Deep Agents model must be a string or model object"
225
+ );
226
+ }
227
+ const providerHint = modelProviderHint(model);
228
+ const identifierHint = modelIdentifierHint(model);
229
+ if (providerHint && identifierHint && !identifierHint.includes(":")) {
230
+ const exact = (0, import_deepagents.getHarnessProfile)(`${providerHint}:${identifierHint}`);
231
+ if (exact !== void 0) return exact;
232
+ }
233
+ if (identifierHint?.includes(":")) {
234
+ const exact = (0, import_deepagents.getHarnessProfile)(identifierHint);
235
+ if (exact !== void 0) return exact;
236
+ }
237
+ if (providerHint) {
238
+ const provider = (0, import_deepagents.getHarnessProfile)(providerHint);
239
+ if (provider !== void 0) return provider;
240
+ }
241
+ return import_deepagents.EMPTY_HARNESS_PROFILE;
242
+ }
243
+ function applyProfileToolDescriptions(tools, profile) {
244
+ const overrides = profile?.toolDescriptionOverrides ?? {};
245
+ if (Object.keys(overrides).length === 0) return [...tools];
246
+ return tools.map((tool) => {
247
+ if (typeof tool !== "object" && typeof tool !== "function" || tool === null) {
248
+ return tool;
249
+ }
250
+ const name = Reflect.get(tool, "name");
251
+ if (typeof name !== "string" || !(name in overrides)) return tool;
252
+ return Object.assign(
253
+ Object.create(Object.getPrototypeOf(tool)),
254
+ tool,
255
+ { description: overrides[name] }
256
+ );
257
+ });
258
+ }
259
+ function generalPurposeRootOverrides(profile, middleware) {
260
+ const profileMiddleware = profile?.extraMiddleware ?? [];
261
+ if (typeof profileMiddleware === "function" && middleware.length > 0) {
262
+ throw new Error(
263
+ "Protected Deep Agents cannot preserve root middleware overrides when the active profile uses an extraMiddleware factory; use a static profile middleware array"
264
+ );
265
+ }
266
+ const names = new Set(GENERAL_PURPOSE_DEFAULT_MIDDLEWARE);
267
+ names.add("SkillsMiddleware");
268
+ if (Array.isArray(profileMiddleware)) {
269
+ for (const entry of profileMiddleware) names.add(entry.name);
270
+ }
271
+ for (const excluded of profile?.excludedMiddleware ?? []) {
272
+ names.delete(excluded);
273
+ }
274
+ return middleware.filter((entry) => names.has(entry.name));
275
+ }
276
+ function applyGeneralPurposeProfile(profile) {
277
+ const config = profile?.generalPurposeSubagent;
278
+ if (config?.systemPrompt !== void 0) {
279
+ return {
280
+ description: config.description ?? import_deepagents.GENERAL_PURPOSE_SUBAGENT.description,
281
+ systemPrompt: config.systemPrompt
282
+ };
283
+ }
284
+ let systemPrompt = profile?.baseSystemPrompt ?? import_deepagents.GENERAL_PURPOSE_SUBAGENT.systemPrompt;
285
+ if (profile?.systemPromptSuffix !== void 0) {
286
+ systemPrompt = systemPrompt ? `${systemPrompt}
287
+
288
+ ${profile.systemPromptSuffix}` : profile.systemPromptSuffix;
289
+ }
290
+ return {
291
+ description: config?.description ?? import_deepagents.GENERAL_PURPOSE_SUBAGENT.description,
292
+ systemPrompt
293
+ };
294
+ }
144
295
  function textOf(message) {
145
296
  return typeof message.content === "string" ? message.content : JSON.stringify(message.content);
146
297
  }
@@ -205,50 +356,74 @@ function createDeepAgentsMiddleware(firewall, options = {}) {
205
356
  }
206
357
  const effectiveMode = validateMode(options.mode) ?? firewall.mode;
207
358
  const notificationChecks = /* @__PURE__ */ new Map();
208
- const classify = async (text, hook, conversationId, toolName) => {
209
- if (!text.trim()) return { enforce: false, mode: effectiveMode };
210
- try {
211
- const result = await firewall.classify(text, {
212
- hook,
213
- ...toolName === void 0 ? {} : { toolName },
214
- ...effectiveMode === void 0 ? {} : { mode: effectiveMode },
215
- metadata: { ...conversationId === void 0 ? {} : { conversationId }, ...remoteLineage((0, import_runnables.ensureConfig)()) }
216
- });
217
- const mode = effectiveMode ?? result.mode ?? "block";
218
- const blocked = result.prediction === "MALICIOUS" || result.governance?.action === "block";
219
- if (options.onClassify) {
220
- try {
221
- options.onClassify({ hook, ...toolName === void 0 ? {} : { toolName }, text, result, blocked, mode, shadowMode: mode === "shadow" });
222
- } catch {
223
- }
359
+ const parallel = options.parallel ?? false;
360
+ const background = effectiveMode === "shadow" && options.failOpen !== false;
361
+ const decide = (result, text, hook, toolName) => {
362
+ const mode = effectiveMode ?? result.mode ?? "block";
363
+ const blocked = result.prediction === "MALICIOUS" || result.governance?.action === "block";
364
+ if (options.onClassify) {
365
+ try {
366
+ options.onClassify({ hook, ...toolName === void 0 ? {} : { toolName }, text, result, blocked, mode, shadowMode: mode === "shadow" });
367
+ } catch {
224
368
  }
225
- return { enforce: blocked && mode === "block", mode, cacheable: true };
226
- } catch (error) {
227
- if (isReviewCompatibilityError(error)) throw error;
228
- if (options.failOpen === false) throw error;
229
- return { enforce: false, mode: effectiveMode };
230
369
  }
370
+ return { enforce: blocked && mode === "block", mode, cacheable: true };
371
+ };
372
+ const prepare = (text, hook, conversationId2, toolName) => {
373
+ if (!text.trim()) return async () => ({ enforce: false, mode: effectiveMode });
374
+ const request = {
375
+ hook,
376
+ ...toolName === void 0 ? {} : { toolName },
377
+ ...effectiveMode === void 0 ? {} : { mode: effectiveMode },
378
+ metadata: { ...conversationId2 === void 0 ? {} : { conversationId: conversationId2 }, ...remoteLineage((0, import_runnables.ensureConfig)()) }
379
+ };
380
+ if (background) {
381
+ const observed = firewall.observe(text, request).then((result) => {
382
+ if (result !== void 0) decide(result, text, hook, toolName);
383
+ return result !== void 0;
384
+ });
385
+ return async () => ({ enforce: false, mode: effectiveMode, observed });
386
+ }
387
+ return async () => {
388
+ try {
389
+ return decide(await firewall.classify(text, request), text, hook, toolName);
390
+ } catch (error) {
391
+ if (isReviewCompatibilityError(error)) throw error;
392
+ if (options.failOpen === false) throw error;
393
+ return { enforce: false, mode: effectiveMode };
394
+ }
395
+ };
396
+ };
397
+ const classify = (text, hook, conversationId2, toolName) => {
398
+ const check = prepare(text, hook, conversationId2, toolName);
399
+ return parallel && !background ? firewall.pending.submit(check, conversationId({ conversationId: conversationId2 })) : check();
400
+ };
401
+ const rememberNotification = (key, blocked) => {
402
+ notificationChecks.set(key, blocked);
403
+ while (notificationChecks.size > 1024) notificationChecks.delete(notificationChecks.keys().next().value);
231
404
  };
232
405
  return (0, import_langchain.createMiddleware)({
233
406
  name: "SilmarilDeepAgentsMiddleware",
234
407
  wrapModelCall: async (request, handler) => {
235
- const conversationId = nativeThreadId(request.runtime, void 0, void 0, (0, import_runnables.ensureConfig)());
408
+ const conversationId2 = nativeThreadId(request.runtime, void 0, void 0, (0, import_runnables.ensureConfig)());
236
409
  const messages = [];
237
410
  for (const message of request.messages) {
238
411
  let blocked = false;
239
412
  if (remoteNotification(message)) {
240
- const key = await notificationKey(message, conversationId, effectiveMode);
413
+ const key = await notificationKey(message, conversationId2, effectiveMode);
241
414
  const cached = key === void 0 ? void 0 : notificationChecks.get(key);
242
415
  if (cached !== void 0) {
243
416
  blocked = cached;
244
417
  notificationChecks.delete(key);
245
418
  notificationChecks.set(key, cached);
246
419
  } else {
247
- const decision = await classify(textOf(message), HookLabel.TOOL_RESPONSE, conversationId, "async_subagent");
420
+ const decision = await classify(textOf(message), HookLabel.TOOL_RESPONSE, conversationId2, "async_subagent");
248
421
  blocked = decision.enforce;
249
- if (key !== void 0 && decision.cacheable) {
250
- notificationChecks.set(key, blocked);
251
- while (notificationChecks.size > 1024) notificationChecks.delete(notificationChecks.keys().next().value);
422
+ if (key !== void 0 && decision.cacheable) rememberNotification(key, blocked);
423
+ if (key !== void 0) {
424
+ void decision.observed?.then((completed) => {
425
+ if (completed) rememberNotification(key, false);
426
+ });
252
427
  }
253
428
  }
254
429
  }
@@ -267,23 +442,27 @@ function createDeepAgentsMiddleware(firewall, options = {}) {
267
442
  (message) => import_messages.ToolMessage.isInstance(message) && message.content === SAFE_TOOL_MESSAGE && message.additional_kwargs?.silmarilBlocked === BLOCKED_TOOL_MARKER
268
443
  ).length;
269
444
  const latestUser = [...request.messages].reverse().find(import_messages.HumanMessage.isInstance);
270
- const inputDecision = latestUser ? await classify(textOf(latestUser), HookLabel.USER_INPUT, conversationId) : void 0;
445
+ const racesModel = parallel && !background && blockedCount < maxBlockedAttempts;
446
+ const protectedRequest = request;
447
+ const running = racesModel ? Promise.resolve().then(() => handler(protectedRequest)) : void 0;
448
+ running?.catch(() => void 0);
449
+ const inputDecision = latestUser === void 0 ? void 0 : await classify(textOf(latestUser), HookLabel.USER_INPUT, conversationId2);
271
450
  if (inputDecision?.enforce) return new import_messages.AIMessage(SAFE_OUTPUT_MESSAGE);
272
451
  const capMode = effectiveMode ?? inputDecision?.mode ?? "block";
273
452
  if (blockedCount >= maxBlockedAttempts && capMode === "block") {
274
453
  return new import_messages.AIMessage(SAFE_FINAL_MESSAGE);
275
454
  }
276
- const response = await handler(request);
277
- if (response instanceof import_langgraph.Command && (await classify(textOfStructuredValue(response.update), HookLabel.LLM_OUTPUT, conversationId)).enforce) {
455
+ const response = await (running ?? handler(request));
456
+ if (response instanceof import_langgraph.Command && (await classify(textOfStructuredValue(response.update), HookLabel.LLM_OUTPUT, conversationId2)).enforce) {
278
457
  return new import_messages.AIMessage(SAFE_OUTPUT_MESSAGE);
279
458
  }
280
- if (import_messages.AIMessage.isInstance(response) && (await classify(textOf(response), HookLabel.LLM_OUTPUT, conversationId)).enforce) {
459
+ if (import_messages.AIMessage.isInstance(response) && (await classify(textOf(response), HookLabel.LLM_OUTPUT, conversationId2)).enforce) {
281
460
  return new import_messages.AIMessage(SAFE_OUTPUT_MESSAGE);
282
461
  }
283
462
  return response;
284
463
  },
285
464
  wrapToolCall: async (request, handler) => {
286
- const conversationId = nativeThreadId(request.runtime, void 0, void 0, (0, import_runnables.ensureConfig)());
465
+ const conversationId2 = nativeThreadId(request.runtime, void 0, void 0, (0, import_runnables.ensureConfig)());
287
466
  const safe = () => {
288
467
  const message = new import_messages.ToolMessage({
289
468
  content: SAFE_TOOL_MESSAGE,
@@ -294,7 +473,7 @@ function createDeepAgentsMiddleware(firewall, options = {}) {
294
473
  issuedBlockedMessages.add(message);
295
474
  return message;
296
475
  };
297
- if ((await classify(JSON.stringify(request.toolCall.args ?? {}), HookLabel.TOOL_CALL, conversationId, request.toolCall.name)).enforce) {
476
+ if ((await classify(JSON.stringify(request.toolCall.args ?? {}), HookLabel.TOOL_CALL, conversationId2, request.toolCall.name)).enforce) {
298
477
  return safe();
299
478
  }
300
479
  const result = await handler(request);
@@ -302,10 +481,10 @@ function createDeepAgentsMiddleware(firewall, options = {}) {
302
481
  try {
303
482
  resultText = import_messages.ToolMessage.isInstance(result) ? textOf(result) : result instanceof import_langgraph.Command ? textOfStructuredValue(result.update) : String(result);
304
483
  } catch {
305
- const decision = await classify("[uninspectable tool result]", HookLabel.TOOL_RESPONSE, conversationId, request.toolCall.name);
484
+ const decision = await classify("[uninspectable tool result]", HookLabel.TOOL_RESPONSE, conversationId2, request.toolCall.name);
306
485
  return decision.mode === "block" ? safe() : stripAllowedMarker(result);
307
486
  }
308
- if ((await classify(resultText, HookLabel.TOOL_RESPONSE, conversationId, request.toolCall.name)).enforce) {
487
+ if ((await classify(resultText, HookLabel.TOOL_RESPONSE, conversationId2, request.toolCall.name)).enforce) {
309
488
  if (["start_async_task", "check_async_task", "update_async_task", "cancel_async_task", "list_async_tasks"].includes(request.toolCall.name) && result instanceof import_langgraph.Command && result.update && !Array.isArray(result.update) && "asyncTasks" in result.update) {
310
489
  return new import_langgraph.Command({ update: { messages: [safe()], asyncTasks: result.update.asyncTasks } });
311
490
  }
@@ -317,17 +496,32 @@ function createDeepAgentsMiddleware(firewall, options = {}) {
317
496
  }
318
497
  function createProtectedCompiledSubagent(firewall, options) {
319
498
  rejectConversationOptions(options);
320
- const { name, description, silmaril, middleware = [], ...agentOptions } = options;
499
+ const { name, description, mode, silmaril, middleware = [], ...agentOptions } = options;
500
+ if (mode !== void 0 && !isCompiledMode(mode)) {
501
+ throw new Error("Compiled subagent mode must be isolated or fork");
502
+ }
321
503
  const runnable = (0, import_langchain.createAgent)({
322
504
  ...agentOptions,
323
505
  middleware: [...middleware, createDeepAgentsMiddleware(firewall, silmaril)]
324
506
  });
325
- protectedCompiledGraphs.set(runnable, firewall);
326
- return { name, description, runnable };
507
+ protectedCompiledGraphs.set(runnable, { firewall, mode });
508
+ return {
509
+ name,
510
+ description,
511
+ runnable,
512
+ ...mode === void 0 ? {} : { mode }
513
+ };
327
514
  }
328
515
  function createProtectedDeepAgent(firewall, options = {}) {
329
516
  rejectConversationOptions(options);
330
517
  const { silmaril, subagents = [], protectedCompiledSubagents = [], middleware = [], ...agentOptions } = options;
518
+ const model = agentOptions.model ?? "anthropic:claude-sonnet-4-6";
519
+ const harnessProfile = resolveProtectedHarnessProfile(model);
520
+ const parentTools = agentOptions.tools ?? [];
521
+ const effectiveParentTools = applyProfileToolDescriptions(
522
+ parentTools,
523
+ harnessProfile
524
+ );
331
525
  const protectedSubagents = subagents.map((subagent) => {
332
526
  if ("runnable" in subagent) {
333
527
  throw new Error("Compiled subagents must use createProtectedCompiledSubagent");
@@ -335,11 +529,30 @@ function createProtectedDeepAgent(firewall, options = {}) {
335
529
  if ("graphId" in subagent) return { ...subagent };
336
530
  return { ...subagent, middleware: [...subagent.middleware ?? [], createDeepAgentsMiddleware(firewall, silmaril)] };
337
531
  });
338
- if (!protectedSubagents.some((subagent) => subagent.name === import_deepagents.GENERAL_PURPOSE_SUBAGENT.name)) {
339
- protectedSubagents.unshift({ ...import_deepagents.GENERAL_PURPOSE_SUBAGENT, middleware: [createDeepAgentsMiddleware(firewall, silmaril)] });
532
+ const gpConfig = harnessProfile?.generalPurposeSubagent;
533
+ if (gpConfig?.enabled !== false && !protectedSubagents.some(
534
+ (subagent) => subagent.name === import_deepagents.GENERAL_PURPOSE_SUBAGENT.name
535
+ )) {
536
+ const inheritedMiddleware = generalPurposeRootOverrides(
537
+ harnessProfile,
538
+ middleware
539
+ );
540
+ protectedSubagents.unshift({
541
+ ...import_deepagents.GENERAL_PURPOSE_SUBAGENT,
542
+ ...applyGeneralPurposeProfile(harnessProfile),
543
+ model,
544
+ tools: effectiveParentTools,
545
+ ...agentOptions.skills === void 0 ? {} : { skills: agentOptions.skills },
546
+ middleware: [
547
+ ...inheritedMiddleware,
548
+ createDeepAgentsMiddleware(firewall, silmaril)
549
+ ]
550
+ });
340
551
  }
341
552
  for (const spec of protectedCompiledSubagents) {
342
- if (!spec.runnable || protectedCompiledGraphs.get(spec.runnable) !== firewall) {
553
+ const registration = spec.runnable ? protectedCompiledGraphs.get(spec.runnable) : void 0;
554
+ const candidateMode = spec.mode;
555
+ if (registration?.firewall !== firewall || candidateMode !== void 0 && !isCompiledMode(candidateMode) || candidateMode !== registration.mode) {
343
556
  throw new Error("Compiled subagents must be built with createProtectedCompiledSubagent for this Firewall client");
344
557
  }
345
558
  }