@evalops/maestro 0.10.10 → 0.10.12
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 +5 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands/config.d.ts.map +1 -1
- package/dist/cli/commands/config.js +3 -2
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/evalops.d.ts +1 -1
- package/dist/cli/commands/evalops.d.ts.map +1 -1
- package/dist/cli/commands/evalops.js +28 -2
- package/dist/cli/commands/evalops.js.map +1 -1
- package/dist/cli/commands/init.d.ts +5 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +166 -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 +982 -293
- 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 +477 -0
- package/dist/evalops/agent-bootstrap.js.map +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -1
- 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/models/builtin.d.ts.map +1 -1
- package/dist/models/builtin.js +2 -3
- package/dist/models/builtin.js.map +1 -1
- package/dist/oauth/evalops.d.ts.map +1 -1
- package/dist/oauth/evalops.js +3 -2
- package/dist/oauth/evalops.js.map +1 -1
- package/dist/platform/core-services.d.ts +1 -0
- package/dist/platform/core-services.d.ts.map +1 -1
- package/dist/platform/core-services.js +1 -0
- package/dist/platform/core-services.js.map +1 -1
- package/dist/providers/auth.d.ts +1 -1
- package/dist/providers/auth.d.ts.map +1 -1
- package/dist/providers/auth.js +30 -2
- package/dist/providers/auth.js.map +1 -1
- package/dist/providers/evalops-managed.d.ts +1 -0
- package/dist/providers/evalops-managed.d.ts.map +1 -1
- package/dist/providers/evalops-managed.js +1 -0
- package/dist/providers/evalops-managed.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;
|
|
@@ -48365,6 +48369,7 @@ function assertEvalOpsManagedGatewayEnabled() {
|
|
|
48365
48369
|
}
|
|
48366
48370
|
throw new Error("EvalOps managed gateway access is currently disabled by dynamic config.");
|
|
48367
48371
|
}
|
|
48372
|
+
var DEFAULT_EVALOPS_MANAGED_GATEWAY_BASE_URL = "https://llm-gateway.evalops.dev/v1";
|
|
48368
48373
|
var ALL_EVALOPS_MANAGED_PROVIDER_DEFINITIONS;
|
|
48369
48374
|
var managedProvidersByID;
|
|
48370
48375
|
var init_evalops_managed = __esm2(() => {
|
|
@@ -49288,6 +49293,7 @@ var init_core_services = __esm2(() => {
|
|
|
49288
49293
|
};
|
|
49289
49294
|
PLATFORM_HTTP_ROUTES = {
|
|
49290
49295
|
identity: {
|
|
49296
|
+
apiKeys: "/v1/api-keys",
|
|
49291
49297
|
authGoogleStart: "/v1/auth/google/start",
|
|
49292
49298
|
deviceChallenges: "/v1/device-challenges",
|
|
49293
49299
|
devices: "/v1/devices",
|
|
@@ -51189,7 +51195,8 @@ async function loginEvalOps(onAuthUrl, onStatus) {
|
|
|
51189
51195
|
const result = await Promise.race([
|
|
51190
51196
|
getResult(),
|
|
51191
51197
|
new Promise((_, reject) => {
|
|
51192
|
-
setTimeout(() => reject(new Error("EvalOps login timed out after 5 minutes")), 5 * 60 * 1e3);
|
|
51198
|
+
const timeout = setTimeout(() => reject(new Error("EvalOps login timed out after 5 minutes")), 5 * 60 * 1e3);
|
|
51199
|
+
timeout.unref?.();
|
|
51193
51200
|
})
|
|
51194
51201
|
]);
|
|
51195
51202
|
const deviceId = await enrollDesktopDeviceIdentity(identityBaseUrl, result.accessToken, process.env.npm_package_version);
|
|
@@ -51281,7 +51288,7 @@ var CALLBACK_PORT = 1460;
|
|
|
51281
51288
|
var CALLBACK_PATH = "/auth/callback/evalops";
|
|
51282
51289
|
var CALLBACK_ORIGIN;
|
|
51283
51290
|
var CALLBACK_URI;
|
|
51284
|
-
var DEFAULT_IDENTITY_URL = "
|
|
51291
|
+
var DEFAULT_IDENTITY_URL = "https://identity.evalops.dev";
|
|
51285
51292
|
var IDENTITY_BASE_URL_ENV_VARS;
|
|
51286
51293
|
var SHARED_PLATFORM_BASE_URL_ENV_VARS;
|
|
51287
51294
|
var DEFAULT_PROVIDER_REF_PROVIDER = "openai";
|
|
@@ -53647,8 +53654,8 @@ function isPrivateIP(ip) {
|
|
|
53647
53654
|
}
|
|
53648
53655
|
return false;
|
|
53649
53656
|
}
|
|
53650
|
-
function isLocalhostAlias(
|
|
53651
|
-
const lower2 =
|
|
53657
|
+
function isLocalhostAlias(hostname2) {
|
|
53658
|
+
const lower2 = hostname2.toLowerCase();
|
|
53652
53659
|
return lower2 === "localhost" || lower2 === "localhost.localdomain" || lower2 === "0.0.0.0";
|
|
53653
53660
|
}
|
|
53654
53661
|
function extractUrlsFromValue(value) {
|
|
@@ -58830,8 +58837,8 @@ function isLocalBaseUrl(url) {
|
|
|
58830
58837
|
}
|
|
58831
58838
|
try {
|
|
58832
58839
|
const parsed = new URL(url);
|
|
58833
|
-
const
|
|
58834
|
-
return
|
|
58840
|
+
const hostname2 = parsed.hostname.replace(/^\[|\]$/g, "");
|
|
58841
|
+
return hostname2 === "localhost" || hostname2 === "127.0.0.1" || hostname2 === "::1" || hostname2 === "0.0.0.0";
|
|
58835
58842
|
} catch {
|
|
58836
58843
|
return false;
|
|
58837
58844
|
}
|
|
@@ -70078,7 +70085,7 @@ var init_models_generated = __esm2(() => {
|
|
|
70078
70085
|
});
|
|
70079
70086
|
function getManagedGatewayBaseUrl() {
|
|
70080
70087
|
const configured2 = process.env.MAESTRO_LLM_GATEWAY_URL?.trim();
|
|
70081
|
-
return configured2 ||
|
|
70088
|
+
return configured2 || DEFAULT_EVALOPS_MANAGED_GATEWAY_BASE_URL;
|
|
70082
70089
|
}
|
|
70083
70090
|
function getManagedGatewayBaseUrlForApi(api) {
|
|
70084
70091
|
const managedBaseUrl = getManagedGatewayBaseUrl();
|
|
@@ -70196,7 +70203,6 @@ function getProviders() {
|
|
|
70196
70203
|
function getModels(provider) {
|
|
70197
70204
|
return getBuiltinModels()[provider] || [];
|
|
70198
70205
|
}
|
|
70199
|
-
var DEFAULT_MANAGED_GATEWAY_BASE_URL = "http://127.0.0.1:8081/v1";
|
|
70200
70206
|
var ANTHROPIC_OPUS_46_OVERLAY;
|
|
70201
70207
|
var OPENROUTER_RESPONSES_OVERLAY;
|
|
70202
70208
|
var GROQ_RESPONSES_OVERLAY;
|
|
@@ -85988,6 +85994,25 @@ function isRecord8(value) {
|
|
|
85988
85994
|
function getNonEmptyString(value) {
|
|
85989
85995
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
85990
85996
|
}
|
|
85997
|
+
function getStringArray2(value) {
|
|
85998
|
+
return Array.isArray(value) ? value.map((entry2) => typeof entry2 === "string" ? entry2.trim() : "").filter((entry2) => entry2.length > 0) : [];
|
|
85999
|
+
}
|
|
86000
|
+
function isFutureTimestamp(value) {
|
|
86001
|
+
const timestamp3 = getNonEmptyString(value);
|
|
86002
|
+
return !timestamp3 || Date.parse(timestamp3) > Date.now();
|
|
86003
|
+
}
|
|
86004
|
+
function resolveEvalOpsAgentMcpAPIKey(metadata) {
|
|
86005
|
+
const agentMcp = isRecord8(metadata?.agentMcp) ? metadata.agentMcp : void 0;
|
|
86006
|
+
const apiKey = getNonEmptyString(agentMcp?.apiKey);
|
|
86007
|
+
if (!apiKey || !isFutureTimestamp(agentMcp?.expiresAt)) {
|
|
86008
|
+
return;
|
|
86009
|
+
}
|
|
86010
|
+
const scopes = getStringArray2(agentMcp?.scopes);
|
|
86011
|
+
if (scopes.length > 0 && !scopes.includes("llm_gateway:invoke")) {
|
|
86012
|
+
return;
|
|
86013
|
+
}
|
|
86014
|
+
return apiKey;
|
|
86015
|
+
}
|
|
85991
86016
|
function resolveEvalOpsOrganizationId(metadata) {
|
|
85992
86017
|
const candidate = getNonEmptyString(metadata?.organizationId);
|
|
85993
86018
|
if (candidate && candidate.trim().length > 0) {
|
|
@@ -86069,10 +86094,15 @@ function createAuthResolver(options) {
|
|
|
86069
86094
|
};
|
|
86070
86095
|
}
|
|
86071
86096
|
if (isEvalOpsManagedProvider(provider) && options.mode !== "api-key") {
|
|
86097
|
+
const credentials = loadOAuthCredentials("evalops");
|
|
86098
|
+
const agentAPIKey = resolveEvalOpsAgentMcpAPIKey(credentials?.metadata);
|
|
86099
|
+
if (agentAPIKey) {
|
|
86100
|
+
return buildEvalOpsCredential(provider, agentAPIKey, "evalops_agent_key_file", credentials?.metadata);
|
|
86101
|
+
}
|
|
86072
86102
|
const oauthToken = await getOAuthToken("evalops");
|
|
86073
86103
|
if (oauthToken) {
|
|
86074
|
-
const
|
|
86075
|
-
return buildEvalOpsCredential(provider, oauthToken, "evalops_oauth_file", credentials?.metadata);
|
|
86104
|
+
const refreshedCredentials = loadOAuthCredentials("evalops");
|
|
86105
|
+
return buildEvalOpsCredential(provider, oauthToken, "evalops_oauth_file", refreshedCredentials?.metadata ?? credentials?.metadata);
|
|
86076
86106
|
}
|
|
86077
86107
|
}
|
|
86078
86108
|
if (isOpenAICodexProvider(provider) && options.mode !== "api-key") {
|
|
@@ -87024,6 +87054,457 @@ var init_env_limits = __esm2(() => {
|
|
|
87024
87054
|
}
|
|
87025
87055
|
];
|
|
87026
87056
|
});
|
|
87057
|
+
function loadPackageMetadata() {
|
|
87058
|
+
if (cachedPackageMetadata) {
|
|
87059
|
+
return cachedPackageMetadata;
|
|
87060
|
+
}
|
|
87061
|
+
try {
|
|
87062
|
+
const packageJson4 = createRequire4(import.meta.url)("../package.json");
|
|
87063
|
+
cachedPackageMetadata = packageJson4;
|
|
87064
|
+
return packageJson4;
|
|
87065
|
+
} catch {
|
|
87066
|
+
cachedPackageMetadata = {};
|
|
87067
|
+
return cachedPackageMetadata;
|
|
87068
|
+
}
|
|
87069
|
+
}
|
|
87070
|
+
function getPackageVersion() {
|
|
87071
|
+
return process.env.MAESTRO_VERSION ?? loadPackageMetadata().version ?? "unknown";
|
|
87072
|
+
}
|
|
87073
|
+
function getPackageName() {
|
|
87074
|
+
const metadata = loadPackageMetadata();
|
|
87075
|
+
return process.env.MAESTRO_PACKAGE_NAME ?? metadata.name ?? metadata.maestro?.canonicalPackageName ?? "@evalops/maestro";
|
|
87076
|
+
}
|
|
87077
|
+
function getGlobalInstallCommand(packageManager = "npm", packageName = getPackageName()) {
|
|
87078
|
+
return `${packageManager} install -g ${packageName}`;
|
|
87079
|
+
}
|
|
87080
|
+
var cachedPackageMetadata = null;
|
|
87081
|
+
var init_package_metadata = () => {
|
|
87082
|
+
};
|
|
87083
|
+
function isRecord9(value) {
|
|
87084
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
87085
|
+
}
|
|
87086
|
+
function nonEmptyString(value) {
|
|
87087
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
87088
|
+
}
|
|
87089
|
+
function stringArray(value) {
|
|
87090
|
+
if (!Array.isArray(value)) {
|
|
87091
|
+
return;
|
|
87092
|
+
}
|
|
87093
|
+
const values = value.map((entry2) => nonEmptyString(entry2)).filter((entry2) => Boolean(entry2));
|
|
87094
|
+
return values.length > 0 ? values : void 0;
|
|
87095
|
+
}
|
|
87096
|
+
function positiveInteger(value) {
|
|
87097
|
+
return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
|
|
87098
|
+
}
|
|
87099
|
+
function getStoredAgentMcpMetadata(credentials) {
|
|
87100
|
+
const metadata = credentials?.metadata;
|
|
87101
|
+
const agentMcp = isRecord9(metadata?.agentMcp) ? metadata.agentMcp : void 0;
|
|
87102
|
+
const apiKey = nonEmptyString(agentMcp?.apiKey);
|
|
87103
|
+
const endpoint = nonEmptyString(agentMcp?.endpoint);
|
|
87104
|
+
const registeredAt = nonEmptyString(agentMcp?.registeredAt);
|
|
87105
|
+
const createdAt = nonEmptyString(agentMcp?.createdAt);
|
|
87106
|
+
const surface = nonEmptyString(agentMcp?.surface);
|
|
87107
|
+
if (!apiKey || !endpoint || !registeredAt || !createdAt || !surface) {
|
|
87108
|
+
return;
|
|
87109
|
+
}
|
|
87110
|
+
return {
|
|
87111
|
+
type: "agent-mcp",
|
|
87112
|
+
apiKey,
|
|
87113
|
+
createdAt,
|
|
87114
|
+
endpoint,
|
|
87115
|
+
registeredAt,
|
|
87116
|
+
surface,
|
|
87117
|
+
agentId: nonEmptyString(agentMcp?.agentId),
|
|
87118
|
+
expiresAt: nonEmptyString(agentMcp?.expiresAt),
|
|
87119
|
+
keyId: nonEmptyString(agentMcp?.keyId),
|
|
87120
|
+
keyName: nonEmptyString(agentMcp?.keyName),
|
|
87121
|
+
keyPrefix: nonEmptyString(agentMcp?.keyPrefix),
|
|
87122
|
+
manifestUrl: nonEmptyString(agentMcp?.manifestUrl),
|
|
87123
|
+
registryVisible: typeof agentMcp?.registryVisible === "boolean" ? agentMcp.registryVisible : void 0,
|
|
87124
|
+
runId: nonEmptyString(agentMcp?.runId),
|
|
87125
|
+
scopes: stringArray(agentMcp?.scopes),
|
|
87126
|
+
sessionExpiresAt: nonEmptyString(agentMcp?.sessionExpiresAt),
|
|
87127
|
+
workspaceId: nonEmptyString(agentMcp?.workspaceId)
|
|
87128
|
+
};
|
|
87129
|
+
}
|
|
87130
|
+
function getStoredEvalOpsAgentMcpMetadata() {
|
|
87131
|
+
return getStoredAgentMcpMetadata(loadOAuthCredentials("evalops"));
|
|
87132
|
+
}
|
|
87133
|
+
function normalizeMcpEndpoint(url) {
|
|
87134
|
+
const normalized = normalizeBaseUrl2(url);
|
|
87135
|
+
const parsed = new URL(normalized);
|
|
87136
|
+
if (parsed.pathname === "" || parsed.pathname === "/" || parsed.pathname === AGENT_MCP_MANIFEST_PATH) {
|
|
87137
|
+
parsed.pathname = AGENT_MCP_PATH;
|
|
87138
|
+
parsed.search = "";
|
|
87139
|
+
parsed.hash = "";
|
|
87140
|
+
}
|
|
87141
|
+
return normalizeBaseUrl2(parsed.toString());
|
|
87142
|
+
}
|
|
87143
|
+
function normalizeManifestUrl(url) {
|
|
87144
|
+
const normalized = normalizeBaseUrl2(url);
|
|
87145
|
+
const parsed = new URL(normalized);
|
|
87146
|
+
if (parsed.pathname === "" || parsed.pathname === "/") {
|
|
87147
|
+
parsed.pathname = AGENT_MCP_MANIFEST_PATH;
|
|
87148
|
+
}
|
|
87149
|
+
return parsed.toString();
|
|
87150
|
+
}
|
|
87151
|
+
function resolveIdentityBaseUrl(credentials, endpoint) {
|
|
87152
|
+
const configured2 = getEnvValue3([
|
|
87153
|
+
"MAESTRO_IDENTITY_URL",
|
|
87154
|
+
"EVALOPS_IDENTITY_URL",
|
|
87155
|
+
"MAESTRO_PLATFORM_BASE_URL",
|
|
87156
|
+
"MAESTRO_EVALOPS_BASE_URL",
|
|
87157
|
+
"EVALOPS_BASE_URL"
|
|
87158
|
+
]);
|
|
87159
|
+
const stored = typeof credentials?.metadata?.identityBaseUrl === "string" ? credentials.metadata.identityBaseUrl : void 0;
|
|
87160
|
+
const derived = identityBaseUrlFromMcpEndpoint(endpoint?.endpoint);
|
|
87161
|
+
const storedBeforeDerived = endpoint ? !endpoint.preferDerivedIdentity && isCustomMcpEndpoint(endpoint.endpoint) : false;
|
|
87162
|
+
return normalizeBaseUrl2(configured2 ?? endpoint?.identityBaseUrl ?? (endpoint?.preferDerivedIdentity ? derived : void 0) ?? (storedBeforeDerived ? stored : void 0) ?? derived ?? stored ?? DEFAULT_IDENTITY_BASE_URL, Object.values(PLATFORM_HTTP_ROUTES.identity));
|
|
87163
|
+
}
|
|
87164
|
+
function isCustomMcpEndpoint(endpoint) {
|
|
87165
|
+
const parsed = new URL(normalizeBaseUrl2(endpoint));
|
|
87166
|
+
return parsed.hostname !== "app.evalops.dev" && parsed.hostname !== "staging.evalops.dev";
|
|
87167
|
+
}
|
|
87168
|
+
function identityBaseUrlFromMcpEndpoint(endpoint) {
|
|
87169
|
+
if (!endpoint) {
|
|
87170
|
+
return;
|
|
87171
|
+
}
|
|
87172
|
+
const parsed = new URL(normalizeBaseUrl2(endpoint));
|
|
87173
|
+
if (parsed.hostname === "app.evalops.dev") {
|
|
87174
|
+
return DEFAULT_IDENTITY_BASE_URL;
|
|
87175
|
+
}
|
|
87176
|
+
if (parsed.hostname === "staging.evalops.dev") {
|
|
87177
|
+
return "https://api.staging.evalops.dev";
|
|
87178
|
+
}
|
|
87179
|
+
if (parsed.hostname.startsWith("app.")) {
|
|
87180
|
+
parsed.hostname = `identity.${parsed.hostname.slice("app.".length)}`;
|
|
87181
|
+
}
|
|
87182
|
+
parsed.pathname = "";
|
|
87183
|
+
parsed.search = "";
|
|
87184
|
+
parsed.hash = "";
|
|
87185
|
+
return normalizeBaseUrl2(parsed.toString());
|
|
87186
|
+
}
|
|
87187
|
+
async function resolveEndpointFromManifest(manifestUrl, fetchImpl) {
|
|
87188
|
+
const response = await fetchImpl(manifestUrl, {
|
|
87189
|
+
headers: { accept: "application/json" }
|
|
87190
|
+
});
|
|
87191
|
+
if (!response.ok) {
|
|
87192
|
+
throw new Error(`Failed to fetch EvalOps MCP manifest (${response.status} ${response.statusText})`);
|
|
87193
|
+
}
|
|
87194
|
+
const payload = await response.json();
|
|
87195
|
+
const payloadRecord = isRecord9(payload) ? payload : void 0;
|
|
87196
|
+
const protocol = payloadRecord && isRecord9(payloadRecord.protocol) ? payloadRecord.protocol : void 0;
|
|
87197
|
+
const endpoint = nonEmptyString(protocol?.endpoint);
|
|
87198
|
+
if (!endpoint) {
|
|
87199
|
+
throw new Error("EvalOps MCP manifest did not include protocol.endpoint");
|
|
87200
|
+
}
|
|
87201
|
+
const identity = payloadRecord?.identity;
|
|
87202
|
+
const identityBaseUrl = nonEmptyString(isRecord9(identity) ? identity.base_url : void 0) ?? nonEmptyString(isRecord9(identity) ? identity.baseUrl : void 0) ?? nonEmptyString(isRecord9(identity) ? identity.url : void 0) ?? nonEmptyString(payloadRecord?.identity_base_url) ?? nonEmptyString(payloadRecord?.identityBaseUrl);
|
|
87203
|
+
return {
|
|
87204
|
+
endpoint: normalizeMcpEndpoint(endpoint),
|
|
87205
|
+
identityBaseUrl,
|
|
87206
|
+
manifestUrl,
|
|
87207
|
+
preferDerivedIdentity: true
|
|
87208
|
+
};
|
|
87209
|
+
}
|
|
87210
|
+
async function resolveAgentMcpEndpoint(options, deps) {
|
|
87211
|
+
if (options.mcpUrl) {
|
|
87212
|
+
return {
|
|
87213
|
+
endpoint: normalizeMcpEndpoint(options.mcpUrl),
|
|
87214
|
+
preferDerivedIdentity: true
|
|
87215
|
+
};
|
|
87216
|
+
}
|
|
87217
|
+
if (options.manifestUrl) {
|
|
87218
|
+
return resolveEndpointFromManifest(normalizeManifestUrl(options.manifestUrl), deps.fetch);
|
|
87219
|
+
}
|
|
87220
|
+
const configuredMcpUrl = getEnvValue3([
|
|
87221
|
+
"MAESTRO_PLATFORM_MCP_URL",
|
|
87222
|
+
"MAESTRO_AGENT_MCP_URL",
|
|
87223
|
+
"MAESTRO_EVALOPS_AGENT_MCP_URL"
|
|
87224
|
+
]);
|
|
87225
|
+
if (configuredMcpUrl) {
|
|
87226
|
+
return {
|
|
87227
|
+
endpoint: normalizeMcpEndpoint(configuredMcpUrl),
|
|
87228
|
+
preferDerivedIdentity: true
|
|
87229
|
+
};
|
|
87230
|
+
}
|
|
87231
|
+
const configuredManifestUrl = getEnvValue3([
|
|
87232
|
+
"MAESTRO_PLATFORM_MCP_MANIFEST_URL",
|
|
87233
|
+
"MAESTRO_AGENT_MCP_MANIFEST_URL",
|
|
87234
|
+
"MAESTRO_EVALOPS_AGENT_MCP_MANIFEST_URL"
|
|
87235
|
+
]);
|
|
87236
|
+
if (configuredManifestUrl) {
|
|
87237
|
+
return resolveEndpointFromManifest(normalizeManifestUrl(configuredManifestUrl), deps.fetch);
|
|
87238
|
+
}
|
|
87239
|
+
const stored = getStoredAgentMcpMetadata(deps.loadCredentials("evalops"));
|
|
87240
|
+
if (stored?.endpoint) {
|
|
87241
|
+
return {
|
|
87242
|
+
endpoint: normalizeMcpEndpoint(stored.endpoint),
|
|
87243
|
+
manifestUrl: stored.manifestUrl
|
|
87244
|
+
};
|
|
87245
|
+
}
|
|
87246
|
+
return resolveEndpointFromManifest(`${DEFAULT_AGENT_MCP_BASE_URL}${AGENT_MCP_MANIFEST_PATH}`, deps.fetch);
|
|
87247
|
+
}
|
|
87248
|
+
function createDefaultMcpClient(endpoint, bearerToken) {
|
|
87249
|
+
const client = new Client({
|
|
87250
|
+
name: "maestro",
|
|
87251
|
+
version: getPackageVersion()
|
|
87252
|
+
}, {
|
|
87253
|
+
capabilities: {}
|
|
87254
|
+
});
|
|
87255
|
+
const headers = {
|
|
87256
|
+
accept: "application/json, text/event-stream",
|
|
87257
|
+
"content-type": "application/json",
|
|
87258
|
+
...bearerToken ? { authorization: `Bearer ${bearerToken}` } : {}
|
|
87259
|
+
};
|
|
87260
|
+
const transport = new StreamableHTTPClientTransport(new URL(endpoint), {
|
|
87261
|
+
requestInit: {
|
|
87262
|
+
headers
|
|
87263
|
+
}
|
|
87264
|
+
});
|
|
87265
|
+
return {
|
|
87266
|
+
callTool: (name, args) => client.callTool({
|
|
87267
|
+
name,
|
|
87268
|
+
arguments: args
|
|
87269
|
+
}),
|
|
87270
|
+
close: () => client.close(),
|
|
87271
|
+
connect: () => client.connect(transport)
|
|
87272
|
+
};
|
|
87273
|
+
}
|
|
87274
|
+
async function callMcpTool(createClient, endpoint, token, toolName, args) {
|
|
87275
|
+
const client = createClient(endpoint, token);
|
|
87276
|
+
await client.connect();
|
|
87277
|
+
try {
|
|
87278
|
+
const result = await client.callTool(toolName, args);
|
|
87279
|
+
if (result.isError) {
|
|
87280
|
+
throw new Error(`${toolName} returned an MCP error`);
|
|
87281
|
+
}
|
|
87282
|
+
return parseToolOutput(toolName, result);
|
|
87283
|
+
} finally {
|
|
87284
|
+
await client.close().catch(() => {
|
|
87285
|
+
return;
|
|
87286
|
+
});
|
|
87287
|
+
}
|
|
87288
|
+
}
|
|
87289
|
+
function parseToolOutput(toolName, result) {
|
|
87290
|
+
const structuredContent = isRecord9(result.structuredContent) ? result.structuredContent : void 0;
|
|
87291
|
+
if (structuredContent) {
|
|
87292
|
+
return structuredContent;
|
|
87293
|
+
}
|
|
87294
|
+
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;
|
|
87295
|
+
if (text2) {
|
|
87296
|
+
const parsed = JSON.parse(text2);
|
|
87297
|
+
if (isRecord9(parsed)) {
|
|
87298
|
+
return parsed;
|
|
87299
|
+
}
|
|
87300
|
+
}
|
|
87301
|
+
throw new Error(`${toolName} did not return structured JSON output`);
|
|
87302
|
+
}
|
|
87303
|
+
async function ensureEvalOpsLogin(options, deps) {
|
|
87304
|
+
if (options.forceLogin || !deps.hasOAuthCredentials("evalops")) {
|
|
87305
|
+
deps.onStatus({ message: "Opening EvalOps login" });
|
|
87306
|
+
await deps.login("evalops", {
|
|
87307
|
+
onAuthUrl: deps.onAuthUrl,
|
|
87308
|
+
onStatus: (message) => deps.onStatus({ message })
|
|
87309
|
+
});
|
|
87310
|
+
}
|
|
87311
|
+
let token = await deps.getOAuthToken("evalops");
|
|
87312
|
+
if (!token) {
|
|
87313
|
+
deps.onStatus({ message: "Refreshing EvalOps login" });
|
|
87314
|
+
await deps.login("evalops", {
|
|
87315
|
+
onAuthUrl: deps.onAuthUrl,
|
|
87316
|
+
onStatus: (message) => deps.onStatus({ message })
|
|
87317
|
+
});
|
|
87318
|
+
token = await deps.getOAuthToken("evalops");
|
|
87319
|
+
}
|
|
87320
|
+
if (!token) {
|
|
87321
|
+
throw new Error("EvalOps login did not produce an access token");
|
|
87322
|
+
}
|
|
87323
|
+
return token;
|
|
87324
|
+
}
|
|
87325
|
+
function buildKeyName(options, now2) {
|
|
87326
|
+
if (options.keyName?.trim()) {
|
|
87327
|
+
return options.keyName.trim();
|
|
87328
|
+
}
|
|
87329
|
+
const host = hostname().replace(/[^a-zA-Z0-9._-]+/gu, "-").slice(0, 48);
|
|
87330
|
+
return `maestro-init-${host || "local"}-${now2.toISOString().slice(0, 10)}`;
|
|
87331
|
+
}
|
|
87332
|
+
async function createAgentAPIKey(options, identityBaseUrl, oauthToken, fetchImpl, now2) {
|
|
87333
|
+
const expiresInDays = positiveInteger(options.expiresInDays);
|
|
87334
|
+
const expiresAt = expiresInDays ? new Date(now2.getTime() + expiresInDays * 24 * 60 * 60 * 1e3).toISOString() : void 0;
|
|
87335
|
+
const response = await fetchImpl(`${identityBaseUrl}${PLATFORM_HTTP_ROUTES.identity.apiKeys}`, {
|
|
87336
|
+
method: "POST",
|
|
87337
|
+
headers: {
|
|
87338
|
+
Authorization: `Bearer ${oauthToken}`,
|
|
87339
|
+
"Content-Type": "application/json"
|
|
87340
|
+
},
|
|
87341
|
+
body: JSON.stringify({
|
|
87342
|
+
name: buildKeyName(options, now2),
|
|
87343
|
+
scopes: options.apiKeyScopes ?? DEFAULT_API_KEY_SCOPES,
|
|
87344
|
+
...expiresAt ? { expires_at: expiresAt } : {}
|
|
87345
|
+
})
|
|
87346
|
+
});
|
|
87347
|
+
const output = await response.json().catch(() => ({}));
|
|
87348
|
+
if (!response.ok) {
|
|
87349
|
+
throw new Error(typeof output.error === "string" && output.error.trim() ? output.error : `EvalOps API key creation failed (${response.status})`);
|
|
87350
|
+
}
|
|
87351
|
+
const key = isRecord9(output.key) ? output.key : void 0;
|
|
87352
|
+
const normalized = {
|
|
87353
|
+
api_key: nonEmptyString(output.api_key) ?? "",
|
|
87354
|
+
expires_at: nonEmptyString(output.expires_at) ?? nonEmptyString(key?.expires_at),
|
|
87355
|
+
key_id: nonEmptyString(output.key_id) ?? nonEmptyString(key?.id),
|
|
87356
|
+
name: nonEmptyString(output.name) ?? nonEmptyString(key?.name),
|
|
87357
|
+
prefix: nonEmptyString(output.prefix) ?? nonEmptyString(key?.prefix),
|
|
87358
|
+
scopes: stringArray(output.scopes) ?? stringArray(key?.scopes) ?? stringArray(output.scopes_granted)
|
|
87359
|
+
};
|
|
87360
|
+
if (!nonEmptyString(normalized.api_key)) {
|
|
87361
|
+
throw new Error("EvalOps API key creation did not return api_key");
|
|
87362
|
+
}
|
|
87363
|
+
return normalized;
|
|
87364
|
+
}
|
|
87365
|
+
async function registerAgent(options, endpoint, apiKey, createClient) {
|
|
87366
|
+
const output = await callMcpTool(createClient, endpoint, apiKey, "evalops_register", {
|
|
87367
|
+
agent_type: options.agentType ?? DEFAULT_AGENT_TYPE,
|
|
87368
|
+
capabilities: ["maestro:init", "maestro:cli"],
|
|
87369
|
+
...options.registerScopes?.length ? { scopes: options.registerScopes } : {},
|
|
87370
|
+
surface: options.surface ?? DEFAULT_SURFACE2,
|
|
87371
|
+
...positiveInteger(options.ttlSeconds) ? { ttl_seconds: options.ttlSeconds } : {},
|
|
87372
|
+
...options.workspaceId ? { workspace_id: options.workspaceId } : {}
|
|
87373
|
+
});
|
|
87374
|
+
if (output.registered !== true || !nonEmptyString(output.agent_id)) {
|
|
87375
|
+
throw new Error("EvalOps agent registration did not return an agent_id");
|
|
87376
|
+
}
|
|
87377
|
+
return output;
|
|
87378
|
+
}
|
|
87379
|
+
function organizationIdFromCredentials(credentials) {
|
|
87380
|
+
return nonEmptyString(credentials?.metadata?.organizationId) ?? nonEmptyString(credentials?.metadata?.organization_id);
|
|
87381
|
+
}
|
|
87382
|
+
function saveBootstrapMetadata(credentials, agentMcp, saveCredentials) {
|
|
87383
|
+
saveCredentials("evalops", {
|
|
87384
|
+
...credentials,
|
|
87385
|
+
metadata: {
|
|
87386
|
+
...credentials.metadata,
|
|
87387
|
+
agentId: agentMcp.agentId ?? credentials.metadata?.agentId,
|
|
87388
|
+
runId: agentMcp.runId ?? credentials.metadata?.runId,
|
|
87389
|
+
surface: agentMcp.surface,
|
|
87390
|
+
agentMcp
|
|
87391
|
+
}
|
|
87392
|
+
});
|
|
87393
|
+
}
|
|
87394
|
+
async function bootstrapEvalOpsAgent(options = {}, dependencies = {}) {
|
|
87395
|
+
const deps = {
|
|
87396
|
+
createMcpClient: dependencies.createMcpClient ?? createDefaultMcpClient,
|
|
87397
|
+
fetch: dependencies.fetch ?? fetch,
|
|
87398
|
+
getOAuthToken: dependencies.getOAuthToken ?? getOAuthToken,
|
|
87399
|
+
hasOAuthCredentials: dependencies.hasOAuthCredentials ?? hasOAuthCredentials,
|
|
87400
|
+
loadCredentials: dependencies.loadCredentials ?? loadOAuthCredentials,
|
|
87401
|
+
login: dependencies.login ?? login,
|
|
87402
|
+
now: dependencies.now ?? (() => /* @__PURE__ */ new Date()),
|
|
87403
|
+
onAuthUrl: dependencies.onAuthUrl ?? ((url) => {
|
|
87404
|
+
process.stdout.write(`${url}
|
|
87405
|
+
`);
|
|
87406
|
+
}),
|
|
87407
|
+
onStatus: dependencies.onStatus ?? (() => {
|
|
87408
|
+
return;
|
|
87409
|
+
}),
|
|
87410
|
+
saveCredentials: dependencies.saveCredentials ?? saveOAuthCredentials
|
|
87411
|
+
};
|
|
87412
|
+
const oauthToken = await ensureEvalOpsLogin(options, deps);
|
|
87413
|
+
const endpoint = await resolveAgentMcpEndpoint(options, deps);
|
|
87414
|
+
const credentialsBeforeKey = deps.loadCredentials("evalops");
|
|
87415
|
+
const stored = getStoredAgentMcpMetadata(credentialsBeforeKey);
|
|
87416
|
+
const identityBaseUrl = resolveIdentityBaseUrl(credentialsBeforeKey, endpoint);
|
|
87417
|
+
const now2 = deps.now();
|
|
87418
|
+
let apiKey = stored && !options.rotateKey ? stored.apiKey : void 0;
|
|
87419
|
+
let keyOutput;
|
|
87420
|
+
let apiKeyCreated = false;
|
|
87421
|
+
if (!apiKey) {
|
|
87422
|
+
deps.onStatus({ message: "Creating EvalOps agent API key" });
|
|
87423
|
+
keyOutput = await createAgentAPIKey(options, identityBaseUrl, oauthToken, deps.fetch, now2);
|
|
87424
|
+
apiKey = keyOutput.api_key;
|
|
87425
|
+
apiKeyCreated = true;
|
|
87426
|
+
} else {
|
|
87427
|
+
deps.onStatus({ message: "Reusing stored EvalOps agent API key" });
|
|
87428
|
+
}
|
|
87429
|
+
deps.onStatus({ message: "Registering Maestro with EvalOps agent MCP" });
|
|
87430
|
+
let registerOutput;
|
|
87431
|
+
try {
|
|
87432
|
+
registerOutput = await registerAgent(options, endpoint.endpoint, apiKey, deps.createMcpClient);
|
|
87433
|
+
} catch (error) {
|
|
87434
|
+
if (apiKeyCreated) {
|
|
87435
|
+
throw error;
|
|
87436
|
+
}
|
|
87437
|
+
deps.onStatus({
|
|
87438
|
+
message: "Stored EvalOps agent API key failed; rotating and retrying"
|
|
87439
|
+
});
|
|
87440
|
+
keyOutput = await createAgentAPIKey({ ...options, rotateKey: true }, identityBaseUrl, oauthToken, deps.fetch, now2);
|
|
87441
|
+
apiKey = keyOutput.api_key;
|
|
87442
|
+
apiKeyCreated = true;
|
|
87443
|
+
registerOutput = await registerAgent(options, endpoint.endpoint, apiKey, deps.createMcpClient);
|
|
87444
|
+
}
|
|
87445
|
+
const credentials = deps.loadCredentials("evalops");
|
|
87446
|
+
if (!credentials) {
|
|
87447
|
+
throw new Error("EvalOps OAuth credentials disappeared during init");
|
|
87448
|
+
}
|
|
87449
|
+
const keyPrefix = nonEmptyString(keyOutput?.prefix) ?? stored?.keyPrefix;
|
|
87450
|
+
const scopes = keyOutput?.scopes ?? stored?.scopes;
|
|
87451
|
+
const agentMcp = {
|
|
87452
|
+
type: "agent-mcp",
|
|
87453
|
+
apiKey,
|
|
87454
|
+
createdAt: (apiKeyCreated ? now2 : new Date(stored?.createdAt ?? now2)).toISOString(),
|
|
87455
|
+
endpoint: endpoint.endpoint,
|
|
87456
|
+
registeredAt: deps.now().toISOString(),
|
|
87457
|
+
surface: options.surface ?? DEFAULT_SURFACE2,
|
|
87458
|
+
agentId: registerOutput.agent_id,
|
|
87459
|
+
expiresAt: nonEmptyString(keyOutput?.expires_at) ?? stored?.expiresAt,
|
|
87460
|
+
keyId: nonEmptyString(keyOutput?.key_id) ?? stored?.keyId,
|
|
87461
|
+
keyName: nonEmptyString(keyOutput?.name) ?? stored?.keyName,
|
|
87462
|
+
keyPrefix,
|
|
87463
|
+
manifestUrl: endpoint.manifestUrl,
|
|
87464
|
+
registryVisible: registerOutput.registry_visible,
|
|
87465
|
+
runId: registerOutput.run_id,
|
|
87466
|
+
scopes,
|
|
87467
|
+
sessionExpiresAt: registerOutput.expires_at,
|
|
87468
|
+
workspaceId: options.workspaceId ?? organizationIdFromCredentials(credentials)
|
|
87469
|
+
};
|
|
87470
|
+
saveBootstrapMetadata(credentials, agentMcp, deps.saveCredentials);
|
|
87471
|
+
return {
|
|
87472
|
+
agentId: registerOutput.agent_id,
|
|
87473
|
+
apiKeyCreated,
|
|
87474
|
+
endpoint: endpoint.endpoint,
|
|
87475
|
+
keyPrefix,
|
|
87476
|
+
manifestUrl: endpoint.manifestUrl,
|
|
87477
|
+
organizationId: organizationIdFromCredentials(credentials),
|
|
87478
|
+
registryVisible: registerOutput.registry_visible,
|
|
87479
|
+
runId: registerOutput.run_id,
|
|
87480
|
+
scopesGranted: registerOutput.scopes_granted,
|
|
87481
|
+
sessionExpiresAt: registerOutput.expires_at,
|
|
87482
|
+
stored: true
|
|
87483
|
+
};
|
|
87484
|
+
}
|
|
87485
|
+
var DEFAULT_AGENT_MCP_BASE_URL = "https://app.evalops.dev";
|
|
87486
|
+
var DEFAULT_IDENTITY_BASE_URL = "https://identity.evalops.dev";
|
|
87487
|
+
var AGENT_MCP_MANIFEST_PATH = "/.well-known/evalops/agent-mcp.json";
|
|
87488
|
+
var AGENT_MCP_PATH = "/mcp";
|
|
87489
|
+
var DEFAULT_AGENT_TYPE = "maestro";
|
|
87490
|
+
var DEFAULT_SURFACE2 = "cli";
|
|
87491
|
+
var DEFAULT_API_KEY_SCOPES;
|
|
87492
|
+
var init_agent_bootstrap = __esm2(() => {
|
|
87493
|
+
init_oauth();
|
|
87494
|
+
init_storage();
|
|
87495
|
+
init_package_metadata();
|
|
87496
|
+
init_client();
|
|
87497
|
+
init_core_services();
|
|
87498
|
+
DEFAULT_API_KEY_SCOPES = [
|
|
87499
|
+
"agent:register",
|
|
87500
|
+
"agent:heartbeat",
|
|
87501
|
+
"governance:evaluate",
|
|
87502
|
+
"llm_gateway:invoke",
|
|
87503
|
+
"memories:read",
|
|
87504
|
+
"memories:write",
|
|
87505
|
+
"meter:record"
|
|
87506
|
+
];
|
|
87507
|
+
});
|
|
87027
87508
|
function isPlatformMcpExplicitlyDisabled() {
|
|
87028
87509
|
const enabled = getEnvValue3(PLATFORM_MCP_ENABLED_ENV_VARS);
|
|
87029
87510
|
if (!enabled) {
|
|
@@ -87032,15 +87513,16 @@ function isPlatformMcpExplicitlyDisabled() {
|
|
|
87032
87513
|
return PLATFORM_MCP_DISABLED_VALUES.has(enabled.trim().toLowerCase());
|
|
87033
87514
|
}
|
|
87034
87515
|
function buildPlatformMcpHeaders() {
|
|
87035
|
-
const
|
|
87036
|
-
const
|
|
87516
|
+
const stored = getStoredEvalOpsAgentMcpMetadata();
|
|
87517
|
+
const token = getEnvValue3(PLATFORM_MCP_TOKEN_ENV_VARS) ?? stored?.apiKey ?? resolveConfiguredToken(PLATFORM_MCP_TOKEN_ENV_VARS);
|
|
87518
|
+
const workspaceId = resolveWorkspaceId2(PLATFORM_MCP_WORKSPACE_ENV_VARS) ?? stored?.workspaceId;
|
|
87037
87519
|
const headers = Object.fromEntries(Object.entries({
|
|
87038
87520
|
...token ? { Authorization: `Bearer ${token}` } : {},
|
|
87039
87521
|
"Mcp-Session-Id": getEnvValue3(["MAESTRO_SESSION_ID"]),
|
|
87040
87522
|
"X-EvalOps-Workspace-Id": workspaceId,
|
|
87041
87523
|
"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"]),
|
|
87524
|
+
"X-EvalOps-Agent-Id": getEnvValue3(PLATFORM_MCP_AGENT_ID_ENV_VARS) ?? stored?.agentId,
|
|
87525
|
+
"X-EvalOps-Agent-Run-Id": getEnvValue3(["MAESTRO_AGENT_RUN_ID"]) ?? stored?.runId,
|
|
87044
87526
|
"X-EvalOps-Scopes": getEnvValue3(PLATFORM_MCP_SCOPES_ENV_VARS),
|
|
87045
87527
|
"X-EvalOps-Request-Id": getEnvValue3(["MAESTRO_REQUEST_ID"]),
|
|
87046
87528
|
"X-EvalOps-Trace-Id": getEnvValue3(["TRACE_ID", "OTEL_TRACE_ID"]),
|
|
@@ -87048,11 +87530,28 @@ function buildPlatformMcpHeaders() {
|
|
|
87048
87530
|
}).filter((entry2) => typeof entry2[1] === "string" && entry2[1].trim().length > 0));
|
|
87049
87531
|
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
87050
87532
|
}
|
|
87533
|
+
function normalizePlatformMcpEndpoint(url) {
|
|
87534
|
+
const normalized = normalizeBaseUrl2(url);
|
|
87535
|
+
try {
|
|
87536
|
+
const parsed = new URL(normalized);
|
|
87537
|
+
if (parsed.pathname === "" || parsed.pathname === "/" || parsed.pathname === AGENT_MCP_MANIFEST_PATH2) {
|
|
87538
|
+
parsed.pathname = AGENT_MCP_PATH2;
|
|
87539
|
+
parsed.search = "";
|
|
87540
|
+
parsed.hash = "";
|
|
87541
|
+
return normalizeBaseUrl2(parsed.toString());
|
|
87542
|
+
}
|
|
87543
|
+
} catch {
|
|
87544
|
+
}
|
|
87545
|
+
return normalized;
|
|
87546
|
+
}
|
|
87547
|
+
function resolvePlatformMcpURL() {
|
|
87548
|
+
return getEnvValue3(PLATFORM_MCP_URL_ENV_VARS) ?? getEnvValue3(PLATFORM_MCP_MANIFEST_URL_ENV_VARS) ?? getStoredEvalOpsAgentMcpMetadata()?.endpoint;
|
|
87549
|
+
}
|
|
87051
87550
|
function getPlatformMcpPluginServers() {
|
|
87052
87551
|
if (isPlatformMcpExplicitlyDisabled()) {
|
|
87053
87552
|
return [];
|
|
87054
87553
|
}
|
|
87055
|
-
const url =
|
|
87554
|
+
const url = resolvePlatformMcpURL();
|
|
87056
87555
|
if (!url) {
|
|
87057
87556
|
return [];
|
|
87058
87557
|
}
|
|
@@ -87060,7 +87559,7 @@ function getPlatformMcpPluginServers() {
|
|
|
87060
87559
|
{
|
|
87061
87560
|
name: getEnvValue3(PLATFORM_MCP_NAME_ENV_VARS) ?? DEFAULT_PLATFORM_MCP_SERVER_NAME,
|
|
87062
87561
|
transport: "http",
|
|
87063
|
-
url:
|
|
87562
|
+
url: normalizePlatformMcpEndpoint(url),
|
|
87064
87563
|
headers: buildPlatformMcpHeaders(),
|
|
87065
87564
|
scope: "plugin"
|
|
87066
87565
|
}
|
|
@@ -87070,12 +87569,16 @@ var PLATFORM_MCP_DISABLED_VALUES;
|
|
|
87070
87569
|
var PLATFORM_MCP_ENABLED_ENV_VARS;
|
|
87071
87570
|
var PLATFORM_MCP_NAME_ENV_VARS;
|
|
87072
87571
|
var PLATFORM_MCP_URL_ENV_VARS;
|
|
87572
|
+
var PLATFORM_MCP_MANIFEST_URL_ENV_VARS;
|
|
87073
87573
|
var PLATFORM_MCP_TOKEN_ENV_VARS;
|
|
87074
87574
|
var PLATFORM_MCP_WORKSPACE_ENV_VARS;
|
|
87075
87575
|
var PLATFORM_MCP_AGENT_ID_ENV_VARS;
|
|
87076
87576
|
var PLATFORM_MCP_SCOPES_ENV_VARS;
|
|
87077
87577
|
var DEFAULT_PLATFORM_MCP_SERVER_NAME = "evalops";
|
|
87578
|
+
var AGENT_MCP_MANIFEST_PATH2 = "/.well-known/evalops/agent-mcp.json";
|
|
87579
|
+
var AGENT_MCP_PATH2 = "/mcp";
|
|
87078
87580
|
var init_platform_plugin = __esm2(() => {
|
|
87581
|
+
init_agent_bootstrap();
|
|
87079
87582
|
init_client();
|
|
87080
87583
|
PLATFORM_MCP_DISABLED_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
|
|
87081
87584
|
PLATFORM_MCP_ENABLED_ENV_VARS = [
|
|
@@ -87091,6 +87594,11 @@ var init_platform_plugin = __esm2(() => {
|
|
|
87091
87594
|
"MAESTRO_AGENT_MCP_URL",
|
|
87092
87595
|
"MAESTRO_EVALOPS_AGENT_MCP_URL"
|
|
87093
87596
|
];
|
|
87597
|
+
PLATFORM_MCP_MANIFEST_URL_ENV_VARS = [
|
|
87598
|
+
"MAESTRO_PLATFORM_MCP_MANIFEST_URL",
|
|
87599
|
+
"MAESTRO_AGENT_MCP_MANIFEST_URL",
|
|
87600
|
+
"MAESTRO_EVALOPS_AGENT_MCP_MANIFEST_URL"
|
|
87601
|
+
];
|
|
87094
87602
|
PLATFORM_MCP_TOKEN_ENV_VARS = [
|
|
87095
87603
|
"MAESTRO_PLATFORM_MCP_TOKEN",
|
|
87096
87604
|
"MAESTRO_AGENT_MCP_TOKEN",
|
|
@@ -87252,9 +87760,9 @@ function addMcpServerToConfig(options) {
|
|
|
87252
87760
|
throw new Error(`Invalid MCP config at ${path23}: ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
87253
87761
|
}
|
|
87254
87762
|
const nextConfig = structuredClone(parsed.data);
|
|
87255
|
-
const hasObjectFormat =
|
|
87763
|
+
const hasObjectFormat = isRecord10(nextConfig.mcpServers) || !Array.isArray(nextConfig.servers);
|
|
87256
87764
|
if (hasObjectFormat) {
|
|
87257
|
-
const existingServers =
|
|
87765
|
+
const existingServers = isRecord10(nextConfig.mcpServers) ? nextConfig.mcpServers : {};
|
|
87258
87766
|
if (Object.prototype.hasOwnProperty.call(existingServers, validatedServer.name)) {
|
|
87259
87767
|
throw new Error(`MCP server "${validatedServer.name}" already exists in ${path23}`);
|
|
87260
87768
|
}
|
|
@@ -87287,7 +87795,7 @@ function addMcpAuthPresetToConfig(options) {
|
|
|
87287
87795
|
throw new Error(`Invalid MCP config at ${path23}: ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
87288
87796
|
}
|
|
87289
87797
|
const nextConfig = structuredClone(parsed.data);
|
|
87290
|
-
const existingPresets =
|
|
87798
|
+
const existingPresets = isRecord10(nextConfig.authPresets) ? nextConfig.authPresets : {};
|
|
87291
87799
|
if (Object.prototype.hasOwnProperty.call(existingPresets, validatedPreset.name)) {
|
|
87292
87800
|
throw new Error(`MCP auth preset "${validatedPreset.name}" already exists in ${path23}`);
|
|
87293
87801
|
}
|
|
@@ -87388,7 +87896,7 @@ function parseConfigFile2(path23, scope) {
|
|
|
87388
87896
|
}
|
|
87389
87897
|
if (parsed.data.mcpServers) {
|
|
87390
87898
|
for (const [name, raw] of Object.entries(parsed.data.mcpServers)) {
|
|
87391
|
-
const merged =
|
|
87899
|
+
const merged = isRecord10(raw) ? { ...raw, name } : { name };
|
|
87392
87900
|
const normalized = normalizeServer(merged, name, scope);
|
|
87393
87901
|
if (normalized)
|
|
87394
87902
|
servers.push(normalized);
|
|
@@ -87396,7 +87904,7 @@ function parseConfigFile2(path23, scope) {
|
|
|
87396
87904
|
}
|
|
87397
87905
|
if (parsed.data.authPresets) {
|
|
87398
87906
|
for (const [name, raw] of Object.entries(parsed.data.authPresets)) {
|
|
87399
|
-
const merged =
|
|
87907
|
+
const merged = isRecord10(raw) ? { ...raw, name } : { name };
|
|
87400
87908
|
const normalized = normalizeAuthPreset(merged, name, scope);
|
|
87401
87909
|
if (normalized)
|
|
87402
87910
|
authPresets.push(normalized);
|
|
@@ -87449,7 +87957,7 @@ function resolveWritableAuthPresetMutationScope(name, scope, projectRoot) {
|
|
|
87449
87957
|
return activePreset.scope;
|
|
87450
87958
|
}
|
|
87451
87959
|
function mutateWritableMcpConfig(config2, name, mode, options) {
|
|
87452
|
-
if (
|
|
87960
|
+
if (isRecord10(config2.mcpServers) && Object.prototype.hasOwnProperty.call(config2.mcpServers, name)) {
|
|
87453
87961
|
if (mode === "remove") {
|
|
87454
87962
|
delete config2.mcpServers[name];
|
|
87455
87963
|
} else {
|
|
@@ -87474,7 +87982,7 @@ function mutateWritableMcpConfig(config2, name, mode, options) {
|
|
|
87474
87982
|
return false;
|
|
87475
87983
|
}
|
|
87476
87984
|
function mutateWritableMcpAuthPresetConfig(config2, name, mode, options) {
|
|
87477
|
-
if (
|
|
87985
|
+
if (isRecord10(config2.authPresets) && Object.prototype.hasOwnProperty.call(config2.authPresets, name)) {
|
|
87478
87986
|
if (mode === "remove") {
|
|
87479
87987
|
delete config2.authPresets[name];
|
|
87480
87988
|
} else {
|
|
@@ -87580,7 +88088,7 @@ function buildPersistedAuthPresetConfig(preset) {
|
|
|
87580
88088
|
headersHelper: preset.headersHelper
|
|
87581
88089
|
};
|
|
87582
88090
|
}
|
|
87583
|
-
function
|
|
88091
|
+
function isRecord10(value) {
|
|
87584
88092
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
87585
88093
|
}
|
|
87586
88094
|
function isWritableScope(value) {
|
|
@@ -87672,7 +88180,7 @@ var init_config3 = __esm2(() => {
|
|
|
87672
88180
|
init_schema();
|
|
87673
88181
|
logger97 = createLogger("mcp:config");
|
|
87674
88182
|
});
|
|
87675
|
-
function
|
|
88183
|
+
function isRecord11(value) {
|
|
87676
88184
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
87677
88185
|
}
|
|
87678
88186
|
function collectConcreteUrls(entry2) {
|
|
@@ -87757,11 +88265,11 @@ function buildCacheFromResponse(data) {
|
|
|
87757
88265
|
entries: [],
|
|
87758
88266
|
status: "ready"
|
|
87759
88267
|
};
|
|
87760
|
-
if (!
|
|
88268
|
+
if (!isRecord11(data) || !Array.isArray(data.servers)) {
|
|
87761
88269
|
return next;
|
|
87762
88270
|
}
|
|
87763
88271
|
for (const entry2 of data.servers) {
|
|
87764
|
-
if (!
|
|
88272
|
+
if (!isRecord11(entry2))
|
|
87765
88273
|
continue;
|
|
87766
88274
|
const typedEntry = entry2;
|
|
87767
88275
|
const info = buildRegistryInfo(typedEntry);
|
|
@@ -88410,7 +88918,7 @@ var init_manager2 = __esm2(() => {
|
|
|
88410
88918
|
const requestInit = await buildRemoteRequestInit(config2, buildAuthPresetMap(this.config.authPresets));
|
|
88411
88919
|
const transportOptions = requestInit ? { requestInit } : void 0;
|
|
88412
88920
|
if (transportType === "http") {
|
|
88413
|
-
transport = new
|
|
88921
|
+
transport = new StreamableHTTPClientTransport2(new URL(config2.url), transportOptions);
|
|
88414
88922
|
} else {
|
|
88415
88923
|
transport = new SSEClientTransport(new URL(config2.url), transportOptions);
|
|
88416
88924
|
}
|
|
@@ -88426,7 +88934,7 @@ var init_manager2 = __esm2(() => {
|
|
|
88426
88934
|
cwd: config2.cwd
|
|
88427
88935
|
});
|
|
88428
88936
|
}
|
|
88429
|
-
const client = new
|
|
88937
|
+
const client = new Client2({
|
|
88430
88938
|
name: "composer",
|
|
88431
88939
|
version: "1.0.0"
|
|
88432
88940
|
}, {
|
|
@@ -90876,11 +91384,11 @@ function collapseRepeatedLinesWithHistory(text2, options = {}) {
|
|
|
90876
91384
|
return { text: result.join(`
|
|
90877
91385
|
`), changed };
|
|
90878
91386
|
}
|
|
90879
|
-
function
|
|
91387
|
+
function isRecord12(value) {
|
|
90880
91388
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
90881
91389
|
}
|
|
90882
91390
|
function isAssistantContentBlock(value) {
|
|
90883
|
-
if (!
|
|
91391
|
+
if (!isRecord12(value)) {
|
|
90884
91392
|
return false;
|
|
90885
91393
|
}
|
|
90886
91394
|
switch (value.type) {
|
|
@@ -90889,7 +91397,7 @@ function isAssistantContentBlock(value) {
|
|
|
90889
91397
|
case "thinking":
|
|
90890
91398
|
return typeof value.thinking === "string";
|
|
90891
91399
|
case "toolCall":
|
|
90892
|
-
return typeof value.id === "string" && typeof value.name === "string" &&
|
|
91400
|
+
return typeof value.id === "string" && typeof value.name === "string" && isRecord12(value.arguments);
|
|
90893
91401
|
default:
|
|
90894
91402
|
return false;
|
|
90895
91403
|
}
|
|
@@ -90904,7 +91412,7 @@ function normalizeAssistantContent(content) {
|
|
|
90904
91412
|
return content.filter(isAssistantContentBlock);
|
|
90905
91413
|
}
|
|
90906
91414
|
function isToolResultContentBlock(value) {
|
|
90907
|
-
if (!
|
|
91415
|
+
if (!isRecord12(value)) {
|
|
90908
91416
|
return false;
|
|
90909
91417
|
}
|
|
90910
91418
|
if (value.type === "text") {
|
|
@@ -101841,7 +102349,7 @@ var init_export_html = __esm2(() => {
|
|
|
101841
102349
|
init_context_firewall();
|
|
101842
102350
|
init_types3();
|
|
101843
102351
|
init_path_expansion();
|
|
101844
|
-
packageJson =
|
|
102352
|
+
packageJson = createRequire5(import.meta.url)("../package.json");
|
|
101845
102353
|
VERSION2 = packageJson.version ?? "unknown";
|
|
101846
102354
|
});
|
|
101847
102355
|
function loadFactoryConfigOrThrow() {
|
|
@@ -102661,8 +103169,8 @@ function resolveOllamaUrl(path23) {
|
|
|
102661
103169
|
}
|
|
102662
103170
|
return url;
|
|
102663
103171
|
}
|
|
102664
|
-
function isLoopbackHost(
|
|
102665
|
-
return
|
|
103172
|
+
function isLoopbackHost(hostname2) {
|
|
103173
|
+
return hostname2 === "localhost" || hostname2 === "127.0.0.1" || hostname2 === "::1" || hostname2.startsWith("127.");
|
|
102666
103174
|
}
|
|
102667
103175
|
var OllamaView;
|
|
102668
103176
|
var init_ollama_view = __esm2(() => {
|
|
@@ -106210,32 +106718,6 @@ var SlashCycleState = class {
|
|
|
106210
106718
|
};
|
|
106211
106719
|
var init_slash = () => {
|
|
106212
106720
|
};
|
|
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
106721
|
function formatLink(url, label) {
|
|
106240
106722
|
const text2 = label ?? url;
|
|
106241
106723
|
if (!process.stdout.isTTY)
|
|
@@ -122572,7 +123054,7 @@ Reply with option numbers (e.g., '1' or '1, 3' for multi-select), option labels,
|
|
|
122572
123054
|
}
|
|
122573
123055
|
});
|
|
122574
123056
|
});
|
|
122575
|
-
function
|
|
123057
|
+
function isRecord13(value) {
|
|
122576
123058
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
122577
123059
|
}
|
|
122578
123060
|
function getOptionalNumber(record, key) {
|
|
@@ -122590,7 +123072,7 @@ function normalizeOptionEntries(values, labels) {
|
|
|
122590
123072
|
}));
|
|
122591
123073
|
}
|
|
122592
123074
|
function parseFieldDefinition(key, value) {
|
|
122593
|
-
if (!
|
|
123075
|
+
if (!isRecord13(value) || typeof value.type !== "string") {
|
|
122594
123076
|
return null;
|
|
122595
123077
|
}
|
|
122596
123078
|
const label = getOptionalString(value, "title") ?? key;
|
|
@@ -122616,7 +123098,7 @@ function parseFieldDefinition(key, value) {
|
|
|
122616
123098
|
options: normalizeOptionEntries(value.enum, enumNames)
|
|
122617
123099
|
};
|
|
122618
123100
|
}
|
|
122619
|
-
if (Array.isArray(value.oneOf) && value.oneOf.every((entry2) =>
|
|
123101
|
+
if (Array.isArray(value.oneOf) && value.oneOf.every((entry2) => isRecord13(entry2) && typeof entry2.const === "string" && typeof entry2.title === "string")) {
|
|
122620
123102
|
return {
|
|
122621
123103
|
key,
|
|
122622
123104
|
kind: "select",
|
|
@@ -122652,7 +123134,7 @@ function parseFieldDefinition(key, value) {
|
|
|
122652
123134
|
minimum: getOptionalNumber(value, "minimum")
|
|
122653
123135
|
};
|
|
122654
123136
|
}
|
|
122655
|
-
if (value.type === "array" &&
|
|
123137
|
+
if (value.type === "array" && isRecord13(value.items)) {
|
|
122656
123138
|
if (Array.isArray(value.items.enum) && value.items.enum.every((entry2) => typeof entry2 === "string")) {
|
|
122657
123139
|
return {
|
|
122658
123140
|
key,
|
|
@@ -122665,7 +123147,7 @@ function parseFieldDefinition(key, value) {
|
|
|
122665
123147
|
options: normalizeOptionEntries(value.items.enum)
|
|
122666
123148
|
};
|
|
122667
123149
|
}
|
|
122668
|
-
if (Array.isArray(value.items.anyOf) && value.items.anyOf.every((entry2) =>
|
|
123150
|
+
if (Array.isArray(value.items.anyOf) && value.items.anyOf.every((entry2) => isRecord13(entry2) && typeof entry2.const === "string" && typeof entry2.title === "string")) {
|
|
122669
123151
|
return {
|
|
122670
123152
|
key,
|
|
122671
123153
|
kind: "multi-select",
|
|
@@ -122684,7 +123166,7 @@ function parseFieldDefinition(key, value) {
|
|
|
122684
123166
|
return null;
|
|
122685
123167
|
}
|
|
122686
123168
|
function parseMcpElicitationRequest(args) {
|
|
122687
|
-
if (!
|
|
123169
|
+
if (!isRecord13(args)) {
|
|
122688
123170
|
return {
|
|
122689
123171
|
kind: "malformed",
|
|
122690
123172
|
message: "MCP server requested additional input.",
|
|
@@ -122722,7 +123204,7 @@ function parseMcpElicitationRequest(args) {
|
|
|
122722
123204
|
};
|
|
122723
123205
|
}
|
|
122724
123206
|
const requestedSchema = args.requestedSchema;
|
|
122725
|
-
if (!
|
|
123207
|
+
if (!isRecord13(requestedSchema)) {
|
|
122726
123208
|
return {
|
|
122727
123209
|
kind: "malformed",
|
|
122728
123210
|
message,
|
|
@@ -122731,7 +123213,7 @@ function parseMcpElicitationRequest(args) {
|
|
|
122731
123213
|
error: "Missing requested schema for form elicitation."
|
|
122732
123214
|
};
|
|
122733
123215
|
}
|
|
122734
|
-
if (requestedSchema.type !== "object" || !
|
|
123216
|
+
if (requestedSchema.type !== "object" || !isRecord13(requestedSchema.properties)) {
|
|
122735
123217
|
return {
|
|
122736
123218
|
kind: "malformed",
|
|
122737
123219
|
message,
|
|
@@ -132015,7 +132497,7 @@ function parseArgs(args) {
|
|
|
132015
132497
|
result.subcommand = nextArg;
|
|
132016
132498
|
i2++;
|
|
132017
132499
|
}
|
|
132018
|
-
if (arg === "remote" || arg === "hosted-runner") {
|
|
132500
|
+
if (arg === "remote" || arg === "hosted-runner" || arg === "init" || arg === "evalops") {
|
|
132019
132501
|
result.commandArgs = args.slice(i2 + 1);
|
|
132020
132502
|
break;
|
|
132021
132503
|
}
|
|
@@ -132038,6 +132520,7 @@ var init_args = __esm2(() => {
|
|
|
132038
132520
|
"exec",
|
|
132039
132521
|
"web",
|
|
132040
132522
|
"hosted-runner",
|
|
132523
|
+
"init",
|
|
132041
132524
|
"anthropic",
|
|
132042
132525
|
"evalops",
|
|
132043
132526
|
"openai",
|
|
@@ -135766,7 +136249,10 @@ function printHelp(version3) {
|
|
|
135766
136249
|
# Use Codex subscription models after \`maestro codex login\`
|
|
135767
136250
|
maestro --provider openai-codex --model gpt-5.5 "Plan this migration"
|
|
135768
136251
|
|
|
135769
|
-
#
|
|
136252
|
+
# Bootstrap EvalOps login, API key, and agent registration in one flow
|
|
136253
|
+
maestro init
|
|
136254
|
+
|
|
136255
|
+
# Use EvalOps managed gateway models after \`maestro init\`
|
|
135770
136256
|
maestro --provider evalops --model gpt-4o-mini "Say hello in one sentence"
|
|
135771
136257
|
|
|
135772
136258
|
# Export a portable session log
|
|
@@ -135845,6 +136331,10 @@ function printHelp(version3) {
|
|
|
135845
136331
|
maestro remote attach <session-id> [--verify] [--print-env]
|
|
135846
136332
|
maestro remote extend <session-id> --ttl 2h
|
|
135847
136333
|
maestro remote stop <session-id> [--reason <text>]`)}`;
|
|
136334
|
+
const initSection = `${sectionHeading("maestro init")}${muted(` maestro init Login, create or reuse an API key, and register this agent
|
|
136335
|
+
maestro init --rotate-key Replace the stored agent MCP API key
|
|
136336
|
+
maestro init --mcp-url <url> Override the EvalOps agent MCP endpoint
|
|
136337
|
+
maestro init --json Emit machine-readable bootstrap output`)}`;
|
|
135848
136338
|
const hostedRunnerSection = `${sectionHeading("maestro hosted-runner")}${muted(` maestro hosted-runner --runner-session-id <id> --workspace-root <path> [--listen 0.0.0.0:8080]
|
|
135849
136339
|
|
|
135850
136340
|
Env mode:
|
|
@@ -135882,6 +136372,7 @@ function printHelp(version3) {
|
|
|
135882
136372
|
webSection,
|
|
135883
136373
|
portabilitySection,
|
|
135884
136374
|
memorySection,
|
|
136375
|
+
initSection,
|
|
135885
136376
|
remoteSection,
|
|
135886
136377
|
hostedRunnerSection,
|
|
135887
136378
|
sessionsSection,
|
|
@@ -140515,7 +141006,7 @@ function getString(value, field) {
|
|
|
140515
141006
|
const trimmed = value.trim();
|
|
140516
141007
|
return trimmed || void 0;
|
|
140517
141008
|
}
|
|
140518
|
-
function
|
|
141009
|
+
function getStringArray3(value, field) {
|
|
140519
141010
|
if (value === void 0 || value === null) {
|
|
140520
141011
|
return;
|
|
140521
141012
|
}
|
|
@@ -140544,7 +141035,7 @@ function parseHostedRunnerDrainInput(body) {
|
|
|
140544
141035
|
return {
|
|
140545
141036
|
reason: getString(record.reason, "reason") ?? getString(record.stop_reason, "stop_reason"),
|
|
140546
141037
|
requestedBy: getString(record.requested_by, "requested_by") ?? getString(record.requestedBy, "requestedBy"),
|
|
140547
|
-
exportPaths:
|
|
141038
|
+
exportPaths: getStringArray3(record.export_paths, "export_paths") ?? getStringArray3(record.exportPaths, "exportPaths")
|
|
140548
141039
|
};
|
|
140549
141040
|
}
|
|
140550
141041
|
function isWithinPath(root, target) {
|
|
@@ -140814,7 +141305,7 @@ var init_hosted_runner_drain = __esm2(() => {
|
|
|
140814
141305
|
init_server_utils();
|
|
140815
141306
|
execFileAsync2 = promisify5(execFile4);
|
|
140816
141307
|
});
|
|
140817
|
-
function
|
|
141308
|
+
function isRecord14(value) {
|
|
140818
141309
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
140819
141310
|
}
|
|
140820
141311
|
function cleanRequiredString(value, label) {
|
|
@@ -140856,7 +141347,7 @@ function cleanOptionalPositiveInteger(value, label) {
|
|
|
140856
141347
|
return Math.floor(value);
|
|
140857
141348
|
}
|
|
140858
141349
|
function normalizeModelPreferences(value) {
|
|
140859
|
-
const input =
|
|
141350
|
+
const input = isRecord14(value) ? value : {};
|
|
140860
141351
|
const defaultModel = cleanOptionalString(input.defaultModel);
|
|
140861
141352
|
const preferredProvider = cleanOptionalString(input.preferredProvider);
|
|
140862
141353
|
return {
|
|
@@ -140867,7 +141358,7 @@ function normalizeModelPreferences(value) {
|
|
|
140867
141358
|
};
|
|
140868
141359
|
}
|
|
140869
141360
|
function normalizeSafetyRules(value) {
|
|
140870
|
-
const input =
|
|
141361
|
+
const input = isRecord14(value) ? value : {};
|
|
140871
141362
|
const requireApprovals = cleanOptionalBoolean(input.requireApprovals);
|
|
140872
141363
|
const maxTokensPerSession = cleanOptionalPositiveInteger(input.maxTokensPerSession, "safetyRules.maxTokensPerSession");
|
|
140873
141364
|
return {
|
|
@@ -140880,7 +141371,7 @@ function normalizeSafetyRules(value) {
|
|
|
140880
141371
|
};
|
|
140881
141372
|
}
|
|
140882
141373
|
function normalizeRateLimits(value) {
|
|
140883
|
-
const input =
|
|
141374
|
+
const input = isRecord14(value) ? value : {};
|
|
140884
141375
|
const requestsPerMinute = cleanOptionalPositiveInteger(input.requestsPerMinute, "rateLimits.requestsPerMinute");
|
|
140885
141376
|
const tokensPerMinute = cleanOptionalPositiveInteger(input.tokensPerMinute, "rateLimits.tokensPerMinute");
|
|
140886
141377
|
const maxConcurrentSessions = cleanOptionalPositiveInteger(input.maxConcurrentSessions, "rateLimits.maxConcurrentSessions");
|
|
@@ -140893,7 +141384,7 @@ function normalizeRateLimits(value) {
|
|
|
140893
141384
|
};
|
|
140894
141385
|
}
|
|
140895
141386
|
function normalizeWorkspaceConfigInput(input, now2 = /* @__PURE__ */ new Date()) {
|
|
140896
|
-
if (!
|
|
141387
|
+
if (!isRecord14(input)) {
|
|
140897
141388
|
throw new WorkspaceConfigValidationError("Workspace config must be an object.");
|
|
140898
141389
|
}
|
|
140899
141390
|
return {
|
|
@@ -140906,22 +141397,22 @@ function normalizeWorkspaceConfigInput(input, now2 = /* @__PURE__ */ new Date())
|
|
|
140906
141397
|
};
|
|
140907
141398
|
}
|
|
140908
141399
|
function normalizeWorkspaceConfigPatchInput(workspaceId, input, existing, now2 = /* @__PURE__ */ new Date()) {
|
|
140909
|
-
if (!
|
|
141400
|
+
if (!isRecord14(input)) {
|
|
140910
141401
|
throw new WorkspaceConfigValidationError("Workspace config must be an object.");
|
|
140911
141402
|
}
|
|
140912
141403
|
return {
|
|
140913
141404
|
workspaceId: cleanRequiredString(workspaceId, "workspaceId"),
|
|
140914
141405
|
modelPreferences: normalizeModelPreferences({
|
|
140915
141406
|
...existing?.modelPreferences ?? {},
|
|
140916
|
-
...
|
|
141407
|
+
...isRecord14(input.modelPreferences) ? input.modelPreferences : {}
|
|
140917
141408
|
}),
|
|
140918
141409
|
safetyRules: normalizeSafetyRules({
|
|
140919
141410
|
...existing?.safetyRules ?? {},
|
|
140920
|
-
...
|
|
141411
|
+
...isRecord14(input.safetyRules) ? input.safetyRules : {}
|
|
140921
141412
|
}),
|
|
140922
141413
|
rateLimits: normalizeRateLimits({
|
|
140923
141414
|
...existing?.rateLimits ?? {},
|
|
140924
|
-
...
|
|
141415
|
+
...isRecord14(input.rateLimits) ? input.rateLimits : {}
|
|
140925
141416
|
}),
|
|
140926
141417
|
createdAt: existing?.createdAt ?? now2.toISOString(),
|
|
140927
141418
|
updatedAt: now2.toISOString()
|
|
@@ -149944,7 +150435,7 @@ function safeStringify2(value) {
|
|
|
149944
150435
|
return "[unserializable]";
|
|
149945
150436
|
}
|
|
149946
150437
|
}
|
|
149947
|
-
function
|
|
150438
|
+
function isRecord15(value) {
|
|
149948
150439
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
149949
150440
|
}
|
|
149950
150441
|
function toComposerAttachments(attachments, options) {
|
|
@@ -150187,7 +150678,7 @@ function convertAppMessagesToComposer(messages, options) {
|
|
|
150187
150678
|
function normalizeToolCall(tool, messageIndex, contentIndex) {
|
|
150188
150679
|
const name = tool.name?.trim() || `tool_${messageIndex}_${contentIndex}`;
|
|
150189
150680
|
const toolCallId = tool.toolCallId || `web-tool-${messageIndex}-${contentIndex}`;
|
|
150190
|
-
const args =
|
|
150681
|
+
const args = isRecord15(tool.args) ? tool.args : {};
|
|
150191
150682
|
return {
|
|
150192
150683
|
type: "toolCall",
|
|
150193
150684
|
id: toolCallId,
|
|
@@ -151221,7 +151712,7 @@ var init_chat_ws = __esm2(() => {
|
|
|
151221
151712
|
init_validation3();
|
|
151222
151713
|
logger158 = createLogger("web:chat-ws");
|
|
151223
151714
|
});
|
|
151224
|
-
function
|
|
151715
|
+
function isRecord16(value) {
|
|
151225
151716
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
151226
151717
|
}
|
|
151227
151718
|
function canWrite(ws) {
|
|
@@ -151243,7 +151734,7 @@ function toErrorResponse(id, code, message) {
|
|
|
151243
151734
|
};
|
|
151244
151735
|
}
|
|
151245
151736
|
function parseClientRequest(raw) {
|
|
151246
|
-
if (!
|
|
151737
|
+
if (!isRecord16(raw)) {
|
|
151247
151738
|
throw new Error("Runtime app-server request must be an object");
|
|
151248
151739
|
}
|
|
151249
151740
|
if (raw.jsonrpc !== "2.0") {
|
|
@@ -151374,7 +151865,7 @@ function handleRuntimeAppServerWebSocket(ws, options = {}) {
|
|
|
151374
151865
|
}
|
|
151375
151866
|
const request = parseClientRequest(parsed);
|
|
151376
151867
|
if (request.method === "runtime.initialize") {
|
|
151377
|
-
const requestedSessionId =
|
|
151868
|
+
const requestedSessionId = isRecord16(request.params) ? request.params.sessionId : void 0;
|
|
151378
151869
|
await bindSessionId(requestedSessionId);
|
|
151379
151870
|
const result = initializeResult();
|
|
151380
151871
|
send2(ws, { jsonrpc: "2.0", id: request.id, result });
|
|
@@ -151397,7 +151888,7 @@ function handleRuntimeAppServerWebSocket(ws, options = {}) {
|
|
|
151397
151888
|
}
|
|
151398
151889
|
send2(ws, { jsonrpc: "2.0", id: request.id, result: { ok: true } });
|
|
151399
151890
|
} catch (error) {
|
|
151400
|
-
const id =
|
|
151891
|
+
const id = isRecord16(parsed) && (typeof parsed.id === "string" || typeof parsed.id === "number") ? parsed.id : null;
|
|
151401
151892
|
send2(ws, toErrorResponse(id, error instanceof Error && error.message === "Unsupported runtime app-server method" ? -32601 : -32600, error instanceof Error ? error.message : "Invalid request"));
|
|
151402
151893
|
}
|
|
151403
151894
|
});
|
|
@@ -151409,11 +151900,11 @@ var init_runtime_app_server_ws = __esm2(() => {
|
|
|
151409
151900
|
init_registry();
|
|
151410
151901
|
init_server_request_manager();
|
|
151411
151902
|
});
|
|
151412
|
-
function
|
|
151903
|
+
function isRecord17(value) {
|
|
151413
151904
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
151414
151905
|
}
|
|
151415
151906
|
function getToolRetryPayload(args) {
|
|
151416
|
-
return
|
|
151907
|
+
return isRecord17(args) ? args : {};
|
|
151417
151908
|
}
|
|
151418
151909
|
function pendingRequestArgs(entry2) {
|
|
151419
151910
|
if (entry2.kind !== "tool_retry") {
|
|
@@ -156456,7 +156947,7 @@ var init_types6 = __esm2(() => {
|
|
|
156456
156947
|
];
|
|
156457
156948
|
TRACE_SPAN_STATUSES = ["unset", "ok", "error"];
|
|
156458
156949
|
});
|
|
156459
|
-
function
|
|
156950
|
+
function isRecord18(value) {
|
|
156460
156951
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
156461
156952
|
}
|
|
156462
156953
|
function cleanRequiredString3(value, label) {
|
|
@@ -156547,7 +157038,7 @@ function sanitizeJsonValue(value, depth = 0) {
|
|
|
156547
157038
|
if (Array.isArray(value)) {
|
|
156548
157039
|
return value.map((item) => sanitizeJsonValue(item, depth + 1)).filter((item) => item !== void 0);
|
|
156549
157040
|
}
|
|
156550
|
-
if (
|
|
157041
|
+
if (isRecord18(value)) {
|
|
156551
157042
|
const result = {};
|
|
156552
157043
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
156553
157044
|
const sanitized = sanitizeJsonValue(nestedValue, depth + 1);
|
|
@@ -156578,7 +157069,7 @@ function inferDurationMs(startTime, endTime) {
|
|
|
156578
157069
|
return duration >= 0 ? duration : void 0;
|
|
156579
157070
|
}
|
|
156580
157071
|
function normalizeSpan(input, parentSpanId) {
|
|
156581
|
-
if (!
|
|
157072
|
+
if (!isRecord18(input)) {
|
|
156582
157073
|
throw new TracesValidationError("Each span must be an object.");
|
|
156583
157074
|
}
|
|
156584
157075
|
const error = cleanOptionalString3(input.error);
|
|
@@ -156642,7 +157133,7 @@ function countTraceSpans(spans) {
|
|
|
156642
157133
|
return count2;
|
|
156643
157134
|
}
|
|
156644
157135
|
function normalizeExecutionTraceInput(input) {
|
|
156645
|
-
if (!
|
|
157136
|
+
if (!isRecord18(input)) {
|
|
156646
157137
|
throw new TracesValidationError("Trace payload must be an object.");
|
|
156647
157138
|
}
|
|
156648
157139
|
if (!Array.isArray(input.spans)) {
|
|
@@ -157187,7 +157678,7 @@ var COMPLIANCE_FRAMEWORKS;
|
|
|
157187
157678
|
var init_types7 = __esm2(() => {
|
|
157188
157679
|
COMPLIANCE_FRAMEWORKS = ["soc2", "iso27001"];
|
|
157189
157680
|
});
|
|
157190
|
-
function
|
|
157681
|
+
function isRecord19(value) {
|
|
157191
157682
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
157192
157683
|
}
|
|
157193
157684
|
function cleanOptionalString4(value) {
|
|
@@ -157245,7 +157736,7 @@ function sanitizeJsonValue2(value, depth = 0) {
|
|
|
157245
157736
|
if (Array.isArray(value)) {
|
|
157246
157737
|
return value.map((item) => sanitizeJsonValue2(item, depth + 1)).filter((item) => item !== void 0);
|
|
157247
157738
|
}
|
|
157248
|
-
if (
|
|
157739
|
+
if (isRecord19(value)) {
|
|
157249
157740
|
const result = {};
|
|
157250
157741
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
157251
157742
|
const sanitized = sanitizeJsonValue2(nestedValue, depth + 1);
|
|
@@ -157261,7 +157752,7 @@ function sanitizeMetadata(value) {
|
|
|
157261
157752
|
if (!value)
|
|
157262
157753
|
return {};
|
|
157263
157754
|
const sanitized = sanitizeJsonValue2(value);
|
|
157264
|
-
return
|
|
157755
|
+
return isRecord19(sanitized) ? sanitized : {};
|
|
157265
157756
|
}
|
|
157266
157757
|
function stableActionId(input, timestamp3) {
|
|
157267
157758
|
const explicit = cleanOptionalString4(input.actionId);
|
|
@@ -157291,7 +157782,7 @@ function stableGovernanceEvaluationId(input, timestamp3) {
|
|
|
157291
157782
|
return `governance_${digest || randomUUID14()}`;
|
|
157292
157783
|
}
|
|
157293
157784
|
function normalizeAgentActionInput(input) {
|
|
157294
|
-
if (!
|
|
157785
|
+
if (!isRecord19(input)) {
|
|
157295
157786
|
throw new ComplianceValidationError("Agent action must be an object.");
|
|
157296
157787
|
}
|
|
157297
157788
|
const timestamp3 = parseDate2(input.timestamp, "action.timestamp") ?? /* @__PURE__ */ new Date();
|
|
@@ -157313,7 +157804,7 @@ function normalizeAgentActionInput(input) {
|
|
|
157313
157804
|
};
|
|
157314
157805
|
}
|
|
157315
157806
|
function normalizeGovernanceEvaluationInput(input) {
|
|
157316
|
-
if (!
|
|
157807
|
+
if (!isRecord19(input)) {
|
|
157317
157808
|
throw new ComplianceValidationError("Governance evaluation must be an object.");
|
|
157318
157809
|
}
|
|
157319
157810
|
const timestamp3 = parseDate2(input.timestamp, "governanceEvents[].timestamp") ?? /* @__PURE__ */ new Date();
|
|
@@ -157338,7 +157829,7 @@ function normalizeGovernanceEvaluationInput(input) {
|
|
|
157338
157829
|
};
|
|
157339
157830
|
}
|
|
157340
157831
|
function normalizeComplianceReportRequest(input) {
|
|
157341
|
-
if (!
|
|
157832
|
+
if (!isRecord19(input)) {
|
|
157342
157833
|
throw new ComplianceValidationError("Report request must be an object.");
|
|
157343
157834
|
}
|
|
157344
157835
|
const reportInput = input;
|
|
@@ -157877,7 +158368,7 @@ var init_types8 = __esm2(() => {
|
|
|
157877
158368
|
"latency"
|
|
157878
158369
|
];
|
|
157879
158370
|
});
|
|
157880
|
-
function
|
|
158371
|
+
function isRecord20(value) {
|
|
157881
158372
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
157882
158373
|
}
|
|
157883
158374
|
function cleanOptionalString5(value) {
|
|
@@ -157949,13 +158440,13 @@ function normalizeAvailableModels(value) {
|
|
|
157949
158440
|
if (!Array.isArray(value)) {
|
|
157950
158441
|
throw new IntelligentRouterValidationError("availableModels must be an array.");
|
|
157951
158442
|
}
|
|
157952
|
-
return value.filter(
|
|
158443
|
+
return value.filter(isRecord20).map((entry2) => {
|
|
157953
158444
|
const provider = cleanRequiredString5(entry2.provider, "provider");
|
|
157954
158445
|
const model = cleanRequiredString5(entry2.model, "model");
|
|
157955
158446
|
const name = cleanOptionalString5(entry2.name);
|
|
157956
158447
|
const available = typeof entry2.available === "boolean" ? entry2.available : void 0;
|
|
157957
158448
|
const cost = (() => {
|
|
157958
|
-
if (!
|
|
158449
|
+
if (!isRecord20(entry2.cost))
|
|
157959
158450
|
return;
|
|
157960
158451
|
const input = parseFiniteNumber(entry2.cost.input, "cost.input");
|
|
157961
158452
|
const output = parseFiniteNumber(entry2.cost.output, "cost.output");
|
|
@@ -157978,7 +158469,7 @@ function normalizeAvailableModels(value) {
|
|
|
157978
158469
|
});
|
|
157979
158470
|
}
|
|
157980
158471
|
function normalizeRoutingRequest(input, defaultAvailableModels) {
|
|
157981
|
-
if (!
|
|
158472
|
+
if (!isRecord20(input)) {
|
|
157982
158473
|
throw new IntelligentRouterValidationError("Routing request must be an object.");
|
|
157983
158474
|
}
|
|
157984
158475
|
const requestInput = input;
|
|
@@ -157995,7 +158486,7 @@ function normalizeRoutingRequest(input, defaultAvailableModels) {
|
|
|
157995
158486
|
};
|
|
157996
158487
|
}
|
|
157997
158488
|
function normalizePerformanceMetricInput(input) {
|
|
157998
|
-
if (!
|
|
158489
|
+
if (!isRecord20(input)) {
|
|
157999
158490
|
throw new IntelligentRouterValidationError("Metric must be an object.");
|
|
158000
158491
|
}
|
|
158001
158492
|
const metricInput = input;
|
|
@@ -158020,7 +158511,7 @@ function normalizePerformanceMetricInput(input) {
|
|
|
158020
158511
|
};
|
|
158021
158512
|
}
|
|
158022
158513
|
function normalizeRoutingOverrideInput(input) {
|
|
158023
|
-
if (!
|
|
158514
|
+
if (!isRecord20(input)) {
|
|
158024
158515
|
throw new IntelligentRouterValidationError("Override must be an object.");
|
|
158025
158516
|
}
|
|
158026
158517
|
const overrideInput = input;
|
|
@@ -163627,7 +164118,7 @@ var init_types9 = __esm2(() => {
|
|
|
163627
164118
|
"custom"
|
|
163628
164119
|
];
|
|
163629
164120
|
});
|
|
163630
|
-
function
|
|
164121
|
+
function isRecord21(value) {
|
|
163631
164122
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
163632
164123
|
}
|
|
163633
164124
|
function cleanOptionalString6(value) {
|
|
@@ -163711,7 +164202,7 @@ function sanitizeJsonValue3(value, depth = 0) {
|
|
|
163711
164202
|
if (Array.isArray(value)) {
|
|
163712
164203
|
return value.map((item) => sanitizeJsonValue3(item, depth + 1)).filter((item) => item !== void 0);
|
|
163713
164204
|
}
|
|
163714
|
-
if (
|
|
164205
|
+
if (isRecord21(value)) {
|
|
163715
164206
|
const result = {};
|
|
163716
164207
|
for (const [key, nestedValue] of Object.entries(value)) {
|
|
163717
164208
|
const sanitized = sanitizeJsonValue3(nestedValue, depth + 1);
|
|
@@ -163727,10 +164218,10 @@ function sanitizeMetadata2(value) {
|
|
|
163727
164218
|
if (!value)
|
|
163728
164219
|
return {};
|
|
163729
164220
|
const sanitized = sanitizeJsonValue3(value);
|
|
163730
|
-
return
|
|
164221
|
+
return isRecord21(sanitized) ? sanitized : {};
|
|
163731
164222
|
}
|
|
163732
164223
|
function normalizeRevenueOutcomeInput(input) {
|
|
163733
|
-
if (!
|
|
164224
|
+
if (!isRecord21(input)) {
|
|
163734
164225
|
throw new RevenueAttributionValidationError("Outcome must be an object.");
|
|
163735
164226
|
}
|
|
163736
164227
|
const outcomeInput = input;
|
|
@@ -169388,7 +169879,7 @@ __export2(exports_config, {
|
|
|
169388
169879
|
buildConfigShowSections: () => buildConfigShowSections
|
|
169389
169880
|
});
|
|
169390
169881
|
function getManagedGatewayBaseUrl2() {
|
|
169391
|
-
return process.env.MAESTRO_LLM_GATEWAY_URL?.trim() ||
|
|
169882
|
+
return process.env.MAESTRO_LLM_GATEWAY_URL?.trim() || DEFAULT_EVALOPS_MANAGED_GATEWAY_BASE_URL;
|
|
169392
169883
|
}
|
|
169393
169884
|
function getManagedGatewayProviderPresets() {
|
|
169394
169885
|
return getEvalOpsManagedProviderDefinitions().map((definition) => ({
|
|
@@ -170248,12 +170739,185 @@ var init_openai3 = __esm2(() => {
|
|
|
170248
170739
|
init_openai_auth();
|
|
170249
170740
|
CALLBACK_ORIGIN4 = `http://127.0.0.1:${DEFAULT_PORT}`;
|
|
170250
170741
|
});
|
|
170742
|
+
var exports_init = {};
|
|
170743
|
+
__export2(exports_init, {
|
|
170744
|
+
parseInitArgs: () => parseInitArgs,
|
|
170745
|
+
handleInitCommand: () => handleInitCommand2,
|
|
170746
|
+
formatInitHelp: () => formatInitHelp
|
|
170747
|
+
});
|
|
170748
|
+
function formatInitHelp() {
|
|
170749
|
+
return `${sectionHeading("maestro init")}${muted(` maestro init Login, create or reuse an API key, and register this agent
|
|
170750
|
+
maestro init --rotate-key Replace the stored agent MCP API key
|
|
170751
|
+
maestro init --mcp-url <url> Override the EvalOps agent MCP endpoint
|
|
170752
|
+
maestro init --json Emit machine-readable bootstrap output
|
|
170753
|
+
|
|
170754
|
+
Options
|
|
170755
|
+
--agent-type <type> Agent type to register, defaults to maestro
|
|
170756
|
+
--surface <surface> Surface to register, defaults to cli
|
|
170757
|
+
--workspace, --workspace-id <id> Workspace to associate with the registration
|
|
170758
|
+
--scope <scope[,scope...]> Registration scopes to request
|
|
170759
|
+
--key-scope <scope[,scope...]> API key scopes to request
|
|
170760
|
+
--expires-in-days <days> API key TTL in days
|
|
170761
|
+
--force-login Re-run EvalOps OAuth before bootstrapping
|
|
170762
|
+
--manifest-url <url> Override the agent MCP manifest URL
|
|
170763
|
+
--ttl-seconds <seconds> Registration TTL in seconds`)}`;
|
|
170764
|
+
}
|
|
170765
|
+
function readValue(args, index2, flag) {
|
|
170766
|
+
const value = args[index2 + 1];
|
|
170767
|
+
if (!value || value.startsWith("-")) {
|
|
170768
|
+
throw new Error(`${flag} requires a value`);
|
|
170769
|
+
}
|
|
170770
|
+
return value;
|
|
170771
|
+
}
|
|
170772
|
+
function parsePositiveInteger(value, flag) {
|
|
170773
|
+
const parsed = Number.parseInt(value, 10);
|
|
170774
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
170775
|
+
throw new Error(`${flag} must be a positive integer`);
|
|
170776
|
+
}
|
|
170777
|
+
return parsed;
|
|
170778
|
+
}
|
|
170779
|
+
function appendScopes(existing, value) {
|
|
170780
|
+
return [
|
|
170781
|
+
...existing ?? [],
|
|
170782
|
+
...value.split(",").map((entry2) => entry2.trim()).filter((entry2) => entry2.length > 0)
|
|
170783
|
+
];
|
|
170784
|
+
}
|
|
170785
|
+
function parseInitArgs(args) {
|
|
170786
|
+
const options = {};
|
|
170787
|
+
for (let i2 = 0; i2 < args.length; i2++) {
|
|
170788
|
+
const arg = args[i2];
|
|
170789
|
+
switch (arg) {
|
|
170790
|
+
case "--agent-mcp-url":
|
|
170791
|
+
case "--mcp-url":
|
|
170792
|
+
options.mcpUrl = readValue(args, i2, arg);
|
|
170793
|
+
i2++;
|
|
170794
|
+
break;
|
|
170795
|
+
case "--agent-type":
|
|
170796
|
+
options.agentType = readValue(args, i2, arg);
|
|
170797
|
+
i2++;
|
|
170798
|
+
break;
|
|
170799
|
+
case "--api-key-scope":
|
|
170800
|
+
case "--key-scope":
|
|
170801
|
+
options.apiKeyScopes = appendScopes(options.apiKeyScopes, readValue(args, i2, arg));
|
|
170802
|
+
i2++;
|
|
170803
|
+
break;
|
|
170804
|
+
case "--expires-in-days":
|
|
170805
|
+
options.expiresInDays = parsePositiveInteger(readValue(args, i2, arg), arg);
|
|
170806
|
+
i2++;
|
|
170807
|
+
break;
|
|
170808
|
+
case "--force-login":
|
|
170809
|
+
options.forceLogin = true;
|
|
170810
|
+
break;
|
|
170811
|
+
case "--json":
|
|
170812
|
+
options.json = true;
|
|
170813
|
+
break;
|
|
170814
|
+
case "--key-name":
|
|
170815
|
+
options.keyName = readValue(args, i2, arg);
|
|
170816
|
+
i2++;
|
|
170817
|
+
break;
|
|
170818
|
+
case "--manifest-url":
|
|
170819
|
+
options.manifestUrl = readValue(args, i2, arg);
|
|
170820
|
+
i2++;
|
|
170821
|
+
break;
|
|
170822
|
+
case "--register-scope":
|
|
170823
|
+
case "--scope":
|
|
170824
|
+
options.registerScopes = appendScopes(options.registerScopes, readValue(args, i2, arg));
|
|
170825
|
+
i2++;
|
|
170826
|
+
break;
|
|
170827
|
+
case "--rotate-key":
|
|
170828
|
+
options.rotateKey = true;
|
|
170829
|
+
break;
|
|
170830
|
+
case "--surface":
|
|
170831
|
+
options.surface = readValue(args, i2, arg);
|
|
170832
|
+
i2++;
|
|
170833
|
+
break;
|
|
170834
|
+
case "--ttl-seconds":
|
|
170835
|
+
options.ttlSeconds = parsePositiveInteger(readValue(args, i2, arg), arg);
|
|
170836
|
+
i2++;
|
|
170837
|
+
break;
|
|
170838
|
+
case "--workspace":
|
|
170839
|
+
case "--workspace-id":
|
|
170840
|
+
options.workspaceId = readValue(args, i2, arg);
|
|
170841
|
+
i2++;
|
|
170842
|
+
break;
|
|
170843
|
+
default:
|
|
170844
|
+
if (arg?.startsWith("-")) {
|
|
170845
|
+
throw new Error(`Unknown maestro init option: ${arg}`);
|
|
170846
|
+
}
|
|
170847
|
+
throw new Error(`Unexpected maestro init argument: ${arg}`);
|
|
170848
|
+
}
|
|
170849
|
+
}
|
|
170850
|
+
return options;
|
|
170851
|
+
}
|
|
170852
|
+
async function handleInitCommand2(args = []) {
|
|
170853
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
170854
|
+
console.log(formatInitHelp());
|
|
170855
|
+
return;
|
|
170856
|
+
}
|
|
170857
|
+
let options;
|
|
170858
|
+
try {
|
|
170859
|
+
options = parseInitArgs(args);
|
|
170860
|
+
} catch (error) {
|
|
170861
|
+
console.error(chalk62.red(error instanceof Error ? error.message : String(error)));
|
|
170862
|
+
process.exit(1);
|
|
170863
|
+
}
|
|
170864
|
+
if (!options.json) {
|
|
170865
|
+
console.log(chalk62.bold("Maestro EvalOps Init"));
|
|
170866
|
+
}
|
|
170867
|
+
const result = await bootstrapEvalOpsAgent(options, {
|
|
170868
|
+
onAuthUrl: (url) => {
|
|
170869
|
+
if (options.json) {
|
|
170870
|
+
console.error("Open this URL in your browser to authenticate with EvalOps:");
|
|
170871
|
+
console.error(url);
|
|
170872
|
+
return;
|
|
170873
|
+
}
|
|
170874
|
+
console.log(chalk62.yellow("Open this URL in your browser to authenticate with EvalOps:"));
|
|
170875
|
+
console.log(chalk62.underline(url));
|
|
170876
|
+
},
|
|
170877
|
+
onStatus: (status) => {
|
|
170878
|
+
if (options.json) {
|
|
170879
|
+
console.error(status.message);
|
|
170880
|
+
return;
|
|
170881
|
+
}
|
|
170882
|
+
console.log(chalk62.dim(status.message));
|
|
170883
|
+
}
|
|
170884
|
+
});
|
|
170885
|
+
if (options.json) {
|
|
170886
|
+
console.log(JSON.stringify(result, null, 2));
|
|
170887
|
+
return;
|
|
170888
|
+
}
|
|
170889
|
+
console.log(chalk62.green("EvalOps agent bootstrap complete."));
|
|
170890
|
+
console.log(chalk62.dim(`MCP endpoint: ${result.endpoint}`));
|
|
170891
|
+
if (result.organizationId) {
|
|
170892
|
+
console.log(chalk62.dim(`Organization: ${result.organizationId}`));
|
|
170893
|
+
}
|
|
170894
|
+
if (result.agentId) {
|
|
170895
|
+
console.log(chalk62.dim(`Agent: ${result.agentId}`));
|
|
170896
|
+
}
|
|
170897
|
+
if (result.runId) {
|
|
170898
|
+
console.log(chalk62.dim(`Run: ${result.runId}`));
|
|
170899
|
+
}
|
|
170900
|
+
if (result.keyPrefix) {
|
|
170901
|
+
const keyMode = result.apiKeyCreated ? "created" : "reused";
|
|
170902
|
+
console.log(chalk62.dim(`API key ${keyMode}: ${result.keyPrefix}`));
|
|
170903
|
+
}
|
|
170904
|
+
console.log(chalk62.dim("Stored EvalOps MCP credentials locally for future Maestro sessions."));
|
|
170905
|
+
}
|
|
170906
|
+
var init_init = __esm2(() => {
|
|
170907
|
+
init_agent_bootstrap();
|
|
170908
|
+
init_theme2();
|
|
170909
|
+
});
|
|
170251
170910
|
var exports_evalops = {};
|
|
170252
170911
|
__export2(exports_evalops, {
|
|
170253
170912
|
handleEvalOpsCommand: () => handleEvalOpsCommand
|
|
170254
170913
|
});
|
|
170255
|
-
async function handleEvalOpsCommand(subcommand) {
|
|
170914
|
+
async function handleEvalOpsCommand(subcommand, args = []) {
|
|
170256
170915
|
switch (subcommand) {
|
|
170916
|
+
case "init": {
|
|
170917
|
+
const { handleInitCommand: handleInitCommand3 } = await Promise.resolve().then(() => (init_init(), exports_init));
|
|
170918
|
+
await handleInitCommand3(args);
|
|
170919
|
+
return;
|
|
170920
|
+
}
|
|
170257
170921
|
case "login":
|
|
170258
170922
|
await handleLogin3();
|
|
170259
170923
|
return;
|
|
@@ -170264,50 +170928,70 @@ async function handleEvalOpsCommand(subcommand) {
|
|
|
170264
170928
|
await handleStatus3();
|
|
170265
170929
|
return;
|
|
170266
170930
|
default:
|
|
170267
|
-
console.error(
|
|
170931
|
+
console.error(chalk63.red('Unknown evalops subcommand. Try "maestro init" for setup, or "maestro evalops login", "logout", or "status".'));
|
|
170268
170932
|
process.exit(1);
|
|
170269
170933
|
}
|
|
170270
170934
|
}
|
|
170271
170935
|
async function handleLogin3() {
|
|
170272
|
-
console.log(
|
|
170936
|
+
console.log(chalk63.bold("Maestro EvalOps Login"));
|
|
170273
170937
|
await login("evalops", {
|
|
170274
170938
|
onAuthUrl: (url) => {
|
|
170275
|
-
console.log(
|
|
170276
|
-
console.log(
|
|
170939
|
+
console.log(chalk63.yellow("Open this URL in your browser to authenticate with EvalOps:"));
|
|
170940
|
+
console.log(chalk63.underline(url));
|
|
170277
170941
|
},
|
|
170278
|
-
onStatus: (status) => console.log(
|
|
170942
|
+
onStatus: (status) => console.log(chalk63.dim(status))
|
|
170279
170943
|
});
|
|
170280
|
-
console.log(
|
|
170281
|
-
console.log(
|
|
170944
|
+
console.log(chalk63.green("EvalOps credentials saved successfully."));
|
|
170945
|
+
console.log(chalk63.dim('Try "maestro --provider evalops --model gpt-4o-mini".'));
|
|
170282
170946
|
}
|
|
170283
170947
|
async function handleLogout2() {
|
|
170284
170948
|
await logout("evalops");
|
|
170285
|
-
console.log(
|
|
170949
|
+
console.log(chalk63.green("Removed stored EvalOps credentials."));
|
|
170286
170950
|
}
|
|
170287
170951
|
async function handleStatus3() {
|
|
170288
170952
|
if (!hasOAuthCredentials("evalops")) {
|
|
170289
|
-
console.log(
|
|
170290
|
-
console.log(
|
|
170953
|
+
console.log(chalk63.yellow("No stored EvalOps credentials."));
|
|
170954
|
+
console.log(chalk63.dim('Run "maestro evalops login" to authenticate with EvalOps.'));
|
|
170291
170955
|
return;
|
|
170292
170956
|
}
|
|
170293
170957
|
const credentials = loadOAuthCredentials("evalops");
|
|
170294
170958
|
const remainingMs = Math.max(0, (credentials?.expires ?? Date.now()) - Date.now());
|
|
170295
170959
|
const minutes = Math.round(remainingMs / 6e4);
|
|
170296
170960
|
const metadata = credentials?.metadata;
|
|
170961
|
+
const agentMcp = getStoredEvalOpsAgentMcpMetadata();
|
|
170297
170962
|
const organizationId = typeof metadata?.organizationId === "string" ? metadata.organizationId : void 0;
|
|
170298
170963
|
const providerRef = metadata?.providerRef && typeof metadata.providerRef === "object" && !Array.isArray(metadata.providerRef) ? metadata.providerRef : void 0;
|
|
170299
|
-
console.log(
|
|
170964
|
+
console.log(chalk63.green("Stored EvalOps credentials detected."));
|
|
170300
170965
|
if (organizationId) {
|
|
170301
|
-
console.log(
|
|
170966
|
+
console.log(chalk63.dim(`Organization: ${organizationId}`));
|
|
170302
170967
|
}
|
|
170303
170968
|
if (providerRef) {
|
|
170304
170969
|
const provider = typeof providerRef.provider === "string" ? providerRef.provider : "openai";
|
|
170305
170970
|
const environment = typeof providerRef.environment === "string" ? providerRef.environment : "prod";
|
|
170306
|
-
console.log(
|
|
170971
|
+
console.log(chalk63.dim(`Provider ref: ${provider}/${environment}`));
|
|
170972
|
+
}
|
|
170973
|
+
if (agentMcp) {
|
|
170974
|
+
console.log(chalk63.green("EvalOps agent session configured."));
|
|
170975
|
+
console.log(chalk63.dim(`MCP endpoint: ${agentMcp.endpoint}`));
|
|
170976
|
+
if (agentMcp.agentId) {
|
|
170977
|
+
console.log(chalk63.dim(`Agent: ${agentMcp.agentId}`));
|
|
170978
|
+
}
|
|
170979
|
+
if (agentMcp.runId) {
|
|
170980
|
+
console.log(chalk63.dim(`Run: ${agentMcp.runId}`));
|
|
170981
|
+
}
|
|
170982
|
+
if (agentMcp.keyPrefix) {
|
|
170983
|
+
console.log(chalk63.dim(`API key: ${agentMcp.keyPrefix}`));
|
|
170984
|
+
}
|
|
170985
|
+
if (agentMcp.sessionExpiresAt) {
|
|
170986
|
+
console.log(chalk63.dim(`Session expires: ${agentMcp.sessionExpiresAt}`));
|
|
170987
|
+
}
|
|
170988
|
+
} else {
|
|
170989
|
+
console.log(chalk63.yellow('No EvalOps agent session yet. Run "maestro init".'));
|
|
170307
170990
|
}
|
|
170308
|
-
console.log(
|
|
170991
|
+
console.log(chalk63.dim(`Access token expires in ~${minutes} minute${minutes === 1 ? "" : "s"} (auto-refresh enabled).`));
|
|
170309
170992
|
}
|
|
170310
170993
|
var init_evalops2 = __esm2(() => {
|
|
170994
|
+
init_agent_bootstrap();
|
|
170311
170995
|
init_oauth();
|
|
170312
170996
|
init_storage();
|
|
170313
170997
|
});
|
|
@@ -170327,7 +171011,7 @@ async function handleCodexCommand(subcommand, _params = []) {
|
|
|
170327
171011
|
await handleStatus4();
|
|
170328
171012
|
return;
|
|
170329
171013
|
default:
|
|
170330
|
-
console.error(
|
|
171014
|
+
console.error(chalk64.red('Unknown codex subcommand. Try "maestro codex login", "logout", or "status".'));
|
|
170331
171015
|
process.exit(1);
|
|
170332
171016
|
}
|
|
170333
171017
|
}
|
|
@@ -170340,37 +171024,37 @@ async function promptCode() {
|
|
|
170340
171024
|
}
|
|
170341
171025
|
}
|
|
170342
171026
|
async function handleLogin4() {
|
|
170343
|
-
console.log(
|
|
171027
|
+
console.log(chalk64.bold("Maestro OpenAI Codex Login"));
|
|
170344
171028
|
await login("openai-codex", {
|
|
170345
171029
|
onAuthUrl: (url) => {
|
|
170346
|
-
console.log(
|
|
170347
|
-
console.log(
|
|
171030
|
+
console.log(chalk64.yellow("Open this URL in your browser to authenticate with OpenAI:"));
|
|
171031
|
+
console.log(chalk64.underline(url));
|
|
170348
171032
|
},
|
|
170349
171033
|
onPromptCode: promptCode,
|
|
170350
|
-
onStatus: (status) => console.log(
|
|
171034
|
+
onStatus: (status) => console.log(chalk64.dim(status))
|
|
170351
171035
|
});
|
|
170352
|
-
console.log(
|
|
170353
|
-
console.log(
|
|
171036
|
+
console.log(chalk64.green("OpenAI Codex credentials saved successfully."));
|
|
171037
|
+
console.log(chalk64.dim('Select provider "openai-codex" or a model like "openai-codex/gpt-5.5".'));
|
|
170354
171038
|
}
|
|
170355
171039
|
async function handleLogout3() {
|
|
170356
171040
|
await logout("openai-codex");
|
|
170357
|
-
console.log(
|
|
171041
|
+
console.log(chalk64.green("Removed stored OpenAI Codex credentials."));
|
|
170358
171042
|
}
|
|
170359
171043
|
async function handleStatus4() {
|
|
170360
171044
|
if (!hasOAuthCredentials("openai-codex")) {
|
|
170361
|
-
console.log(
|
|
170362
|
-
console.log(
|
|
171045
|
+
console.log(chalk64.yellow("No stored OpenAI Codex credentials."));
|
|
171046
|
+
console.log(chalk64.dim('Run "maestro codex login" to authenticate with OpenAI.'));
|
|
170363
171047
|
return;
|
|
170364
171048
|
}
|
|
170365
171049
|
const credentials = loadOAuthCredentials("openai-codex");
|
|
170366
171050
|
const remainingMs = Math.max(0, (credentials?.expires ?? Date.now()) - Date.now());
|
|
170367
171051
|
const minutes = Math.round(remainingMs / 6e4);
|
|
170368
171052
|
const accountId = typeof credentials?.metadata?.accountId === "string" ? credentials.metadata.accountId : void 0;
|
|
170369
|
-
console.log(
|
|
171053
|
+
console.log(chalk64.green("Stored OpenAI Codex credentials detected."));
|
|
170370
171054
|
if (accountId) {
|
|
170371
|
-
console.log(
|
|
171055
|
+
console.log(chalk64.dim(`ChatGPT account id: ${accountId}`));
|
|
170372
171056
|
}
|
|
170373
|
-
console.log(
|
|
171057
|
+
console.log(chalk64.dim(`Access token expires in ~${minutes} minute${minutes === 1 ? "" : "s"} (auto-refresh enabled).`));
|
|
170374
171058
|
}
|
|
170375
171059
|
var init_codex = __esm2(() => {
|
|
170376
171060
|
init_oauth();
|
|
@@ -170382,8 +171066,8 @@ __export2(exports_hooks, {
|
|
|
170382
171066
|
});
|
|
170383
171067
|
async function handleHooksCommand(subcommand) {
|
|
170384
171068
|
if (subcommand && subcommand !== "status") {
|
|
170385
|
-
console.error(
|
|
170386
|
-
console.error(
|
|
171069
|
+
console.error(chalk65.red(`Unknown hooks subcommand: ${subcommand}`));
|
|
171070
|
+
console.error(chalk65.dim("Try: maestro hooks status"));
|
|
170387
171071
|
process.exit(1);
|
|
170388
171072
|
}
|
|
170389
171073
|
cleanupAsyncHooks();
|
|
@@ -170395,10 +171079,10 @@ async function handleHooksCommand(subcommand) {
|
|
|
170395
171079
|
["Queued requests", concurrency.queued],
|
|
170396
171080
|
["Async in-flight", asyncInFlight]
|
|
170397
171081
|
];
|
|
170398
|
-
console.log(
|
|
171082
|
+
console.log(chalk65.bold("Hook Status"));
|
|
170399
171083
|
for (const [label, value] of rows) {
|
|
170400
171084
|
const padded = label.padEnd(18);
|
|
170401
|
-
console.log(`${
|
|
171085
|
+
console.log(`${chalk65.cyan(padded)} ${value}`);
|
|
170402
171086
|
}
|
|
170403
171087
|
}
|
|
170404
171088
|
var init_hooks2 = __esm2(() => {
|
|
@@ -170410,8 +171094,8 @@ __export2(exports_session_transfer, {
|
|
|
170410
171094
|
handleExportCommand: () => handleExportCommand
|
|
170411
171095
|
});
|
|
170412
171096
|
function exitWithUsage(message, usage) {
|
|
170413
|
-
console.error(
|
|
170414
|
-
console.error(
|
|
171097
|
+
console.error(chalk66.red(message));
|
|
171098
|
+
console.error(chalk66.dim(usage));
|
|
170415
171099
|
process.exit(1);
|
|
170416
171100
|
}
|
|
170417
171101
|
async function handleExportCommand(sessionId, outputPath, format, options = {}) {
|
|
@@ -170429,7 +171113,7 @@ async function handleExportCommand(sessionId, outputPath, format, options = {})
|
|
|
170429
171113
|
}
|
|
170430
171114
|
const exportManager = new SessionManager(false, sessionFile);
|
|
170431
171115
|
const exportedPath = normalizedFormat === JSON_FORMAT ? await exportSessionToJson(exportManager, outputPath, options) : await exportSessionToJsonl(exportManager, outputPath, options);
|
|
170432
|
-
console.log(
|
|
171116
|
+
console.log(chalk66.green(`Exported session ${sessionId} to ${resolve59(exportedPath)} (${normalizedFormat}).`));
|
|
170433
171117
|
}
|
|
170434
171118
|
async function handleImportCommand(sourcePath) {
|
|
170435
171119
|
if (!sourcePath) {
|
|
@@ -170437,8 +171121,8 @@ async function handleImportCommand(sourcePath) {
|
|
|
170437
171121
|
}
|
|
170438
171122
|
const sessionManager = new SessionManager(false);
|
|
170439
171123
|
const imported = sessionManager.importPortableSession(sourcePath);
|
|
170440
|
-
console.log(
|
|
170441
|
-
console.log(
|
|
171124
|
+
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)}.`));
|
|
171125
|
+
console.log(chalk66.dim(`Stored at ${imported.sessionFile}`));
|
|
170442
171126
|
}
|
|
170443
171127
|
var JSONL_FORMAT = "jsonl";
|
|
170444
171128
|
var JSON_FORMAT = "json";
|
|
@@ -170455,7 +171139,7 @@ __export2(exports_memory, {
|
|
|
170455
171139
|
function getConfig() {
|
|
170456
171140
|
const base = process.env.MAESTRO_SHARED_MEMORY_BASE?.trim();
|
|
170457
171141
|
if (!base) {
|
|
170458
|
-
console.error(
|
|
171142
|
+
console.error(chalk67.red("MAESTRO_SHARED_MEMORY_BASE is not set. Configure shared memory to use this command."));
|
|
170459
171143
|
process.exit(1);
|
|
170460
171144
|
}
|
|
170461
171145
|
const apiKey = process.env.MAESTRO_SHARED_MEMORY_API_KEY?.trim();
|
|
@@ -170519,7 +171203,7 @@ async function printStatus(config2) {
|
|
|
170519
171203
|
}
|
|
170520
171204
|
printCapabilities(metrics.capabilities);
|
|
170521
171205
|
} catch (error) {
|
|
170522
|
-
console.error(
|
|
171206
|
+
console.error(chalk67.red(`Failed to fetch shared memory status: ${error instanceof Error ? error.message : String(error)}`));
|
|
170523
171207
|
process.exit(1);
|
|
170524
171208
|
}
|
|
170525
171209
|
}
|
|
@@ -170557,7 +171241,7 @@ async function printAudit(config2, sessionId, limit) {
|
|
|
170557
171241
|
const mode = entry2.mode ? String(entry2.mode) : "?";
|
|
170558
171242
|
const events = entry2.event_count ? String(entry2.event_count) : "0";
|
|
170559
171243
|
const source = entry2.source ? String(entry2.source) : "?";
|
|
170560
|
-
console.log(`${
|
|
171244
|
+
console.log(`${chalk67.cyan(at)} ${separator()}${badge("mode", mode)}${separator()}${badge("events", events)}${separator()}${badge("source", source)}`);
|
|
170561
171245
|
}
|
|
170562
171246
|
}
|
|
170563
171247
|
async function exportMetrics(config2, sessionId) {
|
|
@@ -170595,7 +171279,7 @@ async function handleMemoryCommand2(subcommand, args) {
|
|
|
170595
171279
|
case "session": {
|
|
170596
171280
|
const sessionId = args[0];
|
|
170597
171281
|
if (!sessionId) {
|
|
170598
|
-
console.error(
|
|
171282
|
+
console.error(chalk67.red("Session id required."));
|
|
170599
171283
|
process.exit(1);
|
|
170600
171284
|
}
|
|
170601
171285
|
const config2 = getConfig();
|
|
@@ -170605,7 +171289,7 @@ async function handleMemoryCommand2(subcommand, args) {
|
|
|
170605
171289
|
case "audit": {
|
|
170606
171290
|
const sessionId = args[0];
|
|
170607
171291
|
if (!sessionId) {
|
|
170608
|
-
console.error(
|
|
171292
|
+
console.error(chalk67.red("Session id required."));
|
|
170609
171293
|
process.exit(1);
|
|
170610
171294
|
}
|
|
170611
171295
|
const config2 = getConfig();
|
|
@@ -170616,7 +171300,7 @@ async function handleMemoryCommand2(subcommand, args) {
|
|
|
170616
171300
|
case "export": {
|
|
170617
171301
|
const sessionId = args[0];
|
|
170618
171302
|
if (!sessionId) {
|
|
170619
|
-
console.error(
|
|
171303
|
+
console.error(chalk67.red("Session id required."));
|
|
170620
171304
|
process.exit(1);
|
|
170621
171305
|
}
|
|
170622
171306
|
const config2 = getConfig();
|
|
@@ -170636,22 +171320,22 @@ async function handleMemoryCommand2(subcommand, args) {
|
|
|
170636
171320
|
await printStatus(config2);
|
|
170637
171321
|
}
|
|
170638
171322
|
} catch (error) {
|
|
170639
|
-
console.error(
|
|
171323
|
+
console.error(chalk67.red(`Shared memory watch error: ${error instanceof Error ? error.message : String(error)}`));
|
|
170640
171324
|
}
|
|
170641
171325
|
await new Promise((resolve602) => setTimeout(resolve602, intervalMs));
|
|
170642
171326
|
}
|
|
170643
171327
|
return;
|
|
170644
171328
|
}
|
|
170645
171329
|
default:
|
|
170646
|
-
console.error(
|
|
170647
|
-
console.log(
|
|
171330
|
+
console.error(chalk67.red(`Unknown memory subcommand: ${subcommand}`));
|
|
171331
|
+
console.log(chalk67.dim(`
|
|
170648
171332
|
Available commands:`));
|
|
170649
|
-
console.log(
|
|
170650
|
-
console.log(
|
|
170651
|
-
console.log(
|
|
170652
|
-
console.log(
|
|
170653
|
-
console.log(
|
|
170654
|
-
console.log(
|
|
171333
|
+
console.log(chalk67.dim(" maestro memory [status]"));
|
|
171334
|
+
console.log(chalk67.dim(" maestro memory capabilities"));
|
|
171335
|
+
console.log(chalk67.dim(" maestro memory session <id>"));
|
|
171336
|
+
console.log(chalk67.dim(" maestro memory audit <id> [limit]"));
|
|
171337
|
+
console.log(chalk67.dim(" maestro memory export <id>"));
|
|
171338
|
+
console.log(chalk67.dim(" maestro memory watch [id] [intervalMs]"));
|
|
170655
171339
|
process.exit(1);
|
|
170656
171340
|
}
|
|
170657
171341
|
}
|
|
@@ -171018,7 +171702,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171018
171702
|
const beginAssistantOutput = () => {
|
|
171019
171703
|
if (!visibleResponseOpen) {
|
|
171020
171704
|
clearPromptLine(stdout2);
|
|
171021
|
-
stdout2.write(
|
|
171705
|
+
stdout2.write(chalk68.bold("assistant> "));
|
|
171022
171706
|
visibleResponseOpen = true;
|
|
171023
171707
|
responseEndsWithNewline = false;
|
|
171024
171708
|
}
|
|
@@ -171033,7 +171717,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171033
171717
|
`);
|
|
171034
171718
|
};
|
|
171035
171719
|
const printStatus2 = () => {
|
|
171036
|
-
writeLine(
|
|
171720
|
+
writeLine(chalk68.bold(`Remote session ${input.sessionId}`));
|
|
171037
171721
|
writeLine(` role: ${input.role}`);
|
|
171038
171722
|
writeLine(` ready: ${state2.is_ready ? "yes" : "no"}`);
|
|
171039
171723
|
writeLine(` responding: ${state2.is_responding ? "yes" : "no"}`);
|
|
@@ -171048,11 +171732,11 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171048
171732
|
};
|
|
171049
171733
|
const connection = await connectToRemoteRunnerSession(input);
|
|
171050
171734
|
state2 = connection.state;
|
|
171051
|
-
writeLine(
|
|
171735
|
+
writeLine(chalk68.bold(`Attached to ${connection.sessionId} as ${connection.role === "viewer" ? "viewer" : "controller"}`));
|
|
171052
171736
|
if (connection.role === "controller") {
|
|
171053
|
-
writeLine(
|
|
171737
|
+
writeLine(chalk68.dim("Enter a prompt below. Use /status, /help, or /exit. Press Ctrl+C to interrupt an active response."));
|
|
171054
171738
|
} else {
|
|
171055
|
-
writeLine(
|
|
171739
|
+
writeLine(chalk68.dim("Viewer mode is read-only. Use /status or /exit."));
|
|
171056
171740
|
}
|
|
171057
171741
|
const attachContext = {
|
|
171058
171742
|
gatewayBaseUrl: input.gatewayBaseUrl,
|
|
@@ -171083,13 +171767,13 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171083
171767
|
visibleResponseOpen = false;
|
|
171084
171768
|
break;
|
|
171085
171769
|
case "status":
|
|
171086
|
-
writeLine(
|
|
171770
|
+
writeLine(chalk68.dim(message.message));
|
|
171087
171771
|
break;
|
|
171088
171772
|
case "error":
|
|
171089
|
-
writeLine(
|
|
171773
|
+
writeLine(chalk68.red(message.message));
|
|
171090
171774
|
break;
|
|
171091
171775
|
case "compaction":
|
|
171092
|
-
writeLine(
|
|
171776
|
+
writeLine(chalk68.dim(`Compacted remote history: ${message.summary}`));
|
|
171093
171777
|
break;
|
|
171094
171778
|
default:
|
|
171095
171779
|
break;
|
|
@@ -171098,7 +171782,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171098
171782
|
},
|
|
171099
171783
|
onReset: (snapshotState) => {
|
|
171100
171784
|
state2 = snapshotState;
|
|
171101
|
-
writeLine(
|
|
171785
|
+
writeLine(chalk68.dim("Remote session state resynced from snapshot."));
|
|
171102
171786
|
updates.notify();
|
|
171103
171787
|
}
|
|
171104
171788
|
}, streamAbort.signal).catch((error) => {
|
|
@@ -171132,15 +171816,15 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171132
171816
|
return true;
|
|
171133
171817
|
case "/interrupt":
|
|
171134
171818
|
if (connection.role !== "controller") {
|
|
171135
|
-
writeLine(
|
|
171819
|
+
writeLine(chalk68.yellow("Viewer mode cannot interrupt the session."));
|
|
171136
171820
|
return true;
|
|
171137
171821
|
}
|
|
171138
171822
|
if (!state2.is_responding) {
|
|
171139
|
-
writeLine(
|
|
171823
|
+
writeLine(chalk68.dim("No active response to interrupt."));
|
|
171140
171824
|
return true;
|
|
171141
171825
|
}
|
|
171142
171826
|
await sendInteractiveMessage({ type: "interrupt" });
|
|
171143
|
-
writeLine(
|
|
171827
|
+
writeLine(chalk68.dim("Interrupt sent."));
|
|
171144
171828
|
return true;
|
|
171145
171829
|
case "/exit":
|
|
171146
171830
|
case "/quit":
|
|
@@ -171149,17 +171833,17 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171149
171833
|
return true;
|
|
171150
171834
|
default:
|
|
171151
171835
|
if (line.startsWith("/")) {
|
|
171152
|
-
writeLine(
|
|
171836
|
+
writeLine(chalk68.yellow(`Unknown command: ${line}`));
|
|
171153
171837
|
return true;
|
|
171154
171838
|
}
|
|
171155
171839
|
return false;
|
|
171156
171840
|
}
|
|
171157
171841
|
};
|
|
171158
171842
|
const handleApproval2 = async (request) => {
|
|
171159
|
-
writeLine(
|
|
171843
|
+
writeLine(chalk68.yellow(`Approval required: ${formatRequestLabel(request)}`));
|
|
171160
171844
|
const summary2 = summarizeArgs(request.args);
|
|
171161
171845
|
if (summary2) {
|
|
171162
|
-
writeLine(
|
|
171846
|
+
writeLine(chalk68.dim(summary2));
|
|
171163
171847
|
}
|
|
171164
171848
|
while (!closeRequested) {
|
|
171165
171849
|
const answer = (await rl.question("Approve? [y/N]: ")).trim();
|
|
@@ -171201,10 +171885,10 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171201
171885
|
}
|
|
171202
171886
|
};
|
|
171203
171887
|
const handleUserInput = async (request) => {
|
|
171204
|
-
writeLine(
|
|
171888
|
+
writeLine(chalk68.yellow(`Input requested: ${formatRequestLabel(request)}`));
|
|
171205
171889
|
const summary2 = summarizeArgs(request.args);
|
|
171206
171890
|
if (summary2) {
|
|
171207
|
-
writeLine(
|
|
171891
|
+
writeLine(chalk68.dim(summary2));
|
|
171208
171892
|
}
|
|
171209
171893
|
while (!closeRequested) {
|
|
171210
171894
|
const answer = await rl.question("Reply: ");
|
|
@@ -171231,10 +171915,10 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171231
171915
|
}
|
|
171232
171916
|
};
|
|
171233
171917
|
const handleToolRetry2 = async (request) => {
|
|
171234
|
-
writeLine(
|
|
171918
|
+
writeLine(chalk68.yellow(`Tool retry requested: ${formatRequestLabel(request)}`));
|
|
171235
171919
|
const summary2 = summarizeArgs(request.args);
|
|
171236
171920
|
if (summary2) {
|
|
171237
|
-
writeLine(
|
|
171921
|
+
writeLine(chalk68.dim(summary2));
|
|
171238
171922
|
}
|
|
171239
171923
|
while (!closeRequested) {
|
|
171240
171924
|
const answer = (await rl.question("Decision [retry/skip/abort]: ")).trim().toLowerCase();
|
|
@@ -171242,7 +171926,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171242
171926
|
continue;
|
|
171243
171927
|
}
|
|
171244
171928
|
if (!["retry", "skip", "abort"].includes(answer)) {
|
|
171245
|
-
writeLine(
|
|
171929
|
+
writeLine(chalk68.yellow("Enter retry, skip, or abort."));
|
|
171246
171930
|
continue;
|
|
171247
171931
|
}
|
|
171248
171932
|
await sendInteractiveMessage({
|
|
@@ -171260,7 +171944,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171260
171944
|
streamError = error instanceof Error ? error : new Error(String(error));
|
|
171261
171945
|
updates.notify();
|
|
171262
171946
|
});
|
|
171263
|
-
writeLine(
|
|
171947
|
+
writeLine(chalk68.dim("Interrupt sent."));
|
|
171264
171948
|
return;
|
|
171265
171949
|
}
|
|
171266
171950
|
closeRequested = true;
|
|
@@ -171302,7 +171986,7 @@ async function attachToRemoteRunnerSession(input) {
|
|
|
171302
171986
|
continue;
|
|
171303
171987
|
}
|
|
171304
171988
|
if (connection.role !== "controller") {
|
|
171305
|
-
writeLine(
|
|
171989
|
+
writeLine(chalk68.yellow("Viewer mode is read-only."));
|
|
171306
171990
|
version3 = updates.current();
|
|
171307
171991
|
continue;
|
|
171308
171992
|
}
|
|
@@ -172156,7 +172840,7 @@ function printJson(value) {
|
|
|
172156
172840
|
console.log(JSON.stringify(value, null, 2));
|
|
172157
172841
|
}
|
|
172158
172842
|
function printSession(session) {
|
|
172159
|
-
console.log(
|
|
172843
|
+
console.log(chalk69.bold(session.id));
|
|
172160
172844
|
console.log(` state: ${stateLabel(session.state)}`);
|
|
172161
172845
|
console.log(` workspace: ${session.workspaceId ?? "-"}`);
|
|
172162
172846
|
console.log(` profile: ${session.runnerProfile ?? "-"}`);
|
|
@@ -172170,7 +172854,7 @@ function printSession(session) {
|
|
|
172170
172854
|
}
|
|
172171
172855
|
function printSessionTable(sessions2) {
|
|
172172
172856
|
if (!sessions2.length) {
|
|
172173
|
-
console.log(
|
|
172857
|
+
console.log(chalk69.dim("No remote runner sessions found."));
|
|
172174
172858
|
return;
|
|
172175
172859
|
}
|
|
172176
172860
|
const rows = sessions2.map((session) => ({
|
|
@@ -172219,21 +172903,21 @@ function printAttachInstructions(input) {
|
|
|
172219
172903
|
});
|
|
172220
172904
|
return;
|
|
172221
172905
|
}
|
|
172222
|
-
console.log(
|
|
172906
|
+
console.log(chalk69.bold(`Remote runner attach token minted for ${input.sessionId}`));
|
|
172223
172907
|
console.log(` gateway: ${input.gatewayBaseUrl}`);
|
|
172224
172908
|
console.log(` token: ${input.tokenId}`);
|
|
172225
172909
|
console.log(` expires: ${input.expiresAt ?? "-"}`);
|
|
172226
172910
|
if (input.verified) {
|
|
172227
|
-
console.log(
|
|
172911
|
+
console.log(chalk69.green(" headless gateway: verified"));
|
|
172228
172912
|
}
|
|
172229
172913
|
if (input.showSecret || !input.verified) {
|
|
172230
172914
|
console.log("");
|
|
172231
|
-
console.log(
|
|
172915
|
+
console.log(chalk69.dim("Ephemeral remote transport environment:"));
|
|
172232
172916
|
console.log(`export MAESTRO_REMOTE_BASE_URL=${JSON.stringify(input.gatewayBaseUrl)}`);
|
|
172233
172917
|
console.log(`export MAESTRO_REMOTE_API_KEY=${JSON.stringify(input.tokenSecret)}`);
|
|
172234
172918
|
console.log(`export MAESTRO_REMOTE_HEADER_X_EVALOPS_RUNNER_ATTACH_TOKEN_ID=${JSON.stringify(input.tokenId)}`);
|
|
172235
172919
|
} else {
|
|
172236
|
-
console.log(
|
|
172920
|
+
console.log(chalk69.dim(" token secret hidden; rerun with --show-secret or --json when handoff needs it."));
|
|
172237
172921
|
}
|
|
172238
172922
|
}
|
|
172239
172923
|
async function handleStart(options) {
|
|
@@ -172295,10 +172979,10 @@ async function handleStart(options) {
|
|
|
172295
172979
|
}
|
|
172296
172980
|
printSession(waitResult?.session ?? result.session);
|
|
172297
172981
|
if (waitResult) {
|
|
172298
|
-
console.log(
|
|
172982
|
+
console.log(chalk69.dim(` ready: ${formatElapsedMs(waitResult.elapsedMs)} (${waitResult.attempts} checks)`));
|
|
172299
172983
|
}
|
|
172300
172984
|
if (result.replayed) {
|
|
172301
|
-
console.log(
|
|
172985
|
+
console.log(chalk69.dim(" replayed: existing idempotent request"));
|
|
172302
172986
|
}
|
|
172303
172987
|
console.log("");
|
|
172304
172988
|
if (attachResult) {
|
|
@@ -172314,7 +172998,7 @@ async function handleStart(options) {
|
|
|
172314
172998
|
});
|
|
172315
172999
|
return;
|
|
172316
173000
|
}
|
|
172317
|
-
console.log(
|
|
173001
|
+
console.log(chalk69.dim(`Attach: maestro remote attach ${result.session.id}`));
|
|
172318
173002
|
}
|
|
172319
173003
|
async function handleList2(options) {
|
|
172320
173004
|
const result = await listRunnerSessions({
|
|
@@ -172329,7 +173013,7 @@ async function handleList2(options) {
|
|
|
172329
173013
|
}
|
|
172330
173014
|
printSessionTable(result.sessions);
|
|
172331
173015
|
if (result.nextOffset !== void 0 && result.nextOffset > 0) {
|
|
172332
|
-
console.log(
|
|
173016
|
+
console.log(chalk69.dim(`next offset: ${result.nextOffset}`));
|
|
172333
173017
|
}
|
|
172334
173018
|
}
|
|
172335
173019
|
async function handleStatus5(options) {
|
|
@@ -172338,7 +173022,7 @@ async function handleStatus5(options) {
|
|
|
172338
173022
|
printJson(status);
|
|
172339
173023
|
return;
|
|
172340
173024
|
}
|
|
172341
|
-
console.log(
|
|
173025
|
+
console.log(chalk69.bold(status.service ?? "remote-runner"));
|
|
172342
173026
|
console.log(` workspace: ${status.workspaceId ?? "-"}`);
|
|
172343
173027
|
console.log(` policy: ${status.downstreamPolicy ?? "-"}`);
|
|
172344
173028
|
}
|
|
@@ -172372,7 +173056,7 @@ async function handleEvents(options) {
|
|
|
172372
173056
|
console.log(`${String(event.sequence ?? "-").padStart(4)} ${event.occurredAt ?? "-"} ${event.eventType ?? "-"}`);
|
|
172373
173057
|
}
|
|
172374
173058
|
if (!result.events.length) {
|
|
172375
|
-
console.log(
|
|
173059
|
+
console.log(chalk69.dim("No remote runner events found."));
|
|
172376
173060
|
}
|
|
172377
173061
|
}
|
|
172378
173062
|
async function handleStop(options) {
|
|
@@ -172471,7 +173155,7 @@ async function handleAttachToken(options) {
|
|
|
172471
173155
|
printJson(minted);
|
|
172472
173156
|
return;
|
|
172473
173157
|
}
|
|
172474
|
-
console.log(
|
|
173158
|
+
console.log(chalk69.bold(`Attach token for ${sessionId}`));
|
|
172475
173159
|
console.log(` gateway: ${minted.gatewayBaseUrl}`);
|
|
172476
173160
|
console.log(` token: ${minted.token.id}`);
|
|
172477
173161
|
console.log(` secret: ${minted.tokenSecret}`);
|
|
@@ -172488,7 +173172,7 @@ async function handleRevokeToken(options) {
|
|
|
172488
173172
|
printJson(result);
|
|
172489
173173
|
return;
|
|
172490
173174
|
}
|
|
172491
|
-
console.log(
|
|
173175
|
+
console.log(chalk69.bold(`Revoked attach token ${result.token.id}`));
|
|
172492
173176
|
}
|
|
172493
173177
|
async function handleTarget(options) {
|
|
172494
173178
|
const sessionId = options.positionals[0];
|
|
@@ -172552,7 +173236,7 @@ async function handleRemoteCommand(subcommand, args = []) {
|
|
|
172552
173236
|
}
|
|
172553
173237
|
} catch (error) {
|
|
172554
173238
|
const message = error instanceof Error ? error.message : String(error);
|
|
172555
|
-
console.error(
|
|
173239
|
+
console.error(chalk69.red(message));
|
|
172556
173240
|
process.exitCode = 1;
|
|
172557
173241
|
}
|
|
172558
173242
|
}
|
|
@@ -172604,24 +173288,24 @@ async function handleAnthropicCommand(subcommand, params = []) {
|
|
|
172604
173288
|
await handleStatus6();
|
|
172605
173289
|
return;
|
|
172606
173290
|
default:
|
|
172607
|
-
console.error(
|
|
173291
|
+
console.error(chalk70.red('Unknown anthropic subcommand. Try "maestro anthropic login", "logout", or "status".'));
|
|
172608
173292
|
process.exit(1);
|
|
172609
173293
|
}
|
|
172610
173294
|
}
|
|
172611
173295
|
async function handleLogin5(mode) {
|
|
172612
|
-
console.log(
|
|
173296
|
+
console.log(chalk70.bold("Maestro Claude Code login"));
|
|
172613
173297
|
const { url, verifier } = await generateAnthropicLoginUrl(mode);
|
|
172614
|
-
console.log(
|
|
173298
|
+
console.log(chalk70.gray(url));
|
|
172615
173299
|
const rl = createInterface4({ input: stdin, output: stdout });
|
|
172616
173300
|
const code = (await rl.question("2. Paste the code shown in the browser: "))?.trim();
|
|
172617
173301
|
rl.close();
|
|
172618
173302
|
if (!code) {
|
|
172619
|
-
console.error(
|
|
173303
|
+
console.error(chalk70.red("Authorization code is required."));
|
|
172620
173304
|
process.exit(1);
|
|
172621
173305
|
}
|
|
172622
173306
|
const tokens = await exchangeAnthropicAuthorizationCode(code, verifier);
|
|
172623
173307
|
if (!tokens) {
|
|
172624
|
-
console.error(
|
|
173308
|
+
console.error(chalk70.red("Failed to exchange the authorization code. Please try again."));
|
|
172625
173309
|
process.exit(1);
|
|
172626
173310
|
}
|
|
172627
173311
|
await saveAnthropicOAuthCredential({
|
|
@@ -172630,27 +173314,27 @@ async function handleLogin5(mode) {
|
|
|
172630
173314
|
expiresAt: tokens.expiresAt,
|
|
172631
173315
|
mode
|
|
172632
173316
|
});
|
|
172633
|
-
console.log(
|
|
172634
|
-
console.log(
|
|
173317
|
+
console.log(chalk70.green("Claude Code credentials saved."));
|
|
173318
|
+
console.log(chalk70.dim("Future runs can use --auth claude or set it as default. Credentials refresh automatically."));
|
|
172635
173319
|
}
|
|
172636
173320
|
async function handleLogout4() {
|
|
172637
173321
|
await deleteAnthropicOAuthCredential();
|
|
172638
|
-
console.log(
|
|
173322
|
+
console.log(chalk70.green("Removed stored Claude Code credentials."));
|
|
172639
173323
|
}
|
|
172640
173324
|
async function handleStatus6() {
|
|
172641
173325
|
const stored = await getStoredAnthropicOAuthCredential();
|
|
172642
173326
|
if (!stored) {
|
|
172643
|
-
console.log(
|
|
172644
|
-
console.log(
|
|
173327
|
+
console.log(chalk70.yellow("No stored Claude Code credentials."));
|
|
173328
|
+
console.log(chalk70.dim('Run "maestro anthropic login" to link a Claude Pro/Max subscription.'));
|
|
172645
173329
|
return;
|
|
172646
173330
|
}
|
|
172647
173331
|
const remainingMs = Math.max(0, stored.expiresAt - Date.now());
|
|
172648
173332
|
const minutes = Math.round(remainingMs / 6e4);
|
|
172649
|
-
console.log(
|
|
172650
|
-
console.log(
|
|
173333
|
+
console.log(chalk70.green("Stored Claude Code credentials detected."));
|
|
173334
|
+
console.log(chalk70.dim(`Access token expires in ~${minutes} minute${minutes === 1 ? "" : "s"} (auto-refresh enabled).`));
|
|
172651
173335
|
const fresh = await getFreshAnthropicOAuthCredential();
|
|
172652
173336
|
if (fresh) {
|
|
172653
|
-
console.log(
|
|
173337
|
+
console.log(chalk70.dim(`Beta headers applied: ${CLAUDE_CODE_BETA_HEADER}`));
|
|
172654
173338
|
}
|
|
172655
173339
|
}
|
|
172656
173340
|
var init_anthropic3 = __esm2(() => {
|
|
@@ -172718,7 +173402,7 @@ async function handleCostSummary(period) {
|
|
|
172718
173402
|
badge("tok", formatTokens(data.tokens), "info"),
|
|
172719
173403
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn")
|
|
172720
173404
|
];
|
|
172721
|
-
console.log(` ${
|
|
173405
|
+
console.log(` ${chalk71.cyan(provider.padEnd(16))} ${metrics.join(separator())}`);
|
|
172722
173406
|
}
|
|
172723
173407
|
console.log();
|
|
172724
173408
|
}
|
|
@@ -172730,7 +173414,7 @@ async function handleCostSummary(period) {
|
|
|
172730
173414
|
badge("req", data.requests.toString(), "info"),
|
|
172731
173415
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn")
|
|
172732
173416
|
];
|
|
172733
|
-
console.log(` ${
|
|
173417
|
+
console.log(` ${chalk71.dim(model.padEnd(32))} ${detail.join(separator())}`);
|
|
172734
173418
|
}
|
|
172735
173419
|
if (Object.keys(summary2.byModel).length > 10) {
|
|
172736
173420
|
console.log(muted(` ... and ${Object.keys(summary2.byModel).length - 10} more models`));
|
|
@@ -172745,7 +173429,7 @@ async function handleCostClear() {
|
|
|
172745
173429
|
input: process.stdin,
|
|
172746
173430
|
output: process.stdout
|
|
172747
173431
|
});
|
|
172748
|
-
const confirm = await rl.question(
|
|
173432
|
+
const confirm = await rl.question(chalk71.yellow("Are you sure you want to clear all usage data? (y/N): "));
|
|
172749
173433
|
rl.close();
|
|
172750
173434
|
if (confirm.toLowerCase() === "y") {
|
|
172751
173435
|
clearUsage();
|
|
@@ -172776,7 +173460,7 @@ async function handleCostBreakdown() {
|
|
|
172776
173460
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn"),
|
|
172777
173461
|
contextualBadge("share", share, { warn: 30, danger: 50 })
|
|
172778
173462
|
];
|
|
172779
|
-
console.log(` ${
|
|
173463
|
+
console.log(` ${chalk71.cyan(provider.padEnd(16))} ${metrics.join(separator())}`);
|
|
172780
173464
|
}
|
|
172781
173465
|
console.log();
|
|
172782
173466
|
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 +173568,7 @@ function renderProviderBreakdown(byProvider) {
|
|
|
172884
173568
|
badge("tok", formatTokens2(data.tokens), "info"),
|
|
172885
173569
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn")
|
|
172886
173570
|
];
|
|
172887
|
-
console.log(` ${
|
|
173571
|
+
console.log(` ${chalk72.cyan(provider.padEnd(16))} ${metrics.join(separator())}`);
|
|
172888
173572
|
}
|
|
172889
173573
|
console.log();
|
|
172890
173574
|
}
|
|
@@ -172899,7 +173583,7 @@ function renderModelBreakdown(byModel) {
|
|
|
172899
173583
|
badge("tok", formatTokens2(data.tokens), "info"),
|
|
172900
173584
|
badge("cost", `$${data.cost.toFixed(4)}`, "warn")
|
|
172901
173585
|
];
|
|
172902
|
-
console.log(` ${
|
|
173586
|
+
console.log(` ${chalk72.dim(model.padEnd(32))} ${metrics.join(separator())}`);
|
|
172903
173587
|
}
|
|
172904
173588
|
console.log();
|
|
172905
173589
|
}
|
|
@@ -172914,7 +173598,7 @@ function renderSessionBreakdown(entries) {
|
|
|
172914
173598
|
badge("tok", formatTokens2(session.tokens), "info"),
|
|
172915
173599
|
badge("cost", `$${session.cost.toFixed(4)}`, "warn")
|
|
172916
173600
|
];
|
|
172917
|
-
console.log(` ${
|
|
173601
|
+
console.log(` ${chalk72.dim(session.sessionId.padEnd(32))} ${metrics.join(separator())}`);
|
|
172918
173602
|
}
|
|
172919
173603
|
console.log();
|
|
172920
173604
|
}
|
|
@@ -172971,7 +173655,7 @@ function formatSource(model) {
|
|
|
172971
173655
|
}
|
|
172972
173656
|
function printModelEntry(model) {
|
|
172973
173657
|
const localBadge = model.isLocal ? ` ${badge("local", void 0, "warn")}` : "";
|
|
172974
|
-
console.log(` \u2022 ${
|
|
173658
|
+
console.log(` \u2022 ${chalk73.bold(model.id)} ${separator()} ${muted(model.name)}`);
|
|
172975
173659
|
console.log(` ${formatReasoning(model)}${separator()}${badge("context", model.contextWindow.toLocaleString())}${separator()}${badge("max", model.maxTokens.toLocaleString())}${separator()}${formatSource(model)}${localBadge}`);
|
|
172976
173660
|
console.log(muted(` ${model.baseUrl}`));
|
|
172977
173661
|
}
|
|
@@ -172984,7 +173668,7 @@ function filterModels(providerFilter) {
|
|
|
172984
173668
|
}
|
|
172985
173669
|
function printEmptyState(providerFilter) {
|
|
172986
173670
|
if (providerFilter) {
|
|
172987
|
-
console.error(
|
|
173671
|
+
console.error(chalk73.red(`No models registered for provider "${providerFilter}".`));
|
|
172988
173672
|
} else {
|
|
172989
173673
|
console.log(badge("No models registered", void 0, "warn"));
|
|
172990
173674
|
}
|
|
@@ -173017,7 +173701,7 @@ async function handleModelsList(providerFilter) {
|
|
|
173017
173701
|
continue;
|
|
173018
173702
|
entries.sort((a, b) => a.id.localeCompare(b.id));
|
|
173019
173703
|
const providerLabel = entries[0]?.providerName ?? provider;
|
|
173020
|
-
console.log(`${
|
|
173704
|
+
console.log(`${chalk73.cyan(provider)} ${separator()} ${badge("models", String(entries.length))}`);
|
|
173021
173705
|
console.log(muted(` ${providerLabel}`));
|
|
173022
173706
|
for (const model of entries) {
|
|
173023
173707
|
printModelEntry(model);
|
|
@@ -173076,7 +173760,7 @@ async function handleModelsProviders(providerFilter) {
|
|
|
173076
173760
|
if (entry2.custom > 0)
|
|
173077
173761
|
sourceSummary.push(`${entry2.custom} custom`);
|
|
173078
173762
|
const localLabel = entry2.localCount ? `${entry2.localCount} local endpoint${entry2.localCount === 1 ? "" : "s"}` : "no local endpoints";
|
|
173079
|
-
console.log(`${
|
|
173763
|
+
console.log(`${chalk73.cyan(provider)} ${separator()} ${badge("models", String(entry2.total))}`);
|
|
173080
173764
|
console.log(muted(` ${entry2.name} (${sourceSummary.join(", ") || "0 models"})`));
|
|
173081
173765
|
console.log(muted(` ${localLabel}`));
|
|
173082
173766
|
const envLabel = envVars.length ? envVars.join(", ") : "(custom or not configured)";
|
|
@@ -173116,7 +173800,7 @@ async function resolveModelFromArgs(params) {
|
|
|
173116
173800
|
if (maybeProvider && maybeModelId && !maybeProvider.includes(".")) {
|
|
173117
173801
|
provider = maybeProvider;
|
|
173118
173802
|
modelId = maybeModelId;
|
|
173119
|
-
console.log(
|
|
173803
|
+
console.log(chalk74.dim(`Parsed model: ${parsedModel} \u2192 ${provider}/${modelId}`));
|
|
173120
173804
|
}
|
|
173121
173805
|
}
|
|
173122
173806
|
if (modelId && !provider) {
|
|
@@ -173124,14 +173808,14 @@ async function resolveModelFromArgs(params) {
|
|
|
173124
173808
|
if (resolved) {
|
|
173125
173809
|
provider = resolved.provider;
|
|
173126
173810
|
modelId = resolved.modelId;
|
|
173127
|
-
console.log(
|
|
173811
|
+
console.log(chalk74.dim(`Using alias: ${parsedModel} \u2192 ${provider}/${modelId}`));
|
|
173128
173812
|
}
|
|
173129
173813
|
}
|
|
173130
173814
|
if (modelId && !provider) {
|
|
173131
173815
|
const foundModel = findModelById(modelId);
|
|
173132
173816
|
if (foundModel) {
|
|
173133
173817
|
provider = foundModel.provider;
|
|
173134
|
-
console.log(
|
|
173818
|
+
console.log(chalk74.dim(`Found model: ${modelId} (provider: ${provider})`));
|
|
173135
173819
|
}
|
|
173136
173820
|
}
|
|
173137
173821
|
if (!provider || !modelId) {
|
|
@@ -174169,7 +174853,7 @@ async function createToolsAndSandbox(params) {
|
|
|
174169
174853
|
throw new Error(`No valid tools matched --tools filter: ${parsedTools.join(", ")}. Available tools: ${Object.keys(toolRegistry).sort().join(", ")}`);
|
|
174170
174854
|
}
|
|
174171
174855
|
baseTools = filteredTools;
|
|
174172
|
-
console.log(
|
|
174856
|
+
console.log(chalk75.dim(`Tools restricted to: ${filteredTools.map((t2) => t2.name).join(", ")}`));
|
|
174173
174857
|
}
|
|
174174
174858
|
const inlineTools = loadInlineTools();
|
|
174175
174859
|
const allTools = [...baseTools, ...inlineTools];
|
|
@@ -174276,12 +174960,12 @@ function createAgentInstance(params) {
|
|
|
174276
174960
|
if (params.readonly) {
|
|
174277
174961
|
const success = composerManager.activate("explore", cwd);
|
|
174278
174962
|
if (!success) {
|
|
174279
|
-
console.warn(
|
|
174963
|
+
console.warn(chalk76.yellow('Warning: Could not activate read-only mode. The "explore" composer may not be available.'));
|
|
174280
174964
|
}
|
|
174281
174965
|
} else if (params.composer) {
|
|
174282
174966
|
const success = composerManager.activate(params.composer, cwd);
|
|
174283
174967
|
if (!success) {
|
|
174284
|
-
console.warn(
|
|
174968
|
+
console.warn(chalk76.yellow(`Warning: Could not activate composer "${params.composer}". Check that it exists.`));
|
|
174285
174969
|
}
|
|
174286
174970
|
}
|
|
174287
174971
|
return { agent };
|
|
@@ -174514,7 +175198,7 @@ async function restoreSessionState(params) {
|
|
|
174514
175198
|
const messages = sessionManager.loadMessages();
|
|
174515
175199
|
if (messages.length > 0) {
|
|
174516
175200
|
if (shouldPrintMessages) {
|
|
174517
|
-
console.log(
|
|
175201
|
+
console.log(chalk77.dim(`Loaded ${messages.length} messages from previous session`));
|
|
174518
175202
|
}
|
|
174519
175203
|
agent.replaceMessages(messages);
|
|
174520
175204
|
}
|
|
@@ -174528,32 +175212,32 @@ async function restoreSessionState(params) {
|
|
|
174528
175212
|
agent.setModel(restoredModel);
|
|
174529
175213
|
}
|
|
174530
175214
|
if (shouldPrintMessages) {
|
|
174531
|
-
console.log(
|
|
175215
|
+
console.log(chalk77.dim(`Restored model: ${savedModel}`));
|
|
174532
175216
|
}
|
|
174533
175217
|
} catch (error) {
|
|
174534
175218
|
if (shouldPrintMessages) {
|
|
174535
175219
|
const message = error instanceof Error ? error.message : String(error);
|
|
174536
|
-
console.error(
|
|
175220
|
+
console.error(chalk77.yellow(`Warning: Could not restore model ${savedModel}: ${message}`));
|
|
174537
175221
|
}
|
|
174538
175222
|
}
|
|
174539
175223
|
} else if (shouldPrintMessages) {
|
|
174540
|
-
console.error(
|
|
175224
|
+
console.error(chalk77.yellow(`Warning: Could not restore model ${savedModel}: unknown provider`));
|
|
174541
175225
|
}
|
|
174542
175226
|
}
|
|
174543
175227
|
const thinkingLevel = sessionManager.loadThinkingLevel();
|
|
174544
175228
|
if (thinkingLevel) {
|
|
174545
175229
|
agent.setThinkingLevel(thinkingLevel);
|
|
174546
175230
|
if (shouldPrintMessages) {
|
|
174547
|
-
console.log(
|
|
175231
|
+
console.log(chalk77.dim(`Restored thinking level: ${thinkingLevel}`));
|
|
174548
175232
|
}
|
|
174549
175233
|
}
|
|
174550
175234
|
}
|
|
174551
175235
|
if (shouldPrintMessages && !isContinueOrResume) {
|
|
174552
175236
|
const contextFiles = loadProjectContextFiles();
|
|
174553
175237
|
if (contextFiles.length > 0) {
|
|
174554
|
-
console.log(
|
|
175238
|
+
console.log(chalk77.dim("Loaded project context from:"));
|
|
174555
175239
|
for (const { path: filePath } of contextFiles) {
|
|
174556
|
-
console.log(
|
|
175240
|
+
console.log(chalk77.dim(` - ${filePath}`));
|
|
174557
175241
|
}
|
|
174558
175242
|
}
|
|
174559
175243
|
}
|
|
@@ -174561,7 +175245,7 @@ async function restoreSessionState(params) {
|
|
|
174561
175245
|
if (models && models.length > 0) {
|
|
174562
175246
|
scopedModels = resolveModelScope(models);
|
|
174563
175247
|
if (scopedModels.length === 0 && shouldPrintMessages) {
|
|
174564
|
-
console.log(
|
|
175248
|
+
console.log(chalk77.yellow(`Warning: --models patterns (${models.join(", ")}) did not match any registered models`));
|
|
174565
175249
|
}
|
|
174566
175250
|
}
|
|
174567
175251
|
let startupChangelogSummary = null;
|
|
@@ -174834,13 +175518,13 @@ function setupEventSubscriptions(params) {
|
|
|
174834
175518
|
const sessions2 = sessionManager.loadAllSessions();
|
|
174835
175519
|
activeCount = sessions2.filter((s2) => Date.now() - s2.modified.getTime() < 60 * 60 * 1e3).length;
|
|
174836
175520
|
} catch (error) {
|
|
174837
|
-
console.error(
|
|
175521
|
+
console.error(chalk78.yellow(`[Policy] Failed to count active sessions: ${error instanceof Error ? error.message : String(error)}`));
|
|
174838
175522
|
}
|
|
174839
175523
|
const limitCheck = checkSessionLimits({ startedAt: /* @__PURE__ */ new Date() }, activeCount !== void 0 ? { activeSessionCount: activeCount + 1 } : void 0);
|
|
174840
175524
|
if (!limitCheck.allowed) {
|
|
174841
175525
|
const msg = `
|
|
174842
175526
|
[Policy] ${limitCheck.reason}`;
|
|
174843
|
-
console.error(
|
|
175527
|
+
console.error(chalk78.red(msg));
|
|
174844
175528
|
process.exit(1);
|
|
174845
175529
|
}
|
|
174846
175530
|
sessionManager.startSession(agent.state);
|
|
@@ -175146,7 +175830,7 @@ async function main(args) {
|
|
|
175146
175830
|
process.exit(0);
|
|
175147
175831
|
}
|
|
175148
175832
|
if (parsed.error) {
|
|
175149
|
-
console.error(
|
|
175833
|
+
console.error(chalk79.red(parsed.error));
|
|
175150
175834
|
process.exit(1);
|
|
175151
175835
|
}
|
|
175152
175836
|
if (parsed.command === "hosted-runner") {
|
|
@@ -175158,7 +175842,7 @@ async function main(args) {
|
|
|
175158
175842
|
}
|
|
175159
175843
|
if (parsed.command === "web") {
|
|
175160
175844
|
if (parsed.messages.length > 0) {
|
|
175161
|
-
console.error(
|
|
175845
|
+
console.error(chalk79.red("`maestro web` does not accept prompt arguments. Use `maestro` (interactive) or `maestro exec` instead."));
|
|
175162
175846
|
process.exit(1);
|
|
175163
175847
|
}
|
|
175164
175848
|
const { startWebServer: startWebServer2 } = await Promise.resolve().then(() => (init_web_server(), exports_web_server));
|
|
@@ -175201,7 +175885,7 @@ async function main(args) {
|
|
|
175201
175885
|
process.stderr.write(`${stack ?? message}
|
|
175202
175886
|
`);
|
|
175203
175887
|
} else {
|
|
175204
|
-
console.error(
|
|
175888
|
+
console.error(chalk79.red(message));
|
|
175205
175889
|
}
|
|
175206
175890
|
process.exit(1);
|
|
175207
175891
|
};
|
|
@@ -175284,7 +175968,7 @@ async function main(args) {
|
|
|
175284
175968
|
startupProfiler.checkpoint("runtime:prepared");
|
|
175285
175969
|
const frameworkWarning = validateFrameworkPreference();
|
|
175286
175970
|
if (frameworkWarning) {
|
|
175287
|
-
console.warn(
|
|
175971
|
+
console.warn(chalk79.yellow(`Framework preference warning: ${frameworkWarning}`));
|
|
175288
175972
|
}
|
|
175289
175973
|
if (parsed.command === "config") {
|
|
175290
175974
|
const {
|
|
@@ -175307,13 +175991,13 @@ async function main(args) {
|
|
|
175307
175991
|
await handleConfigLocal2();
|
|
175308
175992
|
return;
|
|
175309
175993
|
default:
|
|
175310
|
-
console.error(
|
|
175311
|
-
console.log(
|
|
175994
|
+
console.error(chalk79.red(`Unknown config subcommand: ${parsed.subcommand || "(none)"}`));
|
|
175995
|
+
console.log(chalk79.dim(`
|
|
175312
175996
|
Available commands:`));
|
|
175313
|
-
console.log(
|
|
175314
|
-
console.log(
|
|
175315
|
-
console.log(
|
|
175316
|
-
console.log(
|
|
175997
|
+
console.log(chalk79.dim(" maestro config validate - Validate configuration"));
|
|
175998
|
+
console.log(chalk79.dim(" maestro config show - Show configuration details"));
|
|
175999
|
+
console.log(chalk79.dim(" maestro config init - Initialize configuration"));
|
|
176000
|
+
console.log(chalk79.dim(" maestro config local - Manage local providers"));
|
|
175317
176001
|
process.exit(1);
|
|
175318
176002
|
}
|
|
175319
176003
|
}
|
|
@@ -175324,7 +176008,12 @@ Available commands:`));
|
|
|
175324
176008
|
}
|
|
175325
176009
|
if (parsed.command === "evalops") {
|
|
175326
176010
|
const { handleEvalOpsCommand: handleEvalOpsCommand2 } = await Promise.resolve().then(() => (init_evalops2(), exports_evalops));
|
|
175327
|
-
await handleEvalOpsCommand2(parsed.subcommand);
|
|
176011
|
+
await handleEvalOpsCommand2(parsed.subcommand, parsed.commandArgs ?? []);
|
|
176012
|
+
return;
|
|
176013
|
+
}
|
|
176014
|
+
if (parsed.command === "init") {
|
|
176015
|
+
const { handleInitCommand: handleInitCommand3 } = await Promise.resolve().then(() => (init_init(), exports_init));
|
|
176016
|
+
await handleInitCommand3(parsed.commandArgs ?? []);
|
|
175328
176017
|
return;
|
|
175329
176018
|
}
|
|
175330
176019
|
if (parsed.command === "codex") {
|
|
@@ -175382,16 +176071,16 @@ Available commands:`));
|
|
|
175382
176071
|
await handleCostSummary2("today");
|
|
175383
176072
|
return;
|
|
175384
176073
|
default:
|
|
175385
|
-
console.error(
|
|
175386
|
-
console.log(
|
|
176074
|
+
console.error(chalk79.red(`Unknown cost subcommand: ${parsed.subcommand}`));
|
|
176075
|
+
console.log(chalk79.dim(`
|
|
175387
176076
|
Available commands:`));
|
|
175388
|
-
console.log(
|
|
175389
|
-
console.log(
|
|
175390
|
-
console.log(
|
|
175391
|
-
console.log(
|
|
175392
|
-
console.log(
|
|
175393
|
-
console.log(
|
|
175394
|
-
console.log(
|
|
176077
|
+
console.log(chalk79.dim(" maestro cost [today] - Show today's costs (default)"));
|
|
176078
|
+
console.log(chalk79.dim(" maestro cost yesterday - Show yesterday's costs"));
|
|
176079
|
+
console.log(chalk79.dim(" maestro cost week - Show last 7 days"));
|
|
176080
|
+
console.log(chalk79.dim(" maestro cost month - Show last 30 days"));
|
|
176081
|
+
console.log(chalk79.dim(" maestro cost all - Show all time costs"));
|
|
176082
|
+
console.log(chalk79.dim(" maestro cost breakdown - Detailed breakdown"));
|
|
176083
|
+
console.log(chalk79.dim(" maestro cost clear - Clear usage data"));
|
|
175395
176084
|
process.exit(1);
|
|
175396
176085
|
}
|
|
175397
176086
|
}
|
|
@@ -175412,15 +176101,15 @@ Available commands:`));
|
|
|
175412
176101
|
});
|
|
175413
176102
|
return;
|
|
175414
176103
|
default:
|
|
175415
|
-
console.error(
|
|
175416
|
-
console.log(
|
|
176104
|
+
console.error(chalk79.red(`Unknown stats subcommand: ${parsed.subcommand}`));
|
|
176105
|
+
console.log(chalk79.dim(`
|
|
175417
176106
|
Available commands:`));
|
|
175418
|
-
console.log(
|
|
175419
|
-
console.log(
|
|
175420
|
-
console.log(
|
|
175421
|
-
console.log(
|
|
175422
|
-
console.log(
|
|
175423
|
-
console.log(
|
|
176107
|
+
console.log(chalk79.dim(" maestro stats - Show last 7 days"));
|
|
176108
|
+
console.log(chalk79.dim(" maestro stats --session <id> - Show one session"));
|
|
176109
|
+
console.log(chalk79.dim(" maestro stats today - Show today"));
|
|
176110
|
+
console.log(chalk79.dim(" maestro stats month - Show last 30 days"));
|
|
176111
|
+
console.log(chalk79.dim(" maestro stats all - Show all time"));
|
|
176112
|
+
console.log(chalk79.dim(" maestro stats --format json|csv - Export usage data"));
|
|
175424
176113
|
process.exit(1);
|
|
175425
176114
|
}
|
|
175426
176115
|
}
|
|
@@ -175436,11 +176125,11 @@ Available commands:`));
|
|
|
175436
176125
|
await handleModelsList2(providerFilter);
|
|
175437
176126
|
return;
|
|
175438
176127
|
default:
|
|
175439
|
-
console.error(
|
|
175440
|
-
console.log(
|
|
176128
|
+
console.error(chalk79.red(`Unknown models subcommand: ${parsed.subcommand || "(none)"}`));
|
|
176129
|
+
console.log(chalk79.dim(`
|
|
175441
176130
|
Available commands:`));
|
|
175442
|
-
console.log(
|
|
175443
|
-
console.log(
|
|
176131
|
+
console.log(chalk79.dim(" maestro models list - List registered models"));
|
|
176132
|
+
console.log(chalk79.dim(" maestro models providers - Summarize providers"));
|
|
175444
176133
|
process.exit(1);
|
|
175445
176134
|
}
|
|
175446
176135
|
}
|
|
@@ -175449,7 +176138,7 @@ Available commands:`));
|
|
|
175449
176138
|
if (parsed.command === "agents") {
|
|
175450
176139
|
const { buildAgentsInitPrompt: buildAgentsInitPrompt2, handleAgentsInit: handleAgentsInit2 } = await Promise.resolve().then(() => (init_agents(), exports_agents));
|
|
175451
176140
|
if (parsed.subcommand && parsed.subcommand !== "init") {
|
|
175452
|
-
console.error(
|
|
176141
|
+
console.error(chalk79.red(`Unknown agents subcommand: ${parsed.subcommand}. Try "maestro agents init"`));
|
|
175453
176142
|
process.exit(1);
|
|
175454
176143
|
}
|
|
175455
176144
|
try {
|
|
@@ -175462,7 +176151,7 @@ Available commands:`));
|
|
|
175462
176151
|
}
|
|
175463
176152
|
} catch (error) {
|
|
175464
176153
|
const message = error instanceof Error ? error.message : "Failed to initialize AGENTS.md";
|
|
175465
|
-
console.error(
|
|
176154
|
+
console.error(chalk79.red(message));
|
|
175466
176155
|
process.exit(1);
|
|
175467
176156
|
}
|
|
175468
176157
|
}
|
|
@@ -175474,14 +176163,14 @@ Available commands:`));
|
|
|
175474
176163
|
if (parsed.execResumeId) {
|
|
175475
176164
|
targetPath = sessionManager.getSessionFileById(parsed.execResumeId);
|
|
175476
176165
|
if (!targetPath) {
|
|
175477
|
-
console.error(
|
|
176166
|
+
console.error(chalk79.red(`No session found with id ${parsed.execResumeId}.`));
|
|
175478
176167
|
process.exit(1);
|
|
175479
176168
|
}
|
|
175480
176169
|
} else if (parsed.execUseLast) {
|
|
175481
176170
|
const sessions2 = sessionManager.loadAllSessions();
|
|
175482
176171
|
const lastExec = sessions2.find((session) => session.summary?.startsWith(EXEC_SESSION_SUMMARY_PREFIX));
|
|
175483
176172
|
if (!lastExec) {
|
|
175484
|
-
console.error(
|
|
176173
|
+
console.error(chalk79.red("No previous maestro exec sessions were found."));
|
|
175485
176174
|
process.exit(1);
|
|
175486
176175
|
}
|
|
175487
176176
|
targetPath = lastExec.path;
|
|
@@ -175497,7 +176186,7 @@ Available commands:`));
|
|
|
175497
176186
|
if (parsed.resume) {
|
|
175498
176187
|
const selectedSession = await selectSession(sessionManager);
|
|
175499
176188
|
if (!selectedSession) {
|
|
175500
|
-
console.log(
|
|
176189
|
+
console.log(chalk79.dim("No session selected"));
|
|
175501
176190
|
return;
|
|
175502
176191
|
}
|
|
175503
176192
|
sessionManager.setSessionFile(selectedSession);
|
|
@@ -175618,10 +176307,10 @@ Available commands:`));
|
|
|
175618
176307
|
const shouldPrintMessages = (isInteractive || mode === "text") && mode !== "headless" && !parsed.headless;
|
|
175619
176308
|
const isGitRepository = isInsideGitRepository();
|
|
175620
176309
|
if (sandbox && shouldPrintMessages) {
|
|
175621
|
-
console.log(
|
|
176310
|
+
console.log(chalk79.dim(`Sandbox enabled (mode: ${sandboxMode})`));
|
|
175622
176311
|
}
|
|
175623
176312
|
if (approvalModeOverride === "auto" && !isGitRepository && shouldPrintMessages) {
|
|
175624
|
-
console.log(
|
|
176313
|
+
console.log(chalk79.yellow("Auto approval is enabled outside a git repository. Changes will not be version controlled."));
|
|
175625
176314
|
}
|
|
175626
176315
|
const shouldRestoreSession = parsed.continue || parsed.resume || execResumeApplied;
|
|
175627
176316
|
const isFreshInteractiveSession = isInteractive && !shouldRestoreSession && mode !== "rpc";
|
|
@@ -175686,9 +176375,9 @@ Available commands:`));
|
|
|
175686
176375
|
const targetPath = agentsInitPath ?? "AGENTS.md";
|
|
175687
176376
|
const displayPath = targetPath.startsWith(cwd) && targetPath !== cwd ? `.${targetPath.slice(cwd.length)}` : targetPath;
|
|
175688
176377
|
const runMode = mode === "rpc" || mode === "headless" ? "text" : mode;
|
|
175689
|
-
console.log(
|
|
176378
|
+
console.log(chalk79.green(`Drafting AGENTS.md at ${displayPath}...`));
|
|
175690
176379
|
await runSingleShotMode(agent, sessionManager, [agentsInitPrompt], runMode);
|
|
175691
|
-
console.log(
|
|
176380
|
+
console.log(chalk79.dim(`AGENTS.md generated at ${displayPath}`));
|
|
175692
176381
|
} else if (mode === "headless" || parsed.headless) {
|
|
175693
176382
|
startupProfiler.terminal("headless:ready");
|
|
175694
176383
|
await runHeadlessMode(agent, sessionManager, approvalService, toolRetryService);
|