@myagentroam/node 0.9.75 → 0.9.77

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.
@@ -6,6 +6,8 @@ export class MarAgentConversationNormalizer {
6
6
  #processOrigins = new Map();
7
7
  #subagentTitles = new Map();
8
8
  #subagentDetails = new Map();
9
+ #subagentStarts = new Map();
10
+ #subagentLifecycles = new Map();
9
11
  messageItemId(nativeItemId) {
10
12
  return itemId('message', nativeItemId);
11
13
  }
@@ -120,57 +122,8 @@ export class MarAgentConversationNormalizer {
120
122
  merge: true
121
123
  }
122
124
  ];
123
- if (event.type === 'subagent.started' || event.type === 'subagent.completed') {
124
- const eventDescription = record(event)?.description;
125
- const eventTitle = compactRunnerText(typeof eventDescription === 'string' ? eventDescription : '', 500);
126
- if (eventTitle.length > 0)
127
- this.#subagentTitles.set(event.agentId, eventTitle);
128
- const title = eventTitle || this.#subagentTitles.get(event.agentId) || 'Subagent';
129
- const details = mergeSubagentDetails(this.#subagentDetails.get(event.agentId), subagentDetails(event));
130
- if (Object.keys(details).length > 0)
131
- this.#subagentDetails.set(event.agentId, details);
132
- const latestText = typeof details.latestMessage?.text === 'string' ? details.latestMessage.text : undefined;
133
- const outputSummary = event.type === 'subagent.completed'
134
- ? latestText === undefined
135
- ? event.errorMessage === undefined
136
- ? null
137
- : boundedToolSummary(event.errorMessage)
138
- : boundedToolSummary(latestText)
139
- : null;
140
- return [
141
- {
142
- itemId: itemId('subagent', event.agentId),
143
- kind: 'tool_call',
144
- status: event.type === 'subagent.started'
145
- ? 'IN_PROGRESS'
146
- : event.status === 'completed'
147
- ? 'COMPLETED'
148
- : event.status === 'cancelled'
149
- ? 'CANCELLED'
150
- : event.status === 'interrupted'
151
- ? 'INTERRUPTED'
152
- : 'FAILED',
153
- payload: {
154
- namespace: 'mar-agent',
155
- toolName: 'agent_wait',
156
- title,
157
- inputSummary: event.type === 'subagent.started'
158
- ? compactRunnerText(event.description, 10_000)
159
- : null,
160
- outputSummary,
161
- progressLabel: event.type === 'subagent.started' ? 'Running' : null,
162
- errorCode: event.type === 'subagent.completed' && event.status === 'failed'
163
- ? (event.errorCode ?? 'MAR_AGENT_SUBAGENT_FAILED')
164
- : null,
165
- truncated: latestText !== undefined && outputSummary !== latestText,
166
- subagentOperation: 'STATUS',
167
- subagentId: event.agentId,
168
- ...subagentPayload(details)
169
- },
170
- merge: true
171
- }
172
- ];
173
- }
125
+ if (event.type === 'subagent.started' || event.type === 'subagent.completed')
126
+ return this.#subagentLifecycle(event);
174
127
  return [];
175
128
  }
176
129
  #toolStarted(event) {
