@evalops/maestro 0.10.46 → 0.10.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/providers/openai-codex-session.js +1 -1
- package/dist/agent/providers/openai-codex-session.js.map +1 -1
- package/dist/app-server/in-process-client.d.ts +2 -2
- package/dist/app-server/in-process-client.js.map +1 -1
- package/dist/app-server/protocol-modes-api.js +1 -1
- package/dist/app-server/protocol-modes-api.js.map +1 -1
- package/dist/app-server/sandbox-check-api.d.ts +21 -0
- package/dist/app-server/{sandbox-proof-api.d.ts.map → sandbox-check-api.d.ts.map} +1 -1
- package/dist/app-server/{sandbox-proof-api.js → sandbox-check-api.js} +18 -18
- package/dist/app-server/{sandbox-proof-api.js.map → sandbox-check-api.js.map} +1 -1
- package/dist/app-server/session-api.d.ts +5 -5
- package/dist/app-server/session-api.js +18 -18
- package/dist/app-server/session-api.js.map +1 -1
- package/dist/audit/logger.d.ts +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands/codex.js +30 -3
- package/dist/cli/commands/codex.js.map +1 -1
- package/dist/cli-tui/auth-state.d.ts +7 -0
- package/dist/cli-tui/auth-state.d.ts.map +1 -0
- package/dist/cli-tui/auth-state.js +46 -0
- package/dist/cli-tui/auth-state.js.map +1 -0
- package/dist/cli-tui/commands/command-catalog.d.ts.map +1 -1
- package/dist/cli-tui/commands/command-catalog.js +6 -1
- package/dist/cli-tui/commands/command-catalog.js.map +1 -1
- package/dist/cli-tui/commands/command-suite-handlers.d.ts +2 -5
- package/dist/cli-tui/commands/command-suite-handlers.d.ts.map +1 -1
- package/dist/cli-tui/commands/command-suite-handlers.js.map +1 -1
- package/dist/cli-tui/commands/subcommands/auth-commands.d.ts +6 -5
- package/dist/cli-tui/commands/subcommands/auth-commands.d.ts.map +1 -1
- package/dist/cli-tui/commands/subcommands/auth-commands.js +2 -2
- package/dist/cli-tui/commands/subcommands/auth-commands.js.map +1 -1
- package/dist/cli-tui/oauth/oauth-flow-controller.d.ts.map +1 -1
- package/dist/cli-tui/oauth/oauth-flow-controller.js +24 -11
- package/dist/cli-tui/oauth/oauth-flow-controller.js.map +1 -1
- package/dist/cli-tui/selectors/oauth-selector-view.d.ts +1 -0
- package/dist/cli-tui/selectors/oauth-selector-view.d.ts.map +1 -1
- package/dist/cli-tui/selectors/oauth-selector-view.js +1 -1
- package/dist/cli-tui/selectors/oauth-selector-view.js.map +1 -1
- package/dist/cli-tui/selectors/oauth-selector.d.ts +2 -1
- package/dist/cli-tui/selectors/oauth-selector.d.ts.map +1 -1
- package/dist/cli-tui/selectors/oauth-selector.js +25 -2
- package/dist/cli-tui/selectors/oauth-selector.js.map +1 -1
- package/dist/cli-tui/tui-renderer/command-suite-wiring.d.ts +2 -5
- package/dist/cli-tui/tui-renderer/command-suite-wiring.d.ts.map +1 -1
- package/dist/cli-tui/tui-renderer/command-suite-wiring.js.map +1 -1
- package/dist/cli-tui/tui-renderer.d.ts +0 -4
- package/dist/cli-tui/tui-renderer.d.ts.map +1 -1
- package/dist/cli-tui/tui-renderer.js +3 -28
- package/dist/cli-tui/tui-renderer.js.map +1 -1
- package/dist/cli.js +896 -497
- package/dist/codex/app-server-client.d.ts +8 -2
- package/dist/codex/app-server-client.d.ts.map +1 -1
- package/dist/codex/app-server-client.js +18 -4
- package/dist/codex/app-server-client.js.map +1 -1
- package/dist/codex/auth.d.ts +4 -0
- package/dist/codex/auth.d.ts.map +1 -0
- package/dist/codex/auth.js +103 -0
- package/dist/codex/auth.js.map +1 -0
- package/dist/db/schema.d.ts +1 -1
- package/dist/evalops/agent-bootstrap.js +2 -2
- package/dist/evalops/agent-bootstrap.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -1
- package/dist/main.js.map +1 -1
- package/dist/models/config-loader.d.ts +5 -5
- package/dist/node_modules/@evalops/contracts/dist/maestro-app-server.d.ts +19 -19
- package/dist/node_modules/@evalops/contracts/dist/maestro-app-server.d.ts.map +1 -1
- package/dist/node_modules/@evalops/contracts/dist/maestro-app-server.js +12 -13
- package/dist/node_modules/@evalops/contracts/dist/maestro-app-server.js.map +1 -1
- package/dist/node_modules/@evalops/contracts/package.json +1 -1
- package/dist/node_modules/@evalops/tui/package.json +1 -1
- package/dist/oauth/index.d.ts +1 -0
- package/dist/oauth/index.d.ts.map +1 -1
- package/dist/oauth/index.js +42 -2
- package/dist/oauth/index.js.map +1 -1
- package/dist/server/app-context.d.ts +2 -0
- package/dist/server/app-context.d.ts.map +1 -1
- package/dist/server/app-context.js.map +1 -1
- package/dist/server/handlers/headless-sessions.d.ts.map +1 -1
- package/dist/server/handlers/headless-sessions.js +44 -10
- package/dist/server/handlers/headless-sessions.js.map +1 -1
- package/dist/server/handlers/hosted-runner-identity.d.ts +2 -0
- package/dist/server/handlers/hosted-runner-identity.d.ts.map +1 -1
- package/dist/server/handlers/hosted-runner-identity.js +2 -0
- package/dist/server/handlers/hosted-runner-identity.js.map +1 -1
- package/dist/server/handlers/platform-a2a-push.d.ts.map +1 -1
- package/dist/server/handlers/platform-a2a-push.js +113 -2
- package/dist/server/handlers/platform-a2a-push.js.map +1 -1
- package/dist/server/headless-in-process-host.d.ts.map +1 -1
- package/dist/server/headless-in-process-host.js +1 -1
- package/dist/server/headless-in-process-host.js.map +1 -1
- package/dist/server/headless-runtime-service.d.ts +9 -2
- package/dist/server/headless-runtime-service.d.ts.map +1 -1
- package/dist/server/headless-runtime-service.js +54 -15
- package/dist/server/headless-runtime-service.js.map +1 -1
- package/dist/tools/background/task-runtime.js +1 -1
- package/dist/tools/background/task-runtime.js.map +1 -1
- package/dist/version.json +2 -2
- package/package.json +1 -1
- package/dist/app-server/sandbox-proof-api.d.ts +0 -21
package/dist/cli.js
CHANGED
|
@@ -18551,6 +18551,8 @@ import { join as join2, resolve } from "node:path";
|
|
|
18551
18551
|
import { join as join3, resolve as resolve2 } from "node:path";
|
|
18552
18552
|
import { appendFileSync, mkdirSync } from "node:fs";
|
|
18553
18553
|
import { dirname, join as join4 } from "node:path";
|
|
18554
|
+
import { spawn as spawnChild } from "node:child_process";
|
|
18555
|
+
import { createInterface } from "node:readline";
|
|
18554
18556
|
import { readFileSync, statSync as statSync2 } from "node:fs";
|
|
18555
18557
|
import {
|
|
18556
18558
|
chmodSync,
|
|
@@ -18713,8 +18715,6 @@ import { parse as partialParse } from "partial-json";
|
|
|
18713
18715
|
import OpenAI from "openai";
|
|
18714
18716
|
import crypto2 from "node:crypto";
|
|
18715
18717
|
import { arch, platform, release } from "node:os";
|
|
18716
|
-
import { spawn as spawnChild } from "node:child_process";
|
|
18717
|
-
import { createInterface } from "node:readline";
|
|
18718
18718
|
|
|
18719
18719
|
// node_modules/@google/genai/dist/node/index.mjs
|
|
18720
18720
|
var import_p_retry = __toESM(require_p_retry(), 1);
|
|
@@ -38863,6 +38863,445 @@ var init_downstream_http = __esm2(() => {
|
|
|
38863
38863
|
}
|
|
38864
38864
|
};
|
|
38865
38865
|
});
|
|
38866
|
+
var CodexAppServerRpcClient = class _CodexAppServerRpcClient {
|
|
38867
|
+
transport;
|
|
38868
|
+
options;
|
|
38869
|
+
pending = /* @__PURE__ */ new Map();
|
|
38870
|
+
notificationListeners = /* @__PURE__ */ new Set();
|
|
38871
|
+
notificationHistory = [];
|
|
38872
|
+
notificationWaiters = /* @__PURE__ */ new Set();
|
|
38873
|
+
requestHandlers = /* @__PURE__ */ new Set();
|
|
38874
|
+
stderrTail = [];
|
|
38875
|
+
rl;
|
|
38876
|
+
nextId = 1;
|
|
38877
|
+
closed = false;
|
|
38878
|
+
constructor(transport, options = {}) {
|
|
38879
|
+
this.transport = transport;
|
|
38880
|
+
this.options = options;
|
|
38881
|
+
this.rl = createInterface({ input: transport.stdout });
|
|
38882
|
+
this.rl.on("line", (line) => this.handleLine(line));
|
|
38883
|
+
this.rl.on("close", () => this.rejectAll("Codex app-server closed stdout"));
|
|
38884
|
+
transport.stderr?.on("data", (chunk) => this.captureStderr(chunk));
|
|
38885
|
+
transport.once?.("exit", (code, signal) => {
|
|
38886
|
+
const suffix = code === null || code === void 0 ? `signal ${String(signal)}` : `code ${String(code)}`;
|
|
38887
|
+
this.rejectAll(`Codex app-server exited with ${suffix}`);
|
|
38888
|
+
});
|
|
38889
|
+
transport.once?.("error", (error) => {
|
|
38890
|
+
const message = error instanceof Error ? error.message : `Process error: ${String(error)}`;
|
|
38891
|
+
this.rejectAll(message);
|
|
38892
|
+
});
|
|
38893
|
+
}
|
|
38894
|
+
static spawn(options = {}) {
|
|
38895
|
+
const command = options.command ?? "codex";
|
|
38896
|
+
const args = options.args ?? ["app-server", "--listen", "stdio://"];
|
|
38897
|
+
const child = spawnChild(command, args, {
|
|
38898
|
+
cwd: options.cwd,
|
|
38899
|
+
env: options.env ?? process.env,
|
|
38900
|
+
stdio: "pipe"
|
|
38901
|
+
});
|
|
38902
|
+
return new _CodexAppServerRpcClient(child, {
|
|
38903
|
+
requestTimeoutMs: options.requestTimeoutMs
|
|
38904
|
+
});
|
|
38905
|
+
}
|
|
38906
|
+
async initialize(options = {}) {
|
|
38907
|
+
const capabilities = options.experimentalApi || options.optOutNotificationMethods?.length ? {
|
|
38908
|
+
experimentalApi: options.experimentalApi || void 0,
|
|
38909
|
+
optOutNotificationMethods: options.optOutNotificationMethods ?? void 0
|
|
38910
|
+
} : void 0;
|
|
38911
|
+
const result2 = await this.request("initialize", {
|
|
38912
|
+
clientInfo: options.clientInfo ?? DEFAULT_CLIENT_INFO,
|
|
38913
|
+
capabilities
|
|
38914
|
+
}, { timeoutMs: options.timeoutMs });
|
|
38915
|
+
this.notify("initialized");
|
|
38916
|
+
return result2;
|
|
38917
|
+
}
|
|
38918
|
+
request(method, params, options = {}) {
|
|
38919
|
+
if (this.closed) {
|
|
38920
|
+
return Promise.reject(new Error("Codex app-server client is closed"));
|
|
38921
|
+
}
|
|
38922
|
+
const id = this.nextId++;
|
|
38923
|
+
const timeoutMs = options.timeoutMs ?? this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
38924
|
+
return new Promise((resolve310, reject) => {
|
|
38925
|
+
const timer = setTimeout(() => {
|
|
38926
|
+
this.pending.delete(id);
|
|
38927
|
+
reject(new Error(`Codex app-server request timed out: ${method}`));
|
|
38928
|
+
}, timeoutMs);
|
|
38929
|
+
this.pending.set(id, {
|
|
38930
|
+
resolve: (value) => resolve310(value),
|
|
38931
|
+
reject,
|
|
38932
|
+
timer
|
|
38933
|
+
});
|
|
38934
|
+
try {
|
|
38935
|
+
this.writeMessage({ id, method, params });
|
|
38936
|
+
} catch (error) {
|
|
38937
|
+
clearTimeout(timer);
|
|
38938
|
+
this.pending.delete(id);
|
|
38939
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
38940
|
+
}
|
|
38941
|
+
});
|
|
38942
|
+
}
|
|
38943
|
+
notify(method, params) {
|
|
38944
|
+
this.writeMessage({ method, params });
|
|
38945
|
+
}
|
|
38946
|
+
onNotification(listener) {
|
|
38947
|
+
this.notificationListeners.add(listener);
|
|
38948
|
+
return () => {
|
|
38949
|
+
this.notificationListeners.delete(listener);
|
|
38950
|
+
};
|
|
38951
|
+
}
|
|
38952
|
+
onRequest(listener) {
|
|
38953
|
+
this.requestHandlers.add(listener);
|
|
38954
|
+
return () => {
|
|
38955
|
+
this.requestHandlers.delete(listener);
|
|
38956
|
+
};
|
|
38957
|
+
}
|
|
38958
|
+
waitForNotification(predicate, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS) {
|
|
38959
|
+
const buffered = this.notificationHistory.find(predicate);
|
|
38960
|
+
if (buffered) {
|
|
38961
|
+
return Promise.resolve(buffered);
|
|
38962
|
+
}
|
|
38963
|
+
if (this.closed) {
|
|
38964
|
+
return Promise.reject(new Error("Codex app-server client is closed"));
|
|
38965
|
+
}
|
|
38966
|
+
return new Promise((resolve310, reject) => {
|
|
38967
|
+
let unsubscribe = () => {
|
|
38968
|
+
};
|
|
38969
|
+
const waiter = {
|
|
38970
|
+
reject: (error) => {
|
|
38971
|
+
clearTimeout(waiter.timer);
|
|
38972
|
+
unsubscribe();
|
|
38973
|
+
this.notificationWaiters.delete(waiter);
|
|
38974
|
+
reject(error);
|
|
38975
|
+
},
|
|
38976
|
+
timer: setTimeout(() => {
|
|
38977
|
+
waiter.reject(new Error("Timed out waiting for Codex app-server notification"));
|
|
38978
|
+
}, timeoutMs),
|
|
38979
|
+
unsubscribe: () => unsubscribe()
|
|
38980
|
+
};
|
|
38981
|
+
unsubscribe = this.onNotification((notification) => {
|
|
38982
|
+
if (!predicate(notification)) {
|
|
38983
|
+
return;
|
|
38984
|
+
}
|
|
38985
|
+
clearTimeout(waiter.timer);
|
|
38986
|
+
waiter.unsubscribe();
|
|
38987
|
+
this.notificationWaiters.delete(waiter);
|
|
38988
|
+
resolve310(notification);
|
|
38989
|
+
});
|
|
38990
|
+
this.notificationWaiters.add(waiter);
|
|
38991
|
+
});
|
|
38992
|
+
}
|
|
38993
|
+
readAccount(refreshToken2 = false) {
|
|
38994
|
+
return this.request("account/read", { refreshToken: refreshToken2 });
|
|
38995
|
+
}
|
|
38996
|
+
startChatGptLogin(flow = "browser", options = {}) {
|
|
38997
|
+
const params = flow === "device" ? { type: "chatgptDeviceCode" } : {
|
|
38998
|
+
type: "chatgpt",
|
|
38999
|
+
codexStreamlinedLogin: options.codexStreamlinedLogin || void 0
|
|
39000
|
+
};
|
|
39001
|
+
return this.request("account/login/start", params);
|
|
39002
|
+
}
|
|
39003
|
+
async waitForLoginCompletion(loginId, timeoutMs = DEFAULT_LOGIN_TIMEOUT_MS) {
|
|
39004
|
+
const notification = await this.waitForNotification((candidate) => candidate.method === "account/login/completed" && isRecord(candidate.params) && candidate.params.loginId === loginId, timeoutMs);
|
|
39005
|
+
const params = notification.params;
|
|
39006
|
+
if (!params?.success) {
|
|
39007
|
+
throw new Error(params?.error || "ChatGPT sign-in did not complete");
|
|
39008
|
+
}
|
|
39009
|
+
return params;
|
|
39010
|
+
}
|
|
39011
|
+
async logout() {
|
|
39012
|
+
await this.request("account/logout", void 0);
|
|
39013
|
+
}
|
|
39014
|
+
close() {
|
|
39015
|
+
if (this.closed) {
|
|
39016
|
+
return;
|
|
39017
|
+
}
|
|
39018
|
+
this.closed = true;
|
|
39019
|
+
this.rejectAll("Codex app-server client closed");
|
|
39020
|
+
this.rl.close();
|
|
39021
|
+
try {
|
|
39022
|
+
this.transport.stdin.end();
|
|
39023
|
+
} catch {
|
|
39024
|
+
}
|
|
39025
|
+
this.transport.kill?.("SIGTERM");
|
|
39026
|
+
}
|
|
39027
|
+
handleLine(line) {
|
|
39028
|
+
const trimmed = line.trim();
|
|
39029
|
+
if (!trimmed) {
|
|
39030
|
+
return;
|
|
39031
|
+
}
|
|
39032
|
+
let message;
|
|
39033
|
+
try {
|
|
39034
|
+
message = JSON.parse(trimmed);
|
|
39035
|
+
} catch {
|
|
39036
|
+
return;
|
|
39037
|
+
}
|
|
39038
|
+
if (!isRecord(message)) {
|
|
39039
|
+
return;
|
|
39040
|
+
}
|
|
39041
|
+
if ("id" in message && ("result" in message || "error" in message)) {
|
|
39042
|
+
this.handleResponse(message);
|
|
39043
|
+
return;
|
|
39044
|
+
}
|
|
39045
|
+
if (typeof message.method === "string" && "id" in message) {
|
|
39046
|
+
this.handleServerRequest(message);
|
|
39047
|
+
return;
|
|
39048
|
+
}
|
|
39049
|
+
if (typeof message.method === "string") {
|
|
39050
|
+
this.emitNotification({
|
|
39051
|
+
method: message.method,
|
|
39052
|
+
params: message.params
|
|
39053
|
+
});
|
|
39054
|
+
}
|
|
39055
|
+
}
|
|
39056
|
+
handleResponse(response) {
|
|
39057
|
+
if (response.id === void 0) {
|
|
39058
|
+
return;
|
|
39059
|
+
}
|
|
39060
|
+
const pending = this.pending.get(response.id);
|
|
39061
|
+
if (!pending) {
|
|
39062
|
+
return;
|
|
39063
|
+
}
|
|
39064
|
+
this.pending.delete(response.id);
|
|
39065
|
+
clearTimeout(pending.timer);
|
|
39066
|
+
if (response.error) {
|
|
39067
|
+
const message = response.error.message ?? "Codex app-server request failed";
|
|
39068
|
+
pending.reject(new Error(message));
|
|
39069
|
+
return;
|
|
39070
|
+
}
|
|
39071
|
+
pending.resolve(response.result);
|
|
39072
|
+
}
|
|
39073
|
+
async handleServerRequest(request) {
|
|
39074
|
+
this.emitNotification({
|
|
39075
|
+
method: request.method,
|
|
39076
|
+
params: request.params
|
|
39077
|
+
});
|
|
39078
|
+
if (request.method === "account/chatgptAuthTokens/refresh") {
|
|
39079
|
+
this.writeMessage({
|
|
39080
|
+
id: request.id,
|
|
39081
|
+
error: {
|
|
39082
|
+
code: -32601,
|
|
39083
|
+
message: "Maestro does not manage Codex ChatGPT auth tokens directly. Run `maestro codex login` or `codex login` so Codex app-server owns ChatGPT auth refresh."
|
|
39084
|
+
}
|
|
39085
|
+
});
|
|
39086
|
+
return;
|
|
39087
|
+
}
|
|
39088
|
+
for (const handler of Array.from(this.requestHandlers)) {
|
|
39089
|
+
try {
|
|
39090
|
+
const handled = await handler(request);
|
|
39091
|
+
if (!handled.handled) {
|
|
39092
|
+
continue;
|
|
39093
|
+
}
|
|
39094
|
+
if ("error" in handled) {
|
|
39095
|
+
this.writeMessage({
|
|
39096
|
+
id: request.id,
|
|
39097
|
+
error: {
|
|
39098
|
+
code: handled.error.code ?? -32e3,
|
|
39099
|
+
message: handled.error.message,
|
|
39100
|
+
data: handled.error.data
|
|
39101
|
+
}
|
|
39102
|
+
});
|
|
39103
|
+
return;
|
|
39104
|
+
}
|
|
39105
|
+
this.writeMessage({ id: request.id, result: handled.result });
|
|
39106
|
+
return;
|
|
39107
|
+
} catch (error) {
|
|
39108
|
+
this.writeMessage({
|
|
39109
|
+
id: request.id,
|
|
39110
|
+
error: {
|
|
39111
|
+
code: -32e3,
|
|
39112
|
+
message: error instanceof Error ? error.message : String(error)
|
|
39113
|
+
}
|
|
39114
|
+
});
|
|
39115
|
+
return;
|
|
39116
|
+
}
|
|
39117
|
+
}
|
|
39118
|
+
const fallback = defaultServerRequestResponse(request.method);
|
|
39119
|
+
if (fallback.ok) {
|
|
39120
|
+
this.writeMessage({ id: request.id, result: fallback.result });
|
|
39121
|
+
return;
|
|
39122
|
+
}
|
|
39123
|
+
this.writeMessage({
|
|
39124
|
+
id: request.id,
|
|
39125
|
+
error: {
|
|
39126
|
+
code: -32601,
|
|
39127
|
+
message: `Unsupported Codex app-server request: ${request.method}`
|
|
39128
|
+
}
|
|
39129
|
+
});
|
|
39130
|
+
}
|
|
39131
|
+
emitNotification(notification) {
|
|
39132
|
+
this.notificationHistory.push(notification);
|
|
39133
|
+
if (this.notificationHistory.length > MAX_NOTIFICATION_HISTORY) {
|
|
39134
|
+
this.notificationHistory.shift();
|
|
39135
|
+
}
|
|
39136
|
+
for (const listener of this.notificationListeners) {
|
|
39137
|
+
listener(notification);
|
|
39138
|
+
}
|
|
39139
|
+
}
|
|
39140
|
+
writeMessage(message) {
|
|
39141
|
+
const compact = Object.fromEntries(Object.entries(message).filter(([, value]) => value !== void 0));
|
|
39142
|
+
const line = `${JSON.stringify(compact)}
|
|
39143
|
+
`;
|
|
39144
|
+
if (!this.transport.stdin.write(line)) {
|
|
39145
|
+
}
|
|
39146
|
+
}
|
|
39147
|
+
captureStderr(chunk) {
|
|
39148
|
+
const text2 = Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk);
|
|
39149
|
+
for (const line of text2.split(/\r?\n/)) {
|
|
39150
|
+
const trimmed = line.trim();
|
|
39151
|
+
if (!trimmed) {
|
|
39152
|
+
continue;
|
|
39153
|
+
}
|
|
39154
|
+
this.stderrTail.push(trimmed);
|
|
39155
|
+
if (this.stderrTail.length > 20) {
|
|
39156
|
+
this.stderrTail.shift();
|
|
39157
|
+
}
|
|
39158
|
+
}
|
|
39159
|
+
}
|
|
39160
|
+
rejectAll(message) {
|
|
39161
|
+
this.closed = true;
|
|
39162
|
+
const stderr = this.stderrTail.length ? `
|
|
39163
|
+
${this.stderrTail.slice(-5).join(`
|
|
39164
|
+
`)}` : "";
|
|
39165
|
+
const error = new Error(`${message}${stderr}`);
|
|
39166
|
+
for (const pending of this.pending.values()) {
|
|
39167
|
+
clearTimeout(pending.timer);
|
|
39168
|
+
pending.reject(error);
|
|
39169
|
+
}
|
|
39170
|
+
this.pending.clear();
|
|
39171
|
+
for (const waiter of Array.from(this.notificationWaiters)) {
|
|
39172
|
+
waiter.reject(error);
|
|
39173
|
+
}
|
|
39174
|
+
this.notificationWaiters.clear();
|
|
39175
|
+
}
|
|
39176
|
+
};
|
|
39177
|
+
function createCodexAppServerClient(options = {}) {
|
|
39178
|
+
return CodexAppServerRpcClient.spawn(options);
|
|
39179
|
+
}
|
|
39180
|
+
function isRecord(value) {
|
|
39181
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
39182
|
+
}
|
|
39183
|
+
function defaultServerRequestResponse(method) {
|
|
39184
|
+
switch (method) {
|
|
39185
|
+
case "item/commandExecution/requestApproval":
|
|
39186
|
+
return { ok: true, result: { decision: "decline" } };
|
|
39187
|
+
case "item/fileChange/requestApproval":
|
|
39188
|
+
return { ok: true, result: { decision: "decline" } };
|
|
39189
|
+
case "item/permissions/requestApproval":
|
|
39190
|
+
return { ok: true, result: { permissions: {}, scope: "turn" } };
|
|
39191
|
+
case "item/tool/requestUserInput":
|
|
39192
|
+
return { ok: true, result: { answers: {} } };
|
|
39193
|
+
case "mcpServer/elicitation/request":
|
|
39194
|
+
return {
|
|
39195
|
+
ok: true,
|
|
39196
|
+
result: { action: "decline", content: null, _meta: null }
|
|
39197
|
+
};
|
|
39198
|
+
case "applyPatchApproval":
|
|
39199
|
+
case "execCommandApproval":
|
|
39200
|
+
return { ok: true, result: { decision: "denied" } };
|
|
39201
|
+
default:
|
|
39202
|
+
return { ok: false };
|
|
39203
|
+
}
|
|
39204
|
+
}
|
|
39205
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
39206
|
+
var DEFAULT_LOGIN_TIMEOUT_MS;
|
|
39207
|
+
var MAX_NOTIFICATION_HISTORY = 100;
|
|
39208
|
+
var DEFAULT_CLIENT_INFO;
|
|
39209
|
+
var init_app_server_client = __esm2(() => {
|
|
39210
|
+
init_package_version();
|
|
39211
|
+
DEFAULT_LOGIN_TIMEOUT_MS = 5 * 6e4;
|
|
39212
|
+
DEFAULT_CLIENT_INFO = {
|
|
39213
|
+
name: "maestro",
|
|
39214
|
+
title: "Maestro",
|
|
39215
|
+
version: readPackageVersion()
|
|
39216
|
+
};
|
|
39217
|
+
});
|
|
39218
|
+
function accountLabel(state2) {
|
|
39219
|
+
const account = state2.account;
|
|
39220
|
+
if (!account) {
|
|
39221
|
+
return "missing";
|
|
39222
|
+
}
|
|
39223
|
+
if (account.type === "chatgpt") {
|
|
39224
|
+
const plan = typeof account.planType === "string" && account.planType.length > 0 ? `, ${account.planType}` : "";
|
|
39225
|
+
return `${account.email}${plan}`;
|
|
39226
|
+
}
|
|
39227
|
+
if (account.type === "apiKey") {
|
|
39228
|
+
return "API key";
|
|
39229
|
+
}
|
|
39230
|
+
return account.type;
|
|
39231
|
+
}
|
|
39232
|
+
function isBrowserLogin(value) {
|
|
39233
|
+
return value.type === "chatgpt" && typeof value.loginId === "string" && typeof value.authUrl === "string";
|
|
39234
|
+
}
|
|
39235
|
+
function isDeviceCodeLogin(value) {
|
|
39236
|
+
return value.type === "chatgptDeviceCode" && typeof value.loginId === "string" && typeof value.verificationUrl === "string" && typeof value.userCode === "string";
|
|
39237
|
+
}
|
|
39238
|
+
async function loginOpenAICodexAppServer(onAuthUrl, _onPromptCode, onStatus) {
|
|
39239
|
+
const client = createCodexAppServerClient();
|
|
39240
|
+
try {
|
|
39241
|
+
await client.initialize({ experimentalApi: true });
|
|
39242
|
+
let currentAccount = null;
|
|
39243
|
+
try {
|
|
39244
|
+
currentAccount = await client.readAccount(true);
|
|
39245
|
+
} catch {
|
|
39246
|
+
onStatus?.("Codex app-server account refresh failed; starting sign-in to repair authentication.");
|
|
39247
|
+
}
|
|
39248
|
+
if (currentAccount?.account) {
|
|
39249
|
+
onStatus?.(`Codex app-server is already authenticated: ${accountLabel(currentAccount)}.`);
|
|
39250
|
+
return;
|
|
39251
|
+
}
|
|
39252
|
+
const login2 = await client.startChatGptLogin("browser", {
|
|
39253
|
+
codexStreamlinedLogin: true
|
|
39254
|
+
});
|
|
39255
|
+
if (isBrowserLogin(login2)) {
|
|
39256
|
+
onAuthUrl(login2.authUrl);
|
|
39257
|
+
onStatus?.("Complete Codex ChatGPT sign-in in the browser.");
|
|
39258
|
+
await client.waitForLoginCompletion(login2.loginId);
|
|
39259
|
+
} else if (isDeviceCodeLogin(login2)) {
|
|
39260
|
+
onAuthUrl(login2.verificationUrl);
|
|
39261
|
+
onStatus?.(`Complete Codex device sign-in with code ${login2.userCode}.`);
|
|
39262
|
+
await client.waitForLoginCompletion(login2.loginId);
|
|
39263
|
+
} else if (login2.type === "apiKey") {
|
|
39264
|
+
onStatus?.("Codex app-server is configured with an API key.");
|
|
39265
|
+
return;
|
|
39266
|
+
} else if (login2.type === "chatgptAuthTokens") {
|
|
39267
|
+
onStatus?.("Codex app-server is using externally managed ChatGPT auth.");
|
|
39268
|
+
return;
|
|
39269
|
+
} else {
|
|
39270
|
+
throw new Error(`Unsupported Codex login response: ${login2.type}`);
|
|
39271
|
+
}
|
|
39272
|
+
const account = await client.readAccount(true);
|
|
39273
|
+
if (!account.account) {
|
|
39274
|
+
throw new Error("Codex app-server did not report a signed-in account.");
|
|
39275
|
+
}
|
|
39276
|
+
onStatus?.(`Codex ChatGPT sign-in complete: ${accountLabel(account)}.`);
|
|
39277
|
+
} finally {
|
|
39278
|
+
client.close();
|
|
39279
|
+
}
|
|
39280
|
+
}
|
|
39281
|
+
async function logoutOpenAICodexAppServer() {
|
|
39282
|
+
const client = createCodexAppServerClient();
|
|
39283
|
+
try {
|
|
39284
|
+
await client.initialize({ experimentalApi: true });
|
|
39285
|
+
await client.logout();
|
|
39286
|
+
} finally {
|
|
39287
|
+
client.close();
|
|
39288
|
+
}
|
|
39289
|
+
}
|
|
39290
|
+
async function hasOpenAICodexAppServerAccount() {
|
|
39291
|
+
const client = createCodexAppServerClient();
|
|
39292
|
+
try {
|
|
39293
|
+
await client.initialize({ experimentalApi: true });
|
|
39294
|
+
const account = await client.readAccount(false);
|
|
39295
|
+
return account.account !== null;
|
|
39296
|
+
} catch {
|
|
39297
|
+
return false;
|
|
39298
|
+
} finally {
|
|
39299
|
+
client.close();
|
|
39300
|
+
}
|
|
39301
|
+
}
|
|
39302
|
+
var init_auth = __esm2(() => {
|
|
39303
|
+
init_app_server_client();
|
|
39304
|
+
});
|
|
38866
39305
|
function getFeatureFlagsPath(env = process.env) {
|
|
38867
39306
|
const configured2 = env.EVALOPS_FEATURE_FLAGS_PATH?.trim();
|
|
38868
39307
|
return configured2 ? configured2 : void 0;
|
|
@@ -40667,7 +41106,7 @@ function normalizeConnectorSourceOfTruthArea(area) {
|
|
|
40667
41106
|
}
|
|
40668
41107
|
return null;
|
|
40669
41108
|
}
|
|
40670
|
-
function
|
|
41109
|
+
function isRecord2(value) {
|
|
40671
41110
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
40672
41111
|
}
|
|
40673
41112
|
function getMetadataString(metadata, key) {
|
|
@@ -40684,7 +41123,7 @@ function getMetadataStringArray(metadata, key) {
|
|
|
40684
41123
|
}
|
|
40685
41124
|
function getMetadataStringMap(metadata, key) {
|
|
40686
41125
|
const value = metadata?.[key];
|
|
40687
|
-
if (!
|
|
41126
|
+
if (!isRecord2(value)) {
|
|
40688
41127
|
return;
|
|
40689
41128
|
}
|
|
40690
41129
|
const entries = Object.entries(value).map(([entryKey2, entryValue]) => [
|
|
@@ -41165,7 +41604,7 @@ function parseScopesPayload(value) {
|
|
|
41165
41604
|
}
|
|
41166
41605
|
return value.filter((entry2) => typeof entry2 === "string").map((entry2) => entry2.trim()).filter((entry2) => entry2.length > 0);
|
|
41167
41606
|
}
|
|
41168
|
-
function
|
|
41607
|
+
function isRecord3(value) {
|
|
41169
41608
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41170
41609
|
}
|
|
41171
41610
|
function getMetadataString2(metadata, key) {
|
|
@@ -41181,7 +41620,7 @@ function getMetadataScopes(metadata) {
|
|
|
41181
41620
|
}
|
|
41182
41621
|
function resolveProviderRef(metadata) {
|
|
41183
41622
|
const fallback = getProviderRef();
|
|
41184
|
-
const providerRef =
|
|
41623
|
+
const providerRef = isRecord3(metadata?.providerRef) ? metadata.providerRef : void 0;
|
|
41185
41624
|
return {
|
|
41186
41625
|
provider: getMetadataString2(providerRef, "provider") ?? fallback.provider,
|
|
41187
41626
|
environment: getMetadataString2(providerRef, "environment") ?? fallback.environment,
|
|
@@ -42924,6 +43363,7 @@ __export2(exports_oauth, {
|
|
|
42924
43363
|
logout: () => logout,
|
|
42925
43364
|
login: () => login,
|
|
42926
43365
|
listOAuthProviders: () => listOAuthProviders2,
|
|
43366
|
+
listOAuthLogoutProvidersWithCodexAppServer: () => listOAuthLogoutProvidersWithCodexAppServer,
|
|
42927
43367
|
listOAuthLogoutProviders: () => listOAuthLogoutProviders,
|
|
42928
43368
|
issueEvalOpsDelegationToken: () => issueEvalOpsDelegationToken,
|
|
42929
43369
|
hasOAuthCredentials: () => hasOAuthCredentials,
|
|
@@ -42984,6 +43424,13 @@ function listOAuthProviders2() {
|
|
|
42984
43424
|
function listOAuthLogoutProviders() {
|
|
42985
43425
|
return listOAuthProviders().filter((provider) => isSupportedOAuthProvider(provider) || isLegacyLogoutOnlyOAuthProvider(provider));
|
|
42986
43426
|
}
|
|
43427
|
+
async function listOAuthLogoutProvidersWithCodexAppServer() {
|
|
43428
|
+
const providers = listOAuthLogoutProviders();
|
|
43429
|
+
if (!providers.includes("openai-codex") && await hasOpenAICodexAppServerAccount()) {
|
|
43430
|
+
return [...providers, "openai-codex"];
|
|
43431
|
+
}
|
|
43432
|
+
return providers;
|
|
43433
|
+
}
|
|
42987
43434
|
function getOAuthLogoutProviders() {
|
|
42988
43435
|
const loggedInProviders = new Set(listOAuthLogoutProviders());
|
|
42989
43436
|
const supported = getOAuthProviders().filter((provider) => loggedInProviders.has(provider.id));
|
|
@@ -43012,8 +43459,12 @@ async function login(provider, options) {
|
|
|
43012
43459
|
shouldSyncConnectorConnection = true;
|
|
43013
43460
|
break;
|
|
43014
43461
|
case "openai-codex":
|
|
43015
|
-
|
|
43016
|
-
|
|
43462
|
+
if (options.mode === "responses" || options.mode === "legacy-responses") {
|
|
43463
|
+
await loginOpenAICodex(options.onAuthUrl, options.onPromptCode, options.onStatus);
|
|
43464
|
+
shouldSyncConnectorConnection = true;
|
|
43465
|
+
} else {
|
|
43466
|
+
await loginOpenAICodexAppServer(options.onAuthUrl, options.onPromptCode, options.onStatus);
|
|
43467
|
+
}
|
|
43017
43468
|
break;
|
|
43018
43469
|
case "evalops":
|
|
43019
43470
|
assertEvalOpsManagedGatewayEnabled();
|
|
@@ -43043,6 +43494,7 @@ async function login(provider, options) {
|
|
|
43043
43494
|
}
|
|
43044
43495
|
async function logout(provider) {
|
|
43045
43496
|
const credentials = loadOAuthCredentials(provider);
|
|
43497
|
+
let codexAppServerLogoutError;
|
|
43046
43498
|
if (isLegacyLogoutOnlyOAuthProvider(provider)) {
|
|
43047
43499
|
await revokeOAuthProviderConnection(provider, credentials);
|
|
43048
43500
|
removeOAuthCredentials(provider);
|
|
@@ -43058,10 +43510,32 @@ async function logout(provider) {
|
|
|
43058
43510
|
});
|
|
43059
43511
|
}
|
|
43060
43512
|
}
|
|
43513
|
+
if (provider === "openai-codex") {
|
|
43514
|
+
const shouldLogoutAppServer = !credentials || await hasOpenAICodexAppServerAccount();
|
|
43515
|
+
if (shouldLogoutAppServer) {
|
|
43516
|
+
try {
|
|
43517
|
+
await logoutOpenAICodexAppServer();
|
|
43518
|
+
} catch (error) {
|
|
43519
|
+
if (!credentials) {
|
|
43520
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
43521
|
+
throw new Error(`Failed to sign out of Codex app-server: ${message}`);
|
|
43522
|
+
}
|
|
43523
|
+
codexAppServerLogoutError = error;
|
|
43524
|
+
}
|
|
43525
|
+
}
|
|
43526
|
+
}
|
|
43061
43527
|
if (provider !== "evalops") {
|
|
43062
43528
|
await revokeOAuthProviderConnection(provider, credentials);
|
|
43063
43529
|
}
|
|
43064
43530
|
removeOAuthCredentials(provider);
|
|
43531
|
+
if (codexAppServerLogoutError) {
|
|
43532
|
+
const message = codexAppServerLogoutError instanceof Error ? codexAppServerLogoutError.message : String(codexAppServerLogoutError);
|
|
43533
|
+
logger15.warn("Failed to sign out of Codex app-server", {
|
|
43534
|
+
error: message,
|
|
43535
|
+
provider
|
|
43536
|
+
});
|
|
43537
|
+
throw new Error(`Failed to sign out of Codex app-server; legacy OAuth credentials were removed: ${message}`);
|
|
43538
|
+
}
|
|
43065
43539
|
}
|
|
43066
43540
|
async function refreshToken(provider) {
|
|
43067
43541
|
const credentials = loadOAuthCredentials(provider);
|
|
@@ -43130,6 +43604,7 @@ var logger15;
|
|
|
43130
43604
|
var SUPPORTED_OAUTH_PROVIDERS;
|
|
43131
43605
|
var LEGACY_LOGOUT_ONLY_OAUTH_PROVIDERS;
|
|
43132
43606
|
var init_oauth = __esm2(() => {
|
|
43607
|
+
init_auth();
|
|
43133
43608
|
init_evalops_managed();
|
|
43134
43609
|
init_logger();
|
|
43135
43610
|
init_connectors();
|
|
@@ -43832,7 +44307,7 @@ function resolveA2AAgentCardUrl(input) {
|
|
|
43832
44307
|
return normalizePairingUrl(parsed.toString(), "agentCardUrl");
|
|
43833
44308
|
}
|
|
43834
44309
|
function normalizeDecodedPayload(input, options = {}) {
|
|
43835
|
-
if (!
|
|
44310
|
+
if (!isRecord4(input)) {
|
|
43836
44311
|
throw new Error("A2A pairing code payload must be an object");
|
|
43837
44312
|
}
|
|
43838
44313
|
if (input.version !== PAIRING_CODE_VERSION) {
|
|
@@ -43848,14 +44323,14 @@ function normalizeDecodedPayload(input, options = {}) {
|
|
|
43848
44323
|
issuedAt: toDate(input.issuedAt, "issuedAt").toISOString(),
|
|
43849
44324
|
expiresAt: toDate(input.expiresAt, "expiresAt").toISOString(),
|
|
43850
44325
|
...typeof input.peerId === "string" ? { peerId: requireNonEmptyString(input.peerId, "peerId") } : {},
|
|
43851
|
-
...
|
|
43852
|
-
...
|
|
44326
|
+
...isRecord4(input.provider) ? { provider: normalizeProvider(input.provider) } : {},
|
|
44327
|
+
...isRecord4(input.capabilities) ? { capabilities: normalizeCapabilities(input.capabilities) } : {},
|
|
43853
44328
|
...Array.isArray(input.skills) ? { skills: normalizeSkills(input.skills) } : {},
|
|
43854
44329
|
...typeof input.keyFingerprint === "string" ? {
|
|
43855
44330
|
keyFingerprint: requireNonEmptyString(input.keyFingerprint, "keyFingerprint")
|
|
43856
44331
|
} : {},
|
|
43857
|
-
...
|
|
43858
|
-
...
|
|
44332
|
+
...isRecord4(input.relayHints) ? { relayHints: normalizeRelayHints(input.relayHints) } : {},
|
|
44333
|
+
...isRecord4(input.metadata) ? { metadata: normalizeMetadata(input.metadata) } : {}
|
|
43859
44334
|
};
|
|
43860
44335
|
validateA2APeerPairingPayload(payload, options);
|
|
43861
44336
|
return payload;
|
|
@@ -43928,7 +44403,7 @@ function normalizeCapabilities(input) {
|
|
|
43928
44403
|
}
|
|
43929
44404
|
function normalizeSkills(input) {
|
|
43930
44405
|
return input.slice(0, MAX_SKILLS_IN_PAIRING_CODE).map((skill, index2) => {
|
|
43931
|
-
if (!
|
|
44406
|
+
if (!isRecord4(skill)) {
|
|
43932
44407
|
throw new Error(`skills[${index2}] must be an object`);
|
|
43933
44408
|
}
|
|
43934
44409
|
return {
|
|
@@ -43965,7 +44440,7 @@ function copyStringList(input, key, limit = Number.POSITIVE_INFINITY) {
|
|
|
43965
44440
|
}
|
|
43966
44441
|
function copyStringRecord(input, key) {
|
|
43967
44442
|
const value = input[key];
|
|
43968
|
-
if (!
|
|
44443
|
+
if (!isRecord4(value)) {
|
|
43969
44444
|
return {};
|
|
43970
44445
|
}
|
|
43971
44446
|
const entries = Object.entries(value).map(([entryKey2, entryValue]) => [
|
|
@@ -43976,7 +44451,7 @@ function copyStringRecord(input, key) {
|
|
|
43976
44451
|
}
|
|
43977
44452
|
function copyPrimitiveRecord(input, key) {
|
|
43978
44453
|
const value = input[key];
|
|
43979
|
-
if (!
|
|
44454
|
+
if (!isRecord4(value)) {
|
|
43980
44455
|
return {};
|
|
43981
44456
|
}
|
|
43982
44457
|
const output = {};
|
|
@@ -44018,7 +44493,7 @@ function rejectSecretBearingFields(value, path3 = "$") {
|
|
|
44018
44493
|
}
|
|
44019
44494
|
return;
|
|
44020
44495
|
}
|
|
44021
|
-
if (!
|
|
44496
|
+
if (!isRecord4(value)) {
|
|
44022
44497
|
return;
|
|
44023
44498
|
}
|
|
44024
44499
|
for (const [key, child] of Object.entries(value)) {
|
|
@@ -44065,7 +44540,7 @@ ${payload.agentCardUrl}
|
|
|
44065
44540
|
${payload.transportUrl}`).digest("base64url").slice(0, 16);
|
|
44066
44541
|
return `a2a-peer-${hash}`;
|
|
44067
44542
|
}
|
|
44068
|
-
function
|
|
44543
|
+
function isRecord4(value) {
|
|
44069
44544
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44070
44545
|
}
|
|
44071
44546
|
function errorMessage(error) {
|
|
@@ -44101,10 +44576,10 @@ async function loadA2APeerRegistry(options = {}) {
|
|
|
44101
44576
|
throw error;
|
|
44102
44577
|
}
|
|
44103
44578
|
const parsed = JSON.parse(raw);
|
|
44104
|
-
if (!
|
|
44579
|
+
if (!isRecord5(parsed)) {
|
|
44105
44580
|
throw new Error(`A2A peer registry at ${path3} must be a JSON object`);
|
|
44106
44581
|
}
|
|
44107
|
-
const peers =
|
|
44582
|
+
const peers = isRecord5(parsed.peers) ? parsed.peers : {};
|
|
44108
44583
|
const registry2 = {
|
|
44109
44584
|
peers: Object.fromEntries(Object.entries(peers).map(([name, value]) => [
|
|
44110
44585
|
name,
|
|
@@ -44239,7 +44714,7 @@ function resolveUpsertTokenFields(input) {
|
|
|
44239
44714
|
};
|
|
44240
44715
|
}
|
|
44241
44716
|
function normalizeRegistryEntry(input, label) {
|
|
44242
|
-
if (!
|
|
44717
|
+
if (!isRecord5(input)) {
|
|
44243
44718
|
throw new Error(`${label} must be an object`);
|
|
44244
44719
|
}
|
|
44245
44720
|
const url = typeof input.url === "string" ? input.url.trim() : "";
|
|
@@ -44261,7 +44736,7 @@ function normalizeRegistryEntry(input, label) {
|
|
|
44261
44736
|
...copyString(input, "actorId"),
|
|
44262
44737
|
...typeof input.timeoutMs === "number" && input.timeoutMs > 0 ? { timeoutMs: input.timeoutMs } : {},
|
|
44263
44738
|
...typeof input.maxAttempts === "number" && input.maxAttempts > 0 ? { maxAttempts: input.maxAttempts } : {},
|
|
44264
|
-
...
|
|
44739
|
+
...isRecord5(input.capabilities) ? {
|
|
44265
44740
|
capabilities: {
|
|
44266
44741
|
...typeof input.capabilities.streaming === "boolean" ? { streaming: input.capabilities.streaming } : {},
|
|
44267
44742
|
...typeof input.capabilities.pushNotifications === "boolean" ? { pushNotifications: input.capabilities.pushNotifications } : {},
|
|
@@ -44270,7 +44745,7 @@ function normalizeRegistryEntry(input, label) {
|
|
|
44270
44745
|
} : {},
|
|
44271
44746
|
...Array.isArray(input.skills) ? { skills: normalizeRegistrySkills(input.skills) } : {},
|
|
44272
44747
|
...copyString(input, "keyFingerprint"),
|
|
44273
|
-
...
|
|
44748
|
+
...isRecord5(input.metadata) ? {
|
|
44274
44749
|
metadata: input.metadata
|
|
44275
44750
|
} : {},
|
|
44276
44751
|
...copyString(input, "createdAt"),
|
|
@@ -44278,7 +44753,7 @@ function normalizeRegistryEntry(input, label) {
|
|
|
44278
44753
|
};
|
|
44279
44754
|
}
|
|
44280
44755
|
function normalizeRegistrySkills(input) {
|
|
44281
|
-
return input.filter(
|
|
44756
|
+
return input.filter(isRecord5).map((skill) => ({
|
|
44282
44757
|
id: typeof skill.id === "string" ? skill.id : "",
|
|
44283
44758
|
name: typeof skill.name === "string" ? skill.name : "",
|
|
44284
44759
|
...copyString(skill, "description"),
|
|
@@ -44307,7 +44782,7 @@ function copyStringList2(input, key) {
|
|
|
44307
44782
|
}
|
|
44308
44783
|
function copyStringRecord2(input, key) {
|
|
44309
44784
|
const value = input[key];
|
|
44310
|
-
if (!
|
|
44785
|
+
if (!isRecord5(value)) {
|
|
44311
44786
|
return {};
|
|
44312
44787
|
}
|
|
44313
44788
|
const entries = Object.entries(value).map(([entryKey2, entryValue]) => [
|
|
@@ -44318,7 +44793,7 @@ function copyStringRecord2(input, key) {
|
|
|
44318
44793
|
}
|
|
44319
44794
|
function copyPrimitiveRecord2(input, key) {
|
|
44320
44795
|
const value = input[key];
|
|
44321
|
-
if (!
|
|
44796
|
+
if (!isRecord5(value)) {
|
|
44322
44797
|
return {};
|
|
44323
44798
|
}
|
|
44324
44799
|
const output = {};
|
|
@@ -44346,7 +44821,7 @@ function expandHome(path3) {
|
|
|
44346
44821
|
}
|
|
44347
44822
|
return resolve4(path3);
|
|
44348
44823
|
}
|
|
44349
|
-
function
|
|
44824
|
+
function isRecord5(value) {
|
|
44350
44825
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44351
44826
|
}
|
|
44352
44827
|
function hasNodeCode(error, code) {
|
|
@@ -44363,7 +44838,7 @@ function extractA2AWorkGraphMetadata(task) {
|
|
|
44363
44838
|
return normalizeA2AWorkGraphMetadata(task?.metadata?.workGraph);
|
|
44364
44839
|
}
|
|
44365
44840
|
function normalizeA2AWorkGraphMetadata(input) {
|
|
44366
|
-
if (!
|
|
44841
|
+
if (!isRecord6(input)) {
|
|
44367
44842
|
return;
|
|
44368
44843
|
}
|
|
44369
44844
|
const codexSubagents = normalizeCodexSubagents(input.codexSubagents);
|
|
@@ -44425,7 +44900,7 @@ function formatA2AWorkGraphCodexSubagents(graph) {
|
|
|
44425
44900
|
return `Codex subagents: ${parts.join(" | ")}`;
|
|
44426
44901
|
}
|
|
44427
44902
|
function normalizeCodexSubagents(input) {
|
|
44428
|
-
if (!
|
|
44903
|
+
if (!isRecord6(input)) {
|
|
44429
44904
|
return;
|
|
44430
44905
|
}
|
|
44431
44906
|
const edges = normalizeCodexSubagentEdges(input.edges);
|
|
@@ -44444,7 +44919,7 @@ function normalizeCodexSubagentEdges(input) {
|
|
|
44444
44919
|
}
|
|
44445
44920
|
const edges = [];
|
|
44446
44921
|
for (const value of input) {
|
|
44447
|
-
if (!
|
|
44922
|
+
if (!isRecord6(value)) {
|
|
44448
44923
|
continue;
|
|
44449
44924
|
}
|
|
44450
44925
|
const edge = {};
|
|
@@ -44498,7 +44973,7 @@ function normalizeCodexSubagentEdges(input) {
|
|
|
44498
44973
|
return edges;
|
|
44499
44974
|
}
|
|
44500
44975
|
function normalizeNumberRecord(input) {
|
|
44501
|
-
if (!
|
|
44976
|
+
if (!isRecord6(input)) {
|
|
44502
44977
|
return;
|
|
44503
44978
|
}
|
|
44504
44979
|
const entries = Object.entries(input).map(([key, value]) => [key, numberValue(value)]).filter((entry2) => entry2[1] !== void 0);
|
|
@@ -44567,7 +45042,7 @@ function numberValue(input) {
|
|
|
44567
45042
|
const parsed = Number(input);
|
|
44568
45043
|
return Number.isFinite(parsed) ? parsed : void 0;
|
|
44569
45044
|
}
|
|
44570
|
-
function
|
|
45045
|
+
function isRecord6(value) {
|
|
44571
45046
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44572
45047
|
}
|
|
44573
45048
|
function getA2ATaskLedgerPath(path3) {
|
|
@@ -44589,7 +45064,7 @@ async function loadA2ATaskLedger(options = {}) {
|
|
|
44589
45064
|
throw error;
|
|
44590
45065
|
}
|
|
44591
45066
|
const parsed = JSON.parse(raw);
|
|
44592
|
-
if (!
|
|
45067
|
+
if (!isRecord7(parsed)) {
|
|
44593
45068
|
throw new Error(`A2A task ledger at ${path3} must be a JSON object`);
|
|
44594
45069
|
}
|
|
44595
45070
|
const tasks = Array.isArray(parsed.tasks) ? parsed.tasks : [];
|
|
@@ -44980,7 +45455,7 @@ function latestAgentMessageInHistory(history) {
|
|
|
44980
45455
|
return;
|
|
44981
45456
|
}
|
|
44982
45457
|
function normalizeLedgerEntry(input, path3) {
|
|
44983
|
-
if (!
|
|
45458
|
+
if (!isRecord7(input)) {
|
|
44984
45459
|
throw new Error(`A2A task ledger ${path3} must be a JSON object`);
|
|
44985
45460
|
}
|
|
44986
45461
|
const id = requiredString(input.id, `${path3}.id`);
|
|
@@ -45016,7 +45491,7 @@ function normalizeLedgerEntry(input, path3) {
|
|
|
45016
45491
|
entry2[key] = value;
|
|
45017
45492
|
}
|
|
45018
45493
|
}
|
|
45019
|
-
if (
|
|
45494
|
+
if (isRecord7(input.metadata)) {
|
|
45020
45495
|
entry2.metadata = cleanMetadata(input.metadata);
|
|
45021
45496
|
}
|
|
45022
45497
|
const workGraph = normalizeA2AWorkGraphMetadata(input.workGraph);
|
|
@@ -45026,7 +45501,7 @@ function normalizeLedgerEntry(input, path3) {
|
|
|
45026
45501
|
return entry2;
|
|
45027
45502
|
}
|
|
45028
45503
|
function normalizeTranscriptEntry(input, path3) {
|
|
45029
|
-
if (!
|
|
45504
|
+
if (!isRecord7(input)) {
|
|
45030
45505
|
throw new Error(`A2A task ledger ${path3} must be a JSON object`);
|
|
45031
45506
|
}
|
|
45032
45507
|
const role = input.role === "agent" ? "agent" : "user";
|
|
@@ -45051,7 +45526,7 @@ function cleanMetadata(input) {
|
|
|
45051
45526
|
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
45052
45527
|
}
|
|
45053
45528
|
function extractA2ATaskLedgerMetadata(task) {
|
|
45054
|
-
if (!
|
|
45529
|
+
if (!isRecord7(task.metadata)) {
|
|
45055
45530
|
return;
|
|
45056
45531
|
}
|
|
45057
45532
|
return cleanMetadata(Object.fromEntries(Object.entries(task.metadata).filter(([key]) => !isSecretLikeKey2(key))));
|
|
@@ -45078,12 +45553,12 @@ function expandHome2(path3) {
|
|
|
45078
45553
|
return path3 === "~" || path3.startsWith("~/") ? join9(homedir3(), path3.slice(2)) : path3;
|
|
45079
45554
|
}
|
|
45080
45555
|
function hasNodeCode2(error, code) {
|
|
45081
|
-
return
|
|
45556
|
+
return isRecord7(error) && error.code === code;
|
|
45082
45557
|
}
|
|
45083
45558
|
function sleep3(ms) {
|
|
45084
45559
|
return new Promise((resolve510) => setTimeout(resolve510, ms));
|
|
45085
45560
|
}
|
|
45086
|
-
function
|
|
45561
|
+
function isRecord7(value) {
|
|
45087
45562
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45088
45563
|
}
|
|
45089
45564
|
function fail(message) {
|
|
@@ -48330,16 +48805,16 @@ async function handleA2ATelemetry(parsed) {
|
|
|
48330
48805
|
}
|
|
48331
48806
|
async function loadA2ATelemetryEvents(path3) {
|
|
48332
48807
|
const parsed = JSON.parse(await readFile3(path3, "utf8"));
|
|
48333
|
-
const events = Array.isArray(parsed) ? parsed :
|
|
48808
|
+
const events = Array.isArray(parsed) ? parsed : isRecord8(parsed) && Array.isArray(parsed.events) ? parsed.events : void 0;
|
|
48334
48809
|
if (!events) {
|
|
48335
48810
|
throw new Error("A2A telemetry events file must be an array or { events }");
|
|
48336
48811
|
}
|
|
48337
48812
|
return events.filter(isA2ATelemetryCloudEventLike);
|
|
48338
48813
|
}
|
|
48339
48814
|
function isA2ATelemetryCloudEventLike(value) {
|
|
48340
|
-
return
|
|
48815
|
+
return isRecord8(value) && typeof value.type === "string" && (value.data === void 0 || isRecord8(value.data));
|
|
48341
48816
|
}
|
|
48342
|
-
function
|
|
48817
|
+
function isRecord8(value) {
|
|
48343
48818
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
48344
48819
|
}
|
|
48345
48820
|
async function handleA2ATasks(parsed) {
|
|
@@ -55682,13 +56157,13 @@ function getAvailableThemes(workspaceDir = process.cwd()) {
|
|
|
55682
56157
|
}
|
|
55683
56158
|
return Array.from(themes).sort();
|
|
55684
56159
|
}
|
|
55685
|
-
function
|
|
56160
|
+
function isRecord9(value) {
|
|
55686
56161
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
55687
56162
|
}
|
|
55688
56163
|
function normalizeThemeJson(raw) {
|
|
55689
|
-
if (!
|
|
56164
|
+
if (!isRecord9(raw))
|
|
55690
56165
|
return raw;
|
|
55691
|
-
if (!
|
|
56166
|
+
if (!isRecord9(raw.colors))
|
|
55692
56167
|
return raw;
|
|
55693
56168
|
const {
|
|
55694
56169
|
bashMode: _bashMode,
|
|
@@ -60763,7 +61238,7 @@ function getEffectiveUserPolicyPath() {
|
|
|
60763
61238
|
const candidates = getUserPolicyPathCandidates();
|
|
60764
61239
|
return candidates.find(isPolicyFile) ?? null;
|
|
60765
61240
|
}
|
|
60766
|
-
function
|
|
61241
|
+
function isRecord10(value) {
|
|
60767
61242
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60768
61243
|
}
|
|
60769
61244
|
function getPolicySources() {
|
|
@@ -60856,20 +61331,20 @@ function readOptionalRecord(source, key) {
|
|
|
60856
61331
|
if (!(key in source))
|
|
60857
61332
|
return;
|
|
60858
61333
|
const value = source[key];
|
|
60859
|
-
if (!
|
|
61334
|
+
if (!isRecord10(value)) {
|
|
60860
61335
|
throw new Error(`Workspace policy key "${key}" must be a table`);
|
|
60861
61336
|
}
|
|
60862
61337
|
return value;
|
|
60863
61338
|
}
|
|
60864
61339
|
function selectWorkspacePolicyRoot(parsed) {
|
|
60865
|
-
if (!
|
|
61340
|
+
if (!isRecord10(parsed)) {
|
|
60866
61341
|
throw new Error("Workspace policy must be a TOML table");
|
|
60867
61342
|
}
|
|
60868
61343
|
const nestedPolicy = parsed.policy;
|
|
60869
61344
|
if (nestedPolicy === void 0) {
|
|
60870
61345
|
return parsed;
|
|
60871
61346
|
}
|
|
60872
|
-
if (!
|
|
61347
|
+
if (!isRecord10(nestedPolicy)) {
|
|
60873
61348
|
throw new Error('Workspace policy key "policy" must be a table');
|
|
60874
61349
|
}
|
|
60875
61350
|
return nestedPolicy;
|
|
@@ -65150,11 +65625,11 @@ __export2(exports_scripted, {
|
|
|
65150
65625
|
SCRIPTED_REPLAY_PROVIDER: () => SCRIPTED_REPLAY_PROVIDER,
|
|
65151
65626
|
SCRIPTED_REPLAY_MODEL_ID: () => SCRIPTED_REPLAY_MODEL_ID
|
|
65152
65627
|
});
|
|
65153
|
-
function
|
|
65628
|
+
function isRecord11(value) {
|
|
65154
65629
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
65155
65630
|
}
|
|
65156
65631
|
function parseScriptedScenario(value, label) {
|
|
65157
|
-
if (!
|
|
65632
|
+
if (!isRecord11(value) || value.schemaVersion !== MAESTRO_SCRIPTED_SCENARIO_SCHEMA) {
|
|
65158
65633
|
throw new Error(`Replay scenario ${label} must use schemaVersion ${MAESTRO_SCRIPTED_SCENARIO_SCHEMA}`);
|
|
65159
65634
|
}
|
|
65160
65635
|
if (typeof value.id !== "string" || value.id.trim().length === 0) {
|
|
@@ -65169,7 +65644,7 @@ function parseScriptedScenario(value, label) {
|
|
|
65169
65644
|
if (!Array.isArray(value.frames)) {
|
|
65170
65645
|
throw new Error(`Replay scenario ${label} must contain frames`);
|
|
65171
65646
|
}
|
|
65172
|
-
if (!
|
|
65647
|
+
if (!isRecord11(value.metadata)) {
|
|
65173
65648
|
throw new Error(`Replay scenario ${label} must contain metadata`);
|
|
65174
65649
|
}
|
|
65175
65650
|
if (typeof value.metadata.recordedAt !== "string" || value.metadata.recordedAt.trim().length === 0) {
|
|
@@ -65195,7 +65670,7 @@ function parseScriptedScenario(value, label) {
|
|
|
65195
65670
|
throw new Error(`Replay scenario ${label} assertions must be an array`);
|
|
65196
65671
|
}
|
|
65197
65672
|
for (const [assertionOffset, assertion2] of (value.assertions ?? []).entries()) {
|
|
65198
|
-
if (!
|
|
65673
|
+
if (!isRecord11(assertion2) || typeof assertion2.id !== "string" || typeof assertion2.kind !== "string") {
|
|
65199
65674
|
throw new Error(`Replay scenario ${label} assertion ${assertionOffset} must contain id and kind`);
|
|
65200
65675
|
}
|
|
65201
65676
|
if (![
|
|
@@ -65209,14 +65684,14 @@ function parseScriptedScenario(value, label) {
|
|
|
65209
65684
|
}
|
|
65210
65685
|
}
|
|
65211
65686
|
for (const [frameOffset, frame] of value.frames.entries()) {
|
|
65212
|
-
if (!
|
|
65687
|
+
if (!isRecord11(frame) || !Number.isInteger(frame.index) || !Array.isArray(frame.statements)) {
|
|
65213
65688
|
throw new Error(`Replay scenario ${label} frame ${frameOffset} must contain index and statements`);
|
|
65214
65689
|
}
|
|
65215
65690
|
if (frame.index !== frameOffset) {
|
|
65216
65691
|
throw new Error(`Replay scenario ${label} frame indexes must be contiguous, unique, and start at 0; frame ${frameOffset} has index ${frame.index}`);
|
|
65217
65692
|
}
|
|
65218
65693
|
for (const [statementOffset, statement] of frame.statements.entries()) {
|
|
65219
|
-
if (!
|
|
65694
|
+
if (!isRecord11(statement) || typeof statement.kind !== "string") {
|
|
65220
65695
|
throw new Error(`Replay scenario ${label} frame ${frame.index} statement ${statementOffset} must contain kind`);
|
|
65221
65696
|
}
|
|
65222
65697
|
if (statement.kind === "text" && typeof statement.text !== "string") {
|
|
@@ -65304,7 +65779,7 @@ function replayFrameIndex(context2) {
|
|
|
65304
65779
|
return context2.messages.filter((message) => message.role === "assistant" && message.provider === SCRIPTED_REPLAY_PROVIDER).length;
|
|
65305
65780
|
}
|
|
65306
65781
|
function isToolResultMessage2(value) {
|
|
65307
|
-
return
|
|
65782
|
+
return isRecord11(value) && value.role === "toolResult";
|
|
65308
65783
|
}
|
|
65309
65784
|
function expectedToolResultError(scenario, frameIndex, context2) {
|
|
65310
65785
|
if (frameIndex <= 0)
|
|
@@ -65339,7 +65814,7 @@ function expectedToolResultError(scenario, frameIndex, context2) {
|
|
|
65339
65814
|
return;
|
|
65340
65815
|
}
|
|
65341
65816
|
function normalizeToolInput(input) {
|
|
65342
|
-
return
|
|
65817
|
+
return isRecord11(input) ? input : {};
|
|
65343
65818
|
}
|
|
65344
65819
|
function toolCallId(scenario, frameIndex, statementIndex, statement) {
|
|
65345
65820
|
return statement.id ?? `replay_${scenario.id}_${String(frameIndex).padStart(3, "0")}_${String(statementIndex).padStart(3, "0")}`;
|
|
@@ -65571,7 +66046,7 @@ function parseStreamingJson(partialJson) {
|
|
|
65571
66046
|
}
|
|
65572
66047
|
var init_json_parse = () => {
|
|
65573
66048
|
};
|
|
65574
|
-
function
|
|
66049
|
+
function isRecord12(value) {
|
|
65575
66050
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
65576
66051
|
}
|
|
65577
66052
|
function describeValueType(value) {
|
|
@@ -65601,7 +66076,7 @@ function createToolArgumentNormalizer(options) {
|
|
|
65601
66076
|
}
|
|
65602
66077
|
function parseFromString(raw, context2, parseOptions2) {
|
|
65603
66078
|
const parsed = parseStreamingJson(raw);
|
|
65604
|
-
if (
|
|
66079
|
+
if (isRecord12(parsed)) {
|
|
65605
66080
|
return parsed;
|
|
65606
66081
|
}
|
|
65607
66082
|
if (parseOptions2?.logInvalid ?? true) {
|
|
@@ -65616,7 +66091,7 @@ function createToolArgumentNormalizer(options) {
|
|
|
65616
66091
|
logInvalid: normalizeOptions?.logInvalid
|
|
65617
66092
|
});
|
|
65618
66093
|
}
|
|
65619
|
-
if (
|
|
66094
|
+
if (isRecord12(raw)) {
|
|
65620
66095
|
if (normalizeOptions?.expectString) {
|
|
65621
66096
|
warnOnce("raw:object", `${options.providerLabel} tool call arguments were object, expected string`, buildWarningDetails(context2));
|
|
65622
66097
|
}
|
|
@@ -65639,7 +66114,7 @@ function createToolArgumentNormalizer(options) {
|
|
|
65639
66114
|
partialJson: raw
|
|
65640
66115
|
};
|
|
65641
66116
|
}
|
|
65642
|
-
if (
|
|
66117
|
+
if (isRecord12(raw)) {
|
|
65643
66118
|
if (normalizeOptions?.expectString) {
|
|
65644
66119
|
warnOnce("raw:object", `${options.providerLabel} tool call arguments were object, expected string`, buildWarningDetails(context2));
|
|
65645
66120
|
}
|
|
@@ -66037,7 +66512,7 @@ async function* streamAnthropic(model, context2, options) {
|
|
|
66037
66512
|
const idx = partial.content.length;
|
|
66038
66513
|
let initialArguments = {};
|
|
66039
66514
|
if ("input" in block && block.input !== void 0) {
|
|
66040
|
-
if (
|
|
66515
|
+
if (isRecord12(block.input)) {
|
|
66041
66516
|
initialArguments = block.input;
|
|
66042
66517
|
toolArgOverrides.set(idx, block.input);
|
|
66043
66518
|
} else if (typeof block.input === "string") {
|
|
@@ -66131,7 +66606,7 @@ async function* streamAnthropic(model, context2, options) {
|
|
|
66131
66606
|
if (buf.length > 0) {
|
|
66132
66607
|
block.arguments = toolArgumentNormalizer.parseFromString(buf, { toolId: block.id, name: block.name, stage: "done" }, { logInvalid: true });
|
|
66133
66608
|
} else {
|
|
66134
|
-
block.arguments =
|
|
66609
|
+
block.arguments = isRecord12(block.arguments) ? block.arguments : {};
|
|
66135
66610
|
}
|
|
66136
66611
|
}
|
|
66137
66612
|
toolArgBuffers.delete(idx);
|
|
@@ -66431,7 +66906,7 @@ function canonicalizeSchema(value) {
|
|
|
66431
66906
|
if (Array.isArray(value)) {
|
|
66432
66907
|
return value.map((entry2) => canonicalizeSchema(entry2));
|
|
66433
66908
|
}
|
|
66434
|
-
if (!
|
|
66909
|
+
if (!isRecord12(value)) {
|
|
66435
66910
|
return value;
|
|
66436
66911
|
}
|
|
66437
66912
|
return Object.fromEntries(Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)).map(([entryKey2, entryValue]) => [
|
|
@@ -66517,14 +66992,14 @@ function mergeSharedObjectSchemaConstraints(left, right, enumValues) {
|
|
|
66517
66992
|
return merged;
|
|
66518
66993
|
}
|
|
66519
66994
|
function mergeObjectVariants(variants, requiredMode) {
|
|
66520
|
-
if (variants.length === 0 || !variants.every(
|
|
66995
|
+
if (variants.length === 0 || !variants.every(isRecord12))
|
|
66521
66996
|
return;
|
|
66522
66997
|
if (!variants.every((variant) => variant.type === "object"))
|
|
66523
66998
|
return;
|
|
66524
66999
|
const mergedProperties = {};
|
|
66525
67000
|
const requiredCounts = /* @__PURE__ */ new Map();
|
|
66526
67001
|
for (const variant of variants) {
|
|
66527
|
-
const properties =
|
|
67002
|
+
const properties = isRecord12(variant.properties) ? variant.properties : {};
|
|
66528
67003
|
for (const [propertyName, propertySchema] of Object.entries(properties)) {
|
|
66529
67004
|
const current = mergedProperties[propertyName];
|
|
66530
67005
|
if (current === void 0) {
|
|
@@ -66534,7 +67009,7 @@ function mergeObjectVariants(variants, requiredMode) {
|
|
|
66534
67009
|
if (schemasAreEqual(current, propertySchema)) {
|
|
66535
67010
|
continue;
|
|
66536
67011
|
}
|
|
66537
|
-
if (
|
|
67012
|
+
if (isRecord12(current) && isRecord12(propertySchema)) {
|
|
66538
67013
|
const currentValues = enumLikeValues(current);
|
|
66539
67014
|
const incomingValues = enumLikeValues(propertySchema);
|
|
66540
67015
|
if (currentValues && incomingValues) {
|
|
@@ -66560,7 +67035,7 @@ function mergeObjectVariants(variants, requiredMode) {
|
|
|
66560
67035
|
continue;
|
|
66561
67036
|
}
|
|
66562
67037
|
}
|
|
66563
|
-
if (requiredMode === "union" &&
|
|
67038
|
+
if (requiredMode === "union" && isRecord12(current) && isRecord12(propertySchema)) {
|
|
66564
67039
|
mergedProperties[propertyName] = mergeCompatibleObjectSchemas(current, propertySchema) ?? {};
|
|
66565
67040
|
continue;
|
|
66566
67041
|
}
|
|
@@ -66591,8 +67066,8 @@ function mergeObjectVariants(variants, requiredMode) {
|
|
|
66591
67066
|
function mergeRootObjectConstraints(schema, merged) {
|
|
66592
67067
|
if (schema.type !== "object")
|
|
66593
67068
|
return merged;
|
|
66594
|
-
const rootProperties =
|
|
66595
|
-
const mergedProperties =
|
|
67069
|
+
const rootProperties = isRecord12(schema.properties) ? schema.properties : {};
|
|
67070
|
+
const mergedProperties = isRecord12(merged.properties) ? merged.properties : {};
|
|
66596
67071
|
const properties = { ...rootProperties };
|
|
66597
67072
|
for (const [propertyName, propertySchema] of Object.entries(mergedProperties)) {
|
|
66598
67073
|
const rootPropertySchema = properties[propertyName];
|
|
@@ -66603,7 +67078,7 @@ function mergeRootObjectConstraints(schema, merged) {
|
|
|
66603
67078
|
if (schemasAreEqual(rootPropertySchema, propertySchema)) {
|
|
66604
67079
|
continue;
|
|
66605
67080
|
}
|
|
66606
|
-
if (
|
|
67081
|
+
if (isRecord12(rootPropertySchema) && isRecord12(propertySchema)) {
|
|
66607
67082
|
const compatible = mergeCompatibleObjectSchemas(rootPropertySchema, propertySchema);
|
|
66608
67083
|
if (!compatible)
|
|
66609
67084
|
return;
|
|
@@ -66626,7 +67101,7 @@ function mergeRootObjectConstraints(schema, merged) {
|
|
|
66626
67101
|
};
|
|
66627
67102
|
}
|
|
66628
67103
|
function hasBranchOnlyRequiredFields(variants) {
|
|
66629
|
-
if (variants.length === 0 || !variants.every(
|
|
67104
|
+
if (variants.length === 0 || !variants.every(isRecord12))
|
|
66630
67105
|
return false;
|
|
66631
67106
|
const requiredCounts = /* @__PURE__ */ new Map();
|
|
66632
67107
|
for (const variant of variants) {
|
|
@@ -66663,7 +67138,7 @@ function normalizeOpenAIToolParameters(parameters) {
|
|
|
66663
67138
|
}
|
|
66664
67139
|
function filterResponsesApiTools(tools) {
|
|
66665
67140
|
const hasUnsupportedTopLevelUnion = (params) => {
|
|
66666
|
-
if (!
|
|
67141
|
+
if (!isRecord12(params))
|
|
66667
67142
|
return false;
|
|
66668
67143
|
const topLevelUnionKey = TOP_LEVEL_UNION_KEYS.find((key) => Array.isArray(params[key]));
|
|
66669
67144
|
if (!topLevelUnionKey)
|
|
@@ -66680,7 +67155,7 @@ function filterResponsesApiTools(tools) {
|
|
|
66680
67155
|
return !!(p.oneOf || p.anyOf || p.allOf || p.enum || p.not);
|
|
66681
67156
|
};
|
|
66682
67157
|
const hasUnsupportedTopLevelKeyword = (params) => {
|
|
66683
|
-
if (!
|
|
67158
|
+
if (!isRecord12(params))
|
|
66684
67159
|
return false;
|
|
66685
67160
|
return params.enum !== void 0 || params.not !== void 0;
|
|
66686
67161
|
};
|
|
@@ -66968,7 +67443,7 @@ async function* streamResponsesApiSdk(model, context2, options) {
|
|
|
66968
67443
|
callId: item.call_id,
|
|
66969
67444
|
name: item.name,
|
|
66970
67445
|
stage: "done"
|
|
66971
|
-
}, { logInvalid: true }) :
|
|
67446
|
+
}, { logInvalid: true }) : isRecord12(item.arguments) ? item.arguments : {};
|
|
66972
67447
|
const toolCall = {
|
|
66973
67448
|
type: "toolCall",
|
|
66974
67449
|
id: `${item.call_id}|${item.id}`,
|
|
@@ -67843,7 +68318,7 @@ ${thinkingText}
|
|
|
67843
68318
|
delta: argsDelta,
|
|
67844
68319
|
partial
|
|
67845
68320
|
};
|
|
67846
|
-
} else if (
|
|
68321
|
+
} else if (isRecord12(argsDelta)) {
|
|
67847
68322
|
toolArgumentNormalizer3.warnOnce("delta:object", "OpenAI tool call arguments delta was object", {
|
|
67848
68323
|
callId: block.id,
|
|
67849
68324
|
name: block.name
|
|
@@ -67883,7 +68358,7 @@ ${thinkingText}
|
|
|
67883
68358
|
if (partialArgs !== void 0) {
|
|
67884
68359
|
block.arguments = toolArgumentNormalizer3.parseFromString(partialArgs, { callId: block.id, name: block.name, stage: "done" }, { logInvalid: true });
|
|
67885
68360
|
} else {
|
|
67886
|
-
block.arguments =
|
|
68361
|
+
block.arguments = isRecord12(block.arguments) ? block.arguments : {};
|
|
67887
68362
|
}
|
|
67888
68363
|
}
|
|
67889
68364
|
toolArgBuffers.delete(i2);
|
|
@@ -67973,7 +68448,7 @@ function resolveOpenAICodexAccountId(token, headers) {
|
|
|
67973
68448
|
}
|
|
67974
68449
|
const accountId = process.env.OPENAI_CODEX_ACCOUNT_ID?.trim() ?? process.env.CHATGPT_ACCOUNT_ID?.trim() ?? extractOpenAICodexAccountId(token);
|
|
67975
68450
|
if (!accountId) {
|
|
67976
|
-
throw new Error("OpenAI Codex account id is required. Log in with /login openai-codex or set OPENAI_CODEX_ACCOUNT_ID.");
|
|
68451
|
+
throw new Error("OpenAI Codex account id is required for legacy Codex Responses models. Log in with /login openai-codex:responses or set OPENAI_CODEX_ACCOUNT_ID.");
|
|
67977
68452
|
}
|
|
67978
68453
|
return accountId;
|
|
67979
68454
|
}
|
|
@@ -68534,7 +69009,7 @@ function stringValue4(value) {
|
|
|
68534
69009
|
function getMessageText(item) {
|
|
68535
69010
|
const content = Array.isArray(item.content) ? item.content : [];
|
|
68536
69011
|
return content.map((part) => {
|
|
68537
|
-
if (!
|
|
69012
|
+
if (!isRecord12(part))
|
|
68538
69013
|
return "";
|
|
68539
69014
|
if (part.type === "output_text" && typeof part.text === "string") {
|
|
68540
69015
|
return sanitizeSurrogates(part.text);
|
|
@@ -68547,14 +69022,14 @@ function getMessageText(item) {
|
|
|
68547
69022
|
}
|
|
68548
69023
|
function getReasoningSummaryText(item) {
|
|
68549
69024
|
const summary2 = Array.isArray(item.summary) ? item.summary : [];
|
|
68550
|
-
return summary2.map((part) =>
|
|
69025
|
+
return summary2.map((part) => isRecord12(part) && typeof part.text === "string" ? part.text : "").filter(Boolean).join(`
|
|
68551
69026
|
|
|
68552
69027
|
`);
|
|
68553
69028
|
}
|
|
68554
69029
|
function safeJsonRecord(value) {
|
|
68555
69030
|
try {
|
|
68556
69031
|
const parsed = JSON.parse(value);
|
|
68557
|
-
return
|
|
69032
|
+
return isRecord12(parsed) ? parsed : null;
|
|
68558
69033
|
} catch {
|
|
68559
69034
|
return null;
|
|
68560
69035
|
}
|
|
@@ -68596,346 +69071,6 @@ var init_openai_codex_responses = __esm2(() => {
|
|
|
68596
69071
|
providerLabel: "OpenAI Codex"
|
|
68597
69072
|
});
|
|
68598
69073
|
});
|
|
68599
|
-
var CodexAppServerRpcClient = class _CodexAppServerRpcClient {
|
|
68600
|
-
transport;
|
|
68601
|
-
options;
|
|
68602
|
-
pending = /* @__PURE__ */ new Map();
|
|
68603
|
-
notificationListeners = /* @__PURE__ */ new Set();
|
|
68604
|
-
notificationHistory = [];
|
|
68605
|
-
notificationWaiters = /* @__PURE__ */ new Set();
|
|
68606
|
-
requestHandlers = /* @__PURE__ */ new Set();
|
|
68607
|
-
stderrTail = [];
|
|
68608
|
-
rl;
|
|
68609
|
-
nextId = 1;
|
|
68610
|
-
closed = false;
|
|
68611
|
-
constructor(transport, options = {}) {
|
|
68612
|
-
this.transport = transport;
|
|
68613
|
-
this.options = options;
|
|
68614
|
-
this.rl = createInterface({ input: transport.stdout });
|
|
68615
|
-
this.rl.on("line", (line) => this.handleLine(line));
|
|
68616
|
-
this.rl.on("close", () => this.rejectAll("Codex app-server closed stdout"));
|
|
68617
|
-
transport.stderr?.on("data", (chunk) => this.captureStderr(chunk));
|
|
68618
|
-
transport.once?.("exit", (code, signal) => {
|
|
68619
|
-
const suffix = code === null || code === void 0 ? `signal ${String(signal)}` : `code ${String(code)}`;
|
|
68620
|
-
this.rejectAll(`Codex app-server exited with ${suffix}`);
|
|
68621
|
-
});
|
|
68622
|
-
transport.once?.("error", (error) => {
|
|
68623
|
-
const message = error instanceof Error ? error.message : `Process error: ${String(error)}`;
|
|
68624
|
-
this.rejectAll(message);
|
|
68625
|
-
});
|
|
68626
|
-
}
|
|
68627
|
-
static spawn(options = {}) {
|
|
68628
|
-
const command = options.command ?? "codex";
|
|
68629
|
-
const args = options.args ?? ["app-server", "--listen", "stdio://"];
|
|
68630
|
-
const child = spawnChild(command, args, {
|
|
68631
|
-
cwd: options.cwd,
|
|
68632
|
-
env: options.env ?? process.env,
|
|
68633
|
-
stdio: "pipe"
|
|
68634
|
-
});
|
|
68635
|
-
return new _CodexAppServerRpcClient(child, {
|
|
68636
|
-
requestTimeoutMs: options.requestTimeoutMs
|
|
68637
|
-
});
|
|
68638
|
-
}
|
|
68639
|
-
async initialize(options = {}) {
|
|
68640
|
-
const capabilities = options.experimentalApi || options.optOutNotificationMethods?.length ? {
|
|
68641
|
-
experimentalApi: options.experimentalApi || void 0,
|
|
68642
|
-
optOutNotificationMethods: options.optOutNotificationMethods ?? void 0
|
|
68643
|
-
} : void 0;
|
|
68644
|
-
const result2 = await this.request("initialize", {
|
|
68645
|
-
clientInfo: options.clientInfo ?? DEFAULT_CLIENT_INFO,
|
|
68646
|
-
capabilities
|
|
68647
|
-
}, { timeoutMs: options.timeoutMs });
|
|
68648
|
-
this.notify("initialized");
|
|
68649
|
-
return result2;
|
|
68650
|
-
}
|
|
68651
|
-
request(method, params, options = {}) {
|
|
68652
|
-
if (this.closed) {
|
|
68653
|
-
return Promise.reject(new Error("Codex app-server client is closed"));
|
|
68654
|
-
}
|
|
68655
|
-
const id = this.nextId++;
|
|
68656
|
-
const timeoutMs = options.timeoutMs ?? this.options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
68657
|
-
return new Promise((resolve192, reject) => {
|
|
68658
|
-
const timer = setTimeout(() => {
|
|
68659
|
-
this.pending.delete(id);
|
|
68660
|
-
reject(new Error(`Codex app-server request timed out: ${method}`));
|
|
68661
|
-
}, timeoutMs);
|
|
68662
|
-
this.pending.set(id, {
|
|
68663
|
-
resolve: (value) => resolve192(value),
|
|
68664
|
-
reject,
|
|
68665
|
-
timer
|
|
68666
|
-
});
|
|
68667
|
-
try {
|
|
68668
|
-
this.writeMessage({ id, method, params });
|
|
68669
|
-
} catch (error) {
|
|
68670
|
-
clearTimeout(timer);
|
|
68671
|
-
this.pending.delete(id);
|
|
68672
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
68673
|
-
}
|
|
68674
|
-
});
|
|
68675
|
-
}
|
|
68676
|
-
notify(method, params) {
|
|
68677
|
-
this.writeMessage({ method, params });
|
|
68678
|
-
}
|
|
68679
|
-
onNotification(listener) {
|
|
68680
|
-
this.notificationListeners.add(listener);
|
|
68681
|
-
return () => {
|
|
68682
|
-
this.notificationListeners.delete(listener);
|
|
68683
|
-
};
|
|
68684
|
-
}
|
|
68685
|
-
onRequest(listener) {
|
|
68686
|
-
this.requestHandlers.add(listener);
|
|
68687
|
-
return () => {
|
|
68688
|
-
this.requestHandlers.delete(listener);
|
|
68689
|
-
};
|
|
68690
|
-
}
|
|
68691
|
-
waitForNotification(predicate, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS) {
|
|
68692
|
-
const buffered = this.notificationHistory.find(predicate);
|
|
68693
|
-
if (buffered) {
|
|
68694
|
-
return Promise.resolve(buffered);
|
|
68695
|
-
}
|
|
68696
|
-
if (this.closed) {
|
|
68697
|
-
return Promise.reject(new Error("Codex app-server client is closed"));
|
|
68698
|
-
}
|
|
68699
|
-
return new Promise((resolve192, reject) => {
|
|
68700
|
-
let unsubscribe = () => {
|
|
68701
|
-
};
|
|
68702
|
-
const waiter = {
|
|
68703
|
-
reject: (error) => {
|
|
68704
|
-
clearTimeout(waiter.timer);
|
|
68705
|
-
unsubscribe();
|
|
68706
|
-
this.notificationWaiters.delete(waiter);
|
|
68707
|
-
reject(error);
|
|
68708
|
-
},
|
|
68709
|
-
timer: setTimeout(() => {
|
|
68710
|
-
waiter.reject(new Error("Timed out waiting for Codex app-server notification"));
|
|
68711
|
-
}, timeoutMs),
|
|
68712
|
-
unsubscribe: () => unsubscribe()
|
|
68713
|
-
};
|
|
68714
|
-
unsubscribe = this.onNotification((notification) => {
|
|
68715
|
-
if (!predicate(notification)) {
|
|
68716
|
-
return;
|
|
68717
|
-
}
|
|
68718
|
-
clearTimeout(waiter.timer);
|
|
68719
|
-
waiter.unsubscribe();
|
|
68720
|
-
this.notificationWaiters.delete(waiter);
|
|
68721
|
-
resolve192(notification);
|
|
68722
|
-
});
|
|
68723
|
-
this.notificationWaiters.add(waiter);
|
|
68724
|
-
});
|
|
68725
|
-
}
|
|
68726
|
-
readAccount(refreshToken2 = false) {
|
|
68727
|
-
return this.request("account/read", { refreshToken: refreshToken2 });
|
|
68728
|
-
}
|
|
68729
|
-
startChatGptLogin(flow = "browser") {
|
|
68730
|
-
return this.request("account/login/start", {
|
|
68731
|
-
type: flow === "device" ? "chatgptDeviceCode" : "chatgpt"
|
|
68732
|
-
});
|
|
68733
|
-
}
|
|
68734
|
-
async waitForLoginCompletion(loginId, timeoutMs = DEFAULT_LOGIN_TIMEOUT_MS) {
|
|
68735
|
-
const notification = await this.waitForNotification((candidate) => candidate.method === "account/login/completed" && isRecord12(candidate.params) && candidate.params.loginId === loginId, timeoutMs);
|
|
68736
|
-
const params = notification.params;
|
|
68737
|
-
if (!params?.success) {
|
|
68738
|
-
throw new Error(params?.error || "ChatGPT sign-in did not complete");
|
|
68739
|
-
}
|
|
68740
|
-
return params;
|
|
68741
|
-
}
|
|
68742
|
-
async logout() {
|
|
68743
|
-
await this.request("account/logout", void 0);
|
|
68744
|
-
}
|
|
68745
|
-
close() {
|
|
68746
|
-
if (this.closed) {
|
|
68747
|
-
return;
|
|
68748
|
-
}
|
|
68749
|
-
this.closed = true;
|
|
68750
|
-
this.rejectAll("Codex app-server client closed");
|
|
68751
|
-
this.rl.close();
|
|
68752
|
-
try {
|
|
68753
|
-
this.transport.stdin.end();
|
|
68754
|
-
} catch {
|
|
68755
|
-
}
|
|
68756
|
-
this.transport.kill?.("SIGTERM");
|
|
68757
|
-
}
|
|
68758
|
-
handleLine(line) {
|
|
68759
|
-
const trimmed = line.trim();
|
|
68760
|
-
if (!trimmed) {
|
|
68761
|
-
return;
|
|
68762
|
-
}
|
|
68763
|
-
let message;
|
|
68764
|
-
try {
|
|
68765
|
-
message = JSON.parse(trimmed);
|
|
68766
|
-
} catch {
|
|
68767
|
-
return;
|
|
68768
|
-
}
|
|
68769
|
-
if (!isRecord12(message)) {
|
|
68770
|
-
return;
|
|
68771
|
-
}
|
|
68772
|
-
if ("id" in message && ("result" in message || "error" in message)) {
|
|
68773
|
-
this.handleResponse(message);
|
|
68774
|
-
return;
|
|
68775
|
-
}
|
|
68776
|
-
if (typeof message.method === "string" && "id" in message) {
|
|
68777
|
-
this.handleServerRequest(message);
|
|
68778
|
-
return;
|
|
68779
|
-
}
|
|
68780
|
-
if (typeof message.method === "string") {
|
|
68781
|
-
this.emitNotification({
|
|
68782
|
-
method: message.method,
|
|
68783
|
-
params: message.params
|
|
68784
|
-
});
|
|
68785
|
-
}
|
|
68786
|
-
}
|
|
68787
|
-
handleResponse(response) {
|
|
68788
|
-
if (response.id === void 0) {
|
|
68789
|
-
return;
|
|
68790
|
-
}
|
|
68791
|
-
const pending = this.pending.get(response.id);
|
|
68792
|
-
if (!pending) {
|
|
68793
|
-
return;
|
|
68794
|
-
}
|
|
68795
|
-
this.pending.delete(response.id);
|
|
68796
|
-
clearTimeout(pending.timer);
|
|
68797
|
-
if (response.error) {
|
|
68798
|
-
const message = response.error.message ?? "Codex app-server request failed";
|
|
68799
|
-
pending.reject(new Error(message));
|
|
68800
|
-
return;
|
|
68801
|
-
}
|
|
68802
|
-
pending.resolve(response.result);
|
|
68803
|
-
}
|
|
68804
|
-
async handleServerRequest(request) {
|
|
68805
|
-
this.emitNotification({
|
|
68806
|
-
method: request.method,
|
|
68807
|
-
params: request.params
|
|
68808
|
-
});
|
|
68809
|
-
for (const handler of Array.from(this.requestHandlers)) {
|
|
68810
|
-
try {
|
|
68811
|
-
const handled = await handler(request);
|
|
68812
|
-
if (!handled.handled) {
|
|
68813
|
-
continue;
|
|
68814
|
-
}
|
|
68815
|
-
if ("error" in handled) {
|
|
68816
|
-
this.writeMessage({
|
|
68817
|
-
id: request.id,
|
|
68818
|
-
error: {
|
|
68819
|
-
code: handled.error.code ?? -32e3,
|
|
68820
|
-
message: handled.error.message,
|
|
68821
|
-
data: handled.error.data
|
|
68822
|
-
}
|
|
68823
|
-
});
|
|
68824
|
-
return;
|
|
68825
|
-
}
|
|
68826
|
-
this.writeMessage({ id: request.id, result: handled.result });
|
|
68827
|
-
return;
|
|
68828
|
-
} catch (error) {
|
|
68829
|
-
this.writeMessage({
|
|
68830
|
-
id: request.id,
|
|
68831
|
-
error: {
|
|
68832
|
-
code: -32e3,
|
|
68833
|
-
message: error instanceof Error ? error.message : String(error)
|
|
68834
|
-
}
|
|
68835
|
-
});
|
|
68836
|
-
return;
|
|
68837
|
-
}
|
|
68838
|
-
}
|
|
68839
|
-
const fallback = defaultServerRequestResponse(request.method);
|
|
68840
|
-
if (fallback.ok) {
|
|
68841
|
-
this.writeMessage({ id: request.id, result: fallback.result });
|
|
68842
|
-
return;
|
|
68843
|
-
}
|
|
68844
|
-
this.writeMessage({
|
|
68845
|
-
id: request.id,
|
|
68846
|
-
error: {
|
|
68847
|
-
code: -32601,
|
|
68848
|
-
message: `Unsupported Codex app-server request: ${request.method}`
|
|
68849
|
-
}
|
|
68850
|
-
});
|
|
68851
|
-
}
|
|
68852
|
-
emitNotification(notification) {
|
|
68853
|
-
this.notificationHistory.push(notification);
|
|
68854
|
-
if (this.notificationHistory.length > MAX_NOTIFICATION_HISTORY) {
|
|
68855
|
-
this.notificationHistory.shift();
|
|
68856
|
-
}
|
|
68857
|
-
for (const listener of this.notificationListeners) {
|
|
68858
|
-
listener(notification);
|
|
68859
|
-
}
|
|
68860
|
-
}
|
|
68861
|
-
writeMessage(message) {
|
|
68862
|
-
const compact = Object.fromEntries(Object.entries(message).filter(([, value]) => value !== void 0));
|
|
68863
|
-
const line = `${JSON.stringify(compact)}
|
|
68864
|
-
`;
|
|
68865
|
-
if (!this.transport.stdin.write(line)) {
|
|
68866
|
-
}
|
|
68867
|
-
}
|
|
68868
|
-
captureStderr(chunk) {
|
|
68869
|
-
const text2 = Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk);
|
|
68870
|
-
for (const line of text2.split(/\r?\n/)) {
|
|
68871
|
-
const trimmed = line.trim();
|
|
68872
|
-
if (!trimmed) {
|
|
68873
|
-
continue;
|
|
68874
|
-
}
|
|
68875
|
-
this.stderrTail.push(trimmed);
|
|
68876
|
-
if (this.stderrTail.length > 20) {
|
|
68877
|
-
this.stderrTail.shift();
|
|
68878
|
-
}
|
|
68879
|
-
}
|
|
68880
|
-
}
|
|
68881
|
-
rejectAll(message) {
|
|
68882
|
-
this.closed = true;
|
|
68883
|
-
const stderr = this.stderrTail.length ? `
|
|
68884
|
-
${this.stderrTail.slice(-5).join(`
|
|
68885
|
-
`)}` : "";
|
|
68886
|
-
const error = new Error(`${message}${stderr}`);
|
|
68887
|
-
for (const pending of this.pending.values()) {
|
|
68888
|
-
clearTimeout(pending.timer);
|
|
68889
|
-
pending.reject(error);
|
|
68890
|
-
}
|
|
68891
|
-
this.pending.clear();
|
|
68892
|
-
for (const waiter of Array.from(this.notificationWaiters)) {
|
|
68893
|
-
waiter.reject(error);
|
|
68894
|
-
}
|
|
68895
|
-
this.notificationWaiters.clear();
|
|
68896
|
-
}
|
|
68897
|
-
};
|
|
68898
|
-
function createCodexAppServerClient(options = {}) {
|
|
68899
|
-
return CodexAppServerRpcClient.spawn(options);
|
|
68900
|
-
}
|
|
68901
|
-
function isRecord12(value) {
|
|
68902
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
68903
|
-
}
|
|
68904
|
-
function defaultServerRequestResponse(method) {
|
|
68905
|
-
switch (method) {
|
|
68906
|
-
case "item/commandExecution/requestApproval":
|
|
68907
|
-
return { ok: true, result: { decision: "decline" } };
|
|
68908
|
-
case "item/fileChange/requestApproval":
|
|
68909
|
-
return { ok: true, result: { decision: "decline" } };
|
|
68910
|
-
case "item/permissions/requestApproval":
|
|
68911
|
-
return { ok: true, result: { permissions: {}, scope: "turn" } };
|
|
68912
|
-
case "item/tool/requestUserInput":
|
|
68913
|
-
return { ok: true, result: { answers: {} } };
|
|
68914
|
-
case "mcpServer/elicitation/request":
|
|
68915
|
-
return {
|
|
68916
|
-
ok: true,
|
|
68917
|
-
result: { action: "decline", content: null, _meta: null }
|
|
68918
|
-
};
|
|
68919
|
-
case "applyPatchApproval":
|
|
68920
|
-
case "execCommandApproval":
|
|
68921
|
-
return { ok: true, result: { decision: "denied" } };
|
|
68922
|
-
default:
|
|
68923
|
-
return { ok: false };
|
|
68924
|
-
}
|
|
68925
|
-
}
|
|
68926
|
-
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
68927
|
-
var DEFAULT_LOGIN_TIMEOUT_MS;
|
|
68928
|
-
var MAX_NOTIFICATION_HISTORY = 100;
|
|
68929
|
-
var DEFAULT_CLIENT_INFO;
|
|
68930
|
-
var init_app_server_client = __esm2(() => {
|
|
68931
|
-
init_package_version();
|
|
68932
|
-
DEFAULT_LOGIN_TIMEOUT_MS = 5 * 6e4;
|
|
68933
|
-
DEFAULT_CLIENT_INFO = {
|
|
68934
|
-
name: "maestro",
|
|
68935
|
-
title: "Maestro",
|
|
68936
|
-
version: readPackageVersion()
|
|
68937
|
-
};
|
|
68938
|
-
});
|
|
68939
69074
|
function isCodexAppServerApi(api) {
|
|
68940
69075
|
return api === "openai-codex-app-server";
|
|
68941
69076
|
}
|
|
@@ -71526,7 +71661,7 @@ async function* streamBedrock(model, context2, options) {
|
|
|
71526
71661
|
delta: input2,
|
|
71527
71662
|
partial
|
|
71528
71663
|
};
|
|
71529
|
-
} else if (
|
|
71664
|
+
} else if (isRecord12(input2)) {
|
|
71530
71665
|
toolArgumentNormalizer7.warnOnce("delta:object", "Bedrock tool_use input delta was object", { toolId: block.id, name: block.name });
|
|
71531
71666
|
toolArgOverrides.set(idx, input2);
|
|
71532
71667
|
toolArgBuffers.delete(idx);
|
|
@@ -71585,7 +71720,7 @@ async function* streamBedrock(model, context2, options) {
|
|
|
71585
71720
|
if (buf !== void 0) {
|
|
71586
71721
|
block.arguments = toolArgumentNormalizer7.parseFromString(buf, { toolId: block.id, name: block.name, stage: "done" }, { logInvalid: true });
|
|
71587
71722
|
} else {
|
|
71588
|
-
block.arguments =
|
|
71723
|
+
block.arguments = isRecord12(block.arguments) ? block.arguments : {};
|
|
71589
71724
|
}
|
|
71590
71725
|
}
|
|
71591
71726
|
toolArgBuffers.delete(idx);
|
|
@@ -92409,7 +92544,7 @@ var BackgroundTaskRuntime = class {
|
|
|
92409
92544
|
};
|
|
92410
92545
|
attach(child.stdout);
|
|
92411
92546
|
attach(child.stderr);
|
|
92412
|
-
child.once("
|
|
92547
|
+
child.once("close", closeStream);
|
|
92413
92548
|
child.once("error", closeStream);
|
|
92414
92549
|
}
|
|
92415
92550
|
};
|
|
@@ -98067,7 +98202,7 @@ function createAuthResolver(options) {
|
|
|
98067
98202
|
return;
|
|
98068
98203
|
};
|
|
98069
98204
|
}
|
|
98070
|
-
var
|
|
98205
|
+
var init_auth2 = __esm2(() => {
|
|
98071
98206
|
init_env_aliases();
|
|
98072
98207
|
init_oauth();
|
|
98073
98208
|
init_storage();
|
|
@@ -98154,7 +98289,7 @@ function createAuthSetup(params) {
|
|
|
98154
98289
|
var init_auth_setup = __esm2(() => {
|
|
98155
98290
|
init_registry();
|
|
98156
98291
|
init_api_keys();
|
|
98157
|
-
|
|
98292
|
+
init_auth2();
|
|
98158
98293
|
init_evalops_managed();
|
|
98159
98294
|
});
|
|
98160
98295
|
var DEFAULT_CHECKPOINT_CONFIG;
|
|
@@ -99610,12 +99745,12 @@ async function bootstrapEvalOpsAgent(options = {}, dependencies = {}) {
|
|
|
99610
99745
|
});
|
|
99611
99746
|
}
|
|
99612
99747
|
try {
|
|
99613
|
-
deps.onStatus({ message: "Loading EvalOps control-plane
|
|
99748
|
+
deps.onStatus({ message: "Loading EvalOps control-plane status" });
|
|
99614
99749
|
controlPlaneSummary = await loadControlPlaneSummary(client);
|
|
99615
99750
|
} catch (error) {
|
|
99616
99751
|
const reason = error instanceof Error ? error.message : String(error);
|
|
99617
99752
|
deps.onStatus({
|
|
99618
|
-
message: `EvalOps control-plane
|
|
99753
|
+
message: `EvalOps control-plane status unavailable; continuing bootstrap (${reason})`
|
|
99619
99754
|
});
|
|
99620
99755
|
} finally {
|
|
99621
99756
|
await client.close().catch(() => {
|
|
@@ -107278,6 +107413,47 @@ ${chalk7.dim("No turns recorded yet.")}`;
|
|
|
107278
107413
|
var MAX_SAMPLES = 1e3;
|
|
107279
107414
|
var init_session_perf = () => {
|
|
107280
107415
|
};
|
|
107416
|
+
async function getTuiAuthState(currentProvider) {
|
|
107417
|
+
const providers = listOAuthProviders();
|
|
107418
|
+
let hasCodexAppServerAccount;
|
|
107419
|
+
const maybeHasCodexAppServerAccount = async () => {
|
|
107420
|
+
hasCodexAppServerAccount ??= await hasOpenAICodexAppServerAccount();
|
|
107421
|
+
return hasCodexAppServerAccount;
|
|
107422
|
+
};
|
|
107423
|
+
if (providers.length === 0) {
|
|
107424
|
+
if (await maybeHasCodexAppServerAccount()) {
|
|
107425
|
+
return {
|
|
107426
|
+
authenticated: true,
|
|
107427
|
+
provider: "openai-codex",
|
|
107428
|
+
mode: "app-server"
|
|
107429
|
+
};
|
|
107430
|
+
}
|
|
107431
|
+
return { authenticated: false };
|
|
107432
|
+
}
|
|
107433
|
+
let activeProvider = providers[0];
|
|
107434
|
+
if (currentProvider === "openai-codex") {
|
|
107435
|
+
if (providers.includes("openai-codex") || await maybeHasCodexAppServerAccount()) {
|
|
107436
|
+
activeProvider = "openai-codex";
|
|
107437
|
+
}
|
|
107438
|
+
} else if (currentProvider && providers.includes(currentProvider)) {
|
|
107439
|
+
activeProvider = currentProvider;
|
|
107440
|
+
}
|
|
107441
|
+
if (!activeProvider) {
|
|
107442
|
+
return { authenticated: false, provider: void 0, mode: void 0 };
|
|
107443
|
+
}
|
|
107444
|
+
const credentials = loadOAuthCredentials(activeProvider);
|
|
107445
|
+
const storedMode = credentials?.metadata?.mode;
|
|
107446
|
+
const mode = storedMode ?? (activeProvider === "openai-codex" && await maybeHasCodexAppServerAccount() ? "app-server" : void 0);
|
|
107447
|
+
return {
|
|
107448
|
+
authenticated: true,
|
|
107449
|
+
provider: activeProvider,
|
|
107450
|
+
mode
|
|
107451
|
+
};
|
|
107452
|
+
}
|
|
107453
|
+
var init_auth_state = __esm2(() => {
|
|
107454
|
+
init_auth();
|
|
107455
|
+
init_storage();
|
|
107456
|
+
});
|
|
107281
107457
|
function extractRetryDelayMs(errorMessage32) {
|
|
107282
107458
|
if (!errorMessage32)
|
|
107283
107459
|
return;
|
|
@@ -127382,8 +127558,8 @@ function createAuthCommandHandler(deps) {
|
|
|
127382
127558
|
}
|
|
127383
127559
|
});
|
|
127384
127560
|
}
|
|
127385
|
-
function showAuthStatus(ctx, deps) {
|
|
127386
|
-
const state2 = deps.getAuthState();
|
|
127561
|
+
async function showAuthStatus(ctx, deps) {
|
|
127562
|
+
const state2 = await deps.getAuthState();
|
|
127387
127563
|
if (state2.authenticated) {
|
|
127388
127564
|
ctx.showInfo(`Authentication Status:
|
|
127389
127565
|
Authenticated: yes
|
|
@@ -129184,7 +129360,12 @@ var init_command_catalog = __esm2(() => {
|
|
|
129184
129360
|
description: "OAuth provider (openai-codex by default)"
|
|
129185
129361
|
}
|
|
129186
129362
|
],
|
|
129187
|
-
examples: [
|
|
129363
|
+
examples: [
|
|
129364
|
+
"/login",
|
|
129365
|
+
"/login openai-codex",
|
|
129366
|
+
"/login openai-codex:responses",
|
|
129367
|
+
"/login openai"
|
|
129368
|
+
]
|
|
129188
129369
|
}),
|
|
129189
129370
|
withArgs("logout", "logout", {
|
|
129190
129371
|
description: "Remove stored OAuth credentials",
|
|
@@ -139553,20 +139734,42 @@ var init_mcp_events_setup = __esm2(() => {
|
|
|
139553
139734
|
init_composers();
|
|
139554
139735
|
init_mcp();
|
|
139555
139736
|
});
|
|
139737
|
+
function resolveLogoutProviderInfo(providerId) {
|
|
139738
|
+
const provider = getOAuthProviders().find((candidate) => candidate.id === providerId);
|
|
139739
|
+
if (provider) {
|
|
139740
|
+
return provider;
|
|
139741
|
+
}
|
|
139742
|
+
if (providerId === "anthropic") {
|
|
139743
|
+
return {
|
|
139744
|
+
id: "anthropic",
|
|
139745
|
+
name: "Anthropic OAuth",
|
|
139746
|
+
description: "Legacy Anthropic OAuth credentials (logout only)",
|
|
139747
|
+
available: true
|
|
139748
|
+
};
|
|
139749
|
+
}
|
|
139750
|
+
return {
|
|
139751
|
+
id: providerId,
|
|
139752
|
+
name: providerId,
|
|
139753
|
+
description: "OAuth credentials",
|
|
139754
|
+
available: true
|
|
139755
|
+
};
|
|
139756
|
+
}
|
|
139556
139757
|
var OAuthSelectorComponent;
|
|
139557
139758
|
var init_oauth_selector = __esm2(() => {
|
|
139558
139759
|
init_oauth();
|
|
139559
139760
|
OAuthSelectorComponent = class OAuthSelectorComponent extends Container11 {
|
|
139560
139761
|
onSelectCallback;
|
|
139561
139762
|
onCancelCallback;
|
|
139763
|
+
providerIds;
|
|
139562
139764
|
listContainer;
|
|
139563
139765
|
allProviders = [];
|
|
139564
139766
|
selectedIndex = 0;
|
|
139565
139767
|
mode;
|
|
139566
|
-
constructor(mode, onSelectCallback, onCancelCallback) {
|
|
139768
|
+
constructor(mode, onSelectCallback, onCancelCallback, providerIds) {
|
|
139567
139769
|
super();
|
|
139568
139770
|
this.onSelectCallback = onSelectCallback;
|
|
139569
139771
|
this.onCancelCallback = onCancelCallback;
|
|
139772
|
+
this.providerIds = providerIds;
|
|
139570
139773
|
this.mode = mode;
|
|
139571
139774
|
this.loadProviders();
|
|
139572
139775
|
this.addChild(new Spacer34(1));
|
|
@@ -139580,7 +139783,7 @@ var init_oauth_selector = __esm2(() => {
|
|
|
139580
139783
|
}
|
|
139581
139784
|
loadProviders() {
|
|
139582
139785
|
if (this.mode === "logout") {
|
|
139583
|
-
this.allProviders = getOAuthLogoutProviders();
|
|
139786
|
+
this.allProviders = this.providerIds ? this.providerIds.map((providerId) => resolveLogoutProviderInfo(providerId)) : getOAuthLogoutProviders();
|
|
139584
139787
|
} else {
|
|
139585
139788
|
this.allProviders = getOAuthProviders().filter((p) => p.available);
|
|
139586
139789
|
}
|
|
@@ -139646,7 +139849,7 @@ var OAuthSelectorView = class {
|
|
|
139646
139849
|
}, () => {
|
|
139647
139850
|
this.options.onCancel();
|
|
139648
139851
|
this.hide();
|
|
139649
|
-
});
|
|
139852
|
+
}, this.options.providers);
|
|
139650
139853
|
this.options.modalManager.push(this.selector);
|
|
139651
139854
|
}
|
|
139652
139855
|
hide() {
|
|
@@ -139693,15 +139896,20 @@ var OAuthFlowController = class {
|
|
|
139693
139896
|
this.isOAuthFlowActive = true;
|
|
139694
139897
|
const args = argumentText.trim().toLowerCase();
|
|
139695
139898
|
let requestedProvider;
|
|
139899
|
+
let requestedMode;
|
|
139696
139900
|
if (args) {
|
|
139697
139901
|
if (args.includes(":")) {
|
|
139698
139902
|
const parts = args.split(":").map((s2) => s2.trim());
|
|
139699
139903
|
requestedProvider = parts[0];
|
|
139700
139904
|
const mode = parts[1];
|
|
139701
139905
|
if (mode) {
|
|
139702
|
-
|
|
139703
|
-
|
|
139704
|
-
|
|
139906
|
+
if (requestedProvider === "openai-codex" && mode === "responses") {
|
|
139907
|
+
requestedMode = mode;
|
|
139908
|
+
} else {
|
|
139909
|
+
this.isOAuthFlowActive = false;
|
|
139910
|
+
showError("Provider login modes are no longer supported, except /login openai-codex:responses for legacy Codex Responses credentials.");
|
|
139911
|
+
return;
|
|
139912
|
+
}
|
|
139705
139913
|
}
|
|
139706
139914
|
} else {
|
|
139707
139915
|
requestedProvider = args;
|
|
@@ -139717,7 +139925,7 @@ var OAuthFlowController = class {
|
|
|
139717
139925
|
}
|
|
139718
139926
|
const defaultProvider = providers.find((provider) => provider.id === "openai-codex");
|
|
139719
139927
|
if (!requestedProvider && defaultProvider) {
|
|
139720
|
-
await this.performOAuthLogin(defaultProvider.id,
|
|
139928
|
+
await this.performOAuthLogin(defaultProvider.id, requestedMode, showError);
|
|
139721
139929
|
return;
|
|
139722
139930
|
}
|
|
139723
139931
|
if (providers.length === 1 || requestedProvider) {
|
|
@@ -139727,7 +139935,7 @@ var OAuthFlowController = class {
|
|
|
139727
139935
|
showError(`Unknown provider: ${requestedProvider}`);
|
|
139728
139936
|
return;
|
|
139729
139937
|
}
|
|
139730
|
-
await this.performOAuthLogin(provider.id,
|
|
139938
|
+
await this.performOAuthLogin(provider.id, requestedMode, showError);
|
|
139731
139939
|
return;
|
|
139732
139940
|
}
|
|
139733
139941
|
this.oauthLoginView = new OAuthSelectorView({
|
|
@@ -139756,8 +139964,8 @@ var OAuthFlowController = class {
|
|
|
139756
139964
|
this.isOAuthFlowActive = true;
|
|
139757
139965
|
const args = argumentText.trim().toLowerCase();
|
|
139758
139966
|
const requestedProvider = args || null;
|
|
139759
|
-
const {
|
|
139760
|
-
const loggedInProviders =
|
|
139967
|
+
const { listOAuthLogoutProvidersWithCodexAppServer: listOAuthLogoutProvidersWithCodexAppServer2 } = await Promise.resolve().then(() => (init_oauth(), exports_oauth));
|
|
139968
|
+
const loggedInProviders = await listOAuthLogoutProvidersWithCodexAppServer2();
|
|
139761
139969
|
if (loggedInProviders.length === 0) {
|
|
139762
139970
|
this.isOAuthFlowActive = false;
|
|
139763
139971
|
showInfo("No OAuth providers logged in. Use /login first.");
|
|
@@ -139778,6 +139986,7 @@ var OAuthFlowController = class {
|
|
|
139778
139986
|
modalManager: this.modalManager,
|
|
139779
139987
|
ui: this.renderContext.ui,
|
|
139780
139988
|
mode: "logout",
|
|
139989
|
+
providers: loggedInProviders,
|
|
139781
139990
|
onProviderSelected: async (providerId) => {
|
|
139782
139991
|
try {
|
|
139783
139992
|
await this.performOAuthLogout(providerId, showError);
|
|
@@ -139936,8 +140145,9 @@ Areas: analytics, billing, crm, hris, support`;
|
|
|
139936
140145
|
}
|
|
139937
140146
|
});
|
|
139938
140147
|
this.notificationView.showToast(`Successfully authenticated with ${providerId}!`, "success");
|
|
140148
|
+
const completionMessage = providerId === "openai-codex" && mode !== "responses" ? "Authentication complete. Codex app-server sign-in is ready." : `Authentication complete. ${providerId} OAuth credentials saved.`;
|
|
139939
140149
|
chatContainer.addChild(new Spacer35(1));
|
|
139940
|
-
chatContainer.addChild(new Text38(
|
|
140150
|
+
chatContainer.addChild(new Text38(completionMessage, 1, 0));
|
|
139941
140151
|
requestRender();
|
|
139942
140152
|
} catch (error) {
|
|
139943
140153
|
const message = error instanceof Error ? error.message : "Login failed";
|
|
@@ -139962,9 +140172,10 @@ Areas: analytics, billing, crm, hris, support`;
|
|
|
139962
140172
|
try {
|
|
139963
140173
|
const { logout: logout2 } = await Promise.resolve().then(() => (init_oauth(), exports_oauth));
|
|
139964
140174
|
await logout2(providerId);
|
|
139965
|
-
|
|
140175
|
+
const message = providerId === "openai-codex" ? "Signed out from openai-codex" : `${providerId} OAuth credentials removed`;
|
|
140176
|
+
this.notificationView.showToast(message, "success");
|
|
139966
140177
|
chatContainer.addChild(new Spacer35(1));
|
|
139967
|
-
chatContainer.addChild(new Text38(
|
|
140178
|
+
chatContainer.addChild(new Text38(message, 1, 0));
|
|
139968
140179
|
requestRender();
|
|
139969
140180
|
} catch (error) {
|
|
139970
140181
|
const message = error instanceof Error ? error.message : "Logout failed";
|
|
@@ -146593,26 +146804,8 @@ ${hints}`, 1, 0));
|
|
|
146593
146804
|
this.footer.dispose();
|
|
146594
146805
|
process.stdout.off("resize", this.resizeHandler);
|
|
146595
146806
|
}
|
|
146596
|
-
getActualAuthState() {
|
|
146597
|
-
|
|
146598
|
-
if (providers.length === 0) {
|
|
146599
|
-
return { authenticated: false };
|
|
146600
|
-
}
|
|
146601
|
-
const currentProvider = this.agent.state.model?.provider;
|
|
146602
|
-
let activeProvider = providers[0];
|
|
146603
|
-
if (currentProvider && providers.includes(currentProvider)) {
|
|
146604
|
-
activeProvider = currentProvider;
|
|
146605
|
-
}
|
|
146606
|
-
if (!activeProvider) {
|
|
146607
|
-
return { authenticated: false, provider: void 0, mode: void 0 };
|
|
146608
|
-
}
|
|
146609
|
-
const credentials = loadOAuthCredentials(activeProvider);
|
|
146610
|
-
const mode = credentials?.metadata?.mode;
|
|
146611
|
-
return {
|
|
146612
|
-
authenticated: true,
|
|
146613
|
-
provider: activeProvider,
|
|
146614
|
-
mode
|
|
146615
|
-
};
|
|
146807
|
+
async getActualAuthState() {
|
|
146808
|
+
return getTuiAuthState(this.agent.state.model?.provider);
|
|
146616
146809
|
}
|
|
146617
146810
|
async detectAndApplyTerminalTheme() {
|
|
146618
146811
|
const auto = process.env.MAESTRO_TUI_AUTO_THEME;
|
|
@@ -146717,13 +146910,13 @@ var init_tui_renderer = __esm2(() => {
|
|
|
146717
146910
|
init_mcp();
|
|
146718
146911
|
init_prompt_recovery2();
|
|
146719
146912
|
init_registry();
|
|
146720
|
-
init_storage();
|
|
146721
146913
|
init_opentelemetry();
|
|
146722
146914
|
init_manager3();
|
|
146723
146915
|
init_telemetry();
|
|
146724
146916
|
init_session_perf();
|
|
146725
146917
|
init_theme();
|
|
146726
146918
|
init_training();
|
|
146919
|
+
init_auth_state();
|
|
146727
146920
|
init_auto_compaction();
|
|
146728
146921
|
init_auto_retry();
|
|
146729
146922
|
init_compaction_restoration();
|
|
@@ -146985,7 +147178,7 @@ function parseArgs(args) {
|
|
|
146985
147178
|
i2++;
|
|
146986
147179
|
}
|
|
146987
147180
|
} else if (arg && (Array.from(DEPRECATED_FLAGS_WITH_VALUES).some((flag) => arg.startsWith(`${flag}=`)) || DEPRECATED_FLAG_PREFIXES.some((flag) => arg.startsWith(flag)))) {
|
|
146988
|
-
} else if (result2.command === "codex" && result2.subcommand === "login" && (arg === "--device" || arg === "--device-code")) {
|
|
147181
|
+
} else if (result2.command === "codex" && result2.subcommand === "login" && (arg === "--device" || arg === "--device-code" || arg === "--device-auth")) {
|
|
146989
147182
|
if (!result2.commandArgs) {
|
|
146990
147183
|
result2.commandArgs = [];
|
|
146991
147184
|
}
|
|
@@ -163206,18 +163399,32 @@ async function handleCodexCommand(subcommand, params = []) {
|
|
|
163206
163399
|
}
|
|
163207
163400
|
}
|
|
163208
163401
|
async function handleLogin(params = []) {
|
|
163209
|
-
const deviceFlow = params.includes("--device") || params.includes("--device-code");
|
|
163402
|
+
const deviceFlow = params.includes("--device") || params.includes("--device-code") || params.includes("--device-auth");
|
|
163403
|
+
const forceLogin = params.includes("--force") || params.includes("--refresh");
|
|
163210
163404
|
console.log(chalk63.bold("Maestro OpenAI Codex Login"));
|
|
163211
163405
|
const client = createCodexAppServerClient();
|
|
163212
163406
|
try {
|
|
163213
|
-
await client.initialize();
|
|
163214
|
-
|
|
163215
|
-
|
|
163407
|
+
await client.initialize({ experimentalApi: true });
|
|
163408
|
+
if (!forceLogin) {
|
|
163409
|
+
let account2 = null;
|
|
163410
|
+
try {
|
|
163411
|
+
account2 = await client.readAccount(true);
|
|
163412
|
+
} catch {
|
|
163413
|
+
console.log(chalk63.yellow("Codex app-server account refresh failed; starting a new sign-in flow."));
|
|
163414
|
+
}
|
|
163415
|
+
if (account2?.account) {
|
|
163416
|
+
console.log(chalk63.green(`OpenAI Codex is already signed in${accountLabel2(account2)}.`));
|
|
163417
|
+
console.log(chalk63.dim('Run "maestro codex login --force" to start a new sign-in flow.'));
|
|
163418
|
+
return;
|
|
163419
|
+
}
|
|
163420
|
+
}
|
|
163421
|
+
const login2 = await client.startChatGptLogin(deviceFlow ? "device" : "browser", { codexStreamlinedLogin: true });
|
|
163422
|
+
if (isBrowserLogin2(login2)) {
|
|
163216
163423
|
console.log(chalk63.yellow("Open this URL in your browser to sign in with ChatGPT:"));
|
|
163217
163424
|
console.log(chalk63.underline(login2.authUrl));
|
|
163218
163425
|
console.log(chalk63.dim("Waiting for ChatGPT sign-in to complete..."));
|
|
163219
163426
|
await client.waitForLoginCompletion(login2.loginId);
|
|
163220
|
-
} else if (
|
|
163427
|
+
} else if (isDeviceCodeLogin2(login2)) {
|
|
163221
163428
|
console.log(chalk63.yellow("Open this URL and enter the code:"));
|
|
163222
163429
|
console.log(chalk63.underline(login2.verificationUrl));
|
|
163223
163430
|
console.log(chalk63.bold(login2.userCode));
|
|
@@ -163227,11 +163434,16 @@ async function handleLogin(params = []) {
|
|
|
163227
163434
|
console.log(chalk63.green("OpenAI Codex is already configured with an API key."));
|
|
163228
163435
|
console.log(chalk63.dim('Select provider "openai-codex" or a model like "openai-codex/gpt-5.5".'));
|
|
163229
163436
|
return;
|
|
163437
|
+
} else if (isAuthTokensLogin(login2)) {
|
|
163438
|
+
const account2 = await client.readAccount(true);
|
|
163439
|
+
console.log(chalk63.green(`OpenAI Codex is using externally managed ChatGPT auth${accountLabel2(account2)}.`));
|
|
163440
|
+
console.log(chalk63.dim('Select provider "openai-codex" or a model like "openai-codex/gpt-5.5".'));
|
|
163441
|
+
return;
|
|
163230
163442
|
} else {
|
|
163231
163443
|
throw new Error(`Unsupported Codex login response: ${login2.type}`);
|
|
163232
163444
|
}
|
|
163233
163445
|
const account = await client.readAccount(true);
|
|
163234
|
-
console.log(chalk63.green(`Signed in with ChatGPT${
|
|
163446
|
+
console.log(chalk63.green(`Signed in with ChatGPT${accountLabel2(account)}.`));
|
|
163235
163447
|
console.log(chalk63.dim('Select provider "openai-codex" or a model like "openai-codex/gpt-5.5".'));
|
|
163236
163448
|
} finally {
|
|
163237
163449
|
client.close();
|
|
@@ -163257,7 +163469,7 @@ async function handleStatus() {
|
|
|
163257
163469
|
console.log(chalk63.dim('Run "maestro codex login" to sign in with ChatGPT.'));
|
|
163258
163470
|
return;
|
|
163259
163471
|
}
|
|
163260
|
-
console.log(chalk63.green(`OpenAI Codex is signed in${
|
|
163472
|
+
console.log(chalk63.green(`OpenAI Codex is signed in${accountLabel2(account)}.`));
|
|
163261
163473
|
} finally {
|
|
163262
163474
|
client.close();
|
|
163263
163475
|
}
|
|
@@ -163294,7 +163506,7 @@ async function handleDoctor() {
|
|
|
163294
163506
|
client.close();
|
|
163295
163507
|
}
|
|
163296
163508
|
}
|
|
163297
|
-
function
|
|
163509
|
+
function accountLabel2(state2) {
|
|
163298
163510
|
const account = state2.account;
|
|
163299
163511
|
if (!account || account.type !== "chatgpt") {
|
|
163300
163512
|
return "";
|
|
@@ -163316,13 +163528,16 @@ function accountDoctorLabel(state2) {
|
|
|
163316
163528
|
}
|
|
163317
163529
|
return account.type;
|
|
163318
163530
|
}
|
|
163319
|
-
function
|
|
163531
|
+
function isBrowserLogin2(value) {
|
|
163320
163532
|
return Boolean(value && typeof value === "object") && value.type === "chatgpt" && typeof value.loginId === "string" && typeof value.authUrl === "string";
|
|
163321
163533
|
}
|
|
163322
163534
|
function isApiKeyLogin(value) {
|
|
163323
163535
|
return Boolean(value && typeof value === "object") && value.type === "apiKey";
|
|
163324
163536
|
}
|
|
163325
|
-
function
|
|
163537
|
+
function isAuthTokensLogin(value) {
|
|
163538
|
+
return Boolean(value && typeof value === "object") && value.type === "chatgptAuthTokens";
|
|
163539
|
+
}
|
|
163540
|
+
function isDeviceCodeLogin2(value) {
|
|
163326
163541
|
return Boolean(value && typeof value === "object") && value.type === "chatgptDeviceCode" && typeof value.loginId === "string" && typeof value.verificationUrl === "string" && typeof value.userCode === "string";
|
|
163327
163542
|
}
|
|
163328
163543
|
var init_codex = __esm2(() => {
|
|
@@ -171280,6 +171495,7 @@ function platformA2APushSnapshot(payload, req) {
|
|
|
171280
171495
|
return withPlatformA2APushContext({
|
|
171281
171496
|
kind: "statusUpdate",
|
|
171282
171497
|
taskId,
|
|
171498
|
+
...messageIdFields(payload, payload.statusUpdate),
|
|
171283
171499
|
contextId: stringField2(payload.statusUpdate, "contextId"),
|
|
171284
171500
|
...ownershipFields(payload, payload.statusUpdate),
|
|
171285
171501
|
state: statusState(payload.statusUpdate),
|
|
@@ -171297,6 +171513,7 @@ function platformA2APushSnapshot(payload, req) {
|
|
|
171297
171513
|
return withPlatformA2APushContext({
|
|
171298
171514
|
kind: "task",
|
|
171299
171515
|
taskId,
|
|
171516
|
+
...messageIdFields(payload, payload.task),
|
|
171300
171517
|
contextId: stringField2(payload.task, "contextId"),
|
|
171301
171518
|
...ownershipFields(payload, payload.task),
|
|
171302
171519
|
state: statusState(payload.task),
|
|
@@ -171311,6 +171528,7 @@ function platformA2APushSnapshot(payload, req) {
|
|
|
171311
171528
|
return withPlatformA2APushContext({
|
|
171312
171529
|
kind: "artifactUpdate",
|
|
171313
171530
|
taskId,
|
|
171531
|
+
...messageIdFields(payload, payload.artifactUpdate),
|
|
171314
171532
|
contextId: stringField2(payload.artifactUpdate, "contextId"),
|
|
171315
171533
|
...ownershipFields(payload, payload.artifactUpdate),
|
|
171316
171534
|
receivedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -171318,12 +171536,14 @@ function platformA2APushSnapshot(payload, req) {
|
|
|
171318
171536
|
}
|
|
171319
171537
|
if (isJsonObject(payload.message)) {
|
|
171320
171538
|
const taskId = stringField2(payload.message, "taskId");
|
|
171321
|
-
|
|
171539
|
+
const messageFields = messageIdFields(payload, payload.message);
|
|
171540
|
+
if (!messageFields.messageId) {
|
|
171322
171541
|
return null;
|
|
171323
171542
|
}
|
|
171324
171543
|
return withPlatformA2APushContext({
|
|
171325
171544
|
kind: "message",
|
|
171326
|
-
taskId,
|
|
171545
|
+
...optionalField("taskId", taskId),
|
|
171546
|
+
...messageFields,
|
|
171327
171547
|
contextId: stringField2(payload.message, "contextId"),
|
|
171328
171548
|
...ownershipFields(payload, payload.message),
|
|
171329
171549
|
receivedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -171372,6 +171592,12 @@ function assertHostedRunnerA2APushBoundary(hostedRunner, snapshot) {
|
|
|
171372
171592
|
if (hostedRunner?.a2aTaskId && snapshot.taskId && hostedRunner.a2aTaskId !== snapshot.taskId) {
|
|
171373
171593
|
throw new ApiError2(404, "A2A task not found");
|
|
171374
171594
|
}
|
|
171595
|
+
if (hostedRunner?.a2aMessageId && snapshotHasBoundaryMessageIdEvidence(snapshot) && !snapshotIncludesMessageId(snapshot, hostedRunner.a2aMessageId)) {
|
|
171596
|
+
throw new ApiError2(404, "A2A message not found");
|
|
171597
|
+
}
|
|
171598
|
+
if (hostedRunner && snapshot.kind === "message" && !hostedRunner.a2aMessageId && !snapshotHasMessageBindingCorrelation(snapshot)) {
|
|
171599
|
+
throw new ApiError2(403, "A2A message push is missing correlation metadata");
|
|
171600
|
+
}
|
|
171375
171601
|
if (!hostedRunner?.workspaceId) {
|
|
171376
171602
|
return;
|
|
171377
171603
|
}
|
|
@@ -171391,6 +171617,9 @@ function recordHostedRunnerA2APush(hostedRunner, snapshot) {
|
|
|
171391
171617
|
if (snapshot.taskId && !hostedRunner.a2aTaskId) {
|
|
171392
171618
|
hostedRunner.a2aTaskId = snapshot.taskId;
|
|
171393
171619
|
}
|
|
171620
|
+
if (snapshot.messageId && !hostedRunner.a2aMessageId && snapshot.kind === "message" && snapshotHasMessageBindingCorrelation(snapshot)) {
|
|
171621
|
+
hostedRunner.a2aMessageId = snapshot.messageId;
|
|
171622
|
+
}
|
|
171394
171623
|
}
|
|
171395
171624
|
function statusState(value) {
|
|
171396
171625
|
const status = isJsonObject(value.status) ? value.status : void 0;
|
|
@@ -171412,6 +171641,84 @@ function ownershipFields(payload, value) {
|
|
|
171412
171641
|
...optionalField("tenantId", ownershipString(payload, value, ["tenantId", "tenant_id", "tenant"]))
|
|
171413
171642
|
};
|
|
171414
171643
|
}
|
|
171644
|
+
function messageIdFields(payload, value) {
|
|
171645
|
+
const messageIds = messageIdsFromSources(payload, value);
|
|
171646
|
+
return {
|
|
171647
|
+
...optionalField("messageId", messageIds[0]),
|
|
171648
|
+
...messageIds.length > 0 ? { messageIds } : {}
|
|
171649
|
+
};
|
|
171650
|
+
}
|
|
171651
|
+
function messageIdsFromSources(payload, value) {
|
|
171652
|
+
const result2 = [];
|
|
171653
|
+
for (const source of messageIdSources(payload, value)) {
|
|
171654
|
+
pushIdentifierStrings(result2, source, [
|
|
171655
|
+
"messageId",
|
|
171656
|
+
"message_id",
|
|
171657
|
+
"a2aMessageId",
|
|
171658
|
+
"a2a_message_id"
|
|
171659
|
+
]);
|
|
171660
|
+
pushIdentifierArrayStrings(result2, source, ["messageIds", "message_ids"]);
|
|
171661
|
+
}
|
|
171662
|
+
const payloadMessage = isJsonObject(payload.message) ? payload.message : void 0;
|
|
171663
|
+
if (payloadMessage) {
|
|
171664
|
+
pushMessageObjectIdentifier(result2, payloadMessage);
|
|
171665
|
+
}
|
|
171666
|
+
return result2;
|
|
171667
|
+
}
|
|
171668
|
+
function messageIdSources(payload, value) {
|
|
171669
|
+
const sources = [value, payload];
|
|
171670
|
+
if (isJsonObject(value.artifact)) {
|
|
171671
|
+
sources.push(value.artifact);
|
|
171672
|
+
}
|
|
171673
|
+
return sources;
|
|
171674
|
+
}
|
|
171675
|
+
function pushMessageObjectIdentifier(target, message) {
|
|
171676
|
+
pushUniqueIdentifier(target, stringField2(message, "id"));
|
|
171677
|
+
pushIdentifierStrings(target, message, [
|
|
171678
|
+
"messageId",
|
|
171679
|
+
"message_id",
|
|
171680
|
+
"a2aMessageId",
|
|
171681
|
+
"a2a_message_id"
|
|
171682
|
+
]);
|
|
171683
|
+
}
|
|
171684
|
+
function pushIdentifierStrings(target, value, keys) {
|
|
171685
|
+
for (const key of keys) {
|
|
171686
|
+
pushUniqueIdentifier(target, stringField2(value, key));
|
|
171687
|
+
const metadata = metadataString3(value, key);
|
|
171688
|
+
pushUniqueIdentifier(target, metadata);
|
|
171689
|
+
}
|
|
171690
|
+
}
|
|
171691
|
+
function pushIdentifierArrayStrings(target, value, keys) {
|
|
171692
|
+
for (const key of keys) {
|
|
171693
|
+
const direct = value[key];
|
|
171694
|
+
if (Array.isArray(direct)) {
|
|
171695
|
+
for (const entry2 of direct) {
|
|
171696
|
+
pushUniqueIdentifier(target, typeof entry2 === "string" ? entry2.trim() : void 0);
|
|
171697
|
+
}
|
|
171698
|
+
}
|
|
171699
|
+
const metadata = isJsonObject(value.metadata) ? value.metadata[key] : void 0;
|
|
171700
|
+
if (Array.isArray(metadata)) {
|
|
171701
|
+
for (const entry2 of metadata) {
|
|
171702
|
+
pushUniqueIdentifier(target, typeof entry2 === "string" ? entry2.trim() : void 0);
|
|
171703
|
+
}
|
|
171704
|
+
}
|
|
171705
|
+
}
|
|
171706
|
+
}
|
|
171707
|
+
function pushUniqueIdentifier(target, value) {
|
|
171708
|
+
if (!value || target.some((entry2) => sameMessageIdentifier(entry2, value))) {
|
|
171709
|
+
return;
|
|
171710
|
+
}
|
|
171711
|
+
target.push(value);
|
|
171712
|
+
}
|
|
171713
|
+
function snapshotHasBoundaryMessageIdEvidence(snapshot) {
|
|
171714
|
+
return snapshot.kind === "message" || snapshot.kind === "task" && Boolean(snapshot.messageIds?.length);
|
|
171715
|
+
}
|
|
171716
|
+
function snapshotHasMessageBindingCorrelation(snapshot) {
|
|
171717
|
+
return Boolean(snapshot.taskId || snapshot.workspaceId);
|
|
171718
|
+
}
|
|
171719
|
+
function snapshotIncludesMessageId(snapshot, messageId) {
|
|
171720
|
+
return (snapshot.messageId ? sameMessageIdentifier(snapshot.messageId, messageId) : false) || (snapshot.messageIds ?? []).some((candidate) => sameMessageIdentifier(candidate, messageId));
|
|
171721
|
+
}
|
|
171415
171722
|
function ownershipString(payload, value, keys) {
|
|
171416
171723
|
for (const source of ownershipSources(payload, value)) {
|
|
171417
171724
|
for (const key of keys) {
|
|
@@ -171447,6 +171754,9 @@ function optionalField(key, value) {
|
|
|
171447
171754
|
function sameIdentifier(left, right) {
|
|
171448
171755
|
return left.trim().toLowerCase() === right.trim().toLowerCase();
|
|
171449
171756
|
}
|
|
171757
|
+
function sameMessageIdentifier(left, right) {
|
|
171758
|
+
return left.trim() === right.trim();
|
|
171759
|
+
}
|
|
171450
171760
|
function stringField2(value, key) {
|
|
171451
171761
|
const field = value[key];
|
|
171452
171762
|
return typeof field === "string" && field.trim().length > 0 ? field.trim() : void 0;
|
|
@@ -176180,6 +176490,11 @@ var HeadlessSessionRuntime = class _HeadlessSessionRuntime {
|
|
|
176180
176490
|
assertHeadlessRuntimeSnapshot(snapshot, "headless runtime snapshot");
|
|
176181
176491
|
return snapshot;
|
|
176182
176492
|
}
|
|
176493
|
+
assertRuntimeReady(action) {
|
|
176494
|
+
if (!this.state.is_ready) {
|
|
176495
|
+
throw new HeadlessRuntimeNotReadyError(action, this.state);
|
|
176496
|
+
}
|
|
176497
|
+
}
|
|
176183
176498
|
getSessionFile() {
|
|
176184
176499
|
return this.sessionManager.getSessionFile();
|
|
176185
176500
|
}
|
|
@@ -176469,6 +176784,9 @@ var HeadlessSessionRuntime = class _HeadlessSessionRuntime {
|
|
|
176469
176784
|
createSubscription(options) {
|
|
176470
176785
|
const role = options?.role ?? "controller";
|
|
176471
176786
|
const explicit = options?.explicit ?? true;
|
|
176787
|
+
if (explicit) {
|
|
176788
|
+
this.assertRuntimeReady("new attachments");
|
|
176789
|
+
}
|
|
176472
176790
|
const announceConnectionInfo = options?.announceConnectionInfo ?? true;
|
|
176473
176791
|
const reusableControllerConnectionId = !options?.connectionId && role === "controller" && this.controllerConnectionId && this.connections.get(this.controllerConnectionId)?.subscriptionIds.size === 0 ? this.controllerConnectionId : void 0;
|
|
176474
176792
|
const requestedConnectionId = options?.connectionId ?? reusableControllerConnectionId;
|
|
@@ -176588,10 +176906,13 @@ var HeadlessSessionRuntime = class _HeadlessSessionRuntime {
|
|
|
176588
176906
|
this.syncSubscriptionState(publish && subscriber.explicit);
|
|
176589
176907
|
return true;
|
|
176590
176908
|
}
|
|
176591
|
-
assertCanSend(role, subscriptionId, connectionId) {
|
|
176909
|
+
assertCanSend(role, subscriptionId, connectionId, options) {
|
|
176592
176910
|
if (role === "viewer") {
|
|
176593
176911
|
throw new Error("Viewer headless connections cannot send messages");
|
|
176594
176912
|
}
|
|
176913
|
+
if (!options?.allowNotReady) {
|
|
176914
|
+
this.assertRuntimeReady("controller messages");
|
|
176915
|
+
}
|
|
176595
176916
|
const subscriber = subscriptionId ? this.subscribers.get(subscriptionId) : void 0;
|
|
176596
176917
|
const connection = subscriber ? this.connections.get(subscriber.connectionId) : this.getConnectionById(connectionId);
|
|
176597
176918
|
if (!subscriptionId && !connection) {
|
|
@@ -176703,6 +177024,7 @@ var HeadlessSessionRuntime = class _HeadlessSessionRuntime {
|
|
|
176703
177024
|
};
|
|
176704
177025
|
}
|
|
176705
177026
|
registerConnection(metadata) {
|
|
177027
|
+
this.assertRuntimeReady("new attachments");
|
|
176706
177028
|
const role = metadata.role ?? "controller";
|
|
176707
177029
|
const connection = this.ensureConnection({
|
|
176708
177030
|
connectionId: metadata.connectionId,
|
|
@@ -176748,6 +177070,9 @@ var HeadlessSessionRuntime = class _HeadlessSessionRuntime {
|
|
|
176748
177070
|
if (this.disposed) {
|
|
176749
177071
|
throw new Error("Headless runtime is no longer available");
|
|
176750
177072
|
}
|
|
177073
|
+
if (msg.type !== "shutdown") {
|
|
177074
|
+
this.assertRuntimeReady("controller messages");
|
|
177075
|
+
}
|
|
176751
177076
|
this.updatedAt = Date.now();
|
|
176752
177077
|
switch (msg.type) {
|
|
176753
177078
|
case "hello": {
|
|
@@ -177249,9 +177574,16 @@ var HeadlessRuntimeService = class {
|
|
|
177249
177574
|
}, 60 * 1e3).unref();
|
|
177250
177575
|
}
|
|
177251
177576
|
async ensureRuntime(options) {
|
|
177577
|
+
const shouldRegisterConnection = options.registerConnection !== false && (options.clientProtocolVersion || options.clientInfo || options.capabilities || options.optOutNotifications || options.role);
|
|
177252
177578
|
if (options.sessionId) {
|
|
177253
177579
|
const existing = this.getRuntime(options.scope_key, options.sessionId);
|
|
177254
177580
|
if (existing) {
|
|
177581
|
+
if (shouldRegisterConnection) {
|
|
177582
|
+
const snapshot = existing.getSnapshot();
|
|
177583
|
+
if (!snapshot.state.is_ready) {
|
|
177584
|
+
throw new HeadlessRuntimeNotReadyError("new attachments", snapshot.state);
|
|
177585
|
+
}
|
|
177586
|
+
}
|
|
177255
177587
|
return existing;
|
|
177256
177588
|
}
|
|
177257
177589
|
}
|
|
@@ -177278,16 +177610,23 @@ var HeadlessRuntimeService = class {
|
|
|
177278
177610
|
context: options.context,
|
|
177279
177611
|
sessionManager: options.sessionManager
|
|
177280
177612
|
});
|
|
177281
|
-
if (options.registerConnection !== false && (options.clientProtocolVersion || options.clientInfo || options.capabilities || options.optOutNotifications || options.role)) {
|
|
177282
|
-
runtime.registerConnection({
|
|
177283
|
-
clientProtocolVersion: options.clientProtocolVersion,
|
|
177284
|
-
clientInfo: options.clientInfo,
|
|
177285
|
-
capabilities: options.capabilities,
|
|
177286
|
-
optOutNotifications: options.optOutNotifications,
|
|
177287
|
-
role: options.role
|
|
177288
|
-
});
|
|
177289
|
-
}
|
|
177290
177613
|
this.runtimes.set(runtime.key(), runtime);
|
|
177614
|
+
if (shouldRegisterConnection) {
|
|
177615
|
+
try {
|
|
177616
|
+
runtime.registerConnection({
|
|
177617
|
+
clientProtocolVersion: options.clientProtocolVersion,
|
|
177618
|
+
clientInfo: options.clientInfo,
|
|
177619
|
+
capabilities: options.capabilities,
|
|
177620
|
+
optOutNotifications: options.optOutNotifications,
|
|
177621
|
+
role: options.role
|
|
177622
|
+
});
|
|
177623
|
+
} catch (error) {
|
|
177624
|
+
if (!(error instanceof HeadlessRuntimeNotReadyError)) {
|
|
177625
|
+
this.runtimes.delete(runtime.key());
|
|
177626
|
+
}
|
|
177627
|
+
throw error;
|
|
177628
|
+
}
|
|
177629
|
+
}
|
|
177291
177630
|
return runtime;
|
|
177292
177631
|
}
|
|
177293
177632
|
getRuntime(scopeKey, sessionId) {
|
|
@@ -177379,6 +177718,7 @@ var MAX_IDLE_MS;
|
|
|
177379
177718
|
var MAX_RUNTIME_CLEANUP_FAILURES;
|
|
177380
177719
|
var AMBIENT_ROUTING_SUBJECT = "maestro.ambient_agent.routing.selected";
|
|
177381
177720
|
var HOSTED_RUNNER_SNAPSHOT_MANIFEST_VERSION2 = "evalops.remote-runner.snapshot-manifest.v1";
|
|
177721
|
+
var HeadlessRuntimeNotReadyError;
|
|
177382
177722
|
var init_headless_runtime_service = __esm2(() => {
|
|
177383
177723
|
init_prompt_recovery();
|
|
177384
177724
|
init_runtime_events();
|
|
@@ -177408,6 +177748,15 @@ var init_headless_runtime_service = __esm2(() => {
|
|
|
177408
177748
|
MAX_CONNECTION_IDLE_MS = Number.parseInt(process.env.MAESTRO_HEADLESS_CONNECTION_IDLE_MS || "", 10) || CONNECTION_HEARTBEAT_INTERVAL_MS * 3;
|
|
177409
177749
|
MAX_IDLE_MS = Number.parseInt(process.env.MAESTRO_HEADLESS_RUNTIME_IDLE_MS || "", 10) || 30 * 60 * 1e3;
|
|
177410
177750
|
MAX_RUNTIME_CLEANUP_FAILURES = Number.parseInt(process.env.MAESTRO_HEADLESS_RUNTIME_MAX_CLEANUP_FAILURES || "", 10) || 3;
|
|
177751
|
+
HeadlessRuntimeNotReadyError = class HeadlessRuntimeNotReadyError extends Error {
|
|
177752
|
+
code = "runtime_not_ready";
|
|
177753
|
+
constructor(action, state2) {
|
|
177754
|
+
const status = state2.last_status ? `: ${state2.last_status}` : "";
|
|
177755
|
+
const error = state2.last_error ? ` (${state2.last_error})` : "";
|
|
177756
|
+
super(`Headless runtime is not ready for ${action}${status}${error}`);
|
|
177757
|
+
this.name = "HeadlessRuntimeNotReadyError";
|
|
177758
|
+
}
|
|
177759
|
+
};
|
|
177411
177760
|
});
|
|
177412
177761
|
function compose(middlewares) {
|
|
177413
177762
|
return async (req, res, next) => {
|
|
@@ -183638,6 +183987,20 @@ function rethrowHeadlessMessageError(error) {
|
|
|
183638
183987
|
if (!(error instanceof Error)) {
|
|
183639
183988
|
throw error;
|
|
183640
183989
|
}
|
|
183990
|
+
if (error instanceof HeadlessRuntimeNotReadyError) {
|
|
183991
|
+
throw new ApiError2(
|
|
183992
|
+
503,
|
|
183993
|
+
error.message,
|
|
183994
|
+
[
|
|
183995
|
+
{
|
|
183996
|
+
reason: "runtime_not_ready",
|
|
183997
|
+
domain: HOSTED_RUNNER_ERROR_DOMAIN
|
|
183998
|
+
}
|
|
183999
|
+
],
|
|
184000
|
+
"runtime_not_ready"
|
|
184001
|
+
/* RuntimeNotReady */
|
|
184002
|
+
);
|
|
184003
|
+
}
|
|
183641
184004
|
if (error.message === "Viewer headless connections cannot send messages") {
|
|
183642
184005
|
throw new ApiError2(403, error.message);
|
|
183643
184006
|
}
|
|
@@ -183656,6 +184019,20 @@ function rethrowHeadlessConnectionLifecycleError(error) {
|
|
|
183656
184019
|
if (!(error instanceof Error)) {
|
|
183657
184020
|
throw error;
|
|
183658
184021
|
}
|
|
184022
|
+
if (error instanceof HeadlessRuntimeNotReadyError) {
|
|
184023
|
+
throw new ApiError2(
|
|
184024
|
+
503,
|
|
184025
|
+
error.message,
|
|
184026
|
+
[
|
|
184027
|
+
{
|
|
184028
|
+
reason: "runtime_not_ready",
|
|
184029
|
+
domain: HOSTED_RUNNER_ERROR_DOMAIN
|
|
184030
|
+
}
|
|
184031
|
+
],
|
|
184032
|
+
"runtime_not_ready"
|
|
184033
|
+
/* RuntimeNotReady */
|
|
184034
|
+
);
|
|
184035
|
+
}
|
|
183659
184036
|
if (error.message === "Headless connection not found") {
|
|
183660
184037
|
throw new ApiError2(404, error.message);
|
|
183661
184038
|
}
|
|
@@ -183832,7 +184209,15 @@ function getRuntime(req, context2, sessionId) {
|
|
|
183832
184209
|
}
|
|
183833
184210
|
async function handleHeadlessSessionCreate(req, res, context2) {
|
|
183834
184211
|
const input = await parseAndValidateJson(req, HeadlessSessionCreateSchema);
|
|
183835
|
-
|
|
184212
|
+
let runtime;
|
|
184213
|
+
try {
|
|
184214
|
+
runtime = await ensureRuntime(req, context2, input);
|
|
184215
|
+
} catch (error) {
|
|
184216
|
+
if (error instanceof HeadlessRuntimeNotReadyError) {
|
|
184217
|
+
rethrowHeadlessConnectionLifecycleError(error);
|
|
184218
|
+
}
|
|
184219
|
+
throw error;
|
|
184220
|
+
}
|
|
183836
184221
|
sendJson(res, 200, runtime.getSnapshot(), context2.corsHeaders, req);
|
|
183837
184222
|
}
|
|
183838
184223
|
async function handleHeadlessConnectionCreate(req, res, context2) {
|
|
@@ -183873,6 +184258,9 @@ async function handleHeadlessSessionSubscribe(req, res, context2, params) {
|
|
|
183873
184258
|
optOutNotifications: input.optOutNotifications
|
|
183874
184259
|
}), context2.corsHeaders, req);
|
|
183875
184260
|
} catch (error) {
|
|
184261
|
+
if (error instanceof HeadlessRuntimeNotReadyError) {
|
|
184262
|
+
rethrowHeadlessConnectionLifecycleError(error);
|
|
184263
|
+
}
|
|
183876
184264
|
if (error instanceof Error && error.message === "Controller lease is already held by another connection") {
|
|
183877
184265
|
throw new ApiError2(409, error.message);
|
|
183878
184266
|
}
|
|
@@ -183922,11 +184310,16 @@ function handleHeadlessSessionEvents(req, res, context2, params) {
|
|
|
183922
184310
|
const cursorParam = url.searchParams.get("cursor");
|
|
183923
184311
|
const cursor = cursorParam ? Number.parseInt(cursorParam, 10) : null;
|
|
183924
184312
|
const subscriptionId = url.searchParams.get("subscriptionId") || getHeadlessSubscriberId(req);
|
|
183925
|
-
|
|
183926
|
-
|
|
183927
|
-
|
|
183928
|
-
|
|
183929
|
-
|
|
184313
|
+
let stream;
|
|
184314
|
+
try {
|
|
184315
|
+
stream = subscriptionId ? runtime.attachSubscription(subscriptionId) : runtime.createImplicitStream({
|
|
184316
|
+
cursor,
|
|
184317
|
+
role: getHeadlessRole(req),
|
|
184318
|
+
optOutNotifications: parseOptOutNotifications(req)
|
|
184319
|
+
});
|
|
184320
|
+
} catch (error) {
|
|
184321
|
+
rethrowHeadlessConnectionLifecycleError(error);
|
|
184322
|
+
}
|
|
183930
184323
|
if (!stream) {
|
|
183931
184324
|
throw new ApiError2(404, "Headless subscriber not found");
|
|
183932
184325
|
}
|
|
@@ -183980,7 +184373,7 @@ async function handleHeadlessSessionMessage(req, res, context2, params) {
|
|
|
183980
184373
|
const runtime = getRuntime(req, context2, params?.id);
|
|
183981
184374
|
const input = await parseHeadlessMessage(req);
|
|
183982
184375
|
try {
|
|
183983
|
-
runtime.assertCanSend(getHeadlessRole(req), getHeadlessSubscriberId(req), getHeadlessConnectionId(req));
|
|
184376
|
+
runtime.assertCanSend(getHeadlessRole(req), getHeadlessSubscriberId(req), getHeadlessConnectionId(req), { allowNotReady: input.type === "shutdown" });
|
|
183984
184377
|
} catch (error) {
|
|
183985
184378
|
rethrowHeadlessMessageError(error);
|
|
183986
184379
|
}
|
|
@@ -184282,6 +184675,8 @@ async function buildHostedRunnerIdentity(hostedRunner) {
|
|
|
184282
184675
|
last_platform_a2a_push: {
|
|
184283
184676
|
kind: hostedRunner.lastPlatformA2APush.kind,
|
|
184284
184677
|
task_id: hostedRunner.lastPlatformA2APush.taskId,
|
|
184678
|
+
message_id: hostedRunner.lastPlatformA2APush.messageId,
|
|
184679
|
+
message_ids: hostedRunner.lastPlatformA2APush.messageIds,
|
|
184285
184680
|
context_id: hostedRunner.lastPlatformA2APush.contextId,
|
|
184286
184681
|
workspace_id: hostedRunner.lastPlatformA2APush.workspaceId,
|
|
184287
184682
|
organization_id: hostedRunner.lastPlatformA2APush.organizationId,
|
|
@@ -193377,7 +193772,7 @@ var init_web_server = __esm2(() => {
|
|
|
193377
193772
|
init_opentelemetry();
|
|
193378
193773
|
init_system_prompt2();
|
|
193379
193774
|
init_api_keys();
|
|
193380
|
-
|
|
193775
|
+
init_auth2();
|
|
193381
193776
|
init_background_task_hooks();
|
|
193382
193777
|
init_safe_mode();
|
|
193383
193778
|
init_hosted_runner_drain();
|
|
@@ -203017,7 +203412,11 @@ async function main(args) {
|
|
|
203017
203412
|
}
|
|
203018
203413
|
if (parsed.command === "codex") {
|
|
203019
203414
|
const { handleCodexCommand: handleCodexCommand2 } = await Promise.resolve().then(() => (init_codex(), exports_codex));
|
|
203020
|
-
|
|
203415
|
+
const commandArgs = [...parsed.commandArgs ?? []];
|
|
203416
|
+
if (parsed.subcommand === "login" && parsed.force) {
|
|
203417
|
+
commandArgs.push("--force");
|
|
203418
|
+
}
|
|
203419
|
+
await handleCodexCommand2(parsed.subcommand, commandArgs);
|
|
203021
203420
|
await waitForStartupTelemetryForImmediateExit(startupTelemetry);
|
|
203022
203421
|
return;
|
|
203023
203422
|
}
|