@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
|
@@ -23,7 +23,7 @@ export function resolveOpenAICodexAccountId(token, headers) {
|
|
|
23
23
|
process.env.CHATGPT_ACCOUNT_ID?.trim() ??
|
|
24
24
|
extractOpenAICodexAccountId(token);
|
|
25
25
|
if (!accountId) {
|
|
26
|
-
throw new Error("OpenAI Codex account id is required. Log in with /login openai-codex or set OPENAI_CODEX_ACCOUNT_ID.");
|
|
26
|
+
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.");
|
|
27
27
|
}
|
|
28
28
|
return accountId;
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-codex-session.js","sourceRoot":"","sources":["../../../src/agent/providers/openai-codex-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAE1E,MAAM,CAAC,MAAM,6BAA6B,GAAG,iCAAiC,CAAC;AAC/E,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAgBtD,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACrD,MAAM,GAAG,GACR,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACnC,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,6BAA6B,CAAC;IAClC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5C,IAAI,UAAU,CAAC,QAAQ,CAAC,kBAAkB,CAAC;QAAE,OAAO,UAAU,CAAC;IAC/D,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,GAAG,UAAU,YAAY,CAAC;IACpE,OAAO,GAAG,UAAU,kBAAkB,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,2BAA2B,CAC1C,KAAa,EACb,OAA2C;IAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;QAC1D,IAAI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Y,QAAQ,EAAE,IAAI,OAAO,EAAE,KAAK,IAAI,EAAE,GAAG,CAAC,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,wBAAwB,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IAChD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;IACD,OAAO;QACN,GAAG,EAAE,qBAAqB,CAAC,OAAO,CAAC,YAAY,CAAC;QAChD,SAAS;QACT,OAAO;KACP,CAAC;AACH,CAAC","sourcesContent":["import { arch, platform, release } from \"node:os\";\nimport { extractOpenAICodexAccountId } from \"../../oauth/openai-codex.js\";\n\nexport const DEFAULT_OPENAI_CODEX_BASE_URL = \"https://chatgpt.com/backend-api\";\nexport const OPENAI_CODEX_ORIGINATOR = \"codex_cli_rs\";\n\nexport interface ResolveOpenAICodexSessionOptions {\n\ttoken: string;\n\tmodelBaseUrl?: string;\n\tmodelHeaders?: Record<string, string>;\n\toptionHeaders?: Record<string, string>;\n\tsessionId?: string;\n}\n\nexport interface OpenAICodexSession {\n\turl: string;\n\taccountId: string;\n\theaders: Headers;\n}\n\nexport function resolveOpenAICodexUrl(baseUrl?: string): string {\n\tconst raw =\n\t\tbaseUrl && baseUrl.trim().length > 0\n\t\t\t? baseUrl\n\t\t\t: DEFAULT_OPENAI_CODEX_BASE_URL;\n\tconst normalized = raw.replace(/\\/+$/u, \"\");\n\tif (normalized.endsWith(\"/codex/responses\")) return normalized;\n\tif (normalized.endsWith(\"/codex\")) return `${normalized}/responses`;\n\treturn `${normalized}/codex/responses`;\n}\n\nexport function resolveOpenAICodexAccountId(\n\ttoken: string,\n\theaders: Record<string, string> | undefined,\n): string {\n\tfor (const [key, value] of Object.entries(headers ?? {})) {\n\t\tif (key.toLowerCase() === \"chatgpt-account-id\" && value.trim()) {\n\t\t\treturn value.trim();\n\t\t}\n\t}\n\tconst accountId =\n\t\tprocess.env.OPENAI_CODEX_ACCOUNT_ID?.trim() ??\n\t\tprocess.env.CHATGPT_ACCOUNT_ID?.trim() ??\n\t\textractOpenAICodexAccountId(token);\n\tif (!accountId) {\n\t\tthrow new Error(\n\t\t\t\"OpenAI Codex account id is required for legacy Codex Responses models. Log in with /login openai-codex:responses or set OPENAI_CODEX_ACCOUNT_ID.\",\n\t\t);\n\t}\n\treturn accountId;\n}\n\nexport function resolveOpenAICodexSession(\n\toptions: ResolveOpenAICodexSessionOptions,\n): OpenAICodexSession {\n\tconst accountId = resolveOpenAICodexAccountId(\n\t\toptions.token,\n\t\toptions.optionHeaders,\n\t);\n\tconst headers = new Headers(options.modelHeaders);\n\tfor (const [key, value] of Object.entries(options.optionHeaders ?? {})) {\n\t\theaders.set(key, value);\n\t}\n\theaders.set(\"Authorization\", `Bearer ${options.token}`);\n\theaders.set(\"chatgpt-account-id\", accountId);\n\theaders.set(\"originator\", OPENAI_CODEX_ORIGINATOR);\n\theaders.set(\"User-Agent\", `maestro (${platform()} ${release()}; ${arch()})`);\n\theaders.set(\"OpenAI-Beta\", \"responses=experimental\");\n\theaders.set(\"accept\", \"text/event-stream\");\n\theaders.set(\"content-type\", \"application/json\");\n\tif (options.sessionId) {\n\t\theaders.set(\"session_id\", options.sessionId);\n\t\theaders.set(\"x-client-request-id\", options.sessionId);\n\t}\n\treturn {\n\t\turl: resolveOpenAICodexUrl(options.modelBaseUrl),\n\t\taccountId,\n\t\theaders,\n\t};\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MaestroAppServerClientMethod, MaestroAppServerCommandExecResult, MaestroAppServerCommandProcessResult, MaestroAppServerDaemonStatusResult, MaestroAppServerEmptyResult, MaestroAppServerExternalAgentImportResult, MaestroAppServerFsMetadataResult, MaestroAppServerFsReadDirectoryResult, MaestroAppServerFsReadFileResult, MaestroAppServerFsWatchResult, MaestroAppServerInitializeResult, MaestroAppServerModelListResult, MaestroAppServerModelProviderCapabilitiesReadResult, MaestroAppServerNetworkAuditListResult, MaestroAppServerNetworkFetchResult, MaestroAppServerPluginBundleListResult, MaestroAppServerPluginBundleMutationResult, MaestroAppServerPolicyCheckResult, MaestroAppServerPolicyReadResult, MaestroAppServerProtocolModeListResult, MaestroAppServerProtocolModeSetResult, MaestroAppServerRemoteControlDrainResult, MaestroAppServerRemoteControlLeaseResult, MaestroAppServerRemoteControlStatusResult, MaestroAppServerRequirementsListResult,
|
|
1
|
+
import type { MaestroAppServerClientMethod, MaestroAppServerCommandExecResult, MaestroAppServerCommandProcessResult, MaestroAppServerDaemonStatusResult, MaestroAppServerEmptyResult, MaestroAppServerExternalAgentImportResult, MaestroAppServerFsMetadataResult, MaestroAppServerFsReadDirectoryResult, MaestroAppServerFsReadFileResult, MaestroAppServerFsWatchResult, MaestroAppServerInitializeResult, MaestroAppServerModelListResult, MaestroAppServerModelProviderCapabilitiesReadResult, MaestroAppServerNetworkAuditListResult, MaestroAppServerNetworkFetchResult, MaestroAppServerPluginBundleListResult, MaestroAppServerPluginBundleMutationResult, MaestroAppServerPolicyCheckResult, MaestroAppServerPolicyReadResult, MaestroAppServerProtocolModeListResult, MaestroAppServerProtocolModeSetResult, MaestroAppServerRemoteControlDrainResult, MaestroAppServerRemoteControlLeaseResult, MaestroAppServerRemoteControlStatusResult, MaestroAppServerRequirementsListResult, MaestroAppServerSandboxCheckResult, MaestroAppServerSandboxProbeResult, MaestroAppServerThreadArchiveResult, MaestroAppServerThreadDeleteResult, MaestroAppServerThreadForkResult, MaestroAppServerThreadGoalResult, MaestroAppServerThreadListResult, MaestroAppServerThreadMetadataUpdateResult, MaestroAppServerThreadReadResult, MaestroAppServerThreadStartResult, MaestroAppServerTurnsListResult } from "@evalops/contracts";
|
|
2
2
|
import { type MaestroAppServerSessionApi } from "./session-api.js";
|
|
3
3
|
export interface MaestroAppServerClientInfo {
|
|
4
4
|
name: string;
|
|
@@ -10,7 +10,7 @@ export interface InProcessMaestroAppServerClientOptions {
|
|
|
10
10
|
maxPendingRequests?: number;
|
|
11
11
|
}
|
|
12
12
|
type AppServerRequestMethod = Exclude<MaestroAppServerClientMethod, "initialize">;
|
|
13
|
-
type AppServerMethodResult<M extends AppServerRequestMethod> = M extends "protocol/mode/list" ? MaestroAppServerProtocolModeListResult : M extends "protocol/mode/set" ? MaestroAppServerProtocolModeSetResult : M extends "model/list" ? MaestroAppServerModelListResult : M extends "modelProvider/capabilities/read" ? MaestroAppServerModelProviderCapabilitiesReadResult : M extends "policy/read" ? MaestroAppServerPolicyReadResult : M extends "policy/check" ? MaestroAppServerPolicyCheckResult : M extends "requirements/list" ? MaestroAppServerRequirementsListResult : M extends "network/fetch" ? MaestroAppServerNetworkFetchResult : M extends "network/audit/list" ? MaestroAppServerNetworkAuditListResult : M extends "sandbox/probe" ? MaestroAppServerSandboxProbeResult : M extends "sandbox/
|
|
13
|
+
type AppServerMethodResult<M extends AppServerRequestMethod> = M extends "protocol/mode/list" ? MaestroAppServerProtocolModeListResult : M extends "protocol/mode/set" ? MaestroAppServerProtocolModeSetResult : M extends "model/list" ? MaestroAppServerModelListResult : M extends "modelProvider/capabilities/read" ? MaestroAppServerModelProviderCapabilitiesReadResult : M extends "policy/read" ? MaestroAppServerPolicyReadResult : M extends "policy/check" ? MaestroAppServerPolicyCheckResult : M extends "requirements/list" ? MaestroAppServerRequirementsListResult : M extends "network/fetch" ? MaestroAppServerNetworkFetchResult : M extends "network/audit/list" ? MaestroAppServerNetworkAuditListResult : M extends "sandbox/probe" ? MaestroAppServerSandboxProbeResult : M extends "sandbox/check/run" ? MaestroAppServerSandboxCheckResult : M extends "externalAgent/import" ? MaestroAppServerExternalAgentImportResult : M extends "pluginBundle/list" ? MaestroAppServerPluginBundleListResult : M extends "pluginBundle/install" | "pluginBundle/remove" ? MaestroAppServerPluginBundleMutationResult : M extends "daemon/status" ? MaestroAppServerDaemonStatusResult : M extends "remoteControl/status" ? MaestroAppServerRemoteControlStatusResult : M extends "remoteControl/lease/read" | "remoteControl/lease/heartbeat" ? MaestroAppServerRemoteControlLeaseResult : M extends "remoteControl/drain" ? MaestroAppServerRemoteControlDrainResult : M extends "command/exec" ? MaestroAppServerCommandExecResult : M extends "command/exec/write" | "command/exec/terminate" ? MaestroAppServerCommandProcessResult : M extends "fs/readFile" ? MaestroAppServerFsReadFileResult : M extends "fs/readDirectory" ? MaestroAppServerFsReadDirectoryResult : M extends "fs/getMetadata" ? MaestroAppServerFsMetadataResult : M extends "fs/watch" ? MaestroAppServerFsWatchResult : M extends "fs/writeFile" | "fs/createDirectory" | "fs/remove" | "fs/copy" | "fs/unwatch" ? MaestroAppServerEmptyResult : M extends "thread/list" ? MaestroAppServerThreadListResult : M extends "thread/read" ? MaestroAppServerThreadReadResult : M extends "thread/metadata/update" ? MaestroAppServerThreadMetadataUpdateResult : M extends "thread/name/set" ? MaestroAppServerThreadMetadataUpdateResult : M extends "thread/goal/get" | "thread/goal/set" | "thread/goal/clear" ? MaestroAppServerThreadGoalResult : M extends "thread/start" ? MaestroAppServerThreadStartResult : M extends "thread/fork" ? MaestroAppServerThreadForkResult : M extends "thread/archive" | "thread/unarchive" ? MaestroAppServerThreadArchiveResult : M extends "thread/delete" ? MaestroAppServerThreadDeleteResult : M extends "thread/turns/list" ? MaestroAppServerTurnsListResult : never;
|
|
14
14
|
export declare class InProcessMaestroAppServerClientError extends Error {
|
|
15
15
|
readonly code: number;
|
|
16
16
|
constructor(code: number, message: string);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-process-client.js","sourceRoot":"","sources":["../../src/app-server/in-process-client.ts"],"names":[],"mappings":"AAsCA,OAAO,EAEN,6BAA6B,GAC7B,MAAM,kBAAkB,CA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AC,CAAC;AAC1D,CAAC","sourcesContent":["import type {\n\tMaestroAppServerClientMethod,\n\tMaestroAppServerCommandExecResult,\n\tMaestroAppServerCommandProcessResult,\n\tMaestroAppServerDaemonStatusResult,\n\tMaestroAppServerEmptyResult,\n\tMaestroAppServerExternalAgentImportResult,\n\tMaestroAppServerFsMetadataResult,\n\tMaestroAppServerFsReadDirectoryResult,\n\tMaestroAppServerFsReadFileResult,\n\tMaestroAppServerFsWatchResult,\n\tMaestroAppServerInitializeResult,\n\tMaestroAppServerModelListResult,\n\tMaestroAppServerModelProviderCapabilitiesReadResult,\n\tMaestroAppServerNetworkAuditListResult,\n\tMaestroAppServerNetworkFetchResult,\n\tMaestroAppServerPluginBundleListResult,\n\tMaestroAppServerPluginBundleMutationResult,\n\tMaestroAppServerPolicyCheckResult,\n\tMaestroAppServerPolicyReadResult,\n\tMaestroAppServerProtocolModeListResult,\n\tMaestroAppServerProtocolModeSetResult,\n\tMaestroAppServerRemoteControlDrainResult,\n\tMaestroAppServerRemoteControlLeaseResult,\n\tMaestroAppServerRemoteControlStatusResult,\n\tMaestroAppServerRequirementsListResult,\n\tMaestroAppServerSandboxProbeResult,\n\tMaestroAppServerSandboxProofResult,\n\tMaestroAppServerThreadArchiveResult,\n\tMaestroAppServerThreadDeleteResult,\n\tMaestroAppServerThreadForkResult,\n\tMaestroAppServerThreadGoalResult,\n\tMaestroAppServerThreadListResult,\n\tMaestroAppServerThreadMetadataUpdateResult,\n\tMaestroAppServerThreadReadResult,\n\tMaestroAppServerThreadStartResult,\n\tMaestroAppServerTurnsListResult,\n} from \"@evalops/contracts\";\nimport {\n\ttype MaestroAppServerSessionApi,\n\thandleMaestroAppServerRequest,\n} from \"./session-api.js\";\n\nconst DEFAULT_MAX_PENDING_REQUESTS = 64;\nconst OVERLOADED_ERROR_CODE = -32001;\n\nexport interface MaestroAppServerClientInfo {\n\tname: string;\n\ttitle?: string;\n\tversion: string;\n}\n\nexport interface InProcessMaestroAppServerClientOptions {\n\tclientInfo: MaestroAppServerClientInfo;\n\tmaxPendingRequests?: number;\n}\n\ntype AppServerRequestMethod = Exclude<\n\tMaestroAppServerClientMethod,\n\t\"initialize\"\n>;\n\ntype AppServerMethodResult<M extends AppServerRequestMethod> =\n\tM extends \"protocol/mode/list\"\n\t\t? MaestroAppServerProtocolModeListResult\n\t\t: M extends \"protocol/mode/set\"\n\t\t\t? MaestroAppServerProtocolModeSetResult\n\t\t\t: M extends \"model/list\"\n\t\t\t\t? MaestroAppServerModelListResult\n\t\t\t\t: M extends \"modelProvider/capabilities/read\"\n\t\t\t\t\t? MaestroAppServerModelProviderCapabilitiesReadResult\n\t\t\t\t\t: M extends \"policy/read\"\n\t\t\t\t\t\t? MaestroAppServerPolicyReadResult\n\t\t\t\t\t\t: M extends \"policy/check\"\n\t\t\t\t\t\t\t? MaestroAppServerPolicyCheckResult\n\t\t\t\t\t\t\t: M extends \"requirements/list\"\n\t\t\t\t\t\t\t\t? MaestroAppServerRequirementsListResult\n\t\t\t\t\t\t\t\t: M extends \"network/fetch\"\n\t\t\t\t\t\t\t\t\t? MaestroAppServerNetworkFetchResult\n\t\t\t\t\t\t\t\t\t: M extends \"network/audit/list\"\n\t\t\t\t\t\t\t\t\t\t? MaestroAppServerNetworkAuditListResult\n\t\t\t\t\t\t\t\t\t\t: M extends \"sandbox/probe\"\n\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerSandboxProbeResult\n\t\t\t\t\t\t\t\t\t\t\t: M extends \"sandbox/proof/run\"\n\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerSandboxProofResult\n\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"externalAgent/import\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerExternalAgentImportResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"pluginBundle/list\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerPluginBundleListResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"pluginBundle/install\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"pluginBundle/remove\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerPluginBundleMutationResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"daemon/status\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerDaemonStatusResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"remoteControl/status\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerRemoteControlStatusResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"remoteControl/lease/read\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"remoteControl/lease/heartbeat\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerRemoteControlLeaseResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"remoteControl/drain\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerRemoteControlDrainResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"command/exec\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerCommandExecResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"command/exec/write\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"command/exec/terminate\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerCommandProcessResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"fs/readFile\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerFsReadFileResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"fs/readDirectory\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerFsReadDirectoryResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"fs/getMetadata\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerFsMetadataResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"fs/watch\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerFsWatchResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/writeFile\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/createDirectory\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/remove\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/copy\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/unwatch\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerEmptyResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/list\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadListResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/read\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadReadResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/metadata/update\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadMetadataUpdateResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/name/set\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadMetadataUpdateResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/goal/get\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/goal/set\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/goal/clear\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadGoalResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/start\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadStartResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/fork\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadForkResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/archive\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/unarchive\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadArchiveResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/delete\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadDeleteResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/turns/list\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerTurnsListResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: never;\n\nexport class InProcessMaestroAppServerClientError extends Error {\n\tconstructor(\n\t\treadonly code: number,\n\t\tmessage: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"InProcessMaestroAppServerClientError\";\n\t}\n}\n\nexport class InProcessMaestroAppServerClient {\n\tprivate initialized = false;\n\tprivate initializing = false;\n\tprivate nextRequestId = 1;\n\tprivate pendingRequests = 0;\n\tprivate readonly maxPendingRequests: number;\n\n\tconstructor(\n\t\tprivate readonly api: MaestroAppServerSessionApi,\n\t\tprivate readonly options: InProcessMaestroAppServerClientOptions,\n\t) {\n\t\tthis.maxPendingRequests = Math.max(\n\t\t\t1,\n\t\t\tMath.trunc(options.maxPendingRequests ?? DEFAULT_MAX_PENDING_REQUESTS),\n\t\t);\n\t}\n\n\tasync initialize(): Promise<MaestroAppServerInitializeResult> {\n\t\tif (this.initialized || this.initializing) {\n\t\t\tthrow new InProcessMaestroAppServerClientError(\n\t\t\t\t-32000,\n\t\t\t\t\"Already initialized\",\n\t\t\t);\n\t\t}\n\t\tthis.initializing = true;\n\t\ttry {\n\t\t\tconst response = await handleMaestroAppServerRequest(this.api, {\n\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\tid: 0,\n\t\t\t\tmethod: \"initialize\",\n\t\t\t\tparams: {\n\t\t\t\t\tclientInfo: this.options.clientInfo,\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (response.error) {\n\t\t\t\tthrow new InProcessMaestroAppServerClientError(\n\t\t\t\t\tresponse.error.code,\n\t\t\t\t\tresponse.error.message,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.initialized = true;\n\t\t\treturn response.result as MaestroAppServerInitializeResult;\n\t\t} finally {\n\t\t\tthis.initializing = false;\n\t\t}\n\t}\n\n\tasync request<M extends AppServerRequestMethod>(\n\t\tmethod: M,\n\t\tparams?: Record<string, unknown>,\n\t): Promise<AppServerMethodResult<M>> {\n\t\tif (!this.initialized) {\n\t\t\tthrow new InProcessMaestroAppServerClientError(-32000, \"Not initialized\");\n\t\t}\n\t\tif (this.pendingRequests >= this.maxPendingRequests) {\n\t\t\tthrow new InProcessMaestroAppServerClientError(\n\t\t\t\tOVERLOADED_ERROR_CODE,\n\t\t\t\t\"Server overloaded; retry later.\",\n\t\t\t);\n\t\t}\n\n\t\tthis.pendingRequests++;\n\t\ttry {\n\t\t\tconst response = await handleMaestroAppServerRequest(this.api, {\n\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\tid: this.nextRequestId++,\n\t\t\t\tmethod,\n\t\t\t\tparams,\n\t\t\t});\n\t\t\tif (response.error) {\n\t\t\t\tthrow new InProcessMaestroAppServerClientError(\n\t\t\t\t\tresponse.error.code,\n\t\t\t\t\tresponse.error.message,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn response.result as AppServerMethodResult<M>;\n\t\t} finally {\n\t\t\tthis.pendingRequests--;\n\t\t}\n\t}\n}\n\nexport function createInProcessMaestroAppServerClient(\n\tapi: MaestroAppServerSessionApi,\n\toptions: InProcessMaestroAppServerClientOptions,\n): InProcessMaestroAppServerClient {\n\treturn new InProcessMaestroAppServerClient(api, options);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"in-process-client.js","sourceRoot":"","sources":["../../src/app-server/in-process-client.ts"],"names":[],"mappings":"AAsCA,OAAO,EAEN,6BAA6B,GAC7B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,MAAM,qBAAqB,GAAG,CAAC,KAAK,CAAC;AA2GrC,MAAM,OAAO,oCAAqC,SAAQ,KAAK;IAC9D,YACU,IAAY,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,SAAI,GAAJ,IAAI,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,sCAAsC,CAAC;IACpD,CAAC;CACD;AAED,MAAM,OAAO,+BAA+B;IAO3C,YACkB,GAA+B,EAC/B,OAA+C;QAD/C,QAAG,GAAH,GAAG,CAA4B;QAC/B,YAAO,GAAP,OAAO,CAAwC;QARzD,gBAAW,GAA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AAC;QAC3E,CAAC;QACD,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACrD,MAAM,IAAI,oCAAoC,CAC7C,qBAAqB,EACrB,iCAAiC,CACjC,CAAC;QACH,CAAC;QAED,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,MAAM,6BAA6B,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC9D,OAAO,EAAE,KAAK;gBACd,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE;gBACxB,MAAM;gBACN,MAAM;aACN,CAAC,CAAC;YACH,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACpB,MAAM,IAAI,oCAAoC,CAC7C,QAAQ,CAAC,KAAK,CAAC,IAAI,EACnB,QAAQ,CAAC,KAAK,CAAC,OAAO,CACtB,CAAC;YACH,CAAC;YACD,OAAO,QAAQ,CAAC,MAAkC,CAAC;QACpD,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,eAAe,EAAE,CAAC;QACxB,CAAC;IACF,CAAC;CACD;AAED,MAAM,UAAU,qCAAqC,CACpD,GAA+B,EAC/B,OAA+C;IAE/C,OAAO,IAAI,+BAA+B,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import type {\n\tMaestroAppServerClientMethod,\n\tMaestroAppServerCommandExecResult,\n\tMaestroAppServerCommandProcessResult,\n\tMaestroAppServerDaemonStatusResult,\n\tMaestroAppServerEmptyResult,\n\tMaestroAppServerExternalAgentImportResult,\n\tMaestroAppServerFsMetadataResult,\n\tMaestroAppServerFsReadDirectoryResult,\n\tMaestroAppServerFsReadFileResult,\n\tMaestroAppServerFsWatchResult,\n\tMaestroAppServerInitializeResult,\n\tMaestroAppServerModelListResult,\n\tMaestroAppServerModelProviderCapabilitiesReadResult,\n\tMaestroAppServerNetworkAuditListResult,\n\tMaestroAppServerNetworkFetchResult,\n\tMaestroAppServerPluginBundleListResult,\n\tMaestroAppServerPluginBundleMutationResult,\n\tMaestroAppServerPolicyCheckResult,\n\tMaestroAppServerPolicyReadResult,\n\tMaestroAppServerProtocolModeListResult,\n\tMaestroAppServerProtocolModeSetResult,\n\tMaestroAppServerRemoteControlDrainResult,\n\tMaestroAppServerRemoteControlLeaseResult,\n\tMaestroAppServerRemoteControlStatusResult,\n\tMaestroAppServerRequirementsListResult,\n\tMaestroAppServerSandboxCheckResult,\n\tMaestroAppServerSandboxProbeResult,\n\tMaestroAppServerThreadArchiveResult,\n\tMaestroAppServerThreadDeleteResult,\n\tMaestroAppServerThreadForkResult,\n\tMaestroAppServerThreadGoalResult,\n\tMaestroAppServerThreadListResult,\n\tMaestroAppServerThreadMetadataUpdateResult,\n\tMaestroAppServerThreadReadResult,\n\tMaestroAppServerThreadStartResult,\n\tMaestroAppServerTurnsListResult,\n} from \"@evalops/contracts\";\nimport {\n\ttype MaestroAppServerSessionApi,\n\thandleMaestroAppServerRequest,\n} from \"./session-api.js\";\n\nconst DEFAULT_MAX_PENDING_REQUESTS = 64;\nconst OVERLOADED_ERROR_CODE = -32001;\n\nexport interface MaestroAppServerClientInfo {\n\tname: string;\n\ttitle?: string;\n\tversion: string;\n}\n\nexport interface InProcessMaestroAppServerClientOptions {\n\tclientInfo: MaestroAppServerClientInfo;\n\tmaxPendingRequests?: number;\n}\n\ntype AppServerRequestMethod = Exclude<\n\tMaestroAppServerClientMethod,\n\t\"initialize\"\n>;\n\ntype AppServerMethodResult<M extends AppServerRequestMethod> =\n\tM extends \"protocol/mode/list\"\n\t\t? MaestroAppServerProtocolModeListResult\n\t\t: M extends \"protocol/mode/set\"\n\t\t\t? MaestroAppServerProtocolModeSetResult\n\t\t\t: M extends \"model/list\"\n\t\t\t\t? MaestroAppServerModelListResult\n\t\t\t\t: M extends \"modelProvider/capabilities/read\"\n\t\t\t\t\t? MaestroAppServerModelProviderCapabilitiesReadResult\n\t\t\t\t\t: M extends \"policy/read\"\n\t\t\t\t\t\t? MaestroAppServerPolicyReadResult\n\t\t\t\t\t\t: M extends \"policy/check\"\n\t\t\t\t\t\t\t? MaestroAppServerPolicyCheckResult\n\t\t\t\t\t\t\t: M extends \"requirements/list\"\n\t\t\t\t\t\t\t\t? MaestroAppServerRequirementsListResult\n\t\t\t\t\t\t\t\t: M extends \"network/fetch\"\n\t\t\t\t\t\t\t\t\t? MaestroAppServerNetworkFetchResult\n\t\t\t\t\t\t\t\t\t: M extends \"network/audit/list\"\n\t\t\t\t\t\t\t\t\t\t? MaestroAppServerNetworkAuditListResult\n\t\t\t\t\t\t\t\t\t\t: M extends \"sandbox/probe\"\n\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerSandboxProbeResult\n\t\t\t\t\t\t\t\t\t\t\t: M extends \"sandbox/check/run\"\n\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerSandboxCheckResult\n\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"externalAgent/import\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerExternalAgentImportResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"pluginBundle/list\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerPluginBundleListResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"pluginBundle/install\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"pluginBundle/remove\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerPluginBundleMutationResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"daemon/status\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerDaemonStatusResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"remoteControl/status\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerRemoteControlStatusResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"remoteControl/lease/read\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"remoteControl/lease/heartbeat\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerRemoteControlLeaseResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"remoteControl/drain\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerRemoteControlDrainResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"command/exec\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerCommandExecResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"command/exec/write\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"command/exec/terminate\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerCommandProcessResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"fs/readFile\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerFsReadFileResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"fs/readDirectory\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerFsReadDirectoryResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"fs/getMetadata\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerFsMetadataResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"fs/watch\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerFsWatchResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/writeFile\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/createDirectory\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/remove\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/copy\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"fs/unwatch\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerEmptyResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/list\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadListResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/read\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadReadResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/metadata/update\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadMetadataUpdateResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/name/set\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadMetadataUpdateResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/goal/get\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/goal/set\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/goal/clear\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadGoalResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/start\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadStartResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/fork\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadForkResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/archive\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t| \"thread/unarchive\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadArchiveResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/delete\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerThreadDeleteResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: M extends \"thread/turns/list\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? MaestroAppServerTurnsListResult\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: never;\n\nexport class InProcessMaestroAppServerClientError extends Error {\n\tconstructor(\n\t\treadonly code: number,\n\t\tmessage: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"InProcessMaestroAppServerClientError\";\n\t}\n}\n\nexport class InProcessMaestroAppServerClient {\n\tprivate initialized = false;\n\tprivate initializing = false;\n\tprivate nextRequestId = 1;\n\tprivate pendingRequests = 0;\n\tprivate readonly maxPendingRequests: number;\n\n\tconstructor(\n\t\tprivate readonly api: MaestroAppServerSessionApi,\n\t\tprivate readonly options: InProcessMaestroAppServerClientOptions,\n\t) {\n\t\tthis.maxPendingRequests = Math.max(\n\t\t\t1,\n\t\t\tMath.trunc(options.maxPendingRequests ?? DEFAULT_MAX_PENDING_REQUESTS),\n\t\t);\n\t}\n\n\tasync initialize(): Promise<MaestroAppServerInitializeResult> {\n\t\tif (this.initialized || this.initializing) {\n\t\t\tthrow new InProcessMaestroAppServerClientError(\n\t\t\t\t-32000,\n\t\t\t\t\"Already initialized\",\n\t\t\t);\n\t\t}\n\t\tthis.initializing = true;\n\t\ttry {\n\t\t\tconst response = await handleMaestroAppServerRequest(this.api, {\n\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\tid: 0,\n\t\t\t\tmethod: \"initialize\",\n\t\t\t\tparams: {\n\t\t\t\t\tclientInfo: this.options.clientInfo,\n\t\t\t\t},\n\t\t\t});\n\t\t\tif (response.error) {\n\t\t\t\tthrow new InProcessMaestroAppServerClientError(\n\t\t\t\t\tresponse.error.code,\n\t\t\t\t\tresponse.error.message,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.initialized = true;\n\t\t\treturn response.result as MaestroAppServerInitializeResult;\n\t\t} finally {\n\t\t\tthis.initializing = false;\n\t\t}\n\t}\n\n\tasync request<M extends AppServerRequestMethod>(\n\t\tmethod: M,\n\t\tparams?: Record<string, unknown>,\n\t): Promise<AppServerMethodResult<M>> {\n\t\tif (!this.initialized) {\n\t\t\tthrow new InProcessMaestroAppServerClientError(-32000, \"Not initialized\");\n\t\t}\n\t\tif (this.pendingRequests >= this.maxPendingRequests) {\n\t\t\tthrow new InProcessMaestroAppServerClientError(\n\t\t\t\tOVERLOADED_ERROR_CODE,\n\t\t\t\t\"Server overloaded; retry later.\",\n\t\t\t);\n\t\t}\n\n\t\tthis.pendingRequests++;\n\t\ttry {\n\t\t\tconst response = await handleMaestroAppServerRequest(this.api, {\n\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\tid: this.nextRequestId++,\n\t\t\t\tmethod,\n\t\t\t\tparams,\n\t\t\t});\n\t\t\tif (response.error) {\n\t\t\t\tthrow new InProcessMaestroAppServerClientError(\n\t\t\t\t\tresponse.error.code,\n\t\t\t\t\tresponse.error.message,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn response.result as AppServerMethodResult<M>;\n\t\t} finally {\n\t\t\tthis.pendingRequests--;\n\t\t}\n\t}\n}\n\nexport function createInProcessMaestroAppServerClient(\n\tapi: MaestroAppServerSessionApi,\n\toptions: InProcessMaestroAppServerClientOptions,\n): InProcessMaestroAppServerClient {\n\treturn new InProcessMaestroAppServerClient(api, options);\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { maestroAppServerClientMethods, maestroAppServerProtocolModeIds, maestro
|
|
|
2
2
|
const DEFAULT_MODE = "standard";
|
|
3
3
|
const REVIEW_BLOCKED_METHODS = new Set([
|
|
4
4
|
"network/fetch",
|
|
5
|
-
"sandbox/
|
|
5
|
+
"sandbox/check/run",
|
|
6
6
|
"externalAgent/import",
|
|
7
7
|
"pluginBundle/install",
|
|
8
8
|
"pluginBundle/remove",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-modes-api.js","sourceRoot":"","sources":["../../src/app-server/protocol-modes-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,GAC7B,MAAM,oBAAoB,CAAC;AAI5B,MAAM,YAAY,GAAmC,UAAU,CAAC;AAEhE,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAA+B;IACpE,eAAe;IACf,mBAAmB;IACnB,sBAAsB;IACtB,sBAAsB;IACtB,qBAAqB;IACrB,+BAA+B;IAC/B,qBAAqB;IACrB,cAAc;IACd,oBAAoB;IACpB,wBAAwB;IACxB,cAAc;IACd,oBAAoB;IACpB,WAAW;IACX,SAAS;IACT,UAAU;IACV,wBAAwB;IACxB,iBAAiB;IACjB,iBAAiB;IACjB,mBAAmB;IACnB,cAAc;IACd,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,eAAe;CACf,CAAC,CAAC;AAEH,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IAC5D,YACU,IAAY,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC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C;QACH,CAAC;QAED,OAAO,CAAC,MAAM;YACb,MAAM,gBAAgB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YAC9C,UAAU,GAAG,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAClD,OAAO;gBACN,UAAU;gBACV,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC;aAC9B,CAAC;QACH,CAAC;QAED,WAAW,CAAC,MAAM;YACjB,IAAI,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC;gBAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC1B,CAAC;YACD,OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,GAAG,MAAM,sCAAsC,UAAU,EAAE;aACnE,CAAC;QACH,CAAC;QAED,UAAU;YACT,OAAO,UAAU,CAAC;QACnB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype MaestroAppServerClientMethod,\n\ttype MaestroAppServerProtocolMode,\n\ttype MaestroAppServerProtocolModeId,\n\ttype MaestroAppServerProtocolModeListResult,\n\ttype MaestroAppServerProtocolModeSetResult,\n\tmaestroAppServerClientMethods,\n\tmaestroAppServerProtocolModeIds,\n\tmaestroAppServerServerMethods,\n} from \"@evalops/contracts\";\n\ntype UnknownRecord = Record<string, unknown>;\n\nconst DEFAULT_MODE: MaestroAppServerProtocolModeId = \"standard\";\n\nconst REVIEW_BLOCKED_METHODS = new Set<MaestroAppServerClientMethod>([\n\t\"network/fetch\",\n\t\"sandbox/
|
|
1
|
+
{"version":3,"file":"protocol-modes-api.js","sourceRoot":"","sources":["../../src/app-server/protocol-modes-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,6BAA6B,EAC7B,+BAA+B,EAC/B,6BAA6B,GAC7B,MAAM,oBAAoB,CAAC;AAI5B,MAAM,YAAY,GAAmC,UAAU,CAAC;AAEhE,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAA+B;IACpE,e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A6B,CAAC,CAAC,CAAC,CAAC,EAAE;KAC9D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mCAAmC,CAClD,UAAgD,EAAE;IAElD,IAAI,UAAU,GACb,OAAO,CAAC,WAAW,KAAK,SAAS;QAChC,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACvC,OAAO;QACN,SAAS,CAAC,MAAM;YACf,YAAY,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO;gBACN,UAAU;gBACV,WAAW,EAAE,YAAY;gBACzB,KAAK,EAAE,+BAA+B,CAAC,GAAG,CAAC,YAAY,CAAC;aACxD,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM;YACb,MAAM,gBAAgB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;YAC9C,UAAU,GAAG,aAAa,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAClD,OAAO;gBACN,UAAU;gBACV,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC;aAC9B,CAAC;QACH,CAAC;QAED,WAAW,CAAC,MAAM;YACjB,IAAI,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC;gBAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC1B,CAAC;YACD,OAAO;gBACN,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,GAAG,MAAM,sCAAsC,UAAU,EAAE;aACnE,CAAC;QACH,CAAC;QAED,UAAU;YACT,OAAO,UAAU,CAAC;QACnB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\ttype MaestroAppServerClientMethod,\n\ttype MaestroAppServerProtocolMode,\n\ttype MaestroAppServerProtocolModeId,\n\ttype MaestroAppServerProtocolModeListResult,\n\ttype MaestroAppServerProtocolModeSetResult,\n\tmaestroAppServerClientMethods,\n\tmaestroAppServerProtocolModeIds,\n\tmaestroAppServerServerMethods,\n} from \"@evalops/contracts\";\n\ntype UnknownRecord = Record<string, unknown>;\n\nconst DEFAULT_MODE: MaestroAppServerProtocolModeId = \"standard\";\n\nconst REVIEW_BLOCKED_METHODS = new Set<MaestroAppServerClientMethod>([\n\t\"network/fetch\",\n\t\"sandbox/check/run\",\n\t\"externalAgent/import\",\n\t\"pluginBundle/install\",\n\t\"pluginBundle/remove\",\n\t\"remoteControl/lease/heartbeat\",\n\t\"remoteControl/drain\",\n\t\"command/exec\",\n\t\"command/exec/write\",\n\t\"command/exec/terminate\",\n\t\"fs/writeFile\",\n\t\"fs/createDirectory\",\n\t\"fs/remove\",\n\t\"fs/copy\",\n\t\"fs/watch\",\n\t\"thread/metadata/update\",\n\t\"thread/name/set\",\n\t\"thread/goal/set\",\n\t\"thread/goal/clear\",\n\t\"thread/start\",\n\t\"thread/fork\",\n\t\"thread/archive\",\n\t\"thread/unarchive\",\n\t\"thread/delete\",\n]);\n\nexport class MaestroAppServerProtocolModesError extends Error {\n\tconstructor(\n\t\treadonly code: number,\n\t\tmessage: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MaestroAppServerProtocolModesError\";\n\t}\n}\n\nexport interface MaestroAppServerProtocolModeDecision {\n\tallowed: boolean;\n\treason?: string;\n}\n\nexport interface MaestroAppServerProtocolModes {\n\tlistModes(params?: UnknownRecord): MaestroAppServerProtocolModeListResult;\n\tsetMode(params?: UnknownRecord): MaestroAppServerProtocolModeSetResult;\n\tcheckMethod(\n\t\tmethod: MaestroAppServerClientMethod,\n\t): MaestroAppServerProtocolModeDecision;\n\tactiveMode(): MaestroAppServerProtocolModeId;\n}\n\nexport interface MaestroAppServerProtocolModesOptions {\n\tinitialMode?: MaestroAppServerProtocolModeId;\n}\n\nfunction normalizeMode(value: unknown): MaestroAppServerProtocolModeId {\n\tif (value === undefined || value === null) {\n\t\tthrow new MaestroAppServerProtocolModesError(-32602, \"Missing mode\");\n\t}\n\tif (typeof value !== \"string\") {\n\t\tthrow new MaestroAppServerProtocolModesError(-32602, \"Invalid mode\");\n\t}\n\tif (\n\t\tmaestroAppServerProtocolModeIds.includes(\n\t\t\tvalue as MaestroAppServerProtocolModeId,\n\t\t)\n\t) {\n\t\treturn value as MaestroAppServerProtocolModeId;\n\t}\n\tthrow new MaestroAppServerProtocolModesError(-32602, \"Invalid mode\");\n}\n\nfunction isRecord(value: unknown): value is UnknownRecord {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction paramsRecord(params: unknown): UnknownRecord {\n\tif (params === undefined) {\n\t\treturn {};\n\t}\n\tif (isRecord(params)) {\n\t\treturn params;\n\t}\n\tthrow new MaestroAppServerProtocolModesError(-32602, \"Invalid params\");\n}\n\nfunction modeLabel(mode: MaestroAppServerProtocolModeId): string {\n\tswitch (mode) {\n\t\tcase \"review\":\n\t\t\treturn \"Review\";\n\t\tcase \"realtime\":\n\t\t\treturn \"Realtime\";\n\t\tcase \"standard\":\n\t\t\treturn \"Standard\";\n\t}\n}\n\nfunction isMethodAllowedInMode(\n\tmode: MaestroAppServerProtocolModeId,\n\tmethod: MaestroAppServerClientMethod,\n): boolean {\n\tif (mode !== \"review\") {\n\t\treturn true;\n\t}\n\treturn !REVIEW_BLOCKED_METHODS.has(method);\n}\n\nfunction describeMode(\n\tmode: MaestroAppServerProtocolModeId,\n): MaestroAppServerProtocolMode {\n\tconst allowedMethods = maestroAppServerClientMethods.filter((method) =>\n\t\tisMethodAllowedInMode(mode, method),\n\t);\n\tconst blockedMethods = maestroAppServerClientMethods.filter(\n\t\t(method) => !isMethodAllowedInMode(mode, method),\n\t);\n\treturn {\n\t\tid: mode,\n\t\tlabel: modeLabel(mode),\n\t\treadOnly: mode === \"review\",\n\t\trealtime: mode === \"realtime\",\n\t\tallowedMethods: [...allowedMethods],\n\t\tblockedMethods: [...blockedMethods],\n\t\tserverNotifications:\n\t\t\tmode === \"realtime\" ? [...maestroAppServerServerMethods] : [],\n\t};\n}\n\nexport function createMaestroAppServerProtocolModes(\n\toptions: MaestroAppServerProtocolModesOptions = {},\n): MaestroAppServerProtocolModes {\n\tlet activeMode =\n\t\toptions.initialMode === undefined\n\t\t\t? DEFAULT_MODE\n\t\t\t: normalizeMode(options.initialMode);\n\treturn {\n\t\tlistModes(params) {\n\t\t\tparamsRecord(params);\n\t\t\treturn {\n\t\t\t\tactiveMode,\n\t\t\t\tdefaultMode: DEFAULT_MODE,\n\t\t\t\tmodes: maestroAppServerProtocolModeIds.map(describeMode),\n\t\t\t};\n\t\t},\n\n\t\tsetMode(params) {\n\t\t\tconst normalizedParams = paramsRecord(params);\n\t\t\tactiveMode = normalizeMode(normalizedParams.mode);\n\t\t\treturn {\n\t\t\t\tactiveMode,\n\t\t\t\tmode: describeMode(activeMode),\n\t\t\t};\n\t\t},\n\n\t\tcheckMethod(method) {\n\t\t\tif (isMethodAllowedInMode(activeMode, method)) {\n\t\t\t\treturn { allowed: true };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tallowed: false,\n\t\t\t\treason: `${method} is blocked while protocol mode is ${activeMode}`,\n\t\t\t};\n\t\t},\n\n\t\tactiveMode() {\n\t\t\treturn activeMode;\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MaestroAppServerSandboxCheckResult, MaestroAppServerSandboxProbeResult, MaestroAppServerSandboxType } from "@evalops/contracts";
|
|
2
|
+
import { type CreateSandboxOptions, type Sandbox } from "../sandbox/index.js";
|
|
3
|
+
type UnknownRecord = Record<string, unknown>;
|
|
4
|
+
export declare class MaestroAppServerSandboxCheckError extends Error {
|
|
5
|
+
readonly code: number;
|
|
6
|
+
constructor(code: number, message: string);
|
|
7
|
+
}
|
|
8
|
+
export interface MaestroAppServerSandboxCheck {
|
|
9
|
+
probe(): MaestroAppServerSandboxProbeResult;
|
|
10
|
+
runCheck(params?: UnknownRecord): Promise<MaestroAppServerSandboxCheckResult>;
|
|
11
|
+
}
|
|
12
|
+
export interface MaestroAppServerSandboxCheckOptions {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
isNativeSandboxAvailable?: () => boolean;
|
|
15
|
+
getNativeSandboxType?: () => MaestroAppServerSandboxType;
|
|
16
|
+
createSandbox?: (options: CreateSandboxOptions) => Promise<Sandbox | undefined>;
|
|
17
|
+
}
|
|
18
|
+
export declare function normalizeSandboxCheckParams(value: unknown): UnknownRecord;
|
|
19
|
+
export declare function createMaestroAppServerSandboxCheck(options?: MaestroAppServerSandboxCheckOptions): MaestroAppServerSandboxCheck;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=sandbox-check-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-
|
|
1
|
+
{"version":3,"file":"sandbox-check-api.d.ts","sourceRoot":"","sources":["../../src/app-server/sandbox-check-api.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEX,kCAAkC,EAClC,kCAAkC,EAClC,2BAA2B,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,OAAO,EAIZ,MAAM,qBAAqB,CAAC;AAE7B,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE7C,qBAAa,iCAAkC,SAAQ,KAAK;IAE1D,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKhB;AAED,MAAM,WAAW,4BAA4B;IAC5C,KAAK,IAAI,kCAAkC,CAAC;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kCAAkC,CAAC,CAAC;CAC9E;AAED,MAAM,WAAW,mCAAmC;IACnD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wBAAwB,CAAC,EAAE,MAAM,OAAO,CAAC;IACzC,oBAAoB,CAAC,EAAE,MAAM,2BAA2B,CAAC;IACzD,aAAa,CAAC,EAAE,CACf,OAAO,EAAE,oBAAoB,KACzB,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;CAClC;AAYD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAQzE;AAcD,wBAAgB,kCAAkC,CACjD,OAAO,GAAE,mCAAwC,GAC/C,4BAA4B,CA4I9B"}
|
|
@@ -2,28 +2,28 @@ import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
|
2
2
|
import { platform as osPlatform, tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { createSandbox, getNativeSandboxType, isNativeSandboxAvailable, } from "../sandbox/index.js";
|
|
5
|
-
export class
|
|
5
|
+
export class MaestroAppServerSandboxCheckError extends Error {
|
|
6
6
|
constructor(code, message) {
|
|
7
7
|
super(message);
|
|
8
8
|
this.code = code;
|
|
9
|
-
this.name = "
|
|
9
|
+
this.name = "MaestroAppServerSandboxCheckError";
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function parseCheckMode(value) {
|
|
13
13
|
if (value === undefined || value === null) {
|
|
14
14
|
return "workspace-write";
|
|
15
15
|
}
|
|
16
16
|
if (value === "read-only" || value === "workspace-write") {
|
|
17
17
|
return value;
|
|
18
18
|
}
|
|
19
|
-
throw new
|
|
19
|
+
throw new MaestroAppServerSandboxCheckError(-32602, "Invalid sandbox mode");
|
|
20
20
|
}
|
|
21
|
-
export function
|
|
21
|
+
export function normalizeSandboxCheckParams(value) {
|
|
22
22
|
if (value === undefined || value === null) {
|
|
23
23
|
return {};
|
|
24
24
|
}
|
|
25
25
|
if (typeof value !== "object" || Array.isArray(value)) {
|
|
26
|
-
throw new
|
|
26
|
+
throw new MaestroAppServerSandboxCheckError(-32602, "Invalid params");
|
|
27
27
|
}
|
|
28
28
|
return value;
|
|
29
29
|
}
|
|
@@ -33,7 +33,7 @@ function shellQuote(value) {
|
|
|
33
33
|
function checkDetail(name, passed, detail) {
|
|
34
34
|
return { name, passed, detail };
|
|
35
35
|
}
|
|
36
|
-
export function
|
|
36
|
+
export function createMaestroAppServerSandboxCheck(options = {}) {
|
|
37
37
|
const available = options.isNativeSandboxAvailable ?? isNativeSandboxAvailable;
|
|
38
38
|
const sandboxType = options.getNativeSandboxType ?? getNativeSandboxType;
|
|
39
39
|
const sandboxFactory = options.createSandbox ?? createSandbox;
|
|
@@ -46,12 +46,12 @@ export function createMaestroAppServerSandboxProof(options = {}) {
|
|
|
46
46
|
type: sandboxType(),
|
|
47
47
|
platform: osPlatform(),
|
|
48
48
|
supportedModes: isAvailable ? ["read-only", "workspace-write"] : [],
|
|
49
|
-
|
|
49
|
+
checkAvailable: isAvailable,
|
|
50
50
|
};
|
|
51
51
|
},
|
|
52
|
-
async
|
|
53
|
-
const normalizedParams =
|
|
54
|
-
const mode =
|
|
52
|
+
async runCheck(params = {}) {
|
|
53
|
+
const normalizedParams = normalizeSandboxCheckParams(params);
|
|
54
|
+
const mode = parseCheckMode(normalizedParams.mode);
|
|
55
55
|
const type = sandboxType();
|
|
56
56
|
if (!available()) {
|
|
57
57
|
return {
|
|
@@ -63,12 +63,12 @@ export function createMaestroAppServerSandboxProof(options = {}) {
|
|
|
63
63
|
checks: [],
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
const outsidePath = join(tmpdir(), `maestro-native-
|
|
66
|
+
const outsidePath = join(tmpdir(), `maestro-native-check-outside-${process.pid}-${Date.now()}`);
|
|
67
67
|
let workspace;
|
|
68
68
|
let sandbox;
|
|
69
69
|
const checks = [];
|
|
70
70
|
try {
|
|
71
|
-
workspace = mkdtempSync(join(cwd, "maestro-native-
|
|
71
|
+
workspace = mkdtempSync(join(cwd, "maestro-native-check-"));
|
|
72
72
|
sandbox = await sandboxFactory({
|
|
73
73
|
mode,
|
|
74
74
|
cwd: workspace,
|
|
@@ -86,15 +86,15 @@ export function createMaestroAppServerSandboxProof(options = {}) {
|
|
|
86
86
|
const envMarker = await sandbox.exec('printf "%s" "$MAESTRO_SANDBOX"');
|
|
87
87
|
checks.push(checkDetail("native-env-marker", envMarker.exitCode === 0 && envMarker.stdout.trim() === type, `MAESTRO_SANDBOX=${envMarker.stdout.trim() || "(empty)"}`));
|
|
88
88
|
if (mode === "workspace-write") {
|
|
89
|
-
const inside = await sandbox.exec("touch inside-
|
|
89
|
+
const inside = await sandbox.exec("touch inside-check.txt && test -f inside-check.txt");
|
|
90
90
|
checks.push(checkDetail("workspace-write", inside.exitCode === 0, inside.exitCode === 0
|
|
91
91
|
? "wrote inside workspace"
|
|
92
92
|
: inside.stderr || inside.stdout || "inside write failed"));
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
|
-
const readOnly = await sandbox.exec("touch read-only-
|
|
95
|
+
const readOnly = await sandbox.exec("touch read-only-check.txt 2>/dev/null");
|
|
96
96
|
checks.push(checkDetail("read-only-write-blocked", readOnly.exitCode !== 0 &&
|
|
97
|
-
!existsSync(join(workspace, "read-only-
|
|
97
|
+
!existsSync(join(workspace, "read-only-check.txt")), readOnly.exitCode !== 0
|
|
98
98
|
? "blocked workspace write"
|
|
99
99
|
: "workspace write unexpectedly succeeded"));
|
|
100
100
|
}
|
|
@@ -111,7 +111,7 @@ export function createMaestroAppServerSandboxProof(options = {}) {
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
|
-
checks.push(checkDetail("native-sandbox-
|
|
114
|
+
checks.push(checkDetail("native-sandbox-check", false, error instanceof Error ? error.message : "check failed"));
|
|
115
115
|
return { mode, available: true, type, passed: false, checks };
|
|
116
116
|
}
|
|
117
117
|
finally {
|
|
@@ -124,4 +124,4 @@ export function createMaestroAppServerSandboxProof(options = {}) {
|
|
|
124
124
|
},
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
//# sourceMappingURL=sandbox-
|
|
127
|
+
//# sourceMappingURL=sandbox-check-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox-proof-api.js","sourceRoot":"","sources":["../../src/app-server/sandbox-proof-api.ts"],"names":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AK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CACvD,CACD,CAAC;gBACF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YAC/D,CAAC;oBAAS,CAAC;gBACV,MAAM,OAAO,EAAE,OAAO,EAAE,CAAC;gBACzB,IAAI,SAAS,EAAE,CAAC;oBACf,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACrD,CAAC;gBACD,MAAM,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACtC,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { existsSync, mkdtempSync, rmSync } from \"node:fs\";\nimport { platform as osPlatform, tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type {\n\tMaestroAppServerSandboxProbeResult,\n\tMaestroAppServerSandboxProofMode,\n\tMaestroAppServerSandboxProofResult,\n\tMaestroAppServerSandboxType,\n} from \"@evalops/contracts\";\nimport {\n\ttype CreateSandboxOptions,\n\ttype Sandbox,\n\tcreateSandbox,\n\tgetNativeSandboxType,\n\tisNativeSandboxAvailable,\n} from \"../sandbox/index.js\";\n\ntype UnknownRecord = Record<string, unknown>;\n\nexport class MaestroAppServerSandboxProofError extends Error {\n\tconstructor(\n\t\treadonly code: number,\n\t\tmessage: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MaestroAppServerSandboxProofError\";\n\t}\n}\n\nexport interface MaestroAppServerSandboxProof {\n\tprobe(): MaestroAppServerSandboxProbeResult;\n\trunProof(params?: UnknownRecord): Promise<MaestroAppServerSandboxProofResult>;\n}\n\nexport interface MaestroAppServerSandboxProofOptions {\n\tcwd?: string;\n\tisNativeSandboxAvailable?: () => boolean;\n\tgetNativeSandboxType?: () => MaestroAppServerSandboxType;\n\tcreateSandbox?: (\n\t\toptions: CreateSandboxOptions,\n\t) => Promise<Sandbox | undefined>;\n}\n\nfunction parseProofMode(value: unknown): MaestroAppServerSandboxProofMode {\n\tif (value === undefined || value === null) {\n\t\treturn \"workspace-write\";\n\t}\n\tif (value === \"read-only\" || value === \"workspace-write\") {\n\t\treturn value;\n\t}\n\tthrow new MaestroAppServerSandboxProofError(-32602, \"Invalid sandbox mode\");\n}\n\nexport function normalizeSandboxProofParams(value: unknown): UnknownRecord {\n\tif (value === undefined || value === null) {\n\t\treturn {};\n\t}\n\tif (typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new MaestroAppServerSandboxProofError(-32602, \"Invalid params\");\n\t}\n\treturn value as UnknownRecord;\n}\n\nfunction shellQuote(value: string): string {\n\treturn `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n\nfunction checkDetail(\n\tname: string,\n\tpassed: boolean,\n\tdetail: string,\n): MaestroAppServerSandboxProofResult[\"checks\"][number] {\n\treturn { name, passed, detail };\n}\n\nexport function createMaestroAppServerSandboxProof(\n\toptions: MaestroAppServerSandboxProofOptions = {},\n): MaestroAppServerSandboxProof {\n\tconst available =\n\t\toptions.isNativeSandboxAvailable ?? isNativeSandboxAvailable;\n\tconst sandboxType = options.getNativeSandboxType ?? getNativeSandboxType;\n\tconst sandboxFactory = options.createSandbox ?? createSandbox;\n\tconst cwd = options.cwd ?? process.cwd();\n\n\treturn {\n\t\tprobe() {\n\t\t\tconst isAvailable = available();\n\t\t\treturn {\n\t\t\t\tavailable: isAvailable,\n\t\t\t\ttype: sandboxType(),\n\t\t\t\tplatform: osPlatform(),\n\t\t\t\tsupportedModes: isAvailable ? [\"read-only\", \"workspace-write\"] : [],\n\t\t\t\tproofAvailable: isAvailable,\n\t\t\t};\n\t\t},\n\n\t\tasync runProof(params = {}) {\n\t\t\tconst normalizedParams = normalizeSandboxProofParams(params);\n\t\t\tconst mode = parseProofMode(normalizedParams.mode);\n\t\t\tconst type = sandboxType();\n\t\t\tif (!available()) {\n\t\t\t\treturn {\n\t\t\t\t\tmode,\n\t\t\t\t\tavailable: false,\n\t\t\t\t\ttype,\n\t\t\t\t\tpassed: false,\n\t\t\t\t\tskippedReason: \"Native sandbox is not available on this platform.\",\n\t\t\t\t\tchecks: [],\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst outsidePath = join(\n\t\t\t\ttmpdir(),\n\t\t\t\t`maestro-native-proof-outside-${process.pid}-${Date.now()}`,\n\t\t\t);\n\t\t\tlet workspace: string | undefined;\n\t\t\tlet sandbox: Sandbox | undefined;\n\t\t\tconst checks: MaestroAppServerSandboxProofResult[\"checks\"] = [];\n\t\t\ttry {\n\t\t\t\tworkspace = mkdtempSync(join(cwd, \"maestro-native-proof-\"));\n\t\t\t\tsandbox = await sandboxFactory({\n\t\t\t\t\tmode,\n\t\t\t\t\tcwd: workspace,\n\t\t\t\t\tnative: {\n\t\t\t\t\t\tpolicy: mode,\n\t\t\t\t\t\tnetworkAccess: false,\n\t\t\t\t\t\texcludeSlashTmp: true,\n\t\t\t\t\t\texcludeTmpdir: true,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (!sandbox) {\n\t\t\t\t\tchecks.push(\n\t\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\t\"native-sandbox-instance\",\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\"No sandbox instance was created.\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn { mode, available: true, type, passed: false, checks };\n\t\t\t\t}\n\n\t\t\t\tconst envMarker = await sandbox.exec('printf \"%s\" \"$MAESTRO_SANDBOX\"');\n\t\t\t\tchecks.push(\n\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\"native-env-marker\",\n\t\t\t\t\t\tenvMarker.exitCode === 0 && envMarker.stdout.trim() === type,\n\t\t\t\t\t\t`MAESTRO_SANDBOX=${envMarker.stdout.trim() || \"(empty)\"}`,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\tif (mode === \"workspace-write\") {\n\t\t\t\t\tconst inside = await sandbox.exec(\n\t\t\t\t\t\t\"touch inside-proof.txt && test -f inside-proof.txt\",\n\t\t\t\t\t);\n\t\t\t\t\tchecks.push(\n\t\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\t\"workspace-write\",\n\t\t\t\t\t\t\tinside.exitCode === 0,\n\t\t\t\t\t\t\tinside.exitCode === 0\n\t\t\t\t\t\t\t\t? \"wrote inside workspace\"\n\t\t\t\t\t\t\t\t: inside.stderr || inside.stdout || \"inside write failed\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconst readOnly = await sandbox.exec(\n\t\t\t\t\t\t\"touch read-only-proof.txt 2>/dev/null\",\n\t\t\t\t\t);\n\t\t\t\t\tchecks.push(\n\t\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\t\"read-only-write-blocked\",\n\t\t\t\t\t\t\treadOnly.exitCode !== 0 &&\n\t\t\t\t\t\t\t\t!existsSync(join(workspace, \"read-only-proof.txt\")),\n\t\t\t\t\t\t\treadOnly.exitCode !== 0\n\t\t\t\t\t\t\t\t? \"blocked workspace write\"\n\t\t\t\t\t\t\t\t: \"workspace write unexpectedly succeeded\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst outside = await sandbox.exec(\n\t\t\t\t\t`touch ${shellQuote(outsidePath)} 2>/dev/null`,\n\t\t\t\t);\n\t\t\t\tchecks.push(\n\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\"outside-write-blocked\",\n\t\t\t\t\t\toutside.exitCode !== 0 && !existsSync(outsidePath),\n\t\t\t\t\t\toutside.exitCode !== 0\n\t\t\t\t\t\t\t? \"blocked write outside workspace\"\n\t\t\t\t\t\t\t: \"outside write unexpectedly succeeded\",\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tmode,\n\t\t\t\t\tavailable: true,\n\t\t\t\t\ttype,\n\t\t\t\t\tpassed: checks.every((check) => check.passed),\n\t\t\t\t\tchecks,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tchecks.push(\n\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\"native-sandbox-proof\",\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\terror instanceof Error ? error.message : \"proof failed\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn { mode, available: true, type, passed: false, checks };\n\t\t\t} finally {\n\t\t\t\tawait sandbox?.dispose();\n\t\t\t\tif (workspace) {\n\t\t\t\t\trmSync(workspace, { recursive: true, force: true });\n\t\t\t\t}\n\t\t\t\trmSync(outsidePath, { force: true });\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sandbox-check-api.js","sourceRoot":"","sources":["../../src/app-server/sandbox-check-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,OAAO,EAGN,aAAa,EACb,oBAAoB,EACpB,wBAAwB,GACxB,MAAM,qBAAqB,CAAC;AAI7B,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAC3D,YACU,IAAY,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,SAAI,GAAJ,IAAI,CAAQ;QAIrB,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;IACjD,CAAC;CACD;AAgBD,SAAS,cAAc,CAAC,KAAc;IACrC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC3C,OAAO,iBAAiB,CAAC;IAC1B,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,GAAG,MAAM,OAAO,CAAC,IAAI,CACjC,SAAS,UAAU,CAAC,WAAW,CAAC,cAAc,CAC9C,CAAC;gBACF,MAAM,CAAC,IAAI,CACV,WAAW,CACV,uBAAuB,EACvB,OAAO,CAAC,QAAQ,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAClD,OAAO,CAAC,QAAQ,KAAK,CAAC;oBACrB,CAAC,CAAC,iCAAiC;oBACnC,CAAC,CAAC,sCAAsC,CACzC,CACD,CAAC;gBAEF,OAAO;oBACN,IAAI;oBACJ,SAAS,EAAE,IAAI;oBACf,IAAI;oBACJ,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;oBAC7C,MAAM;iBACN,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,CAAC,IAAI,CACV,WAAW,CACV,sBAAsB,EACtB,KAAK,EACL,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CACvD,CACD,CAAC;gBACF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;YAC/D,CAAC;oBAAS,CAAC;gBACV,MAAM,OAAO,EAAE,OAAO,EAAE,CAAC;gBACzB,IAAI,SAAS,EAAE,CAAC;oBACf,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACrD,CAAC;gBACD,MAAM,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACtC,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { existsSync, mkdtempSync, rmSync } from \"node:fs\";\nimport { platform as osPlatform, tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type {\n\tMaestroAppServerSandboxCheckMode,\n\tMaestroAppServerSandboxCheckResult,\n\tMaestroAppServerSandboxProbeResult,\n\tMaestroAppServerSandboxType,\n} from \"@evalops/contracts\";\nimport {\n\ttype CreateSandboxOptions,\n\ttype Sandbox,\n\tcreateSandbox,\n\tgetNativeSandboxType,\n\tisNativeSandboxAvailable,\n} from \"../sandbox/index.js\";\n\ntype UnknownRecord = Record<string, unknown>;\n\nexport class MaestroAppServerSandboxCheckError extends Error {\n\tconstructor(\n\t\treadonly code: number,\n\t\tmessage: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MaestroAppServerSandboxCheckError\";\n\t}\n}\n\nexport interface MaestroAppServerSandboxCheck {\n\tprobe(): MaestroAppServerSandboxProbeResult;\n\trunCheck(params?: UnknownRecord): Promise<MaestroAppServerSandboxCheckResult>;\n}\n\nexport interface MaestroAppServerSandboxCheckOptions {\n\tcwd?: string;\n\tisNativeSandboxAvailable?: () => boolean;\n\tgetNativeSandboxType?: () => MaestroAppServerSandboxType;\n\tcreateSandbox?: (\n\t\toptions: CreateSandboxOptions,\n\t) => Promise<Sandbox | undefined>;\n}\n\nfunction parseCheckMode(value: unknown): MaestroAppServerSandboxCheckMode {\n\tif (value === undefined || value === null) {\n\t\treturn \"workspace-write\";\n\t}\n\tif (value === \"read-only\" || value === \"workspace-write\") {\n\t\treturn value;\n\t}\n\tthrow new MaestroAppServerSandboxCheckError(-32602, \"Invalid sandbox mode\");\n}\n\nexport function normalizeSandboxCheckParams(value: unknown): UnknownRecord {\n\tif (value === undefined || value === null) {\n\t\treturn {};\n\t}\n\tif (typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new MaestroAppServerSandboxCheckError(-32602, \"Invalid params\");\n\t}\n\treturn value as UnknownRecord;\n}\n\nfunction shellQuote(value: string): string {\n\treturn `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n\nfunction checkDetail(\n\tname: string,\n\tpassed: boolean,\n\tdetail: string,\n): MaestroAppServerSandboxCheckResult[\"checks\"][number] {\n\treturn { name, passed, detail };\n}\n\nexport function createMaestroAppServerSandboxCheck(\n\toptions: MaestroAppServerSandboxCheckOptions = {},\n): MaestroAppServerSandboxCheck {\n\tconst available =\n\t\toptions.isNativeSandboxAvailable ?? isNativeSandboxAvailable;\n\tconst sandboxType = options.getNativeSandboxType ?? getNativeSandboxType;\n\tconst sandboxFactory = options.createSandbox ?? createSandbox;\n\tconst cwd = options.cwd ?? process.cwd();\n\n\treturn {\n\t\tprobe() {\n\t\t\tconst isAvailable = available();\n\t\t\treturn {\n\t\t\t\tavailable: isAvailable,\n\t\t\t\ttype: sandboxType(),\n\t\t\t\tplatform: osPlatform(),\n\t\t\t\tsupportedModes: isAvailable ? [\"read-only\", \"workspace-write\"] : [],\n\t\t\t\tcheckAvailable: isAvailable,\n\t\t\t};\n\t\t},\n\n\t\tasync runCheck(params = {}) {\n\t\t\tconst normalizedParams = normalizeSandboxCheckParams(params);\n\t\t\tconst mode = parseCheckMode(normalizedParams.mode);\n\t\t\tconst type = sandboxType();\n\t\t\tif (!available()) {\n\t\t\t\treturn {\n\t\t\t\t\tmode,\n\t\t\t\t\tavailable: false,\n\t\t\t\t\ttype,\n\t\t\t\t\tpassed: false,\n\t\t\t\t\tskippedReason: \"Native sandbox is not available on this platform.\",\n\t\t\t\t\tchecks: [],\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst outsidePath = join(\n\t\t\t\ttmpdir(),\n\t\t\t\t`maestro-native-check-outside-${process.pid}-${Date.now()}`,\n\t\t\t);\n\t\t\tlet workspace: string | undefined;\n\t\t\tlet sandbox: Sandbox | undefined;\n\t\t\tconst checks: MaestroAppServerSandboxCheckResult[\"checks\"] = [];\n\t\t\ttry {\n\t\t\t\tworkspace = mkdtempSync(join(cwd, \"maestro-native-check-\"));\n\t\t\t\tsandbox = await sandboxFactory({\n\t\t\t\t\tmode,\n\t\t\t\t\tcwd: workspace,\n\t\t\t\t\tnative: {\n\t\t\t\t\t\tpolicy: mode,\n\t\t\t\t\t\tnetworkAccess: false,\n\t\t\t\t\t\texcludeSlashTmp: true,\n\t\t\t\t\t\texcludeTmpdir: true,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (!sandbox) {\n\t\t\t\t\tchecks.push(\n\t\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\t\"native-sandbox-instance\",\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t\"No sandbox instance was created.\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn { mode, available: true, type, passed: false, checks };\n\t\t\t\t}\n\n\t\t\t\tconst envMarker = await sandbox.exec('printf \"%s\" \"$MAESTRO_SANDBOX\"');\n\t\t\t\tchecks.push(\n\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\"native-env-marker\",\n\t\t\t\t\t\tenvMarker.exitCode === 0 && envMarker.stdout.trim() === type,\n\t\t\t\t\t\t`MAESTRO_SANDBOX=${envMarker.stdout.trim() || \"(empty)\"}`,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\tif (mode === \"workspace-write\") {\n\t\t\t\t\tconst inside = await sandbox.exec(\n\t\t\t\t\t\t\"touch inside-check.txt && test -f inside-check.txt\",\n\t\t\t\t\t);\n\t\t\t\t\tchecks.push(\n\t\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\t\"workspace-write\",\n\t\t\t\t\t\t\tinside.exitCode === 0,\n\t\t\t\t\t\t\tinside.exitCode === 0\n\t\t\t\t\t\t\t\t? \"wrote inside workspace\"\n\t\t\t\t\t\t\t\t: inside.stderr || inside.stdout || \"inside write failed\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconst readOnly = await sandbox.exec(\n\t\t\t\t\t\t\"touch read-only-check.txt 2>/dev/null\",\n\t\t\t\t\t);\n\t\t\t\t\tchecks.push(\n\t\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\t\"read-only-write-blocked\",\n\t\t\t\t\t\t\treadOnly.exitCode !== 0 &&\n\t\t\t\t\t\t\t\t!existsSync(join(workspace, \"read-only-check.txt\")),\n\t\t\t\t\t\t\treadOnly.exitCode !== 0\n\t\t\t\t\t\t\t\t? \"blocked workspace write\"\n\t\t\t\t\t\t\t\t: \"workspace write unexpectedly succeeded\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst outside = await sandbox.exec(\n\t\t\t\t\t`touch ${shellQuote(outsidePath)} 2>/dev/null`,\n\t\t\t\t);\n\t\t\t\tchecks.push(\n\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\"outside-write-blocked\",\n\t\t\t\t\t\toutside.exitCode !== 0 && !existsSync(outsidePath),\n\t\t\t\t\t\toutside.exitCode !== 0\n\t\t\t\t\t\t\t? \"blocked write outside workspace\"\n\t\t\t\t\t\t\t: \"outside write unexpectedly succeeded\",\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tmode,\n\t\t\t\t\tavailable: true,\n\t\t\t\t\ttype,\n\t\t\t\t\tpassed: checks.every((check) => check.passed),\n\t\t\t\t\tchecks,\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tchecks.push(\n\t\t\t\t\tcheckDetail(\n\t\t\t\t\t\t\"native-sandbox-check\",\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\terror instanceof Error ? error.message : \"check failed\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn { mode, available: true, type, passed: false, checks };\n\t\t\t} finally {\n\t\t\t\tawait sandbox?.dispose();\n\t\t\t\tif (workspace) {\n\t\t\t\t\trmSync(workspace, { recursive: true, force: true });\n\t\t\t\t}\n\t\t\t\trmSync(outsidePath, { force: true });\n\t\t\t}\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MaestroAppServerClientRequest, type MaestroAppServerCommandExecResult, type MaestroAppServerCommandProcessResult, type MaestroAppServerDaemonStatusResult, type MaestroAppServerEmptyResult, type MaestroAppServerExternalAgentImportResult, type MaestroAppServerFsMetadataResult, type MaestroAppServerFsReadDirectoryResult, type MaestroAppServerFsReadFileResult, type MaestroAppServerFsWatchResult, type MaestroAppServerModelListResult, type MaestroAppServerModelProviderCapabilitiesReadResult, type MaestroAppServerNetworkAuditListResult, type MaestroAppServerNetworkFetchResult, type MaestroAppServerPluginBundleListResult, type MaestroAppServerPluginBundleMutationResult, type MaestroAppServerPolicyCheckResult, type MaestroAppServerPolicyReadResult, type MaestroAppServerProtocolModeListResult, type MaestroAppServerProtocolModeSetResult, type MaestroAppServerRemoteControlDrainResult, type MaestroAppServerRemoteControlLeaseResult, type MaestroAppServerRemoteControlStatusResult, type MaestroAppServerRequirementsListResult, type MaestroAppServerResponse, type
|
|
1
|
+
import { type MaestroAppServerClientRequest, type MaestroAppServerCommandExecResult, type MaestroAppServerCommandProcessResult, type MaestroAppServerDaemonStatusResult, type MaestroAppServerEmptyResult, type MaestroAppServerExternalAgentImportResult, type MaestroAppServerFsMetadataResult, type MaestroAppServerFsReadDirectoryResult, type MaestroAppServerFsReadFileResult, type MaestroAppServerFsWatchResult, type MaestroAppServerModelListResult, type MaestroAppServerModelProviderCapabilitiesReadResult, type MaestroAppServerNetworkAuditListResult, type MaestroAppServerNetworkFetchResult, type MaestroAppServerPluginBundleListResult, type MaestroAppServerPluginBundleMutationResult, type MaestroAppServerPolicyCheckResult, type MaestroAppServerPolicyReadResult, type MaestroAppServerProtocolModeListResult, type MaestroAppServerProtocolModeSetResult, type MaestroAppServerRemoteControlDrainResult, type MaestroAppServerRemoteControlLeaseResult, type MaestroAppServerRemoteControlStatusResult, type MaestroAppServerRequirementsListResult, type MaestroAppServerResponse, type MaestroAppServerSandboxCheckResult, type MaestroAppServerSandboxProbeResult, type MaestroAppServerServerNotification, type MaestroAppServerThread, type MaestroAppServerThreadArchiveResult, type MaestroAppServerThreadDeleteResult, type MaestroAppServerThreadForkResult, type MaestroAppServerThreadGoal, type MaestroAppServerThreadGoalResult, type MaestroAppServerThreadListResult, type MaestroAppServerThreadMetadataUpdateResult, type MaestroAppServerThreadStartResult, type MaestroAppServerTurn, type MaestroAppServerTurnsListResult, maestroAppServerClientMethods } from "@evalops/contracts";
|
|
2
2
|
import type { SessionManager } from "../session/manager.js";
|
|
3
3
|
import type { SessionEntry } from "../session/types.js";
|
|
4
4
|
import { type MaestroAppServerDaemonLifecycle } from "./daemon-lifecycle-api.js";
|
|
@@ -8,13 +8,13 @@ import { type MaestroAppServerNetworkGovernance } from "./network-governance-api
|
|
|
8
8
|
import { type MaestroAppServerPluginBundleApi } from "./plugin-bundle-api.js";
|
|
9
9
|
import { type MaestroAppServerPolicyControl } from "./policy-control-api.js";
|
|
10
10
|
import { type MaestroAppServerProtocolModeDecision, type MaestroAppServerProtocolModes } from "./protocol-modes-api.js";
|
|
11
|
-
import { type
|
|
11
|
+
import { type MaestroAppServerSandboxCheck } from "./sandbox-check-api.js";
|
|
12
12
|
export type { MaestroAppServerServerNotification };
|
|
13
13
|
export { type MaestroAppServerDaemonLifecycle, createMaestroAppServerDaemonLifecycle, } from "./daemon-lifecycle-api.js";
|
|
14
14
|
export { type MaestroAppServerExternalAgentImport, createMaestroAppServerExternalAgentImport, } from "./external-agent-import-api.js";
|
|
15
15
|
export { type MaestroAppServerPluginBundleApi, createMaestroAppServerPluginBundleApi, } from "./plugin-bundle-api.js";
|
|
16
16
|
export { type MaestroAppServerProtocolModes, createMaestroAppServerProtocolModes, } from "./protocol-modes-api.js";
|
|
17
|
-
export { type
|
|
17
|
+
export { type MaestroAppServerSandboxCheck, createMaestroAppServerSandboxCheck, } from "./sandbox-check-api.js";
|
|
18
18
|
type MaybePromise<T> = T | Promise<T>;
|
|
19
19
|
type SessionStore = Pick<SessionManager, "getSessionFileById" | "loadAllSessions" | "listSessions" | "loadSession"> & {
|
|
20
20
|
getSessionFile?: () => string;
|
|
@@ -60,7 +60,7 @@ export interface MaestroAppServerSessionApiOptions {
|
|
|
60
60
|
hostControl?: MaestroAppServerHostControl | false;
|
|
61
61
|
policyControl?: MaestroAppServerPolicyControl | false;
|
|
62
62
|
networkGovernance?: MaestroAppServerNetworkGovernance | false;
|
|
63
|
-
|
|
63
|
+
sandboxCheck?: MaestroAppServerSandboxCheck | false;
|
|
64
64
|
externalAgentImport?: MaestroAppServerExternalAgentImport | false;
|
|
65
65
|
pluginBundles?: MaestroAppServerPluginBundleApi | false;
|
|
66
66
|
daemonLifecycle?: MaestroAppServerDaemonLifecycle | false;
|
|
@@ -80,7 +80,7 @@ export interface MaestroAppServerSessionApi {
|
|
|
80
80
|
fetchNetwork(params?: Record<string, unknown>): Promise<MaestroAppServerNetworkFetchResult>;
|
|
81
81
|
listNetworkAudit(params?: Record<string, unknown>): Promise<MaestroAppServerNetworkAuditListResult>;
|
|
82
82
|
probeSandbox(params?: Record<string, unknown>): Promise<MaestroAppServerSandboxProbeResult>;
|
|
83
|
-
|
|
83
|
+
runSandboxCheck(params?: Record<string, unknown>): Promise<MaestroAppServerSandboxCheckResult>;
|
|
84
84
|
importExternalAgent(params?: Record<string, unknown>): Promise<MaestroAppServerExternalAgentImportResult>;
|
|
85
85
|
listPluginBundles(params?: Record<string, unknown>): Promise<MaestroAppServerPluginBundleListResult>;
|
|
86
86
|
installPluginBundle(params?: Record<string, unknown>): Promise<MaestroAppServerPluginBundleMutationResult>;
|
|
@@ -10,14 +10,14 @@ import { MaestroAppServerNetworkGovernanceError, createMaestroAppServerNetworkGo
|
|
|
10
10
|
import { MaestroAppServerPluginBundleError, createMaestroAppServerPluginBundleApi, } from "./plugin-bundle-api.js";
|
|
11
11
|
import { MaestroAppServerPolicyControlError, createMaestroAppServerPolicyControl, } from "./policy-control-api.js";
|
|
12
12
|
import { MaestroAppServerProtocolModesError, createMaestroAppServerProtocolModes, } from "./protocol-modes-api.js";
|
|
13
|
-
import {
|
|
13
|
+
import { MaestroAppServerSandboxCheckError, createMaestroAppServerSandboxCheck, normalizeSandboxCheckParams, } from "./sandbox-check-api.js";
|
|
14
14
|
const DEFAULT_PAGE_LIMIT = 50;
|
|
15
15
|
const MAX_PAGE_LIMIT = 100;
|
|
16
16
|
export { createMaestroAppServerDaemonLifecycle, } from "./daemon-lifecycle-api.js";
|
|
17
17
|
export { createMaestroAppServerExternalAgentImport, } from "./external-agent-import-api.js";
|
|
18
18
|
export { createMaestroAppServerPluginBundleApi, } from "./plugin-bundle-api.js";
|
|
19
19
|
export { createMaestroAppServerProtocolModes, } from "./protocol-modes-api.js";
|
|
20
|
-
export {
|
|
20
|
+
export { createMaestroAppServerSandboxCheck, } from "./sandbox-check-api.js";
|
|
21
21
|
export class MaestroAppServerError extends Error {
|
|
22
22
|
constructor(code, message) {
|
|
23
23
|
super(message);
|
|
@@ -431,9 +431,9 @@ export function createMaestroAppServerSessionApi(store, options = {}) {
|
|
|
431
431
|
? undefined
|
|
432
432
|
: (options.networkGovernance ??
|
|
433
433
|
createMaestroAppServerNetworkGovernance());
|
|
434
|
-
const
|
|
434
|
+
const sandboxCheck = options.sandboxCheck === false
|
|
435
435
|
? undefined
|
|
436
|
-
: (options.
|
|
436
|
+
: (options.sandboxCheck ?? createMaestroAppServerSandboxCheck());
|
|
437
437
|
const pluginBundles = options.pluginBundles === false
|
|
438
438
|
? undefined
|
|
439
439
|
: (options.pluginBundles ?? createMaestroAppServerPluginBundleApi());
|
|
@@ -471,7 +471,7 @@ export function createMaestroAppServerSessionApi(store, options = {}) {
|
|
|
471
471
|
const canUseFilesystemWatch = Boolean(hostControl?.supportsWatch());
|
|
472
472
|
const canUsePolicyControl = Boolean(policyControl);
|
|
473
473
|
const canUseNetworkGovernance = Boolean(networkGovernance);
|
|
474
|
-
const
|
|
474
|
+
const canUseSandboxCheck = Boolean(sandboxCheck);
|
|
475
475
|
const canUseExternalAgentImport = Boolean(externalAgentImport);
|
|
476
476
|
const canUsePluginBundles = Boolean(pluginBundles);
|
|
477
477
|
return {
|
|
@@ -493,8 +493,8 @@ export function createMaestroAppServerSessionApi(store, options = {}) {
|
|
|
493
493
|
requirements: canUsePolicyControl,
|
|
494
494
|
networkProxy: canUseNetworkGovernance,
|
|
495
495
|
networkAudit: canUseNetworkGovernance,
|
|
496
|
-
sandboxProbe:
|
|
497
|
-
|
|
496
|
+
sandboxProbe: canUseSandboxCheck,
|
|
497
|
+
sandboxCheck: canUseSandboxCheck,
|
|
498
498
|
externalAgentImport: canUseExternalAgentImport,
|
|
499
499
|
pluginBundles: canUsePluginBundles,
|
|
500
500
|
daemonStatus: daemonLifecycleCapabilities.daemonStatus,
|
|
@@ -564,18 +564,18 @@ export function createMaestroAppServerSessionApi(store, options = {}) {
|
|
|
564
564
|
return networkGovernance.listAudit(params);
|
|
565
565
|
},
|
|
566
566
|
async probeSandbox(params = {}) {
|
|
567
|
-
if (!
|
|
567
|
+
if (!sandboxCheck) {
|
|
568
568
|
throw new MaestroAppServerError(-32601, "Sandbox probe is not available");
|
|
569
569
|
}
|
|
570
|
-
|
|
571
|
-
return
|
|
570
|
+
normalizeSandboxCheckParams(params);
|
|
571
|
+
return sandboxCheck.probe();
|
|
572
572
|
},
|
|
573
|
-
async
|
|
574
|
-
if (!
|
|
575
|
-
throw new MaestroAppServerError(-32601, "Sandbox
|
|
573
|
+
async runSandboxCheck(params = {}) {
|
|
574
|
+
if (!sandboxCheck) {
|
|
575
|
+
throw new MaestroAppServerError(-32601, "Sandbox check is not available");
|
|
576
576
|
}
|
|
577
|
-
const normalizedParams =
|
|
578
|
-
return
|
|
577
|
+
const normalizedParams = normalizeSandboxCheckParams(params);
|
|
578
|
+
return sandboxCheck.runCheck(normalizedParams);
|
|
579
579
|
},
|
|
580
580
|
async importExternalAgent(params = {}) {
|
|
581
581
|
if (!externalAgentImport) {
|
|
@@ -1153,11 +1153,11 @@ export async function handleMaestroAppServerRequest(api, request) {
|
|
|
1153
1153
|
id,
|
|
1154
1154
|
result: await api.probeSandbox(request.params),
|
|
1155
1155
|
};
|
|
1156
|
-
case "sandbox/
|
|
1156
|
+
case "sandbox/check/run":
|
|
1157
1157
|
return {
|
|
1158
1158
|
jsonrpc: "2.0",
|
|
1159
1159
|
id,
|
|
1160
|
-
result: await api.
|
|
1160
|
+
result: await api.runSandboxCheck(request.params),
|
|
1161
1161
|
};
|
|
1162
1162
|
case "externalAgent/import":
|
|
1163
1163
|
return {
|
|
@@ -1374,7 +1374,7 @@ export async function handleMaestroAppServerRequest(api, request) {
|
|
|
1374
1374
|
error instanceof MaestroAppServerHostControlError ||
|
|
1375
1375
|
error instanceof MaestroAppServerNetworkGovernanceError ||
|
|
1376
1376
|
error instanceof MaestroAppServerPolicyControlError ||
|
|
1377
|
-
error instanceof
|
|
1377
|
+
error instanceof MaestroAppServerSandboxCheckError ||
|
|
1378
1378
|
error instanceof MaestroAppServerExternalAgentImportError ||
|
|
1379
1379
|
error instanceof MaestroAppServerPluginBundleError ||
|
|
1380
1380
|
error instanceof MaestroAppServerDaemonLifecycleError ||
|