maka-agent 0.2.0-dev.26.20260909 → 0.2.0-dev.28.20260911

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 (125) hide show
  1. package/LICENSE +106 -0
  2. package/dist/cli-core.js +28 -0
  3. package/dist/runtime-host-cli.js +43 -3
  4. package/dist/runtime-host-handoff-surface.js +10 -8
  5. package/dist/runtime-host-lifecycle-transaction.js +28 -3
  6. package/dist/runtime-host-local-source-retirement.js +1 -1
  7. package/dist/runtime-host-run-command.js +15 -7
  8. package/dist/runtime-host-setup-command.js +29 -6
  9. package/dist/runtime-host-update-command.js +49 -5
  10. package/dist/session-export-command.js +72 -0
  11. package/dist/session-import-command.js +69 -0
  12. package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
  13. package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
  14. package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
  15. package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
  16. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  17. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +9 -4
  18. package/node_modules/@maka/core/dist/diagnostic-log.js +18 -7
  19. package/node_modules/@maka/core/dist/text-sanitize.js +8 -2
  20. package/node_modules/@maka/core/dist/usage-stats/types.js +2 -0
  21. package/node_modules/@maka/core/dist/workhub-routing.js +126 -0
  22. package/node_modules/@maka/core/package.json +2 -1
  23. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +15 -11
  24. package/node_modules/@maka/runtime/dist/archive-read-tool.js +3 -1
  25. package/node_modules/@maka/runtime/dist/bots/bot-test.js +2 -1
  26. package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +24 -20
  27. package/node_modules/@maka/runtime/dist/bots/slack-bridge.js +5 -3
  28. package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +87 -29
  29. package/node_modules/@maka/runtime/dist/bots/wecom-bridge.js +40 -36
  30. package/node_modules/@maka/runtime/dist/builtin-tools.js +21 -2
  31. package/node_modules/@maka/runtime/dist/computer-use-tools.js +4 -1
  32. package/node_modules/@maka/runtime/dist/deep-research-tools.js +11 -5
  33. package/node_modules/@maka/runtime/dist/edit-replace.js +2 -2
  34. package/node_modules/@maka/runtime/dist/filesystem-worker/operations.js +5 -6
  35. package/node_modules/@maka/runtime/dist/memory-extraction-evidence.js +7 -1
  36. package/node_modules/@maka/runtime/dist/memory-extraction.js +12 -7
  37. package/node_modules/@maka/runtime/dist/openai-responses-websocket.js +2 -5
  38. package/node_modules/@maka/runtime/dist/plugin-agent-service.js +131 -0
  39. package/node_modules/@maka/runtime/dist/plugin-approval-service.js +33 -0
  40. package/node_modules/@maka/runtime/dist/plugin-attachment-service.js +53 -0
  41. package/node_modules/@maka/runtime/dist/plugin-command-service.js +100 -0
  42. package/node_modules/@maka/runtime/dist/plugin-composition-loader.js +11 -2
  43. package/node_modules/@maka/runtime/dist/plugin-data-services.js +332 -0
  44. package/node_modules/@maka/runtime/dist/plugin-fs-service.js +62 -0
  45. package/node_modules/@maka/runtime/dist/plugin-goal-service.js +61 -0
  46. package/node_modules/@maka/runtime/dist/plugin-invocation-signal.js +24 -0
  47. package/node_modules/@maka/runtime/dist/plugin-llm-service.js +85 -0
  48. package/node_modules/@maka/runtime/dist/plugin-lsp-service.js +94 -0
  49. package/node_modules/@maka/runtime/dist/plugin-scope-registry.js +91 -0
  50. package/node_modules/@maka/runtime/dist/plugin-session-query-service.js +71 -0
  51. package/node_modules/@maka/runtime/dist/plugin-shell-env-service.js +87 -0
  52. package/node_modules/@maka/runtime/dist/plugin-shell-service.js +74 -0
  53. package/node_modules/@maka/runtime/dist/plugin-skill-service.js +93 -0
  54. package/node_modules/@maka/runtime/dist/plugin-system-prompt-service.js +346 -0
  55. package/node_modules/@maka/runtime/dist/plugin-tool-service.js +18 -52
  56. package/node_modules/@maka/runtime/dist/plugin-user-question-service.js +43 -0
  57. package/node_modules/@maka/runtime/dist/plugin-web-service.js +69 -0
  58. package/node_modules/@maka/runtime/dist/request-customization-fetch.js +14 -7
  59. package/node_modules/@maka/runtime/dist/session-export.js +178 -0
  60. package/node_modules/@maka/runtime/dist/session-import.js +100 -0
  61. package/node_modules/@maka/runtime/dist/session-manager.js +6 -1
  62. package/node_modules/@maka/runtime/dist/shell-run-manager.js +9 -6
  63. package/node_modules/@maka/runtime/dist/shell-run-tool-result.js +13 -6
  64. package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +43 -10
  65. package/node_modules/@maka/runtime/dist/stream-graph-handoff.js +6 -1
  66. package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +1 -4
  67. package/node_modules/@maka/runtime/dist/system-prompt/workspace-instructions.js +11 -6
  68. package/node_modules/@maka/runtime/dist/tavily-search.js +8 -2
  69. package/node_modules/@maka/runtime/dist/text-line-window.js +49 -0
  70. package/node_modules/@maka/runtime/dist/tool-output.js +35 -12
  71. package/node_modules/@maka/runtime/dist/unified-diff.js +40 -10
  72. package/node_modules/@maka/runtime/dist/web-fetch-tool.js +4 -2
  73. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +82 -33
  74. package/node_modules/@maka/runtime/dist/workspace-executor.js +2 -6
  75. package/node_modules/@maka/runtime/package.json +20 -1
  76. package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +73 -24
  77. package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +46 -12
  78. package/node_modules/@maka/runtime-host/dist/operator/setup-frame.js +31 -21
  79. package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +7 -4
  80. package/node_modules/@maka/runtime-host/dist/protocol/artifact.js +2 -2
  81. package/node_modules/@maka/runtime-host/dist/protocol/index.js +10 -1
  82. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +30 -5
  83. package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +3 -2
  84. package/node_modules/@maka/runtime-host/dist/protocol/skill-catalog.js +2 -1
  85. package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +25 -23
  86. package/node_modules/@maka/runtime-host/dist/server/artifact-coordinator.js +2 -0
  87. package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +62 -4
  88. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +481 -11
  89. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +74 -0
  90. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +6 -1
  91. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +2 -2
  92. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +30 -0
  93. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +114 -20
  94. package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +49 -12
  95. package/node_modules/@maka/runtime-host/dist/server/plugin-data-runtime.js +234 -0
  96. package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +6 -0
  97. package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +12 -0
  98. package/node_modules/@maka/runtime-host/dist/server/root-admission-owner.js +17 -8
  99. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +189 -92
  100. package/node_modules/@maka/runtime-host/dist/server/runtime-resource-projection.js +3 -9
  101. package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +20 -21
  102. package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +24 -2
  103. package/node_modules/@maka/runtime-host/dist/server/skill-catalog-coordinator.js +18 -2
  104. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +44 -35
  105. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +92 -10
  106. package/node_modules/@maka/runtime-host/dist/transport/framed-byte-stream-transport.js +4 -1
  107. package/node_modules/@maka/runtime-host/dist/transport/local-ipc-framing.js +4 -2
  108. package/node_modules/@maka/runtime-host/dist/transport/peer-native.js +9 -8
  109. package/node_modules/@maka/runtime-host/dist/transport/resumable-peer-stream.js +14 -9
  110. package/node_modules/@maka/storage/dist/agent-run-store.js +54 -10
  111. package/node_modules/@maka/storage/dist/context-offload-snapshot.js +32 -10
  112. package/node_modules/@maka/storage/dist/context-value-mutation-gate.js +59 -0
  113. package/node_modules/@maka/storage/dist/execution-stores.js +1 -1
  114. package/node_modules/@maka/storage/dist/session-bundle-policy.js +909 -34
  115. package/node_modules/@maka/storage/dist/session-message-projection.js +8 -4
  116. package/node_modules/@maka/storage/dist/session-store.js +2 -2
  117. package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +18 -4
  118. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +12 -5
  119. package/node_modules/@maka/storage/dist/stable-storage.js +2 -1
  120. package/node_modules/@maka/storage/package.json +2 -0
  121. package/node_modules/@modelcontextprotocol/client/dist/src-D_zzAWoS.mjs +22 -5
  122. package/node_modules/@modelcontextprotocol/client/dist/src-NAgB4Mp8.cjs +22 -5
  123. package/node_modules/zod/v4/core/memoizer.cjs +12 -16
  124. package/node_modules/zod/v4/core/memoizer.js +12 -16
  125. package/package.json +1 -1
