@fro.bot/systematic 3.15.1 → 3.16.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/dist/index.js CHANGED
@@ -8,9 +8,10 @@ import {
8
8
  _enum,
9
9
  AgentOverlaySchema,
10
10
  CategoryOverlaySchema,
11
+ isRecord,
12
+ resolveRouting,
11
13
  loadConfig,
12
14
  loadConfigWithSources,
13
- isRecord,
14
15
  isDiscoverableMarkdown,
15
16
  findAgentsInDir,
16
17
  extractAgentFrontmatter,
@@ -18,7 +19,7 @@ import {
18
19
  extractCommandFrontmatter,
19
20
  findSkillsInDir,
20
21
  discoverSkills
21
- } from "./index-7cyxcwf5.js";
22
+ } from "./index-ae6mhwth.js";
22
23
 
23
24
  // src/index.ts
24
25
  import { createHash as createHash4 } from "crypto";
@@ -482,7 +483,7 @@ function loadSkillAsCommand(loaded) {
482
483
  config.subtask = loaded.subtask;
483
484
  return config;
484
485
  }
485
- function collectAgents(dir, disabledAgents, nativeAgents, overlays) {
486
+ function collectAgents(dir, disabledAgents, nativeAgents, overlays, rawOverlays) {
486
487
  const agents = {};
487
488
  const agentList = findAgentsInDir(dir);
488
489
  const disabledSet = new Set(disabledAgents);
@@ -497,12 +498,16 @@ function collectAgents(dir, disabledAgents, nativeAgents, overlays) {
497
498
  continue;
498
499
  const config = loadAgentAsConfig(agentInfo);
499
500
  if (config) {
500
- agents[agentInfo.name] = applyAgentOverlays(config, agentInfo, overlays);
501
+ agents[agentInfo.name] = applyAgentOverlays(config, agentInfo, overlays, rawOverlays);
501
502
  }
502
503
  }
503
504
  return agents;
504
505
  }
505
- function applyAgentOverlays(config, agentInfo, overlays) {
506
+ var EMPTY_PI_SUBAGENTS_OVERLAYS = {
507
+ agents: {},
508
+ categories: {}
509
+ };
510
+ function applyAgentOverlays(config, agentInfo, overlays, rawOverlays) {
506
511
  const id = agentInfo.category ? `${agentInfo.category}/${agentInfo.name}` : agentInfo.name;
507
512
  const categoryOverlay = agentInfo.category ? overlays.categoriesByKey.get(agentInfo.category) : undefined;
508
513
  const exactOverlay = overlays.agentsByTargetId.get(id);
@@ -512,15 +517,40 @@ function applyAgentOverlays(config, agentInfo, overlays) {
512
517
  if (hasPermissionOverlay && isRecord(config.permission)) {
513
518
  addPermissionRules(permissionRules, config.permission);
514
519
  }
515
- applyAgentOverlay(result, categoryOverlay?.value, permissionRules);
516
- applyAgentOverlay(result, exactOverlay?.value, permissionRules);
520
+ const routing = resolveRouting({
521
+ overlays: rawOverlays,
522
+ piSubagentsOverlays: EMPTY_PI_SUBAGENTS_OVERLAYS,
523
+ target: { agentKey: agentInfo.name, category: agentInfo.category ?? "" },
524
+ harness: "opencode"
525
+ });
526
+ applyAgentOverlayPass(result, categoryOverlay?.value, permissionRules, routing, "category");
527
+ applyAgentOverlayPass(result, exactOverlay?.value, permissionRules, routing, "agent");
517
528
  applyPermissionOverlay(result, permissionRules, hasPermissionOverlay);
518
529
  return result;
519
530
  }
520
- function applyAgentOverlay(target, overlay, permissionRules) {
531
+ function applyAgentOverlayPass(target, overlay, permissionRules, routing, level) {
532
+ if (routing.source.model?.level === level) {
533
+ applyRoutingModel(target, routing.model);
534
+ }
535
+ if (routing.source.qualifier?.level === level) {
536
+ target.variant = routing.qualifier;
537
+ }
521
538
  if (overlay === undefined)
522
539
  return;
523
- applyOverlayObjectWithVariantClearing(target, overlay, permissionRules);
540
+ applyOverlayObjectFields(target, overlay);
541
+ if (isRecord(overlay.permission)) {
542
+ addPermissionRules(permissionRules, overlay.permission);
543
+ }
544
+ if (Array.isArray(overlay.skills)) {
545
+ addManagedSkillRules(permissionRules, overlay.skills);
546
+ }
547
+ }
548
+ function applyRoutingModel(target, model) {
549
+ if (model === null) {
550
+ delete target.model;
551
+ } else if (model !== undefined) {
552
+ target.model = model;
553
+ }
524
554
  }
525
555
  function applyPermissionOverlay(target, permissionRules, hasPermissionOverlay) {
526
556
  if (!hasPermissionOverlay)
@@ -536,8 +566,6 @@ function overlayControlsPermission(overlay) {
536
566
  return overlay !== undefined && (Object.hasOwn(overlay, "permission") || Object.hasOwn(overlay, "skills"));
537
567
  }
538
568
  var OVERLAY_ASSIGN_FIELDS = [
539
- "model",
540
- "variant",
541
569
  "temperature",
542
570
  "top_p",
543
571
  "mode",
@@ -545,27 +573,12 @@ var OVERLAY_ASSIGN_FIELDS = [
545
573
  "steps",
546
574
  "hidden"
547
575
  ];
548
- function applyOverlayObjectWithVariantClearing(target, overlay, permissionRules) {
549
- const overlayHasModel = Object.hasOwn(overlay, "model");
550
- const overlayHasVariant = Object.hasOwn(overlay, "variant");
551
- if (overlayHasModel && !overlayHasVariant) {
552
- delete target.variant;
553
- }
576
+ function applyOverlayObjectFields(target, overlay) {
554
577
  for (const field of OVERLAY_ASSIGN_FIELDS) {
555
578
  if (Object.hasOwn(overlay, field)) {
556
- if (field === "model" && overlay[field] === null) {
557
- delete target[field];
558
- } else {
559
- target[field] = overlay[field];
560
- }
579
+ target[field] = overlay[field];
561
580
  }
562
581
  }
563
- if (isRecord(overlay.permission)) {
564
- addPermissionRules(permissionRules, overlay.permission);
565
- }
566
- if (Array.isArray(overlay.skills)) {
567
- addManagedSkillRules(permissionRules, overlay.skills);
568
- }
569
582
  }
570
583
  function createPermissionRuleAccumulator() {
571
584
  return new Map;
@@ -708,7 +721,7 @@ function createConfigHandler(deps) {
708
721
  enabledSkills: enabledSkillNames
709
722
  });
710
723
  const resolvedOverlays = resolveAgentOverlaySet(validatedOverlays);
711
- const bundledAgents = collectAgents(bundledAgentsDir, systematicConfig.disabled_agents, nativeAgents, resolvedOverlays);
724
+ const bundledAgents = collectAgents(bundledAgentsDir, systematicConfig.disabled_agents, nativeAgents, resolvedOverlays, overlays);
712
725
  const bundledCommands = collectCommands(bundledCommandsDir, systematicConfig.disabled_commands);
713
726
  const discoveredSkillCommands = systematicConfig.skills_as_commands !== false ? collectDiscoveredSkillsAsCommands(directory, homeDir, opencodeConfigDir, opencodeConfigDirOverride, systematicConfig.disabled_commands) : {};
714
727
  const bundledAgentKeys = new Set(Object.keys(bundledAgents));
@@ -3992,7 +4005,7 @@ import { randomBytes as randomBytes3 } from "crypto";
3992
4005
  import fs7 from "fs";
3993
4006
  import { fileURLToPath } from "url";
3994
4007
 
3995
- // node_modules/.bun/web-tree-sitter@0.26.12/node_modules/web-tree-sitter/web-tree-sitter.js
4008
+ // node_modules/.bun/web-tree-sitter@0.27.0/node_modules/web-tree-sitter/web-tree-sitter.js
3996
4009
  var __defProp = Object.defineProperty;
3997
4010
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3998
4011
  var Edit = class {
@@ -4097,44 +4110,65 @@ function setModule(module2) {
4097
4110
  }
4098
4111
  __name(setModule, "setModule");
4099
4112
  var C;
4113
+ function newFinalizer(handler) {
4114
+ try {
4115
+ return new FinalizationRegistry(handler);
4116
+ } catch (e) {
4117
+ console.error("Unsupported FinalizationRegistry:", e);
4118
+ return;
4119
+ }
4120
+ }
4121
+ __name(newFinalizer, "newFinalizer");
4122
+ var finalizer = newFinalizer((address) => {
4123
+ C._ts_lookahead_iterator_delete(address);
4124
+ });
4100
4125
  var LookaheadIterator = class {
4101
4126
  static {
4102
4127
  __name(this, "LookaheadIterator");
4103
4128
  }
4104
4129
  [0] = 0;
4105
4130
  language;
4131
+ positioned = false;
4106
4132
  constructor(internal, address, language) {
4107
4133
  assertInternal(internal);
4108
4134
  this[0] = address;
4109
4135
  this.language = language;
4136
+ finalizer?.register(this, address, this);
4110
4137
  }
4111
4138
  get currentTypeId() {
4112
- return C._ts_lookahead_iterator_current_symbol(this[0]);
4139
+ return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
4113
4140
  }
4114
4141
  get currentType() {
4115
- return this.language.types[this.currentTypeId] || "ERROR";
4142
+ const id = this.currentTypeId;
4143
+ if (id === null)
4144
+ return null;
4145
+ return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
4116
4146
  }
4117
4147
  delete() {
4148
+ finalizer?.unregister(this);
4118
4149
  C._ts_lookahead_iterator_delete(this[0]);
4119
4150
  this[0] = 0;
4120
4151
  }
4121
4152
  reset(language, stateId) {
4122
4153
  if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
4123
4154
  this.language = language;
4155
+ this.positioned = false;
4124
4156
  return true;
4125
4157
  }
4126
4158
  return false;
4127
4159
  }
4128
4160
  resetState(stateId) {
4129
- return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
4161
+ if (!C._ts_lookahead_iterator_reset_state(this[0], stateId))
4162
+ return false;
4163
+ this.positioned = false;
4164
+ return true;
4130
4165
  }
4131
4166
  [Symbol.iterator]() {
4132
4167
  return {
4133
4168
  next: /* @__PURE__ */ __name(() => {
4134
- if (C._ts_lookahead_iterator_next(this[0])) {
4135
- return { done: false, value: this.currentType };
4136
- }
4137
- return { done: true, value: "" };
4169
+ this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
4170
+ const value = this.currentType;
4171
+ return value === null ? { done: true, value: "" } : { done: false, value };
4138
4172
  }, "next")
4139
4173
  };
4140
4174
  }
@@ -4160,6 +4194,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
4160
4194
  return result ?? "";
4161
4195
  }
4162
4196
  __name(getText, "getText");
4197
+ var finalizer2 = newFinalizer((address) => {
4198
+ C._ts_tree_delete(address);
4199
+ });
4163
4200
  var Tree = class _Tree {
4164
4201
  static {
4165
4202
  __name(this, "Tree");
@@ -4172,12 +4209,14 @@ var Tree = class _Tree {
4172
4209
  this[0] = address;
4173
4210
  this.language = language;
4174
4211
  this.textCallback = textCallback;
4212
+ finalizer2?.register(this, address, this);
4175
4213
  }
4176
4214
  copy() {
4177
4215
  const address = C._ts_tree_copy(this[0]);
4178
4216
  return new _Tree(INTERNAL, address, this.language, this.textCallback);
4179
4217
  }
4180
4218
  delete() {
4219
+ finalizer2?.unregister(this);
4181
4220
  C._ts_tree_delete(this[0]);
4182
4221
  this[0] = 0;
4183
4222
  }
@@ -4233,6 +4272,9 @@ var Tree = class _Tree {
4233
4272
  return result;
4234
4273
  }
4235
4274
  };
4275
+ var finalizer3 = newFinalizer((address) => {
4276
+ C._ts_tree_cursor_delete_wasm(address);
4277
+ });
4236
4278
  var TreeCursor = class _TreeCursor {
4237
4279
  static {
4238
4280
  __name(this, "TreeCursor");
@@ -4246,6 +4288,7 @@ var TreeCursor = class _TreeCursor {
4246
4288
  assertInternal(internal);
4247
4289
  this.tree = tree;
4248
4290
  unmarshalTreeCursor(this);
4291
+ finalizer3?.register(this, this.tree[0], this);
4249
4292
  }
4250
4293
  copy() {
4251
4294
  const copy = new _TreeCursor(INTERNAL, this.tree);
@@ -4254,6 +4297,7 @@ var TreeCursor = class _TreeCursor {
4254
4297
  return copy;
4255
4298
  }
4256
4299
  delete() {
4300
+ finalizer3?.unregister(this);
4257
4301
  marshalTreeCursor(this);
4258
4302
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
4259
4303
  this[0] = this[1] = this[2] = 0;
@@ -5013,16 +5057,23 @@ ${body2}`);
5013
5057
  }
5014
5058
  }
5015
5059
  const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
5060
+ return _Language.loadFromWasmExports(mod, { sync: false });
5061
+ }
5062
+ static loadFromWasmExports(mod, { sync }) {
5016
5063
  const symbolNames = Object.keys(mod);
5017
5064
  const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
5018
5065
  if (!functionName) {
5019
5066
  console.log(`Couldn't find language function in Wasm file. Symbols:
5020
5067
  ${JSON.stringify(symbolNames, null, 2)}`);
5021
- throw new Error("Language.load failed: no language function found in Wasm file");
5068
+ throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
5022
5069
  }
5023
5070
  const languageAddress = mod[functionName]();
5024
5071
  return new _Language(INTERNAL, languageAddress);
5025
5072
  }
5073
+ static loadSync(wasmModule) {
5074
+ const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
5075
+ return _Language.loadFromWasmExports(mod, { sync: true });
5076
+ }
5026
5077
  };
5027
5078
  async function Module2(moduleArg = {}) {
5028
5079
  var moduleRtn;
@@ -5542,7 +5593,7 @@ async function Module2(moduleArg = {}) {
5542
5593
  newDSO("__main__", 0, wasmImports);
5543
5594
  }
5544
5595
  };
5545
- var ___heap_base = 78240;
5596
+ var ___heap_base = 82240;
5546
5597
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
5547
5598
  var getMemory = /* @__PURE__ */ __name((size) => {
5548
5599
  if (runtimeInitialized) {
@@ -6068,12 +6119,12 @@ async function Module2(moduleArg = {}) {
6068
6119
  value: "i32",
6069
6120
  mutable: false
6070
6121
  }, 1024);
6071
- var ___stack_high = 78240;
6072
- var ___stack_low = 12704;
6122
+ var ___stack_high = 82240;
6123
+ var ___stack_low = 16704;
6073
6124
  var ___stack_pointer = new WebAssembly.Global({
6074
6125
  value: "i32",
6075
6126
  mutable: true
6076
- }, 78240);
6127
+ }, 82240);
6077
6128
  var ___table_base = new WebAssembly.Global({
6078
6129
  value: "i32",
6079
6130
  mutable: false
@@ -6340,7 +6391,7 @@ async function Module2(moduleArg = {}) {
6340
6391
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
6341
6392
  Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
6342
6393
  var ASM_CONSTS = {};
6343
- var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
6394
+ var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_copy, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswpunct, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
6344
6395
  function assignWasmExports(wasmExports2) {
6345
6396
  Module["_malloc"] = _malloc = wasmExports2["malloc"];
6346
6397
  Module["_calloc"] = _calloc = wasmExports2["calloc"];
@@ -6374,6 +6425,7 @@ async function Module2(moduleArg = {}) {
6374
6425
  Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
6375
6426
  Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
6376
6427
  Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
6428
+ Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
6377
6429
  Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
6378
6430
  Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
6379
6431
  Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
@@ -6479,6 +6531,7 @@ async function Module2(moduleArg = {}) {
6479
6531
  Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
6480
6532
  Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
6481
6533
  Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
6534
+ Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
6482
6535
  Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
6483
6536
  Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
6484
6537
  Module["_memchr"] = _memchr = wasmExports2["memchr"];
@@ -6598,6 +6651,10 @@ __name(checkModule, "checkModule");
6598
6651
  var TRANSFER_BUFFER;
6599
6652
  var LANGUAGE_VERSION;
6600
6653
  var MIN_COMPATIBLE_VERSION;
6654
+ var finalizer4 = newFinalizer((addresses) => {
6655
+ C._ts_parser_delete(addresses[0]);
6656
+ C._free(addresses[1]);
6657
+ });
6601
6658
  var Parser = class {
6602
6659
  static {
6603
6660
  __name(this, "Parser");
@@ -6614,6 +6671,7 @@ var Parser = class {
6614
6671
  }
6615
6672
  constructor() {
6616
6673
  this.initialize();
6674
+ finalizer4?.register(this, [this[0], this[1]], this);
6617
6675
  }
6618
6676
  initialize() {
6619
6677
  if (!checkModule()) {
@@ -6624,6 +6682,7 @@ var Parser = class {
6624
6682
  this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
6625
6683
  }
6626
6684
  delete() {
6685
+ finalizer4?.unregister(this);
6627
6686
  C._ts_parser_delete(this[0]);
6628
6687
  C._free(this[1]);
6629
6688
  this[0] = 0;
@@ -6754,6 +6813,10 @@ var QueryError = class _QueryError extends Error {
6754
6813
  this.length = length;
6755
6814
  this.name = "QueryError";
6756
6815
  }
6816
+ kind;
6817
+ info;
6818
+ index;
6819
+ length;
6757
6820
  static {
6758
6821
  __name(this, "QueryError");
6759
6822
  }
@@ -6937,6 +7000,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
6937
7000
  }
6938
7001
  }
6939
7002
  __name(parsePattern, "parsePattern");
7003
+ var finalizer5 = newFinalizer((address) => {
7004
+ C._ts_query_delete(address);
7005
+ });
6940
7006
  var Query = class {
6941
7007
  static {
6942
7008
  __name(this, "Query");
@@ -7036,8 +7102,10 @@ var Query = class {
7036
7102
  this.assertedProperties = assertedProperties;
7037
7103
  this.refutedProperties = refutedProperties;
7038
7104
  this.exceededMatchLimit = false;
7105
+ finalizer5?.register(this, address, this);
7039
7106
  }
7040
7107
  delete() {
7108
+ finalizer5?.unregister(this);
7041
7109
  C._ts_query_delete(this[0]);
7042
7110
  this[0] = 0;
7043
7111
  }
@@ -1,7 +1,7 @@
1
1
  /** Runtime persona catalog for `systematic_delegate`. Pi has no agent-discovery of its own, so category is dropped when flattening `agents/<category>/<name>.md` into this catalog. */
2
2
  /** A single resolved persona entry in the flattened catalog. */
3
3
  export interface AgentCatalogEntry {
4
- /** Flat persona name (category dropped). */
4
+ /** Flat persona name (category dropped). Used for dispatch matching (`resolveAgent`); may differ from `key` if frontmatter `name` and the file stem diverge. */
5
5
  name: string;
6
6
  /** Human-readable description, used in tool description/parameter hints. */
7
7
  description: string;
@@ -9,6 +9,12 @@ export interface AgentCatalogEntry {
9
9
  body: string;
10
10
  /** Raw comma-separated `tools:` frontmatter value, if declared. Undefined = not declared. */
11
11
  toolsSource: string | undefined;
12
+ /** The agent's source file stem (filename without `.md`), used to key into `agents.<key>` overlays for routing (distinct from the display `name`). */
13
+ key: string;
14
+ /** The agent's category (source subdirectory name), used to key into `categories.<category>` overlays. `''` when the file has no category subdirectory -- the same no-category sentinel `config-handler.ts` and `pi-subagents-export.ts` use. */
15
+ category: string;
16
+ /** Qualified `category/key` id, mirroring `agent-overlays.ts`'s target-id convention, for callers that want a single stable identity. */
17
+ id: string;
12
18
  }
13
19
  /** Fails closed if the same persona name appears under more than one category. */
14
20
  export declare function buildAgentCatalog(agentsDir: string): AgentCatalogEntry[];
@@ -3,7 +3,7 @@ declare const CAPABILITY_SNAPSHOT_COMMAND: 'systematic capabilities';
3
3
  declare const CAPABILITY_SOURCE_IDS: readonly ['config:custom', 'config:global', 'config:project', 'config:user', 'discovery:agents', 'discovery:skills', 'host:runtime', 'package'];
4
4
  declare const CONFIG_SOURCE_KINDS: readonly ['custom', 'project', 'user'];
5
5
  declare const CONFIG_AUTHORITY_FIELD_PATHS: readonly ['bootstrap.enabled', 'bootstrap.file', 'skills_as_commands', 'workflow_guard.debug', 'workflow_guard.mode'];
6
- declare const CONFIG_PROTECTED_FIELD_PATHS: readonly ['workflow_guard', 'agents.*.model', 'agents.*.permission', 'agents.*.skills', 'agents.*.variant', 'categories.*.model', 'categories.*.permission', 'categories.*.skills', 'categories.*.variant'];
6
+ declare const CONFIG_PROTECTED_FIELD_PATHS: readonly ['workflow_guard', 'profiles', 'agents.*.model', 'agents.*.permission', 'agents.*.skills', 'agents.*.variant', 'agents.*.opencode', 'agents.*.pi', 'categories.*.model', 'categories.*.permission', 'categories.*.skills', 'categories.*.variant', 'categories.*.opencode', 'categories.*.pi'];
7
7
  declare const CONFIG_SOURCE_ERROR_CODES: readonly ['parse-failed', 'read-failed', 'schema-invalid', 'source-invalid'];
8
8
  declare const CAPABILITY_SOURCE_PRESENCE: readonly ['absent', 'invalid', 'present'];
9
9
  declare const CAPABILITY_STATUSES: readonly ['available', 'unknown', 'unavailable'];
@@ -54,6 +54,22 @@ export declare const AgentOverlaySchema: z.ZodObject<{
54
54
  ask: "ask";
55
55
  deny: "deny";
56
56
  }>>]>>>;
57
+ opencode: z.ZodOptional<z.ZodObject<{
58
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
59
+ variant: z.ZodOptional<z.ZodString>;
60
+ }, z.core.$strict>>;
61
+ pi: z.ZodOptional<z.ZodObject<{
62
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
63
+ thinking: z.ZodOptional<z.ZodEnum<{
64
+ high: "high";
65
+ low: "low";
66
+ max: "max";
67
+ medium: "medium";
68
+ minimal: "minimal";
69
+ off: "off";
70
+ xhigh: "xhigh";
71
+ }>>;
72
+ }, z.core.$strict>>;
57
73
  }, z.core.$strict>;
58
74
  export declare const CategoryOverlaySchema: z.ZodObject<{
59
75
  model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -86,6 +102,52 @@ export declare const CategoryOverlaySchema: z.ZodObject<{
86
102
  ask: "ask";
87
103
  deny: "deny";
88
104
  }>>]>>>;
105
+ opencode: z.ZodOptional<z.ZodObject<{
106
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
+ variant: z.ZodOptional<z.ZodString>;
108
+ }, z.core.$strict>>;
109
+ pi: z.ZodOptional<z.ZodObject<{
110
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
111
+ thinking: z.ZodOptional<z.ZodEnum<{
112
+ high: "high";
113
+ low: "low";
114
+ max: "max";
115
+ medium: "medium";
116
+ minimal: "minimal";
117
+ off: "off";
118
+ xhigh: "xhigh";
119
+ }>>;
120
+ }, z.core.$strict>>;
121
+ }, z.core.$strict>;
122
+ /**
123
+ * Routing-only projection of the agent/category overlay fields, permitted
124
+ * inside a named `profiles` bundle. Deliberately excludes every non-routing
125
+ * field (`mode`, `color`, `steps`, `hidden`, `disable`, `skills`,
126
+ * `permission`) so a profile cannot smuggle in UI/execution/permission
127
+ * changes through the profile-selection mechanism — only the fields a
128
+ * profile exists to carry: model, variant/thinking, and sampling knobs.
129
+ */
130
+ export declare const ProfileOverlaySchema: z.ZodObject<{
131
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
132
+ variant: z.ZodOptional<z.ZodString>;
133
+ temperature: z.ZodOptional<z.ZodNumber>;
134
+ top_p: z.ZodOptional<z.ZodNumber>;
135
+ opencode: z.ZodOptional<z.ZodObject<{
136
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
137
+ variant: z.ZodOptional<z.ZodString>;
138
+ }, z.core.$strict>>;
139
+ pi: z.ZodOptional<z.ZodObject<{
140
+ model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
141
+ thinking: z.ZodOptional<z.ZodEnum<{
142
+ high: "high";
143
+ low: "low";
144
+ max: "max";
145
+ medium: "medium";
146
+ minimal: "minimal";
147
+ off: "off";
148
+ xhigh: "xhigh";
149
+ }>>;
150
+ }, z.core.$strict>>;
89
151
  }, z.core.$strict>;
90
152
  export declare const PiSubagentsAgentOverlaySchema: z.ZodObject<{
91
153
  thinking: z.ZodOptional<z.ZodEnum<{
@@ -201,4 +263,4 @@ export declare function validateConfig(input: unknown): ValidationResult;
201
263
  *
202
264
  * Matches the hand-coded `SECURITY_OVERLAY_FIELDS` set in `src/lib/config.ts`.
203
265
  */
204
- export declare const SECURITY_OVERLAY_FIELDS: readonly ['model', 'variant', 'skills', 'permission'];
266
+ export declare const SECURITY_OVERLAY_FIELDS: readonly ['model', 'variant', 'skills', 'permission', 'opencode', 'pi'];
@@ -1,3 +1,4 @@
1
+ import { type RoutingTarget } from './routing-resolver.js';
1
2
  export interface BootstrapConfig {
2
3
  enabled: boolean;
3
4
  file?: string;
@@ -19,7 +20,7 @@ export interface SourcedOverlayConfigMap {
19
20
  categories: Record<string, SourcedOverlayConfig>;
20
21
  }
21
22
  export declare const CONFIG_AUTHORITY_FIELD_PATHS: readonly ['bootstrap.enabled', 'bootstrap.file', 'skills_as_commands', 'workflow_guard.debug', 'workflow_guard.mode'];
22
- export declare const CONFIG_PROTECTED_FIELD_PATHS: readonly ['workflow_guard', 'agents.*.model', 'agents.*.permission', 'agents.*.skills', 'agents.*.variant', 'categories.*.model', 'categories.*.permission', 'categories.*.skills', 'categories.*.variant'];
23
+ export declare const CONFIG_PROTECTED_FIELD_PATHS: readonly ['workflow_guard', 'profiles', 'agents.*.model', 'agents.*.permission', 'agents.*.skills', 'agents.*.variant', 'agents.*.opencode', 'agents.*.pi', 'categories.*.model', 'categories.*.permission', 'categories.*.skills', 'categories.*.variant', 'categories.*.opencode', 'categories.*.pi'];
23
24
  export type ConfigSourceKind = 'custom' | 'project' | 'user';
24
25
  export type ConfigSourcePresence = 'absent' | 'invalid' | 'present';
25
26
  export type ConfigSourceErrorCode = 'parse-failed' | 'read-failed' | 'schema-invalid' | 'source-invalid';
@@ -39,15 +40,48 @@ export interface ConfigProtectedFieldMetadata {
39
40
  readonly outcome: 'blocked';
40
41
  readonly sourceKind: ConfigSourceKind;
41
42
  }
43
+ /**
44
+ * The source kind that supplied the winning `profile` selector value, or
45
+ * `null` when no source set `profile` at all (case 1 of the selection table
46
+ * in plan 2026-09-04-002-feat-model-config-profiles, Unit 2). This names
47
+ * whichever source's value won the `custom ?? project ?? user` selector
48
+ * lookup -- including when that value turned out to name a missing bundle
49
+ * and the loader fell back to the user's own default (see
50
+ * {@link ConfigObservationMetadata.profileFallback}).
51
+ */
52
+ export type ProfileSelectorSource = ConfigSourceKind | null;
53
+ /**
54
+ * Present when the winning `profile` selector named a bundle absent from
55
+ * the user source's `profiles` map. `usedDefault` names the user's own
56
+ * default profile if it resolved instead, or `null` if the loader fell back
57
+ * to base configuration (no profile).
58
+ */
59
+ export interface ProfileFallbackMetadata {
60
+ readonly requested: string;
61
+ readonly usedDefault: string | null;
62
+ }
42
63
  export interface ConfigObservationMetadata {
43
64
  readonly authorities: readonly ConfigAuthorityMetadata[];
44
65
  readonly protectedFields: readonly ConfigProtectedFieldMetadata[];
45
66
  readonly sources: readonly ConfigSourceMetadata[];
67
+ /** The active profile's name, or `null` when base configuration is active. */
68
+ readonly activeProfile: string | null;
69
+ readonly profileSelectorSource: ProfileSelectorSource;
70
+ readonly profileFallback: ProfileFallbackMetadata | null;
46
71
  }
47
72
  export interface SourceAwareConfigResult {
48
73
  config: SystematicConfig;
49
74
  metadata: ConfigObservationMetadata;
50
75
  overlays: SourcedOverlayConfigMap;
76
+ /**
77
+ * Merged `pi_subagents.{agents,categories}` overlays (three-entry chain --
78
+ * user, project, custom; no profile pseudo-entry, see the merge-order
79
+ * comment in `loadConfigWithSources`). Exposed so a caller building a
80
+ * routing table (e.g. `systematic config show`) can pass the exact same
81
+ * legacy-`thinking`-fallback input `resolveRouting` uses internally for
82
+ * the post-merge qualifier check, without recomputing it.
83
+ */
84
+ piSubagentsOverlays: SourcedOverlayConfigMap;
51
85
  }
52
86
  export interface PiSubagentsOverlayMap {
53
87
  categories?: OverlayConfigMap;
@@ -95,6 +129,30 @@ export interface LoadConfigOptions {
95
129
  }
96
130
  export declare function loadConfig(projectDir: string, options?: LoadConfigOptions): SystematicConfig;
97
131
  export declare function loadConfigWithSources(projectDir: string, options?: LoadConfigOptions): SourceAwareConfigResult;
132
+ /**
133
+ * Enumerate every routing-resolver target implied by the merged overlays:
134
+ * every raw agent-overlay key that resolves to a real bundled agent (bare or
135
+ * qualified `category/key`), plus every bundled agent whose category has a
136
+ * category overlay (R3b's "categories are not checked in isolation" --
137
+ * `categories.review.variant` with no category model is fine as long as
138
+ * every agent in `review` resolves its own model, so every agent in an
139
+ * overlaid category must be walked, not just the category itself).
140
+ *
141
+ * A raw overlay key that does not resolve to any known bundled agent (e.g.
142
+ * an unrestricted `profiles.<name>.agents.<key>` entry naming something that
143
+ * isn't a real bundled agent) is silently skipped here -- it is not a valid
144
+ * routing target and this check has no stronger claim to make about it than
145
+ * schema validation already does elsewhere.
146
+ *
147
+ * A disabled agent is excluded from the result: matched by bare key or
148
+ * qualified `category/key` id in `disabledAgents` (the merged
149
+ * `disabled_agents` list), or by its own effective overlay's
150
+ * `disable: true` (bare key checked before the qualified id, mirroring
151
+ * `config-handler.ts`'s `collectAgents`/`applyAgentOverlays` precedence).
152
+ * A disabled agent is never emitted to OpenCode at all, so it must never
153
+ * block config load over a routing invariant it can't violate in practice.
154
+ */
155
+ export declare function collectRoutingTargets(overlays: SourcedOverlayConfigMap, disabledAgents?: ReadonlySet<string>): RoutingTarget[];
98
156
  interface ConfigPathOptions {
99
157
  readonly homeDir?: string;
100
158
  readonly userConfigDir?: string;
@@ -22,6 +22,8 @@ export declare function buildDelegateAgentSessionOptions(options: {
22
22
  cwd: string;
23
23
  agentDir: string;
24
24
  model: CreateAgentSessionOptions['model'];
25
+ /** Omitted (not `undefined`-valued) when unset, so the child inherits Pi's default thinking level instead of an explicit `undefined` overriding it. */
26
+ thinkingLevel?: CreateAgentSessionOptions['thinkingLevel'];
25
27
  allowedToolNames: string[];
26
28
  resourceLoader: ResourceLoader;
27
29
  sessionManager: ReturnType<typeof SessionManager.inMemory>;