@myagentroam/node 0.11.36 → 0.11.38

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.
Files changed (145) hide show
  1. package/dist/application/execution-lifecycle.js +54 -0
  2. package/dist/application/node-lifecycle.js +104 -0
  3. package/dist/application/node-operation-admission.js +51 -0
  4. package/dist/application/node-operation-contracts.js +1 -0
  5. package/dist/application/runner-composition.js +22 -0
  6. package/dist/application/session-projection-composition.js +26 -0
  7. package/dist/application/workspace-application.js +61 -0
  8. package/dist/application/workspace-composition.js +21 -0
  9. package/dist/capabilities.js +2 -3
  10. package/dist/codex-app-server.js +1 -471
  11. package/dist/connection/authorization.js +26 -0
  12. package/dist/{service → connection}/direct-transfer-service.js +1 -1
  13. package/dist/connection/endpoints.js +32 -0
  14. package/dist/connector.js +145 -253
  15. package/dist/control-outbound-scheduler.js +3 -0
  16. package/dist/database.js +34 -14
  17. package/dist/git-askpass.js +1 -1
  18. package/dist/git-execution-helper.js +1 -1
  19. package/dist/hosting/hosted-conversation-file-identity.js +27 -0
  20. package/dist/hosting/hosted-conversation-file-operations.js +44 -0
  21. package/dist/hosting/hosted-conversation-node-service.js +974 -0
  22. package/dist/hosting/hosted-conversation-runs.js +599 -0
  23. package/dist/hosting/hosted-conversation-templates.js +280 -0
  24. package/dist/hosting/hosted-conversation-uploads.js +344 -0
  25. package/dist/hosting/hosted-conversation-watch.js +194 -0
  26. package/dist/hosting/runtime-contracts.js +1 -0
  27. package/dist/runner/abstract-runner.js +4 -13
  28. package/dist/{claude-agent-sdk.js → runner/claude/claude-agent-sdk.js} +2 -2
  29. package/dist/runner/claude/conversation-parser.js +2 -1
  30. package/dist/runner/claude/managed-run-controller.js +6 -7
  31. package/dist/runner/claude/message-parsers.js +2 -1
  32. package/dist/runner/claude/native-transcript.js +2 -1
  33. package/dist/runner/claude/tool-normalizer.js +1 -1
  34. package/dist/runner/claude-code-runner.js +2 -2
  35. package/dist/runner/codex/codex-app-server.js +471 -0
  36. package/dist/runner/codex/conversation-parser.js +4 -2
  37. package/dist/runner/codex/managed-run-controller.js +7 -9
  38. package/dist/runner/codex/native-transcript.js +1 -1
  39. package/dist/runner/codex/tool-normalizer.js +1 -1
  40. package/dist/runner/codex-runner.js +9 -27
  41. package/dist/runner/contracts.js +1 -0
  42. package/dist/runner/mar-agent/conversation-normalizer.js +2 -2
  43. package/dist/runner/mar-agent/history-projection.js +1 -1
  44. package/dist/runner/mar-agent/hosted-conversation-runtime.js +6 -10
  45. package/dist/runner/mar-agent/managed-run-controller.js +85 -61
  46. package/dist/runner/mar-agent/runtime-model-factory.js +0 -3
  47. package/dist/runner/mar-agent-runner.js +1 -1
  48. package/dist/runner/normalization.js +42 -0
  49. package/dist/runner/opencode/conversation-parser.js +1 -1
  50. package/dist/runner/opencode/managed-run-controller.js +6 -7
  51. package/dist/{opencode-server.js → runner/opencode/opencode-server.js} +2 -2
  52. package/dist/runner/opencode/tool-normalizer.js +1 -1
  53. package/dist/runner/opencode-runner.js +4 -5
  54. package/dist/runner/runner-registry.js +4 -1
  55. package/dist/runtime-state.js +48 -372
  56. package/dist/service/computer-use-enablement-service.js +1 -1
  57. package/dist/service/continuous-run-coordinator.js +52 -7
  58. package/dist/service/conversation-history-service.js +4 -4
  59. package/dist/service/conversation-hosting-capability-service.js +1 -1
  60. package/dist/service/conversation-hosting-enablement-service.js +1 -1
  61. package/dist/service/conversation-hosting-lifecycle-service.js +3 -3
  62. package/dist/service/conversation-hosting-maintenance-service.js +1 -1
  63. package/dist/service/conversation-observation.js +1 -1
  64. package/dist/service/conversation-segment-service.js +1 -1
  65. package/dist/service/external-session-resume-service.js +47 -27
  66. package/dist/service/fake-managed-run-service.js +3 -7
  67. package/dist/service/git-operation-service.js +1 -1
  68. package/dist/service/goal-continuation-coordinator.js +14 -7
  69. package/dist/service/mar-agent-model-transport-test-service.js +1 -1
  70. package/dist/service/native-session-watch-service.js +1 -1
  71. package/dist/service/node-connection-lifecycle-service.js +6 -3
  72. package/dist/service/node-control-channel.js +48 -11
  73. package/dist/service/node-request-service.js +1 -1
  74. package/dist/service/node-terminal-channel.js +2 -1
  75. package/dist/service/node-workspace-coordinator.js +3 -2
  76. package/dist/service/notification-mcp-bridge.js +6 -2
  77. package/dist/service/recent-run-projection-service.js +1 -1
  78. package/dist/service/restart-session-restorer.js +1 -1
  79. package/dist/service/run-event-service.js +49 -42
  80. package/dist/service/run-workbench-service.js +3 -3
  81. package/dist/service/runner-interaction-service.js +6 -5
  82. package/dist/service/runner-service.js +1 -1
  83. package/dist/service/session-recent-activity.js +2 -1
  84. package/dist/service/skill-directory-service.js +1 -1
  85. package/dist/service/skill-install-service.js +2 -2
  86. package/dist/service/terminal-service.js +1 -1
  87. package/dist/service/workbench-event-projection.js +3 -2
  88. package/dist/service/workbench-event-service.js +1 -1
  89. package/dist/service/workspace-service.js +3 -2
  90. package/dist/session/attachments.js +110 -0
  91. package/dist/session/contracts.js +1 -0
  92. package/dist/{util → session}/conversation-identity.js +1 -1
  93. package/dist/session/input-validation.js +15 -0
  94. package/dist/{service → session}/native-session-projection-service.js +40 -11
  95. package/dist/session/pagination.js +77 -0
  96. package/dist/{util → session}/runner-native-session-parsers.js +2 -1
  97. package/dist/session/runtime/approvals.js +90 -0
  98. package/dist/session/runtime/conversation-projection.js +310 -0
  99. package/dist/session/runtime/type-guards.js +19 -0
  100. package/dist/{service → session}/session-catalog-service.js +5 -4
  101. package/dist/{service → session}/session-command-service.js +3 -3
  102. package/dist/{service → session}/session-identity-service.js +1 -1
  103. package/dist/{service → session}/session-lifecycle-service.js +18 -7
  104. package/dist/{service → session}/session-message-service.js +6 -5
  105. package/dist/{service → session}/session-presentation-service.js +1 -1
  106. package/dist/{service → session}/session-query-service.js +2 -2
  107. package/dist/{service → session}/session-schedule-service.js +2 -2
  108. package/dist/util/records.js +3 -0
  109. package/dist/workspace/contracts.js +1 -0
  110. package/dist/workspace/file-index.js +534 -0
  111. package/dist/workspace/files.js +466 -0
  112. package/dist/workspace/git.js +991 -0
  113. package/dist/workspace/path-access.js +184 -0
  114. package/dist/workspace/utf8.js +12 -0
  115. package/dist/{service → workspace}/workspace-change-service.js +45 -21
  116. package/dist/{service → workspace}/workspace-code-navigation-service.js +6 -6
  117. package/dist/{service → workspace}/workspace-file-manager-service.js +1 -1
  118. package/dist/{service → workspace}/workspace-file-service.js +16 -16
  119. package/dist/{service → workspace}/workspace-git-exclude-service.js +1 -1
  120. package/dist/{service → workspace}/workspace-queue-workbench-service.js +3 -2
  121. package/dist/{service → workspace}/workspace-session-service.js +45 -40
  122. package/dist/{service → workspace}/workspace-upload-service.js +28 -28
  123. package/dist/{service → workspace}/workspace-watch-service.js +29 -28
  124. package/dist/{service → workspace}/workspace-workbench-service.js +4 -3
  125. package/package.json +4 -4
  126. package/dist/service/hosted-conversation-node-service.js +0 -2252
  127. package/dist/service/run-domain-state.js +0 -4
  128. package/dist/service/session-domain-state.js +0 -9
  129. package/dist/service/workspace-domain-state.js +0 -41
  130. package/dist/util/node-operation-parsers.js +0 -320
  131. package/dist/workspace.js +0 -2168
  132. /package/dist/{connector → application}/node-connector-options.js +0 -0
  133. /package/dist/{util → connection}/node-operation-data.js +0 -0
  134. /package/dist/{connector → connection}/node-operation-router.js +0 -0
  135. /package/dist/{service → hosting}/hosted-conversation-sandbox-profile.js +0 -0
  136. /package/dist/{service → hosting}/hosted-conversation-store.js +0 -0
  137. /package/dist/{util → mcp}/secret-environment.js +0 -0
  138. /package/dist/{claude-channel.js → runner/claude/claude-channel.js} +0 -0
  139. /package/dist/{util → runner}/personal-instructions.js +0 -0
  140. /package/dist/{util → runner}/runner-error.js +0 -0
  141. /package/dist/{service/conversation-work-process.js → session/runtime/work-process.js} +0 -0
  142. /package/dist/{service → session}/session-context-service.js +0 -0
  143. /package/dist/{util → workspace}/git-credential-client.js +0 -0
  144. /package/dist/{service → workspace}/workspace-content-search-service.js +0 -0
  145. /package/dist/{service → workspace}/workspace-watch-snapshot-service.js +0 -0
