@skaile/workspaces 4.23.1 → 4.23.3

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 (84) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/{asset-feeds-5WLES6EE.js → asset-feeds-FINEX7SP.js} +4 -4
  3. package/dist/{asset-feeds-5WLES6EE.js.map → asset-feeds-FINEX7SP.js.map} +1 -1
  4. package/dist/asset-manager/index.js +1 -1
  5. package/dist/{chunk-7B362FO3.js → chunk-246NSTR7.js} +3 -3
  6. package/dist/{chunk-7B362FO3.js.map → chunk-246NSTR7.js.map} +1 -1
  7. package/dist/{chunk-ORCSZZLG.js → chunk-5CT42FXA.js} +3 -3
  8. package/dist/{chunk-ORCSZZLG.js.map → chunk-5CT42FXA.js.map} +1 -1
  9. package/dist/{chunk-LLW2MCZE.js → chunk-C2TJPNP2.js} +4 -4
  10. package/dist/{chunk-LLW2MCZE.js.map → chunk-C2TJPNP2.js.map} +1 -1
  11. package/dist/{chunk-KFN55DUL.js → chunk-D5MX76BA.js} +16 -12
  12. package/dist/chunk-D5MX76BA.js.map +1 -0
  13. package/dist/{chunk-RQLL7L72.js → chunk-D6YOE2DB.js} +18 -4
  14. package/dist/chunk-D6YOE2DB.js.map +1 -0
  15. package/dist/{chunk-4FIF2QZH.js → chunk-EVH2X3QF.js} +3 -3
  16. package/dist/{chunk-4FIF2QZH.js.map → chunk-EVH2X3QF.js.map} +1 -1
  17. package/dist/{chunk-H7XC2IAQ.js → chunk-FYLDR3RQ.js} +3 -3
  18. package/dist/{chunk-H7XC2IAQ.js.map → chunk-FYLDR3RQ.js.map} +1 -1
  19. package/dist/{chunk-PTALRV5L.js → chunk-KES5T25I.js} +76 -6
  20. package/dist/chunk-KES5T25I.js.map +1 -0
  21. package/dist/{chunk-3DVBPLIZ.js → chunk-OCZGKA2Q.js} +6 -6
  22. package/dist/{chunk-3DVBPLIZ.js.map → chunk-OCZGKA2Q.js.map} +1 -1
  23. package/dist/{chunk-B6DXWEOC.js → chunk-PPMHNT6A.js} +2 -2
  24. package/dist/{chunk-B6DXWEOC.js.map → chunk-PPMHNT6A.js.map} +1 -1
  25. package/dist/{chunk-4BF3SNGJ.js → chunk-SDUVIZPA.js} +2 -2
  26. package/dist/{chunk-4BF3SNGJ.js.map → chunk-SDUVIZPA.js.map} +1 -1
  27. package/dist/{chunk-UOSXXZJX.js → chunk-SY2QGPRX.js} +6 -6
  28. package/dist/{chunk-UOSXXZJX.js.map → chunk-SY2QGPRX.js.map} +1 -1
  29. package/dist/cli/index.js +29 -29
  30. package/dist/connectors/index.js +2 -2
  31. package/dist/{ensure-sources-CUJPN27W.js → ensure-sources-LJH3SLWG.js} +4 -4
  32. package/dist/{ensure-sources-CUJPN27W.js.map → ensure-sources-LJH3SLWG.js.map} +1 -1
  33. package/dist/factory-assets/connectors/box.js +2 -2
  34. package/dist/factory-assets/connectors/deploy.js +2 -2
  35. package/dist/factory-assets/connectors/devserver.js +2 -2
  36. package/dist/factory-assets/connectors/flow/adapter.js +2 -2
  37. package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts.map +1 -1
  38. package/dist/factory-assets/connectors/flow/prompt-fragments.js +1 -1
  39. package/dist/factory-assets/connectors/flow/run-flow.js +3 -3
  40. package/dist/factory-assets/connectors/flow.js +2 -2
  41. package/dist/factory-assets/connectors/git/CONNECTOR.md +2 -1
  42. package/dist/factory-assets/connectors/git/driver.d.ts +11 -2
  43. package/dist/factory-assets/connectors/git/driver.d.ts.map +1 -1
  44. package/dist/factory-assets/connectors/git.js +2 -2
  45. package/dist/factory-assets/connectors/gmail.js +2 -2
  46. package/dist/factory-assets/connectors/googledrive.js +2 -2
  47. package/dist/factory-assets/connectors/local.js +2 -2
  48. package/dist/factory-assets/connectors/mattermost.js +2 -2
  49. package/dist/factory-assets/connectors/memory.js +2 -2
  50. package/dist/factory-assets/connectors/minio.js +2 -2
  51. package/dist/factory-assets/connectors/postgres.js +2 -2
  52. package/dist/factory-assets/connectors/s3.js +2 -2
  53. package/dist/factory-assets/connectors/sharepoint.js +2 -2
  54. package/dist/factory-assets/connectors/sqlite.js +2 -2
  55. package/dist/factory-assets/connectors/static-server.js +2 -2
  56. package/dist/factory-assets/connectors/tunnel.js +2 -2
  57. package/dist/factory-assets/connectors/webdav.js +2 -2
  58. package/dist/factory-assets/connectors/xstate-store.js +2 -2
  59. package/dist/factory-assets/connectors/xstate.js +2 -2
  60. package/dist/{helpers-TBUFHY4M.js → helpers-HGDT6O4S.js} +4 -4
  61. package/dist/{helpers-TBUFHY4M.js.map → helpers-HGDT6O4S.js.map} +1 -1
  62. package/dist/{library-publish-PQ4QUFSU.js → library-publish-B3OVNRMC.js} +6 -6
  63. package/dist/{library-publish-PQ4QUFSU.js.map → library-publish-B3OVNRMC.js.map} +1 -1
  64. package/dist/{open-library-DTHVX745.js → open-library-DFK6L43P.js} +5 -5
  65. package/dist/{open-library-DTHVX745.js.map → open-library-DFK6L43P.js.map} +1 -1
  66. package/dist/{project-2TGBVK5Z.js → project-JTPQ5R7E.js} +5 -5
  67. package/dist/{project-2TGBVK5Z.js.map → project-JTPQ5R7E.js.map} +1 -1
  68. package/dist/runner/index.js +5 -5
  69. package/dist/runner/src/serve.d.ts.map +1 -1
  70. package/dist/sdk/asset-manager.js +1 -1
  71. package/dist/sdk/index.js +5 -5
  72. package/dist/sdk/runner.js +5 -5
  73. package/dist/{setup-SVSZ72DE.js → setup-IVBCYLJ4.js} +5 -5
  74. package/dist/{setup-SVSZ72DE.js.map → setup-IVBCYLJ4.js.map} +1 -1
  75. package/dist/{source-65BYI424.js → source-AK3GBWT7.js} +6 -6
  76. package/dist/{source-65BYI424.js.map → source-AK3GBWT7.js.map} +1 -1
  77. package/dist/{source-manifest-publish-NZILVOLT.js → source-manifest-publish-4LPTEJOW.js} +7 -7
  78. package/dist/{source-manifest-publish-NZILVOLT.js.map → source-manifest-publish-4LPTEJOW.js.map} +1 -1
  79. package/dist/tui/index.js +5 -5
  80. package/dist/workspace-plugin/index.js +1 -1
  81. package/package.json +1 -1
  82. package/dist/chunk-KFN55DUL.js.map +0 -1
  83. package/dist/chunk-PTALRV5L.js.map +0 -1
  84. package/dist/chunk-RQLL7L72.js.map +0 -1
@@ -44,8 +44,12 @@ function buildOrchestratorPrompt(flowDef, state, stimulus) {
44
44
  return `| ${n.id} | ${nodeLabel(n)} | ${description} | ${required} | ${gate} | ${status} | ${deps} |`;
45
45
  }).join("\n");
46
46
  const nodesByStatus = (s) => Object.values(state.nodes).filter((n) => promptNodeIds.has(n.id) && n.status === s).map((n) => n.id);
47
+ const approvedAwaitingCompletion = Object.values(state.nodes).filter(
48
+ (n) => agentNodeIds.has(n.id) && n.status === "awaiting_approval" && n.approval?.decision === "approved" && n.approval.decidedAt != null
49
+ );
50
+ const approvedIds = new Set(approvedAwaitingCompletion.map((n) => n.id));
47
51
  const available = nodesByStatus("available");
48
- const awaitingApproval = nodesByStatus("awaiting_approval");
52
+ const awaitingApproval = nodesByStatus("awaiting_approval").filter((id) => !approvedIds.has(id));
49
53
  const awaitingInput = nodesByStatus("awaiting_input");
50
54
  const running = nodesByStatus("running");
51
55
  const failed = nodesByStatus("failed");
@@ -59,9 +63,19 @@ function buildOrchestratorPrompt(flowDef, state, stimulus) {
59
63
  `- Available now: ${available.join(", ") || "(none)"}`,
60
64
  `- Currently running: ${running.join(", ") || "(none)"}`,
61
65
  `- Awaiting approval: ${awaitingApproval.join(", ") || "(none)"}`,
66
+ ...approvedIds.size > 0 ? [`- Approved, awaiting \`complete_node\`: ${[...approvedIds].join(", ")}`] : [],
62
67
  `- Awaiting input: ${awaitingInput.join(", ") || "(none)"}`,
63
68
  `- Failed: ${failed.join(", ") || "(none)"}`
64
69
  ].join("\n");
