crewbee 0.1.10 → 0.1.12

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 (156) hide show
  1. package/README.md +438 -239
  2. package/README.zh-CN.md +320 -129
  3. package/dist/opencode-plugin.mjs +765 -506
  4. package/dist/src/adapters/opencode/bootstrap.d.ts +1 -0
  5. package/dist/src/adapters/opencode/bootstrap.d.ts.map +1 -1
  6. package/dist/src/adapters/opencode/bootstrap.js +1 -0
  7. package/dist/src/adapters/opencode/bootstrap.js.map +1 -1
  8. package/dist/src/adapters/opencode/chat-message-hook.d.ts.map +1 -1
  9. package/dist/src/adapters/opencode/chat-message-hook.js +2 -1
  10. package/dist/src/adapters/opencode/chat-message-hook.js.map +1 -1
  11. package/dist/src/adapters/opencode/config-hook.d.ts.map +1 -1
  12. package/dist/src/adapters/opencode/config-hook.js +3 -3
  13. package/dist/src/adapters/opencode/config-hook.js.map +1 -1
  14. package/dist/src/adapters/opencode/defaults.d.ts +3 -0
  15. package/dist/src/adapters/opencode/defaults.d.ts.map +1 -0
  16. package/dist/src/adapters/opencode/defaults.js +5 -0
  17. package/dist/src/adapters/opencode/defaults.js.map +1 -0
  18. package/dist/src/adapters/opencode/index.d.ts +1 -0
  19. package/dist/src/adapters/opencode/index.d.ts.map +1 -1
  20. package/dist/src/adapters/opencode/index.js +3 -1
  21. package/dist/src/adapters/opencode/index.js.map +1 -1
  22. package/dist/src/adapters/opencode/model-resolution.d.ts +33 -0
  23. package/dist/src/adapters/opencode/model-resolution.d.ts.map +1 -0
  24. package/dist/src/adapters/opencode/model-resolution.js +180 -0
  25. package/dist/src/adapters/opencode/model-resolution.js.map +1 -0
  26. package/dist/src/adapters/opencode/projection.d.ts +4 -1
  27. package/dist/src/adapters/opencode/projection.d.ts.map +1 -1
  28. package/dist/src/adapters/opencode/projection.js +7 -12
  29. package/dist/src/adapters/opencode/projection.js.map +1 -1
  30. package/dist/src/adapters/opencode/prompt-builder.d.ts.map +1 -1
  31. package/dist/src/adapters/opencode/prompt-builder.js +7 -17
  32. package/dist/src/adapters/opencode/prompt-builder.js.map +1 -1
  33. package/dist/src/agent-teams/canonical-agent-id.d.ts.map +1 -1
  34. package/dist/src/agent-teams/canonical-agent-id.js +11 -0
  35. package/dist/src/agent-teams/canonical-agent-id.js.map +1 -1
  36. package/dist/src/agent-teams/constants.d.ts +4 -0
  37. package/dist/src/agent-teams/constants.d.ts.map +1 -1
  38. package/dist/src/agent-teams/constants.js +14 -1
  39. package/dist/src/agent-teams/constants.js.map +1 -1
  40. package/dist/src/agent-teams/embedded/coding-team/agent-helpers.d.ts +1 -3
  41. package/dist/src/agent-teams/embedded/coding-team/agent-helpers.d.ts.map +1 -1
  42. package/dist/src/agent-teams/embedded/coding-team/agent-helpers.js +4 -14
  43. package/dist/src/agent-teams/embedded/coding-team/agent-helpers.js.map +1 -1
  44. package/dist/src/agent-teams/embedded/coding-team/agent-profile-builder.d.ts +4 -0
  45. package/dist/src/agent-teams/embedded/coding-team/agent-profile-builder.d.ts.map +1 -0
  46. package/dist/src/agent-teams/embedded/coding-team/agent-profile-builder.js +17 -0
  47. package/dist/src/agent-teams/embedded/coding-team/agent-profile-builder.js.map +1 -0
  48. package/dist/src/agent-teams/embedded/coding-team/agents/codebase-explorer.js +5 -5
  49. package/dist/src/agent-teams/embedded/coding-team/agents/codebase-explorer.js.map +1 -1
  50. package/dist/src/agent-teams/embedded/coding-team/agents/coding-executor.js +4 -4
  51. package/dist/src/agent-teams/embedded/coding-team/agents/coding-executor.js.map +1 -1
  52. package/dist/src/agent-teams/embedded/coding-team/agents/coding-leader.js +8 -8
  53. package/dist/src/agent-teams/embedded/coding-team/agents/coding-leader.js.map +1 -1
  54. package/dist/src/agent-teams/embedded/coding-team/agents/coordination-leader.js +8 -8
  55. package/dist/src/agent-teams/embedded/coding-team/agents/coordination-leader.js.map +1 -1
  56. package/dist/src/agent-teams/embedded/coding-team/agents/multimodal-looker.js +2 -2
  57. package/dist/src/agent-teams/embedded/coding-team/agents/multimodal-looker.js.map +1 -1
  58. package/dist/src/agent-teams/embedded/coding-team/agents/principal-advisor.js +5 -5
  59. package/dist/src/agent-teams/embedded/coding-team/agents/principal-advisor.js.map +1 -1
  60. package/dist/src/agent-teams/embedded/coding-team/agents/reviewer.js +6 -6
  61. package/dist/src/agent-teams/embedded/coding-team/agents/reviewer.js.map +1 -1
  62. package/dist/src/agent-teams/embedded/coding-team/agents/web-researcher.js +5 -5
  63. package/dist/src/agent-teams/embedded/coding-team/agents/web-researcher.js.map +1 -1
  64. package/dist/src/agent-teams/embedded/coding-team.d.ts.map +1 -1
  65. package/dist/src/agent-teams/embedded/coding-team.js +20 -10
  66. package/dist/src/agent-teams/embedded/coding-team.js.map +1 -1
  67. package/dist/src/agent-teams/filesystem.d.ts +10 -0
  68. package/dist/src/agent-teams/filesystem.d.ts.map +1 -1
  69. package/dist/src/agent-teams/filesystem.js +32 -0
  70. package/dist/src/agent-teams/filesystem.js.map +1 -1
  71. package/dist/src/agent-teams/library.d.ts.map +1 -1
  72. package/dist/src/agent-teams/library.js +7 -2
  73. package/dist/src/agent-teams/library.js.map +1 -1
  74. package/dist/src/agent-teams/parsers.d.ts.map +1 -1
  75. package/dist/src/agent-teams/parsers.js +7 -1
  76. package/dist/src/agent-teams/parsers.js.map +1 -1
  77. package/dist/src/agent-teams/validation.d.ts.map +1 -1
  78. package/dist/src/agent-teams/validation.js +14 -0
  79. package/dist/src/agent-teams/validation.js.map +1 -1
  80. package/dist/src/cli/doctor.d.ts.map +1 -1
  81. package/dist/src/cli/doctor.js +31 -7
  82. package/dist/src/cli/doctor.js.map +1 -1
  83. package/dist/src/cli/install.d.ts.map +1 -1
  84. package/dist/src/cli/install.js +8 -3
  85. package/dist/src/cli/install.js.map +1 -1
  86. package/dist/src/cli/parse-install-options.d.ts.map +1 -1
  87. package/dist/src/cli/parse-install-options.js +31 -0
  88. package/dist/src/cli/parse-install-options.js.map +1 -1
  89. package/dist/src/cli/parse-setup-options.d.ts +3 -0
  90. package/dist/src/cli/parse-setup-options.d.ts.map +1 -0
  91. package/dist/src/cli/parse-setup-options.js +102 -0
  92. package/dist/src/cli/parse-setup-options.js.map +1 -0
  93. package/dist/src/cli/render-help.d.ts.map +1 -1
  94. package/dist/src/cli/render-help.js +10 -3
  95. package/dist/src/cli/render-help.js.map +1 -1
  96. package/dist/src/cli/run-cli.d.ts.map +1 -1
  97. package/dist/src/cli/run-cli.js +20 -1
  98. package/dist/src/cli/run-cli.js.map +1 -1
  99. package/dist/src/cli/setup.d.ts +7 -0
  100. package/dist/src/cli/setup.d.ts.map +1 -0
  101. package/dist/src/cli/setup.js +70 -0
  102. package/dist/src/cli/setup.js.map +1 -0
  103. package/dist/src/cli/uninstall-user.d.ts.map +1 -1
  104. package/dist/src/cli/uninstall-user.js +2 -1
  105. package/dist/src/cli/uninstall-user.js.map +1 -1
  106. package/dist/src/core/index.d.ts +13 -1
  107. package/dist/src/core/index.d.ts.map +1 -1
  108. package/dist/src/install/config-writer.d.ts +2 -18
  109. package/dist/src/install/config-writer.d.ts.map +1 -1
  110. package/dist/src/install/config-writer.js +9 -94
  111. package/dist/src/install/config-writer.js.map +1 -1
  112. package/dist/src/install/doctor.d.ts.map +1 -1
  113. package/dist/src/install/doctor.js +21 -19
  114. package/dist/src/install/doctor.js.map +1 -1
  115. package/dist/src/install/index.d.ts +6 -4
  116. package/dist/src/install/index.d.ts.map +1 -1
  117. package/dist/src/install/index.js +20 -11
  118. package/dist/src/install/index.js.map +1 -1
  119. package/dist/src/install/install.d.ts.map +1 -1
  120. package/dist/src/install/install.js +50 -33
  121. package/dist/src/install/install.js.map +1 -1
  122. package/dist/src/install/opencode-cli.d.ts +14 -0
  123. package/dist/src/install/opencode-cli.d.ts.map +1 -0
  124. package/dist/src/install/opencode-cli.js +58 -0
  125. package/dist/src/install/opencode-cli.js.map +1 -0
  126. package/dist/src/install/opencode-config-file.d.ts +26 -0
  127. package/dist/src/install/opencode-config-file.d.ts.map +1 -0
  128. package/dist/src/install/opencode-config-file.js +131 -0
  129. package/dist/src/install/opencode-config-file.js.map +1 -0
  130. package/dist/src/install/package-installation.d.ts +19 -0
  131. package/dist/src/install/package-installation.d.ts.map +1 -0
  132. package/dist/src/install/package-installation.js +95 -0
  133. package/dist/src/install/package-installation.js.map +1 -0
  134. package/dist/src/install/package-manager.d.ts +1 -14
  135. package/dist/src/install/package-manager.d.ts.map +1 -1
  136. package/dist/src/install/package-manager.js +8 -79
  137. package/dist/src/install/package-manager.js.map +1 -1
  138. package/dist/src/install/plugin-entry.d.ts +3 -1
  139. package/dist/src/install/plugin-entry.d.ts.map +1 -1
  140. package/dist/src/install/plugin-entry.js +11 -22
  141. package/dist/src/install/plugin-entry.js.map +1 -1
  142. package/dist/src/install/setup.d.ts +6 -0
  143. package/dist/src/install/setup.d.ts.map +1 -0
  144. package/dist/src/install/setup.js +72 -0
  145. package/dist/src/install/setup.js.map +1 -0
  146. package/dist/src/install/types.d.ts +36 -0
  147. package/dist/src/install/types.d.ts.map +1 -1
  148. package/dist/src/install/uninstall.d.ts.map +1 -1
  149. package/dist/src/install/uninstall.js +30 -18
  150. package/dist/src/install/uninstall.js.map +1 -1
  151. package/dist/src/render/prompt-document-renderer.d.ts +4 -0
  152. package/dist/src/render/prompt-document-renderer.d.ts.map +1 -0
  153. package/dist/src/render/prompt-document-renderer.js +19 -0
  154. package/dist/src/render/prompt-document-renderer.js.map +1 -0
  155. package/package.json +5 -2
  156. package/templates/crewbee.json +30 -1
@@ -7331,6 +7331,19 @@ var BUILTIN_CODING_TEAM_ID = "coding-team";
7331
7331
  var DEFAULT_EMBEDDED_TEAM_PRIORITY = 0;
7332
7332
  var DEFAULT_FILE_TEAM_PRIORITY = 1;
7333
7333
  var EMBEDDED_TEAM_IDS = [BUILTIN_CODING_TEAM_ID];
7334
+ var BUILTIN_CODING_TEAM_MODEL_PRESET = "sota-2026-05";
7335
+ var BUILTIN_CODING_TEAM_MODEL_FALLBACK = "builtin-role-chain";
7336
+ var BUILTIN_CODING_TEAM_FALLBACK_TO_HOST_DEFAULT = true;
7337
+ var BUILTIN_CODING_TEAM_AGENT_MODELS = {
7338
+ "coding-leader": "openai/gpt-5.5",
7339
+ "coordination-leader": "openai/gpt-5.5",
7340
+ "coding-executor": "openai/gpt-5.5",
7341
+ "codebase-explorer": "openai/gpt-5.4-mini",
7342
+ "web-researcher": "google/gemini-3.1-pro-preview",
7343
+ reviewer: "anthropic/claude-opus-4-7",
7344
+ "principal-advisor": "anthropic/claude-opus-4-7",
7345
+ "multimodal-looker": "google/gemini-3.1-pro-preview"
7346
+ };
7334
7347
 
7335
7348
  // src/agent-teams/documentation.ts
7336
7349
  import { existsSync, readdirSync } from "node:fs";
@@ -7354,14 +7367,14 @@ function resolveTeamDocumentation(teamDir, workspaceRoot = process.cwd()) {
7354
7367
  };
7355
7368
  }
7356
7369
 