@@ -262,7 +215,7 @@ export class MarAgentConversationNormalizer {
262
215
  ? (marAgentAgentId(state?.input) ?? marAgentAgentId(controlOutput))
263
216
  : undefined;
264
217
  const details = controlTool
265
- ? mergeSubagentDetails(state?.subagentDetails, subagentDetails(controlOutput))
218
+ ? mergeSubagentDetails(mergeSubagentDetails(agentId === undefined ? undefined : this.#subagentDetails.get(agentId), state?.subagentDetails ?? {}), subagentDetails(controlOutput))
266
219
  : {};
267
220
  if (agentId !== undefined) {
268
221
  const output = structuredRecord(controlOutput);
@@ -273,10 +226,17 @@ export class MarAgentConversationNormalizer {
273
226
  }
274
227
  if (Object.keys(details).length > 0)
275
228
  this.#subagentDetails.set(agentId, details);
229
+ if (event.toolName === 'agent_start' && state !== undefined)
230
+ this.#subagentStarts.set(agentId, state);
276
231
  }
277
- const item = genericToolItem(state?.itemId ?? itemId('tool', event.callId), event.toolName, 'COMPLETED', state?.input, generatedImages.length === 0
278
- ? event.summary
279
- : generatedImages.map((image) => image.name).join(', '), null, event.truncated, event.data, state?.subagentTitle, details);
232
+ const lifecycle = event.toolName === 'agent_start' && agentId !== undefined
233
+ ? this.#subagentLifecycles.get(agentId)
234
+ : undefined;
235
+ const item = genericToolItem(state?.itemId ?? itemId('tool', event.callId), event.toolName, lifecycle?.status ??
236
+ (event.toolName === 'agent_start' ? subagentControlStatus(controlOutput) : 'COMPLETED'), state?.input, lifecycle?.outputSummary ??
237
+ (generatedImages.length === 0
238
+ ? event.summary
239
+ : generatedImages.map((image) => image.name).join(', ')), lifecycle?.errorCode ?? null, lifecycle?.truncated ?? event.truncated, event.data, agentId === undefined ? state?.subagentTitle : this.#subagentTitles.get(agentId), details);
280
240
  return [
281
241
  {
282
242
  ...item,
@@ -297,6 +257,47 @@ export class MarAgentConversationNormalizer {
297
257
  genericToolItem(state?.itemId ?? itemId('tool', event.callId), event.toolName, 'FAILED', state?.input, event.message ?? event.code, event.code, false, undefined, state?.subagentTitle, state?.subagentDetails)
298
258
  ];
299
259
  }
260
+ #subagentLifecycle(event) {
261
+ const eventDescription = record(event)?.description;
262
+ const eventTitle = compactRunnerText(typeof eventDescription === 'string' ? eventDescription : '', 500);
263
+ if (eventTitle.length > 0)
264
+ this.#subagentTitles.set(event.agentId, eventTitle);
265
+ const title = eventTitle || this.#subagentTitles.get(event.agentId) || 'Subagent';
266
+ const details = mergeSubagentDetails(this.#subagentDetails.get(event.agentId), subagentDetails(event));
267
+ if (Object.keys(details).length > 0)
268
+ this.#subagentDetails.set(event.agentId, details);
269
+ const latestText = typeof details.latestMessage?.text === 'string' ? details.latestMessage.text : undefined;
270
+ const outputSummary = event.type === 'subagent.completed'
271
+ ? latestText === undefined
272
+ ? event.errorMessage === undefined
273
+ ? null
274
+ : boundedToolSummary(event.errorMessage)
275
+ : boundedToolSummary(latestText)
276
+ : null;
277
+ const lifecycle = {
278
+ status: event.type === 'subagent.started'
279
+ ? 'IN_PROGRESS'
280
+ : event.status === 'completed'
281
+ ? 'COMPLETED'
282
+ : event.status === 'cancelled'
283
+ ? 'CANCELLED'
284
+ : event.status === 'interrupted'
285
+ ? 'INTERRUPTED'
286
+ : 'FAILED',
287
+ outputSummary,
288
+ errorCode: event.type === 'subagent.completed' && event.status === 'failed'
289
+ ? (event.errorCode ?? 'MAR_AGENT_SUBAGENT_FAILED')
290
+ : null,
291
+ truncated: latestText !== undefined && outputSummary !== latestText
292
+ };
293
+ this.#subagentLifecycles.set(event.agentId, lifecycle);
294
+ const start = this.#subagentStarts.get(event.agentId);
295
+ if (start === undefined)
296
+ return [];
297
+ return [
298
+ subagentStartItem(start, event.agentId, title, details, lifecycle)
299
+ ];
300
+ }
300
301
  }
301
302
  function itemId(kind, value) {
302
303
  return boundedConversationItemId(`mar-agent-${kind}`, value);
@@ -325,6 +326,15 @@ function genericToolItem(id, toolName, status, input, outputSummary = null, erro
325
326
  merge: true
326
327
  };
327
328
  }
329
+ function subagentStartItem(start, agentId, title, details, lifecycle) {
330
+ return genericToolItem(start.itemId, 'agent_start', lifecycle.status, start.input, lifecycle.outputSummary, lifecycle.errorCode, lifecycle.truncated, {
331
+ agentId,
332
+ description: title,
333
+ ...details,
334
+ ...(lifecycle.errorCode === null ? {} : { errorCode: lifecycle.errorCode }),
335
+ ...(lifecycle.outputSummary === null ? {} : { errorMessage: lifecycle.outputSummary })
336
+ }, title, details);
337
+ }
328
338
  function commandItem(command, status) {
329
339
  return {
330
340
  itemId: command.itemId,
@@ -493,6 +503,20 @@ function marAgentSubagentOperation(toolName) {
493
503
  return 'CANCEL';
494
504
  return undefined;
495
505
  }
506
+ function subagentControlStatus(value) {
507
+ const status = structuredRecord(value)?.status;
508
+ if (status === 'queued' || status === 'running')
509
+ return 'IN_PROGRESS';
510
+ if (status === 'completed')
511
+ return 'COMPLETED';
512
+ if (status === 'cancelled')
513
+ return 'CANCELLED';
514
+ if (status === 'interrupted')
515
+ return 'INTERRUPTED';
516
+ if (status === 'failed')
517
+ return 'FAILED';
518
+ return 'COMPLETED';
519
+ }
496
520
  function subagentDetails(value) {
497
521
  const data = structuredRecord(value);
498
522
  if (data === undefined)
@@ -52,6 +52,7 @@ export class MarAgentRuntimeModelFactory {
52
52
  defaultReasoningEffort: resolveMarAgentDefaultReasoningEffort(configuration.defaultReasoningEffort, configuration.reasoningEfforts),
53
53
  titleGeneration: configuration.titleGeneration,
54
54
  codeMode: configuration.codeMode,
55
+ highDensityCompaction: configuration.highDensityCompaction,
55
56
  hostedWebSearch: configuration.hostedWebSearch,
56
57
  ...(imageGeneration === undefined ? {} : { imageGeneration }),
57
58
  ...(configuration.responsesTransport === undefined
@@ -1964,6 +1964,7 @@ function modelSummary(model, index) {
1964
1964
  defaultReasoningEffort: resolveMarAgentDefaultReasoningEffort(model.defaultReasoningEffort, model.reasoningEfforts),
1965
1965
  titleGeneration: model.titleGeneration,
1966
1966
  codeMode: model.codeMode,
1967
+ highDensityCompaction: model.highDensityCompaction,
1967
1968
  hostedWebSearch: model.hostedWebSearch,
1968
1969
  ...(model.responsesTransport === undefined
1969
1970
  ? {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/node",
3
- "version": "0.9.75",
3
+ "version": "0.9.77",
4
4
  "description": "MyAgentRoam Node runtime CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -28,8 +28,8 @@
28
28
  "node-pty": "1.1.0",
29
29
  "ws": "^8.21.3",
30
30
  "zod": "4.4.3",
31
- "@myagentroam/agent": "0.9.75",
32
- "@myagentroam/protocol": "0.9.75"
31
+ "@myagentroam/agent": "0.9.77",
32
+ "@myagentroam/protocol": "0.9.77"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/ws": "^8.18.1"