@myagentroam/agent 0.11.11 → 0.11.13

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.
@@ -297,6 +297,7 @@ export function createSessionOpener(services) {
297
297
  const operation = emitTail.then(async () => {
298
298
  assertLive?.();
299
299
  const persistent = eventForPersistence(full);
300
+ let committedTerminal = false;
300
301
  if (persistent !== undefined && releaseSession !== undefined) {
301
302
  const stored = await store.append(sessionId, {
302
303
  type: full.type,
@@ -307,7 +308,7 @@ export function createSessionOpener(services) {
307
308
  if (full.type === 'execution.completed' ||
308
309
  full.type === 'execution.failed' ||
309
310
  full.type === 'execution.cancelled')
310
- persistedTerminal = true;
311
+ committedTerminal = persistedTerminal = true;
311
312
  if (full.type === 'message.completed') {
312
313
  const message = liveModelMessages.findLast((item) => item.role === 'assistant' && item.content === full.text);
313
314
  if (message)
@@ -316,8 +317,30 @@ export function createSessionOpener(services) {
316
317
  }
317
318
  queue.push(full);
318
319
  compactRequests.publish(full);
319
- if (internal.publishHostEvents !== false)
320
- await host.emit(full);
320
+ if (internal.publishHostEvents !== false) {
321
+ try {
322
+ await host.emit(full);
323
+ }
324
+ catch (error) {
325
+ if (!committedTerminal)
326
+ throw error;
327
+ // Host observation cannot rewrite a terminal already committed to the Store.
328
+ try {
329
+ // Host errors may contain private data; publish only SDK-owned facts.
330
+ process.emitWarning(new MarAgentError('MAR_AGENT_HOST_EVENT_PUBLICATION_FAILED', `Host publication of ${full.type} failed for Execution ${executionId}.`, {
331
+ details: {
332
+ sessionId,
333
+ executionId,
334
+ eventId: full.eventId,
335
+ eventType: full.type
336
+ }
337
+ }));
338
+ }
339
+ catch {
340
+ // A diagnostic sink must not change the committed outcome either.
341
+ }
342
+ }
343
+ }
321
344
  });
322
345
  emitTail = operation.catch(() => undefined);
323
346
  return operation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/agent",
3
- "version": "0.11.11",
3
+ "version": "0.11.13",
4
4
  "description": "Embeddable MAR coding agent SDK and CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",