@@ -245,33 +245,29 @@ export class MarAgentHostedConversationRuntime {
245
245
  clientMessageId: request.clientMessageId
246
246
  });
247
247
  },
248
- cancel: () => {
248
+ cancel: (reason = 'interrupt') => {
249
249
  if (settled || this.#active.get(input.sessionId)?.handle !== handle)
250
250
  return false;
251
+ if (reason === 'shutdown')
252
+ titleController.abort();
251
253
  execution.cancel();
252
254
  return true;
253
255
  }
254
256
  };
255
- this.#active.set(input.sessionId, {
256
- handle,
257
- completion,
258
- cancelTitle: () => titleController.abort()
259
- });
257
+ this.#active.set(input.sessionId, { handle, completion });
260
258
  return handle;
261
259
  }
262
260
  async releaseSession(input) {
263
261
  const active = this.#active.get(input.sessionId);
264
262
  if (active === undefined)
265
263
  return;
266
- active.cancelTitle();
267
- active.handle.cancel();
264
+ active.handle.cancel('shutdown');
268
265
  await active.completion.catch(() => undefined);
269
266
  }
270
267
  async dispose() {
271
268
  const active = [...this.#active.values()];
272
269
  for (const execution of active) {
273
- execution.cancelTitle();
274
- execution.handle.cancel();
270
+ execution.handle.cancel('shutdown');
275
271
  }
276
272
  await Promise.allSettled(active.map((execution) => execution.completion));
277
273
  }
@@ -8,12 +8,12 @@ import { homedir } from 'node:os';
8
8
  import { nodeLog } from '../../operational.js';
9
9
  import { createAgent, generateSessionTitle } from '@myagentroam/agent';
10
10
  import { marAgentReasoningEffortSchema, resolveMarAgentDefaultReasoningEffort } from '@myagentroam/protocol';
11
- import { boundedConversationItemId } from '../../util/node-operation-parsers.js';
12
- import { parseSecretEnvironment } from '../../util/secret-environment.js';
11
+ import { boundedConversationItemId } from '../normalization.js';
12
+ import { parseSecretEnvironment } from '../../mcp/secret-environment.js';
13
13
  import { MarAgentMcpClientCache } from './mcp-client-pool.js';
14
14
  import { MarAgentConversationNormalizer, normalizeMarAgentUsage } from './conversation-normalizer.js';
15
- import { parseRunnerImageAttachments } from '../../util/node-operation-parsers.js';
16
- import { runnerErrorProjection } from '../../util/runner-error.js';
15
+ import { parseRunnerImageAttachments } from '../../session/attachments.js';
16
+ import { runnerErrorProjection } from '../runner-error.js';
17
17
  import { MarAgentRuntimeModelFactory, sdkModelConfigurations, closeImageCredentialProviders } from './runtime-model-factory.js';
18
18
  import { createImageGenerationExtensions } from './image-generation-extensions.js';
19
19
  import { createWebToolsExtensions } from './web-tools-extensions.js';
@@ -111,7 +111,9 @@ export class MarAgentManagedRunController {
111
111
  if (session.externalSessionId === null || session.nativeControl !== 'MAR_MANAGED')
112
112
  throw new Error('RUNNER_COMMAND_UNAVAILABLE');
113
113
  const execution = context.executionContext;
114
- const resolved = resolveMarAgentExecutionInput(execution?.runner === 'mar-agent' ? execution.runnerInput : undefined, session.model ?? '');
114
+ const resolved = resolveMarAgentExecutionInput(execution?.runner === 'mar-agent'
115
+ ? execution.runnerInput
116
+ : undefined, session.model ?? '');
115
117
  if (resolved === undefined)
116
118
  throw new Error('RUNNER_COMMAND_UNAVAILABLE');
117
119
  const runId = randomUUID();
@@ -149,7 +151,7 @@ export class MarAgentManagedRunController {
149
151
  typeof payload.input !== 'string' ||
150
152
  typeof payload.cwd !== 'string' ||
151
153
  typeof payload.model !== 'string' ||
152
- this.host.active.has(payload.runId))
154
+ this.host.isExecutionActive(payload.runId))
153
155
  return;
154
156
  const resolved = resolveMarAgentExecutionInput(marAgentEnvelopeInput(payload), payload.model);
155
157
  if (resolved === undefined) {
@@ -242,7 +244,7 @@ export class MarAgentManagedRunController {
242
244
  this.#executions.set(input.runId, execution);
243
245
  let runtime;
244
246
  let use;
245
- let terminalPublished = false;
247
+ let terminalEvent;
246
248
  let executionMcpLease;
247
249
  let executionMcpBinding;
248
250
  let computerUseBinding;
@@ -250,7 +252,7 @@ export class MarAgentManagedRunController {
250
252
  let titleTask;
251
253
  let cancelledDuringPreparation = false;
252
254
  try {
253
- this.host.active.add(input.runId);
255
+ this.host.executionAccepted(input.runId);
254
256
  this.host.adopt({
255
257
  runId: input.runId,
256
258
  sessionId: input.sessionId,
@@ -419,34 +421,44 @@ export class MarAgentManagedRunController {
419
421
  : result;
420
422
  });
421
423
  this.host.emit(input.runId, 'run.running', {}, 'RUNNING');
422
- for await (const event of handle) {
423
- if (event.type === 'execution.started' && metadata?.automaticTitlePending && !titleTask) {
424
- titleTask = this.#generateTitle({
425
- models: sdkModelConfigurations(executionModels),
426
- currentModelId: input.model.id,
427
- prompt: input.input,
428
- onModelUsage: (usage) => this.host.emit(input.runId, 'run.usage', normalizeMarAgentUsage({
429
- ...usage,
430
- sessionId: session.id,
431
- executionId: handle.executionId,
432
- purpose: 'title',
433
- agentRole: 'root'
434
- })),
435
- signal: titleController.signal
436
- }).catch((error) => {
437
- if (!titleController.signal.aborted)
438
- nodeLog('runner.mar-agent.title.failed', {
424
+ const consumeEvents = async () => {
425
+ for await (const event of handle) {
426
+ if (event.type === 'execution.started' && metadata?.automaticTitlePending && !titleTask) {
427
+ titleTask = this.#generateTitle({
428
+ models: sdkModelConfigurations(executionModels),
429
+ currentModelId: input.model.id,
430
+ prompt: input.input,
431
+ onModelUsage: (usage) => this.host.emit(input.runId, 'run.usage', normalizeMarAgentUsage({
432
+ ...usage,
439
433
  sessionId: session.id,
440
- runId: input.runId,
441
- stage: 'generate',
442
- code: runnerErrorProjection(error, 'MAR_AGENT_TITLE_GENERATION_FAILED').code
443
- });
444
- return undefined;
445
- });
434
+ executionId: handle.executionId,
435
+ purpose: 'title',
436
+ agentRole: 'root'
437
+ })),
438
+ signal: titleController.signal
439
+ }).catch((error) => {
440
+ if (!titleController.signal.aborted)
441
+ nodeLog('runner.mar-agent.title.failed', {
442
+ sessionId: session.id,
443
+ runId: input.runId,
444
+ stage: 'generate',
445
+ code: runnerErrorProjection(error, 'MAR_AGENT_TITLE_GENERATION_FAILED').code
446
+ });
447
+ return undefined;
448
+ });
449
+ }
450
+ this.project(input.runId, event);
446
451
  }
447
- this.project(input.runId, event);
448
- }
449
- const result = await handle.result();
452
+ };
453
+ const [eventsResult, executionResult] = await Promise.allSettled([
454
+ consumeEvents(),
455
+ (async () => handle.result())()
456
+ ]);
457
+ if (eventsResult.status === 'rejected')
458
+ throw eventsResult.reason;
459
+ if (executionResult.status === 'rejected')
460
+ throw executionResult.reason;
461
+ const result = executionResult.value;
450
462
  const title = await titleTask;
451
463
  if (title && !titleController.signal.aborted)
452
464
  await runtime.agent
@@ -473,30 +485,33 @@ export class MarAgentManagedRunController {
473
485
  ? 'CANCELLED'
474
486
  : 'FAILED';
475
487
  use?.terminal();
476
- terminalPublished = true;
477
- this.host.emit(input.runId, status === 'SUCCEEDED'
478
- ? 'run.completed'
479
- : status === 'CANCELLED'
480
- ? 'run.cancelled'
481
- : status === 'FAILED'
482
- ? 'run.failed'
483
- : 'run.completed', {
484
- status,
485
- ...(result.errorCode ? { code: result.errorCode } : {}),
486
- ...(result.errorMessage ? { message: result.errorMessage } : {}),
487
- ...(permissionStop === undefined
488
- ? {}
489
- : {
490
- permissionStop,
491
- code: permissionStop.action === 'ask'
492
- ? 'MAR_AGENT_PERMISSION_ASK'
493
- : 'MAR_AGENT_PERMISSION_DENIED',
494
- message: permissionStop.reason
495
- })
496
- }, status);
488
+ terminalEvent = {
489
+ eventType: status === 'SUCCEEDED'
490
+ ? 'run.completed'
491
+ : status === 'CANCELLED'
492
+ ? 'run.cancelled'
493
+ : status === 'FAILED'
494
+ ? 'run.failed'
495
+ : 'run.completed',
496
+ payload: {
497
+ status,
498
+ ...(result.errorCode ? { code: result.errorCode } : {}),
499
+ ...(result.errorMessage ? { message: result.errorMessage } : {}),
500
+ ...(permissionStop === undefined
501
+ ? {}
502
+ : {
503
+ permissionStop,
504
+ code: permissionStop.action === 'ask'
505
+ ? 'MAR_AGENT_PERMISSION_ASK'
506
+ : 'MAR_AGENT_PERMISSION_DENIED',
507
+ message: permissionStop.reason
508
+ })
509
+ },
510
+ status
511
+ };
497
512
  }
498
513
  catch (error) {
499
- if (terminalPublished) {
514
+ if (terminalEvent !== undefined) {
500
515
  nodeLog('runner.mar-agent.run.cleanup_failed', {
501
516
  runId: input.runId,
502
517
  code: 'MAR_AGENT_RUN_CLEANUP_FAILED'
@@ -519,7 +534,7 @@ export class MarAgentManagedRunController {
519
534
  retryAfterMs: null
520
535
  }
521
536
  });
522
- this.host.emit(input.runId, 'run.failed', projected, 'FAILED');
537
+ terminalEvent = { eventType: 'run.failed', payload: projected, status: 'FAILED' };
523
538
  }
524
539
  }
525
540
  finally {
@@ -560,13 +575,22 @@ export class MarAgentManagedRunController {
560
575
  finally {
561
576
  use?.terminal();
562
577
  this.#normalizers.delete(input.runId);
563
- this.host.active.delete(input.runId);
564
578
  this.#executions.delete(input.runId);
565
579
  this.#steerTargets.delete(input.runId);
566
- resolveSettled();
580
+ if (cancelledDuringPreparation)
581
+ terminalEvent = {
582
+ eventType: 'run.cancelled',
583
+ payload: { status: 'CANCELLED' },
584
+ status: 'CANCELLED'
585
+ };
586
+ try {
587
+ if (terminalEvent !== undefined)
588
+ this.host.emit(input.runId, terminalEvent.eventType, terminalEvent.payload, terminalEvent.status);
589
+ }
590
+ finally {
591
+ resolveSettled();
592
+ }
567
593
  }
568
- if (cancelledDuringPreparation)
569
- this.host.emit(input.runId, 'run.cancelled', { status: 'CANCELLED' }, 'CANCELLED');
570
594
  }
571
595
  }
572
596
  #resolveMcpServers(installations, environment, executionServers = []) {
@@ -68,9 +68,6 @@ export class MarAgentRuntimeModelFactory {
68
68
  ...(configuration.serviceTier === undefined
69
69
  ? {}
70
70
  : { serviceTier: configuration.serviceTier }),
71
- ...(configuration.serviceTier === undefined && configuration.fastMode === true
72
- ? { fastMode: true }
73
- : {}),
74
71
  hostedWebSearch: configuration.hostedWebSearch,
75
72
  useResourceUrl: configuration.useResourceUrl,
76
73
  ...(imageGeneration === undefined ? {} : { imageGeneration }),
@@ -1,6 +1,6 @@
1
1
  import { marAgentNodeModelSummarySchema, parseComposerTags, resolveMarAgentDefaultReasoningEffort, serializeComposerTag } from '@myagentroam/protocol';
2
2
  import { nodeLog } from '../operational.js';
3
- import { runnerErrorProjection } from '../util/runner-error.js';
3
+ import { runnerErrorProjection } from './runner-error.js';
4
4
  import { AgentError, openAgentSessionCatalog } from '@myagentroam/agent';
5
5
  import { homedir } from 'node:os';
6
6
  import { resolve } from 'node:path';
@@ -0,0 +1,42 @@
1
+ export function compactRunnerText(value, limit) {
2
+ return value.length <= limit ? value : `${value.slice(0, Math.max(0, limit - 1))}…`;
3
+ }
4
+ export function compactRunnerValue(value, limit) {
5
+ if (value === undefined || value === null)
6
+ return { text: '', truncated: false };
7
+ let text;
8
+ if (typeof value === 'string')
9
+ text = value;
10
+ else {
11
+ try {
12
+ text = JSON.stringify(value);
13
+ }
14
+ catch {
15
+ return { text: '(Unable to display)', truncated: false };
16
+ }
17
+ }
18
+ return { text: compactRunnerText(text, limit), truncated: text.length > limit };
19
+ }
20
+ export function nativePageEnd(cursor, sessionId, fallback) {
21
+ if (cursor === undefined)
22
+ return fallback;
23
+ try {
24
+ const value = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
25
+ return value.sessionId === sessionId &&
26
+ Number.isInteger(value.end) &&
27
+ value.end >= 0
28
+ ? Math.min(value.end, fallback)
29
+ : fallback;
30
+ }
31
+ catch {
32
+ return fallback;
33
+ }
34
+ }
35
+ export function boundedConversationItemId(prefix, value) {
36
+ const candidate = `${prefix}:${value}`;
37
+ if (candidate.length <= 88)
38
+ return candidate;
39
+ return `${prefix}:${Buffer.from(value)
40
+ .toString('base64url')
41
+ .slice(0, 88 - prefix.length - 1)}`;
42
+ }
@@ -1,4 +1,4 @@
1
- import { boundedConversationItemId, compactRunnerText } from '../../util/node-operation-parsers.js';
1
+ import { boundedConversationItemId, compactRunnerText } from '../normalization.js';
2
2
  import { publicGoalHistoryText } from '../../service/goal-runtime.js';
3
3
  import { normalizeOpenCodeTool } from './tool-normalizer.js';
4
4
  import { RunnerUsageTracker, usageToken, usageTokenSum } from '../../service/runner-usage-tracker.js';
@@ -1,9 +1,9 @@
1
1
  import { OpenCodeUsageNormalizer, openCodeSourceItemId } from './conversation-parser.js';
2
2
  import { parseComposerTags } from '@myagentroam/protocol';
3
3
  import { nodeExecutionEnvironment } from '../../node-execution-environment.js';
4
- import { parseSecretEnvironment } from '../../util/secret-environment.js';
5
- import { runnerErrorProjection } from '../../util/runner-error.js';
6
- import { boundedConversationItemId, compactRunnerText } from '../../util/node-operation-parsers.js';
4
+ import { parseSecretEnvironment } from '../../mcp/secret-environment.js';
5
+ import { runnerErrorProjection } from '../runner-error.js';
6
+ import { boundedConversationItemId, compactRunnerText } from '../normalization.js';
7
7
  import { openCodePatchToolPayload, openCodeQuestions } from './conversation-parser.js';
8
8
  import { normalizeOpenCodeTool } from './tool-normalizer.js';
9
9
  import { ResponseLatencyTracker } from '../../service/response-latency-tracker.js';
@@ -65,7 +65,7 @@ export class OpenCodeManagedRunController {
65
65
  externalSessionId: session.externalSessionId,
66
66
  ...(initiatedByUserId === undefined ? {} : { initiatedByUserId })
67
67
  });
68
- this.host.active.add(runId);
68
+ this.host.executionAccepted(runId);
69
69
  this.runner.execution.set(runId, {
70
70
  runId,
71
71
  sessionId: session.id,
@@ -108,7 +108,7 @@ export class OpenCodeManagedRunController {
108
108
  typeof payload.cwd !== 'string' ||
109
109
  typeof payload.model !== 'string' ||
110
110
  this.host.intercepted() ||
111
- this.host.active.has(payload.runId))
111
+ this.host.isExecutionActive(payload.runId))
112
112
  return;
113
113
  let environment;
114
114
  let mcp;
@@ -207,7 +207,7 @@ export class OpenCodeManagedRunController {
207
207
  const client = this.runner.managedClient(input.environment, hasMcpConfiguration(input.mcp) ? input.runId : undefined);
208
208
  this.startingClients.set(input.runId, client);
209
209
  this.startingCwds.set(input.runId, input.cwd);
210
- this.host.active.add(input.runId);
210
+ this.host.executionAccepted(input.runId);
211
211
  this.host.emit(input.runId, 'run.started', {}, 'STARTING');
212
212
  let settlePrompt;
213
213
  const promptSettled = new Promise((resolve) => {
@@ -758,7 +758,6 @@ export class OpenCodeManagedRunController {
758
758
  this.messageParents.delete(runId);
759
759
  this.compactionPartIds.delete(runId);
760
760
  this.completedCompactionParents.delete(runId);
761
- this.host.active.delete(runId);
762
761
  for (const [id, pending] of this.permissions)
763
762
  if (pending.runId === runId) {
764
763
  clearTimeout(pending.timer);
@@ -1,8 +1,8 @@
1
1
  import { spawn } from 'node:child_process';
2
2
  import { randomBytes } from 'node:crypto';
3
3
  import { createServer } from 'node:net';
4
- import { minimalRunnerEnvironment, platformCliInvocation } from './operational.js';
5
- import { terminateProcessTree } from './process-tree.js';
4
+ import { minimalRunnerEnvironment, platformCliInvocation } from '../../operational.js';
5
+ import { terminateProcessTree } from '../../process-tree.js';
6
6
  const START_TIMEOUT_MS = 10_000;
7
7
  export class OpenCodeServerClient {
8
8
  options;
@@ -1,4 +1,4 @@
1
- import { compactRunnerText, compactRunnerValue } from '../../util/node-operation-parsers.js';
1
+ import { compactRunnerText, compactRunnerValue } from '../normalization.js';
2
2
  export function normalizeOpenCodeTool(toolName, state) {
3
3
  const status = state?.status === 'completed'
4
4
  ? 'COMPLETED'
@@ -1,14 +1,14 @@
1
1
  import { withMarctlGuide } from '../mcp/marctl-guide.js';
2
- import { OpenCodeServerClient } from '../opencode-server.js';
2
+ import { OpenCodeServerClient } from './opencode/opencode-server.js';
3
3
  import { openCodeContextLimits, openCodeProfileModels } from '../opencode-runtime.js';
4
4
  import { declaredRunnerProfiles } from '../runner-profiles.js';
5
5
  import { AbstractRunner } from './abstract-runner.js';
6
- import { isWithinWorkspace } from '../util/runner-native-session-parsers.js';
6
+ import { isWithinWorkspace } from '../session/runner-native-session-parsers.js';
7
7
  import { createHash } from 'node:crypto';
8
8
  import { homedir } from 'node:os';
9
9
  import { openCodeConversationPage, openCodeUserMessagePreview } from './opencode/conversation-parser.js';
10
10
  import { nodeLog } from '../operational.js';
11
- import { runnerErrorProjection } from '../util/runner-error.js';
11
+ import { runnerErrorProjection } from './runner-error.js';
12
12
  const PROFILE_ENTRY_TTL_MS = 30 * 60_000;
13
13
  const PROFILE_FAILURE_RETRY_MS = 30_000;
14
14
  const PROFILE_REFRESH_TIMEOUT_MS = 90_000;
@@ -355,10 +355,9 @@ export class OpenCodeRunner extends AbstractRunner {
355
355
  commandStates: context.commandStates
356
356
  };
357
357
  }
358
- async renameNative(session, input, database) {
358
+ async renameNative(session, input) {
359
359
  if (session.externalSessionId !== null && input.title !== undefined)
360
360
  await this.client.updateSession(session.cwd, session.externalSessionId, input.title ?? '');
361
- await super.renameNative(session, input, database);
362
361
  }
363
362
  async removeNative(session, nativeSessionId) {
364
363
  await this.client.deleteSession(session.cwd, nativeSessionId);
@@ -94,6 +94,9 @@ export class RunnerRegistry {
94
94
  return false;
95
95
  }
96
96
  async stop() {
97
- await Promise.allSettled([...this.runners.values()].map((runner) => runner.stop()));
97
+ const results = await Promise.allSettled([...this.runners.values()].map(async (runner) => runner.stop()));
98
+ const failure = results.find((result) => result.status === 'rejected');
99
+ if (failure !== undefined)
100
+ throw failure.reason;
98
101
  }
99
102
  }