@myagentroam/node 0.11.38 → 0.11.40

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 (65) hide show
  1. package/dist/computer-use/contracts.js +8 -0
  2. package/dist/{runner/mar-agent/computer-use-indicator.js → computer-use/indicator.js} +61 -38
  3. package/dist/computer-use/probe.js +95 -0
  4. package/dist/computer-use/provider.js +159 -0
  5. package/dist/computer-use/session.js +334 -0
  6. package/dist/computer-use/worker-source.js +135 -0
  7. package/dist/computer-use/worker.js +321 -0
  8. package/dist/connector.js +181 -22
  9. package/dist/database.js +35 -11
  10. package/dist/main.js +12 -1
  11. package/dist/marctl-guidance.js +18 -27
  12. package/dist/mcp/naming.js +6 -1
  13. package/dist/migrations/v022.js +58 -0
  14. package/dist/runner/abstract-runner.js +14 -0
  15. package/dist/runner/claude/tool-normalizer.js +6 -1
  16. package/dist/runner/codex/conversation-parser.js +23 -4
  17. package/dist/runner/codex/managed-run-controller.js +4 -2
  18. package/dist/runner/codex/tool-normalizer.js +9 -0
  19. package/dist/runner/execution-presentation.js +56 -0
  20. package/dist/runner/mar-agent/agent-network-extension.js +168 -0
  21. package/dist/runner/mar-agent/agent-network-wait-output.js +72 -0
  22. package/dist/runner/mar-agent/computer-use-skill.js +11 -2
  23. package/dist/runner/mar-agent/computer-use.js +104 -728
  24. package/dist/runner/mar-agent/conversation-normalizer.js +241 -121
  25. package/dist/runner/mar-agent/managed-run-controller.js +13 -5
  26. package/dist/runner/mar-agent/marctl-skill.js +3 -3
  27. package/dist/runner/mar-agent/runtime-model-factory.js +1 -0
  28. package/dist/runner/mar-agent/session-runtime.js +34 -1
  29. package/dist/runner/mar-agent-runner.js +36 -0
  30. package/dist/runner/opencode/tool-normalizer.js +6 -1
  31. package/dist/runtime-state.js +57 -0
  32. package/dist/service/agent-network-bindings.js +483 -0
  33. package/dist/service/agent-network-goal.js +19 -0
  34. package/dist/service/agent-network-invoke.js +179 -0
  35. package/dist/service/agent-network-observations.js +377 -0
  36. package/dist/service/agent-network-service.js +315 -0
  37. package/dist/service/agent-network-wait.js +130 -0
  38. package/dist/service/composer-message-input.js +9 -2
  39. package/dist/service/computer-use-enablement-service.js +13 -7
  40. package/dist/service/continuous-run-coordinator.js +24 -1
  41. package/dist/service/conversation-hosting-enablement-service.js +2 -2
  42. package/dist/service/goal-continuation-coordinator.js +12 -2
  43. package/dist/service/marctl-caller.js +80 -0
  44. package/dist/service/marctl-execution-credential-control.js +65 -0
  45. package/dist/service/model-usage-service.js +9 -0
  46. package/dist/service/node-config-mutations.js +27 -0
  47. package/dist/service/node-control-message-service.js +10 -0
  48. package/dist/service/node-request-service.js +52 -7
  49. package/dist/service/node-upgrade-coordinator.js +79 -8
  50. package/dist/service/node-upgrade-credential-control.js +57 -0
  51. package/dist/service/node-upgrade-reporter.js +108 -0
  52. package/dist/service/run-event-service.js +8 -0
  53. package/dist/service/run-workbench-service.js +11 -0
  54. package/dist/service/supervised-node-child.js +153 -0
  55. package/dist/service/supervisor-upgrade-handoff.js +104 -0
  56. package/dist/session/native-session-projection-service.js +69 -6
  57. package/dist/session/operation-admission.js +7 -0
  58. package/dist/session/runtime/conversation-projection.js +25 -3
  59. package/dist/session/session-catalog-service.js +156 -32
  60. package/dist/session/session-lifecycle-service.js +68 -42
  61. package/dist/session/session-message-service.js +16 -6
  62. package/dist/supervisor.js +209 -20
  63. package/dist/terminal.js +41 -21
  64. package/package.json +6 -5
  65. /package/dist/{runner/mar-agent/computer-use-probe.js → computer-use/probe-source.js} +0 -0
