@bitkyc08/opencodex 2.52.0 → 2.53.0-preview.20260913
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/gui/dist/assets/index-BBOZWGB6.css +1 -0
- package/gui/dist/assets/index-D7ynYo2K.js +128 -0
- package/gui/dist/index.html +2 -2
- package/native/remote-workspace-helper/Cargo.lock +130 -0
- package/native/remote-workspace-helper/Cargo.toml +24 -0
- package/native/remote-workspace-helper/src/main.rs +49 -0
- package/native/remote-workspace-helper/src/protocol.rs +246 -0
- package/native/remote-workspace-helper/src/sandbox/macos.rs +19 -0
- package/native/remote-workspace-helper/src/sandbox/mod.rs +77 -0
- package/native/remote-workspace-helper/src/sandbox/windows.rs +15 -0
- package/package.json +6 -1
- package/src/adapters/anthropic-image-normalize.ts +30 -2
- package/src/adapters/anthropic.ts +1 -1
- package/src/adapters/base.ts +8 -2
- package/src/adapters/cursor/cursor-errors.ts +12 -0
- package/src/adapters/cursor/thread-continuity.ts +93 -0
- package/src/adapters/cursor.ts +104 -73
- package/src/adapters/devin/cloud-direct/chat.ts +312 -23
- package/src/adapters/devin/cloud-direct/metadata.ts +31 -2
- package/src/adapters/devin/live-models.ts +70 -3
- package/src/adapters/devin.ts +281 -21
- package/src/adapters/google-wire-compiler.ts +14 -6
- package/src/adapters/google.ts +22 -8
- package/src/adapters/kiro/adapter.ts +316 -0
- package/src/adapters/kiro/conversation.ts +136 -0
- package/src/adapters/kiro/payload.ts +432 -0
- package/src/adapters/kiro/reasoning.ts +56 -0
- package/src/adapters/kiro/stream.ts +1153 -0
- package/src/adapters/kiro/usage.ts +223 -0
- package/src/adapters/kiro/wire.ts +76 -0
- package/src/adapters/kiro.ts +8 -2319
- package/src/adapters/mimo-free.ts +1 -1
- package/src/adapters/openai-chat-images.ts +101 -0
- package/src/adapters/openai-chat.ts +201 -181
- package/src/adapters/openai-responses.ts +92 -224
- package/src/adapters/registry.ts +0 -7
- package/src/adapters/run-turn-queue.ts +13 -6
- package/src/bridge.ts +14 -15
- package/src/chat/inbound.ts +29 -4
- package/src/chat/outbound.ts +145 -107
- package/src/claude/desktop-profile.ts +4 -6
- package/src/cli/account-api.ts +14 -0
- package/src/cli/account-extended.ts +1 -1
- package/src/cli/account-history.ts +60 -0
- package/src/cli/account-main.ts +80 -0
- package/src/cli/account.ts +11 -3
- package/src/cli/capabilities.ts +113 -0
- package/src/cli/catalog.ts +109 -0
- package/src/cli/dispatch.ts +9 -0
- package/src/cli/help.ts +2 -0
- package/src/cli/index.ts +2 -2
- package/src/cli/observe.ts +28 -1
- package/src/cli/opencode.ts +42 -8
- package/src/cli/provider-runtime.ts +11 -1
- package/src/cli/provider.ts +22 -2
- package/src/cli/registry.ts +21 -0
- package/src/cli/remote-workspace.ts +154 -0
- package/src/cli/status.ts +39 -7
- package/src/cli/usage-report.ts +14 -2
- package/src/client/hub-client.ts +34 -0
- package/src/client/hub-state.ts +9 -1
- package/src/codex/account-store.ts +78 -0
- package/src/codex/auth-api.ts +81 -54
- package/src/codex/auth-context.ts +45 -16
- package/src/codex/catalog/effort.ts +1 -1
- package/src/codex/catalog/metadata.ts +3 -6
- package/src/codex/catalog/native-models.ts +4 -4
- package/src/codex/catalog/parsing.ts +2 -20
- package/src/codex/catalog/provider-fetch.ts +10 -1
- package/src/codex/catalog/remote.ts +233 -0
- package/src/codex/catalog/sync.ts +403 -35
- package/src/codex/convergence.ts +1 -1
- package/src/codex/history-manifest.ts +36 -0
- package/src/codex/history-provider.ts +32 -5
- package/src/codex/inject.ts +9 -0
- package/src/codex/main-account.ts +113 -0
- package/src/codex/main-device-reauth-api.ts +89 -0
- package/src/codex/main-device-reauth.ts +217 -0
- package/src/codex/native-residue.ts +9 -2
- package/src/codex/quota-auto-refresh.ts +3 -2
- package/src/codex/quota-capacity.ts +98 -0
- package/src/codex/quota-history.ts +160 -0
- package/src/codex/quota-types.ts +8 -0
- package/src/codex/quota.ts +118 -91
- package/src/codex/refresh.ts +2 -1
- package/src/codex/routing.ts +90 -17
- package/src/codex/sync.ts +33 -4
- package/src/combos/request.ts +19 -1
- package/src/config/multi-agent-surface.ts +61 -0
- package/src/config/provider-validation.ts +176 -0
- package/src/config.ts +213 -11
- package/src/generated/compatibility-version.json +436 -168
- package/src/images/loop.ts +119 -36
- package/src/lib/admission.ts +12 -6
- package/src/lib/redact.ts +7 -0
- package/src/lib/translator-budget.ts +4 -3
- package/src/lib/windows-atomic-replace.ts +1 -0
- package/src/lib/windows-elevation.ts +1 -1
- package/src/oauth/chatgpt-device.ts +62 -5
- package/src/oauth/devin/cli-import.ts +130 -0
- package/src/oauth/devin.ts +63 -8
- package/src/oauth/index.ts +29 -14
- package/src/oauth/kiro.ts +18 -6
- package/src/oauth/login-cli.ts +9 -1
- package/src/oauth/meta-muse-device.ts +464 -0
- package/src/oauth/meta-muse.ts +123 -32
- package/src/oauth/pool-kernel.ts +9 -0
- package/src/oauth/pool-settings-capability.ts +2 -2
- package/src/oauth/store.ts +57 -0
- package/src/oauth/types.ts +31 -0
- package/src/providers/derive.ts +13 -3
- package/src/providers/devin-cli-authmode-migration.ts +57 -35
- package/src/providers/devin-provider-merge-migration.ts +240 -0
- package/src/providers/muse-key-quota.ts +117 -0
- package/src/providers/muse-subscription-usage.ts +14 -2
- package/src/providers/openai-sidecar.ts +25 -3
- package/src/providers/opencode-zen-rate-limit.ts +58 -0
- package/src/providers/provider-id-rewrite.ts +20 -5
- package/src/providers/quota-types.ts +12 -0
- package/src/providers/quota.ts +143 -102
- package/src/providers/reasoning-metadata.ts +543 -0
- package/src/providers/registry.ts +80 -49
- package/src/reasoning-effort.ts +26 -2
- package/src/remote/hub-usage.ts +32 -0
- package/src/remote-control/index.ts +192 -41
- package/src/remote-control/workspace-activation.ts +9 -0
- package/src/remote-control/workspace-agent-connection.ts +366 -0
- package/src/remote-control/workspace-claude-runtime.ts +243 -0
- package/src/remote-control/workspace-codex-runtime.ts +531 -0
- package/src/remote-control/workspace-codex-sandbox.ts +115 -0
- package/src/remote-control/workspace-command-runner.ts +748 -0
- package/src/remote-control/workspace-coordinator.ts +231 -0
- package/src/remote-control/workspace-device.ts +585 -0
- package/src/remote-control/workspace-executable.ts +43 -0
- package/src/remote-control/workspace-executor.ts +397 -0
- package/src/remote-control/workspace-hub.ts +519 -0
- package/src/remote-control/workspace-pi-runtime.ts +382 -0
- package/src/remote-control/workspace-process.ts +129 -0
- package/src/remote-control/workspace-rpc.ts +304 -0
- package/src/remote-control/workspace-runtime.ts +60 -0
- package/src/remote-control/workspace-secret-store.ts +39 -0
- package/src/remote-control/workspace-sessions.ts +799 -0
- package/src/remote-control/workspace-tool-bridge.ts +192 -0
- package/src/responses/code-mode-helper-compat.ts +22 -3
- package/src/responses/hosted-tool-policy.ts +0 -1
- package/src/responses/muse-tool-name-alias.ts +379 -0
- package/src/responses/plaintext-v2-agent-messages.ts +902 -0
- package/src/router.ts +7 -0
- package/src/routing/compatibility/behavior.ts +0 -1
- package/src/server/audio-client.ts +64 -0
- package/src/server/audio-dictation.ts +91 -0
- package/src/server/audio-live.ts +185 -0
- package/src/server/audio-transcriptions.ts +183 -0
- package/src/server/audio-upstream.ts +153 -0
- package/src/server/auth-cors.ts +61 -2
- package/src/server/chat-completions.ts +1 -1
- package/src/server/chat-native-sse.ts +92 -48
- package/src/server/chat-native.ts +37 -15
- package/src/server/hub-usage.ts +57 -0
- package/src/server/images.ts +4 -0
- package/src/server/index.ts +722 -57
- package/src/server/lifecycle.ts +5 -6
- package/src/server/live-call-bindings.ts +60 -0
- package/src/server/live.ts +12 -1
- package/src/server/management/agent-settings-routes.ts +25 -4
- package/src/server/management/api-access.ts +37 -0
- package/src/server/management/api-key-usage.ts +7 -2
- package/src/server/management/config-routes.ts +1 -18
- package/src/server/management/context.ts +15 -0
- package/src/server/management/logs-usage-routes.ts +2 -0
- package/src/server/management/oauth-account-routes.ts +39 -12
- package/src/server/management/provider-routes.ts +125 -2
- package/src/server/management/remote-workspace-routes.ts +140 -0
- package/src/server/management/route-registry.ts +15 -0
- package/src/server/management/usage-aggregate-cache.ts +14 -15
- package/src/server/management/usage-summary-cache.ts +2 -0
- package/src/server/management-api.ts +23 -0
- package/src/server/ports.ts +17 -0
- package/src/server/relay-eager.ts +4 -1
- package/src/server/relay.ts +70 -10
- package/src/server/request-decompress.ts +6 -3
- package/src/server/responses/agent-task-recovery.ts +25 -32
- package/src/server/responses/codex-auth-error.ts +11 -0
- package/src/server/responses/codex-ws-exchange.ts +52 -3
- package/src/server/responses/codex-ws-wire.ts +55 -0
- package/src/server/responses/compact.ts +9 -1
- package/src/server/responses/core.ts +337 -73
- package/src/server/responses/encrypted-payload.ts +45 -2
- package/src/server/responses/ws-upstream.ts +4 -1
- package/src/server/responses-self-named-namespace-scrub.ts +1 -3
- package/src/server/responses-undeclared-tool-guard.ts +1 -1
- package/src/server/search.ts +3 -0
- package/src/server/sse-payload-rewrite.ts +136 -51
- package/src/server/ws-bridge.ts +35 -1
- package/src/service/cli.ts +372 -0
- package/src/service/diagnostics.ts +340 -0
- package/src/service/guards.ts +303 -0
- package/src/service/health.ts +222 -0
- package/src/service/launchd.ts +853 -0
- package/src/service/orchestration.ts +617 -0
- package/src/service/repair.ts +334 -0
- package/src/service/state.ts +363 -0
- package/src/service/systemd.ts +229 -0
- package/src/service/windows-ops.ts +690 -0
- package/src/service/windows-scheduler.ts +769 -0
- package/src/service/windows-taskxml.ts +613 -0
- package/src/service.ts +22 -5550
- package/src/storage/cleanup/db.ts +258 -0
- package/src/storage/cleanup/execute.ts +358 -0
- package/src/storage/cleanup/paths.ts +189 -0
- package/src/storage/cleanup/pending.ts +140 -0
- package/src/storage/cleanup/preview.ts +292 -0
- package/src/storage/cleanup/reconcile.ts +347 -0
- package/src/storage/cleanup/restore.ts +932 -0
- package/src/storage/cleanup/satellite.ts +474 -0
- package/src/storage/cleanup/staging.ts +129 -0
- package/src/storage/cleanup/types.ts +98 -0
- package/src/storage/cleanup.ts +49 -3127
- package/src/types/accounts.ts +2 -0
- package/src/types/config.ts +13 -12
- package/src/types/provider.ts +37 -0
- package/src/types/request.ts +2 -0
- package/src/types/tools.ts +17 -5
- package/src/types.ts +1 -0
- package/src/usage/expected-prices.ts +127 -0
- package/src/usage/log.ts +58 -1
- package/src/vision/eligibility.ts +13 -2
- package/src/web-search/loop.ts +56 -3
- package/gui/dist/assets/index-CWXut3rG.js +0 -115
- package/gui/dist/assets/index-EdoPnm9_.css +0 -1
- package/src/adapters/devin-cli/acp.ts +0 -204
- package/src/adapters/devin-cli/adapter.ts +0 -345
- package/src/adapters/devin-cli/binary.ts +0 -69
- package/src/adapters/devin-cli/models.ts +0 -57
- package/src/oauth/devin-cli.ts +0 -149
- package/src/server/responses-reasoning-summary-rewrite.ts +0 -178
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { resolveTrustedWindowsSystemDirectory } from "../lib/windows-elevation";
|
|
4
|
+
import {
|
|
5
|
+
REMOTE_WORKSPACE_MAX_TOOL_RESULT_BYTES,
|
|
6
|
+
REMOTE_WORKSPACE_TOOL_NAMESPACE,
|
|
7
|
+
parseRemoteWorkspaceToolCall,
|
|
8
|
+
remoteWorkspaceCodexDeveloperInstructions,
|
|
9
|
+
remoteWorkspaceCapabilityForTool,
|
|
10
|
+
remoteWorkspaceDeveloperInstructions,
|
|
11
|
+
remoteWorkspaceToolsForCapabilities,
|
|
12
|
+
type RemoteWorkspaceCapability,
|
|
13
|
+
type RemoteWorkspaceToolName,
|
|
14
|
+
type RemoteWorkspaceToolCallParams,
|
|
15
|
+
type RemoteWorkspaceToolResult,
|
|
16
|
+
} from "./workspace-tools";
|
|
17
|
+
import type { RemoteWorkspaceExecutionRequest } from "./workspace-executor";
|
|
18
|
+
|
|
19
|
+
export interface RemoteWorkspaceSessionBinding {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
threadId: string;
|
|
22
|
+
executorDeviceId: string;
|
|
23
|
+
executorName: string;
|
|
24
|
+
rootId: string;
|
|
25
|
+
capabilities: RemoteWorkspaceCapability[];
|
|
26
|
+
tools: RemoteWorkspaceToolName[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface RemoteWorkspaceTransport {
|
|
30
|
+
isOnline(deviceId: string): boolean;
|
|
31
|
+
invoke(request: RemoteWorkspaceExecutionRequest): Promise<RemoteWorkspaceToolResult>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface AppServerDynamicToolRequest {
|
|
35
|
+
method: "item/tool/call";
|
|
36
|
+
id: string | number;
|
|
37
|
+
params: unknown;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AppServerDynamicToolResponse {
|
|
41
|
+
id: string | number;
|
|
42
|
+
result: {
|
|
43
|
+
contentItems: Array<{ type: "inputText"; text: string }>;
|
|
44
|
+
success: boolean;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function identifier(value: string, label: string): string {
|
|
49
|
+
if (value.length < 1 || value.length > 256 || /[\x00-\x1f\x7f]/.test(value)) {
|
|
50
|
+
throw new Error(`invalid remote workspace ${label}`);
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function boundedResult(result: RemoteWorkspaceToolResult): { text: string; success: boolean } {
|
|
56
|
+
const encoded = JSON.stringify(result);
|
|
57
|
+
if (Buffer.byteLength(encoded, "utf8") > REMOTE_WORKSPACE_MAX_TOOL_RESULT_BYTES) {
|
|
58
|
+
return { text: JSON.stringify({ ok: false, error: "remote workspace tool result exceeded the coordinator limit" }), success: false };
|
|
59
|
+
}
|
|
60
|
+
return { text: encoded, success: result.ok };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function remoteWorkspaceThreadStartParams(options: {
|
|
64
|
+
executorName: string;
|
|
65
|
+
coordinatorIsolationPath: string;
|
|
66
|
+
tools: readonly RemoteWorkspaceToolName[];
|
|
67
|
+
platform?: NodeJS.Platform;
|
|
68
|
+
windowsSystemDirectory?: string;
|
|
69
|
+
mcp?: {
|
|
70
|
+
url: string;
|
|
71
|
+
bearerTokenEnvVar: string;
|
|
72
|
+
disabledServerNames?: readonly string[];
|
|
73
|
+
disabledHookNames?: readonly string[];
|
|
74
|
+
hubRuntimeReadPaths?: readonly string[];
|
|
75
|
+
};
|
|
76
|
+
}): Record<string, unknown> {
|
|
77
|
+
if (!isAbsolute(options.coordinatorIsolationPath) || options.coordinatorIsolationPath.includes("\0")) {
|
|
78
|
+
throw new Error("remote workspace coordinator isolation path must be absolute");
|
|
79
|
+
}
|
|
80
|
+
const platform = options.platform ?? process.platform;
|
|
81
|
+
const shellEnvironment = platform === "win32"
|
|
82
|
+
? {
|
|
83
|
+
HOME: options.coordinatorIsolationPath,
|
|
84
|
+
USERPROFILE: options.coordinatorIsolationPath,
|
|
85
|
+
TEMP: options.coordinatorIsolationPath,
|
|
86
|
+
TMP: options.coordinatorIsolationPath,
|
|
87
|
+
PATH: options.windowsSystemDirectory ?? resolveTrustedWindowsSystemDirectory(),
|
|
88
|
+
}
|
|
89
|
+
: {
|
|
90
|
+
HOME: options.coordinatorIsolationPath,
|
|
91
|
+
PATH: platform === "darwin" ? "/usr/bin:/bin" : "/usr/local/bin:/usr/bin:/bin",
|
|
92
|
+
LANG: "C.UTF-8",
|
|
93
|
+
};
|
|
94
|
+
const config = options.mcp ? {
|
|
95
|
+
// A Remote Workspace thread may authenticate/model-call from the Hub, but every
|
|
96
|
+
// model-visible action must either be the one OCX MCP server or fail closed.
|
|
97
|
+
default_permissions: "ocx-remote-deny-local",
|
|
98
|
+
permissions: {
|
|
99
|
+
"ocx-remote-deny-local": {
|
|
100
|
+
description: "Deny Hub-local command filesystem and network access for Remote Workspace.",
|
|
101
|
+
filesystem: {
|
|
102
|
+
":minimal": "read",
|
|
103
|
+
":workspace_roots": { ".": "read" },
|
|
104
|
+
...Object.fromEntries((options.mcp.hubRuntimeReadPaths ?? []).map(path => [path, "read"])),
|
|
105
|
+
},
|
|
106
|
+
network: { enabled: false },
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
approval_policy: "never",
|
|
110
|
+
allow_login_shell: false,
|
|
111
|
+
shell_environment_policy: {
|
|
112
|
+
inherit: "none",
|
|
113
|
+
ignore_default_excludes: false,
|
|
114
|
+
set: shellEnvironment,
|
|
115
|
+
},
|
|
116
|
+
web_search: "disabled",
|
|
117
|
+
tools: { view_image: false, web_search: false },
|
|
118
|
+
agents: { enabled: false },
|
|
119
|
+
apps: { _default: { enabled: false } },
|
|
120
|
+
features: {
|
|
121
|
+
apps: false,
|
|
122
|
+
browser_use: false,
|
|
123
|
+
computer_use: false,
|
|
124
|
+
in_app_browser: false,
|
|
125
|
+
memories: false,
|
|
126
|
+
multi_agent: false,
|
|
127
|
+
plugins: false,
|
|
128
|
+
remote_plugin: false,
|
|
129
|
+
},
|
|
130
|
+
memories: { use_memories: false, generate_memories: false },
|
|
131
|
+
hooks: Object.fromEntries((options.mcp.disabledHookNames ?? []).map(name => [name, []])),
|
|
132
|
+
mcp_servers: {
|
|
133
|
+
...Object.fromEntries((options.mcp.disabledServerNames ?? [])
|
|
134
|
+
.filter(name => name !== REMOTE_WORKSPACE_TOOL_NAMESPACE)
|
|
135
|
+
.map(name => [name, { enabled: false }])),
|
|
136
|
+
[REMOTE_WORKSPACE_TOOL_NAMESPACE]: {
|
|
137
|
+
enabled: true,
|
|
138
|
+
required: true,
|
|
139
|
+
url: options.mcp.url,
|
|
140
|
+
bearer_token_env_var: options.mcp.bearerTokenEnvVar,
|
|
141
|
+
enabled_tools: [...options.tools],
|
|
142
|
+
default_tools_approval_mode: "approve",
|
|
143
|
+
startup_timeout_sec: 5,
|
|
144
|
+
tool_timeout_sec: 65,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
} : undefined;
|
|
148
|
+
return {
|
|
149
|
+
cwd: options.coordinatorIsolationPath,
|
|
150
|
+
runtimeWorkspaceRoots: [options.coordinatorIsolationPath],
|
|
151
|
+
approvalPolicy: "never",
|
|
152
|
+
ephemeral: false,
|
|
153
|
+
serviceName: "opencodex_remote_workspace",
|
|
154
|
+
developerInstructions: options.mcp
|
|
155
|
+
? remoteWorkspaceCodexDeveloperInstructions(options.executorName, options.tools)
|
|
156
|
+
: remoteWorkspaceDeveloperInstructions(options.executorName, options.tools),
|
|
157
|
+
...(config ? { config } : {}),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export class RemoteWorkspaceCoordinator {
|
|
162
|
+
private readonly sessions = new Map<string, RemoteWorkspaceSessionBinding>();
|
|
163
|
+
|
|
164
|
+
constructor(private readonly transport: RemoteWorkspaceTransport) {}
|
|
165
|
+
|
|
166
|
+
register(binding: RemoteWorkspaceSessionBinding): () => void {
|
|
167
|
+
const capabilities = [...binding.capabilities];
|
|
168
|
+
const tools = remoteWorkspaceToolsForCapabilities(capabilities);
|
|
169
|
+
if (tools.length < 1) throw new Error("remote workspace binding has no usable tools");
|
|
170
|
+
const normalized: RemoteWorkspaceSessionBinding = {
|
|
171
|
+
sessionId: identifier(binding.sessionId, "session ID"),
|
|
172
|
+
threadId: identifier(binding.threadId, "thread ID"),
|
|
173
|
+
executorDeviceId: identifier(binding.executorDeviceId, "executor device ID"),
|
|
174
|
+
executorName: identifier(binding.executorName, "executor name"),
|
|
175
|
+
rootId: identifier(binding.rootId, "root ID"),
|
|
176
|
+
capabilities,
|
|
177
|
+
tools,
|
|
178
|
+
};
|
|
179
|
+
if (this.sessions.has(normalized.threadId)) throw new Error("remote workspace thread is already bound");
|
|
180
|
+
this.sessions.set(normalized.threadId, normalized);
|
|
181
|
+
return () => {
|
|
182
|
+
if (this.sessions.get(normalized.threadId)?.sessionId === normalized.sessionId) {
|
|
183
|
+
this.sessions.delete(normalized.threadId);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
async handle(request: AppServerDynamicToolRequest): Promise<AppServerDynamicToolResponse> {
|
|
189
|
+
if (request.method !== "item/tool/call") throw new Error("unsupported App Server request");
|
|
190
|
+
let call: RemoteWorkspaceToolCallParams;
|
|
191
|
+
try {
|
|
192
|
+
call = parseRemoteWorkspaceToolCall(request.params);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
return this.response(request.id, { ok: false, error: error instanceof Error ? error.message : "invalid remote tool call" });
|
|
195
|
+
}
|
|
196
|
+
const binding = this.sessions.get(call.threadId);
|
|
197
|
+
if (!binding) return this.response(request.id, { ok: false, error: "remote workspace thread is not bound" });
|
|
198
|
+
if (!binding.tools.includes(call.tool)
|
|
199
|
+
|| !binding.capabilities.includes(remoteWorkspaceCapabilityForTool(call.tool))) {
|
|
200
|
+
return this.response(request.id, { ok: false, error: "remote workspace tool is not supported by this executor" });
|
|
201
|
+
}
|
|
202
|
+
if (!this.transport.isOnline(binding.executorDeviceId)) {
|
|
203
|
+
return this.response(request.id, { ok: false, error: "remote executor is offline; local fallback is disabled" });
|
|
204
|
+
}
|
|
205
|
+
let result: RemoteWorkspaceToolResult;
|
|
206
|
+
try {
|
|
207
|
+
result = await this.transport.invoke({
|
|
208
|
+
requestId: randomUUID(),
|
|
209
|
+
sessionId: binding.sessionId,
|
|
210
|
+
executorDeviceId: binding.executorDeviceId,
|
|
211
|
+
rootId: binding.rootId,
|
|
212
|
+
tool: call.tool,
|
|
213
|
+
arguments: call.arguments,
|
|
214
|
+
});
|
|
215
|
+
} catch {
|
|
216
|
+
result = { ok: false, error: "remote executor transport failed; local fallback is disabled" };
|
|
217
|
+
}
|
|
218
|
+
return this.response(request.id, result);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private response(id: string | number, result: RemoteWorkspaceToolResult): AppServerDynamicToolResponse {
|
|
222
|
+
const bounded = boundedResult(result);
|
|
223
|
+
return {
|
|
224
|
+
id,
|
|
225
|
+
result: {
|
|
226
|
+
contentItems: [{ type: "inputText", text: bounded.text }],
|
|
227
|
+
success: bounded.success,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|