stageflow 0.36.0 → 0.40.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 +61 -26
- package/dist/agent/claudeAdapter.js +21 -1
- package/dist/agent/claudeTools.d.ts +13 -0
- package/dist/agent/claudeTools.js +98 -0
- package/dist/agent/piAdapter.d.ts +9 -1
- package/dist/agent/piAdapter.js +59 -18
- package/dist/agent/piIsolatedMcp.js +14 -2
- package/dist/agent/piIsolatedMcpProbe.d.ts +5 -1
- package/dist/agent/piIsolatedMcpProbe.js +16 -30
- package/dist/agent/port.d.ts +5 -0
- package/dist/agent/sandboxPiTools.d.ts +99 -0
- package/dist/agent/sandboxPiTools.js +109 -0
- package/dist/agents/agentId.d.ts +8 -0
- package/dist/agents/agentId.js +27 -0
- package/dist/agents/approvalBroker.d.ts +16 -0
- package/dist/agents/approvalBroker.js +45 -0
- package/dist/agents/authorChat.d.ts +19 -0
- package/dist/agents/authorChat.js +63 -0
- package/dist/agents/chatTurn.d.ts +23 -0
- package/dist/agents/chatTurn.js +77 -0
- package/dist/agents/communications/agentmail.d.ts +19 -0
- package/dist/agents/communications/agentmail.js +46 -0
- package/dist/agents/communications/agentmailListener.d.ts +59 -0
- package/dist/agents/communications/agentmailListener.js +183 -0
- package/dist/agents/communications/allowlist.d.ts +10 -0
- package/dist/agents/communications/allowlist.js +36 -0
- package/dist/agents/communications/channelConnections.d.ts +3 -0
- package/dist/agents/communications/channelConnections.js +51 -0
- package/dist/agents/communications/delivery.d.ts +53 -0
- package/dist/agents/communications/delivery.js +142 -0
- package/dist/agents/communications/email.d.ts +26 -0
- package/dist/agents/communications/email.js +20 -0
- package/dist/agents/communications/identity.d.ts +13 -0
- package/dist/agents/communications/identity.js +18 -0
- package/dist/agents/communications/imessageListener.d.ts +41 -0
- package/dist/agents/communications/imessageListener.js +92 -0
- package/dist/agents/communications/inbound.d.ts +63 -0
- package/dist/agents/communications/inbound.js +143 -0
- package/dist/agents/communications/listener.d.ts +36 -0
- package/dist/agents/communications/listener.js +38 -0
- package/dist/agents/communications/photon.d.ts +19 -0
- package/dist/agents/communications/photon.js +38 -0
- package/dist/agents/communications/port.d.ts +27 -0
- package/dist/agents/communications/port.js +6 -0
- package/dist/agents/communications/slack.d.ts +28 -0
- package/dist/agents/communications/slack.js +65 -0
- package/dist/agents/communications/supervisor.d.ts +36 -0
- package/dist/agents/communications/supervisor.js +96 -0
- package/dist/agents/communications/telegram.d.ts +19 -0
- package/dist/agents/communications/telegram.js +52 -0
- package/dist/agents/definitionSummary.d.ts +13 -0
- package/dist/agents/definitionSummary.js +91 -0
- package/dist/agents/delegate.d.ts +3 -0
- package/dist/agents/delegate.js +8 -0
- package/dist/agents/errors.d.ts +10 -0
- package/dist/agents/errors.js +32 -0
- package/dist/agents/guardrails.d.ts +24 -0
- package/dist/agents/guardrails.js +39 -0
- package/dist/agents/historyFit.d.ts +10 -0
- package/dist/agents/historyFit.js +26 -0
- package/dist/agents/hostContext.d.ts +54 -0
- package/dist/agents/hostContext.js +156 -0
- package/dist/agents/ledgers.d.ts +29 -0
- package/dist/agents/ledgers.js +31 -0
- package/dist/agents/lineDiff.d.ts +12 -0
- package/dist/agents/lineDiff.js +46 -0
- package/dist/agents/ndjson.d.ts +9 -0
- package/dist/agents/ndjson.js +47 -0
- package/dist/agents/otlpExport.d.ts +9 -0
- package/dist/agents/otlpExport.js +58 -0
- package/dist/agents/otlpSink.d.ts +7 -0
- package/dist/agents/otlpSink.js +23 -0
- package/dist/agents/policy.d.ts +31 -0
- package/dist/agents/policy.js +84 -0
- package/dist/agents/projectRoot.d.ts +5 -0
- package/dist/agents/projectRoot.js +15 -0
- package/dist/agents/runtime/piRuntime.d.ts +52 -0
- package/dist/agents/runtime/piRuntime.js +474 -0
- package/dist/agents/runtime/types.d.ts +77 -0
- package/dist/agents/runtime/types.js +26 -0
- package/dist/agents/sandbox.d.ts +17 -0
- package/dist/agents/sandbox.js +10 -0
- package/dist/agents/scheduleSource.d.ts +32 -0
- package/dist/agents/scheduleSource.js +100 -0
- package/dist/agents/service.d.ts +298 -0
- package/dist/agents/service.js +1105 -0
- package/dist/agents/sessions.d.ts +38 -0
- package/dist/agents/sessions.js +321 -0
- package/dist/agents/store.d.ts +277 -0
- package/dist/agents/store.js +643 -0
- package/dist/agents/trace.d.ts +27 -0
- package/dist/agents/trace.js +29 -0
- package/dist/agents/turnLifecycle.d.ts +72 -0
- package/dist/agents/turnLifecycle.js +157 -0
- package/dist/agents/webChat/publicChat.d.ts +36 -0
- package/dist/agents/webChat/publicChat.js +290 -0
- package/dist/agents/webChat/rateLimit.d.ts +15 -0
- package/dist/agents/webChat/rateLimit.js +33 -0
- package/dist/agents/webChat/slug.d.ts +2 -0
- package/dist/agents/webChat/slug.js +9 -0
- package/dist/channels/providers/agentmail.js +14 -1
- package/dist/channels/providers/photonImessage.js +36 -0
- package/dist/channels/providers/slack.js +2 -1
- package/dist/channels/providers/telegram.js +2 -1
- package/dist/channels/types.d.ts +27 -0
- package/dist/cli/agentsCommand.d.ts +14 -0
- package/dist/cli/agentsCommand.js +291 -0
- package/dist/cli.js +9 -0
- package/dist/config/browseCatalog.js +4 -11
- package/dist/config/draftPackage.d.ts +1 -0
- package/dist/config/draftPackage.js +4 -0
- package/dist/config/hostConfig.js +9 -0
- package/dist/config/loadAgent.d.ts +266 -0
- package/dist/config/loadAgent.js +374 -0
- package/dist/config/loadPipeline.js +5 -2
- package/dist/config/loadTask.js +34 -1
- package/dist/config/mcpHostCatalog.d.ts +50 -0
- package/dist/config/mcpHostCatalog.js +405 -0
- package/dist/config/mcpOAuth.d.ts +37 -0
- package/dist/config/mcpOAuth.js +263 -0
- package/dist/config/mcpRedaction.d.ts +42 -0
- package/dist/config/mcpRedaction.js +314 -0
- package/dist/config/mcpToolCache.d.ts +20 -0
- package/dist/config/mcpToolCache.js +43 -0
- package/dist/config/mergePipelineIncludes.d.ts +2 -0
- package/dist/config/mergePipelineIncludes.js +25 -0
- package/dist/config/resolveStageMcpServers.d.ts +35 -3
- package/dist/config/resolveStageMcpServers.js +124 -9
- package/dist/config/validateCatalog.d.ts +1 -1
- package/dist/config/validateCatalog.js +22 -1
- package/dist/mcp/agentTools.d.ts +8 -0
- package/dist/mcp/agentTools.js +132 -0
- package/dist/mcp/catalogTools.js +17 -10
- package/dist/mcp/deps.d.ts +6 -0
- package/dist/mcp/pipelineAuthorSupport.d.ts +19 -0
- package/dist/mcp/pipelineAuthorSupport.js +10 -0
- package/dist/mcp/pipelineAuthorTools.d.ts +8 -0
- package/dist/mcp/pipelineAuthorTools.js +109 -0
- package/dist/mcp/server.js +5 -0
- package/dist/mcp/tools.js +4 -0
- package/dist/mcp/triggerTools.js +32 -0
- package/dist/memory/access.d.ts +36 -0
- package/dist/memory/access.js +116 -0
- package/dist/memory/agentIssues.d.ts +3 -0
- package/dist/memory/agentIssues.js +23 -0
- package/dist/memory/bashDeny.d.ts +6 -0
- package/dist/memory/bashDeny.js +35 -0
- package/dist/memory/host.d.ts +51 -0
- package/dist/memory/host.js +394 -0
- package/dist/memory/ids.d.ts +15 -0
- package/dist/memory/ids.js +31 -0
- package/dist/memory/worker.d.ts +1 -0
- package/dist/memory/worker.js +84 -0
- package/dist/models/catalog.d.ts +113 -0
- package/dist/models/catalog.js +238 -0
- package/dist/models/response.d.ts +29 -0
- package/dist/models/response.js +25 -0
- package/dist/operatorAgent/agentAuthorContext.d.ts +17 -0
- package/dist/operatorAgent/agentAuthorContext.js +32 -0
- package/dist/operatorAgent/fakeHost.js +2 -0
- package/dist/operatorAgent/host.js +6 -3
- package/dist/operatorAgent/index.d.ts +4 -0
- package/dist/operatorAgent/index.js +4 -0
- package/dist/operatorAgent/piModel.js +2 -0
- package/dist/operatorAgent/profiles/agentAuthor.d.ts +11 -0
- package/dist/operatorAgent/profiles/agentAuthor.js +192 -0
- package/dist/operatorAgent/profiles/agentAuthorPlaybook.d.ts +1 -0
- package/dist/operatorAgent/profiles/agentAuthorPlaybook.js +29 -0
- package/dist/operatorAgent/profiles/workshopAuthor.js +2 -2
- package/dist/operatorAgent/profiles/workshopAuthorTools.js +3 -3
- package/dist/operatorAgent/proposals.d.ts +1 -0
- package/dist/operatorAgent/proposals.js +23 -2
- package/dist/package-meta.d.ts +1 -1
- package/dist/package-meta.js +1 -1
- package/dist/preflight/pipelinePreflight.js +1 -0
- package/dist/runstore/createStore.d.ts +2 -0
- package/dist/runstore/createStore.js +8 -0
- package/dist/runstore/overviewSummary.d.ts +56 -0
- package/dist/runstore/overviewSummary.js +134 -0
- package/dist/runstore/port.d.ts +3 -0
- package/dist/runstore/sqlite/SqliteRunStore.d.ts +2 -0
- package/dist/runstore/sqlite/SqliteRunStore.js +18 -0
- package/dist/runstore/sqlite/migrations/013-agents.d.ts +12 -0
- package/dist/runstore/sqlite/migrations/013-agents.js +156 -0
- package/dist/runstore/sqlite/migrations/014-agent-deliveries.d.ts +11 -0
- package/dist/runstore/sqlite/migrations/014-agent-deliveries.js +32 -0
- package/dist/runstore/sqlite/migrations/index.js +4 -0
- package/dist/runtime/gitCheckoutCapability.d.ts +1 -0
- package/dist/runtime/gitCheckoutCapability.js +1 -1
- package/dist/runtime/gitWorktreeCheckout.d.ts +22 -0
- package/dist/runtime/gitWorktreeCheckout.js +120 -0
- package/dist/runtime/sandboxContainer.d.ts +62 -0
- package/dist/runtime/sandboxContainer.js +151 -0
- package/dist/runtime/sandboxDesk.d.ts +28 -0
- package/dist/runtime/sandboxDesk.js +242 -0
- package/dist/runtime/sandboxFiles.d.ts +20 -0
- package/dist/runtime/sandboxFiles.js +150 -0
- package/dist/runtime/stageAttemptBootstrap.js +15 -1
- package/dist/runtime/stageEnvironment.d.ts +2 -0
- package/dist/runtime/stageEnvironment.js +8 -1
- package/dist/runtime/stageProcessLauncher.js +23 -0
- package/dist/runtime/stageRoots.d.ts +9 -0
- package/dist/runtime/stageRoots.js +14 -0
- package/dist/runtime/stageRunner.d.ts +5 -0
- package/dist/runtime/stageRunner.js +38 -4
- package/dist/runtime/stageSandbox.d.ts +16 -0
- package/dist/runtime/stageSandbox.js +54 -0
- package/dist/runtime/stageSecrets.d.ts +6 -1
- package/dist/runtime/stageSecrets.js +34 -1
- package/dist/runtime/stageWorker.js +138 -105
- package/dist/runtime/workspaceBinding.d.ts +2 -1
- package/dist/runtime/workspaceBinding.js +20 -4
- package/dist/server/agentAuthorRoutes.d.ts +5 -0
- package/dist/server/agentAuthorRoutes.js +64 -0
- package/dist/server/agentRoutes.d.ts +5 -0
- package/dist/server/agentRoutes.js +323 -0
- package/dist/server/bootstrap.d.ts +8 -0
- package/dist/server/bootstrap.js +36 -10
- package/dist/server/controlToken.js +8 -0
- package/dist/server/http.d.ts +8 -1
- package/dist/server/http.js +172 -20
- package/dist/server/mcpHost.js +1 -0
- package/dist/server/memoryRoutes.d.ts +5 -0
- package/dist/server/memoryRoutes.js +146 -0
- package/dist/server/projectMcpRoutes.d.ts +1 -0
- package/dist/server/projectMcpRoutes.js +241 -3
- package/dist/toolkit/guard.d.ts +27 -0
- package/dist/toolkit/guard.js +98 -0
- package/dist/toolkit/index.d.ts +48 -0
- package/dist/toolkit/index.js +82 -0
- package/dist/toolkit/meta.d.ts +36 -0
- package/dist/toolkit/meta.js +117 -0
- package/dist/toolkit/profiles.d.ts +13 -0
- package/dist/toolkit/profiles.js +25 -0
- package/dist/toolkit/record.d.ts +15 -0
- package/dist/toolkit/record.js +17 -0
- package/dist/tools/memoryTools.d.ts +95 -0
- package/dist/tools/memoryTools.js +179 -0
- package/dist/types/pipeline.d.ts +3 -0
- package/dist/types/stage.d.ts +2 -0
- package/dist/types/task.d.ts +11 -1
- package/dist/ui/assets/AssistantRuntimeProvider-CsiPFhCT.js +9 -0
- package/dist/ui/assets/MarkdownText-D7tYaIFO.js +29 -0
- package/dist/ui/assets/ReadonlyStore-BfXqHykm.js +6 -0
- package/dist/ui/assets/Tooltip-DrpoRRNi.js +1 -0
- package/dist/ui/assets/chat-BbLukq9W.js +5 -0
- package/dist/ui/assets/chat-zIZU_bP1.css +2 -0
- package/dist/ui/assets/jsx-runtime-iVoFAvQ_.js +1 -0
- package/dist/ui/assets/{index-Clv4sJpU.css → main-BFo79krC.css} +1 -1
- package/dist/ui/assets/main-CijYMeM0.js +259 -0
- package/dist/ui/chat.html +25 -0
- package/dist/ui/index.html +6 -2
- package/dist/workshop/modelSettings.d.ts +2 -2
- package/dist/workshop/modelSettings.js +5 -11
- package/examples/README.md +1 -0
- package/examples/channels-smoke/README.md +12 -1
- package/examples/github-release/README.md +1 -1
- package/examples/memory/README.md +101 -0
- package/examples/memory/desk-outage.task.yaml +15 -0
- package/examples/memory/desk-refund.task.yaml +15 -0
- package/examples/memory/desk-revisit-outage.task.yaml +11 -0
- package/examples/memory/desk-revisit.pipeline.yaml +123 -0
- package/examples/memory/desk.pipeline.yaml +192 -0
- package/examples/memory/file-card.pipeline.yaml +39 -0
- package/examples/memory/file-ledger.task.yaml +22 -0
- package/examples/memory/file-release.task.yaml +24 -0
- package/examples/memory/file-rich.pipeline.yaml +40 -0
- package/examples/memory/file-ticket.task.yaml +7 -0
- package/examples/memory/file-timeline.task.yaml +28 -0
- package/examples/memory/find-card.pipeline.yaml +46 -0
- package/examples/memory/find-ticket.task.yaml +7 -0
- package/examples/memory/missing.pipeline.yaml +16 -0
- package/examples/memory/probe-bash.task.yaml +3 -0
- package/examples/memory/recall.pipeline.yaml +24 -0
- package/examples/memory/recall.task.yaml +5 -0
- package/examples/memory/remember-ada.task.yaml +6 -0
- package/examples/memory/remember-grace.task.yaml +6 -0
- package/examples/memory/remember.pipeline.yaml +58 -0
- package/examples/memory/sandbox-memory-bash.pipeline.yaml +28 -0
- package/examples/memory/stageflow.yaml +12 -0
- package/examples/memory/update-card.pipeline.yaml +43 -0
- package/examples/memory/update-ledger.task.yaml +23 -0
- package/examples/memory/update-rich.pipeline.yaml +44 -0
- package/examples/memory/update-ticket.task.yaml +7 -0
- package/examples/ship-feature/README.md +15 -0
- package/examples/stage-mcp/README.md +1 -1
- package/package.json +2 -1
- package/dist/ui/assets/index-BOhqnPNg.js +0 -260
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { loadDraftPackage, validateDraftPackage } from "../config/draftPackage.js";
|
|
2
|
+
import { publishDraftPackage } from "../config/publishDraftPackage.js";
|
|
3
|
+
export { loadDraftPackage, validateDraftPackage };
|
|
4
|
+
/** Write a package the way the Workshop's save does, flattening its result shape. */
|
|
5
|
+
export async function publishDraftPackageFacade(projectRoot, input, mode) {
|
|
6
|
+
const { write } = await publishDraftPackage(projectRoot, input, mode);
|
|
7
|
+
if (!write.ok)
|
|
8
|
+
return { ok: false, error: write.error, status: write.status };
|
|
9
|
+
return { ok: true, pipelinePath: write.pipelinePath, stagePaths: write.stagePaths, ...(write.taskPath !== undefined ? { taskPath: write.taskPath } : {}) };
|
|
10
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { McpToolDeps } from "./deps.js";
|
|
3
|
+
/**
|
|
4
|
+
* Author pipelines and tasks straight on disk. Each mutation loads the package,
|
|
5
|
+
* applies the same builder the Workshop uses, and writes it back through the
|
|
6
|
+
* Workshop's publish path (validate first, nothing written when invalid).
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerPipelineAuthorTools(server: McpServer, deps: McpToolDeps): void;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { loadDraftPackage, publishDraftPackageFacade, validateDraftPackage } from "./pipelineAuthorSupport.js";
|
|
4
|
+
import { buildCreatePipelineDraft, buildCreateStageDraft, buildCreateTaskDraft, buildEditPipelineDraft, buildEditStageDraft, buildEditTaskDraft, } from "../operatorAgent/profiles/workshopAuthorTools.js";
|
|
5
|
+
import { textResult } from "./toolResults.js";
|
|
6
|
+
const pipelinePath = z
|
|
7
|
+
.string()
|
|
8
|
+
.describe("Pipeline YAML path relative to the project root, e.g. workshop/release/pipeline.yaml");
|
|
9
|
+
const record = z.record(z.string(), z.unknown());
|
|
10
|
+
const allowInvalid = z
|
|
11
|
+
.boolean()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Write even when validation fails, so a pipeline can be built up step by step. Default false.");
|
|
14
|
+
/**
|
|
15
|
+
* Author pipelines and tasks straight on disk. Each mutation loads the package,
|
|
16
|
+
* applies the same builder the Workshop uses, and writes it back through the
|
|
17
|
+
* Workshop's publish path (validate first, nothing written when invalid).
|
|
18
|
+
*/
|
|
19
|
+
export function registerPipelineAuthorTools(server, deps) {
|
|
20
|
+
const root = () => deps.projectRoot ?? deps.cwd;
|
|
21
|
+
async function mutate(relPath, mode, build, options = {}) {
|
|
22
|
+
const projectRoot = root();
|
|
23
|
+
let draft = { pipeline: { id: "", stages: [] } };
|
|
24
|
+
if (mode === "overwrite") {
|
|
25
|
+
const loaded = await loadDraftPackage(projectRoot, relPath, options.taskPath ? { taskPath: options.taskPath } : {});
|
|
26
|
+
if (!loaded.ok)
|
|
27
|
+
return textResult({ error: loaded.error, status: loaded.status }, true);
|
|
28
|
+
draft = loaded.draft;
|
|
29
|
+
}
|
|
30
|
+
const built = build(draft);
|
|
31
|
+
if (!built.ok)
|
|
32
|
+
return textResult({ error: built.error }, true);
|
|
33
|
+
const directory = path.posix.dirname(relPath.replace(/\\/g, "/")) || ".";
|
|
34
|
+
const published = await publishDraftPackageFacade(projectRoot, {
|
|
35
|
+
directory,
|
|
36
|
+
draft: built.nextDraft,
|
|
37
|
+
pipelineFilename: path.posix.basename(relPath),
|
|
38
|
+
...(options.allowInvalid ? { allowInvalid: true } : {}),
|
|
39
|
+
}, mode);
|
|
40
|
+
if (!published.ok)
|
|
41
|
+
return textResult({ error: published.error, status: published.status }, true);
|
|
42
|
+
return textResult({ pipelinePath: published.pipelinePath, stagePaths: published.stagePaths, taskPath: published.taskPath ?? null });
|
|
43
|
+
}
|
|
44
|
+
server.registerTool("read_pipeline", {
|
|
45
|
+
description: "Read a pipeline package from disk (pipeline, stage files, optional task) with its validation result. Use before editing.",
|
|
46
|
+
inputSchema: z.object({ path: pipelinePath, task_path: z.string().optional().describe("Task file to include, relative to the project root") }),
|
|
47
|
+
}, async ({ path: relPath, task_path }) => {
|
|
48
|
+
const loaded = await loadDraftPackage(root(), relPath, task_path ? { taskPath: task_path } : {});
|
|
49
|
+
if (!loaded.ok)
|
|
50
|
+
return textResult({ error: loaded.error, status: loaded.status }, true);
|
|
51
|
+
const validation = await validateDraftPackage(loaded.draft, { cwd: deps.cwd, projectRoot: root() });
|
|
52
|
+
return textResult({ draft: loaded.draft, destination: loaded.destination, validation });
|
|
53
|
+
});
|
|
54
|
+
server.registerTool("create_pipeline", {
|
|
55
|
+
description: "Create a new pipeline package on disk (id, optional model/stages). Fails if it already exists; use edit_pipeline instead. A pipeline needs at least one stage to validate, so add stages or pass allow_invalid and then create_stage.",
|
|
56
|
+
inputSchema: z.object({
|
|
57
|
+
directory: z.string().describe("Catalog folder relative to the project root, e.g. workshop/release. The file is written as <id>.pipeline.yaml"),
|
|
58
|
+
id: z.string(),
|
|
59
|
+
model: z.string().optional(),
|
|
60
|
+
agent: z.unknown().optional(),
|
|
61
|
+
stages: z.array(record).optional(),
|
|
62
|
+
pipeline: record.optional().describe("Whole pipeline object, instead of id/model/stages"),
|
|
63
|
+
allow_invalid: allowInvalid,
|
|
64
|
+
}),
|
|
65
|
+
}, ({ directory, allow_invalid, ...args }) => {
|
|
66
|
+
const folder = directory.replace(/[\\/]+$/, "");
|
|
67
|
+
const file = `${typeof args.id === "string" ? args.id : ""}.pipeline.yaml`;
|
|
68
|
+
return mutate(folder === "" || folder === "." ? file : `${folder}/${file}`, "create", (draft) => buildCreatePipelineDraft(draft, args), { allowInvalid: allow_invalid });
|
|
69
|
+
});
|
|
70
|
+
server.registerTool("edit_pipeline", {
|
|
71
|
+
description: "Edit pipeline fields on disk (id, model, agent, stages wiring, schemas, requires). Pass the fields to change under patch.",
|
|
72
|
+
inputSchema: z.object({ path: pipelinePath, patch: record, allow_invalid: allowInvalid }),
|
|
73
|
+
}, ({ path: relPath, patch, allow_invalid }) => mutate(relPath, "overwrite", (draft) => buildEditPipelineDraft(draft, { patch }), { allowInvalid: allow_invalid }));
|
|
74
|
+
server.registerTool("create_stage", {
|
|
75
|
+
description: "Add a file-backed stage to a pipeline on disk (uses: ./id.yaml plus the stage body with io).",
|
|
76
|
+
inputSchema: z.object({
|
|
77
|
+
path: pipelinePath,
|
|
78
|
+
id: z.string().optional(),
|
|
79
|
+
summary: z.string().optional(),
|
|
80
|
+
system_prompt: z.string().optional(),
|
|
81
|
+
model: z.string().optional(),
|
|
82
|
+
entry: z.boolean().optional(),
|
|
83
|
+
route: z.array(record).optional(),
|
|
84
|
+
io: record.optional(),
|
|
85
|
+
body: record.optional().describe("Extra stage body fields"),
|
|
86
|
+
allow_invalid: allowInvalid,
|
|
87
|
+
}),
|
|
88
|
+
}, ({ path: relPath, allow_invalid, ...args }) => mutate(relPath, "overwrite", (draft) => buildCreateStageDraft(draft, args), { allowInvalid: allow_invalid }));
|
|
89
|
+
server.registerTool("edit_stage", {
|
|
90
|
+
description: "Edit an existing stage on disk by id: body fields and/or its pipeline entry (route, entry, uses).",
|
|
91
|
+
inputSchema: z.looseObject({ path: pipelinePath, id: z.string(), allow_invalid: allowInvalid }),
|
|
92
|
+
}, ({ path: relPath, allow_invalid, ...args }) => mutate(relPath, "overwrite", (draft) => buildEditStageDraft(draft, args), { allowInvalid: allow_invalid }));
|
|
93
|
+
server.registerTool("create_task", {
|
|
94
|
+
description: "Create or replace the task beside a pipeline on disk (id and goal, optional body).",
|
|
95
|
+
inputSchema: z.object({ path: pipelinePath, id: z.string().optional(), goal: z.string().optional(), filename: z.string().optional(), body: record.optional(), allow_invalid: allowInvalid }),
|
|
96
|
+
}, ({ path: relPath, allow_invalid, ...args }) => mutate(relPath, "overwrite", (draft) => buildCreateTaskDraft(draft, args), { allowInvalid: allow_invalid }));
|
|
97
|
+
server.registerTool("edit_task", {
|
|
98
|
+
description: "Edit the task of a pipeline on disk (id, goal, body fields).",
|
|
99
|
+
inputSchema: z.object({
|
|
100
|
+
path: pipelinePath,
|
|
101
|
+
task_path: z.string().describe("Task file relative to the project root"),
|
|
102
|
+
id: z.string().optional(),
|
|
103
|
+
goal: z.string().optional(),
|
|
104
|
+
patch: record.optional(),
|
|
105
|
+
body: record.optional(),
|
|
106
|
+
allow_invalid: allowInvalid,
|
|
107
|
+
}),
|
|
108
|
+
}, ({ path: relPath, task_path, allow_invalid, ...args }) => mutate(relPath, "overwrite", (draft) => buildEditTaskDraft(draft, args), { taskPath: task_path, allowInvalid: allow_invalid }));
|
|
109
|
+
}
|
package/dist/mcp/server.js
CHANGED
|
@@ -44,6 +44,11 @@ function toolDepsFrom(deps) {
|
|
|
44
44
|
: {}),
|
|
45
45
|
...(deps.projectRoot !== undefined ? { projectRoot: deps.projectRoot } : {}),
|
|
46
46
|
...(deps.providerBoot !== undefined ? { providerBoot: deps.providerBoot } : {}),
|
|
47
|
+
...(deps.agentService !== undefined ? { agentService: deps.agentService } : {}),
|
|
48
|
+
...(deps.agentChat !== undefined ? { agentChat: deps.agentChat } : {}),
|
|
49
|
+
...(deps.agentConversationBackend !== undefined
|
|
50
|
+
? { agentConversationBackend: deps.agentConversationBackend }
|
|
51
|
+
: {}),
|
|
47
52
|
};
|
|
48
53
|
}
|
|
49
54
|
function attachBusNotifications(server, bus) {
|
package/dist/mcp/tools.js
CHANGED
|
@@ -3,10 +3,12 @@ import { registerCatalogTools } from "./catalogTools.js";
|
|
|
3
3
|
import { registerCheckoutTools } from "./checkoutTools.js";
|
|
4
4
|
import { registerControlTools } from "./controlTools.js";
|
|
5
5
|
import { registerProjectMcpTools } from "./projectMcpTools.js";
|
|
6
|
+
import { registerPipelineAuthorTools } from "./pipelineAuthorTools.js";
|
|
6
7
|
import { registerProviderTools } from "./providerTools.js";
|
|
7
8
|
import { registerTriggerTools } from "./triggerTools.js";
|
|
8
9
|
import { textResult } from "./toolResults.js";
|
|
9
10
|
import { DEFAULT_TIMEOUT_MS, waitRun } from "./waitRun.js";
|
|
11
|
+
import { registerAgentTools } from "./agentTools.js";
|
|
10
12
|
import { registerGetStartedTool } from "./getStartedTool.js";
|
|
11
13
|
export function registerMcpTools(server, deps) {
|
|
12
14
|
const { store } = deps;
|
|
@@ -17,6 +19,8 @@ export function registerMcpTools(server, deps) {
|
|
|
17
19
|
registerProviderTools(server, deps);
|
|
18
20
|
registerProjectMcpTools(server, deps);
|
|
19
21
|
registerTriggerTools(server, deps);
|
|
22
|
+
registerPipelineAuthorTools(server, deps);
|
|
23
|
+
registerAgentTools(server, deps);
|
|
20
24
|
server.registerTool("wait_run", {
|
|
21
25
|
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.",
|
|
22
26
|
inputSchema: z.object({
|
package/dist/mcp/triggerTools.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { CatalogPathError, catalogPathErrorBody, resolveWritableCatalogRoot, } from "../config/catalogRelativePath.js";
|
|
3
3
|
import { createTrigger, parseCreateTriggerBody } from "../config/createTrigger.js";
|
|
4
|
+
import { parsePatchTriggerBody, parsePutTriggerBody, updateTriggerDefinition, updateTriggerEnabled } from "../config/updateTrigger.js";
|
|
4
5
|
import { loadCatalogTriggers } from "../config/triggerCatalog.js";
|
|
5
6
|
import { writeAudit } from "../logging/audit.js";
|
|
6
7
|
import { logger as rootLogger } from "../logging/logger.js";
|
|
@@ -167,4 +168,35 @@ export function registerTriggerTools(server, deps) {
|
|
|
167
168
|
});
|
|
168
169
|
return textResult(result.trigger);
|
|
169
170
|
});
|
|
171
|
+
server.registerTool("update_trigger", {
|
|
172
|
+
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: z.object({
|
|
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
|
+
}),
|
|
183
|
+
}, async ({ id, project_root, ...body }) => {
|
|
184
|
+
const parsed = parsePutTriggerBody(body, id);
|
|
185
|
+
if ("ok" in parsed)
|
|
186
|
+
return textResult({ error: parsed.error, status: parsed.status }, true);
|
|
187
|
+
const result = await updateTriggerDefinition(cwd, store, id, parsed, { projectRootFilter: project_root });
|
|
188
|
+
writeAudit(auditLog, { caller_id: callerIdFromRequestAuth(), surface: getRequestAuth()?.surface ?? "mcp", action: "trigger_update", outcome: result.ok ? "ok" : "error" });
|
|
189
|
+
return result.ok ? textResult(result.trigger) : textResult({ error: result.error, status: result.status }, true);
|
|
190
|
+
});
|
|
191
|
+
server.registerTool("set_trigger_enabled", {
|
|
192
|
+
description: "Enable or disable a trigger. Same write path as PATCH /api/triggers/:id.",
|
|
193
|
+
inputSchema: z.object({ id: z.string(), enabled: z.boolean(), project_root: z.string().optional() }),
|
|
194
|
+
}, async ({ id, enabled, project_root }) => {
|
|
195
|
+
const parsed = parsePatchTriggerBody({ enabled });
|
|
196
|
+
if ("ok" in parsed)
|
|
197
|
+
return textResult({ error: parsed.error, status: parsed.status }, true);
|
|
198
|
+
const result = await updateTriggerEnabled(cwd, store, id, parsed.enabled, { projectRootFilter: project_root });
|
|
199
|
+
writeAudit(auditLog, { caller_id: callerIdFromRequestAuth(), surface: getRequestAuth()?.surface ?? "mcp", action: "trigger_patch", outcome: result.ok ? "ok" : "error" });
|
|
200
|
+
return result.ok ? textResult(result.trigger) : textResult({ error: result.error, status: result.status }, true);
|
|
201
|
+
});
|
|
170
202
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type MemoryCardHit, type MemoryHost, type MemoryMeta } from "./host.js";
|
|
2
|
+
/** What a stage or agent session is allowed to do with the memories attached to it. */
|
|
3
|
+
export type StageMemory = {
|
|
4
|
+
attachments: MemoryMeta[];
|
|
5
|
+
refreshAttachments(): Promise<MemoryMeta[]>;
|
|
6
|
+
read(id: string): Promise<string>;
|
|
7
|
+
replace(id: string, content: string): Promise<void>;
|
|
8
|
+
addCard(id: string, key: string, body: string): Promise<void>;
|
|
9
|
+
updateCard(id: string, key: string, body: string): Promise<void>;
|
|
10
|
+
readCard(id: string, key: string): Promise<string>;
|
|
11
|
+
searchCards(id: string, query: string): Promise<MemoryCardHit[]>;
|
|
12
|
+
};
|
|
13
|
+
/** Unchecked reads and writes. The attachment allowlist sits in front of this. */
|
|
14
|
+
export type MemoryPort = {
|
|
15
|
+
meta(id: string): Promise<MemoryMeta>;
|
|
16
|
+
read(id: string): Promise<string>;
|
|
17
|
+
replace(id: string, content: string): Promise<void>;
|
|
18
|
+
addCard(id: string, key: string, body: string): Promise<void>;
|
|
19
|
+
updateCard(id: string, key: string, body: string): Promise<void>;
|
|
20
|
+
readCard(id: string, key: string): Promise<string>;
|
|
21
|
+
searchCards(id: string, query: string): Promise<MemoryCardHit[]>;
|
|
22
|
+
};
|
|
23
|
+
declare const MEMORY_VERBS: readonly ["memory.read", "memory.replace", "memory.meta", "memory.addCard", "memory.updateCard", "memory.readCard", "memory.searchCards"];
|
|
24
|
+
export type MemoryVerb = (typeof MEMORY_VERBS)[number];
|
|
25
|
+
export declare function isMemoryVerb(type: string | undefined): type is MemoryVerb;
|
|
26
|
+
/** One allowlist in front of either the host or the worker port. */
|
|
27
|
+
export declare function attachMemory(ids: readonly string[], port: MemoryPort): Promise<StageMemory>;
|
|
28
|
+
export declare function bindStageMemory(host: MemoryHost, ids: readonly string[]): Promise<StageMemory>;
|
|
29
|
+
/** Parent-side dispatch for a stage worker. Refuses an id the stage was not given. */
|
|
30
|
+
export declare function runMemoryRequest(host: MemoryHost, allowed: readonly string[], type: MemoryVerb, input: unknown): Promise<{
|
|
31
|
+
body?: string;
|
|
32
|
+
meta?: MemoryMeta;
|
|
33
|
+
hits?: MemoryCardHit[];
|
|
34
|
+
}>;
|
|
35
|
+
export declare function formatMemoryPrompt(attachments: readonly MemoryMeta[]): string;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { MemoryError } from "./host.js";
|
|
2
|
+
const MEMORY_VERBS = [
|
|
3
|
+
"memory.read",
|
|
4
|
+
"memory.replace",
|
|
5
|
+
"memory.meta",
|
|
6
|
+
"memory.addCard",
|
|
7
|
+
"memory.updateCard",
|
|
8
|
+
"memory.readCard",
|
|
9
|
+
"memory.searchCards",
|
|
10
|
+
];
|
|
11
|
+
export function isMemoryVerb(type) {
|
|
12
|
+
return type !== undefined && MEMORY_VERBS.includes(type);
|
|
13
|
+
}
|
|
14
|
+
function gate(allowed, id) {
|
|
15
|
+
if (!allowed.has(id))
|
|
16
|
+
throw new MemoryError("MEMORY_NOT_ATTACHED");
|
|
17
|
+
}
|
|
18
|
+
/** One allowlist in front of either the host or the worker port. */
|
|
19
|
+
export async function attachMemory(ids, port) {
|
|
20
|
+
const attachments = [];
|
|
21
|
+
for (const id of ids)
|
|
22
|
+
attachments.push(await port.meta(id));
|
|
23
|
+
const allowed = new Set(ids);
|
|
24
|
+
return {
|
|
25
|
+
attachments,
|
|
26
|
+
async refreshAttachments() {
|
|
27
|
+
const next = [];
|
|
28
|
+
for (const id of ids)
|
|
29
|
+
next.push(await port.meta(id));
|
|
30
|
+
attachments.length = 0;
|
|
31
|
+
attachments.push(...next);
|
|
32
|
+
return next;
|
|
33
|
+
},
|
|
34
|
+
async read(id) {
|
|
35
|
+
gate(allowed, id);
|
|
36
|
+
return port.read(id);
|
|
37
|
+
},
|
|
38
|
+
async replace(id, content) {
|
|
39
|
+
gate(allowed, id);
|
|
40
|
+
await port.replace(id, content);
|
|
41
|
+
},
|
|
42
|
+
async addCard(id, key, body) {
|
|
43
|
+
gate(allowed, id);
|
|
44
|
+
await port.addCard(id, key, body);
|
|
45
|
+
},
|
|
46
|
+
async updateCard(id, key, body) {
|
|
47
|
+
gate(allowed, id);
|
|
48
|
+
await port.updateCard(id, key, body);
|
|
49
|
+
},
|
|
50
|
+
async readCard(id, key) {
|
|
51
|
+
gate(allowed, id);
|
|
52
|
+
return port.readCard(id, key);
|
|
53
|
+
},
|
|
54
|
+
async searchCards(id, query) {
|
|
55
|
+
gate(allowed, id);
|
|
56
|
+
return port.searchCards(id, query);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function bindStageMemory(host, ids) {
|
|
61
|
+
return attachMemory(ids, {
|
|
62
|
+
meta: (id) => host.readMeta(id),
|
|
63
|
+
read: (id) => host.read(id),
|
|
64
|
+
replace: (id, content) => host.replace(id, content),
|
|
65
|
+
addCard: (id, key, body) => host.addCard(id, key, body),
|
|
66
|
+
updateCard: (id, key, body) => host.updateCard(id, key, body),
|
|
67
|
+
readCard: (id, key) => host.readCard(id, key),
|
|
68
|
+
searchCards: (id, query) => host.searchCards(id, query),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** Parent-side dispatch for a stage worker. Refuses an id the stage was not given. */
|
|
72
|
+
export async function runMemoryRequest(host, allowed, type, input) {
|
|
73
|
+
const args = (input ?? {});
|
|
74
|
+
const id = args.memory;
|
|
75
|
+
if (typeof id !== "string" || !allowed.includes(id))
|
|
76
|
+
throw new MemoryError("MEMORY_NOT_ATTACHED");
|
|
77
|
+
if (type === "memory.read")
|
|
78
|
+
return { body: await host.read(id) };
|
|
79
|
+
if (type === "memory.replace") {
|
|
80
|
+
if (typeof args.content !== "string")
|
|
81
|
+
throw new MemoryError("MEMORY_UNREADABLE");
|
|
82
|
+
await host.replace(id, args.content);
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
if (type === "memory.addCard" || type === "memory.updateCard") {
|
|
86
|
+
if (typeof args.key !== "string")
|
|
87
|
+
throw new MemoryError("MEMORY_INVALID_KEY");
|
|
88
|
+
if (typeof args.content !== "string")
|
|
89
|
+
throw new MemoryError("MEMORY_UNREADABLE");
|
|
90
|
+
if (type === "memory.addCard")
|
|
91
|
+
await host.addCard(id, args.key, args.content);
|
|
92
|
+
else
|
|
93
|
+
await host.updateCard(id, args.key, args.content);
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
if (type === "memory.readCard") {
|
|
97
|
+
if (typeof args.key !== "string")
|
|
98
|
+
throw new MemoryError("MEMORY_INVALID_KEY");
|
|
99
|
+
return { body: await host.readCard(id, args.key) };
|
|
100
|
+
}
|
|
101
|
+
if (type === "memory.searchCards") {
|
|
102
|
+
const query = typeof args.query === "string" ? args.query : "";
|
|
103
|
+
return { hits: await host.searchCards(id, query) };
|
|
104
|
+
}
|
|
105
|
+
return { meta: await host.readMeta(id) };
|
|
106
|
+
}
|
|
107
|
+
export function formatMemoryPrompt(attachments) {
|
|
108
|
+
const lines = attachments.map((item) => `- ${item.id}: ${item.description}`);
|
|
109
|
+
return [
|
|
110
|
+
"Memories you can read and replace:",
|
|
111
|
+
...lines,
|
|
112
|
+
"Call read_memory with the memory id to get the page. Call replace_memory with the full new page.",
|
|
113
|
+
"Call add_memory_card, update_memory_card, and read_memory_card with the memory id and the card key. Call search_memory_cards with the memory id and a query.",
|
|
114
|
+
"The page is not shown here. Card bodies are not shown here. Do not try to open memory files yourself.",
|
|
115
|
+
].join("\n");
|
|
116
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { inspectMemorySync, memoryHome } from "./host.js";
|
|
2
|
+
const MESSAGE = {
|
|
3
|
+
MEMORY_NOT_FOUND: (id) => `Memory "${id}" does not exist. Create it before attaching it.`,
|
|
4
|
+
MEMORY_MISMATCH: (id) => `Memory "${id}" does not match the id in its file.`,
|
|
5
|
+
MEMORY_UNREADABLE: (id) => `Memory "${id}" could not be read.`,
|
|
6
|
+
MEMORY_INVALID_ID: (id) => `Memory "${id}" is not a valid id.`,
|
|
7
|
+
};
|
|
8
|
+
/** Hard errors for an agent that names a memory the data directory does not have. */
|
|
9
|
+
export function agentMemoryIssues(ids, env = process.env) {
|
|
10
|
+
if (!ids?.length)
|
|
11
|
+
return [];
|
|
12
|
+
const home = memoryHome(env);
|
|
13
|
+
return ids.flatMap((id, index) => {
|
|
14
|
+
const inspected = inspectMemorySync(home, id);
|
|
15
|
+
if (inspected.ok)
|
|
16
|
+
return [];
|
|
17
|
+
return [{
|
|
18
|
+
path: `memories.${index}`,
|
|
19
|
+
code: "agent.memory_unavailable",
|
|
20
|
+
message: (MESSAGE[inspected.code] ?? MESSAGE.MEMORY_UNREADABLE)(id),
|
|
21
|
+
}];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
export declare const MEMORY_STORE_BASH_DENIED = "The memory store cannot be accessed with shell commands. Use the memory tools.";
|
|
3
|
+
export declare function memoryStorePathInCommand(command: string, home: string): boolean;
|
|
4
|
+
export declare function createMemoryStoreBashDenyExtension(options: {
|
|
5
|
+
home: string;
|
|
6
|
+
}): ExtensionFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
export const MEMORY_STORE_BASH_DENIED = "The memory store cannot be accessed with shell commands. Use the memory tools.";
|
|
3
|
+
const MEMORY_STORE_SEGMENT = /\/memories\/[a-z][a-z0-9_-]{0,63}\b/;
|
|
4
|
+
export function memoryStorePathInCommand(command, home) {
|
|
5
|
+
const trimmed = command.trim();
|
|
6
|
+
if (trimmed.length === 0)
|
|
7
|
+
return false;
|
|
8
|
+
const store = path.resolve(path.join(home, "memories"));
|
|
9
|
+
const variants = [store, store.split(path.sep).join("/")];
|
|
10
|
+
for (const candidate of variants) {
|
|
11
|
+
if (candidate.length > 0 && trimmed.includes(candidate))
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (MEMORY_STORE_SEGMENT.test(trimmed))
|
|
15
|
+
return true;
|
|
16
|
+
if (/\$STAGEFLOW_HOME\/memories\b/.test(trimmed) || /\$\{STAGEFLOW_HOME\}\/memories\b/.test(trimmed)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
export function createMemoryStoreBashDenyExtension(options) {
|
|
22
|
+
const { home } = options;
|
|
23
|
+
return (pi) => {
|
|
24
|
+
pi.on("tool_call", async (event) => {
|
|
25
|
+
if (event.toolName !== "bash")
|
|
26
|
+
return undefined;
|
|
27
|
+
const command = event.input.command;
|
|
28
|
+
if (typeof command !== "string")
|
|
29
|
+
return undefined;
|
|
30
|
+
if (!memoryStorePathInCommand(command, home))
|
|
31
|
+
return undefined;
|
|
32
|
+
return { block: true, reason: MEMORY_STORE_BASH_DENIED };
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare const MEMORY_ERROR_CODES: readonly ["MEMORY_INVALID_ID", "MEMORY_INVALID_DESCRIPTION", "MEMORY_INVALID_KEY", "MEMORY_EXISTS", "MEMORY_NOT_FOUND", "MEMORY_NO_PREVIOUS", "MEMORY_CARD_EXISTS", "MEMORY_CARD_NOT_FOUND", "MEMORY_TOO_MANY_CARDS", "MEMORY_MISMATCH", "MEMORY_UNREADABLE", "MEMORY_TOO_LARGE", "MEMORY_NOT_ATTACHED"];
|
|
2
|
+
export type MemoryErrorCode = (typeof MEMORY_ERROR_CODES)[number];
|
|
3
|
+
export declare class MemoryError extends Error {
|
|
4
|
+
readonly code: MemoryErrorCode;
|
|
5
|
+
constructor(code: MemoryErrorCode);
|
|
6
|
+
}
|
|
7
|
+
export type MemoryMeta = {
|
|
8
|
+
id: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
export type MemoryListItem = MemoryMeta & {
|
|
12
|
+
cardCount: number;
|
|
13
|
+
};
|
|
14
|
+
export type MemoryRecord = MemoryMeta & {
|
|
15
|
+
body: string;
|
|
16
|
+
};
|
|
17
|
+
export type MemoryCardHit = {
|
|
18
|
+
key: string;
|
|
19
|
+
snippet: string;
|
|
20
|
+
};
|
|
21
|
+
export type MemoryHost = {
|
|
22
|
+
create(input: {
|
|
23
|
+
id: string;
|
|
24
|
+
description: string;
|
|
25
|
+
}): Promise<MemoryRecord>;
|
|
26
|
+
list(): Promise<MemoryListItem[]>;
|
|
27
|
+
read(id: string): Promise<string>;
|
|
28
|
+
readMeta(id: string): Promise<MemoryMeta>;
|
|
29
|
+
replace(id: string, body: string): Promise<void>;
|
|
30
|
+
readPreviousCover(id: string): Promise<string>;
|
|
31
|
+
addCard(id: string, key: string, body: string): Promise<void>;
|
|
32
|
+
updateCard(id: string, key: string, body: string): Promise<void>;
|
|
33
|
+
readCard(id: string, key: string): Promise<string>;
|
|
34
|
+
readPreviousCard(id: string, key: string): Promise<string>;
|
|
35
|
+
listCards(id: string): Promise<string[]>;
|
|
36
|
+
searchCards(id: string, query: string): Promise<MemoryCardHit[]>;
|
|
37
|
+
deleteCard(id: string, key: string): Promise<void>;
|
|
38
|
+
};
|
|
39
|
+
export declare function memoryHome(env?: NodeJS.ProcessEnv): string;
|
|
40
|
+
export declare function memoryDir(home: string, id: string): string;
|
|
41
|
+
type InspectResult = {
|
|
42
|
+
ok: true;
|
|
43
|
+
meta: MemoryMeta;
|
|
44
|
+
} | {
|
|
45
|
+
ok: false;
|
|
46
|
+
code: MemoryErrorCode;
|
|
47
|
+
};
|
|
48
|
+
export declare function inspectMemorySync(home: string, id: string): InspectResult;
|
|
49
|
+
export declare function createMemoryHost(home: string): MemoryHost;
|
|
50
|
+
export declare function memoryHostFor(env?: NodeJS.ProcessEnv): MemoryHost;
|
|
51
|
+
export {};
|