@@ -2,6 +2,8 @@ import { createHash, randomUUID } from 'node:crypto';
2
2
  import { homedir } from 'node:os';
3
3
  import { access, constants } from 'node:fs/promises';
4
4
  import { LocalAgentHost } from '@myagentroam/agent/host';
5
+ import { SESSION_CONTEXT_PROVIDER } from '@myagentroam/agent/extensions';
6
+ import { agentNetworkExtension } from './agent-network-extension.js';
5
7
  import { marAgentRuntimeCompactConfigurationSchema } from '@myagentroam/protocol';
6
8
  import { nodeExecutionEnvironment } from '../../node-execution-environment.js';
7
9
  import { nodeLog } from '../../operational.js';
@@ -26,8 +28,10 @@ export async function createSessionRuntime(input, sessionKey, fingerprint, hostC
26
28
  let agent;
27
29
  let models = [];
28
30
  let releaseEnvironment;
31
+ let networkContext;
29
32
  try {
30
33
  releaseEnvironment = dependencies.retainEnvironment?.(input.secretEnvironment ?? {});
34
+ networkContext = dependencies.attachNetworkContext?.(input.sessionId);
31
35
  const mcp = mcpLease.pool;
32
36
  const localHost = new LocalAgentHost({
33
37
  publishModelResource: dependencies.publishModelResource === undefined
@@ -68,12 +72,36 @@ export async function createSessionRuntime(input, sessionKey, fingerprint, hostC
68
72
  });
69
73
  const compactState = { revision: 0 };
70
74
  updateMarAgentCompactState(compactState, input.compact, models, input.models.map((model) => model.id));
75
+ const compactSource = marAgentCompactExtensionSource(compactState);
76
+ const networkProvider = networkContext;
71
77
  agent = await dependencies.createAgent({
72
78
  mode: 'node',
73
79
  host: localHost,
74
80
  models: sdkModelConfigurations(models.filter((model) => input.models.some((candidate) => candidate.id === model.id))),
75
81
  defaultModelId: input.model.id,
76
- extensions: marAgentCompactExtensionSource(compactState),
82
+ extensions: networkProvider === undefined
83
+ ? compactSource
84
+ : {
85
+ async resolve(request) {
86
+ const snapshot = await compactSource.resolve(request);
87
+ return {
88
+ ...snapshot,
89
+ extensions: [
90
+ ...snapshot.extensions,
91
+ {
92
+ id: 'mar.node.agent-network-context',
93
+ apiVersion: '1.0',
94
+ attachSession(context) {
95
+ context.services.provide(SESSION_CONTEXT_PROVIDER, networkProvider);
96
+ }
97
+ },
98
+ ...(networkProvider.invoke === undefined
99
+ ? []
100
+ : [agentNetworkExtension(networkProvider.invoke, currentRunId)])
101
+ ]
102
+ };
103
+ }
104
+ },
77
105
  ...(input.personalInstructions ? { systemInstruction: input.personalInstructions } : {})
78
106
  });
79
107
  const customTitle = dependencies.customTitle(input.sessionId) ?? undefined;
@@ -92,6 +120,9 @@ export async function createSessionRuntime(input, sessionKey, fingerprint, hostC
92
120
  normalizer: new MarAgentConversationNormalizer(),
93
121
  mcpLease,
94
122
  releaseEnvironment,
123
+ ...(networkContext === undefined
124
+ ? {}
125
+ : { releaseNetworkContext: () => networkContext?.close() }),
95
126
  automaticTitleEnabled: input.externalSessionId === undefined,
96
127
  models,
97
128
  compactState,
@@ -103,6 +134,7 @@ export async function createSessionRuntime(input, sessionKey, fingerprint, hostC
103
134
  catch (error) {
104
135
  for (const cleanup of [
105
136
  () => agent?.dispose(),
137
+ () => networkContext?.close(),
106
138
  () => closeModelCredentialProviders(models),
107
139
  () => mcpLease.release(),
108
140
  () => releaseEnvironment?.()
@@ -155,6 +187,7 @@ export async function releaseSessionRuntime(runtime) {
155
187
  const failures = [];
156
188
  for (const cleanup of [
157
189
  () => runtime.agent.dispose(),
190
+ () => runtime.releaseNetworkContext?.(),
158
191
  () => runtime.mcpLease.release(),
159
192
  () => runtime.releaseEnvironment?.()
160
193
  ]) {
@@ -122,6 +122,7 @@ export class MarAgentRunner extends AbstractRunner {
122
122
  id: model.id,
123
123
  label: model.name,
124
124
  supportedEfforts: [...model.reasoningEfforts],
125
+ subagentModel: model.subagentModel === true,
125
126
  defaultEffort: resolveMarAgentDefaultReasoningEffort(model.defaultReasoningEffort, model.reasoningEfforts),
126
127
  ...(index === 0 ? { isDefault: true } : {})
127
128
  })),
@@ -195,6 +196,16 @@ export class MarAgentRunner extends AbstractRunner {
195
196
  ]
196
197
  };
197
198
  }
199
+ childModels() {
200
+ const eligible = new Set(this.#models
201
+ .filter((model) => model.enabled && model.conversationModel !== false && model.subagentModel === true)
202
+ .map((model) => model.id));
203
+ return this.profileForValidation().models.filter((model) => eligible.has(model.id));
204
+ }
205
+ assertChildModel(modelId) {
206
+ if (!this.childModels().some((model) => model.id === modelId))
207
+ throw new Error('MAR_AGENT_SUBAGENT_MODEL_UNAVAILABLE');
208
+ }
198
209
  supportsConfiguration(configuration) {
199
210
  if (configuration.runner !== this.name)
200
211
  return false;
@@ -289,6 +300,9 @@ export class MarAgentRunner extends AbstractRunner {
289
300
  runner: this.name,
290
301
  externalSessionId: session.id,
291
302
  cwd: session.workspace,
303
+ ...(session.source?.parentSessionId === undefined
304
+ ? {}
305
+ : { parentSessionId: session.source.parentSessionId }),
292
306
  lastActivityAt: Date.parse(session.lastActivityAt)
293
307
  })
294
308
  ]
@@ -311,6 +325,9 @@ export class MarAgentRunner extends AbstractRunner {
311
325
  runner: this.name,
312
326
  externalSessionId: session.id,
313
327
  cwd: session.workspace,
328
+ ...(session.source?.parentSessionId === undefined
329
+ ? {}
330
+ : { parentSessionId: session.source.parentSessionId }),
314
331
  ...title,
315
332
  lastActivityAt: Date.parse(session.lastActivityAt)
316
333
  }),
@@ -406,6 +423,25 @@ export class MarAgentRunner extends AbstractRunner {
406
423
  await catalog.close().catch(() => undefined);
407
424
  }
408
425
  }
426
+ supportsNativeBatchRemoval() {
427
+ return true;
428
+ }
429
+ async removeNativeMembers(sessions) {
430
+ const ids = sessions.map((session) => {
431
+ if (session.runner !== this.name || session.externalSessionId === null)
432
+ throw new Error('NATIVE_TRANSCRIPT_UNAVAILABLE');
433
+ return session.externalSessionId;
434
+ });
435
+ for (const id of ids)
436
+ await this.#releaseSessionResources?.(id);
437
+ const catalog = await openAgentSessionCatalog({ homeDirectory: this.homeDirectory });
438
+ try {
439
+ await catalog.deleteMembers(ids);
440
+ }
441
+ finally {
442
+ await catalog.close().catch(() => undefined);
443
+ }
444
+ }
409
445
  async readManagedRunnerTitle(session, nativeSessionId) {
410
446
  if (session.runner !== this.name || session.externalSessionId !== nativeSessionId)
411
447
  return undefined;
@@ -1,4 +1,5 @@
1
1
  import { compactRunnerText, compactRunnerValue } from '../normalization.js';
2
+ import { publicOutputSnapshot, shellExecution } from '../execution-presentation.js';
2
3
  export function normalizeOpenCodeTool(toolName, state) {
3
4
  const status = state?.status === 'completed'
4
5
  ? 'COMPLETED'
@@ -23,7 +24,11 @@ export function normalizeOpenCodeTool(toolName, state) {
23
24
  outputRef: null,
24
25
  exitCode: typeof state?.exitCode === 'number' ? state.exitCode : null,
25
26
  durationMs: null,
26
- truncated: false
27
+ truncated: typeof state?.output === 'string' && state.output.length > 10_000,
28
+ ...(typeof state?.output === 'string'
29
+ ? { output: publicOutputSnapshot(state.output) }
30
+ : {}),
31
+ toolPresentation: shellExecution(typeof state?.output === 'string' ? state.output : undefined)
27
32
  }
28
33
  };
29
34
  return {
@@ -872,6 +872,63 @@ export class NodeRuntimeState {
872
872
  return executionId;
873
873
  return undefined;
874
874
  }
875
+ /** Read the identity and status of one Execution without following a later turn. */
876
+ executionSnapshot(executionId) {
877
+ const execution = this.executions.get(executionId);
878
+ if (execution !== undefined) {
879
+ const run = this.getRun(execution.runId);
880
+ return run === undefined
881
+ ? undefined
882
+ : {
883
+ executionId,
884
+ runId: run.id,
885
+ sessionId: run.sessionId,
886
+ status: execution.status
887
+ };
888
+ }
889
+ const retained = this.retainedExecutionTurns.get(executionId);
890
+ if (retained === undefined)
891
+ return undefined;
892
+ const turn = this.turns.get(retained.sessionId)?.find((value) => value.id === retained.turnId);
893
+ return turn?.runId == null
894
+ ? undefined
895
+ : {
896
+ executionId,
897
+ runId: turn.runId,
898
+ sessionId: retained.sessionId,
899
+ status: turn.status
900
+ };
901
+ }
902
+ latestRunExecution(runId) {
903
+ const turn = this.conversationTurnForRun(runId);
904
+ if (turn === undefined)
905
+ return undefined;
906
+ for (const execution of this.executions.values())
907
+ if (execution.runId === runId && execution.turnId === turn.id)
908
+ return this.executionSnapshot(execution.id);
909
+ for (const [executionId, retained] of this.retainedExecutionTurns)
910
+ if (retained.sessionId === turn.sessionId && retained.turnId === turn.id)
911
+ return this.executionSnapshot(executionId);
912
+ return undefined;
913
+ }
914
+ /** Resolve the current or most recent retained Execution of a Session. */
915
+ latestSessionExecution(sessionId) {
916
+ const active = this.activeSessionRun(sessionId);
917
+ if (active !== undefined)
918
+ return this.latestRunExecution(active.id);
919
+ const turns = this.turns.get(sessionId) ?? [];
920
+ for (let index = turns.length - 1; index >= 0; index -= 1) {
921
+ const turn = turns[index];
922
+ const live = [...this.executions.values()].find((value) => value.turnId === turn.id);
923
+ if (live !== undefined)
924
+ return this.executionSnapshot(live.id);
925
+ for (const [executionId, retained] of this.retainedExecutionTurns) {
926
+ if (retained.sessionId === sessionId && retained.turnId === turn.id)
927
+ return this.executionSnapshot(executionId);
928
+ }
929
+ }
930
+ return undefined;
931
+ }
875
932
  createExecution(runId) {
876
933
  const canonicalRunId = this.canonicalRunId(runId);
877
934
  const turn = this.currentTurnForRun(canonicalRunId);