maka-agent 0.2.0-dev.11.20260831 → 0.2.0-dev.14.20260902

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 (226) hide show
  1. package/LICENSE +2 -2
  2. package/RUNTIME_HOST_PEER_DEPENDENCIES.rust.tsv +70 -0
  3. package/RUNTIME_HOST_PEER_THIRD_PARTY_NOTICES.txt +1839 -140
  4. package/THIRD_PARTY_NOTICES.txt +2 -2
  5. package/dist/acp/maka-acp-agent.js +6 -3
  6. package/dist/acp/session-registry.js +307 -0
  7. package/dist/acp/stdio-server.js +20 -1
  8. package/dist/cli-core.js +40 -3
  9. package/dist/mcp-capability-provider.js +1 -1
  10. package/dist/onboarding-catalog.js +3 -5
  11. package/dist/pi-transcript.js +21 -17
  12. package/dist/pi-tui-layout.js +4 -2
  13. package/dist/pi-tui-mcp-status.js +44 -130
  14. package/dist/pi-tui-pickers.js +11 -5
  15. package/dist/pi-tui-runner.js +133 -102
  16. package/dist/runtime-host-access-command.js +37 -4
  17. package/dist/runtime-host-capability-provider-command.js +16 -2
  18. package/dist/runtime-host-cli-context.js +73 -3
  19. package/dist/runtime-host-cli.js +187 -10
  20. package/dist/runtime-host-lifecycle-transaction.js +5 -2
  21. package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
  22. package/dist/runtime-host-onboarding.js +12 -16
  23. package/dist/runtime-host-peer-management-command.js +16 -4
  24. package/dist/runtime-host-plugin-command.js +101 -0
  25. package/dist/runtime-host-run-command.js +8 -2
  26. package/dist/runtime-host-service-management-command.js +2 -1
  27. package/dist/runtime-host-setup-command.js +1 -0
  28. package/dist/runtime-host-task-readiness.js +2 -3
  29. package/dist/runtime-host-tui-command.js +1 -1
  30. package/dist/runtime-host-tui-context.js +18 -5
  31. package/dist/runtime-host-update-command.js +71 -35
  32. package/dist/runtime-host-update-discovery.js +1 -0
  33. package/dist/tui-clipboard.js +86 -0
  34. package/dist/tui-copy-catalog.js +248 -0
  35. package/dist/tui-copy-command.js +103 -0
  36. package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
  37. package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
  38. package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
  39. package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
  40. package/node_modules/@maka/core/dist/attachments.js +92 -1
  41. package/node_modules/@maka/core/dist/bounded-response.js +71 -0
  42. package/node_modules/@maka/core/dist/chat-model-choice.js +8 -33
  43. package/node_modules/@maka/core/dist/client-capability-grant.js +149 -0
  44. package/node_modules/@maka/core/dist/connection-error-copy.js +17 -34
  45. package/node_modules/@maka/core/dist/connection-readiness.js +3 -31
  46. package/node_modules/@maka/core/dist/deep-research.js +1 -20
  47. package/node_modules/@maka/core/dist/events.js +22 -14
  48. package/node_modules/@maka/core/dist/foreign-session.js +2 -2
  49. package/node_modules/@maka/core/dist/interaction.js +49 -2
  50. package/node_modules/@maka/core/dist/llm-connections.js +74 -82
  51. package/node_modules/@maka/core/dist/maka-wordmark.js +23 -0
  52. package/node_modules/@maka/core/dist/model-catalog.js +242 -315
  53. package/node_modules/@maka/core/dist/model-facts.js +13 -19
  54. package/node_modules/@maka/core/dist/model-metadata.generated.js +1907 -1872
  55. package/node_modules/@maka/core/dist/model-metadata.js +184 -199
  56. package/node_modules/@maka/core/dist/model-thinking.js +1 -1
  57. package/node_modules/@maka/core/dist/models-dev-projection.js +302 -0
  58. package/node_modules/@maka/core/dist/models-dev-refresh.js +55 -0
  59. package/node_modules/@maka/core/dist/onboarding.js +2 -1
  60. package/node_modules/@maka/core/dist/provider-auth.js +47 -291
  61. package/node_modules/@maka/core/dist/provider-registry.js +68 -357
  62. package/node_modules/@maka/core/dist/runtime-event.js +5 -0
  63. package/node_modules/@maka/core/dist/runtime-policy/connection-catalog-codec.js +83 -18
  64. package/node_modules/@maka/core/dist/runtime-policy/credential-vault-codec.js +9 -1
  65. package/node_modules/@maka/core/dist/runtime-policy/model-catalog-entry-codec.js +84 -0
  66. package/node_modules/@maka/core/dist/runtime-policy/policy-codec.js +75 -0
  67. package/node_modules/@maka/core/dist/runtime-policy.js +5 -2
  68. package/node_modules/@maka/core/dist/session-send-projection.js +2 -1
  69. package/node_modules/@maka/core/dist/session-start-mode.js +42 -0
  70. package/node_modules/@maka/core/dist/session.js +120 -5
  71. package/node_modules/@maka/core/dist/settings.js +10 -2
  72. package/node_modules/@maka/core/dist/slash-command-catalog.js +1 -0
  73. package/node_modules/@maka/core/dist/task-submission-readiness.js +2 -1
  74. package/node_modules/@maka/core/dist/usage-record-schema.js +11 -1
  75. package/node_modules/@maka/core/dist/workhub-creation-intent.js +896 -0
  76. package/node_modules/@maka/core/package.json +8 -2
  77. package/node_modules/@maka/mcp/dist/index.js +1 -0
  78. package/node_modules/@maka/runtime/dist/agent-run.js +7 -0
  79. package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +55 -82
  80. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +178 -140
  81. package/node_modules/@maka/runtime/dist/archive-read-tool.js +26 -5
  82. package/node_modules/@maka/runtime/dist/builtin-tools.js +27 -2
  83. package/node_modules/@maka/runtime/dist/context-budget-policy.js +0 -12
  84. package/node_modules/@maka/runtime/dist/conversation-copy.js +66 -43
  85. package/node_modules/@maka/runtime/dist/durable-tool-result-projection.js +31 -0
  86. package/node_modules/@maka/runtime/dist/history-compact-error.js +10 -2
  87. package/node_modules/@maka/runtime/dist/history-compact-input-fit.js +7 -1
  88. package/node_modules/@maka/runtime/dist/history-compaction.js +13 -22
  89. package/node_modules/@maka/runtime/dist/image-file.js +5 -20
  90. package/node_modules/@maka/runtime/dist/local-web-fetch.js +2 -43
  91. package/node_modules/@maka/runtime/dist/mcp-tools.js +28 -0
  92. package/node_modules/@maka/runtime/dist/model-fetcher.js +15 -8
  93. package/node_modules/@maka/runtime/dist/model-history.js +59 -17
  94. package/node_modules/@maka/runtime/dist/model-runtime.js +2 -2
  95. package/node_modules/@maka/runtime/dist/plugin-composition-loader.js +173 -20
  96. package/node_modules/@maka/runtime/dist/plugin-runtime.js +219 -0
  97. package/node_modules/@maka/runtime/dist/provider-image-overflow-recovery.js +12 -31
  98. package/node_modules/@maka/runtime/dist/quiescent-session-snapshot.js +78 -0
  99. package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +6 -0
  100. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +14 -2
  101. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +11 -10
  102. package/node_modules/@maka/runtime/dist/shell-tools.js +77 -1
  103. package/node_modules/@maka/runtime/dist/telemetry/model-pricing.generated.js +93 -83
  104. package/node_modules/@maka/runtime/dist/test-connection.js +6 -6
  105. package/node_modules/@maka/runtime/dist/tool-availability.js +74 -5
  106. package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +333 -52
  107. package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +34 -3
  108. package/node_modules/@maka/runtime/dist/tool-runtime.js +62 -6
  109. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +39 -16
  110. package/node_modules/@maka/runtime/package.json +1 -0
  111. package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +10 -3
  112. package/node_modules/@maka/runtime-host/dist/client/catalog-reader.js +59 -18
  113. package/node_modules/@maka/runtime-host/dist/client/client-capability-channel.js +3 -2
  114. package/node_modules/@maka/runtime-host/dist/client/connection.js +72 -31
  115. package/node_modules/@maka/runtime-host/dist/client/host-profile.js +49 -4
  116. package/node_modules/@maka/runtime-host/dist/client/index.js +3 -2
  117. package/node_modules/@maka/runtime-host/dist/client/oauth-presentation.js +1 -1
  118. package/node_modules/@maka/runtime-host/dist/client/owner-connection-code.js +32 -1
  119. package/node_modules/@maka/runtime-host/dist/client/peer-client.js +26 -4
  120. package/node_modules/@maka/runtime-host/dist/client/reconnecting-connection.js +8 -0
  121. package/node_modules/@maka/runtime-host/dist/operator/access-management-frame.js +10 -1
  122. package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
  123. package/node_modules/@maka/runtime-host/dist/operator/managed-deployment.js +2 -0
  124. package/node_modules/@maka/runtime-host/dist/operator/peer-management-frame.js +2 -0
  125. package/node_modules/@maka/runtime-host/dist/operator/service-management-frame.js +2 -0
  126. package/node_modules/@maka/runtime-host/dist/peer-mesh/node.js +56 -12
  127. package/node_modules/@maka/runtime-host/dist/peer-mesh/owner.js +4 -0
  128. package/node_modules/@maka/runtime-host/dist/protocol/client-capability.js +22 -1
  129. package/node_modules/@maka/runtime-host/dist/protocol/configuration.js +55 -9
  130. package/node_modules/@maka/{storage/dist/task-ledger-store-internal.js → runtime-host/dist/protocol/connection-catalog-change.js} +7 -13
  131. package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +37 -0
  132. package/node_modules/@maka/runtime-host/dist/protocol/index.js +49 -1
  133. package/node_modules/@maka/runtime-host/dist/protocol/network-proxy.js +1 -7
  134. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
  135. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +512 -0
  136. package/node_modules/@maka/runtime-host/dist/protocol/runtime-policy.js +72 -61
  137. package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +1 -1
  138. package/node_modules/@maka/runtime-host/dist/protocol/session-collaboration.js +4 -2
  139. package/node_modules/@maka/runtime-host/dist/protocol/turn.js +5 -12
  140. package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +92 -4
  141. package/node_modules/@maka/runtime-host/dist/server/access-authority.js +17 -14
  142. package/node_modules/@maka/runtime-host/dist/server/access-credential-metadata.js +4 -2
  143. package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +119 -47
  144. package/node_modules/@maka/runtime-host/dist/server/agent-graph-execution-coordinator.js +1 -2
  145. package/node_modules/@maka/runtime-host/dist/server/bootstrap-runtime-policy.js +10 -4
  146. package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +0 -9
  147. package/node_modules/@maka/runtime-host/dist/server/client-capability-coordinator.js +192 -18
  148. package/node_modules/@maka/runtime-host/dist/server/client-capability-invocation-broker.js +122 -48
  149. package/node_modules/@maka/runtime-host/dist/server/client-capability-provider-id.js +31 -0
  150. package/node_modules/@maka/runtime-host/dist/server/configuration-coordinator.js +20 -1
  151. package/node_modules/@maka/runtime-host/dist/server/connection-effect-coordinator.js +5 -5
  152. package/node_modules/@maka/runtime-host/dist/server/connection-session.js +1 -0
  153. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +163 -28
  154. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +2 -2
  155. package/node_modules/@maka/runtime-host/dist/server/execution-service.js +4 -1
  156. package/node_modules/@maka/runtime-host/dist/server/extension-bundle.js +249 -0
  157. package/node_modules/@maka/runtime-host/dist/server/extension-package-manifest.js +262 -0
  158. package/node_modules/@maka/runtime-host/dist/server/host-change-feed.js +11 -0
  159. package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +15 -0
  160. package/node_modules/@maka/runtime-host/dist/server/index.js +5 -0
  161. package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +181 -13
  162. package/node_modules/@maka/runtime-host/dist/server/interaction-projection.js +6 -0
  163. package/node_modules/@maka/runtime-host/dist/server/listener-set.js +8 -4
  164. package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +88 -22
  165. package/node_modules/@maka/runtime-host/dist/server/model-metadata-refresh.js +96 -0
  166. package/node_modules/@maka/runtime-host/dist/server/network-proxy-coordinator.js +0 -1
  167. package/node_modules/@maka/runtime-host/dist/server/operation-dispatcher.js +43 -118
  168. package/node_modules/@maka/runtime-host/dist/server/peer-listener.js +3 -0
  169. package/node_modules/@maka/runtime-host/dist/server/plugin-composition-patch.js +58 -0
  170. package/node_modules/@maka/runtime-host/dist/server/plugin-composition-store.js +141 -0
  171. package/node_modules/@maka/runtime-host/dist/server/plugin-package-loader.js +130 -0
  172. package/node_modules/@maka/runtime-host/dist/server/plugin-package-store.js +528 -0
  173. package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +249 -0
  174. package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +1130 -0
  175. package/node_modules/@maka/runtime-host/dist/server/root-admission-owner.js +4 -0
  176. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +24 -5
  177. package/node_modules/@maka/runtime-host/dist/server/runtime-policy-coordinator.js +57 -5
  178. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +2 -1
  179. package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +3 -3
  180. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +35 -3
  181. package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +16 -0
  182. package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +10 -2
  183. package/node_modules/@maka/runtime-host/dist/server/web-fetch-tool.js +1 -1
  184. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +276 -3
  185. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +101 -1
  186. package/node_modules/@maka/runtime-host/dist/transport/peer-native.js +1 -0
  187. package/node_modules/@maka/runtime-host/dist/webrtc-stun-policy.js +114 -0
  188. package/node_modules/@maka/runtime-host/package.json +2 -0
  189. package/node_modules/@maka/storage/dist/agent-run-store.js +4 -0
  190. package/node_modules/@maka/storage/dist/artifact-store.js +7 -23
  191. package/node_modules/@maka/storage/dist/conversation-operational-state.js +3 -0
  192. package/node_modules/@maka/storage/dist/execution-stores.js +3 -0
  193. package/node_modules/@maka/storage/dist/interaction-store-public.js +1 -1
  194. package/node_modules/@maka/storage/dist/interaction-store.js +173 -0
  195. package/node_modules/@maka/storage/dist/production-session-snapshot.js +761 -0
  196. package/node_modules/@maka/storage/dist/quiescent-session-snapshot.js +1 -1
  197. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +19 -22
  198. package/node_modules/@maka/storage/dist/runtime-policy/coordinator.js +205 -42
  199. package/node_modules/@maka/storage/dist/runtime-policy/onboarding-transaction.js +2 -2
  200. package/node_modules/@maka/storage/dist/runtime-policy-stores.js +5 -2
  201. package/node_modules/@maka/storage/dist/session-message-projection.js +1 -1
  202. package/node_modules/@maka/storage/dist/session-store.js +32 -6
  203. package/node_modules/@maka/storage/dist/session-todo-store.js +6 -68
  204. package/node_modules/@maka/storage/dist/settings-store.js +16 -25
  205. package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +19 -0
  206. package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +10 -1
  207. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +73 -3
  208. package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +2 -10
  209. package/node_modules/@maka/storage/package.json +2 -0
  210. package/node_modules/fast-uri/index.js +215 -47
  211. package/node_modules/fast-uri/lib/schemes.js +9 -4
  212. package/node_modules/fast-uri/lib/utils.js +396 -92
  213. package/node_modules/fast-uri/package.json +1 -1
  214. package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
  215. package/node_modules/qs/CHANGELOG.md +15 -0
  216. package/node_modules/qs/README.md +19 -1
  217. package/node_modules/qs/dist/qs.js +21 -21
  218. package/node_modules/qs/eslint.config.mjs +1 -1
  219. package/node_modules/qs/lib/parse.js +3 -4
  220. package/node_modules/qs/lib/stringify.js +23 -8
  221. package/node_modules/qs/lib/utils.js +10 -3
  222. package/node_modules/qs/package.json +4 -4
  223. package/package.json +1 -1
  224. package/node_modules/@maka/core/dist/task-ledger.js +0 -669
  225. package/node_modules/@maka/storage/dist/task-ledger-authority.js +0 -121
  226. package/node_modules/@maka/storage/dist/task-ledger-store.js +0 -663
