stageflow 0.42.0 → 0.44.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/README.md +12 -3
- package/dist/agent/activity.d.ts +18 -0
- package/dist/agent/claudeAdapter.js +7 -0
- package/dist/agent/claudeTools.d.ts +27 -18
- package/dist/agent/claudeTools.js +54 -15
- package/dist/agent/compactionEvents.d.ts +34 -0
- package/dist/agent/compactionEvents.js +37 -0
- package/dist/agent/openRouterRouting.d.ts +7 -0
- package/dist/agent/openRouterRouting.js +23 -0
- package/dist/agent/piAdapter.d.ts +6 -0
- package/dist/agent/piAdapter.js +128 -27
- package/dist/agent/piSettings.d.ts +7 -0
- package/dist/agent/piSettings.js +9 -0
- package/dist/agent/sandboxPiTools.d.ts +3 -1
- package/dist/agent/sandboxPiTools.js +8 -2
- package/dist/agent/stageTurnDriver.d.ts +11 -2
- package/dist/agent/stageTurnDriver.js +45 -4
- package/dist/agent/toolOutputBudget.d.ts +15 -1
- package/dist/agent/toolOutputBudget.js +18 -0
- package/dist/agent/toolOutputBudgetExtension.d.ts +2 -0
- package/dist/agent/toolOutputBudgetExtension.js +40 -3
- package/dist/agents/authorChat.d.ts +1 -0
- package/dist/agents/authorChat.js +7 -0
- package/dist/agents/authorSessionStore.d.ts +3 -0
- package/dist/agents/authorSessionStore.js +17 -2
- package/dist/agents/hostContext.d.ts +1 -1
- package/dist/agents/runtime/piRuntime.d.ts +5 -1
- package/dist/agents/runtime/piRuntime.js +46 -12
- package/dist/agents/service.js +3 -2
- package/dist/agents/sessions.js +3 -1
- package/dist/compaction/directives.d.ts +18 -0
- package/dist/compaction/directives.js +119 -0
- package/dist/compaction/extension.d.ts +20 -0
- package/dist/compaction/extension.js +78 -0
- package/dist/compaction/mask.d.ts +18 -0
- package/dist/compaction/mask.js +155 -0
- package/dist/compaction/pin.d.ts +21 -0
- package/dist/compaction/pin.js +270 -0
- package/dist/compaction/scrub.d.ts +7 -0
- package/dist/compaction/scrub.js +26 -0
- package/dist/compaction/sessionWiring.d.ts +22 -0
- package/dist/compaction/sessionWiring.js +26 -0
- package/dist/compaction/summarize.d.ts +79 -0
- package/dist/compaction/summarize.js +171 -0
- package/dist/compaction/toolPolicy.d.ts +3 -0
- package/dist/compaction/toolPolicy.js +33 -0
- package/dist/compaction/types.d.ts +45 -0
- package/dist/compaction/types.js +7 -0
- package/dist/compaction/workingState.d.ts +56 -0
- package/dist/compaction/workingState.js +198 -0
- package/dist/config/createPipeline.js +2 -0
- package/dist/config/createTrigger.js +7 -1
- package/dist/config/ensureCatalogScanRoot.d.ts +2 -0
- package/dist/config/ensureCatalogScanRoot.js +6 -0
- package/dist/config/evalCatalog.js +30 -2
- package/dist/config/githubTriggerAction.d.ts +8 -0
- package/dist/config/githubTriggerAction.js +29 -0
- package/dist/config/hostConfig.js +2 -0
- package/dist/config/loadEval.js +21 -3
- package/dist/config/pipelineNeeds.d.ts +2 -0
- package/dist/config/pipelineNeeds.js +16 -3
- package/dist/config/pipelineRoute.js +5 -4
- package/dist/config/validateCatalog.d.ts +1 -1
- package/dist/config/validateCatalog.js +12 -0
- package/dist/config/validateEval.js +43 -2
- package/dist/config/writeEval.js +2 -2
- package/dist/envelope/assertEmittedArtifacts.d.ts +12 -0
- package/dist/envelope/assertEmittedArtifacts.js +43 -0
- package/dist/envelope/preEmitChecks.d.ts +3 -0
- package/dist/evals/constants.d.ts +3 -1
- package/dist/evals/constants.js +3 -1
- package/dist/evals/engine/FakeEngine.d.ts +1 -1
- package/dist/evals/engine/FakeEngine.js +2 -1
- package/dist/evals/engine/promptfoo/PromptfooEngine.d.ts +1 -1
- package/dist/evals/engine/promptfoo/PromptfooEngine.js +2 -1
- package/dist/evals/engine/promptfoo/generate.d.ts +1 -1
- package/dist/evals/engine/promptfoo/generate.js +11 -8
- package/dist/evals/engine/promptfoo/rubricPrompt.d.ts +1 -1
- package/dist/evals/engine/promptfoo/rubricPrompt.js +5 -3
- package/dist/evals/manager.d.ts +13 -0
- package/dist/evals/manager.js +10 -2
- package/dist/evals/plan.d.ts +8 -1
- package/dist/evals/plan.js +28 -9
- package/dist/evals/planInternalAgent.d.ts +19 -0
- package/dist/evals/planInternalAgent.js +205 -0
- package/dist/evals/read/api.d.ts +12 -0
- package/dist/evals/read/api.js +5 -0
- package/dist/evals/read/list.js +10 -1
- package/dist/evals/read/runs.d.ts +5 -0
- package/dist/evals/read/runs.js +7 -1
- package/dist/evals/runner/caseRunner.d.ts +2 -1
- package/dist/evals/runner/caseRunner.js +16 -5
- package/dist/evals/runner/internalAgentCaseRunner.d.ts +6 -0
- package/dist/evals/runner/internalAgentCaseRunner.js +250 -0
- package/dist/evals/snapshot.d.ts +10 -2
- package/dist/evals/snapshot.js +8 -3
- package/dist/evals/types.d.ts +12 -2
- package/dist/evals/types.js +4 -1
- package/dist/guide/cardContract.d.ts +133 -0
- package/dist/guide/cardContract.js +156 -0
- package/dist/guide/chat.d.ts +45 -0
- package/dist/guide/chat.js +378 -0
- package/dist/guide/knowledge/index.d.ts +14 -0
- package/dist/guide/knowledge/index.js +109 -0
- package/dist/guide/knowledge/topics/agents.d.ts +2 -0
- package/dist/guide/knowledge/topics/agents.js +58 -0
- package/dist/guide/knowledge/topics/bestPractices.d.ts +2 -0
- package/dist/guide/knowledge/topics/bestPractices.js +67 -0
- package/dist/guide/knowledge/topics/connections.d.ts +2 -0
- package/dist/guide/knowledge/topics/connections.js +66 -0
- package/dist/guide/knowledge/topics/consoleMap.d.ts +2 -0
- package/dist/guide/knowledge/topics/consoleMap.js +55 -0
- package/dist/guide/knowledge/topics/evals.d.ts +2 -0
- package/dist/guide/knowledge/topics/evals.js +72 -0
- package/dist/guide/knowledge/topics/limitations.d.ts +2 -0
- package/dist/guide/knowledge/topics/limitations.js +84 -0
- package/dist/guide/knowledge/topics/mcpSkillsBrowser.d.ts +2 -0
- package/dist/guide/knowledge/topics/mcpSkillsBrowser.js +57 -0
- package/dist/guide/knowledge/topics/memories.d.ts +2 -0
- package/dist/guide/knowledge/topics/memories.js +63 -0
- package/dist/guide/knowledge/topics/modelsAndProviders.d.ts +2 -0
- package/dist/guide/knowledge/topics/modelsAndProviders.js +56 -0
- package/dist/guide/knowledge/topics/overview.d.ts +2 -0
- package/dist/guide/knowledge/topics/overview.js +56 -0
- package/dist/guide/knowledge/topics/pipelines.d.ts +2 -0
- package/dist/guide/knowledge/topics/pipelines.js +93 -0
- package/dist/guide/knowledge/topics/stages.d.ts +2 -0
- package/dist/guide/knowledge/topics/stages.js +54 -0
- package/dist/guide/knowledge/topics/tasks.d.ts +2 -0
- package/dist/guide/knowledge/topics/tasks.js +52 -0
- package/dist/guide/knowledge/topics/triggers.d.ts +2 -0
- package/dist/guide/knowledge/topics/triggers.js +68 -0
- package/dist/guide/knowledge/topics/troubleshooting.d.ts +2 -0
- package/dist/guide/knowledge/topics/troubleshooting.js +85 -0
- package/dist/guide/knowledgeTools.d.ts +2 -0
- package/dist/guide/knowledgeTools.js +56 -0
- package/dist/guide/showUi.d.ts +6 -0
- package/dist/guide/showUi.js +546 -0
- package/dist/guide/threadStore.d.ts +48 -0
- package/dist/guide/threadStore.js +189 -0
- package/dist/guide/writeRoot.d.ts +11 -0
- package/dist/guide/writeRoot.js +70 -0
- package/dist/hosted/translate.js +2 -0
- package/dist/mcp/agentTools.js +12 -0
- package/dist/mcp/catalogTools.js +18 -20
- package/dist/mcp/catalogWriteTools.d.ts +8 -0
- package/dist/mcp/catalogWriteTools.js +225 -0
- package/dist/mcp/connectionTools.d.ts +3 -0
- package/dist/mcp/connectionTools.js +85 -0
- package/dist/mcp/controlTools.js +34 -1
- package/dist/mcp/deps.d.ts +9 -0
- package/dist/mcp/evalTools.js +684 -21
- package/dist/mcp/memoryHostTools.d.ts +3 -0
- package/dist/mcp/memoryHostTools.js +72 -0
- package/dist/mcp/pipelineAuthorTools.js +14 -1
- package/dist/mcp/server.js +5 -0
- package/dist/mcp/tools.js +6 -0
- package/dist/mcp/triggerTools.js +77 -31
- package/dist/operatorAgent/evalGate.d.ts +22 -0
- package/dist/operatorAgent/evalGate.js +77 -0
- package/dist/operatorAgent/fakeHost.js +10 -2
- package/dist/operatorAgent/host.js +18 -2
- package/dist/operatorAgent/index.d.ts +1 -0
- package/dist/operatorAgent/index.js +1 -0
- package/dist/operatorAgent/internalAgents.d.ts +11 -0
- package/dist/operatorAgent/internalAgents.js +13 -0
- package/dist/operatorAgent/piModel.d.ts +5 -1
- package/dist/operatorAgent/piModel.js +15 -10
- package/dist/operatorAgent/profiles/agentAuthor.js +66 -22
- package/dist/operatorAgent/profiles/agentAuthorPlaybook.d.ts +1 -1
- package/dist/operatorAgent/profiles/agentAuthorPlaybook.js +1 -1
- package/dist/operatorAgent/profiles/guideConfirm.d.ts +21 -0
- package/dist/operatorAgent/profiles/guideConfirm.js +100 -0
- package/dist/operatorAgent/profiles/guideTools.d.ts +7 -0
- package/dist/operatorAgent/profiles/guideTools.js +123 -0
- package/dist/operatorAgent/profiles/stageflowGuide.d.ts +7 -0
- package/dist/operatorAgent/profiles/stageflowGuide.js +132 -0
- package/dist/operatorAgent/profiles/workshopAuthor.js +23 -0
- package/dist/operatorAgent/profiles/workshopAuthorPlaybook.d.ts +1 -1
- package/dist/operatorAgent/profiles/workshopAuthorPlaybook.js +9 -1
- package/dist/operatorAgent/profiles/workshopAuthorTools.d.ts +2 -0
- package/dist/operatorAgent/profiles/workshopAuthorTools.js +197 -9
- package/dist/operatorAgent/types.d.ts +23 -0
- package/dist/package-meta.d.ts +1 -1
- package/dist/package-meta.js +1 -1
- package/dist/runstore/retention.d.ts +2 -1
- package/dist/runstore/retention.js +3 -7
- package/dist/runstore/runStatusClock.d.ts +17 -0
- package/dist/runstore/runStatusClock.js +19 -0
- package/dist/runstore/sqlite/SqliteRunStore.d.ts +1 -0
- package/dist/runstore/sqlite/SqliteRunStore.js +45 -45
- package/dist/runstore/workspaceLayout.js +6 -1
- package/dist/runtime/artifactDiskInspect.d.ts +14 -0
- package/dist/runtime/artifactDiskInspect.js +52 -0
- package/dist/runtime/artifactPath.d.ts +24 -0
- package/dist/runtime/artifactPath.js +84 -0
- package/dist/runtime/completionCheckRunner.js +15 -43
- package/dist/runtime/githubPollSource.d.ts +22 -4
- package/dist/runtime/githubPollSource.js +93 -8
- package/dist/runtime/priorArtifactGrants.d.ts +8 -0
- package/dist/runtime/priorArtifactGrants.js +105 -0
- package/dist/runtime/runActionEligibility.d.ts +46 -0
- package/dist/runtime/runActionEligibility.js +123 -0
- package/dist/runtime/runManager.d.ts +4 -1
- package/dist/runtime/runManager.js +52 -10
- package/dist/runtime/runRetryCoordinator.d.ts +2 -14
- package/dist/runtime/runRetryCoordinator.js +3 -67
- package/dist/runtime/sandboxContainer.d.ts +7 -0
- package/dist/runtime/sandboxContainer.js +48 -6
- package/dist/runtime/sandboxDesk.d.ts +2 -1
- package/dist/runtime/sandboxDesk.js +11 -12
- package/dist/runtime/stageEnvironment.js +1 -0
- package/dist/runtime/stageRoots.d.ts +12 -0
- package/dist/runtime/stageSandbox.d.ts +2 -1
- package/dist/runtime/stageSandbox.js +18 -2
- package/dist/runtime/stageWorker.js +20 -0
- package/dist/server/agentAuthorRoutes.js +12 -3
- package/dist/server/bootstrap.d.ts +5 -0
- package/dist/server/bootstrap.js +14 -1
- package/dist/server/evalRoutes.js +38 -9
- package/dist/server/guideRoutes.d.ts +5 -0
- package/dist/server/guideRoutes.js +166 -0
- package/dist/server/http.d.ts +10 -0
- package/dist/server/http.js +35 -1
- package/dist/server/internalAgentRoutes.d.ts +6 -0
- package/dist/server/internalAgentRoutes.js +12 -0
- package/dist/server/mcpHost.js +2 -0
- package/dist/toolkit/meta.d.ts +1 -1
- package/dist/toolkit/meta.js +39 -1
- package/dist/toolkit/profiles.d.ts +5 -0
- package/dist/toolkit/profiles.js +12 -0
- package/dist/tools/askOperator.js +2 -1
- package/dist/tools/emitStageEnvelope.d.ts +17 -16
- package/dist/tools/emitStageEnvelope.js +46 -32
- package/dist/tools/stageToolNames.d.ts +4 -0
- package/dist/tools/stageToolNames.js +4 -0
- package/dist/tools/workingState.d.ts +40 -0
- package/dist/tools/workingState.js +108 -0
- package/dist/tools/writeStageArtifact.d.ts +0 -9
- package/dist/tools/writeStageArtifact.js +2 -1
- package/dist/ui/assets/{MarkdownText-BTrOqu5J.js → MarkdownText-S5C_vemc.js} +2 -2
- package/dist/ui/assets/adapters-C0l4ruiR.js +17 -0
- package/dist/ui/assets/chat-CjnsmvqR.js +2 -0
- package/dist/ui/assets/chat-DFDd4UjS.css +2 -0
- package/dist/ui/assets/{main-CHlmTNJe.css → main-Del1GeLf.css} +1 -1
- package/dist/ui/assets/main-_yXVqcW9.js +277 -0
- package/dist/ui/chat.html +3 -4
- package/dist/ui/index.html +3 -4
- package/dist/workshop/chatTurn.js +1 -1
- package/dist/workshop/workshopPin.d.ts +3 -3
- package/dist/workshop/workshopPin.js +16 -15
- package/examples/compaction-stress/README.md +30 -0
- package/examples/compaction-stress/check-run.mjs +53 -0
- package/examples/compaction-stress/collect-evidence.yaml +60 -0
- package/examples/compaction-stress/compaction-stress.pipeline.yaml +141 -0
- package/examples/compaction-stress/compaction-stress.task.yaml +15 -0
- package/examples/compaction-stress/generate-evidence.mjs +110 -0
- package/examples/compaction-stress/root-cause.yaml +26 -0
- package/examples/compaction-stress/stageflow.yaml +9 -0
- package/examples/compaction-stress/write-postmortem.yaml +40 -0
- package/examples/evals/README.md +18 -0
- package/examples/evals/guide-behavior.dataset.jsonl +15 -0
- package/examples/evals/guide-behavior.eval.yaml +35 -0
- package/examples/evals/guide-depth.dataset.jsonl +35 -0
- package/examples/evals/guide-depth.eval.yaml +169 -0
- package/examples/memory/evals/guide-behavior.dataset.jsonl +15 -0
- package/examples/memory/evals/guide-behavior.eval.yaml +35 -0
- package/examples/memory/evals/guide-depth.dataset.jsonl +35 -0
- package/examples/memory/evals/guide-depth.eval.yaml +169 -0
- package/package.json +1 -1
- package/dist/ui/assets/AssistantRuntimeProvider-qIX1xNoH.js +0 -9
- package/dist/ui/assets/ReadonlyStore-BfXqHykm.js +0 -6
- package/dist/ui/assets/chat-Df_wCpak.js +0 -5
- package/dist/ui/assets/chat-P7KQznHm.css +0 -2
- package/dist/ui/assets/main-CvVfxmMd.js +0 -271
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { MemoryError } from "../memory/host.js";
|
|
3
|
+
import { textResult } from "./toolResults.js";
|
|
4
|
+
async function call(deps, work) {
|
|
5
|
+
const host = deps.memories;
|
|
6
|
+
if (!host)
|
|
7
|
+
return textResult({ error: "MEMORIES_UNAVAILABLE" }, true);
|
|
8
|
+
try {
|
|
9
|
+
return textResult(await work(host));
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error instanceof MemoryError)
|
|
13
|
+
return textResult({ error: error.code }, true);
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function registerMemoryHostTools(server, deps) {
|
|
18
|
+
server.registerTool("list_memories", {
|
|
19
|
+
description: "List host memories (id, description, and card count).",
|
|
20
|
+
inputSchema: z.object({}),
|
|
21
|
+
}, () => call(deps, async (host) => ({ memories: await host.list() })));
|
|
22
|
+
server.registerTool("get_memory", {
|
|
23
|
+
description: "Read one host memory: its description, cover page, and card keys.",
|
|
24
|
+
inputSchema: z.object({
|
|
25
|
+
id: z.string(),
|
|
26
|
+
}),
|
|
27
|
+
}, ({ id }) => call(deps, async (host) => {
|
|
28
|
+
const meta = await host.readMeta(id);
|
|
29
|
+
const body = await host.read(id);
|
|
30
|
+
const keys = await host.listCards(id);
|
|
31
|
+
return { ...meta, body, keys };
|
|
32
|
+
}));
|
|
33
|
+
server.registerTool("create_memory", {
|
|
34
|
+
description: "Create a host memory with an id and description. The cover page starts empty.",
|
|
35
|
+
inputSchema: z.object({
|
|
36
|
+
id: z.string(),
|
|
37
|
+
description: z.string(),
|
|
38
|
+
}),
|
|
39
|
+
}, ({ id, description }) => call(deps, (host) => host.create({ id, description })));
|
|
40
|
+
server.registerTool("write_memory", {
|
|
41
|
+
description: "Replace the cover page of a host memory.",
|
|
42
|
+
inputSchema: z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
body: z.string(),
|
|
45
|
+
}),
|
|
46
|
+
}, ({ id, body }) => call(deps, async (host) => {
|
|
47
|
+
await host.replace(id, body);
|
|
48
|
+
const meta = await host.readMeta(id);
|
|
49
|
+
return { ...meta, body };
|
|
50
|
+
}));
|
|
51
|
+
server.registerTool("write_memory_card", {
|
|
52
|
+
description: "Replace an existing host memory card. A missing card is not created.",
|
|
53
|
+
inputSchema: z.object({
|
|
54
|
+
id: z.string(),
|
|
55
|
+
key: z.string(),
|
|
56
|
+
body: z.string(),
|
|
57
|
+
}),
|
|
58
|
+
}, ({ id, key, body }) => call(deps, async (host) => {
|
|
59
|
+
await host.updateCard(id, key, body);
|
|
60
|
+
return { body };
|
|
61
|
+
}));
|
|
62
|
+
server.registerTool("delete_memory_card", {
|
|
63
|
+
description: "Delete one card from a host memory.",
|
|
64
|
+
inputSchema: z.object({
|
|
65
|
+
id: z.string(),
|
|
66
|
+
key: z.string(),
|
|
67
|
+
}),
|
|
68
|
+
}, ({ id, key }) => call(deps, async (host) => {
|
|
69
|
+
await host.deleteCard(id, key);
|
|
70
|
+
return { removed: true };
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
@@ -88,7 +88,20 @@ export function registerPipelineAuthorTools(server, deps) {
|
|
|
88
88
|
}, ({ path: relPath, allow_invalid, ...args }) => mutate(relPath, "overwrite", (draft) => buildCreateStageDraft(draft, args), { allowInvalid: allow_invalid }));
|
|
89
89
|
server.registerTool("edit_stage", {
|
|
90
90
|
description: "Edit an existing stage on disk by id: body fields and/or its pipeline entry (route, entry, uses).",
|
|
91
|
-
inputSchema: z.
|
|
91
|
+
inputSchema: z.object({
|
|
92
|
+
path: pipelinePath,
|
|
93
|
+
id: z.string(),
|
|
94
|
+
patch: record.optional(),
|
|
95
|
+
body: record.optional(),
|
|
96
|
+
pipeline_entry: record.optional(),
|
|
97
|
+
entry: z.boolean().optional(),
|
|
98
|
+
route: z.array(record).optional(),
|
|
99
|
+
uses: z.string().optional(),
|
|
100
|
+
system_prompt: z.string().optional(),
|
|
101
|
+
model: z.string().optional(),
|
|
102
|
+
io: record.optional(),
|
|
103
|
+
allow_invalid: allowInvalid,
|
|
104
|
+
}),
|
|
92
105
|
}, ({ path: relPath, allow_invalid, ...args }) => mutate(relPath, "overwrite", (draft) => buildEditStageDraft(draft, args), { allowInvalid: allow_invalid }));
|
|
93
106
|
server.registerTool("create_task", {
|
|
94
107
|
description: "Create or replace the task beside a pipeline on disk (id and goal, optional body).",
|
package/dist/mcp/server.js
CHANGED
|
@@ -50,6 +50,11 @@ function toolDepsFrom(deps) {
|
|
|
50
50
|
? { agentConversationBackend: deps.agentConversationBackend }
|
|
51
51
|
: {}),
|
|
52
52
|
...(deps.evalRunManager !== undefined ? { evalRunManager: deps.evalRunManager } : {}),
|
|
53
|
+
...(deps.evalEngineStatus !== undefined ? { evalEngineStatus: deps.evalEngineStatus } : {}),
|
|
54
|
+
...(deps.triage !== undefined ? { triage: deps.triage } : {}),
|
|
55
|
+
...(deps.channels !== undefined ? { channels: deps.channels } : {}),
|
|
56
|
+
...(deps.memories !== undefined ? { memories: deps.memories } : {}),
|
|
57
|
+
...(deps.issueFetch !== undefined ? { issueFetch: deps.issueFetch } : {}),
|
|
53
58
|
};
|
|
54
59
|
}
|
|
55
60
|
function attachBusNotifications(server, bus) {
|
package/dist/mcp/tools.js
CHANGED
|
@@ -10,7 +10,10 @@ import { registerTriggerTools } from "./triggerTools.js";
|
|
|
10
10
|
import { textResult } from "./toolResults.js";
|
|
11
11
|
import { DEFAULT_TIMEOUT_MS, waitRun } from "./waitRun.js";
|
|
12
12
|
import { registerAgentTools } from "./agentTools.js";
|
|
13
|
+
import { registerCatalogWriteTools } from "./catalogWriteTools.js";
|
|
14
|
+
import { registerConnectionTools } from "./connectionTools.js";
|
|
13
15
|
import { registerGetStartedTool } from "./getStartedTool.js";
|
|
16
|
+
import { registerMemoryHostTools } from "./memoryHostTools.js";
|
|
14
17
|
export function registerMcpTools(server, deps) {
|
|
15
18
|
const { store } = deps;
|
|
16
19
|
registerGetStartedTool(server, deps);
|
|
@@ -22,6 +25,9 @@ export function registerMcpTools(server, deps) {
|
|
|
22
25
|
registerTriggerTools(server, deps);
|
|
23
26
|
registerEvalTools(server, deps);
|
|
24
27
|
registerPipelineAuthorTools(server, deps);
|
|
28
|
+
registerCatalogWriteTools(server, deps);
|
|
29
|
+
registerConnectionTools(server, deps);
|
|
30
|
+
registerMemoryHostTools(server, deps);
|
|
25
31
|
registerAgentTools(server, deps);
|
|
26
32
|
server.registerTool("wait_run", {
|
|
27
33
|
description: "Long-poll until a run is waiting for HITL input and/or terminal (succeeded/failed), or until timeout_ms. Default until=any wakes on waiting OR terminal. Abort cancels only this wait (not the run). Optional notifications/progress when the client supplies _meta.progressToken. Compose: wait_run → answer_gate → wait_run.",
|
package/dist/mcp/triggerTools.js
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { CatalogPathError, catalogPathErrorBody, resolveWritableCatalogRoot, } from "../config/catalogRelativePath.js";
|
|
3
3
|
import { createTrigger, parseCreateTriggerBody } from "../config/createTrigger.js";
|
|
4
4
|
import { parsePatchTriggerBody, parsePutTriggerBody, updateTriggerDefinition, updateTriggerEnabled } from "../config/updateTrigger.js";
|
|
5
|
+
import { readTriggerAdapterStatus } from "../config/triggerAdapterStatus.js";
|
|
5
6
|
import { loadCatalogTriggers } from "../config/triggerCatalog.js";
|
|
6
7
|
import { writeAudit } from "../logging/audit.js";
|
|
7
8
|
import { logger as rootLogger } from "../logging/logger.js";
|
|
@@ -41,23 +42,58 @@ const triggerEventSchema = z.object({
|
|
|
41
42
|
match: z.record(z.string(), z.unknown()).optional(),
|
|
42
43
|
config: z.record(z.string(), z.unknown()).optional(),
|
|
43
44
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
function findListedTrigger(items, id, projectRoot) {
|
|
46
|
+
if (projectRoot) {
|
|
47
|
+
const found = items.find((item) => item.id === id && item.project_root === projectRoot);
|
|
48
|
+
if (!found)
|
|
49
|
+
return { error: `Trigger not found: ${id}`, status: 404 };
|
|
50
|
+
return found;
|
|
51
|
+
}
|
|
52
|
+
const matches = items.filter((item) => item.id === id);
|
|
53
|
+
if (matches.length === 0)
|
|
54
|
+
return { error: `Trigger not found: ${id}`, status: 404 };
|
|
55
|
+
if (matches.length > 1) {
|
|
56
|
+
return {
|
|
57
|
+
error: `Trigger id is ambiguous across catalog roots: ${id}`,
|
|
58
|
+
status: 409,
|
|
59
|
+
project_roots: [...new Set(matches.map((item) => item.project_root))].sort((a, b) => a.localeCompare(b)),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return matches[0];
|
|
63
|
+
}
|
|
64
|
+
const triggerProjectRoot = z
|
|
65
|
+
.string()
|
|
66
|
+
.optional()
|
|
67
|
+
.describe("Catalog project root to write into; required when multiple catalog roots are configured and no sole non-seeded root exists");
|
|
68
|
+
const triggerTask = z
|
|
69
|
+
.string()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("Catalog task id; omit to create a dynamic-mode trigger whose task is supplied at fire time");
|
|
72
|
+
const createTriggerBase = {
|
|
73
|
+
project_root: triggerProjectRoot,
|
|
49
74
|
directory: z.string(),
|
|
50
75
|
id: z.string(),
|
|
51
76
|
pipeline: z.string(),
|
|
52
|
-
task:
|
|
53
|
-
.string()
|
|
54
|
-
.optional()
|
|
55
|
-
.describe("Catalog task id; omit to create a dynamic-mode trigger whose task is supplied at fire time"),
|
|
56
|
-
kind: z.enum(["manual", "schedule", "event"]),
|
|
57
|
-
schedule: triggerScheduleSchema.optional(),
|
|
58
|
-
event: triggerEventSchema.optional(),
|
|
77
|
+
task: triggerTask,
|
|
59
78
|
enabled: z.boolean().optional(),
|
|
60
|
-
}
|
|
79
|
+
};
|
|
80
|
+
const createTriggerSchema = z.discriminatedUnion("kind", [
|
|
81
|
+
z.object({ ...createTriggerBase, kind: z.literal("manual") }),
|
|
82
|
+
z.object({ ...createTriggerBase, kind: z.literal("schedule"), schedule: triggerScheduleSchema }),
|
|
83
|
+
z.object({ ...createTriggerBase, kind: z.literal("event"), event: triggerEventSchema }),
|
|
84
|
+
]);
|
|
85
|
+
const updateTriggerBase = {
|
|
86
|
+
id: z.string(),
|
|
87
|
+
project_root: z.string().optional(),
|
|
88
|
+
pipeline: z.string(),
|
|
89
|
+
task: z.string().optional(),
|
|
90
|
+
enabled: z.boolean(),
|
|
91
|
+
};
|
|
92
|
+
const updateTriggerSchema = z.discriminatedUnion("kind", [
|
|
93
|
+
z.object({ ...updateTriggerBase, kind: z.literal("manual") }),
|
|
94
|
+
z.object({ ...updateTriggerBase, kind: z.literal("schedule"), schedule: triggerScheduleSchema }),
|
|
95
|
+
z.object({ ...updateTriggerBase, kind: z.literal("event"), event: triggerEventSchema }),
|
|
96
|
+
]);
|
|
61
97
|
export function registerTriggerTools(server, deps) {
|
|
62
98
|
const { store, cwd, manager } = deps;
|
|
63
99
|
server.registerTool("list_triggers", {
|
|
@@ -65,32 +101,51 @@ export function registerTriggerTools(server, deps) {
|
|
|
65
101
|
inputSchema: z.object({}),
|
|
66
102
|
}, async () => {
|
|
67
103
|
const items = await loadCatalogTriggers({ store, bootCwd: cwd });
|
|
68
|
-
|
|
104
|
+
const triggers = await Promise.all(items.map(async (item) => ({
|
|
105
|
+
...item,
|
|
106
|
+
adapter_status: await readTriggerAdapterStatus(item, store),
|
|
107
|
+
})));
|
|
108
|
+
return textResult({ triggers });
|
|
69
109
|
});
|
|
70
110
|
server.registerTool("get_trigger", {
|
|
71
111
|
description: "Look up one catalog trigger by id (same source as GET /api/triggers/:id).",
|
|
72
112
|
inputSchema: z.object({
|
|
73
113
|
id: z.string(),
|
|
114
|
+
project_root: z
|
|
115
|
+
.string()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe("Catalog project root; required when the same trigger id exists in more than one root"),
|
|
74
118
|
}),
|
|
75
|
-
}, async ({ id }) => {
|
|
119
|
+
}, async ({ id, project_root }) => {
|
|
76
120
|
const items = await loadCatalogTriggers({ store, bootCwd: cwd });
|
|
77
|
-
const found = items
|
|
78
|
-
if (
|
|
79
|
-
return textResult({ error:
|
|
121
|
+
const found = findListedTrigger(items, id, project_root);
|
|
122
|
+
if ("error" in found) {
|
|
123
|
+
return textResult({ error: found.error, status: found.status, ...(found.project_roots ? { project_roots: found.project_roots } : {}) }, true);
|
|
80
124
|
}
|
|
81
|
-
return textResult(
|
|
125
|
+
return textResult({
|
|
126
|
+
...found,
|
|
127
|
+
adapter_status: await readTriggerAdapterStatus(found, store),
|
|
128
|
+
});
|
|
82
129
|
});
|
|
83
130
|
server.registerTool("fire_trigger", {
|
|
84
131
|
description: "Fire a catalog trigger by id: resolves its pipeline/task refs and starts a run through the same RunManager.startRun path as start_run (same as POST /api/triggers/:id/fire). Returns { runId } or { runId, queued: true, queuePosition }. Fails not_found (404) for an unknown id, or 409 when the trigger is disabled.",
|
|
85
132
|
inputSchema: z.object({
|
|
86
133
|
id: z.string(),
|
|
134
|
+
project_root: z
|
|
135
|
+
.string()
|
|
136
|
+
.optional()
|
|
137
|
+
.describe("Catalog project root; required when the same trigger id exists in more than one root"),
|
|
87
138
|
task: taskFileSchema
|
|
88
139
|
.optional()
|
|
89
140
|
.describe("Inline TaskFile, required to fire a dynamic-mode trigger (no catalog task) and rejected for a catalog-mode trigger"),
|
|
90
141
|
}),
|
|
91
|
-
}, async ({ id, task }) => {
|
|
142
|
+
}, async ({ id, task, project_root }) => {
|
|
92
143
|
const callerId = callerIdFromRequestAuth();
|
|
93
|
-
const result = await fireTrigger(id, store, manager, {
|
|
144
|
+
const result = await fireTrigger(id, store, manager, {
|
|
145
|
+
cwd,
|
|
146
|
+
task,
|
|
147
|
+
...(project_root ? { project_root } : {}),
|
|
148
|
+
});
|
|
94
149
|
if (!result.ok) {
|
|
95
150
|
writeAudit(auditLog, {
|
|
96
151
|
caller_id: callerId,
|
|
@@ -170,16 +225,7 @@ export function registerTriggerTools(server, deps) {
|
|
|
170
225
|
});
|
|
171
226
|
server.registerTool("update_trigger", {
|
|
172
227
|
description: "Replace a trigger's definition (pipeline, task, kind, schedule or event, enabled). Same validation and write path as PUT /api/triggers/:id; the id cannot change.",
|
|
173
|
-
inputSchema:
|
|
174
|
-
id: z.string(),
|
|
175
|
-
project_root: z.string().optional(),
|
|
176
|
-
pipeline: z.string(),
|
|
177
|
-
task: z.string().optional(),
|
|
178
|
-
kind: z.enum(["manual", "schedule", "event"]),
|
|
179
|
-
schedule: triggerScheduleSchema.optional(),
|
|
180
|
-
event: triggerEventSchema.optional(),
|
|
181
|
-
enabled: z.boolean().optional(),
|
|
182
|
-
}),
|
|
228
|
+
inputSchema: updateTriggerSchema,
|
|
183
229
|
}, async ({ id, project_root, ...body }) => {
|
|
184
230
|
const parsed = parsePutTriggerBody(body, id);
|
|
185
231
|
if ("ok" in parsed)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type EvalToolCallRecord, type EvalToolPolicy } from "../agents/evalGate.js";
|
|
2
|
+
import type { OperatorAgentToolResult } from "./types.js";
|
|
3
|
+
export type OperatorEvalPolicy = {
|
|
4
|
+
tools: EvalToolPolicy;
|
|
5
|
+
mocks: Record<string, {
|
|
6
|
+
result?: unknown;
|
|
7
|
+
error?: string;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Tool gate for an eval of a built-in operator agent. Reads may run. Writes, sends and deletes
|
|
12
|
+
* are stubbed or mocked and never reach the handler. `real` is treated as read-only: these
|
|
13
|
+
* agents write the operator's own project, so an eval cannot opt into that.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createOperatorEvalGate(options: {
|
|
16
|
+
policy: OperatorEvalPolicy;
|
|
17
|
+
turn: () => number;
|
|
18
|
+
}): {
|
|
19
|
+
decide(name: string, args: Record<string, unknown>): OperatorAgentToolResult | null;
|
|
20
|
+
observe(name: string, result: OperatorAgentToolResult): void;
|
|
21
|
+
records(): EvalToolCallRecord[];
|
|
22
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { STUB_RESULT } from "../agents/evalGate.js";
|
|
3
|
+
import { TOOL_META } from "../toolkit/meta.js";
|
|
4
|
+
const ALWAYS_BLOCKED = new Set([
|
|
5
|
+
"run_eval",
|
|
6
|
+
"agent_chat",
|
|
7
|
+
"fire_trigger",
|
|
8
|
+
"sort_eval_failures",
|
|
9
|
+
"cancel_eval_run",
|
|
10
|
+
"start_run",
|
|
11
|
+
"run_stage",
|
|
12
|
+
"rerun",
|
|
13
|
+
"retry_stage",
|
|
14
|
+
"resume_stage",
|
|
15
|
+
"delete_run",
|
|
16
|
+
"cancel_run",
|
|
17
|
+
"gc_runs",
|
|
18
|
+
"remove_connection",
|
|
19
|
+
"delete_eval_run",
|
|
20
|
+
"delete_memory_card",
|
|
21
|
+
"archive_agent",
|
|
22
|
+
"enable_agent",
|
|
23
|
+
"set_trigger_enabled",
|
|
24
|
+
"test_connection",
|
|
25
|
+
"import_task_file",
|
|
26
|
+
"probe_project_mcp",
|
|
27
|
+
]);
|
|
28
|
+
/** Tools that only talk to the person or read Stageflow's own docs. They never change the project. */
|
|
29
|
+
const SAFE = new Set(["confirm_action", "show_ui", "list_guide_topics", "read_guide_topic"]);
|
|
30
|
+
/**
|
|
31
|
+
* Tool gate for an eval of a built-in operator agent. Reads may run. Writes, sends and deletes
|
|
32
|
+
* are stubbed or mocked and never reach the handler. `real` is treated as read-only: these
|
|
33
|
+
* agents write the operator's own project, so an eval cannot opt into that.
|
|
34
|
+
*/
|
|
35
|
+
export function createOperatorEvalGate(options) {
|
|
36
|
+
const records = [];
|
|
37
|
+
let pending;
|
|
38
|
+
const push = (record) => {
|
|
39
|
+
records.push(record);
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
decide(name, args) {
|
|
43
|
+
const base = { id: randomUUID(), turn: options.turn(), name, args };
|
|
44
|
+
const mock = options.policy.mocks[name];
|
|
45
|
+
const deny = (result, policyOutcome) => {
|
|
46
|
+
push({ ...base, policyOutcome, status: "not_run", result });
|
|
47
|
+
return { ok: false, error: "eval.tool_not_run", content: { error: "eval.tool_not_run", message: result } };
|
|
48
|
+
};
|
|
49
|
+
if (ALWAYS_BLOCKED.has(name))
|
|
50
|
+
return deny(`${name} cannot run in an evaluation.`, "denied");
|
|
51
|
+
if (mock && (options.policy.tools === "mocked" || !mayRun(name))) {
|
|
52
|
+
const text = mock.error ?? (typeof mock.result === "string" ? mock.result : JSON.stringify(mock.result ?? null));
|
|
53
|
+
push({ ...base, policyOutcome: "mocked", status: mock.error !== undefined ? "error" : "ok", result: text });
|
|
54
|
+
return { ok: mock.error === undefined, ...(mock.error !== undefined ? { error: mock.error } : {}), content: mock.result ?? mock.error };
|
|
55
|
+
}
|
|
56
|
+
if (!mayRun(name))
|
|
57
|
+
return deny(STUB_RESULT(name), "stubbed");
|
|
58
|
+
pending = { ...base, policyOutcome: "ran", status: "ok" };
|
|
59
|
+
push(pending);
|
|
60
|
+
return null;
|
|
61
|
+
},
|
|
62
|
+
observe(_name, result) {
|
|
63
|
+
if (!pending)
|
|
64
|
+
return;
|
|
65
|
+
pending.result = typeof result.content === "string" ? result.content : JSON.stringify(result.content ?? null);
|
|
66
|
+
if (!result.ok)
|
|
67
|
+
pending.status = "error";
|
|
68
|
+
pending = undefined;
|
|
69
|
+
},
|
|
70
|
+
records: () => records,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function mayRun(name) {
|
|
74
|
+
if (SAFE.has(name))
|
|
75
|
+
return true;
|
|
76
|
+
return TOOL_META[name]?.risk === "read";
|
|
77
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createOperatorAgentHost, invokeProfileTool, } from "./host.js";
|
|
2
2
|
import { createAgentAuthorProfile } from "./profiles/agentAuthor.js";
|
|
3
|
+
import { createStageflowGuideProfile } from "./profiles/stageflowGuide.js";
|
|
3
4
|
import { createWorkshopAuthorProfile, isTaskProposalIntent, proposeStageFromUserMessage, proposeTaskFromUserMessage, WORKSHOP_AUTHOR_PROFILE_ID, } from "./profiles/workshopAuthor.js";
|
|
4
5
|
/**
|
|
5
6
|
* Deterministic Operator Agent Host for Workshop and tests.
|
|
@@ -8,7 +9,7 @@ import { createWorkshopAuthorProfile, isTaskProposalIntent, proposeStageFromUser
|
|
|
8
9
|
export function createFakeOperatorAgentModel(script = [{ type: "propose_stage" }]) {
|
|
9
10
|
let index = 0;
|
|
10
11
|
return {
|
|
11
|
-
async complete({ profile, message, tools }) {
|
|
12
|
+
async complete({ profile, message, tools, onActivity }) {
|
|
12
13
|
const turn = script[Math.min(index, script.length - 1)] ?? {
|
|
13
14
|
type: "propose_stage",
|
|
14
15
|
};
|
|
@@ -28,7 +29,13 @@ export function createFakeOperatorAgentModel(script = [{ type: "propose_stage" }
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
if (turn.type === "call_tool") {
|
|
31
|
-
const
|
|
32
|
+
const args = turn.args ?? {};
|
|
33
|
+
const callId = `${turn.name}-${index}`;
|
|
34
|
+
onActivity?.({ id: callId, name: turn.name, status: "running", args });
|
|
35
|
+
const result = await invokeProfileTool(profile, turn.name, args, tools);
|
|
36
|
+
onActivity?.(result.ok
|
|
37
|
+
? { id: callId, name: turn.name, status: "complete", result: result.content }
|
|
38
|
+
: { id: callId, name: turn.name, status: "error", errorMessage: result.error ?? "unknown error" });
|
|
32
39
|
const events = [
|
|
33
40
|
{ type: "tool_result", name: turn.name, result },
|
|
34
41
|
];
|
|
@@ -88,6 +95,7 @@ export function createWorkshopOperatorHost(scriptOrOptions) {
|
|
|
88
95
|
projectRoot: options.projectRoot,
|
|
89
96
|
}),
|
|
90
97
|
createAgentAuthorProfile(),
|
|
98
|
+
createStageflowGuideProfile(),
|
|
91
99
|
]);
|
|
92
100
|
return host;
|
|
93
101
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { profileMayUse } from "../toolkit/profiles.js";
|
|
2
2
|
import { enrichProposal, isMutationConflict, operatorContextFingerprint, UNDO_MUTATION_CONFLICT_NOTICE, } from "./proposals.js";
|
|
3
3
|
import { rejectUnlinkedWorkshopDraftTool } from "../workshop/workshopPin.js";
|
|
4
|
-
function createSession(profile, initialContext, model) {
|
|
4
|
+
function createSession(profile, initialContext, model, evalGate) {
|
|
5
5
|
let context = initialContext;
|
|
6
6
|
let closed = false;
|
|
7
7
|
const mutations = new Map();
|
|
@@ -23,6 +23,7 @@ function createSession(profile, initialContext, model) {
|
|
|
23
23
|
lastMutationId = applied.id;
|
|
24
24
|
lastEmitted = applied;
|
|
25
25
|
},
|
|
26
|
+
...(evalGate ? { evalGate } : {}),
|
|
26
27
|
};
|
|
27
28
|
function resolveMutation(mutationId) {
|
|
28
29
|
if (mutations.size === 0)
|
|
@@ -165,6 +166,16 @@ export function createOperatorAgentHost(model, seedProfiles = []) {
|
|
|
165
166
|
}
|
|
166
167
|
return createSession(profile, context, model);
|
|
167
168
|
},
|
|
169
|
+
openEvalSession({ profileId, context, gate }) {
|
|
170
|
+
if (!gate) {
|
|
171
|
+
throw new Error("An internal-agent eval session requires a tool gate");
|
|
172
|
+
}
|
|
173
|
+
const profile = profiles.get(profileId);
|
|
174
|
+
if (!profile) {
|
|
175
|
+
throw new Error(`Unknown operator agent profile: ${profileId}`);
|
|
176
|
+
}
|
|
177
|
+
return createSession(profile, context, model, gate);
|
|
178
|
+
},
|
|
168
179
|
};
|
|
169
180
|
}
|
|
170
181
|
export async function invokeProfileTool(profile, name, args, ctx) {
|
|
@@ -178,5 +189,10 @@ export async function invokeProfileTool(profile, name, args, ctx) {
|
|
|
178
189
|
const blocked = rejectUnlinkedWorkshopDraftTool(ctx.getContext(), name);
|
|
179
190
|
if (blocked)
|
|
180
191
|
return blocked;
|
|
181
|
-
|
|
192
|
+
const refused = ctx.evalGate?.decide(name, args);
|
|
193
|
+
if (refused)
|
|
194
|
+
return refused;
|
|
195
|
+
const result = await tool.handler(args, ctx);
|
|
196
|
+
ctx.evalGate?.observe(name, result);
|
|
197
|
+
return result;
|
|
182
198
|
}
|
|
@@ -6,6 +6,7 @@ export { createLiveWorkshopOperatorHost, createPiOperatorAgentModel, type LiveWo
|
|
|
6
6
|
export { createFailingDocsRetriever, createFilesystemDocsRetriever, createStubDocsRetriever, resolveWorkshopCatalogRoot, type DocsRetrievalHit, type DocsRetrievalResult, type DocsRetriever, } from "./docsRetrieval.js";
|
|
7
7
|
export { agentAuthorContextAdapter, emptyAgentAuthorDraft, isAgentAuthorContext, readAgentAuthorDraft, AGENT_AUTHOR_GREETING, type AgentAuthorContext, type AgentAuthorDraft, } from "./agentAuthorContext.js";
|
|
8
8
|
export { AGENT_AUTHOR_PROFILE_ID, AGENT_AUTHOR_TOOL_NAMES, createAgentAuthorContext, createAgentAuthorProfile, } from "./profiles/agentAuthor.js";
|
|
9
|
+
export { STAGEFLOW_GUIDE_GREETING, STAGEFLOW_GUIDE_PLAYBOOK, STAGEFLOW_GUIDE_PROFILE_ID, STAGEFLOW_GUIDE_TOOL_NAMES, createStageflowGuideProfile, } from "./profiles/stageflowGuide.js";
|
|
9
10
|
export { AGENT_AUTHOR_PLAYBOOK } from "./profiles/agentAuthorPlaybook.js";
|
|
10
11
|
export { operatorContextFingerprint } from "./proposals.js";
|
|
11
12
|
export { createWorkshopDraftContext, draftTrackStages, emptyDraftPackage, isWorkshopDraftContext, readDraftFromContext, withDestination, withDraft, withProjectRoot, workshopDraftContextAdapter, WORKSHOP_AUTHOR_GREETING, } from "./draftContext.js";
|
|
@@ -5,6 +5,7 @@ export { createLiveWorkshopOperatorHost, createPiOperatorAgentModel, } from "./p
|
|
|
5
5
|
export { createFailingDocsRetriever, createFilesystemDocsRetriever, createStubDocsRetriever, resolveWorkshopCatalogRoot, } from "./docsRetrieval.js";
|
|
6
6
|
export { agentAuthorContextAdapter, emptyAgentAuthorDraft, isAgentAuthorContext, readAgentAuthorDraft, AGENT_AUTHOR_GREETING, } from "./agentAuthorContext.js";
|
|
7
7
|
export { AGENT_AUTHOR_PROFILE_ID, AGENT_AUTHOR_TOOL_NAMES, createAgentAuthorContext, createAgentAuthorProfile, } from "./profiles/agentAuthor.js";
|
|
8
|
+
export { STAGEFLOW_GUIDE_GREETING, STAGEFLOW_GUIDE_PLAYBOOK, STAGEFLOW_GUIDE_PROFILE_ID, STAGEFLOW_GUIDE_TOOL_NAMES, createStageflowGuideProfile, } from "./profiles/stageflowGuide.js";
|
|
8
9
|
export { AGENT_AUTHOR_PLAYBOOK } from "./profiles/agentAuthorPlaybook.js";
|
|
9
10
|
export { operatorContextFingerprint } from "./proposals.js";
|
|
10
11
|
export { createWorkshopDraftContext, draftTrackStages, emptyDraftPackage, isWorkshopDraftContext, readDraftFromContext, withDestination, withDraft, withProjectRoot, workshopDraftContextAdapter, WORKSHOP_AUTHOR_GREETING, } from "./draftContext.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OperatorAgentHost } from "./types.js";
|
|
2
|
+
export declare const SHOW_INTERNAL_AGENTS_ENV = "STAGEFLOW_SHOW_INTERNAL_AGENTS";
|
|
3
|
+
export type InternalAgentInfo = {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
greeting?: string;
|
|
7
|
+
playbook: string;
|
|
8
|
+
tools: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare function internalAgentsVisible(env?: NodeJS.ProcessEnv): boolean;
|
|
11
|
+
export declare function describeInternalAgents(host: OperatorAgentHost): InternalAgentInfo[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const SHOW_INTERNAL_AGENTS_ENV = "STAGEFLOW_SHOW_INTERNAL_AGENTS";
|
|
2
|
+
export function internalAgentsVisible(env = process.env) {
|
|
3
|
+
return env[SHOW_INTERNAL_AGENTS_ENV] === "1";
|
|
4
|
+
}
|
|
5
|
+
export function describeInternalAgents(host) {
|
|
6
|
+
return host.listProfiles().map((profile) => ({
|
|
7
|
+
id: profile.id,
|
|
8
|
+
title: profile.title,
|
|
9
|
+
...(profile.greeting !== undefined ? { greeting: profile.greeting } : {}),
|
|
10
|
+
playbook: profile.playbook,
|
|
11
|
+
tools: profile.tools.map((tool) => tool.name),
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AgentSession, defineTool, SessionManager } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import "../agent/cursorProvider.js";
|
|
3
|
+
import type { McpToolDeps } from "../mcp/deps.js";
|
|
3
4
|
import { type OperatorAgentModel } from "./host.js";
|
|
4
5
|
import { type WorkshopAuthorProfileOptions } from "./profiles/workshopAuthor.js";
|
|
5
6
|
import type { OperatorAgentHost, OperatorAgentProfile, OperatorAgentToolContext, OperatorAgentToolResult, WorkshopToolActivityUpdate } from "./types.js";
|
|
@@ -76,5 +77,8 @@ export declare function workshopToolActivity(id: string, name: string, phase: "s
|
|
|
76
77
|
* Pi OperatorAgentModel: durable session per host tool-context, Workshop tools only.
|
|
77
78
|
*/
|
|
78
79
|
export declare function createPiOperatorAgentModel(options: PiOperatorAgentModelOptions): PiOperatorAgentModel;
|
|
79
|
-
export type LiveWorkshopOperatorHostOptions = WorkshopAuthorProfileOptions & PiOperatorAgentModelOptions
|
|
80
|
+
export type LiveWorkshopOperatorHostOptions = WorkshopAuthorProfileOptions & PiOperatorAgentModelOptions & {
|
|
81
|
+
/** When set, Guide can call the Stageflow catalog. Without it, Guide only talks. */
|
|
82
|
+
guideDeps?: McpToolDeps;
|
|
83
|
+
};
|
|
80
84
|
export declare function createLiveWorkshopOperatorHost(options: LiveWorkshopOperatorHostOptions): OperatorAgentHost;
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { mkdir } from "node:fs/promises";
|
|
10
10
|
import path from "node:path";
|
|
11
|
-
import { defineTool, ModelRuntime, resolveCliModel, SessionManager,
|
|
12
|
-
import { Type } from "typebox";
|
|
11
|
+
import { defineTool, ModelRuntime, resolveCliModel, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
13
12
|
import { createPiAgentSession, createSealedResourceLoader, resolveWorkshopToolNames, } from "../agent/piSessionFactory.js";
|
|
13
|
+
import { createPiSettingsManager } from "../agent/piSettings.js";
|
|
14
|
+
import { createSessionContextWiring } from "../compaction/sessionWiring.js";
|
|
14
15
|
import { bindCursorApiKey, cursorBridgePrompt, isCursorModelRef } from "../agent/cursorProvider.js";
|
|
15
16
|
import { findProviderSupport } from "../agent/providerSupport.js";
|
|
16
17
|
import "../agent/cursorProvider.js";
|
|
@@ -20,6 +21,7 @@ import { isUsableAuthFile, resolveCredentialBinding, } from "../runtime/credenti
|
|
|
20
21
|
import { resolveWorkshopModel } from "../workshop/modelSettings.js";
|
|
21
22
|
import { createOperatorAgentHost, invokeProfileTool, } from "./host.js";
|
|
22
23
|
import { AGENT_AUTHOR_PROFILE_ID, agentAuthorBridgeHint, createAgentAuthorProfile, formatAgentAuthorTurnPrompt, } from "./profiles/agentAuthor.js";
|
|
24
|
+
import { createStageflowGuideProfile } from "./profiles/stageflowGuide.js";
|
|
23
25
|
import { createWorkshopAuthorProfile, } from "./profiles/workshopAuthor.js";
|
|
24
26
|
import { readDraftFromContext } from "./draftContext.js";
|
|
25
27
|
export function sessionNeedsExtensionReload(loaded, needed) {
|
|
@@ -37,7 +39,6 @@ function extensionPathsForModel(modelId) {
|
|
|
37
39
|
return [];
|
|
38
40
|
return prepared.extensionPaths;
|
|
39
41
|
}
|
|
40
|
-
const FLEX_PARAMS = Type.Object({}, { additionalProperties: true });
|
|
41
42
|
const workshopLog = rootLogger.child({ component: "workshop" });
|
|
42
43
|
export function workshopToolLogFields(args, result) {
|
|
43
44
|
const body = args.body;
|
|
@@ -106,7 +107,8 @@ function buildWorkshopCustomTools(profileTools, getProfile, getTools, onToolResu
|
|
|
106
107
|
name: tool.name,
|
|
107
108
|
label: tool.name,
|
|
108
109
|
description: tool.description,
|
|
109
|
-
parameters:
|
|
110
|
+
parameters: tool.parameters,
|
|
111
|
+
constrainedSampling: { type: "json_schema", strict: "prefer" },
|
|
110
112
|
execute: async (_toolCallId, params) => {
|
|
111
113
|
const args = params !== null && typeof params === "object" && !Array.isArray(params)
|
|
112
114
|
? params
|
|
@@ -119,6 +121,7 @@ function buildWorkshopCustomTools(profileTools, getProfile, getTools, onToolResu
|
|
|
119
121
|
reportActivity({
|
|
120
122
|
...workshopToolActivity(callId, tool.name, "start", args),
|
|
121
123
|
...(pinnedBuildId ? { buildId: pinnedBuildId } : {}),
|
|
124
|
+
args,
|
|
122
125
|
});
|
|
123
126
|
const result = await invokeProfileTool(getProfile(), tool.name, args, getTools());
|
|
124
127
|
const fields = workshopToolLogFields(args, result);
|
|
@@ -136,6 +139,7 @@ function buildWorkshopCustomTools(profileTools, getProfile, getTools, onToolResu
|
|
|
136
139
|
...update,
|
|
137
140
|
draft,
|
|
138
141
|
...(doneBuildId ? { buildId: doneBuildId } : {}),
|
|
142
|
+
result: result.content,
|
|
139
143
|
});
|
|
140
144
|
}
|
|
141
145
|
else {
|
|
@@ -225,14 +229,14 @@ async function openDefaultPiSession(input) {
|
|
|
225
229
|
authPath: input.authPath,
|
|
226
230
|
modelsPath: path.join(path.dirname(input.authPath), "models.json"),
|
|
227
231
|
});
|
|
228
|
-
const settingsManager =
|
|
229
|
-
|
|
230
|
-
});
|
|
232
|
+
const settingsManager = createPiSettingsManager();
|
|
233
|
+
const contextWiring = createSessionContextWiring({ workingState: true });
|
|
231
234
|
const loader = createSealedResourceLoader({
|
|
232
235
|
cwd: input.cwd,
|
|
233
236
|
agentDir: input.agentDir,
|
|
234
237
|
settingsManager,
|
|
235
|
-
systemPrompt: input.systemPrompt,
|
|
238
|
+
systemPrompt: contextWiring.guidance ? `${input.systemPrompt}\n\n${contextWiring.guidance}` : input.systemPrompt,
|
|
239
|
+
extensionFactories: contextWiring.extensions,
|
|
236
240
|
...(additionalExtensionPaths.length > 0
|
|
237
241
|
? { additionalExtensionPaths }
|
|
238
242
|
: {}),
|
|
@@ -257,7 +261,7 @@ async function openDefaultPiSession(input) {
|
|
|
257
261
|
sessionManager,
|
|
258
262
|
settingsManager,
|
|
259
263
|
resourceLoader: loader,
|
|
260
|
-
tools: input.toolNames,
|
|
264
|
+
tools: [...input.toolNames, ...contextWiring.toolNames],
|
|
261
265
|
customTools: input.customTools,
|
|
262
266
|
});
|
|
263
267
|
session = created.session;
|
|
@@ -542,7 +546,7 @@ export function createPiOperatorAgentModel(options) {
|
|
|
542
546
|
return model;
|
|
543
547
|
}
|
|
544
548
|
export function createLiveWorkshopOperatorHost(options) {
|
|
545
|
-
const { cwd, agentDir, authPath, model, settingsDefault, profileDefault, piSessionDir, openPiSession, resolveModelId, retriever, projectRoot, } = options;
|
|
549
|
+
const { cwd, agentDir, authPath, model, settingsDefault, profileDefault, piSessionDir, openPiSession, resolveModelId, retriever, projectRoot, guideDeps, } = options;
|
|
546
550
|
return createOperatorAgentHost(createPiOperatorAgentModel({
|
|
547
551
|
cwd,
|
|
548
552
|
...(agentDir !== undefined ? { agentDir } : {}),
|
|
@@ -559,5 +563,6 @@ export function createLiveWorkshopOperatorHost(options) {
|
|
|
559
563
|
...(projectRoot !== undefined ? { projectRoot } : {}),
|
|
560
564
|
}),
|
|
561
565
|
createAgentAuthorProfile(),
|
|
566
|
+
createStageflowGuideProfile(guideDeps),
|
|
562
567
|
]);
|
|
563
568
|
}
|