@myagentroam/node 0.11.48 → 0.11.49

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/connector.js CHANGED
@@ -67,7 +67,7 @@ import { SessionScheduleService } from './session/session-schedule-service.js';
67
67
  import { ScheduledSessionCoordinator } from './service/scheduled-session-coordinator.js';
68
68
  import { ScheduledSessionStore } from './service/scheduled-session-store.js';
69
69
  import { RunAuthorizationControl } from './service/run-authorization-control.js';
70
- import { PlannedRestartHandoff } from './service/planned-restart-handoff.js';
70
+ import { PlannedRestartHandoff, plannedRestartCaptureDiagnostic } from './service/planned-restart-handoff.js';
71
71
  import { NodeUpgradeCredentialControl } from './service/node-upgrade-credential-control.js';
72
72
  import { RestartSessionRestorer } from './service/restart-session-restorer.js';
73
73
  import { ScheduleMcpBridge } from './service/schedule-mcp-bridge.js';
@@ -200,7 +200,8 @@ export class NodeConnector {
200
200
  publish: (snapshot) => this.restartHandoff.publish(snapshot),
201
201
  diagnose: (stage, error) => nodeLog('node.shutdown.failed', {
202
202
  stage,
203
- errorCode: safeErrorCode(error, 'NODE_SHUTDOWN_FAILED')
203
+ errorCode: safeErrorCode(error, 'NODE_SHUTDOWN_FAILED'),
204
+ ...(stage === 'capture' ? plannedRestartCaptureDiagnostic(error) : undefined)
204
205
  })
205
206
  });
206
207
  get stopped() {
@@ -131,7 +131,9 @@ const tools = [
131
131
  ];
132
132
  const delegationPrompt = [
133
133
  '# Delegation and coordination',
134
- 'Delegate bounded, self-contained tasks when independent progress or context savings materially helps. Keep simple or tightly coupled work local.',
134
+ 'Handle focused or tightly coupled work locally by default.',
135
+ 'Delegate a clearly separable subtask when parallel progress or context savings materially outweigh coordination overhead.',
136
+ 'Do not split work merely because agents are available.',
135
137
  'Give each child an objective, necessary context, expected output, and a read-only boundary or non-overlapping write scope.',
136
138
  'Follow up through the direct delegate by default; inspect deeper Sessions only when a concrete issue needs independent verification.',
137
139
  'While children run, continue meaningful non-overlapping work. Do not redo delegated work. Wait only when the next step needs the result.',
@@ -84,6 +84,44 @@ const legacyPlannedRestartSchema = plannedRestartSchema.extend({
84
84
  })
85
85
  }))
86
86
  });
87
+ // Only this producer can associate log-safe metadata with an original failure.
88
+ const captureDiagnostics = new WeakMap();
89
+ const captureFields = new Set([
90
+ ...Object.keys(plannedRestartSchema.shape),
91
+ ...Object.keys(sessionSchema.shape),
92
+ ...Object.keys(sessionSchema.shape.session.shape),
93
+ ...Object.keys(goalSchema.shape),
94
+ ...Object.keys(goalSchema.shape.goal.shape),
95
+ ...Object.keys(messageSchema.shape),
96
+ ...Object.keys(attachmentSchema.shape)
97
+ ]);
98
+ export function plannedRestartCaptureDiagnostic(error) {
99
+ return error instanceof Error ? captureDiagnostics.get(error) : undefined;
100
+ }
101
+ function parseCapture(schema, input, reason) {
102
+ const result = schema.safeParse(input);
103
+ if (result.success)
104
+ return result.data;
105
+ captureDiagnostics.set(result.error, {
106
+ reason,
107
+ issues: result.error.issues.slice(0, 12).map((issue) => ({
108
+ code: issue.code,
109
+ // Only schema-owned fields and array offsets, never unknown keys or input values.
110
+ path: issue.path
111
+ .slice(0, 8)
112
+ .map((part) => typeof part === 'number'
113
+ ? `[${part}]`
114
+ : captureFields.has(String(part))
115
+ ? String(part)
116
+ : '*')
117
+ .join('.')
118
+ .replaceAll('.[', '[')
119
+ .slice(0, 160)
120
+ })),
121
+ issuesTruncated: result.error.issues.length > 12
122
+ });
123
+ throw result.error;
124
+ }
87
125
  export const RESTART_NOTICE = 'The previous execution was interrupted by a system restart. Check the session history and current workspace, then continue unfinished work. Verify completed or uncertain actions before proceeding; do not blindly repeat actions with external side effects.';
88
126
  /** A one-shot orderly-shutdown handoff, not a crash-recovery journal. */
89
127
  export class PlannedRestartHandoff {
@@ -197,8 +235,13 @@ export class PlannedRestartHandoff {
197
235
  : toMessage(currentId, pending.clientMessageId ?? active.clientMessageId, pending.restartMessage.content, [...pending.restartMessage.attachments], pending.restartMessage.initiatedByUserId ?? active?.initiatedByUserId, active?.suppressNotifications);
198
236
  if (current === undefined && items.length === 0 && goal === undefined && !awaitingGoal)
199
237
  continue;
200
- if (session.externalSessionId === null)
201
- throw new Error('RESTART_SESSION_NOT_READY');
238
+ if (session.externalSessionId === null) {
239
+ const error = Object.assign(new Error('RESTART_SESSION_NOT_READY'), {
240
+ code: 'RESTART_SESSION_NOT_READY'
241
+ });
242
+ captureDiagnostics.set(error, { reason: 'session_not_ready' });
243
+ throw error;
244
+ }
202
245
  const ownerUserId = active?.initiatedByUserId ??
203
246
  items[0]?.initiatedByUserId ??
204
247
  this.owners.get(session.id) ??
@@ -220,18 +263,20 @@ export class PlannedRestartHandoff {
220
263
  ...(notificationSource?.suppressNotifications === true
221
264
  ? { suppressNotifications: true }
222
265
  : {}),
223
- ...(goal === undefined ? {} : { goal: goalSchema.parse(goal) }),
266
+ ...(goal === undefined
267
+ ? {}
268
+ : { goal: parseCapture(goalSchema, goal, 'goal_schema_invalid') }),
224
269
  ...(current === undefined ? {} : { current }),
225
270
  queue: items
226
271
  });
227
272
  }
228
- return plannedRestartSchema.parse({
273
+ return parseCapture(plannedRestartSchema, {
229
274
  schemaVersion: 2,
230
275
  id: randomUUID(),
231
276
  ...this.options.identity(),
232
277
  createdAt: Date.now(),
233
278
  sessions
234
- });
279
+ }, 'snapshot_schema_invalid');
235
280
  }
236
281
  async publish(snapshot) {
237
282
  for (const entry of snapshot.sessions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/node",
3
- "version": "0.11.48",
3
+ "version": "0.11.49",
4
4
  "description": "MyAgentRoam Node runtime CLI.",
5
5
  "license": "Apache-2.0 AND GPL-2.0-or-later",
6
6
  "type": "module",
@@ -38,10 +38,10 @@
38
38
  "sharp": "0.35.5",
39
39
  "ws": "^8.21.3",
40
40
  "zod": "4.4.3",
41
- "@myagentroam/agent": "0.11.48",
41
+ "@myagentroam/agent": "0.11.49",
42
42
  "@myagentroam/code-navigation": "0.11.1",
43
- "@myagentroam/protocol": "0.11.48",
44
- "@myagentroam/marctl": "0.11.9"
43
+ "@myagentroam/marctl": "0.11.9",
44
+ "@myagentroam/protocol": "0.11.49"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/ws": "^8.18.1"