@evalops/maestro 0.10.10 → 0.10.11
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/args.d.ts.map +1 -1
- package/dist/cli/args.js +2 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands/evalops.d.ts.map +1 -1
- package/dist/cli/commands/evalops.js +6 -1
- package/dist/cli/commands/evalops.js.map +1 -1
- package/dist/cli/commands/init.d.ts +4 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +140 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +9 -1
- package/dist/cli/help.js.map +1 -1
- package/dist/cli.js +826 -283
- package/dist/evalops/agent-bootstrap.d.ts +73 -0
- package/dist/evalops/agent-bootstrap.d.ts.map +1 -0
- package/dist/evalops/agent-bootstrap.js +380 -0
- package/dist/evalops/agent-bootstrap.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -0
- package/dist/main.js.map +1 -1
- package/dist/mcp/platform-plugin.d.ts.map +1 -1
- package/dist/mcp/platform-plugin.js +40 -6
- package/dist/mcp/platform-plugin.js.map +1 -1
- package/dist/oauth/evalops.js +1 -1
- package/dist/oauth/evalops.js.map +1 -1
- package/dist/version.json +2 -2
- package/node_modules/@evalops/contracts/package.json +1 -1
- package/node_modules/@evalops/tui/package.json +1 -1
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -36841,6 +36841,10 @@ import { dirname as dirname20, join as join33 } from "node:path";
|
|
|
36841
36841
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
36842
36842
|
import { isAbsolute as isAbsolute8, relative as relative3, resolve as resolve21, sep as sep5 } from "node:path";
|
|
36843
36843
|
import { minimatch as minimatch6 } from "minimatch";
|
|
36844
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
36845
|
+
import { hostname } from "node:os";
|
|
36846
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
36847
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
36844
36848
|
import { z } from "zod";
|
|
36845
36849
|
import { readFileSync as readFileSync30, statSync as statSync13 } from "node:fs";
|
|
36846
36850
|
import { join as join34, resolve as resolve22 } from "node:path";
|
|
@@ -36849,10 +36853,10 @@ import { resolve as resolve23 } from "node:path";
|
|
|
36849
36853
|
import { execFile } from "node:child_process";
|
|
36850
36854
|
import { EventEmitter as EventEmitter4 } from "node:events";
|
|
36851
36855
|
import { promisify as promisify2 } from "node:util";
|
|
36852
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
36856
|
+
import { Client as Client2 } from "@modelcontextprotocol/sdk/client/index.js";
|
|
36853
36857
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
36854
36858
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
36855
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
36859
|
+
import { StreamableHTTPClientTransport as StreamableHTTPClientTransport2 } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
36856
36860
|
import {
|
|
36857
36861
|
ElicitRequestSchema,
|
|
36858
36862
|
LoggingMessageNotificationSchema,
|
|
@@ -36999,7 +37003,7 @@ import {
|
|
|
36999
37003
|
existsSync as existsSync56,
|
|
37000
37004
|
writeFileSync as writeFileSync20
|
|
37001
37005
|
} from "node:fs";
|
|
37002
|
-
import { createRequire as
|
|
37006
|
+
import { createRequire as createRequire5 } from "node:module";
|
|
37003
37007
|
import { basename as basename11 } from "node:path";
|
|
37004
37008
|
import { createInterface } from "node:readline";
|
|
37005
37009
|
import { existsSync as existsSync57, mkdirSync as mkdirSync22, writeFileSync as writeFileSync21 } from "node:fs";
|
|
@@ -37086,7 +37090,6 @@ import {
|
|
|
37086
37090
|
writeFileSync as writeFileSync23
|
|
37087
37091
|
} from "node:fs";
|
|
37088
37092
|
import { dirname as dirname34 } from "node:path";
|
|
37089
|
-
import { createRequire as createRequire5 } from "node:module";
|
|
37090
37093
|
import { Spacer as Spacer24, Text as Text25 } from "@evalops/tui";
|
|
37091
37094
|
import chalk34 from "chalk";
|
|
37092
37095
|
import { Spacer as Spacer25, Text as Text26 } from "@evalops/tui";
|
|
@@ -37570,12 +37573,13 @@ import {
|
|
|
37570
37573
|
import { URL as URL2 } from "node:url";
|
|
37571
37574
|
import chalk61 from "chalk";
|
|
37572
37575
|
import chalk62 from "chalk";
|
|
37573
|
-
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
37574
37576
|
import chalk63 from "chalk";
|
|
37577
|
+
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
37575
37578
|
import chalk64 from "chalk";
|
|
37576
|
-
import { resolve as resolve59 } from "node:path";
|
|
37577
37579
|
import chalk65 from "chalk";
|
|
37580
|
+
import { resolve as resolve59 } from "node:path";
|
|
37578
37581
|
import chalk66 from "chalk";
|
|
37582
|
+
import chalk67 from "chalk";
|
|
37579
37583
|
import { clearLine, cursorTo } from "node:readline";
|
|
37580
37584
|
import { createInterface as createInterface3 } from "node:readline/promises";
|
|
37581
37585
|
import {
|
|
@@ -37584,17 +37588,17 @@ import {
|
|
|
37584
37588
|
assertHeadlessRuntimeSubscriptionSnapshot as assertHeadlessRuntimeSubscriptionSnapshot2,
|
|
37585
37589
|
headlessProtocolVersion as headlessProtocolVersion2
|
|
37586
37590
|
} from "@evalops/contracts";
|
|
37587
|
-
import
|
|
37591
|
+
import chalk68 from "chalk";
|
|
37588
37592
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
37589
37593
|
import { headlessProtocolVersion as headlessProtocolVersion3 } from "@evalops/contracts";
|
|
37590
|
-
import
|
|
37594
|
+
import chalk69 from "chalk";
|
|
37591
37595
|
import { stdin, stdout } from "node:process";
|
|
37592
37596
|
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
37593
|
-
import chalk69 from "chalk";
|
|
37594
37597
|
import chalk70 from "chalk";
|
|
37595
37598
|
import chalk71 from "chalk";
|
|
37596
37599
|
import chalk72 from "chalk";
|
|
37597
37600
|
import chalk73 from "chalk";
|
|
37601
|
+
import chalk74 from "chalk";
|
|
37598
37602
|
import { exec as exec3 } from "node:child_process";
|
|
37599
37603
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
37600
37604
|
import { promisify as promisify6 } from "node:util";
|
|
@@ -37623,12 +37627,12 @@ import { spawn as spawn20 } from "node:child_process";
|
|
|
37623
37627
|
import { existsSync as existsSync106, readFileSync as readFileSync78 } from "node:fs";
|
|
37624
37628
|
import { join as join85, resolve as resolve60 } from "node:path";
|
|
37625
37629
|
import { Type as Type46 } from "@sinclair/typebox";
|
|
37626
|
-
import chalk74 from "chalk";
|
|
37627
37630
|
import chalk75 from "chalk";
|
|
37628
37631
|
import chalk76 from "chalk";
|
|
37629
37632
|
import chalk77 from "chalk";
|
|
37630
|
-
import { createRequire as createRequire7 } from "node:module";
|
|
37631
37633
|
import chalk78 from "chalk";
|
|
37634
|
+
import { createRequire as createRequire7 } from "node:module";
|
|
37635
|
+
import chalk79 from "chalk";
|
|
37632
37636
|
var __defProp2 = Object.defineProperty;
|
|
37633
37637
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
37634
37638
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -51281,7 +51285,7 @@ var CALLBACK_PORT = 1460;
|
|
|
51281
51285
|
var CALLBACK_PATH = "/auth/callback/evalops";
|
|
51282
51286
|
var CALLBACK_ORIGIN;
|
|
51283
51287
|
var CALLBACK_URI;
|
|
51284
|
-
var DEFAULT_IDENTITY_URL = "
|
|
51288
|
+
var DEFAULT_IDENTITY_URL = "https://identity.evalops.dev";
|
|
51285
51289
|
var IDENTITY_BASE_URL_ENV_VARS;
|
|
51286
51290
|
var SHARED_PLATFORM_BASE_URL_ENV_VARS;
|
|
51287
51291
|
var DEFAULT_PROVIDER_REF_PROVIDER = "openai";
|
|
@@ -53647,8 +53651,8 @@ function isPrivateIP(ip) {
|
|
|
53647
53651
|
}
|
|
53648
53652
|
return false;
|
|
53649
53653
|
}
|
|
53650
|
-
function isLocalhostAlias(
|
|
53651
|
-
const lower2 =
|
|
53654
|
+
function isLocalhostAlias(hostname2) {
|
|
53655
|
+
const lower2 = hostname2.toLowerCase();
|
|
53652
53656
|
return lower2 === "localhost" || lower2 === "localhost.localdomain" || lower2 === "0.0.0.0";
|
|
53653
53657
|
}
|
|
53654
53658
|
function extractUrlsFromValue(value) {
|
|
@@ -58830,8 +58834,8 @@ function isLocalBaseUrl(url) {
|
|
|
58830
58834
|
}
|
|
58831
58835
|
try {
|
|
58832
58836
|
const parsed = new URL(url);
|
|
58833
|
-
const
|
|
58834
|
-
return
|
|
58837
|
+
const hostname2 = parsed.hostname.replace(/^\[|\]$/g, "");
|
|
58838
|
+
return hostname2 === "localhost" || hostname2 === "127.0.0.1" || hostname2 === "::1" || hostname2 === "0.0.0.0";
|
|
58835
58839
|
} catch {
|
|
58836
58840
|
return false;
|
|
58837
58841
|
}
|
|
@@ -87024,6 +87028,384 @@ var init_env_limits = __esm2(() => {
|
|
|
87024
87028
|
}
|
|
87025
87029
|
];
|
|
87026
87030
|
});
|
|
87031
|
+
function loadPackageMetadata() {
|
|
87032
|
+
if (cachedPackageMetadata) {
|
|
87033
|
+
return cachedPackageMetadata;
|
|
87034
|
+
}
|
|
87035
|
+
try {
|
|
87036
|
+
const packageJson4 = createRequire4(import.meta.url)("../package.json");
|
|
87037
|
+
cachedPackageMetadata = packageJson4;
|
|
87038
|
+
return packageJson4;
|
|
87039
|
+
} catch {
|
|
87040
|
+
cachedPackageMetadata = {};
|
|
87041
|
+
return cachedPackageMetadata;
|
|
87042
|
+
}
|
|
87043
|
+
}
|
|
87044
|
+
function getPackageVersion() {
|
|
87045
|
+
return process.env.MAESTRO_VERSION ?? loadPackageMetadata().version ?? "unknown";
|
|
87046
|
+
}
|
|
87047
|
+
function getPackageName() {
|
|
87048
|
+
const metadata = loadPackageMetadata();
|
|
87049
|
+
return process.env.MAESTRO_PACKAGE_NAME ?? metadata.name ?? metadata.maestro?.canonicalPackageName ?? "@evalops/maestro";
|
|
87050
|
+
}
|
|
87051
|
+
function getGlobalInstallCommand(packageManager = "npm", packageName = getPackageName()) {
|
|
87052
|
+
return `${packageManager} install -g ${packageName}`;
|
|
87053
|
+
}
|
|
87054
|
+
var cachedPackageMetadata = null;
|
|
87055
|
+
var init_package_metadata = () => {
|
|
87056
|
+
};
|
|
87057
|
+
function isRecord9(value) {
|
|
87058
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
87059
|
+
}
|
|
87060
|
+
function nonEmptyString(value) {
|
|
87061
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
87062
|
+
}
|
|
87063
|
+
function stringArray(value) {
|
|
87064
|
+
if (!Array.isArray(value)) {
|
|
87065
|
+
return;
|
|
87066
|
+
}
|
|
87067
|
+
const values = value.map((entry2) => nonEmptyString(entry2)).filter((entry2) => Boolean(entry2));
|
|
87068
|
+
return values.length > 0 ? values : void 0;
|
|
87069
|
+
}
|
|
87070
|
+
function positiveInteger(value) {
|
|
87071
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
|
|
87072
|
+
}
|
|
87073
|
+
function getStoredAgentMcpMetadata(credentials) {
|
|
87074
|
+
const metadata = credentials?.metadata;
|
|
87075
|
+
const agentMcp = isRecord9(metadata?.agentMcp) ? metadata.agentMcp : void 0;
|
|
87076
|
+
const apiKey = nonEmptyString(agentMcp?.apiKey);
|
|
87077
|
+
const endpoint = nonEmptyString(agentMcp?.endpoint);
|
|
87078
|
+
const registeredAt = nonEmptyString(agentMcp?.registeredAt);
|
|
87079
|
+
const createdAt = nonEmptyString(agentMcp?.createdAt);
|
|
87080
|
+
const surface = nonEmptyString(agentMcp?.surface);
|
|
87081
|
+
if (!apiKey || !endpoint || !registeredAt || !createdAt || !surface) {
|
|
87082
|
+
return;
|
|
87083
|
+
}
|
|
87084
|
+
return {
|
|
87085
|
+
type: "agent-mcp",
|
|
87086
|
+
apiKey,
|
|
87087
|
+
createdAt,
|
|
87088
|
+
endpoint,
|
|
87089
|
+
registeredAt,
|
|
87090
|
+
surface,
|
|
87091
|
+
agentId: nonEmptyString(agentMcp?.agentId),
|
|
87092
|
+
expiresAt: nonEmptyString(agentMcp?.expiresAt),
|
|
87093
|
+
keyId: nonEmptyString(agentMcp?.keyId),
|
|
87094
|
+
keyName: nonEmptyString(agentMcp?.keyName),
|
|
87095
|
+
keyPrefix: nonEmptyString(agentMcp?.keyPrefix),
|
|
87096
|
+
manifestUrl: nonEmptyString(agentMcp?.manifestUrl),
|
|
87097
|
+
registryVisible: typeof agentMcp?.registryVisible === "boolean" ? agentMcp.registryVisible : void 0,
|
|
87098
|
+
runId: nonEmptyString(agentMcp?.runId),
|
|
87099
|
+
scopes: stringArray(agentMcp?.scopes),
|
|
87100
|
+
sessionExpiresAt: nonEmptyString(agentMcp?.sessionExpiresAt),
|
|
87101
|
+
workspaceId: nonEmptyString(agentMcp?.workspaceId)
|
|
87102
|
+
};
|
|
87103
|
+
}
|
|
87104
|
+
function getStoredEvalOpsAgentMcpMetadata() {
|
|
87105
|
+
return getStoredAgentMcpMetadata(loadOAuthCredentials("evalops"));
|
|
87106
|
+
}
|
|
87107
|
+
function normalizeMcpEndpoint(url) {
|
|
87108
|
+
const normalized = normalizeBaseUrl2(url);
|
|
87109
|
+
const parsed = new URL(normalized);
|
|
87110
|
+
if (parsed.pathname === "" || parsed.pathname === "/" || parsed.pathname === AGENT_MCP_MANIFEST_PATH) {
|
|
87111
|
+
parsed.pathname = AGENT_MCP_PATH;
|
|
87112
|
+
parsed.search = "";
|
|
87113
|
+
parsed.hash = "";
|
|
87114
|
+
}
|
|
87115
|
+
return normalizeBaseUrl2(parsed.toString());
|
|
87116
|
+
}
|
|
87117
|
+
function normalizeManifestUrl(url) {
|
|
87118
|
+
const normalized = normalizeBaseUrl2(url);
|
|
87119
|
+
const parsed = new URL(normalized);
|
|
87120
|
+
if (parsed.pathname === "" || parsed.pathname === "/") {
|
|
87121
|
+
parsed.pathname = AGENT_MCP_MANIFEST_PATH;
|
|
87122
|
+
}
|
|
87123
|
+
return parsed.toString();
|
|
87124
|
+
}
|
|
87125
|
+
async function resolveEndpointFromManifest(manifestUrl, fetchImpl) {
|
|
87126
|
+
const response = await fetchImpl(manifestUrl, {
|
|
87127
|
+
headers: { accept: "application/json" }
|
|
87128
|
+
});
|
|
87129
|
+
if (!response.ok) {
|
|
87130
|
+
throw new Error(`Failed to fetch EvalOps MCP manifest (${response.status} ${response.statusText})`);
|
|
87131
|
+
}
|
|
87132
|
+
const payload = await response.json();
|
|
87133
|
+
const protocol = isRecord9(payload) && isRecord9(payload.protocol) ? payload.protocol : void 0;
|
|
87134
|
+
const endpoint = nonEmptyString(protocol?.endpoint);
|
|
87135
|
+
if (!endpoint) {
|
|
87136
|
+
throw new Error("EvalOps MCP manifest did not include protocol.endpoint");
|
|
87137
|
+
}
|
|
87138
|
+
return { endpoint: normalizeMcpEndpoint(endpoint), manifestUrl };
|
|
87139
|
+
}
|
|
87140
|
+
async function resolveAgentMcpEndpoint(options, deps) {
|
|
87141
|
+
if (options.mcpUrl) {
|
|
87142
|
+
return { endpoint: normalizeMcpEndpoint(options.mcpUrl) };
|
|
87143
|
+
}
|
|
87144
|
+
if (options.manifestUrl) {
|
|
87145
|
+
return resolveEndpointFromManifest(normalizeManifestUrl(options.manifestUrl), deps.fetch);
|
|
87146
|
+
}
|
|
87147
|
+
const configuredMcpUrl = getEnvValue3([
|
|
87148
|
+
"MAESTRO_PLATFORM_MCP_URL",
|
|
87149
|
+
"MAESTRO_AGENT_MCP_URL",
|
|
87150
|
+
"MAESTRO_EVALOPS_AGENT_MCP_URL"
|
|
87151
|
+
]);
|
|
87152
|
+
if (configuredMcpUrl) {
|
|
87153
|
+
return { endpoint: normalizeMcpEndpoint(configuredMcpUrl) };
|
|
87154
|
+
}
|
|
87155
|
+
const configuredManifestUrl = getEnvValue3([
|
|
87156
|
+
"MAESTRO_PLATFORM_MCP_MANIFEST_URL",
|
|
87157
|
+
"MAESTRO_AGENT_MCP_MANIFEST_URL",
|
|
87158
|
+
"MAESTRO_EVALOPS_AGENT_MCP_MANIFEST_URL"
|
|
87159
|
+
]);
|
|
87160
|
+
if (configuredManifestUrl) {
|
|
87161
|
+
return resolveEndpointFromManifest(normalizeManifestUrl(configuredManifestUrl), deps.fetch);
|
|
87162
|
+
}
|
|
87163
|
+
const stored = getStoredAgentMcpMetadata(deps.loadCredentials("evalops"));
|
|
87164
|
+
if (stored?.endpoint) {
|
|
87165
|
+
return {
|
|
87166
|
+
endpoint: normalizeMcpEndpoint(stored.endpoint),
|
|
87167
|
+
manifestUrl: stored.manifestUrl
|
|
87168
|
+
};
|
|
87169
|
+
}
|
|
87170
|
+
return resolveEndpointFromManifest(`${DEFAULT_AGENT_MCP_BASE_URL}${AGENT_MCP_MANIFEST_PATH}`, deps.fetch);
|
|
87171
|
+
}
|
|
87172
|
+
function createDefaultMcpClient(endpoint, bearerToken) {
|
|
87173
|
+
const client = new Client({
|
|
87174
|
+
name: "maestro",
|
|
87175
|
+
version: getPackageVersion()
|
|
87176
|
+
}, {
|
|
87177
|
+
capabilities: {}
|
|
87178
|
+
});
|
|
87179
|
+
const headers = {
|
|
87180
|
+
accept: "application/json, text/event-stream",
|
|
87181
|
+
"content-type": "application/json",
|
|
87182
|
+
...bearerToken ? { authorization: `Bearer ${bearerToken}` } : {}
|
|
87183
|
+
};
|
|
87184
|
+
const transport = new StreamableHTTPClientTransport(new URL(endpoint), {
|
|
87185
|
+
requestInit: {
|
|
87186
|
+
headers
|
|
87187
|
+
}
|
|
87188
|
+
});
|
|
87189
|
+
return {
|
|
87190
|
+
callTool: (name, args) => client.callTool({
|
|
87191
|
+
name,
|
|
87192
|
+
arguments: args
|
|
87193
|
+
}),
|
|
87194
|
+
close: () => client.close(),
|
|
87195
|
+
connect: () => client.connect(transport)
|
|
87196
|
+
};
|
|
87197
|
+
}
|
|
87198
|
+
async function callMcpTool(createClient, endpoint, token, toolName, args) {
|
|
87199
|
+
const client = createClient(endpoint, token);
|
|
87200
|
+
await client.connect();
|
|
87201
|
+
try {
|
|
87202
|
+
const result = await client.callTool(toolName, args);
|
|
87203
|
+
if (result.isError) {
|
|
87204
|
+
throw new Error(`${toolName} returned an MCP error`);
|
|
87205
|
+
}
|
|
87206
|
+
return parseToolOutput(toolName, result);
|
|
87207
|
+
} finally {
|
|
87208
|
+
await client.close().catch(() => {
|
|
87209
|
+
return;
|
|
87210
|
+
});
|
|
87211
|
+
}
|
|
87212
|
+
}
|
|
87213
|
+
function parseToolOutput(toolName, result) {
|
|
87214
|
+
const structuredContent = isRecord9(result.structuredContent) ? result.structuredContent : void 0;
|
|
87215
|
+
if (structuredContent) {
|
|
87216
|
+
return structuredContent;
|
|
87217
|
+
}
|
|
87218
|
+
const text2 = Array.isArray(result.content) ? result.content.map((entry2) => entry2.type === "text" && typeof entry2.text === "string" ? entry2.text : void 0).find((entry2) => Boolean(entry2)) : void 0;
|
|
87219
|
+
if (text2) {
|
|
87220
|
+
const parsed = JSON.parse(text2);
|
|
87221
|
+
if (isRecord9(parsed)) {
|
|
87222
|
+
return parsed;
|
|
87223
|
+
}
|
|
87224
|
+
}
|
|
87225
|
+
throw new Error(`${toolName} did not return structured JSON output`);
|
|
87226
|
+
}
|
|
87227
|
+
async function ensureEvalOpsLogin(options, deps) {
|
|
87228
|
+
if (options.forceLogin || !deps.hasOAuthCredentials("evalops")) {
|
|
87229
|
+
deps.onStatus({ message: "Opening EvalOps login" });
|
|
87230
|
+
await deps.login("evalops", {
|
|
87231
|
+
onAuthUrl: deps.onAuthUrl,
|
|
87232
|
+
onStatus: (message) => deps.onStatus({ message })
|
|
87233
|
+
});
|
|
87234
|
+
}
|
|
87235
|
+
let token = await deps.getOAuthToken("evalops");
|
|
87236
|
+
if (!token) {
|
|
87237
|
+
deps.onStatus({ message: "Refreshing EvalOps login" });
|
|
87238
|
+
await deps.login("evalops", {
|
|
87239
|
+
onAuthUrl: deps.onAuthUrl,
|
|
87240
|
+
onStatus: (message) => deps.onStatus({ message })
|
|
87241
|
+
});
|
|
87242
|
+
token = await deps.getOAuthToken("evalops");
|
|
87243
|
+
}
|
|
87244
|
+
if (!token) {
|
|
87245
|
+
throw new Error("EvalOps login did not produce an access token");
|
|
87246
|
+
}
|
|
87247
|
+
return token;
|
|
87248
|
+
}
|
|
87249
|
+
function buildKeyName(options, now2) {
|
|
87250
|
+
if (options.keyName?.trim()) {
|
|
87251
|
+
return options.keyName.trim();
|
|
87252
|
+
}
|
|
87253
|
+
const host = hostname().replace(/[^a-zA-Z0-9._-]+/gu, "-").slice(0, 48);
|
|
87254
|
+
return `maestro-init-${host || "local"}-${now2.toISOString().slice(0, 10)}`;
|
|
87255
|
+
}
|
|
87256
|
+
async function createAgentAPIKey(options, endpoint, oauthToken, createClient, now2) {
|
|
87257
|
+
const output = await callMcpTool(createClient, endpoint, "", "evalops_create_api_key", {
|
|
87258
|
+
name: buildKeyName(options, now2),
|
|
87259
|
+
scopes: options.apiKeyScopes ?? DEFAULT_API_KEY_SCOPES,
|
|
87260
|
+
user_token: oauthToken,
|
|
87261
|
+
...positiveInteger(options.expiresInDays) ? { expires_in_days: options.expiresInDays } : {}
|
|
87262
|
+
});
|
|
87263
|
+
if (!nonEmptyString(output.api_key)) {
|
|
87264
|
+
throw new Error("EvalOps API key creation did not return api_key");
|
|
87265
|
+
}
|
|
87266
|
+
return output;
|
|
87267
|
+
}
|
|
87268
|
+
async function registerAgent(options, endpoint, apiKey, createClient) {
|
|
87269
|
+
const output = await callMcpTool(createClient, endpoint, "", "evalops_register", {
|
|
87270
|
+
agent_type: options.agentType ?? DEFAULT_AGENT_TYPE,
|
|
87271
|
+
capabilities: ["maestro:init", "maestro:cli"],
|
|
87272
|
+
scopes: options.registerScopes ?? DEFAULT_REGISTER_SCOPES,
|
|
87273
|
+
surface: options.surface ?? DEFAULT_SURFACE2,
|
|
87274
|
+
user_token: apiKey,
|
|
87275
|
+
...positiveInteger(options.ttlSeconds) ? { ttl_seconds: options.ttlSeconds } : {},
|
|
87276
|
+
...options.workspaceId ? { workspace_id: options.workspaceId } : {}
|
|
87277
|
+
});
|
|
87278
|
+
if (output.registered !== true || !nonEmptyString(output.agent_id)) {
|
|
87279
|
+
throw new Error("EvalOps agent registration did not return an agent_id");
|
|
87280
|
+
}
|
|
87281
|
+
return output;
|
|
87282
|
+
}
|
|
87283
|
+
function organizationIdFromCredentials(credentials) {
|
|
87284
|
+
return nonEmptyString(credentials?.metadata?.organizationId) ?? nonEmptyString(credentials?.metadata?.organization_id);
|
|
87285
|
+
}
|
|
87286
|
+
function saveBootstrapMetadata(credentials, agentMcp, saveCredentials) {
|
|
87287
|
+
saveCredentials("evalops", {
|
|
87288
|
+
...credentials,
|
|
87289
|
+
metadata: {
|
|
87290
|
+
...credentials.metadata,
|
|
87291
|
+
agentId: agentMcp.agentId ?? credentials.metadata?.agentId,
|
|
87292
|
+
runId: agentMcp.runId ?? credentials.metadata?.runId,
|
|
87293
|
+
surface: agentMcp.surface,
|
|
87294
|
+
agentMcp
|
|
87295
|
+
}
|
|
87296
|
+
});
|
|
87297
|
+
}
|
|
87298
|
+
async function bootstrapEvalOpsAgent(options = {}, dependencies = {}) {
|
|
87299
|
+
const deps = {
|
|
87300
|
+
createMcpClient: dependencies.createMcpClient ?? createDefaultMcpClient,
|
|
87301
|
+
fetch: dependencies.fetch ?? fetch,
|
|
87302
|
+
getOAuthToken: dependencies.getOAuthToken ?? getOAuthToken,
|
|
87303
|
+
hasOAuthCredentials: dependencies.hasOAuthCredentials ?? hasOAuthCredentials,
|
|
87304
|
+
loadCredentials: dependencies.loadCredentials ?? loadOAuthCredentials,
|
|
87305
|
+
login: dependencies.login ?? login,
|
|
87306
|
+
now: dependencies.now ?? (() => /* @__PURE__ */ new Date()),
|
|
87307
|
+
onAuthUrl: dependencies.onAuthUrl ?? ((url) => {
|
|
87308
|
+
process.stdout.write(`${url}
|
|
87309
|
+
`);
|
|
87310
|
+
}),
|
|
87311
|
+
onStatus: dependencies.onStatus ?? (() => {
|
|
87312
|
+
return;
|
|
87313
|
+
}),
|
|
87314
|
+
saveCredentials: dependencies.saveCredentials ?? saveOAuthCredentials
|
|
87315
|
+
};
|
|
87316
|
+
const oauthToken = await ensureEvalOpsLogin(options, deps);
|
|
87317
|
+
const endpoint = await resolveAgentMcpEndpoint(options, deps);
|
|
87318
|
+
const credentialsBeforeKey = deps.loadCredentials("evalops");
|
|
87319
|
+
const stored = getStoredAgentMcpMetadata(credentialsBeforeKey);
|
|
87320
|
+
const now2 = deps.now();
|
|
87321
|
+
let apiKey = stored && !options.rotateKey ? stored.apiKey : void 0;
|
|
87322
|
+
let keyOutput;
|
|
87323
|
+
let apiKeyCreated = false;
|
|
87324
|
+
if (!apiKey) {
|
|
87325
|
+
deps.onStatus({ message: "Creating EvalOps agent API key" });
|
|
87326
|
+
keyOutput = await createAgentAPIKey(options, endpoint.endpoint, oauthToken, deps.createMcpClient, now2);
|
|
87327
|
+
apiKey = keyOutput.api_key;
|
|
87328
|
+
apiKeyCreated = true;
|
|
87329
|
+
} else {
|
|
87330
|
+
deps.onStatus({ message: "Reusing stored EvalOps agent API key" });
|
|
87331
|
+
}
|
|
87332
|
+
deps.onStatus({ message: "Registering Maestro with EvalOps agent MCP" });
|
|
87333
|
+
let registerOutput;
|
|
87334
|
+
try {
|
|
87335
|
+
registerOutput = await registerAgent(options, endpoint.endpoint, apiKey, deps.createMcpClient);
|
|
87336
|
+
} catch (error) {
|
|
87337
|
+
if (apiKeyCreated) {
|
|
87338
|
+
throw error;
|
|
87339
|
+
}
|
|
87340
|
+
deps.onStatus({
|
|
87341
|
+
message: "Stored EvalOps agent API key failed; rotating and retrying"
|
|
87342
|
+
});
|
|
87343
|
+
keyOutput = await createAgentAPIKey({ ...options, rotateKey: true }, endpoint.endpoint, oauthToken, deps.createMcpClient, now2);
|
|
87344
|
+
apiKey = keyOutput.api_key;
|
|
87345
|
+
apiKeyCreated = true;
|
|
87346
|
+
registerOutput = await registerAgent(options, endpoint.endpoint, apiKey, deps.createMcpClient);
|
|
87347
|
+
}
|
|
87348
|
+
const credentials = deps.loadCredentials("evalops");
|
|
87349
|
+
if (!credentials) {
|
|
87350
|
+
throw new Error("EvalOps OAuth credentials disappeared during init");
|
|
87351
|
+
}
|
|
87352
|
+
const keyPrefix = nonEmptyString(keyOutput?.prefix) ?? stored?.keyPrefix;
|
|
87353
|
+
const scopes = keyOutput?.scopes ?? stored?.scopes;
|
|
87354
|
+
const agentMcp = {
|
|
87355
|
+
type: "agent-mcp",
|
|
87356
|
+
apiKey,
|
|
87357
|
+
createdAt: (apiKeyCreated ? now2 : new Date(stored?.createdAt ?? now2)).toISOString(),
|
|
87358
|
+
endpoint: endpoint.endpoint,
|
|
87359
|
+
registeredAt: deps.now().toISOString(),
|
|
87360
|
+
surface: options.surface ?? DEFAULT_SURFACE2,
|
|
87361
|
+
agentId: registerOutput.agent_id,
|
|
87362
|
+
expiresAt: nonEmptyString(keyOutput?.expires_at) ?? stored?.expiresAt,
|
|
87363
|
+
keyId: nonEmptyString(keyOutput?.key_id) ?? stored?.keyId,
|
|
87364
|
+
keyName: nonEmptyString(keyOutput?.name) ?? stored?.keyName,
|
|
87365
|
+
keyPrefix,
|
|
87366
|
+
manifestUrl: endpoint.manifestUrl,
|
|
87367
|
+
registryVisible: registerOutput.registry_visible,
|
|
87368
|
+
runId: registerOutput.run_id,
|
|
87369
|
+
scopes,
|
|
87370
|
+
sessionExpiresAt: registerOutput.expires_at,
|
|
87371
|
+
workspaceId: options.workspaceId ?? organizationIdFromCredentials(credentials)
|
|
87372
|
+
};
|
|
87373
|
+
saveBootstrapMetadata(credentials, agentMcp, deps.saveCredentials);
|
|
87374
|
+
return {
|
|
87375
|
+
agentId: registerOutput.agent_id,
|
|
87376
|
+
apiKeyCreated,
|
|
87377
|
+
endpoint: endpoint.endpoint,
|
|
87378
|
+
keyPrefix,
|
|
87379
|
+
manifestUrl: endpoint.manifestUrl,
|
|
87380
|
+
organizationId: organizationIdFromCredentials(credentials),
|
|
87381
|
+
registryVisible: registerOutput.registry_visible,
|
|
87382
|
+
runId: registerOutput.run_id,
|
|
87383
|
+
scopesGranted: registerOutput.scopes_granted,
|
|
87384
|
+
sessionExpiresAt: registerOutput.expires_at,
|
|
87385
|
+
stored: true
|
|
87386
|
+
};
|
|
87387
|
+
}
|
|
87388
|
+
var DEFAULT_AGENT_MCP_BASE_URL = "https://app.evalops.dev";
|
|
87389
|
+
var AGENT_MCP_MANIFEST_PATH = "/.well-known/evalops/agent-mcp.json";
|
|
87390
|
+
var AGENT_MCP_PATH = "/mcp";
|
|
87391
|
+
var DEFAULT_AGENT_TYPE = "maestro";
|
|
87392
|
+
var DEFAULT_SURFACE2 = "cli";
|
|
87393
|
+
var DEFAULT_REGISTER_SCOPES;
|
|
87394
|
+
var DEFAULT_API_KEY_SCOPES;
|
|
87395
|
+
var init_agent_bootstrap = __esm2(() => {
|
|
87396
|
+
init_oauth();
|
|
87397
|
+
init_storage();
|
|
87398
|
+
init_package_metadata();
|
|
87399
|
+
init_client();
|
|
87400
|
+
DEFAULT_REGISTER_SCOPES = ["llm_gateway:invoke"];
|
|
87401
|
+
DEFAULT_API_KEY_SCOPES = [
|
|
87402
|
+
"agent:register",
|
|
87403
|
+
"agent:heartbeat",
|
|
87404
|
+
"governance:evaluate",
|
|
87405
|
+
"memories:read",
|
|
87406
|
+
"meter:record"
|
|
87407
|
+
];
|
|
87408
|
+
});
|
|
87027
87409
|
function isPlatformMcpExplicitlyDisabled() {
|
|
87028
87410
|
const enabled = getEnvValue3(PLATFORM_MCP_ENABLED_ENV_VARS);
|
|
87029
87411
|
if (!enabled) {
|
|
@@ -87032,15 +87414,16 @@ function isPlatformMcpExplicitlyDisabled() {
|
|
|
87032
87414
|
return PLATFORM_MCP_DISABLED_VALUES.has(enabled.trim().toLowerCase());
|
|
87033
87415
|
}
|
|
87034
87416
|
function buildPlatformMcpHeaders() {
|
|
87035
|
-
const
|
|
87036
|
-
const
|
|
87417
|
+
const stored = getStoredEvalOpsAgentMcpMetadata();
|
|
87418
|
+
const token = getEnvValue3(PLATFORM_MCP_TOKEN_ENV_VARS) ?? stored?.apiKey ?? resolveConfiguredToken(PLATFORM_MCP_TOKEN_ENV_VARS);
|
|
87419
|
+
const workspaceId = resolveWorkspaceId2(PLATFORM_MCP_WORKSPACE_ENV_VARS) ?? stored?.workspaceId;
|
|
87037
87420
|
const headers = Object.fromEntries(Object.entries({
|
|
87038
87421
|
...token ? { Authorization: `Bearer ${token}` } : {},
|
|
87039
87422
|
"Mcp-Session-Id": getEnvValue3(["MAESTRO_SESSION_ID"]),
|
|
87040
87423
|
"X-EvalOps-Workspace-Id": workspaceId,
|
|
87041
87424
|
"X-EvalOps-Session-Id": getEnvValue3(["MAESTRO_SESSION_ID"]),
|
|
87042
|
-
"X-EvalOps-Agent-Id": getEnvValue3(PLATFORM_MCP_AGENT_ID_ENV_VARS),
|
|
87043
|
-
"X-EvalOps-Agent-Run-Id": getEnvValue3(["MAESTRO_AGENT_RUN_ID"]),
|
|
87425
|
+
"X-EvalOps-Agent-Id": getEnvValue3(PLATFORM_MCP_AGENT_ID_ENV_VARS) ?? stored?.agentId,
|
|
87426
|
+
"X-EvalOps-Agent-Run-Id": getEnvValue3(["MAESTRO_AGENT_RUN_ID"]) ?? stored?.runId,
|
|
87044
87427
|
"X-EvalOps-Scopes": getEnvValue3(PLATFORM_MCP_SCOPES_ENV_VARS),
|
|
87045
87428
|
"X-EvalOps-Request-Id": getEnvValue3(["MAESTRO_REQUEST_ID"]),
|
|
87046
87429
|
"X-EvalOps-Trace-Id": getEnvValue3(["TRACE_ID", "OTEL_TRACE_ID"]),
|
|
@@ -87048,11 +87431,28 @@ function buildPlatformMcpHeaders() {
|
|
|
87048
87431
|
}).filter((entry2) => typeof entry2[1] === "string" && entry2[1].trim().length > 0));
|
|
87049
87432
|
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
87050
87433
|
}
|
|
87434
|
+
function normalizePlatformMcpEndpoint(url) {
|
|
87435
|
+
const normalized = normalizeBaseUrl2(url);
|
|
87436
|
+
try {
|
|
87437
|
+
const parsed = new URL(normalized);
|
|
87438
|
+
if (parsed.pathname === "" || parsed.pathname === "/" || parsed.pathname === AGENT_MCP_MANIFEST_PATH2) {
|
|
87439
|
+
parsed.pathname = AGENT_MCP_PATH2;
|
|
87440
|
+
parsed.search = "";
|
|
87441
|
+
parsed.hash = "";
|
|
87442
|
+
return normalizeBaseUrl2(parsed.toString());
|
|
87443
|
+
}
|
|
87444
|
+
} catch {
|
|
87445
|
+
}
|
|
87446
|
+
return normalized;
|
|
87447
|
+
}
|
|
87448
|
+
function resolvePlatformMcpURL() {
|
|
87449
|
+
return getEnvValue3(PLATFORM_MCP_URL_ENV_VARS) ?? getEnvValue3(PLATFORM_MCP_MANIFEST_URL_ENV_VARS) ?? getStoredEvalOpsAgentMcpMetadata()?.endpoint;
|
|
87450
|
+
}
|
|
87051
87451
|
function getPlatformMcpPluginServers() {
|
|
87052
87452
|
if (isPlatformMcpExplicitlyDisabled()) {
|
|
87053
87453
|
return [];
|
|
87054
87454
|
}
|
|
87055
|
-
const url =
|
|
87455
|
+
const url = resolvePlatformMcpURL();
|
|
87056
87456
|
if (!url) {
|
|
87057
87457
|
return [];
|
|
87058
87458
|
}
|
|
@@ -87060,7 +87460,7 @@ function getPlatformMcpPluginServers() {
|
|
|
87060
87460
|
{
|
|
87061
87461
|
name: getEnvValue3(PLATFORM_MCP_NAME_ENV_VARS) ?? DEFAULT_PLATFORM_MCP_SERVER_NAME,
|
|
87062
87462
|
transport: "http",
|
|
87063
|
-
url:
|
|
87463
|
+
url: normalizePlatformMcpEndpoint(url),
|
|
87064
87464
|
headers: buildPlatformMcpHeaders(),
|
|
87065
87465
|
scope: "plugin"
|
|
87066
87466
|
}
|
|
@@ -87070,12 +87470,16 @@ var PLATFORM_MCP_DISABLED_VALUES;
|
|
|
87070
87470
|
var PLATFORM_MCP_ENABLED_ENV_VARS;
|
|
87071
87471
|
var PLATFORM_MCP_NAME_ENV_VARS;
|
|
87072
87472
|
var PLATFORM_MCP_URL_ENV_VARS;
|
|
87473
|
+
var PLATFORM_MCP_MANIFEST_URL_ENV_VARS;
|
|
87073
87474
|
var PLATFORM_MCP_TOKEN_ENV_VARS;
|
|
87074
87475
|
var PLATFORM_MCP_WORKSPACE_ENV_VARS;
|
|
87075
87476
|
var PLATFORM_MCP_AGENT_ID_ENV_VARS;
|
|
87076
87477
|
var PLATFORM_MCP_SCOPES_ENV_VARS;
|
|
87077
87478
|
var DEFAULT_PLATFORM_MCP_SERVER_NAME = "evalops";
|
|
87479
|
+
var AGENT_MCP_MANIFEST_PATH2 = "/.well-known/evalops/agent-mcp.json";
|
|
87480
|
+
var AGENT_MCP_PATH2 = "/mcp";
|
|
87078
87481
|
var init_platform_plugin = __esm2(() => {
|
|
87482
|
+
init_agent_bootstrap();
|
|
87079
87483
|
init_client();
|
|
87080
87484
|
PLATFORM_MCP_DISABLED_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
87081
87485
|
PLATFORM_MCP_ENABLED_ENV_VARS = [
|
|
@@ -87091,6 +87495,11 @@ var init_platform_plugin = __esm2(() => {
|
|
|
87091
87495
|
"MAESTRO_AGENT_MCP_URL",
|
|
87092
87496
|
"MAESTRO_EVALOPS_AGENT_MCP_URL"
|
|
87093
87497
|
];
|
|
87498
|
+
PLATFORM_MCP_MANIFEST_URL_ENV_VARS = [
|
|
87499
|
+
"MAESTRO_PLATFORM_MCP_MANIFEST_URL",
|
|
87500
|
+
"MAESTRO_AGENT_MCP_MANIFEST_URL",
|
|
87501
|
+
"MAESTRO_EVALOPS_AGENT_MCP_MANIFEST_URL"
|
|
87502
|
+
];
|
|
87094
87503
|
PLATFORM_MCP_TOKEN_ENV_VARS = [
|
|
87095
87504
|
"MAESTRO_PLATFORM_MCP_TOKEN",
|
|
87096
87505
|
"MAESTRO_AGENT_MCP_TOKEN",
|
|
@@ -87252,9 +87661,9 @@ function addMcpServerToConfig(options) {
|
|
|
87252
87661
|
throw new Error(`Invalid MCP config at ${path23}: ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
87253
87662
|
}
|
|
87254
87663
|
const nextConfig = structuredClone(parsed.data);
|
|
87255
|
-
const hasObjectFormat =
|
|
87664
|
+
const hasObjectFormat = isRecord10(nextConfig.mcpServers) || !Array.isArray(nextConfig.servers);
|
|
87256
87665
|
if (hasObjectFormat) {
|
|
87257
|
-
const existingServers =
|
|
87666
|
+
const existingServers = isRecord10(nextConfig.mcpServers) ? nextConfig.mcpServers : {};
|
|
87258
87667
|
if (Object.prototype.hasOwnProperty.call(existingServers, validatedServer.name)) {
|
|
87259
87668
|
throw new Error(`MCP server "${validatedServer.name}" already exists in ${path23}`);
|
|
87260
87669
|
}
|
|
@@ -87287,7 +87696,7 @@ function addMcpAuthPresetToConfig(options) {
|
|
|
87287
87696
|
throw new Error(`Invalid MCP config at ${path23}: ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
87288
87697
|
}
|
|
87289
87698
|
const nextConfig = structuredClone(parsed.data);
|
|
87290
|
-
const existingPresets =
|
|
87699
|
+
const existingPresets = isRecord10(nextConfig.authPresets) ? nextConfig.authPresets : {};
|
|
87291
87700
|
if (Object.prototype.hasOwnProperty.call(existingPresets, validatedPreset.name)) {
|
|
87292
87701
|
throw new Error(`MCP auth preset "${validatedPreset.name}" already exists in ${path23}`);
|
|
87293
87702
|
}
|
|
@@ -87388,7 +87797,7 @@ function parseConfigFile2(path23, scope) {
|
|
|
87388
87797
|
}
|
|
87389
87798
|
if (parsed.data.mcpServers) {
|
|
87390
87799
|
for (const [name, raw] of Object.entries(parsed.data.mcpServers)) {
|
|
87391
|
-
const merged =
|
|
87800
|
+
const merged = isRecord10(raw) ? { ...raw, name } : { name };
|
|
87392
87801
|
const normalized = normalizeServer(merged, name, scope);
|
|
87393
87802
|
if (normalized)
|
|
87394
87803
|
servers.push(normalized);
|
|
@@ -87396,7 +87805,7 @@ function parseConfigFile2(path23, scope) {
|
|
|
87396
87805
|
}
|
|
87397
87806
|
if (parsed.data.authPresets) {
|
|
87398
87807
|
for (const [name, raw] of Object.entries(parsed.data.authPresets)) {
|
|
87399
|
-
const merged =
|
|
87808
|
+
const merged = isRecord10(raw) ? { ...raw, name } : { name };
|
|
87400
87809
|
const normalized = normalizeAuthPreset(merged, name, scope);
|
|
87401
87810
|
if (normalized)
|
|
87402
87811
|
authPresets.push(normalized);
|
|
@@ -87449,7 +87858,7 @@ function resolveWritableAuthPresetMutationScope(name, scope, projectRoot) {
|
|
|
87449
87858
|
return activePreset.scope;
|
|
87450
87859
|
}
|
|
87451
87860
|
function mutateWritableMcpConfig(config2, name, mode, options) {
|
|
87452
|
-
if (
|
|
87861
|
+
if (isRecord10(config2.mcpServers) && Object.prototype.hasOwnProperty.call(config2.mcpServers, name)) {
|
|
87453
87862
|
if (mode === "remove") {
|
|
87454
87863
|
delete config2.mcpServers[name];
|
|
87455
87864
|
} else {
|
|
@@ -87474,7 +87883,7 @@ function mutateWritableMcpConfig(config2, name, mode, options) {
|
|
|
87474
87883
|
return false;
|
|
87475
87884
|
}
|
|
87476
87885
|
function mutateWritableMcpAuthPresetConfig(config2, name, mode, options) {
|
|
87477
|
-
if (
|
|
87886
|
+
if (isRecord10(config2.authPresets) && Object.prototype.hasOwnProperty.call(config2.authPresets, name)) {
|
|
87478
87887
|
if (mode === "remove") {
|
|
87479
87888
|
delete config2.authPresets[name];
|
|
87480
87889
|
} else {
|
|
@@ -87580,7 +87989,7 @@ function buildPersistedAuthPresetConfig(preset) {
|
|
|
87580
87989
|
headersHelper: preset.headersHelper
|
|
87581
87990
|
};
|
|
87582
87991
|
}
|
|
87583
|
-
function
|
|
87992
|
+
function isRecord10(value) {
|
|
87584
87993
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
87585
87994
|
}
|
|
87586
87995
|
function isWritableScope(value) {
|
|
@@ -87672,7 +88081,7 @@ var init_config3 = __esm2(() => {
|
|
|
87672
88081
|
init_schema();
|
|
87673
88082
|
logger97 = createLogger("mcp:config");
|
|
87674
88083
|
});
|
|
87675
|
-
function
|
|
88084
|
+
function isRecord11(value) {
|
|
87676
88085
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
87677
88086
|
}
|
|
87678
88087
|
function collectConcreteUrls(entry2) {
|
|
@@ -87757,11 +88166,11 @@ function buildCacheFromResponse(data) {
|
|
|
87757
88166
|
entries: [],
|
|
87758
88167
|
status: "ready"
|
|
87759
88168
|
};
|
|
87760
|
-
if (!
|
|
88169
|
+
if (!isRecord11(data) || !Array.isArray(data.servers)) {
|
|
87761
88170
|
return next;
|
|
87762
88171
|
}
|
|
87763
88172
|
for (const entry2 of data.servers) {
|
|
87764
|
-
if (!
|
|
88173
|
+
if (!isRecord11(entry2))
|
|
87765
88174
|
continue;
|
|
87766
88175
|
const typedEntry = entry2;
|
|
87767
88176
|
const info = buildRegistryInfo(typedEntry);
|
|
@@ -88410,7 +88819,7 @@ var init_manager2 = __esm2(() => {
|
|
|
88410
88819
|
const requestInit = await buildRemoteRequestInit(config2, buildAuthPresetMap(this.config.authPresets));
|
|
88411
88820
|
const transportOptions = requestInit ? { requestInit } : void 0;
|
|
88412
88821
|
if (transportType === "http") {
|
|
88413
|
-
transport = new
|
|
88822
|
+
transport = new StreamableHTTPClientTransport2(new URL(config2.url), transportOptions);
|
|
88414
88823
|
} else {
|
|
88415
88824
|
transport = new SSEClientTransport(new URL(config2.url), transportOptions);
|
|
88416
88825
|
}
|
|
@@ -88426,7 +88835,7 @@ var init_manager2 = __esm2(() => {
|
|
|
88426
88835
|
cwd: config2.cwd
|
|
88427
88836
|
});
|
|
88428
88837
|
}
|
|
88429
|
-
const client = new
|
|
88838
|
+
const client = new Client2({
|
|
88430
88839
|
name: "composer",
|
|
88431
88840
|
version: "1.0.0"
|
|
88432
88841
|
}, {
|
|
@@ -90876,11 +91285,11 @@ function collapseRepeatedLinesWithHistory(text2, options = {}) {
|
|
|
90876
91285
|
return { text: result.join(`
|
|
90877
91286
|
`), changed };
|
|
90878
91287
|
}
|
|
90879
|
-
function
|
|
91288
|
+
function isRecord12(value) {
|
|
90880
91289
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
90881
91290
|
}
|
|
90882
91291
|
function isAssistantContentBlock(value) {
|
|
90883
|
-
if (!
|
|
91292
|
+
if (!isRecord12(value)) {
|
|
90884
91293
|
return false;
|
|
90885
91294
|
}
|
|
90886
91295
|
switch (value.type) {
|
|
@@ -90889,7 +91298,7 @@ function isAssistantContentBlock(value) {
|
|
|
90889
91298
|
case "thinking":
|
|
90890
91299
|
return typeof value.thinking === "string";
|
|
90891
91300
|
case "toolCall":
|
|
90892
|
-
return typeof value.id === "string" && typeof value.name === "string" &&
|
|
91301
|
+
return typeof value.id === "string" && typeof value.name === "string" && isRecord12(value.arguments);
|
|
90893
91302
|
default:
|
|
90894
91303
|
return false;
|
|
90895
91304
|
}
|
|
@@ -90904,7 +91313,7 @@ function normalizeAssistantContent(content) {
|
|
|
90904
91313
|
return content.filter(isAssistantContentBlock);
|
|
90905
91314
|
}
|
|
90906
91315
|
function isToolResultContentBlock(value) {
|
|
90907
|
-
if (!
|
|
91316
|
+
if (!isRecord12(value)) {
|
|
90908
91317
|
return false;
|
|
90909
91318
|
}
|
|
90910
91319
|
if (value.type === "text") {
|
|
@@ -101841,7 +102250,7 @@ var init_export_html = __esm2(() => {
|
|
|
101841
102250
|
init_context_firewall();
|
|
101842
102251
|
init_types3();
|
|
101843
102252
|
init_path_expansion();
|
|
101844
|
-
packageJson =
|
|
102253
|
+
packageJson = createRequire5(import.meta.url)("../package.json");
|
|
101845
102254
|
VERSION2 = packageJson.version ?? "unknown";
|
|
101846
102255
|
});
|
|
101847
102256
|
function loadFactoryConfigOrThrow() {
|
|
@@ -102661,8 +103070,8 @@ function resolveOllamaUrl(path23) {
|
|
|
102661
103070
|
}
|
|
102662
103071
|
return url;
|
|
102663
103072
|
}
|
|
102664
|
-
function isLoopbackHost(
|
|
102665
|
-
return
|
|
103073
|
+
function isLoopbackHost(hostname2) {
|
|
103074
|
+
return hostname2 === "localhost" || hostname2 === "127.0.0.1" || hostname2 === "::1" || hostname2.startsWith("127.");
|
|
102666
103075
|
}
|
|
102667
103076
|
var OllamaView;
|
|
102668
103077
|
var init_ollama_view = __esm2(() => {
|
|
@@ -106210,32 +106619,6 @@ var SlashCycleState = class {
|
|
|
106210
106619
|
};
|
|
106211
106620
|
var init_slash = () => {
|
|
106212
106621
|
};
|
|
106213
|
-
function loadPackageMetadata() {
|
|
106214
|
-
if (cachedPackageMetadata) {
|
|
106215
|
-
return cachedPackageMetadata;
|
|
106216
|
-
}
|
|
106217
|
-
try {
|
|
106218
|
-
const packageJson22 = createRequire5(import.meta.url)("../package.json");
|
|
106219
|
-
cachedPackageMetadata = packageJson22;
|
|
106220
|
-
return packageJson22;
|
|
106221
|
-
} catch {
|
|
106222
|
-
cachedPackageMetadata = {};
|
|
106223
|
-
return cachedPackageMetadata;
|
|
106224
|
-
}
|
|
106225
|
-
}
|
|
106226
|
-
function getPackageVersion() {
|
|
106227
|
-
return process.env.MAESTRO_VERSION ?? loadPackageMetadata().version ?? "unknown";
|
|
106228
|
-
}
|
|
106229
|
-
function getPackageName() {
|
|
106230
|
-
const metadata = loadPackageMetadata();
|
|
106231
|
-
return process.env.MAESTRO_PACKAGE_NAME ?? metadata.name ?? metadata.maestro?.canonicalPackageName ?? "@evalops/maestro";
|
|
106232
|
-
}
|
|
106233
|
-
function getGlobalInstallCommand(packageManager = "npm", packageName = getPackageName()) {
|
|
106234
|
-
return `${packageManager} install -g ${packageName}`;
|
|
106235
|
-
}
|
|
106236
|
-
var cachedPackageMetadata = null;
|
|
106237
|
-
var init_package_metadata = () => {
|
|
106238
|
-
};
|
|
106239
106622
|
function formatLink(url, label) {
|
|
106240
106623
|
const text2 = label ?? url;
|
|
106241
106624
|
if (!process.stdout.isTTY)
|
|
@@ -122572,7 +122955,7 @@ Reply with option numbers (e.g., '1' or '1, 3' for multi-select), option labels,
|
|
|
122572
122955
|
}
|
|
122573
122956
|
});
|
|
122574
122957
|
});
|
|
122575
|
-
function
|
|
122958
|
+
function isRecord13(value) {
|
|
122576
122959
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
122577
122960
|
}
|
|
122578
122961
|
function getOptionalNumber(record, key) {
|
|
@@ -122590,7 +122973,7 @@ function normalizeOptionEntries(values, labels) {
|
|
|
122590
122973
|
}));
|
|
122591
122974
|
}
|
|
122592
122975
|
function parseFieldDefinition(key, value) {
|
|
122593
|
-
if (!
|
|
122976
|
+
if (!isRecord13(value) || typeof value.type !== "string") {
|
|
122594
122977
|
return null;
|
|
122595
122978
|
}
|
|
122596
122979
|
const label = getOptionalString(value, "title") ?? key;
|
|
@@ -122616,7 +122999,7 @@ function parseFieldDefinition(key, value) {
|
|
|
122616
122999
|
options: normalizeOptionEntries(value.enum, enumNames)
|
|
122617
123000
|
};
|
|
122618
123001
|
}
|
|
122619
|
-
if (Array.isArray(value.oneOf) && value.oneOf.every((entry2) =>
|
|
123002
|
+
if (Array.isArray(value.oneOf) && value.oneOf.every((entry2) => isRecord13(entry2) && typeof entry2.const === "string" && typeof entry2.title === "string")) {
|
|
122620
123003
|
return {
|
|
122621
123004
|
key,
|
|
122622
123005
|
kind: "select",
|
|
@@ -122652,7 +123035,7 @@ function parseFieldDefinition(key, value) {
|
|
|
122652
123035
|
minimum: getOptionalNumber(value, "minimum")
|
|
122653
123036
|
};
|
|
122654
123037
|
}
|
|
122655
|
-
if (value.type === "array" &&
|
|
123038
|
+
if (value.type === "array" && isRecord13(value.items)) {
|
|
122656
123039
|
if (Array.isArray(value.items.enum) && value.items.enum.every((entry2) => typeof entry2 === "string")) {
|
|
122657
123040
|
return {
|
|
122658
123041
|
key,
|
|
@@ -122665,7 +123048,7 @@ function parseFieldDefinition(key, value) {
|
|
|
122665
123048
|
options: normalizeOptionEntries(value.items.enum)
|
|
122666
123049
|
};
|
|
122667
123050
|
}
|
|
122668
|
-
if (Array.isArray(value.items.anyOf) && value.items.anyOf.every((entry2) =>
|
|
123051
|
+
if (Array.isArray(value.items.anyOf) && value.items.anyOf.every((entry2) => isRecord13(entry2) && typeof entry2.const === "string" && typeof entry2.title === "string")) {
|
|
122669
123052
|
return {
|
|
122670
123053
|
key,
|
|
122671
123054
|
kind: "multi-select",
|
|
@@ -122684,7 +123067,7 @@ function parseFieldDefinition(key, value) {
|
|
|
122684
123067
|
return null;
|
|
122685
123068
|
}
|
|
122686
123069
|
function parseMcpElicitationRequest(args) {
|
|
122687
|
-
if (!
|
|
123070
|
+
if (!isRecord13(args)) {
|
|
122688
123071
|
return {
|
|
122689
123072
|
kind: "malformed",
|
|
122690
123073
|
message: "MCP server requested additional input.",
|
|
@@ -122722,7 +123105,7 @@ function parseMcpElicitationRequest(args) {
|
|
|
122722
123105
|
};
|
|
122723
123106
|
}
|
|
122724
123107
|
const requestedSchema = args.requestedSchema;
|
|
122725
|
-
if (!
|
|
123108
|
+
if (!isRecord13(requestedSchema)) {
|
|
122726
123109
|
return {
|
|
122727
123110
|
kind: "malformed",
|
|
122728
123111
|
message,
|
|
@@ -122731,7 +123114,7 @@ function parseMcpElicitationRequest(args) {
|
|
|
122731
123114
|
error: "Missing requested schema for form elicitation."
|
|
122732
123115
|
};
|
|
122733
123116
|
}
|
|
122734
|
-
if (requestedSchema.type !== "object" || !
|
|
123117
|
+
if (requestedSchema.type !== "object" || !isRecord13(requestedSchema.properties)) {
|
|
122735
123118
|
return {
|
|
122736
123119
|
kind: "malformed",
|
|
122737
123120
|
message,
|
|
@@ -132015,7 +132398,7 @@ function parseArgs(args) {
|
|
|
132015
132398
|
result.subcommand = nextArg;
|
|
132016
132399
|
i2++;
|
|
132017
132400
|
}
|
|
132018
|
-
if (arg === "remote" || arg === "hosted-runner") {
|
|
132401
|
+
if (arg === "remote" || arg === "hosted-runner" || arg === "init") {
|
|
132019
132402
|
result.commandArgs = args.slice(i2 + 1);
|
|
132020
132403
|
break;
|
|
132021
132404
|
}
|
|
@@ -132038,6 +132421,7 @@ var init_args = __esm2(() => {
|
|
|
132038
132421
|
"exec",
|
|
132039
132422
|
"web",
|
|
132040
132423
|
"hosted-runner",
|
|
132424
|
+
"init",
|
|
132041
132425
|
"anthropic",
|
|
132042
132426
|
"evalops",
|
|
132043
132427
|
"openai",
|
|
@@ -135766,7 +136150,10 @@ function printHelp(version3) {
|
|
|
135766
136150
|
# Use Codex subscription models after \`maestro codex login\`
|
|
135767
136151
|
maestro --provider openai-codex --model gpt-5.5 "Plan this migration"
|
|
135768
136152
|
|
|
135769
|
-
#
|
|
136153
|
+
# Bootstrap EvalOps login, API key, and agent registration in one flow
|
|
136154
|
+
maestro init
|
|
136155
|
+
|
|
136156
|
+
# Use EvalOps managed gateway models after \`maestro init\`
|
|
135770
136157
|
maestro --provider evalops --model gpt-4o-mini "Say hello in one sentence"
|
|
135771
136158
|
|
|
135772
136159
|
# Export a portable session log
|
|
@@ -135845,6 +136232,10 @@ function printHelp(version3) {
|
|
|
135845
136232
|
maestro remote attach <session-id> [--verify] [--print-env]
|
|
135846
136233
|
maestro remote extend <session-id> --ttl 2h
|
|
135847
136234
|
maestro remote stop <session-id> [--reason <text>]`)}`;
|
|
136235
|
+
const initSection = `${sectionHeading("maestro init")}${muted(` maestro init Login, create or reuse an API key, and register this agent
|
|
136236
|
+
maestro init --rotate-key Replace the stored agent MCP API key
|
|
136237
|
+
maestro init --mcp-url <url> Override the EvalOps agent MCP endpoint
|
|
136238
|
+
maestro init --json Emit machine-readable bootstrap output`)}`;
|
|
135848
136239
|
const hostedRunnerSection = `${sectionHeading("maestro hosted-runner")}${muted(` maestro hosted-runner --runner-session-id <id> --workspace-root <path> [--listen 0.0.0.0:8080]
|
|
135849
136240
|
|
|
135850
136241
|
Env mode:
|
|
@@ -135882,6 +136273,7 @@ function printHelp(version3) {
|
|
|
135882
136273
|
webSection,
|
|
135883
136274
|
portabilitySection,
|
|
135884
136275
|
memorySection,
|
|
136276
|
+
initSection,
|
|
135885
136277
|
remoteSection,
|
|
135886
136278
|
hostedRunnerSection,
|
|
135887
136279
|
sessionsSection,
|
|
@@ -140814,7 +141206,7 @@ var init_hosted_runner_drain = __esm2(() => {
|
|
|
140814
141206
|
init_server_utils();
|
|
140815
141207
|
execFileAsync2 = promisify5(execFile4);
|
|
140816
141208
|
});
|
|
140817
|
-
function
|
|
141209
|
+
function isRecord14(value) {
|
|
140818
141210
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
140819
141211
|
}
|
|
140820
141212
|
function cleanRequiredString(value, label) {
|
|
@@ -140856,7 +141248,7 @@ function cleanOptionalPositiveInteger(value, label) {
|
|
|
140856
141248
|
return Math.floor(value);
|
|
140857
141249
|
}
|
|
140858
141250
|
function normalizeModelPreferences(value) {
|
|
140859
|
-
const input =
|
|
141251
|
+
const input = isRecord14(value) ? value : {};
|
|
140860
141252
|
const defaultModel = cleanOptionalString(input.defaultModel);
|
|
140861
141253
|
const preferredProvider = cleanOptionalString(input.preferredProvider);
|
|
140862
141254
|
return {
|
|
@@ -140867,7 +141259,7 @@ function normalizeModelPreferences(value) {
|
|
|
140867
141259
|
};
|
|
140868
141260
|
}
|
|
140869
141261
|
function normalizeSafetyRules(value) {
|
|
140870
|
-
const input =
|
|
141262
|
+
const input = isRecord14(value) ? value : {};
|
|
140871
141263
|
const requireApprovals = cleanOptionalBoolean(input.requireApprovals);
|
|
140872
141264
|
const maxTokensPerSession = cleanOptionalPositiveInteger(input.maxTokensPerSession, "safetyRules.maxTokensPerSession");
|
|
140873
141265
|
return {
|
|
@@ -140880,7 +141272,7 @@ function normalizeSafetyRules(value) {
|
|
|
140880
141272
|
};
|
|
140881
141273
|
}
|
|
140882
141274
|
function normalizeRateLimits(value) {
|
|
140883
|
-
const input =
|
|
141275
|
+
const input = isRecord14(value) ? value : {};
|
|
140884
141276
|
const requestsPerMinute = cleanOptionalPositiveInteger(input.requestsPerMinute, "rateLimits.requestsPerMinute");
|
|
140885
141277
|
const tokensPerMinute = cleanOptionalPositiveInteger(input.tokensPerMinute, "rateLimits.tokensPerMinute");
|
|
140886
141278
|
const maxConcurrentSessions = cleanOptionalPositiveInteger(input.maxConcurrentSessions, "rateLimits.maxConcurrentSessions");
|
|
@@ -140893,7 +141285,7 @@ function normalizeRateLimits(value) {
|
|
|
140893
141285
|
};
|
|
140894
141286
|
}
|
|
140895
141287
|
function normalizeWorkspaceConfigInput(input, now2 = /* @__PURE__ */ new Date()) {
|
|
140896
|
-
if (!
|
|
141288
|
+
if (!isRecord14(input)) {
|
|
140897
141289
|
throw new WorkspaceConfigValidationError("Workspace config must be an object.");
|
|
140898
141290
|
}
|
|
140899
141291
|
return {
|
|
@@ -140906,22 +141298,22 @@ function normalizeWorkspaceConfigInput(input, now2 = /* @__PURE__ */ new Date())
|
|
|
140906
141298
|
};
|
|
140907
141299
|
}
|
|
140908
141300
|
function normalizeWorkspaceConfigPatchInput(workspaceId, input, existing, now2 = /* @__PURE__ */ new Date()) {
|
|
140909
|
-
if (!
|
|
141301
|
+
if (!isRecord14(input)) {
|
|
140910
141302
|
throw new WorkspaceConfigValidationError("Workspace config must be an object.");
|
|
140911
141303
|
}
|
|
140912
141304
|
return {
|
|
140913
141305
|
workspaceId: cleanRequiredString(workspaceId, "workspaceId"),
|
|
140914
141306
|
modelPreferences: normalizeModelPreferences({
|
|
140915
141307
|
...existing?.modelPreferences ?? {},
|
|
140916
|
-
...
|
|
141308
|
+
...isRecord14(input.modelPreferences) ? input.modelPreferences : {}
|
|
140917
141309
|
}),
|
|
140918
141310
|
safetyRules: normalizeSafetyRules({
|
|
140919
141311
|
...existing?.safetyRules ?? {},
|
|
140920
|
-
...
|
|
141312
|
+
...isRecord14(input.safetyRules) ? input.safetyRules : {}
|
|
140921
141313
|
}),
|
|
140922
141314
|
rateLimits: normalizeRateLimits({
|
|
140923
141315
|
...existing?.rateLimits ?? {},
|
|
140924
|
-
...
|
|
141316
|
+
...isRecord14(input.rateLimits) ? input.rateLimits : {}
|
|
140925
141317
|
}),
|
|
140926
141318
|
createdAt: existing?.createdAt ?? now2.toISOString(),
|
|
140927
141319
|
updatedAt: now2.toISOString()
|
|
@@ -149944,7 +150336,7 @@ function safeStringify2(value) {
|
|
|
149944
150336
|
return "[unserializable]";
|
|
149945
150337
|
}
|
|
149946
150338
|
}
|
|
149947
|
-
function
|
|
150339
|
+
function isRecord15(value) {
|
|
149948
150340
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
149949
150341
|
}
|
|
149950
150342
|
function toComposerAttachments(attachments, options) {
|
|
@@ -150187,7 +150579,7 @@ function convertAppMessagesToComposer(messages, options) {
|
|
|
150187
150579
|
function normalizeToolCall(tool, messageIndex, contentIndex) {
|
|
150188
150580
|
const name = tool.name?.trim() || `tool_${messageIndex}_${contentIndex}`;
|
|
150189
150581
|
const toolCallId = tool.toolCallId || `web-tool-${messageIndex}-${contentIndex}`;
|
|
150190
|
-
const args =
|
|
150582
|
+
const args = isRecord15(tool.args) ? tool.args : {};
|
|
150191
150583
|
return {
|
|
150192
150584
|
type: "toolCall",
|
|
150193
150585
|
id: toolCallId,
|
|
@@ -151221,7 +151613,7 @@ var init_chat_ws = __esm2(() => {
|
|
|
151221
151613
|
init_validation3();
|
|
151222
151614
|
logger158 = createLogger("web:chat-ws");
|
|
151223
151615
|
});
|
|
151224
|
-
function
|
|
151616
|
+
function isRecord16(value) {
|
|
151225
151617
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
151226
151618
|
}
|
|
151227
151619
|
function canWrite(ws) {
|
|
@@ -151243,7 +151635,7 @@ function toErrorResponse(id, code, message) {
|
|
|
151243
151635
|
};
|
|
151244
151636
|
}
|
|
151245
151637
|
function parseClientRequest(raw) {
|
|
151246
|
-
if (!
|
|
151638
|
+
if (!isRecord16(raw)) {
|
|
151247
151639
|
throw new Error("Runtime app-server request must be an object");
|
|
151248
151640
|
}
|
|
151249
151641
|
if (raw.jsonrpc !== "2.0") {
|
|
@@ -151374,7 +151766,7 @@ function handleRuntimeAppServerWebSocket(ws, options = {}) {
|
|
|
151374
151766
|
}
|
|
151375
151767
|
const request = parseClientRequest(parsed);
|
|
151376
151768
|
if (request.method === "runtime.initialize") {
|
|
151377
|
-
const requestedSessionId =
|
|
151769
|
+
const requestedSessionId = isRecord16(request.params) ? request.params.sessionId : void 0;
|
|
151378
151770
|
await bindSessionId(requestedSessionId);
|
|
151379
151771
|
const result = initializeResult();
|
|
151380
151772
|
send2(ws, { jsonrpc: "2.0", id: request.id, result });
|
|
@@ -151397,7 +151789,7 @@ function handleRuntimeAppServerWebSocket(ws, options = {}) {
|
|
|
151397
151789
|
}
|
|
151398
151790
|
send2(ws, { jsonrpc: "2.0", id: request.id, result: { ok: true } });
|
|
151399
151791
|
} catch (error) {
|
|
151400
|
-
const id =
|
|
151792
|
+
const id = isRecord16(parsed) && (typeof parsed.id === "string" || typeof parsed.id === "number") ? parsed.id : null;
|
|
151401
151793
|
send2(ws, toErrorResponse(id, error instanceof Error && error.message === "Unsupported runtime app-server method" ? -32601 : -32600, error instanceof Error ? error.message : "Invalid request"));
|
|
151402
151794
|
}
|
|
151403
151795
|
});
|
|
@@ -151409,11 +151801,11 @@ var init_runtime_app_server_ws = __esm2(() => {
|
|
|
151409
151801
|
init_registry();
|
|
151410
151802
|
init_server_request_manager();
|
|
151411
151803
|
});
|
|
151412
|
-
function
|
|
151804
|
+
function isRecord17(value) {
|
|
151413
151805
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
151414
151806
|
}
|
|
151415
151807
|
function getToolRetryPayload(args) {
|
|
151416
|
-
return
|
|
151808
|
+
return isRecord17(args) ? args : {};
|
|
151417
151809
|
}
|
|
151418
151810
|
function pendingRequestArgs(entry2) {
|
|
151419
151811
|
if (entry2.kind !== "tool_retry") {
|
|
@@ -156456,7 +156848,7 @@ var init_types6 = __esm2(() => {
|
|
|
156456
156848
|
];
|
|
156457
156849
|
TRACE_SPAN_STATUSES = ["unset", "ok", "error"];
|
|
156458
156850
|
});
|
|
156459
|
-
function
|
|
156851
|
+
function isRecord18(value) {
|
|
156460
156852
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
156461
156853
|
}
|
|
156462
156854
|
function cleanRequiredString3(value, label) {
|
|
@@ -156547,7 +156939,7 @@ function sanitizeJsonValue(value, depth = 0) {
|
|
|
156547
156939
|
if (Array.isArray(value)) {
|
|
156548
156940
|
return value.map((item) => sanitizeJsonValue(item, depth + 1)).filter((item) => item !== void 0);
|
|
156549
156941
|
}
|
|
156550
|
-
if (
|
|
156942
|
+
if (isRecord18(value)) {
|
|
156551
156943
|
const result = {};
|
|
156552
156944
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
156553
156945
|
const sanitized = sanitizeJsonValue(nestedValue, depth + 1);
|
|
@@ -156578,7 +156970,7 @@ function inferDurationMs(startTime, endTime) {
|
|
|
156578
156970
|
return duration >= 0 ? duration : void 0;
|
|
156579
156971
|
}
|
|
156580
156972
|
function normalizeSpan(input, parentSpanId) {
|
|
156581
|
-
if (!
|
|
156973
|
+
if (!isRecord18(input)) {
|
|
156582
156974
|
throw new TracesValidationError("Each span must be an object.");
|
|
156583
156975
|
}
|
|
156584
156976
|
const error = cleanOptionalString3(input.error);
|
|
@@ -156642,7 +157034,7 @@ function countTraceSpans(spans) {
|
|
|
156642
157034
|
return count2;
|
|
156643
157035
|
}
|
|
156644
157036
|
function normalizeExecutionTraceInput(input) {
|
|
156645
|
-
if (!
|
|
157037
|
+
if (!isRecord18(input)) {
|
|
156646
157038
|
throw new TracesValidationError("Trace payload must be an object.");
|
|
156647
157039
|
}
|
|
156648
157040
|
if (!Array.isArray(input.spans)) {
|
|
@@ -157187,7 +157579,7 @@ var COMPLIANCE_FRAMEWORKS;
|
|
|
157187
157579
|
var init_types7 = __esm2(() => {
|
|
157188
157580
|
COMPLIANCE_FRAMEWORKS = ["soc2", "iso27001"];
|
|
157189
157581
|
});
|
|
157190
|
-
function
|
|
157582
|
+
function isRecord19(value) {
|
|
157191
157583
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
157192
157584
|
}
|
|
157193
157585
|
function cleanOptionalString4(value) {
|
|
@@ -157245,7 +157637,7 @@ function sanitizeJsonValue2(value, depth = 0) {
|
|
|
157245
157637
|
if (Array.isArray(value)) {
|
|
157246
157638
|
return value.map((item) => sanitizeJsonValue2(item, depth + 1)).filter((item) => item !== void 0);
|
|
157247
157639
|
}
|
|
157248
|
-
if (
|
|
157640
|
+
if (isRecord19(value)) {
|
|
157249
157641
|
const result = {};
|
|
157250
157642
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
157251
157643
|
const sanitized = sanitizeJsonValue2(nestedValue, depth + 1);
|
|
@@ -157261,7 +157653,7 @@ function sanitizeMetadata(value) {
|
|
|
157261
157653
|
if (!value)
|
|
157262
157654
|
return {};
|
|
157263
157655
|
const sanitized = sanitizeJsonValue2(value);
|
|
157264
|
-
return
|
|
157656
|
+
return isRecord19(sanitized) ? sanitized : {};
|
|
157265
157657
|
}
|
|
157266
157658
|
function stableActionId(input, timestamp3) {
|
|
157267
157659
|
const explicit = cleanOptionalString4(input.actionId);
|
|
@@ -157291,7 +157683,7 @@ function stableGovernanceEvaluationId(input, timestamp3) {
|
|
|
157291
157683
|
return `governance_${digest || randomUUID14()}`;
|
|
157292
157684
|
}
|
|
157293
157685
|
function normalizeAgentActionInput(input) {
|
|
157294
|
-
if (!
|
|
157686
|
+
if (!isRecord19(input)) {
|
|
157295
157687
|
throw new ComplianceValidationError("Agent action must be an object.");
|
|
157296
157688
|
}
|
|
157297
157689
|
const timestamp3 = parseDate2(input.timestamp, "action.timestamp") ?? /* @__PURE__ */ new Date();
|
|
@@ -157313,7 +157705,7 @@ function normalizeAgentActionInput(input) {
|
|
|
157313
157705
|
};
|
|
157314
157706
|
}
|
|
157315
157707
|
function normalizeGovernanceEvaluationInput(input) {
|
|
157316
|
-
if (!
|
|
157708
|
+
if (!isRecord19(input)) {
|
|
157317
157709
|
throw new ComplianceValidationError("Governance evaluation must be an object.");
|
|
157318
157710
|
}
|
|
157319
157711
|
const timestamp3 = parseDate2(input.timestamp, "governanceEvents[].timestamp") ?? /* @__PURE__ */ new Date();
|
|
@@ -157338,7 +157730,7 @@ function normalizeGovernanceEvaluationInput(input) {
|
|
|
157338
157730
|
};
|
|
157339
157731
|
}
|
|
157340
157732
|
function normalizeComplianceReportRequest(input) {
|
|
157341
|
-
if (!
|
|
157733
|
+
if (!isRecord19(input)) {
|
|
157342
157734
|
throw new ComplianceValidationError("Report request must be an object.");
|
|
157343
157735
|
}
|
|
157344
157736
|
const reportInput = input;
|
|
@@ -157877,7 +158269,7 @@ var init_types8 = __esm2(() => {
|
|
|
157877
158269
|
"latency"
|
|
157878
158270
|
];
|
|
157879
158271
|
});
|
|
157880
|
-
function
|
|
158272
|
+
function isRecord20(value) {
|
|
157881
158273
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
157882
158274
|
}
|
|
157883
158275
|
function cleanOptionalString5(value) {
|
|
@@ -157949,13 +158341,13 @@ function normalizeAvailableModels(value) {
|
|
|
157949
158341
|
if (!Array.isArray(value)) {
|
|
157950
158342
|
throw new IntelligentRouterValidationError("availableModels must be an array.");
|
|
157951
158343
|
}
|
|
157952
|
-
return value.filter(
|
|
158344
|
+
return value.filter(isRecord20).map((entry2) => {
|
|
157953
158345
|
const provider = cleanRequiredString5(entry2.provider, "provider");
|
|
157954
158346
|
const model = cleanRequiredString5(entry2.model, "model");
|
|
157955
158347
|
const name = cleanOptionalString5(entry2.name);
|
|
157956
158348
|
const available = typeof entry2.available === "boolean" ? entry2.available : void 0;
|
|
157957
158349
|
const cost = (() => {
|
|
157958
|
-
if (!
|
|
158350
|
+
if (!isRecord20(entry2.cost))
|
|
157959
158351
|
return;
|
|
157960
158352
|
const input = parseFiniteNumber(entry2.cost.input, "cost.input");
|
|
157961
158353
|
const output = parseFiniteNumber(entry2.cost.output, "cost.output");
|
|
@@ -157978,7 +158370,7 @@ function normalizeAvailableModels(value) {
|
|
|
157978
158370
|
});
|
|
157979
158371
|
}
|
|
157980
158372
|
function normalizeRoutingRequest(input, defaultAvailableModels) {
|
|
157981
|
-
if (!
|
|
158373
|
+
if (!isRecord20(input)) {
|
|
157982
158374
|
throw new IntelligentRouterValidationError("Routing request must be an object.");
|
|
157983
158375
|
}
|
|
157984
158376
|
const requestInput = input;
|
|
@@ -157995,7 +158387,7 @@ function normalizeRoutingRequest(input, defaultAvailableModels) {
|
|
|
157995
158387
|
};
|
|
157996
158388
|
}
|
|
157997
158389
|
function normalizePerformanceMetricInput(input) {
|
|
157998
|
-
if (!
|
|
158390
|
+
if (!isRecord20(input)) {
|
|
157999
158391
|
throw new IntelligentRouterValidationError("Metric must be an object.");
|
|
158000
158392
|
}
|
|
158001
158393
|
const metricInput = input;
|
|
@@ -158020,7 +158412,7 @@ function normalizePerformanceMetricInput(input) {
|
|
|
158020
158412
|
};
|
|
158021
158413
|
}
|
|
158022
158414
|
function normalizeRoutingOverrideInput(input) {
|
|
158023
|
-
if (!
|
|
158415
|
+
if (!isRecord20(input)) {
|
|
158024
158416
|
throw new IntelligentRouterValidationError("Override must be an object.");
|
|
158025
158417
|
}
|
|
158026
158418
|
const overrideInput = input;
|
|
@@ -163627,7 +164019,7 @@ var init_types9 = __esm2(() => {
|
|
|
163627
164019
|
"custom"
|
|
163628
164020
|
];
|
|
163629
164021
|
});
|
|
163630
|
-
function
|
|
164022
|
+
function isRecord21(value) {
|
|
163631
164023
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
163632
164024
|
}
|
|
163633
164025
|
function cleanOptionalString6(value) {
|
|
@@ -163711,7 +164103,7 @@ function sanitizeJsonValue3(value, depth = 0) {
|
|
|
163711
164103
|
if (Array.isArray(value)) {
|
|
163712
164104
|
return value.map((item) => sanitizeJsonValue3(item, depth + 1)).filter((item) => item !== void 0);
|
|
163713
164105
|
}
|
|
163714
|
-
if (
|
|
164106
|
+
if (isRecord21(value)) {
|
|
163715
164107
|
const result = {};
|
|
163716
164108
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
163717
164109
|
const sanitized = sanitizeJsonValue3(nestedValue, depth + 1);
|
|
@@ -163727,10 +164119,10 @@ function sanitizeMetadata2(value) {
|
|
|
163727
164119
|
if (!value)
|
|
163728
164120
|
return {};
|
|
163729
164121
|
const sanitized = sanitizeJsonValue3(value);
|
|
163730
|
-
return
|
|
164122
|
+
return isRecord21(sanitized) ? sanitized : {};
|
|
163731
164123
|
}
|
|
163732
164124
|
function normalizeRevenueOutcomeInput(input) {
|
|
163733
|
-
if (!
|
|
164125
|
+
if (!isRecord21(input)) {
|
|
163734
164126
|
throw new RevenueAttributionValidationError("Outcome must be an object.");
|
|
163735
164127
|
}
|
|
163736
164128
|
const outcomeInput = input;
|
|
@@ -170248,12 +170640,158 @@ var init_openai3 = __esm2(() => {
|
|
|
170248
170640
|
init_openai_auth();
|
|
170249
170641
|
CALLBACK_ORIGIN4 = `http://127.0.0.1:${DEFAULT_PORT}`;
|
|
170250
170642
|
});
|
|
170643
|
+
var exports_init = {};
|
|
170644
|
+
__export2(exports_init, {
|
|
170645
|
+
parseInitArgs: () => parseInitArgs,
|
|
170646
|
+
handleInitCommand: () => handleInitCommand2
|
|
170647
|
+
});
|
|
170648
|
+
function readValue(args, index2, flag) {
|
|
170649
|
+
const value = args[index2 + 1];
|
|
170650
|
+
if (!value || value.startsWith("-")) {
|
|
170651
|
+
throw new Error(`${flag} requires a value`);
|
|
170652
|
+
}
|
|
170653
|
+
return value;
|
|
170654
|
+
}
|
|
170655
|
+
function parsePositiveInteger(value, flag) {
|
|
170656
|
+
const parsed = Number.parseInt(value, 10);
|
|
170657
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
170658
|
+
throw new Error(`${flag} must be a positive integer`);
|
|
170659
|
+
}
|
|
170660
|
+
return parsed;
|
|
170661
|
+
}
|
|
170662
|
+
function appendScopes(existing, value) {
|
|
170663
|
+
return [
|
|
170664
|
+
...existing ?? [],
|
|
170665
|
+
...value.split(",").map((entry2) => entry2.trim()).filter((entry2) => entry2.length > 0)
|
|
170666
|
+
];
|
|
170667
|
+
}
|
|
170668
|
+
function parseInitArgs(args) {
|
|
170669
|
+
const options = {};
|
|
170670
|
+
for (let i2 = 0; i2 < args.length; i2++) {
|
|
170671
|
+
const arg = args[i2];
|
|
170672
|
+
switch (arg) {
|
|
170673
|
+
case "--agent-mcp-url":
|
|
170674
|
+
case "--mcp-url":
|
|
170675
|
+
options.mcpUrl = readValue(args, i2, arg);
|
|
170676
|
+
i2++;
|
|
170677
|
+
break;
|
|
170678
|
+
case "--agent-type":
|
|
170679
|
+
options.agentType = readValue(args, i2, arg);
|
|
170680
|
+
i2++;
|
|
170681
|
+
break;
|
|
170682
|
+
case "--api-key-scope":
|
|
170683
|
+
case "--key-scope":
|
|
170684
|
+
options.apiKeyScopes = appendScopes(options.apiKeyScopes, readValue(args, i2, arg));
|
|
170685
|
+
i2++;
|
|
170686
|
+
break;
|
|
170687
|
+
case "--expires-in-days":
|
|
170688
|
+
options.expiresInDays = parsePositiveInteger(readValue(args, i2, arg), arg);
|
|
170689
|
+
i2++;
|
|
170690
|
+
break;
|
|
170691
|
+
case "--force-login":
|
|
170692
|
+
options.forceLogin = true;
|
|
170693
|
+
break;
|
|
170694
|
+
case "--json":
|
|
170695
|
+
options.json = true;
|
|
170696
|
+
break;
|
|
170697
|
+
case "--key-name":
|
|
170698
|
+
options.keyName = readValue(args, i2, arg);
|
|
170699
|
+
i2++;
|
|
170700
|
+
break;
|
|
170701
|
+
case "--manifest-url":
|
|
170702
|
+
options.manifestUrl = readValue(args, i2, arg);
|
|
170703
|
+
i2++;
|
|
170704
|
+
break;
|
|
170705
|
+
case "--register-scope":
|
|
170706
|
+
case "--scope":
|
|
170707
|
+
options.registerScopes = appendScopes(options.registerScopes, readValue(args, i2, arg));
|
|
170708
|
+
i2++;
|
|
170709
|
+
break;
|
|
170710
|
+
case "--rotate-key":
|
|
170711
|
+
options.rotateKey = true;
|
|
170712
|
+
break;
|
|
170713
|
+
case "--surface":
|
|
170714
|
+
options.surface = readValue(args, i2, arg);
|
|
170715
|
+
i2++;
|
|
170716
|
+
break;
|
|
170717
|
+
case "--ttl-seconds":
|
|
170718
|
+
options.ttlSeconds = parsePositiveInteger(readValue(args, i2, arg), arg);
|
|
170719
|
+
i2++;
|
|
170720
|
+
break;
|
|
170721
|
+
case "--workspace":
|
|
170722
|
+
case "--workspace-id":
|
|
170723
|
+
options.workspaceId = readValue(args, i2, arg);
|
|
170724
|
+
i2++;
|
|
170725
|
+
break;
|
|
170726
|
+
default:
|
|
170727
|
+
if (arg?.startsWith("-")) {
|
|
170728
|
+
throw new Error(`Unknown maestro init option: ${arg}`);
|
|
170729
|
+
}
|
|
170730
|
+
throw new Error(`Unexpected maestro init argument: ${arg}`);
|
|
170731
|
+
}
|
|
170732
|
+
}
|
|
170733
|
+
return options;
|
|
170734
|
+
}
|
|
170735
|
+
async function handleInitCommand2(args = []) {
|
|
170736
|
+
let options;
|
|
170737
|
+
try {
|
|
170738
|
+
options = parseInitArgs(args);
|
|
170739
|
+
} catch (error) {
|
|
170740
|
+
console.error(chalk62.red(error instanceof Error ? error.message : String(error)));
|
|
170741
|
+
process.exit(1);
|
|
170742
|
+
}
|
|
170743
|
+
if (!options.json) {
|
|
170744
|
+
console.log(chalk62.bold("Maestro EvalOps Init"));
|
|
170745
|
+
}
|
|
170746
|
+
const result = await bootstrapEvalOpsAgent(options, {
|
|
170747
|
+
onAuthUrl: (url) => {
|
|
170748
|
+
if (options.json) {
|
|
170749
|
+
return;
|
|
170750
|
+
}
|
|
170751
|
+
console.log(chalk62.yellow("Open this URL in your browser to authenticate with EvalOps:"));
|
|
170752
|
+
console.log(chalk62.underline(url));
|
|
170753
|
+
},
|
|
170754
|
+
onStatus: (status) => {
|
|
170755
|
+
if (!options.json) {
|
|
170756
|
+
console.log(chalk62.dim(status.message));
|
|
170757
|
+
}
|
|
170758
|
+
}
|
|
170759
|
+
});
|
|
170760
|
+
if (options.json) {
|
|
170761
|
+
console.log(JSON.stringify(result, null, 2));
|
|
170762
|
+
return;
|
|
170763
|
+
}
|
|
170764
|
+
console.log(chalk62.green("EvalOps agent bootstrap complete."));
|
|
170765
|
+
console.log(chalk62.dim(`MCP endpoint: ${result.endpoint}`));
|
|
170766
|
+
if (result.organizationId) {
|
|
170767
|
+
console.log(chalk62.dim(`Organization: ${result.organizationId}`));
|
|
170768
|
+
}
|
|
170769
|
+
if (result.agentId) {
|
|
170770
|
+
console.log(chalk62.dim(`Agent: ${result.agentId}`));
|
|
170771
|
+
}
|
|
170772
|
+
if (result.runId) {
|
|
170773
|
+
console.log(chalk62.dim(`Run: ${result.runId}`));
|
|
170774
|
+
}
|
|
170775
|
+
if (result.keyPrefix) {
|
|
170776
|
+
const keyMode = result.apiKeyCreated ? "created" : "reused";
|
|
170777
|
+
console.log(chalk62.dim(`API key ${keyMode}: ${result.keyPrefix}`));
|
|
170778
|
+
}
|
|
170779
|
+
console.log(chalk62.dim("Stored EvalOps MCP credentials locally for future Maestro sessions."));
|
|
170780
|
+
}
|
|
170781
|
+
var init_init = __esm2(() => {
|
|
170782
|
+
init_agent_bootstrap();
|
|
170783
|
+
});
|
|
170251
170784
|
var exports_evalops = {};
|
|
170252
170785
|
__export2(exports_evalops, {
|
|
170253
170786
|
handleEvalOpsCommand: () => handleEvalOpsCommand
|
|
170254
170787
|
});
|
|
170255
170788
|
async function handleEvalOpsCommand(subcommand) {
|
|
170256
170789
|
switch (subcommand) {
|
|
170790
|
+
case "init": {
|
|
170791
|
+
const { handleInitCommand: handleInitCommand3 } = await Promise.resolve().then(() => (init_init(), exports_init));
|
|
170792
|
+
await handleInitCommand3();
|
|
170793
|
+
return;
|
|
170794
|
+
}
|
|
170257
170795
|
case "login":
|
|
170258
170796
|
await handleLogin3();
|
|
170259
170797
|
return;
|
|
@@ -170264,30 +170802,30 @@ async function handleEvalOpsCommand(subcommand) {
|
|
|
170264
170802
|
await handleStatus3();
|
|
170265
170803
|
return;
|
|
170266
170804
|
default:
|
|
170267
|
-
console.error(
|
|
170805
|
+
console.error(chalk63.red('Unknown evalops subcommand. Try "maestro init" for setup, or "maestro evalops login", "logout", or "status".'));
|
|
170268
170806
|
process.exit(1);
|
|
170269
170807
|
}
|
|
170270
170808
|
}
|
|
170271
170809
|
async function handleLogin3() {
|
|
170272
|
-
console.log(
|
|
170810
|
+
console.log(chalk63.bold("Maestro EvalOps Login"));
|
|
170273
170811
|
await login("evalops", {
|
|
170274
170812
|
onAuthUrl: (url) => {
|
|
170275
|
-
console.log(
|
|
170276
|
-
console.log(
|
|
170813
|
+
console.log(chalk63.yellow("Open this URL in your browser to authenticate with EvalOps:"));
|
|
170814
|
+
console.log(chalk63.underline(url));
|
|
170277
170815
|
},
|
|
170278
|
-
onStatus: (status) => console.log(
|
|
170816
|
+
onStatus: (status) => console.log(chalk63.dim(status))
|
|
170279
170817
|
});
|
|
170280
|
-
console.log(
|
|
170281
|
-
console.log(
|
|
170818
|
+
console.log(chalk63.green("EvalOps credentials saved successfully."));
|
|
170819
|
+
console.log(chalk63.dim('Try "maestro --provider evalops --model gpt-4o-mini".'));
|
|
170282
170820
|
}
|
|
170283
170821
|
async function handleLogout2() {
|
|
170284
170822
|
await logout("evalops");
|
|
170285
|
-
console.log(
|
|
170823
|
+
console.log(chalk63.green("Removed stored EvalOps credentials."));
|
|
170286
170824
|
}
|
|
170287
170825
|
async function handleStatus3() {
|
|
170288
170826
|
if (!hasOAuthCredentials("evalops")) {
|
|
170289
|
-
console.log(
|
|
170290
|
-
console.log(
|
|
170827
|
+
console.log(chalk63.yellow("No stored EvalOps credentials."));
|
|
170828
|
+
console.log(chalk63.dim('Run "maestro evalops login" to authenticate with EvalOps.'));
|
|
170291
170829
|
return;
|
|
170292
170830
|
}
|
|
170293
170831
|
const credentials = loadOAuthCredentials("evalops");
|
|
@@ -170296,16 +170834,16 @@ async function handleStatus3() {
|
|
|
170296
170834
|
const metadata = credentials?.metadata;
|
|
170297
170835
|
const organizationId = typeof metadata?.organizationId === "string" ? metadata.organizationId : void 0;
|
|
170298
170836
|
const providerRef = metadata?.providerRef && typeof metadata.providerRef === "object" && !Array.isArray(metadata.providerRef) ? metadata.providerRef : void 0;
|
|
170299
|
-
console.log(
|
|
170837
|
+
console.log(chalk63.green("Stored EvalOps credentials detected."));
|
|
170300
170838
|
if (organizationId) {
|
|
170301
|
-
console.log(
|
|
170839
|
+
console.log(chalk63.dim(`Organization: ${organizationId}`));
|
|
170302
170840
|
}
|
|
170303
170841
|
if (providerRef) {
|
|
170304
170842
|
const provider = typeof providerRef.provider === "string" ? providerRef.provider : "openai";
|
|
170305
170843
|
const environment = typeof providerRef.environment === "string" ? providerRef.environment : "prod";
|
|
170306
|
-
console.log(
|
|
170844
|
+
console.log(chalk63.dim(`Provider ref: ${provider}/${environment}`));
|
|
170307
170845
|
}
|
|
170308
|
-
console.log(
|
|
170846
|
+
console.log(chalk63.dim(`Access token expires in ~${minutes} minute${minutes === 1 ? "" : "s"} (auto-refresh enabled).`));
|
|
170309
170847
|
}
|
|
170310
170848
|
var init_evalops2 = __esm2(() => {
|
|
170311
170849
|
init_oauth();
|
|
@@ -170327,7 +170865,7 @@ async function handleCodexCommand(subcommand, _params = []) {
|
|
|
170327
170865
|
await handleStatus4();
|
|
170328
170866
|
return;
|
|
170329
170867
|
default:
|
|
170330
|
-
console.error(
|
|
170868
|
+
console.error(chalk64.red('Unknown codex subcommand. Try "maestro codex login", "logout", or "status".'));
|
|
170331
170869
|
process.exit(1);
|
|
170332
170870
|
}
|
|
170333
170871
|
}
|
|
@@ -170340,37 +170878,37 @@ async function promptCode() {
|
|
|
170340
170878
|
}
|
|
170341
170879
|
}
|
|
170342
170880
|
async function handleLogin4() {
|
|
170343
|
-
console.log(
|
|
170881
|
+
console.log(chalk64.bold("Maestro OpenAI Codex Login"));
|
|
170344
170882
|
await login("openai-codex", {
|
|
170345
170883
|
onAuthUrl: (url) => {
|
|
170346
|
-
console.log(
|
|
170347
|
-
console.log(
|
|
170884
|
+
console.log(chalk64.yellow("Open this URL in your browser to authenticate with OpenAI:"));
|
|
170885
|
+
console.log(chalk64.underline(url));
|
|
170348
170886
|
},
|
|
170349
170887
|
onPromptCode: promptCode,
|
|
170350
|
-
onStatus: (status) => console.log(
|
|
170888
|
+
onStatus: (status) => console.log(chalk64.dim(status))
|
|
170351
170889
|
});
|
|
170352
|
-
console.log(
|
|
170353
|
-
console.log(
|
|
170890
|
+
console.log(chalk64.green("OpenAI Codex credentials saved successfully."));
|
|
170891
|
+
console.log(chalk64.dim('Select provider "openai-codex" or a model like "openai-codex/gpt-5.5".'));
|
|
170354
170892
|
}
|
|
170355
170893
|
async function handleLogout3() {
|
|
170356
170894
|
await logout("openai-codex");
|
|
170357
|
-
console.log(
|
|
170895
|
+
console.log(chalk64.green("Removed stored OpenAI Codex credentials."));
|
|
170358
170896
|
}
|
|
170359
170897
|
async function handleStatus4() {
|
|
170360
170898
|
if (!hasOAuthCredentials("openai-codex")) {
|
|
170361
|
-
console.log(
|
|
170362
|
-
console.log(
|
|
170899
|
+
console.log(chalk64.yellow("No stored OpenAI Codex credentials."));
|
|
170900
|
+
console.log(chalk64.dim('Run "maestro codex login" to authenticate with OpenAI.'));
|
|
170363
170901
|
return;
|
|
170364
170902
|
}
|
|
170365
170903
|
const credentials = loadOAuthCredentials("openai-codex");
|
|
170366
170904
|
const remainingMs = Math.max(0, (credentials?.expires ?? Date.now()) - Date.now());
|
|
170367
170905
|
const minutes = Math.round(remainingMs / 6e4);
|
|
170368
170906
|
const accountId = typeof credentials?.metadata?.accountId === "string" ? credentials.metadata.accountId : void 0;
|
|
170369
|
-
console.log(
|
|
170907
|
+
console.log(chalk64.green("Stored OpenAI Codex credentials detected."));
|
|
170370
170908
|
if (accountId) {
|
|
170371
|
-
console.log(
|
|
170909
|
+
console.log(chalk64.dim(`ChatGPT account id: ${accountId}`));
|
|
170372
170910
|
}
|
|
170373
|
-
console.log(
|
|
170911
|
+
console.log(chalk64.dim(`Access token expires in ~${minutes} minute${minutes === 1 ? "" : "s"} (auto-refresh enabled).`));
|
|
170374
170912
|
}
|
|
170375
170913
|
var init_codex = __esm2(() => {
|
|
170376
170914
|
init_oauth();
|
|
@@ -170382,8 +170920,8 @@ __export2(exports_hooks, {
|
|
|
170382
170920
|
});
|
|
170383
170921
|
async function handleHooksCommand(subcommand) {
|
|
170384
170922
|
if (subcommand && subcommand !== "status") {
|
|
170385
|
-
console.error(
|
|
170386
|
-
console.error(
|
|
170923
|
+
console.error(chalk65.red(`Unknown hooks subcommand: ${subcommand}`));
|
|
170924
|
+
console.error(chalk65.dim("Try: maestro hooks status"));
|
|
170387
170925
|
process.exit(1);
|
|
170388
170926
|
}
|
|
170389
170927
|
cleanupAsyncHooks();
|
|
@@ -170395,10 +170933,10 @@ async function handleHooksCommand(subcommand) {
|
|
|
170395
170933
|
["Queued requests", concurrency.queued],
|
|
170396
170934
|
["Async in-flight", asyncInFlight]
|
|
170397
170935
|
];
|
|
170398
|
-
console.log(
|
|
170936
|
+
console.log(chalk65.bold("Hook Status"));
|
|
170399
170937
|
for (const [label, value] of rows) {
|
|
170400
170938
|
const padded = label.padEnd(18);
|
|
170401
|
-
console.log(`${
|
|
170939
|
+
console.log(`${chalk65.cyan(padded)} ${value}`);
|
|
170402
170940
|
}
|
|
170403
170941
|
}
|
|
170404
170942
|
var init_hooks2 = __esm2(() => {
|
|
@@ -170410,8 +170948,8 @@ __export2(exports_session_transfer, {
|
|
|
170410
170948
|
handleExportCommand: () => handleExportCommand
|
|
170411
170949
|
});
|
|
170412
170950
|
function exitWithUsage(message, usage) {
|
|
170413
|
-
console.error(
|
|
170414
|
-
console.error(
|
|
170951
|
+
console.error(chalk66.red(message));
|
|
170952
|
+
console.error(chalk66.dim(usage));
|
|
170415
170953
|
process.exit(1);
|
|
170416
170954
|
}
|
|
170417
170955
|
async function handleExportCommand(sessionId, outputPath, format, options = {}) {
|
|
@@ -170429,7 +170967,7 @@ async function handleExportCommand(sessionId, outputPath, format, options = {})
|
|
|
170429
170967
|
}
|
|
170430
170968
|
const exportManager = new SessionManager(false, sessionFile);
|
|
170431
170969
|
const exportedPath = normalizedFormat === JSON_FORMAT ? await exportSessionToJson(exportManager, outputPath, options) : await exportSessionToJsonl(exportManager, outputPath, options);
|
|
170432
|
-
console.log(
|
|
170970
|
+
console.log(chalk66.green(`Exported session ${sessionId} to ${resolve59(exportedPath)} (${normalizedFormat}).`));
|
|
170433
170971
|
}
|
|
170434
170972
|
async function handleImportCommand(sourcePath) {
|
|
170435
170973
|
if (!sourcePath) {
|
|
@@ -170437,8 +170975,8 @@ async function handleImportCommand(sourcePath) {
|
|
|
170437
170975
|
}
|
|
170438
170976
|
const sessionManager = new SessionManager(false);
|
|
170439
170977
|
const imported = sessionManager.importPortableSession(sourcePath);
|
|
170440
|
-
console.log(
|
|
170441
|
-
console.log(
|
|
170978
|
+
console.log(chalk66.green(imported.importedCount > 1 ? `Imported ${imported.importedCount} sessions from ${resolve59(sourcePath)}. Active session: ${imported.sessionId}.` : `Imported session ${imported.sessionId} from ${resolve59(sourcePath)}.`));
|
|
170979
|
+
console.log(chalk66.dim(`Stored at ${imported.sessionFile}`));
|
|
170442
170980
|
}
|
|
170443
170981
|
var JSONL_FORMAT = "jsonl";
|
|
170444
170982
|
var JSON_FORMAT = "json";
|
|
@@ -170455,7 +170993,7 @@ __export2(exports_memory, {
|
|
|
170455
170993
|
function getConfig() {
|
|
170456
170994
|
const base = process.env.MAESTRO_SHARED_MEMORY_BASE?.trim();
|
|
170457
170995
|
if (!base) {
|
|
170458
|
-
console.error(
|
|
170996
|
+
console.error(chalk67.red("MAESTRO_SHARED_MEMORY_BASE is not set. Configure shared memory to use this command."));
|
|
170459
170997
|
process.exit(1);
|
|
170460
170998
|
}
|
|
170461
170999
|
const apiKey = process.env.MAESTRO_SHARED_MEMORY_API_KEY?.trim();
|
|
@@ -170519,7 +171057,7 @@ async function printStatus(config2) {
|
|
|
170519
171057
|
}
|
|
170520
171058
|
printCapabilities(metrics.capabilities);
|
|
170521
171059
|
} catch (error) {
|
|
170522
|
-
console.error(
|
|
171060
|
+
console.error(chalk67.red(`Failed to fetch shared memory status: ${error instanceof Error ? error.message : String(error)}`));
|
|
170523
171061
|
process.exit(1);
|
|
170524
171062
|
}
|
|
170525
171063
|
}
|
|
@@ -170557,7 +171095,7 @@ async function printAudit(config2, sessionId, limit) {
|
|
|
170557
171095
|
const mode = entry2.mode ? String(entry2.mode) : "?";
|
|
170558
171096
|
const events = entry2.event_count ? String(entry2.event_count) : "0";
|
|
170559
171097
|
const source = entry2.source ? String(entry2.source) : "?";
|
|
170560
|
-
console.log(`${
|
|
171098
|
+
console.log(`${chalk67.cyan(at)} ${separator()}${badge("mode", mode)}${separator()}${badge("events", events)}${separator()}${badge("source", source)}`);
|
|
170561
171099
|
}
|
|
170562
171100
|
}
|
|
170563
171101
|
async function exportMetrics(config2, sessionId) {
|
|
@@ -170595,7 +171133,7 @@ async function handleMemoryCommand2(subcommand, args) {
|
|
|
170595
171133
|
case "session": {
|
|
170596
171134
|
const sessionId = args[0];
|
|
170597
171135
|
if (!sessionId) {
|
|
170598
|
-
console.error(
|
|
171136
|
+
console.error(chalk67.red("Session id required."));
|
|
170599
171137
|
process.exit(1);
|
|
170600
171138
|
}
|
|
170601
171139
|
const config2 = getConfig();
|
|
@@ -170605,7 +171143,7 @@ async function handleMemoryCommand2(subcommand, args) {
|
|
|
170605
171143
|
case "audit": {
|
|
170606
171144
|
const sessionId = args[0];
|
|
170607
171145
|
if (!sessionId) {
|
|
170608
|
-
console.error(
|
|
171146
|
+
console.error(chalk67.red("Session id required."));
|
|
170609
171147
|
process.exit(1);
|
|
170610
171148
|
}
|
|
170611
171149
|
const config2 = getConfig();
|
|
@@ -170616,7 +171154,7 @@ async function handleMemoryCommand2(subcommand, args) {
|
|
|
170616
171154
|
case "export": {
|
|
170617
171155
|
const sessionId = args[0];
|
|
170618
171156
|
if (!sessionId) {
|
|
170619
|
-
console.error(
|
|
171157
|
+
console.error(chalk67.red("Session id required."));
|
|
170620
171158
|
process.exit(1);
|
|
170621
171159
|
}
|
|
170622
171160
|
const config2 = getConfig();
|
|
@@ -170636,22 +171174,22 @@ async function handleMemoryCommand2(subcommand, args) {
|
|
|
170636
171174
|
await printStatus(config2);
|
|
170637
171175
|
}
|
|
170638
171176
|
} catch (error) {
|
|
170639
|
-
console.error(
|
|
171177
|
+
console.error(chalk67.red(`Shared memory watch error: ${error instanceof Error ? error.message : String(error)}`));
|
|
170640
171178
|
}
|
|
170641
171179
|
await new Promise((resolve602) => setTimeout(resolve602, intervalMs));
|
|
170642
171180
|
}
|
|
170643
171181
|
return;
|
|
170644
171182
|
}
|
|
170645
171183
|
default:
|
|
170646
|
-
console.error(
|
|
170647
|
-
console.log(
|
|
171184
|
+
console.error(chalk67.red(`Unknown memory subcommand: ${subcommand}`));
|
|
171185
|
+
console.log(chalk67.dim(`
|
|
170648
171186
|
Available commands:`));
|
|
170649
|
-
console.log(
|
|
170650
|
-
console.log(
|
|
170651
|
-
console.log(
|
|
170652
|
-
console.log(
|
|
170653
|
-
console.log(
|
|
170654
|
-
console.log(
|
|
171187
|
+
console.log(chalk67.dim(" maestro memory [status]"));
|
|
171188
|
+
console.log(chalk67.dim(" maestro memory capabilities"));
|
|
171189
|
+
console.log(chalk67.dim(" maestro memory session <id>"));
|
|
171190
|
+
console.log(chalk67.dim(" maestro memory audit <id> [limit]"));
|
|
171191
|
+
console.log(chalk67.dim(" maestro memory export <id>"));
|
|
171192
|
+
console.log(chalk67.dim(" maestro memory watch [id] [intervalMs]"));
|
|
170655
171193
|
process.exit(1);
|
|
170656
171194
|
}
|
|
170657
171195
|
}
|
|
@@ -171018,7 +171556,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171018
171556
|
const beginAssistantOutput = () => {
|
|
171019
171557
|
if (!visibleResponseOpen) {
|
|
171020
171558
|
clearPromptLine(stdout2);
|
|
171021
|
-
stdout2.write(
|
|
171559
|
+
stdout2.write(chalk68.bold("assistant> "));
|
|
171022
171560
|
visibleResponseOpen = true;
|
|
171023
171561
|
responseEndsWithNewline = false;
|
|
171024
171562
|
}
|
|
@@ -171033,7 +171571,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171033
171571
|
`);
|
|
171034
171572
|
};
|
|
171035
171573
|
const printStatus2 = () => {
|
|
171036
|
-
writeLine(
|
|
171574
|
+
writeLine(chalk68.bold(`Remote session ${input.sessionId}`));
|
|
171037
171575
|
writeLine(` role: ${input.role}`);
|
|
171038
171576
|
writeLine(` ready: ${state2.is_ready ? "yes" : "no"}`);
|
|
171039
171577
|
writeLine(` responding: ${state2.is_responding ? "yes" : "no"}`);
|
|
@@ -171048,11 +171586,11 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171048
171586
|
};
|
|
171049
171587
|
const connection = await connectToRemoteRunnerSession(input);
|
|
171050
171588
|
state2 = connection.state;
|
|
171051
|
-
writeLine(
|
|
171589
|
+
writeLine(chalk68.bold(`Attached to ${connection.sessionId} as ${connection.role === "viewer" ? "viewer" : "controller"}`));
|
|
171052
171590
|
if (connection.role === "controller") {
|
|
171053
|
-
writeLine(
|
|
171591
|
+
writeLine(chalk68.dim("Enter a prompt below. Use /status, /help, or /exit. Press Ctrl+C to interrupt an active response."));
|
|
171054
171592
|
} else {
|
|
171055
|
-
writeLine(
|
|
171593
|
+
writeLine(chalk68.dim("Viewer mode is read-only. Use /status or /exit."));
|
|
171056
171594
|
}
|
|
171057
171595
|
const attachContext = {
|
|
171058
171596
|
gatewayBaseUrl: input.gatewayBaseUrl,
|
|
@@ -171083,13 +171621,13 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171083
171621
|
visibleResponseOpen = false;
|
|
171084
171622
|
break;
|
|
171085
171623
|
case "status":
|
|
171086
|
-
writeLine(
|
|
171624
|
+
writeLine(chalk68.dim(message.message));
|
|
171087
171625
|
break;
|
|
171088
171626
|
case "error":
|
|
171089
|
-
writeLine(
|
|
171627
|
+
writeLine(chalk68.red(message.message));
|
|
171090
171628
|
break;
|
|
171091
171629
|
case "compaction":
|
|
171092
|
-
writeLine(
|
|
171630
|
+
writeLine(chalk68.dim(`Compacted remote history: ${message.summary}`));
|
|
171093
171631
|
break;
|
|
171094
171632
|
default:
|
|
171095
171633
|
break;
|
|
@@ -171098,7 +171636,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171098
171636
|
},
|
|
171099
171637
|
onReset: (snapshotState) => {
|
|
171100
171638
|
state2 = snapshotState;
|
|
171101
|
-
writeLine(
|
|
171639
|
+
writeLine(chalk68.dim("Remote session state resynced from snapshot."));
|
|
171102
171640
|
updates.notify();
|
|
171103
171641
|
}
|
|
171104
171642
|
}, streamAbort.signal).catch((error) => {
|
|
@@ -171132,15 +171670,15 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171132
171670
|
return true;
|
|
171133
171671
|
case "/interrupt":
|
|
171134
171672
|
if (connection.role !== "controller") {
|
|
171135
|
-
writeLine(
|
|
171673
|
+
writeLine(chalk68.yellow("Viewer mode cannot interrupt the session."));
|
|
171136
171674
|
return true;
|
|
171137
171675
|
}
|
|
171138
171676
|
if (!state2.is_responding) {
|
|
171139
|
-
writeLine(
|
|
171677
|
+
writeLine(chalk68.dim("No active response to interrupt."));
|
|
171140
171678
|
return true;
|
|
171141
171679
|
}
|
|
171142
171680
|
await sendInteractiveMessage({ type: "interrupt" });
|
|
171143
|
-
writeLine(
|
|
171681
|
+
writeLine(chalk68.dim("Interrupt sent."));
|
|
171144
171682
|
return true;
|
|
171145
171683
|
case "/exit":
|
|
171146
171684
|
case "/quit":
|
|
@@ -171149,17 +171687,17 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171149
171687
|
return true;
|
|
171150
171688
|
default:
|
|
171151
171689
|
if (line.startsWith("/")) {
|
|
171152
|
-
writeLine(
|
|
171690
|
+
writeLine(chalk68.yellow(`Unknown command: ${line}`));
|
|
171153
171691
|
return true;
|
|
171154
171692
|
}
|
|
171155
171693
|
return false;
|
|
171156
171694
|
}
|
|
171157
171695
|
};
|
|
171158
171696
|
const handleApproval2 = async (request) => {
|
|
171159
|
-
writeLine(
|
|
171697
|
+
writeLine(chalk68.yellow(`Approval required: ${formatRequestLabel(request)}`));
|
|
171160
171698
|
const summary2 = summarizeArgs(request.args);
|
|
171161
171699
|
if (summary2) {
|
|
171162
|
-
writeLine(
|
|
171700
|
+
writeLine(chalk68.dim(summary2));
|
|
171163
171701
|
}
|
|
171164
171702
|
while (!closeRequested) {
|
|
171165
171703
|
const answer = (await rl.question("Approve? [y/N]: ")).trim();
|
|
@@ -171201,10 +171739,10 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171201
171739
|
}
|
|
171202
171740
|
};
|
|
171203
171741
|
const handleUserInput = async (request) => {
|
|
171204
|
-
writeLine(
|
|
171742
|
+
writeLine(chalk68.yellow(`Input requested: ${formatRequestLabel(request)}`));
|
|
171205
171743
|
const summary2 = summarizeArgs(request.args);
|
|
171206
171744
|
if (summary2) {
|
|
171207
|
-
writeLine(
|
|
171745
|
+
writeLine(chalk68.dim(summary2));
|
|
171208
171746
|
}
|
|
171209
171747
|
while (!closeRequested) {
|
|
171210
171748
|
const answer = await rl.question("Reply: ");
|
|
@@ -171231,10 +171769,10 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171231
171769
|
}
|
|
171232
171770
|
};
|
|
171233
171771
|
const handleToolRetry2 = async (request) => {
|
|
171234
|
-
writeLine(
|
|
171772
|
+
writeLine(chalk68.yellow(`Tool retry requested: ${formatRequestLabel(request)}`));
|
|
171235
171773
|
const summary2 = summarizeArgs(request.args);
|
|
171236
171774
|
if (summary2) {
|
|
171237
|
-
writeLine(
|
|
171775
|
+
writeLine(chalk68.dim(summary2));
|
|
171238
171776
|
}
|
|
171239
171777
|
while (!closeRequested) {
|
|
171240
171778
|
const answer = (await rl.question("Decision [retry/skip/abort]: ")).trim().toLowerCase();
|
|
@@ -171242,7 +171780,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171242
171780
|
continue;
|
|
171243
171781
|
}
|
|
171244
171782
|
if (!["retry", "skip", "abort"].includes(answer)) {
|
|
171245
|
-
writeLine(
|
|
171783
|
+
writeLine(chalk68.yellow("Enter retry, skip, or abort."));
|
|
171246
171784
|
continue;
|
|
171247
171785
|
}
|
|
171248
171786
|
await sendInteractiveMessage({
|
|
@@ -171260,7 +171798,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171260
171798
|
streamError = error instanceof Error ? error : new Error(String(error));
|
|
171261
171799
|
updates.notify();
|
|
171262
171800
|
});
|
|
171263
|
-
writeLine(
|
|
171801
|
+
writeLine(chalk68.dim("Interrupt sent."));
|
|
171264
171802
|
return;
|
|
171265
171803
|
}
|
|
171266
171804
|
closeRequested = true;
|
|
@@ -171302,7 +171840,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171302
171840
|
continue;
|
|
171303
171841
|
}
|
|
171304
171842
|
if (connection.role !== "controller") {
|
|
171305
|
-
writeLine(
|
|
171843
|
+
writeLine(chalk68.yellow("Viewer mode is read-only."));
|
|
171306
171844
|
version3 = updates.current();
|
|
171307
171845
|
continue;
|
|
171308
171846
|
}
|
|
@@ -172156,7 +172694,7 @@ function printJson(value) {
|
|
|
172156
172694
|
console.log(JSON.stringify(value, null, 2));
|
|
172157
172695
|
}
|
|
172158
172696
|
function printSession(session) {
|
|
172159
|
-
console.log(
|
|
172697
|
+
console.log(chalk69.bold(session.id));
|
|
172160
172698
|
console.log(` state: ${stateLabel(session.state)}`);
|
|
172161
172699
|
console.log(` workspace: ${session.workspaceId ?? "-"}`);
|
|
172162
172700
|
console.log(` profile: ${session.runnerProfile ?? "-"}`);
|
|
@@ -172170,7 +172708,7 @@ function printSession(session) {
|
|
|
172170
172708
|
}
|
|
172171
172709
|
function printSessionTable(sessions2) {
|
|
172172
172710
|
if (!sessions2.length) {
|
|
172173
|
-
console.log(
|
|
172711
|
+
console.log(chalk69.dim("No remote runner sessions found."));
|
|
172174
172712
|
return;
|
|
172175
172713
|
}
|
|
172176
172714
|
const rows = sessions2.map((session) => ({
|
|
@@ -172219,21 +172757,21 @@ function printAttachInstructions(input) {
|
|
|
172219
172757
|
});
|
|
172220
172758
|
return;
|
|
172221
172759
|
}
|
|
172222
|
-
console.log(
|
|
172760
|
+
console.log(chalk69.bold(`Remote runner attach token minted for ${input.sessionId}`));
|
|
172223
172761
|
console.log(` gateway: ${input.gatewayBaseUrl}`);
|
|
172224
172762
|
console.log(` token: ${input.tokenId}`);
|
|
172225
172763
|
console.log(` expires: ${input.expiresAt ?? "-"}`);
|
|
172226
172764
|
if (input.verified) {
|
|
172227
|
-
console.log(
|
|
172765
|
+
console.log(chalk69.green(" headless gateway: verified"));
|
|
172228
172766
|
}
|
|
172229
172767
|
if (input.showSecret || !input.verified) {
|
|
172230
172768
|
console.log("");
|
|
172231
|
-
console.log(
|
|
172769
|
+
console.log(chalk69.dim("Ephemeral remote transport environment:"));
|
|
172232
172770
|
console.log(`export MAESTRO_REMOTE_BASE_URL=${JSON.stringify(input.gatewayBaseUrl)}`);
|
|
172233
172771
|
console.log(`export MAESTRO_REMOTE_API_KEY=${JSON.stringify(input.tokenSecret)}`);
|
|
172234
172772
|
console.log(`export MAESTRO_REMOTE_HEADER_X_EVALOPS_RUNNER_ATTACH_TOKEN_ID=${JSON.stringify(input.tokenId)}`);
|
|
172235
172773
|
} else {
|
|
172236
|
-
console.log(
|
|
172774
|
+
console.log(chalk69.dim(" token secret hidden; rerun with --show-secret or --json when handoff needs it."));
|
|
172237
172775
|
}
|
|
172238
172776
|
}
|
|
172239
172777
|
async function handleStart(options) {
|
|
@@ -172295,10 +172833,10 @@ async function handleStart(options) {
|
|
|
172295
172833
|
}
|
|
172296
172834
|
printSession(waitResult?.session ?? result.session);
|
|
172297
172835
|
if (waitResult) {
|
|
172298
|
-
console.log(
|
|
172836
|
+
console.log(chalk69.dim(` ready: ${formatElapsedMs(waitResult.elapsedMs)} (${waitResult.attempts} checks)`));
|
|
172299
172837
|
}
|
|
172300
172838
|
if (result.replayed) {
|
|
172301
|
-
console.log(
|
|
172839
|
+
console.log(chalk69.dim(" replayed: existing idempotent request"));
|
|
172302
172840
|
}
|
|
172303
172841
|
console.log("");
|
|
172304
172842
|
if (attachResult) {
|
|
@@ -172314,7 +172852,7 @@ async function handleStart(options) {
|
|
|
172314
172852
|
});
|
|
172315
172853
|
return;
|
|
172316
172854
|
}
|
|
172317
|
-
console.log(
|
|
172855
|
+
console.log(chalk69.dim(`Attach: maestro remote attach ${result.session.id}`));
|
|
172318
172856
|
}
|
|
172319
172857
|
async function handleList2(options) {
|
|
172320
172858
|
const result = await listRunnerSessions({
|
|
@@ -172329,7 +172867,7 @@ async function handleList2(options) {
|
|
|
172329
172867
|
}
|
|
172330
172868
|
printSessionTable(result.sessions);
|
|
172331
172869
|
if (result.nextOffset !== void 0 && result.nextOffset > 0) {
|
|
172332
|
-
console.log(
|
|
172870
|
+
console.log(chalk69.dim(`next offset: ${result.nextOffset}`));
|
|
172333
172871
|
}
|
|
172334
172872
|
}
|
|
172335
172873
|
async function handleStatus5(options) {
|
|
@@ -172338,7 +172876,7 @@ async function handleStatus5(options) {
|
|
|
172338
172876
|
printJson(status);
|
|
172339
172877
|
return;
|
|
172340
172878
|
}
|
|
172341
|
-
console.log(
|
|
172879
|
+
console.log(chalk69.bold(status.service ?? "remote-runner"));
|
|
172342
172880
|
console.log(` workspace: ${status.workspaceId ?? "-"}`);
|
|
172343
172881
|
console.log(` policy: ${status.downstreamPolicy ?? "-"}`);
|
|
172344
172882
|
}
|
|
@@ -172372,7 +172910,7 @@ async function handleEvents(options) {
|
|
|
172372
172910
|
console.log(`${String(event.sequence ?? "-").padStart(4)} ${event.occurredAt ?? "-"} ${event.eventType ?? "-"}`);
|
|
172373
172911
|
}
|
|
172374
172912
|
if (!result.events.length) {
|
|
172375
|
-
console.log(
|
|
172913
|
+
console.log(chalk69.dim("No remote runner events found."));
|
|
172376
172914
|
}
|
|
172377
172915
|
}
|
|
172378
172916
|
async function handleStop(options) {
|
|
@@ -172471,7 +173009,7 @@ async function handleAttachToken(options) {
|
|
|
172471
173009
|
printJson(minted);
|
|
172472
173010
|
return;
|
|
172473
173011
|
}
|
|
172474
|
-
console.log(
|
|
173012
|
+
console.log(chalk69.bold(`Attach token for ${sessionId}`));
|
|
172475
173013
|
console.log(` gateway: ${minted.gatewayBaseUrl}`);
|
|
172476
173014
|
console.log(` token: ${minted.token.id}`);
|
|
172477
173015
|
console.log(` secret: ${minted.tokenSecret}`);
|
|
@@ -172488,7 +173026,7 @@ async function handleRevokeToken(options) {
|
|
|
172488
173026
|
printJson(result);
|
|
172489
173027
|
return;
|
|
172490
173028
|
}
|
|
172491
|
-
console.log(
|
|
173029
|
+
console.log(chalk69.bold(`Revoked attach token ${result.token.id}`));
|
|
172492
173030
|
}
|
|
172493
173031
|
async function handleTarget(options) {
|
|
172494
173032
|
const sessionId = options.positionals[0];
|
|
@@ -172552,7 +173090,7 @@ async function handleRemoteCommand(subcommand, args = []) {
|
|
|
172552
173090
|
}
|
|
172553
173091
|
} catch (error) {
|
|
172554
173092
|
const message = error instanceof Error ? error.message : String(error);
|
|
172555
|
-
console.error(
|
|
173093
|
+
console.error(chalk69.red(message));
|
|
172556
173094
|
process.exitCode = 1;
|
|
172557
173095
|
}
|
|
172558
173096
|
}
|
|
@@ -172604,24 +173142,24 @@ async function handleAnthropicCommand(subcommand, params = []) {
|
|
|
172604
173142
|
await handleStatus6();
|
|
172605
173143
|
return;
|
|
172606
173144
|
default:
|
|
172607
|
-
console.error(
|
|
173145
|
+
console.error(chalk70.red('Unknown anthropic subcommand. Try "maestro anthropic login", "logout", or "status".'));
|
|
172608
173146
|
process.exit(1);
|
|
172609
173147
|
}
|
|
172610
173148
|
}
|
|
172611
173149
|
async function handleLogin5(mode) {
|
|
172612
|
-
console.log(
|
|
173150
|
+
console.log(chalk70.bold("Maestro Claude Code login"));
|
|
172613
173151
|
const { url, verifier } = await generateAnthropicLoginUrl(mode);
|
|
172614
|
-
console.log(
|
|
173152
|
+
console.log(chalk70.gray(url));
|
|
172615
173153
|
const rl = createInterface4({ input: stdin, output: stdout });
|
|
172616
173154
|
const code = (await rl.question("2. Paste the code shown in the browser: "))?.trim();
|
|
172617
173155
|
rl.close();
|
|
172618
173156
|
if (!code) {
|
|
172619
|
-
console.error(
|
|
173157
|
+
console.error(chalk70.red("Authorization code is required."));
|
|
172620
173158
|
process.exit(1);
|
|
172621
173159
|
}
|
|
172622
173160
|
const tokens = await exchangeAnthropicAuthorizationCode(code, verifier);
|
|
172623
173161
|
if (!tokens) {
|
|
172624
|
-
console.error(
|
|
173162
|
+
console.error(chalk70.red("Failed to exchange the authorization code. Please try again."));
|
|
172625
173163
|
process.exit(1);
|
|
172626
173164
|
}
|
|
172627
173165
|
await saveAnthropicOAuthCredential({
|
|
@@ -172630,27 +173168,27 @@ async function handleLogin5(mode) {
|
|
|
172630
173168
|
expiresAt: tokens.expiresAt,
|
|
172631
173169
|
mode
|
|
172632
173170
|
});
|
|
172633
|
-
console.log(
|
|
172634
|
-
console.log(
|
|
173171
|
+
console.log(chalk70.green("Claude Code credentials saved."));
|
|
173172
|
+
console.log(chalk70.dim("Future runs can use --auth claude or set it as default. Credentials refresh automatically."));
|
|
172635
173173
|
}
|
|
172636
173174
|
async function handleLogout4() {
|
|
172637
173175
|
await deleteAnthropicOAuthCredential();
|
|
172638
|
-
console.log(
|
|
173176
|
+
console.log(chalk70.green("Removed stored Claude Code credentials."));
|
|
172639
173177
|
}
|
|
172640
173178
|
async function handleStatus6() {
|
|
172641
173179
|
const stored = await getStoredAnthropicOAuthCredential();
|
|
172642
173180
|
if (!stored) {
|
|
172643
|
-
console.log(
|
|
172644
|
-
console.log(
|
|
173181
|
+
console.log(chalk70.yellow("No stored Claude Code credentials."));
|
|
173182
|
+
console.log(chalk70.dim('Run "maestro anthropic login" to link a Claude Pro/Max subscription.'));
|
|
172645
173183
|
return;
|
|
172646
173184
|
}
|
|
172647
173185
|
const remainingMs = Math.max(0, stored.expiresAt - Date.now());
|
|
172648
173186
|
const minutes = Math.round(remainingMs / 6e4);
|
|
172649
|
-
console.log(
|
|
172650
|
-
console.log(
|
|
173187
|
+
console.log(chalk70.green("Stored Claude Code credentials detected."));
|
|
173188
|
+
console.log(chalk70.dim(`Access token expires in ~${minutes} minute${minutes === 1 ? "" : "s"} (auto-refresh enabled).`));
|
|
172651
173189
|
const fresh = await getFreshAnthropicOAuthCredential();
|
|
172652
173190
|
if (fresh) {
|
|
172653
|
-
console.log(
|
|
173191
|
+
console.log(chalk70.dim(`Beta headers applied: ${CLAUDE_CODE_BETA_HEADER}`));
|
|
172654
173192
|
}
|
|
172655
173193
|
}
|
|
172656
173194
|
var init_anthropic3 = __esm2(() => {
|
|
@@ -172718,7 +173256,7 @@ async function handleCostSummary(period) {
|
|
|
172718
173256
|
badge("tok", formatTokens(data.tokens), "info"),
|
|
172719
173257
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn")
|
|
172720
173258
|
];
|
|
172721
|
-
console.log(` ${
|
|
173259
|
+
console.log(` ${chalk71.cyan(provider.padEnd(16))} ${metrics.join(separator())}`);
|
|
172722
173260
|
}
|
|
172723
173261
|
console.log();
|
|
172724
173262
|
}
|
|
@@ -172730,7 +173268,7 @@ async function handleCostSummary(period) {
|
|
|
172730
173268
|
badge("req", data.requests.toString(), "info"),
|
|
172731
173269
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn")
|
|
172732
173270
|
];
|
|
172733
|
-
console.log(` ${
|
|
173271
|
+
console.log(` ${chalk71.dim(model.padEnd(32))} ${detail.join(separator())}`);
|
|
172734
173272
|
}
|
|
172735
173273
|
if (Object.keys(summary2.byModel).length > 10) {
|
|
172736
173274
|
console.log(muted(` ... and ${Object.keys(summary2.byModel).length - 10} more models`));
|
|
@@ -172745,7 +173283,7 @@ async function handleCostClear() {
|
|
|
172745
173283
|
input: process.stdin,
|
|
172746
173284
|
output: process.stdout
|
|
172747
173285
|
});
|
|
172748
|
-
const confirm = await rl.question(
|
|
173286
|
+
const confirm = await rl.question(chalk71.yellow("Are you sure you want to clear all usage data? (y/N): "));
|
|
172749
173287
|
rl.close();
|
|
172750
173288
|
if (confirm.toLowerCase() === "y") {
|
|
172751
173289
|
clearUsage();
|
|
@@ -172776,7 +173314,7 @@ async function handleCostBreakdown() {
|
|
|
172776
173314
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn"),
|
|
172777
173315
|
contextualBadge("share", share, { warn: 30, danger: 50 })
|
|
172778
173316
|
];
|
|
172779
|
-
console.log(` ${
|
|
173317
|
+
console.log(` ${chalk71.cyan(provider.padEnd(16))} ${metrics.join(separator())}`);
|
|
172780
173318
|
}
|
|
172781
173319
|
console.log();
|
|
172782
173320
|
console.log(` ${badge("Total requests", summary2.totalRequests.toLocaleString(), "info")} ${separator()} ${badge("Total tokens", summary2.totalTokens.toLocaleString(), "info")} ${separator()} ${badge("Total cost", `$${summary2.totalCost.toFixed(4)}`, "warn")}`);
|
|
@@ -172884,7 +173422,7 @@ function renderProviderBreakdown(byProvider) {
|
|
|
172884
173422
|
badge("tok", formatTokens2(data.tokens), "info"),
|
|
172885
173423
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn")
|
|
172886
173424
|
];
|
|
172887
|
-
console.log(` ${
|
|
173425
|
+
console.log(` ${chalk72.cyan(provider.padEnd(16))} ${metrics.join(separator())}`);
|
|
172888
173426
|
}
|
|
172889
173427
|
console.log();
|
|
172890
173428
|
}
|
|
@@ -172899,7 +173437,7 @@ function renderModelBreakdown(byModel) {
|
|
|
172899
173437
|
badge("tok", formatTokens2(data.tokens), "info"),
|
|
172900
173438
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn")
|
|
172901
173439
|
];
|
|
172902
|
-
console.log(` ${
|
|
173440
|
+
console.log(` ${chalk72.dim(model.padEnd(32))} ${metrics.join(separator())}`);
|
|
172903
173441
|
}
|
|
172904
173442
|
console.log();
|
|
172905
173443
|
}
|
|
@@ -172914,7 +173452,7 @@ function renderSessionBreakdown(entries) {
|
|
|
172914
173452
|
badge("tok", formatTokens2(session.tokens), "info"),
|
|
172915
173453
|
badge("cost", `$${session.cost.toFixed(4)}`, "warn")
|
|
172916
173454
|
];
|
|
172917
|
-
console.log(` ${
|
|
173455
|
+
console.log(` ${chalk72.dim(session.sessionId.padEnd(32))} ${metrics.join(separator())}`);
|
|
172918
173456
|
}
|
|
172919
173457
|
console.log();
|
|
172920
173458
|
}
|
|
@@ -172971,7 +173509,7 @@ function formatSource(model) {
|
|
|
172971
173509
|
}
|
|
172972
173510
|
function printModelEntry(model) {
|
|
172973
173511
|
const localBadge = model.isLocal ? ` ${badge("local", void 0, "warn")}` : "";
|
|
172974
|
-
console.log(` \u2022 ${
|
|
173512
|
+
console.log(` \u2022 ${chalk73.bold(model.id)} ${separator()} ${muted(model.name)}`);
|
|
172975
173513
|
console.log(` ${formatReasoning(model)}${separator()}${badge("context", model.contextWindow.toLocaleString())}${separator()}${badge("max", model.maxTokens.toLocaleString())}${separator()}${formatSource(model)}${localBadge}`);
|
|
172976
173514
|
console.log(muted(` ${model.baseUrl}`));
|
|
172977
173515
|
}
|
|
@@ -172984,7 +173522,7 @@ function filterModels(providerFilter) {
|
|
|
172984
173522
|
}
|
|
172985
173523
|
function printEmptyState(providerFilter) {
|
|
172986
173524
|
if (providerFilter) {
|
|
172987
|
-
console.error(
|
|
173525
|
+
console.error(chalk73.red(`No models registered for provider "${providerFilter}".`));
|
|
172988
173526
|
} else {
|
|
172989
173527
|
console.log(badge("No models registered", void 0, "warn"));
|
|
172990
173528
|
}
|
|
@@ -173017,7 +173555,7 @@ async function handleModelsList(providerFilter) {
|
|
|
173017
173555
|
continue;
|
|
173018
173556
|
entries.sort((a, b) => a.id.localeCompare(b.id));
|
|
173019
173557
|
const providerLabel = entries[0]?.providerName ?? provider;
|
|
173020
|
-
console.log(`${
|
|
173558
|
+
console.log(`${chalk73.cyan(provider)} ${separator()} ${badge("models", String(entries.length))}`);
|
|
173021
173559
|
console.log(muted(` ${providerLabel}`));
|
|
173022
173560
|
for (const model of entries) {
|
|
173023
173561
|
printModelEntry(model);
|
|
@@ -173076,7 +173614,7 @@ async function handleModelsProviders(providerFilter) {
|
|
|
173076
173614
|
if (entry2.custom > 0)
|
|
173077
173615
|
sourceSummary.push(`${entry2.custom} custom`);
|
|
173078
173616
|
const localLabel = entry2.localCount ? `${entry2.localCount} local endpoint${entry2.localCount === 1 ? "" : "s"}` : "no local endpoints";
|
|
173079
|
-
console.log(`${
|
|
173617
|
+
console.log(`${chalk73.cyan(provider)} ${separator()} ${badge("models", String(entry2.total))}`);
|
|
173080
173618
|
console.log(muted(` ${entry2.name} (${sourceSummary.join(", ") || "0 models"})`));
|
|
173081
173619
|
console.log(muted(` ${localLabel}`));
|
|
173082
173620
|
const envLabel = envVars.length ? envVars.join(", ") : "(custom or not configured)";
|
|
@@ -173116,7 +173654,7 @@ async function resolveModelFromArgs(params) {
|
|
|
173116
173654
|
if (maybeProvider && maybeModelId && !maybeProvider.includes(".")) {
|
|
173117
173655
|
provider = maybeProvider;
|
|
173118
173656
|
modelId = maybeModelId;
|
|
173119
|
-
console.log(
|
|
173657
|
+
console.log(chalk74.dim(`Parsed model: ${parsedModel} \u2192 ${provider}/${modelId}`));
|
|
173120
173658
|
}
|
|
173121
173659
|
}
|
|
173122
173660
|
if (modelId && !provider) {
|
|
@@ -173124,14 +173662,14 @@ async function resolveModelFromArgs(params) {
|
|
|
173124
173662
|
if (resolved) {
|
|
173125
173663
|
provider = resolved.provider;
|
|
173126
173664
|
modelId = resolved.modelId;
|
|
173127
|
-
console.log(
|
|
173665
|
+
console.log(chalk74.dim(`Using alias: ${parsedModel} \u2192 ${provider}/${modelId}`));
|
|
173128
173666
|
}
|
|
173129
173667
|
}
|
|
173130
173668
|
if (modelId && !provider) {
|
|
173131
173669
|
const foundModel = findModelById(modelId);
|
|
173132
173670
|
if (foundModel) {
|
|
173133
173671
|
provider = foundModel.provider;
|
|
173134
|
-
console.log(
|
|
173672
|
+
console.log(chalk74.dim(`Found model: ${modelId} (provider: ${provider})`));
|
|
173135
173673
|
}
|
|
173136
173674
|
}
|
|
173137
173675
|
if (!provider || !modelId) {
|
|
@@ -174169,7 +174707,7 @@ async function createToolsAndSandbox(params) {
|
|
|
174169
174707
|
throw new Error(`No valid tools matched --tools filter: ${parsedTools.join(", ")}. Available tools: ${Object.keys(toolRegistry).sort().join(", ")}`);
|
|
174170
174708
|
}
|
|
174171
174709
|
baseTools = filteredTools;
|
|
174172
|
-
console.log(
|
|
174710
|
+
console.log(chalk75.dim(`Tools restricted to: ${filteredTools.map((t2) => t2.name).join(", ")}`));
|
|
174173
174711
|
}
|
|
174174
174712
|
const inlineTools = loadInlineTools();
|
|
174175
174713
|
const allTools = [...baseTools, ...inlineTools];
|
|
@@ -174276,12 +174814,12 @@ function createAgentInstance(params) {
|
|
|
174276
174814
|
if (params.readonly) {
|
|
174277
174815
|
const success = composerManager.activate("explore", cwd);
|
|
174278
174816
|
if (!success) {
|
|
174279
|
-
console.warn(
|
|
174817
|
+
console.warn(chalk76.yellow('Warning: Could not activate read-only mode. The "explore" composer may not be available.'));
|
|
174280
174818
|
}
|
|
174281
174819
|
} else if (params.composer) {
|
|
174282
174820
|
const success = composerManager.activate(params.composer, cwd);
|
|
174283
174821
|
if (!success) {
|
|
174284
|
-
console.warn(
|
|
174822
|
+
console.warn(chalk76.yellow(`Warning: Could not activate composer "${params.composer}". Check that it exists.`));
|
|
174285
174823
|
}
|
|
174286
174824
|
}
|
|
174287
174825
|
return { agent };
|
|
@@ -174514,7 +175052,7 @@ async function restoreSessionState(params) {
|
|
|
174514
175052
|
const messages = sessionManager.loadMessages();
|
|
174515
175053
|
if (messages.length > 0) {
|
|
174516
175054
|
if (shouldPrintMessages) {
|
|
174517
|
-
console.log(
|
|
175055
|
+
console.log(chalk77.dim(`Loaded ${messages.length} messages from previous session`));
|
|
174518
175056
|
}
|
|
174519
175057
|
agent.replaceMessages(messages);
|
|
174520
175058
|
}
|
|
@@ -174528,32 +175066,32 @@ async function restoreSessionState(params) {
|
|
|
174528
175066
|
agent.setModel(restoredModel);
|
|
174529
175067
|
}
|
|
174530
175068
|
if (shouldPrintMessages) {
|
|
174531
|
-
console.log(
|
|
175069
|
+
console.log(chalk77.dim(`Restored model: ${savedModel}`));
|
|
174532
175070
|
}
|
|
174533
175071
|
} catch (error) {
|
|
174534
175072
|
if (shouldPrintMessages) {
|
|
174535
175073
|
const message = error instanceof Error ? error.message : String(error);
|
|
174536
|
-
console.error(
|
|
175074
|
+
console.error(chalk77.yellow(`Warning: Could not restore model ${savedModel}: ${message}`));
|
|
174537
175075
|
}
|
|
174538
175076
|
}
|
|
174539
175077
|
} else if (shouldPrintMessages) {
|
|
174540
|
-
console.error(
|
|
175078
|
+
console.error(chalk77.yellow(`Warning: Could not restore model ${savedModel}: unknown provider`));
|
|
174541
175079
|
}
|
|
174542
175080
|
}
|
|
174543
175081
|
const thinkingLevel = sessionManager.loadThinkingLevel();
|
|
174544
175082
|
if (thinkingLevel) {
|
|
174545
175083
|
agent.setThinkingLevel(thinkingLevel);
|
|
174546
175084
|
if (shouldPrintMessages) {
|
|
174547
|
-
console.log(
|
|
175085
|
+
console.log(chalk77.dim(`Restored thinking level: ${thinkingLevel}`));
|
|
174548
175086
|
}
|
|
174549
175087
|
}
|
|
174550
175088
|
}
|
|
174551
175089
|
if (shouldPrintMessages && !isContinueOrResume) {
|
|
174552
175090
|
const contextFiles = loadProjectContextFiles();
|
|
174553
175091
|
if (contextFiles.length > 0) {
|
|
174554
|
-
console.log(
|
|
175092
|
+
console.log(chalk77.dim("Loaded project context from:"));
|
|
174555
175093
|
for (const { path: filePath } of contextFiles) {
|
|
174556
|
-
console.log(
|
|
175094
|
+
console.log(chalk77.dim(` - ${filePath}`));
|
|
174557
175095
|
}
|
|
174558
175096
|
}
|
|
174559
175097
|
}
|
|
@@ -174561,7 +175099,7 @@ async function restoreSessionState(params) {
|
|
|
174561
175099
|
if (models && models.length > 0) {
|
|
174562
175100
|
scopedModels = resolveModelScope(models);
|
|
174563
175101
|
if (scopedModels.length === 0 && shouldPrintMessages) {
|
|
174564
|
-
console.log(
|
|
175102
|
+
console.log(chalk77.yellow(`Warning: --models patterns (${models.join(", ")}) did not match any registered models`));
|
|
174565
175103
|
}
|
|
174566
175104
|
}
|
|
174567
175105
|
let startupChangelogSummary = null;
|
|
@@ -174834,13 +175372,13 @@ function setupEventSubscriptions(params) {
|
|
|
174834
175372
|
const sessions2 = sessionManager.loadAllSessions();
|
|
174835
175373
|
activeCount = sessions2.filter((s2) => Date.now() - s2.modified.getTime() < 60 * 60 * 1e3).length;
|
|
174836
175374
|
} catch (error) {
|
|
174837
|
-
console.error(
|
|
175375
|
+
console.error(chalk78.yellow(`[Policy] Failed to count active sessions: ${error instanceof Error ? error.message : String(error)}`));
|
|
174838
175376
|
}
|
|
174839
175377
|
const limitCheck = checkSessionLimits({ startedAt: /* @__PURE__ */ new Date() }, activeCount !== void 0 ? { activeSessionCount: activeCount + 1 } : void 0);
|
|
174840
175378
|
if (!limitCheck.allowed) {
|
|
174841
175379
|
const msg = `
|
|
174842
175380
|
[Policy] ${limitCheck.reason}`;
|
|
174843
|
-
console.error(
|
|
175381
|
+
console.error(chalk78.red(msg));
|
|
174844
175382
|
process.exit(1);
|
|
174845
175383
|
}
|
|
174846
175384
|
sessionManager.startSession(agent.state);
|
|
@@ -175146,7 +175684,7 @@ async function main(args) {
|
|
|
175146
175684
|
process.exit(0);
|
|
175147
175685
|
}
|
|
175148
175686
|
if (parsed.error) {
|
|
175149
|
-
console.error(
|
|
175687
|
+
console.error(chalk79.red(parsed.error));
|
|
175150
175688
|
process.exit(1);
|
|
175151
175689
|
}
|
|
175152
175690
|
if (parsed.command === "hosted-runner") {
|
|
@@ -175158,7 +175696,7 @@ async function main(args) {
|
|
|
175158
175696
|
}
|
|
175159
175697
|
if (parsed.command === "web") {
|
|
175160
175698
|
if (parsed.messages.length > 0) {
|
|
175161
|
-
console.error(
|
|
175699
|
+
console.error(chalk79.red("`maestro web` does not accept prompt arguments. Use `maestro` (interactive) or `maestro exec` instead."));
|
|
175162
175700
|
process.exit(1);
|
|
175163
175701
|
}
|
|
175164
175702
|
const { startWebServer: startWebServer2 } = await Promise.resolve().then(() => (init_web_server(), exports_web_server));
|
|
@@ -175201,7 +175739,7 @@ async function main(args) {
|
|
|
175201
175739
|
process.stderr.write(`${stack ?? message}
|
|
175202
175740
|
`);
|
|
175203
175741
|
} else {
|
|
175204
|
-
console.error(
|
|
175742
|
+
console.error(chalk79.red(message));
|
|
175205
175743
|
}
|
|
175206
175744
|
process.exit(1);
|
|
175207
175745
|
};
|
|
@@ -175284,7 +175822,7 @@ async function main(args) {
|
|
|
175284
175822
|
startupProfiler.checkpoint("runtime:prepared");
|
|
175285
175823
|
const frameworkWarning = validateFrameworkPreference();
|
|
175286
175824
|
if (frameworkWarning) {
|
|
175287
|
-
console.warn(
|
|
175825
|
+
console.warn(chalk79.yellow(`Framework preference warning: ${frameworkWarning}`));
|
|
175288
175826
|
}
|
|
175289
175827
|
if (parsed.command === "config") {
|
|
175290
175828
|
const {
|
|
@@ -175307,13 +175845,13 @@ async function main(args) {
|
|
|
175307
175845
|
await handleConfigLocal2();
|
|
175308
175846
|
return;
|
|
175309
175847
|
default:
|
|
175310
|
-
console.error(
|
|
175311
|
-
console.log(
|
|
175848
|
+
console.error(chalk79.red(`Unknown config subcommand: ${parsed.subcommand || "(none)"}`));
|
|
175849
|
+
console.log(chalk79.dim(`
|
|
175312
175850
|
Available commands:`));
|
|
175313
|
-
console.log(
|
|
175314
|
-
console.log(
|
|
175315
|
-
console.log(
|
|
175316
|
-
console.log(
|
|
175851
|
+
console.log(chalk79.dim(" maestro config validate - Validate configuration"));
|
|
175852
|
+
console.log(chalk79.dim(" maestro config show - Show configuration details"));
|
|
175853
|
+
console.log(chalk79.dim(" maestro config init - Initialize configuration"));
|
|
175854
|
+
console.log(chalk79.dim(" maestro config local - Manage local providers"));
|
|
175317
175855
|
process.exit(1);
|
|
175318
175856
|
}
|
|
175319
175857
|
}
|
|
@@ -175327,6 +175865,11 @@ Available commands:`));
|
|
|
175327
175865
|
await handleEvalOpsCommand2(parsed.subcommand);
|
|
175328
175866
|
return;
|
|
175329
175867
|
}
|
|
175868
|
+
if (parsed.command === "init") {
|
|
175869
|
+
const { handleInitCommand: handleInitCommand3 } = await Promise.resolve().then(() => (init_init(), exports_init));
|
|
175870
|
+
await handleInitCommand3(parsed.commandArgs ?? []);
|
|
175871
|
+
return;
|
|
175872
|
+
}
|
|
175330
175873
|
if (parsed.command === "codex") {
|
|
175331
175874
|
const { handleCodexCommand: handleCodexCommand2 } = await Promise.resolve().then(() => (init_codex(), exports_codex));
|
|
175332
175875
|
await handleCodexCommand2(parsed.subcommand, parsed.messages);
|
|
@@ -175382,16 +175925,16 @@ Available commands:`));
|
|
|
175382
175925
|
await handleCostSummary2("today");
|
|
175383
175926
|
return;
|
|
175384
175927
|
default:
|
|
175385
|
-
console.error(
|
|
175386
|
-
console.log(
|
|
175928
|
+
console.error(chalk79.red(`Unknown cost subcommand: ${parsed.subcommand}`));
|
|
175929
|
+
console.log(chalk79.dim(`
|
|
175387
175930
|
Available commands:`));
|
|
175388
|
-
console.log(
|
|
175389
|
-
console.log(
|
|
175390
|
-
console.log(
|
|
175391
|
-
console.log(
|
|
175392
|
-
console.log(
|
|
175393
|
-
console.log(
|
|
175394
|
-
console.log(
|
|
175931
|
+
console.log(chalk79.dim(" maestro cost [today] - Show today's costs (default)"));
|
|
175932
|
+
console.log(chalk79.dim(" maestro cost yesterday - Show yesterday's costs"));
|
|
175933
|
+
console.log(chalk79.dim(" maestro cost week - Show last 7 days"));
|
|
175934
|
+
console.log(chalk79.dim(" maestro cost month - Show last 30 days"));
|
|
175935
|
+
console.log(chalk79.dim(" maestro cost all - Show all time costs"));
|
|
175936
|
+
console.log(chalk79.dim(" maestro cost breakdown - Detailed breakdown"));
|
|
175937
|
+
console.log(chalk79.dim(" maestro cost clear - Clear usage data"));
|
|
175395
175938
|
process.exit(1);
|
|
175396
175939
|
}
|
|
175397
175940
|
}
|
|
@@ -175412,15 +175955,15 @@ Available commands:`));
|
|
|
175412
175955
|
});
|
|
175413
175956
|
return;
|
|
175414
175957
|
default:
|
|
175415
|
-
console.error(
|
|
175416
|
-
console.log(
|
|
175958
|
+
console.error(chalk79.red(`Unknown stats subcommand: ${parsed.subcommand}`));
|
|
175959
|
+
console.log(chalk79.dim(`
|
|
175417
175960
|
Available commands:`));
|
|
175418
|
-
console.log(
|
|
175419
|
-
console.log(
|
|
175420
|
-
console.log(
|
|
175421
|
-
console.log(
|
|
175422
|
-
console.log(
|
|
175423
|
-
console.log(
|
|
175961
|
+
console.log(chalk79.dim(" maestro stats - Show last 7 days"));
|
|
175962
|
+
console.log(chalk79.dim(" maestro stats --session <id> - Show one session"));
|
|
175963
|
+
console.log(chalk79.dim(" maestro stats today - Show today"));
|
|
175964
|
+
console.log(chalk79.dim(" maestro stats month - Show last 30 days"));
|
|
175965
|
+
console.log(chalk79.dim(" maestro stats all - Show all time"));
|
|
175966
|
+
console.log(chalk79.dim(" maestro stats --format json|csv - Export usage data"));
|
|
175424
175967
|
process.exit(1);
|
|
175425
175968
|
}
|
|
175426
175969
|
}
|
|
@@ -175436,11 +175979,11 @@ Available commands:`));
|
|
|
175436
175979
|
await handleModelsList2(providerFilter);
|
|
175437
175980
|
return;
|
|
175438
175981
|
default:
|
|
175439
|
-
console.error(
|
|
175440
|
-
console.log(
|
|
175982
|
+
console.error(chalk79.red(`Unknown models subcommand: ${parsed.subcommand || "(none)"}`));
|
|
175983
|
+
console.log(chalk79.dim(`
|
|
175441
175984
|
Available commands:`));
|
|
175442
|
-
console.log(
|
|
175443
|
-
console.log(
|
|
175985
|
+
console.log(chalk79.dim(" maestro models list - List registered models"));
|
|
175986
|
+
console.log(chalk79.dim(" maestro models providers - Summarize providers"));
|
|
175444
175987
|
process.exit(1);
|
|
175445
175988
|
}
|
|
175446
175989
|
}
|
|
@@ -175449,7 +175992,7 @@ Available commands:`));
|
|
|
175449
175992
|
if (parsed.command === "agents") {
|
|
175450
175993
|
const { buildAgentsInitPrompt: buildAgentsInitPrompt2, handleAgentsInit: handleAgentsInit2 } = await Promise.resolve().then(() => (init_agents(), exports_agents));
|
|
175451
175994
|
if (parsed.subcommand && parsed.subcommand !== "init") {
|
|
175452
|
-
console.error(
|
|
175995
|
+
console.error(chalk79.red(`Unknown agents subcommand: ${parsed.subcommand}. Try "maestro agents init"`));
|
|
175453
175996
|
process.exit(1);
|
|
175454
175997
|
}
|
|
175455
175998
|
try {
|
|
@@ -175462,7 +176005,7 @@ Available commands:`));
|
|
|
175462
176005
|
}
|
|
175463
176006
|
} catch (error) {
|
|
175464
176007
|
const message = error instanceof Error ? error.message : "Failed to initialize AGENTS.md";
|
|
175465
|
-
console.error(
|
|
176008
|
+
console.error(chalk79.red(message));
|
|
175466
176009
|
process.exit(1);
|
|
175467
176010
|
}
|
|
175468
176011
|
}
|
|
@@ -175474,14 +176017,14 @@ Available commands:`));
|
|
|
175474
176017
|
if (parsed.execResumeId) {
|
|
175475
176018
|
targetPath = sessionManager.getSessionFileById(parsed.execResumeId);
|
|
175476
176019
|
if (!targetPath) {
|
|
175477
|
-
console.error(
|
|
176020
|
+
console.error(chalk79.red(`No session found with id ${parsed.execResumeId}.`));
|
|
175478
176021
|
process.exit(1);
|
|
175479
176022
|
}
|
|
175480
176023
|
} else if (parsed.execUseLast) {
|
|
175481
176024
|
const sessions2 = sessionManager.loadAllSessions();
|
|
175482
176025
|
const lastExec = sessions2.find((session) => session.summary?.startsWith(EXEC_SESSION_SUMMARY_PREFIX));
|
|
175483
176026
|
if (!lastExec) {
|
|
175484
|
-
console.error(
|
|
176027
|
+
console.error(chalk79.red("No previous maestro exec sessions were found."));
|
|
175485
176028
|
process.exit(1);
|
|
175486
176029
|
}
|
|
175487
176030
|
targetPath = lastExec.path;
|
|
@@ -175497,7 +176040,7 @@ Available commands:`));
|
|
|
175497
176040
|
if (parsed.resume) {
|
|
175498
176041
|
const selectedSession = await selectSession(sessionManager);
|
|
175499
176042
|
if (!selectedSession) {
|
|
175500
|
-
console.log(
|
|
176043
|
+
console.log(chalk79.dim("No session selected"));
|
|
175501
176044
|
return;
|
|
175502
176045
|
}
|
|
175503
176046
|
sessionManager.setSessionFile(selectedSession);
|
|
@@ -175618,10 +176161,10 @@ Available commands:`));
|
|
|
175618
176161
|
const shouldPrintMessages = (isInteractive || mode === "text") && mode !== "headless" && !parsed.headless;
|
|
175619
176162
|
const isGitRepository = isInsideGitRepository();
|
|
175620
176163
|
if (sandbox && shouldPrintMessages) {
|
|
175621
|
-
console.log(
|
|
176164
|
+
console.log(chalk79.dim(`Sandbox enabled (mode: ${sandboxMode})`));
|
|
175622
176165
|
}
|
|
175623
176166
|
if (approvalModeOverride === "auto" && !isGitRepository && shouldPrintMessages) {
|
|
175624
|
-
console.log(
|
|
176167
|
+
console.log(chalk79.yellow("Auto approval is enabled outside a git repository. Changes will not be version controlled."));
|
|
175625
176168
|
}
|
|
175626
176169
|
const shouldRestoreSession = parsed.continue || parsed.resume || execResumeApplied;
|
|
175627
176170
|
const isFreshInteractiveSession = isInteractive && !shouldRestoreSession && mode !== "rpc";
|
|
@@ -175686,9 +176229,9 @@ Available commands:`));
|
|
|
175686
176229
|
const targetPath = agentsInitPath ?? "AGENTS.md";
|
|
175687
176230
|
const displayPath = targetPath.startsWith(cwd) && targetPath !== cwd ? `.${targetPath.slice(cwd.length)}` : targetPath;
|
|
175688
176231
|
const runMode = mode === "rpc" || mode === "headless" ? "text" : mode;
|
|
175689
|
-
console.log(
|
|
176232
|
+
console.log(chalk79.green(`Drafting AGENTS.md at ${displayPath}...`));
|
|
175690
176233
|
await runSingleShotMode(agent, sessionManager, [agentsInitPrompt], runMode);
|
|
175691
|
-
console.log(
|
|
176234
|
+
console.log(chalk79.dim(`AGENTS.md generated at ${displayPath}`));
|
|
175692
176235
|
} else if (mode === "headless" || parsed.headless) {
|
|
175693
176236
|
startupProfiler.terminal("headless:ready");
|
|
175694
176237
|
await runHeadlessMode(agent, sessionManager, approvalService, toolRetryService);
|