@skaile/workspaces 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{asset-feeds-MWEMXMZA.js → asset-feeds-WIBEP37F.js} +4 -4
- package/dist/{asset-feeds-MWEMXMZA.js.map → asset-feeds-WIBEP37F.js.map} +1 -1
- package/dist/asset-manager/index.js +1 -1
- package/dist/bridge/drivers/claude-sdk.js +31 -26
- package/dist/bridge/drivers/claude-sdk.js.map +1 -1
- package/dist/bridge/drivers/codex.js +1 -1
- package/dist/bridge/drivers/continue.js +2 -2
- package/dist/bridge/drivers/echo.js +1 -1
- package/dist/bridge/drivers/gemini.js +3 -3
- package/dist/bridge/drivers/goose.js +2 -2
- package/dist/bridge/drivers/omp.js +1 -1
- package/dist/bridge/drivers/opencode.js +2 -2
- package/dist/bridge/drivers/qwen.js +3 -3
- package/dist/bridge/index.js +2 -2
- package/dist/bridge/src/drivers/claude-sdk.d.ts +12 -56
- package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
- package/dist/{chunk-MTM6C7IS.js → chunk-6POODADP.js} +12 -3
- package/dist/chunk-6POODADP.js.map +1 -0
- package/dist/{chunk-DPUZJI45.js → chunk-A22KZ7GZ.js} +2 -2
- package/dist/{chunk-DPUZJI45.js.map → chunk-A22KZ7GZ.js.map} +1 -1
- package/dist/{chunk-LTQOZIJO.js → chunk-ACWCVB5Q.js} +2 -2
- package/dist/{chunk-LTQOZIJO.js.map → chunk-ACWCVB5Q.js.map} +1 -1
- package/dist/{chunk-HA53HVIS.js → chunk-BG4XVMG2.js} +7 -7
- package/dist/{chunk-HA53HVIS.js.map → chunk-BG4XVMG2.js.map} +1 -1
- package/dist/{chunk-Z6NGK5YC.js → chunk-BYS6JDZB.js} +3 -3
- package/dist/{chunk-Z6NGK5YC.js.map → chunk-BYS6JDZB.js.map} +1 -1
- package/dist/{chunk-MJEUK6VJ.js → chunk-C4KVFALU.js} +2 -2
- package/dist/{chunk-MJEUK6VJ.js.map → chunk-C4KVFALU.js.map} +1 -1
- package/dist/{chunk-SRWIVMJI.js → chunk-EPWY2ABE.js} +3 -3
- package/dist/{chunk-SRWIVMJI.js.map → chunk-EPWY2ABE.js.map} +1 -1
- package/dist/{chunk-NRXVS7E4.js → chunk-FIUGSIKC.js} +6 -6
- package/dist/{chunk-NRXVS7E4.js.map → chunk-FIUGSIKC.js.map} +1 -1
- package/dist/{chunk-F3ET4UGP.js → chunk-M5GJT3D7.js} +3 -3
- package/dist/{chunk-F3ET4UGP.js.map → chunk-M5GJT3D7.js.map} +1 -1
- package/dist/{chunk-XW3SWH7C.js → chunk-MNKUZUN2.js} +3 -3
- package/dist/{chunk-XW3SWH7C.js.map → chunk-MNKUZUN2.js.map} +1 -1
- package/dist/{chunk-SELNYOEO.js → chunk-MO43URUI.js} +4 -4
- package/dist/{chunk-SELNYOEO.js.map → chunk-MO43URUI.js.map} +1 -1
- package/dist/{chunk-6ZLMG5GR.js → chunk-O5VCUU6D.js} +4 -4
- package/dist/{chunk-6ZLMG5GR.js.map → chunk-O5VCUU6D.js.map} +1 -1
- package/dist/{chunk-73HV7RV3.js → chunk-WSTY3AWY.js} +3 -3
- package/dist/{chunk-73HV7RV3.js.map → chunk-WSTY3AWY.js.map} +1 -1
- package/dist/{chunk-3EBFDMZC.js → chunk-Y662DNQQ.js} +14 -3
- package/dist/chunk-Y662DNQQ.js.map +1 -0
- package/dist/{chunk-RADBQ5XJ.js → chunk-YULV7UTU.js} +6 -6
- package/dist/{chunk-RADBQ5XJ.js.map → chunk-YULV7UTU.js.map} +1 -1
- package/dist/cli/index.js +28 -28
- package/dist/connectors/index.js +2 -2
- package/dist/connectors/src/connector-prompt.d.ts.map +1 -1
- package/dist/{ensure-sources-QGL44IRI.js → ensure-sources-RSTZONIE.js} +4 -4
- package/dist/{ensure-sources-QGL44IRI.js.map → ensure-sources-RSTZONIE.js.map} +1 -1
- package/dist/factory-assets/connectors/box.js +2 -2
- package/dist/factory-assets/connectors/deploy.js +2 -2
- package/dist/factory-assets/connectors/devserver.js +2 -2
- package/dist/factory-assets/connectors/flow/CONNECTOR.md +3 -1
- package/dist/factory-assets/connectors/flow/adapter.d.ts +2 -1
- package/dist/factory-assets/connectors/flow/adapter.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/adapter.js +2 -2
- package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts +9 -2
- package/dist/factory-assets/connectors/flow/prompt-fragments.d.ts.map +1 -1
- package/dist/factory-assets/connectors/flow/prompt-fragments.js +1 -1
- package/dist/factory-assets/connectors/flow/run-flow.js +3 -3
- package/dist/factory-assets/connectors/flow.js +2 -2
- package/dist/factory-assets/connectors/git.js +2 -2
- package/dist/factory-assets/connectors/gmail.js +2 -2
- package/dist/factory-assets/connectors/googledrive.js +2 -2
- package/dist/factory-assets/connectors/local.js +2 -2
- package/dist/factory-assets/connectors/mattermost.js +2 -2
- package/dist/factory-assets/connectors/memory.js +2 -2
- package/dist/factory-assets/connectors/minio.js +2 -2
- package/dist/factory-assets/connectors/postgres.js +2 -2
- package/dist/factory-assets/connectors/s3.js +2 -2
- package/dist/factory-assets/connectors/sharepoint.js +2 -2
- package/dist/factory-assets/connectors/sqlite.js +2 -2
- package/dist/factory-assets/connectors/static-server.js +2 -2
- package/dist/factory-assets/connectors/tunnel.js +2 -2
- package/dist/factory-assets/connectors/webdav.js +2 -2
- package/dist/factory-assets/connectors/xstate-store.js +2 -2
- package/dist/factory-assets/connectors/xstate.js +2 -2
- package/dist/{helpers-FMWODXTW.js → helpers-GUUWPPAX.js} +4 -4
- package/dist/{helpers-FMWODXTW.js.map → helpers-GUUWPPAX.js.map} +1 -1
- package/dist/{library-publish-7YDHQGBN.js → library-publish-UKKSJP7V.js} +6 -6
- package/dist/{library-publish-7YDHQGBN.js.map → library-publish-UKKSJP7V.js.map} +1 -1
- package/dist/{open-library-O6T3ELPK.js → open-library-VALRYGFV.js} +5 -5
- package/dist/{open-library-O6T3ELPK.js.map → open-library-VALRYGFV.js.map} +1 -1
- package/dist/{project-HAMLHLD5.js → project-IRUJLIVX.js} +5 -5
- package/dist/{project-HAMLHLD5.js.map → project-IRUJLIVX.js.map} +1 -1
- package/dist/runner/index.js +6 -6
- package/dist/sdk/asset-manager.js +1 -1
- package/dist/sdk/bridge.js +2 -2
- package/dist/sdk/index.js +6 -6
- package/dist/sdk/runner.js +6 -6
- package/dist/{setup-OJC74Q2Q.js → setup-WJPNUE32.js} +4 -4
- package/dist/{setup-OJC74Q2Q.js.map → setup-WJPNUE32.js.map} +1 -1
- package/dist/{source-ITDH4367.js → source-5KDURFBS.js} +6 -6
- package/dist/{source-ITDH4367.js.map → source-5KDURFBS.js.map} +1 -1
- package/dist/{source-manifest-publish-RMHC7R6M.js → source-manifest-publish-DPQI44D3.js} +7 -7
- package/dist/{source-manifest-publish-RMHC7R6M.js.map → source-manifest-publish-DPQI44D3.js.map} +1 -1
- package/dist/tui/index.js +6 -6
- package/dist/workspace-plugin/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3EBFDMZC.js.map +0 -1
- package/dist/chunk-MTM6C7IS.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skaile/workspaces",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Skaile workspaces runtime — types, core, bridge, runner, store, connectors, and supporting layers as one publishable package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "bun@1.3.9",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../factory-assets/connectors/flow/prompt-fragments.ts"],"names":[],"mappings":";AAkDO,SAAS,qBAAqB,QAAA,EAAgC;AACnE,EAAA,QAAQ,SAAS,IAAA;AAAM,IACrB,KAAK,cAAA;AACH,MAAA,OAAO,iKAAA;AAAA,IACT,KAAK,mBAAA,EAAqB;AACxB,M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QAAQ;;AAAA;;AAAA;;AAAA,EAMR,YAAY;;AAAA;;AAAA,EAIZ,iBAAiB;;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAyBnB;AAUO,SAAS,iBAAiB,QAAA,EAAgC;AAC/D,EAAA,QAAQ,SAAS,IAAA;AAAM,IACrB,KAAK,cAAA;AACH,MAAA,OAAO,cAAA;AAAA,IACT,KAAK,mBAAA;AACH,MAAA,OAAO,CAAA,kBAAA,EAAqB,QAAA,CAAS,MAAM,CAAA,CAAA,EAAI,SAAS,QAAQ,CAAA,CAAA;AAAA,IAClE,KAAK,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-3EBFDMZC.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\";\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 * Identical to `FlowOrchestrator.buildOrchestratorPrompt` (Phase 3 lift —\n * any divergence is a regression). 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 skillNodes = flowDef.nodes.filter((n) => n.type === \"skill\");\n\n // ── Section 1: definition table ──\n const nodeRows = skillNodes\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 = n.data?.optional ? \"optional\" : \"required\";\n const gate = n.data?.approval?.mandatory ? \"mandatory\" : \"—\";\n const nodeState = state.nodes[n.id];\n const status = nodeState?.status ?? \"not_started\";\n return `| ${n.id} | ${n.data?.skill ?? n.id} | ${n.data?.label ?? n.id} | ${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) => n.status === s)\n .map((n) => n.id);\n const available = nodesByStatus(\"available\");\n const awaitingApproval = nodesByStatus(\"awaiting_approval\");\n const awaitingInput = nodesByStatus(\"awaiting_input\");\n const running = nodesByStatus(\"running\");\n const failed = nodesByStatus(\"failed\");\n const completed = nodesByStatus(\"complete\");\n const totalRequired = skillNodes.filter((n) => !n.data?.optional).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 `- Awaiting input: ${awaitingInput.join(\", \") || \"(none)\"}`,\n `- Failed: ${failed.join(\", \") || \"(none)\"}`,\n ].join(\"\\n\");\n\n // ── Section 3: stimulus paragraph ──\n const stimulusParagraph = renderStimulusPrompt(stimulus);\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 | Skill | Label | 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.\n\n## Current state\n\n${stateSummary}\n\n## 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- \\`build_handoff(nodeId)\\` — curated context from upstream predecessors (summaries + artifacts)\n- \\`start_node(nodeId)\\` — transition \\`available\\` → \\`running\\`; call before executing the skill\n- \\`request_approval(nodeId, summary, artifacts)\\` — transition \\`running\\` → \\`awaiting_approval\\`. **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, output)\\` — transition to \\`complete\\`. Valid only if the node was approved, OR autonomousMode is true and the node is not a mandatory gate.\n- \\`fail_node(nodeId, message, recoverable)\\` — transition to \\`failed\\`. \\`recoverable=true\\` returns the node to \\`available\\`.\n- \\`skip_node(nodeId)\\` — transition to \\`skipped\\`. Only valid for optional nodes.\n\n## Rules\n\n1. Before executing a skill, call \\`start_node(nodeId)\\`.\n2. After executing the skill, 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. If you need information from the user before or during execution, call \\`request_input\\`. This ends your turn until the user responds.\n4. On unrecoverable failure, call \\`fail_node(..., recoverable: false)\\`. On recoverable failure, call \\`fail_node(..., recoverable: true)\\` and the engine returns the node to \\`available\\`.\n5. When all required nodes are \\`complete\\` or \\`skipped\\`, stop. The runner marks the flow done automatically.\n6. Free-chat user messages do not require flow action. Respond directly, continue flow work, or both — your call.\n`;\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"]}
|