@@ -69,10 +69,14 @@ function normalizePreviewText(text) {
69
69
  return text.replace(/\s+/g, ' ').trim();
70
70
  }
71
71
  function truncatePreview(text, maxLength = 96) {
72
- const chars = Array.from(text);
73
- if (chars.length <= maxLength)
74
- return text;
75
- return `${chars.slice(0, maxLength - 1).join('')}…`;
72
+ const chars = [];
73
+ for (const point of text) {
74
+ if (chars.length === maxLength) {
75
+ return `${chars.slice(0, maxLength - 1).join('')}…`;
76
+ }
77
+ chars.push(point);
78
+ }
79
+ return text;
76
80
  }
77
81
  /** One Turn's summary, folded message by message in transcript order. */
78
82
  export function foldTurnContribution(current, turnId, sequence, message) {
@@ -446,9 +446,9 @@ class SqliteSessionStore {
446
446
  await this.ensureReady();
447
447
  await this.metadata.updateMessageAdmission(admission);
448
448
  }
449
- async reorderMessageAdmissions(sessionId, messageIds) {
449
+ async reorderMessageAdmissions(sessionId, messageIds, disposition = 'followup') {
450
450
  await this.ensureReady();
451
- await this.metadata.reorderMessageAdmissions(sessionId, messageIds);
451
+ await this.metadata.reorderMessageAdmissions(sessionId, messageIds, disposition);
452
452
  }
453
453
  async cancelMessageAdmissions(sessionId, messageIds) {
454
454
  await this.ensureReady();
@@ -24,6 +24,7 @@ import { dirname, isAbsolute, join, relative, sep } from 'node:path';
24
24
  import { CONTEXT_OFFLOAD_ID_MAX_CODE_POINTS, } from '@maka/core/context-offload';
25
25
  import { configureSqliteContextOffloadDatabase, migrateSqliteContextOffloadDatabase, } from './sqlite-context-offload-schema.js';
26
26
  import { readStableBoundedFile, syncDirectory, syncDirectoryChain, syncFile, } from './stable-storage.js';
27
+ import { runWithContextValueMutation } from './context-value-mutation-gate.js';
27
28
  const MAX_MEDIA_TYPE_CODE_POINTS = 256;
28
29
  const SHA256_PATTERN = /^[0-9a-f]{64}$/;
29
30
  const MANAGED_FILE_LOCATOR_PATTERN = /^sha256\/([0-9a-f]{2})\/([0-9a-f]{64})$/;
@@ -40,7 +41,7 @@ export class SqliteContextOffloadStore {
40
41
  #onUnavailable;
41
42
  #storageRoot;
42
43
  #valueRoot;
43
- #managedValueMutationTail = Promise.resolve();
44
+ #mutationGateKey;
44
45
  #closed = false;
45
46
  constructor(path, options) {
46
47
  if (!path)
@@ -57,6 +58,11 @@ export class SqliteContextOffloadStore {
57
58
  this.#valueRoot = this.#storageRoot
58
59
  ? join(this.#storageRoot, CONTEXT_OFFLOAD_VALUES_DIRECTORY_NAME)
59
60
  : undefined;
61
+ // The canonical root is the key, so every writer of these files -- this
62
+ // Store and an importer publishing into the same workspace -- queues in one
63
+ // place. A Store with no durable root holds no managed files, so it queues
64
+ // against itself alone and keeps the behaviour it had.
65
+ this.#mutationGateKey = this.#storageRoot ?? `memory:${randomUUID()}`;
60
66
  const Database = loadDatabaseSync();
61
67
  this.#database = new Database(path);
62
68
  try {
@@ -874,10 +880,18 @@ export class SqliteContextOffloadStore {
874
880
  }
875
881
  return join(valueRoot, 'sha256', match[1], blobId);
876
882
  }
883
+ /**
884
+ * Takes a turn in the Storage Root's context mutation queue.
885
+ *
886
+ * This used to be a promise tail private to the instance, which serialised
887
+ * this Store's publication against its own collection and fenced nothing
888
+ * else. An importer publishing payloads into a live workspace has to take the
889
+ * same turn: these operations read database state, await, and only then act
890
+ * on files, so anything interleaving at that await acts on a decision that is
891
+ * no longer true.
892
+ */
877
893
  #runManagedValueMutation(operation) {
878
- const pending = this.#managedValueMutationTail.then(operation, operation);
879
- this.#managedValueMutationTail = pending.then(() => undefined, () => undefined);
880
- return pending;
894
+ return runWithContextValueMutation(this.#mutationGateKey, operation);
881
895
  }
882
896
  #markBlobUnreferencedIfEligible(blobId, unreferencedAt) {
883
897
  this.#database
@@ -1799,7 +1799,7 @@ export class SqliteSessionMetadataStore {
1799
1799
  }
1800
1800
  });
1801
1801
  }
1802
- async reorderMessageAdmissions(sessionId, messageIds) {
1802
+ async reorderMessageAdmissions(sessionId, messageIds, disposition = 'followup') {
1803
1803
  this.assertOpen();
1804
1804
  assertSafeSessionId(sessionId);
1805
1805
  const unique = [...new Set(messageIds)];
@@ -1813,13 +1813,13 @@ export class SqliteSessionMetadataStore {
1813
1813
  .prepare(`
1814
1814
  SELECT message_id
1815
1815
  FROM message_admissions
1816
- WHERE session_id = ? AND disposition = 'followup'
1816
+ WHERE session_id = ? AND disposition = ?
1817
1817
  ORDER BY queue_order, sequence
1818
1818
  `)
1819
- .all(sessionId);
1819
+ .all(sessionId, disposition);
1820
1820
  const current = rows.map((row) => row.message_id);
1821
1821
  const currentIds = new Set(current);
1822
- if (current.length !== unique.length ||
1822
+ if ((disposition === 'followup' && current.length !== unique.length) ||
1823
1823
  unique.some((messageId) => !currentIds.has(messageId))) {
1824
1824
  throw new SessionMetadataConflictError('Message admission reorder identity conflict');
1825
1825
  }
@@ -1828,7 +1828,14 @@ export class SqliteSessionMetadataStore {
1828
1828
  SET queue_order = ?
1829
1829
  WHERE session_id = ? AND message_id = ?
1830
1830
  `);
1831
- unique.forEach((messageId, index) => update.run(index, sessionId, messageId));
1831
+ // Older steering may already be in flight. Keep those entries in their
1832
+ // slots so recovery never interleaves them with a newly reordered batch.
1833
+ const selected = new Set(unique);
1834
+ let next = 0;
1835
+ current.forEach((messageId, index) => {
1836
+ const orderedId = selected.has(messageId) ? unique[next++] : messageId;
1837
+ update.run(index, sessionId, orderedId);
1838
+ });
1832
1839
  });
1833
1840
  }
1834
1841
  async readCoordinationTranscriptIndexState() {
@@ -42,7 +42,8 @@ export async function readStableBoundedFile(input, dependencies = {}) {
42
42
  }
43
43
  try {
44
44
  const initial = await stableFileSnapshot(handle, input, deps);
45
- const bytes = Buffer.allocUnsafe(input.maxBytes + 1);
45
+ // One extra byte detects growth even if the file shrinks before the final stat.
46
+ const bytes = Buffer.allocUnsafe(Number(initial.size) + 1);
46
47
  let offset = 0;
47
48
  while (offset < bytes.length) {
48
49
  const result = await handle.read(bytes, offset, bytes.length - offset, offset);
@@ -43,6 +43,8 @@
43
43
  "./scheduled-task-store": "./dist/scheduled-task-store.js",
44
44
  "./quiescent-session-snapshot": "./dist/quiescent-session-snapshot.js",
45
45
  "./production-session-snapshot": "./dist/production-session-snapshot.js",
46
+ "./session-bundle-contract": "./dist/session-bundle-contract.js",
47
+ "./session-bundle-file-service": "./dist/session-bundle-file-service.js",
46
48
  "./session-bundle-policy": "./dist/session-bundle-policy.js",
47
49
  "./session-copy-cleanup": "./dist/session-copy-cleanup.js",
48
50
  "./session-todo-authority": "./dist/session-todo-authority.js",
@@ -5552,6 +5552,22 @@ function requestStateAccessor(value) {
5552
5552
  /** Shared no-state accessor: the common case allocates nothing per request. */
5553
5553
  const NO_REQUEST_STATE = requestStateAccessor(void 0);
5554
5554
  let writeNegotiatedProtocolVersion;
5555
+ // Separate scopes keep pending transport sends from retaining request arguments.
5556
+ function makaCancellationErrorObserver(protocol) {
5557
+ return (error) => protocol._onerror(new Error(`Failed to send cancellation: ${error}`));
5558
+ }
5559
+ function makaRequestErrorObserver(protocol, messageId, reject) {
5560
+ return {
5561
+ onError(error) {
5562
+ protocol._progressHandlers.delete(messageId);
5563
+ reject?.(error);
5564
+ },
5565
+ release() {
5566
+ // Native reject retains the settled promise graph until explicitly revoked.
5567
+ reject = void 0;
5568
+ }
5569
+ };
5570
+ }
5555
5571
  /**
5556
5572
  * Implements MCP protocol framing on top of a pluggable transport, including
5557
5573
  * features like request/response linking, notifications, and progress.
@@ -6055,6 +6071,7 @@ var Protocol = class {
6055
6071
  const flowStartedAt = Date.now();
6056
6072
  let onAbort;
6057
6073
  let cleanupMessageId;
6074
+ let sendObserver;
6058
6075
  return new Promise((resolve, reject) => {
6059
6076
  const earlyReject = (error) => {
6060
6077
  reject(error);
@@ -6107,7 +6124,7 @@ var Protocol = class {
6107
6124
  relatedRequestId,
6108
6125
  resumptionToken,
6109
6126
  onresumptiontoken
6110
- }).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error}`)));
6127
+ }).catch(makaCancellationErrorObserver(this));
6111
6128
  else requestAbort.abort();
6112
6129
  reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
6113
6130
  };
@@ -6148,17 +6165,17 @@ var Protocol = class {
6148
6165
  const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
6149
6166
  const timeoutHandler = () => cancel(new SdkError(SdkErrorCode.RequestTimeout, "Request timed out", { timeout }));
6150
6167
  this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
6168
+ sendObserver = makaRequestErrorObserver(this, messageId, reject);
6151
6169
  this._transport.send(outbound, {
6152
6170
  relatedRequestId,
6153
6171
  resumptionToken,
6154
6172
  onresumptiontoken,
6155
6173
  headers,
6156
6174
  requestSignal: requestAbort?.signal
6157
- }).catch((error) => {
6158
- this._progressHandlers.delete(messageId);
6159
- reject(error);
6160
- });
6175
+ }).catch(sendObserver.onError);
6161
6176
  }).finally(() => {
6177
+ // Release request state without dropping queued frames or closing the connection.
6178
+ sendObserver?.release();
6162
6179
  if (onAbort) options?.signal?.removeEventListener("abort", onAbort);
6163
6180
  if (cleanupMessageId !== void 0) {
6164
6181
  this._responseHandlers.delete(cleanupMessageId);
@@ -5553,6 +5553,22 @@ function requestStateAccessor(value) {
5553
5553
  /** Shared no-state accessor: the common case allocates nothing per request. */
5554
5554
  const NO_REQUEST_STATE = requestStateAccessor(void 0);
5555
5555
  let writeNegotiatedProtocolVersion;
5556
+ // Separate scopes keep pending transport sends from retaining request arguments.
5557
+ function makaCancellationErrorObserver(protocol) {
5558
+ return (error) => protocol._onerror(new Error(`Failed to send cancellation: ${error}`));
5559
+ }
5560
+ function makaRequestErrorObserver(protocol, messageId, reject) {
5561
+ return {
5562
+ onError(error) {
5563
+ protocol._progressHandlers.delete(messageId);
5564
+ reject?.(error);
5565
+ },
5566
+ release() {
5567
+ // Native reject retains the settled promise graph until explicitly revoked.
5568
+ reject = void 0;
5569
+ }
5570
+ };
5571
+ }
5556
5572
  /**
5557
5573
  * Implements MCP protocol framing on top of a pluggable transport, including
5558
5574
  * features like request/response linking, notifications, and progress.
@@ -6056,6 +6072,7 @@ var Protocol = class {
6056
6072
  const flowStartedAt = Date.now();
6057
6073
  let onAbort;
6058
6074
  let cleanupMessageId;
6075
+ let sendObserver;
6059
6076
  return new Promise((resolve, reject) => {
6060
6077
  const earlyReject = (error) => {
6061
6078
  reject(error);
@@ -6108,7 +6125,7 @@ var Protocol = class {
6108
6125
  relatedRequestId,
6109
6126
  resumptionToken,
6110
6127
  onresumptiontoken
6111
- }).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error}`)));
6128
+ }).catch(makaCancellationErrorObserver(this));
6112
6129
  else requestAbort.abort();
6113
6130
  reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
6114
6131
  };
@@ -6149,17 +6166,17 @@ var Protocol = class {
6149
6166
  const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
6150
6167
  const timeoutHandler = () => cancel(new SdkError(SdkErrorCode.RequestTimeout, "Request timed out", { timeout }));
6151
6168
  this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
6169
+ sendObserver = makaRequestErrorObserver(this, messageId, reject);
6152
6170
  this._transport.send(outbound, {
6153
6171
  relatedRequestId,
6154
6172
  resumptionToken,
6155
6173
  onresumptiontoken,
6156
6174
  headers,
6157
6175
  requestSignal: requestAbort?.signal
6158
- }).catch((error) => {
6159
- this._progressHandlers.delete(messageId);
6160
- reject(error);
6161
- });
6176
+ }).catch(sendObserver.onError);
6162
6177
  }).finally(() => {
6178
+ // Release request state without dropping queued frames or closing the connection.
6179
+ sendObserver?.release();
6163
6180
  if (onAbort) options?.signal?.removeEventListener("abort", onAbort);
6164
6181
  if (cleanupMessageId !== void 0) {
6165
6182
  this._responseHandlers.delete(cleanupMessageId);
@@ -187,9 +187,6 @@ const memo = {
187
187
  attach(inst) {
188
188
  var _a;
189
189
  let isRecursiveInst;
190
- // `bucket` memoized for one parse; a recursive schema is re-entered many times and its bucket never changes
191
- let lastCtx;
192
- let lastBucket;
193
190
  // Wraps `parse` in a deferred so it sees the container's final parse. Core's own deferred copies `parse` into `run` when there are no checks, and it ran first, so `run` is patched to match; with checks, `run` reads `parse` dynamically.
194
191
  (_a = inst._zod).deferred ?? (_a.deferred = []);
195
192
  inst._zod.deferred.push(() => {
@@ -213,15 +210,7 @@ const memo = {
213
210
  state = { buckets: new Map(), backEdges: undefined };
214
211
  ctx[STATE] = state;
215
212
  }
216
- let bucket;
217
- if (lastCtx === ctx) {
218
- bucket = lastBucket;
219
- }
220
- else {
221
- bucket = bucketFor(state, inst);
222
- lastCtx = ctx;
223
- lastBucket = bucket;
224
- }
213
+ const bucket = bucketFor(state, inst);
225
214
  const hit = bucket.get(input);
226
215
  if (hit) {
227
216
  payload.value = hit.value;
@@ -237,12 +226,19 @@ const memo = {
237
226
  }
238
227
  return payload;
239
228
  }
229
+ const previousHandoff = handoff;
240
230
  handoff = bucket;
241
231
  const depth = open.length;
242
- const result = base(payload, ctx);
243
- handoff = undefined;
244
- // A container that rejected its input outright allocated nothing.
245
- const entry = open.length > depth ? open.pop() : undefined;
232
+ let result;
233
+ let entry;
234
+ try {
235
+ result = base(payload, ctx);
236
+ }
237
+ finally {
238
+ handoff = previousHandoff;
239
+ // A container that rejected its input outright allocated nothing.
240
+ entry = open.length > depth ? open.pop() : undefined;
241
+ }
246
242
  // Both paths written out so the sync one allocates no closure. It runs once per node, and capturing here cost more than everything else combined.
247
243
  if (result instanceof Promise) {
248
244
  return result.then((r) => {
@@ -180,9 +180,6 @@ const memo = {
180
180
  attach(inst) {
181
181
  var _a;
182
182
  let isRecursiveInst;
183
- // `bucket` memoized for one parse; a recursive schema is re-entered many times and its bucket never changes
184
- let lastCtx;
185
- let lastBucket;
186
183
  // Wraps `parse` in a deferred so it sees the container's final parse. Core's own deferred copies `parse` into `run` when there are no checks, and it ran first, so `run` is patched to match; with checks, `run` reads `parse` dynamically.
187
184
  (_a = inst._zod).deferred ?? (_a.deferred = []);
188
185
  inst._zod.deferred.push(() => {
@@ -206,15 +203,7 @@ const memo = {
206
203
  state = { buckets: new Map(), backEdges: undefined };
207
204
  ctx[STATE] = state;
208
205
  }
209
- let bucket;
210
- if (lastCtx === ctx) {
211
- bucket = lastBucket;
212
- }
213
- else {
214
- bucket = bucketFor(state, inst);
215
- lastCtx = ctx;
216
- lastBucket = bucket;
217
- }
206
+ const bucket = bucketFor(state, inst);
218
207
  const hit = bucket.get(input);
219
208
  if (hit) {
220
209
  payload.value = hit.value;
@@ -230,12 +219,19 @@ const memo = {
230
219
  }
231
220
  return payload;
232
221
  }
222
+ const previousHandoff = handoff;
233
223
  handoff = bucket;
234
224
  const depth = open.length;
235
- const result = base(payload, ctx);
236
- handoff = undefined;
237
- // A container that rejected its input outright allocated nothing.
238
- const entry = open.length > depth ? open.pop() : undefined;
225
+ let result;
226
+ let entry;
227
+ try {
228
+ result = base(payload, ctx);
229
+ }
230
+ finally {
231
+ handoff = previousHandoff;
232
+ // A container that rejected its input outright allocated nothing.
233
+ entry = open.length > depth ? open.pop() : undefined;
234
+ }
239
235
  // Both paths written out so the sync one allocates no closure. It runs once per node, and capturing here cost more than everything else combined.
240
236
  if (result instanceof Promise) {
241
237
  return result.then((r) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maka-agent",
3
- "version": "0.2.0-dev.26.20260909",
3
+ "version": "0.2.0-dev.28.20260911",
4
4
  "description": "Apache Maka (Incubating) developer snapshot; not an Apache release.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",