@@ -16,7 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
- import { CONNECTION_CATALOG_MAX_CONNECTIONS, CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS, CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION, decodeCanonicalConnectionBaseUrl, decodeCanonicalRuntimePolicy, decodeConnectionModel, decodeConnectionModelId, decodeConnectionName, decodeConnectionSlug, decodeConnectionTarget, decodeConnectionTestSummary, decodeConnectionVersionBasis, decodeRuntimePolicyEntityId, decodeCredentialLocator, decodeCredentialStatus, decodeCredentialVersionBasis, decodeProviderType, normalizeCreateCatalogConnectionInput, normalizeDeleteCredentialInput, normalizeRemoveCatalogConnectionInput, normalizeOptionalRequestBodyOverlay, normalizeRequestHeaderUpdates, normalizeRuntimePolicyMutation, normalizeSetCredentialInput, normalizeSetDefaultConnectionTargetInput, normalizeUpdateCatalogConnectionInput, REQUEST_HEADERS_MAX_BYTES, RequestCustomizationValidationError, RuntimePolicyDomainDecodeError, } from '@maka/core/runtime-policy';
19
+ import { CONNECTION_CATALOG_MAX_CONNECTIONS, CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS, CONNECTION_CATALOG_MAX_ENTRIES_PER_CONNECTION, CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION, decodeCanonicalConnectionBaseUrl, decodeModelCatalogEntry, decodeCanonicalRuntimePolicy, decodeConnectionModel, decodeConnectionModelId, decodeConnectionName, decodeConnectionSlug, decodeConnectionTarget, decodeConnectionTestSummary, decodeConnectionVersionBasis, decodeRuntimePolicyEntityId, decodeCredentialLocator, decodeCredentialStatus, decodeCredentialVersionBasis, decodeProviderType, normalizeCreateCatalogConnectionInput, normalizeDeleteCredentialInput, normalizeRemoveCatalogConnectionInput, normalizeOptionalRequestBodyOverlay, normalizeNetworkProxyUpdate, normalizeNetworkProxyCredentialTarget, normalizeRequestHeaderUpdates, normalizeRuntimePolicyMutation, normalizeSetCredentialInput, normalizeSetDefaultConnectionTargetInput, normalizeUpdateCatalogConnectionInput, REQUEST_HEADERS_MAX_BYTES, RequestCustomizationValidationError, RuntimePolicyDomainDecodeError, } from '@maka/core/runtime-policy';
20
20
  import { normalizeRelayModelProfiles } from '@maka/core/model-thinking';