7357
- // src/agent-teams/embedded/coding-team/agent-helpers.ts
7358
- function createAgent(metadata, config2) {
7370
+ // src/agent-teams/embedded/coding-team/agent-profile-builder.ts
7371
+ function createAgentProfile(metadata, profile) {
7359
7372
  return {
7360
7373
  metadata,
7361
- ...config2
7374
+ ...profile
7362
7375
  };
7363
7376
  }
7364
- function binding(agentRef, description) {
7377
+ function createCollaborationBinding(agentRef, description) {
7365
7378
  return {
7366
7379
  agentRef,
7367
7380
  description
@@ -7370,7 +7383,7 @@ function binding(agentRef, description) {
7370
7383
 
7371
7384
  // src/agent-teams/embedded/coding-team/agents/codebase-explorer.ts
7372
7385
  function createCodebaseExplorerAgent() {
7373
- return createAgent(
7386
+ return createAgentProfile(
7374
7387
  {
7375
7388
  id: "codebase-explorer",
7376
7389
  name: "\u4EE3\u7801\u5E93\u63A2\u7D22\u8005",
@@ -7444,9 +7457,9 @@ function createCodebaseExplorerAgent() {
7444
7457
  },
7445
7458
  collaboration: {
7446
7459
  defaultConsults: [
7447
- binding("web-researcher", "\u5F53\u4ED3\u5E93\u95EE\u9898\u6D89\u53CA\u5916\u90E8\u4F9D\u8D56\u3001\u5B98\u65B9\u6587\u6863\u6216\u5F00\u6E90\u5B9E\u73B0\u65F6\u8865\u5916\u90E8\u8BC1\u636E"),
7448
- binding("multimodal-looker", "\u5F53\u5B9A\u4F4D\u4F9D\u8D56\u622A\u56FE\u3001PDF\u3001\u67B6\u6784\u56FE\u7B49\u975E\u6E90\u7801\u6750\u6599\u65F6\u89E3\u8BFB"),
7449
- binding("principal-advisor", "\u5F53\u641C\u7D22\u7ED3\u679C\u66B4\u9732\u590D\u6742\u7ED3\u6784\u5206\u6B67\uFF0C\u4E14\u9700\u8981\u66F4\u9AD8\u5C42\u6B21\u6280\u672F\u5224\u65AD\u65F6\u54A8\u8BE2")
7460
+ createCollaborationBinding("web-researcher", "\u5F53\u4ED3\u5E93\u95EE\u9898\u6D89\u53CA\u5916\u90E8\u4F9D\u8D56\u3001\u5B98\u65B9\u6587\u6863\u6216\u5F00\u6E90\u5B9E\u73B0\u65F6\u8865\u5916\u90E8\u8BC1\u636E"),
7461
+ createCollaborationBinding("multimodal-looker", "\u5F53\u5B9A\u4F4D\u4F9D\u8D56\u622A\u56FE\u3001PDF\u3001\u67B6\u6784\u56FE\u7B49\u975E\u6E90\u7801\u6750\u6599\u65F6\u89E3\u8BFB"),
7462
+ createCollaborationBinding("principal-advisor", "\u5F53\u641C\u7D22\u7ED3\u679C\u66B4\u9732\u590D\u6742\u7ED3\u6784\u5206\u6B67\uFF0C\u4E14\u9700\u8981\u66F4\u9AD8\u5C42\u6B21\u6280\u672F\u5224\u65AD\u65F6\u54A8\u8BE2")
7450
7463
  ],
7451
7464
  defaultHandoffs: []
7452
7465
  },
@@ -7556,7 +7569,7 @@ function createCodebaseExplorerAgent() {
7556
7569
 
7557
7570
  // src/agent-teams/embedded/coding-team/agents/coordination-leader.ts
7558
7571
  function createCoordinationLeaderAgent() {
7559
- return createAgent(
7572
+ return createAgentProfile(
7560
7573
  {
7561
7574
  id: "coordination-leader",
7562
7575
  name: "\u7BA1\u7406\u578B\u7EC4\u957F",
@@ -7638,14 +7651,14 @@ function createCoordinationLeaderAgent() {
7638
7651
  },
7639
7652
  collaboration: {
7640
7653
  defaultConsults: [
7641
- binding("codebase-explorer", "\u4ED3\u5E93\u5185\u4EE3\u7801\u5B9A\u4F4D\u3001\u4F9D\u8D56\u5173\u7CFB\u4E0E\u6A21\u5F0F\u63A2\u7D22"),
7642
- binding("web-researcher", "\u5916\u90E8\u6587\u6863\u3001\u7248\u672C\u3001\u6700\u4F73\u5B9E\u8DF5\u4E0E\u5F00\u6E90\u5B9E\u73B0\u7814\u7A76"),
7643
- binding("reviewer", "\u9ED8\u8BA4\u72EC\u7ACB\u590D\u6838\u8D44\u6E90\uFF1B\u7528\u4E8E\u8BA1\u5212\u3001\u5B9E\u73B0\u7ED3\u679C\u4E0E\u5B8C\u6210\u58F0\u660E\u7684\u4E8C\u6B21\u6821\u9A8C\u3002\u5BF9\u975E\u7410\u788E\u4EFB\u52A1\uFF0C\u901A\u5E38\u5E94\u5728\u5BA3\u79F0\u5B8C\u6210\u524D\u8003\u8651\u8BF7\u6C42\u5176\u5BA1\u89C6\uFF1B\u662F\u5426\u8C03\u7528\u7531\u5F53\u524D owner \u6839\u636E\u98CE\u9669\u3001\u590D\u6742\u5EA6\u4E0E\u8BC1\u636E\u5145\u5206\u6027\u5224\u65AD\u3002"),
7644
- binding("principal-advisor", "\u9AD8\u4EE3\u4EF7\u67B6\u6784\u3001\u5B89\u5168\u3001\u6027\u80FD\u4E0E\u590D\u6742\u5EA6\u51B3\u7B56\u54A8\u8BE2"),
7645
- binding("multimodal-looker", "\u56FE\u8868\u3001PDF\u3001\u622A\u56FE\u3001\u754C\u9762\u4E0E\u67B6\u6784\u56FE\u89E3\u8BFB")
7654
+ createCollaborationBinding("codebase-explorer", "\u4ED3\u5E93\u5185\u4EE3\u7801\u5B9A\u4F4D\u3001\u4F9D\u8D56\u5173\u7CFB\u4E0E\u6A21\u5F0F\u63A2\u7D22"),
7655
+ createCollaborationBinding("web-researcher", "\u5916\u90E8\u6587\u6863\u3001\u7248\u672C\u3001\u6700\u4F73\u5B9E\u8DF5\u4E0E\u5F00\u6E90\u5B9E\u73B0\u7814\u7A76"),
7656
+ createCollaborationBinding("reviewer", "\u9ED8\u8BA4\u72EC\u7ACB\u590D\u6838\u8D44\u6E90\uFF1B\u7528\u4E8E\u8BA1\u5212\u3001\u5B9E\u73B0\u7ED3\u679C\u4E0E\u5B8C\u6210\u58F0\u660E\u7684\u4E8C\u6B21\u6821\u9A8C\u3002\u5BF9\u975E\u7410\u788E\u4EFB\u52A1\uFF0C\u901A\u5E38\u5E94\u5728\u5BA3\u79F0\u5B8C\u6210\u524D\u8003\u8651\u8BF7\u6C42\u5176\u5BA1\u89C6\uFF1B\u662F\u5426\u8C03\u7528\u7531\u5F53\u524D owner \u6839\u636E\u98CE\u9669\u3001\u590D\u6742\u5EA6\u4E0E\u8BC1\u636E\u5145\u5206\u6027\u5224\u65AD\u3002"),
7657
+ createCollaborationBinding("principal-advisor", "\u9AD8\u4EE3\u4EF7\u67B6\u6784\u3001\u5B89\u5168\u3001\u6027\u80FD\u4E0E\u590D\u6742\u5EA6\u51B3\u7B56\u54A8\u8BE2"),
7658
+ createCollaborationBinding("multimodal-looker", "\u56FE\u8868\u3001PDF\u3001\u622A\u56FE\u3001\u754C\u9762\u4E0E\u67B6\u6784\u56FE\u89E3\u8BFB")
7646
7659
  ],
7647
7660
  defaultHandoffs: [
7648
- binding("coding-executor", "\u8FB9\u754C\u6E05\u6670\u6216\u5DF2\u6536\u675F\u7684\u5B9E\u73B0\u3001\u4FEE\u590D\u3001\u8C03\u8BD5\u4E0E\u5C40\u90E8\u91CD\u6784\u6267\u884C\u8005")
7661
+ createCollaborationBinding("coding-executor", "\u8FB9\u754C\u6E05\u6670\u6216\u5DF2\u6536\u675F\u7684\u5B9E\u73B0\u3001\u4FEE\u590D\u3001\u8C03\u8BD5\u4E0E\u5C40\u90E8\u91CD\u6784\u6267\u884C\u8005")
7649
7662
  ]
7650
7663
  },
7651
7664
  runtimeConfig: {
@@ -7933,7 +7946,7 @@ function createCoordinationLeaderAgent() {
7933
7946
 
7934
7947
  // src/agent-teams/embedded/coding-team/agents/coding-executor.ts
7935
7948
  function createCodingExecutorAgent() {
7936
- return createAgent(
7949
+ return createAgentProfile(
7937
7950
  {
7938
7951
  id: "coding-executor",
7939
7952
  name: "\u7F16\u7801\u6267\u884C\u8005",
@@ -8009,8 +8022,8 @@ function createCodingExecutorAgent() {
8009
8022
  },
8010
8023
  collaboration: {
8011
8024
  defaultConsults: [
8012
- binding("codebase-explorer", "\u4EE3\u7801\u5E93\u63A2\u7D22\u8005"),
8013
- binding("web-researcher", "\u5728\u7EBF\u7814\u7A76\u8005")
8025
+ createCollaborationBinding("codebase-explorer", "\u4EE3\u7801\u5E93\u63A2\u7D22\u8005"),
8026
+ createCollaborationBinding("web-researcher", "\u5728\u7EBF\u7814\u7A76\u8005")
8014
8027
  ],
8015
8028
  defaultHandoffs: []
8016
8029
  },
@@ -8120,7 +8133,7 @@ function createCodingExecutorAgent() {
8120
8133
 
8121
8134
  // src/agent-teams/embedded/coding-team/agents/coding-leader.ts
8122
8135
  function createCodingLeaderAgent() {
8123
- return createAgent(
8136
+ return createAgentProfile(
8124
8137
  {
8125
8138
  id: "coding-leader",
8126
8139
  name: "CodingLeader",
@@ -8200,14 +8213,14 @@ function createCodingLeaderAgent() {
8200
8213
  },
8201
8214
  collaboration: {
8202
8215
  defaultConsults: [
8203
- binding("codebase-explorer", "\u4ED3\u5E93\u5185\u4EE3\u7801\u5B9A\u4F4D\u3001\u8C03\u7528\u94FE\u548C\u6A21\u5F0F\u63A2\u7D22"),
8204
- binding("web-researcher", "\u5916\u90E8\u6587\u6863\u3001\u5F00\u6E90\u5B9E\u73B0\u3001\u7248\u672C\u4E0E\u5386\u53F2\u8BC1\u636E\u7814\u7A76"),
8205
- binding("reviewer", "\u9ED8\u8BA4\u72EC\u7ACB\u590D\u6838\u8D44\u6E90\uFF1B\u7528\u4E8E\u8BA1\u5212\u3001\u5B9E\u73B0\u7ED3\u679C\u4E0E\u5B8C\u6210\u58F0\u660E\u7684\u4E8C\u6B21\u6821\u9A8C\u3002\u5BF9\u975E\u7410\u788E\u4EFB\u52A1\uFF0C\u901A\u5E38\u5E94\u5728\u5BA3\u79F0\u5B8C\u6210\u524D\u8003\u8651\u8BF7\u6C42\u5176\u5BA1\u89C6\uFF1B\u662F\u5426\u8C03\u7528\u7531\u5F53\u524D owner \u6839\u636E\u98CE\u9669\u3001\u590D\u6742\u5EA6\u4E0E\u8BC1\u636E\u5145\u5206\u6027\u5224\u65AD\u3002"),
8206
- binding("principal-advisor", "\u9AD8\u98CE\u9669\u67B6\u6784\u3001\u6027\u80FD\u3001\u5B89\u5168\u4E0E\u590D\u6742\u5EA6\u51B3\u7B56\u54A8\u8BE2"),
8207
- binding("multimodal-looker", "\u56FE\u8868\u3001\u622A\u56FE\u3001PDF\u3001\u754C\u9762\u4E0E\u67B6\u6784\u56FE\u7684\u591A\u6A21\u6001\u89E3\u8BFB")
8216
+ createCollaborationBinding("codebase-explorer", "\u4ED3\u5E93\u5185\u4EE3\u7801\u5B9A\u4F4D\u3001\u8C03\u7528\u94FE\u548C\u6A21\u5F0F\u63A2\u7D22"),
8217
+ createCollaborationBinding("web-researcher", "\u5916\u90E8\u6587\u6863\u3001\u5F00\u6E90\u5B9E\u73B0\u3001\u7248\u672C\u4E0E\u5386\u53F2\u8BC1\u636E\u7814\u7A76"),
8218
+ createCollaborationBinding("reviewer", "\u9ED8\u8BA4\u72EC\u7ACB\u590D\u6838\u8D44\u6E90\uFF1B\u7528\u4E8E\u8BA1\u5212\u3001\u5B9E\u73B0\u7ED3\u679C\u4E0E\u5B8C\u6210\u58F0\u660E\u7684\u4E8C\u6B21\u6821\u9A8C\u3002\u5BF9\u975E\u7410\u788E\u4EFB\u52A1\uFF0C\u901A\u5E38\u5E94\u5728\u5BA3\u79F0\u5B8C\u6210\u524D\u8003\u8651\u8BF7\u6C42\u5176\u5BA1\u89C6\uFF1B\u662F\u5426\u8C03\u7528\u7531\u5F53\u524D owner \u6839\u636E\u98CE\u9669\u3001\u590D\u6742\u5EA6\u4E0E\u8BC1\u636E\u5145\u5206\u6027\u5224\u65AD\u3002"),
8219
+ createCollaborationBinding("principal-advisor", "\u9AD8\u98CE\u9669\u67B6\u6784\u3001\u6027\u80FD\u3001\u5B89\u5168\u4E0E\u590D\u6742\u5EA6\u51B3\u7B56\u54A8\u8BE2"),
8220
+ createCollaborationBinding("multimodal-looker", "\u56FE\u8868\u3001\u622A\u56FE\u3001PDF\u3001\u754C\u9762\u4E0E\u67B6\u6784\u56FE\u7684\u591A\u6A21\u6001\u89E3\u8BFB")
8208
8221
  ],
8209
8222
  defaultHandoffs: [
8210
- binding("coding-executor", "\u8FB9\u754C\u6E05\u6670\u3001\u65E0\u9700\u590D\u6742\u7F16\u6392\u7684\u53F6\u5B50\u5B9E\u73B0\u3001\u4FEE\u590D\u3001\u8C03\u8BD5\u4E0E\u5C40\u90E8\u91CD\u6784")
8223
+ createCollaborationBinding("coding-executor", "\u8FB9\u754C\u6E05\u6670\u3001\u65E0\u9700\u590D\u6742\u7F16\u6392\u7684\u53F6\u5B50\u5B9E\u73B0\u3001\u4FEE\u590D\u3001\u8C03\u8BD5\u4E0E\u5C40\u90E8\u91CD\u6784")
8211
8224
  ]
8212
8225
  },
8213
8226
  runtimeConfig: {
@@ -8479,7 +8492,7 @@ function createCodingLeaderAgent() {
8479
8492
 
8480
8493
  // src/agent-teams/embedded/coding-team/agents/multimodal-looker.ts
8481
8494
  function createMultimodalLookerAgent() {
8482
- return createAgent(
8495
+ return createAgentProfile(
8483
8496
  {
8484
8497
  id: "multimodal-looker",
8485
8498
  name: "MultimodalLooker",
@@ -8626,7 +8639,7 @@ function createMultimodalLookerAgent() {
8626
8639
 
8627
8640
  // src/agent-teams/embedded/coding-team/agents/principal-advisor.ts
8628
8641
  function createPrincipalAdvisorAgent() {
8629
- return createAgent(
8642
+ return createAgentProfile(
8630
8643
  {
8631
8644
  id: "principal-advisor",
8632
8645
  name: "\u9996\u5E2D\u987E\u95EE",
@@ -8710,9 +8723,9 @@ function createPrincipalAdvisorAgent() {
8710
8723
  },
8711
8724
  collaboration: {
8712
8725
  defaultConsults: [
8713
- binding("codebase-explorer", "\u4ED3\u5E93\u5185\u7ED3\u6784\u3001\u8C03\u7528\u94FE\u3001\u6A21\u5F0F\u4E0E\u5B9E\u73B0\u4F4D\u7F6E\u63A2\u7D22"),
8714
- binding("web-researcher", "\u5916\u90E8\u6587\u6863\u3001\u6700\u4F73\u5B9E\u8DF5\u3001\u7248\u672C\u5DEE\u5F02\u4E0E\u5F00\u6E90\u5B9E\u73B0\u7814\u7A76"),
8715
- binding("multimodal-looker", "\u56FE\u8868\u3001PDF\u3001\u622A\u56FE\u3001\u754C\u9762\u4E0E\u67B6\u6784\u56FE\u89E3\u8BFB")
8726
+ createCollaborationBinding("codebase-explorer", "\u4ED3\u5E93\u5185\u7ED3\u6784\u3001\u8C03\u7528\u94FE\u3001\u6A21\u5F0F\u4E0E\u5B9E\u73B0\u4F4D\u7F6E\u63A2\u7D22"),
8727
+ createCollaborationBinding("web-researcher", "\u5916\u90E8\u6587\u6863\u3001\u6700\u4F73\u5B9E\u8DF5\u3001\u7248\u672C\u5DEE\u5F02\u4E0E\u5F00\u6E90\u5B9E\u73B0\u7814\u7A76"),
8728
+ createCollaborationBinding("multimodal-looker", "\u56FE\u8868\u3001PDF\u3001\u622A\u56FE\u3001\u754C\u9762\u4E0E\u67B6\u6784\u56FE\u89E3\u8BFB")
8716
8729
  ],
8717
8730
  defaultHandoffs: []
8718
8731
  },
@@ -8910,7 +8923,7 @@ function createPrincipalAdvisorAgent() {
8910
8923
 
8911
8924
  // src/agent-teams/embedded/coding-team/agents/reviewer.ts
8912
8925
  function createReviewerAgent() {
8913
- return createAgent(
8926
+ return createAgentProfile(
8914
8927
  {
8915
8928
  id: "reviewer",
8916
8929
  name: "\u8BC4\u5BA1\u8005",
@@ -8994,10 +9007,10 @@ function createReviewerAgent() {
8994
9007
  },
8995
9008
  collaboration: {
8996
9009
  defaultConsults: [
8997
- binding("codebase-explorer", "\u4ED3\u5E93\u5185\u5F15\u7528\u3001\u8C03\u7528\u94FE\u3001\u6A21\u5F0F\u4E0E\u5B9E\u73B0\u4F4D\u7F6E\u63A2\u7D22"),
8998
- binding("web-researcher", "\u5916\u90E8\u6587\u6863\u3001\u7248\u672C\u884C\u4E3A\u4E0E\u53C2\u8003\u5B9E\u73B0\u6838\u9A8C"),
8999
- binding("principal-advisor", "\u9AD8\u98CE\u9669\u67B6\u6784\u3001\u5B89\u5168\u3001\u6027\u80FD\u6216\u590D\u6742\u5EA6\u95EE\u9898\u54A8\u8BE2"),
9000
- binding("multimodal-looker", "\u56FE\u8868\u3001PDF\u3001\u622A\u56FE\u3001\u754C\u9762\u4E0E\u67B6\u6784\u56FE\u89E3\u8BFB")
9010
+ createCollaborationBinding("codebase-explorer", "\u4ED3\u5E93\u5185\u5F15\u7528\u3001\u8C03\u7528\u94FE\u3001\u6A21\u5F0F\u4E0E\u5B9E\u73B0\u4F4D\u7F6E\u63A2\u7D22"),
9011
+ createCollaborationBinding("web-researcher", "\u5916\u90E8\u6587\u6863\u3001\u7248\u672C\u884C\u4E3A\u4E0E\u53C2\u8003\u5B9E\u73B0\u6838\u9A8C"),
9012
+ createCollaborationBinding("principal-advisor", "\u9AD8\u98CE\u9669\u67B6\u6784\u3001\u5B89\u5168\u3001\u6027\u80FD\u6216\u590D\u6742\u5EA6\u95EE\u9898\u54A8\u8BE2"),
9013
+ createCollaborationBinding("multimodal-looker", "\u56FE\u8868\u3001PDF\u3001\u622A\u56FE\u3001\u754C\u9762\u4E0E\u67B6\u6784\u56FE\u89E3\u8BFB")
9001
9014
  ],
9002
9015
  defaultHandoffs: []
9003
9016
  },
@@ -9195,7 +9208,7 @@ function createReviewerAgent() {
9195
9208
 
9196
9209
  // src/agent-teams/embedded/coding-team/agents/web-researcher.ts
9197
9210
  function createWebResearcherAgent() {
9198
- return createAgent(
9211
+ return createAgentProfile(
9199
9212
  {
9200
9213
  id: "web-researcher",
9201
9214
  name: "\u5728\u7EBF\u7814\u7A76\u8005",
@@ -9268,9 +9281,9 @@ function createWebResearcherAgent() {
9268
9281
  },
9269
9282
  collaboration: {
9270
9283
  defaultConsults: [
9271
- binding("codebase-explorer", "\u5F53\u5916\u90E8\u7814\u7A76\u9700\u8981\u6620\u5C04\u56DE\u672C\u4ED3\u5E93\u4E2D\u7684\u63A5\u5165\u70B9\u3001\u8C03\u7528\u4F4D\u7F6E\u6216\u65E2\u6709\u6A21\u5F0F\u65F6\u534F\u540C"),
9272
- binding("multimodal-looker", "\u5F53\u5B98\u65B9\u8D44\u6599\u6216\u5F00\u6E90\u8BA8\u8BBA\u5305\u542B PDF\u3001\u622A\u56FE\u3001\u56FE\u8868\u7B49\u975E\u6E90\u7801\u6750\u6599\u65F6\u89E3\u8BFB"),
9273
- binding("principal-advisor", "\u5F53\u7814\u7A76\u7ED3\u679C\u9700\u8981\u5347\u683C\u4E3A\u67B6\u6784\u3001\u5B89\u5168\u3001\u6027\u80FD\u6216\u590D\u6742\u5EA6\u51B3\u7B56\u65F6\u54A8\u8BE2")
9284
+ createCollaborationBinding("codebase-explorer", "\u5F53\u5916\u90E8\u7814\u7A76\u9700\u8981\u6620\u5C04\u56DE\u672C\u4ED3\u5E93\u4E2D\u7684\u63A5\u5165\u70B9\u3001\u8C03\u7528\u4F4D\u7F6E\u6216\u65E2\u6709\u6A21\u5F0F\u65F6\u534F\u540C"),
9285
+ createCollaborationBinding("multimodal-looker", "\u5F53\u5B98\u65B9\u8D44\u6599\u6216\u5F00\u6E90\u8BA8\u8BBA\u5305\u542B PDF\u3001\u622A\u56FE\u3001\u56FE\u8868\u7B49\u975E\u6E90\u7801\u6750\u6599\u65F6\u89E3\u8BFB"),
9286
+ createCollaborationBinding("principal-advisor", "\u5F53\u7814\u7A76\u7ED3\u679C\u9700\u8981\u5347\u683C\u4E3A\u67B6\u6784\u3001\u5B89\u5168\u3001\u6027\u80FD\u6216\u590D\u6742\u5EA6\u51B3\u7B56\u65F6\u54A8\u8BE2")
9274
9287
  ],
9275
9288
  defaultHandoffs: []
9276
9289
  },
@@ -9492,7 +9505,27 @@ function createCodingTeamAgents() {
9492
9505
  }
9493
9506
 
9494
9507
  // src/agent-teams/embedded/coding-team.ts
9508
+ var CODING_TEAM_RUNTIME_PROFILES = {
9509
+ "coding-leader": { temperature: 0.2, topP: 0.85, variant: "long-context" },
9510
+ "coordination-leader": { temperature: 0.15, topP: 0.75 },
9511
+ "coding-executor": { temperature: 0.25, topP: 0.9 },
9512
+ "codebase-explorer": { temperature: 0.1, topP: 0.8 },
9513
+ "web-researcher": { temperature: 0.2, topP: 0.85 },
9514
+ reviewer: { temperature: 0.15, topP: 0.75 },
9515
+ "principal-advisor": { temperature: 0.15, topP: 0.75 },
9516
+ "multimodal-looker": { temperature: 0.2, topP: 0.85 }
9517
+ };
9495
9518
  function createEmbeddedCodingTeam() {
9519
+ const runtime = Object.fromEntries(
9520
+ Object.entries(BUILTIN_CODING_TEAM_AGENT_MODELS).map(([agentId, model]) => [
9521
+ agentId,
9522
+ {
9523
+ model,
9524
+ ...CODING_TEAM_RUNTIME_PROFILES[agentId],
9525
+ fallbackToHostDefault: BUILTIN_CODING_TEAM_FALLBACK_TO_HOST_DEFAULT
9526
+ }
9527
+ ])
9528
+ );
9496
9529
  const manifest = {
9497
9530
  id: "coding-team",
9498
9531
  version: "1.0.0",
@@ -9601,16 +9634,7 @@ function createEmbeddedCodingTeam() {
9601
9634
  "\u4ED3\u5E93\u5185\u7814\u7A76\u4E0E\u5916\u90E8\u7814\u7A76\u5FC5\u987B\u5206\u79BB"
9602
9635
  ]
9603
9636
  },
9604
- agentRuntime: {
9605
- "coding-leader": { provider: "openai", model: "gpt-5.5", temperature: 0.2, topP: 0.85, variant: "long-context" },
9606
- "coordination-leader": { provider: "openai", model: "gpt-5.5", temperature: 0.15, topP: 0.75 },
9607
- "coding-executor": { provider: "openai", model: "gpt-5.5", temperature: 0.25, topP: 0.9 },
9608
- "codebase-explorer": { provider: "openai", model: "gpt-5.5", temperature: 0.1, topP: 0.8 },
9609
- "web-researcher": { provider: "openai", model: "gpt-5.5", temperature: 0.2, topP: 0.85 },
9610
- reviewer: { provider: "openai", model: "gpt-5.5", temperature: 0.15, topP: 0.75 },
9611
- "principal-advisor": { provider: "openai", model: "gpt-5.5", temperature: 0.15, topP: 0.75 },
9612
- "multimodal-looker": { provider: "openai", model: "gpt-5.5", temperature: 0.2, topP: 0.85 }
9613
- },
9637
+ agentRuntime: runtime,
9614
9638
  tags: ["\u4EE3\u7801", "leader\u9A71\u52A8", "\u4E0A\u4E0B\u6587\u8FDE\u7EED\u6027", "\u4E3B\u6267\u884C\u8005\u4E2D\u5FC3", "\u8BC4\u5BA1\u4E2D\u5FC3", "\u8BC1\u636E\u9A71\u52A8"]
9615
9639
  };
9616
9640
  const agents = createCodingTeamAgents();
@@ -10228,12 +10252,14 @@ function mapAgentRuntime(raw) {
10228
10252
  const record2 = asRecord(value, `agent_runtime.${agentId}`);
10229
10253
  const options = asOptionalRecord(record2.options);
10230
10254
  const runtime = {
10231
- provider: asString(record2.provider, `agent_runtime.${agentId}.provider`),
10255
+ provider: record2.provider !== void 0 ? asString(record2.provider, `agent_runtime.${agentId}.provider`) : void 0,
10232
10256
  model: asString(record2.model, `agent_runtime.${agentId}.model`),
10233
10257
  temperature: record2.temperature !== void 0 ? Number(record2.temperature) : void 0,
10234
10258
  topP: record2.top_p !== void 0 || record2.topP !== void 0 ? Number(record2.top_p ?? record2.topP) : void 0,
10235
10259
  variant: asOptionalString(record2.variant),
10236
- options: options ? { ...options } : void 0
10260
+ options: options ? { ...options } : void 0,
10261
+ fallbackModels: record2.fallback_models || record2.fallbackModels ? asStringArray(record2.fallback_models ?? record2.fallbackModels, `agent_runtime.${agentId}.fallback_models`) : void 0,
10262
+ fallbackToHostDefault: record2.fallback_to_host_default !== void 0 || record2.fallbackToHostDefault !== void 0 ? asBoolean(record2.fallback_to_host_default ?? record2.fallbackToHostDefault, `agent_runtime.${agentId}.fallback_to_host_default`) : void 0
10237
10263
  };
10238
10264
  return [agentId, runtime];
10239
10265
  })
@@ -10492,6 +10518,31 @@ function getOptionalPriority(value, fallback) {
10492
10518
  function getOptionalString(value) {
10493
10519
  return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
10494
10520
  }
10521
+ function normalizeConfiguredTeamModelOverride(raw) {
10522
+ const modelPreset = getOptionalString(raw.model_preset ?? raw.modelPreset);
10523
+ const fallback = getOptionalString(raw.fallback);
10524
+ const fallbackToHostDefaultValue = raw.fallback_to_host_default ?? raw.fallbackToHostDefault;
10525
+ const fallbackToHostDefault = typeof fallbackToHostDefaultValue === "boolean" ? fallbackToHostDefaultValue : void 0;
10526
+ const agents = isRecord3(raw.agents) ? Object.fromEntries(
10527
+ Object.entries(raw.agents).flatMap(([agentId, value]) => {
10528
+ if (!isRecord3(value)) {
10529
+ return [];
10530
+ }
10531
+ const model = getOptionalString(value.model);
10532
+ return [[agentId, { ...model ? { model } : {} }]];
10533
+ })
10534
+ ) : void 0;
10535
+ const normalizedAgents = agents && Object.keys(agents).length > 0 ? agents : void 0;
10536
+ if (!modelPreset && !fallback && fallbackToHostDefault === void 0 && !normalizedAgents) {
10537
+ return void 0;
10538
+ }
10539
+ return {
10540
+ modelPreset,
10541
+ fallback,
10542
+ fallbackToHostDefault,
10543
+ agents: normalizedAgents
10544
+ };
10545
+ }
10495
10546
  function createDefaultCodingTeamSource(input) {
10496
10547
  return {
10497
10548
  kind: "embedded",
@@ -10501,14 +10552,21 @@ function createDefaultCodingTeamSource(input) {
10501
10552
  order: -1,
10502
10553
  sourceScope: input.sourceScope,
10503
10554
  sourcePrecedence: input.sourcePrecedence,
10504
- configPath: input.configPath
10555
+ configPath: input.configPath,
10556
+ modelConfigOverride: normalizeConfiguredTeamModelOverride(createDefaultCodingTeamConfigEntry())
10505
10557
  };
10506
10558
  }
10507
10559
  function createDefaultCodingTeamConfigEntry() {
10508
10560
  return {
10509
10561
  id: BUILTIN_CODING_TEAM_ID,
10510
10562
  enabled: true,
10511
- priority: DEFAULT_EMBEDDED_TEAM_PRIORITY
10563
+ priority: DEFAULT_EMBEDDED_TEAM_PRIORITY,
10564
+ model_preset: BUILTIN_CODING_TEAM_MODEL_PRESET,
10565
+ fallback: BUILTIN_CODING_TEAM_MODEL_FALLBACK,
10566
+ fallback_to_host_default: BUILTIN_CODING_TEAM_FALLBACK_TO_HOST_DEFAULT,
10567
+ agents: Object.fromEntries(
10568
+ Object.entries(BUILTIN_CODING_TEAM_AGENT_MODELS).map(([agentId, model]) => [agentId, { model }])
10569
+ )
10512
10570
  };
10513
10571
  }
10514
10572
  function getPackagedTemplateRootPath() {
@@ -10752,7 +10810,8 @@ function normalizeConfiguredTeamEntry(input) {
10752
10810
  order: input.index,
10753
10811
  sourceScope: input.sourceScope,
10754
10812
  sourcePrecedence: input.sourcePrecedence,
10755
- configPath: input.configPath
10813
+ configPath: input.configPath,
10814
+ modelConfigOverride: normalizeConfiguredTeamModelOverride(raw)
10756
10815
  },
10757
10816
  issues: []
10758
10817
  };
@@ -10767,7 +10826,8 @@ function normalizeConfiguredTeamEntry(input) {
10767
10826
  order: input.index,
10768
10827
  sourceScope: input.sourceScope,
10769
10828
  sourcePrecedence: input.sourcePrecedence,
10770
- configPath: input.configPath
10829
+ configPath: input.configPath,
10830
+ modelConfigOverride: normalizeConfiguredTeamModelOverride(raw)
10771
10831
  },
10772
10832
  issues: []
10773
10833
  };
@@ -11011,13 +11071,13 @@ function createCanonicalAgentId(teamId, agentId) {
11011
11071
  function createFallbackCanonicalAgentId(teamId, agentId) {
11012
11072
  return `${sanitizeSegment(teamId)}-${resolveAgentSlug(agentId)}`;
11013
11073
  }
11014
- function rewriteBinding(binding3, agentIdMap) {
11015
- if (typeof binding3 === "string") {
11016
- return agentIdMap.get(binding3) ?? binding3;
11074
+ function rewriteBinding(binding2, agentIdMap) {
11075
+ if (typeof binding2 === "string") {
11076
+ return agentIdMap.get(binding2) ?? binding2;
11017
11077
  }
11018
11078
  return {
11019
- ...binding3,
11020
- agentRef: agentIdMap.get(binding3.agentRef) ?? binding3.agentRef
11079
+ ...binding2,
11080
+ agentRef: agentIdMap.get(binding2.agentRef) ?? binding2.agentRef
11021
11081
  };
11022
11082
  }
11023
11083
  function normalizeTeamAgentIds(input) {
@@ -11068,6 +11128,15 @@ function normalizeTeamAgentIds(input) {
11068
11128
  ])
11069
11129
  ) : void 0
11070
11130
  },
11131
+ modelConfigOverride: input.team.modelConfigOverride ? {
11132
+ ...input.team.modelConfigOverride,
11133
+ agents: input.team.modelConfigOverride.agents ? Object.fromEntries(
11134
+ Object.entries(input.team.modelConfigOverride.agents).map(([agentId, override]) => [
11135
+ agentIdMap.get(agentId) ?? agentId,
11136
+ override
11137
+ ])
11138
+ ) : void 0
11139
+ } : void 0,
11071
11140
  agents: input.team.agents.map((agent) => {
11072
11141
  const canonicalAgentId = agentIdMap.get(agent.metadata.id) ?? agent.metadata.id;
11073
11142
  return {
@@ -11080,8 +11149,8 @@ function normalizeTeamAgentIds(input) {
11080
11149
  name: canonicalAgentId
11081
11150
  },
11082
11151
  collaboration: {
11083
- defaultConsults: agent.collaboration.defaultConsults.map((binding3) => rewriteBinding(binding3, agentIdMap)),
11084
- defaultHandoffs: agent.collaboration.defaultHandoffs.map((binding3) => rewriteBinding(binding3, agentIdMap))
11152
+ defaultConsults: agent.collaboration.defaultConsults.map((binding2) => rewriteBinding(binding2, agentIdMap)),
11153
+ defaultHandoffs: agent.collaboration.defaultHandoffs.map((binding2) => rewriteBinding(binding2, agentIdMap))
11085
11154
  },
11086
11155
  entryPoint: agent.entryPoint ? {
11087
11156
  ...agent.entryPoint,
@@ -11101,8 +11170,8 @@ function normalizeTeamAgentIds(input) {
11101
11170
  }
11102
11171
 
11103
11172
  // src/agent-teams/validation.ts
11104
- function getBindingAgentRef(binding3) {
11105
- return typeof binding3 === "string" ? binding3 : binding3.agentRef;
11173
+ function getBindingAgentRef(binding2) {
11174
+ return typeof binding2 === "string" ? binding2 : binding2.agentRef;
11106
11175
  }
11107
11176
  function validateTeamDefinition(team) {
11108
11177
  const issues = [];
@@ -11148,6 +11217,9 @@ function validateTeamDefinition(team) {
11148
11217
  return issues;
11149
11218
  }
11150
11219
  for (const [agentId] of Object.entries(manifest.agentRuntime ?? {})) {
11220
+ if (agentId === "$default") {
11221
+ continue;
11222
+ }
11151
11223
  if (!agentIds.has(agentId)) {
11152
11224
  issues.push({
11153
11225
  level: "warning",
@@ -11158,6 +11230,17 @@ function validateTeamDefinition(team) {
11158
11230
  });
11159
11231
  }
11160
11232
  }
11233
+ for (const [agentId] of Object.entries(team.modelConfigOverride?.agents ?? {})) {
11234
+ if (!agentIds.has(agentId)) {
11235
+ issues.push({
11236
+ level: "warning",
11237
+ code: "team_agent_model_override_target_missing",
11238
+ path: `teams.${manifest.id}.agents.${agentId}`,
11239
+ message: `Agent model override '${agentId}' is not defined in Team '${manifest.id}'.`,
11240
+ suggestion: "Remove this model override or add the target Agent profile."
11241
+ });
11242
+ }
11243
+ }
11161
11244
  for (const agent of team.agents) {
11162
11245
  const requestedTools = new Set(agent.runtimeConfig.requestedTools);
11163
11246
  const collaborationTargets = [
@@ -11299,7 +11382,10 @@ function loadDefaultTeamLibrary(input = process.cwd()) {
11299
11382
  continue;
11300
11383
  }
11301
11384
  pendingTeams.push({
11302
- loader: () => ({ team: embeddedTeam.team, issues: [] }),
11385
+ loader: () => ({
11386
+ team: embeddedTeam.team ? { ...embeddedTeam.team, modelConfigOverride: source.modelConfigOverride } : void 0,
11387
+ issues: []
11388
+ }),
11303
11389
  priority: source.priority,
11304
11390
  order: source.order,
11305
11391
  sourcePrecedence: source.sourcePrecedence,
@@ -11313,7 +11399,7 @@ function loadDefaultTeamLibrary(input = process.cwd()) {
11313
11399
  try {
11314
11400
  const loaded = loadTeamDefinitionFromDirectoryWithIssues(source.teamDir, baseDir);
11315
11401
  return {
11316
- team: loaded.team,
11402
+ team: { ...loaded.team, modelConfigOverride: source.modelConfigOverride },
11317
11403
  issues: loaded.issues
11318
11404
  };
11319
11405
  } catch (error45) {
@@ -11415,8 +11501,8 @@ function loadEmbeddedTeam(source) {
11415
11501
  };
11416
11502
  }
11417
11503
 
11418
- // src/install/config-writer.ts
11419
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
11504
+ // src/install/opencode-config-file.ts
11505
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
11420
11506
 
11421
11507
  // src/install/jsonc.ts
11422
11508
  function parseJsoncText(text) {
@@ -11530,7 +11616,7 @@ function findNextNonWhitespaceCharacter(text, startIndex) {
11530
11616
  return void 0;
11531
11617
  }
11532
11618
 
11533
- // src/install/config-writer.ts
11619
+ // src/install/opencode-config-file.ts
11534
11620
  function readOpenCodeConfig(configPath) {
11535
11621
  if (!existsSync4(configPath)) {
11536
11622
  return {
@@ -11717,51 +11803,106 @@ function shouldEmitCrewBeeLog(level = "info") {
11717
11803
  return level === "error" || level === "warn" || isCrewBeeLoggingEnabled();
11718
11804
  }
11719
11805
 
11720
- // src/adapters/opencode/delegation/prompt.ts
11721
- function truncatePrompt(value) {
11722
- const trimmed = value.trim().replace(/\s+/g, " ");
11723
- return trimmed.length <= 80 ? trimmed : `${trimmed.slice(0, 77)}...`;
11806
+ // src/adapters/opencode/capabilities.ts
11807
+ function createOpenCodeCapabilityContract() {
11808
+ return {
11809
+ supportsAgentRegistration: true,
11810
+ supportsAgentSwitching: true,
11811
+ supportsNativeAgentSelection: true,
11812
+ supportsNativeModelSelection: true,
11813
+ supportsCliOverrides: true,
11814
+ supportsSingleExecutorMode: true,
11815
+ supportsTeamCollaboration: false,
11816
+ supportsRuntimeEvents: true,
11817
+ supportsToolDomainInjection: false,
11818
+ supportsSessionLogExport: false
11819
+ };
11724
11820
  }
11725
- function createDelegatedTitle(agent, prompt) {
11726
- return `${agent}: ${truncatePrompt(prompt)}`;
11821
+
11822
+ // src/adapters/opencode/ownership.ts
11823
+ function isRecord4(value) {
11824
+ return typeof value === "object" && value !== null;
11727
11825
  }
11728
- function resolveDelegateModel(target, fallback) {
11729
- if (target.resolvedModel) {
11730
- return {
11731
- providerID: target.resolvedModel.providerID,
11732
- modelID: target.resolvedModel.modelID
11733
- };
11826
+ function isManagedCrewBeeAgentDefinition(value) {
11827
+ if (!isRecord4(value)) {
11828
+ return false;
11734
11829
  }
11735
- return fallback;
11830
+ const options = value.options;
11831
+ if (!isRecord4(options)) {
11832
+ return false;
11833
+ }
11834
+ const crewbee = options.crewbee;
11835
+ return isRecord4(crewbee) && crewbee.managed === true;
11736
11836
  }
11737
- function createDelegationEnvelope(input) {
11738
- return [
11739
- `You are continuing work as CrewBee team member: ${input.agent}.`,
11740
- "",
11741
- `Parent session: ${input.parentSessionID}`,
11742
- `Delegated session: ${input.sessionID}`,
11743
- "",
11744
- "Your delegated objective:",
11745
- input.prompt.trim(),
11746
- "",
11747
- "Execution rules:",
11748
- "- Work only on this delegated objective",
11749
- "- Do not broaden scope",
11750
- "- If you need a skill, decide and load it yourself based on the task",
11751
- "- Prefer a compact result focused on outcome, files changed, blockers, and next step",
11752
- "",
11753
- "Return:",
11754
- "1. Result / conclusion",
11755
- "2. Files changed or inspected",
11756
- "3. Remaining risk or blocker",
11757
- "4. Recommended next step"
11758
- ].join("\n");
11837
+ function createManagedCrewBeeAgentOptions(input) {
11838
+ return {
11839
+ ...input.existingOptions ?? {},
11840
+ crewbee: {
11841
+ managed: true,
11842
+ teamId: input.teamId,
11843
+ canonicalAgentId: input.canonicalAgentId
11844
+ }
11845
+ };
11759
11846
  }
11760
- function createCheckpoint(agent, model) {
11847
+
11848
+ // src/adapters/opencode/config-merge.ts
11849
+ function applyOpenCodeAgentConfigPatch(config2, patch) {
11850
+ const patchKeys = new Set(Object.keys(patch.agent));
11851
+ const nextAgents = Object.fromEntries(
11852
+ Object.entries(config2.agent ?? {}).filter(([key, definition]) => {
11853
+ if (isManagedCrewBeeAgentDefinition(definition) && !patchKeys.has(key)) {
11854
+ return false;
11855
+ }
11856
+ return true;
11857
+ })
11858
+ );
11859
+ const insertedAgentKeys = [];
11860
+ const updatedAgentKeys = [];
11861
+ const skippedAgentKeys = [];
11862
+ for (const [key, definition] of Object.entries(patch.agent)) {
11863
+ if (!(key in nextAgents)) {
11864
+ nextAgents[key] = definition;
11865
+ insertedAgentKeys.push(key);
11866
+ continue;
11867
+ }
11868
+ const existingDefinition = nextAgents[key];
11869
+ if (isManagedCrewBeeAgentDefinition(existingDefinition)) {
11870
+ nextAgents[key] = definition;
11871
+ updatedAgentKeys.push(key);
11872
+ continue;
11873
+ }
11874
+ skippedAgentKeys.push(key);
11875
+ }
11876
+ const nextConfig = {
11877
+ ...config2,
11878
+ agent: nextAgents
11879
+ };
11880
+ if (patch.defaultAgent) {
11881
+ nextConfig.default_agent = patch.defaultAgent;
11882
+ }
11761
11883
  return {
11762
- agent: agent.configKey,
11763
- model,
11764
- tools: [...agent.runtimeConfig.requestedTools]
11884
+ config: nextConfig,
11885
+ insertedAgentKeys,
11886
+ updatedAgentKeys,
11887
+ skippedAgentKeys
11888
+ };
11889
+ }
11890
+
11891
+ // src/adapters/opencode/coexistence.ts
11892
+ function createOpenCodeCoexistencePolicy() {
11893
+ return {
11894
+ pluginId: "crewbee",
11895
+ dependsOnOhMyOpenCode: false,
11896
+ featureDevelopmentMode: "mutually-exclusive",
11897
+ safeWhenCoInstalled: true,
11898
+ reservedConfigKeyPrefix: "",
11899
+ neverMutateForeignAgents: true
11900
+ };
11901
+ }
11902
+ function detectOpenCodeProjectionCollisions(input) {
11903
+ const existingConfigKeys = new Set(input.existingConfigKeys ?? []);
11904
+ return {
11905
+ configKeyCollisions: input.projectedAgents.filter((agent) => existingConfigKeys.has(agent.configKey)).map((agent) => agent.configKey)
11765
11906
  };
11766
11907
  }
11767
11908
 
@@ -11815,142 +11956,43 @@ function createOpenCodePermissionConfig(permissionRules) {
11815
11956
  return permission;
11816
11957
  }
11817
11958
 
11818
- // src/adapters/opencode/ownership.ts
11819
- function isRecord4(value) {
11820
- return typeof value === "object" && value !== null;
11821
- }
11822
- function isManagedCrewBeeAgentDefinition(value) {
11823
- if (!isRecord4(value)) {
11824
- return false;
11825
- }
11826
- const options = value.options;
11827
- if (!isRecord4(options)) {
11828
- return false;
11829
- }
11830
- const crewbee = options.crewbee;
11831
- return isRecord4(crewbee) && crewbee.managed === true;
11832
- }
11833
- function createManagedCrewBeeAgentOptions(input) {
11834
- return {
11835
- ...input.existingOptions ?? {},
11836
- crewbee: {
11837
- managed: true,
11838
- teamId: input.teamId,
11839
- canonicalAgentId: input.canonicalAgentId
11840
- }
11841
- };
11842
- }
11843
-
11844
- // src/catalog/build-prompt-catalog.ts
11845
- function formatDisplayLabel(key) {
11846
- return key.replace(/_/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char) => char.toUpperCase());
11959
+ // src/normalize/build-agent-prompt-source.ts
11960
+ function isRecord5(value) {
11961
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
11847
11962
  }
11848
- function toTitleLabel(key) {
11849
- return formatDisplayLabel(key);
11963
+ function toSnakeCase2(value) {
11964
+ return value.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[-\s]+/g, "_").toLowerCase();
11850
11965
  }
11851
- function detectNodeKind(value) {
11966
+ function toSnakeCaseValue(value) {
11852
11967
  if (Array.isArray(value)) {
11853
- return "array";
11968
+ return value.map((entry) => toSnakeCaseValue(entry));
11854
11969
  }
11855
- if (typeof value === "object") {
11856
- return "object";
11970
+ if (!isRecord5(value)) {
11971
+ return value;
11857
11972
  }
11858
- return "scalar";
11973
+ return Object.fromEntries(
11974
+ Object.entries(value).map(([key, entry]) => [toSnakeCase2(key), toSnakeCaseValue(entry)])
11975
+ );
11859
11976
  }
11860
- function buildNode(path10, key, value, order) {
11861
- const kind = detectNodeKind(value);
11862
- if (kind !== "object") {
11863
- return {
11864
- path: path10,
11865
- key,
11866
- label: toTitleLabel(key),
11867
- kind,
11868
- value,
11869
- order,
11870
- visibleByDefault: true
11871
- };
11977
+ function asMetadataRecord(value) {
11978
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
11979
+ throw new Error("agent.metadata is invalid");
11872
11980
  }
11873
- const children = Object.entries(value).map(
11874
- ([childKey, childValue], index) => buildNode(`${path10}.${childKey}`, childKey, childValue, index)
11875
- );
11876
- return {
11877
- path: path10,
11981
+ return value;
11982
+ }
11983
+ function pushBlock(blocks, key, value, order) {
11984
+ const normalized = normalizeValue(toSnakeCaseValue(value));
11985
+ if (normalized === void 0) {
11986
+ return order;
11987
+ }
11988
+ blocks.push({
11878
11989
  key,
11879
- label: toTitleLabel(key),
11880
- kind,
11881
- value,
11882
- children,
11990
+ path: key,
11991
+ value: normalized,
11883
11992
  order,
11884
- visibleByDefault: true
11885
- };
11886
- }
11887
- function applyMetadataVisibility(node) {
11888
- if (node.path !== "metadata" || !node.children) {
11889
- return node;
11890
- }
11891
- const visiblePaths = /* @__PURE__ */ new Set(["metadata.id", "metadata.name", "metadata.archetype"]);
11892
- return {
11893
- ...node,
11894
- visibleByDefault: false,
11895
- children: node.children.map((child) => ({
11896
- ...child,
11897
- visibleByDefault: visiblePaths.has(child.path)
11898
- }))
11899
- };
11900
- }
11901
- function buildPromptCatalog(doc) {
11902
- const metadataNode = applyMetadataVisibility(buildNode("metadata", "metadata", doc.metadata, -1));
11903
- const nodes = [metadataNode];
11904
- for (const block of doc.blocks) {
11905
- const node = buildNode(block.path, block.key, block.value, block.order);
11906
- nodes.push({
11907
- ...node,
11908
- label: block.title ?? node.label
11909
- });
11910
- }
11911
- return {
11912
- kind: doc.kind,
11913
- nodes
11914
- };
11915
- }
11916
-
11917
- // src/normalize/build-agent-prompt-source.ts
11918
- function isRecord5(value) {
11919
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
11920
- }
11921
- function toSnakeCase2(value) {
11922
- return value.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[-\s]+/g, "_").toLowerCase();
11923
- }
11924
- function toSnakeCaseValue(value) {
11925
- if (Array.isArray(value)) {
11926
- return value.map((entry) => toSnakeCaseValue(entry));
11927
- }
11928
- if (!isRecord5(value)) {
11929
- return value;
11930
- }
11931
- return Object.fromEntries(
11932
- Object.entries(value).map(([key, entry]) => [toSnakeCase2(key), toSnakeCaseValue(entry)])
11933
- );
11934
- }
11935
- function asMetadataRecord(value) {
11936
- if (!value || typeof value !== "object" || Array.isArray(value)) {
11937
- throw new Error("agent.metadata is invalid");
11938
- }
11939
- return value;
11940
- }
11941
- function pushBlock(blocks, key, value, order) {
11942
- const normalized = normalizeValue(toSnakeCaseValue(value));
11943
- if (normalized === void 0) {
11944
- return order;
11945
- }
11946
- blocks.push({
11947
- key,
11948
- path: key,
11949
- value: normalized,
11950
- order,
11951
- source: "generated"
11952
- });
11953
- return order + 1;
11993
+ source: "generated"
11994
+ });
11995
+ return order + 1;
11954
11996
  }
11955
11997
  function buildAgentPromptSourceWithOverrides(agent, overrides) {
11956
11998
  const blocks = [];
@@ -12063,6 +12105,79 @@ function buildTeamPromptSource(manifest, policy, bodySections = []) {
12063
12105
  };
12064
12106
  }
12065
12107
 
12108
+ // src/catalog/build-prompt-catalog.ts
12109
+ function formatDisplayLabel(key) {
12110
+ return key.replace(/_/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char) => char.toUpperCase());
12111
+ }
12112
+ function toTitleLabel(key) {
12113
+ return formatDisplayLabel(key);
12114
+ }
12115
+ function detectNodeKind(value) {
12116
+ if (Array.isArray(value)) {
12117
+ return "array";
12118
+ }
12119
+ if (typeof value === "object") {
12120
+ return "object";
12121
+ }
12122
+ return "scalar";
12123
+ }
12124
+ function buildNode(path10, key, value, order) {
12125
+ const kind = detectNodeKind(value);
12126
+ if (kind !== "object") {
12127
+ return {
12128
+ path: path10,
12129
+ key,
12130
+ label: toTitleLabel(key),
12131
+ kind,
12132
+ value,
12133
+ order,
12134
+ visibleByDefault: true
12135
+ };
12136
+ }
12137
+ const children = Object.entries(value).map(
12138
+ ([childKey, childValue], index) => buildNode(`${path10}.${childKey}`, childKey, childValue, index)
12139
+ );
12140
+ return {
12141
+ path: path10,
12142
+ key,
12143
+ label: toTitleLabel(key),
12144
+ kind,
12145
+ value,
12146
+ children,
12147
+ order,
12148
+ visibleByDefault: true
12149
+ };
12150
+ }
12151
+ function applyMetadataVisibility(node) {
12152
+ if (node.path !== "metadata" || !node.children) {
12153
+ return node;
12154
+ }
12155
+ const visiblePaths = /* @__PURE__ */ new Set(["metadata.id", "metadata.name", "metadata.archetype"]);
12156
+ return {
12157
+ ...node,
12158
+ visibleByDefault: false,
12159
+ children: node.children.map((child) => ({
12160
+ ...child,
12161
+ visibleByDefault: visiblePaths.has(child.path)
12162
+ }))
12163
+ };
12164
+ }
12165
+ function buildPromptCatalog(doc) {
12166
+ const metadataNode = applyMetadataVisibility(buildNode("metadata", "metadata", doc.metadata, -1));
12167
+ const nodes = [metadataNode];
12168
+ for (const block of doc.blocks) {
12169
+ const node = buildNode(block.path, block.key, block.value, block.order);
12170
+ nodes.push({
12171
+ ...node,
12172
+ label: block.title ?? node.label
12173
+ });
12174
+ }
12175
+ return {
12176
+ kind: doc.kind,
12177
+ nodes
12178
+ };
12179
+ }
12180
+
12066
12181
  // src/plan/build-prompt-plan.ts
12067
12182
  var CANONICAL_SECTION_TITLES = {
12068
12183
  working_rules: "Working Rules",
@@ -12266,17 +12381,25 @@ function renderPromptPlan(plan, ctx = defaultRenderContext) {
12266
12381
  return plan.sections.map((section) => renderSection(section, ctx)).filter((block) => Boolean(block)).join("\n\n");
12267
12382
  }
12268
12383
 
12384
+ // src/render/prompt-document-renderer.ts
12385
+ function renderNormalizedPromptDocument(document) {
12386
+ const catalog = buildPromptCatalog(document);
12387
+ const projectedCatalog = applyPromptProjection(catalog, document.promptProjection);
12388
+ const plan = buildPromptPlan(projectedCatalog);
12389
+ return renderPromptPlan(plan, defaultRenderContext);
12390
+ }
12391
+
12269
12392
  // src/adapters/opencode/prompt-builder.ts
12270
12393
  function resolveTargetAgent(team, agentRef) {
12271
12394
  return team.agents.find((candidate) => candidate.metadata.id === agentRef);
12272
12395
  }
12273
12396
  function createCollaborationPromptValue(agent) {
12274
12397
  const team = agent.sourceTeam;
12275
- const mapBinding = (binding3) => {
12276
- const agentRef = typeof binding3 === "string" ? binding3 : binding3.agentRef;
12398
+ const mapBinding = (binding2) => {
12399
+ const agentRef = typeof binding2 === "string" ? binding2 : binding2.agentRef;
12277
12400
  const targetAgent = resolveTargetAgent(team, agentRef);
12278
12401
  const member = team.manifest.members[agentRef];
12279
- const fallbackDescription = typeof binding3 === "string" ? void 0 : binding3.description;
12402
+ const fallbackDescription = typeof binding2 === "string" ? void 0 : binding2.description;
12280
12403
  return {
12281
12404
  id: targetAgent ? targetAgent.canonicalAgentId ?? targetAgent.metadata.id : agentRef,
12282
12405
  description: member?.responsibility ?? targetAgent?.responsibilityCore.description ?? fallbackDescription ?? agentRef,
@@ -12302,27 +12425,196 @@ function createOpenCodeAgentPrompt(agent, _requestedTools) {
12302
12425
  },
12303
12426
  agent.sourceTeam.policy
12304
12427
  );
12305
- const teamPart = renderPromptPlan(
12306
- buildPromptPlan(applyPromptProjection(buildPromptCatalog(teamSource), teamSource.promptProjection)),
12307
- defaultRenderContext
12308
- );
12428
+ const teamPart = renderNormalizedPromptDocument(teamSource);
12309
12429
  const normalizedAgent = buildAgentPromptSourceWithOverrides(agent.sourceAgent, {
12310
12430
  collaborationValue: createCollaborationPromptValue(agent)
12311
12431
  });
12312
- const agentPart = renderPromptPlan(
12313
- buildPromptPlan(applyPromptProjection(buildPromptCatalog(normalizedAgent), normalizedAgent.promptProjection)),
12314
- defaultRenderContext
12315
- );
12432
+ const agentPart = renderNormalizedPromptDocument(normalizedAgent);
12316
12433
  return [renderPart("Team Contract", teamPart), renderPart("Agent Contract", agentPart)].filter((block) => Boolean(block)).join("\n\n");
12317
12434
  }
12318
12435
 
12436
+ // src/adapters/opencode/model-resolution.ts
12437
+ var HOST_DEFAULT_MODEL_ID = "host-default";
12438
+ var TEAM_MANIFEST_FALLBACK_STRATEGY = "team-manifest";
12439
+ var BUILTIN_ROLE_FALLBACKS = {
12440
+ "coding-leader": ["openai/gpt-5.5-pro", "anthropic/claude-opus-4-7", "google/gemini-3.1-pro-preview"],
12441
+ "coordination-leader": ["anthropic/claude-opus-4-7", "google/gemini-3.1-pro-preview", "openai/gpt-5.4-mini"],
12442
+ "coding-executor": ["openai/gpt-5.5-pro", "anthropic/claude-opus-4-7", "google/gemini-3.1-pro-preview"],
12443
+ "codebase-explorer": ["google/gemini-3.1-flash-lite-preview", "openai/gpt-5.5", "google/gemini-3.1-pro-preview"],
12444
+ "web-researcher": ["openai/gpt-5.5", "anthropic/claude-opus-4-7", "google/gemini-3.1-flash-lite-preview"],
12445
+ reviewer: ["openai/gpt-5.5-pro", "openai/gpt-5.5", "google/gemini-3.1-pro-preview"],
12446
+ "principal-advisor": ["openai/gpt-5.5-pro", "openai/gpt-5.5", "google/gemini-3.1-pro-preview"],
12447
+ "multimodal-looker": ["openai/gpt-5.5", "anthropic/claude-opus-4-7"],
12448
+ "task-orchestrator": ["anthropic/claude-opus-4-7", "google/gemini-3.1-pro-preview", "openai/gpt-5.4-mini"]
12449
+ };
12450
+ function resolveRuntimeModelId(runtime) {
12451
+ if (!runtime?.model) {
12452
+ return void 0;
12453
+ }
12454
+ if (runtime.model === HOST_DEFAULT_MODEL_ID || runtime.model.includes("/")) {
12455
+ return runtime.model;
12456
+ }
12457
+ return runtime.provider ? `${runtime.provider}/${runtime.model}` : runtime.model;
12458
+ }
12459
+ function parseProviderModel(model) {
12460
+ const separator = model.indexOf("/");
12461
+ if (separator <= 0 || separator >= model.length - 1) {
12462
+ return void 0;
12463
+ }
12464
+ return {
12465
+ providerID: model.slice(0, separator),
12466
+ modelID: model.slice(separator + 1)
12467
+ };
12468
+ }
12469
+ function appendUniqueCandidate(candidates, candidate) {
12470
+ if (candidates.some((entry) => entry.model === candidate.model)) {
12471
+ return;
12472
+ }
12473
+ candidates.push(candidate);
12474
+ }
12475
+ function getCandidateModelIds(candidates) {
12476
+ return candidates.map((candidate) => candidate.model);
12477
+ }
12478
+ function createHostDefaultTrace(input) {
12479
+ return {
12480
+ teamId: input.agent.teamId,
12481
+ agentId: input.agent.canonicalAgentId,
12482
+ configuredModel: input.configuredModel,
12483
+ resolvedModel: HOST_DEFAULT_MODEL_ID,
12484
+ source: "host-default",
12485
+ fallback: input.fallbackStrategy,
12486
+ fallbackToHostDefault: input.fallbackToHostDefault,
12487
+ candidates: getCandidateModelIds(input.candidates),
12488
+ skipped: input.skipped,
12489
+ reason: input.reason
12490
+ };
12491
+ }
12492
+ function appendConfiguredModelCandidate(input) {
12493
+ const runtimeModel = resolveRuntimeModelId(input.runtime);
12494
+ const defaultRuntimeModel = resolveRuntimeModelId(input.defaultRuntime);
12495
+ if (input.agentOverrideModel) {
12496
+ appendUniqueCandidate(input.candidates, { model: input.agentOverrideModel, source: "crewbee-json", runtime: input.runtime });
12497
+ return;
12498
+ }
12499
+ if (runtimeModel) {
12500
+ appendUniqueCandidate(input.candidates, { model: runtimeModel, source: "team-manifest", runtime: input.runtime });
12501
+ return;
12502
+ }
12503
+ if (defaultRuntimeModel) {
12504
+ appendUniqueCandidate(input.candidates, { model: defaultRuntimeModel, source: "team-manifest-default", runtime: input.defaultRuntime });
12505
+ }
12506
+ }
12507
+ function resolveAgentModel(input) {
12508
+ const { agent } = input;
12509
+ const teamOverride = agent.sourceTeam.modelConfigOverride;
12510
+ const agentOverride = teamOverride?.agents?.[agent.canonicalAgentId];
12511
+ const runtime = agent.sourceTeam.manifest.agentRuntime?.[agent.canonicalAgentId];
12512
+ const defaultRuntime = agent.sourceTeam.manifest.agentRuntime?.$default;
12513
+ const fallbackStrategy = teamOverride?.fallback ?? (agent.teamId === BUILTIN_CODING_TEAM_ID ? BUILTIN_CODING_TEAM_MODEL_FALLBACK : TEAM_MANIFEST_FALLBACK_STRATEGY);
12514
+ const fallbackToHostDefault = teamOverride?.fallbackToHostDefault ?? runtime?.fallbackToHostDefault ?? defaultRuntime?.fallbackToHostDefault ?? true;
12515
+ const runtimeModel = resolveRuntimeModelId(runtime);
12516
+ const configuredModel = agentOverride?.model ?? runtimeModel ?? resolveRuntimeModelId(defaultRuntime);
12517
+ const candidates = [];
12518
+ appendConfiguredModelCandidate({
12519
+ candidates,
12520
+ agentOverrideModel: agentOverride?.model,
12521
+ runtime,
12522
+ defaultRuntime
12523
+ });
12524
+ if (agentOverride?.model === HOST_DEFAULT_MODEL_ID || !agentOverride?.model && runtimeModel === HOST_DEFAULT_MODEL_ID) {
12525
+ return {
12526
+ trace: createHostDefaultTrace({
12527
+ agent,
12528
+ configuredModel,
12529
+ fallbackStrategy,
12530
+ fallbackToHostDefault,
12531
+ candidates,
12532
+ skipped: [],
12533
+ reason: "host-default selected explicitly"
12534
+ })
12535
+ };
12536
+ }
12537
+ const sourceAgentId = agent.sourceAgent.metadata.sourceId ?? agent.canonicalAgentId;
12538
+ if (fallbackStrategy === BUILTIN_CODING_TEAM_MODEL_FALLBACK && agent.teamId === BUILTIN_CODING_TEAM_ID) {
12539
+ for (const model of BUILTIN_ROLE_FALLBACKS[sourceAgentId] ?? BUILTIN_ROLE_FALLBACKS[agent.canonicalAgentId] ?? []) {
12540
+ appendUniqueCandidate(candidates, { model, source: "builtin-role-chain", runtime });
12541
+ }
12542
+ } else {
12543
+ for (const model of runtime?.fallbackModels ?? defaultRuntime?.fallbackModels ?? []) {
12544
+ appendUniqueCandidate(candidates, { model, source: "team-manifest", runtime });
12545
+ }
12546
+ }
12547
+ const availableModels = input.availableModels ? new Set(input.availableModels) : void 0;
12548
+ const skipped = [];
12549
+ for (const candidate of candidates) {
12550
+ if (candidate.model === HOST_DEFAULT_MODEL_ID) {
12551
+ return {
12552
+ trace: createHostDefaultTrace({
12553
+ agent,
12554
+ configuredModel,
12555
+ fallbackStrategy,
12556
+ fallbackToHostDefault,
12557
+ candidates,
12558
+ skipped,
12559
+ reason: "host-default selected from candidate chain"
12560
+ })
12561
+ };
12562
+ }
12563
+ const parsed = parseProviderModel(candidate.model);
12564
+ if (!parsed) {
12565
+ skipped.push({ model: candidate.model, reason: "model must use provider/model format" });
12566
+ continue;
12567
+ }
12568
+ if (availableModels && !availableModels.has(candidate.model)) {
12569
+ skipped.push({ model: candidate.model, reason: "model not available in current OpenCode environment" });
12570
+ continue;
12571
+ }
12572
+ return {
12573
+ model: {
12574
+ providerID: parsed.providerID,
12575
+ modelID: parsed.modelID,
12576
+ temperature: candidate.runtime?.temperature,
12577
+ topP: candidate.runtime?.topP,
12578
+ variant: candidate.runtime?.variant,
12579
+ options: candidate.runtime?.options,
12580
+ source: candidate.source
12581
+ },
12582
+ trace: {
12583
+ teamId: agent.teamId,
12584
+ agentId: agent.canonicalAgentId,
12585
+ configuredModel,
12586
+ resolvedModel: candidate.model,
12587
+ source: candidate.source,
12588
+ fallback: fallbackStrategy,
12589
+ fallbackToHostDefault,
12590
+ candidates: getCandidateModelIds(candidates),
12591
+ skipped
12592
+ }
12593
+ };
12594
+ }
12595
+ return {
12596
+ trace: createHostDefaultTrace({
12597
+ agent,
12598
+ configuredModel,
12599
+ fallbackStrategy,
12600
+ fallbackToHostDefault,
12601
+ candidates,
12602
+ skipped,
12603
+ reason: fallbackToHostDefault ? "no usable model candidate; fallback_to_host_default enabled" : "no usable model candidate"
12604
+ })
12605
+ };
12606
+ }
12607
+
12319
12608
  // src/adapters/opencode/projection.ts
12320
12609
  function createOpenCodeConfigKey(agent) {
12321
12610
  return agent.canonicalAgentId;
12322
12611
  }
12323
12612
  function createOpenCodeAgentConfig(agent, options = {}) {
12324
12613
  const runtimeConfig = agent.sourceAgent.runtimeConfig;
12325
- const runtimeOverride = agent.sourceTeam.manifest.agentRuntime?.[agent.canonicalAgentId];
12614
+ const modelResolution = resolveAgentModel({
12615
+ agent,
12616
+ availableModels: options.availableModels
12617
+ });
12326
12618
  const availableToolContext = createAvailableToolContext(options.availableTools);
12327
12619
  const requestedTools = mapOpenCodeToolNames(runtimeConfig.requestedTools);
12328
12620
  const availableTools = availableToolContext.hasExplicitTools ? requestedTools.filter((toolId) => isAvailableTool(toolId, availableToolContext)) : [...requestedTools];
@@ -12345,15 +12637,8 @@ function createOpenCodeAgentConfig(agent, options = {}) {
12345
12637
  memory: runtimeConfig.memory,
12346
12638
  hooks: runtimeConfig.hooks
12347
12639
  },
12348
- resolvedModel: runtimeOverride ? {
12349
- providerID: runtimeOverride.provider,
12350
- modelID: runtimeOverride.model,
12351
- temperature: runtimeOverride.temperature,
12352
- topP: runtimeOverride.topP,
12353
- variant: runtimeOverride.variant,
12354
- options: runtimeOverride.options,
12355
- source: "team-manifest"
12356
- } : void 0,
12640
+ resolvedModel: modelResolution.model,
12641
+ modelResolution: modelResolution.trace,
12357
12642
  resolvedTooling: {
12358
12643
  requestedTools,
12359
12644
  availableTools,
@@ -12449,241 +12734,36 @@ function createProjectedAgentTaskAliasHelpLines(agents) {
12449
12734
  });
12450
12735
  }
12451
12736
 
12452
- // src/adapters/opencode/chat-message-hook.ts
12453
- function getDefaultAgent(boot) {
12454
- return boot.mergedConfig?.default_agent ?? boot.configPatch.defaultAgent;
12455
- }
12456
- function resolveModel(agent, model) {
12457
- if (model) {
12458
- return model;
12459
- }
12460
- if (!agent.resolvedModel) {
12461
- return void 0;
12462
- }
12737
+ // src/adapters/opencode/tool-domain.ts
12738
+ function createOpenCodeToolDomainPlan() {
12739
+ const implementedTools = listImplementedCrewBeePluginTools().filter((tool) => tool.hostTargets.includes("opencode"));
12740
+ const reservedTools = listCrewBeePluginTools().filter((tool) => tool.hostTargets.includes("opencode"));
12463
12741
  return {
12464
- providerID: agent.resolvedModel.providerID,
12465
- modelID: agent.resolvedModel.modelID
12742
+ hostId: "opencode",
12743
+ reservedTools,
12744
+ implementedTools,
12745
+ toolInjectionMode: implementedTools.length > 0 ? "inject-implemented-tools" : "reserved-only"
12466
12746
  };
12467
12747
  }
12468
- function createChatMessageHook(input) {
12469
- return async (message, _output) => {
12470
- const boot = input.getBoot();
12471
- const selected = message.agent ?? getDefaultAgent(boot);
12472
- if (!selected) {
12473
- return;
12474
- }
12475
- const agent = resolveProjectedAgentSelection(boot.projectedAgents, {
12476
- configKey: selected
12477
- });
12478
- if (!agent) {
12479
- return;
12480
- }
12481
- const binding3 = createSessionRuntimeBinding({
12482
- projection: boot.projection,
12483
- sessionID: message.sessionID,
12484
- teamId: agent.teamId,
12485
- canonicalAgentId: agent.canonicalAgentId,
12486
- mode: "single-executor",
12487
- source: message.agent ? "host-agent-selection" : "plugin-default"
12488
- });
12489
- input.bindings.set(message.sessionID, binding3);
12490
- input.store.setCheckpoint(message.sessionID, createCheckpoint(agent, resolveModel(agent, message.model)));
12491
- };
12492
- }
12493
-
12494
- // src/adapters/opencode/delegation/sdk-response.ts
12495
- function unwrapSdkResponse(value) {
12496
- if (typeof value === "object" && value !== null && "data" in value) {
12497
- return value.data;
12498
- }
12499
- return value;
12500
- }
12501
-
12502
- // src/adapters/opencode/delegation/continuity.ts
12503
- function formatDelegatedSessions(store, sessionID) {
12504
- const sessions = store.getSessionsByParent(sessionID);
12505
- if (sessions.length === 0) {
12506
- return "- None";
12507
- }
12508
- return sessions.map((session) => {
12509
- const task = store.getTaskBySession(session.sessionID);
12510
- return [
12511
- `- ${session.canonicalAgentId}`,
12512
- task?.status ?? "completed",
12513
- task?.description ?? "foreground delegation",
12514
- `session_id=${session.sessionID}`,
12515
- "resume, don't restart"
12516
- ].join(" | ");
12517
- }).join("\n");
12518
- }
12519
- function formatTodoSnapshot(store, sessionID) {
12520
- const todos = store.getTodos(sessionID);
12521
- if (todos.length === 0) {
12522
- return "- None";
12523
- }
12524
- return todos.map((todo) => `- [${todo.status}][${todo.priority ?? "medium"}] ${todo.content}`).join("\n");
12525
- }
12526
- function formatCheckpointSummary(store, sessionID) {
12527
- const checkpoint = store.getCheckpoint(sessionID);
12528
- if (!checkpoint) {
12529
- return "- None";
12530
- }
12531
- return [
12532
- `- agent=${checkpoint.agent}`,
12533
- checkpoint.model ? `- model=${checkpoint.model.providerID}/${checkpoint.model.modelID}` : void 0,
12534
- checkpoint.tools.length > 0 ? `- tools=${checkpoint.tools.join(", ")}` : "- tools=None"
12535
- ].filter(Boolean).join("\n");
12536
- }
12537
- async function captureTodoSnapshot(ctx, store, sessionID) {
12538
- const result = unwrapSdkResponse(await ctx.client.session.todo({ path: { id: sessionID } }).catch(() => []));
12539
- store.setTodos(sessionID, Array.isArray(result) ? result : []);
12540
- }
12541
- function buildCompactionContext(store, sessionID) {
12542
- return [
12543
- "[CrewBee Continuity Context]",
12544
- "",
12545
- "When summarizing this session, preserve the sections below in the compacted summary.",
12546
- "",
12547
- "1. User Requests / Final Goal",
12548
- "2. Work Completed",
12549
- "3. Remaining Tasks",
12550
- "4. Active Working Context",
12551
- "5. Explicit Constraints",
12552
- "6. Agent Verification State",
12553
- "7. Checkpointed Agent Configuration",
12554
- " - include current agent / source agent / model / enabled tools when known",
12555
- "8. Todo Snapshot",
12556
- " - preserve outstanding todos and their status/priority",
12557
- "9. Delegated Agent Sessions",
12558
- " - include agent, status, description, session_id",
12559
- " - instruction: resume, don't restart",
12560
- "",
12561
- "[Checkpointed agent configuration]",
12562
- formatCheckpointSummary(store, sessionID),
12563
- "",
12564
- "[Todo snapshot]",
12565
- formatTodoSnapshot(store, sessionID),
12566
- "",
12567
- "[Runtime-carried delegated sessions]",
12568
- formatDelegatedSessions(store, sessionID)
12569
- ].join("\n");
12570
- }
12571
-
12572
- // src/adapters/opencode/compaction-hook.ts
12573
- function createCompactionHook(ctx, store) {
12574
- return async (input, output) => {
12575
- await captureTodoSnapshot(ctx, store, input.sessionID);
12576
- output.context.push(buildCompactionContext(store, input.sessionID));
12577
- };
12578
- }
12579
-
12580
- // src/adapters/opencode/capabilities.ts
12581
- function createOpenCodeCapabilityContract() {
12582
- return {
12583
- supportsAgentRegistration: true,
12584
- supportsAgentSwitching: true,
12585
- supportsNativeAgentSelection: true,
12586
- supportsNativeModelSelection: true,
12587
- supportsCliOverrides: true,
12588
- supportsSingleExecutorMode: true,
12589
- supportsTeamCollaboration: false,
12590
- supportsRuntimeEvents: true,
12591
- supportsToolDomainInjection: false,
12592
- supportsSessionLogExport: false
12593
- };
12594
- }
12595
-
12596
- // src/adapters/opencode/config-merge.ts
12597
- function applyOpenCodeAgentConfigPatch(config2, patch) {
12598
- const patchKeys = new Set(Object.keys(patch.agent));
12599
- const nextAgents = Object.fromEntries(
12600
- Object.entries(config2.agent ?? {}).filter(([key, definition]) => {
12601
- if (isManagedCrewBeeAgentDefinition(definition) && !patchKeys.has(key)) {
12602
- return false;
12603
- }
12604
- return true;
12605
- })
12606
- );
12607
- const insertedAgentKeys = [];
12608
- const updatedAgentKeys = [];
12609
- const skippedAgentKeys = [];
12610
- for (const [key, definition] of Object.entries(patch.agent)) {
12611
- if (!(key in nextAgents)) {
12612
- nextAgents[key] = definition;
12613
- insertedAgentKeys.push(key);
12614
- continue;
12615
- }
12616
- const existingDefinition = nextAgents[key];
12617
- if (isManagedCrewBeeAgentDefinition(existingDefinition)) {
12618
- nextAgents[key] = definition;
12619
- updatedAgentKeys.push(key);
12620
- continue;
12621
- }
12622
- skippedAgentKeys.push(key);
12623
- }
12624
- const nextConfig = {
12625
- ...config2,
12626
- agent: nextAgents
12627
- };
12628
- if (patch.defaultAgent) {
12629
- nextConfig.default_agent = patch.defaultAgent;
12630
- }
12631
- return {
12632
- config: nextConfig,
12633
- insertedAgentKeys,
12634
- updatedAgentKeys,
12635
- skippedAgentKeys
12636
- };
12637
- }
12638
-
12639
- // src/adapters/opencode/coexistence.ts
12640
- function createOpenCodeCoexistencePolicy() {
12641
- return {
12642
- pluginId: "crewbee",
12643
- dependsOnOhMyOpenCode: false,
12644
- featureDevelopmentMode: "mutually-exclusive",
12645
- safeWhenCoInstalled: true,
12646
- reservedConfigKeyPrefix: "",
12647
- neverMutateForeignAgents: true
12648
- };
12649
- }
12650
- function detectOpenCodeProjectionCollisions(input) {
12651
- const existingConfigKeys = new Set(input.existingConfigKeys ?? []);
12652
- return {
12653
- configKeyCollisions: input.projectedAgents.filter((agent) => existingConfigKeys.has(agent.configKey)).map((agent) => agent.configKey)
12654
- };
12655
- }
12656
-
12657
- // src/adapters/opencode/tool-domain.ts
12658
- function createOpenCodeToolDomainPlan() {
12659
- const implementedTools = listImplementedCrewBeePluginTools().filter((tool) => tool.hostTargets.includes("opencode"));
12660
- const reservedTools = listCrewBeePluginTools().filter((tool) => tool.hostTargets.includes("opencode"));
12661
- return {
12662
- hostId: "opencode",
12663
- reservedTools,
12664
- implementedTools,
12665
- toolInjectionMode: implementedTools.length > 0 ? "inject-implemented-tools" : "reserved-only"
12666
- };
12667
- }
12668
-
12669
- // src/adapters/opencode/bootstrap.ts
12670
- function createOpenCodeAdapterDefinition() {
12671
- const coexistence = createOpenCodeCoexistencePolicy();
12672
- return {
12673
- hostId: "opencode",
12674
- displayName: "OpenCode",
12675
- capabilities: createOpenCodeCapabilityContract(),
12676
- entryModel: {
12677
- hostOwnsPrimaryEntry: true,
12678
- usesNativeAgentSelection: true,
12679
- usesNativeModelSelection: true,
12680
- usesHostCli: true,
12681
- requiresCustomManagerEntry: false
12682
- },
12683
- coexistence: {
12684
- independentFromForeignPlugins: true,
12685
- safeWhenCoInstalled: coexistence.safeWhenCoInstalled,
12686
- reservedConfigKeyPrefix: coexistence.reservedConfigKeyPrefix
12748
+
12749
+ // src/adapters/opencode/bootstrap.ts
12750
+ function createOpenCodeAdapterDefinition() {
12751
+ const coexistence = createOpenCodeCoexistencePolicy();
12752
+ return {
12753
+ hostId: "opencode",
12754
+ displayName: "OpenCode",
12755
+ capabilities: createOpenCodeCapabilityContract(),
12756
+ entryModel: {
12757
+ hostOwnsPrimaryEntry: true,
12758
+ usesNativeAgentSelection: true,
12759
+ usesNativeModelSelection: true,
12760
+ usesHostCli: true,
12761
+ requiresCustomManagerEntry: false
12762
+ },
12763
+ coexistence: {
12764
+ independentFromForeignPlugins: true,
12765
+ safeWhenCoInstalled: coexistence.safeWhenCoInstalled,
12766
+ reservedConfigKeyPrefix: coexistence.reservedConfigKeyPrefix
12687
12767
  }
12688
12768
  };
12689
12769
  }
@@ -12759,7 +12839,8 @@ function createOpenCodeBootstrap(input) {
12759
12839
  const projection = createTeamLibraryProjection(input.teamLibrary);
12760
12840
  const toolDomainPlan = createOpenCodeToolDomainPlan();
12761
12841
  const projectedAgents = createOpenCodeAgentConfigs(projection, {
12762
- availableTools: input.availableTools
12842
+ availableTools: input.availableTools,
12843
+ availableModels: input.availableModels
12763
12844
  });
12764
12845
  const foreignCollisions = getForeignCollisionInputs({
12765
12846
  existingConfig: input.existingConfig,
@@ -12810,6 +12891,185 @@ function createOpenCodeBootstrap(input) {
12810
12891
  };
12811
12892
  }
12812
12893
 
12894
+ // src/adapters/opencode/defaults.ts
12895
+ var DEFAULT_OPENCODE_EXECUTION_MODE = "single-executor";
12896
+
12897
+ // src/adapters/opencode/delegation/prompt.ts
12898
+ function truncatePrompt(value) {
12899
+ const trimmed = value.trim().replace(/\s+/g, " ");
12900
+ return trimmed.length <= 80 ? trimmed : `${trimmed.slice(0, 77)}...`;
12901
+ }
12902
+ function createDelegatedTitle(agent, prompt) {
12903
+ return `${agent}: ${truncatePrompt(prompt)}`;
12904
+ }
12905
+ function resolveDelegateModel(target, fallback) {
12906
+ if (target.resolvedModel) {
12907
+ return {
12908
+ providerID: target.resolvedModel.providerID,
12909
+ modelID: target.resolvedModel.modelID
12910
+ };
12911
+ }
12912
+ return fallback;
12913
+ }
12914
+ function createDelegationEnvelope(input) {
12915
+ return [
12916
+ `You are continuing work as CrewBee team member: ${input.agent}.`,
12917
+ "",
12918
+ `Parent session: ${input.parentSessionID}`,
12919
+ `Delegated session: ${input.sessionID}`,
12920
+ "",
12921
+ "Your delegated objective:",
12922
+ input.prompt.trim(),
12923
+ "",
12924
+ "Execution rules:",
12925
+ "- Work only on this delegated objective",
12926
+ "- Do not broaden scope",
12927
+ "- If you need a skill, decide and load it yourself based on the task",
12928
+ "- Prefer a compact result focused on outcome, files changed, blockers, and next step",
12929
+ "",
12930
+ "Return:",
12931
+ "1. Result / conclusion",
12932
+ "2. Files changed or inspected",
12933
+ "3. Remaining risk or blocker",
12934
+ "4. Recommended next step"
12935
+ ].join("\n");
12936
+ }
12937
+ function createCheckpoint(agent, model) {
12938
+ return {
12939
+ agent: agent.configKey,
12940
+ model,
12941
+ tools: [...agent.runtimeConfig.requestedTools]
12942
+ };
12943
+ }
12944
+
12945
+ // src/adapters/opencode/chat-message-hook.ts
12946
+ function getDefaultAgent(boot) {
12947
+ return boot.mergedConfig?.default_agent ?? boot.configPatch.defaultAgent;
12948
+ }
12949
+ function resolveModel(agent, model) {
12950
+ if (model) {
12951
+ return model;
12952
+ }
12953
+ if (!agent.resolvedModel) {
12954
+ return void 0;
12955
+ }
12956
+ return {
12957
+ providerID: agent.resolvedModel.providerID,
12958
+ modelID: agent.resolvedModel.modelID
12959
+ };
12960
+ }
12961
+ function createChatMessageHook(input) {
12962
+ return async (message, _output) => {
12963
+ const boot = input.getBoot();
12964
+ const selected = message.agent ?? getDefaultAgent(boot);
12965
+ if (!selected) {
12966
+ return;
12967
+ }
12968
+ const agent = resolveProjectedAgentSelection(boot.projectedAgents, {
12969
+ configKey: selected
12970
+ });
12971
+ if (!agent) {
12972
+ return;
12973
+ }
12974
+ const binding2 = createSessionRuntimeBinding({
12975
+ projection: boot.projection,
12976
+ sessionID: message.sessionID,
12977
+ teamId: agent.teamId,
12978
+ canonicalAgentId: agent.canonicalAgentId,
12979
+ mode: DEFAULT_OPENCODE_EXECUTION_MODE,
12980
+ source: message.agent ? "host-agent-selection" : "plugin-default"
12981
+ });
12982
+ input.bindings.set(message.sessionID, binding2);
12983
+ input.store.setCheckpoint(message.sessionID, createCheckpoint(agent, resolveModel(agent, message.model)));
12984
+ };
12985
+ }
12986
+
12987
+ // src/adapters/opencode/delegation/sdk-response.ts
12988
+ function unwrapSdkResponse(value) {
12989
+ if (typeof value === "object" && value !== null && "data" in value) {
12990
+ return value.data;
12991
+ }
12992
+ return value;
12993
+ }
12994
+
12995
+ // src/adapters/opencode/delegation/continuity.ts
12996
+ function formatDelegatedSessions(store, sessionID) {
12997
+ const sessions = store.getSessionsByParent(sessionID);
12998
+ if (sessions.length === 0) {
12999
+ return "- None";
13000
+ }
13001
+ return sessions.map((session) => {
13002
+ const task = store.getTaskBySession(session.sessionID);
13003
+ return [
13004
+ `- ${session.canonicalAgentId}`,
13005
+ task?.status ?? "completed",
13006
+ task?.description ?? "foreground delegation",
13007
+ `session_id=${session.sessionID}`,
13008
+ "resume, don't restart"
13009
+ ].join(" | ");
13010
+ }).join("\n");
13011
+ }
13012
+ function formatTodoSnapshot(store, sessionID) {
13013
+ const todos = store.getTodos(sessionID);
13014
+ if (todos.length === 0) {
13015
+ return "- None";
13016
+ }
13017
+ return todos.map((todo) => `- [${todo.status}][${todo.priority ?? "medium"}] ${todo.content}`).join("\n");
13018
+ }
13019
+ function formatCheckpointSummary(store, sessionID) {
13020
+ const checkpoint = store.getCheckpoint(sessionID);
13021
+ if (!checkpoint) {
13022
+ return "- None";
13023
+ }
13024
+ return [
13025
+ `- agent=${checkpoint.agent}`,
13026
+ checkpoint.model ? `- model=${checkpoint.model.providerID}/${checkpoint.model.modelID}` : void 0,
13027
+ checkpoint.tools.length > 0 ? `- tools=${checkpoint.tools.join(", ")}` : "- tools=None"
13028
+ ].filter(Boolean).join("\n");
13029
+ }
13030
+ async function captureTodoSnapshot(ctx, store, sessionID) {
13031
+ const result = unwrapSdkResponse(await ctx.client.session.todo({ path: { id: sessionID } }).catch(() => []));
13032
+ store.setTodos(sessionID, Array.isArray(result) ? result : []);
13033
+ }
13034
+ function buildCompactionContext(store, sessionID) {
13035
+ return [
13036
+ "[CrewBee Continuity Context]",
13037
+ "",
13038
+ "When summarizing this session, preserve the sections below in the compacted summary.",
13039
+ "",
13040
+ "1. User Requests / Final Goal",
13041
+ "2. Work Completed",
13042
+ "3. Remaining Tasks",
13043
+ "4. Active Working Context",
13044
+ "5. Explicit Constraints",
13045
+ "6. Agent Verification State",
13046
+ "7. Checkpointed Agent Configuration",
13047
+ " - include current agent / source agent / model / enabled tools when known",
13048
+ "8. Todo Snapshot",
13049
+ " - preserve outstanding todos and their status/priority",
13050
+ "9. Delegated Agent Sessions",
13051
+ " - include agent, status, description, session_id",
13052
+ " - instruction: resume, don't restart",
13053
+ "",
13054
+ "[Checkpointed agent configuration]",
13055
+ formatCheckpointSummary(store, sessionID),
13056
+ "",
13057
+ "[Todo snapshot]",
13058
+ formatTodoSnapshot(store, sessionID),
13059
+ "",
13060
+ "[Runtime-carried delegated sessions]",
13061
+ formatDelegatedSessions(store, sessionID)
13062
+ ].join("\n");
13063
+ }
13064
+
13065
+ // src/adapters/opencode/compaction-hook.ts
13066
+ function createCompactionHook(ctx, store) {
13067
+ return async (input, output) => {
13068
+ await captureTodoSnapshot(ctx, store, input.sessionID);
13069
+ output.context.push(buildCompactionContext(store, input.sessionID));
13070
+ };
13071
+ }
13072
+
12813
13073
  // src/adapters/opencode/logging.ts
12814
13074
  async function logCrewBee(ctx, message, extra, level = "info") {
12815
13075
  if (!shouldEmitCrewBeeLog(level)) {
@@ -12826,7 +13086,6 @@ async function logCrewBee(ctx, message, extra, level = "info") {
12826
13086
  }
12827
13087
 
12828
13088
  // src/adapters/opencode/config-hook.ts
12829
- var DEFAULT_MODE = "single-executor";
12830
13089
  function summarizeProjectedAgents(boot) {
12831
13090
  return boot.projectedAgents.map((agent) => ({
12832
13091
  configKey: agent.configKey,
@@ -12864,7 +13123,7 @@ async function validateAndLogTeamLibrary(ctx, teamLibrary) {
12864
13123
  function createInitialBootstrap(teamLibrary) {
12865
13124
  const boot = createOpenCodeBootstrap({
12866
13125
  teamLibrary,
12867
- defaults: { defaultMode: DEFAULT_MODE }
13126
+ defaults: { defaultMode: DEFAULT_OPENCODE_EXECUTION_MODE }
12868
13127
  });
12869
13128
  return {
12870
13129
  boot,
@@ -12876,7 +13135,7 @@ function createConfigHook(input) {
12876
13135
  const current = getConfig(cfg);
12877
13136
  const next = createOpenCodeBootstrap({
12878
13137
  teamLibrary: input.teamLibrary,
12879
- defaults: { defaultMode: DEFAULT_MODE },
13138
+ defaults: { defaultMode: DEFAULT_OPENCODE_EXECUTION_MODE },
12880
13139
  existingConfig: current,
12881
13140
  existingDefaultAgent: typeof current.default_agent === "string" ? current.default_agent : void 0
12882
13141
  });
@@ -25574,11 +25833,11 @@ function resolveDelegateAgent(input) {
25574
25833
  canonicalAgentId: byAlias.agent.canonicalAgentId
25575
25834
  };
25576
25835
  }
25577
- function isSelfDelegate(binding3, canonicalAgentId) {
25578
- if (!binding3) {
25836
+ function isSelfDelegate(binding2, canonicalAgentId) {
25837
+ if (!binding2) {
25579
25838
  return false;
25580
25839
  }
25581
- return binding3.selectedAgentId === canonicalAgentId;
25840
+ return binding2.selectedAgentId === canonicalAgentId;
25582
25841
  }
25583
25842
 
25584
25843
  // src/adapters/opencode/delegation/tool-result.ts
@@ -25744,8 +26003,8 @@ function createDelegateTools(input) {
25744
26003
  if (!target) {
25745
26004
  return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "unknown_agent", `Unknown CrewBee agent: ${args.agent}`));
25746
26005
  }
25747
- const binding3 = input.bindings.get(ctx.sessionID);
25748
- if (isSelfDelegate(binding3, target.canonicalAgentId)) {
26006
+ const binding2 = input.bindings.get(ctx.sessionID);
26007
+ if (isSelfDelegate(binding2, target.canonicalAgentId)) {
25749
26008
  return stringifyDelegateTaskResult(createFailedResult(ctx.sessionID, "self_delegate_forbidden", "Do not delegate a CrewBee session back to the same active agent."));
25750
26009
  }
25751
26010
  const title = createDelegatedTitle(target.canonicalAgentId, args.prompt);
@@ -25870,16 +26129,16 @@ function createSystemTransformHook(bindings, getLoadIssues = () => []) {
25870
26129
  if (!input.sessionID) {
25871
26130
  return;
25872
26131
  }
25873
- const binding3 = bindings.get(input.sessionID);
25874
- if (!binding3) {
26132
+ const binding2 = bindings.get(input.sessionID);
26133
+ if (!binding2) {
25875
26134
  return;
25876
26135
  }
25877
26136
  const lines = [
25878
26137
  "CrewBee runtime binding:",
25879
- `- Team: ${binding3.teamId}`,
25880
- `- Entry Agent: ${binding3.selectedAgentId}`,
25881
- `- Active Owner: ${binding3.activeOwnerId}`,
25882
- `- Mode: ${binding3.mode}`
26138
+ `- Team: ${binding2.teamId}`,
26139
+ `- Entry Agent: ${binding2.selectedAgentId}`,
26140
+ `- Active Owner: ${binding2.activeOwnerId}`,
26141
+ `- Mode: ${binding2.mode}`
25883
26142
  ];
25884
26143
  const loadIssues = getLoadIssues();
25885
26144
  if (loadIssues.length > 0) {
@@ -26142,7 +26401,7 @@ function resolveReleaseLockPath() {
26142
26401
  }
26143
26402
 
26144
26403
  // src/update/workspace.ts
26145
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync6, rmSync, writeFileSync as writeFileSync5 } from "node:fs";
26404
+ import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync6, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "node:fs";
26146
26405
  import path8 from "node:path";
26147
26406
  function readInstalledWorkspaceVersion(workspaceRoot) {
26148
26407
  const manifestPath = path8.join(workspaceRoot, "node_modules", "crewbee", "package.json");
@@ -26183,11 +26442,11 @@ function invalidateWorkspacePackage(intent) {
26183
26442
  const lockPath = path8.join(intent.workspaceRoot, "package-lock.json");
26184
26443
  let changed = false;
26185
26444
  if (existsSync7(packageRoot)) {
26186
- rmSync(packageRoot, { recursive: true, force: true });
26445
+ rmSync2(packageRoot, { recursive: true, force: true });
26187
26446
  changed = true;
26188
26447
  }
26189
26448
  if (existsSync7(lockPath)) {
26190
- rmSync(lockPath, { force: true });
26449
+ rmSync2(lockPath, { force: true });
26191
26450
  changed = true;
26192
26451
  }
26193
26452
  return changed;