@myagentroam/node 0.9.8 → 0.9.10
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/capabilities.js +2 -92
- package/dist/claude-agent-sdk.js +2 -330
- package/dist/claude-channel.js +2 -44
- package/dist/codex-app-server.js +2 -503
- package/dist/config.js +2 -56
- package/dist/connector/node-connector-options.js +2 -1
- package/dist/connector/node-operation-router.js +2 -22
- package/dist/connector.js +2 -841
- package/dist/control-outbound-scheduler.js +2 -154
- package/dist/database.js +2 -1418
- package/dist/event-buffer.js +2 -19
- package/dist/fake-runner.js +2 -129
- package/dist/health.js +2 -3
- package/dist/main.js +2 -54
- package/dist/migrations/v001.js +3 -144
- package/dist/migrations/v002.js +2 -143
- package/dist/migrations/v003.js +2 -44
- package/dist/migrations/v004.js +34 -30
- package/dist/native-jsonl-reader.js +2 -186
- package/dist/native-session-history.js +2 -1119
- package/dist/opencode-runtime.js +2 -80
- package/dist/opencode-server.js +2 -263
- package/dist/operational.js +2 -122
- package/dist/process-tree.js +2 -18
- package/dist/rotating-log.js +2 -67
- package/dist/runner/abstract-runner.js +2 -232
- package/dist/runner/claude/managed-run-controller.js +2 -345
- package/dist/runner/claude-code-runner.js +2 -303
- package/dist/runner/codex/composer-image-markers.js +2 -0
- package/dist/runner/codex/conversation-parser.js +2 -861
- package/dist/runner/codex/managed-run-controller.js +2 -460
- package/dist/runner/codex-runner.js +2 -628
- package/dist/runner/fake-test-runner.js +2 -47
- package/dist/runner/opencode/conversation-parser.js +2 -221
- package/dist/runner/opencode/managed-run-controller.js +2 -537
- package/dist/runner/opencode-runner.js +2 -448
- package/dist/runner/runner-registry.js +2 -90
- package/dist/runner-command-engine.js +2 -70
- package/dist/runner-profiles.js +2 -215
- package/dist/runner-usage.js +2 -190
- package/dist/runtime-command-detector.js +2 -73
- package/dist/runtime-state.js +2 -973
- package/dist/service/attachment-domain-state.js +2 -7
- package/dist/service/conversation-history-service.js +2 -457
- package/dist/service/conversation-segment-service.js +2 -162
- package/dist/service/external-session-resume-service.js +2 -118
- package/dist/service/fake-managed-run-service.js +2 -60
- package/dist/service/managed-runner-session-service.js +2 -35
- package/dist/service/mcp-installation-verifier.js +2 -87
- package/dist/service/mcp-node-operation-service.js +2 -90
- package/dist/service/mcp-package-installer.js +2 -136
- package/dist/service/native-session-projection-service.js +2 -280
- package/dist/service/native-session-watch-service.js +2 -383
- package/dist/service/node-connection-lifecycle-service.js +2 -83
- package/dist/service/node-control-channel.js +2 -85
- package/dist/service/node-control-message-service.js +2 -107
- package/dist/service/node-request-service.js +2 -52
- package/dist/service/node-run-event-bridge.js +2 -83
- package/dist/service/node-terminal-channel.js +2 -182
- package/dist/service/node-upgrade-coordinator.js +2 -137
- package/dist/service/node-workspace-coordinator.js +2 -70
- package/dist/service/recent-run-projection-service.js +2 -0
- package/dist/service/run-attachment-service.js +2 -194
- package/dist/service/run-domain-state.js +2 -4
- package/dist/service/run-event-service.js +2 -193
- package/dist/service/run-workbench-service.js +2 -104
- package/dist/service/runner-channel-message-service.js +2 -20
- package/dist/service/runner-interaction-service.js +2 -243
- package/dist/service/runner-service.js +2 -71
- package/dist/service/session-catalog-service.js +2 -224
- package/dist/service/session-command-service.js +2 -76
- package/dist/service/session-context-service.js +2 -101
- package/dist/service/session-domain-state.js +2 -9
- package/dist/service/session-identity-service.js +2 -86
- package/dist/service/session-lifecycle-service.js +2 -240
- package/dist/service/session-message-service.js +2 -173
- package/dist/service/session-presentation-service.js +2 -43
- package/dist/service/session-query-service.js +2 -82
- package/dist/service/skill-directory-service.js +2 -238
- package/dist/service/skill-install-service.js +2 -434
- package/dist/service/skill-node-operation-service.js +2 -206
- package/dist/service/terminal-relay-state.js +2 -3
- package/dist/service/terminal-service.js +2 -52
- package/dist/service/workbench-event-service.js +2 -19
- package/dist/service/workbench-manifest-service.js +2 -69
- package/dist/service/workspace-change-service.js +2 -86
- package/dist/service/workspace-content-search-service.js +2 -477
- package/dist/service/workspace-domain-state.js +2 -41
- package/dist/service/workspace-file-service.js +2 -122
- package/dist/service/workspace-git-exclude-service.js +2 -119
- package/dist/service/workspace-queue-workbench-service.js +2 -304
- package/dist/service/workspace-service.js +2 -69
- package/dist/service/workspace-session-service.js +2 -139
- package/dist/service/workspace-upload-service.js +2 -262
- package/dist/service/workspace-watch-service.js +2 -146
- package/dist/service/workspace-workbench-service.js +2 -405
- package/dist/service.js +2 -38
- package/dist/storage.js +2 -32
- package/dist/supervisor.js +2 -136
- package/dist/terminal.js +2 -416
- package/dist/util/node-operation-parsers.js +2 -382
- package/dist/util/personal-instructions.js +2 -31
- package/dist/util/runner-error.js +2 -52
- package/dist/util/runner-native-session-parsers.js +2 -490
- package/dist/util/safe-error.js +2 -5
- package/dist/util/secret-environment.js +2 -25
- package/dist/workspace.js +2 -1519
- package/package.json +3 -3
- package/dist/capabilities.d.ts +0 -12
- package/dist/claude-agent-sdk.d.ts +0 -92
- package/dist/claude-channel.d.ts +0 -28
- package/dist/codex-app-server.d.ts +0 -133
- package/dist/config.d.ts +0 -18
- package/dist/connector/node-connector-options.d.ts +0 -27
- package/dist/connector/node-operation-router.d.ts +0 -9
- package/dist/connector.d.ts +0 -93
- package/dist/control-outbound-scheduler.d.ts +0 -29
- package/dist/database.d.ts +0 -305
- package/dist/event-buffer.d.ts +0 -9
- package/dist/fake-runner.d.ts +0 -42
- package/dist/health.d.ts +0 -4
- package/dist/main.d.ts +0 -2
- package/dist/migrations/v001.d.ts +0 -3
- package/dist/migrations/v002.d.ts +0 -4
- package/dist/migrations/v003.d.ts +0 -4
- package/dist/migrations/v004.d.ts +0 -4
- package/dist/native-jsonl-reader.d.ts +0 -35
- package/dist/native-session-history.d.ts +0 -126
- package/dist/opencode-runtime.d.ts +0 -33
- package/dist/opencode-server.d.ts +0 -49
- package/dist/operational.d.ts +0 -39
- package/dist/process-tree.d.ts +0 -9
- package/dist/rotating-log.d.ts +0 -17
- package/dist/runner/abstract-runner.d.ts +0 -172
- package/dist/runner/claude/managed-run-controller.d.ts +0 -51
- package/dist/runner/claude-code-runner.d.ts +0 -72
- package/dist/runner/codex/conversation-parser.d.ts +0 -59
- package/dist/runner/codex/managed-run-controller.d.ts +0 -90
- package/dist/runner/codex-runner.d.ts +0 -103
- package/dist/runner/fake-test-runner.d.ts +0 -26
- package/dist/runner/opencode/conversation-parser.d.ts +0 -31
- package/dist/runner/opencode/managed-run-controller.d.ts +0 -82
- package/dist/runner/opencode-runner.d.ts +0 -71
- package/dist/runner/runner-registry.d.ts +0 -19
- package/dist/runner-command-engine.d.ts +0 -28
- package/dist/runner-profiles.d.ts +0 -15
- package/dist/runner-usage.d.ts +0 -33
- package/dist/runtime-command-detector.d.ts +0 -3
- package/dist/runtime-state.d.ts +0 -169
- package/dist/service/attachment-domain-state.d.ts +0 -7
- package/dist/service/conversation-history-service.d.ts +0 -43
- package/dist/service/conversation-segment-service.d.ts +0 -20
- package/dist/service/external-session-resume-service.d.ts +0 -34
- package/dist/service/fake-managed-run-service.d.ts +0 -28
- package/dist/service/managed-runner-session-service.d.ts +0 -12
- package/dist/service/mcp-installation-verifier.d.ts +0 -9
- package/dist/service/mcp-node-operation-service.d.ts +0 -11
- package/dist/service/mcp-package-installer.d.ts +0 -8
- package/dist/service/native-session-projection-service.d.ts +0 -52
- package/dist/service/native-session-watch-service.d.ts +0 -62
- package/dist/service/node-connection-lifecycle-service.d.ts +0 -35
- package/dist/service/node-control-channel.d.ts +0 -32
- package/dist/service/node-control-message-service.d.ts +0 -27
- package/dist/service/node-request-service.d.ts +0 -14
- package/dist/service/node-run-event-bridge.d.ts +0 -40
- package/dist/service/node-terminal-channel.d.ts +0 -29
- package/dist/service/node-upgrade-coordinator.d.ts +0 -29
- package/dist/service/node-workspace-coordinator.d.ts +0 -29
- package/dist/service/run-attachment-service.d.ts +0 -38
- package/dist/service/run-domain-state.d.ts +0 -4
- package/dist/service/run-event-service.d.ts +0 -33
- package/dist/service/run-workbench-service.d.ts +0 -25
- package/dist/service/runner-channel-message-service.d.ts +0 -13
- package/dist/service/runner-interaction-service.d.ts +0 -39
- package/dist/service/runner-service.d.ts +0 -46
- package/dist/service/session-catalog-service.d.ts +0 -45
- package/dist/service/session-command-service.d.ts +0 -24
- package/dist/service/session-context-service.d.ts +0 -35
- package/dist/service/session-domain-state.d.ts +0 -9
- package/dist/service/session-identity-service.d.ts +0 -24
- package/dist/service/session-lifecycle-service.d.ts +0 -31
- package/dist/service/session-message-service.d.ts +0 -33
- package/dist/service/session-presentation-service.d.ts +0 -34
- package/dist/service/session-query-service.d.ts +0 -35
- package/dist/service/skill-directory-service.d.ts +0 -20
- package/dist/service/skill-install-service.d.ts +0 -21
- package/dist/service/skill-node-operation-service.d.ts +0 -44
- package/dist/service/terminal-relay-state.d.ts +0 -6
- package/dist/service/terminal-service.d.ts +0 -12
- package/dist/service/workbench-event-service.d.ts +0 -9
- package/dist/service/workbench-manifest-service.d.ts +0 -90
- package/dist/service/workspace-change-service.d.ts +0 -9
- package/dist/service/workspace-content-search-service.d.ts +0 -14
- package/dist/service/workspace-domain-state.d.ts +0 -79
- package/dist/service/workspace-file-service.d.ts +0 -18
- package/dist/service/workspace-git-exclude-service.d.ts +0 -4
- package/dist/service/workspace-queue-workbench-service.d.ts +0 -86
- package/dist/service/workspace-service.d.ts +0 -15
- package/dist/service/workspace-session-service.d.ts +0 -23
- package/dist/service/workspace-upload-service.d.ts +0 -39
- package/dist/service/workspace-watch-service.d.ts +0 -23
- package/dist/service/workspace-workbench-service.d.ts +0 -58
- package/dist/service.d.ts +0 -4
- package/dist/storage.d.ts +0 -2
- package/dist/supervisor.d.ts +0 -1
- package/dist/terminal.d.ts +0 -133
- package/dist/util/node-operation-parsers.d.ts +0 -92
- package/dist/util/personal-instructions.d.ts +0 -2
- package/dist/util/runner-error.d.ts +0 -6
- package/dist/util/runner-native-session-parsers.d.ts +0 -74
- package/dist/util/safe-error.d.ts +0 -2
- package/dist/util/secret-environment.d.ts +0 -1
- package/dist/workspace.d.ts +0 -217
|
@@ -1,448 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { openCodeContextLimits, openCodeProfileModels } from '../opencode-runtime.js';
|
|
3
|
-
import { declaredRunnerProfiles } from '../runner-profiles.js';
|
|
4
|
-
import { AbstractRunner } from './abstract-runner.js';
|
|
5
|
-
import { isWithinWorkspace } from './codex/conversation-parser.js';
|
|
6
|
-
import { createHash } from 'node:crypto';
|
|
7
|
-
import { openCodeConversationPage } from './opencode/conversation-parser.js';
|
|
8
|
-
import { nodeLog } from '../operational.js';
|
|
9
|
-
const PROFILE_ENTRY_TTL_MS = 30 * 60_000;
|
|
10
|
-
export class OpenCodeRunner extends AbstractRunner {
|
|
11
|
-
client;
|
|
12
|
-
clientFactory;
|
|
13
|
-
name = 'opencode';
|
|
14
|
-
discoveryScope = 'WORKSPACE_REQUIRED';
|
|
15
|
-
modelsByWorkspace = new Map();
|
|
16
|
-
contextLimitsByWorkspace = new Map();
|
|
17
|
-
profileTimersByWorkspace = new Map();
|
|
18
|
-
profileCache = new Map();
|
|
19
|
-
profileRefreshes = new Map();
|
|
20
|
-
execution = new Map();
|
|
21
|
-
managedTurns = new Map();
|
|
22
|
-
environmentClients = new Map();
|
|
23
|
-
stoppingClients = new Set();
|
|
24
|
-
constructor(client = new OpenCodeServerClient(), clientFactory = () => new OpenCodeServerClient()) {
|
|
25
|
-
super();
|
|
26
|
-
this.client = client;
|
|
27
|
-
this.clientFactory = clientFactory;
|
|
28
|
-
}
|
|
29
|
-
profile(capabilities) {
|
|
30
|
-
const base = declaredRunnerProfiles({
|
|
31
|
-
codexAvailable: capabilities.codex.available,
|
|
32
|
-
claudeCodeAvailable: capabilities.claudeCode.available,
|
|
33
|
-
openCodeAvailable: capabilities.openCode?.available === true
|
|
34
|
-
}).find((profile) => profile.runner === this.name);
|
|
35
|
-
return { ...base, models: [] };
|
|
36
|
-
}
|
|
37
|
-
async refreshProfile(capabilities, workspace, environment = {}) {
|
|
38
|
-
if (capabilities.openCode?.available !== true || workspace === undefined) {
|
|
39
|
-
return this.profile(capabilities);
|
|
40
|
-
}
|
|
41
|
-
const cacheKey = this.profileCacheKey(workspace.path, environment);
|
|
42
|
-
const now = Date.now();
|
|
43
|
-
for (const [key, entry] of this.profileCache)
|
|
44
|
-
if (entry.expiresAt <= now)
|
|
45
|
-
this.profileCache.delete(key);
|
|
46
|
-
const cached = this.profileCache.get(cacheKey);
|
|
47
|
-
if (cached !== undefined) {
|
|
48
|
-
nodeLog('runner.opencode.profile.cache-hit', {
|
|
49
|
-
workspaceId: workspace.id,
|
|
50
|
-
models: cached.models.length,
|
|
51
|
-
remainingTtlMs: cached.expiresAt - now
|
|
52
|
-
});
|
|
53
|
-
this.modelsByWorkspace.set(workspace.path, cached.models);
|
|
54
|
-
this.contextLimitsByWorkspace.set(workspace.path, cached.contextLimits);
|
|
55
|
-
this.scheduleProfileExpiry(workspace.path);
|
|
56
|
-
return { ...this.profile(capabilities), models: cached.models };
|
|
57
|
-
}
|
|
58
|
-
const current = this.profileRefreshes.get(cacheKey);
|
|
59
|
-
if (current !== undefined) {
|
|
60
|
-
nodeLog('runner.opencode.profile.single-flight-joined', { workspaceId: workspace.id });
|
|
61
|
-
return current;
|
|
62
|
-
}
|
|
63
|
-
const refresh = this.fetchProfile(capabilities, workspace, environment, cacheKey).finally(() => {
|
|
64
|
-
if (this.profileRefreshes.get(cacheKey) === refresh)
|
|
65
|
-
this.profileRefreshes.delete(cacheKey);
|
|
66
|
-
});
|
|
67
|
-
this.profileRefreshes.set(cacheKey, refresh);
|
|
68
|
-
return refresh;
|
|
69
|
-
}
|
|
70
|
-
async fetchProfile(capabilities, workspace, environment, cacheKey) {
|
|
71
|
-
const client = this.managedClient(environment);
|
|
72
|
-
const startedAt = performance.now();
|
|
73
|
-
try {
|
|
74
|
-
const catalog = await client.providers(workspace.path);
|
|
75
|
-
const models = openCodeProfileModels(catalog);
|
|
76
|
-
const contextLimits = openCodeContextLimits(catalog);
|
|
77
|
-
this.modelsByWorkspace.set(workspace.path, models);
|
|
78
|
-
this.contextLimitsByWorkspace.set(workspace.path, contextLimits);
|
|
79
|
-
this.profileCache.set(cacheKey, {
|
|
80
|
-
expiresAt: Date.now() + PROFILE_ENTRY_TTL_MS,
|
|
81
|
-
workspacePath: workspace.path,
|
|
82
|
-
environmentFingerprint: this.environmentFingerprint(environment),
|
|
83
|
-
models,
|
|
84
|
-
contextLimits
|
|
85
|
-
});
|
|
86
|
-
this.scheduleProfileExpiry(workspace.path);
|
|
87
|
-
nodeLog('runner.opencode.profile.providers.completed', {
|
|
88
|
-
workspaceId: workspace.id,
|
|
89
|
-
models: models.length,
|
|
90
|
-
durationMs: Math.round(performance.now() - startedAt)
|
|
91
|
-
});
|
|
92
|
-
return { ...this.profile(capabilities), models };
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
nodeLog('runner.opencode.profile.providers.failed', {
|
|
96
|
-
workspaceId: workspace.id,
|
|
97
|
-
durationMs: Math.round(performance.now() - startedAt)
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
finally {
|
|
101
|
-
this.releaseManagedClient(client);
|
|
102
|
-
}
|
|
103
|
-
return this.profile(capabilities);
|
|
104
|
-
}
|
|
105
|
-
profileCacheKey(workspacePath, environment) {
|
|
106
|
-
return createHash('sha256')
|
|
107
|
-
.update(JSON.stringify({ workspacePath, environment: this.environmentFingerprint(environment) }))
|
|
108
|
-
.digest('hex');
|
|
109
|
-
}
|
|
110
|
-
environmentFingerprint(environment) {
|
|
111
|
-
const entries = Object.entries(environment).sort(([left], [right]) => left.localeCompare(right));
|
|
112
|
-
return createHash('sha256').update(JSON.stringify(entries)).digest('hex');
|
|
113
|
-
}
|
|
114
|
-
available(capabilities) {
|
|
115
|
-
return capabilities.openCode?.available === true;
|
|
116
|
-
}
|
|
117
|
-
profileForValidation() {
|
|
118
|
-
return this.profile({
|
|
119
|
-
platform: 'linux',
|
|
120
|
-
architecture: 'validation',
|
|
121
|
-
nodeAppVersion: 'validation',
|
|
122
|
-
nodeVersion: 'validation',
|
|
123
|
-
codex: { available: false },
|
|
124
|
-
claudeCode: { available: false },
|
|
125
|
-
openCode: { available: true }
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
supportsConfiguration(configuration, workspace, environment = {}) {
|
|
129
|
-
if (configuration.runner !== this.name)
|
|
130
|
-
return false;
|
|
131
|
-
const models = this.cachedModels(workspace, environment);
|
|
132
|
-
const model = models.find((candidate) => candidate.id === configuration.model);
|
|
133
|
-
return (model !== undefined &&
|
|
134
|
-
(model.supportedEfforts.length === 0 ||
|
|
135
|
-
model.supportedEfforts.includes(configuration.effort)) &&
|
|
136
|
-
this.profileForValidation().accessOptions.some((candidate) => candidate.id === configuration.access));
|
|
137
|
-
}
|
|
138
|
-
defaultConfiguration(workspace, environment = {}) {
|
|
139
|
-
const model = this.cachedModels(workspace, environment)[0];
|
|
140
|
-
return {
|
|
141
|
-
runner: this.name,
|
|
142
|
-
model: model?.id ?? '',
|
|
143
|
-
effort: model?.supportedEfforts[0] ?? '',
|
|
144
|
-
access: 'default'
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
cachedModels(workspace, environment) {
|
|
148
|
-
const fingerprint = this.environmentFingerprint(environment);
|
|
149
|
-
const now = Date.now();
|
|
150
|
-
return [...this.profileCache.values()]
|
|
151
|
-
.filter((entry) => entry.expiresAt > now &&
|
|
152
|
-
entry.environmentFingerprint === fingerprint &&
|
|
153
|
-
(workspace === undefined || entry.workspacePath === workspace.path))
|
|
154
|
-
.flatMap((entry) => entry.models);
|
|
155
|
-
}
|
|
156
|
-
mcpConfiguration(raw, secrets) {
|
|
157
|
-
const servers = super.mcpConfiguration(raw, secrets);
|
|
158
|
-
return Object.fromEntries(servers.map((server) => [
|
|
159
|
-
server.name,
|
|
160
|
-
server.transport === 'STDIO'
|
|
161
|
-
? {
|
|
162
|
-
type: 'local',
|
|
163
|
-
command: [server.command, ...(server.args ?? [])],
|
|
164
|
-
environment: { ...(server.environment ?? {}) }
|
|
165
|
-
}
|
|
166
|
-
: {
|
|
167
|
-
type: 'remote',
|
|
168
|
-
url: server.url,
|
|
169
|
-
headers: { ...(server.headers ?? {}) },
|
|
170
|
-
oauth: false
|
|
171
|
-
}
|
|
172
|
-
]));
|
|
173
|
-
}
|
|
174
|
-
async discoverSessions(context, workspace) {
|
|
175
|
-
const result = [];
|
|
176
|
-
for (const target of workspace === undefined ? context.workspaces : [workspace]) {
|
|
177
|
-
let sessions;
|
|
178
|
-
try {
|
|
179
|
-
sessions = await this.client.sessions(target.path);
|
|
180
|
-
}
|
|
181
|
-
catch {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
for (const value of sessions) {
|
|
185
|
-
const session = openCodeSession(value);
|
|
186
|
-
if (session === undefined ||
|
|
187
|
-
session.parentId !== undefined ||
|
|
188
|
-
!isWithinWorkspace(session.directory, target.path))
|
|
189
|
-
continue;
|
|
190
|
-
result.push(context.createProjection({
|
|
191
|
-
workspace: target,
|
|
192
|
-
runner: this.name,
|
|
193
|
-
externalSessionId: session.id,
|
|
194
|
-
cwd: session.directory,
|
|
195
|
-
title: session.title,
|
|
196
|
-
titleOrigin: 'OFFICIAL',
|
|
197
|
-
lastActivityAt: session.updatedAt
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return result;
|
|
202
|
-
}
|
|
203
|
-
async resumeExternal(external, context) {
|
|
204
|
-
if (external.runner !== this.name || external.externalSessionId === null || !context.available)
|
|
205
|
-
return { failureCode: 'RUNNER_UNAVAILABLE' };
|
|
206
|
-
const activity = await this.readExternalActivity(external);
|
|
207
|
-
if (activity !== 'IDLE')
|
|
208
|
-
return {
|
|
209
|
-
activity: activity ?? 'UNAVAILABLE',
|
|
210
|
-
failureCode: activity === 'EXTERNAL_ACTIVE' ? 'EXTERNAL_SESSION_ACTIVE' : 'RUNNER_RESUME_FAILED'
|
|
211
|
-
};
|
|
212
|
-
const projection = context.projectionFor(external);
|
|
213
|
-
const session = projection === undefined ? context.create(external) : context.promote(projection.id);
|
|
214
|
-
return session === undefined
|
|
215
|
-
? { activity: 'UNAVAILABLE', failureCode: 'RUNNER_RESUME_FAILED' }
|
|
216
|
-
: { activity: 'IDLE', session: context.ensureConfiguration(session) };
|
|
217
|
-
}
|
|
218
|
-
async readExternalActivity(session) {
|
|
219
|
-
if (session.externalSessionId === null)
|
|
220
|
-
return 'UNAVAILABLE';
|
|
221
|
-
try {
|
|
222
|
-
const status = await this.client.sessionStatus(session.cwd);
|
|
223
|
-
const value = status[session.externalSessionId];
|
|
224
|
-
return value?.type === 'busy' || value?.type === 'retry'
|
|
225
|
-
? 'EXTERNAL_ACTIVE'
|
|
226
|
-
: value?.type === 'idle' || value === undefined
|
|
227
|
-
? 'IDLE'
|
|
228
|
-
: 'UNAVAILABLE';
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
231
|
-
return 'UNAVAILABLE';
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
async readOfficialConversation(session, input, managedTurn) {
|
|
235
|
-
if (session.externalSessionId === null)
|
|
236
|
-
return undefined;
|
|
237
|
-
try {
|
|
238
|
-
return openCodeConversationPage(session, await this.client.messages(session.cwd, session.externalSessionId, 500), input, managedTurn);
|
|
239
|
-
}
|
|
240
|
-
catch {
|
|
241
|
-
return undefined;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
async readConversationHistory(readers) {
|
|
245
|
-
const official = await readers.official();
|
|
246
|
-
return official === undefined ? undefined : { ...official, source: 'official' };
|
|
247
|
-
}
|
|
248
|
-
managedRunForNativeTurn(nativeTurnId) {
|
|
249
|
-
return this.managedTurns.get(nativeTurnId);
|
|
250
|
-
}
|
|
251
|
-
presentSession(session, capabilities, context) {
|
|
252
|
-
const available = capabilities.openCode?.available === true;
|
|
253
|
-
const managed = session.nativeControl === 'MAR_MANAGED';
|
|
254
|
-
const activity = context.managedActive
|
|
255
|
-
? 'MANAGED_ACTIVE'
|
|
256
|
-
: (context.externalActivity ?? (available ? 'IDLE' : 'UNAVAILABLE'));
|
|
257
|
-
if (!available)
|
|
258
|
-
return {
|
|
259
|
-
activity: 'UNAVAILABLE',
|
|
260
|
-
control: { level: 'UNAVAILABLE', capabilities: [] },
|
|
261
|
-
runtime: { level: 'UNAVAILABLE', capabilities: [], reasonCode: 'RUNNER_UNAVAILABLE' },
|
|
262
|
-
commandStates: context.commandStates
|
|
263
|
-
};
|
|
264
|
-
const runtimeCapabilities = [
|
|
265
|
-
'history.read',
|
|
266
|
-
'events.live',
|
|
267
|
-
'turn.start',
|
|
268
|
-
'turn.queue',
|
|
269
|
-
'turn.interrupt',
|
|
270
|
-
'run.cancel',
|
|
271
|
-
'approval.respond',
|
|
272
|
-
'user-input.respond',
|
|
273
|
-
'session.rename',
|
|
274
|
-
'session.remove',
|
|
275
|
-
'session.pin',
|
|
276
|
-
...(session.externalSessionId === null ? [] : ['session.rewind'])
|
|
277
|
-
];
|
|
278
|
-
return {
|
|
279
|
-
activity,
|
|
280
|
-
control: {
|
|
281
|
-
level: managed ? 'MANAGED' : activity === 'IDLE' ? 'RESUMABLE' : 'OBSERVE_ONLY',
|
|
282
|
-
capabilities: managed || activity === 'IDLE'
|
|
283
|
-
? ['history.read', 'events.live', 'turn.start', 'turn.interrupt']
|
|
284
|
-
: ['history.read', 'events.live']
|
|
285
|
-
},
|
|
286
|
-
runtime: {
|
|
287
|
-
level: managed ? 'MANAGED' : activity === 'IDLE' ? 'RESUMABLE' : 'OBSERVE_ONLY',
|
|
288
|
-
capabilities: runtimeCapabilities,
|
|
289
|
-
reasonCode: activity === 'EXTERNAL_ACTIVE' ? 'EXTERNAL_SESSION_OBSERVE_ONLY' : null
|
|
290
|
-
},
|
|
291
|
-
commandStates: context.commandStates
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
async renameNative(session, input, database) {
|
|
295
|
-
if (session.externalSessionId !== null && input.title !== undefined)
|
|
296
|
-
await this.client.updateSession(session.cwd, session.externalSessionId, input.title ?? '');
|
|
297
|
-
await super.renameNative(session, input, database);
|
|
298
|
-
}
|
|
299
|
-
async removeNative(session, nativeSessionId) {
|
|
300
|
-
await this.client.deleteSession(session.cwd, nativeSessionId);
|
|
301
|
-
return true;
|
|
302
|
-
}
|
|
303
|
-
async forkNative(session, boundary, title) {
|
|
304
|
-
if (session.externalSessionId === null)
|
|
305
|
-
throw new Error('SESSION_REWIND_UNAVAILABLE');
|
|
306
|
-
const result = boundary === null
|
|
307
|
-
? await this.client.createSession(session.cwd, title)
|
|
308
|
-
: await this.client.forkSession(session.cwd, session.externalSessionId, boundary);
|
|
309
|
-
const value = object(result);
|
|
310
|
-
if (typeof value?.id !== 'string')
|
|
311
|
-
throw new Error('SESSION_REWIND_FAILED');
|
|
312
|
-
if (boundary !== null)
|
|
313
|
-
await this.client.updateSession(session.cwd, value.id, title);
|
|
314
|
-
return value.id;
|
|
315
|
-
}
|
|
316
|
-
async executeCompact(session, environment) {
|
|
317
|
-
if (session.externalSessionId === null || session.model === null)
|
|
318
|
-
throw new Error('RUNNER_COMMAND_UNAVAILABLE');
|
|
319
|
-
const client = this.managedClient(environment);
|
|
320
|
-
try {
|
|
321
|
-
return await client.summarize(session.cwd, session.externalSessionId, session.model);
|
|
322
|
-
}
|
|
323
|
-
finally {
|
|
324
|
-
this.releaseManagedClient(client);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
async readContextUsage(session) {
|
|
328
|
-
if (session.externalSessionId === null)
|
|
329
|
-
return undefined;
|
|
330
|
-
const messages = await this.client.messages(session.cwd, session.externalSessionId, 100);
|
|
331
|
-
const assistants = messages.flatMap((value) => {
|
|
332
|
-
const entry = object(value);
|
|
333
|
-
const info = object(entry?.info);
|
|
334
|
-
return info?.role === 'assistant' ? [info] : [];
|
|
335
|
-
});
|
|
336
|
-
const latest = assistants.at(-1);
|
|
337
|
-
const provider = typeof latest?.providerID === 'string' ? latest.providerID : undefined;
|
|
338
|
-
const model = typeof latest?.modelID === 'string' ? latest.modelID : undefined;
|
|
339
|
-
const tokens = object(latest?.tokens);
|
|
340
|
-
const cache = object(tokens?.cache);
|
|
341
|
-
const usedTokens = positiveNumber(tokens?.input) + positiveNumber(cache?.read);
|
|
342
|
-
const modelId = provider !== undefined && model !== undefined ? `${provider}/${model}` : session.model;
|
|
343
|
-
const limits = [...this.contextLimitsByWorkspace].find(([workspacePath]) => isWithinWorkspace(session.cwd, workspacePath))?.[1];
|
|
344
|
-
const maxTokens = modelId === null ? undefined : limits?.get(modelId);
|
|
345
|
-
return maxTokens === undefined || usedTokens <= 0
|
|
346
|
-
? undefined
|
|
347
|
-
: { model: modelId, usedTokens, maxTokens };
|
|
348
|
-
}
|
|
349
|
-
async stop() {
|
|
350
|
-
for (const execution of this.execution.values())
|
|
351
|
-
execution.abort.abort();
|
|
352
|
-
this.execution.clear();
|
|
353
|
-
this.managedTurns.clear();
|
|
354
|
-
for (const timer of this.profileTimersByWorkspace.values())
|
|
355
|
-
clearTimeout(timer);
|
|
356
|
-
this.profileTimersByWorkspace.clear();
|
|
357
|
-
this.profileCache.clear();
|
|
358
|
-
this.profileRefreshes.clear();
|
|
359
|
-
this.modelsByWorkspace.clear();
|
|
360
|
-
this.contextLimitsByWorkspace.clear();
|
|
361
|
-
const stopping = [
|
|
362
|
-
this.client.stop(),
|
|
363
|
-
...[...this.environmentClients.values()].map(({ client }) => client.stop()),
|
|
364
|
-
...this.stoppingClients
|
|
365
|
-
];
|
|
366
|
-
this.environmentClients.clear();
|
|
367
|
-
await Promise.allSettled(stopping);
|
|
368
|
-
this.stoppingClients.clear();
|
|
369
|
-
}
|
|
370
|
-
scheduleProfileExpiry(workspacePath) {
|
|
371
|
-
this.clearProfileTimer(workspacePath);
|
|
372
|
-
const timer = setTimeout(() => {
|
|
373
|
-
this.profileTimersByWorkspace.delete(workspacePath);
|
|
374
|
-
this.modelsByWorkspace.delete(workspacePath);
|
|
375
|
-
this.contextLimitsByWorkspace.delete(workspacePath);
|
|
376
|
-
}, PROFILE_ENTRY_TTL_MS);
|
|
377
|
-
timer.unref();
|
|
378
|
-
this.profileTimersByWorkspace.set(workspacePath, timer);
|
|
379
|
-
}
|
|
380
|
-
clearProfileTimer(workspacePath) {
|
|
381
|
-
const timer = this.profileTimersByWorkspace.get(workspacePath);
|
|
382
|
-
if (timer !== undefined)
|
|
383
|
-
clearTimeout(timer);
|
|
384
|
-
this.profileTimersByWorkspace.delete(workspacePath);
|
|
385
|
-
}
|
|
386
|
-
managedClient(environment, isolationKey) {
|
|
387
|
-
const entries = Object.entries(environment).sort(([left], [right]) => left.localeCompare(right));
|
|
388
|
-
if (entries.length === 0 && isolationKey === undefined)
|
|
389
|
-
return this.client;
|
|
390
|
-
const fingerprint = createHash('sha256')
|
|
391
|
-
.update(JSON.stringify({ entries, isolationKey }))
|
|
392
|
-
.digest('hex');
|
|
393
|
-
const existing = this.environmentClients.get(fingerprint);
|
|
394
|
-
if (existing !== undefined) {
|
|
395
|
-
existing.leases += 1;
|
|
396
|
-
return existing.client;
|
|
397
|
-
}
|
|
398
|
-
const client = this.clientFactory();
|
|
399
|
-
client.configureEnvironment(environment);
|
|
400
|
-
this.environmentClients.set(fingerprint, { client, leases: 1 });
|
|
401
|
-
return client;
|
|
402
|
-
}
|
|
403
|
-
releaseManagedClient(client) {
|
|
404
|
-
if (client === this.client)
|
|
405
|
-
return;
|
|
406
|
-
for (const [fingerprint, entry] of this.environmentClients) {
|
|
407
|
-
if (entry.client !== client)
|
|
408
|
-
continue;
|
|
409
|
-
entry.leases -= 1;
|
|
410
|
-
if (entry.leases <= 0) {
|
|
411
|
-
const stopping = entry.client.stop();
|
|
412
|
-
this.stoppingClients.add(stopping);
|
|
413
|
-
void stopping.finally(() => this.stoppingClients.delete(stopping));
|
|
414
|
-
this.environmentClients.delete(fingerprint);
|
|
415
|
-
}
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
function object(value) {
|
|
421
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
422
|
-
? value
|
|
423
|
-
: undefined;
|
|
424
|
-
}
|
|
425
|
-
function positiveNumber(value) {
|
|
426
|
-
return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : 0;
|
|
427
|
-
}
|
|
428
|
-
function openCodeSession(value) {
|
|
429
|
-
if (typeof value !== 'object' || value === null)
|
|
430
|
-
return undefined;
|
|
431
|
-
const record = value;
|
|
432
|
-
const time = typeof record.time === 'object' && record.time !== null
|
|
433
|
-
? record.time
|
|
434
|
-
: undefined;
|
|
435
|
-
if (typeof record.id !== 'string' ||
|
|
436
|
-
typeof record.directory !== 'string' ||
|
|
437
|
-
typeof record.title !== 'string')
|
|
438
|
-
return undefined;
|
|
439
|
-
return {
|
|
440
|
-
id: record.id,
|
|
441
|
-
directory: record.directory,
|
|
442
|
-
title: record.title,
|
|
443
|
-
updatedAt: typeof time?.updated === 'number' ? time.updated : 0,
|
|
444
|
-
...(typeof record.parentID === 'string' && record.parentID.length > 0
|
|
445
|
-
? { parentId: record.parentID }
|
|
446
|
-
: {})
|
|
447
|
-
};
|
|
448
|
-
}
|
|
1
|
+
/* mar-release-protected */
|
|
2
|
+
const _0x39f737=_0x52fa;(function(_0xfaea53,_0x27e0a5){const _0x2a3b59=_0x52fa,_0x5e7029=_0xfaea53();while(!![]){try{const _0x5d10c3=-parseInt(_0x2a3b59(0x1f4))/(-0x16*-0x9+0x13*0x26+-0x397)+-parseInt(_0x2a3b59(0x166))/(-0xb54+-0x2057+0x2bad)*(-parseInt(_0x2a3b59(0x1b4))/(-0x1*-0xa45+-0x11f*0x7+0x269*-0x1))+-parseInt(_0x2a3b59(0x1d1))/(-0x2*0xc88+0x84c+0x10c8)+-parseInt(_0x2a3b59(0x217))/(0x22f5+0x2e6+-0x25d6)+parseInt(_0x2a3b59(0x1ee))/(0x1640+0x653*0x4+-0x7*0x6ca)+parseInt(_0x2a3b59(0x181))/(-0xc45*0x1+-0x2394+0x2fe0)*(-parseInt(_0x2a3b59(0x194))/(0xadf+0x1915*0x1+0x11f6*-0x2))+parseInt(_0x2a3b59(0x17f))/(-0x3f1*-0x9+0x209e+-0x2*0x2207);if(_0x5d10c3===_0x27e0a5)break;else _0x5e7029['push'](_0x5e7029['shift']());}catch(_0x1b15c9){_0x5e7029['push'](_0x5e7029['shift']());}}}(_0x465f,-0x508a0+-0x1*-0x74231+0x1ff12));function _0x465f(){const _0x2f0de2=['CNvUBMvYlM9Wzw5JB2rLlNbYB2zPBguUChjVDMLKzxjZlMnVBxbSzxrLza','t0zgsunjquW','ChjLC2vUDfnLC3nPB24','y2XHDwrLq29Kzq','surmrq','zMLSDgvY','yxzHAwXHyMXL','zM9YA05HDgL2zq','Aw5WDxq','tufoquDfra','CMvHzenVBNzLCNnHDgLVBKHPC3rVCNK','BwfUywDLzefJDgL2zq','C2vZC2LVBI5WAw4','DxnLCI1PBNb1Dc5YzxnWB25K','m095sfPyyG','BM93','C2vZC2LVBI5YzxDPBMq','CMvHzenVBNrLEhrvC2fNzq','y29UzMLNDxjLrw52AxjVBM1LBNq','ywXSu2v0DgXLza','zNjVBuvUDhjPzxm','ChjVzMLSzvrPBwvYC0j5v29YA3nWywnL','y2XLyxjqCM9MAwXLvgLTzxi','zgvMyxvSDenVBMzPz3vYyxrPB24','zgLZy292zxjtzxnZAw9UCW','y29TBwfUza','BgvUz3rO','yxjNCW','CM91BMq','tufsx01btKfhruq','zxHLy3v0Aw9U','y2fJAgvKtw9KzwXZ','Bw9KzwXZ','B3bLBMnVzgu','BgvHC2vZ','C2vZC2LVBI5Yzw5HBwu','z2v0','Aw5JBhvKzxm','ChjVDMLKzxjZ','BgLUDxG','AgvHzgvYCW','C2vZC2LVBLn0yxr1CW','CNvUBMvYlM9Wzw5JB2rLlNbYB2zPBguUy2fJAguTAgL0','mte2nJCYmePbu1zHrG','ChjVDMLKzxjjra','Bw9KzwXZqNLxB3jRC3bHy2u','BwfUywDLzfr1CM5Z','yxnZAxn0yw50','zgvMyxvSDa','zxzLBNrZlMXPDMu','CNvUBMvYlM9Wzw5JB2rLlNbYB2zPBguUC2LUz2XLlwzSAwDODc1QB2LUzwq','DMfSDwvZ','DxbKyxrLzef0','y29UDgv4DeXPBwL0C0j5v29YA3nWywnL','C29YDa','zw52AxjVBM1LBNq','D29YA3nWywnLCW','zMLUywXSEq','uLvotKvsx1voqvzbsuXbqKXf','u0vtu0LptL9srvDjtKrFvu5bvKfjtefcteu','CMvTB3zLtMf0AxzL','ChjVzMLSzunHy2HLs2v5','u1resu8','CMvHza','CMvHze9MzMLJAwfSq29UDMvYC2f0Aw9U','BMfTzq','DhvYBI5ZDgfYDa','ChjVzMLSzq','CMvHzev4DgvYBMfSqwn0AxzPDhK','y3jLyxrLu2vZC2LVBG','ChvZAa','t0jtrvjwrv9ptKXz','nda3mdy0AunsrwXN','zxH0zxjUywXtzxnZAw9Uswq','AxngAw5PDgu','BwnWq29UzMLNDxjHDgLVBG','tufoquDfrf9bq1rjvKu','CMvSzwfZzu1HBMfNzwrdBgLLBNq','mtq2mZK5CeXLA3b2','AxnbCNjHEq','C3vWCg9YDgvKrwzMB3j0CW','DgLTzq','Dg9Rzw5Z','BwfUywDLzenSAwvUDa','ywnJzxnZt3b0Aw9UCW','D29YA3nWywnLugf0Aa','zgvSzxrL','zMv0y2HqCM9MAwXL','uLvotKvsx0nptu1btKrFvu5bvKfjtefcteu','y2fJAgu','ywnJzxnZ','zw5ZDxjLq29UzMLNDxjHDgLVBG','CMvMCMvZAfbYB2zPBgu','uLvotKvsx1jfu1vnrv9gquLmruq','CNvUBMvY','yNvZEq','zw50CMLLCW','Aw5MBW','y2XPzw50','Bw9KzwW','DxbKyxrL','y3DK','CNvUlMnHBMnLBa','CgfYzw50swq','C2HHmJu2','C3rVCa','DxbKyxrLza','rvHurvjoquXFu0vtu0LptL9bq1rjvKu','zgLNzxn0','zgvSzxrLu2vZC2LVBG','y3jLyxrLuhjVAMvJDgLVBG','ywjVCNq','Bg9JywW','ody3ntvHqLj6qMy','ChjVAMvJDgLVBKzVCG','CM9Szq','DhjHBNnWB3j0','BwfUywDLzfj1BKzVCK5HDgL2zvr1CM4','B2zMAwnPywW','BwvZC2fNzxm','zxH0zxjUywXby3rPDML0Eq','ChjVzMLSzvjLzNjLC2HLCW','v09ss1nqqunfx1jfuvvjuKve','C29Tzq','mtGZnJq2A0TgyNfe','AwrSzq','CMv0CNK','B2jQzwn0','yxbWCM92ywWUCMvZCg9Uza','B3bLBKnVzgu','C2v0','zgLYzwn0B3j5','CMvUyw1LtMf0AxzL','DgL0Bgu','zw52AxjVBM1LBNrgAw5NzxjWCMLUDa','zM9YA1nLC3nPB24','C3rVChbPBMDdBgLLBNrZ','C3vWCg9YDhndB25MAwD1CMf0Aw9U','C2vZC2LVBNm','uKvtvu1bqKXf','CMvZDw1LrxH0zxjUywW','zxHLy3v0zunVBxbHy3q','AgLZDg9YEs5YzwfK','rvHurvjoquXFu0vtu0LptL9pqLnfuLzfx09otfK','DhvYBI5PBNrLCNj1Chq','C2vZC2LVBI5Yzw1VDMu','rvHurvjoquXFqunusvzf','y29UDgv4DeXPBwL0CW','DhLWzq','nJe1ota0mNbXrNbJwa','ChjVBw90zq','mtK1odGXt3PrtKrA','vu5bvKfjtefcteu','C2nOzwr1BgvqCM9MAwXLrxHWAxj5','zwzMB3j0','ChjVzMLSzunHy2HL','Cgf0Aa','zMLUza','ywrK','y2XPzw50rMfJDg9YEq','Dw5Yzwy','BMf0AxzLq29UDhjVBa','u0vtu0LptL9srvDjtKrFrKfjteve','DMfSAwrHDgLVBG','BwfW','DxbKyxrLu2vZC2LVBG','zMXHDe1HCa','Bw9KzwXjra','zw52AxjVBM1LBNrdBgLLBNrZ','C3vTBwfYAxPL','mZjitvPlt24','C3rYAw5NAwz5','CgfYzw50suq','CMvTB3rL','ChjVzMLSzuzVCLzHBgLKyxrPB24','DhvYBI5XDwv1zq','DxjS','CNvUBMvYlM9Wzw5JB2rLlNbYB2zPBguUChjVDMLKzxjZlMzHAwXLza','Agv4','C3rYAw5N','y29TBwfUzfn0yxrLCW','zgLZy292zxj5u2nVCgu','y3jLyxrL','BNvTyMvY','y29KzxG','zxHWAxjLC0f0','Bg9JywXLq29TCgfYzq','y2XLyxi'];_0x465f=function(){return _0x2f0de2;};return _0x465f();}import{OpenCodeServerClient}from'../opencode-server.js';import{openCodeContextLimits,openCodeProfileModels}from'../opencode-runtime.js';import{declaredRunnerProfiles}from'../runner-profiles.js';import{AbstractRunner}from'./abstract-runner.js';import{isWithinWorkspace}from'./codex/conversation-parser.js';import{createHash}from'node:crypto';function _0x52fa(_0x20391d,_0x1e6320){_0x20391d=_0x20391d-(0x1c1*-0x11+0x23*-0x109+0x35f*0x14);const _0x339c16=_0x465f();let _0x5c13b1=_0x339c16[_0x20391d];if(_0x52fa['FLNLik']===undefined){var _0x25825f=function(_0x356b7c){const _0x3e6996='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x46d659='',_0x696384='';for(let _0x15ed48=0x1164+-0xf99+-0x1cb,_0x3131b2,_0x5b4944,_0x262a59=-0x1*-0x1168+0x90+0x32*-0x5c;_0x5b4944=_0x356b7c['charAt'](_0x262a59++);~_0x5b4944&&(_0x3131b2=_0x15ed48%(0x2*-0xe8+-0x1*0x1d77+-0x1*-0x1f4b)?_0x3131b2*(-0x200f+0x2*-0xacf+0x35ed)+_0x5b4944:_0x5b4944,_0x15ed48++%(-0xe7e+-0x497+-0x1319*-0x1))?_0x46d659+=String['fromCharCode'](0x22b7+-0x1995+-0x823&_0x3131b2>>(-(0x907+-0x5b*0x19+-0x22)*_0x15ed48&0x41b*-0x4+0x596+-0x5*-0x22c)):0x1f98+-0x126f+-0xd29){_0x5b4944=_0x3e6996['indexOf'](_0x5b4944);}for(let _0x2056f3=-0x93d+-0x494+0x189*0x9,_0x494382=_0x46d659['length'];_0x2056f3<_0x494382;_0x2056f3++){_0x696384+='%'+('00'+_0x46d659['charCodeAt'](_0x2056f3)['toString'](-0x1217+0x17ec+-0xd3*0x7))['slice'](-(-0xef8+0x10fe+-0x3*0xac));}return decodeURIComponent(_0x696384);};_0x52fa['sGHAcK']=_0x25825f,_0x52fa['hWfOeb']={},_0x52fa['FLNLik']=!![];}const _0x48c9fb=_0x339c16[-0x148c+-0x6b*-0x5d+-0x1253];_0x52fa['uBvycR']!==_0x48c9fb&&(_0x52fa['hWfOeb']={},_0x52fa['uBvycR']=_0x48c9fb);const _0x2cf737=_0x52fa['hWfOeb'][_0x20391d];return _0x2cf737===undefined?(_0x5c13b1=_0x52fa['sGHAcK'](_0x5c13b1),_0x52fa['hWfOeb'][_0x20391d]=_0x5c13b1):_0x5c13b1=_0x2cf737,_0x5c13b1;}import{openCodeConversationPage}from'./opencode/conversation-parser.js';import{nodeLog}from'../operational.js';const PROFILE_ENTRY_TTL_MS=(-0x14ad+0x1*-0x22f+-0x1*-0x16fa)*(-0x1*0xd7e1+0x18394+0x1*0x3ead);export class OpenCodeRunner extends AbstractRunner{[_0x39f737(0x208)];[_0x39f737(0x189)];[_0x39f737(0x1e7)]=_0x39f737(0x1c7);[_0x39f737(0x19f)]=_0x39f737(0x164);[_0x39f737(0x1d3)]=new Map();[_0x39f737(0x1db)]=new Map();[_0x39f737(0x1bb)]=new Map();[_0x39f737(0x185)]=new Map();[_0x39f737(0x163)]=new Map();[_0x39f737(0x1c4)]=new Map();[_0x39f737(0x1d4)]=new Map();[_0x39f737(0x192)]=new Map();[_0x39f737(0x172)]=new Set();constructor(_0xdb236c=new OpenCodeServerClient(),_0x242e05=()=>new OpenCodeServerClient()){const _0x226f09=_0x39f737;super(),this[_0x226f09(0x208)]=_0xdb236c,this[_0x226f09(0x189)]=_0x242e05;}[_0x39f737(0x1e9)](_0x2182d9){const _0x16a479=_0x39f737,_0x40aad9=declaredRunnerProfiles({'codexAvailable':_0x2182d9[_0x16a479(0x1a2)][_0x16a479(0x1ac)],'claudeCodeAvailable':_0x2182d9[_0x16a479(0x1a9)][_0x16a479(0x1ac)],'openCodeAvailable':_0x2182d9[_0x16a479(0x16b)]?.[_0x16a479(0x1ac)]===!![]})[_0x16a479(0x187)](_0x34cab6=>_0x34cab6[_0x16a479(0x204)]===this[_0x16a479(0x1e7)]);return{..._0x40aad9,'models':[]};}async[_0x39f737(0x202)](_0x46a61f,_0x4dc871,_0x4a3e39={}){const _0x47d06b=_0x39f737;if(_0x46a61f[_0x47d06b(0x16b)]?.[_0x47d06b(0x1ac)]!==!![]||_0x4dc871===undefined)return this[_0x47d06b(0x1e9)](_0x46a61f);const _0x42a043=this[_0x47d06b(0x1e3)](_0x4dc871[_0x47d06b(0x186)],_0x4a3e39),_0x3fe849=Date[_0x47d06b(0x1b5)]();for(const [_0x328351,_0x7daf3a]of this[_0x47d06b(0x185)])if(_0x7daf3a[_0x47d06b(0x1a3)]<=_0x3fe849)this[_0x47d06b(0x185)][_0x47d06b(0x1fc)](_0x328351);const _0x37e9fa=this[_0x47d06b(0x185)][_0x47d06b(0x1ca)](_0x42a043);if(_0x37e9fa!==undefined)return nodeLog(_0x47d06b(0x1d0),{'workspaceId':_0x4dc871['id'],'models':_0x37e9fa[_0x47d06b(0x1c6)][_0x47d06b(0x1c0)],'remainingTtlMs':_0x37e9fa[_0x47d06b(0x1a3)]-_0x3fe849}),this[_0x47d06b(0x1d3)][_0x47d06b(0x16c)](_0x4dc871[_0x47d06b(0x186)],_0x37e9fa[_0x47d06b(0x1c6)]),this[_0x47d06b(0x1db)][_0x47d06b(0x16c)](_0x4dc871[_0x47d06b(0x186)],_0x37e9fa[_0x47d06b(0x17d)]),this[_0x47d06b(0x183)](_0x4dc871[_0x47d06b(0x186)]),{...this[_0x47d06b(0x1e9)](_0x46a61f),'models':_0x37e9fa[_0x47d06b(0x1c6)]};const _0x586e43=this[_0x47d06b(0x163)][_0x47d06b(0x1ca)](_0x42a043);if(_0x586e43!==undefined)return nodeLog(_0x47d06b(0x1d8),{'workspaceId':_0x4dc871['id']}),_0x586e43;const _0xd72bb0=this[_0x47d06b(0x1fd)](_0x46a61f,_0x4dc871,_0x4a3e39,_0x42a043)[_0x47d06b(0x1df)](()=>{const _0x4df10d=_0x47d06b;if(this[_0x4df10d(0x163)][_0x4df10d(0x1ca)](_0x42a043)===_0xd72bb0)this[_0x4df10d(0x163)][_0x4df10d(0x1fc)](_0x42a043);});return this[_0x47d06b(0x163)][_0x47d06b(0x16c)](_0x42a043,_0xd72bb0),_0xd72bb0;}async[_0x39f737(0x1fd)](_0x459b44,_0x47e585,_0x455ea5,_0x53ea3c){const _0xb4b7d2=_0x39f737,_0x57f39a=this[_0xb4b7d2(0x1f9)](_0x455ea5),_0x69991a=performance[_0xb4b7d2(0x1b5)]();try{const _0x5ae788=await _0x57f39a[_0xb4b7d2(0x1cc)](_0x47e585[_0xb4b7d2(0x186)]),_0x79950e=openCodeProfileModels(_0x5ae788),_0x33e268=openCodeContextLimits(_0x5ae788);return this[_0xb4b7d2(0x1d3)][_0xb4b7d2(0x16c)](_0x47e585[_0xb4b7d2(0x186)],_0x79950e),this[_0xb4b7d2(0x1db)][_0xb4b7d2(0x16c)](_0x47e585[_0xb4b7d2(0x186)],_0x33e268),this[_0xb4b7d2(0x185)][_0xb4b7d2(0x16c)](_0x53ea3c,{'expiresAt':Date[_0xb4b7d2(0x1b5)]()+PROFILE_ENTRY_TTL_MS,'workspacePath':_0x47e585[_0xb4b7d2(0x186)],'environmentFingerprint':this[_0xb4b7d2(0x170)](_0x455ea5),'models':_0x79950e,'contextLimits':_0x33e268}),this[_0xb4b7d2(0x183)](_0x47e585[_0xb4b7d2(0x186)]),nodeLog(_0xb4b7d2(0x1a6),{'workspaceId':_0x47e585['id'],'models':_0x79950e[_0xb4b7d2(0x1c0)],'durationMs':Math[_0xb4b7d2(0x1c2)](performance[_0xb4b7d2(0x1b5)]()-_0x69991a)}),{...this[_0xb4b7d2(0x1e9)](_0x459b44),'models':_0x79950e};}catch{nodeLog(_0xb4b7d2(0x19b),{'workspaceId':_0x47e585['id'],'durationMs':Math[_0xb4b7d2(0x1c2)](performance[_0xb4b7d2(0x1b5)]()-_0x69991a)});}finally{this[_0xb4b7d2(0x1f3)](_0x57f39a);}return this[_0xb4b7d2(0x1e9)](_0x459b44);}[_0x39f737(0x1e3)](_0x1bc81f,_0x17cfc7){const _0x4aca69=_0x39f737;return createHash(_0x4aca69(0x20e))[_0x4aca69(0x20a)](JSON[_0x4aca69(0x195)]({'workspacePath':_0x1bc81f,'environment':this[_0x4aca69(0x170)](_0x17cfc7)}))[_0x4aca69(0x212)](_0x4aca69(0x19c));}[_0x39f737(0x170)](_0x3531de){const _0x151e61=_0x39f737,_0x3d96b1=Object[_0x151e61(0x206)](_0x3531de)[_0x151e61(0x1dc)](([_0x39b83d],[_0x709a06])=>_0x39b83d[_0x151e61(0x1a4)](_0x709a06));return createHash(_0x151e61(0x20e))[_0x151e61(0x20a)](JSON[_0x151e61(0x195)](_0x3d96b1))[_0x151e61(0x212)](_0x151e61(0x19c));}[_0x39f737(0x1ac)](_0x5a0c42){const _0x5cc847=_0x39f737;return _0x5a0c42[_0x5cc847(0x16b)]?.[_0x5cc847(0x1ac)]===!![];}[_0x39f737(0x198)](){const _0x21389d=_0x39f737;return this[_0x21389d(0x1e9)]({'platform':_0x21389d(0x1cd),'architecture':_0x21389d(0x18d),'nodeAppVersion':_0x21389d(0x18d),'nodeVersion':_0x21389d(0x18d),'codex':{'available':![]},'claudeCode':{'available':![]},'openCode':{'available':!![]}});}[_0x39f737(0x173)](_0x4e9597,_0x132283,_0x48997b={}){const _0x5569bc=_0x39f737;if(_0x4e9597[_0x5569bc(0x204)]!==this[_0x5569bc(0x1e7)])return![];const _0x53b552=this[_0x5569bc(0x1c5)](_0x132283,_0x48997b),_0x532ed8=_0x53b552[_0x5569bc(0x187)](_0x38c342=>_0x38c342['id']===_0x4e9597[_0x5569bc(0x209)]);return _0x532ed8!==undefined&&(_0x532ed8[_0x5569bc(0x1f6)][_0x5569bc(0x1c0)]===-0xc*-0x10e+-0x951+-0x357||_0x532ed8[_0x5569bc(0x1f6)][_0x5569bc(0x1cb)](_0x4e9597[_0x5569bc(0x184)]))&&this[_0x5569bc(0x198)]()[_0x5569bc(0x1fa)][_0x5569bc(0x165)](_0x47396a=>_0x47396a['id']===_0x4e9597[_0x5569bc(0x200)]);}[_0x39f737(0x1bd)](_0x239428,_0x5a786c={}){const _0x568e2c=_0x39f737,_0x5e0908=this[_0x568e2c(0x1c5)](_0x239428,_0x5a786c)[-0x1*0x25f9+0x1dfd+0x7fc];return{'runner':this[_0x568e2c(0x1e7)],'model':_0x5e0908?.['id']??'','effort':_0x5e0908?.[_0x568e2c(0x1f6)][-0x2a1*0xd+-0x27*0xb+0x23da]??'','access':_0x568e2c(0x1d6)};}[_0x39f737(0x1c5)](_0x30c924,_0x313396){const _0x50fb16=_0x39f737,_0xc09039=this[_0x50fb16(0x170)](_0x313396),_0x23ac56=Date[_0x50fb16(0x1b5)]();return[...this[_0x50fb16(0x185)][_0x50fb16(0x1d9)]()][_0x50fb16(0x1ab)](_0x466459=>_0x466459[_0x50fb16(0x1a3)]>_0x23ac56&&_0x466459[_0x50fb16(0x170)]===_0xc09039&&(_0x30c924===undefined||_0x466459[_0x50fb16(0x1fb)]===_0x30c924[_0x50fb16(0x186)]))[_0x50fb16(0x190)](_0x374f5e=>_0x374f5e[_0x50fb16(0x1c6)]);}[_0x39f737(0x1f1)](_0x173e80,_0x1a9592){const _0x238ed9=_0x39f737,_0x3c7617=super[_0x238ed9(0x1f1)](_0x173e80,_0x1a9592);return Object[_0x238ed9(0x1ba)](_0x3c7617[_0x238ed9(0x18e)](_0x3c1d1a=>[_0x3c1d1a[_0x238ed9(0x1e7)],_0x3c1d1a[_0x238ed9(0x21a)]===_0x238ed9(0x1e4)?{'type':_0x238ed9(0x216),'command':[_0x3c1d1a[_0x238ed9(0x1bf)],..._0x3c1d1a[_0x238ed9(0x1c1)]??[]],'environment':{..._0x3c1d1a[_0x238ed9(0x1dd)]??{}}}:{'type':_0x238ed9(0x197),'url':_0x3c1d1a[_0x238ed9(0x19a)],'headers':{..._0x3c1d1a[_0x238ed9(0x1ce)]??{}},'oauth':![]}]));}async[_0x39f737(0x1be)](_0x204b6a,_0x488fda){const _0x1ca6fe=_0x39f737,_0x565ba0=[];for(const _0x174faf of _0x488fda===undefined?_0x204b6a[_0x1ca6fe(0x1de)]:[_0x488fda]){let _0x43c247;try{_0x43c247=await this[_0x1ca6fe(0x208)][_0x1ca6fe(0x174)](_0x174faf[_0x1ca6fe(0x186)]);}catch{continue;}for(const _0x2ff992 of _0x43c247){const _0x36a491=openCodeSession(_0x2ff992);if(_0x36a491===undefined||_0x36a491[_0x1ca6fe(0x20d)]!==undefined||!isWithinWorkspace(_0x36a491[_0x1ca6fe(0x16d)],_0x174faf[_0x1ca6fe(0x186)]))continue;_0x565ba0[_0x1ca6fe(0x1ec)](_0x204b6a[_0x1ca6fe(0x214)]({'workspace':_0x174faf,'runner':this[_0x1ca6fe(0x1e7)],'externalSessionId':_0x36a491['id'],'cwd':_0x36a491[_0x1ca6fe(0x16d)],'title':_0x36a491[_0x1ca6fe(0x16f)],'titleOrigin':_0x1ca6fe(0x1a7),'lastActivityAt':_0x36a491[_0x1ca6fe(0x1da)]}));}}return _0x565ba0;}async[_0x39f737(0x176)](_0x30393b,_0x5a92c6){const _0x39e929=_0x39f737;if(_0x30393b[_0x39e929(0x204)]!==this[_0x39e929(0x1e7)]||_0x30393b[_0x39e929(0x1ef)]===null||!_0x5a92c6[_0x39e929(0x1ac)])return{'failureCode':_0x39e929(0x1e0)};const _0x17f4d0=await this[_0x39e929(0x1ea)](_0x30393b);if(_0x17f4d0!==_0x39e929(0x1aa))return{'activity':_0x17f4d0??_0x39e929(0x182),'failureCode':_0x17f4d0===_0x39e929(0x17c)?_0x39e929(0x211):_0x39e929(0x203)};const _0xfb4682=_0x5a92c6[_0x39e929(0x218)](_0x30393b),_0x2d16a3=_0xfb4682===undefined?_0x5a92c6[_0x39e929(0x1a0)](_0x30393b):_0x5a92c6[_0x39e929(0x180)](_0xfb4682['id']);return _0x2d16a3===undefined?{'activity':_0x39e929(0x182),'failureCode':_0x39e929(0x203)}:{'activity':_0x39e929(0x1aa),'session':_0x5a92c6[_0x39e929(0x201)](_0x2d16a3)};}async[_0x39f737(0x1ea)](_0x220beb){const _0x11f3ac=_0x39f737;if(_0x220beb[_0x11f3ac(0x1ef)]===null)return _0x11f3ac(0x182);try{const _0x1f237a=await this[_0x11f3ac(0x208)][_0x11f3ac(0x1cf)](_0x220beb[_0x11f3ac(0x20b)]),_0x3b4200=_0x1f237a[_0x220beb[_0x11f3ac(0x1ef)]];return _0x3b4200?.[_0x11f3ac(0x17e)]===_0x11f3ac(0x205)||_0x3b4200?.[_0x11f3ac(0x17e)]===_0x11f3ac(0x168)?_0x11f3ac(0x17c):_0x3b4200?.[_0x11f3ac(0x17e)]===_0x11f3ac(0x167)||_0x3b4200===undefined?_0x11f3ac(0x1aa):_0x11f3ac(0x182);}catch{return _0x11f3ac(0x182);}}async[_0x39f737(0x1e6)](_0x237245,_0x87de1e,_0x1ef32c){const _0x491526=_0x39f737;if(_0x237245[_0x491526(0x1ef)]===null)return undefined;try{return openCodeConversationPage(_0x237245,await this[_0x491526(0x208)][_0x491526(0x161)](_0x237245[_0x491526(0x20b)],_0x237245[_0x491526(0x1ef)],-0x3*0x56b+-0x1982+-0x169*-0x1f),_0x87de1e,_0x1ef32c);}catch{return undefined;}}async[_0x39f737(0x1b0)](_0x58713d){const _0x46d144=_0x39f737,_0x2595ef=await _0x58713d[_0x46d144(0x160)]();return _0x2595ef===undefined?undefined:{..._0x2595ef,'source':_0x46d144(0x160)};}[_0x39f737(0x21b)](_0x670867){const _0x144b5b=_0x39f737;return this[_0x144b5b(0x1d4)][_0x144b5b(0x1ca)](_0x670867);}[_0x39f737(0x1a8)](_0x1e1849,_0x1d3b83,_0x8f7944){const _0x5e3338=_0x39f737,_0x3f7f1c=_0x1d3b83[_0x5e3338(0x16b)]?.[_0x5e3338(0x1ac)]===!![],_0x25306f=_0x1e1849[_0x5e3338(0x18b)]===_0x5e3338(0x1c3),_0x25d5fb=_0x8f7944[_0x5e3338(0x1b1)]?_0x5e3338(0x1f2):_0x8f7944[_0x5e3338(0x162)]??(_0x3f7f1c?_0x5e3338(0x1aa):_0x5e3338(0x182));if(!_0x3f7f1c)return{'activity':_0x5e3338(0x182),'control':{'level':_0x5e3338(0x182),'capabilities':[]},'runtime':{'level':_0x5e3338(0x182),'capabilities':[],'reasonCode':_0x5e3338(0x1e0)},'commandStates':_0x8f7944[_0x5e3338(0x19e)]};const _0x31e4f3=[_0x5e3338(0x178),_0x5e3338(0x1d7),_0x5e3338(0x1e8),_0x5e3338(0x199),_0x5e3338(0x17a),_0x5e3338(0x20c),_0x5e3338(0x16a),_0x5e3338(0x1b3),_0x5e3338(0x1c9),_0x5e3338(0x17b),_0x5e3338(0x1b2),..._0x1e1849[_0x5e3338(0x1ef)]===null?[]:[_0x5e3338(0x1b6)]];return{'activity':_0x25d5fb,'control':{'level':_0x25306f?_0x5e3338(0x1af):_0x25d5fb===_0x5e3338(0x1aa)?_0x5e3338(0x175):_0x5e3338(0x1ed),'capabilities':_0x25306f||_0x25d5fb===_0x5e3338(0x1aa)?[_0x5e3338(0x178),_0x5e3338(0x1d7),_0x5e3338(0x1e8),_0x5e3338(0x17a)]:[_0x5e3338(0x178),_0x5e3338(0x1d7)]},'runtime':{'level':_0x25306f?_0x5e3338(0x1af):_0x25d5fb===_0x5e3338(0x1aa)?_0x5e3338(0x175):_0x5e3338(0x1ed),'capabilities':_0x31e4f3,'reasonCode':_0x25d5fb===_0x5e3338(0x17c)?_0x5e3338(0x179):null},'commandStates':_0x8f7944[_0x5e3338(0x19e)]};}async[_0x39f737(0x16e)](_0x4a3893,_0x408a57,_0x30ecf2){const _0x19da85=_0x39f737;if(_0x4a3893[_0x19da85(0x1ef)]!==null&&_0x408a57[_0x19da85(0x16f)]!==undefined)await this[_0x19da85(0x208)][_0x19da85(0x18f)](_0x4a3893[_0x19da85(0x20b)],_0x4a3893[_0x19da85(0x1ef)],_0x408a57[_0x19da85(0x16f)]??'');await super[_0x19da85(0x16e)](_0x4a3893,_0x408a57,_0x30ecf2);}async[_0x39f737(0x1e2)](_0x338941,_0x2ccdbc){const _0x526be5=_0x39f737;return await this[_0x526be5(0x208)][_0x526be5(0x213)](_0x338941[_0x526be5(0x20b)],_0x2ccdbc),!![];}async[_0x39f737(0x1ad)](_0x37b6c2,_0x2687cb,_0x1daf57){const _0x10576c=_0x39f737;if(_0x37b6c2[_0x10576c(0x1ef)]===null)throw new Error(_0x10576c(0x1e1));const _0x1bc71e=_0x2687cb===null?await this[_0x10576c(0x208)][_0x10576c(0x1eb)](_0x37b6c2[_0x10576c(0x20b)],_0x1daf57):await this[_0x10576c(0x208)][_0x10576c(0x171)](_0x37b6c2[_0x10576c(0x20b)],_0x37b6c2[_0x10576c(0x1ef)],_0x2687cb),_0x311689=object(_0x1bc71e);if(typeof _0x311689?.['id']!==_0x10576c(0x19d))throw new Error(_0x10576c(0x18c));if(_0x2687cb!==null)await this[_0x10576c(0x208)][_0x10576c(0x18f)](_0x37b6c2[_0x10576c(0x20b)],_0x311689['id'],_0x1daf57);return _0x311689['id'];}async[_0x39f737(0x177)](_0x1a7649,_0x5c22cd){const _0x331fbf=_0x39f737;if(_0x1a7649[_0x331fbf(0x1ef)]===null||_0x1a7649[_0x331fbf(0x209)]===null)throw new Error(_0x331fbf(0x1fe));const _0x24d1f1=this[_0x331fbf(0x1f9)](_0x5c22cd);try{return await _0x24d1f1[_0x331fbf(0x193)](_0x1a7649[_0x331fbf(0x20b)],_0x1a7649[_0x331fbf(0x1ef)],_0x1a7649[_0x331fbf(0x209)]);}finally{this[_0x331fbf(0x1f3)](_0x24d1f1);}}async[_0x39f737(0x1b7)](_0x57e9a1){const _0x64f6d4=_0x39f737;if(_0x57e9a1[_0x64f6d4(0x1ef)]===null)return undefined;const _0x4838c5=await this[_0x64f6d4(0x208)][_0x64f6d4(0x161)](_0x57e9a1[_0x64f6d4(0x20b)],_0x57e9a1[_0x64f6d4(0x1ef)],0x2051*-0x1+-0x836*0x2+-0x1*-0x3121),_0x4a6da7=_0x4838c5[_0x64f6d4(0x190)](_0x10ba96=>{const _0x5a7978=_0x64f6d4,_0x11bb28=object(_0x10ba96),_0x4cdb86=object(_0x11bb28?.[_0x5a7978(0x207)]);return _0x4cdb86?.[_0x5a7978(0x219)]===_0x5a7978(0x1d5)?[_0x4cdb86]:[];}),_0x2fa344=_0x4a6da7['at'](-(0x1f98+-0x126f+-0xd28)),_0xe6f6c6=typeof _0x2fa344?.[_0x64f6d4(0x1d2)]===_0x64f6d4(0x19d)?_0x2fa344[_0x64f6d4(0x1d2)]:undefined,_0x59cd87=typeof _0x2fa344?.[_0x64f6d4(0x191)]===_0x64f6d4(0x19d)?_0x2fa344[_0x64f6d4(0x191)]:undefined,_0x590b01=object(_0x2fa344?.[_0x64f6d4(0x1f8)]),_0x17a628=object(_0x590b01?.[_0x64f6d4(0x1ff)]),_0x1bf7c1=positiveNumber(_0x590b01?.[_0x64f6d4(0x1ae)])+positiveNumber(_0x17a628?.[_0x64f6d4(0x1e5)]),_0x3490a3=_0xe6f6c6!==undefined&&_0x59cd87!==undefined?_0xe6f6c6+'/'+_0x59cd87:_0x57e9a1[_0x64f6d4(0x209)],_0x1d2741=[...this[_0x64f6d4(0x1db)]][_0x64f6d4(0x187)](([_0x120604])=>isWithinWorkspace(_0x57e9a1[_0x64f6d4(0x20b)],_0x120604))?.[-0x93d+-0x494+0x7a*0x1d],_0x4a06b5=_0x3490a3===null?undefined:_0x1d2741?.[_0x64f6d4(0x1ca)](_0x3490a3);return _0x4a06b5===undefined||_0x1bf7c1<=-0x1217+0x17ec+-0x5d5*0x1?undefined:{'model':_0x3490a3,'usedTokens':_0x1bf7c1,'maxTokens':_0x4a06b5};}async[_0x39f737(0x20f)](){const _0xe22d1d=_0x39f737;for(const _0x1062bb of this[_0xe22d1d(0x1c4)][_0xe22d1d(0x1d9)]())_0x1062bb[_0xe22d1d(0x215)][_0xe22d1d(0x215)]();this[_0xe22d1d(0x1c4)][_0xe22d1d(0x1a5)](),this[_0xe22d1d(0x1d4)][_0xe22d1d(0x1a5)]();for(const _0x2b36f7 of this[_0xe22d1d(0x1bb)][_0xe22d1d(0x1d9)]())clearTimeout(_0x2b36f7);this[_0xe22d1d(0x1bb)][_0xe22d1d(0x1a5)](),this[_0xe22d1d(0x185)][_0xe22d1d(0x1a5)](),this[_0xe22d1d(0x163)][_0xe22d1d(0x1a5)](),this[_0xe22d1d(0x1d3)][_0xe22d1d(0x1a5)](),this[_0xe22d1d(0x1db)][_0xe22d1d(0x1a5)]();const _0x3f77aa=[this[_0xe22d1d(0x208)][_0xe22d1d(0x20f)](),...[...this[_0xe22d1d(0x192)][_0xe22d1d(0x1d9)]()][_0xe22d1d(0x18e)](({client:_0x4d3ae7})=>_0x4d3ae7[_0xe22d1d(0x20f)]()),...this[_0xe22d1d(0x172)]];this[_0xe22d1d(0x192)][_0xe22d1d(0x1a5)](),await Promise[_0xe22d1d(0x1b9)](_0x3f77aa),this[_0xe22d1d(0x172)][_0xe22d1d(0x1a5)]();}[_0x39f737(0x183)](_0x45218a){const _0x2adb8d=_0x39f737;this[_0x2adb8d(0x1bc)](_0x45218a);const _0x1b8b3f=setTimeout(()=>{const _0x41b4c9=_0x2adb8d;this[_0x41b4c9(0x1bb)][_0x41b4c9(0x1fc)](_0x45218a),this[_0x41b4c9(0x1d3)][_0x41b4c9(0x1fc)](_0x45218a),this[_0x41b4c9(0x1db)][_0x41b4c9(0x1fc)](_0x45218a);},PROFILE_ENTRY_TTL_MS);_0x1b8b3f[_0x2adb8d(0x18a)](),this[_0x2adb8d(0x1bb)][_0x2adb8d(0x16c)](_0x45218a,_0x1b8b3f);}[_0x39f737(0x1bc)](_0x24798b){const _0x11d2c5=_0x39f737,_0x58f7ba=this[_0x11d2c5(0x1bb)][_0x11d2c5(0x1ca)](_0x24798b);if(_0x58f7ba!==undefined)clearTimeout(_0x58f7ba);this[_0x11d2c5(0x1bb)][_0x11d2c5(0x1fc)](_0x24798b);}[_0x39f737(0x1f9)](_0x107ae4,_0x689077){const _0x1e4017=_0x39f737,_0x4f8fa=Object[_0x1e4017(0x206)](_0x107ae4)[_0x1e4017(0x1dc)](([_0x4481b3],[_0x4554a4])=>_0x4481b3[_0x1e4017(0x1a4)](_0x4554a4));if(_0x4f8fa[_0x1e4017(0x1c0)]===-0xef8+0x10fe+-0x2*0x103&&_0x689077===undefined)return this[_0x1e4017(0x208)];const _0x270045=createHash(_0x1e4017(0x20e))[_0x1e4017(0x20a)](JSON[_0x1e4017(0x195)]({'entries':_0x4f8fa,'isolationKey':_0x689077}))[_0x1e4017(0x212)](_0x1e4017(0x19c)),_0x24e412=this[_0x1e4017(0x192)][_0x1e4017(0x1ca)](_0x270045);if(_0x24e412!==undefined)return _0x24e412[_0x1e4017(0x1c8)]+=-0x148c+-0x6b*-0x5d+-0x1252,_0x24e412[_0x1e4017(0x208)];const _0x4c3c99=this[_0x1e4017(0x189)]();return _0x4c3c99[_0x1e4017(0x1b8)](_0x107ae4),this[_0x1e4017(0x192)][_0x1e4017(0x16c)](_0x270045,{'client':_0x4c3c99,'leases':0x1}),_0x4c3c99;}[_0x39f737(0x1f3)](_0x15a283){const _0x3ac550=_0x39f737;if(_0x15a283===this[_0x3ac550(0x208)])return;for(const [_0x1ca1cd,_0x1cd088]of this[_0x3ac550(0x192)]){if(_0x1cd088[_0x3ac550(0x208)]!==_0x15a283)continue;_0x1cd088[_0x3ac550(0x1c8)]-=0xcac*-0x1+-0xe2d+-0x1*-0x1ada;if(_0x1cd088[_0x3ac550(0x1c8)]<=-0x2456*0x1+0xc10+0x1846*0x1){const _0x2fab62=_0x1cd088[_0x3ac550(0x208)][_0x3ac550(0x20f)]();this[_0x3ac550(0x172)][_0x3ac550(0x188)](_0x2fab62),void _0x2fab62[_0x3ac550(0x1df)](()=>this[_0x3ac550(0x172)][_0x3ac550(0x1fc)](_0x2fab62)),this[_0x3ac550(0x192)][_0x3ac550(0x1fc)](_0x1ca1cd);}return;}}}function object(_0x426743){const _0x4fa366=_0x39f737;return typeof _0x426743===_0x4fa366(0x169)&&_0x426743!==null&&!Array[_0x4fa366(0x1f5)](_0x426743)?_0x426743:undefined;}function positiveNumber(_0x369453){const _0x412fa0=_0x39f737;return typeof _0x369453===_0x412fa0(0x1a1)&&Number[_0x412fa0(0x1f0)](_0x369453)&&_0x369453>0x7cd*-0x1+-0xc93+0x1460*0x1?_0x369453:0x1f0+-0x3e*0x8a+0x1f7c;}function openCodeSession(_0x4d2a06){const _0x130790=_0x39f737;if(typeof _0x4d2a06!==_0x130790(0x169)||_0x4d2a06===null)return undefined;const _0x986b33=_0x4d2a06,_0x2d406f=typeof _0x986b33[_0x130790(0x1f7)]===_0x130790(0x169)&&_0x986b33[_0x130790(0x1f7)]!==null?_0x986b33[_0x130790(0x1f7)]:undefined;if(typeof _0x986b33['id']!==_0x130790(0x19d)||typeof _0x986b33[_0x130790(0x16d)]!==_0x130790(0x19d)||typeof _0x986b33[_0x130790(0x16f)]!==_0x130790(0x19d))return undefined;return{'id':_0x986b33['id'],'directory':_0x986b33[_0x130790(0x16d)],'title':_0x986b33[_0x130790(0x16f)],'updatedAt':typeof _0x2d406f?.[_0x130790(0x210)]===_0x130790(0x1a1)?_0x2d406f[_0x130790(0x210)]:0x159b*0x1+0x22eb+-0x5*0xb4e,...typeof _0x986b33[_0x130790(0x196)]===_0x130790(0x19d)&&_0x986b33[_0x130790(0x196)][_0x130790(0x1c0)]>-0x8b6+-0x3a6+-0x71*-0x1c?{'parentId':_0x986b33[_0x130790(0x196)]}:{}};}
|
|
@@ -1,90 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export class RunnerRegistry {
|
|
3
|
-
runners = new Map();
|
|
4
|
-
constructor(runners = []) {
|
|
5
|
-
for (const runner of runners)
|
|
6
|
-
this.register(runner);
|
|
7
|
-
}
|
|
8
|
-
register(runner) {
|
|
9
|
-
if (this.runners.has(runner.name))
|
|
10
|
-
throw new Error(`RUNNER_ALREADY_REGISTERED:${runner.name}`);
|
|
11
|
-
this.runners.set(runner.name, runner);
|
|
12
|
-
return runner;
|
|
13
|
-
}
|
|
14
|
-
optional(name) {
|
|
15
|
-
return this.runners.get(name);
|
|
16
|
-
}
|
|
17
|
-
require(name) {
|
|
18
|
-
const runner = this.optional(name);
|
|
19
|
-
if (runner === undefined)
|
|
20
|
-
throw new Error(`RUNNER_NOT_REGISTERED:${name}`);
|
|
21
|
-
return runner;
|
|
22
|
-
}
|
|
23
|
-
advertised() {
|
|
24
|
-
return [...this.runners.values()].filter((runner) => runner.advertised);
|
|
25
|
-
}
|
|
26
|
-
product(name) {
|
|
27
|
-
if (typeof name !== 'string')
|
|
28
|
-
return undefined;
|
|
29
|
-
const runner = this.runners.get(name);
|
|
30
|
-
return runner?.advertised === true ? runner : undefined;
|
|
31
|
-
}
|
|
32
|
-
profiles(capabilities) {
|
|
33
|
-
return this.advertised().flatMap((runner) => {
|
|
34
|
-
const profile = runner.profile(capabilities);
|
|
35
|
-
return profile === undefined ? [] : [profile];
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async refreshProfiles(capabilities, workspace, environment = {}) {
|
|
39
|
-
const profiles = await Promise.all(this.advertised().map(async (runner) => {
|
|
40
|
-
const startedAt = performance.now();
|
|
41
|
-
try {
|
|
42
|
-
return await runner.refreshProfile(capabilities, workspace, environment);
|
|
43
|
-
}
|
|
44
|
-
finally {
|
|
45
|
-
const durationMs = Math.round(performance.now() - startedAt);
|
|
46
|
-
if (durationMs >= 100)
|
|
47
|
-
nodeLog('runner.profile.refresh.completed', {
|
|
48
|
-
runner: runner.name,
|
|
49
|
-
workspaceId: workspace?.id,
|
|
50
|
-
durationMs
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
return profiles.flatMap((profile) => (profile === undefined ? [] : [profile]));
|
|
55
|
-
}
|
|
56
|
-
supportsConfiguration(configuration, workspace, environment) {
|
|
57
|
-
return (this.product(configuration.runner)?.supportsConfiguration(configuration, workspace, environment) === true);
|
|
58
|
-
}
|
|
59
|
-
startManagedRun(envelope) {
|
|
60
|
-
const runnerName = envelope.payload.runner;
|
|
61
|
-
const values = [...this.runners.values()];
|
|
62
|
-
const runner = values.find((candidate) => candidate.interceptsRuns && candidate.acceptsRun(runnerName)) ??
|
|
63
|
-
values.find((candidate) => candidate.acceptsRun(runnerName));
|
|
64
|
-
if (runner === undefined)
|
|
65
|
-
return false;
|
|
66
|
-
runner.startManagedRun(envelope);
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
cancelManagedRun(runId, intent) {
|
|
70
|
-
for (const runner of this.runners.values())
|
|
71
|
-
if (runner.cancelManagedRun(runId, intent))
|
|
72
|
-
return true;
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
decideApproval(input) {
|
|
76
|
-
let handled = false;
|
|
77
|
-
for (const runner of this.runners.values())
|
|
78
|
-
handled = runner.decideApproval(input) || handled;
|
|
79
|
-
return handled;
|
|
80
|
-
}
|
|
81
|
-
respondUserInput(runId, requestId, answers) {
|
|
82
|
-
for (const runner of this.runners.values())
|
|
83
|
-
if (runner.respondUserInput(runId, requestId, answers))
|
|
84
|
-
return true;
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
async stop() {
|
|
88
|
-
await Promise.allSettled([...this.runners.values()].map((runner) => runner.stop()));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
/* mar-release-protected */
|
|
2
|
+
function _0x1504(_0x396d6e,_0x4f64a9){_0x396d6e=_0x396d6e-(-0x43*-0x41+-0x5b3*0x1+0x21d*-0x5);const _0x5ba9d0=_0x3c2a();let _0x244962=_0x5ba9d0[_0x396d6e];if(_0x1504['SMTVCj']===undefined){var _0x1e5113=function(_0x441093){const _0x3ef53a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x18b0a1='',_0x4c6176='';for(let _0x21db07=-0x1*0xbe1+0x5*0xf1+-0x396*-0x2,_0x4b09e8,_0x7976cb,_0x55295f=0x9*-0x2a6+0x2047+-0x871;_0x7976cb=_0x441093['charAt'](_0x55295f++);~_0x7976cb&&(_0x4b09e8=_0x21db07%(0x656+-0x231a+-0x133*-0x18)?_0x4b09e8*(0x1b72+0x1013*0x1+-0x1*0x2b45)+_0x7976cb:_0x7976cb,_0x21db07++%(-0x2019+0x7fc+0x1821))?_0x18b0a1+=String['fromCharCode'](-0x1*-0x971+0x2*0xdfa+0x2466*-0x1&_0x4b09e8>>(-(0x1db6+-0xd*0x1b7+-0x769)*_0x21db07&-0x1*0x17ae+-0x1521+0x2cd5)):0x16dd+0x1f88+-0x22d*0x19){_0x7976cb=_0x3ef53a['indexOf'](_0x7976cb);}for(let _0x19050d=-0x61a*-0x2+-0x9e8+-0xc*0x31,_0x354fee=_0x18b0a1['length'];_0x19050d<_0x354fee;_0x19050d++){_0x4c6176+='%'+('00'+_0x18b0a1['charCodeAt'](_0x19050d)['toString'](0xd15*0x1+-0xeef*0x2+0x10d9))['slice'](-(0x2*0xbc+-0x2639+0x24c3));}return decodeURIComponent(_0x4c6176);};_0x1504['DRBywM']=_0x1e5113,_0x1504['iBFbTv']={},_0x1504['SMTVCj']=!![];}const _0x46ebb6=_0x5ba9d0[0x115*0xb+-0xc7*0x2b+-0x5*-0x44e];_0x1504['rwSvgT']!==_0x46ebb6&&(_0x1504['iBFbTv']={},_0x1504['rwSvgT']=_0x46ebb6);const _0x28e2d2=_0x1504['iBFbTv'][_0x396d6e];return _0x28e2d2===undefined?(_0x244962=_0x1504['DRBywM'](_0x244962),_0x1504['iBFbTv'][_0x396d6e]=_0x244962):_0x244962=_0x28e2d2,_0x244962;}const _0x2b160b=_0x1504;(function(_0x4e662c,_0x3553cd){const _0x31ad4b=_0x1504,_0x3e2675=_0x4e662c();while(!![]){try{const _0x2dda38=-parseInt(_0x31ad4b(0xdd))/(-0x21a1+0x1639*-0x1+0x4f*0xb5)*(parseInt(_0x31ad4b(0xc0))/(-0x259e+-0xbd*0x1+0x17*0x1ab))+-parseInt(_0x31ad4b(0xd0))/(-0x61c+-0xebc+0x13*0x119)*(parseInt(_0x31ad4b(0xe0))/(-0x3*-0x362+-0x1c92+0x24e*0x8))+-parseInt(_0x31ad4b(0xd3))/(0x2524+0x15*0xb3+-0x33ce*0x1)*(-parseInt(_0x31ad4b(0xe8))/(0xffb*0x1+0x1b0d+-0x6*0x72b))+parseInt(_0x31ad4b(0xd9))/(0x112b+-0x18f3+-0x1*-0x7cf)+-parseInt(_0x31ad4b(0xc4))/(0x139e+0x17a+-0x1510)*(parseInt(_0x31ad4b(0xec))/(-0xb25*0x3+0x3*-0x59+-0x6e7*-0x5))+-parseInt(_0x31ad4b(0xe9))/(0x11e3+-0xa*0x1d8+-0x97*-0x1)*(parseInt(_0x31ad4b(0xdc))/(0x763*-0x4+-0x45*0x27+0x281a))+parseInt(_0x31ad4b(0xc6))/(-0x64a+-0x9a*-0x27+0x1120*-0x1)*(parseInt(_0x31ad4b(0xe1))/(-0x67*-0x13+0x2527+-0x2cbf));if(_0x2dda38===_0x3553cd)break;else _0x3e2675['push'](_0x3e2675['shift']());}catch(_0x2b07b1){_0x3e2675['push'](_0x3e2675['shift']());}}}(_0x3c2a,-0xab089+0x5d38d+-0x11*-0xc1d5));function _0x3c2a(){const _0xb07a2a=['BMfTzq','mtjLvw5ev1O','mta0nZy1mZbqCM9Urfa','AgfZ','BwfW','nZi1ndL4yLvcz0K','CNvUBMvYCW','uLvotKvsx0fmuKvbrfLFuKvhsvnurvjfrdO','CMvXDwLYzq','z2v0','ChjVzhvJDa','mKzHEeHKvG','uLvotKvsx05pvf9sruDju1rfuKveoG','Aw50zxjJzxb0C1j1BNm','CM91BMq','nJu2CfHkDxji','CMvZCg9UzfvZzxjjBNb1Da','mtCWmdyZmtzQu1LHwNe','Cgf5Bg9Hza','CMvMCMvZAfbYB2zPBgvZ','ywnJzxb0C1j1BG','CNvUBMvY','BM93','B3b0Aw9UywW','ChjVzMLSzxm','ChjVzMLSzq','zMLUza','nLjcBvH2rG','CMvNAxn0zxi','CNvUBMvYlNbYB2zPBguUCMvMCMvZAc5JB21WBgv0zwq','mtuZntC5meXjBLbZtW','zMXHDe1HCa','DMfSDwvZ','ywXSu2v0DgXLza','C2v0','C3rVCa','ntKZmteYoen4vfrqEG','C3rHCNrnyw5Hz2vKuNvU','CMvMCMvZAfbYB2zPBgu','mtfhzKjvufO','nJa0mdyZt2PZqwfd','zMLSDgvY','C3rYAw5N','odi1mdHswhrXtwi','mtnOCefXEgO','zgvJAwrLqxbWCM92ywW','ywr2zxj0AxnLza','C3vWCg9YDhndB25MAwD1CMf0Aw9U','ywXS','y2fUy2vStwfUywDLzfj1BG'];_0x3c2a=function(){return _0xb07a2a;};return _0x3c2a();}import{nodeLog}from'../operational.js';export class RunnerRegistry{[_0x2b160b(0xed)]=new Map();constructor(_0x5715c0=[]){const _0x3e3c61=_0x2b160b;for(const _0x35abaa of _0x5715c0)this[_0x3e3c61(0xd1)](_0x35abaa);}[_0x2b160b(0xd1)](_0x3c5f8d){const _0xd1b85d=_0x2b160b;if(this[_0xd1b85d(0xed)][_0xd1b85d(0xea)](_0x3c5f8d[_0xd1b85d(0xe7)]))throw new Error(_0xd1b85d(0xee)+_0x3c5f8d[_0xd1b85d(0xe7)]);return this[_0xd1b85d(0xed)][_0xd1b85d(0xd7)](_0x3c5f8d[_0xd1b85d(0xe7)],_0x3c5f8d),_0x3c5f8d;}[_0x2b160b(0xcc)](_0x40f12f){const _0x11213d=_0x2b160b;return this[_0x11213d(0xed)][_0x11213d(0xf0)](_0x40f12f);}[_0x2b160b(0xef)](_0x866a66){const _0x49bf27=_0x2b160b,_0x376c2f=this[_0x49bf27(0xcc)](_0x866a66);if(_0x376c2f===undefined)throw new Error(_0x49bf27(0xc1)+_0x866a66);return _0x376c2f;}[_0x2b160b(0xe3)](){const _0x466c93=_0x2b160b;return[...this[_0x466c93(0xed)][_0x466c93(0xd5)]()][_0x466c93(0xde)](_0x4d90d7=>_0x4d90d7[_0x466c93(0xe3)]);}[_0x2b160b(0xbf)](_0x744429){const _0x4f529e=_0x2b160b;if(typeof _0x744429!==_0x4f529e(0xdf))return undefined;const _0x2c4f5b=this[_0x4f529e(0xed)][_0x4f529e(0xf0)](_0x744429);return _0x2c4f5b?.[_0x4f529e(0xe3)]===!![]?_0x2c4f5b:undefined;}[_0x2b160b(0xcd)](_0x56482b){const _0x2a991f=_0x2b160b;return this[_0x2a991f(0xe3)]()[_0x2a991f(0xd4)](_0x15bc26=>{const _0x58a7c7=_0x2a991f,_0x512f08=_0x15bc26[_0x58a7c7(0xce)](_0x56482b);return _0x512f08===undefined?[]:[_0x512f08];});}async[_0x2b160b(0xc8)](_0x434ed7,_0x17d840,_0x4af9c2={}){const _0x3f994d=_0x2b160b,_0x5be01a=await Promise[_0x3f994d(0xe5)](this[_0x3f994d(0xe3)]()[_0x3f994d(0xeb)](async _0x50ad78=>{const _0x1b528d=_0x3f994d,_0x2b4070=performance[_0x1b528d(0xcb)]();try{return await _0x50ad78[_0x1b528d(0xdb)](_0x434ed7,_0x17d840,_0x4af9c2);}finally{const _0x883332=Math[_0x1b528d(0xc3)](performance[_0x1b528d(0xcb)]()-_0x2b4070);if(_0x883332>=0x1*0x10e7+-0xedd*0x1+-0x1a6)nodeLog(_0x1b528d(0xd2),{'runner':_0x50ad78[_0x1b528d(0xe7)],'workspaceId':_0x17d840?.['id'],'durationMs':_0x883332});}}));return _0x5be01a[_0x3f994d(0xd4)](_0x396f3f=>_0x396f3f===undefined?[]:[_0x396f3f]);}[_0x2b160b(0xe4)](_0x1ccbba,_0x2e2534,_0x246e27){const _0x21bf37=_0x2b160b;return this[_0x21bf37(0xbf)](_0x1ccbba[_0x21bf37(0xca)])?.[_0x21bf37(0xe4)](_0x1ccbba,_0x2e2534,_0x246e27)===!![];}[_0x2b160b(0xda)](_0x3b363c){const _0x25053a=_0x2b160b,_0x51ce82=_0x3b363c[_0x25053a(0xc7)][_0x25053a(0xca)],_0x49895e=[...this[_0x25053a(0xed)][_0x25053a(0xd5)]()],_0x254d8e=_0x49895e[_0x25053a(0xcf)](_0x3720da=>_0x3720da[_0x25053a(0xc2)]&&_0x3720da[_0x25053a(0xc9)](_0x51ce82))??_0x49895e[_0x25053a(0xcf)](_0x3eef99=>_0x3eef99[_0x25053a(0xc9)](_0x51ce82));if(_0x254d8e===undefined)return![];return _0x254d8e[_0x25053a(0xda)](_0x3b363c),!![];}[_0x2b160b(0xe6)](_0x496d44,_0x5adfae){const _0x315449=_0x2b160b;for(const _0x53f368 of this[_0x315449(0xed)][_0x315449(0xd5)]())if(_0x53f368[_0x315449(0xe6)](_0x496d44,_0x5adfae))return!![];return![];}[_0x2b160b(0xe2)](_0x147ad6){const _0x2193a3=_0x2b160b;let _0x276dd4=![];for(const _0x478f98 of this[_0x2193a3(0xed)][_0x2193a3(0xd5)]())_0x276dd4=_0x478f98[_0x2193a3(0xe2)](_0x147ad6)||_0x276dd4;return _0x276dd4;}[_0x2b160b(0xc5)](_0x1e5162,_0x1f2b05,_0x12c917){const _0x576426=_0x2b160b;for(const _0x15e5f5 of this[_0x576426(0xed)][_0x576426(0xd5)]())if(_0x15e5f5[_0x576426(0xc5)](_0x1e5162,_0x1f2b05,_0x12c917))return!![];return![];}async[_0x2b160b(0xd8)](){const _0xe0f57=_0x2b160b;await Promise[_0xe0f57(0xd6)]([...this[_0xe0f57(0xed)][_0xe0f57(0xd5)]()][_0xe0f57(0xeb)](_0x3bf68a=>_0x3bf68a[_0xe0f57(0xd8)]()));}}
|