21
21
  import { requireExactRecord, requireShapedRecord, requireRecord } from './codec.js';
22
22
  import { invalidProtocolFrame } from './errors.js';
@@ -25,33 +25,6 @@ export const CONNECTION_CATALOG_PAGE_MAX_ITEMS = 128;
25
25
  export const CONNECTION_CATALOG_PAGE_MAX_BYTES = 48 * 1024;
26
26
  export const RUNTIME_POLICY_SNAPSHOT_MAX_BYTES = 48 * 1024;
27
27
  export const CREDENTIAL_SECRET_MAX_BYTES = 10 * 1024;
28
- const CONNECTION_MODEL_FIELDS = [
29
- 'id',
30
- 'displayName',
31
- 'description',
32
- 'apiProtocol',
33
- 'contextWindow',
34
- 'inputLimit',
35
- 'maxOutputTokens',
36
- 'knowledgeCutoff',
37
- 'structuredOutput',
38
- 'lastUpdated',
39
- 'capabilities',
40
- 'modalities',
41
- ];
42
- const MODEL_FACT_OVERRIDE_FIELDS = [
43
- 'displayName',
44
- 'description',
45
- 'apiProtocol',
46
- 'contextWindow',
47
- 'inputLimit',
48
- 'maxOutputTokens',
49
- 'knowledgeCutoff',
50
- 'structuredOutput',
51
- 'lastUpdated',
52
- 'capabilities',
53
- 'modalities',
54
- ];
55
28
  const QUERY_ERRORS = [
56
29
  'host_not_ready',
57
30
  'host_draining',
@@ -85,6 +58,13 @@ export const RUNTIME_POLICY_OPERATION_SPECS = {
85
58
  decodeInput: decodeRuntimePolicyMutation,
86
59
  decodeOutput: decodeRuntimePolicyMutationResult,
87
60
  }),
