@evalops/maestro 0.10.21 → 0.10.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent.d.ts +1 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +15 -4
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/swarm/executor.d.ts.map +1 -1
- package/dist/agent/swarm/executor.js +68 -3
- package/dist/agent/swarm/executor.js.map +1 -1
- package/dist/agent/swarm/types.d.ts +3 -0
- package/dist/agent/swarm/types.d.ts.map +1 -1
- package/dist/agent/swarm/types.js.map +1 -1
- package/dist/agent/transport.d.ts.map +1 -1
- package/dist/agent/transport.js +7 -1
- package/dist/agent/transport.js.map +1 -1
- package/dist/audit/logger.d.ts +1 -1
- package/dist/bootstrap/tools-setup.d.ts.map +1 -1
- package/dist/bootstrap/tools-setup.js +3 -2
- package/dist/bootstrap/tools-setup.js.map +1 -1
- package/dist/cli/commands/a2a.d.ts.map +1 -1
- package/dist/cli/commands/a2a.js +141 -8
- package/dist/cli/commands/a2a.js.map +1 -1
- package/dist/cli/commands/codex.d.ts.map +1 -1
- package/dist/cli/commands/codex.js +4 -3
- package/dist/cli/commands/codex.js.map +1 -1
- package/dist/cli/commands/hosted-runner.d.ts +1 -0
- package/dist/cli/commands/hosted-runner.d.ts.map +1 -1
- package/dist/cli/commands/hosted-runner.js +31 -2
- package/dist/cli/commands/hosted-runner.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +2 -9
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli-tui/commands/a2a-handlers.d.ts.map +1 -1
- package/dist/cli-tui/commands/a2a-handlers.js +55 -0
- package/dist/cli-tui/commands/a2a-handlers.js.map +1 -1
- package/dist/cli.js +3925 -2024
- package/dist/codex/compatibility.d.ts +17 -1
- package/dist/codex/compatibility.d.ts.map +1 -1
- package/dist/codex/compatibility.js +57 -1
- package/dist/codex/compatibility.js.map +1 -1
- package/dist/guardian/config.d.ts +8 -6
- package/dist/guardian/config.d.ts.map +1 -1
- package/dist/guardian/config.js +33 -7
- package/dist/guardian/config.js.map +1 -1
- package/dist/guardian/runner.d.ts.map +1 -1
- package/dist/guardian/runner.js +54 -9
- package/dist/guardian/runner.js.map +1 -1
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/mcp/config.js +2 -0
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/fathom-cua.d.ts +3 -0
- package/dist/mcp/fathom-cua.d.ts.map +1 -0
- package/dist/mcp/fathom-cua.js +158 -0
- package/dist/mcp/fathom-cua.js.map +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/node_modules/@evalops/contracts/dist/artifacts.d.ts +58 -0
- package/dist/node_modules/@evalops/contracts/dist/artifacts.d.ts.map +1 -0
- package/dist/node_modules/@evalops/contracts/dist/artifacts.js +191 -0
- package/dist/node_modules/@evalops/contracts/dist/artifacts.js.map +1 -0
- package/dist/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.d.ts +10 -10
- package/dist/node_modules/@evalops/contracts/dist/index.d.ts +1 -0
- package/dist/node_modules/@evalops/contracts/dist/index.d.ts.map +1 -1
- package/dist/node_modules/@evalops/contracts/dist/index.js +1 -0
- package/dist/node_modules/@evalops/contracts/dist/index.js.map +1 -1
- package/dist/node_modules/@evalops/contracts/dist/runtime-app-server.d.ts +1 -1
- package/dist/node_modules/@evalops/contracts/dist/runtime-server-request.d.ts +3 -3
- package/dist/node_modules/@evalops/contracts/package.json +1 -1
- package/dist/node_modules/@evalops/tui/package.json +1 -1
- package/dist/platform/a2a-cockpit.d.ts +90 -0
- package/dist/platform/a2a-cockpit.d.ts.map +1 -0
- package/dist/platform/a2a-cockpit.js +302 -0
- package/dist/platform/a2a-cockpit.js.map +1 -0
- package/dist/platform/a2a-fleet.d.ts +14 -0
- package/dist/platform/a2a-fleet.d.ts.map +1 -1
- package/dist/platform/a2a-fleet.js +66 -1
- package/dist/platform/a2a-fleet.js.map +1 -1
- package/dist/platform/a2a-ownership.d.ts +27 -0
- package/dist/platform/a2a-ownership.d.ts.map +1 -0
- package/dist/platform/a2a-ownership.js +149 -0
- package/dist/platform/a2a-ownership.js.map +1 -0
- package/dist/platform/a2a-task-ledger.d.ts.map +1 -1
- package/dist/platform/a2a-task-ledger.js +29 -5
- package/dist/platform/a2a-task-ledger.js.map +1 -1
- package/dist/server/agent-trajectory-replay-lab.d.ts +36 -0
- package/dist/server/agent-trajectory-replay-lab.d.ts.map +1 -0
- package/dist/server/agent-trajectory-replay-lab.js +48 -0
- package/dist/server/agent-trajectory-replay-lab.js.map +1 -0
- package/dist/server/any-agent-control-plane-proof.d.ts +42 -0
- package/dist/server/any-agent-control-plane-proof.d.ts.map +1 -0
- package/dist/server/any-agent-control-plane-proof.js +175 -0
- package/dist/server/any-agent-control-plane-proof.js.map +1 -0
- package/dist/server/app-context.d.ts +1 -0
- package/dist/server/app-context.d.ts.map +1 -1
- package/dist/server/app-context.js.map +1 -1
- package/dist/server/handlers/a2a-cockpit.d.ts +3 -0
- package/dist/server/handlers/a2a-cockpit.d.ts.map +1 -0
- package/dist/server/handlers/a2a-cockpit.js +71 -0
- package/dist/server/handlers/a2a-cockpit.js.map +1 -0
- package/dist/server/handlers/headless-sessions.d.ts.map +1 -1
- package/dist/server/handlers/headless-sessions.js +17 -2
- package/dist/server/handlers/headless-sessions.js.map +1 -1
- package/dist/server/handlers/session-artifacts.d.ts.map +1 -1
- package/dist/server/handlers/session-artifacts.js +14 -58
- package/dist/server/handlers/session-artifacts.js.map +1 -1
- package/dist/server/handlers/session-replay-lab.d.ts +13 -0
- package/dist/server/handlers/session-replay-lab.d.ts.map +1 -0
- package/dist/server/handlers/session-replay-lab.js +80 -0
- package/dist/server/handlers/session-replay-lab.js.map +1 -0
- package/dist/server/handlers/stats.js +1 -1
- package/dist/server/handlers/stats.js.map +1 -1
- package/dist/server/handlers/status.d.ts +44 -3
- package/dist/server/handlers/status.d.ts.map +1 -1
- package/dist/server/handlers/status.js +227 -17
- package/dist/server/handlers/status.js.map +1 -1
- package/dist/server/headless-runtime-service.d.ts +17 -0
- package/dist/server/headless-runtime-service.d.ts.map +1 -1
- package/dist/server/headless-runtime-service.js +143 -3
- package/dist/server/headless-runtime-service.js.map +1 -1
- package/dist/server/hosted-agent-runtime-progress.d.ts +17 -0
- package/dist/server/hosted-agent-runtime-progress.d.ts.map +1 -1
- package/dist/server/hosted-agent-runtime-progress.js +352 -15
- package/dist/server/hosted-agent-runtime-progress.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +14 -0
- package/dist/server/routes.js.map +1 -1
- package/dist/services/intelligent-router/index.d.ts +1 -1
- package/dist/services/intelligent-router/index.d.ts.map +1 -1
- package/dist/services/intelligent-router/index.js +1 -1
- package/dist/services/intelligent-router/index.js.map +1 -1
- package/dist/services/intelligent-router/normalize.d.ts +10 -2
- package/dist/services/intelligent-router/normalize.d.ts.map +1 -1
- package/dist/services/intelligent-router/normalize.js +20 -1
- package/dist/services/intelligent-router/normalize.js.map +1 -1
- package/dist/services/intelligent-router/service.d.ts.map +1 -1
- package/dist/services/intelligent-router/service.js +35 -0
- package/dist/services/intelligent-router/service.js.map +1 -1
- package/dist/services/intelligent-router/types.d.ts +13 -0
- package/dist/services/intelligent-router/types.d.ts.map +1 -1
- package/dist/services/intelligent-router/types.js +1 -0
- package/dist/services/intelligent-router/types.js.map +1 -1
- package/dist/telemetry/cli-command-aggregator.d.ts +1 -0
- package/dist/telemetry/cli-command-aggregator.d.ts.map +1 -1
- package/dist/telemetry/cli-command-aggregator.js +23 -0
- package/dist/telemetry/cli-command-aggregator.js.map +1 -1
- package/dist/telemetry/maestro-event-bus.d.ts.map +1 -1
- package/dist/telemetry/maestro-event-bus.js +11 -5
- package/dist/telemetry/maestro-event-bus.js.map +1 -1
- package/dist/telemetry/maestro-event-catalog.d.ts +15 -1
- package/dist/telemetry/maestro-event-catalog.d.ts.map +1 -1
- package/dist/telemetry/maestro-event-catalog.js +30 -0
- package/dist/telemetry/maestro-event-catalog.js.map +1 -1
- package/dist/version.json +2 -2
- package/package.json +289 -283
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { getEnvValue } from "../platform/client.js";
|
|
4
|
+
import { createLogger } from "../utils/logger.js";
|
|
5
|
+
const logger = createLogger("mcp:fathom-cua");
|
|
6
|
+
const DISABLED_VALUES = new Set(["0", "false", "no", "off"]);
|
|
7
|
+
const ENABLED_ENV_VARS = [
|
|
8
|
+
"MAESTRO_FATHOM_CUA_ENABLED",
|
|
9
|
+
"FATHOM_CUA_MCP_ENABLED",
|
|
10
|
+
];
|
|
11
|
+
const NAME_ENV_VARS = ["MAESTRO_FATHOM_CUA_MCP_NAME", "FATHOM_CUA_MCP_NAME"];
|
|
12
|
+
const COMMAND_ENV_VARS = [
|
|
13
|
+
"MAESTRO_FATHOM_CUA_CLIENT_COMMAND",
|
|
14
|
+
"FATHOM_CUA_CLIENT_COMMAND",
|
|
15
|
+
];
|
|
16
|
+
const ARGS_ENV_VARS = [
|
|
17
|
+
"MAESTRO_FATHOM_CUA_CLIENT_ARGS_JSON",
|
|
18
|
+
"FATHOM_CUA_CLIENT_ARGS_JSON",
|
|
19
|
+
];
|
|
20
|
+
const REPO_ENV_VARS = ["MAESTRO_FATHOM_CUA_REPO", "FATHOM_CUA_REPO"];
|
|
21
|
+
const CWD_ENV_VARS = [
|
|
22
|
+
"MAESTRO_FATHOM_CUA_CLIENT_CWD",
|
|
23
|
+
"FATHOM_CUA_CLIENT_CWD",
|
|
24
|
+
];
|
|
25
|
+
const WORKSPACE_ENV_VARS = [
|
|
26
|
+
"MAESTRO_FATHOM_CUA_WORKSPACE_ID",
|
|
27
|
+
"FATHOM_CUA_WORKSPACE_ID",
|
|
28
|
+
"MAESTRO_WORKSPACE_ID",
|
|
29
|
+
"MAESTRO_EVALOPS_WORKSPACE_ID",
|
|
30
|
+
"EVALOPS_WORKSPACE_ID",
|
|
31
|
+
];
|
|
32
|
+
const HELPER_ENDPOINT_ENV_VARS = [
|
|
33
|
+
"MAESTRO_FATHOM_CUA_HELPER_ENDPOINT",
|
|
34
|
+
"FATHOM_CUA_HELPER_ENDPOINT",
|
|
35
|
+
];
|
|
36
|
+
const IPC_ROOT_ENV_VARS = [
|
|
37
|
+
"MAESTRO_FATHOM_CUA_IPC_ROOT",
|
|
38
|
+
"FATHOM_CUA_IPC_ROOT",
|
|
39
|
+
"FATHOM_IPC_ROOT",
|
|
40
|
+
];
|
|
41
|
+
const SESSION_ID_ENV_VARS = [
|
|
42
|
+
"MAESTRO_FATHOM_CUA_SESSION_ID",
|
|
43
|
+
"FATHOM_CUA_SESSION_ID",
|
|
44
|
+
"MAESTRO_SESSION_ID",
|
|
45
|
+
];
|
|
46
|
+
const TURN_ID_ENV_VARS = [
|
|
47
|
+
"MAESTRO_FATHOM_CUA_TURN_ID",
|
|
48
|
+
"FATHOM_CUA_TURN_ID",
|
|
49
|
+
"MAESTRO_AGENT_RUN_ID",
|
|
50
|
+
"MAESTRO_REQUEST_ID",
|
|
51
|
+
];
|
|
52
|
+
const DISABLE_IPC_ENV_VARS = [
|
|
53
|
+
"MAESTRO_FATHOM_CUA_DISABLE_IPC",
|
|
54
|
+
"FATHOM_CUA_DISABLE_IPC",
|
|
55
|
+
];
|
|
56
|
+
const DEFAULT_SERVER_NAME = "fathom-cua";
|
|
57
|
+
function envFlagEnabled(names) {
|
|
58
|
+
const value = getEnvValue(names);
|
|
59
|
+
if (!value) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return !DISABLED_VALUES.has(value.trim().toLowerCase());
|
|
63
|
+
}
|
|
64
|
+
function envFlagDisabled(names) {
|
|
65
|
+
const value = getEnvValue(names);
|
|
66
|
+
if (!value) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return DISABLED_VALUES.has(value.trim().toLowerCase());
|
|
70
|
+
}
|
|
71
|
+
function parseArgsJson(raw) {
|
|
72
|
+
if (!raw) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const parsed = JSON.parse(raw);
|
|
77
|
+
if (!Array.isArray(parsed)) {
|
|
78
|
+
throw new Error("expected an array");
|
|
79
|
+
}
|
|
80
|
+
return parsed.map((item) => {
|
|
81
|
+
if (typeof item !== "string") {
|
|
82
|
+
throw new Error("expected only string arguments");
|
|
83
|
+
}
|
|
84
|
+
return item;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
logger.warn("Ignoring invalid Fathom CUA MCP args JSON", {
|
|
89
|
+
error: error instanceof Error ? error.message : String(error),
|
|
90
|
+
});
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function appendFlag(args, flag, value) {
|
|
95
|
+
if (value) {
|
|
96
|
+
args.push(flag, value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function resolveFathomRepo() {
|
|
100
|
+
const configured = getEnvValue(REPO_ENV_VARS);
|
|
101
|
+
if (configured) {
|
|
102
|
+
return configured;
|
|
103
|
+
}
|
|
104
|
+
const candidates = [
|
|
105
|
+
join(process.cwd(), "..", "fathom"),
|
|
106
|
+
join(process.cwd(), "..", "..", "fathom"),
|
|
107
|
+
join(process.cwd(), "..", "..", "..", "fathom"),
|
|
108
|
+
];
|
|
109
|
+
return candidates.find((candidate) => existsSync(join(candidate, "cmd", "fathom-client", "main.go")));
|
|
110
|
+
}
|
|
111
|
+
function buildFathomCuaServer() {
|
|
112
|
+
const repo = resolveFathomRepo();
|
|
113
|
+
const configuredCommand = getEnvValue(COMMAND_ENV_VARS);
|
|
114
|
+
const configuredCwd = getEnvValue(CWD_ENV_VARS);
|
|
115
|
+
const command = configuredCommand ?? (repo ? "go" : "fathom-client");
|
|
116
|
+
const cwd = configuredCwd ?? (configuredCommand ? undefined : repo);
|
|
117
|
+
const extraArgs = parseArgsJson(getEnvValue(ARGS_ENV_VARS));
|
|
118
|
+
const args = configuredCommand
|
|
119
|
+
? [...extraArgs]
|
|
120
|
+
: repo
|
|
121
|
+
? ["run", "./cmd/fathom-client", ...extraArgs]
|
|
122
|
+
: [...extraArgs];
|
|
123
|
+
const workspaceId = getEnvValue(WORKSPACE_ENV_VARS);
|
|
124
|
+
const helperEndpoint = getEnvValue(HELPER_ENDPOINT_ENV_VARS);
|
|
125
|
+
const ipcRoot = getEnvValue(IPC_ROOT_ENV_VARS);
|
|
126
|
+
const sessionId = getEnvValue(SESSION_ID_ENV_VARS);
|
|
127
|
+
const turnId = getEnvValue(TURN_ID_ENV_VARS);
|
|
128
|
+
appendFlag(args, "-workspace-id", workspaceId);
|
|
129
|
+
appendFlag(args, "-helper-endpoint", helperEndpoint);
|
|
130
|
+
appendFlag(args, "-ipc-root", ipcRoot);
|
|
131
|
+
appendFlag(args, "-session-id", sessionId);
|
|
132
|
+
appendFlag(args, "-turn-id", turnId);
|
|
133
|
+
if (envFlagEnabled(DISABLE_IPC_ENV_VARS)) {
|
|
134
|
+
args.push("-disable-ipc");
|
|
135
|
+
}
|
|
136
|
+
const env = Object.fromEntries(Object.entries({
|
|
137
|
+
FATHOM_CALLER_PRODUCT: "maestro",
|
|
138
|
+
FATHOM_CUA_PRODUCT: "maestro",
|
|
139
|
+
FATHOM_CUA_WORKSPACE_ID: workspaceId,
|
|
140
|
+
FATHOM_IPC_ROOT: ipcRoot,
|
|
141
|
+
}).filter((entry) => Boolean(entry[1])));
|
|
142
|
+
return {
|
|
143
|
+
name: getEnvValue(NAME_ENV_VARS) ?? DEFAULT_SERVER_NAME,
|
|
144
|
+
transport: "stdio",
|
|
145
|
+
command,
|
|
146
|
+
args,
|
|
147
|
+
cwd,
|
|
148
|
+
env,
|
|
149
|
+
scope: "plugin",
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export function getFathomCuaPluginServers() {
|
|
153
|
+
if (envFlagDisabled(ENABLED_ENV_VARS) || !envFlagEnabled(ENABLED_ENV_VARS)) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
return [buildFathomCuaServer()];
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=fathom-cua.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fathom-cua.js","sourceRoot":"","sources":["../../src/mcp/fathom-cua.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,MAAM,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AAE9C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7D,MAAM,gBAAgB,GAAG;IACxB,4BAA4B;IAC5B,wBAAwB;CACf,CAAC;AACX,MAAM,aAAa,GAAG,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;AAC7E,MAAM,gBAAgB,GAAG;IACxB,mCAAmC;IACnC,2BAA2B;CAClB,CAAC;AACX,MAAM,aAAa,GAAG;IACrB,qCAAqC;IACrC,6BAA6B;CACpB,CAAC;AACX,MAAM,aAAa,GAAG,CAAC,yBAAyB,EAAE,iBAAiB,CAAU,CAAC;AAC9E,MAAM,YAAY,GAAG;IACpB,+BAA+B;IAC/B,uBAAuB;CACd,CAAC;AACX,MAAM,kBAAkB,GAAG;IAC1B,iCAAiC;IACjC,yBAAyB;IACzB,sBAAsB;IACtB,8BAA8B;IAC9B,sBAAsB;C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,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;IAC3C,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,cAAc,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAC7B,MAAM,CAAC,OAAO,CAAC;QACd,qBAAqB,EAAE,SAAS;QAChC,kBAAkB,EAAE,SAAS;QAC7B,uBAAuB,EAAE,WAAW;QACpC,eAAe,EAAE,OAAO;KACxB,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAClE,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC,IAAI,mBAAmB;QACvD,SAAS,EAAE,OAAO;QAClB,OAAO;QACP,IAAI;QACJ,GAAG;QACH,GAAG;QACH,KAAK,EAAE,QAAQ;KACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB;IACxC,IAAI,eAAe,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC5E,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { getEnvValue } from \"../platform/client.js\";\nimport { createLogger } from \"../utils/logger.js\";\nimport type { McpServerConfig } from \"./types.js\";\n\nconst logger = createLogger(\"mcp:fathom-cua\");\n\nconst DISABLED_VALUES = new Set([\"0\", \"false\", \"no\", \"off\"]);\nconst ENABLED_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_ENABLED\",\n\t\"FATHOM_CUA_MCP_ENABLED\",\n] as const;\nconst NAME_ENV_VARS = [\"MAESTRO_FATHOM_CUA_MCP_NAME\", \"FATHOM_CUA_MCP_NAME\"];\nconst COMMAND_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_CLIENT_COMMAND\",\n\t\"FATHOM_CUA_CLIENT_COMMAND\",\n] as const;\nconst ARGS_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_CLIENT_ARGS_JSON\",\n\t\"FATHOM_CUA_CLIENT_ARGS_JSON\",\n] as const;\nconst REPO_ENV_VARS = [\"MAESTRO_FATHOM_CUA_REPO\", \"FATHOM_CUA_REPO\"] as const;\nconst CWD_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_CLIENT_CWD\",\n\t\"FATHOM_CUA_CLIENT_CWD\",\n] as const;\nconst WORKSPACE_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_WORKSPACE_ID\",\n\t\"FATHOM_CUA_WORKSPACE_ID\",\n\t\"MAESTRO_WORKSPACE_ID\",\n\t\"MAESTRO_EVALOPS_WORKSPACE_ID\",\n\t\"EVALOPS_WORKSPACE_ID\",\n] as const;\nconst HELPER_ENDPOINT_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_HELPER_ENDPOINT\",\n\t\"FATHOM_CUA_HELPER_ENDPOINT\",\n] as const;\nconst IPC_ROOT_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_IPC_ROOT\",\n\t\"FATHOM_CUA_IPC_ROOT\",\n\t\"FATHOM_IPC_ROOT\",\n] as const;\nconst SESSION_ID_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_SESSION_ID\",\n\t\"FATHOM_CUA_SESSION_ID\",\n\t\"MAESTRO_SESSION_ID\",\n] as const;\nconst TURN_ID_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_TURN_ID\",\n\t\"FATHOM_CUA_TURN_ID\",\n\t\"MAESTRO_AGENT_RUN_ID\",\n\t\"MAESTRO_REQUEST_ID\",\n] as const;\nconst DISABLE_IPC_ENV_VARS = [\n\t\"MAESTRO_FATHOM_CUA_DISABLE_IPC\",\n\t\"FATHOM_CUA_DISABLE_IPC\",\n] as const;\nconst DEFAULT_SERVER_NAME = \"fathom-cua\";\n\nfunction envFlagEnabled(names: readonly string[]): boolean {\n\tconst value = getEnvValue(names);\n\tif (!value) {\n\t\treturn false;\n\t}\n\treturn !DISABLED_VALUES.has(value.trim().toLowerCase());\n}\n\nfunction envFlagDisabled(names: readonly string[]): boolean {\n\tconst value = getEnvValue(names);\n\tif (!value) {\n\t\treturn false;\n\t}\n\treturn DISABLED_VALUES.has(value.trim().toLowerCase());\n}\n\nfunction parseArgsJson(raw: string | undefined): string[] {\n\tif (!raw) {\n\t\treturn [];\n\t}\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as unknown;\n\t\tif (!Array.isArray(parsed)) {\n\t\t\tthrow new Error(\"expected an array\");\n\t\t}\n\t\treturn parsed.map((item) => {\n\t\t\tif (typeof item !== \"string\") {\n\t\t\t\tthrow new Error(\"expected only string arguments\");\n\t\t\t}\n\t\t\treturn item;\n\t\t});\n\t} catch (error) {\n\t\tlogger.warn(\"Ignoring invalid Fathom CUA MCP args JSON\", {\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t});\n\t\treturn [];\n\t}\n}\n\nfunction appendFlag(\n\targs: string[],\n\tflag: string,\n\tvalue: string | undefined,\n): void {\n\tif (value) {\n\t\targs.push(flag, value);\n\t}\n}\n\nfunction resolveFathomRepo(): string | undefined {\n\tconst configured = getEnvValue(REPO_ENV_VARS);\n\tif (configured) {\n\t\treturn configured;\n\t}\n\n\tconst candidates = [\n\t\tjoin(process.cwd(), \"..\", \"fathom\"),\n\t\tjoin(process.cwd(), \"..\", \"..\", \"fathom\"),\n\t\tjoin(process.cwd(), \"..\", \"..\", \"..\", \"fathom\"),\n\t];\n\treturn candidates.find((candidate) =>\n\t\texistsSync(join(candidate, \"cmd\", \"fathom-client\", \"main.go\")),\n\t);\n}\n\nfunction buildFathomCuaServer(): McpServerConfig {\n\tconst repo = resolveFathomRepo();\n\tconst configuredCommand = getEnvValue(COMMAND_ENV_VARS);\n\tconst configuredCwd = getEnvValue(CWD_ENV_VARS);\n\tconst command = configuredCommand ?? (repo ? \"go\" : \"fathom-client\");\n\tconst cwd = configuredCwd ?? (configuredCommand ? undefined : repo);\n\tconst extraArgs = parseArgsJson(getEnvValue(ARGS_ENV_VARS));\n\tconst args = configuredCommand\n\t\t? [...extraArgs]\n\t\t: repo\n\t\t\t? [\"run\", \"./cmd/fathom-client\", ...extraArgs]\n\t\t\t: [...extraArgs];\n\tconst workspaceId = getEnvValue(WORKSPACE_ENV_VARS);\n\tconst helperEndpoint = getEnvValue(HELPER_ENDPOINT_ENV_VARS);\n\tconst ipcRoot = getEnvValue(IPC_ROOT_ENV_VARS);\n\tconst sessionId = getEnvValue(SESSION_ID_ENV_VARS);\n\tconst turnId = getEnvValue(TURN_ID_ENV_VARS);\n\n\tappendFlag(args, \"-workspace-id\", workspaceId);\n\tappendFlag(args, \"-helper-endpoint\", helperEndpoint);\n\tappendFlag(args, \"-ipc-root\", ipcRoot);\n\tappendFlag(args, \"-session-id\", sessionId);\n\tappendFlag(args, \"-turn-id\", turnId);\n\tif (envFlagEnabled(DISABLE_IPC_ENV_VARS)) {\n\t\targs.push(\"-disable-ipc\");\n\t}\n\n\tconst env = Object.fromEntries(\n\t\tObject.entries({\n\t\t\tFATHOM_CALLER_PRODUCT: \"maestro\",\n\t\t\tFATHOM_CUA_PRODUCT: \"maestro\",\n\t\t\tFATHOM_CUA_WORKSPACE_ID: workspaceId,\n\t\t\tFATHOM_IPC_ROOT: ipcRoot,\n\t\t}).filter((entry): entry is [string, string] => Boolean(entry[1])),\n\t);\n\n\treturn {\n\t\tname: getEnvValue(NAME_ENV_VARS) ?? DEFAULT_SERVER_NAME,\n\t\ttransport: \"stdio\",\n\t\tcommand,\n\t\targs,\n\t\tcwd,\n\t\tenv,\n\t\tscope: \"plugin\",\n\t};\n}\n\nexport function getFathomCuaPluginServers(): McpServerConfig[] {\n\tif (envFlagDisabled(ENABLED_ENV_VARS) || !envFlagEnabled(ENABLED_ENV_VARS)) {\n\t\treturn [];\n\t}\n\treturn [buildFathomCuaServer()];\n}\n"]}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { buildMcpToolName, isMcpTool, parseMcpToolName } from "./names.js";
|
|
|
5
5
|
export { defaultEnvValidators, evaluateEnvValidators, type EnvValidator, type EnvValidatorResult, } from "./env-limits.js";
|
|
6
6
|
export { getMcpRemoteHost, getOfficialMcpRegistryUrls, getOfficialMcpRegistryEntries, getOfficialMcpRegistryMatch, normalizeMcpRemoteUrl, officialMcpRegistryEntryMatchesUrl, prefetchOfficialMcpRegistry, resetOfficialMcpRegistryCacheForTesting, resolveOfficialMcpRegistryEntry, searchOfficialMcpRegistry, setOfficialMcpRegistryCacheForTesting, buildSuggestedMcpServerName, } from "./official-registry.js";
|
|
7
7
|
export { buildProjectMcpServerFingerprint, getProjectMcpServerApprovalStatus, setProjectMcpServerApprovalDecision, } from "./project-approvals.js";
|
|
8
|
+
export { getFathomCuaPluginServers } from "./fathom-cua.js";
|
|
8
9
|
export { getPlatformMcpPluginServers } from "./platform-plugin.js";
|
|
9
10
|
export type { McpAuthPresetConfig, McpAuthPresetStatus, McpConfig, McpOfficialRegistryEntry, McpOfficialRegistryInfo, McpOfficialRegistryUrlOption, McpProjectApprovalDecision, McpProjectApprovalStatus, McpServerConfig, McpServerStatus, McpManagerStatus, McpRemoteTrust, McpTransport, McpScope, } from "./types.js";
|
|
10
11
|
export type { McpAuthPresetInput, McpServerInput } from "./schema.js";
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,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ACb,6BAA6B,EAC7B,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,EACvB,KAAK,gBAAgB,GACrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,aAAa,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EACN,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,YAAY,EACjB,KAAK,kBAAkB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,gBAAgB,EAChB,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,qBAAqB,EACrB,kCAAkC,EAClC,2BAA2B,EAC3B,uCAAuC,EACvC,+BAA+B,EAC/B,yBAAyB,EACzB,qCAAqC,EACrC,2BAA2B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,gCAAgC,EAChC,iCAAiC,EACjC,mCAAmC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,YAAY,EACX,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,QAAQ,GACR,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -5,5 +5,6 @@ export { buildMcpToolName, isMcpTool, parseMcpToolName } from "./names.js";
|
|
|
5
5
|
export { defaultEnvValidators, evaluateEnvValidators, } from "./env-limits.js";
|
|
6
6
|
export { getMcpRemoteHost, getOfficialMcpRegistryUrls, getOfficialMcpRegistryEntries, getOfficialMcpRegistryMatch, normalizeMcpRemoteUrl, officialMcpRegistryEntryMatchesUrl, prefetchOfficialMcpRegistry, resetOfficialMcpRegistryCacheForTesting, resolveOfficialMcpRegistryEntry, searchOfficialMcpRegistry, setOfficialMcpRegistryCacheForTesting, buildSuggestedMcpServerName, } from "./official-registry.js";
|
|
7
7
|
export { buildProjectMcpServerFingerprint, getProjectMcpServerApprovalStatus, setProjectMcpServerApprovalDecision, } from "./project-approvals.js";
|
|
8
|
+
export { getFathomCuaPluginServers } from "./fathom-cua.js";
|
|
8
9
|
export { getPlatformMcpPluginServers } from "./platform-plugin.js";
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,EACb,6BAA6B,EAC7B,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,GAEvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,aAAa,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EACN,oBAAoB,EACpB,qBAAqB,GAGrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,gBAAgB,EAChB,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,qBAAqB,EACrB,kCAAkC,EAClC,2BAA2B,EAC3B,uCAAuC,EACvC,+BAA+B,EAC/B,yBAAyB,EACzB,qCAAqC,EACrC,2BAA2B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,gCAAgC,EAChC,iCAAiC,EACjC,mCAAmC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export {\n\taddMcpAuthPresetToConfig,\n\taddMcpServerToConfig,\n\tgetConfigPaths,\n\tgetWritableMcpConfigPath,\n\tinferRemoteMcpTransport,\n\tloadMcpConfig,\n\tremoveMcpAuthPresetFromConfig,\n\tremoveMcpServerFromConfig,\n\tupdateMcpAuthPresetInConfig,\n\tupdateMcpServerInConfig,\n\ttype WritableMcpScope,\n} from \"./config.js\";\nexport { mcpManager, McpClientManager } from \"./manager.js\";\nexport {\n\tcreateMcpToolWrapper,\n\tgetAllMcpTools,\n\tgetMcpToolMap,\n} from \"./tool-bridge.js\";\nexport { buildMcpToolName, isMcpTool, parseMcpToolName } from \"./names.js\";\nexport {\n\tdefaultEnvValidators,\n\tevaluateEnvValidators,\n\ttype EnvValidator,\n\ttype EnvValidatorResult,\n} from \"./env-limits.js\";\nexport {\n\tgetMcpRemoteHost,\n\tgetOfficialMcpRegistryUrls,\n\tgetOfficialMcpRegistryEntries,\n\tgetOfficialMcpRegistryMatch,\n\tnormalizeMcpRemoteUrl,\n\tofficialMcpRegistryEntryMatchesUrl,\n\tprefetchOfficialMcpRegistry,\n\tresetOfficialMcpRegistryCacheForTesting,\n\tresolveOfficialMcpRegistryEntry,\n\tsearchOfficialMcpRegistry,\n\tsetOfficialMcpRegistryCacheForTesting,\n\tbuildSuggestedMcpServerName,\n} from \"./official-registry.js\";\nexport {\n\tbuildProjectMcpServerFingerprint,\n\tgetProjectMcpServerApprovalStatus,\n\tsetProjectMcpServerApprovalDecision,\n} from \"./project-approvals.js\";\nexport { getPlatformMcpPluginServers } from \"./platform-plugin.js\";\nexport type {\n\tMcpAuthPresetConfig,\n\tMcpAuthPresetStatus,\n\tMcpConfig,\n\tMcpOfficialRegistryEntry,\n\tMcpOfficialRegistryInfo,\n\tMcpOfficialRegistryUrlOption,\n\tMcpProjectApprovalDecision,\n\tMcpProjectApprovalStatus,\n\tMcpServerConfig,\n\tMcpServerStatus,\n\tMcpManagerStatus,\n\tMcpRemoteTrust,\n\tMcpTransport,\n\tMcpScope,\n} from \"./types.js\";\nexport type { McpAuthPresetInput, McpServerInput } from \"./schema.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,oBAAoB,EACpB,cAAc,EACd,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,EACb,6BAA6B,EAC7B,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,GAEvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,aAAa,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EACN,oBAAoB,EACpB,qBAAqB,GAGrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,gBAAgB,EAChB,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAC3B,qBAAqB,EACrB,kCAAkC,EAClC,2BAA2B,EAC3B,uCAAuC,EACvC,+BAA+B,EAC/B,yBAAyB,EACzB,qCAAqC,EACrC,2BAA2B,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,gCAAgC,EAChC,iCAAiC,EACjC,mCAAmC,GACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export {\n\taddMcpAuthPresetToConfig,\n\taddMcpServerToConfig,\n\tgetConfigPaths,\n\tgetWritableMcpConfigPath,\n\tinferRemoteMcpTransport,\n\tloadMcpConfig,\n\tremoveMcpAuthPresetFromConfig,\n\tremoveMcpServerFromConfig,\n\tupdateMcpAuthPresetInConfig,\n\tupdateMcpServerInConfig,\n\ttype WritableMcpScope,\n} from \"./config.js\";\nexport { mcpManager, McpClientManager } from \"./manager.js\";\nexport {\n\tcreateMcpToolWrapper,\n\tgetAllMcpTools,\n\tgetMcpToolMap,\n} from \"./tool-bridge.js\";\nexport { buildMcpToolName, isMcpTool, parseMcpToolName } from \"./names.js\";\nexport {\n\tdefaultEnvValidators,\n\tevaluateEnvValidators,\n\ttype EnvValidator,\n\ttype EnvValidatorResult,\n} from \"./env-limits.js\";\nexport {\n\tgetMcpRemoteHost,\n\tgetOfficialMcpRegistryUrls,\n\tgetOfficialMcpRegistryEntries,\n\tgetOfficialMcpRegistryMatch,\n\tnormalizeMcpRemoteUrl,\n\tofficialMcpRegistryEntryMatchesUrl,\n\tprefetchOfficialMcpRegistry,\n\tresetOfficialMcpRegistryCacheForTesting,\n\tresolveOfficialMcpRegistryEntry,\n\tsearchOfficialMcpRegistry,\n\tsetOfficialMcpRegistryCacheForTesting,\n\tbuildSuggestedMcpServerName,\n} from \"./official-registry.js\";\nexport {\n\tbuildProjectMcpServerFingerprint,\n\tgetProjectMcpServerApprovalStatus,\n\tsetProjectMcpServerApprovalDecision,\n} from \"./project-approvals.js\";\nexport { getFathomCuaPluginServers } from \"./fathom-cua.js\";\nexport { getPlatformMcpPluginServers } from \"./platform-plugin.js\";\nexport type {\n\tMcpAuthPresetConfig,\n\tMcpAuthPresetStatus,\n\tMcpConfig,\n\tMcpOfficialRegistryEntry,\n\tMcpOfficialRegistryInfo,\n\tMcpOfficialRegistryUrlOption,\n\tMcpProjectApprovalDecision,\n\tMcpProjectApprovalStatus,\n\tMcpServerConfig,\n\tMcpServerStatus,\n\tMcpManagerStatus,\n\tMcpRemoteTrust,\n\tMcpTransport,\n\tMcpScope,\n} from \"./types.js\";\nexport type { McpAuthPresetInput, McpServerInput } from \"./schema.js\";\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type ArtifactsCommand = "create" | "update" | "rewrite" | "get" | "delete" | "logs";
|
|
2
|
+
export type ArtifactCommandErrorCode = "artifact.command_missing" | "artifact.command_unknown" | "artifact.filename_missing" | "artifact.filename_invalid" | "artifact.exists" | "artifact.not_found" | "artifact.update_args_missing" | "artifact.update_empty_old_str" | "artifact.update_old_str_not_found";
|
|
3
|
+
export type ArtifactCommandSuccessCode = "artifact.created" | "artifact.rewritten" | "artifact.updated" | "artifact.read" | "artifact.deleted" | "artifact.logs_requested";
|
|
4
|
+
export type ArtifactCommandResultCode = ArtifactCommandErrorCode | ArtifactCommandSuccessCode;
|
|
5
|
+
export interface ArtifactsArgs {
|
|
6
|
+
command?: ArtifactsCommand | string;
|
|
7
|
+
filename?: string;
|
|
8
|
+
content?: string;
|
|
9
|
+
old_str?: string;
|
|
10
|
+
new_str?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Artifact {
|
|
13
|
+
filename: string;
|
|
14
|
+
content: string;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
updatedAt: number;
|
|
17
|
+
}
|
|
18
|
+
export interface ArtifactsState {
|
|
19
|
+
byFilename: Map<string, Artifact>;
|
|
20
|
+
}
|
|
21
|
+
export interface ArtifactCommandResult {
|
|
22
|
+
state: ArtifactsState;
|
|
23
|
+
output: string;
|
|
24
|
+
isError: boolean;
|
|
25
|
+
code: ArtifactCommandResultCode;
|
|
26
|
+
mutated: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ArtifactReplayDiagnostic {
|
|
29
|
+
code: ArtifactCommandResultCode;
|
|
30
|
+
command?: string;
|
|
31
|
+
filename?: string;
|
|
32
|
+
isError: boolean;
|
|
33
|
+
mutated: boolean;
|
|
34
|
+
output: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ArtifactReplayOptions {
|
|
37
|
+
onDiagnostic?: (diagnostic: ArtifactReplayDiagnostic) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface ArtifactReplayToolCall {
|
|
40
|
+
id?: unknown;
|
|
41
|
+
name?: string;
|
|
42
|
+
status?: string;
|
|
43
|
+
toolCallId?: unknown;
|
|
44
|
+
args?: unknown;
|
|
45
|
+
result?: unknown;
|
|
46
|
+
}
|
|
47
|
+
export interface ArtifactReplayMessage {
|
|
48
|
+
content?: unknown;
|
|
49
|
+
role?: unknown;
|
|
50
|
+
tools?: ArtifactReplayToolCall[];
|
|
51
|
+
}
|
|
52
|
+
export declare function createEmptyArtifactsState(): ArtifactsState;
|
|
53
|
+
export declare function isValidArtifactFilename(filename: string): boolean;
|
|
54
|
+
export declare function coerceArtifactsArgs(value: unknown): ArtifactsArgs;
|
|
55
|
+
export declare function applyArtifactsCommand(state: ArtifactsState, args: ArtifactsArgs): ArtifactCommandResult;
|
|
56
|
+
export declare function artifactContentsByFilename(state: ArtifactsState): Map<string, string>;
|
|
57
|
+
export declare function reconstructArtifactsFromMessages(messages: ArtifactReplayMessage[], options?: ArtifactReplayOptions): ArtifactsState;
|
|
58
|
+
//# sourceMappingURL=artifacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACzB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,KAAK,GACL,QAAQ,GACR,MAAM,CAAC;AAEV,MAAM,MAAM,wBAAwB,GACjC,0BAA0B,GAC1B,0BAA0B,GAC1B,2BAA2B,GAC3B,2BAA2B,GAC3B,iBAAiB,GACjB,oBAAoB,GACpB,8BAA8B,GAC9B,+BAA+B,GAC/B,mCAAmC,CAAC;AAEvC,MAAM,MAAM,0BAA0B,GACnC,kBAAkB,GAClB,oBAAoB,GACpB,kBAAkB,G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CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACjC;AAWD,wBAAgB,yBAAyB,IAAI,cAAc,CAE1D;AAkBD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAQjE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAUjE;AA+BD,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,aAAa,GACjB,qBAAqB,CAsKvB;AAED,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,cAAc,GACnB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAOrB;AAED,wBAAgB,gCAAgC,CAC/C,QAAQ,EAAE,qBAAqB,EAAE,EACjC,OAAO,GAAE,qBAA0B,GACjC,cAAc,CAgChB"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
const ARTIFACT_COMMANDS = new Set([
|
|
2
|
+
"create",
|
|
3
|
+
"update",
|
|
4
|
+
"rewrite",
|
|
5
|
+
"get",
|
|
6
|
+
"delete",
|
|
7
|
+
"logs",
|
|
8
|
+
]);
|
|
9
|
+
export function createEmptyArtifactsState() {
|
|
10
|
+
return { byFilename: new Map() };
|
|
11
|
+
}
|
|
12
|
+
function asString(value) {
|
|
13
|
+
return typeof value === "string" ? value : undefined;
|
|
14
|
+
}
|
|
15
|
+
function isValidArtifactCommand(command) {
|
|
16
|
+
return typeof command === "string" && ARTIFACT_COMMANDS.has(command);
|
|
17
|
+
}
|
|
18
|
+
function hasControlCharacter(value) {
|
|
19
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
20
|
+
const code = value.charCodeAt(index);
|
|
21
|
+
if (code < 32 || code === 127)
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
export function isValidArtifactFilename(filename) {
|
|
27
|
+
return (filename.length > 0 &&
|
|
28
|
+
!filename.includes("..") &&
|
|
29
|
+
!filename.includes("/") &&
|
|
30
|
+
!filename.includes("\\") &&
|
|
31
|
+
!hasControlCharacter(filename));
|
|
32
|
+
}
|
|
33
|
+
export function coerceArtifactsArgs(value) {
|
|
34
|
+
if (!value || typeof value !== "object")
|
|
35
|
+
return {};
|
|
36
|
+
const v = value;
|
|
37
|
+
return {
|
|
38
|
+
command: asString(v.command),
|
|
39
|
+
filename: asString(v.filename),
|
|
40
|
+
content: asString(v.content),
|
|
41
|
+
old_str: asString(v.old_str),
|
|
42
|
+
new_str: asString(v.new_str),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function artifactError(state, code, message) {
|
|
46
|
+
return {
|
|
47
|
+
state,
|
|
48
|
+
output: `Error [${code}]: ${message}`,
|
|
49
|
+
isError: true,
|
|
50
|
+
code,
|
|
51
|
+
mutated: false,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function artifactSuccess(state, code, output, mutated) {
|
|
55
|
+
return {
|
|
56
|
+
state,
|
|
57
|
+
output,
|
|
58
|
+
isError: false,
|
|
59
|
+
code,
|
|
60
|
+
mutated,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function applyArtifactsCommand(state, args) {
|
|
64
|
+
const command = args.command;
|
|
65
|
+
const filename = args.filename?.trim();
|
|
66
|
+
if (!command) {
|
|
67
|
+
return artifactError(state, "artifact.command_missing", "missing command");
|
|
68
|
+
}
|
|
69
|
+
if (!isValidArtifactCommand(command)) {
|
|
70
|
+
return artifactError(state, "artifact.command_unknown", `unknown command: ${command}`);
|
|
71
|
+
}
|
|
72
|
+
if (!filename) {
|
|
73
|
+
return artifactError(state, "artifact.filename_missing", "missing filename");
|
|
74
|
+
}
|
|
75
|
+
if (!isValidArtifactFilename(filename)) {
|
|
76
|
+
return artifactError(state, "artifact.filename_invalid", "invalid filename");
|
|
77
|
+
}
|
|
78
|
+
const current = state.byFilename.get(filename);
|
|
79
|
+
switch (command) {
|
|
80
|
+
case "create": {
|
|
81
|
+
if (current) {
|
|
82
|
+
return artifactError(state, "artifact.exists", `${filename} already exists`);
|
|
83
|
+
}
|
|
84
|
+
const content = args.content ?? "";
|
|
85
|
+
const now = Date.now();
|
|
86
|
+
const next = new Map(state.byFilename);
|
|
87
|
+
next.set(filename, {
|
|
88
|
+
filename,
|
|
89
|
+
content,
|
|
90
|
+
createdAt: now,
|
|
91
|
+
updatedAt: now,
|
|
92
|
+
});
|
|
93
|
+
return artifactSuccess({ byFilename: next }, "artifact.created", `Created ${filename}`, true);
|
|
94
|
+
}
|
|
95
|
+
case "rewrite": {
|
|
96
|
+
if (!current) {
|
|
97
|
+
return artifactError(state, "artifact.not_found", `${filename} not found`);
|
|
98
|
+
}
|
|
99
|
+
const content = args.content ?? "";
|
|
100
|
+
const next = new Map(state.byFilename);
|
|
101
|
+
next.set(filename, { ...current, content, updatedAt: Date.now() });
|
|
102
|
+
return artifactSuccess({ byFilename: next }, "artifact.rewritten", `Rewrote ${filename}`, true);
|
|
103
|
+
}
|
|
104
|
+
case "update": {
|
|
105
|
+
if (!current) {
|
|
106
|
+
return artifactError(state, "artifact.not_found", `${filename} not found`);
|
|
107
|
+
}
|
|
108
|
+
const oldStr = args.old_str;
|
|
109
|
+
const newStr = args.new_str;
|
|
110
|
+
if (oldStr === undefined || newStr === undefined) {
|
|
111
|
+
return artifactError(state, "artifact.update_args_missing", "update requires old_str and new_str");
|
|
112
|
+
}
|
|
113
|
+
if (oldStr.length === 0) {
|
|
114
|
+
return artifactError(state, "artifact.update_empty_old_str", "update requires non-empty old_str");
|
|
115
|
+
}
|
|
116
|
+
if (!current.content.includes(oldStr)) {
|
|
117
|
+
return artifactError(state, "artifact.update_old_str_not_found", `old_str not found in ${filename}`);
|
|
118
|
+
}
|
|
119
|
+
const nextContent = current.content.replace(oldStr, newStr);
|
|
120
|
+
const next = new Map(state.byFilename);
|
|
121
|
+
next.set(filename, {
|
|
122
|
+
...current,
|
|
123
|
+
content: nextContent,
|
|
124
|
+
updatedAt: Date.now(),
|
|
125
|
+
});
|
|
126
|
+
return artifactSuccess({ byFilename: next }, "artifact.updated", `Updated ${filename}`, true);
|
|
127
|
+
}
|
|
128
|
+
case "get": {
|
|
129
|
+
if (!current) {
|
|
130
|
+
return artifactError(state, "artifact.not_found", `${filename} not found`);
|
|
131
|
+
}
|
|
132
|
+
return artifactSuccess(state, "artifact.read", current.content, false);
|
|
133
|
+
}
|
|
134
|
+
case "delete": {
|
|
135
|
+
if (!current) {
|
|
136
|
+
return artifactError(state, "artifact.not_found", `${filename} not found`);
|
|
137
|
+
}
|
|
138
|
+
const next = new Map(state.byFilename);
|
|
139
|
+
next.delete(filename);
|
|
140
|
+
return artifactSuccess({ byFilename: next }, "artifact.deleted", `Deleted ${filename}`, true);
|
|
141
|
+
}
|
|
142
|
+
case "logs": {
|
|
143
|
+
if (!current) {
|
|
144
|
+
return artifactError(state, "artifact.not_found", `${filename} not found`);
|
|
145
|
+
}
|
|
146
|
+
return artifactSuccess(state, "artifact.logs_requested", `Logs requested for ${filename}`, false);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export function artifactContentsByFilename(state) {
|
|
151
|
+
return new Map(Array.from(state.byFilename.entries(), ([filename, artifact]) => [
|
|
152
|
+
filename,
|
|
153
|
+
artifact.content,
|
|
154
|
+
]));
|
|
155
|
+
}
|
|
156
|
+
export function reconstructArtifactsFromMessages(messages, options = {}) {
|
|
157
|
+
let state = createEmptyArtifactsState();
|
|
158
|
+
for (const msg of messages) {
|
|
159
|
+
const toolCalls = msg.tools ?? [];
|
|
160
|
+
for (const tool of toolCalls) {
|
|
161
|
+
if (tool.name !== "artifacts")
|
|
162
|
+
continue;
|
|
163
|
+
if (tool.status !== "completed")
|
|
164
|
+
continue;
|
|
165
|
+
if (tool.result && typeof tool.result === "object") {
|
|
166
|
+
const maybeErr = tool.result;
|
|
167
|
+
if (maybeErr.isError)
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const args = coerceArtifactsArgs(tool.args);
|
|
171
|
+
// Ignore get/logs for reconstruction; they don't change state.
|
|
172
|
+
if (args.command === "get" || args.command === "logs")
|
|
173
|
+
continue;
|
|
174
|
+
const result = applyArtifactsCommand(state, args);
|
|
175
|
+
if (result.isError || !result.mutated) {
|
|
176
|
+
options.onDiagnostic?.({
|
|
177
|
+
code: result.code,
|
|
178
|
+
command: args.command,
|
|
179
|
+
filename: args.filename,
|
|
180
|
+
isError: result.isError,
|
|
181
|
+
mutated: result.mutated,
|
|
182
|
+
output: result.output,
|
|
183
|
+
});
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
state = result.state;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return state;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAsFA,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS;IACzC,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,KAAK;IACL,QAAQ;IACR,MAAM;CACN,CAAC,CAAC;AAEH,MAAM,UAAU,yBAAyB;IACxC,OAAO,EAAE,UAAU,EAAE,IAAI,GAAG,EAAoB,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAgB;IAC/C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,iBAA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,IAAI,CAAC,IAAI,KAAK,WAAW;gBAAE,SAAS;YACxC,IAAI,IAAI,CAAC,MAAM,KAAK,WAAW;gBAAE,SAAS;YAC1C,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAA+B,CAAC;gBACtD,IAAI,QAAQ,CAAC,OAAO;oBAAE,SAAS;YAChC,CAAC;YACD,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5C,+DAA+D;YAC/D,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM;gBAAE,SAAS;YAChE,MAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAClD,IAAI,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACvC,OAAO,CAAC,YAAY,EAAE,CAAC;oBACtB,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;oBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,MAAM,EAAE,MAAM,CAAC,MAAM;iBACrB,CAAC,CAAC;gBACH,SAAS;YACV,CAAC;YACD,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["export type ArtifactsCommand =\n\t| \"create\"\n\t| \"update\"\n\t| \"rewrite\"\n\t| \"get\"\n\t| \"delete\"\n\t| \"logs\";\n\nexport type ArtifactCommandErrorCode =\n\t| \"artifact.command_missing\"\n\t| \"artifact.command_unknown\"\n\t| \"artifact.filename_missing\"\n\t| \"artifact.filename_invalid\"\n\t| \"artifact.exists\"\n\t| \"artifact.not_found\"\n\t| \"artifact.update_args_missing\"\n\t| \"artifact.update_empty_old_str\"\n\t| \"artifact.update_old_str_not_found\";\n\nexport type ArtifactCommandSuccessCode =\n\t| \"artifact.created\"\n\t| \"artifact.rewritten\"\n\t| \"artifact.updated\"\n\t| \"artifact.read\"\n\t| \"artifact.deleted\"\n\t| \"artifact.logs_requested\";\n\nexport type ArtifactCommandResultCode =\n\t| ArtifactCommandErrorCode\n\t| ArtifactCommandSuccessCode;\n\nexport interface ArtifactsArgs {\n\tcommand?: ArtifactsCommand | string;\n\tfilename?: string;\n\tcontent?: string;\n\told_str?: string;\n\tnew_str?: string;\n}\n\nexport interface Artifact {\n\tfilename: string;\n\tcontent: string;\n\tcreatedAt: number;\n\tupdatedAt: number;\n}\n\nexport interface ArtifactsState {\n\tbyFilename: Map<string, Artifact>;\n}\n\nexport interface ArtifactCommandResult {\n\tstate: ArtifactsState;\n\toutput: string;\n\tisError: boolean;\n\tcode: ArtifactCommandResultCode;\n\tmutated: boolean;\n}\n\nexport interface ArtifactReplayDiagnostic {\n\tcode: ArtifactCommandResultCode;\n\tcommand?: string;\n\tfilename?: string;\n\tisError: boolean;\n\tmutated: boolean;\n\toutput: string;\n}\n\nexport interface ArtifactReplayOptions {\n\tonDiagnostic?: (diagnostic: ArtifactReplayDiagnostic) => void;\n}\n\nexport interface ArtifactReplayToolCall {\n\tid?: unknown;\n\tname?: string;\n\tstatus?: string;\n\ttoolCallId?: unknown;\n\targs?: unknown;\n\tresult?: unknown;\n}\n\nexport interface ArtifactReplayMessage {\n\tcontent?: unknown;\n\trole?: unknown;\n\ttools?: ArtifactReplayToolCall[];\n}\n\nconst ARTIFACT_COMMANDS = new Set<string>([\n\t\"create\",\n\t\"update\",\n\t\"rewrite\",\n\t\"get\",\n\t\"delete\",\n\t\"logs\",\n]);\n\nexport function createEmptyArtifactsState(): ArtifactsState {\n\treturn { byFilename: new Map<string, Artifact>() };\n}\n\nfunction asString(value: unknown): string | undefined {\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nfunction isValidArtifactCommand(command: unknown): command is ArtifactsCommand {\n\treturn typeof command === \"string\" && ARTIFACT_COMMANDS.has(command);\n}\n\nfunction hasControlCharacter(value: string): boolean {\n\tfor (let index = 0; index < value.length; index += 1) {\n\t\tconst code = value.charCodeAt(index);\n\t\tif (code < 32 || code === 127) return true;\n\t}\n\treturn false;\n}\n\nexport function isValidArtifactFilename(filename: string): boolean {\n\treturn (\n\t\tfilename.length > 0 &&\n\t\t!filename.includes(\"..\") &&\n\t\t!filename.includes(\"/\") &&\n\t\t!filename.includes(\"\\\\\") &&\n\t\t!hasControlCharacter(filename)\n\t);\n}\n\nexport function coerceArtifactsArgs(value: unknown): ArtifactsArgs {\n\tif (!value || typeof value !== \"object\") return {};\n\tconst v = value as Record<string, unknown>;\n\treturn {\n\t\tcommand: asString(v.command),\n\t\tfilename: asString(v.filename),\n\t\tcontent: asString(v.content),\n\t\told_str: asString(v.old_str),\n\t\tnew_str: asString(v.new_str),\n\t};\n}\n\nfunction artifactError(\n\tstate: ArtifactsState,\n\tcode: ArtifactCommandErrorCode,\n\tmessage: string,\n): ArtifactCommandResult {\n\treturn {\n\t\tstate,\n\t\toutput: `Error [${code}]: ${message}`,\n\t\tisError: true,\n\t\tcode,\n\t\tmutated: false,\n\t};\n}\n\nfunction artifactSuccess(\n\tstate: ArtifactsState,\n\tcode: ArtifactCommandSuccessCode,\n\toutput: string,\n\tmutated: boolean,\n): ArtifactCommandResult {\n\treturn {\n\t\tstate,\n\t\toutput,\n\t\tisError: false,\n\t\tcode,\n\t\tmutated,\n\t};\n}\n\nexport function applyArtifactsCommand(\n\tstate: ArtifactsState,\n\targs: ArtifactsArgs,\n): ArtifactCommandResult {\n\tconst command = args.command;\n\tconst filename = args.filename?.trim();\n\tif (!command) {\n\t\treturn artifactError(state, \"artifact.command_missing\", \"missing command\");\n\t}\n\tif (!isValidArtifactCommand(command)) {\n\t\treturn artifactError(\n\t\t\tstate,\n\t\t\t\"artifact.command_unknown\",\n\t\t\t`unknown command: ${command}`,\n\t\t);\n\t}\n\tif (!filename) {\n\t\treturn artifactError(\n\t\t\tstate,\n\t\t\t\"artifact.filename_missing\",\n\t\t\t\"missing filename\",\n\t\t);\n\t}\n\tif (!isValidArtifactFilename(filename)) {\n\t\treturn artifactError(\n\t\t\tstate,\n\t\t\t\"artifact.filename_invalid\",\n\t\t\t\"invalid filename\",\n\t\t);\n\t}\n\n\tconst current = state.byFilename.get(filename);\n\n\tswitch (command) {\n\t\tcase \"create\": {\n\t\t\tif (current) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.exists\",\n\t\t\t\t\t`${filename} already exists`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst content = args.content ?? \"\";\n\t\t\tconst now = Date.now();\n\t\t\tconst next = new Map(state.byFilename);\n\t\t\tnext.set(filename, {\n\t\t\t\tfilename,\n\t\t\t\tcontent,\n\t\t\t\tcreatedAt: now,\n\t\t\t\tupdatedAt: now,\n\t\t\t});\n\t\t\treturn artifactSuccess(\n\t\t\t\t{ byFilename: next },\n\t\t\t\t\"artifact.created\",\n\t\t\t\t`Created ${filename}`,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tcase \"rewrite\": {\n\t\t\tif (!current) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.not_found\",\n\t\t\t\t\t`${filename} not found`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst content = args.content ?? \"\";\n\t\t\tconst next = new Map(state.byFilename);\n\t\t\tnext.set(filename, { ...current, content, updatedAt: Date.now() });\n\t\t\treturn artifactSuccess(\n\t\t\t\t{ byFilename: next },\n\t\t\t\t\"artifact.rewritten\",\n\t\t\t\t`Rewrote ${filename}`,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tcase \"update\": {\n\t\t\tif (!current) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.not_found\",\n\t\t\t\t\t`${filename} not found`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst oldStr = args.old_str;\n\t\t\tconst newStr = args.new_str;\n\t\t\tif (oldStr === undefined || newStr === undefined) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.update_args_missing\",\n\t\t\t\t\t\"update requires old_str and new_str\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (oldStr.length === 0) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.update_empty_old_str\",\n\t\t\t\t\t\"update requires non-empty old_str\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!current.content.includes(oldStr)) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.update_old_str_not_found\",\n\t\t\t\t\t`old_str not found in ${filename}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst nextContent = current.content.replace(oldStr, newStr);\n\t\t\tconst next = new Map(state.byFilename);\n\t\t\tnext.set(filename, {\n\t\t\t\t...current,\n\t\t\t\tcontent: nextContent,\n\t\t\t\tupdatedAt: Date.now(),\n\t\t\t});\n\t\t\treturn artifactSuccess(\n\t\t\t\t{ byFilename: next },\n\t\t\t\t\"artifact.updated\",\n\t\t\t\t`Updated ${filename}`,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tcase \"get\": {\n\t\t\tif (!current) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.not_found\",\n\t\t\t\t\t`${filename} not found`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn artifactSuccess(state, \"artifact.read\", current.content, false);\n\t\t}\n\n\t\tcase \"delete\": {\n\t\t\tif (!current) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.not_found\",\n\t\t\t\t\t`${filename} not found`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst next = new Map(state.byFilename);\n\t\t\tnext.delete(filename);\n\t\t\treturn artifactSuccess(\n\t\t\t\t{ byFilename: next },\n\t\t\t\t\"artifact.deleted\",\n\t\t\t\t`Deleted ${filename}`,\n\t\t\t\ttrue,\n\t\t\t);\n\t\t}\n\n\t\tcase \"logs\": {\n\t\t\tif (!current) {\n\t\t\t\treturn artifactError(\n\t\t\t\t\tstate,\n\t\t\t\t\t\"artifact.not_found\",\n\t\t\t\t\t`${filename} not found`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn artifactSuccess(\n\t\t\t\tstate,\n\t\t\t\t\"artifact.logs_requested\",\n\t\t\t\t`Logs requested for ${filename}`,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function artifactContentsByFilename(\n\tstate: ArtifactsState,\n): Map<string, string> {\n\treturn new Map(\n\t\tArray.from(state.byFilename.entries(), ([filename, artifact]) => [\n\t\t\tfilename,\n\t\t\tartifact.content,\n\t\t]),\n\t);\n}\n\nexport function reconstructArtifactsFromMessages(\n\tmessages: ArtifactReplayMessage[],\n\toptions: ArtifactReplayOptions = {},\n): ArtifactsState {\n\tlet state = createEmptyArtifactsState();\n\n\tfor (const msg of messages) {\n\t\tconst toolCalls = msg.tools ?? [];\n\t\tfor (const tool of toolCalls) {\n\t\t\tif (tool.name !== \"artifacts\") continue;\n\t\t\tif (tool.status !== \"completed\") continue;\n\t\t\tif (tool.result && typeof tool.result === \"object\") {\n\t\t\t\tconst maybeErr = tool.result as { isError?: boolean };\n\t\t\t\tif (maybeErr.isError) continue;\n\t\t\t}\n\t\t\tconst args = coerceArtifactsArgs(tool.args);\n\t\t\t// Ignore get/logs for reconstruction; they don't change state.\n\t\t\tif (args.command === \"get\" || args.command === \"logs\") continue;\n\t\t\tconst result = applyArtifactsCommand(state, args);\n\t\t\tif (result.isError || !result.mutated) {\n\t\t\t\toptions.onDiagnostic?.({\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tcommand: args.command,\n\t\t\t\t\tfilename: args.filename,\n\t\t\t\t\tisError: result.isError,\n\t\t\t\t\tmutated: result.mutated,\n\t\t\t\t\toutput: result.output,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstate = result.state;\n\t\t}\n\t}\n\n\treturn state;\n}\n"]}
|
|
@@ -452,7 +452,7 @@ export declare const HeadlessServerRequestResolvedMessageSchema: import("@sincla
|
|
|
452
452
|
request_id: import("@sinclair/typebox").TString;
|
|
453
453
|
request_type: import("@sinclair/typebox").TUnsafe<"approval" | "client_tool" | "mcp_elicitation" | "user_input" | "tool_retry">;
|
|
454
454
|
call_id: import("@sinclair/typebox").TString;
|
|
455
|
-
resolution: import("@sinclair/typebox").TUnsafe<"
|
|
455
|
+
resolution: import("@sinclair/typebox").TUnsafe<"completed" | "approved" | "denied" | "failed" | "answered" | "retried" | "skipped" | "aborted" | "cancelled">;
|
|
456
456
|
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
457
457
|
resolved_by: import("@sinclair/typebox").TUnsafe<"user" | "policy" | "client" | "runtime">;
|
|
458
458
|
started_at_ms: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -534,7 +534,7 @@ export declare const HeadlessUtilityFileWatchStartedMessageSchema: import("@sinc
|
|
|
534
534
|
export declare const HeadlessUtilityFileWatchEventMessageSchema: import("@sinclair/typebox").TObject<{
|
|
535
535
|
type: import("@sinclair/typebox").TLiteral<"utility_file_watch_event">;
|
|
536
536
|
watch_id: import("@sinclair/typebox").TString;
|
|
537
|
-
change_type: import("@sinclair/typebox").TUnsafe<"create" | "
|
|
537
|
+
change_type: import("@sinclair/typebox").TUnsafe<"create" | "delete" | "modify" | "rename">;
|
|
538
538
|
path: import("@sinclair/typebox").TString;
|
|
539
539
|
relative_path: import("@sinclair/typebox").TString;
|
|
540
540
|
timestamp: import("@sinclair/typebox").TNumber;
|
|
@@ -748,7 +748,7 @@ export declare const headlessFromAgentMessageSchemasByType: {
|
|
|
748
748
|
request_id: import("@sinclair/typebox").TString;
|
|
749
749
|
request_type: import("@sinclair/typebox").TUnsafe<"approval" | "client_tool" | "mcp_elicitation" | "user_input" | "tool_retry">;
|
|
750
750
|
call_id: import("@sinclair/typebox").TString;
|
|
751
|
-
resolution: import("@sinclair/typebox").TUnsafe<"
|
|
751
|
+
resolution: import("@sinclair/typebox").TUnsafe<"completed" | "approved" | "denied" | "failed" | "answered" | "retried" | "skipped" | "aborted" | "cancelled">;
|
|
752
752
|
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
753
753
|
resolved_by: import("@sinclair/typebox").TUnsafe<"user" | "policy" | "client" | "runtime">;
|
|
754
754
|
started_at_ms: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -826,7 +826,7 @@ export declare const headlessFromAgentMessageSchemasByType: {
|
|
|
826
826
|
readonly utility_file_watch_event: import("@sinclair/typebox").TObject<{
|
|
827
827
|
type: import("@sinclair/typebox").TLiteral<"utility_file_watch_event">;
|
|
828
828
|
watch_id: import("@sinclair/typebox").TString;
|
|
829
|
-
change_type: import("@sinclair/typebox").TUnsafe<"create" | "
|
|
829
|
+
change_type: import("@sinclair/typebox").TUnsafe<"create" | "delete" | "modify" | "rename">;
|
|
830
830
|
path: import("@sinclair/typebox").TString;
|
|
831
831
|
relative_path: import("@sinclair/typebox").TString;
|
|
832
832
|
timestamp: import("@sinclair/typebox").TNumber;
|
|
@@ -1132,7 +1132,7 @@ export declare const HeadlessFromAgentMessageSchema: import("@sinclair/typebox")
|
|
|
1132
1132
|
request_id: import("@sinclair/typebox").TString;
|
|
1133
1133
|
request_type: import("@sinclair/typebox").TUnsafe<"approval" | "client_tool" | "mcp_elicitation" | "user_input" | "tool_retry">;
|
|
1134
1134
|
call_id: import("@sinclair/typebox").TString;
|
|
1135
|
-
resolution: import("@sinclair/typebox").TUnsafe<"
|
|
1135
|
+
resolution: import("@sinclair/typebox").TUnsafe<"completed" | "approved" | "denied" | "failed" | "answered" | "retried" | "skipped" | "aborted" | "cancelled">;
|
|
1136
1136
|
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
1137
1137
|
resolved_by: import("@sinclair/typebox").TUnsafe<"user" | "policy" | "client" | "runtime">;
|
|
1138
1138
|
started_at_ms: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -1201,7 +1201,7 @@ export declare const HeadlessFromAgentMessageSchema: import("@sinclair/typebox")
|
|
|
1201
1201
|
}>, import("@sinclair/typebox").TObject<{
|
|
1202
1202
|
type: import("@sinclair/typebox").TLiteral<"utility_file_watch_event">;
|
|
1203
1203
|
watch_id: import("@sinclair/typebox").TString;
|
|
1204
|
-
change_type: import("@sinclair/typebox").TUnsafe<"create" | "
|
|
1204
|
+
change_type: import("@sinclair/typebox").TUnsafe<"create" | "delete" | "modify" | "rename">;
|
|
1205
1205
|
path: import("@sinclair/typebox").TString;
|
|
1206
1206
|
relative_path: import("@sinclair/typebox").TString;
|
|
1207
1207
|
timestamp: import("@sinclair/typebox").TNumber;
|
|
@@ -2051,7 +2051,7 @@ export declare const HeadlessRuntimeEventEnvelopeSchema: import("@sinclair/typeb
|
|
|
2051
2051
|
request_id: import("@sinclair/typebox").TString;
|
|
2052
2052
|
request_type: import("@sinclair/typebox").TUnsafe<"approval" | "client_tool" | "mcp_elicitation" | "user_input" | "tool_retry">;
|
|
2053
2053
|
call_id: import("@sinclair/typebox").TString;
|
|
2054
|
-
resolution: import("@sinclair/typebox").TUnsafe<"
|
|
2054
|
+
resolution: import("@sinclair/typebox").TUnsafe<"completed" | "approved" | "denied" | "failed" | "answered" | "retried" | "skipped" | "aborted" | "cancelled">;
|
|
2055
2055
|
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
2056
2056
|
resolved_by: import("@sinclair/typebox").TUnsafe<"user" | "policy" | "client" | "runtime">;
|
|
2057
2057
|
started_at_ms: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -2120,7 +2120,7 @@ export declare const HeadlessRuntimeEventEnvelopeSchema: import("@sinclair/typeb
|
|
|
2120
2120
|
}>, import("@sinclair/typebox").TObject<{
|
|
2121
2121
|
type: import("@sinclair/typebox").TLiteral<"utility_file_watch_event">;
|
|
2122
2122
|
watch_id: import("@sinclair/typebox").TString;
|
|
2123
|
-
change_type: import("@sinclair/typebox").TUnsafe<"create" | "
|
|
2123
|
+
change_type: import("@sinclair/typebox").TUnsafe<"create" | "delete" | "modify" | "rename">;
|
|
2124
2124
|
path: import("@sinclair/typebox").TString;
|
|
2125
2125
|
relative_path: import("@sinclair/typebox").TString;
|
|
2126
2126
|
timestamp: import("@sinclair/typebox").TNumber;
|
|
@@ -2709,7 +2709,7 @@ export declare const HeadlessRuntimeStreamEnvelopeSchema: import("@sinclair/type
|
|
|
2709
2709
|
request_id: import("@sinclair/typebox").TString;
|
|
2710
2710
|
request_type: import("@sinclair/typebox").TUnsafe<"approval" | "client_tool" | "mcp_elicitation" | "user_input" | "tool_retry">;
|
|
2711
2711
|
call_id: import("@sinclair/typebox").TString;
|
|
2712
|
-
resolution: import("@sinclair/typebox").TUnsafe<"
|
|
2712
|
+
resolution: import("@sinclair/typebox").TUnsafe<"completed" | "approved" | "denied" | "failed" | "answered" | "retried" | "skipped" | "aborted" | "cancelled">;
|
|
2713
2713
|
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
2714
2714
|
resolved_by: import("@sinclair/typebox").TUnsafe<"user" | "policy" | "client" | "runtime">;
|
|
2715
2715
|
started_at_ms: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
@@ -2778,7 +2778,7 @@ export declare const HeadlessRuntimeStreamEnvelopeSchema: import("@sinclair/type
|
|
|
2778
2778
|
}>, import("@sinclair/typebox").TObject<{
|
|
2779
2779
|
type: import("@sinclair/typebox").TLiteral<"utility_file_watch_event">;
|
|
2780
2780
|
watch_id: import("@sinclair/typebox").TString;
|
|
2781
|
-
change_type: import("@sinclair/typebox").TUnsafe<"create" | "
|
|
2781
|
+
change_type: import("@sinclair/typebox").TUnsafe<"create" | "delete" | "modify" | "rename">;
|
|
2782
2782
|
path: import("@sinclair/typebox").TString;
|
|
2783
2783
|
relative_path: import("@sinclair/typebox").TString;
|
|
2784
2784
|
timestamp: import("@sinclair/typebox").TNumber;
|
|
@@ -46,6 +46,7 @@ export * from "./headless-protocol-generated.js";
|
|
|
46
46
|
export * from "./headless-protocol-schemas.generated.js";
|
|
47
47
|
export * as headlessProto from "./proto/maestro/v1/headless_pb.js";
|
|
48
48
|
export * from "./advisor-effort.js";
|
|
49
|
+
export * from "./artifacts.js";
|
|
49
50
|
export * from "./delegation-prompt.js";
|
|
50
51
|
export * from "./guarded-files-settings.js";
|
|
51
52
|
export * from "./key-value-tokens.js";
|