70
+ const approvedSection = approvedAwaitingCompletion.length > 0 ? `## Approved nodes awaiting completion
71
+
72
+ ${approvedAwaitingCompletion.map(
73
+ (node) => `- \`${node.id}\` \u2014 approved by ${node.approval?.decidedBy ?? "unknown reviewer"} at ${node.approval?.decidedAt}`
74
+ ).join("\n")}
75
+
76
+ A human has already approved these nodes. Do not wait for another decision and do not call \`request_approval\` again. Carry out whatever the approval authorised that is still outstanding, then call \`complete_node\` for each.
77
+
78
+ ` : "";
65
79
  const outputCorrections = Object.values(state.nodes).filter(
66
80
  (node) => agentNodeIds.has(node.id) && node.outputCorrection && node.status !== "complete" && node.status !== "failed"
67
81
  ).map(
@@ -143,7 +157,7 @@ Nodes with **Gate = first-class** are runtime-owned human decisions. The runtime
143
157
 
144
158
  ${stateSummary}
145
159
 
146
- ${globalsSection}${correctionSection}${rejectedGateSection}${overriddenCheckSection}## Why this turn is happening
160
+ ${globalsSection}${correctionSection}${rejectedGateSection}${overriddenCheckSection}${approvedSection}## Why this turn is happening
147
161
 
148
162
  ${stimulusParagraph}
149
163
 
@@ -205,5 +219,5 @@ function describeStimulus(stimulus) {
205
219
  }
206
220
 
207
221
  export { buildOrchestratorPrompt, describeStimulus, renderStimulusPrompt, renderSubpromptPrompt };
208
- //# sourceMappingURL=chunk-RQLL7L72.js.map
209
- //# sourceMappingURL=chunk-RQLL7L72.js.map
222
+ //# sourceMappingURL=chunk-D6YOE2DB.js.map
223
+ //# sourceMappingURL=chunk-D6YOE2DB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../factory-assets/connectors/flow/prompt-fragments.ts"],"names":[],"mappings":";;;AA2DO,SAAS,qBAAqB,QAAA,EAAgC;AACnE,EAAA,QAAQ,SAAS,IAAA;AAAM,IACrB,KAAK,cAAA;AACH,MAAA,OAAO,iKAAA;AAAA,IACT,KAAK,mBAAA,EAAqB;AACxB,MAAA,MAAM,EAAE,MAAA,EAAQ,QAAA,EAAU,SAAA,EAAW,UAAS,GAAI,QAAA;AAClD,MAAA,IAAI,aAAa,UAAA,EAAY;AAC3B,QAAA,OAAO,CAAA,OAAA,EAAU,MAAM,CAAA,uBAAA,EAA0B,SAAS,CAAA,yGAAA,CAAA;AAAA,MAC5D;AACA,MAAA,MAAM,EA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AAK,gBAAA;AACH,MAAA,OAAO,CAAA,eAAA,EAAkB,SAAS,MAAM,CAAA,CAAA;AAAA,IAC1C,KAAK,iBAAA;AACH,MAAA,OAAO,CAAA,gBAAA,EAAmB,SAAS,MAAM,CAAA,CAAA;AAAA,IAC3C,KAAK,cAAA;AACH,MAAA,OAAO,CAAA,aAAA,EAAgB,SAAS,QAAQ,CAAA,CAAA;AAAA,IAC1C,KAAK,2BAAA;AACH,MAAA,OAAO,2BAAA;AAAA,IACT,KAAK,WAAA;AACH,MAAA,OAAO,WAAA;AAAA,IACT,KAAK,eAAA;AACH,MAAA,OAAO,eAAA;AAAA;AAEb","file":"chunk-D6YOE2DB.js","sourcesContent":["/**\n * Prompt fragments for the flow connector.\n *\n * Pure functions that translate a {@link TurnStimulus} into the strings the\n * runner's flow orchestrator splices into the per-turn agent prompt.\n * Extracted from `runner/src/flow-orchestrator.ts` in Phase 3 of the\n * flow-connector extraction (2026-05-08) so the connector owns its\n * prompt-rendering surface without a runtime dep on the orchestrator.\n *\n * The contract is byte-identical to the previous inline implementation —\n * any divergence is a regression.\n *\n * @docLink packages/factory-assets/flow#prompt-fragments\n */\n\nimport type { FlowExecution } from \"@skaile/workspaces/types\";\nimport type { FlowDefinition } from \"./engine/types.js\";\nimport {\n flowDefaults,\n isAgentNode,\n isCheckNode,\n isGateNode,\n nodeIsOptional,\n nodeLabel,\n nodeRequiresApproval,\n} from \"./engine/node-shape.js\";\n\n/**\n * Reasons why a new turn is starting. The flow orchestrator's prompt template\n * renders a stimulus-specific paragraph (via {@link renderStimulusPrompt}) so\n * the agent knows exactly why it has been invoked.\n *\n * @docLink packages/factory-assets/flow#turn-stimulus\n */\nexport type TurnStimulus =\n | { kind: \"flow_started\" }\n | {\n kind: \"approval_received\";\n nodeId: string;\n decision: \"approved\" | \"rejected\";\n feedback?: string;\n decidedBy: string;\n }\n | { kind: \"input_received\"; nodeId: string; response: unknown; providedBy: string }\n | { kind: \"retry_requested\"; nodeId: string; requestedBy: string }\n | { kind: \"user_message\"; text: string; senderId: string }\n | { kind: \"resumed_after_hibernation\" }\n | { kind: \"cancelled\" }\n | { kind: \"state_changed\" };\n\n/**\n * Render the stimulus paragraph the agent sees at turn start.\n *\n * The output is a single paragraph (one or more sentences, no surrounding\n * whitespace) describing why the runner has woken the agent. Spliced into\n * the orchestrator prompt under the `## Why this turn is happening` heading.\n *\n * @docLink packages/factory-assets/flow#render-stimulus-prompt\n */\nexport function renderStimulusPrompt(stimulus: TurnStimulus): string {\n switch (stimulus.kind) {\n case \"flow_started\":\n return \"The user just started this flow. Begin with the first available node — call `get_available`, then `build_handoff` for your chosen node, then `start_node`.\";\n case \"approval_received\": {\n const { nodeId, decision, decidedBy, feedback } = stimulus;\n if (decision === \"approved\") {\n return `Node \\`${nodeId}\\` was **approved** by ${decidedBy}. Call \\`complete_node\\` for this node with the approved output, then advance to the next available node.`;\n }\n const fb = feedback ? ` Feedback: \"${feedback}\".` : \"\";\n return `Node \\`${nodeId}\\` was **rejected** by ${decidedBy}.${fb} Decide how to proceed: retry the node (the engine returned it to \\`available\\`), ask clarifying questions via \\`request_input\\`, or call \\`fail_node(..., recoverable: false)\\` if the issue cannot be addressed.`;\n }\n case \"input_received\":\n return `The user just provided input for node \\`${stimulus.nodeId}\\` (provided by ${stimulus.providedBy}). The node has returned to its prior status. Continue executing the node with this input.`;\n case \"retry_requested\":\n return `A user requested a retry of node \\`${stimulus.nodeId}\\` (requested by ${stimulus.requestedBy}). The node has been returned to \\`available\\` with its prior error preserved in history. Start a fresh attempt — review the error context if relevant and try a different approach.`;\n case \"user_message\":\n return `A user sent a message: \"${stimulus.text}\" (from ${stimulus.senderId}). You can respond directly without touching the flow, continue flow work, or both. If the message is a question about the flow, answer it; if it signals a new direction, consider whether to pause.`;\n case \"resumed_after_hibernation\":\n return \"This session was hibernated and has just resumed. Review the current state above and continue where you left off. No state was lost.\";\n case \"cancelled\":\n return \"The user has cancelled this flow. Wrap up cleanly: do not start any new nodes. You may record a short summary if relevant, then stop.\";\n case \"state_changed\":\n return \"The flow state changed. Review the current state above and continue work accordingly.\";\n }\n}\n\n/**\n * Build the full agent-orchestrator prompt for a flow turn.\n *\n * Reassembles the five-section prompt from the current FlowExecution snapshot\n * and the supplied stimulus:\n *\n * 1. Flow definition (markdown table of nodes)\n * 2. Current state (progress, available/blocked, interaction pointers)\n * 3. Why this turn is happening (stimulus-specific paragraph)\n * 4. Flow tools available (static documentation)\n * 5. Rules\n *\n * Originally a byte-identical lift of the (since-deleted)\n * `FlowOrchestrator.buildOrchestratorPrompt`; the contract now is simply\n * this function's own output. When strict v2 defaults or legacy globals are\n * non-empty, a `## Flow globals` section exposes those run-scoped values. The\n * flow-wide active-node table stays bounded to selection metadata; `build_handoff`\n * supplies a selected agent node's execution payload. First-class gates appear\n * as runtime-owned state but never as agent-executable work.\n * Pure — depends only on its inputs.\n *\n * @docLink packages/factory-assets/flow#build-orchestrator-prompt\n * @since 2.2.0\n */\nexport function buildOrchestratorPrompt(\n flowDef: FlowDefinition,\n state: FlowExecution,\n stimulus: TurnStimulus,\n): string {\n const agentNodes = flowDef.nodes.filter(isAgentNode);\n const gateNodes = flowDef.nodes.filter(isGateNode);\n const checkNodes = flowDef.nodes.filter(isCheckNode);\n const promptNodes = flowDef.nodes.filter((node) => isAgentNode(node) || isGateNode(node));\n const agentNodeIds = new Set(agentNodes.map((node) => node.id));\n const promptNodeIds = new Set(promptNodes.map((node) => node.id));\n\n // ── Section 1: definition table ──\n const nodeRows = promptNodes\n .map((n) => {\n const deps =\n flowDef.edges\n .filter((e) => e.target === n.id && e.type === \"flow\")\n .map((e) => e.source)\n .join(\", \") || \"—\";\n const required = nodeIsOptional(n) ? \"optional\" : \"required\";\n const gate = isGateNode(n) ? \"first-class\" : nodeRequiresApproval(n) ? \"mandatory\" : \"—\";\n const nodeState = state.nodes[n.id];\n const status = nodeState?.status ?? \"not_started\";\n const description = (n.description ?? n.data?.description ?? \"—\")\n .replace(/\\s+/g, \" \")\n .replaceAll(\"|\", \"\\\\|\");\n return `| ${n.id} | ${nodeLabel(n)} | ${description} | ${required} | ${gate} | ${status} | ${deps} |`;\n })\n .join(\"\\n\");\n\n // ── Section 2: current state summary ──\n const nodesByStatus = (s: string) =>\n Object.values(state.nodes)\n .filter((n) => promptNodeIds.has(n.id) && n.status === s)\n .map((n) => n.id);\n // An approved agent node stays `awaiting_approval` until the agent calls\n // `complete_node`. Listed with the undecided ones, a resumed agent reads the\n // human decision as still pending and ends its turn, hanging the run.\n const approvedAwaitingCompletion = Object.values(state.nodes).filter(\n (n) =>\n agentNodeIds.has(n.id) &&\n n.status === \"awaiting_approval\" &&\n n.approval?.decision === \"approved\" &&\n n.approval.decidedAt != null,\n );\n const approvedIds = new Set(approvedAwaitingCompletion.map((n) => n.id));\n const available = nodesByStatus(\"available\");\n const awaitingApproval = nodesByStatus(\"awaiting_approval\").filter((id) => !approvedIds.has(id));\n const awaitingInput = nodesByStatus(\"awaiting_input\");\n const running = nodesByStatus(\"running\");\n const failed = nodesByStatus(\"failed\");\n const completed = nodesByStatus(\"complete\");\n const totalRequired = promptNodes.filter((n) => !nodeIsOptional(n)).length;\n\n const stateSummary = [\n `- Run ID: ${state.runId}`,\n `- Status: ${state.status}`,\n `- Autonomous mode: ${state.autonomousMode}`,\n `- Progress: ${completed.length} / ${totalRequired} required nodes complete`,\n `- Available now: ${available.join(\", \") || \"(none)\"}`,\n `- Currently running: ${running.join(\", \") || \"(none)\"}`,\n `- Awaiting approval: ${awaitingApproval.join(\", \") || \"(none)\"}`,\n ...(approvedIds.size > 0\n ? [`- Approved, awaiting \\`complete_node\\`: ${[...approvedIds].join(\", \")}`]\n : []),\n `- Awaiting input: ${awaitingInput.join(\", \") || \"(none)\"}`,\n `- Failed: ${failed.join(\", \") || \"(none)\"}`,\n ].join(\"\\n\");\n\n const approvedSection =\n approvedAwaitingCompletion.length > 0\n ? `## Approved nodes awaiting completion\n\n${approvedAwaitingCompletion\n .map(\n (node) =>\n `- \\`${node.id}\\` — approved by ${node.approval?.decidedBy ?? \"unknown reviewer\"} at ${node.approval?.decidedAt}`,\n )\n .join(\"\\n\")}\n\nA human has already approved these nodes. Do not wait for another decision and do not call \\`request_approval\\` again. Carry out whatever the approval authorised that is still outstanding, then call \\`complete_node\\` for each.\n\n`\n : \"\";\n\n const outputCorrections = Object.values(state.nodes)\n .filter(\n (node) =>\n agentNodeIds.has(node.id) &&\n node.outputCorrection &&\n node.status !== \"complete\" &&\n node.status !== \"failed\",\n )\n .map(\n (node) =>\n `- Node \\`${node.id}\\`: ${node.outputCorrection?.issues.join(\"; \") ?? \"unknown issue\"}`,\n );\n const correctionSection =\n outputCorrections.length > 0\n ? `## Output correction required\n\nThe following node has already used its single corrective reprompt. Submit one corrected \\`complete_node\\` call that fixes every issue; a second mismatch fails the node.\n\n${outputCorrections.join(\"\\n\")}\n\n`\n : \"\";\n\n const rejectedGates = gateNodes.flatMap((node) => {\n const approval = state.nodes[node.id]?.approval;\n if (approval?.decision !== \"rejected\") return [];\n return [\n `- \\`${node.id}\\` — rejected by ${approval.decidedBy ?? \"unknown reviewer\"}: ${\n approval.feedback ?? \"(no feedback provided)\"\n }`,\n ];\n });\n const rejectedGateSection =\n rejectedGates.length > 0\n ? `## Rejected first-class gates requiring revision\n\n${rejectedGates.join(\"\\n\")}\n\nRevise the surrounding work in conversation, then re-request each gate with \\`request_approval(nodeId, summary, artifacts)\\`. Every gate remains parked until its new human decision; do not start, complete, skip, or fail a first-class gate.\n\n`\n : \"\";\n\n // An override survives only in the approval record: the state table shows the\n // node as `complete` like any other, so without this section the failure is\n // invisible from the turn after the decision onward.\n const overriddenChecks = checkNodes.flatMap((node) => {\n const record = state.nodes[node.id];\n if (record?.status !== \"complete\" || record.approval?.decision !== \"approved\") return [];\n return [\n `- \\`${node.id}\\` — failed, overridden by ${record.approval.decidedBy ?? \"unknown reviewer\"}: ${\n record.approval.feedback ?? \"(no reason recorded)\"\n }`,\n ];\n });\n const overriddenCheckSection =\n overriddenChecks.length > 0\n ? `## Checks completed by human override\n\n${overriddenChecks.join(\"\\n\")}\n\nThese checks did **not** pass. A human decided the run may continue anyway, so they are \\`complete\\` and their dependents are unblocked. Their evidence still records the failure — do not report them as passing, and say so if downstream work depends on what they were meant to verify.\n\n`\n : \"\";\n\n // ── Section 2b: flow globals (additive — omitted entirely when empty so\n // flows without globals keep the byte-identical Phase 3 prompt) ──\n const globals = flowDefaults(flowDef);\n const globalsSection =\n Object.keys(globals).length > 0\n ? `## Flow globals\n\nRun-scoped parameters set by the flow author or by the host that started this run. When \\`run_input\\` is present it carries the payload this run was started with (e.g. a scheduled or webhook-triggered run) — treat it as the run's initial input instead of asking the user for it.\n\n\\`\\`\\`json\n${JSON.stringify(globals, null, 2)}\n\\`\\`\\`\n\n`\n : \"\";\n\n // ── Section 3: stimulus paragraph ──\n const stimulusNode =\n stimulus.kind === \"approval_received\"\n ? flowDef.nodes.find((node) => node.id === stimulus.nodeId)\n : undefined;\n let stimulusParagraph = renderStimulusPrompt(stimulus);\n if (stimulus.kind === \"approval_received\" && stimulusNode && isGateNode(stimulusNode)) {\n if (stimulus.decision === \"approved\") {\n const availableSuccessors = agentNodes\n .filter((node) => state.nodes[node.id]?.status === \"available\")\n .map((node) => `\\`${node.id}\\``);\n stimulusParagraph = `Gate node \\`${stimulus.nodeId}\\` is already \\`complete\\` after approval by ${stimulus.decidedBy}. Do not call \\`complete_node\\` for the gate. Advance to successor work${\n availableSuccessors.length > 0\n ? `; available agent nodes: ${availableSuccessors.join(\", \")}`\n : \"\"\n } — call \\`get_available\\`, then \\`build_handoff\\` and \\`start_node\\` for the chosen agent node.`;\n } else {\n stimulusParagraph = `Gate node \\`${stimulus.nodeId}\\` was **rejected** by ${stimulus.decidedBy}.${\n stimulus.feedback ? ` Feedback: \"${stimulus.feedback}\".` : \"\"\n } Revise the work in conversation and follow the rejected-gate instructions above.`;\n }\n }\n // A check is host-decided the same way a gate is: the adapter already wrote the\n // terminal status, and `complete_node` rejects any non-agent node — so the\n // generic approved/rejected wording would send the agent into a guaranteed throw.\n if (stimulus.kind === \"approval_received\" && stimulusNode && isCheckNode(stimulusNode)) {\n const availableSuccessors = agentNodes\n .filter((node) => state.nodes[node.id]?.status === \"available\")\n .map((node) => `\\`${node.id}\\``);\n stimulusParagraph =\n stimulus.decision === \"approved\"\n ? `Check node \\`${stimulus.nodeId}\\` failed, and ${stimulus.decidedBy} **overrode** the failure${\n stimulus.feedback ? `: \"${stimulus.feedback}\"` : \"\"\n }. The node is already \\`complete\\` and its evidence still records the failure. Do not call \\`complete_node\\` for it. Advance to successor work${\n availableSuccessors.length > 0\n ? `; available agent nodes: ${availableSuccessors.join(\", \")}`\n : \"\"\n } — call \\`get_available\\`, then \\`build_handoff\\` and \\`start_node\\` for the chosen agent node.`\n : `Check node \\`${stimulus.nodeId}\\` failed and ${stimulus.decidedBy} **rejected** it${\n stimulus.feedback ? `: \"${stimulus.feedback}\"` : \"\"\n }. The node is already terminally \\`failed\\` — it did not return to \\`available\\`. Do not call \\`complete_node\\` or \\`fail_node\\` for it. Report the outcome and stop unless other nodes remain available.`;\n }\n\n // ── Section 4+5: static tool surface and rules ──\n return `# Flow Execution Context\n\nYou are orchestrating the flow **${flowDef.name}** (${flowDef.id} v${flowDef.version}). This is a governed flow execution: your job is to run nodes through the flow tools, summarize their outputs for human review, and yield control at approval gates.\n\n## Flow definition\n\n| ID | Label | Description | Required | Gate | Status | Depends on |\n|----|-------|-------------|----------|------|--------|------------|\n${nodeRows}\n\nNodes with **Gate = mandatory** are hard approval gates: they always require \\`request_approval\\` and a human decision, even when autonomous mode is on. They cannot be skipped — \\`request_approval\\` → approval is their only completion path.\nNodes with **Gate = first-class** are runtime-owned human decisions. The runtime parks them automatically and completes them directly on approval; the agent never executes them.\n\n## Current state\n\n${stateSummary}\n\n${globalsSection}${correctionSection}${rejectedGateSection}${overriddenCheckSection}${approvedSection}## Why this turn is happening\n\n${stimulusParagraph}\n\n## Flow tools available\n\nAll tools are exposed by the \\`flow\\` connector:\n\n- \\`get_available()\\` — list node IDs that are ready to start\n- \\`get_state()\\` — full current state including approvals, inputs, outputs\n- \\`get_globals()\\` — the flow's run-scoped globals (e.g. the \\`run_input\\` payload for scheduled/params-bound runs)\n- \\`build_handoff(nodeId)\\` — selected node instruction, supplied bindings, required assets, and upstream context\n- \\`start_node(nodeId)\\` — transition an agent node from \\`available\\` → \\`running\\`; call before executing it. Never start a first-class gate.\n- \\`request_approval(nodeId, summary, artifacts)\\` — transition a running agent node to \\`awaiting_approval\\`, or replace a rejected first-class gate's decision with a fresh pending request. **This ends your turn.**\n- \\`request_input(nodeId, prompt, schema)\\` — transition to \\`awaiting_input\\`. **This ends your turn.** Legal from \\`available\\`, \\`running\\`, or \\`awaiting_approval\\`.\n- \\`complete_node(nodeId, summary, fields?, artifacts?, concerns?)\\` — complete an agent node. When downstream nodes consume declared output fields, include a conforming JSON object. The first mismatch gets one corrective call; the second fails the node. Valid only if the agent node was approved, OR autonomousMode is true and it does not require mandatory approval. First-class gates are completed by the runtime on approval; never call this tool for them.\n- \\`fail_node(nodeId, message, recoverable)\\` — transition to \\`failed\\`, or to \\`skipped\\` if the node is optional. \\`recoverable=true\\` returns the node to \\`available\\` instead.\n- \\`skip_node(nodeId)\\` — transition to \\`skipped\\`. Only valid for optional nodes.\n\n## Rules\n\n1. Before executing an agent node, call \\`build_handoff(nodeId)\\` and follow its instruction with the supplied bindings, assets, and upstream context; then call \\`start_node(nodeId)\\`.\n2. After executing the node, call \\`request_approval\\` unless \\`autonomousMode\\` is true — in which case call \\`complete_node\\` directly. Exception: nodes marked **Gate = mandatory** always require \\`request_approval\\` and a human decision, even in autonomous mode.\n3. First-class nodes marked **Gate = first-class** are runtime-owned. Never start, complete, skip, fail, or request input for them. After rejection, revise in conversation and only call \\`request_approval\\` to create the next attempt.\n4. If you need information from the user before or during agent execution, call \\`request_input\\`. This ends your turn until the user responds.\n5. On unrecoverable agent failure, call \\`fail_node(..., recoverable: false)\\`; an optional node ends \\`skipped\\` rather than \\`failed\\`, so the run continues past it. On recoverable failure, call \\`fail_node(..., recoverable: true)\\` and the engine returns the node to \\`available\\`.\n6. When all required nodes are \\`complete\\` or \\`skipped\\`, stop. The runner marks the flow done automatically.\n7. Free-chat user messages do not require flow action. Respond directly, continue flow work, or both — your call.\n`;\n}\n\n/**\n * Render the full prompt sent to a subprompt node's isolated driver instance.\n *\n * `instruction` is already interpolated with the node's resolved bindings\n * (the same `interpolateNodeInstruction` step an agent handoff uses) — this\n * function only adds the typed-response directive when the node declares an\n * output contract. There is no corrective reprompt for a subprompt (it has no\n * conversation to reprompt in), so the directive is the runtime's only lever\n * for getting parseable JSON back; a malformed or non-conforming reply is an\n * ordinary node failure handled by the caller, never retried in-band here.\n *\n * The object-only constraint is therefore stated twice, before and after the\n * schema: the serialized schema is a large blob, so a directive placed only\n * ahead of it is not the last thing the model reads.\n *\n * @docLink packages/factory-assets/flow#render-subprompt-prompt\n */\nexport function renderSubpromptPrompt(\n instruction: string,\n outputSchema: Record<string, unknown> | undefined,\n): string {\n if (!outputSchema) return instruction;\n return `${instruction}\\n\\nRespond with a single JSON object matching this JSON Schema, and nothing else — no markdown code fences, no commentary before or after it:\\n\\n${JSON.stringify(outputSchema, null, 2)}\\n\\nReply with the object only. The first character of your reply must be \\`{\\` and the last must be \\`}\\` — no explanation, no restatement, no code fence.`;\n}\n\n/**\n * Single-line tag suitable for telemetry / logging. Derives a short, stable\n * summary of a stimulus that's safe to attach to spans, log entries, and\n * trace events. The kind is always included; node-specific stimuli also\n * include their `nodeId` so log queries can pivot on it.\n *\n * @docLink packages/factory-assets/flow#describe-stimulus\n */\nexport function describeStimulus(stimulus: TurnStimulus): string {\n switch (stimulus.kind) {\n case \"flow_started\":\n return \"flow_started\";\n case \"approval_received\":\n return `approval_received:${stimulus.nodeId}:${stimulus.decision}`;\n case \"input_received\":\n return `input_received:${stimulus.nodeId}`;\n case \"retry_requested\":\n return `retry_requested:${stimulus.nodeId}`;\n case \"user_message\":\n return `user_message:${stimulus.senderId}`;\n case \"resumed_after_hibernation\":\n return \"resumed_after_hibernation\";\n case \"cancelled\":\n return \"cancelled\";\n case \"state_changed\":\n return \"state_changed\";\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { softDepName } from './chunk-B6DXWEOC.js';
1
+ import { softDepName } from './chunk-PPMHNT6A.js';
2
2
  import pc from 'picocolors';
3
3
 
4
4
  var S = {
@@ -94,5 +94,5 @@ function formatRelativeTime(date) {
94
94
  }
95
95
 
96
96
  export { KIND_COL_WIDTH, S, bareSoftDepName, colorRef, fitWidth, formatRelativeTime, formatSoftDepAddPreview, formatSoftDepHint, formatSoftDepRemovePreview, formatSoftDepSection, kindColor, kindColorPad, logErr, logInfo, logOk, logWarn };
97
- //# sourceMappingURL=chunk-4FIF2QZH.js.map
98
- //# sourceMappingURL=chunk-4FIF2QZH.js.map
97
+ //# sourceMappingURL=chunk-EVH2X3QF.js.map
98
+ //# sourceMappingURL=chunk-EVH2X3QF.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../cli/src/helpers.ts"],"names":[],"mappings":";;;AAQO,IAAM,CAAA,GAAI;AAAA,EACf,KAAA,EAAO,CAAC,CAAA,KAAc,EAAA,CAAG,KAAK,EAAA,CAAG,IAAA,CAAK,CAAC,CAAC,CAAA;AAAA,EACxC,GAAA,EAAK,CAAC,CAAA,KAAc,EAAA,CAAG,KAAK,CAAC,CAAA;AAAA,EAC7B,OAAA,EAAS,CAAC,CAAA,KAAc,EAAA,CAAG,KAAK,CAAC,CAAA;AAAA,EACjC,IAAA,EAAM,CAAC,CAAA,KAAc,EAAA,CAAG,KAAK,CAAC,CAAA;AAAA,EAC9B,GAAA,EAAK,CAAC,CAAA,KAAc,EAAA,CAAG,IAAI,CAAC,CAAA;AAAA,EAC5B,EAAA,EAAI,CAAC,CAAA,KAAc,EAAA,CAAG,MAAM,CAAC,CAAA;AAAA,EAC7B,IAAA,EAAM,CAAC,CAAA,KAAc,EAAA,CAAG,OAAO,CAAC,CAAA;A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AE,IAAI,CAAA,SAAA,EAAY,IAAI,iBAAiB,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,WAAA,CAAa,CAAA;AAC/E;AAGO,SAAS,mBAAmB,IAAA,EAAoB;AACrD,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,EAAI,GAAI,KAAK,OAAA,EAAQ;AACvC,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,IAAA,GAAO,GAAI,CAAA;AACtC,EAAA,IAAI,OAAA,GAAU,IAAI,OAAO,UAAA;AACzB,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,OAAA,GAAU,EAAE,CAAA;AACvC,EAAA,IAAI,OAAA,GAAU,EAAA,EAAI,OAAO,CAAA,EAAG,OAAO,CAAA,KAAA,CAAA;AACnC,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,OAAA,GAAU,EAAE,CAAA;AACrC,EAAA,IAAI,KAAA,GAAQ,EAAA,EAAI,OAAO,CAAA,EAAG,KAAK,CAAA,KAAA,CAAA;AAC/B,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,KAAA,GAAQ,EAAE,CAAA;AAClC,EAAA,OAAO,GAAG,IAAI,CAAA,KAAA,CAAA;AAChB","file":"chunk-4FIF2QZH.js","sourcesContent":["import { softDepName } from \"@skaile/workspaces/asset-manager\";\nimport pc from \"picocolors\";\n\n/**\n * Terminal styling helpers used across all CLI commands.\n *\n * @docLink cli/dev-guide#helpers\n */\nexport const S = {\n brand: (s: string) => pc.cyan(pc.bold(s)),\n cmd: (s: string) => pc.cyan(s),\n heading: (s: string) => pc.bold(s),\n bold: (s: string) => pc.bold(s),\n dim: (s: string) => pc.dim(s),\n ok: (s: string) => pc.green(s),\n warn: (s: string) => pc.yellow(s),\n err: (s: string) => pc.red(s),\n label: (s: string) => pc.dim(s),\n rule: (w = 40) => pc.dim(\"─\".repeat(w)),\n};\n\nconst KIND_COLORS: Record<string, (s: string) => string> = {\n skill: pc.blue,\n agent: pc.magenta,\n prompt: pc.yellow,\n flow: pc.green,\n bundle: pc.cyan,\n contract: pc.red,\n connector: pc.green,\n mount: pc.green,\n knowledge: pc.cyan,\n persona: pc.cyan,\n ruleset: pc.cyan,\n \"mcp-server\": pc.magenta,\n};\n\n/**\n * Fit a plain (ANSI-free) string into exactly `width` columns: truncate with a\n * trailing `…` when too long, pad with spaces when too short. Keeps fixed-width\n * columns from overflowing the row when a value (e.g. an asset name) is wider\n * than its budget.\n */\nexport function fitWidth(s: string, width: number): string {\n if (width <= 0) return \"\";\n if (s.length > width) return width === 1 ? \"…\" : `${s.slice(0, width - 1)}…`;\n return s.padEnd(width);\n}\n\n/** Color-code an asset kind string. */\nexport function kindColor(kind: string): string {\n const colorFn = KIND_COLORS[kind] ?? pc.dim;\n return colorFn(kind);\n}\n\n/**\n * Widest kind label (`mcp-server`); the default kind-column width fits it so\n * long kinds don't shove the rest of the row out of alignment.\n */\nexport const KIND_COL_WIDTH = 10;\n\n/**\n * Color-code an asset kind string fit to exactly `width` columns — pads short\n * kinds, truncates over-long ones (via {@link fitWidth}) so the column can never\n * overflow and break row alignment.\n */\nexport function kindColorPad(kind: string, width = KIND_COL_WIDTH): string {\n const colorFn = KIND_COLORS[kind] ?? pc.dim;\n return colorFn(fitWidth(kind, width));\n}\n\n/** Color-code a \"kind:name\" reference string. */\nexport function colorRef(ref: string): string {\n const colonIdx = ref.indexOf(\":\");\n if (colonIdx === -1) return ref;\n const kind = ref.slice(0, colonIdx);\n const rest = ref.slice(colonIdx);\n return `${kindColor(kind)}${rest}`;\n}\n\n/**\n * Print a success line prefixed with a green check mark.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logOk(msg: string) {\n console.log(` ${pc.green(\"✓\")} ${msg}`);\n}\n/**\n * Print an error line prefixed with a red cross to stderr.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logErr(msg: string) {\n console.error(` ${pc.red(\"✗\")} ${msg}`);\n}\n/**\n * Print a warning line prefixed with a yellow exclamation mark.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logWarn(msg: string) {\n console.log(` ${pc.yellow(\"!\")} ${msg}`);\n}\n/**\n * Print an info line prefixed with a dim dot.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logInfo(msg: string) {\n console.log(` ${pc.dim(\"·\")} ${msg}`);\n}\n\n/**\n * Bare asset name of a canonical soft-dep target ref (`@pub/name@ver` → `name`),\n * for compact rendering in `info` / `tree` / `why`. Delegates to the asset-manager\n * parser (the soft-dep read surface) so the two never diverge.\n */\nexport function bareSoftDepName(ref: string): string {\n return softDepName(ref);\n}\n\n/**\n * The report-only soft-dep hint line shared by the `add` no-TTY branch and the\n * `install` surface, so the two user-facing wordings can't drift. Appends a\n * runnable `skaile add` suffix only when the target has a parseable ref.\n */\nexport function formatSoftDepHint(edge: { from: string; to: string; toRef?: string }): string {\n const suffix = edge.toRef ? ` — run \\`skaile add ${edge.toRef}\\` to include it.` : \"\";\n return `${bareSoftDepName(edge.from)} references ${bareSoftDepName(edge.to)} (soft dependency)${suffix}`;\n}\n\n/**\n * Build the \"Soft dependencies (inferred)\" section for `skaile info`. Returns one\n * header line plus one line per soft-dep target, each marked `(soft)` to read\n * differently from a typed `requires`. Empty array when there are no soft deps,\n * so the caller prints nothing.\n */\nexport function formatSoftDepSection(targets: string[]): string[] {\n if (targets.length === 0) return [];\n const out = [` ${S.label(\"Soft dependencies (inferred)\")}:`];\n for (const t of targets) out.push(` ${S.dim(\"·\")} ${t} ${S.dim(\"(soft)\")}`);\n return out;\n}\n\n/**\n * Footer line previewing the soft deps that *adding* the highlighted asset would\n * reference (manage TUI). \"references\" + \"not auto-added\" makes clear the pull is\n * report-only. Empty string when there are no targets, so the caller clears.\n */\nexport function formatSoftDepAddPreview(name: string, targets: string[]): string {\n if (targets.length === 0) return \"\";\n return S.dim(`${name} references ${targets.join(\", \")} (soft dep, not auto-added)`);\n}\n\n/**\n * Footer line previewing the soft deps that *removing* the highlighted asset\n * would orphan (manage TUI) — symmetric with {@link formatSoftDepAddPreview}.\n * Empty string when nothing would be orphaned, so the caller clears.\n */\nexport function formatSoftDepRemovePreview(name: string, targets: string[]): string {\n if (targets.length === 0) return \"\";\n return S.dim(`removing ${name} would orphan ${targets.join(\", \")} (soft dep)`);\n}\n\n/** Format a Date as a human-readable relative time string (e.g. \"5m ago\"). */\nexport function formatRelativeTime(date: Date): string {\n const diff = Date.now() - date.getTime();\n const seconds = Math.floor(diff / 1000);\n if (seconds < 60) return \"just now\";\n const minutes = Math.floor(seconds / 60);\n if (minutes < 60) return `${minutes}m ago`;\n const hours = Math.floor(minutes / 60);\n if (hours < 24) return `${hours}h ago`;\n const days = Math.floor(hours / 24);\n return `${days}d ago`;\n}\n"]}
1
+ {"version":3,"sources":["../cli/src/helpers.ts"],"names":[],"mappings":";;;AAQO,IAAM,CAAA,GAAI;AAAA,EACf,KAAA,EAAO,CAAC,CAAA,KAAc,EAAA,CAAG,KAAK,EAAA,CAAG,IAAA,CAAK,CAAC,CAAC,CAAA;AAAA,EACxC,GAAA,EAAK,CAAC,CAAA,KAAc,EAAA,CAAG,KAAK,CAAC,CAAA;AAAA,EAC7B,OAAA,EAAS,CAAC,CAAA,KAAc,EAAA,CAAG,KAAK,CAAC,CAAA;AAAA,EACjC,IAAA,EAAM,CAAC,CAAA,KAAc,EAAA,CAAG,KAAK,CAAC,CAAA;AAAA,EAC9B,GAAA,EAAK,CAAC,CAAA,KAAc,EAAA,CAAG,IAAI,CAAC,CAAA;AAAA,EAC5B,EAAA,EAAI,CAAC,CAAA,KAAc,EAAA,CAAG,MAAM,CAAC,CAAA;AAAA,EAC7B,IAAA,EAAM,CAAC,CAAA,KAAc,EAAA,CAAG,OAAO,CAAC,CAAA;AAAA,EAChC,GAAA,EAAK,CAAC,CAAA,KAAc,EAAA,CAAG,IAAI,C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,CAAK,IAAI,CAAC,CAAA,WAAA,CAAa,CAAA;AAC/E;AAGO,SAAS,mBAAmB,IAAA,EAAoB;AACrD,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,GAAA,EAAI,GAAI,KAAK,OAAA,EAAQ;AACvC,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,IAAA,GAAO,GAAI,CAAA;AACtC,EAAA,IAAI,OAAA,GAAU,IAAI,OAAO,UAAA;AACzB,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,OAAA,GAAU,EAAE,CAAA;AACvC,EAAA,IAAI,OAAA,GAAU,EAAA,EAAI,OAAO,CAAA,EAAG,OAAO,CAAA,KAAA,CAAA;AACnC,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,OAAA,GAAU,EAAE,CAAA;AACrC,EAAA,IAAI,KAAA,GAAQ,EAAA,EAAI,OAAO,CAAA,EAAG,KAAK,CAAA,KAAA,CAAA;AAC/B,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,KAAA,GAAQ,EAAE,CAAA;AAClC,EAAA,OAAO,GAAG,IAAI,CAAA,KAAA,CAAA;AAChB","file":"chunk-EVH2X3QF.js","sourcesContent":["import { softDepName } from \"@skaile/workspaces/asset-manager\";\nimport pc from \"picocolors\";\n\n/**\n * Terminal styling helpers used across all CLI commands.\n *\n * @docLink cli/dev-guide#helpers\n */\nexport const S = {\n brand: (s: string) => pc.cyan(pc.bold(s)),\n cmd: (s: string) => pc.cyan(s),\n heading: (s: string) => pc.bold(s),\n bold: (s: string) => pc.bold(s),\n dim: (s: string) => pc.dim(s),\n ok: (s: string) => pc.green(s),\n warn: (s: string) => pc.yellow(s),\n err: (s: string) => pc.red(s),\n label: (s: string) => pc.dim(s),\n rule: (w = 40) => pc.dim(\"─\".repeat(w)),\n};\n\nconst KIND_COLORS: Record<string, (s: string) => string> = {\n skill: pc.blue,\n agent: pc.magenta,\n prompt: pc.yellow,\n flow: pc.green,\n bundle: pc.cyan,\n contract: pc.red,\n connector: pc.green,\n mount: pc.green,\n knowledge: pc.cyan,\n persona: pc.cyan,\n ruleset: pc.cyan,\n \"mcp-server\": pc.magenta,\n};\n\n/**\n * Fit a plain (ANSI-free) string into exactly `width` columns: truncate with a\n * trailing `…` when too long, pad with spaces when too short. Keeps fixed-width\n * columns from overflowing the row when a value (e.g. an asset name) is wider\n * than its budget.\n */\nexport function fitWidth(s: string, width: number): string {\n if (width <= 0) return \"\";\n if (s.length > width) return width === 1 ? \"…\" : `${s.slice(0, width - 1)}…`;\n return s.padEnd(width);\n}\n\n/** Color-code an asset kind string. */\nexport function kindColor(kind: string): string {\n const colorFn = KIND_COLORS[kind] ?? pc.dim;\n return colorFn(kind);\n}\n\n/**\n * Widest kind label (`mcp-server`); the default kind-column width fits it so\n * long kinds don't shove the rest of the row out of alignment.\n */\nexport const KIND_COL_WIDTH = 10;\n\n/**\n * Color-code an asset kind string fit to exactly `width` columns — pads short\n * kinds, truncates over-long ones (via {@link fitWidth}) so the column can never\n * overflow and break row alignment.\n */\nexport function kindColorPad(kind: string, width = KIND_COL_WIDTH): string {\n const colorFn = KIND_COLORS[kind] ?? pc.dim;\n return colorFn(fitWidth(kind, width));\n}\n\n/** Color-code a \"kind:name\" reference string. */\nexport function colorRef(ref: string): string {\n const colonIdx = ref.indexOf(\":\");\n if (colonIdx === -1) return ref;\n const kind = ref.slice(0, colonIdx);\n const rest = ref.slice(colonIdx);\n return `${kindColor(kind)}${rest}`;\n}\n\n/**\n * Print a success line prefixed with a green check mark.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logOk(msg: string) {\n console.log(` ${pc.green(\"✓\")} ${msg}`);\n}\n/**\n * Print an error line prefixed with a red cross to stderr.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logErr(msg: string) {\n console.error(` ${pc.red(\"✗\")} ${msg}`);\n}\n/**\n * Print a warning line prefixed with a yellow exclamation mark.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logWarn(msg: string) {\n console.log(` ${pc.yellow(\"!\")} ${msg}`);\n}\n/**\n * Print an info line prefixed with a dim dot.\n *\n * @param msg - Message to display.\n * @docLink cli/dev-guide#helpers\n */\nexport function logInfo(msg: string) {\n console.log(` ${pc.dim(\"·\")} ${msg}`);\n}\n\n/**\n * Bare asset name of a canonical soft-dep target ref (`@pub/name@ver` → `name`),\n * for compact rendering in `info` / `tree` / `why`. Delegates to the asset-manager\n * parser (the soft-dep read surface) so the two never diverge.\n */\nexport function bareSoftDepName(ref: string): string {\n return softDepName(ref);\n}\n\n/**\n * The report-only soft-dep hint line shared by the `add` no-TTY branch and the\n * `install` surface, so the two user-facing wordings can't drift. Appends a\n * runnable `skaile add` suffix only when the target has a parseable ref.\n */\nexport function formatSoftDepHint(edge: { from: string; to: string; toRef?: string }): string {\n const suffix = edge.toRef ? ` — run \\`skaile add ${edge.toRef}\\` to include it.` : \"\";\n return `${bareSoftDepName(edge.from)} references ${bareSoftDepName(edge.to)} (soft dependency)${suffix}`;\n}\n\n/**\n * Build the \"Soft dependencies (inferred)\" section for `skaile info`. Returns one\n * header line plus one line per soft-dep target, each marked `(soft)` to read\n * differently from a typed `requires`. Empty array when there are no soft deps,\n * so the caller prints nothing.\n */\nexport function formatSoftDepSection(targets: string[]): string[] {\n if (targets.length === 0) return [];\n const out = [` ${S.label(\"Soft dependencies (inferred)\")}:`];\n for (const t of targets) out.push(` ${S.dim(\"·\")} ${t} ${S.dim(\"(soft)\")}`);\n return out;\n}\n\n/**\n * Footer line previewing the soft deps that *adding* the highlighted asset would\n * reference (manage TUI). \"references\" + \"not auto-added\" makes clear the pull is\n * report-only. Empty string when there are no targets, so the caller clears.\n */\nexport function formatSoftDepAddPreview(name: string, targets: string[]): string {\n if (targets.length === 0) return \"\";\n return S.dim(`${name} references ${targets.join(\", \")} (soft dep, not auto-added)`);\n}\n\n/**\n * Footer line previewing the soft deps that *removing* the highlighted asset\n * would orphan (manage TUI) — symmetric with {@link formatSoftDepAddPreview}.\n * Empty string when nothing would be orphaned, so the caller clears.\n */\nexport function formatSoftDepRemovePreview(name: string, targets: string[]): string {\n if (targets.length === 0) return \"\";\n return S.dim(`removing ${name} would orphan ${targets.join(\", \")} (soft dep)`);\n}\n\n/** Format a Date as a human-readable relative time string (e.g. \"5m ago\"). */\nexport function formatRelativeTime(date: Date): string {\n const diff = Date.now() - date.getTime();\n const seconds = Math.floor(diff / 1000);\n if (seconds < 60) return \"just now\";\n const minutes = Math.floor(seconds / 60);\n if (minutes < 60) return `${minutes}m ago`;\n const hours = Math.floor(minutes / 60);\n if (hours < 24) return `${hours}h ago`;\n const days = Math.floor(hours / 24);\n return `${days}d ago`;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { logErr, logWarn, S, logOk, logInfo } from './chunk-4FIF2QZH.js';
1
+ import { logErr, logWarn, S, logOk, logInfo } from './chunk-EVH2X3QF.js';
2
2
  import { catalogLayer, getProviderPreset, expandPreset, listProviderPresets, presetBaseUrl, probeProviderEntry } from './chunk-IRGI7Q62.js';
3
3
  import { loadProviderRegistry, saveProviderRegistryFile, workspaceProviderRegistryPath, userProviderRegistryPath } from './chunk-UWU572Q6.js';
4
4
  import { resolveCredential } from './chunk-DPLIN2RA.js';
@@ -496,5 +496,5 @@ function makeProvidersCommand() {
496
496
  }
497
497
 
498
498
  export { ProviderRegistryWriteError, addProviderEntry, credentialEnvVarName, loadRegistryView, makeProvidersCommand };
499
- //# sourceMappingURL=chunk-H7XC2IAQ.js.map
500
- //# sourceMappingURL=chunk-H7XC2IAQ.js.map
499
+ //# sourceMappingURL=chunk-FYLDR3RQ.js.map
500
+ //# sourceMappingURL=chunk-FYLDR3RQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../cli/src/commands/providers.ts"],"names":[],"mappings":";;;;;;;;;AAkDA,IAAM,aAAA,GAAgB,QAAA;AAStB,SAAS,WAAW,I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unk-H7XC2IAQ.js","sourcesContent":["/**\n * `skaile providers` — manage the AI provider registry.\n *\n * Endpoints are defined once, in `~/.skaile/providers.yml`, optionally\n * overridden per project in `<workspace>/.skaile/providers.yml` (gitignored by\n * `skaile init`). Every subcommand writes exactly one of those two files and\n * validates the result before it lands — a literal secret never reaches disk.\n *\n * @see PROVIDER-CONFIG-PLAN.md §1, §2.5\n */\n\nimport path from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport {\n catalogLayer,\n expandPreset,\n getProviderPreset,\n listProviderPresets,\n presetBaseUrl,\n probeProviderEntry,\n} from \"@skaile/workspaces/bridge\";\nimport {\n AI_PROVIDER_LAYERS,\n AI_PROVIDER_SURFACES,\n type AIProviderDiagnostic,\n type AIProviderEntry,\n type AIProviderLayerId,\n type AIProviderLlmEntry,\n type AIProviderRegistryDocument,\n type AIProviderSurface,\n entryTransport,\n isEntryEnabled,\n isSafeProviderId,\n loadProviderRegistry,\n type MergedAIProviderRegistry,\n mergeRegistries,\n parseCredentialRef,\n type ProviderRegistryFile,\n resolveCredential,\n resolveEntryBaseUrl,\n saveProviderRegistryFile,\n userProviderRegistryPath,\n validateMergedRegistry,\n validateRegistry,\n workspaceProviderRegistryPath,\n} from \"@skaile/workspaces/core\";\nimport { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\n\n/** Preset id that means \"no preset — I will supply the three literals\". */\nconst CUSTOM_PRESET = \"custom\";\n\n/** Which of the two registry files a command reads or writes. */\nexport interface ScopeOptions {\n projectDir?: string;\n workspace?: boolean;\n}\n\n/** The file a mutating subcommand writes: the workspace layer or the user one. */\nfunction targetFile(opts: ScopeOptions): { layer: \"user\" | \"workspace\"; path: string } {\n if (opts.workspace) {\n return { layer: \"workspace\", path: workspaceProviderRegistryPath(resolveProjectDir(opts)) };\n }\n return { layer: \"user\", path: userProviderRegistryPath() };\n}\n\n/** Project directory a subcommand operates on — `--project-dir` or the cwd. */\nfunction resolveProjectDir(opts: ScopeOptions): string {\n return opts.projectDir ? path.resolve(opts.projectDir) : process.cwd();\n}\n\n/** Both file layers plus the catalog, merged — what every reader sees. */\nexport interface RegistryView {\n merged: MergedAIProviderRegistry;\n files: ProviderRegistryFile[];\n diagnostics: AIProviderDiagnostic[];\n}\n\n/**\n * Load both file layers and merge them with the catalog layer the configured\n * `preset:` keys pull in, then gate the result. Read once, merged twice — the\n * catalog layer can only be built after the configured entries are known,\n * and it is built from the **pre-gate** merge: an entry that leaves `kind` or\n * its transport `params` to the preset fails the first gate by design.\n *\n * The gate is on the merged view, not per file: a workspace entry that sets\n * one field of an entry the user file defines is an override (§1.5), so it is\n * only here that an entry can be judged complete.\n */\nexport function loadRegistryView(opts: ScopeOptions): RegistryView {\n const loaded = loadProviderRegistry({ projectDir: resolveProjectDir(opts) });\n const fileLayers = loaded.files.map((file) => ({\n layer: file.layer as AIProviderLayerId,\n providers: file.document.providers,\n }));\n const catalog = catalogLayer(loaded.patches);\n const { registry, diagnostics } = validateMergedRegistry(\n mergeRegistries([...fileLayers, catalog]),\n {\n sources: [\n ...loaded.files.map((file) => ({ label: file.path, providers: file.document.providers })),\n ],\n },\n );\n return {\n merged: registry,\n files: loaded.files,\n // `loaded.diagnostics` already carries the merge notes for the file layers\n // alone; this second merge adds the catalog, so its notes replace them.\n diagnostics: [...loaded.files.flatMap((file) => file.diagnostics), ...diagnostics],\n };\n}\n\n/** Print diagnostics; returns how many were errors. */\nfunction reportDiagnostics(diagnostics: AIProviderDiagnostic[]): number {\n let errors = 0;\n for (const diagnostic of diagnostics) {\n const where = diagnostic.path ? `${diagnostic.path}: ` : \"\";\n if (diagnostic.severity === \"error\") {\n errors++;\n logErr(`${where}${diagnostic.message}`);\n } else {\n logWarn(`${where}${diagnostic.message}`);\n }\n }\n return errors;\n}\n\n/** Highest layer that pins an entry with `locked: true`. */\nfunction lockOwner(id: string, files: ProviderRegistryFile[]): AIProviderLayerId | undefined {\n let owner: AIProviderLayerId | undefined;\n for (const file of files) {\n if (file.document.providers[id]?.locked) {\n const layer = file.layer as AIProviderLayerId;\n if (!owner || AI_PROVIDER_LAYERS.indexOf(layer) > AI_PROVIDER_LAYERS.indexOf(owner)) {\n owner = layer;\n }\n }\n }\n return owner;\n}\n\n/**\n * The message for an edit a lock forbids, or `undefined` when it is allowed.\n * The merge ignores a lower layer silently; the CLI must not, or the operator\n * would watch an accepted edit have no effect.\n *\n * `set <id> locked <value>` stays legal at the locking layer itself —\n * otherwise a lock could never be lifted without hand-editing the file.\n */\nfunction lockConflict(\n id: string,\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n key?: string,\n): string | undefined {\n const owner = lockOwner(id, files);\n if (!owner) return undefined;\n const ownerRank = AI_PROVIDER_LAYERS.indexOf(owner);\n const targetRank = AI_PROVIDER_LAYERS.indexOf(target.layer);\n if (ownerRank === targetRank && key === \"locked\") return undefined;\n if (ownerRank < targetRank) return undefined;\n return (\n `'${id}' is locked by the ${owner} layer and cannot be changed from ${target.layer}.\\n` +\n (ownerRank === targetRank\n ? ` Unlock it first: skaile providers set ${id} locked false`\n : ` A higher layer owns this entry — change it there.`)\n );\n}\n\n/** Refuse loudly when a locked entry would be edited. */\nfunction exitIfLocked(\n id: string,\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n key?: string,\n): void {\n const message = lockConflict(id, target, files, key);\n if (!message) return;\n logErr(message);\n process.exit(1);\n}\n\n/** Read the target file, or an empty document when it does not exist yet. */\nfunction readTargetDocument(\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n): AIProviderRegistryDocument {\n const file = files.find((f) => f.path === target.path);\n return file?.document ?? { version: 1, providers: {} };\n}\n\n/**\n * Validate the file that is about to be written; exits non-zero on errors.\n *\n * Validated as the layer it is, so `set` may leave a one-field override in the\n * workspace file (§1.5). Completeness is the merged registry's business, and\n * `loadRegistryView` reports it on the next read.\n */\nfunction validateOrExit(\n document: AIProviderRegistryDocument,\n target: { layer: \"user\" | \"workspace\"; path: string },\n): void {\n const { diagnostics } = validateRegistry(\n { version: 1, providers: document.providers },\n { source: target.path, layer: target.layer },\n );\n if (reportDiagnostics(diagnostics) > 0) process.exit(1);\n}\n\n// ── list ───────────────────────────────────────────────────────────────────\n\nfunction pad(value: string, width: number): string {\n return value.length >= width ? value : value + \" \".repeat(width - value.length);\n}\n\nfunction credentialSummary(entry: AIProviderEntry): string {\n const credential = entry.credential;\n if (!credential || credential.kind === \"none\") return \"none\";\n return credential.ref ? `${credential.kind} ${credential.ref}` : credential.kind;\n}\n\nfunction printPresets(): void {\n const presets = listProviderPresets();\n console.log();\n console.log(` ${S.heading(\"Catalog presets\")}`);\n const idWidth = Math.max(...presets.map((x) => x.id.length)) + 2;\n const surfaceWidth = Math.max(...AI_PROVIDER_SURFACES.map((s) => s.length)) + 2;\n const header = `${pad(\"preset\", idWidth)}${pad(\"kind\", 7)}${pad(\"surface\", surfaceWidth)}${pad(\"transport\", 14)}default base URL`;\n console.log(` ${S.dim(header)}`);\n for (const preset of presets) {\n const row =\n pad(preset.id, idWidth) +\n pad(preset.kind, 7) +\n pad(preset.surface ?? \"—\", surfaceWidth) +\n pad(\n preset.kind === \"llm\" || preset.kind === \"embed\" ? (preset.transport ?? \"direct\") : \"—\",\n 14,\n ) +\n (presetBaseUrl(preset) ?? \"—\");\n console.log(` ${row}`);\n }\n}\n\nfunction printConfigured(view: RegistryView): void {\n const ids = view.merged.order;\n console.log();\n console.log(` ${S.heading(\"Configured providers\")}`);\n if (ids.length === 0) {\n console.log(\n ` ${S.dim(\"none — add one with\")} ${S.cmd(\"skaile providers add --preset <preset>\")}`,\n );\n console.log();\n return;\n }\n const idWidth = Math.max(...ids.map((id) => id.length)) + 2;\n const header = `${pad(\"id\", idWidth)}${pad(\"layer\", 11)}${pad(\"surface\", 26)}${pad(\"transport\", 14)}endpoint`;\n console.log(` ${S.dim(header)}`);\n for (const id of ids) {\n const entry = view.merged.providers[id];\n const surface = (entry as AIProviderLlmEntry).surface ?? \"—\";\n const transport = entryTransport(entry) ?? \"—\";\n const url = resolveEntryBaseUrl(entry) ?? S.dim(\"(unresolved)\");\n const flags = [\n isEntryEnabled(entry) ? \"\" : S.warn(\"disabled\"),\n entry.locked ? S.warn(\"locked\") : \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n console.log(\n ` ${pad(id, idWidth)}${pad(view.merged.origin[id], 11)}${pad(surface, 26)}${pad(transport, 14)}${url} ${flags}`.trimEnd(),\n );\n console.log(` ${S.dim(`${pad(\"\", idWidth)}${credentialSummary(entry)}`)}`);\n }\n console.log();\n}\n\n// ── add ────────────────────────────────────────────────────────────────────\n\ninterface AddOptions extends ScopeOptions {\n preset?: string;\n credential?: string;\n baseUrl?: string;\n surface?: string;\n label?: string;\n kind?: string;\n param: string[];\n force?: boolean;\n}\n\nfunction parseParams(pairs: string[]): Record<string, string> {\n const out: Record<string, string> = {};\n for (const pair of pairs) {\n const eq = pair.indexOf(\"=\");\n if (eq <= 0) {\n logErr(`--param expects <key>=<value> (got '${pair}')`);\n process.exit(1);\n }\n out[pair.slice(0, eq)] = pair.slice(eq + 1);\n }\n return out;\n}\n\n/** Ask for the three literals a custom endpoint needs. Nothing else. */\nasync function promptCustomEntry(\n id: string,\n opts: AddOptions,\n): Promise<{ surface: AIProviderSurface; baseUrl: string; credentialRef: string }> {\n const interactive = process.stdin.isTTY === true;\n let surface = opts.surface as AIProviderSurface | undefined;\n let baseUrl = opts.baseUrl;\n let credentialRef = opts.credential;\n\n if (!interactive && (!surface || !baseUrl || !credentialRef)) {\n logErr(\n \"--preset custom needs --surface, --base-url and --credential when there is no terminal to prompt on\",\n );\n process.exit(1);\n }\n\n if (!surface) {\n const answer = await p.select({\n message: \"Wire surface:\",\n options: AI_PROVIDER_SURFACES.map((value) => ({ value, label: value })),\n initialValue: \"openai-completions\" as AIProviderSurface,\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n surface = answer as AIProviderSurface;\n }\n if (!baseUrl) {\n const answer = await p.text({\n message: \"Base URL:\",\n placeholder: \"https://api.example.com/v1\",\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n baseUrl = answer as string;\n }\n if (!credentialRef) {\n const answer = await p.text({\n message: \"Credential reference (env:NAME, cmd:<shell>, platform:<id>, keyring:<svc>/<acct>):\",\n initialValue: `env:${id.toUpperCase().replace(/[^A-Z0-9]/g, \"_\")}_API_KEY`,\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n credentialRef = answer as string;\n }\n return { surface, baseUrl, credentialRef };\n}\n\n/** A rejected registry write. The message is already CLI-ready. */\nexport class ProviderRegistryWriteError extends Error {}\n\n/** What {@link addProviderEntry} writes. */\nexport interface AddProviderEntryInput extends ScopeOptions {\n /** Registry entry id — `[a-z0-9][a-z0-9_-]*`. */\n id: string;\n /** Catalog preset to expand. Mutually exclusive with `entry`. */\n presetId?: string;\n /** A fully-built entry (the `--preset custom` path, which needs prompts). */\n entry?: AIProviderEntry;\n /** `env:NAME` / `cmd:…` / `platform:…` / `keyring:…` — never a literal. */\n credentialRef?: string;\n baseUrl?: string;\n surface?: AIProviderSurface;\n label?: string;\n params?: Record<string, string>;\n /** Overwrite an entry that already exists in the target file. */\n force?: boolean;\n}\n\n/** Result of {@link addProviderEntry}. */\nexport interface AddedProviderEntry {\n id: string;\n layer: \"user\" | \"workspace\";\n path: string;\n entry: AIProviderEntry;\n /** True when an existing entry in the target file was overwritten. */\n replaced: boolean;\n}\n\n/**\n * Write one entry into a registry file — the single write path behind\n * `skaile providers add` and the `skaile setup` wizard.\n *\n * Throws {@link ProviderRegistryWriteError} instead of exiting, so a wizard\n * can report the failure in its own idiom. Every rejection a caller can\n * provoke (bad id, unknown preset, missing transport parameter, locked entry,\n * a literal secret) lands here, and the document is validated before it is\n * written — a secret cannot reach disk through this function.\n */\nexport function addProviderEntry(input: AddProviderEntryInput): AddedProviderEntry {\n const { id } = input;\n if (!isSafeProviderId(id)) {\n throw new ProviderRegistryWriteError(\n `'${id}' is not a valid entry id — use [a-z0-9][a-z0-9_-]*`,\n );\n }\n if (input.credentialRef && !parseCredentialRef(input.credentialRef)) {\n throw new ProviderRegistryWriteError(\n \"the credential must be a reference, not a secret: \" +\n \"env:NAME, cmd:<shell>, platform:<configId> or keyring:<service>/<account>\",\n );\n }\n\n const view = loadRegistryView(input);\n const target = targetFile(input);\n const locked = lockConflict(id, target, view.files);\n if (locked) throw new ProviderRegistryWriteError(locked);\n\n const document = readTargetDocument(target, view.files);\n const replaced = document.providers[id] !== undefined;\n if (replaced && !input.force) {\n throw new ProviderRegistryWriteError(\n `'${id}' already exists in ${target.path} — pass --force to overwrite it.`,\n );\n }\n\n let entry: AIProviderEntry;\n if (input.entry) {\n entry = input.entry;\n } else {\n const preset = input.presetId ? getProviderPreset(input.presetId) : undefined;\n if (!preset) {\n throw new ProviderRegistryWriteError(\n `Unknown preset '${input.presetId}'. Run \\`skaile providers list\\` to see the catalog, ` +\n \"or use `--preset custom`.\",\n );\n }\n entry = expandPreset(preset, {\n credentialRef: input.credentialRef,\n baseUrl: input.baseUrl,\n surface: input.surface,\n label: input.label,\n params: input.params,\n });\n const missing = (preset.required_params ?? []).filter(\n (key) => !(key in ((entry as AIProviderLlmEntry).params ?? {})),\n );\n if (missing.length > 0) {\n throw new ProviderRegistryWriteError(\n `Preset '${preset.id}' needs ${missing.map((m) => `--param ${m}=<value>`).join(\" \")}`,\n );\n }\n }\n\n const next: AIProviderRegistryDocument = {\n version: 1,\n providers: { ...document.providers, [id]: entry },\n };\n const { diagnostics } = validateRegistry(\n { version: 1, providers: next.providers },\n { source: target.path },\n );\n const errors = diagnostics.filter((d) => d.severity === \"error\");\n if (errors.length > 0) {\n throw new ProviderRegistryWriteError(\n errors.map((d) => (d.path ? `${d.path}: ${d.message}` : d.message)).join(\"\\n\"),\n );\n }\n saveProviderRegistryFile(target.path, next);\n\n return { id, layer: target.layer, path: target.path, entry, replaced };\n}\n\n/** The env var an `env:` credential reference points at, if it is one. */\nexport function credentialEnvVarName(entry: AIProviderEntry): string | undefined {\n const ref = entry.credential?.ref;\n return ref?.startsWith(\"env:\") ? ref.slice(4) : undefined;\n}\n\n/** Build the `--preset custom` entry from the three literals the user gave. */\nfunction customEntry(\n answers: { surface: AIProviderSurface; baseUrl: string; credentialRef: string },\n opts: AddOptions,\n): AIProviderEntry {\n const kind = (opts.kind ?? \"llm\") as AIProviderEntry[\"kind\"];\n // Anthropic- and Google-shaped surfaces read a dedicated API-key header;\n // everything else is a bearer token. `set <id> credential.kind …` adjusts.\n const credentialKind =\n kind === \"stt\" ||\n kind === \"tts\" ||\n answers.surface === \"anthropic-messages\" ||\n answers.surface === \"google-generative-ai\" ||\n answers.surface === \"azure-openai-responses\"\n ? \"api_key_header\"\n : \"bearer\";\n if (kind === \"stt\" || kind === \"tts\") {\n return {\n kind,\n ...(opts.label ? { label: opts.label } : {}),\n base_url: answers.baseUrl,\n credential: { kind: credentialKind, ref: answers.credentialRef },\n };\n }\n return {\n kind,\n ...(opts.label ? { label: opts.label } : {}),\n surface: answers.surface,\n base_url: answers.baseUrl,\n credential: { kind: credentialKind, ref: answers.credentialRef },\n } as AIProviderLlmEntry;\n}\n\nasync function runAdd(idArg: string | undefined, opts: AddOptions): Promise<void> {\n const presetId = opts.preset;\n if (!presetId) {\n logErr(\n `--preset is required. Run ${S.cmd(\"skaile providers list\")} for the catalog, ` +\n `or use ${S.cmd(\"--preset custom\")}.`,\n );\n process.exit(1);\n }\n const id = idArg ?? presetId;\n if (id === CUSTOM_PRESET && !idArg) {\n logErr(\"--preset custom needs an entry id: skaile providers add <id> --preset custom\");\n process.exit(1);\n }\n\n const entry =\n presetId === CUSTOM_PRESET ? customEntry(await promptCustomEntry(id, opts), opts) : undefined;\n\n let added: AddedProviderEntry;\n try {\n added = addProviderEntry({\n id,\n ...(entry ? { entry } : { presetId }),\n credentialRef: opts.credential,\n baseUrl: opts.baseUrl,\n surface: opts.surface as AIProviderSurface | undefined,\n label: opts.label,\n params: parseParams(opts.param),\n projectDir: opts.projectDir,\n workspace: opts.workspace,\n force: opts.force,\n });\n } catch (error) {\n logErr(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n\n logOk(`Added ${S.bold(id)} (${presetId}) to the ${added.layer} registry`);\n console.log(S.dim(` → ${added.path}`));\n const name = credentialEnvVarName(added.entry);\n if (name) {\n console.log(\n ` ${S.dim(\"The secret itself never goes in this file — export it:\")} ${S.cmd(`export ${name}=…`)}`,\n );\n }\n console.log(` ${S.dim(\"Verify with:\")} ${S.cmd(`skaile providers test ${id}`)}`);\n}\n\n// ── set / rm ───────────────────────────────────────────────────────────────\n\n/** Coerce a CLI string into the type the schema expects at `key`. */\nfunction coerceValue(key: string, value: string): unknown {\n const leaf = key.split(\".\").pop() ?? key;\n if (leaf === \"enabled\" || leaf === \"locked\" || leaf === \"tools\" || leaf === \"images\") {\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n logErr(`'${key}' takes true or false (got '${value}')`);\n process.exit(1);\n }\n if (leaf === \"context_window\" || leaf === \"thinking_max\") {\n const parsed = Number(value);\n if (!Number.isFinite(parsed)) {\n logErr(`'${key}' takes a number (got '${value}')`);\n process.exit(1);\n }\n return parsed;\n }\n return value;\n}\n\n/** Write `value` at a dotted path, creating intermediate maps. */\nfunction setDotted(entry: Record<string, unknown>, key: string, value: unknown): void {\n const segments = key.split(\".\");\n let cursor = entry;\n for (const segment of segments.slice(0, -1)) {\n const next = cursor[segment];\n if (typeof next !== \"object\" || next === null || Array.isArray(next)) {\n cursor[segment] = {};\n }\n cursor = cursor[segment] as Record<string, unknown>;\n }\n cursor[segments[segments.length - 1]] = value;\n}\n\nfunction runSet(id: string, key: string, value: string, opts: ScopeOptions): void {\n const view = loadRegistryView(opts);\n const target = targetFile(opts);\n exitIfLocked(id, target, view.files, key);\n\n const document = readTargetDocument(target, view.files);\n const existing = document.providers[id];\n const inherited = view.merged.providers[id];\n if (!existing && !inherited) {\n logErr(\n `No provider '${id}'. Add it with ${S.cmd(`skaile providers add ${id} --preset <preset>`)}`,\n );\n process.exit(1);\n }\n\n // Writing a field into a layer that has no entry yet leaves a one-field\n // override: the layers below keep supplying the rest (§1.5), so copying\n // their `kind` down here would pin a value this layer does not own.\n const base = (existing ? structuredClone(existing) : {}) as unknown as Record<string, unknown>;\n setDotted(base, key, coerceValue(key, value));\n\n const next: AIProviderRegistryDocument = {\n version: 1,\n providers: { ...document.providers, [id]: base as unknown as AIProviderEntry },\n };\n validateOrExit(next, target);\n saveProviderRegistryFile(target.path, next);\n\n logOk(`Set ${S.bold(`${id}.${key}`)} = ${value} in the ${target.layer} registry`);\n console.log(S.dim(` → ${target.path}`));\n}\n\nfunction runRemove(id: string, opts: ScopeOptions): void {\n const view = loadRegistryView(opts);\n const target = targetFile(opts);\n exitIfLocked(id, target, view.files);\n\n const document = readTargetDocument(target, view.files);\n if (!document.providers[id]) {\n logErr(`No provider '${id}' in ${target.path}`);\n process.exit(1);\n }\n const providers = { ...document.providers };\n delete providers[id];\n saveProviderRegistryFile(target.path, { version: 1, providers });\n\n logOk(`Removed ${S.bold(id)} from the ${target.layer} registry`);\n console.log(S.dim(` → ${target.path}`));\n if (\n view.merged.providers[id] &&\n view.files.some((f) => f.path !== target.path && f.document.providers[id])\n ) {\n logInfo(`'${id}' is still defined in another layer — run 'skaile providers list' to see it.`);\n }\n}\n\n// ── test ───────────────────────────────────────────────────────────────────\n\nasync function runTest(id: string, opts: ScopeOptions): Promise<void> {\n const view = loadRegistryView(opts);\n const entry = view.merged.providers[id];\n if (!entry) {\n logErr(`No provider '${id}'. Run ${S.cmd(\"skaile providers list\")} to see what is configured.`);\n process.exit(1);\n }\n\n const credential = resolveCredential(entry);\n console.log();\n console.log(` ${S.heading(id)} ${S.dim(`(${view.merged.origin[id]} layer)`)}`);\n console.log(` ${S.label(\"endpoint \")} ${resolveEntryBaseUrl(entry) ?? S.dim(\"(unresolved)\")}`);\n console.log(\n ` ${S.label(\"credential\")} ${credentialSummary(entry)} ${\n credential.error\n ? S.err(`— ${credential.error}`)\n : S.dim(`— resolved from ${credential.source}`)\n }`,\n );\n\n if (credential.error) {\n console.log();\n logErr(`${id} is not usable yet: ${credential.error}`);\n process.exit(1);\n }\n\n const result = await probeProviderEntry(entry, { secret: credential.value });\n if (result.url) console.log(` ${S.label(\"probe \")} GET ${result.url}`);\n console.log();\n if (result.ok) {\n logOk(`${id}: ${result.detail}${result.status ? ` (HTTP ${result.status})` : \"\"}`);\n return;\n }\n if (!result.probed) {\n logWarn(`${id}: ${result.detail}`);\n return;\n }\n logErr(`${id}: ${result.detail}`);\n process.exit(1);\n}\n\n// ── command ────────────────────────────────────────────────────────────────\n\n/**\n * Create the `skaile providers` command group.\n *\n * `list` shows the catalog and what is configured; `add` writes an entry from\n * a preset (or from three literals with `--preset custom`); `set` and `rm`\n * edit one layer; `test` sends one read-only request and reports what came\n * back, never the credential.\n *\n * @returns Configured {@link Command} ready for `program.addCommand()`.\n */\nexport function makeProvidersCommand(): Command {\n const cmd = new Command(\"providers\").description(\n \"Manage AI provider endpoints (~/.skaile/providers.yml)\",\n );\n\n cmd\n .command(\"list\")\n .description(\"List catalog presets and configured providers\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .option(\"--json\", \"Machine-readable output\")\n .action((opts) => {\n const view = loadRegistryView(opts);\n if (opts.json) {\n console.log(\n JSON.stringify(\n {\n presets: listProviderPresets().map((preset) => ({\n id: preset.id,\n kind: preset.kind,\n surface: preset.surface,\n transport: preset.transport ?? (preset.surface ? \"direct\" : undefined),\n base_url: presetBaseUrl(preset),\n credential: preset.credential,\n required_params: preset.required_params,\n })),\n providers: view.merged.order.map((id) => ({\n id,\n layer: view.merged.origin[id],\n entry: view.merged.providers[id],\n base_url: resolveEntryBaseUrl(view.merged.providers[id]),\n })),\n },\n null,\n 2,\n ),\n );\n return;\n }\n reportDiagnostics(view.diagnostics);\n printPresets();\n printConfigured(view);\n });\n\n cmd\n .command(\"add [id]\")\n .description(\"Add a provider from a catalog preset (id defaults to the preset name)\")\n .requiredOption(\"--preset <preset>\", `Catalog preset, or '${CUSTOM_PRESET}'`)\n .option(\"--credential <ref>\", \"Credential reference (env:NAME, cmd:…, platform:…, keyring:…)\")\n .option(\"--base-url <url>\", \"Override the preset endpoint\")\n .option(\"--surface <surface>\", `Wire surface (${AI_PROVIDER_SURFACES.join(\", \")})`)\n .option(\"--kind <kind>\", \"Entry kind for --preset custom (llm, embed, stt, tts)\", \"llm\")\n .option(\"--label <text>\", \"Display label\")\n .option(\n \"--param <key=value>\",\n \"Transport parameter (repeatable): region, project, location, resource, deployment, api_version\",\n (value: string, previous: string[]) => [...previous, value],\n [] as string[],\n )\n .option(\"--workspace\", \"Write <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .option(\"--force\", \"Overwrite an existing entry in the target file\")\n .action((id: string | undefined, opts: AddOptions) => runAdd(id, opts));\n\n cmd\n .command(\"set <id> <key> <value>\")\n .description(\n \"Set one field (base_url, enabled, credential.ref, headers.<name>, model_map.<id>…)\",\n )\n .option(\"--workspace\", \"Write <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, key: string, value: string, opts: ScopeOptions) =>\n runSet(id, key, value, opts),\n );\n\n cmd\n .command(\"rm <id>\")\n .description(\"Remove a provider from one layer\")\n .option(\"--workspace\", \"Edit <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, opts: ScopeOptions) => runRemove(id, opts));\n\n cmd\n .command(\"test <id>\")\n .description(\"Send one read-only request to a provider and report the result\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, opts: ScopeOptions) => runTest(id, opts));\n\n return cmd;\n}\n"]}
1
+ {"version":3,"sources":["../cli/src/commands/providers.ts"],"names":[],"mappings":";;;;;;;;;AAkDA,IAAM,aAAA,GAA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,EAAA,OAAO,GAAA;AACT","file":"chunk-FYLDR3RQ.js","sourcesContent":["/**\n * `skaile providers` — manage the AI provider registry.\n *\n * Endpoints are defined once, in `~/.skaile/providers.yml`, optionally\n * overridden per project in `<workspace>/.skaile/providers.yml` (gitignored by\n * `skaile init`). Every subcommand writes exactly one of those two files and\n * validates the result before it lands — a literal secret never reaches disk.\n *\n * @see PROVIDER-CONFIG-PLAN.md §1, §2.5\n */\n\nimport path from \"node:path\";\nimport * as p from \"@clack/prompts\";\nimport {\n catalogLayer,\n expandPreset,\n getProviderPreset,\n listProviderPresets,\n presetBaseUrl,\n probeProviderEntry,\n} from \"@skaile/workspaces/bridge\";\nimport {\n AI_PROVIDER_LAYERS,\n AI_PROVIDER_SURFACES,\n type AIProviderDiagnostic,\n type AIProviderEntry,\n type AIProviderLayerId,\n type AIProviderLlmEntry,\n type AIProviderRegistryDocument,\n type AIProviderSurface,\n entryTransport,\n isEntryEnabled,\n isSafeProviderId,\n loadProviderRegistry,\n type MergedAIProviderRegistry,\n mergeRegistries,\n parseCredentialRef,\n type ProviderRegistryFile,\n resolveCredential,\n resolveEntryBaseUrl,\n saveProviderRegistryFile,\n userProviderRegistryPath,\n validateMergedRegistry,\n validateRegistry,\n workspaceProviderRegistryPath,\n} from \"@skaile/workspaces/core\";\nimport { Command } from \"commander\";\nimport { logErr, logInfo, logOk, logWarn, S } from \"../helpers.ts\";\n\n/** Preset id that means \"no preset — I will supply the three literals\". */\nconst CUSTOM_PRESET = \"custom\";\n\n/** Which of the two registry files a command reads or writes. */\nexport interface ScopeOptions {\n projectDir?: string;\n workspace?: boolean;\n}\n\n/** The file a mutating subcommand writes: the workspace layer or the user one. */\nfunction targetFile(opts: ScopeOptions): { layer: \"user\" | \"workspace\"; path: string } {\n if (opts.workspace) {\n return { layer: \"workspace\", path: workspaceProviderRegistryPath(resolveProjectDir(opts)) };\n }\n return { layer: \"user\", path: userProviderRegistryPath() };\n}\n\n/** Project directory a subcommand operates on — `--project-dir` or the cwd. */\nfunction resolveProjectDir(opts: ScopeOptions): string {\n return opts.projectDir ? path.resolve(opts.projectDir) : process.cwd();\n}\n\n/** Both file layers plus the catalog, merged — what every reader sees. */\nexport interface RegistryView {\n merged: MergedAIProviderRegistry;\n files: ProviderRegistryFile[];\n diagnostics: AIProviderDiagnostic[];\n}\n\n/**\n * Load both file layers and merge them with the catalog layer the configured\n * `preset:` keys pull in, then gate the result. Read once, merged twice — the\n * catalog layer can only be built after the configured entries are known,\n * and it is built from the **pre-gate** merge: an entry that leaves `kind` or\n * its transport `params` to the preset fails the first gate by design.\n *\n * The gate is on the merged view, not per file: a workspace entry that sets\n * one field of an entry the user file defines is an override (§1.5), so it is\n * only here that an entry can be judged complete.\n */\nexport function loadRegistryView(opts: ScopeOptions): RegistryView {\n const loaded = loadProviderRegistry({ projectDir: resolveProjectDir(opts) });\n const fileLayers = loaded.files.map((file) => ({\n layer: file.layer as AIProviderLayerId,\n providers: file.document.providers,\n }));\n const catalog = catalogLayer(loaded.patches);\n const { registry, diagnostics } = validateMergedRegistry(\n mergeRegistries([...fileLayers, catalog]),\n {\n sources: [\n ...loaded.files.map((file) => ({ label: file.path, providers: file.document.providers })),\n ],\n },\n );\n return {\n merged: registry,\n files: loaded.files,\n // `loaded.diagnostics` already carries the merge notes for the file layers\n // alone; this second merge adds the catalog, so its notes replace them.\n diagnostics: [...loaded.files.flatMap((file) => file.diagnostics), ...diagnostics],\n };\n}\n\n/** Print diagnostics; returns how many were errors. */\nfunction reportDiagnostics(diagnostics: AIProviderDiagnostic[]): number {\n let errors = 0;\n for (const diagnostic of diagnostics) {\n const where = diagnostic.path ? `${diagnostic.path}: ` : \"\";\n if (diagnostic.severity === \"error\") {\n errors++;\n logErr(`${where}${diagnostic.message}`);\n } else {\n logWarn(`${where}${diagnostic.message}`);\n }\n }\n return errors;\n}\n\n/** Highest layer that pins an entry with `locked: true`. */\nfunction lockOwner(id: string, files: ProviderRegistryFile[]): AIProviderLayerId | undefined {\n let owner: AIProviderLayerId | undefined;\n for (const file of files) {\n if (file.document.providers[id]?.locked) {\n const layer = file.layer as AIProviderLayerId;\n if (!owner || AI_PROVIDER_LAYERS.indexOf(layer) > AI_PROVIDER_LAYERS.indexOf(owner)) {\n owner = layer;\n }\n }\n }\n return owner;\n}\n\n/**\n * The message for an edit a lock forbids, or `undefined` when it is allowed.\n * The merge ignores a lower layer silently; the CLI must not, or the operator\n * would watch an accepted edit have no effect.\n *\n * `set <id> locked <value>` stays legal at the locking layer itself —\n * otherwise a lock could never be lifted without hand-editing the file.\n */\nfunction lockConflict(\n id: string,\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n key?: string,\n): string | undefined {\n const owner = lockOwner(id, files);\n if (!owner) return undefined;\n const ownerRank = AI_PROVIDER_LAYERS.indexOf(owner);\n const targetRank = AI_PROVIDER_LAYERS.indexOf(target.layer);\n if (ownerRank === targetRank && key === \"locked\") return undefined;\n if (ownerRank < targetRank) return undefined;\n return (\n `'${id}' is locked by the ${owner} layer and cannot be changed from ${target.layer}.\\n` +\n (ownerRank === targetRank\n ? ` Unlock it first: skaile providers set ${id} locked false`\n : ` A higher layer owns this entry — change it there.`)\n );\n}\n\n/** Refuse loudly when a locked entry would be edited. */\nfunction exitIfLocked(\n id: string,\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n key?: string,\n): void {\n const message = lockConflict(id, target, files, key);\n if (!message) return;\n logErr(message);\n process.exit(1);\n}\n\n/** Read the target file, or an empty document when it does not exist yet. */\nfunction readTargetDocument(\n target: { layer: \"user\" | \"workspace\"; path: string },\n files: ProviderRegistryFile[],\n): AIProviderRegistryDocument {\n const file = files.find((f) => f.path === target.path);\n return file?.document ?? { version: 1, providers: {} };\n}\n\n/**\n * Validate the file that is about to be written; exits non-zero on errors.\n *\n * Validated as the layer it is, so `set` may leave a one-field override in the\n * workspace file (§1.5). Completeness is the merged registry's business, and\n * `loadRegistryView` reports it on the next read.\n */\nfunction validateOrExit(\n document: AIProviderRegistryDocument,\n target: { layer: \"user\" | \"workspace\"; path: string },\n): void {\n const { diagnostics } = validateRegistry(\n { version: 1, providers: document.providers },\n { source: target.path, layer: target.layer },\n );\n if (reportDiagnostics(diagnostics) > 0) process.exit(1);\n}\n\n// ── list ───────────────────────────────────────────────────────────────────\n\nfunction pad(value: string, width: number): string {\n return value.length >= width ? value : value + \" \".repeat(width - value.length);\n}\n\nfunction credentialSummary(entry: AIProviderEntry): string {\n const credential = entry.credential;\n if (!credential || credential.kind === \"none\") return \"none\";\n return credential.ref ? `${credential.kind} ${credential.ref}` : credential.kind;\n}\n\nfunction printPresets(): void {\n const presets = listProviderPresets();\n console.log();\n console.log(` ${S.heading(\"Catalog presets\")}`);\n const idWidth = Math.max(...presets.map((x) => x.id.length)) + 2;\n const surfaceWidth = Math.max(...AI_PROVIDER_SURFACES.map((s) => s.length)) + 2;\n const header = `${pad(\"preset\", idWidth)}${pad(\"kind\", 7)}${pad(\"surface\", surfaceWidth)}${pad(\"transport\", 14)}default base URL`;\n console.log(` ${S.dim(header)}`);\n for (const preset of presets) {\n const row =\n pad(preset.id, idWidth) +\n pad(preset.kind, 7) +\n pad(preset.surface ?? \"—\", surfaceWidth) +\n pad(\n preset.kind === \"llm\" || preset.kind === \"embed\" ? (preset.transport ?? \"direct\") : \"—\",\n 14,\n ) +\n (presetBaseUrl(preset) ?? \"—\");\n console.log(` ${row}`);\n }\n}\n\nfunction printConfigured(view: RegistryView): void {\n const ids = view.merged.order;\n console.log();\n console.log(` ${S.heading(\"Configured providers\")}`);\n if (ids.length === 0) {\n console.log(\n ` ${S.dim(\"none — add one with\")} ${S.cmd(\"skaile providers add --preset <preset>\")}`,\n );\n console.log();\n return;\n }\n const idWidth = Math.max(...ids.map((id) => id.length)) + 2;\n const header = `${pad(\"id\", idWidth)}${pad(\"layer\", 11)}${pad(\"surface\", 26)}${pad(\"transport\", 14)}endpoint`;\n console.log(` ${S.dim(header)}`);\n for (const id of ids) {\n const entry = view.merged.providers[id];\n const surface = (entry as AIProviderLlmEntry).surface ?? \"—\";\n const transport = entryTransport(entry) ?? \"—\";\n const url = resolveEntryBaseUrl(entry) ?? S.dim(\"(unresolved)\");\n const flags = [\n isEntryEnabled(entry) ? \"\" : S.warn(\"disabled\"),\n entry.locked ? S.warn(\"locked\") : \"\",\n ]\n .filter(Boolean)\n .join(\" \");\n console.log(\n ` ${pad(id, idWidth)}${pad(view.merged.origin[id], 11)}${pad(surface, 26)}${pad(transport, 14)}${url} ${flags}`.trimEnd(),\n );\n console.log(` ${S.dim(`${pad(\"\", idWidth)}${credentialSummary(entry)}`)}`);\n }\n console.log();\n}\n\n// ── add ────────────────────────────────────────────────────────────────────\n\ninterface AddOptions extends ScopeOptions {\n preset?: string;\n credential?: string;\n baseUrl?: string;\n surface?: string;\n label?: string;\n kind?: string;\n param: string[];\n force?: boolean;\n}\n\nfunction parseParams(pairs: string[]): Record<string, string> {\n const out: Record<string, string> = {};\n for (const pair of pairs) {\n const eq = pair.indexOf(\"=\");\n if (eq <= 0) {\n logErr(`--param expects <key>=<value> (got '${pair}')`);\n process.exit(1);\n }\n out[pair.slice(0, eq)] = pair.slice(eq + 1);\n }\n return out;\n}\n\n/** Ask for the three literals a custom endpoint needs. Nothing else. */\nasync function promptCustomEntry(\n id: string,\n opts: AddOptions,\n): Promise<{ surface: AIProviderSurface; baseUrl: string; credentialRef: string }> {\n const interactive = process.stdin.isTTY === true;\n let surface = opts.surface as AIProviderSurface | undefined;\n let baseUrl = opts.baseUrl;\n let credentialRef = opts.credential;\n\n if (!interactive && (!surface || !baseUrl || !credentialRef)) {\n logErr(\n \"--preset custom needs --surface, --base-url and --credential when there is no terminal to prompt on\",\n );\n process.exit(1);\n }\n\n if (!surface) {\n const answer = await p.select({\n message: \"Wire surface:\",\n options: AI_PROVIDER_SURFACES.map((value) => ({ value, label: value })),\n initialValue: \"openai-completions\" as AIProviderSurface,\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n surface = answer as AIProviderSurface;\n }\n if (!baseUrl) {\n const answer = await p.text({\n message: \"Base URL:\",\n placeholder: \"https://api.example.com/v1\",\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n baseUrl = answer as string;\n }\n if (!credentialRef) {\n const answer = await p.text({\n message: \"Credential reference (env:NAME, cmd:<shell>, platform:<id>, keyring:<svc>/<acct>):\",\n initialValue: `env:${id.toUpperCase().replace(/[^A-Z0-9]/g, \"_\")}_API_KEY`,\n });\n if (p.isCancel(answer)) {\n p.cancel(\"Cancelled.\");\n process.exit(1);\n }\n credentialRef = answer as string;\n }\n return { surface, baseUrl, credentialRef };\n}\n\n/** A rejected registry write. The message is already CLI-ready. */\nexport class ProviderRegistryWriteError extends Error {}\n\n/** What {@link addProviderEntry} writes. */\nexport interface AddProviderEntryInput extends ScopeOptions {\n /** Registry entry id — `[a-z0-9][a-z0-9_-]*`. */\n id: string;\n /** Catalog preset to expand. Mutually exclusive with `entry`. */\n presetId?: string;\n /** A fully-built entry (the `--preset custom` path, which needs prompts). */\n entry?: AIProviderEntry;\n /** `env:NAME` / `cmd:…` / `platform:…` / `keyring:…` — never a literal. */\n credentialRef?: string;\n baseUrl?: string;\n surface?: AIProviderSurface;\n label?: string;\n params?: Record<string, string>;\n /** Overwrite an entry that already exists in the target file. */\n force?: boolean;\n}\n\n/** Result of {@link addProviderEntry}. */\nexport interface AddedProviderEntry {\n id: string;\n layer: \"user\" | \"workspace\";\n path: string;\n entry: AIProviderEntry;\n /** True when an existing entry in the target file was overwritten. */\n replaced: boolean;\n}\n\n/**\n * Write one entry into a registry file — the single write path behind\n * `skaile providers add` and the `skaile setup` wizard.\n *\n * Throws {@link ProviderRegistryWriteError} instead of exiting, so a wizard\n * can report the failure in its own idiom. Every rejection a caller can\n * provoke (bad id, unknown preset, missing transport parameter, locked entry,\n * a literal secret) lands here, and the document is validated before it is\n * written — a secret cannot reach disk through this function.\n */\nexport function addProviderEntry(input: AddProviderEntryInput): AddedProviderEntry {\n const { id } = input;\n if (!isSafeProviderId(id)) {\n throw new ProviderRegistryWriteError(\n `'${id}' is not a valid entry id — use [a-z0-9][a-z0-9_-]*`,\n );\n }\n if (input.credentialRef && !parseCredentialRef(input.credentialRef)) {\n throw new ProviderRegistryWriteError(\n \"the credential must be a reference, not a secret: \" +\n \"env:NAME, cmd:<shell>, platform:<configId> or keyring:<service>/<account>\",\n );\n }\n\n const view = loadRegistryView(input);\n const target = targetFile(input);\n const locked = lockConflict(id, target, view.files);\n if (locked) throw new ProviderRegistryWriteError(locked);\n\n const document = readTargetDocument(target, view.files);\n const replaced = document.providers[id] !== undefined;\n if (replaced && !input.force) {\n throw new ProviderRegistryWriteError(\n `'${id}' already exists in ${target.path} — pass --force to overwrite it.`,\n );\n }\n\n let entry: AIProviderEntry;\n if (input.entry) {\n entry = input.entry;\n } else {\n const preset = input.presetId ? getProviderPreset(input.presetId) : undefined;\n if (!preset) {\n throw new ProviderRegistryWriteError(\n `Unknown preset '${input.presetId}'. Run \\`skaile providers list\\` to see the catalog, ` +\n \"or use `--preset custom`.\",\n );\n }\n entry = expandPreset(preset, {\n credentialRef: input.credentialRef,\n baseUrl: input.baseUrl,\n surface: input.surface,\n label: input.label,\n params: input.params,\n });\n const missing = (preset.required_params ?? []).filter(\n (key) => !(key in ((entry as AIProviderLlmEntry).params ?? {})),\n );\n if (missing.length > 0) {\n throw new ProviderRegistryWriteError(\n `Preset '${preset.id}' needs ${missing.map((m) => `--param ${m}=<value>`).join(\" \")}`,\n );\n }\n }\n\n const next: AIProviderRegistryDocument = {\n version: 1,\n providers: { ...document.providers, [id]: entry },\n };\n const { diagnostics } = validateRegistry(\n { version: 1, providers: next.providers },\n { source: target.path },\n );\n const errors = diagnostics.filter((d) => d.severity === \"error\");\n if (errors.length > 0) {\n throw new ProviderRegistryWriteError(\n errors.map((d) => (d.path ? `${d.path}: ${d.message}` : d.message)).join(\"\\n\"),\n );\n }\n saveProviderRegistryFile(target.path, next);\n\n return { id, layer: target.layer, path: target.path, entry, replaced };\n}\n\n/** The env var an `env:` credential reference points at, if it is one. */\nexport function credentialEnvVarName(entry: AIProviderEntry): string | undefined {\n const ref = entry.credential?.ref;\n return ref?.startsWith(\"env:\") ? ref.slice(4) : undefined;\n}\n\n/** Build the `--preset custom` entry from the three literals the user gave. */\nfunction customEntry(\n answers: { surface: AIProviderSurface; baseUrl: string; credentialRef: string },\n opts: AddOptions,\n): AIProviderEntry {\n const kind = (opts.kind ?? \"llm\") as AIProviderEntry[\"kind\"];\n // Anthropic- and Google-shaped surfaces read a dedicated API-key header;\n // everything else is a bearer token. `set <id> credential.kind …` adjusts.\n const credentialKind =\n kind === \"stt\" ||\n kind === \"tts\" ||\n answers.surface === \"anthropic-messages\" ||\n answers.surface === \"google-generative-ai\" ||\n answers.surface === \"azure-openai-responses\"\n ? \"api_key_header\"\n : \"bearer\";\n if (kind === \"stt\" || kind === \"tts\") {\n return {\n kind,\n ...(opts.label ? { label: opts.label } : {}),\n base_url: answers.baseUrl,\n credential: { kind: credentialKind, ref: answers.credentialRef },\n };\n }\n return {\n kind,\n ...(opts.label ? { label: opts.label } : {}),\n surface: answers.surface,\n base_url: answers.baseUrl,\n credential: { kind: credentialKind, ref: answers.credentialRef },\n } as AIProviderLlmEntry;\n}\n\nasync function runAdd(idArg: string | undefined, opts: AddOptions): Promise<void> {\n const presetId = opts.preset;\n if (!presetId) {\n logErr(\n `--preset is required. Run ${S.cmd(\"skaile providers list\")} for the catalog, ` +\n `or use ${S.cmd(\"--preset custom\")}.`,\n );\n process.exit(1);\n }\n const id = idArg ?? presetId;\n if (id === CUSTOM_PRESET && !idArg) {\n logErr(\"--preset custom needs an entry id: skaile providers add <id> --preset custom\");\n process.exit(1);\n }\n\n const entry =\n presetId === CUSTOM_PRESET ? customEntry(await promptCustomEntry(id, opts), opts) : undefined;\n\n let added: AddedProviderEntry;\n try {\n added = addProviderEntry({\n id,\n ...(entry ? { entry } : { presetId }),\n credentialRef: opts.credential,\n baseUrl: opts.baseUrl,\n surface: opts.surface as AIProviderSurface | undefined,\n label: opts.label,\n params: parseParams(opts.param),\n projectDir: opts.projectDir,\n workspace: opts.workspace,\n force: opts.force,\n });\n } catch (error) {\n logErr(error instanceof Error ? error.message : String(error));\n process.exit(1);\n }\n\n logOk(`Added ${S.bold(id)} (${presetId}) to the ${added.layer} registry`);\n console.log(S.dim(` → ${added.path}`));\n const name = credentialEnvVarName(added.entry);\n if (name) {\n console.log(\n ` ${S.dim(\"The secret itself never goes in this file — export it:\")} ${S.cmd(`export ${name}=…`)}`,\n );\n }\n console.log(` ${S.dim(\"Verify with:\")} ${S.cmd(`skaile providers test ${id}`)}`);\n}\n\n// ── set / rm ───────────────────────────────────────────────────────────────\n\n/** Coerce a CLI string into the type the schema expects at `key`. */\nfunction coerceValue(key: string, value: string): unknown {\n const leaf = key.split(\".\").pop() ?? key;\n if (leaf === \"enabled\" || leaf === \"locked\" || leaf === \"tools\" || leaf === \"images\") {\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n logErr(`'${key}' takes true or false (got '${value}')`);\n process.exit(1);\n }\n if (leaf === \"context_window\" || leaf === \"thinking_max\") {\n const parsed = Number(value);\n if (!Number.isFinite(parsed)) {\n logErr(`'${key}' takes a number (got '${value}')`);\n process.exit(1);\n }\n return parsed;\n }\n return value;\n}\n\n/** Write `value` at a dotted path, creating intermediate maps. */\nfunction setDotted(entry: Record<string, unknown>, key: string, value: unknown): void {\n const segments = key.split(\".\");\n let cursor = entry;\n for (const segment of segments.slice(0, -1)) {\n const next = cursor[segment];\n if (typeof next !== \"object\" || next === null || Array.isArray(next)) {\n cursor[segment] = {};\n }\n cursor = cursor[segment] as Record<string, unknown>;\n }\n cursor[segments[segments.length - 1]] = value;\n}\n\nfunction runSet(id: string, key: string, value: string, opts: ScopeOptions): void {\n const view = loadRegistryView(opts);\n const target = targetFile(opts);\n exitIfLocked(id, target, view.files, key);\n\n const document = readTargetDocument(target, view.files);\n const existing = document.providers[id];\n const inherited = view.merged.providers[id];\n if (!existing && !inherited) {\n logErr(\n `No provider '${id}'. Add it with ${S.cmd(`skaile providers add ${id} --preset <preset>`)}`,\n );\n process.exit(1);\n }\n\n // Writing a field into a layer that has no entry yet leaves a one-field\n // override: the layers below keep supplying the rest (§1.5), so copying\n // their `kind` down here would pin a value this layer does not own.\n const base = (existing ? structuredClone(existing) : {}) as unknown as Record<string, unknown>;\n setDotted(base, key, coerceValue(key, value));\n\n const next: AIProviderRegistryDocument = {\n version: 1,\n providers: { ...document.providers, [id]: base as unknown as AIProviderEntry },\n };\n validateOrExit(next, target);\n saveProviderRegistryFile(target.path, next);\n\n logOk(`Set ${S.bold(`${id}.${key}`)} = ${value} in the ${target.layer} registry`);\n console.log(S.dim(` → ${target.path}`));\n}\n\nfunction runRemove(id: string, opts: ScopeOptions): void {\n const view = loadRegistryView(opts);\n const target = targetFile(opts);\n exitIfLocked(id, target, view.files);\n\n const document = readTargetDocument(target, view.files);\n if (!document.providers[id]) {\n logErr(`No provider '${id}' in ${target.path}`);\n process.exit(1);\n }\n const providers = { ...document.providers };\n delete providers[id];\n saveProviderRegistryFile(target.path, { version: 1, providers });\n\n logOk(`Removed ${S.bold(id)} from the ${target.layer} registry`);\n console.log(S.dim(` → ${target.path}`));\n if (\n view.merged.providers[id] &&\n view.files.some((f) => f.path !== target.path && f.document.providers[id])\n ) {\n logInfo(`'${id}' is still defined in another layer — run 'skaile providers list' to see it.`);\n }\n}\n\n// ── test ───────────────────────────────────────────────────────────────────\n\nasync function runTest(id: string, opts: ScopeOptions): Promise<void> {\n const view = loadRegistryView(opts);\n const entry = view.merged.providers[id];\n if (!entry) {\n logErr(`No provider '${id}'. Run ${S.cmd(\"skaile providers list\")} to see what is configured.`);\n process.exit(1);\n }\n\n const credential = resolveCredential(entry);\n console.log();\n console.log(` ${S.heading(id)} ${S.dim(`(${view.merged.origin[id]} layer)`)}`);\n console.log(` ${S.label(\"endpoint \")} ${resolveEntryBaseUrl(entry) ?? S.dim(\"(unresolved)\")}`);\n console.log(\n ` ${S.label(\"credential\")} ${credentialSummary(entry)} ${\n credential.error\n ? S.err(`— ${credential.error}`)\n : S.dim(`— resolved from ${credential.source}`)\n }`,\n );\n\n if (credential.error) {\n console.log();\n logErr(`${id} is not usable yet: ${credential.error}`);\n process.exit(1);\n }\n\n const result = await probeProviderEntry(entry, { secret: credential.value });\n if (result.url) console.log(` ${S.label(\"probe \")} GET ${result.url}`);\n console.log();\n if (result.ok) {\n logOk(`${id}: ${result.detail}${result.status ? ` (HTTP ${result.status})` : \"\"}`);\n return;\n }\n if (!result.probed) {\n logWarn(`${id}: ${result.detail}`);\n return;\n }\n logErr(`${id}: ${result.detail}`);\n process.exit(1);\n}\n\n// ── command ────────────────────────────────────────────────────────────────\n\n/**\n * Create the `skaile providers` command group.\n *\n * `list` shows the catalog and what is configured; `add` writes an entry from\n * a preset (or from three literals with `--preset custom`); `set` and `rm`\n * edit one layer; `test` sends one read-only request and reports what came\n * back, never the credential.\n *\n * @returns Configured {@link Command} ready for `program.addCommand()`.\n */\nexport function makeProvidersCommand(): Command {\n const cmd = new Command(\"providers\").description(\n \"Manage AI provider endpoints (~/.skaile/providers.yml)\",\n );\n\n cmd\n .command(\"list\")\n .description(\"List catalog presets and configured providers\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .option(\"--json\", \"Machine-readable output\")\n .action((opts) => {\n const view = loadRegistryView(opts);\n if (opts.json) {\n console.log(\n JSON.stringify(\n {\n presets: listProviderPresets().map((preset) => ({\n id: preset.id,\n kind: preset.kind,\n surface: preset.surface,\n transport: preset.transport ?? (preset.surface ? \"direct\" : undefined),\n base_url: presetBaseUrl(preset),\n credential: preset.credential,\n required_params: preset.required_params,\n })),\n providers: view.merged.order.map((id) => ({\n id,\n layer: view.merged.origin[id],\n entry: view.merged.providers[id],\n base_url: resolveEntryBaseUrl(view.merged.providers[id]),\n })),\n },\n null,\n 2,\n ),\n );\n return;\n }\n reportDiagnostics(view.diagnostics);\n printPresets();\n printConfigured(view);\n });\n\n cmd\n .command(\"add [id]\")\n .description(\"Add a provider from a catalog preset (id defaults to the preset name)\")\n .requiredOption(\"--preset <preset>\", `Catalog preset, or '${CUSTOM_PRESET}'`)\n .option(\"--credential <ref>\", \"Credential reference (env:NAME, cmd:…, platform:…, keyring:…)\")\n .option(\"--base-url <url>\", \"Override the preset endpoint\")\n .option(\"--surface <surface>\", `Wire surface (${AI_PROVIDER_SURFACES.join(\", \")})`)\n .option(\"--kind <kind>\", \"Entry kind for --preset custom (llm, embed, stt, tts)\", \"llm\")\n .option(\"--label <text>\", \"Display label\")\n .option(\n \"--param <key=value>\",\n \"Transport parameter (repeatable): region, project, location, resource, deployment, api_version\",\n (value: string, previous: string[]) => [...previous, value],\n [] as string[],\n )\n .option(\"--workspace\", \"Write <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .option(\"--force\", \"Overwrite an existing entry in the target file\")\n .action((id: string | undefined, opts: AddOptions) => runAdd(id, opts));\n\n cmd\n .command(\"set <id> <key> <value>\")\n .description(\n \"Set one field (base_url, enabled, credential.ref, headers.<name>, model_map.<id>…)\",\n )\n .option(\"--workspace\", \"Write <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, key: string, value: string, opts: ScopeOptions) =>\n runSet(id, key, value, opts),\n );\n\n cmd\n .command(\"rm <id>\")\n .description(\"Remove a provider from one layer\")\n .option(\"--workspace\", \"Edit <workspace>/.skaile/providers.yml instead of the user file\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, opts: ScopeOptions) => runRemove(id, opts));\n\n cmd\n .command(\"test <id>\")\n .description(\"Send one read-only request to a provider and report the result\")\n .option(\"--project-dir <path>\", \"Project directory\")\n .action((id: string, opts: ScopeOptions) => runTest(id, opts));\n\n return cmd;\n}\n"]}
@@ -8,7 +8,7 @@ import { computeStimulus } from './chunk-IFGTRL2I.js';
8
8
  import { interpolateNodeInstruction, resolveNodeBindings, getConsumedOutputSchema, validateConsumedNodeOutput, appendAttempt, resolveTerminalFailureStatus, remainingActiveExecutionMs, deriveCheckEvidence, computeFlowStateFromSnapshots, availableRouterFrontier, evaluateRouterSelection, routerSelectionOutput, planRouterSkips, unsettledRouterBranchIds, countFailedAttempts, hasAutomaticRetryBudget, persistedRouterSelection } from './chunk-KTCMBEEB.js';
9
9
  import { INPUT_SCHEMA_SHAPES_HINT, coerceInputSchema } from './chunk-XPDB4O4H.js';
10
10
  import { parseFlowDefinition } from './chunk-ALLCAFHQ.js';
11
- import { describeStimulus, buildOrchestratorPrompt, renderSubpromptPrompt, renderStimulusPrompt } from './chunk-RQLL7L72.js';
11
+ import { describeStimulus, buildOrchestratorPrompt, renderSubpromptPrompt, renderStimulusPrompt } from './chunk-D6YOE2DB.js';
12
12
  import { deterministicNodeKindLabel, nodeInstruction, flowDefaults, isAgentNode, isGateNode, isCheckNode, nodeRequiresApproval, isSubFlowNode, isFunctionNode, isSubpromptNode, isRouterNode, isActiveRuntimeNode, nodeIsOptional, nodeLabel, nodeAssets } from './chunk-V4RGCKYC.js';
13
13
  import { classifierDecision, withoutReservedClassifierFields } from './chunk-DHMBE5J7.js';
14
14
  import { withActivityLabelDefs } from './chunk-GRBB4CQL.js';
@@ -1762,6 +1762,52 @@ async function dropTrackingRefspec(branch, cwd) {
1762
1762
  async function isAncestor(ancestor, descendant, cwd) {
1763
1763
  return await gitOrNull(["merge-base", "--is-ancestor", ancestor, descendant], cwd) !== null;
1764
1764
  }
1765
+ async function integrateOriginBaseBranch(branch, cwd) {
1766
+ if (await gitOrNull(["symbolic-ref", "-q", "HEAD"], cwd) !== `refs/heads/${branch}`) return;
1767
+ if (await hasUnfinishedOperation(cwd)) return;
1768
+ try {
1769
+ await runGit([...gitPrefix(cwd), "fetch", "origin", branch], {
1770
+ cwd,
1771
+ timeout: 6e4,
1772
+ env: cLocaleEnv()
1773
+ });
1774
+ } catch (err) {
1775
+ if (/couldn't find remote ref/.test(err instanceof Error ? err.message : String(err))) return;
1776
+ throw err;
1777
+ }
1778
+ if (await isAncestor("FETCH_HEAD", "HEAD", cwd)) return;
1779
+ try {
1780
+ await gitCommitting(["merge", "--ff", "--no-edit", "FETCH_HEAD"], cwd, 6e4);
1781
+ } catch (err) {
1782
+ const unmerged = await gitOrNull(["diff", "--name-only", "--diff-filter=U"], cwd) ?? "";
1783
+ if (await gitOrNull(["rev-parse", "--quiet", "--verify", "MERGE_HEAD"], cwd) !== null) {
1784
+ await gitOrNull(["merge", "--abort"], cwd);
1785
+ }
1786
+ const files = unmerged.split("\n").filter(Boolean);
1787
+ if (files.length > 0) {
1788
+ throw new Error(
1789
+ `origin/${branch} and the local branch both have new commits that conflict in ${files.join(", ")}; the merge was aborted and nothing was pushed`
1790
+ );
1791
+ }
1792
+ throw err;
1793
+ }
1794
+ }
1795
+ async function hasUnfinishedOperation(cwd) {
1796
+ for (const ref of ["MERGE_HEAD", "CHERRY_PICK_HEAD", "REVERT_HEAD"]) {
1797
+ if (await gitOrNull(["rev-parse", "--quiet", "--verify", ref], cwd) !== null) return true;
1798
+ }
1799
+ for (const dir of ["rebase-merge", "rebase-apply"]) {
1800
+ const path = await gitOrNull(["rev-parse", "--git-path", dir], cwd);
1801
+ if (path === null) continue;
1802
+ const found = await tryWithFsDeadline(
1803
+ `stat ${dir}`,
1804
+ () => stat(resolve(cwd, path)).then(() => true),
1805
+ false
1806
+ );
1807
+ if (found) return true;
1808
+ }
1809
+ return false;
1810
+ }
1765
1811
  async function originTrackingRef(branch, cwd) {
1766
1812
  const ref = `refs/remotes/origin/${branch}`;
1767
1813
  return await gitOrNull(["rev-parse", "--verify", "--quiet", ref], cwd) === null ? null : ref;
@@ -2255,11 +2301,13 @@ var GitConnector = class extends AbstractConnector {
2255
2301
  * only on `origin/<branch>` merged in, so the push is a fast-forward and
2256
2302
  * never needs a force. It is pushed with `-u` and then recorded (see
2257
2303
  * {@link recordPushedSessionBranch}), so `@{upstream}` resolves — the
2258
- * platform's hibernate save gate reads exactly that. The base branch keeps
2259
- * its plain push.
2304
+ * platform's hibernate save gate reads exactly that. The base branch is
2305
+ * first brought up to date with origin ({@link integrateOriginBaseBranch}),
2306
+ * so a base branch that origin moved past is pushed rather than rejected.
2260
2307
  */
2261
2308
  async pushActiveBranch(s, cwd) {
2262
2309
  if (s.activeBranch === s.branch) {
2310
+ await integrateOriginBaseBranch(s.branch, cwd);
2263
2311
  await git(["push", "origin", s.activeBranch], cwd, 6e4);
2264
2312
  return;
2265
2313
  }
@@ -2469,7 +2517,7 @@ var GitConnector = class extends AbstractConnector {
2469
2517
  const lc = s.lifecycle;
2470
2518
  if (!lc.commitOnHibernate) return;
2471
2519
  const result = await commitAll(handle.mountPath, `skaile: hibernate snapshot`);
2472
- if (!result) return "Nothing to commit.";
2520
+ if (!result) return this.pushUnpushedOnHibernate(s, handle.mountPath);
2473
2521
  const sha = await git(["rev-parse", "--short", "HEAD"], handle.mountPath);
2474
2522
  if (lc.pushOnHibernate) {
2475
2523
  try {
@@ -2482,6 +2530,28 @@ var GitConnector = class extends AbstractConnector {
2482
2530
  }
2483
2531
  return `Committed ${sha} on ${s.activeBranch}${lc.pushOnHibernate ? " (pushed)" : ""}`;
2484
2532
  }
2533
+ /**
2534
+ * Hibernate with nothing new to commit: push commits that are still only
2535
+ * local (the agent committed its own work, or an earlier push failed).
2536
+ * "Unpushed" is measured exactly as the platform's hibernate save gate reads
2537
+ * `sync_status`: ahead of the upstream, or, with no upstream, ahead of
2538
+ * `origin/<base>`. Skipping it left the gate refusing to hibernate forever.
2539
+ */
2540
+ async pushUnpushedOnHibernate(s, cwd) {
2541
+ if (!s.lifecycle.pushOnHibernate) return "Nothing to commit.";
2542
+ const status = await readGitSyncStatus(cwd, s.branch);
2543
+ if (status.branch !== s.activeBranch) return "Nothing to commit.";
2544
+ const unpushed = status.hasUpstream ? status.ahead : status.mainAhead;
2545
+ if (unpushed === 0) return "Nothing to commit.";
2546
+ try {
2547
+ await this.pushActiveBranch(s, cwd);
2548
+ this.log.info("push ok", { branch: s.activeBranch, unpushed });
2549
+ } catch (err) {
2550
+ this.log.error("push failed", err, { branch: s.activeBranch });
2551
+ throw err;
2552
+ }
2553
+ return `Nothing to commit; pushed ${unpushed} unpushed commit(s) on ${s.activeBranch}`;
2554
+ }
2485
2555
  async onSessionClose(handle) {
2486
2556
  this.log.info("session closed");
2487
2557
  const s = handle.state;
@@ -11967,5 +12037,5 @@ function describeFlowOperations() {
11967
12037
  }
11968
12038
 
11969
12039
  export { AbstractConnector, BUILTIN_CONNECTOR_CATALOG, BoxConnector, ClassifierSubpromptRunner, ConnectorManager, DeployConnector, DevServerConnector, FlowAdapter, GitConnector, GmailConnector, GoogleDriveConnector, LocalConnector, LogBuffer, MAX_REARM_MS, MIN_REFRESH_DELAY_MS, ManagedGitconfigCollisionError, MattermostConnector, MemoryConnector, MinIOConnector, NO_ACTIVE_FLOW_ERROR, PortPool, PostgresConnector, REFRESH_LEAD_MS, S3Connector, S3FetchStoppedError, S3PresignedRequestError, S3_PRESIGN_BATCH, SQLiteConnector, SessionInlineSubFlowRunner, SessionNodeExecutor, SessionSubpromptRunner, SharePointConnector, StaticServerConnector, TunnelConnector, WebDAVConnector, XStateConnector, XStateStoreConnector, __test, atomicReplaceCredential, buildConnectorPromptSection, buildConnectorToolDefs, buildFlowPromptEvent, buildFlowToolDefs, buildLazyFlowToolDefs, buildLazySdkFlowTools, buildSdkConnectorTools, buildSdkFlowTools, checkFleetMountLiveness, classifierQuestion, classifyConnectError, createConnector, createConnector10, createConnector11, createConnector12, createConnector13, createConnector14, createConnector15, createConnector16, createConnector17, createConnector18, createConnector19, createConnector2, createConnector20, createConnector3, createConnector4, createConnector5, createConnector6, createConnector7, createConnector8, createConnector9, createFsWatcher, createWorktree, defaultSpawn, describeFlowOperations, driveOrchestratorTurn, ensureDirMode, ensureFleetMounted, ensureRefreshAttemptStamp, findGitRoot, findMissingPackages, getConnector, installNpmPackages, isFleetManaged, isPackageResolvable, listConnectors, listWorktrees, parseListObjectsV2, presignScopePrefix, presignableKey, readGitSyncStatus, registerBuiltinConnectors, removeMountBlock, removeUnavailableMountBlock, renderCredentialHelperScript, tryGetConnector, worktreeRegistry, writeHelperScript, writeMountBlock, writeUnavailableMountBlock };
11970
- //# sourceMappingURL=chunk-PTALRV5L.js.map
11971
- //# sourceMappingURL=chunk-PTALRV5L.js.map
12040
+ //# sourceMappingURL=chunk-KES5T25I.js.map
12041
+ //# sourceMappingURL=chunk-KES5T25I.js.map