61
+ 'runtime.policy.network-proxy.update': defineOperation({
62
+ mode: 'command',
63
+ availability: 'ready',
64
+ errors: MUTATION_ERRORS,
65
+ decodeInput: decodeRuntimePolicyNetworkProxyUpdate,
66
+ decodeOutput: decodeRuntimePolicyNetworkProxyUpdateResult,
67
+ }),
88
68
  'connection.catalog.query': defineOperation({
89
69
  mode: 'query',
90
70
  availability: 'ready',
@@ -185,6 +165,44 @@ function decodeRuntimePolicyMutationResult(value) {
185
165
  }
186
166
  return revisionConflict(item, 'runtime policy mutation result');
187
167
  }
168
+ function decodeRuntimePolicyNetworkProxyUpdate(value) {
169
+ const input = decodeDomain(() => normalizeNetworkProxyUpdate(value));
170
+ if (input.credential.kind === 'replace' &&
171
+ Buffer.byteLength(input.credential.secret, 'utf8') > CREDENTIAL_SECRET_MAX_BYTES) {
172
+ throw invalidProtocolFrame('Invalid network proxy credential secret');
173
+ }
174
+ return input;
175
+ }
176
+ function decodeRuntimePolicyNetworkProxyUpdateResult(value) {
177
+ const item = requireRecord(value, 'network proxy update result');
178
+ if (item.kind === 'committed') {
179
+ const committed = requireExactRecord(item, 'network proxy update committed result', [
180
+ 'kind',
181
+ 'revision',
182
+ 'credentialStatus',
183
+ ]);
184
+ return {
185
+ kind: 'committed',
186
+ revision: revision(committed.revision, 'runtime policy revision'),
187
+ credentialStatus: decodeDomain(() => decodeCredentialStatus(committed.credentialStatus)),
188
+ };
189
+ }
190
+ if (item.kind === 'credential_stale')
191
+ return credentialStale(item);
192
+ if (item.kind === 'proxy_target_mismatch') {
193
+ const mismatch = requireExactRecord(item, 'network proxy target mismatch', [
194
+ 'kind',
195
+ 'expected',
196
+ 'actual',
197
+ ]);
198
+ return {
199
+ kind: 'proxy_target_mismatch',
200
+ expected: decodeDomain(() => normalizeNetworkProxyCredentialTarget(mismatch.expected)),
201
+ actual: decodeDomain(() => normalizeNetworkProxyCredentialTarget(mismatch.actual)),
202
+ };
203
+ }
204
+ return revisionConflict(item, 'network proxy update result');
205
+ }
188
206
  function decodeCatalogQueryInput(value) {
189
207
  const item = requireRecord(value, 'connection catalog query input');
190
208
  if (item.kind === 'start') {
@@ -260,7 +278,7 @@ function catalogCursor(value) {
260
278
  part: 'connection',
261
279
  };
262
280
  }
263
- if (item.part === 'enabled_model_id' || item.part === 'model') {
281
+ if (item.part === 'enabled_model_id' || item.part === 'model' || item.part === 'catalog_entry') {
264
282
  const cursor = requireExactRecord(item, 'connection catalog cursor', [
265
283
  'connectionIndex',
266
284
  'part',
@@ -268,7 +286,9 @@ function catalogCursor(value) {
268
286
  ]);
269
287
  const maxItems = item.part === 'enabled_model_id'
270
288
  ? CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS
271
- : CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION;
289
+ : item.part === 'model'
290
+ ? CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION
291
+ : CONNECTION_CATALOG_MAX_ENTRIES_PER_CONNECTION;
272
292
  return {
273
293
  connectionIndex: integer(cursor.connectionIndex, 'connection index', 0, CONNECTION_CATALOG_MAX_CONNECTIONS - 1),
274
294
  part: item.part,
@@ -315,7 +335,21 @@ function catalogPageItem(value) {
315
335
  kind: 'model',
316
336
  connectionIndex: integer(modelItem.connectionIndex, 'connection index', 0, CONNECTION_CATALOG_MAX_CONNECTIONS - 1),
317
337
  itemIndex: integer(modelItem.itemIndex, 'item index', 0, CONNECTION_CATALOG_MAX_MODELS_PER_CONNECTION - 1),
318
- model: decodeProjectedCatalogModel(modelItem.model),
338
+ model: decodeDomain(() => decodeConnectionModel(modelItem.model)),
339
+ };
340
+ }
341
+ if (item.kind === 'catalog_entry') {
342
+ const entryItem = requireExactRecord(item, 'connection catalog entry item', [
343
+ 'kind',
344
+ 'connectionIndex',
345
+ 'itemIndex',
346
+ 'entry',
347
+ ]);
348
+ return {
349
+ kind: 'catalog_entry',
350
+ connectionIndex: integer(entryItem.connectionIndex, 'connection index', 0, CONNECTION_CATALOG_MAX_CONNECTIONS - 1),
351
+ itemIndex: integer(entryItem.itemIndex, 'item index', 0, CONNECTION_CATALOG_MAX_ENTRIES_PER_CONNECTION - 1),
352
+ entry: decodeDomain(() => decodeModelCatalogEntry(entryItem.entry)),
319
353
  };
320
354
  }
321
355
  if (item.kind !== 'connection')
@@ -331,11 +365,11 @@ function catalogPageItem(value) {
331
365
  'baseUrl',
332
366
  'enabled',
333
367
  'modelSource',
334
- 'modelsFetchedAt',
335
368
  'lastTest',
336
369
  'requestBodyOverlay',
337
370
  'enabledModelIdCount',
338
371
  'modelCount',
372
+ 'catalogEntryCount',
339
373
  ], [
340
374
  'kind',
341
375
  'connectionIndex',
@@ -347,10 +381,8 @@ function catalogPageItem(value) {
347
381
  'enabled',
348
382
  'enabledModelIdCount',
349
383
  'modelCount',
384
+ 'catalogEntryCount',
350
385
  ]);
351
- if ((header.modelSource === undefined) !== (header.modelsFetchedAt === undefined)) {
352
- throw invalidProtocolFrame('Invalid connection header model discovery fields');
353
- }
354
386
  const provider = decodeDomain(() => decodeProviderType(header.providerType));
355
387
  const baseUrl = header.baseUrl === undefined
356
388
  ? undefined
@@ -377,40 +409,15 @@ function catalogPageItem(value) {
377
409
  ...(baseUrl === undefined ? {} : { baseUrl }),
378
410
  enabled: boolean(header.enabled, 'connection enabled'),
379
411
  ...(header.modelSource === undefined ? {} : { modelSource: modelSource(header.modelSource) }),
380
- ...(header.modelsFetchedAt === undefined
381
- ? {}
382
- : {
383
- modelsFetchedAt: integer(header.modelsFetchedAt, 'models fetched at', 0, Number.MAX_SAFE_INTEGER),
384
- }),
385
412
  ...(header.lastTest === undefined
386
413
  ? {}
387
414
  : { lastTest: decodeDomain(() => decodeConnectionTestSummary(header.lastTest)) }),
388
415
  ...(requestBodyOverlay === undefined ? {} : { requestBodyOverlay }),
389
416
  enabledModelIdCount: integer(header.enabledModelIdCount, 'enabled model id count', 0, CONNECTION_CATALOG_MAX_ENABLED_MODEL_IDS),
390
417
  modelCount,
418
+ catalogEntryCount: integer(header.catalogEntryCount, 'catalog entry count', 0, CONNECTION_CATALOG_MAX_ENTRIES_PER_CONNECTION),
391
419
  };
392
420
  }
393
- /** Decode catalog-only read-time provenance without admitting it to persisted models. */
394
- function decodeProjectedCatalogModel(value) {
395
- const item = requireShapedRecord(value, 'projected connection model', ['id'], [...CONNECTION_MODEL_FIELDS.slice(1), 'factOverriddenFields']);
396
- const { factOverriddenFields: rawOverriddenFields, ...persistentModel } = item;
397
- const model = decodeDomain(() => decodeConnectionModel(persistentModel));
398
- if (rawOverriddenFields === undefined)
399
- return model;
400
- if (!Array.isArray(rawOverriddenFields) || rawOverriddenFields.length === 0) {
401
- throw invalidProtocolFrame('Invalid model fact overridden fields');
402
- }
403
- const factOverriddenFields = rawOverriddenFields.map((field) => {
404
- if (!MODEL_FACT_OVERRIDE_FIELDS.includes(field)) {
405
- throw invalidProtocolFrame('Invalid model fact overridden field');
406
- }
407
- return field;
408
- });
409
- if (new Set(factOverriddenFields).size !== factOverriddenFields.length) {
410
- throw invalidProtocolFrame('Duplicate model fact overridden field');
411
- }
412
- return { ...model, factOverriddenFields };
413
- }
414
421
  function decodeCreateConnectionInput(value) {
415
422
  const input = decodeDomain(() => normalizeCreateCatalogConnectionInput(value));
416
423
  assertMutationEnabledModelIds(input.connection.enabledModelIds);
@@ -535,6 +542,8 @@ function decodeSetCredentialResult(value) {
535
542
  requireExactRecord(item, 'credential connection not found result', ['kind']);
536
543
  return { kind: 'connection_not_found' };
537
544
  }
545
+ if (item.kind === 'connection_stale')
546
+ return connectionStale(item);
538
547
  return credentialStale(item);
539
548
  }
540
549
  function decodeDeleteCredentialResult(value) {
@@ -664,6 +673,8 @@ function catalogCursorPartOrder(part) {
664
673
  return 1;
665
674
  case 'model':
666
675
  return 2;
676
+ case 'catalog_entry':
677
+ return 3;
667
678
  }
668
679
  }
669
680
  function credentialCommitted(value) {
@@ -19,7 +19,7 @@
19
19
  import { isCollaborationMode } from '@maka/core/collaboration';
20
20
  import { isOrchestrationMode } from '@maka/core/orchestration';
21
21
  import { isPermissionMode } from '@maka/core/permission';
22
- import { isSessionStartMode } from '@maka/core/deep-research';
22
+ import { isSessionStartMode } from '@maka/core/session-start-mode';
23
23
  import { isSessionBlockedReason, isSessionToolProfile, } from '@maka/core/session';
24
24
  import { isThinkingLevel } from '@maka/core/model-thinking';
25
25
  import { assertAllowedKeys, requireCount, requireEncodedByteLimit, requireEntityId, requireExactRecord, requireRecord, requireShapedRecord, requireUtf8String, } from './codec.js';
@@ -212,8 +212,10 @@ function decodeCollaborationTurnRequestCreateInput(value) {
212
212
  return { intent: decodeSessionTurnRequestIntent(record.intent) };
213
213
  }
214
214
  function decodeCollaborationTurnRequestQueryInput(value) {
215
- const record = requireExactRecord(value, 'collaboration Turn request query', ['sessionId']);
216
- return { sessionId: requireEntityId(record.sessionId, 'sessionId') };
215
+ const record = requireShapedRecord(value, 'collaboration Turn request query', [], ['sessionId']);
216
+ return record.sessionId === undefined
217
+ ? {}
218
+ : { sessionId: requireEntityId(record.sessionId, 'sessionId') };
217
219
  }
218
220
  function decodeCollaborationTurnRequestQueryResult(value) {
219
221
  const record = requireExactRecord(value, 'collaboration Turn request query result', [
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
  import { MAX_ATTACHMENT_BYTES, MAX_ATTACHMENT_COUNT } from '@maka/core/attachments';
20
- import { decodeMessageContent as decodeCanonicalMessageContent, isContextBudgetExhaustedDetail, isCanonicalAttachmentRef, } from '@maka/core/events';
20
+ import { decodeMessageContent as decodeCanonicalMessageContent, DIRECTORY_REFERENCE_MAX_COUNT, isCanonicalAttachmentRef, } from '@maka/core/events';
21
21
  import { isOrchestrationMode, isTurnOrchestrationSource, } from '@maka/core/orchestration';
22
22
  import { decodeSkillInvocationResult, } from '@maka/core/skill-invocation';
23
23
  import { invalidProtocolFrame } from './errors.js';
@@ -226,6 +226,9 @@ export function decodeMessageContent(value, allowEmptyText = false) {
226
226
  if (content.displayText !== undefined) {
227
227
  requireUtf8String(content.displayText, 'Message displayText', TURN_MESSAGE_TEXT_MAX_BYTES, true);
228
228
  }
229
+ if ((content.directoryReferences?.length ?? 0) > DIRECTORY_REFERENCE_MAX_COUNT) {
230
+ throw invalidProtocolFrame('Too many directory references');
231
+ }
229
232
  if ((content.attachments?.length ?? 0) > MAX_ATTACHMENT_COUNT) {
230
233
  throw invalidProtocolFrame('Invalid Message attachments');
231
234
  }
@@ -446,7 +449,7 @@ export function decodeTurnSnapshot(value) {
446
449
  };
447
450
  }
448
451
  if (status === 'failed') {
449
- requireShapedRecord(record, 'failed Turn snapshot', ['sessionId', 'turnId', 'runId', 'status', 'terminalEventId', 'failureClass'], ['failureMessage', 'contextBudgetExhaustedDetail']);
452
+ requireShapedRecord(record, 'failed Turn snapshot', ['sessionId', 'turnId', 'runId', 'status', 'terminalEventId', 'failureClass'], ['failureMessage']);
450
453
  return {
451
454
  ...base,
452
455
  status,
@@ -457,11 +460,6 @@ export function decodeTurnSnapshot(value) {
457
460
  failureMessage: requireUtf8String(record.failureMessage, 'failureMessage', TURN_FAILURE_MESSAGE_MAX_BYTES, false),
458
461
  }
459
462
  : {}),
460
- ...(record.contextBudgetExhaustedDetail !== undefined
461
- ? {
462
- contextBudgetExhaustedDetail: requireContextBudgetExhaustedDetail(record.contextBudgetExhaustedDetail),
463
- }
464
- : {}),
465
463
  };
466
464
  }
467
465
  if (status === 'cancelled') {
@@ -489,11 +487,6 @@ export function decodeTurnSnapshot(value) {
489
487
  : {}),
490
488
  };
491
489
  }
492
- function requireContextBudgetExhaustedDetail(value) {
493
- if (isContextBudgetExhaustedDetail(value))
494
- return value;
495
- throw invalidProtocolFrame('Invalid context budget exhausted detail');
496
- }
497
490
  export function decodeContextCompactionOutcome(value) {
498
491
  const record = requireRecord(value, 'Context compaction outcome');
499
492
  const kind = requireString(record.kind, 'kind', 32);
@@ -146,7 +146,7 @@ export function decodeWorkHubCoordinationCandidatesResult(value) {
146
146
  };
147
147
  }
148
148
  export function decodeWorkHubCoordinationActInput(value) {
149
- const input = requireShapedRecord(value, 'WorkHub Coordination action input', ['actionId', 'userText', 'proposal'], ['candidateSetId', 'create']);
149
+ const input = requireShapedRecord(value, 'WorkHub Coordination action input', ['actionId', 'userText', 'proposal'], ['candidateSetId', 'create', 'confirmation']);
150
150
  const proposal = decodeWorkHubCoordinationProposal(input.proposal);
151
151
  const base = {
152
152
  actionId: requireEntityId(input.actionId, 'WorkHub Coordination action id'),
@@ -154,18 +154,45 @@ export function decodeWorkHubCoordinationActInput(value) {
154
154
  proposal,
155
155
  };
156
156
  if (proposal.disposition === 'delegate_existing') {
157
- if (input.create !== undefined || input.candidateSetId === undefined) {
157
+ if (input.create !== undefined ||
158
+ input.candidateSetId === undefined ||
159
+ input.confirmation !== undefined) {
158
160
  throw invalidProtocolFrame('Invalid WorkHub delegation context');
159
161
  }
160
162
  return { ...base, candidateSetId: candidateSetId(input.candidateSetId) };
161
163
  }
162
164
  if (proposal.disposition === 'create_new') {
163
- if (input.candidateSetId !== undefined || input.create === undefined) {
165
+ if (input.candidateSetId !== undefined ||
166
+ input.create === undefined ||
167
+ input.confirmation !== undefined) {
164
168
  throw invalidProtocolFrame('Invalid WorkHub creation context');
165
169
  }
166
170
  return { ...base, create: decodeWorkHubCoordinationCreateContext(input.create) };
167
171
  }
168
- if (input.candidateSetId !== undefined || input.create !== undefined) {
172
+ if (proposal.disposition === 'replace') {
173
+ const confirmation = decodeWorkHubCoordinationDestructiveConfirmation(input.confirmation);
174
+ if (proposal.target.disposition === 'delegate_existing') {
175
+ if (input.candidateSetId === undefined || input.create !== undefined) {
176
+ throw invalidProtocolFrame('Invalid WorkHub replacement context');
177
+ }
178
+ return {
179
+ ...base,
180
+ candidateSetId: candidateSetId(input.candidateSetId),
181
+ confirmation,
182
+ };
183
+ }
184
+ if (input.candidateSetId !== undefined || input.create === undefined) {
185
+ throw invalidProtocolFrame('Invalid WorkHub replacement creation context');
186
+ }
187
+ return {
188
+ ...base,
189
+ create: decodeWorkHubCoordinationCreateContext(input.create),
190
+ confirmation,
191
+ };
192
+ }
193
+ if (input.candidateSetId !== undefined ||
194
+ input.create !== undefined ||
195
+ input.confirmation !== undefined) {
169
196
  throw invalidProtocolFrame('Unexpected WorkHub action context');
170
197
  }
171
198
  return base;
@@ -194,6 +221,23 @@ export function decodeWorkHubCoordinationActResult(value) {
194
221
  ...(exact.steered === true ? { steered: true } : {}),
195
222
  };
196
223
  }
224
+ if (result.disposition === 'replace') {
225
+ const exact = requireShapedRecord(result, 'WorkHub Coordination replacement result', ['disposition', 'replacementDisposition', 'targetSessionId', 'targetTurnId'], ['steered']);
226
+ if (exact.replacementDisposition !== 'delegate_existing' &&
227
+ exact.replacementDisposition !== 'create_new') {
228
+ throw invalidProtocolFrame('Invalid WorkHub replacement disposition');
229
+ }
230
+ if (exact.steered !== undefined && exact.steered !== true) {
231
+ throw invalidProtocolFrame('Invalid WorkHub Coordination steering result');
232
+ }
233
+ return {
234
+ disposition: 'replace',
235
+ replacementDisposition: exact.replacementDisposition,
236
+ targetSessionId: requireEntityId(exact.targetSessionId, 'WorkHub target Session id'),
237
+ targetTurnId: requireEntityId(exact.targetTurnId, 'WorkHub target Turn id'),
238
+ ...(exact.steered === true ? { steered: true } : {}),
239
+ };
240
+ }
197
241
  throw invalidProtocolFrame('Invalid WorkHub Coordination action disposition');
198
242
  }
199
243
  function decodeWorkHubCoordinationCandidate(value) {
@@ -250,6 +294,43 @@ function decodeWorkHubCoordinationProposal(value) {
250
294
  title: requireUtf8String(exact.title, 'WorkHub Session title', COORDINATION_TITLE_MAX_BYTES),
251
295
  };
252
296
  }
297
+ if (proposal.disposition === 'replace') {
298
+ const exact = requireExactRecord(proposal, 'WorkHub replacement proposal', [
299
+ 'disposition',
300
+ 'replacesActionId',
301
+ 'target',
302
+ ]);
303
+ const target = requireRecord(exact.target, 'WorkHub replacement target');
304
+ if (target.disposition === 'delegate_existing') {
305
+ const targetExact = requireExactRecord(target, 'WorkHub replacement delegation target', [
306
+ 'disposition',
307
+ 'candidateRef',
308
+ ]);
309
+ return {
310
+ disposition: 'replace',
311
+ replacesActionId: requireEntityId(exact.replacesActionId, 'WorkHub replaced action id'),
312
+ target: {
313
+ disposition: 'delegate_existing',
314
+ candidateRef: requireEntityId(targetExact.candidateRef, 'WorkHub candidate ref'),
315
+ },
316
+ };
317
+ }
318
+ if (target.disposition === 'create_new') {
319
+ const targetExact = requireExactRecord(target, 'WorkHub replacement creation target', [
320
+ 'disposition',
321
+ 'title',
322
+ ]);
323
+ return {
324
+ disposition: 'replace',
325
+ replacesActionId: requireEntityId(exact.replacesActionId, 'WorkHub replaced action id'),
326
+ target: {
327
+ disposition: 'create_new',
328
+ title: requireUtf8String(targetExact.title, 'WorkHub Session title', COORDINATION_TITLE_MAX_BYTES),
329
+ },
330
+ };
331
+ }
332
+ throw invalidProtocolFrame('Invalid WorkHub replacement target');
333
+ }
253
334
  throw invalidProtocolFrame('Invalid WorkHub Coordination proposal disposition');
254
335
  }
255
336
  function decodeWorkHubCoordinationCreateContext(value) {
@@ -258,6 +339,13 @@ function decodeWorkHubCoordinationCreateContext(value) {
258
339
  workspace: decodeWorkspaceTarget(context.workspace),
259
340
  };
260
341
  }
342
+ function decodeWorkHubCoordinationDestructiveConfirmation(value) {
343
+ const confirmation = requireExactRecord(value, 'WorkHub destructive confirmation', ['kind']);
344
+ if (confirmation.kind !== 'user_correction') {
345
+ throw invalidProtocolFrame('Invalid WorkHub destructive confirmation');
346
+ }
347
+ return { kind: 'user_correction' };
348
+ }
261
349
  function candidateSetId(value) {
262
350
  const id = requireUtf8String(value, 'WorkHub candidate set id', CANDIDATE_SET_ID_MAX_BYTES);
263
351
  if (!/^sha256:[a-f0-9]{64}$/u.test(id)) {
@@ -22,15 +22,11 @@ import { runtimeHostAccessCredentialHash } from '../access-credential-identity.j
22
22
  import { encodeCollaborationInvitationCode, } from '../protocol/index.js';
23
23
  import { createRuntimeHostConnectionAuthority, } from './connection-authority.js';
24
24
  import { createAccessCredentialDelivery, discardAccessCredentialDelivery, purgeAccessCredentialDeliveries, } from '../control/access-credential-delivery.js';
25
- import { ACCESS_FILE_NAME, assertAccessCredentialFileCapacity, createAccessCredentialFile, issuedAccessGrants, readAccessCredentialFile, RuntimeHostAccessCommitOutcomeUnknownError, RuntimeHostAccessInputError, SESSION_GUEST_OPERATION_GRANTS, writeAccessCredentialFile, } from './access-credential-store.js';
25
+ import { ACCESS_FILE_NAME, assertAccessCredentialFileCapacity, CAPABILITY_PROVIDER_OPERATION_GRANTS, createAccessCredentialFile, effectiveOperationGrants, issuedAccessGrants, readAccessCredentialFile, RuntimeHostAccessCommitOutcomeUnknownError, RuntimeHostAccessInputError, SESSION_GUEST_OPERATION_GRANTS, writeAccessCredentialFile, } from './access-credential-store.js';
26
26
  const ACCESS_CREDENTIAL_PREFIX = 'maka_rh_';
27
27
  const PENDING_CREDENTIAL_LIFETIME_MS = 15 * 60_000;
28
28
  const TURN_ACCESS_REQUEST_ACTIVE_MAX = 4;
29
- const CAPABILITY_PROVIDER_GRANTS = new Set([
30
- 'host.status',
31
- 'client.capability.replace',
32
- 'client.capability.unregister',
33
- ]);
29
+ const CAPABILITY_PROVIDER_GRANTS = new Set(CAPABILITY_PROVIDER_OPERATION_GRANTS);
34
30
  function createNextAccessCredentialFile(current, credentials, sessionGrants, turnAccessRequests = current.turnAccessRequests) {
35
31
  return createAccessCredentialFile(credentials, sessionGrants, turnAccessRequests);
36
32
  }
@@ -79,8 +75,8 @@ class FileRuntimeHostAccessAuthority {
79
75
  operationGrants: match.bindClientInstanceOnFinalize
80
76
  ? ['host.status', 'access.credential.finalize']
81
77
  : match.clientInstanceId
82
- ? [...match.operationGrants, 'access.credential.finalize']
83
- : match.operationGrants,
78
+ ? [...effectiveOperationGrants(match), 'access.credential.finalize']
79
+ : effectiveOperationGrants(match),
84
80
  canPublishClientCapabilities: !match.bindClientInstanceOnFinalize && match.canPublishClientCapabilities,
85
81
  canUseHostPaths: !match.bindClientInstanceOnFinalize && match.canUseHostPaths,
86
82
  ...(match.clientInstanceId ? { clientInstanceId: match.clientInstanceId } : {}),
@@ -111,7 +107,7 @@ class FileRuntimeHostAccessAuthority {
111
107
  principalId,
112
108
  principalKind: 'session_guest',
113
109
  status: 'pending',
114
- operationGrants: SESSION_GUEST_OPERATION_GRANTS,
110
+ grants: SESSION_GUEST_OPERATION_GRANTS,
115
111
  canPublishClientCapabilities: false,
116
112
  canUseHostPaths: false,
117
113
  createdAt,
@@ -219,10 +215,11 @@ class FileRuntimeHostAccessAuthority {
219
215
  const guest = principal.principalKind === 'session_guest';
220
216
  return {
221
217
  canRequestTurns: guest &&
218
+ input.sessionId !== undefined &&
222
219
  this.activeSessionGrant(principal.principalId, input.sessionId, 'session_turn_request') !==
223
220
  undefined,
224
221
  requests: this.#file.turnAccessRequests.filter((request) => (!guest || request.principalId === principal.principalId) &&
225
- request.intent.sessionId === input.sessionId),
222
+ (input.sessionId === undefined || request.intent.sessionId === input.sessionId)),
226
223
  };
227
224
  }
228
225
  acknowledgeTurnAccessRequest(principalId, input) {
@@ -314,17 +311,23 @@ class FileRuntimeHostAccessAuthority {
314
311
  return this.#createCredential({
315
312
  principalId: current.principalId,
316
313
  principalKind: current.principalKind,
317
- operationGrants: current.operationGrants,
314
+ operationGrants: effectiveOperationGrants(current),
318
315
  canPublishClientCapabilities: current.canPublishClientCapabilities,
319
316
  canUseHostPaths: current.canUseHostPaths,
320
317
  bindClientInstance: current.clientInstanceId !== undefined,
321
- }, 'prepare', current.operationGrants);
318
+ }, 'prepare', current.grants);
322
319
  });
323
320
  }
324
321
  #issue(input, mode) {
325
322
  return this.#mutate(() => this.#createCredential(input, mode));
326
323
  }
327
- async #createCredential(input, mode, operationGrants = issuedAccessGrants(input.operationGrants)) {
324
+ async #createCredential(input, mode,
325
+ // Rotation exchanges the secret and keeps the authority, so it hands over
326
+ // the predecessor's record verbatim — including keys this build cannot
327
+ // account for. Every other path records exactly what it just issued.
328
+ inheritedGrants) {
329
+ const operationGrants = issuedAccessGrants(input.operationGrants);
330
+ const grants = inheritedGrants ?? operationGrants;
328
331
  assertCredentialAuthority(input, operationGrants);
329
332
  const capabilityOwner = this.#resolveCapabilityOwner('capabilityOwnerCredentialId' in input ? input.capabilityOwnerCredentialId : undefined);
330
333
  if (mode === 'prepare' &&
@@ -350,7 +353,7 @@ class FileRuntimeHostAccessAuthority {
350
353
  principalId: input.principalId,
351
354
  principalKind: input.principalKind,
352
355
  status: mode === 'prepare' ? 'pending' : 'active',
353
- operationGrants,
356
+ grants,
354
357
  canPublishClientCapabilities: input.canPublishClientCapabilities,
355
358
  canUseHostPaths: input.canUseHostPaths,
356
359
  ...(capabilityOwner ? { capabilityOwner } : {}),
@@ -19,7 +19,7 @@
19
19
  import { join } from 'node:path';
20
20
  import { runtimeHostAccessCredentialFingerprintFromHash } from '../access-credential-identity.js';
21
21
  import { discoverMarkedStorageRoot, resolveExistingStorageRootControlDirectory, resolveExistingStorageRoot, } from '@maka/storage/root-authority';
22
- import { ACCESS_FILE_NAME, readAccessCredentialFile } from './access-credential-store.js';
22
+ import { ACCESS_FILE_NAME, effectiveOperationGrants, readAccessCredentialFile, } from './access-credential-store.js';
23
23
  export async function readRuntimeHostAccessCredentialMetadata(rootPath, expectedRootId) {
24
24
  const capability = expectedRootId
25
25
  ? await resolveExistingStorageRoot({
@@ -45,7 +45,9 @@ export async function readRuntimeHostAccessCredentialMetadata(rootPath, expected
45
45
  principalKind: credential.principalKind,
46
46
  principalId: credential.principalId,
47
47
  status: credential.status,
48
- operationGrants: credential.operationGrants,
48
+ // What the credential can exercise on this build, not what its record
49
+ // happens to hold — an operator reading this is asking about now.
50
+ operationGrants: effectiveOperationGrants(credential),
49
51
  canPublishClientCapabilities: credential.canPublishClientCapabilities,
50
52
  canUseHostPaths: credential.canUseHostPaths,
51
53
  createdAt: credential.createdAt,