@runfusion/fusion 0.75.1-beta.2 → 0.76.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +2883 -1203
- package/dist/child-process-worker.js +2345 -1000
- package/dist/client/.vite/manifest.json +260 -260
- package/dist/client/assets/AgentDetailView-Czb9wfC3.css +1 -0
- package/dist/client/assets/AgentDetailView-nsriz_Mw.js +13 -0
- package/dist/client/assets/{AgentPermissionPolicyEditor-CC_rrbbG.js → AgentPermissionPolicyEditor-TKuT5ryJ.js} +1 -1
- package/dist/client/assets/AgentsView-BBLq03lO.js +24 -0
- package/dist/client/assets/{ChatView-mFKfoegS.js → ChatView-BEc5SVfU.js} +1 -1
- package/dist/client/assets/{CommandCenter-C2wvDq_N.js → CommandCenter-DBCxo_tI.js} +1 -1
- package/dist/client/assets/{DevServerView-0MWEJM7o.js → DevServerView-BaLUl9De.js} +1 -1
- package/dist/client/assets/{DirectoryPicker-BjMPhCdh.js → DirectoryPicker-CKj8CfUJ.js} +1 -1
- package/dist/client/assets/{DocumentsView-ckH3rjmd.js → DocumentsView-Cu8vlXJT.js} +1 -1
- package/dist/client/assets/{EvalsView-NyA644VF.js → EvalsView-CbdRWRjR.js} +1 -1
- package/dist/client/assets/{ExperimentalAgentOnboardingModal-D0ZfbBRN.js → ExperimentalAgentOnboardingModal-BVdW0xJ3.js} +1 -1
- package/dist/client/assets/{GoalsView-Ctt5P_yo.js → GoalsView-CCbeAvBm.js} +1 -1
- package/dist/client/assets/{InsightsView-NDp0bdNB.js → InsightsView-B46ZemSm.js} +1 -1
- package/dist/client/assets/{MemoryView-BKbA4Bm4.js → MemoryView-JM1fFU2D.js} +1 -1
- package/dist/client/assets/{PiExtensionsManager-V3AFWMHm.js → PiExtensionsManager-KHsw2af9.js} +1 -1
- package/dist/client/assets/{PluginManager-D88G_TZh.js → PluginManager-BeKLun0C.js} +1 -1
- package/dist/client/assets/{PullRequestView-DQQmFFYC.js → PullRequestView-CwQW2pe4.js} +1 -1
- package/dist/client/assets/{ReportModal-Clh1S8RF.js → ReportModal-BC9DhvX4.js} +1 -1
- package/dist/client/assets/{ResearchView-kxvq4zp5.js → ResearchView-CuB7IbEB.js} +1 -1
- package/dist/client/assets/{SecretsView-Dm0Vk8SA.js → SecretsView-DD8uA6G7.js} +1 -1
- package/dist/client/assets/{SessionTerminal-DJO4JTEX.js → SessionTerminal-B0S1e8qf.js} +1 -1
- package/dist/client/assets/SettingsModal-BHNEJWD4.js +21 -0
- package/dist/client/assets/{SettingsModal-BN5mL_ym.js → SettingsModal-BxrdR4-f.js} +1 -1
- package/dist/client/assets/{SettingsTextareaRow-CvKszqO-.js → SettingsTextareaRow-CpJOy-rv.js} +1 -1
- package/dist/client/assets/{SetupWizardModal-D5hVZh1G.js → SetupWizardModal-DviAPDlf.js} +2 -2
- package/dist/client/assets/{SkillsView-DQVz21w2.js → SkillsView-DeoEN_K0.js} +1 -1
- package/dist/client/assets/{WorkflowNodeEditor-CpKIi6Tb.js → WorkflowNodeEditor-CPk8plo1.js} +3 -3
- package/dist/client/assets/{agent-import-generation-DGUNF3nd.js → agent-import-generation-D74gC46R.js} +1 -1
- package/dist/client/assets/app-64JrFN7_.js +13 -0
- package/dist/client/assets/app-BxMYvSHk.js +13 -0
- package/dist/client/assets/app-CCgIvcFy.js +5 -0
- package/dist/client/assets/app-CVFYXkbM.js +13 -0
- package/dist/client/assets/app-Cl4NLAGd.js +13 -0
- package/dist/client/assets/app-_gHuSFBp.js +13 -0
- package/dist/client/assets/{architectureDiagram-3BPJPVTR-CV83wubP.js → architectureDiagram-3BPJPVTR-DUNXxw_k.js} +1 -1
- package/dist/client/assets/{blockDiagram-GPEHLZMM-CNQsA3dD.js → blockDiagram-GPEHLZMM-CTxWMFSZ.js} +1 -1
- package/dist/client/assets/{c4Diagram-AAUBKEIU-CXe7ii5H.js → c4Diagram-AAUBKEIU-DI15zO_G.js} +1 -1
- package/dist/client/assets/channel-DDHw4Vcu.js +1 -0
- package/dist/client/assets/{chunk-2J33WTMH-BS6W9bWv.js → chunk-2J33WTMH-D1X3sNvd.js} +1 -1
- package/dist/client/assets/{chunk-4BX2VUAB-DbehRhdW.js → chunk-4BX2VUAB-DYz990rf.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-DMI5SR42.js → chunk-55IACEB6-BQshFTjv.js} +1 -1
- package/dist/client/assets/{chunk-727SXJPM-D1d-GBVj.js → chunk-727SXJPM-DiVH9Rd6.js} +1 -1
- package/dist/client/assets/{chunk-AQP2D5EJ-BzO6K3Uf.js → chunk-AQP2D5EJ-Bx8LBEvE.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-BVRLV3lK.js → chunk-FMBD7UC4-7rsNdXy-.js} +1 -1
- package/dist/client/assets/{chunk-ND2GUHAM-DdWByQfn.js → chunk-ND2GUHAM-COOZ3ff5.js} +1 -1
- package/dist/client/assets/{chunk-QZHKN3VN-1ia12cRV.js → chunk-QZHKN3VN-oL-CU1gN.js} +1 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-C5tnFtxH.js +1 -0
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-C5tnFtxH.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-BPDT41HR.js → cose-bilkent-S5V4N54A-CHXhlVh-.js} +1 -1
- package/dist/client/assets/{dagre-BM42HDAG-Cktn26EH.js → dagre-BM42HDAG-BJVXidIK.js} +1 -1
- package/dist/client/assets/{dashboard-view-zd8GxC49.js → dashboard-view-B8OjndkD.js} +1 -1
- package/dist/client/assets/{dashboard-view-8o0EUcRX.js → dashboard-view-BOqEOmsR.js} +1 -1
- package/dist/client/assets/{dashboard-view-CkCerlVJ.js → dashboard-view-CCg2wkwd.js} +1 -1
- package/dist/client/assets/{dashboard-view-D_HC4lnr.js → dashboard-view-DOWuByTe.js} +1 -1
- package/dist/client/assets/{diagram-2AECGRRQ-But4Lvf-.js → diagram-2AECGRRQ-CBS8IBP_.js} +1 -1
- package/dist/client/assets/{diagram-5GNKFQAL-2bpQAGFc.js → diagram-5GNKFQAL-Dmyxol5P.js} +1 -1
- package/dist/client/assets/{diagram-KO2AKTUF-Ckn9Qd1u.js → diagram-KO2AKTUF-DVF_5fDu.js} +1 -1
- package/dist/client/assets/{diagram-LMA3HP47-Bjn8h84N.js → diagram-LMA3HP47-DqbOTb-t.js} +1 -1
- package/dist/client/assets/{diagram-OG6HWLK6-BI6541hx.js → diagram-OG6HWLK6-BIhwB3ji.js} +1 -1
- package/dist/client/assets/{erDiagram-TEJ5UH35-BqMiwHiM.js → erDiagram-TEJ5UH35-BcYtj6RH.js} +1 -1
- package/dist/client/assets/{flowDiagram-I6XJVG4X-Q_SAB10M.js → flowDiagram-I6XJVG4X-CBYrhc7v.js} +1 -1
- package/dist/client/assets/{folder-open-CHiAJbTN.js → folder-open-DBW3UhL6.js} +1 -1
- package/dist/client/assets/{ganttDiagram-6RSMTGT7-CqWFSfPF.js → ganttDiagram-6RSMTGT7-BtFaOg92.js} +1 -1
- package/dist/client/assets/{gitGraphDiagram-PVQCEYII-B1o4uEjO.js → gitGraphDiagram-PVQCEYII-BE5E5ctQ.js} +1 -1
- package/dist/client/assets/{index-kwRywd9M.js → index-D6J9uyUx.js} +306 -306
- package/dist/client/assets/index-DDdZ20Cz.css +1 -0
- package/dist/client/assets/{infoDiagram-5YYISTIA-BzaMa0c2.js → infoDiagram-5YYISTIA-BBpwj0Ir.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-I38yge00.js → ishikawaDiagram-YF4QCWOH-CwjmjYav.js} +1 -1
- package/dist/client/assets/{journeyDiagram-JHISSGLW-WVQSgx4P.js → journeyDiagram-JHISSGLW-ChnMZl1o.js} +1 -1
- package/dist/client/assets/{kanban-definition-UN3LZRKU-BWtPQ3AH.js → kanban-definition-UN3LZRKU-BA_bNZa3.js} +1 -1
- package/dist/client/assets/{mermaid.core-D1hnBtbi.js → mermaid.core-CNMqiN_t.js} +4 -4
- package/dist/client/assets/{mindmap-definition-RKZ34NQL-DqiSLkW7.js → mindmap-definition-RKZ34NQL-D-8_lEGp.js} +1 -1
- package/dist/client/assets/{pieDiagram-4H26LBE5-CcgwbdIN.js → pieDiagram-4H26LBE5-Cz_dYW8h.js} +1 -1
- package/dist/client/assets/{puzzle-BhXUaTQl.js → puzzle-Bbsv6mZh.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-W4KKPZXB-MsqQQfDN.js → quadrantDiagram-W4KKPZXB-BtXzvuUT.js} +1 -1
- package/dist/client/assets/{requirementDiagram-4Y6WPE33-CILGjMMA.js → requirementDiagram-4Y6WPE33-CK29bQbQ.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-5OEKKPKP-c14fWbtR.js → sankeyDiagram-5OEKKPKP-DGxLW8W6.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-3UESZ5HK-BD5bxMom.js → sequenceDiagram-3UESZ5HK-CPOz7wfR.js} +1 -1
- package/dist/client/assets/{shield-alert-C9W2WywS.js → shield-alert-BnpS5qUu.js} +1 -1
- package/dist/client/assets/{standing-instructions-template-CJdbDSyg.js → standing-instructions-template-jeWwq3Zh.js} +1 -1
- package/dist/client/assets/{stateDiagram-AJRCARHV-CZ5YqeOn.js → stateDiagram-AJRCARHV-CxpQ3AE6.js} +1 -1
- package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-mdMN-PNX.js → stateDiagram-v2-BHNVJYJU-BSImQHUw.js} +1 -1
- package/dist/client/assets/{timeline-definition-PNZ67QCA-DHKay9uj.js → timeline-definition-PNZ67QCA-jt74--XQ.js} +1 -1
- package/dist/client/assets/{upload-DxEwowRU.js → upload-D2j8N8vC.js} +1 -1
- package/dist/client/assets/{users-mNFgW_Zd.js → users-BtzATmoI.js} +1 -1
- package/dist/client/assets/{vennDiagram-CIIHVFJN-X29K9hWM.js → vennDiagram-CIIHVFJN-3vOGHb8-.js} +1 -1
- package/dist/client/assets/{wardley-L42UT6IY-yEoTrfmN.js → wardley-L42UT6IY-DNuWuyr8.js} +1 -1
- package/dist/client/assets/{wardleyDiagram-YWT4CUSO-ny4k3kG0.js → wardleyDiagram-YWT4CUSO-D-kFe8Uz.js} +1 -1
- package/dist/client/assets/{xychartDiagram-2RQKCTM6-DC8ODtRJ.js → xychartDiagram-2RQKCTM6-DvDQ30sY.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/client/version.json +1 -1
- package/dist/droid-cli/package.json +1 -1
- package/dist/extension.js +2702 -1117
- package/dist/migrations/0045_fn_8764_multi_role_workflow_agents.sql +20 -0
- package/dist/migrations/0046_fn_8764_workflow_principal_fence.sql +49 -0
- package/dist/migrations/0047_fn_8829_task_recommendations.sql +3 -0
- package/dist/pi-claude-cli/package.json +1 -1
- package/dist/plugin-sdk/index.d.ts +43 -0
- package/dist/plugin-sdk/index.js +357 -25
- package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-claude-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-claude-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-cli-printing-press/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
- package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
- package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
- package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-grok-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-grok-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-linear-import/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
- package/dist/plugins/fusion-plugin-omp-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-omp-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-quality/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-quality/package.json +1 -1
- package/dist/plugins/fusion-plugin-reports/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-reports/package.json +1 -1
- package/dist/plugins/fusion-plugin-roadmap/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-roadmap/manifest.json +11 -1
- package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
- package/dist/plugins/fusion-plugin-todos/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-todos/manifest.json +11 -1
- package/dist/plugins/fusion-plugin-todos/package.json +1 -1
- package/dist/plugins/fusion-plugin-whatsapp-chat/bundled.js +357 -25
- package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
- package/package.json +1 -1
- package/skill/fusion/SKILL.md +1 -1
- package/skill/fusion/references/extension-tools.md +16 -2
- package/skill/fusion/references/fusion-capabilities.md +1 -0
- package/dist/client/assets/AgentDetailView-C8-9_SOC.css +0 -1
- package/dist/client/assets/AgentDetailView-ltOG8f0-.js +0 -13
- package/dist/client/assets/AgentsView-DWUdi27N.js +0 -24
- package/dist/client/assets/SettingsModal-CTf5voEW.js +0 -21
- package/dist/client/assets/app-B4gkbXNS.js +0 -13
- package/dist/client/assets/app-BXLZYY_A.js +0 -13
- package/dist/client/assets/app-CNFmVt1q.js +0 -13
- package/dist/client/assets/app-DCERHstn.js +0 -13
- package/dist/client/assets/app-iKAA6v9i.js +0 -5
- package/dist/client/assets/app-p_Hq0vGS.js +0 -13
- package/dist/client/assets/channel-DoX862zl.js +0 -1
- package/dist/client/assets/classDiagram-4FO5ZUOK-mb2IeAGN.js +0 -1
- package/dist/client/assets/classDiagram-v2-Q7XG4LA2-mb2IeAGN.js +0 -1
- package/dist/client/assets/index-Bdw5eNKV.css +0 -1
package/dist/plugin-sdk/index.js
CHANGED
|
@@ -5763,6 +5763,7 @@ __export(project_exports, {
|
|
|
5763
5763
|
unplannedExecutionBlocks: () => unplannedExecutionBlocks,
|
|
5764
5764
|
usageEvents: () => usageEvents,
|
|
5765
5765
|
verificationCache: () => verificationCache,
|
|
5766
|
+
workflowAgentCapacityLeases: () => workflowAgentCapacityLeases,
|
|
5766
5767
|
workflowPromptOverrides: () => workflowPromptOverrides,
|
|
5767
5768
|
workflowRunBranches: () => workflowRunBranches,
|
|
5768
5769
|
workflowRunStepInstances: () => workflowRunStepInstances,
|
|
@@ -5871,6 +5872,8 @@ var tasks = projectSchema.table("tasks", {
|
|
|
5871
5872
|
nextRecoveryAt: text("next_recovery_at"),
|
|
5872
5873
|
error: text("error"),
|
|
5873
5874
|
summary: text("summary"),
|
|
5875
|
+
// FNXC:TaskRecommendations 2026-08-08-05:02: structured completion suggestions remain project-scoped JSONB beside the source task.
|
|
5876
|
+
recommendations: jsonb("recommendations"),
|
|
5874
5877
|
thinkingLevel: text("thinking_level"),
|
|
5875
5878
|
// FNXC:Settings-ThinkingLevel 2026-07-13 (merge port): validator/planning reasoning-effort overrides.
|
|
5876
5879
|
validatorThinkingLevel: text("validator_thinking_level"),
|
|
@@ -6451,7 +6454,9 @@ var agents = projectSchema.table("agents", {
|
|
|
6451
6454
|
projectId: text("project_id").notNull().default(sql`current_setting('fusion.project_id', true)`),
|
|
6452
6455
|
id: text("id").notNull(),
|
|
6453
6456
|
name: text("name").notNull(),
|
|
6457
|
+
/** Deprecated singular compatibility column; canonical roles live in roles JSONB. */
|
|
6454
6458
|
role: text("role").notNull(),
|
|
6459
|
+
roles: jsonb("roles").notNull().default([]),
|
|
6455
6460
|
state: text("state").notNull().default("idle"),
|
|
6456
6461
|
taskId: text("task_id"),
|
|
6457
6462
|
createdAt: text("created_at").notNull(),
|
|
@@ -6575,6 +6580,17 @@ var completionHandoffMarkers = projectSchema.table("completion_handoff_markers",
|
|
|
6575
6580
|
foreignKey({ columns: [t.projectId, t.taskId], foreignColumns: [tasks.projectId, tasks.id] }).onDelete("cascade"),
|
|
6576
6581
|
index("idx_completion_handoff_markers_acceptedAt").on(t.acceptedAt)
|
|
6577
6582
|
]);
|
|
6583
|
+
var workflowAgentCapacityLeases = projectSchema.table("workflow_agent_capacity_leases", {
|
|
6584
|
+
projectId: text("project_id").notNull().default(sql`current_setting('fusion.project_id', true)`),
|
|
6585
|
+
attemptId: text("attempt_id").notNull(),
|
|
6586
|
+
agentId: text("agent_id").notNull(),
|
|
6587
|
+
createdAt: text("created_at").notNull(),
|
|
6588
|
+
// FNXC:WorkflowAgentRouting 2026-08-07-07:16: A crashed engine cannot run its finally cleanup, so durable workflow capacity leases expire and are reclaimed on the next admission.
|
|
6589
|
+
expiresAt: text("expires_at").notNull()
|
|
6590
|
+
}, (t) => [
|
|
6591
|
+
primaryKey({ columns: [t.projectId, t.attemptId] }),
|
|
6592
|
+
index("idx_workflow_agent_capacity_leases_agent").on(t.projectId, t.agentId)
|
|
6593
|
+
]);
|
|
6578
6594
|
var workflowWorkItems = projectSchema.table("workflow_work_items", {
|
|
6579
6595
|
projectId: text("project_id").notNull().default(sql`current_setting('fusion.project_id', true)`),
|
|
6580
6596
|
id: text("id").notNull(),
|
|
@@ -6595,6 +6611,13 @@ var workflowWorkItems = projectSchema.table("workflow_work_items", {
|
|
|
6595
6611
|
sourceColumn: text("source_column"),
|
|
6596
6612
|
targetColumn: text("target_column"),
|
|
6597
6613
|
irHash: text("ir_hash"),
|
|
6614
|
+
// FNXC:WorkflowAgentRouting 2026-08-07-03:25:
|
|
6615
|
+
// A workflow claim fences its durable principal and exact template instance.
|
|
6616
|
+
// Session retries must reuse this identity rather than re-routing a task.
|
|
6617
|
+
principalAgentId: text("principal_agent_id"),
|
|
6618
|
+
workflowRole: text("workflow_role"),
|
|
6619
|
+
authorityKind: text("authority_kind"),
|
|
6620
|
+
nodeInstanceId: text("node_instance_id"),
|
|
6598
6621
|
createdAt: text("created_at").notNull(),
|
|
6599
6622
|
updatedAt: text("updated_at").notNull()
|
|
6600
6623
|
}, (t) => [
|
|
@@ -8590,6 +8613,7 @@ var BLOCKING_TASK_STATUSES = /* @__PURE__ */ new Set([
|
|
|
8590
8613
|
// ../core/src/tasks/in-review-stall.ts
|
|
8591
8614
|
var DEFAULT_STALE_MERGING_MIN_AGE_MS = 5 * 6e4;
|
|
8592
8615
|
var DEFAULT_MAX_AUTO_MERGE_RETRIES = 3;
|
|
8616
|
+
var CONSECUTIVE_TOOL_FAILURE_RETRY_THRESHOLD = 1;
|
|
8593
8617
|
|
|
8594
8618
|
// ../core/src/config/settings-schema.ts
|
|
8595
8619
|
var DEFAULT_GLOBAL_SETTINGS = {
|
|
@@ -8930,6 +8954,8 @@ var DEFAULT_GLOBAL_SETTINGS = {
|
|
|
8930
8954
|
cliAgents: {}
|
|
8931
8955
|
};
|
|
8932
8956
|
var DEFAULT_PROJECT_SETTINGS = {
|
|
8957
|
+
// FNXC:TaskRecommendations 2026-08-08-05:02: completion follows-ups stay bounded by default; 0 disables writing them.
|
|
8958
|
+
maxRecommendationsPerTask: 3,
|
|
8933
8959
|
globalPause: false,
|
|
8934
8960
|
globalPauseReason: void 0,
|
|
8935
8961
|
defaultWorkflowId: void 0,
|
|
@@ -9098,9 +9124,15 @@ var DEFAULT_PROJECT_SETTINGS = {
|
|
|
9098
9124
|
* Project settings own the auto-merge conflict retry cap because existing engine/dashboard consumers already resolve project settings; the default imports core's stall-detection fallback to keep every surface on the historical value of 3.
|
|
9099
9125
|
*/
|
|
9100
9126
|
maxAutoMergeRetries: DEFAULT_MAX_AUTO_MERGE_RETRIES,
|
|
9127
|
+
/*
|
|
9128
|
+
FNXC:ExecutorToolFailureRetry 2026-08-06-14:56:
|
|
9129
|
+
Fresh projects retry the existing bounded same-model continuation after one
|
|
9130
|
+
terminal tool error. Persisted project values are not migrated, so explicit
|
|
9131
|
+
operator thresholds remain authoritative.
|
|
9132
|
+
*/
|
|
9101
9133
|
executorToolFailureRetryCount: 2,
|
|
9102
9134
|
executorToolFailureRetryBackoffMs: 2e3,
|
|
9103
|
-
executorToolFailureThreshold:
|
|
9135
|
+
executorToolFailureThreshold: CONSECUTIVE_TOOL_FAILURE_RETRY_THRESHOLD,
|
|
9104
9136
|
executorModelEscalationEnabled: false,
|
|
9105
9137
|
executorEscalationProvider: void 0,
|
|
9106
9138
|
executorEscalationModelId: void 0,
|
|
@@ -9136,6 +9168,12 @@ var DEFAULT_PROJECT_SETTINGS = {
|
|
|
9136
9168
|
// proportional to the change; the thin merge gate carries cross-cutting
|
|
9137
9169
|
// coverage. Falls back to package/explicit command when no tests resolve.
|
|
9138
9170
|
scopeVerificationToChangedFiles: true,
|
|
9171
|
+
/*
|
|
9172
|
+
FNXC:WorkflowAgentRouting 2026-08-07-08:45:
|
|
9173
|
+
Keep the legacy project setting defaulted and persistable for existing clients and
|
|
9174
|
+
configuration records. Workflow-stage routing must ignore its value; durable role
|
|
9175
|
+
principals own scheduler, executor, and mission-stage authority.
|
|
9176
|
+
*/
|
|
9139
9177
|
ephemeralAgentsEnabled: true,
|
|
9140
9178
|
/*
|
|
9141
9179
|
FNXC:EphemeralAgentTaskCreation 2026-07-01-00:00:
|
|
@@ -9437,6 +9475,23 @@ function isEphemeralAgent(agent) {
|
|
|
9437
9475
|
}
|
|
9438
9476
|
|
|
9439
9477
|
// ../core/src/types/agents/agents.ts
|
|
9478
|
+
var AGENT_CAPABILITIES = [
|
|
9479
|
+
"triage",
|
|
9480
|
+
"executor",
|
|
9481
|
+
"reviewer",
|
|
9482
|
+
"merger",
|
|
9483
|
+
"scheduler",
|
|
9484
|
+
"engineer",
|
|
9485
|
+
"custom"
|
|
9486
|
+
];
|
|
9487
|
+
function normalizeAgentRoles(roles, legacyRole) {
|
|
9488
|
+
const values = roles?.length ? roles : legacyRole ? [legacyRole] : [];
|
|
9489
|
+
const unique2 = new Set(values);
|
|
9490
|
+
const normalized = AGENT_CAPABILITIES.filter((role) => unique2.has(role));
|
|
9491
|
+
if (normalized.length !== unique2.size) throw new Error("Agent roles contain an unknown capability");
|
|
9492
|
+
if (normalized.length === 0) throw new Error("Agent requires at least one role");
|
|
9493
|
+
return normalized;
|
|
9494
|
+
}
|
|
9440
9495
|
var AGENT_PERMISSIONS = [
|
|
9441
9496
|
"tasks:assign",
|
|
9442
9497
|
// Assign tasks to agents
|
|
@@ -9558,6 +9613,7 @@ function getDefaultHeartbeatProcedurePath(agentId, agentName) {
|
|
|
9558
9613
|
function agentToConfigSnapshot(agent) {
|
|
9559
9614
|
return {
|
|
9560
9615
|
name: agent.name,
|
|
9616
|
+
roles: [...agent.roles],
|
|
9561
9617
|
role: agent.role,
|
|
9562
9618
|
title: agent.title,
|
|
9563
9619
|
icon: agent.icon,
|
|
@@ -9892,6 +9948,41 @@ function resolveColumnFlags(column) {
|
|
|
9892
9948
|
return getTraitRegistry().resolveColumnFlags(column);
|
|
9893
9949
|
}
|
|
9894
9950
|
|
|
9951
|
+
// ../core/src/workflows/workflow-ir-types.ts
|
|
9952
|
+
var WORKFLOW_AGENT_ROLES = ["triage", "executor", "reviewer", "merger"];
|
|
9953
|
+
function isWorkflowAgentRole(value) {
|
|
9954
|
+
return typeof value === "string" && WORKFLOW_AGENT_ROLES.includes(value);
|
|
9955
|
+
}
|
|
9956
|
+
function classifyWorkflowAgentNode(node) {
|
|
9957
|
+
if (node.kind === "step-review") return "reviewer";
|
|
9958
|
+
if (node.kind !== "prompt" && node.kind !== "script") return void 0;
|
|
9959
|
+
switch (node.config?.seam) {
|
|
9960
|
+
/*
|
|
9961
|
+
* FNXC:WorkflowAgentRouting 2026-08-07-05:52:
|
|
9962
|
+
* Planning, independent review, and promotion seams each launch work under
|
|
9963
|
+
* their permanent stage owner. Classify those production seams here rather
|
|
9964
|
+
* than treating their handoff worker as an unowned lifecycle operation.
|
|
9965
|
+
* Only pure handoff/scheduling seams remain principal-free.
|
|
9966
|
+
*/
|
|
9967
|
+
case "planning":
|
|
9968
|
+
return "triage";
|
|
9969
|
+
case "execute":
|
|
9970
|
+
case "step-execute":
|
|
9971
|
+
return "executor";
|
|
9972
|
+
case "review":
|
|
9973
|
+
return "reviewer";
|
|
9974
|
+
case "merge":
|
|
9975
|
+
return "merger";
|
|
9976
|
+
case "review-handoff":
|
|
9977
|
+
case "schedule":
|
|
9978
|
+
return void 0;
|
|
9979
|
+
default: {
|
|
9980
|
+
const explicit = node.config?.workflowRole;
|
|
9981
|
+
return isWorkflowAgentRole(explicit) ? explicit : void 0;
|
|
9982
|
+
}
|
|
9983
|
+
}
|
|
9984
|
+
}
|
|
9985
|
+
|
|
9895
9986
|
// ../core/src/workflows/workflow-extension-types.ts
|
|
9896
9987
|
function workflowExtensionRegistryId(pluginId, extensionId) {
|
|
9897
9988
|
return `plugin:${pluginId}:${extensionId}`;
|
|
@@ -10880,6 +10971,20 @@ function validateCredentialInstanceIdConfig(nodes2) {
|
|
|
10880
10971
|
if (Array.isArray(templateNodes)) validateCredentialInstanceIdConfig(templateNodes);
|
|
10881
10972
|
}
|
|
10882
10973
|
}
|
|
10974
|
+
function validateReviewerAgentOverrides(nodes2) {
|
|
10975
|
+
for (const node of nodes2) {
|
|
10976
|
+
if (node.reviewerAgentId !== void 0) {
|
|
10977
|
+
if (typeof node.reviewerAgentId !== "string" || !node.reviewerAgentId.trim()) {
|
|
10978
|
+
throw new WorkflowIrError(`Workflow node '${node.id}' reviewerAgentId must be a non-empty string`);
|
|
10979
|
+
}
|
|
10980
|
+
if (classifyWorkflowAgentNode(node) !== "reviewer") {
|
|
10981
|
+
throw new WorkflowIrError(`Workflow node '${node.id}' reviewerAgentId is only legal on reviewer-session nodes`);
|
|
10982
|
+
}
|
|
10983
|
+
}
|
|
10984
|
+
const templateNodes = node.config?.template?.nodes;
|
|
10985
|
+
if (Array.isArray(templateNodes)) validateReviewerAgentOverrides(templateNodes);
|
|
10986
|
+
}
|
|
10987
|
+
}
|
|
10883
10988
|
function validateThinkingLevelConfig(nodes2) {
|
|
10884
10989
|
for (const node of nodes2) {
|
|
10885
10990
|
const value = node.config?.thinkingLevel;
|
|
@@ -11495,6 +11600,7 @@ function validateV2(ir) {
|
|
|
11495
11600
|
validateStepExecutePlacement(ir.nodes);
|
|
11496
11601
|
validateThinkingLevelConfig(ir.nodes);
|
|
11497
11602
|
validateCredentialInstanceIdConfig(ir.nodes);
|
|
11603
|
+
validateReviewerAgentOverrides(ir.nodes);
|
|
11498
11604
|
for (const node of ir.nodes) {
|
|
11499
11605
|
if (node.kind === "foreach") validateForeach(node, topLevelIds, columnIds);
|
|
11500
11606
|
if (node.kind === "loop") validateLoop(node, topLevelIds, columnIds);
|
|
@@ -15728,7 +15834,8 @@ function normalizePermissions(raw) {
|
|
|
15728
15834
|
return permissions;
|
|
15729
15835
|
}
|
|
15730
15836
|
function computeAccessState(agent) {
|
|
15731
|
-
const
|
|
15837
|
+
const roles = agent.roles?.length ? agent.roles : [agent.role];
|
|
15838
|
+
const roleDefaultPermissions = new Set(roles.flatMap((role) => ROLE_DEFAULT_PERMISSIONS[role] ?? []));
|
|
15732
15839
|
const explicitPermissions = normalizePermissions(agent.permissions ?? {});
|
|
15733
15840
|
const resolvedPermissions = new Set(roleDefaultPermissions);
|
|
15734
15841
|
for (const permission of explicitPermissions) {
|
|
@@ -15759,6 +15866,9 @@ var IMPLEMENTATION_TASK_COLUMNS = /* @__PURE__ */ new Set([
|
|
|
15759
15866
|
"in-progress",
|
|
15760
15867
|
"in-review"
|
|
15761
15868
|
]);
|
|
15869
|
+
function agentRoles(agent) {
|
|
15870
|
+
return agent.roles?.length ? agent.roles : agent.role ? [agent.role] : [];
|
|
15871
|
+
}
|
|
15762
15872
|
function getAgentAssignmentPolicy(agent) {
|
|
15763
15873
|
const raw = (agent.runtimeConfig ?? {})["assignmentPolicy"];
|
|
15764
15874
|
return raw === "explicit-only" || raw === "none" ? raw : "auto";
|
|
@@ -15773,10 +15883,10 @@ function isImplementationTask(task) {
|
|
|
15773
15883
|
return IMPLEMENTATION_TASK_COLUMNS.has(task.column);
|
|
15774
15884
|
}
|
|
15775
15885
|
function isExecutorRoleAgent(agent) {
|
|
15776
|
-
return agent.
|
|
15886
|
+
return agentRoles(agent).includes("executor");
|
|
15777
15887
|
}
|
|
15778
15888
|
function isEngineerRoleAgent(agent) {
|
|
15779
|
-
return agent.
|
|
15889
|
+
return agentRoles(agent).includes("engineer");
|
|
15780
15890
|
}
|
|
15781
15891
|
function canAgentTakeImplementationTaskForExplicitRouting(agent, task) {
|
|
15782
15892
|
if (!isImplementationTask(task)) return true;
|
|
@@ -15825,7 +15935,8 @@ function formatRoleMismatchReason(agent, task) {
|
|
|
15825
15935
|
if (policy !== "auto") {
|
|
15826
15936
|
return `Agent ${agent.id} has assignmentPolicy "${policy}"; implementation task ${task.id} cannot be routed to it${policy === "none" ? " by any path (no override supported)" : " automatically \u2014 explicit routing only"}.`;
|
|
15827
15937
|
}
|
|
15828
|
-
|
|
15938
|
+
const roles = agentRoles(agent);
|
|
15939
|
+
return `Agent ${agent.id} has roles "${roles.join(", ") || "none"}"; implementation task ${task.id} requires an "executor"-role agent by default, with durable "engineer" supported only for explicit routing. Pass override=true to bypass.`;
|
|
15829
15940
|
}
|
|
15830
15941
|
|
|
15831
15942
|
// ../core/src/agents/agent-permission-policy.ts
|
|
@@ -15948,6 +16059,7 @@ var agentColumns = {
|
|
|
15948
16059
|
id: project_exports.agents.id,
|
|
15949
16060
|
name: project_exports.agents.name,
|
|
15950
16061
|
role: project_exports.agents.role,
|
|
16062
|
+
roles: project_exports.agents.roles,
|
|
15951
16063
|
state: project_exports.agents.state,
|
|
15952
16064
|
taskId: project_exports.agents.taskId,
|
|
15953
16065
|
createdAt: project_exports.agents.createdAt,
|
|
@@ -15978,6 +16090,7 @@ function agentToData(agent) {
|
|
|
15978
16090
|
return {
|
|
15979
16091
|
id: agent.id,
|
|
15980
16092
|
name: agent.name,
|
|
16093
|
+
roles: agent.roles,
|
|
15981
16094
|
role: agent.role,
|
|
15982
16095
|
state: agent.state,
|
|
15983
16096
|
taskId: agent.taskId,
|
|
@@ -16012,6 +16125,7 @@ async function writeAgent(handle, agent, projectId) {
|
|
|
16012
16125
|
id: agent.id,
|
|
16013
16126
|
name: agent.name,
|
|
16014
16127
|
role: agent.role,
|
|
16128
|
+
roles: agent.roles,
|
|
16015
16129
|
state: agent.state,
|
|
16016
16130
|
taskId: agent.taskId ?? null,
|
|
16017
16131
|
createdAt: agent.createdAt,
|
|
@@ -16024,6 +16138,7 @@ async function writeAgent(handle, agent, projectId) {
|
|
|
16024
16138
|
set: {
|
|
16025
16139
|
name: agent.name,
|
|
16026
16140
|
role: agent.role,
|
|
16141
|
+
roles: agent.roles,
|
|
16027
16142
|
state: agent.state,
|
|
16028
16143
|
taskId: agent.taskId ?? null,
|
|
16029
16144
|
updatedAt: agent.updatedAt,
|
|
@@ -16045,6 +16160,7 @@ function mergeAgentRow(row) {
|
|
|
16045
16160
|
...data,
|
|
16046
16161
|
id: row.id,
|
|
16047
16162
|
name: row.name,
|
|
16163
|
+
roles: row.roles?.length ? row.roles : [row.role],
|
|
16048
16164
|
role: row.role,
|
|
16049
16165
|
state: row.state,
|
|
16050
16166
|
taskId: row.taskId ?? void 0,
|
|
@@ -16374,8 +16490,62 @@ var FsWatchPollController = class {
|
|
|
16374
16490
|
}
|
|
16375
16491
|
};
|
|
16376
16492
|
|
|
16493
|
+
// ../core/src/agents/workflow-role-agent-defaults.ts
|
|
16494
|
+
var BUILTIN_WORKFLOW_AGENT_BUNDLE_CONFIG = {
|
|
16495
|
+
mode: "managed",
|
|
16496
|
+
entryFile: "AGENTS.md",
|
|
16497
|
+
files: ["AGENTS.md", "soul.md"]
|
|
16498
|
+
};
|
|
16499
|
+
var BUILTIN_WORKFLOW_ROLE_AGENT_DEFAULTS = {
|
|
16500
|
+
triage: {
|
|
16501
|
+
role: "triage",
|
|
16502
|
+
name: "Workflow Planner",
|
|
16503
|
+
title: "Built-in workflow planning owner",
|
|
16504
|
+
instructionsText: "You are the Workflow Planner. Turn incoming work into clear, bounded, testable plans. Identify the user outcome, constraints, affected surfaces, and acceptance evidence before release. Keep planning distinct from implementation: do not claim code is complete, invent decisions, or bypass approval gates. Communicate concisely, make uncertainty explicit, and leave an executable plan that another agent can follow.",
|
|
16505
|
+
soul: "Calm, structured, and curious. You reduce ambiguity without adding ceremony, respect operator intent, and prefer concrete evidence over confident guesses."
|
|
16506
|
+
},
|
|
16507
|
+
executor: {
|
|
16508
|
+
role: "executor",
|
|
16509
|
+
name: "Workflow Executor",
|
|
16510
|
+
title: "Built-in workflow execution owner",
|
|
16511
|
+
instructionsText: "You are the Workflow Executor. Implement the approved scope with production-quality, maintainable changes. Read the task specification, preserve existing behavior outside scope, and verify the smallest relevant checks before reporting completion. Do not redesign workflow policy, broaden permissions, or conceal blockers; record concrete evidence and surface a genuine dependency when work cannot proceed. Communicate changes and verification precisely.",
|
|
16512
|
+
soul: "Methodical, practical, and accountable. You favor small safe steps, protect user work, and let tests and observable behavior guide your confidence."
|
|
16513
|
+
},
|
|
16514
|
+
reviewer: {
|
|
16515
|
+
role: "reviewer",
|
|
16516
|
+
name: "Workflow Reviewer",
|
|
16517
|
+
title: "Built-in workflow review owner",
|
|
16518
|
+
instructionsText: "You are the Workflow Reviewer. Independently assess whether the submitted work satisfies its specification, preserves system invariants, and has credible verification. Focus on correctness, regressions, security, maintainability, and missing evidence rather than rewriting the implementation. State actionable findings with severity and rationale; approve only when the evidence supports it. Do not perform implementation or override workflow gates.",
|
|
16519
|
+
soul: "Independent, exacting, and fair. You are skeptical of unsupported claims, respectful in feedback, and clear about what would make the work safe to accept."
|
|
16520
|
+
},
|
|
16521
|
+
merger: {
|
|
16522
|
+
role: "merger",
|
|
16523
|
+
name: "Workflow Merger",
|
|
16524
|
+
title: "Built-in workflow merge owner",
|
|
16525
|
+
instructionsText: "You are the Workflow Merger. Integrate only work that has met the project\u2019s configured completion and review requirements. Protect the target branch, inspect merge state and conflicts carefully, and preserve unrelated work. Do not substitute judgment for missing approval, bypass safeguards, or silently discard changes. Report the integration result, any conflicts, and the evidence used to make the decision.",
|
|
16526
|
+
soul: "Deliberate, conservative, and transparent. You optimize for repository integrity, treat uncertainty as a reason to stop, and communicate operational state plainly."
|
|
16527
|
+
}
|
|
16528
|
+
};
|
|
16529
|
+
var BUILTIN_WORKFLOW_ROLE_AGENT_DEFAULT_LIST = Object.values(BUILTIN_WORKFLOW_ROLE_AGENT_DEFAULTS);
|
|
16530
|
+
|
|
16377
16531
|
// ../core/src/agents/agent-store.ts
|
|
16378
16532
|
var agentStoreLog = createLogger("agent-store");
|
|
16533
|
+
function isCanonicalOrPartialBuiltinWorkflowBundle(config2) {
|
|
16534
|
+
if (config2?.mode !== "managed" || config2.entryFile !== "AGENTS.md") return false;
|
|
16535
|
+
return config2.files.every((file) => (file === "AGENTS.md" || file === "soul.md") && config2.files.indexOf(file) === config2.files.lastIndexOf(file));
|
|
16536
|
+
}
|
|
16537
|
+
function isCompleteBuiltinWorkflowBundle(config2) {
|
|
16538
|
+
return isCanonicalOrPartialBuiltinWorkflowBundle(config2) && config2.files.length === BUILTIN_WORKFLOW_AGENT_BUNDLE_CONFIG.files.length;
|
|
16539
|
+
}
|
|
16540
|
+
function compareBuiltinWorkflowOwnerAge(a, b) {
|
|
16541
|
+
const aTime = Date.parse(a.createdAt);
|
|
16542
|
+
const bTime = Date.parse(b.createdAt);
|
|
16543
|
+
const aValid = Number.isFinite(aTime);
|
|
16544
|
+
const bValid = Number.isFinite(bTime);
|
|
16545
|
+
if (aValid && bValid && aTime !== bTime) return aTime - bTime;
|
|
16546
|
+
if (aValid !== bValid) return aValid ? -1 : 1;
|
|
16547
|
+
return a.id.localeCompare(b.id);
|
|
16548
|
+
}
|
|
16379
16549
|
var DEFAULT_AGENT_HEARTBEAT_INTERVAL_MS = 36e5;
|
|
16380
16550
|
function normalizeStoredPermissions(raw) {
|
|
16381
16551
|
if (!raw) return void 0;
|
|
@@ -16486,6 +16656,73 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
16486
16656
|
}
|
|
16487
16657
|
return projectId;
|
|
16488
16658
|
}
|
|
16659
|
+
/** The durable project partition used by workflow routing and capacity leases. */
|
|
16660
|
+
get workflowProjectId() {
|
|
16661
|
+
return this.asyncLayer?.projectId;
|
|
16662
|
+
}
|
|
16663
|
+
/**
|
|
16664
|
+
* FNXC:WorkflowAgentRouting 2026-08-07-05:52:
|
|
16665
|
+
* Workflow capacity is a PostgreSQL lease rather than a process-local count.
|
|
16666
|
+
* The project advisory lock serializes project then agent admission across
|
|
16667
|
+
* engine processes; model work starts only after this short transaction ends.
|
|
16668
|
+
*/
|
|
16669
|
+
async acquireWorkflowSessionCapacity(input) {
|
|
16670
|
+
if (!this.asyncLayer) return "acquired";
|
|
16671
|
+
const projectId = this.backendProjectId;
|
|
16672
|
+
const now = /* @__PURE__ */ new Date();
|
|
16673
|
+
const expiresAt = new Date(now.getTime() + (input.leaseDurationMs ?? 10 * 6e4)).toISOString();
|
|
16674
|
+
return this.asyncLayer.transactionImmediate(async (tx) => {
|
|
16675
|
+
await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtext(${projectId}), hashtext('workflow-agent-capacity'))`);
|
|
16676
|
+
await tx.delete(project_exports.workflowAgentCapacityLeases).where(and(
|
|
16677
|
+
eq(project_exports.workflowAgentCapacityLeases.projectId, projectId),
|
|
16678
|
+
lte(project_exports.workflowAgentCapacityLeases.expiresAt, now.toISOString())
|
|
16679
|
+
));
|
|
16680
|
+
const existing = await tx.select({ attemptId: project_exports.workflowAgentCapacityLeases.attemptId }).from(project_exports.workflowAgentCapacityLeases).where(and(
|
|
16681
|
+
eq(project_exports.workflowAgentCapacityLeases.projectId, projectId),
|
|
16682
|
+
eq(project_exports.workflowAgentCapacityLeases.attemptId, input.attemptId)
|
|
16683
|
+
)).limit(1);
|
|
16684
|
+
if (existing[0]) return "acquired";
|
|
16685
|
+
const projectCount = await tx.select({ count: sql`count(*)::int` }).from(project_exports.workflowAgentCapacityLeases).where(eq(project_exports.workflowAgentCapacityLeases.projectId, projectId));
|
|
16686
|
+
if (input.maxProjectSessions !== void 0 && (projectCount[0]?.count ?? 0) >= input.maxProjectSessions) return "project-capacity";
|
|
16687
|
+
const agentCount = await tx.select({ count: sql`count(*)::int` }).from(project_exports.workflowAgentCapacityLeases).where(and(
|
|
16688
|
+
eq(project_exports.workflowAgentCapacityLeases.projectId, projectId),
|
|
16689
|
+
eq(project_exports.workflowAgentCapacityLeases.agentId, input.agentId)
|
|
16690
|
+
));
|
|
16691
|
+
if (input.maxAgentSessions !== void 0 && (agentCount[0]?.count ?? 0) >= input.maxAgentSessions) return "agent-capacity";
|
|
16692
|
+
await tx.insert(project_exports.workflowAgentCapacityLeases).values({
|
|
16693
|
+
projectId,
|
|
16694
|
+
agentId: input.agentId,
|
|
16695
|
+
attemptId: input.attemptId,
|
|
16696
|
+
createdAt: now.toISOString(),
|
|
16697
|
+
expiresAt
|
|
16698
|
+
});
|
|
16699
|
+
return "acquired";
|
|
16700
|
+
});
|
|
16701
|
+
}
|
|
16702
|
+
/** Renew only the caller's project-scoped attempt; a reclaimed lease never resurrects. */
|
|
16703
|
+
async renewWorkflowSessionCapacity(attemptId, leaseDurationMs = 10 * 6e4) {
|
|
16704
|
+
if (!this.asyncLayer) return true;
|
|
16705
|
+
const now = /* @__PURE__ */ new Date();
|
|
16706
|
+
const result = await this.asyncLayer.db.update(project_exports.workflowAgentCapacityLeases).set({ expiresAt: new Date(now.getTime() + leaseDurationMs).toISOString() }).where(and(
|
|
16707
|
+
eq(project_exports.workflowAgentCapacityLeases.projectId, this.backendProjectId),
|
|
16708
|
+
eq(project_exports.workflowAgentCapacityLeases.attemptId, attemptId),
|
|
16709
|
+
/*
|
|
16710
|
+
* FNXC:WorkflowAgentRouting 2026-08-07-07:30:
|
|
16711
|
+
* Renew a currently live lease only. An expired row may already have
|
|
16712
|
+
* been reclaimed by another engine's admission transaction.
|
|
16713
|
+
*/
|
|
16714
|
+
gt(project_exports.workflowAgentCapacityLeases.expiresAt, now.toISOString())
|
|
16715
|
+
)).returning({ attemptId: project_exports.workflowAgentCapacityLeases.attemptId });
|
|
16716
|
+
return result.length > 0;
|
|
16717
|
+
}
|
|
16718
|
+
/** Release is project-scoped and idempotent so cancellation and recovery may race safely. */
|
|
16719
|
+
async releaseWorkflowSessionCapacity(attemptId) {
|
|
16720
|
+
if (!this.asyncLayer) return;
|
|
16721
|
+
await this.asyncLayer.db.delete(project_exports.workflowAgentCapacityLeases).where(and(
|
|
16722
|
+
eq(project_exports.workflowAgentCapacityLeases.projectId, this.backendProjectId),
|
|
16723
|
+
eq(project_exports.workflowAgentCapacityLeases.attemptId, attemptId)
|
|
16724
|
+
));
|
|
16725
|
+
}
|
|
16489
16726
|
get db() {
|
|
16490
16727
|
throw new Error("SQLite Database is not available in backend mode (asyncLayer injected)");
|
|
16491
16728
|
}
|
|
@@ -16500,7 +16737,7 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
16500
16737
|
*/
|
|
16501
16738
|
async init() {
|
|
16502
16739
|
await mkdir(this.agentsDir, { recursive: true });
|
|
16503
|
-
|
|
16740
|
+
await this.provisionBuiltinWorkflowRoleAgents();
|
|
16504
16741
|
}
|
|
16505
16742
|
/**
|
|
16506
16743
|
* One-shot migration that re-points every non-ephemeral agent off the
|
|
@@ -16662,8 +16899,8 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
16662
16899
|
* @param name - Agent name to match exactly
|
|
16663
16900
|
* @returns Matching non-ephemeral agent, or null when none exists
|
|
16664
16901
|
*/
|
|
16665
|
-
async findAgentByName(name) {
|
|
16666
|
-
const agents2 = await findAgentRowsByName(this.asyncLayer.db, name);
|
|
16902
|
+
async findAgentByName(name, executor) {
|
|
16903
|
+
const agents2 = await findAgentRowsByName(executor ?? this.asyncLayer.db, name);
|
|
16667
16904
|
for (const agent of agents2) {
|
|
16668
16905
|
if (!isEphemeralAgent(agent)) {
|
|
16669
16906
|
return this.parseAgent(agent);
|
|
@@ -16698,18 +16935,16 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
16698
16935
|
* @returns The created agent
|
|
16699
16936
|
* @throws Error if input is invalid or a duplicate non-ephemeral name exists
|
|
16700
16937
|
*/
|
|
16701
|
-
async createAgent(input) {
|
|
16938
|
+
async createAgent(input, executor) {
|
|
16702
16939
|
if (!input.name?.trim()) {
|
|
16703
16940
|
throw new Error("Agent name is required");
|
|
16704
16941
|
}
|
|
16705
|
-
|
|
16706
|
-
throw new Error("Agent role is required");
|
|
16707
|
-
}
|
|
16942
|
+
const roles = normalizeAgentRoles(input.roles, input.role);
|
|
16708
16943
|
const normalizedName = input.name.trim();
|
|
16709
16944
|
const metadata = input.metadata ?? {};
|
|
16710
|
-
const ephemeral = isEphemeralAgent({ metadata, name: input.name, role:
|
|
16945
|
+
const ephemeral = isEphemeralAgent({ metadata, name: input.name, role: roles[0], reportsTo: input.reportsTo });
|
|
16711
16946
|
if (!ephemeral) {
|
|
16712
|
-
const existing = await this.findAgentByName(normalizedName);
|
|
16947
|
+
const existing = await this.findAgentByName(normalizedName, executor);
|
|
16713
16948
|
if (existing) {
|
|
16714
16949
|
throw new Error(`Agent with name "${normalizedName}" already exists (agentId: ${existing.id})`);
|
|
16715
16950
|
}
|
|
@@ -16722,7 +16957,8 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
16722
16957
|
const agent = {
|
|
16723
16958
|
id: agentId,
|
|
16724
16959
|
name: normalizedName,
|
|
16725
|
-
|
|
16960
|
+
roles,
|
|
16961
|
+
role: roles[0],
|
|
16726
16962
|
// Non-ephemeral agents start active so they immediately participate in
|
|
16727
16963
|
// heartbeat scheduling; ephemeral/task-worker agents start idle and are
|
|
16728
16964
|
// activated by the engine when work is assigned.
|
|
@@ -16744,7 +16980,7 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
16744
16980
|
...input.bundleConfig && { bundleConfig: input.bundleConfig },
|
|
16745
16981
|
...resolvedHeartbeatProcedurePath && { heartbeatProcedurePath: resolvedHeartbeatProcedurePath }
|
|
16746
16982
|
};
|
|
16747
|
-
await this.writeAgent(agent);
|
|
16983
|
+
await this.writeAgent(agent, executor);
|
|
16748
16984
|
this.emit("agent:created", agent);
|
|
16749
16985
|
return agent;
|
|
16750
16986
|
}
|
|
@@ -17087,10 +17323,12 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
17087
17323
|
const beforeSnapshot = agentToConfigSnapshot(agent);
|
|
17088
17324
|
const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
17089
17325
|
const normalizedUpdatedPermissionPolicy = "permissionPolicy" in updates && updates.permissionPolicy !== void 0 ? normalizeAgentPermissionPolicy(updates.permissionPolicy) : updates.permissionPolicy;
|
|
17326
|
+
const roles = updates.roles !== void 0 || updates.role !== void 0 ? normalizeAgentRoles(updates.roles, updates.role) : agent.roles;
|
|
17090
17327
|
const updated = {
|
|
17091
17328
|
...agent,
|
|
17092
17329
|
name: nextName ?? agent.name,
|
|
17093
|
-
|
|
17330
|
+
roles,
|
|
17331
|
+
role: roles[0],
|
|
17094
17332
|
metadata: updates.metadata !== void 0 ? updates.metadata : agent.metadata,
|
|
17095
17333
|
updatedAt,
|
|
17096
17334
|
..."title" in updates && { title: updates.title },
|
|
@@ -17625,12 +17863,81 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
17625
17863
|
* @param filter - Optional filter criteria
|
|
17626
17864
|
* @returns Array of agents
|
|
17627
17865
|
*/
|
|
17628
|
-
async listAgents(filter) {
|
|
17629
|
-
const agents2 = await listAgentRows(this.asyncLayer.db, {
|
|
17630
|
-
|
|
17631
|
-
|
|
17866
|
+
async listAgents(filter, executor) {
|
|
17867
|
+
const agents2 = await listAgentRows(executor ?? this.asyncLayer.db, { state: filter?.state });
|
|
17868
|
+
return agents2.map((a) => this.parseAgent(a)).filter((agent) => !filter?.role || agent.roles.includes(filter.role)).filter((agent) => filter?.includeEphemeral === true || !isEphemeralAgent(agent));
|
|
17869
|
+
}
|
|
17870
|
+
/**
|
|
17871
|
+
* Idempotently seed the permanent owners that route built-in workflow stages.
|
|
17872
|
+
* Matching operator-created agents are intentionally not reused: provenance
|
|
17873
|
+
* makes upgrade repair deterministic while operators remain free to add pool
|
|
17874
|
+
* members with the same tag.
|
|
17875
|
+
*/
|
|
17876
|
+
async provisionBuiltinWorkflowRoleAgents() {
|
|
17877
|
+
const provision = async (executor) => {
|
|
17878
|
+
const existing = await this.listAgents({ includeEphemeral: true }, executor);
|
|
17879
|
+
const supportedRoles = new Set(BUILTIN_WORKFLOW_ROLE_AGENT_DEFAULT_LIST.map(({ role }) => role));
|
|
17880
|
+
const groups = /* @__PURE__ */ new Map();
|
|
17881
|
+
for (const agent of existing) {
|
|
17882
|
+
const role = agent.metadata?.workflowRole;
|
|
17883
|
+
if (agent.metadata?.builtInWorkflowRole === true && typeof role === "string" && supportedRoles.has(role)) {
|
|
17884
|
+
const group = groups.get(role) ?? [];
|
|
17885
|
+
group.push(agent);
|
|
17886
|
+
groups.set(role, group);
|
|
17887
|
+
}
|
|
17888
|
+
}
|
|
17889
|
+
const winners = /* @__PURE__ */ new Map();
|
|
17890
|
+
for (const [role, group] of groups) {
|
|
17891
|
+
group.sort(compareBuiltinWorkflowOwnerAge);
|
|
17892
|
+
winners.set(role, group[0]);
|
|
17893
|
+
for (const loser of group.slice(1)) {
|
|
17894
|
+
const { builtInWorkflowRole: _builtIn, workflowRole: _role, ...metadata } = loser.metadata;
|
|
17895
|
+
await this.writeAgent({ ...loser, metadata, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, executor);
|
|
17896
|
+
}
|
|
17897
|
+
}
|
|
17898
|
+
const result = [];
|
|
17899
|
+
for (const definition of BUILTIN_WORKFLOW_ROLE_AGENT_DEFAULT_LIST) {
|
|
17900
|
+
let agent = winners.get(definition.role);
|
|
17901
|
+
if (!agent) {
|
|
17902
|
+
agent = await this.createAgent({
|
|
17903
|
+
name: definition.name,
|
|
17904
|
+
roles: [definition.role],
|
|
17905
|
+
title: definition.title,
|
|
17906
|
+
metadata: { builtInWorkflowRole: true, workflowRole: definition.role },
|
|
17907
|
+
runtimeConfig: { enabled: false },
|
|
17908
|
+
instructionsText: definition.instructionsText,
|
|
17909
|
+
soul: definition.soul,
|
|
17910
|
+
bundleConfig: { ...BUILTIN_WORKFLOW_AGENT_BUNDLE_CONFIG, files: [...BUILTIN_WORKFLOW_AGENT_BUNDLE_CONFIG.files] }
|
|
17911
|
+
}, executor);
|
|
17912
|
+
} else {
|
|
17913
|
+
const canonicalOrPartialBundle = isCanonicalOrPartialBuiltinWorkflowBundle(agent.bundleConfig);
|
|
17914
|
+
const customInstructions = Boolean(agent.instructionsPath?.trim()) || agent.bundleConfig?.mode === "external" || agent.bundleConfig !== void 0 && !canonicalOrPartialBundle || Boolean(agent.instructionsText?.trim()) && agent.instructionsText !== definition.instructionsText;
|
|
17915
|
+
const updates = {};
|
|
17916
|
+
if (!customInstructions && !agent.instructionsText?.trim()) updates.instructionsText = definition.instructionsText;
|
|
17917
|
+
if (!agent.soul?.trim()) updates.soul = definition.soul;
|
|
17918
|
+
if (!customInstructions && !isCompleteBuiltinWorkflowBundle(agent.bundleConfig)) {
|
|
17919
|
+
updates.bundleConfig = { ...BUILTIN_WORKFLOW_AGENT_BUNDLE_CONFIG, files: [...BUILTIN_WORKFLOW_AGENT_BUNDLE_CONFIG.files] };
|
|
17920
|
+
}
|
|
17921
|
+
if (Object.keys(updates).length > 0) {
|
|
17922
|
+
agent = { ...agent, ...updates, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
17923
|
+
await this.writeAgent(agent, executor);
|
|
17924
|
+
}
|
|
17925
|
+
}
|
|
17926
|
+
result.push(agent);
|
|
17927
|
+
}
|
|
17928
|
+
return result;
|
|
17929
|
+
};
|
|
17930
|
+
if (!this.asyncLayer) {
|
|
17931
|
+
const agents3 = await provision();
|
|
17932
|
+
await Promise.all(agents3.map((agent) => this.materializeBuiltinWorkflowRoleBundle(agent)));
|
|
17933
|
+
return agents3;
|
|
17934
|
+
}
|
|
17935
|
+
const agents2 = await this.asyncLayer.transactionImmediate(async (tx) => {
|
|
17936
|
+
await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtext(${this.backendProjectId}), hashtext('builtin-workflow-role-provisioning'))`);
|
|
17937
|
+
return provision(tx);
|
|
17632
17938
|
});
|
|
17633
|
-
|
|
17939
|
+
await Promise.all(agents2.map((agent) => this.materializeBuiltinWorkflowRoleBundle(agent)));
|
|
17940
|
+
return agents2;
|
|
17634
17941
|
}
|
|
17635
17942
|
/**
|
|
17636
17943
|
* Create an API key for an agent.
|
|
@@ -18198,6 +18505,29 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
18198
18505
|
}
|
|
18199
18506
|
return null;
|
|
18200
18507
|
}
|
|
18508
|
+
/** Seed only missing or blank default-owned mirror files after the provisioning transaction commits. */
|
|
18509
|
+
async materializeBuiltinWorkflowRoleBundle(agent) {
|
|
18510
|
+
return this.withLock(agent.id, async () => {
|
|
18511
|
+
const role = agent.metadata?.workflowRole;
|
|
18512
|
+
const definition = BUILTIN_WORKFLOW_ROLE_AGENT_DEFAULT_LIST.find((candidate) => candidate.role === role);
|
|
18513
|
+
if (!definition || agent.metadata?.builtInWorkflowRole !== true) return;
|
|
18514
|
+
const config2 = agent.bundleConfig;
|
|
18515
|
+
if (!isCanonicalOrPartialBuiltinWorkflowBundle(config2)) return;
|
|
18516
|
+
if (agent.instructionsPath?.trim() || agent.instructionsText?.trim() && agent.instructionsText !== definition.instructionsText) return;
|
|
18517
|
+
const bundleDir = await this.resolveCompatibleBundleDir(agent.id, true);
|
|
18518
|
+
await mkdir(bundleDir, { recursive: true });
|
|
18519
|
+
for (const [file, content] of [["AGENTS.md", definition.instructionsText], ["soul.md", definition.soul]]) {
|
|
18520
|
+
const path = join(bundleDir, file);
|
|
18521
|
+
let current = "";
|
|
18522
|
+
try {
|
|
18523
|
+
current = await readFile(path, "utf-8");
|
|
18524
|
+
} catch (error) {
|
|
18525
|
+
if (error.code !== "ENOENT") throw error;
|
|
18526
|
+
}
|
|
18527
|
+
if (!current.trim()) await writeFile(path, content, "utf-8");
|
|
18528
|
+
}
|
|
18529
|
+
});
|
|
18530
|
+
}
|
|
18201
18531
|
getCanonicalBundleDir(agent) {
|
|
18202
18532
|
return join(this.agentsDir, getCanonicalAgentInstructionsBundleDirName(agent.name, agent.id));
|
|
18203
18533
|
}
|
|
@@ -18320,6 +18650,7 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
18320
18650
|
...data,
|
|
18321
18651
|
id: row.id,
|
|
18322
18652
|
name: row.name,
|
|
18653
|
+
roles: data.roles?.length ? data.roles : [row.role],
|
|
18323
18654
|
role: row.role,
|
|
18324
18655
|
state: row.state,
|
|
18325
18656
|
taskId: row.taskId ?? void 0,
|
|
@@ -18353,7 +18684,8 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
18353
18684
|
return {
|
|
18354
18685
|
id: data.id,
|
|
18355
18686
|
name: data.name,
|
|
18356
|
-
|
|
18687
|
+
roles: normalizeAgentRoles(data.roles, data.role),
|
|
18688
|
+
role: normalizeAgentRoles(data.roles, data.role)[0],
|
|
18357
18689
|
state: data.state,
|
|
18358
18690
|
taskId: data.taskId,
|
|
18359
18691
|
createdAt: data.createdAt,
|
|
@@ -18379,8 +18711,8 @@ var AgentStore = class _AgentStore extends EventEmitter {
|
|
|
18379
18711
|
heartbeatProcedurePath: data.heartbeatProcedurePath
|
|
18380
18712
|
};
|
|
18381
18713
|
}
|
|
18382
|
-
async writeAgent(agent) {
|
|
18383
|
-
await writeAgent(this.asyncLayer.db, agent, this.asyncLayer.projectId);
|
|
18714
|
+
async writeAgent(agent, executor) {
|
|
18715
|
+
await writeAgent(executor ?? this.asyncLayer.db, agent, this.asyncLayer.projectId);
|
|
18384
18716
|
return;
|
|
18385
18717
|
}
|
|
18386
18718
|
/**
|