@evalops/maestro 0.10.37 → 0.10.38
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/cli/rpc-mode.d.ts.map +1 -1
- package/dist/cli/rpc-mode.js +19 -9
- package/dist/cli/rpc-mode.js.map +1 -1
- package/dist/cli.js +93 -46
- package/dist/node_modules/@evalops/contracts/package.json +1 -1
- package/dist/node_modules/@evalops/tui/package.json +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-client.js.map +1 -1
- package/dist/safety/validators/network-policy-validator.d.ts.map +1 -1
- package/dist/safety/validators/network-policy-validator.js +38 -38
- package/dist/safety/validators/network-policy-validator.js.map +1 -1
- package/dist/telemetry/maestro-event-catalog.d.ts +1 -1
- package/dist/telemetry/maestro-event-catalog.d.ts.map +1 -1
- package/dist/telemetry/maestro-event-catalog.js +2 -1
- package/dist/telemetry/maestro-event-catalog.js.map +1 -1
- package/dist/tools/ripgrep-utils.d.ts.map +1 -1
- package/dist/tools/ripgrep-utils.js +40 -1
- package/dist/tools/ripgrep-utils.js.map +1 -1
- package/dist/version.json +2 -2
- package/package.json +8 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-mode.d.ts","sourceRoot":"","sources":["../../src/cli/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA2B/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAqC5D;;;;;GAKG;AACH,wBAAsB,UAAU,CAC/B,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,GAC5B,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"rpc-mode.d.ts","sourceRoot":"","sources":["../../src/cli/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA2B/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAqC5D;;;;;GAKG;AACH,wBAAsB,UAAU,CAC/B,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,GAC5B,OAAO,CAAC,IAAI,CAAC,CAqKf"}
|
package/dist/cli/rpc-mode.js
CHANGED
|
@@ -63,8 +63,11 @@ export async function runRpcMode(agent, sessionManager) {
|
|
|
63
63
|
});
|
|
64
64
|
// Process incoming RPC commands line by line
|
|
65
65
|
rl.on("line", async (line) => {
|
|
66
|
+
let requestId;
|
|
67
|
+
const withRequestId = (response) => requestId ? { id: requestId, ...response } : response;
|
|
66
68
|
try {
|
|
67
69
|
const input = JSON.parse(line);
|
|
70
|
+
requestId = typeof input.id === "string" ? input.id : undefined;
|
|
68
71
|
if (input.type === "prompt" && input.message) {
|
|
69
72
|
await runUserPromptWithRecovery({
|
|
70
73
|
agent,
|
|
@@ -84,13 +87,13 @@ export async function runRpcMode(agent, sessionManager) {
|
|
|
84
87
|
agent.abort();
|
|
85
88
|
}
|
|
86
89
|
else if (input.type === "get_messages") {
|
|
87
|
-
console.log(JSON.stringify({
|
|
90
|
+
console.log(JSON.stringify(withRequestId({
|
|
88
91
|
type: "messages",
|
|
89
92
|
messages: agent.state.messages,
|
|
90
|
-
}));
|
|
93
|
+
})));
|
|
91
94
|
}
|
|
92
95
|
else if (input.type === "get_state") {
|
|
93
|
-
console.log(JSON.stringify({
|
|
96
|
+
console.log(JSON.stringify(withRequestId({
|
|
94
97
|
type: "state",
|
|
95
98
|
state: {
|
|
96
99
|
model: agent.state.model,
|
|
@@ -101,7 +104,7 @@ export async function runRpcMode(agent, sessionManager) {
|
|
|
101
104
|
session: agent.state.session,
|
|
102
105
|
queuedMessageCount: agent.getQueuedMessageCount(),
|
|
103
106
|
},
|
|
104
|
-
}));
|
|
107
|
+
})));
|
|
105
108
|
}
|
|
106
109
|
else if (input.type === "continue") {
|
|
107
110
|
await runWithPromptRecovery({
|
|
@@ -135,14 +138,14 @@ export async function runRpcMode(agent, sessionManager) {
|
|
|
135
138
|
},
|
|
136
139
|
});
|
|
137
140
|
if (!result.success) {
|
|
138
|
-
console.log(JSON.stringify({
|
|
141
|
+
console.log(JSON.stringify(withRequestId({
|
|
139
142
|
type: "error",
|
|
140
143
|
error: result.error,
|
|
141
|
-
}));
|
|
144
|
+
})));
|
|
142
145
|
return;
|
|
143
146
|
}
|
|
144
147
|
// Emit compaction event
|
|
145
|
-
const compactionEvent = {
|
|
148
|
+
const compactionEvent = withRequestId({
|
|
146
149
|
type: "compaction",
|
|
147
150
|
summary: result.summary ?? `Compacted ${result.compactedCount} messages`,
|
|
148
151
|
firstKeptEntryIndex: result.firstKeptEntryIndex ?? 0,
|
|
@@ -150,13 +153,20 @@ export async function runRpcMode(agent, sessionManager) {
|
|
|
150
153
|
auto: false,
|
|
151
154
|
customInstructions,
|
|
152
155
|
timestamp: new Date().toISOString(),
|
|
153
|
-
};
|
|
156
|
+
});
|
|
154
157
|
console.log(JSON.stringify(compactionEvent));
|
|
155
158
|
}
|
|
159
|
+
else {
|
|
160
|
+
const commandType = typeof input.type === "string" && input.type ? input.type : "unknown";
|
|
161
|
+
console.log(JSON.stringify(withRequestId({
|
|
162
|
+
type: "error",
|
|
163
|
+
error: `Unknown RPC command: ${commandType}`,
|
|
164
|
+
})));
|
|
165
|
+
}
|
|
156
166
|
}
|
|
157
167
|
catch (error) {
|
|
158
168
|
const message = error instanceof Error ? error.message : String(error);
|
|
159
|
-
console.log(JSON.stringify({ type: "error", error: message }));
|
|
169
|
+
console.log(JSON.stringify(withRequestId({ type: "error", error: message })));
|
|
160
170
|
}
|
|
161
171
|
});
|
|
162
172
|
// Keep process alive indefinitely - exits when stdin closes
|
package/dist/cli/rpc-mode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-mode.js","sourceRoot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AC,OAAO,IAAI,aAAa,MAAM,CAAC,cAAc,WAAW;oBAChE,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,IAAI,CAAC;oBACpD,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,CAAC;oBACtC,IAAI,EAAE,KAAK;oBACX,kBAAkB;oBAClB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;iBACnC,CAAC;gBACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;YAC9C,CAAC;QACF,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAChE,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,4DAA4D;IAC5D,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * RPC Mode - JSON-over-stdio protocol for programmatic agent control.\n *\n * Moved from main.ts. Provides a line-based JSON protocol for IDE integrations,\n * language servers, and other tools that embed Maestro functionality.\n *\n * ## Protocol\n *\n * **Input (stdin)**: JSON objects, one per line\n * ```json\n * {\"type\": \"prompt\", \"message\": \"Hello\"}\n * {\"type\": \"abort\"}\n * {\"type\": \"compact\", \"customInstructions\": \"Focus on...\"}\n * ```\n *\n * **Output (stdout)**: Agent events as JSON objects, one per line\n *\n * @module cli/rpc-mode\n */\n\nimport type { Agent } from \"../agent/agent.js\";\nimport { buildCompactionHookContext } from \"../agent/compaction-hooks.js\";\nimport {\n\tcollectBackgroundTaskMessagesForCompaction,\n\tcollectMcpMessagesForCompaction,\n\tcollectPlanMessagesForCompaction,\n} from \"../agent/compaction-restoration.js\";\nimport { performCompaction } from \"../agent/compaction.js\";\nimport {\n\tbuildCompactionEvent,\n\trunWithPromptRecovery,\n} from \"../agent/prompt-recovery.js\";\nimport type {\n\tAgentEvent,\n\tAppMessage,\n\tAssistantMessage,\n} from \"../agent/types.js\";\nimport {\n\tcollectPersistedSessionStartHookMessages,\n\trunUserPromptWithRecovery,\n} from \"../agent/user-prompt-runtime.js\";\nimport {\n\tcreateRenderableMessage,\n\trenderMessageToPlainText,\n} from \"../conversation/render-model.js\";\nimport { mcpManager } from \"../mcp/index.js\";\nimport { withMcpPostKeepMessages } from \"../mcp/prompt-recovery.js\";\nimport type { SessionManager } from \"../session/manager.js\";\n\nasync function collectRpcPostKeepMessages(\n\tsessionManager: SessionManager,\n\tcwd: string,\n\tpreservedMessages: AppMessage[],\n): Promise<AppMessage[]> {\n\tconst [\n\t\tplanMessages,\n\t\tbackgroundTaskMessages,\n\t\tmcpMessages,\n\t\tsessionStartMessages,\n\t] = await Promise.all([\n\t\tPromise.resolve(collectPlanMessagesForCompaction(preservedMessages)),\n\t\tPromise.resolve(\n\t\t\tcollectBackgroundTaskMessagesForCompaction(preservedMessages),\n\t\t),\n\t\tPromise.resolve(\n\t\t\tcollectMcpMessagesForCompaction(\n\t\t\t\tpreservedMessages,\n\t\t\t\tmcpManager.getStatus().servers,\n\t\t\t),\n\t\t),\n\t\tcollectPersistedSessionStartHookMessages({\n\t\t\tsessionManager,\n\t\t\tcwd,\n\t\t\tsource: \"compact\",\n\t\t}),\n\t]);\n\treturn [\n\t\t...planMessages,\n\t\t...backgroundTaskMessages,\n\t\t...mcpMessages,\n\t\t...sessionStartMessages,\n\t];\n}\n\n/**\n * Run the CLI in RPC mode.\n *\n * The process runs indefinitely until stdin closes or it receives\n * a termination signal.\n */\nexport async function runRpcMode(\n\tagent: Agent,\n\tsessionManager: SessionManager,\n): Promise<void> {\n\t// Subscribe to all events and emit as JSON for client consumption\n\tagent.subscribe((event) => {\n\t\tconsole.log(JSON.stringify(event));\n\t});\n\n\t// Set up JSON-over-stdin readline interface\n\tconst readline = await import(\"node:readline\");\n\tconst rl = readline.createInterface({\n\t\tinput: process.stdin,\n\t\toutput: process.stdout,\n\t\tterminal: false,\n\t});\n\n\t// Process incoming RPC commands line by line\n\trl.on(\"line\", async (line: string) => {\n\t\ttry {\n\t\t\tconst input = JSON.parse(line);\n\n\t\t\tif (input.type === \"prompt\" && input.message) {\n\t\t\t\tawait runUserPromptWithRecovery({\n\t\t\t\t\tagent,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\tcwd: process.cwd(),\n\t\t\t\t\tprompt: input.message,\n\t\t\t\t\texecute: () => agent.prompt(input.message),\n\t\t\t\t\tgetPostKeepMessages: withMcpPostKeepMessages(),\n\t\t\t\t\tcallbacks: {\n\t\t\t\t\t\tonCompacted: (result) => {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\tJSON.stringify(buildCompactionEvent(result, { auto: true })),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else if (input.type === \"abort\") {\n\t\t\t\tagent.abort();\n\t\t\t} else if (input.type === \"get_messages\") {\n\t\t\t\tconsole.log(\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\ttype: \"messages\",\n\t\t\t\t\t\tmessages: agent.state.messages,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else if (input.type === \"get_state\") {\n\t\t\t\tconsole.log(\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\ttype: \"state\",\n\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\tmodel: agent.state.model,\n\t\t\t\t\t\t\tmessages: agent.state.messages,\n\t\t\t\t\t\t\tisStreaming: agent.state.isStreaming,\n\t\t\t\t\t\t\terror: agent.state.error,\n\t\t\t\t\t\t\tthinkingLevel: agent.state.thinkingLevel,\n\t\t\t\t\t\t\tsession: agent.state.session,\n\t\t\t\t\t\t\tqueuedMessageCount: agent.getQueuedMessageCount(),\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else if (input.type === \"continue\") {\n\t\t\t\tawait runWithPromptRecovery({\n\t\t\t\t\tagent,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\thookContext: buildCompactionHookContext(\n\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t),\n\t\t\t\t\texecute: () => agent.continue(input.options),\n\t\t\t\t\tgetPostKeepMessages: (preservedMessages) =>\n\t\t\t\t\t\tcollectRpcPostKeepMessages(\n\t\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t\t\tpreservedMessages,\n\t\t\t\t\t\t),\n\t\t\t\t\tcallbacks: {\n\t\t\t\t\t\tonCompacted: (result) => {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\tJSON.stringify(buildCompactionEvent(result, { auto: true })),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else if (input.type === \"compact\") {\n\t\t\t\tconst customInstructions = input.customInstructions as\n\t\t\t\t\t| string\n\t\t\t\t\t| undefined;\n\n\t\t\t\tconst result = await performCompaction({\n\t\t\t\t\tagent,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\tauto: false,\n\t\t\t\t\ttrigger: \"manual\",\n\t\t\t\t\thookContext: buildCompactionHookContext(\n\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t),\n\t\t\t\t\tgetPostKeepMessages: (preservedMessages) =>\n\t\t\t\t\t\tcollectRpcPostKeepMessages(\n\t\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t\t\tpreservedMessages,\n\t\t\t\t\t\t),\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\trenderSummaryText: (summary: AssistantMessage) => {\n\t\t\t\t\t\tconst renderable = createRenderableMessage(summary as AppMessage);\n\t\t\t\t\t\treturn renderable\n\t\t\t\t\t\t\t? renderMessageToPlainText(renderable).trim()\n\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (!result.success) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Emit compaction event\n\t\t\t\tconst compactionEvent: AgentEvent = {\n\t\t\t\t\ttype: \"compaction\",\n\t\t\t\t\tsummary:\n\t\t\t\t\t\tresult.summary ?? `Compacted ${result.compactedCount} messages`,\n\t\t\t\t\tfirstKeptEntryIndex: result.firstKeptEntryIndex ?? 0,\n\t\t\t\t\ttokensBefore: result.tokensBefore ?? 0,\n\t\t\t\t\tauto: false,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t};\n\t\t\t\tconsole.log(JSON.stringify(compactionEvent));\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.log(JSON.stringify({ type: \"error\", error: message }));\n\t\t}\n\t});\n\n\t// Keep process alive indefinitely - exits when stdin closes\n\treturn new Promise(() => {});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rpc-mode.js","sourceRoot":"","sources":["../../src/cli/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EACN,0CAA0C,EAC1C,+BAA+B,EAC/B,gCAAgC,GAChC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,iBA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AC,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * RPC Mode - JSON-over-stdio protocol for programmatic agent control.\n *\n * Moved from main.ts. Provides a line-based JSON protocol for IDE integrations,\n * language servers, and other tools that embed Maestro functionality.\n *\n * ## Protocol\n *\n * **Input (stdin)**: JSON objects, one per line\n * ```json\n * {\"type\": \"prompt\", \"message\": \"Hello\"}\n * {\"type\": \"abort\"}\n * {\"type\": \"compact\", \"customInstructions\": \"Focus on...\"}\n * ```\n *\n * **Output (stdout)**: Agent events as JSON objects, one per line\n *\n * @module cli/rpc-mode\n */\n\nimport type { Agent } from \"../agent/agent.js\";\nimport { buildCompactionHookContext } from \"../agent/compaction-hooks.js\";\nimport {\n\tcollectBackgroundTaskMessagesForCompaction,\n\tcollectMcpMessagesForCompaction,\n\tcollectPlanMessagesForCompaction,\n} from \"../agent/compaction-restoration.js\";\nimport { performCompaction } from \"../agent/compaction.js\";\nimport {\n\tbuildCompactionEvent,\n\trunWithPromptRecovery,\n} from \"../agent/prompt-recovery.js\";\nimport type {\n\tAgentEvent,\n\tAppMessage,\n\tAssistantMessage,\n} from \"../agent/types.js\";\nimport {\n\tcollectPersistedSessionStartHookMessages,\n\trunUserPromptWithRecovery,\n} from \"../agent/user-prompt-runtime.js\";\nimport {\n\tcreateRenderableMessage,\n\trenderMessageToPlainText,\n} from \"../conversation/render-model.js\";\nimport { mcpManager } from \"../mcp/index.js\";\nimport { withMcpPostKeepMessages } from \"../mcp/prompt-recovery.js\";\nimport type { SessionManager } from \"../session/manager.js\";\n\nasync function collectRpcPostKeepMessages(\n\tsessionManager: SessionManager,\n\tcwd: string,\n\tpreservedMessages: AppMessage[],\n): Promise<AppMessage[]> {\n\tconst [\n\t\tplanMessages,\n\t\tbackgroundTaskMessages,\n\t\tmcpMessages,\n\t\tsessionStartMessages,\n\t] = await Promise.all([\n\t\tPromise.resolve(collectPlanMessagesForCompaction(preservedMessages)),\n\t\tPromise.resolve(\n\t\t\tcollectBackgroundTaskMessagesForCompaction(preservedMessages),\n\t\t),\n\t\tPromise.resolve(\n\t\t\tcollectMcpMessagesForCompaction(\n\t\t\t\tpreservedMessages,\n\t\t\t\tmcpManager.getStatus().servers,\n\t\t\t),\n\t\t),\n\t\tcollectPersistedSessionStartHookMessages({\n\t\t\tsessionManager,\n\t\t\tcwd,\n\t\t\tsource: \"compact\",\n\t\t}),\n\t]);\n\treturn [\n\t\t...planMessages,\n\t\t...backgroundTaskMessages,\n\t\t...mcpMessages,\n\t\t...sessionStartMessages,\n\t];\n}\n\n/**\n * Run the CLI in RPC mode.\n *\n * The process runs indefinitely until stdin closes or it receives\n * a termination signal.\n */\nexport async function runRpcMode(\n\tagent: Agent,\n\tsessionManager: SessionManager,\n): Promise<void> {\n\t// Subscribe to all events and emit as JSON for client consumption\n\tagent.subscribe((event) => {\n\t\tconsole.log(JSON.stringify(event));\n\t});\n\n\t// Set up JSON-over-stdin readline interface\n\tconst readline = await import(\"node:readline\");\n\tconst rl = readline.createInterface({\n\t\tinput: process.stdin,\n\t\toutput: process.stdout,\n\t\tterminal: false,\n\t});\n\n\t// Process incoming RPC commands line by line\n\trl.on(\"line\", async (line: string) => {\n\t\tlet requestId: string | undefined;\n\t\tconst withRequestId = <T extends Record<string, unknown>>(response: T) =>\n\t\t\trequestId ? { id: requestId, ...response } : response;\n\t\ttry {\n\t\t\tconst input = JSON.parse(line);\n\t\t\trequestId = typeof input.id === \"string\" ? input.id : undefined;\n\n\t\t\tif (input.type === \"prompt\" && input.message) {\n\t\t\t\tawait runUserPromptWithRecovery({\n\t\t\t\t\tagent,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\tcwd: process.cwd(),\n\t\t\t\t\tprompt: input.message,\n\t\t\t\t\texecute: () => agent.prompt(input.message),\n\t\t\t\t\tgetPostKeepMessages: withMcpPostKeepMessages(),\n\t\t\t\t\tcallbacks: {\n\t\t\t\t\t\tonCompacted: (result) => {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\tJSON.stringify(buildCompactionEvent(result, { auto: true })),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else if (input.type === \"abort\") {\n\t\t\t\tagent.abort();\n\t\t\t} else if (input.type === \"get_messages\") {\n\t\t\t\tconsole.log(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\twithRequestId({\n\t\t\t\t\t\t\ttype: \"messages\",\n\t\t\t\t\t\t\tmessages: agent.state.messages,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (input.type === \"get_state\") {\n\t\t\t\tconsole.log(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\twithRequestId({\n\t\t\t\t\t\t\ttype: \"state\",\n\t\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t\tmodel: agent.state.model,\n\t\t\t\t\t\t\t\tmessages: agent.state.messages,\n\t\t\t\t\t\t\t\tisStreaming: agent.state.isStreaming,\n\t\t\t\t\t\t\t\terror: agent.state.error,\n\t\t\t\t\t\t\t\tthinkingLevel: agent.state.thinkingLevel,\n\t\t\t\t\t\t\t\tsession: agent.state.session,\n\t\t\t\t\t\t\t\tqueuedMessageCount: agent.getQueuedMessageCount(),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (input.type === \"continue\") {\n\t\t\t\tawait runWithPromptRecovery({\n\t\t\t\t\tagent,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\thookContext: buildCompactionHookContext(\n\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t),\n\t\t\t\t\texecute: () => agent.continue(input.options),\n\t\t\t\t\tgetPostKeepMessages: (preservedMessages) =>\n\t\t\t\t\t\tcollectRpcPostKeepMessages(\n\t\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t\t\tpreservedMessages,\n\t\t\t\t\t\t),\n\t\t\t\t\tcallbacks: {\n\t\t\t\t\t\tonCompacted: (result) => {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\tJSON.stringify(buildCompactionEvent(result, { auto: true })),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else if (input.type === \"compact\") {\n\t\t\t\tconst customInstructions = input.customInstructions as\n\t\t\t\t\t| string\n\t\t\t\t\t| undefined;\n\n\t\t\t\tconst result = await performCompaction({\n\t\t\t\t\tagent,\n\t\t\t\t\tsessionManager,\n\t\t\t\t\tauto: false,\n\t\t\t\t\ttrigger: \"manual\",\n\t\t\t\t\thookContext: buildCompactionHookContext(\n\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t),\n\t\t\t\t\tgetPostKeepMessages: (preservedMessages) =>\n\t\t\t\t\t\tcollectRpcPostKeepMessages(\n\t\t\t\t\t\t\tsessionManager,\n\t\t\t\t\t\t\tprocess.cwd(),\n\t\t\t\t\t\t\tpreservedMessages,\n\t\t\t\t\t\t),\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\trenderSummaryText: (summary: AssistantMessage) => {\n\t\t\t\t\t\tconst renderable = createRenderableMessage(summary as AppMessage);\n\t\t\t\t\t\treturn renderable\n\t\t\t\t\t\t\t? renderMessageToPlainText(renderable).trim()\n\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (!result.success) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\twithRequestId({\n\t\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Emit compaction event\n\t\t\t\tconst compactionEvent: AgentEvent & { id?: string } = withRequestId({\n\t\t\t\t\ttype: \"compaction\" as const,\n\t\t\t\t\tsummary:\n\t\t\t\t\t\tresult.summary ?? `Compacted ${result.compactedCount} messages`,\n\t\t\t\t\tfirstKeptEntryIndex: result.firstKeptEntryIndex ?? 0,\n\t\t\t\t\ttokensBefore: result.tokensBefore ?? 0,\n\t\t\t\t\tauto: false,\n\t\t\t\t\tcustomInstructions,\n\t\t\t\t\ttimestamp: new Date().toISOString(),\n\t\t\t\t});\n\t\t\t\tconsole.log(JSON.stringify(compactionEvent));\n\t\t\t} else {\n\t\t\t\tconst commandType =\n\t\t\t\t\ttypeof input.type === \"string\" && input.type ? input.type : \"unknown\";\n\t\t\t\tconsole.log(\n\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\twithRequestId({\n\t\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\t\terror: `Unknown RPC command: ${commandType}`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\tconsole.log(\n\t\t\t\tJSON.stringify(withRequestId({ type: \"error\", error: message })),\n\t\t\t);\n\t\t}\n\t});\n\n\t// Keep process alive indefinitely - exits when stdin closes\n\treturn new Promise(() => {});\n}\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -49041,7 +49041,7 @@ var init_maestro_event_catalog = __esm2(() => {
|
|
|
49041
49041
|
[
|
|
49042
49042
|
"maestro.events.tool_call.attempted"
|
|
49043
49043
|
/* ToolCallAttempted */
|
|
49044
|
-
]: entry("maestro.events.tool_call.attempted", "tool", "ToolCallAttempt", ["meter.maestro-tool-call-events"]),
|
|
49044
|
+
]: entry("maestro.events.tool_call.attempted", "tool", "ToolCallAttempt", ["meter.maestro-tool-call-events", "release.maestro-tool-attempt-gates"]),
|
|
49045
49045
|
[
|
|
49046
49046
|
"maestro.events.tool_call.completed"
|
|
49047
49047
|
/* ToolCallCompleted */
|
|
@@ -49162,6 +49162,7 @@ var init_maestro_event_catalog = __esm2(() => {
|
|
|
49162
49162
|
/* SessionClosed */
|
|
49163
49163
|
],
|
|
49164
49164
|
tool: [
|
|
49165
|
+
"maestro.events.tool_call.attempted",
|
|
49165
49166
|
"maestro.events.tool_call.completed",
|
|
49166
49167
|
"maestro.events.tool_call.failed"
|
|
49167
49168
|
/* ToolCallFailed */
|
|
@@ -60509,80 +60510,80 @@ async function checkNetworkRestrictionsDetailed(url, network) {
|
|
|
60509
60510
|
const parsed = new URL(url);
|
|
60510
60511
|
const host = parsed.hostname.toLowerCase();
|
|
60511
60512
|
const normalizedHost = host.replace(/^\[|\]$/g, "");
|
|
60512
|
-
|
|
60513
|
-
|
|
60514
|
-
|
|
60515
|
-
|
|
60516
|
-
const addresses = await lookup(normalizedHost, { all: true });
|
|
60517
|
-
resolvedIPs.push(...addresses.map(({ address }) => address));
|
|
60518
|
-
} catch {
|
|
60519
|
-
if (network.blockPrivateIPs || network.blockLocalhost) {
|
|
60513
|
+
if (network.blockedHosts?.length) {
|
|
60514
|
+
for (const blockedHost of network.blockedHosts) {
|
|
60515
|
+
const lowerBlocked = blockedHost.toLowerCase();
|
|
60516
|
+
if (host === lowerBlocked || host.endsWith(`.${lowerBlocked}`)) {
|
|
60520
60517
|
return {
|
|
60521
60518
|
allowed: false,
|
|
60522
|
-
reason: `
|
|
60519
|
+
reason: `Host "${host}" is blocked by enterprise policy.`,
|
|
60523
60520
|
host,
|
|
60524
60521
|
normalizedHost,
|
|
60525
|
-
resolvedIPs
|
|
60522
|
+
resolvedIPs: []
|
|
60526
60523
|
};
|
|
60527
60524
|
}
|
|
60528
60525
|
}
|
|
60529
|
-
} else {
|
|
60530
|
-
resolvedIPs.push(normalizedHost);
|
|
60531
60526
|
}
|
|
60532
|
-
if (network.
|
|
60533
|
-
if (
|
|
60527
|
+
if (network.allowedHosts) {
|
|
60528
|
+
if (network.allowedHosts.length === 0) {
|
|
60534
60529
|
return {
|
|
60535
60530
|
allowed: false,
|
|
60536
|
-
reason: "
|
|
60531
|
+
reason: `Host "${host}" is not in the allowed hosts list.`,
|
|
60537
60532
|
host,
|
|
60538
60533
|
normalizedHost,
|
|
60539
|
-
resolvedIPs
|
|
60534
|
+
resolvedIPs: []
|
|
60540
60535
|
};
|
|
60541
60536
|
}
|
|
60542
|
-
|
|
60543
|
-
|
|
60544
|
-
|
|
60537
|
+
const isAllowed = network.allowedHosts.some((allowedHost) => {
|
|
60538
|
+
const lowerAllowed = allowedHost.toLowerCase();
|
|
60539
|
+
return host === lowerAllowed || host.endsWith(`.${lowerAllowed}`);
|
|
60540
|
+
});
|
|
60541
|
+
if (!isAllowed) {
|
|
60545
60542
|
return {
|
|
60546
60543
|
allowed: false,
|
|
60547
|
-
reason: "
|
|
60544
|
+
reason: `Host "${host}" is not in the allowed hosts list.`,
|
|
60548
60545
|
host,
|
|
60549
60546
|
normalizedHost,
|
|
60550
|
-
resolvedIPs
|
|
60547
|
+
resolvedIPs: []
|
|
60551
60548
|
};
|
|
60552
60549
|
}
|
|
60553
60550
|
}
|
|
60554
|
-
|
|
60555
|
-
|
|
60556
|
-
|
|
60557
|
-
|
|
60551
|
+
const resolvedIPs = [];
|
|
60552
|
+
const isIP2 = parseIPv4(normalizedHost) !== null || parseIPv4MappedHex(normalizedHost) !== null || normalizedHost.includes(":");
|
|
60553
|
+
if (!isIP2) {
|
|
60554
|
+
try {
|
|
60555
|
+
const addresses = await lookup(normalizedHost, { all: true });
|
|
60556
|
+
resolvedIPs.push(...addresses.map(({ address }) => address));
|
|
60557
|
+
} catch {
|
|
60558
|
+
if (network.blockPrivateIPs || network.blockLocalhost) {
|
|
60558
60559
|
return {
|
|
60559
60560
|
allowed: false,
|
|
60560
|
-
reason: `
|
|
60561
|
+
reason: `DNS resolution failed for "${host}" and network policy requires IP validation (blockPrivateIPs/blockLocalhost enabled). Access blocked.`,
|
|
60561
60562
|
host,
|
|
60562
60563
|
normalizedHost,
|
|
60563
60564
|
resolvedIPs
|
|
60564
60565
|
};
|
|
60565
60566
|
}
|
|
60566
60567
|
}
|
|
60568
|
+
} else {
|
|
60569
|
+
resolvedIPs.push(normalizedHost);
|
|
60567
60570
|
}
|
|
60568
|
-
if (network.
|
|
60569
|
-
if (
|
|
60571
|
+
if (network.blockLocalhost) {
|
|
60572
|
+
if (isLocalhostAlias(normalizedHost) || resolvedIPs.some(isLoopbackIP)) {
|
|
60570
60573
|
return {
|
|
60571
60574
|
allowed: false,
|
|
60572
|
-
reason:
|
|
60575
|
+
reason: "Access to localhost is blocked by enterprise policy.",
|
|
60573
60576
|
host,
|
|
60574
60577
|
normalizedHost,
|
|
60575
60578
|
resolvedIPs
|
|
60576
60579
|
};
|
|
60577
60580
|
}
|
|
60578
|
-
|
|
60579
|
-
|
|
60580
|
-
|
|
60581
|
-
});
|
|
60582
|
-
if (!isAllowed) {
|
|
60581
|
+
}
|
|
60582
|
+
if (network.blockPrivateIPs) {
|
|
60583
|
+
if (resolvedIPs.some(isPrivateIP)) {
|
|
60583
60584
|
return {
|
|
60584
60585
|
allowed: false,
|
|
60585
|
-
reason:
|
|
60586
|
+
reason: "Access to private IP addresses is blocked by enterprise policy.",
|
|
60586
60587
|
host,
|
|
60587
60588
|
normalizedHost,
|
|
60588
60589
|
resolvedIPs
|
|
@@ -160325,6 +160326,39 @@ function toArray(value) {
|
|
|
160325
160326
|
}
|
|
160326
160327
|
return Array.isArray(value) ? value : [value];
|
|
160327
160328
|
}
|
|
160329
|
+
function ripgrepAbortError() {
|
|
160330
|
+
return new Error("ripgrep search aborted before start");
|
|
160331
|
+
}
|
|
160332
|
+
async function resolveRipgrepExecutable() {
|
|
160333
|
+
ripgrepExecutablePromise ??= ensureTool("rg", true);
|
|
160334
|
+
const executable = await ripgrepExecutablePromise;
|
|
160335
|
+
if (!executable) {
|
|
160336
|
+
ripgrepExecutablePromise = null;
|
|
160337
|
+
throw new Error("ripgrep is not available and could not be downloaded");
|
|
160338
|
+
}
|
|
160339
|
+
return executable;
|
|
160340
|
+
}
|
|
160341
|
+
function throwIfRipgrepAborted(signal) {
|
|
160342
|
+
if (signal?.aborted) {
|
|
160343
|
+
throw ripgrepAbortError();
|
|
160344
|
+
}
|
|
160345
|
+
}
|
|
160346
|
+
async function resolveRipgrepExecutableWithAbort(signal) {
|
|
160347
|
+
throwIfRipgrepAborted(signal);
|
|
160348
|
+
if (!signal) {
|
|
160349
|
+
return await resolveRipgrepExecutable();
|
|
160350
|
+
}
|
|
160351
|
+
return await new Promise((resolve532, reject) => {
|
|
160352
|
+
const onAbort = () => {
|
|
160353
|
+
signal.removeEventListener("abort", onAbort);
|
|
160354
|
+
reject(ripgrepAbortError());
|
|
160355
|
+
};
|
|
160356
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
160357
|
+
resolveRipgrepExecutable().then(resolve532, reject).finally(() => {
|
|
160358
|
+
signal.removeEventListener("abort", onAbort);
|
|
160359
|
+
});
|
|
160360
|
+
});
|
|
160361
|
+
}
|
|
160328
160362
|
function shellQuoteArg(value) {
|
|
160329
160363
|
if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {
|
|
160330
160364
|
return value;
|
|
@@ -160335,7 +160369,9 @@ function formatRipgrepCommand(args) {
|
|
|
160335
160369
|
return ["rg", ...args].map(shellQuoteArg).join(" ");
|
|
160336
160370
|
}
|
|
160337
160371
|
async function runRipgrep(args, signal, cwd) {
|
|
160338
|
-
const
|
|
160372
|
+
const executable = await resolveRipgrepExecutableWithAbort(signal);
|
|
160373
|
+
throwIfRipgrepAborted(signal);
|
|
160374
|
+
const child = spawn17(executable, args, {
|
|
160339
160375
|
cwd: cwd ?? process.cwd(),
|
|
160340
160376
|
stdio: ["ignore", "pipe", "pipe"],
|
|
160341
160377
|
signal
|
|
@@ -160401,8 +160437,10 @@ function parseRipgrepJson(output) {
|
|
|
160401
160437
|
var pathSchema;
|
|
160402
160438
|
var globSchema;
|
|
160403
160439
|
var MAX_RIPGREP_OUTPUT_BYTES = 2e6;
|
|
160440
|
+
var ripgrepExecutablePromise = null;
|
|
160404
160441
|
var init_ripgrep_utils = __esm2(() => {
|
|
160405
160442
|
init_json();
|
|
160443
|
+
init_tools_manager();
|
|
160406
160444
|
pathSchema = Type25.Optional(Type25.Union([
|
|
160407
160445
|
Type25.String({
|
|
160408
160446
|
description: "Directory or file to search",
|
|
@@ -202353,8 +202391,11 @@ async function runRpcMode(agent, sessionManager) {
|
|
|
202353
202391
|
terminal: false
|
|
202354
202392
|
});
|
|
202355
202393
|
rl.on("line", async (line) => {
|
|
202394
|
+
let requestId;
|
|
202395
|
+
const withRequestId = (response) => requestId ? { id: requestId, ...response } : response;
|
|
202356
202396
|
try {
|
|
202357
202397
|
const input = JSON.parse(line);
|
|
202398
|
+
requestId = typeof input.id === "string" ? input.id : void 0;
|
|
202358
202399
|
if (input.type === "prompt" && input.message) {
|
|
202359
202400
|
await runUserPromptWithRecovery({
|
|
202360
202401
|
agent,
|
|
@@ -202372,12 +202413,12 @@ async function runRpcMode(agent, sessionManager) {
|
|
|
202372
202413
|
} else if (input.type === "abort") {
|
|
202373
202414
|
agent.abort();
|
|
202374
202415
|
} else if (input.type === "get_messages") {
|
|
202375
|
-
console.log(JSON.stringify({
|
|
202416
|
+
console.log(JSON.stringify(withRequestId({
|
|
202376
202417
|
type: "messages",
|
|
202377
202418
|
messages: agent.state.messages
|
|
202378
|
-
}));
|
|
202419
|
+
})));
|
|
202379
202420
|
} else if (input.type === "get_state") {
|
|
202380
|
-
console.log(JSON.stringify({
|
|
202421
|
+
console.log(JSON.stringify(withRequestId({
|
|
202381
202422
|
type: "state",
|
|
202382
202423
|
state: {
|
|
202383
202424
|
model: agent.state.model,
|
|
@@ -202388,7 +202429,7 @@ async function runRpcMode(agent, sessionManager) {
|
|
|
202388
202429
|
session: agent.state.session,
|
|
202389
202430
|
queuedMessageCount: agent.getQueuedMessageCount()
|
|
202390
202431
|
}
|
|
202391
|
-
}));
|
|
202432
|
+
})));
|
|
202392
202433
|
} else if (input.type === "continue") {
|
|
202393
202434
|
await runWithPromptRecovery({
|
|
202394
202435
|
agent,
|
|
@@ -202418,13 +202459,13 @@ async function runRpcMode(agent, sessionManager) {
|
|
|
202418
202459
|
}
|
|
202419
202460
|
});
|
|
202420
202461
|
if (!result2.success) {
|
|
202421
|
-
console.log(JSON.stringify({
|
|
202462
|
+
console.log(JSON.stringify(withRequestId({
|
|
202422
202463
|
type: "error",
|
|
202423
202464
|
error: result2.error
|
|
202424
|
-
}));
|
|
202465
|
+
})));
|
|
202425
202466
|
return;
|
|
202426
202467
|
}
|
|
202427
|
-
const compactionEvent = {
|
|
202468
|
+
const compactionEvent = withRequestId({
|
|
202428
202469
|
type: "compaction",
|
|
202429
202470
|
summary: result2.summary ?? `Compacted ${result2.compactedCount} messages`,
|
|
202430
202471
|
firstKeptEntryIndex: result2.firstKeptEntryIndex ?? 0,
|
|
@@ -202432,12 +202473,18 @@ async function runRpcMode(agent, sessionManager) {
|
|
|
202432
202473
|
auto: false,
|
|
202433
202474
|
customInstructions,
|
|
202434
202475
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
202435
|
-
};
|
|
202476
|
+
});
|
|
202436
202477
|
console.log(JSON.stringify(compactionEvent));
|
|
202478
|
+
} else {
|
|
202479
|
+
const commandType = typeof input.type === "string" && input.type ? input.type : "unknown";
|
|
202480
|
+
console.log(JSON.stringify(withRequestId({
|
|
202481
|
+
type: "error",
|
|
202482
|
+
error: `Unknown RPC command: ${commandType}`
|
|
202483
|
+
})));
|
|
202437
202484
|
}
|
|
202438
202485
|
} catch (error) {
|
|
202439
202486
|
const message = error instanceof Error ? error.message : String(error);
|
|
202440
|
-
console.log(JSON.stringify({ type: "error", error: message }));
|
|
202487
|
+
console.log(JSON.stringify(withRequestId({ type: "error", error: message })));
|
|
202441
202488
|
}
|
|
202442
202489
|
});
|
|
202443
202490
|
return new Promise(() => {
|
package/dist/rpc/rpc-client.js
CHANGED
|
@@ -53,7 +53,7 @@ export class RpcClient extends EventEmitter {
|
|
|
53
53
|
...process.env,
|
|
54
54
|
...this.options.env,
|
|
55
55
|
};
|
|
56
|
-
this.process = spawn(this.options.cliPath, ["--rpc"], {
|
|
56
|
+
this.process = spawn(this.options.cliPath, ["--mode", "rpc"], {
|
|
57
57
|
cwd: this.options.cwd,
|
|
58
58
|
env,
|
|
59
59
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client.js","sourceRoot":"","sources":["../../src/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAkB,eAAe,EAAE,MAAM,eAAe,CAAC;AAShE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAgB/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,SAAU,SAAQ,YAAY;IAc1C,YAAY,UAA4B,EAAE;QACzC,KAAK,EAAE,CAAC;QAdD,YAAO,GAAwB,IAAI,CAAC;QACpC,aAAQ,GAAqB,IAAI,CAAC;QAClC,YAAO,GAOX,IAAI,GAAG,EAAE,CAAC;QACN,cAAS,GAAG,CAAC,CAAC;QAKrB,IAAI,CAAC,OAAO,GAAG;YACd,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,SAAS;YACrC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE;YACjC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;SACjC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACV,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC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AK,CAAC,WAAW,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/**\n * RPC Client for Maestro Agent\n *\n * Provides a typed TypeScript client for interacting with Maestro\n * over JSON-over-stdio RPC.\n *\n * @module rpc/rpc-client\n */\n\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { EventEmitter } from \"node:events\";\nimport { type Interface, createInterface } from \"node:readline\";\nimport type { AgentEvent, Message } from \"../agent/types.js\";\nimport type {\n\tRpcCommand,\n\tRpcErrorResponse,\n\tRpcMessagesResponse,\n\tRpcResponse,\n\tRpcStateResponse,\n} from \"./rpc-types.js\";\nimport { isAgentEvent, isErrorResponse } from \"./rpc-types.js\";\n\n/**\n * Options for creating an RPC client.\n */\nexport interface RpcClientOptions {\n\t/** Path to the Maestro CLI executable */\n\tcliPath?: string;\n\t/** Working directory for the agent */\n\tcwd?: string;\n\t/** Additional environment variables */\n\tenv?: Record<string, string>;\n\t/** Timeout for requests in milliseconds (default: 30000) */\n\ttimeout?: number;\n}\n\n/**\n * Typed RPC client for Maestro Agent.\n *\n * @example\n * ```ts\n * const client = new RpcClient();\n * await client.start();\n *\n * client.on(\"message_update\", (event) => {\n * console.log(\"Streaming:\", event.message.content);\n * });\n *\n * await client.promptAndWait(\"Hello, world!\");\n * const messages = await client.getMessages();\n *\n * client.stop();\n * ```\n */\nexport class RpcClient extends EventEmitter {\n\tprivate process: ChildProcess | null = null;\n\tprivate readline: Interface | null = null;\n\tprivate pending: Map<\n\t\tstring,\n\t\t{\n\t\t\tresolve: (value: RpcResponse) => void;\n\t\t\treject: (error: Error) => void;\n\t\t\ttimeout: NodeJS.Timeout;\n\t\t}\n\t> = new Map();\n\tprivate requestId = 0;\n\tprivate options: Required<RpcClientOptions>;\n\n\tconstructor(options: RpcClientOptions = {}) {\n\t\tsuper();\n\t\tthis.options = {\n\t\t\tcliPath: options.cliPath ?? \"maestro\",\n\t\t\tcwd: options.cwd ?? process.cwd(),\n\t\t\tenv: options.env ?? {},\n\t\t\ttimeout: options.timeout ?? 30000,\n\t\t};\n\t}\n\n\t/**\n\t * Start the Maestro agent process.\n\t */\n\tasync start(): Promise<void> {\n\t\tif (this.process) {\n\t\t\tthrow new Error(\"Client already started\");\n\t\t}\n\n\t\tconst env = {\n\t\t\t...process.env,\n\t\t\t...this.options.env,\n\t\t};\n\n\t\tthis.process = spawn(this.options.cliPath, [\"--rpc\"], {\n\t\t\tcwd: this.options.cwd,\n\t\t\tenv,\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t});\n\n\t\tif (!this.process.stdin || !this.process.stdout) {\n\t\t\tthrow new Error(\"Failed to create stdio pipes\");\n\t\t}\n\n\t\t// Set up readline for response parsing\n\t\tthis.readline = createInterface({\n\t\t\tinput: this.process.stdout,\n\t\t\tterminal: false,\n\t\t});\n\n\t\t// Handle incoming responses\n\t\tthis.readline.on(\"line\", (line) => {\n\t\t\ttry {\n\t\t\t\tconst response = JSON.parse(line) as RpcResponse;\n\t\t\t\tthis.handleResponse(response);\n\t\t\t} catch (error) {\n\t\t\t\tthis.emit(\"error\", new Error(`Failed to parse response: ${line}`));\n\t\t\t}\n\t\t});\n\n\t\t// Handle process errors\n\t\tthis.process.on(\"error\", (error) => {\n\t\t\tthis.emit(\"error\", error);\n\t\t});\n\n\t\tthis.process.on(\"exit\", (code) => {\n\t\t\tthis.emit(\"exit\", code);\n\t\t\tthis.cleanup();\n\t\t});\n\n\t\t// Forward stderr for debugging\n\t\tthis.process.stderr?.on(\"data\", (data) => {\n\t\t\tthis.emit(\"stderr\", data.toString());\n\t\t});\n\n\t\t// Wait for process to be ready\n\t\tawait new Promise<void>((resolve) => {\n\t\t\t// Give the process a moment to start\n\t\t\tsetTimeout(resolve, 100);\n\t\t});\n\t}\n\n\t/**\n\t * Stop the Maestro agent process.\n\t */\n\tstop(): void {\n\t\tthis.cleanup();\n\t\tif (this.process) {\n\t\t\tthis.process.kill();\n\t\t\tthis.process = null;\n\t\t}\n\t}\n\n\tprivate cleanup(): void {\n\t\tif (this.readline) {\n\t\t\tthis.readline.close();\n\t\t\tthis.readline = null;\n\t\t}\n\n\t\t// Reject all pending requests\n\t\tfor (const [id, pending] of this.pending) {\n\t\t\tclearTimeout(pending.timeout);\n\t\t\tpending.reject(new Error(\"Client stopped\"));\n\t\t}\n\t\tthis.pending.clear();\n\t}\n\n\tprivate handleResponse(response: RpcResponse): void {\n\t\t// Check if this is a response to a pending request\n\t\tconst id = (response as { id?: string }).id;\n\t\tif (id) {\n\t\t\tconst pending = this.pending.get(id);\n\t\t\tif (pending) {\n\t\t\t\tclearTimeout(pending.timeout);\n\t\t\t\tthis.pending.delete(id);\n\t\t\t\tpending.resolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Emit agent events\n\t\tif (isAgentEvent(response)) {\n\t\t\tthis.emit(response.type, response);\n\t\t\tthis.emit(\"event\", response);\n\t\t} else if (isErrorResponse(response)) {\n\t\t\tthis.emit(\"error\", new Error(response.error));\n\t\t} else {\n\t\t\t// Other responses without IDs\n\t\t\tthis.emit(\"response\", response);\n\t\t}\n\t}\n\n\t/**\n\t * Send a command to the agent.\n\t */\n\tprivate send(command: RpcCommand): void {\n\t\tif (!this.process?.stdin) {\n\t\t\tthrow new Error(\"Client not started\");\n\t\t}\n\t\tthis.process.stdin.write(`${JSON.stringify(command)}\\n`);\n\t}\n\n\t/**\n\t * Send a command and wait for a specific response type.\n\t */\n\tprivate async request<T extends RpcResponse>(\n\t\tcommand: RpcCommand,\n\t\texpectedType?: string,\n\t): Promise<T> {\n\t\tconst id = `req_${++this.requestId}`;\n\t\tconst commandWithId = { ...command, id };\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.pending.delete(id);\n\t\t\t\treject(new Error(`Request timeout: ${command.type}`));\n\t\t\t}, this.options.timeout);\n\n\t\t\tthis.pending.set(id, {\n\t\t\t\tresolve: resolve as (value: RpcResponse) => void,\n\t\t\t\treject,\n\t\t\t\ttimeout,\n\t\t\t});\n\n\t\t\tthis.send(commandWithId);\n\t\t});\n\t}\n\n\t/**\n\t * Send a prompt to the agent (fire and forget).\n\t * Use promptAndWait() if you need to wait for completion.\n\t */\n\tprompt(message: string): void {\n\t\tthis.send({ type: \"prompt\", message });\n\t}\n\n\t/**\n\t * Send a prompt and wait for the agent to finish.\n\t * Returns when agent_end event is received.\n\t */\n\tasync promptAndWait(message: string): Promise<AgentEvent> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst cleanup = () => {\n\t\t\t\tthis.off(\"agent_end\", onEnd);\n\t\t\t\tthis.off(\"error\", onError);\n\t\t\t};\n\n\t\t\tconst onEnd = (event: AgentEvent) => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve(event);\n\t\t\t};\n\n\t\t\tconst onError = (error: Error) => {\n\t\t\t\tcleanup();\n\t\t\t\treject(error);\n\t\t\t};\n\n\t\t\tthis.once(\"agent_end\", onEnd);\n\t\t\tthis.once(\"error\", onError);\n\n\t\t\tthis.prompt(message);\n\t\t});\n\t}\n\n\t/**\n\t * Abort the current operation.\n\t */\n\tabort(): void {\n\t\tthis.send({ type: \"abort\" });\n\t}\n\n\t/**\n\t * Get the current conversation messages.\n\t */\n\tasync getMessages(): Promise<Message[]> {\n\t\tconst response = await this.request<RpcMessagesResponse>({\n\t\t\ttype: \"get_messages\",\n\t\t});\n\t\treturn response.messages;\n\t}\n\n\t/**\n\t * Get the full agent state.\n\t */\n\tasync getState(): Promise<RpcStateResponse[\"state\"]> {\n\t\tconst response = await this.request<RpcStateResponse>({\n\t\t\ttype: \"get_state\",\n\t\t});\n\t\treturn response.state;\n\t}\n\n\t/**\n\t * Continue the conversation without a new user message.\n\t */\n\tcontinue(options?: { systemPromptOverride?: string }): void {\n\t\tthis.send({ type: \"continue\", options });\n\t}\n\n\t/**\n\t * Continue and wait for the agent to finish.\n\t */\n\tasync continueAndWait(options?: {\n\t\tsystemPromptOverride?: string;\n\t}): Promise<AgentEvent> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst cleanup = () => {\n\t\t\t\tthis.off(\"agent_end\", onEnd);\n\t\t\t\tthis.off(\"error\", onError);\n\t\t\t};\n\n\t\t\tconst onEnd = (event: AgentEvent) => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve(event);\n\t\t\t};\n\n\t\t\tconst onError = (error: Error) => {\n\t\t\t\tcleanup();\n\t\t\t\treject(error);\n\t\t\t};\n\n\t\t\tthis.once(\"agent_end\", onEnd);\n\t\t\tthis.once(\"error\", onError);\n\n\t\t\tthis.continue(options);\n\t\t});\n\t}\n\n\t/**\n\t * Trigger context compaction.\n\t */\n\tcompact(customInstructions?: string): void {\n\t\tthis.send({ type: \"compact\", customInstructions });\n\t}\n\n\t/**\n\t * Wait for the agent to become idle.\n\t */\n\tasync waitForIdle(): Promise<void> {\n\t\tconst state = await this.getState();\n\t\tif (!state.isStreaming) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tconst onEnd = () => {\n\t\t\t\tthis.off(\"agent_end\", onEnd);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tthis.once(\"agent_end\", onEnd);\n\t\t});\n\t}\n\n\t/**\n\t * Check if the agent is currently streaming.\n\t */\n\tasync isStreaming(): Promise<boolean> {\n\t\tconst state = await this.getState();\n\t\treturn state.isStreaming;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"rpc-client.js","sourceRoot":"","sources":["../../src/rpc/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAkB,eAAe,EAAE,MAAM,eAAe,CAAC;AAShE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAgB/D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,SAAU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kB,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QAChB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YACxB,OAAO;QACR,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,KAAK,GAAG,GAAG,EAAE;gBAClB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;gBAC7B,OAAO,EAAE,CAAC;YACX,CAAC,CAAC;YACF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QAChB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC,WAAW,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/**\n * RPC Client for Maestro Agent\n *\n * Provides a typed TypeScript client for interacting with Maestro\n * over JSON-over-stdio RPC.\n *\n * @module rpc/rpc-client\n */\n\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { EventEmitter } from \"node:events\";\nimport { type Interface, createInterface } from \"node:readline\";\nimport type { AgentEvent, Message } from \"../agent/types.js\";\nimport type {\n\tRpcCommand,\n\tRpcErrorResponse,\n\tRpcMessagesResponse,\n\tRpcResponse,\n\tRpcStateResponse,\n} from \"./rpc-types.js\";\nimport { isAgentEvent, isErrorResponse } from \"./rpc-types.js\";\n\n/**\n * Options for creating an RPC client.\n */\nexport interface RpcClientOptions {\n\t/** Path to the Maestro CLI executable */\n\tcliPath?: string;\n\t/** Working directory for the agent */\n\tcwd?: string;\n\t/** Additional environment variables */\n\tenv?: Record<string, string>;\n\t/** Timeout for requests in milliseconds (default: 30000) */\n\ttimeout?: number;\n}\n\n/**\n * Typed RPC client for Maestro Agent.\n *\n * @example\n * ```ts\n * const client = new RpcClient();\n * await client.start();\n *\n * client.on(\"message_update\", (event) => {\n * console.log(\"Streaming:\", event.message.content);\n * });\n *\n * await client.promptAndWait(\"Hello, world!\");\n * const messages = await client.getMessages();\n *\n * client.stop();\n * ```\n */\nexport class RpcClient extends EventEmitter {\n\tprivate process: ChildProcess | null = null;\n\tprivate readline: Interface | null = null;\n\tprivate pending: Map<\n\t\tstring,\n\t\t{\n\t\t\tresolve: (value: RpcResponse) => void;\n\t\t\treject: (error: Error) => void;\n\t\t\ttimeout: NodeJS.Timeout;\n\t\t}\n\t> = new Map();\n\tprivate requestId = 0;\n\tprivate options: Required<RpcClientOptions>;\n\n\tconstructor(options: RpcClientOptions = {}) {\n\t\tsuper();\n\t\tthis.options = {\n\t\t\tcliPath: options.cliPath ?? \"maestro\",\n\t\t\tcwd: options.cwd ?? process.cwd(),\n\t\t\tenv: options.env ?? {},\n\t\t\ttimeout: options.timeout ?? 30000,\n\t\t};\n\t}\n\n\t/**\n\t * Start the Maestro agent process.\n\t */\n\tasync start(): Promise<void> {\n\t\tif (this.process) {\n\t\t\tthrow new Error(\"Client already started\");\n\t\t}\n\n\t\tconst env = {\n\t\t\t...process.env,\n\t\t\t...this.options.env,\n\t\t};\n\n\t\tthis.process = spawn(this.options.cliPath, [\"--mode\", \"rpc\"], {\n\t\t\tcwd: this.options.cwd,\n\t\t\tenv,\n\t\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t\t});\n\n\t\tif (!this.process.stdin || !this.process.stdout) {\n\t\t\tthrow new Error(\"Failed to create stdio pipes\");\n\t\t}\n\n\t\t// Set up readline for response parsing\n\t\tthis.readline = createInterface({\n\t\t\tinput: this.process.stdout,\n\t\t\tterminal: false,\n\t\t});\n\n\t\t// Handle incoming responses\n\t\tthis.readline.on(\"line\", (line) => {\n\t\t\ttry {\n\t\t\t\tconst response = JSON.parse(line) as RpcResponse;\n\t\t\t\tthis.handleResponse(response);\n\t\t\t} catch (error) {\n\t\t\t\tthis.emit(\"error\", new Error(`Failed to parse response: ${line}`));\n\t\t\t}\n\t\t});\n\n\t\t// Handle process errors\n\t\tthis.process.on(\"error\", (error) => {\n\t\t\tthis.emit(\"error\", error);\n\t\t});\n\n\t\tthis.process.on(\"exit\", (code) => {\n\t\t\tthis.emit(\"exit\", code);\n\t\t\tthis.cleanup();\n\t\t});\n\n\t\t// Forward stderr for debugging\n\t\tthis.process.stderr?.on(\"data\", (data) => {\n\t\t\tthis.emit(\"stderr\", data.toString());\n\t\t});\n\n\t\t// Wait for process to be ready\n\t\tawait new Promise<void>((resolve) => {\n\t\t\t// Give the process a moment to start\n\t\t\tsetTimeout(resolve, 100);\n\t\t});\n\t}\n\n\t/**\n\t * Stop the Maestro agent process.\n\t */\n\tstop(): void {\n\t\tthis.cleanup();\n\t\tif (this.process) {\n\t\t\tthis.process.kill();\n\t\t\tthis.process = null;\n\t\t}\n\t}\n\n\tprivate cleanup(): void {\n\t\tif (this.readline) {\n\t\t\tthis.readline.close();\n\t\t\tthis.readline = null;\n\t\t}\n\n\t\t// Reject all pending requests\n\t\tfor (const [id, pending] of this.pending) {\n\t\t\tclearTimeout(pending.timeout);\n\t\t\tpending.reject(new Error(\"Client stopped\"));\n\t\t}\n\t\tthis.pending.clear();\n\t}\n\n\tprivate handleResponse(response: RpcResponse): void {\n\t\t// Check if this is a response to a pending request\n\t\tconst id = (response as { id?: string }).id;\n\t\tif (id) {\n\t\t\tconst pending = this.pending.get(id);\n\t\t\tif (pending) {\n\t\t\t\tclearTimeout(pending.timeout);\n\t\t\t\tthis.pending.delete(id);\n\t\t\t\tpending.resolve(response);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Emit agent events\n\t\tif (isAgentEvent(response)) {\n\t\t\tthis.emit(response.type, response);\n\t\t\tthis.emit(\"event\", response);\n\t\t} else if (isErrorResponse(response)) {\n\t\t\tthis.emit(\"error\", new Error(response.error));\n\t\t} else {\n\t\t\t// Other responses without IDs\n\t\t\tthis.emit(\"response\", response);\n\t\t}\n\t}\n\n\t/**\n\t * Send a command to the agent.\n\t */\n\tprivate send(command: RpcCommand): void {\n\t\tif (!this.process?.stdin) {\n\t\t\tthrow new Error(\"Client not started\");\n\t\t}\n\t\tthis.process.stdin.write(`${JSON.stringify(command)}\\n`);\n\t}\n\n\t/**\n\t * Send a command and wait for a specific response type.\n\t */\n\tprivate async request<T extends RpcResponse>(\n\t\tcommand: RpcCommand,\n\t\texpectedType?: string,\n\t): Promise<T> {\n\t\tconst id = `req_${++this.requestId}`;\n\t\tconst commandWithId = { ...command, id };\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\tthis.pending.delete(id);\n\t\t\t\treject(new Error(`Request timeout: ${command.type}`));\n\t\t\t}, this.options.timeout);\n\n\t\t\tthis.pending.set(id, {\n\t\t\t\tresolve: resolve as (value: RpcResponse) => void,\n\t\t\t\treject,\n\t\t\t\ttimeout,\n\t\t\t});\n\n\t\t\tthis.send(commandWithId);\n\t\t});\n\t}\n\n\t/**\n\t * Send a prompt to the agent (fire and forget).\n\t * Use promptAndWait() if you need to wait for completion.\n\t */\n\tprompt(message: string): void {\n\t\tthis.send({ type: \"prompt\", message });\n\t}\n\n\t/**\n\t * Send a prompt and wait for the agent to finish.\n\t * Returns when agent_end event is received.\n\t */\n\tasync promptAndWait(message: string): Promise<AgentEvent> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst cleanup = () => {\n\t\t\t\tthis.off(\"agent_end\", onEnd);\n\t\t\t\tthis.off(\"error\", onError);\n\t\t\t};\n\n\t\t\tconst onEnd = (event: AgentEvent) => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve(event);\n\t\t\t};\n\n\t\t\tconst onError = (error: Error) => {\n\t\t\t\tcleanup();\n\t\t\t\treject(error);\n\t\t\t};\n\n\t\t\tthis.once(\"agent_end\", onEnd);\n\t\t\tthis.once(\"error\", onError);\n\n\t\t\tthis.prompt(message);\n\t\t});\n\t}\n\n\t/**\n\t * Abort the current operation.\n\t */\n\tabort(): void {\n\t\tthis.send({ type: \"abort\" });\n\t}\n\n\t/**\n\t * Get the current conversation messages.\n\t */\n\tasync getMessages(): Promise<Message[]> {\n\t\tconst response = await this.request<RpcMessagesResponse>({\n\t\t\ttype: \"get_messages\",\n\t\t});\n\t\treturn response.messages;\n\t}\n\n\t/**\n\t * Get the full agent state.\n\t */\n\tasync getState(): Promise<RpcStateResponse[\"state\"]> {\n\t\tconst response = await this.request<RpcStateResponse>({\n\t\t\ttype: \"get_state\",\n\t\t});\n\t\treturn response.state;\n\t}\n\n\t/**\n\t * Continue the conversation without a new user message.\n\t */\n\tcontinue(options?: { systemPromptOverride?: string }): void {\n\t\tthis.send({ type: \"continue\", options });\n\t}\n\n\t/**\n\t * Continue and wait for the agent to finish.\n\t */\n\tasync continueAndWait(options?: {\n\t\tsystemPromptOverride?: string;\n\t}): Promise<AgentEvent> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst cleanup = () => {\n\t\t\t\tthis.off(\"agent_end\", onEnd);\n\t\t\t\tthis.off(\"error\", onError);\n\t\t\t};\n\n\t\t\tconst onEnd = (event: AgentEvent) => {\n\t\t\t\tcleanup();\n\t\t\t\tresolve(event);\n\t\t\t};\n\n\t\t\tconst onError = (error: Error) => {\n\t\t\t\tcleanup();\n\t\t\t\treject(error);\n\t\t\t};\n\n\t\t\tthis.once(\"agent_end\", onEnd);\n\t\t\tthis.once(\"error\", onError);\n\n\t\t\tthis.continue(options);\n\t\t});\n\t}\n\n\t/**\n\t * Trigger context compaction.\n\t */\n\tcompact(customInstructions?: string): void {\n\t\tthis.send({ type: \"compact\", customInstructions });\n\t}\n\n\t/**\n\t * Wait for the agent to become idle.\n\t */\n\tasync waitForIdle(): Promise<void> {\n\t\tconst state = await this.getState();\n\t\tif (!state.isStreaming) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Promise((resolve) => {\n\t\t\tconst onEnd = () => {\n\t\t\t\tthis.off(\"agent_end\", onEnd);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tthis.once(\"agent_end\", onEnd);\n\t\t});\n\t}\n\n\t/**\n\t * Check if the agent is currently streaming.\n\t */\n\tasync isStreaming(): Promise<boolean> {\n\t\tconst state = await this.getState();\n\t\treturn state.isStreaming;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-policy-validator.d.ts","sourceRoot":"","sources":["../../../src/safety/validators/network-policy-validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAY5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAsBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAc1E;AAED;;GAEG;AACH,wBAAsB,gCAAgC,CACrD,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAC/C,OAAO,CAAC,uBAAuB,CAAC,
|
|
1
|
+
{"version":3,"file":"network-policy-validator.d.ts","sourceRoot":"","sources":["../../../src/safety/validators/network-policy-validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAY5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;CACtB;AAsBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAc1E;AAED;;GAEG;AACH,wBAAsB,gCAAgC,CACrD,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAC/C,OAAO,CAAC,uBAAuB,CAAC,CAyGlC;AAED,wBAAsB,wBAAwB,CAC7C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAC/C,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAKhD;AAED,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,GAC/C,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAShD"}
|
|
@@ -39,6 +39,44 @@ export async function checkNetworkRestrictionsDetailed(url, network) {
|
|
|
39
39
|
const parsed = new URL(url);
|
|
40
40
|
const host = parsed.hostname.toLowerCase();
|
|
41
41
|
const normalizedHost = host.replace(/^\[|\]$/g, "");
|
|
42
|
+
if (network.blockedHosts?.length) {
|
|
43
|
+
for (const blockedHost of network.blockedHosts) {
|
|
44
|
+
const lowerBlocked = blockedHost.toLowerCase();
|
|
45
|
+
if (host === lowerBlocked || host.endsWith(`.${lowerBlocked}`)) {
|
|
46
|
+
return {
|
|
47
|
+
allowed: false,
|
|
48
|
+
reason: `Host "${host}" is blocked by enterprise policy.`,
|
|
49
|
+
host,
|
|
50
|
+
normalizedHost,
|
|
51
|
+
resolvedIPs: [],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (network.allowedHosts) {
|
|
57
|
+
if (network.allowedHosts.length === 0) {
|
|
58
|
+
return {
|
|
59
|
+
allowed: false,
|
|
60
|
+
reason: `Host "${host}" is not in the allowed hosts list.`,
|
|
61
|
+
host,
|
|
62
|
+
normalizedHost,
|
|
63
|
+
resolvedIPs: [],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const isAllowed = network.allowedHosts.some((allowedHost) => {
|
|
67
|
+
const lowerAllowed = allowedHost.toLowerCase();
|
|
68
|
+
return host === lowerAllowed || host.endsWith(`.${lowerAllowed}`);
|
|
69
|
+
});
|
|
70
|
+
if (!isAllowed) {
|
|
71
|
+
return {
|
|
72
|
+
allowed: false,
|
|
73
|
+
reason: `Host "${host}" is not in the allowed hosts list.`,
|
|
74
|
+
host,
|
|
75
|
+
normalizedHost,
|
|
76
|
+
resolvedIPs: [],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
42
80
|
const resolvedIPs = [];
|
|
43
81
|
const isIP = parseIPv4(normalizedHost) !== null ||
|
|
44
82
|
parseIPv4MappedHex(normalizedHost) !== null ||
|
|
@@ -85,44 +123,6 @@ export async function checkNetworkRestrictionsDetailed(url, network) {
|
|
|
85
123
|
};
|
|
86
124
|
}
|
|
87
125
|
}
|
|
88
|
-
if (network.blockedHosts?.length) {
|
|
89
|
-
for (const blockedHost of network.blockedHosts) {
|
|
90
|
-
const lowerBlocked = blockedHost.toLowerCase();
|
|
91
|
-
if (host === lowerBlocked || host.endsWith(`.${lowerBlocked}`)) {
|
|
92
|
-
return {
|
|
93
|
-
allowed: false,
|
|
94
|
-
reason: `Host "${host}" is blocked by enterprise policy.`,
|
|
95
|
-
host,
|
|
96
|
-
normalizedHost,
|
|
97
|
-
resolvedIPs,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (network.allowedHosts) {
|
|
103
|
-
if (network.allowedHosts.length === 0) {
|
|
104
|
-
return {
|
|
105
|
-
allowed: false,
|
|
106
|
-
reason: `Host "${host}" is not in the allowed hosts list.`,
|
|
107
|
-
host,
|
|
108
|
-
normalizedHost,
|
|
109
|
-
resolvedIPs,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const isAllowed = network.allowedHosts.some((allowedHost) => {
|
|
113
|
-
const lowerAllowed = allowedHost.toLowerCase();
|
|
114
|
-
return host === lowerAllowed || host.endsWith(`.${lowerAllowed}`);
|
|
115
|
-
});
|
|
116
|
-
if (!isAllowed) {
|
|
117
|
-
return {
|
|
118
|
-
allowed: false,
|
|
119
|
-
reason: `Host "${host}" is not in the allowed hosts list.`,
|
|
120
|
-
host,
|
|
121
|
-
normalizedHost,
|
|
122
|
-
resolvedIPs,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
126
|
return { allowed: true, host, normalizedHost, resolvedIPs };
|
|
127
127
|
}
|
|
128
128
|
catch {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-policy-validator.js","sourceRoot":"","sources":["../../../src/safety/validators/network-policy-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,kBAAkB,GAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,2BAA2B,EAC3B,oBAAoB,GACpB,MAAM,8BAA8B,CAAC;AAWtC,SAAS,aAAa,CACrB,OAA8B;IAE9B,OAAO,OAAO,CAAC,IAAI,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;QACtD,CAAC,CAAE,OAAO,CAAC,IAAgC;QAC3C,CAAC,CAAC,IAAI,CAAC;AACT,CAAC;AAED,SAAS,YAAY,CACpB,OAA8B,EAC9B,GAAW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d,MAAM,EAAE,8DAA8D;YACtE,WAAW,EAAE,EAAE;SACf,CAAC;IACH,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC7C,GAAW,EACX,OAAiD;IAEjD,MAAM,KAAK,GAAG,MAAM,gCAAgC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC,MAAM;QAClB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;QAClD,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,OAA8B,EAC9B,OAAiD;IAEjD,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACxC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,MAAM,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import { lookup } from \"node:dns/promises\";\nimport type { ActionApprovalContext } from \"../../agent/action-approval.js\";\nimport {\n\tisLocalhostAlias,\n\tisLoopbackIP,\n\tisPrivateIP,\n\tparseIPv4,\n\tparseIPv4MappedHex,\n} from \"../../utils/ip-address-parser.js\";\nimport {\n\textractUrlsFromShellCommand,\n\textractUrlsFromValue,\n} from \"../../utils/url-extractor.js\";\nimport type { EnterprisePolicy } from \"../policy.js\";\n\nexport interface NetworkRestrictionCheck {\n\tallowed: boolean;\n\treason?: string;\n\thost?: string;\n\tnormalizedHost?: string;\n\tresolvedIPs: string[];\n}\n\nfunction getArgsObject(\n\tcontext: ActionApprovalContext,\n): Record<string, unknown> | null {\n\treturn context.args && typeof context.args === \"object\"\n\t\t? (context.args as Record<string, unknown>)\n\t\t: null;\n}\n\nfunction getStringArg(\n\tcontext: ActionApprovalContext,\n\tkey: string,\n): string | null {\n\tconst args = getArgsObject(context);\n\tif (!args) {\n\t\treturn null;\n\t}\n\tconst value = args[key];\n\treturn typeof value === \"string\" ? value : null;\n}\n\n/**\n * Extract URLs from tool arguments (recursively checks nested objects)\n * Also extracts URLs from curl/wget commands in bash.\n */\nexport function extractPolicyUrls(context: ActionApprovalContext): string[] {\n\tconst args = getArgsObject(context);\n\tif (!args) return [];\n\n\tconst urls = extractUrlsFromValue(args);\n\n\tif (context.toolName === \"bash\" || context.toolName === \"background_tasks\") {\n\t\tconst command = getStringArg(context, \"command\");\n\t\tif (command) {\n\t\t\turls.push(...extractUrlsFromShellCommand(command));\n\t\t}\n\t}\n\n\treturn urls;\n}\n\n/**\n * Check if a URL/host matches network restrictions.\n */\nexport async function checkNetworkRestrictionsDetailed(\n\turl: string,\n\tnetwork: NonNullable<EnterprisePolicy[\"network\"]>,\n): Promise<NetworkRestrictionCheck> {\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\tconst host = parsed.hostname.toLowerCase();\n\n\t\tconst normalizedHost = host.replace(/^\\[|\\]$/g, \"\");\n\n\t\tconst resolvedIPs: string[] = [];\n\t\tconst isIP =\n\t\t\tparseIPv4(normalizedHost) !== null ||\n\t\t\tparseIPv4MappedHex(normalizedHost) !== null ||\n\t\t\tnormalizedHost.includes(\":\");\n\n\t\tif (!isIP) {\n\t\t\ttry {\n\t\t\t\tconst addresses = await lookup(normalizedHost, { all: true });\n\t\t\t\tresolvedIPs.push(...addresses.map(({ address }) => address));\n\t\t\t} catch {\n\t\t\t\tif (network.blockPrivateIPs || network.blockLocalhost) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tallowed: false,\n\t\t\t\t\t\treason: `DNS resolution failed for \"${host}\" and network policy requires IP validation (blockPrivateIPs/blockLocalhost enabled). Access blocked.`,\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tnormalizedHost,\n\t\t\t\t\t\tresolvedIPs,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresolvedIPs.push(normalizedHost);\n\t\t}\n\n\t\tif (network.blockLocalhost) {\n\t\t\tif (isLocalhostAlias(normalizedHost) || resolvedIPs.some(isLoopbackIP)) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason: \"Access to localhost is blocked by enterprise policy.\",\n\t\t\t\t\thost,\n\t\t\t\t\tnormalizedHost,\n\t\t\t\t\tresolvedIPs,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (network.blockPrivateIPs) {\n\t\t\tif (resolvedIPs.some(isPrivateIP)) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason:\n\t\t\t\t\t\t\"Access to private IP addresses is blocked by enterprise policy.\",\n\t\t\t\t\thost,\n\t\t\t\t\tnormalizedHost,\n\t\t\t\t\tresolvedIPs,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (network.blockedHosts?.length) {\n\t\t\tfor (const blockedHost of network.blockedHosts) {\n\t\t\t\tconst lowerBlocked = blockedHost.toLowerCase();\n\t\t\t\tif (host === lowerBlocked || host.endsWith(`.${lowerBlocked}`)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tallowed: false,\n\t\t\t\t\t\treason: `Host \"${host}\" is blocked by enterprise policy.`,\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tnormalizedHost,\n\t\t\t\t\t\tresolvedIPs,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (network.allowedHosts) {\n\t\t\tif (network.allowedHosts.length === 0) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason: `Host \"${host}\" is not in the allowed hosts list.`,\n\t\t\t\t\thost,\n\t\t\t\t\tnormalizedHost,\n\t\t\t\t\tresolvedIPs,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst isAllowed = network.allowedHosts.some((allowedHost) => {\n\t\t\t\tconst lowerAllowed = allowedHost.toLowerCase();\n\t\t\t\treturn host === lowerAllowed || host.endsWith(`.${lowerAllowed}`);\n\t\t\t});\n\t\t\tif (!isAllowed) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason: `Host \"${host}\" is not in the allowed hosts list.`,\n\t\t\t\t\thost,\n\t\t\t\t\tnormalizedHost,\n\t\t\t\t\tresolvedIPs,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn { allowed: true, host, normalizedHost, resolvedIPs };\n\t} catch {\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\treason: \"Invalid URL format - cannot validate against network policy.\",\n\t\t\tresolvedIPs: [],\n\t\t};\n\t}\n}\n\nexport async function checkNetworkRestrictions(\n\turl: string,\n\tnetwork: NonNullable<EnterprisePolicy[\"network\"]>,\n): Promise<{ allowed: boolean; reason?: string }> {\n\tconst check = await checkNetworkRestrictionsDetailed(url, network);\n\treturn check.reason\n\t\t? { allowed: check.allowed, reason: check.reason }\n\t\t: { allowed: check.allowed };\n}\n\nexport async function checkNetworkPolicy(\n\tcontext: ActionApprovalContext,\n\tnetwork: NonNullable<EnterprisePolicy[\"network\"]>,\n): Promise<{ allowed: boolean; reason?: string }> {\n\tconst urls = extractPolicyUrls(context);\n\tfor (const url of urls) {\n\t\tconst check = await checkNetworkRestrictions(url, network);\n\t\tif (!check.allowed) {\n\t\t\treturn check;\n\t\t}\n\t}\n\treturn { allowed: true };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"network-policy-validator.js","sourceRoot":"","sources":["../../../src/safety/validators/network-policy-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,WAA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:dns/promises\";\nimport type { ActionApprovalContext } from \"../../agent/action-approval.js\";\nimport {\n\tisLocalhostAlias,\n\tisLoopbackIP,\n\tisPrivateIP,\n\tparseIPv4,\n\tparseIPv4MappedHex,\n} from \"../../utils/ip-address-parser.js\";\nimport {\n\textractUrlsFromShellCommand,\n\textractUrlsFromValue,\n} from \"../../utils/url-extractor.js\";\nimport type { EnterprisePolicy } from \"../policy.js\";\n\nexport interface NetworkRestrictionCheck {\n\tallowed: boolean;\n\treason?: string;\n\thost?: string;\n\tnormalizedHost?: string;\n\tresolvedIPs: string[];\n}\n\nfunction getArgsObject(\n\tcontext: ActionApprovalContext,\n): Record<string, unknown> | null {\n\treturn context.args && typeof context.args === \"object\"\n\t\t? (context.args as Record<string, unknown>)\n\t\t: null;\n}\n\nfunction getStringArg(\n\tcontext: ActionApprovalContext,\n\tkey: string,\n): string | null {\n\tconst args = getArgsObject(context);\n\tif (!args) {\n\t\treturn null;\n\t}\n\tconst value = args[key];\n\treturn typeof value === \"string\" ? value : null;\n}\n\n/**\n * Extract URLs from tool arguments (recursively checks nested objects)\n * Also extracts URLs from curl/wget commands in bash.\n */\nexport function extractPolicyUrls(context: ActionApprovalContext): string[] {\n\tconst args = getArgsObject(context);\n\tif (!args) return [];\n\n\tconst urls = extractUrlsFromValue(args);\n\n\tif (context.toolName === \"bash\" || context.toolName === \"background_tasks\") {\n\t\tconst command = getStringArg(context, \"command\");\n\t\tif (command) {\n\t\t\turls.push(...extractUrlsFromShellCommand(command));\n\t\t}\n\t}\n\n\treturn urls;\n}\n\n/**\n * Check if a URL/host matches network restrictions.\n */\nexport async function checkNetworkRestrictionsDetailed(\n\turl: string,\n\tnetwork: NonNullable<EnterprisePolicy[\"network\"]>,\n): Promise<NetworkRestrictionCheck> {\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\tconst host = parsed.hostname.toLowerCase();\n\n\t\tconst normalizedHost = host.replace(/^\\[|\\]$/g, \"\");\n\n\t\tif (network.blockedHosts?.length) {\n\t\t\tfor (const blockedHost of network.blockedHosts) {\n\t\t\t\tconst lowerBlocked = blockedHost.toLowerCase();\n\t\t\t\tif (host === lowerBlocked || host.endsWith(`.${lowerBlocked}`)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tallowed: false,\n\t\t\t\t\t\treason: `Host \"${host}\" is blocked by enterprise policy.`,\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tnormalizedHost,\n\t\t\t\t\t\tresolvedIPs: [],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (network.allowedHosts) {\n\t\t\tif (network.allowedHosts.length === 0) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason: `Host \"${host}\" is not in the allowed hosts list.`,\n\t\t\t\t\thost,\n\t\t\t\t\tnormalizedHost,\n\t\t\t\t\tresolvedIPs: [],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst isAllowed = network.allowedHosts.some((allowedHost) => {\n\t\t\t\tconst lowerAllowed = allowedHost.toLowerCase();\n\t\t\t\treturn host === lowerAllowed || host.endsWith(`.${lowerAllowed}`);\n\t\t\t});\n\t\t\tif (!isAllowed) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason: `Host \"${host}\" is not in the allowed hosts list.`,\n\t\t\t\t\thost,\n\t\t\t\t\tnormalizedHost,\n\t\t\t\t\tresolvedIPs: [],\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst resolvedIPs: string[] = [];\n\t\tconst isIP =\n\t\t\tparseIPv4(normalizedHost) !== null ||\n\t\t\tparseIPv4MappedHex(normalizedHost) !== null ||\n\t\t\tnormalizedHost.includes(\":\");\n\n\t\tif (!isIP) {\n\t\t\ttry {\n\t\t\t\tconst addresses = await lookup(normalizedHost, { all: true });\n\t\t\t\tresolvedIPs.push(...addresses.map(({ address }) => address));\n\t\t\t} catch {\n\t\t\t\tif (network.blockPrivateIPs || network.blockLocalhost) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tallowed: false,\n\t\t\t\t\t\treason: `DNS resolution failed for \"${host}\" and network policy requires IP validation (blockPrivateIPs/blockLocalhost enabled). Access blocked.`,\n\t\t\t\t\t\thost,\n\t\t\t\t\t\tnormalizedHost,\n\t\t\t\t\t\tresolvedIPs,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tresolvedIPs.push(normalizedHost);\n\t\t}\n\n\t\tif (network.blockLocalhost) {\n\t\t\tif (isLocalhostAlias(normalizedHost) || resolvedIPs.some(isLoopbackIP)) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason: \"Access to localhost is blocked by enterprise policy.\",\n\t\t\t\t\thost,\n\t\t\t\t\tnormalizedHost,\n\t\t\t\t\tresolvedIPs,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (network.blockPrivateIPs) {\n\t\t\tif (resolvedIPs.some(isPrivateIP)) {\n\t\t\t\treturn {\n\t\t\t\t\tallowed: false,\n\t\t\t\t\treason:\n\t\t\t\t\t\t\"Access to private IP addresses is blocked by enterprise policy.\",\n\t\t\t\t\thost,\n\t\t\t\t\tnormalizedHost,\n\t\t\t\t\tresolvedIPs,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn { allowed: true, host, normalizedHost, resolvedIPs };\n\t} catch {\n\t\treturn {\n\t\t\tallowed: false,\n\t\t\treason: \"Invalid URL format - cannot validate against network policy.\",\n\t\t\tresolvedIPs: [],\n\t\t};\n\t}\n}\n\nexport async function checkNetworkRestrictions(\n\turl: string,\n\tnetwork: NonNullable<EnterprisePolicy[\"network\"]>,\n): Promise<{ allowed: boolean; reason?: string }> {\n\tconst check = await checkNetworkRestrictionsDetailed(url, network);\n\treturn check.reason\n\t\t? { allowed: check.allowed, reason: check.reason }\n\t\t: { allowed: check.allowed };\n}\n\nexport async function checkNetworkPolicy(\n\tcontext: ActionApprovalContext,\n\tnetwork: NonNullable<EnterprisePolicy[\"network\"]>,\n): Promise<{ allowed: boolean; reason?: string }> {\n\tconst urls = extractPolicyUrls(context);\n\tfor (const url of urls) {\n\t\tconst check = await checkNetworkRestrictions(url, network);\n\t\tif (!check.allowed) {\n\t\t\treturn check;\n\t\t}\n\t}\n\treturn { allowed: true };\n}\n"]}
|
|
@@ -75,7 +75,7 @@ export type MaestroReleaseGateEventCategory = (typeof MAESTRO_RELEASE_GATE_EVENT
|
|
|
75
75
|
export declare const MAESTRO_RELEASE_GATE_EVENT_SUBJECTS_BY_CATEGORY: {
|
|
76
76
|
readonly install: readonly [MaestroBusEventType.InstallCheckCompleted];
|
|
77
77
|
readonly session: readonly [MaestroBusEventType.SessionClosed];
|
|
78
|
-
readonly tool: readonly [MaestroBusEventType.ToolCallCompleted, MaestroBusEventType.ToolCallFailed];
|
|
78
|
+
readonly tool: readonly [MaestroBusEventType.ToolCallAttempted, MaestroBusEventType.ToolCallCompleted, MaestroBusEventType.ToolCallFailed];
|
|
79
79
|
readonly approval: readonly [MaestroBusEventType.ApprovalHit];
|
|
80
80
|
readonly error: readonly [MaestroBusEventType.ErrorCaptured];
|
|
81
81
|
readonly artifact: readonly [MaestroBusEventType.ArtifactCreated];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maestro-event-catalog.d.ts","sourceRoot":"","sources":["../../src/telemetry/maestro-event-catalog.ts"],"names":[],"mappings":"AAAA,oBAAY,mBAAmB;IAC9B,cAAc,qCAAqC;IACnD,gBAAgB,uCAAuC;IACvD,cAAc,qCAAqC;IACnD,aAAa,oCAAoC;IACjD,qBAAqB,2CAA2C;IAChE,WAAW,gCAAgC;IAC3C,gBAAgB,qCAAqC;IACrD,aAAa,kCAAkC;IAC/C,iBAAiB,uCAAuC;IACxD,iBAAiB,uCAAuC;IACxD,cAAc,oCAAoC;IAClD,aAAa,kCAAkC;IAC/C,eAAe,oCAAoC;IACnD,mBAAmB,yCAAyC;IAC5D,qBAAqB,2CAA2C;IAChE,cAAc,mCAAmC;IACjD,YAAY,iCAAiC;IAC7C,cAAc,mCAAmC;IACjD,WAAW,gCAAgC;IAC3C,kBAAkB,uCAAuC;IACzD,eAAe,qCAAqC;IACpD,iBAAiB,uCAAuC;IACxD,eAAe,qCAAqC;IACpD,gBAAgB,sCAAsC;IACtD,aAAa,mCAAmC;IAChD,gBAAgB,sCAAsC;IACtD,eAAe,qCAAqC;IACpD,oBAAoB,0CAA0C;IAC9D,UAAU,+BAA+B;CACzC;AAED,MAAM,MAAM,uBAAuB,GAChC,SAAS,GACT,SAAS,GACT,OAAO,GACP,UAAU,GACV,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,GACV,cAAc,GACd,QAAQ,GACR,WAAW,GACX,OAAO,GACP,KAAK,GACL,MAAM,CAAC;AAEV,MAAM,WAAW,2BAA2B;IAC3C,QAAQ,EAAE,uBAAuB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,IAAI,EAAE,mBAAmB,CAAC;CAC1B;AAoBD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwNuC,CAAC;AAE9E,eAAO,MAAM,uBAAuB,uBAAqC,CAAC;AAE1E,eAAO,MAAM,qCAAqC,0FAQK,CAAC;AAExD,MAAM,MAAM,+BAA+B,GAC1C,CAAC,OAAO,qCAAqC,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,eAAO,MAAM,+CAA+C;;;;;;;;
|
|
1
|
+
{"version":3,"file":"maestro-event-catalog.d.ts","sourceRoot":"","sources":["../../src/telemetry/maestro-event-catalog.ts"],"names":[],"mappings":"AAAA,oBAAY,mBAAmB;IAC9B,cAAc,qCAAqC;IACnD,gBAAgB,uCAAuC;IACvD,cAAc,qCAAqC;IACnD,aAAa,oCAAoC;IACjD,qBAAqB,2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,GAC5E,SAAS,+BAA+B,EAAE,CAW5C;AAED,wBAAgB,4CAA4C,CAC3D,OAAO,GAAE,SAAS,2BAA2B,EAAiC,GAC5E,SAAS,mBAAmB,EAAE,CAOhC;AAED,wBAAgB,qDAAqD,CACpE,OAAO,GAAE,SAAS,2BAA2B,EAAiC,GAC5E,SAAS,8CAA8C,EAAE,CA8B3D;AAMD,wBAAgB,iCAAiC,CAChD,OAAO,GAAE,SAAS,2BAA2B,EAAiC,GAC5E,4BAA4B,CAwB9B"}
|
|
@@ -63,7 +63,7 @@ export const MAESTRO_BUS_EVENT_CATALOG = {
|
|
|
63
63
|
[MaestroBusEventType.ApprovalHit]: entry(MaestroBusEventType.ApprovalHit, "approval", "ApprovalHit", ["governance.maestro-approval-hit", "release.maestro-approval-gates"]),
|
|
64
64
|
[MaestroBusEventType.SandboxViolation]: entry(MaestroBusEventType.SandboxViolation, "safety", "SandboxViolation", ["governance.maestro-sandbox-violation"]),
|
|
65
65
|
[MaestroBusEventType.FirewallBlock]: entry(MaestroBusEventType.FirewallBlock, "safety", "FirewallBlock", ["governance.maestro-firewall-block"]),
|
|
66
|
-
[MaestroBusEventType.ToolCallAttempted]: entry(MaestroBusEventType.ToolCallAttempted, "tool", "ToolCallAttempt", ["meter.maestro-tool-call-events"]),
|
|
66
|
+
[MaestroBusEventType.ToolCallAttempted]: entry(MaestroBusEventType.ToolCallAttempted, "tool", "ToolCallAttempt", ["meter.maestro-tool-call-events", "release.maestro-tool-attempt-gates"]),
|
|
67
67
|
[MaestroBusEventType.ToolCallCompleted]: entry(MaestroBusEventType.ToolCallCompleted, "tool", "ToolCallResult", [
|
|
68
68
|
"meter.maestro-tool-call-events",
|
|
69
69
|
"release.maestro-tool-success-gates",
|
|
@@ -127,6 +127,7 @@ export const MAESTRO_RELEASE_GATE_EVENT_SUBJECTS_BY_CATEGORY = {
|
|
|
127
127
|
install: [MaestroBusEventType.InstallCheckCompleted],
|
|
128
128
|
session: [MaestroBusEventType.SessionClosed],
|
|
129
129
|
tool: [
|
|
130
|
+
MaestroBusEventType.ToolCallAttempted,
|
|
130
131
|
MaestroBusEventType.ToolCallCompleted,
|
|
131
132
|
MaestroBusEventType.ToolCallFailed,
|
|
132
133
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maestro-event-catalog.js","sourceRoot":"","sources":["../../src/telemetry/maestro-event-catalog.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBA8BX;AA9BD,WAAY,mBAAmB;IAC9B,0EAAmD,CAAA;IACnD,8EAAuD,CAAA;IACvD,0EAAmD,CAAA;IACnD,wEAAiD,CAAA;IACjD,uFAAgE,CAAA;IAChE,kEAA2C,CAAA;IAC3C,4EAAqD,CAAA;IACrD,sEAA+C,CAAA;IAC/C,+EAAwD,CAAA;IACxD,+EAAwD,CAAA;IACxD,yEAAkD,CAAA;IAClD,sEAA+C,CAAA;IAC/C,0EAAmD,CAAA;IACnD,mFAA4D,CAAA;IAC5D,uFAAgE,CAAA;IAChE,wEAAiD,CAAA;IACjD,oEAA6C,CAAA;IAC7C,wEAAiD,CAAA;IACjD,kEAA2C,CAAA;IAC3C,gFAAyD,CAAA;IACzD,2EAAoD,CAAA;IACpD,+EAAwD,CAAA;IACxD,2EAAoD,CAAA;IACpD,6EAAsD,CAAA;IACtD,uEAAgD,CAAA;IAChD,6EAAsD,CAAA;IACtD,2EAAoD,CAAA;IACpD,qFAA8D,CAAA;IAC9D,gEAAyC,CAAA;AAC1C,CAAC,EA9BW,mBAAmB,KAAnB,mBAAmB,QA8B9B;AA2BD,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAE7C,SAAS,KAAK,CACb,IAAyB,EACzB,QAAiC,EACjC,YAAoB,EACpB,iBAAoC;IAEpC,OAAO;QACN,QAAQ;QACR,UAAU,EAAE,sCAAsC,YAAY,EAAE;QAChE,iBAAiB,EAAE,CAAC,aAAa,EAAE,GAAG,iBAAiB,CAAC,CAAC,IAAI,EAAE;QAC/D,YAA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E,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;aAC9C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACN,UAAU,EAAE,qCAAqC;QACjD,WAAW,EAAE,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1E,iBAAiB,EAAE,YAAY,CAC9B,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC1D;QACD,aAAa,EAAE,YAAY,CAC1B,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CACjD;QACD,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;QACtD,kBAAkB;KAClB,CAAC;AACH,CAAC","sourcesContent":["export enum MaestroBusEventType {\n\tSessionStarted = \"maestro.sessions.session.started\",\n\tSessionSuspended = \"maestro.sessions.session.suspended\",\n\tSessionResumed = \"maestro.sessions.session.resumed\",\n\tSessionClosed = \"maestro.sessions.session.closed\",\n\tInstallCheckCompleted = \"maestro.events.install_check.completed\",\n\tApprovalHit = \"maestro.events.approval_hit\",\n\tSandboxViolation = \"maestro.events.sandbox_violation\",\n\tFirewallBlock = \"maestro.events.firewall_block\",\n\tToolCallAttempted = \"maestro.events.tool_call.attempted\",\n\tToolCallCompleted = \"maestro.events.tool_call.completed\",\n\tToolCallFailed = \"maestro.events.tool_call.failed\",\n\tErrorCaptured = \"maestro.events.error.captured\",\n\tArtifactCreated = \"maestro.events.artifact.created\",\n\tFinalStatusReported = \"maestro.events.final_status.reported\",\n\tPromptVariantSelected = \"maestro.events.prompt_variant.selected\",\n\tContextLearned = \"maestro.events.context.learned\",\n\tSkillInvoked = \"maestro.events.skill.invoked\",\n\tSkillSucceeded = \"maestro.events.skill.succeeded\",\n\tSkillFailed = \"maestro.events.skill.failed\",\n\tSubagentDispatched = \"maestro.events.subagent.dispatched\",\n\tA2APeerSelected = \"maestro.events.a2a.peer.selected\",\n\tA2ATaskDispatched = \"maestro.events.a2a.task.dispatched\",\n\tA2ATaskProgress = \"maestro.events.a2a.task.progress\",\n\tA2ATaskCompleted = \"maestro.events.a2a.task.completed\",\n\tA2ATaskFailed = \"maestro.events.a2a.task.failed\",\n\tA2ATaskCancelled = \"maestro.events.a2a.task.cancelled\",\n\tA2APushReceived = \"maestro.events.a2a.push.received\",\n\tA2AEvidenceCompleted = \"maestro.events.a2a.evidence.completed\",\n\tEvalScored = \"maestro.events.eval.scored\",\n}\n\nexport type MaestroBusEventCategory =\n\t| \"session\"\n\t| \"install\"\n\t| \"agent\"\n\t| \"approval\"\n\t| \"safety\"\n\t| \"tool\"\n\t| \"error\"\n\t| \"artifact\"\n\t| \"final-status\"\n\t| \"prompt\"\n\t| \"knowledge\"\n\t| \"skill\"\n\t| \"a2a\"\n\t| \"eval\";\n\nexport interface MaestroBusEventCatalogEntry {\n\tcategory: MaestroBusEventCategory;\n\tdataSchema: string;\n\tplatformConsumers: readonly string[];\n\tprotoAnyType: string;\n\tsubject: MaestroBusEventType;\n\ttype: MaestroBusEventType;\n}\n\nconst auditConsumer = \"audit.maestro-events\";\n\nfunction entry(\n\ttype: MaestroBusEventType,\n\tcategory: MaestroBusEventCategory,\n\tprotoMessage: string,\n\tplatformConsumers: readonly string[],\n): MaestroBusEventCatalogEntry {\n\treturn {\n\t\tcategory,\n\t\tdataSchema: `buf.build/evalops/proto/maestro.v1.${protoMessage}`,\n\t\tplatformConsumers: [auditConsumer, ...platformConsumers].sort(),\n\t\tprotoAnyType: `type.googleapis.com/maestro.v1.${protoMessage}`,\n\t\tsubject: type,\n\t\ttype,\n\t};\n}\n\nexport const MAESTRO_BUS_EVENT_CATALOG = {\n\t[MaestroBusEventType.SessionStarted]: entry(\n\t\tMaestroBusEventType.SessionStarted,\n\t\t\"session\",\n\t\t\"MaestroSession\",\n\t\t[\n\t\t\t\"fermata.maestro-session-replay-context\",\n\t\t\t\"meter.maestro-session-lifecycle\",\n\t\t],\n\t),\n\t[MaestroBusEventType.SessionSuspended]: entry(\n\t\tMaestroBusEventType.SessionSuspended,\n\t\t\"session\",\n\t\t\"MaestroSession\",\n\t\t[\n\t\t\t\"fermata.maestro-session-replay-context\",\n\t\t\t\"meter.maestro-session-lifecycle\",\n\t\t],\n\t),\n\t[MaestroBusEventType.SessionResumed]: entry(\n\t\tMaestroBusEventType.SessionResumed,\n\t\t\"session\",\n\t\t\"MaestroSession\",\n\t\t[\n\t\t\t\"fermata.maestro-session-replay-context\",\n\t\t\t\"meter.maestro-session-lifecycle\",\n\t\t],\n\t),\n\t[MaestroBusEventType.SessionClosed]: entry(\n\t\tMaestroBusEventType.SessionClosed,\n\t\t\"session\",\n\t\t\"MaestroSession\",\n\t\t[\n\t\t\t\"fermata.maestro-session-replay-context\",\n\t\t\t\"meter.maestro-session-lifecycle\",\n\t\t\t\"release.maestro-session-final-state\",\n\t\t],\n\t),\n\t[MaestroBusEventType.InstallCheckCompleted]: entry(\n\t\tMaestroBusEventType.InstallCheckCompleted,\n\t\t\"install\",\n\t\t\"PackageInstallCheck\",\n\t\t[\"meter.maestro-install-checks\", \"release.maestro-install-smoke\"],\n\t),\n\t[MaestroBusEventType.ApprovalHit]: entry(\n\t\tMaestroBusEventType.ApprovalHit,\n\t\t\"approval\",\n\t\t\"ApprovalHit\",\n\t\t[\"governance.maestro-approval-hit\", \"release.maestro-approval-gates\"],\n\t),\n\t[MaestroBusEventType.SandboxViolation]: entry(\n\t\tMaestroBusEventType.SandboxViolation,\n\t\t\"safety\",\n\t\t\"SandboxViolation\",\n\t\t[\"governance.maestro-sandbox-violation\"],\n\t),\n\t[MaestroBusEventType.FirewallBlock]: entry(\n\t\tMaestroBusEventType.FirewallBlock,\n\t\t\"safety\",\n\t\t\"FirewallBlock\",\n\t\t[\"governance.maestro-firewall-block\"],\n\t),\n\t[MaestroBusEventType.ToolCallAttempted]: entry(\n\t\tMaestroBusEventType.ToolCallAttempted,\n\t\t\"tool\",\n\t\t\"ToolCallAttempt\",\n\t\t[\"meter.maestro-tool-call-events\"],\n\t),\n\t[MaestroBusEventType.ToolCallCompleted]: entry(\n\t\tMaestroBusEventType.ToolCallCompleted,\n\t\t\"tool\",\n\t\t\"ToolCallResult\",\n\t\t[\n\t\t\t\"meter.maestro-tool-call-events\",\n\t\t\t\"release.maestro-tool-success-gates\",\n\t\t\t\"skills.maestro-tool-call-completed\",\n\t\t],\n\t),\n\t[MaestroBusEventType.ToolCallFailed]: entry(\n\t\tMaestroBusEventType.ToolCallFailed,\n\t\t\"tool\",\n\t\t\"ToolCallResult\",\n\t\t[\n\t\t\t\"meter.maestro-tool-call-events\",\n\t\t\t\"release.maestro-tool-failure-gates\",\n\t\t\t\"skills.maestro-tool-call-failed\",\n\t\t],\n\t),\n\t[MaestroBusEventType.ErrorCaptured]: entry(\n\t\tMaestroBusEventType.ErrorCaptured,\n\t\t\"error\",\n\t\t\"MaestroError\",\n\t\t[\n\t\t\t\"audit.maestro-errors\",\n\t\t\t\"meter.maestro-errors\",\n\t\t\t\"release.maestro-error-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.ArtifactCreated]: entry(\n\t\tMaestroBusEventType.ArtifactCreated,\n\t\t\"artifact\",\n\t\t\"MaestroArtifact\",\n\t\t[\n\t\t\t\"fermata.maestro-artifacts\",\n\t\t\t\"meter.maestro-artifacts\",\n\t\t\t\"release.maestro-artifact-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.FinalStatusReported]: entry(\n\t\tMaestroBusEventType.FinalStatusReported,\n\t\t\"final-status\",\n\t\t\"MaestroFinalStatus\",\n\t\t[\n\t\t\t\"fermata.maestro-final-status\",\n\t\t\t\"meter.maestro-final-status\",\n\t\t\t\"release.maestro-final-status-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.PromptVariantSelected]: entry(\n\t\tMaestroBusEventType.PromptVariantSelected,\n\t\t\"prompt\",\n\t\t\"PromptVariantSelected\",\n\t\t[\"prompts.maestro-prompt-variant-selected\"],\n\t),\n\t[MaestroBusEventType.ContextLearned]: entry(\n\t\tMaestroBusEventType.ContextLearned,\n\t\t\"knowledge\",\n\t\t\"MaestroLearnedContext\",\n\t\t[\"cerebro.maestro-learned-context\"],\n\t),\n\t[MaestroBusEventType.SkillInvoked]: entry(\n\t\tMaestroBusEventType.SkillInvoked,\n\t\t\"skill\",\n\t\t\"SkillInvocation\",\n\t\t[\"skills.maestro-skill-events\"],\n\t),\n\t[MaestroBusEventType.SkillSucceeded]: entry(\n\t\tMaestroBusEventType.SkillSucceeded,\n\t\t\"skill\",\n\t\t\"SkillOutcome\",\n\t\t[\"skills.maestro-skill-events\"],\n\t),\n\t[MaestroBusEventType.SkillFailed]: entry(\n\t\tMaestroBusEventType.SkillFailed,\n\t\t\"skill\",\n\t\t\"SkillOutcome\",\n\t\t[\"skills.maestro-skill-events\"],\n\t),\n\t[MaestroBusEventType.SubagentDispatched]: entry(\n\t\tMaestroBusEventType.SubagentDispatched,\n\t\t\"agent\",\n\t\t\"SubagentDispatch\",\n\t\t[\"agents.maestro-subagent-dispatches\", \"meter.maestro-subagent-dispatches\"],\n\t),\n\t[MaestroBusEventType.A2APeerSelected]: entry(\n\t\tMaestroBusEventType.A2APeerSelected,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2ATaskDispatched]: entry(\n\t\tMaestroBusEventType.A2ATaskDispatched,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2ATaskProgress]: entry(\n\t\tMaestroBusEventType.A2ATaskProgress,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2ATaskCompleted]: entry(\n\t\tMaestroBusEventType.A2ATaskCompleted,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2ATaskFailed]: entry(\n\t\tMaestroBusEventType.A2ATaskFailed,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\n\t\t\t\"a2a.maestro-delegation-events\",\n\t\t\t\"meter.maestro-a2a-delegations\",\n\t\t\t\"release.maestro-a2a-failure-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.A2ATaskCancelled]: entry(\n\t\tMaestroBusEventType.A2ATaskCancelled,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2APushReceived]: entry(\n\t\tMaestroBusEventType.A2APushReceived,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2AEvidenceCompleted]: entry(\n\t\tMaestroBusEventType.A2AEvidenceCompleted,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\n\t\t\t\"a2a.maestro-delegation-events\",\n\t\t\t\"meter.maestro-a2a-delegations\",\n\t\t\t\"release.maestro-a2a-evidence-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.EvalScored]: entry(\n\t\tMaestroBusEventType.EvalScored,\n\t\t\"eval\",\n\t\t\"MaestroEvalScore\",\n\t\t[\"fermata.maestro-eval-scored\", \"prompts.maestro-eval-scored\"],\n\t),\n} as const satisfies Record<MaestroBusEventType, MaestroBusEventCatalogEntry>;\n\nexport const MAESTRO_BUS_EVENT_TYPES = Object.values(MaestroBusEventType);\n\nexport const MAESTRO_RELEASE_GATE_EVENT_CATEGORIES = [\n\t\"install\",\n\t\"session\",\n\t\"tool\",\n\t\"approval\",\n\t\"error\",\n\t\"artifact\",\n\t\"final-status\",\n] as const satisfies readonly MaestroBusEventCategory[];\n\nexport type MaestroReleaseGateEventCategory =\n\t(typeof MAESTRO_RELEASE_GATE_EVENT_CATEGORIES)[number];\n\nexport const MAESTRO_RELEASE_GATE_EVENT_SUBJECTS_BY_CATEGORY = {\n\tinstall: [MaestroBusEventType.InstallCheckCompleted],\n\tsession: [MaestroBusEventType.SessionClosed],\n\ttool: [\n\t\tMaestroBusEventType.ToolCallCompleted,\n\t\tMaestroBusEventType.ToolCallFailed,\n\t],\n\tapproval: [MaestroBusEventType.ApprovalHit],\n\terror: [MaestroBusEventType.ErrorCaptured],\n\tartifact: [MaestroBusEventType.ArtifactCreated],\n\t\"final-status\": [MaestroBusEventType.FinalStatusReported],\n} as const satisfies Readonly<\n\tRecord<MaestroReleaseGateEventCategory, readonly MaestroBusEventType[]>\n>;\n\nexport const MAESTRO_RELEASE_GATE_EVENT_SUBJECTS = Object.values(\n\tMAESTRO_RELEASE_GATE_EVENT_SUBJECTS_BY_CATEGORY,\n).flat() as readonly MaestroBusEventType[];\n\nexport interface MaestroReleaseGateEventQuery {\n\tcategories: readonly MaestroReleaseGateEventCategory[];\n\tdataSchemas: readonly string[];\n\tplatformConsumers: readonly string[];\n\tprotoAnyTypes: readonly string[];\n\tsubjects: readonly MaestroBusEventType[];\n\tsubjectsByCategory: Readonly<\n\t\tRecord<MaestroReleaseGateEventCategory, readonly MaestroBusEventType[]>\n\t>;\n}\n\nexport interface MaestroReleaseGateEventSubjectCategoryMismatch {\n\tactualSubjects: readonly MaestroBusEventType[];\n\tcategory: MaestroReleaseGateEventCategory;\n\texpectedSubjects: readonly MaestroBusEventType[];\n\tmissingSubjects: readonly MaestroBusEventType[];\n\tunexpectedSubjects: readonly MaestroBusEventType[];\n}\n\nexport function isMaestroBusEventType(\n\tvalue: string,\n): value is MaestroBusEventType {\n\treturn MAESTRO_BUS_EVENT_TYPES.includes(value as MaestroBusEventType);\n}\n\nexport function getMaestroBusEventCatalogEntry(\n\ttype: MaestroBusEventType,\n): MaestroBusEventCatalogEntry {\n\treturn MAESTRO_BUS_EVENT_CATALOG[type];\n}\n\nexport function listMaestroBusEventCatalog(): readonly MaestroBusEventCatalogEntry[] {\n\treturn MAESTRO_BUS_EVENT_TYPES.map(getMaestroBusEventCatalogEntry);\n}\n\nexport function listMaestroBusEventCatalogByCategory(\n\tcategory: MaestroBusEventCategory,\n): readonly MaestroBusEventCatalogEntry[] {\n\treturn listMaestroBusEventCatalog().filter(\n\t\t(entry) => entry.category === category,\n\t);\n}\n\nexport function listMaestroReleaseGateEventCatalog(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroBusEventCatalogEntry[] {\n\tconst releaseGateCategories = new Set<MaestroBusEventCategory>(\n\t\tMAESTRO_RELEASE_GATE_EVENT_CATEGORIES,\n\t);\n\treturn catalog.filter(\n\t\t(entry) =>\n\t\t\treleaseGateCategories.has(entry.category) &&\n\t\t\tentry.platformConsumers.some((consumer) =>\n\t\t\t\tconsumer.startsWith(\"release.\"),\n\t\t\t),\n\t);\n}\n\nexport function getMissingMaestroReleaseGateEventCategories(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroReleaseGateEventCategory[] {\n\tconst coveredCategories = new Set(catalog.map((entry) => entry.category));\n\treturn MAESTRO_RELEASE_GATE_EVENT_CATEGORIES.filter(\n\t\t(category) => !coveredCategories.has(category),\n\t);\n}\n\nexport function getMissingMaestroReleaseGateConsumerCategories(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroReleaseGateEventCategory[] {\n\treturn MAESTRO_RELEASE_GATE_EVENT_CATEGORIES.filter(\n\t\t(category) =>\n\t\t\t!catalog\n\t\t\t\t.filter((entry) => entry.category === category)\n\t\t\t\t.some((entry) =>\n\t\t\t\t\tentry.platformConsumers.some((consumer) =>\n\t\t\t\t\t\tconsumer.startsWith(\"release.\"),\n\t\t\t\t\t),\n\t\t\t\t),\n\t);\n}\n\nexport function getUnexpectedMaestroReleaseGateEventSubjects(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroBusEventType[] {\n\tconst expectedSubjects = new Set<MaestroBusEventType>(\n\t\tMAESTRO_RELEASE_GATE_EVENT_SUBJECTS,\n\t);\n\treturn buildMaestroReleaseGateEventQuery(catalog).subjects.filter(\n\t\t(subject) => !expectedSubjects.has(subject),\n\t);\n}\n\nexport function getMismatchedMaestroReleaseGateEventSubjectCategories(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroReleaseGateEventSubjectCategoryMismatch[] {\n\tconst query = buildMaestroReleaseGateEventQuery(catalog);\n\treturn MAESTRO_RELEASE_GATE_EVENT_CATEGORIES.flatMap((category) => {\n\t\tconst actualSubjects: MaestroBusEventType[] = [\n\t\t\t...query.subjectsByCategory[category],\n\t\t].sort();\n\t\tconst expectedSubjects: MaestroBusEventType[] = [\n\t\t\t...MAESTRO_RELEASE_GATE_EVENT_SUBJECTS_BY_CATEGORY[category],\n\t\t].sort();\n\t\tconst actualSubjectSet = new Set(actualSubjects);\n\t\tconst expectedSubjectSet = new Set(expectedSubjects);\n\t\tconst missingSubjects = expectedSubjects.filter(\n\t\t\t(subject) => !actualSubjectSet.has(subject),\n\t\t);\n\t\tconst unexpectedSubjects = actualSubjects.filter(\n\t\t\t(subject) => !expectedSubjectSet.has(subject),\n\t\t);\n\t\tif (missingSubjects.length === 0 && unexpectedSubjects.length === 0) {\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tactualSubjects,\n\t\t\t\tcategory,\n\t\t\t\texpectedSubjects,\n\t\t\t\tmissingSubjects,\n\t\t\t\tunexpectedSubjects,\n\t\t\t},\n\t\t];\n\t});\n}\n\nfunction uniqueSorted(values: Iterable<string>): readonly string[] {\n\treturn Array.from(new Set(values)).sort();\n}\n\nexport function buildMaestroReleaseGateEventQuery(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): MaestroReleaseGateEventQuery {\n\tconst releaseCatalog = listMaestroReleaseGateEventCatalog(catalog);\n\tconst subjectsByCategory = {} as Record<\n\t\tMaestroReleaseGateEventCategory,\n\t\treadonly MaestroBusEventType[]\n\t>;\n\tfor (const category of MAESTRO_RELEASE_GATE_EVENT_CATEGORIES) {\n\t\tsubjectsByCategory[category] = releaseCatalog\n\t\t\t.filter((entry) => entry.category === category)\n\t\t\t.map((entry) => entry.type);\n\t}\n\n\treturn {\n\t\tcategories: MAESTRO_RELEASE_GATE_EVENT_CATEGORIES,\n\t\tdataSchemas: uniqueSorted(releaseCatalog.map((entry) => entry.dataSchema)),\n\t\tplatformConsumers: uniqueSorted(\n\t\t\treleaseCatalog.flatMap((entry) => entry.platformConsumers),\n\t\t),\n\t\tprotoAnyTypes: uniqueSorted(\n\t\t\treleaseCatalog.map((entry) => entry.protoAnyType),\n\t\t),\n\t\tsubjects: releaseCatalog.map((entry) => entry.subject),\n\t\tsubjectsByCategory,\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"maestro-event-catalog.js","sourceRoot":"","sources":["../../src/telemetry/maestro-event-catalog.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBA8BX;AA9BD,WAAY,mBAAmB;IAC9B,0EAAmD,CAAA;IACnD,8EAAuD,CAAA;IACvD,0EAAmD,CAAA;IACnD,wEAAiD,CAAA;IACjD,uFAAgE,CAAA;IAChE,kEAA2C,CAAA;IAC3C,4EAAqD,CA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QACD,aAAa,EAAE,YAAY,CAC1B,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CACjD;QACD,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC;QACtD,kBAAkB;KAClB,CAAC;AACH,CAAC","sourcesContent":["export enum MaestroBusEventType {\n\tSessionStarted = \"maestro.sessions.session.started\",\n\tSessionSuspended = \"maestro.sessions.session.suspended\",\n\tSessionResumed = \"maestro.sessions.session.resumed\",\n\tSessionClosed = \"maestro.sessions.session.closed\",\n\tInstallCheckCompleted = \"maestro.events.install_check.completed\",\n\tApprovalHit = \"maestro.events.approval_hit\",\n\tSandboxViolation = \"maestro.events.sandbox_violation\",\n\tFirewallBlock = \"maestro.events.firewall_block\",\n\tToolCallAttempted = \"maestro.events.tool_call.attempted\",\n\tToolCallCompleted = \"maestro.events.tool_call.completed\",\n\tToolCallFailed = \"maestro.events.tool_call.failed\",\n\tErrorCaptured = \"maestro.events.error.captured\",\n\tArtifactCreated = \"maestro.events.artifact.created\",\n\tFinalStatusReported = \"maestro.events.final_status.reported\",\n\tPromptVariantSelected = \"maestro.events.prompt_variant.selected\",\n\tContextLearned = \"maestro.events.context.learned\",\n\tSkillInvoked = \"maestro.events.skill.invoked\",\n\tSkillSucceeded = \"maestro.events.skill.succeeded\",\n\tSkillFailed = \"maestro.events.skill.failed\",\n\tSubagentDispatched = \"maestro.events.subagent.dispatched\",\n\tA2APeerSelected = \"maestro.events.a2a.peer.selected\",\n\tA2ATaskDispatched = \"maestro.events.a2a.task.dispatched\",\n\tA2ATaskProgress = \"maestro.events.a2a.task.progress\",\n\tA2ATaskCompleted = \"maestro.events.a2a.task.completed\",\n\tA2ATaskFailed = \"maestro.events.a2a.task.failed\",\n\tA2ATaskCancelled = \"maestro.events.a2a.task.cancelled\",\n\tA2APushReceived = \"maestro.events.a2a.push.received\",\n\tA2AEvidenceCompleted = \"maestro.events.a2a.evidence.completed\",\n\tEvalScored = \"maestro.events.eval.scored\",\n}\n\nexport type MaestroBusEventCategory =\n\t| \"session\"\n\t| \"install\"\n\t| \"agent\"\n\t| \"approval\"\n\t| \"safety\"\n\t| \"tool\"\n\t| \"error\"\n\t| \"artifact\"\n\t| \"final-status\"\n\t| \"prompt\"\n\t| \"knowledge\"\n\t| \"skill\"\n\t| \"a2a\"\n\t| \"eval\";\n\nexport interface MaestroBusEventCatalogEntry {\n\tcategory: MaestroBusEventCategory;\n\tdataSchema: string;\n\tplatformConsumers: readonly string[];\n\tprotoAnyType: string;\n\tsubject: MaestroBusEventType;\n\ttype: MaestroBusEventType;\n}\n\nconst auditConsumer = \"audit.maestro-events\";\n\nfunction entry(\n\ttype: MaestroBusEventType,\n\tcategory: MaestroBusEventCategory,\n\tprotoMessage: string,\n\tplatformConsumers: readonly string[],\n): MaestroBusEventCatalogEntry {\n\treturn {\n\t\tcategory,\n\t\tdataSchema: `buf.build/evalops/proto/maestro.v1.${protoMessage}`,\n\t\tplatformConsumers: [auditConsumer, ...platformConsumers].sort(),\n\t\tprotoAnyType: `type.googleapis.com/maestro.v1.${protoMessage}`,\n\t\tsubject: type,\n\t\ttype,\n\t};\n}\n\nexport const MAESTRO_BUS_EVENT_CATALOG = {\n\t[MaestroBusEventType.SessionStarted]: entry(\n\t\tMaestroBusEventType.SessionStarted,\n\t\t\"session\",\n\t\t\"MaestroSession\",\n\t\t[\n\t\t\t\"fermata.maestro-session-replay-context\",\n\t\t\t\"meter.maestro-session-lifecycle\",\n\t\t],\n\t),\n\t[MaestroBusEventType.SessionSuspended]: entry(\n\t\tMaestroBusEventType.SessionSuspended,\n\t\t\"session\",\n\t\t\"MaestroSession\",\n\t\t[\n\t\t\t\"fermata.maestro-session-replay-context\",\n\t\t\t\"meter.maestro-session-lifecycle\",\n\t\t],\n\t),\n\t[MaestroBusEventType.SessionResumed]: entry(\n\t\tMaestroBusEventType.SessionResumed,\n\t\t\"session\",\n\t\t\"MaestroSession\",\n\t\t[\n\t\t\t\"fermata.maestro-session-replay-context\",\n\t\t\t\"meter.maestro-session-lifecycle\",\n\t\t],\n\t),\n\t[MaestroBusEventType.SessionClosed]: entry(\n\t\tMaestroBusEventType.SessionClosed,\n\t\t\"session\",\n\t\t\"MaestroSession\",\n\t\t[\n\t\t\t\"fermata.maestro-session-replay-context\",\n\t\t\t\"meter.maestro-session-lifecycle\",\n\t\t\t\"release.maestro-session-final-state\",\n\t\t],\n\t),\n\t[MaestroBusEventType.InstallCheckCompleted]: entry(\n\t\tMaestroBusEventType.InstallCheckCompleted,\n\t\t\"install\",\n\t\t\"PackageInstallCheck\",\n\t\t[\"meter.maestro-install-checks\", \"release.maestro-install-smoke\"],\n\t),\n\t[MaestroBusEventType.ApprovalHit]: entry(\n\t\tMaestroBusEventType.ApprovalHit,\n\t\t\"approval\",\n\t\t\"ApprovalHit\",\n\t\t[\"governance.maestro-approval-hit\", \"release.maestro-approval-gates\"],\n\t),\n\t[MaestroBusEventType.SandboxViolation]: entry(\n\t\tMaestroBusEventType.SandboxViolation,\n\t\t\"safety\",\n\t\t\"SandboxViolation\",\n\t\t[\"governance.maestro-sandbox-violation\"],\n\t),\n\t[MaestroBusEventType.FirewallBlock]: entry(\n\t\tMaestroBusEventType.FirewallBlock,\n\t\t\"safety\",\n\t\t\"FirewallBlock\",\n\t\t[\"governance.maestro-firewall-block\"],\n\t),\n\t[MaestroBusEventType.ToolCallAttempted]: entry(\n\t\tMaestroBusEventType.ToolCallAttempted,\n\t\t\"tool\",\n\t\t\"ToolCallAttempt\",\n\t\t[\"meter.maestro-tool-call-events\", \"release.maestro-tool-attempt-gates\"],\n\t),\n\t[MaestroBusEventType.ToolCallCompleted]: entry(\n\t\tMaestroBusEventType.ToolCallCompleted,\n\t\t\"tool\",\n\t\t\"ToolCallResult\",\n\t\t[\n\t\t\t\"meter.maestro-tool-call-events\",\n\t\t\t\"release.maestro-tool-success-gates\",\n\t\t\t\"skills.maestro-tool-call-completed\",\n\t\t],\n\t),\n\t[MaestroBusEventType.ToolCallFailed]: entry(\n\t\tMaestroBusEventType.ToolCallFailed,\n\t\t\"tool\",\n\t\t\"ToolCallResult\",\n\t\t[\n\t\t\t\"meter.maestro-tool-call-events\",\n\t\t\t\"release.maestro-tool-failure-gates\",\n\t\t\t\"skills.maestro-tool-call-failed\",\n\t\t],\n\t),\n\t[MaestroBusEventType.ErrorCaptured]: entry(\n\t\tMaestroBusEventType.ErrorCaptured,\n\t\t\"error\",\n\t\t\"MaestroError\",\n\t\t[\n\t\t\t\"audit.maestro-errors\",\n\t\t\t\"meter.maestro-errors\",\n\t\t\t\"release.maestro-error-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.ArtifactCreated]: entry(\n\t\tMaestroBusEventType.ArtifactCreated,\n\t\t\"artifact\",\n\t\t\"MaestroArtifact\",\n\t\t[\n\t\t\t\"fermata.maestro-artifacts\",\n\t\t\t\"meter.maestro-artifacts\",\n\t\t\t\"release.maestro-artifact-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.FinalStatusReported]: entry(\n\t\tMaestroBusEventType.FinalStatusReported,\n\t\t\"final-status\",\n\t\t\"MaestroFinalStatus\",\n\t\t[\n\t\t\t\"fermata.maestro-final-status\",\n\t\t\t\"meter.maestro-final-status\",\n\t\t\t\"release.maestro-final-status-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.PromptVariantSelected]: entry(\n\t\tMaestroBusEventType.PromptVariantSelected,\n\t\t\"prompt\",\n\t\t\"PromptVariantSelected\",\n\t\t[\"prompts.maestro-prompt-variant-selected\"],\n\t),\n\t[MaestroBusEventType.ContextLearned]: entry(\n\t\tMaestroBusEventType.ContextLearned,\n\t\t\"knowledge\",\n\t\t\"MaestroLearnedContext\",\n\t\t[\"cerebro.maestro-learned-context\"],\n\t),\n\t[MaestroBusEventType.SkillInvoked]: entry(\n\t\tMaestroBusEventType.SkillInvoked,\n\t\t\"skill\",\n\t\t\"SkillInvocation\",\n\t\t[\"skills.maestro-skill-events\"],\n\t),\n\t[MaestroBusEventType.SkillSucceeded]: entry(\n\t\tMaestroBusEventType.SkillSucceeded,\n\t\t\"skill\",\n\t\t\"SkillOutcome\",\n\t\t[\"skills.maestro-skill-events\"],\n\t),\n\t[MaestroBusEventType.SkillFailed]: entry(\n\t\tMaestroBusEventType.SkillFailed,\n\t\t\"skill\",\n\t\t\"SkillOutcome\",\n\t\t[\"skills.maestro-skill-events\"],\n\t),\n\t[MaestroBusEventType.SubagentDispatched]: entry(\n\t\tMaestroBusEventType.SubagentDispatched,\n\t\t\"agent\",\n\t\t\"SubagentDispatch\",\n\t\t[\"agents.maestro-subagent-dispatches\", \"meter.maestro-subagent-dispatches\"],\n\t),\n\t[MaestroBusEventType.A2APeerSelected]: entry(\n\t\tMaestroBusEventType.A2APeerSelected,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2ATaskDispatched]: entry(\n\t\tMaestroBusEventType.A2ATaskDispatched,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2ATaskProgress]: entry(\n\t\tMaestroBusEventType.A2ATaskProgress,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2ATaskCompleted]: entry(\n\t\tMaestroBusEventType.A2ATaskCompleted,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2ATaskFailed]: entry(\n\t\tMaestroBusEventType.A2ATaskFailed,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\n\t\t\t\"a2a.maestro-delegation-events\",\n\t\t\t\"meter.maestro-a2a-delegations\",\n\t\t\t\"release.maestro-a2a-failure-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.A2ATaskCancelled]: entry(\n\t\tMaestroBusEventType.A2ATaskCancelled,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2APushReceived]: entry(\n\t\tMaestroBusEventType.A2APushReceived,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\"a2a.maestro-delegation-events\", \"meter.maestro-a2a-delegations\"],\n\t),\n\t[MaestroBusEventType.A2AEvidenceCompleted]: entry(\n\t\tMaestroBusEventType.A2AEvidenceCompleted,\n\t\t\"a2a\",\n\t\t\"MaestroA2ADelegationEvent\",\n\t\t[\n\t\t\t\"a2a.maestro-delegation-events\",\n\t\t\t\"meter.maestro-a2a-delegations\",\n\t\t\t\"release.maestro-a2a-evidence-gates\",\n\t\t],\n\t),\n\t[MaestroBusEventType.EvalScored]: entry(\n\t\tMaestroBusEventType.EvalScored,\n\t\t\"eval\",\n\t\t\"MaestroEvalScore\",\n\t\t[\"fermata.maestro-eval-scored\", \"prompts.maestro-eval-scored\"],\n\t),\n} as const satisfies Record<MaestroBusEventType, MaestroBusEventCatalogEntry>;\n\nexport const MAESTRO_BUS_EVENT_TYPES = Object.values(MaestroBusEventType);\n\nexport const MAESTRO_RELEASE_GATE_EVENT_CATEGORIES = [\n\t\"install\",\n\t\"session\",\n\t\"tool\",\n\t\"approval\",\n\t\"error\",\n\t\"artifact\",\n\t\"final-status\",\n] as const satisfies readonly MaestroBusEventCategory[];\n\nexport type MaestroReleaseGateEventCategory =\n\t(typeof MAESTRO_RELEASE_GATE_EVENT_CATEGORIES)[number];\n\nexport const MAESTRO_RELEASE_GATE_EVENT_SUBJECTS_BY_CATEGORY = {\n\tinstall: [MaestroBusEventType.InstallCheckCompleted],\n\tsession: [MaestroBusEventType.SessionClosed],\n\ttool: [\n\t\tMaestroBusEventType.ToolCallAttempted,\n\t\tMaestroBusEventType.ToolCallCompleted,\n\t\tMaestroBusEventType.ToolCallFailed,\n\t],\n\tapproval: [MaestroBusEventType.ApprovalHit],\n\terror: [MaestroBusEventType.ErrorCaptured],\n\tartifact: [MaestroBusEventType.ArtifactCreated],\n\t\"final-status\": [MaestroBusEventType.FinalStatusReported],\n} as const satisfies Readonly<\n\tRecord<MaestroReleaseGateEventCategory, readonly MaestroBusEventType[]>\n>;\n\nexport const MAESTRO_RELEASE_GATE_EVENT_SUBJECTS = Object.values(\n\tMAESTRO_RELEASE_GATE_EVENT_SUBJECTS_BY_CATEGORY,\n).flat() as readonly MaestroBusEventType[];\n\nexport interface MaestroReleaseGateEventQuery {\n\tcategories: readonly MaestroReleaseGateEventCategory[];\n\tdataSchemas: readonly string[];\n\tplatformConsumers: readonly string[];\n\tprotoAnyTypes: readonly string[];\n\tsubjects: readonly MaestroBusEventType[];\n\tsubjectsByCategory: Readonly<\n\t\tRecord<MaestroReleaseGateEventCategory, readonly MaestroBusEventType[]>\n\t>;\n}\n\nexport interface MaestroReleaseGateEventSubjectCategoryMismatch {\n\tactualSubjects: readonly MaestroBusEventType[];\n\tcategory: MaestroReleaseGateEventCategory;\n\texpectedSubjects: readonly MaestroBusEventType[];\n\tmissingSubjects: readonly MaestroBusEventType[];\n\tunexpectedSubjects: readonly MaestroBusEventType[];\n}\n\nexport function isMaestroBusEventType(\n\tvalue: string,\n): value is MaestroBusEventType {\n\treturn MAESTRO_BUS_EVENT_TYPES.includes(value as MaestroBusEventType);\n}\n\nexport function getMaestroBusEventCatalogEntry(\n\ttype: MaestroBusEventType,\n): MaestroBusEventCatalogEntry {\n\treturn MAESTRO_BUS_EVENT_CATALOG[type];\n}\n\nexport function listMaestroBusEventCatalog(): readonly MaestroBusEventCatalogEntry[] {\n\treturn MAESTRO_BUS_EVENT_TYPES.map(getMaestroBusEventCatalogEntry);\n}\n\nexport function listMaestroBusEventCatalogByCategory(\n\tcategory: MaestroBusEventCategory,\n): readonly MaestroBusEventCatalogEntry[] {\n\treturn listMaestroBusEventCatalog().filter(\n\t\t(entry) => entry.category === category,\n\t);\n}\n\nexport function listMaestroReleaseGateEventCatalog(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroBusEventCatalogEntry[] {\n\tconst releaseGateCategories = new Set<MaestroBusEventCategory>(\n\t\tMAESTRO_RELEASE_GATE_EVENT_CATEGORIES,\n\t);\n\treturn catalog.filter(\n\t\t(entry) =>\n\t\t\treleaseGateCategories.has(entry.category) &&\n\t\t\tentry.platformConsumers.some((consumer) =>\n\t\t\t\tconsumer.startsWith(\"release.\"),\n\t\t\t),\n\t);\n}\n\nexport function getMissingMaestroReleaseGateEventCategories(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroReleaseGateEventCategory[] {\n\tconst coveredCategories = new Set(catalog.map((entry) => entry.category));\n\treturn MAESTRO_RELEASE_GATE_EVENT_CATEGORIES.filter(\n\t\t(category) => !coveredCategories.has(category),\n\t);\n}\n\nexport function getMissingMaestroReleaseGateConsumerCategories(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroReleaseGateEventCategory[] {\n\treturn MAESTRO_RELEASE_GATE_EVENT_CATEGORIES.filter(\n\t\t(category) =>\n\t\t\t!catalog\n\t\t\t\t.filter((entry) => entry.category === category)\n\t\t\t\t.some((entry) =>\n\t\t\t\t\tentry.platformConsumers.some((consumer) =>\n\t\t\t\t\t\tconsumer.startsWith(\"release.\"),\n\t\t\t\t\t),\n\t\t\t\t),\n\t);\n}\n\nexport function getUnexpectedMaestroReleaseGateEventSubjects(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroBusEventType[] {\n\tconst expectedSubjects = new Set<MaestroBusEventType>(\n\t\tMAESTRO_RELEASE_GATE_EVENT_SUBJECTS,\n\t);\n\treturn buildMaestroReleaseGateEventQuery(catalog).subjects.filter(\n\t\t(subject) => !expectedSubjects.has(subject),\n\t);\n}\n\nexport function getMismatchedMaestroReleaseGateEventSubjectCategories(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): readonly MaestroReleaseGateEventSubjectCategoryMismatch[] {\n\tconst query = buildMaestroReleaseGateEventQuery(catalog);\n\treturn MAESTRO_RELEASE_GATE_EVENT_CATEGORIES.flatMap((category) => {\n\t\tconst actualSubjects: MaestroBusEventType[] = [\n\t\t\t...query.subjectsByCategory[category],\n\t\t].sort();\n\t\tconst expectedSubjects: MaestroBusEventType[] = [\n\t\t\t...MAESTRO_RELEASE_GATE_EVENT_SUBJECTS_BY_CATEGORY[category],\n\t\t].sort();\n\t\tconst actualSubjectSet = new Set(actualSubjects);\n\t\tconst expectedSubjectSet = new Set(expectedSubjects);\n\t\tconst missingSubjects = expectedSubjects.filter(\n\t\t\t(subject) => !actualSubjectSet.has(subject),\n\t\t);\n\t\tconst unexpectedSubjects = actualSubjects.filter(\n\t\t\t(subject) => !expectedSubjectSet.has(subject),\n\t\t);\n\t\tif (missingSubjects.length === 0 && unexpectedSubjects.length === 0) {\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tactualSubjects,\n\t\t\t\tcategory,\n\t\t\t\texpectedSubjects,\n\t\t\t\tmissingSubjects,\n\t\t\t\tunexpectedSubjects,\n\t\t\t},\n\t\t];\n\t});\n}\n\nfunction uniqueSorted(values: Iterable<string>): readonly string[] {\n\treturn Array.from(new Set(values)).sort();\n}\n\nexport function buildMaestroReleaseGateEventQuery(\n\tcatalog: readonly MaestroBusEventCatalogEntry[] = listMaestroBusEventCatalog(),\n): MaestroReleaseGateEventQuery {\n\tconst releaseCatalog = listMaestroReleaseGateEventCatalog(catalog);\n\tconst subjectsByCategory = {} as Record<\n\t\tMaestroReleaseGateEventCategory,\n\t\treadonly MaestroBusEventType[]\n\t>;\n\tfor (const category of MAESTRO_RELEASE_GATE_EVENT_CATEGORIES) {\n\t\tsubjectsByCategory[category] = releaseCatalog\n\t\t\t.filter((entry) => entry.category === category)\n\t\t\t.map((entry) => entry.type);\n\t}\n\n\treturn {\n\t\tcategories: MAESTRO_RELEASE_GATE_EVENT_CATEGORIES,\n\t\tdataSchemas: uniqueSorted(releaseCatalog.map((entry) => entry.dataSchema)),\n\t\tplatformConsumers: uniqueSorted(\n\t\t\treleaseCatalog.flatMap((entry) => entry.platformConsumers),\n\t\t),\n\t\tprotoAnyTypes: uniqueSorted(\n\t\t\treleaseCatalog.map((entry) => entry.protoAnyType),\n\t\t),\n\t\tsubjects: releaseCatalog.map((entry) => entry.subject),\n\t\tsubjectsByCategory,\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ripgrep-utils.d.ts","sourceRoot":"","sources":["../../src/tools/ripgrep-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ripgrep-utils.d.ts","sourceRoot":"","sources":["../../src/tools/ripgrep-utils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,2LActB,CAAC;AAEF,eAAO,MAAM,UAAU,2LActB,CAAC;AAEF,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,GAAG,CAAC,EAAE,CAK1D;AAuDD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAE3D;AAED,wBAAsB,UAAU,CAC/B,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,CAAC,EAAE,WAAW,EACpB,GAAG,CAAC,EAAE,MAAM,GACV,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACnB,CAAC,CAoDD;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAmC/D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { safeJsonParse } from "../utils/json.js";
|
|
4
|
+
import { ensureTool } from "./tools-manager.js";
|
|
4
5
|
export const pathSchema = Type.Optional(Type.Union([
|
|
5
6
|
Type.String({
|
|
6
7
|
description: "Directory or file to search",
|
|
@@ -28,6 +29,42 @@ export function toArray(value) {
|
|
|
28
29
|
return Array.isArray(value) ? value : [value];
|
|
29
30
|
}
|
|
30
31
|
const MAX_RIPGREP_OUTPUT_BYTES = 2_000_000; // ~2MB safeguard
|
|
32
|
+
let ripgrepExecutablePromise = null;
|
|
33
|
+
function ripgrepAbortError() {
|
|
34
|
+
return new Error("ripgrep search aborted before start");
|
|
35
|
+
}
|
|
36
|
+
async function resolveRipgrepExecutable() {
|
|
37
|
+
ripgrepExecutablePromise ??= ensureTool("rg", true);
|
|
38
|
+
const executable = await ripgrepExecutablePromise;
|
|
39
|
+
if (!executable) {
|
|
40
|
+
ripgrepExecutablePromise = null;
|
|
41
|
+
throw new Error("ripgrep is not available and could not be downloaded");
|
|
42
|
+
}
|
|
43
|
+
return executable;
|
|
44
|
+
}
|
|
45
|
+
function throwIfRipgrepAborted(signal) {
|
|
46
|
+
if (signal?.aborted) {
|
|
47
|
+
throw ripgrepAbortError();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function resolveRipgrepExecutableWithAbort(signal) {
|
|
51
|
+
throwIfRipgrepAborted(signal);
|
|
52
|
+
if (!signal) {
|
|
53
|
+
return await resolveRipgrepExecutable();
|
|
54
|
+
}
|
|
55
|
+
return await new Promise((resolve, reject) => {
|
|
56
|
+
const onAbort = () => {
|
|
57
|
+
signal.removeEventListener("abort", onAbort);
|
|
58
|
+
reject(ripgrepAbortError());
|
|
59
|
+
};
|
|
60
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
61
|
+
resolveRipgrepExecutable()
|
|
62
|
+
.then(resolve, reject)
|
|
63
|
+
.finally(() => {
|
|
64
|
+
signal.removeEventListener("abort", onAbort);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
31
68
|
function shellQuoteArg(value) {
|
|
32
69
|
if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {
|
|
33
70
|
return value;
|
|
@@ -38,7 +75,9 @@ export function formatRipgrepCommand(args) {
|
|
|
38
75
|
return ["rg", ...args].map(shellQuoteArg).join(" ");
|
|
39
76
|
}
|
|
40
77
|
export async function runRipgrep(args, signal, cwd) {
|
|
41
|
-
const
|
|
78
|
+
const executable = await resolveRipgrepExecutableWithAbort(signal);
|
|
79
|
+
throwIfRipgrepAborted(signal);
|
|
80
|
+
const child = spawn(executable, args, {
|
|
42
81
|
cwd: cwd ?? process.cwd(),
|
|
43
82
|
stdio: ["ignore", "pipe", "pipe"],
|
|
44
83
|
signal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ripgrep-utils.js","sourceRoot":"","sources":["../../src/tools/ripgrep-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ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CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACrB,SAAS;QACV,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAWpB,CAAC;QACF,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5B,SAAS;QACV,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;QAC9C,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,UAAU,IAAI,EAAE,EAAE,CAAC;YACrD,OAAO,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,WAAW,IAAI,CAAC;gBAClC,MAAM,EAAE,QAAQ,CAAC,KAAK,IAAI,CAAC;gBAC3B,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,IAAI,EAAE;gBACjC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,EAAE;aACpC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { Type } from \"@sinclair/typebox\";\nimport { safeJsonParse } from \"../utils/json.js\";\n\nexport const pathSchema = Type.Optional(\n\tType.Union([\n\t\tType.String({\n\t\t\tdescription: \"Directory or file to search\",\n\t\t\tminLength: 1,\n\t\t}),\n\t\tType.Array(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Multiple directories or files to search\",\n\t\t\t\tminLength: 1,\n\t\t\t}),\n\t\t\t{ minItems: 1 },\n\t\t),\n\t]),\n);\n\nexport const globSchema = Type.Optional(\n\tType.Union([\n\t\tType.String({\n\t\t\tdescription: \"Glob pattern passed to ripgrep\",\n\t\t\tminLength: 1,\n\t\t}),\n\t\tType.Array(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Multiple glob patterns\",\n\t\t\t\tminLength: 1,\n\t\t\t}),\n\t\t\t{ minItems: 1 },\n\t\t),\n\t]),\n);\n\nexport function toArray<T>(value: T | T[] | undefined): T[] {\n\tif (value === undefined) {\n\t\treturn [];\n\t}\n\treturn Array.isArray(value) ? value : [value];\n}\n\nconst MAX_RIPGREP_OUTPUT_BYTES = 2_000_000; // ~2MB safeguard\n\nfunction shellQuoteArg(value: string): string {\n\tif (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {\n\t\treturn value;\n\t}\n\treturn `'${value.replace(/'/g, \"'\\\\''\")}'`;\n}\n\nexport function formatRipgrepCommand(args: string[]): string {\n\treturn [\"rg\", ...args].map(shellQuoteArg).join(\" \");\n}\n\nexport async function runRipgrep(\n\targs: string[],\n\tsignal?: AbortSignal,\n\tcwd?: string,\n): Promise<{\n\tstdout: string;\n\tstderr: string;\n\texitCode: number;\n\ttruncated: boolean;\n}> {\n\tconst child = spawn(\"rg\", args, {\n\t\tcwd: cwd ?? process.cwd(),\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\tsignal,\n\t});\n\n\treturn await new Promise((resolve, reject) => {\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\t\tlet truncated = false;\n\n\t\tchild.stdout.setEncoding(\"utf-8\");\n\t\tchild.stdout.on(\"data\", (chunk) => {\n\t\t\tif (stdout.length + chunk.length > MAX_RIPGREP_OUTPUT_BYTES) {\n\t\t\t\ttruncated = true;\n\t\t\t\tstdout += chunk\n\t\t\t\t\t.slice(0, Math.max(0, MAX_RIPGREP_OUTPUT_BYTES - stdout.length))\n\t\t\t\t\t.toString();\n\t\t\t\tchild.kill(\"SIGTERM\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstdout += chunk;\n\t\t});\n\n\t\tchild.stderr.setEncoding(\"utf-8\");\n\t\tchild.stderr.on(\"data\", (chunk) => {\n\t\t\tif (stderr.length + chunk.length > MAX_RIPGREP_OUTPUT_BYTES) {\n\t\t\t\ttruncated = true;\n\t\t\t\tstderr += chunk\n\t\t\t\t\t.slice(0, Math.max(0, MAX_RIPGREP_OUTPUT_BYTES - stderr.length))\n\t\t\t\t\t.toString();\n\t\t\t\tchild.kill(\"SIGTERM\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstderr += chunk;\n\t\t});\n\n\t\tchild.once(\"error\", (error) => {\n\t\t\treject(\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? new Error(`Failed to start ripgrep: ${error.message}`)\n\t\t\t\t\t: new Error(`Failed to start ripgrep: ${String(error)}`),\n\t\t\t);\n\t\t});\n\n\t\tchild.once(\"close\", (code) => {\n\t\t\tresolve({ stdout, stderr, exitCode: code ?? 0, truncated });\n\t\t});\n\t});\n}\n\nexport type RipgrepMatch = {\n\tfile: string;\n\tline: number;\n\tcolumn: number;\n\tmatch: string;\n\tlines: string;\n};\n\nexport function parseRipgrepJson(output: string): RipgrepMatch[] {\n\tconst matches: RipgrepMatch[] = [];\n\tfor (const line of output.split(/\\r?\\n/)) {\n\t\tif (!line.trim()) continue;\n\t\tconst parsed = safeJsonParse<unknown>(line, \"ripgrep output\");\n\t\tif (!parsed.success) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst event = parsed.data as {\n\t\t\ttype?: string;\n\t\t\tdata?: {\n\t\t\t\tpath?: { text?: string };\n\t\t\t\tline_number?: number;\n\t\t\t\tlines?: { text?: string };\n\t\t\t\tsubmatches?: Array<{\n\t\t\t\t\tstart?: number;\n\t\t\t\t\tmatch?: { text?: string };\n\t\t\t\t}>;\n\t\t\t};\n\t\t};\n\t\tif (event.type !== \"match\") {\n\t\t\tcontinue;\n\t\t}\n\t\tconst pathText = event.data?.path?.text ?? \"\";\n\t\tfor (const submatch of event.data?.submatches ?? []) {\n\t\t\tmatches.push({\n\t\t\t\tfile: pathText,\n\t\t\t\tline: event.data?.line_number ?? 0,\n\t\t\t\tcolumn: submatch.start ?? 0,\n\t\t\t\tmatch: submatch.match?.text ?? \"\",\n\t\t\t\tlines: event.data?.lines?.text ?? \"\",\n\t\t\t});\n\t\t}\n\t}\n\treturn matches;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ripgrep-utils.js","sourceRoot":"","sources":["../../src/tools/ripgrep-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CACtC,IAAI,CAAC,KAAK,CAAC;IACV,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,6BAA6B;QAC1C,SAAS,EAAE,CAAC;KACZ,CAAC;IACF,IAAI,CAAC,KAAK,CACT,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,yCAAyC;QACtD,SAAS,EAAE,CAAC;KACZ,CAAC,EACF,EAAE,QAAQ,EAAE,CAAC,EAAE,CACf;CACD,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CACtC,IAAI,CAAC,KAAK,CAAC;IACV,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,gCAAgC;QAC7C,SAAS,EAAE,CAAC;KACZ,CAAC;IACF,IAAI,CAAC,KAAK,CACT,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,wBAAwB;QACrC,SAAS,EAAE,CAAC;KACZ,CAAC,EACF,EAAE,QAAQ,EAAE,CAAC,EAAE,CACf;CACD,CAAC,CACF,CAAC;AAEF,MAAM,UAAU,OAAO,CAAI,KAA0B;IACpD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CA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QACJ,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { Type } from \"@sinclair/typebox\";\nimport { safeJsonParse } from \"../utils/json.js\";\nimport { ensureTool } from \"./tools-manager.js\";\n\nexport const pathSchema = Type.Optional(\n\tType.Union([\n\t\tType.String({\n\t\t\tdescription: \"Directory or file to search\",\n\t\t\tminLength: 1,\n\t\t}),\n\t\tType.Array(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Multiple directories or files to search\",\n\t\t\t\tminLength: 1,\n\t\t\t}),\n\t\t\t{ minItems: 1 },\n\t\t),\n\t]),\n);\n\nexport const globSchema = Type.Optional(\n\tType.Union([\n\t\tType.String({\n\t\t\tdescription: \"Glob pattern passed to ripgrep\",\n\t\t\tminLength: 1,\n\t\t}),\n\t\tType.Array(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Multiple glob patterns\",\n\t\t\t\tminLength: 1,\n\t\t\t}),\n\t\t\t{ minItems: 1 },\n\t\t),\n\t]),\n);\n\nexport function toArray<T>(value: T | T[] | undefined): T[] {\n\tif (value === undefined) {\n\t\treturn [];\n\t}\n\treturn Array.isArray(value) ? value : [value];\n}\n\nconst MAX_RIPGREP_OUTPUT_BYTES = 2_000_000; // ~2MB safeguard\nlet ripgrepExecutablePromise: Promise<string | null> | null = null;\n\nfunction ripgrepAbortError(): Error {\n\treturn new Error(\"ripgrep search aborted before start\");\n}\n\nasync function resolveRipgrepExecutable(): Promise<string> {\n\tripgrepExecutablePromise ??= ensureTool(\"rg\", true);\n\tconst executable = await ripgrepExecutablePromise;\n\tif (!executable) {\n\t\tripgrepExecutablePromise = null;\n\t\tthrow new Error(\"ripgrep is not available and could not be downloaded\");\n\t}\n\treturn executable;\n}\n\nfunction throwIfRipgrepAborted(signal?: AbortSignal): void {\n\tif (signal?.aborted) {\n\t\tthrow ripgrepAbortError();\n\t}\n}\n\nasync function resolveRipgrepExecutableWithAbort(\n\tsignal?: AbortSignal,\n): Promise<string> {\n\tthrowIfRipgrepAborted(signal);\n\tif (!signal) {\n\t\treturn await resolveRipgrepExecutable();\n\t}\n\n\treturn await new Promise<string>((resolve, reject) => {\n\t\tconst onAbort = (): void => {\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\treject(ripgrepAbortError());\n\t\t};\n\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tresolveRipgrepExecutable()\n\t\t\t.then(resolve, reject)\n\t\t\t.finally(() => {\n\t\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\t});\n\t});\n}\n\nfunction shellQuoteArg(value: string): string {\n\tif (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {\n\t\treturn value;\n\t}\n\treturn `'${value.replace(/'/g, \"'\\\\''\")}'`;\n}\n\nexport function formatRipgrepCommand(args: string[]): string {\n\treturn [\"rg\", ...args].map(shellQuoteArg).join(\" \");\n}\n\nexport async function runRipgrep(\n\targs: string[],\n\tsignal?: AbortSignal,\n\tcwd?: string,\n): Promise<{\n\tstdout: string;\n\tstderr: string;\n\texitCode: number;\n\ttruncated: boolean;\n}> {\n\tconst executable = await resolveRipgrepExecutableWithAbort(signal);\n\tthrowIfRipgrepAborted(signal);\n\tconst child = spawn(executable, args, {\n\t\tcwd: cwd ?? process.cwd(),\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\tsignal,\n\t});\n\n\treturn await new Promise((resolve, reject) => {\n\t\tlet stdout = \"\";\n\t\tlet stderr = \"\";\n\t\tlet truncated = false;\n\n\t\tchild.stdout.setEncoding(\"utf-8\");\n\t\tchild.stdout.on(\"data\", (chunk) => {\n\t\t\tif (stdout.length + chunk.length > MAX_RIPGREP_OUTPUT_BYTES) {\n\t\t\t\ttruncated = true;\n\t\t\t\tstdout += chunk\n\t\t\t\t\t.slice(0, Math.max(0, MAX_RIPGREP_OUTPUT_BYTES - stdout.length))\n\t\t\t\t\t.toString();\n\t\t\t\tchild.kill(\"SIGTERM\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstdout += chunk;\n\t\t});\n\n\t\tchild.stderr.setEncoding(\"utf-8\");\n\t\tchild.stderr.on(\"data\", (chunk) => {\n\t\t\tif (stderr.length + chunk.length > MAX_RIPGREP_OUTPUT_BYTES) {\n\t\t\t\ttruncated = true;\n\t\t\t\tstderr += chunk\n\t\t\t\t\t.slice(0, Math.max(0, MAX_RIPGREP_OUTPUT_BYTES - stderr.length))\n\t\t\t\t\t.toString();\n\t\t\t\tchild.kill(\"SIGTERM\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstderr += chunk;\n\t\t});\n\n\t\tchild.once(\"error\", (error) => {\n\t\t\treject(\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? new Error(`Failed to start ripgrep: ${error.message}`)\n\t\t\t\t\t: new Error(`Failed to start ripgrep: ${String(error)}`),\n\t\t\t);\n\t\t});\n\n\t\tchild.once(\"close\", (code) => {\n\t\t\tresolve({ stdout, stderr, exitCode: code ?? 0, truncated });\n\t\t});\n\t});\n}\n\nexport type RipgrepMatch = {\n\tfile: string;\n\tline: number;\n\tcolumn: number;\n\tmatch: string;\n\tlines: string;\n};\n\nexport function parseRipgrepJson(output: string): RipgrepMatch[] {\n\tconst matches: RipgrepMatch[] = [];\n\tfor (const line of output.split(/\\r?\\n/)) {\n\t\tif (!line.trim()) continue;\n\t\tconst parsed = safeJsonParse<unknown>(line, \"ripgrep output\");\n\t\tif (!parsed.success) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst event = parsed.data as {\n\t\t\ttype?: string;\n\t\t\tdata?: {\n\t\t\t\tpath?: { text?: string };\n\t\t\t\tline_number?: number;\n\t\t\t\tlines?: { text?: string };\n\t\t\t\tsubmatches?: Array<{\n\t\t\t\t\tstart?: number;\n\t\t\t\t\tmatch?: { text?: string };\n\t\t\t\t}>;\n\t\t\t};\n\t\t};\n\t\tif (event.type !== \"match\") {\n\t\t\tcontinue;\n\t\t}\n\t\tconst pathText = event.data?.path?.text ?? \"\";\n\t\tfor (const submatch of event.data?.submatches ?? []) {\n\t\t\tmatches.push({\n\t\t\t\tfile: pathText,\n\t\t\t\tline: event.data?.line_number ?? 0,\n\t\t\t\tcolumn: submatch.start ?? 0,\n\t\t\t\tmatch: submatch.match?.text ?? \"\",\n\t\t\t\tlines: event.data?.lines?.text ?? \"\",\n\t\t\t});\n\t\t}\n\t}\n\treturn matches;\n}\n"]}
|
package/dist/version.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.10.
|
|
3
|
-
"notes": "Maestro by EvalOps - Deterministic coding agent with TUI/CLI and Web UI for AI-assisted development v0.10.
|
|
2
|
+
"version": "0.10.38",
|
|
3
|
+
"notes": "Maestro by EvalOps - Deterministic coding agent with TUI/CLI and Web UI for AI-assisted development v0.10.38 is now available."
|
|
4
4
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evalops/maestro",
|
|
3
3
|
"description": "Maestro by EvalOps - Deterministic coding agent with TUI/CLI and Web UI for AI-assisted development",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.38",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
7
7
|
"workspaces": [
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"check:context-manifest": "tsx scripts/check-context-manifest-contract.ts",
|
|
44
44
|
"check:session-wire-contract": "tsx scripts/check-session-wire-contract.ts",
|
|
45
45
|
"check:cli-runtime-conformance": "tsx scripts/check-cli-runtime-conformance.ts",
|
|
46
|
+
"check:rpc-protocol-conformance": "tsx scripts/check-rpc-protocol-conformance.ts",
|
|
46
47
|
"check:session-replay-fixtures": "tsx scripts/check-session-replay-fixtures.ts",
|
|
47
48
|
"check:agent-trajectory-fixtures": "tsx scripts/check-agent-trajectory-fixtures.ts",
|
|
48
49
|
"check:agent-trajectory-replay-fixtures": "tsx scripts/check-agent-trajectory-replay-fixtures.ts",
|
|
@@ -56,8 +57,9 @@
|
|
|
56
57
|
"check:scenario-replay-gate": "node scripts/run-scenario-replay-gate.mjs",
|
|
57
58
|
"check:codex-parity": "node scripts/check-codex-parity-conformance.mjs",
|
|
58
59
|
"check:codex-operating-layer": "node scripts/check-codex-operating-layer-conformance.mjs",
|
|
60
|
+
"check:platform-runtime-conformance": "node scripts/check-platform-runtime-conformance.mjs",
|
|
59
61
|
"check:release-surface": "node scripts/check-release-surface-conformance.mjs",
|
|
60
|
-
"lint:evals": "bun run lint:headless-proto && node scripts/ensure-deps.js --no-install --workspace @evalops/contracts && node scripts/verify-evals.js && node scripts/verify-tool-versions.js && node scripts/validate-system-paths.js && node scripts/validate-package-boundaries.js && node scripts/validate-public-package-deps.js && node scripts/check-public-surface-boundary.mjs && npm run check:context-manifest && npm run check:session-wire-contract && npm run check:cli-runtime-conformance && npm run check:evidence-integrity && npm run check:maestro-release-gate-events && npm run check:session-replay-fixtures && npm run check:agent-trajectory-fixtures && npm run check:agent-trajectory-replay-fixtures && npm run check:agent-trajectory-score-fixtures && npm run check:agent-trajectory-inspection-fixtures && npm run check:agent-trajectory-scenario-fixtures && npm run check:slack-contract-lab-scenarios && npm run check:scripted-scenario-fixtures && node scripts/session-wire-format-codegen.mjs --check && node scripts/headless-protocol-codegen.mjs --check && npm run check:app-server-schema && npm run check:drift-surfaces && npm run check:staged-rollout && npm run check:codex-parity && npm run check:codex-operating-layer && npm run check:release-surface && npm run developer-surface:check",
|
|
62
|
+
"lint:evals": "bun run lint:headless-proto && node scripts/ensure-deps.js --no-install --workspace @evalops/contracts && node scripts/verify-evals.js && node scripts/verify-tool-versions.js && node scripts/validate-system-paths.js && node scripts/validate-package-boundaries.js && node scripts/validate-public-package-deps.js && node scripts/check-public-surface-boundary.mjs && npm run check:context-manifest && npm run check:session-wire-contract && npm run check:cli-runtime-conformance && npm run check:rpc-protocol-conformance && npm run check:evidence-integrity && npm run check:maestro-release-gate-events && npm run check:session-replay-fixtures && npm run check:agent-trajectory-fixtures && npm run check:agent-trajectory-replay-fixtures && npm run check:agent-trajectory-score-fixtures && npm run check:agent-trajectory-inspection-fixtures && npm run check:agent-trajectory-scenario-fixtures && npm run check:slack-contract-lab-scenarios && npm run check:scripted-scenario-fixtures && node scripts/session-wire-format-codegen.mjs --check && node scripts/headless-protocol-codegen.mjs --check && npm run check:app-server-schema && npm run check:drift-surfaces && npm run check:staged-rollout && npm run check:codex-parity && npm run check:codex-operating-layer && npm run check:platform-runtime-conformance && npm run check:release-surface && npm run developer-surface:check",
|
|
61
63
|
"platform:sdk-smoke": "tsx scripts/check-platform-sdk-contract.ts",
|
|
62
64
|
"platform:agentruntime-e2e": "tsx scripts/smoke-platform-agentruntime-lifecycle.ts",
|
|
63
65
|
"platform:timeline-e2e": "tsx scripts/smoke-platform-timeline-e2e.ts",
|
|
@@ -173,13 +175,12 @@
|
|
|
173
175
|
"@aws-sdk/client-bedrock-runtime": "^3.1020.0",
|
|
174
176
|
"@bufbuild/protobuf": "^2.11.0",
|
|
175
177
|
"@crosscopy/clipboard": "^0.2.8",
|
|
176
|
-
"@daytonaio/sdk": "^0.155.0",
|
|
177
178
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
178
179
|
"@opentelemetry/api": "^1.9.1",
|
|
179
|
-
"@opentelemetry/auto-instrumentations-node": "^0.
|
|
180
|
-
"@opentelemetry/resources": "^2.
|
|
181
|
-
"@opentelemetry/sdk-node": "0.
|
|
182
|
-
"@opentelemetry/semantic-conventions": "^1.
|
|
180
|
+
"@opentelemetry/auto-instrumentations-node": "^0.76.0",
|
|
181
|
+
"@opentelemetry/resources": "^2.7.1",
|
|
182
|
+
"@opentelemetry/sdk-node": "0.218.0",
|
|
183
|
+
"@opentelemetry/semantic-conventions": "^1.41.1",
|
|
183
184
|
"@sentry/node": "^10.53.1",
|
|
184
185
|
"@sinclair/typebox": "^0.34.49",
|
|
185
186
|
"ajv": "^8.18.0",
|