memeloop 0.0.1 → 0.1.0

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 (228) hide show
  1. package/README.md +63 -0
  2. package/dist/browser.cjs +1413 -0
  3. package/dist/browser.cjs.map +1 -0
  4. package/dist/browser.d.cts +3066 -0
  5. package/dist/browser.d.ts +3066 -0
  6. package/dist/browser.js +43 -0
  7. package/dist/chunk-426CJUZP.js +630 -0
  8. package/dist/chunk-426CJUZP.js.map +1 -0
  9. package/dist/chunk-44YHBKDL.js +382 -0
  10. package/dist/chunk-44YHBKDL.js.map +1 -0
  11. package/dist/chunk-7ZDTB4VZ.js +63 -0
  12. package/dist/chunk-7ZDTB4VZ.js.map +1 -0
  13. package/dist/chunk-AZFYDWIN.js +98 -0
  14. package/dist/chunk-AZFYDWIN.js.map +1 -0
  15. package/dist/chunk-BGPU4RR7.js +367 -0
  16. package/dist/chunk-BGPU4RR7.js.map +1 -0
  17. package/dist/chunk-CCEFAOSH.js +496 -0
  18. package/dist/chunk-CCEFAOSH.js.map +1 -0
  19. package/dist/chunk-FWSY5HOA.js +63 -0
  20. package/dist/chunk-FWSY5HOA.js.map +1 -0
  21. package/dist/chunk-GYIOMQMY.js +8726 -0
  22. package/dist/chunk-GYIOMQMY.js.map +1 -0
  23. package/dist/chunk-HVB2BR3H.js +42 -0
  24. package/dist/chunk-HVB2BR3H.js.map +1 -0
  25. package/dist/chunk-K6P63KD4.js +68 -0
  26. package/dist/chunk-K6P63KD4.js.map +1 -0
  27. package/dist/chunk-MRKY4HGF.js +205 -0
  28. package/dist/chunk-MRKY4HGF.js.map +1 -0
  29. package/dist/chunk-QFHAAIIM.js +2657 -0
  30. package/dist/chunk-QFHAAIIM.js.map +1 -0
  31. package/dist/chunk-VZKQX5PP.js +1 -0
  32. package/dist/chunk-VZKQX5PP.js.map +1 -0
  33. package/dist/chunk-WAI6BODI.js +175 -0
  34. package/dist/chunk-WAI6BODI.js.map +1 -0
  35. package/dist/chunk-XHRBV6I3.js +3637 -0
  36. package/dist/chunk-XHRBV6I3.js.map +1 -0
  37. package/dist/chunk-YMNXDNDW.js +798 -0
  38. package/dist/chunk-YMNXDNDW.js.map +1 -0
  39. package/dist/conversation.cjs +208 -0
  40. package/dist/conversation.cjs.map +1 -0
  41. package/dist/conversation.d.cts +100 -0
  42. package/dist/conversation.d.ts +100 -0
  43. package/dist/conversation.js +21 -0
  44. package/dist/conversation.js.map +1 -0
  45. package/dist/device-network-portable.cjs +702 -0
  46. package/dist/device-network-portable.cjs.map +1 -0
  47. package/dist/device-network-portable.d.cts +110 -0
  48. package/dist/device-network-portable.d.ts +110 -0
  49. package/dist/device-network-portable.js +53 -0
  50. package/dist/device-network-portable.js.map +1 -0
  51. package/dist/device-network.cjs +906 -0
  52. package/dist/device-network.cjs.map +1 -0
  53. package/dist/device-network.d.cts +6 -0
  54. package/dist/device-network.d.ts +6 -0
  55. package/dist/device-network.js +59 -0
  56. package/dist/device-network.js.map +1 -0
  57. package/dist/fetchProvider-BpcGVSOG.d.cts +91 -0
  58. package/dist/fetchProvider-Cm0sO4Tl.d.ts +91 -0
  59. package/dist/index.cjs +27957 -5459
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +94 -1320
  62. package/dist/index.d.ts +94 -1320
  63. package/dist/index.js +10576 -2386
  64. package/dist/index.js.map +1 -1
  65. package/dist/interface-IrKBFtL1.d.cts +493 -0
  66. package/dist/interface-IrKBFtL1.d.ts +493 -0
  67. package/dist/llm-providers.cjs +43 -8
  68. package/dist/llm-providers.cjs.map +1 -1
  69. package/dist/llm-providers.d.cts +2 -1
  70. package/dist/llm-providers.d.ts +2 -1
  71. package/dist/llm-providers.js +4 -2
  72. package/dist/llm-providers.js.map +1 -1
  73. package/dist/loop-api.cjs +5177 -2050
  74. package/dist/loop-api.cjs.map +1 -1
  75. package/dist/loop-api.d.cts +11 -5
  76. package/dist/loop-api.d.ts +11 -5
  77. package/dist/loop-api.js +84 -49
  78. package/dist/mobile.cjs +2625 -0
  79. package/dist/mobile.cjs.map +1 -0
  80. package/dist/mobile.d.cts +6 -0
  81. package/dist/mobile.d.ts +6 -0
  82. package/dist/mobile.js +22 -0
  83. package/dist/mobile.js.map +1 -0
  84. package/dist/orchestration-portable-Bsf8YRfp.d.cts +2192 -0
  85. package/dist/orchestration-portable-Zw0g5tbj.d.ts +2192 -0
  86. package/dist/orchestration-portable.cjs +9553 -0
  87. package/dist/orchestration-portable.cjs.map +1 -0
  88. package/dist/orchestration-portable.d.cts +5 -0
  89. package/dist/orchestration-portable.d.ts +5 -0
  90. package/dist/orchestration-portable.js +290 -0
  91. package/dist/orchestration-portable.js.map +1 -0
  92. package/dist/pairingInvite-BXPWY3aM.d.cts +149 -0
  93. package/dist/pairingInvite-Cuz0wuq9.d.ts +149 -0
  94. package/dist/promptConcat-WTN-uHcz.d.cts +516 -0
  95. package/dist/promptConcat-deDSWZE3.d.ts +516 -0
  96. package/dist/providerRegistry-9trr5aoK.d.ts +86 -0
  97. package/dist/providerRegistry-xk_B1Ekv.d.cts +86 -0
  98. package/dist/registry-8eztoD_r.d.cts +393 -0
  99. package/dist/registry-DV24sI-3.d.ts +393 -0
  100. package/dist/remoteClient-B_spK019.d.ts +87 -0
  101. package/dist/remoteClient-CBggnRy3.d.cts +87 -0
  102. package/dist/runtime-SKSXVYIM.js +18 -0
  103. package/dist/runtime-SKSXVYIM.js.map +1 -0
  104. package/dist/scriptDeploymentPipeline-BAeo1dPb.d.cts +2463 -0
  105. package/dist/scriptDeploymentPipeline-DsnT0AG6.d.ts +2463 -0
  106. package/dist/syncCloudDevices-BEqwgrhD.d.ts +49 -0
  107. package/dist/syncCloudDevices-Ds_Kcgrv.d.cts +49 -0
  108. package/dist/types-7pYti-k9.d.cts +255 -0
  109. package/dist/types-CdFVSntj.d.ts +255 -0
  110. package/package.json +110 -35
  111. package/dist/anthropic.cjs +0 -72
  112. package/dist/anthropic.cjs.map +0 -1
  113. package/dist/anthropic.d.cts +0 -21
  114. package/dist/anthropic.d.ts +0 -21
  115. package/dist/anthropic.js +0 -21
  116. package/dist/anthropic.js.map +0 -1
  117. package/dist/azure.cjs +0 -72
  118. package/dist/azure.cjs.map +0 -1
  119. package/dist/azure.d.cts +0 -21
  120. package/dist/azure.d.ts +0 -21
  121. package/dist/azure.js +0 -21
  122. package/dist/azure.js.map +0 -1
  123. package/dist/chunk-3CN7DFBL.js +0 -4894
  124. package/dist/chunk-3CN7DFBL.js.map +0 -1
  125. package/dist/chunk-4AZ4D7U5.js +0 -32
  126. package/dist/chunk-4AZ4D7U5.js.map +0 -1
  127. package/dist/chunk-6ON4XSOV.js +0 -63
  128. package/dist/chunk-6ON4XSOV.js.map +0 -1
  129. package/dist/chunk-DJQNGIXX.js +0 -4793
  130. package/dist/chunk-DJQNGIXX.js.map +0 -1
  131. package/dist/chunk-FKQP6AOQ.js +0 -32
  132. package/dist/chunk-FKQP6AOQ.js.map +0 -1
  133. package/dist/chunk-OVJ7JJBA.js +0 -35
  134. package/dist/chunk-OVJ7JJBA.js.map +0 -1
  135. package/dist/chunk-P4UZ7IXC.js +0 -42
  136. package/dist/chunk-YHJ2AEFR.js +0 -4933
  137. package/dist/chunk-YHJ2AEFR.js.map +0 -1
  138. package/dist/chunk-YVK7RYRO.js +0 -4973
  139. package/dist/chunk-YVK7RYRO.js.map +0 -1
  140. package/dist/code-assistant.json +0 -114
  141. package/dist/cohere.cjs +0 -72
  142. package/dist/cohere.cjs.map +0 -1
  143. package/dist/cohere.d.cts +0 -21
  144. package/dist/cohere.d.ts +0 -21
  145. package/dist/cohere.js +0 -21
  146. package/dist/cohere.js.map +0 -1
  147. package/dist/deepseek.cjs +0 -72
  148. package/dist/deepseek.cjs.map +0 -1
  149. package/dist/deepseek.d.cts +0 -21
  150. package/dist/deepseek.d.ts +0 -21
  151. package/dist/deepseek.js +0 -21
  152. package/dist/deepseek.js.map +0 -1
  153. package/dist/dist-65U7OYRG.js +0 -1257
  154. package/dist/dist-65U7OYRG.js.map +0 -1
  155. package/dist/fetchProvider-Cu4WkU5O.d.cts +0 -819
  156. package/dist/fetchProvider-Cu4WkU5O.d.ts +0 -819
  157. package/dist/frontend-ui-ux.json +0 -105
  158. package/dist/general-assistant.json +0 -95
  159. package/dist/git-master.json +0 -51
  160. package/dist/google-vertex.cjs +0 -72
  161. package/dist/google-vertex.cjs.map +0 -1
  162. package/dist/google-vertex.d.cts +0 -21
  163. package/dist/google-vertex.d.ts +0 -21
  164. package/dist/google-vertex.js +0 -21
  165. package/dist/google-vertex.js.map +0 -1
  166. package/dist/google.cjs +0 -72
  167. package/dist/google.cjs.map +0 -1
  168. package/dist/google.d.cts +0 -21
  169. package/dist/google.d.ts +0 -21
  170. package/dist/google.js +0 -21
  171. package/dist/google.js.map +0 -1
  172. package/dist/groq.cjs +0 -72
  173. package/dist/groq.cjs.map +0 -1
  174. package/dist/groq.d.cts +0 -21
  175. package/dist/groq.d.ts +0 -21
  176. package/dist/groq.js +0 -21
  177. package/dist/groq.js.map +0 -1
  178. package/dist/index.d.mts +0 -3203
  179. package/dist/index.mjs +0 -7064
  180. package/dist/index.mjs.map +0 -1
  181. package/dist/mistral.cjs +0 -72
  182. package/dist/mistral.cjs.map +0 -1
  183. package/dist/mistral.d.cts +0 -21
  184. package/dist/mistral.d.ts +0 -21
  185. package/dist/mistral.js +0 -21
  186. package/dist/mistral.js.map +0 -1
  187. package/dist/multipart-parser-EJCXIUHC.js +0 -372
  188. package/dist/multipart-parser-EJCXIUHC.js.map +0 -1
  189. package/dist/openai.cjs +0 -72
  190. package/dist/openai.cjs.map +0 -1
  191. package/dist/openai.d.cts +0 -21
  192. package/dist/openai.d.ts +0 -21
  193. package/dist/openai.js +0 -21
  194. package/dist/openai.js.map +0 -1
  195. package/dist/perplexity.cjs +0 -72
  196. package/dist/perplexity.cjs.map +0 -1
  197. package/dist/perplexity.d.cts +0 -21
  198. package/dist/perplexity.d.ts +0 -21
  199. package/dist/perplexity.js +0 -21
  200. package/dist/perplexity.js.map +0 -1
  201. package/dist/playwright.json +0 -52
  202. package/dist/promptConcat-BJdazTg5.d.cts +0 -1832
  203. package/dist/promptConcat-BJdazTg5.d.ts +0 -1832
  204. package/dist/promptConcat-CAkpni_8.d.cts +0 -1834
  205. package/dist/promptConcat-CAkpni_8.d.ts +0 -1834
  206. package/dist/promptConcat-CfH5-GAE.d.cts +0 -1036
  207. package/dist/promptConcat-ChcAZOOL.d.ts +0 -1036
  208. package/dist/promptConcat-G5TnJVRy.d.cts +0 -1800
  209. package/dist/promptConcat-G5TnJVRy.d.ts +0 -1800
  210. package/dist/promptConcat-L72eowzp.d.ts +0 -1090
  211. package/dist/promptConcat-eLHdN7K8.d.cts +0 -1090
  212. package/dist/src-VTSXKG72.js +0 -1409
  213. package/dist/src-VTSXKG72.js.map +0 -1
  214. package/dist/togetherai.cjs +0 -72
  215. package/dist/togetherai.cjs.map +0 -1
  216. package/dist/togetherai.d.cts +0 -21
  217. package/dist/togetherai.d.ts +0 -21
  218. package/dist/togetherai.js +0 -21
  219. package/dist/togetherai.js.map +0 -1
  220. package/dist/types-B0Jm2l38.d.cts +0 -767
  221. package/dist/types-B0Jm2l38.d.ts +0 -767
  222. package/dist/xai.cjs +0 -72
  223. package/dist/xai.cjs.map +0 -1
  224. package/dist/xai.d.cts +0 -21
  225. package/dist/xai.d.ts +0 -21
  226. package/dist/xai.js +0 -21
  227. package/dist/xai.js.map +0 -1
  228. /package/dist/{chunk-P4UZ7IXC.js.map → browser.js.map} +0 -0
@@ -0,0 +1,3066 @@
1
+ import { y as OrchestrationResourceStatus, E as OrchestrationResource, t as AgentOrchestrationClient, O as OrchestrationErrorData, z as OrchestrationResourceReference, F as OrchestrationResourceQuery, K as OrchestrationResourceList, N as OrchestrationWatchOptions, P as OrchestrationWatchEvent, u as OrchestrationResourceManifest, Q as OrchestrationDeleteOptions, R as OrchestrationDeleteResult, al as OrchestrationResourceWatchEvent, Y as FullAgentStorage, L as ListConversationsOptions, C as ConversationMeta, G as GetMessagesOptions, b as ChatMessage, A as AttachmentReference, m as AgentDefinition, q as AgentInstanceMeta, a5 as IMChannelBinding, S as AgentFrameworkConfig, I as IAgentStorage, a6 as IMPlatformType } from './interface-IrKBFtL1.cjs';
2
+ export { n as AgentDefinitionModelConfig, o as AgentDefinitionToolConfig, p as AgentHeartbeatConfig, Z as AgentInfrastructureInterface, $ as AgentOrchestrationCapabilities, a0 as AgentOrchestrationOperation, X as AgentPromptDescription, r as AiAPIConfig, a as ChatAttachmentPart, c as ChatMessagePart, d as ChatReasoningPart, e as ChatRole, f as ChatTextPart, g as ChatToolCallPart, h as ChatToolResultPart, j as ConversationQueryMode, D as DetailRefType, k as DetailReference, H as HostAgentToolConfig, a4 as IMChannel, U as IPrompt, a8 as ImChannelBindingRecord, M as ModelParameters, s as ModelSelection, a9 as ORCHESTRATION_ERROR_CODES, aa as OrchestrationApplyOptions, ab as OrchestrationBookmarkWatchEvent, ac as OrchestrationCondition, ad as OrchestrationConditionStatus, ae as OrchestrationError, af as OrchestrationErrorCode, ag as OrchestrationErrorWatchEvent, ah as OrchestrationEvent, ai as OrchestrationEventSeverity, B as OrchestrationGetOptions, J as OrchestrationListOptions, aj as OrchestrationManifestMetadata, x as OrchestrationObjectMetadata, v as OrchestrationOwnerReference, ak as OrchestrationPreconditions, am as OrchestrationResourceWatchEventType, w as OrchestrationTypeMeta, W as PromptNode, an as PromptPluginConfig, T as ToolCall, V as VersionVector, i as isConversationMeta, ao as isOrchestrationError, ap as toOrchestrationErrorData } from './interface-IrKBFtL1.cjs';
3
+ import { l as PermissionAction, M as MemeLoopRuntime } from './registry-8eztoD_r.cjs';
4
+ export { A as ALL_CATEGORIES, a as AgentProfileRegistry, C as CategoryConfig, L as LoadPluginModuleOptions, j as LoadedPlugin, k as MergedPermissions, P as PERMISSIONS_TABLE_DDL, m as PermissionRule, n as PermissionSet, o as PermissionSqlDatabase, p as PermissionSqlStatement, q as PluginAPI, r as PluginAPIOptions, s as PluginExports, t as PluginManifest, u as PluginModule, T as TaskCategory, x as checkPermission, y as clearPluginRegistrations, F as createPluginAPI, G as getAgentProfileRegistry, I as getCategoryConfig, J as getLoadedPlugin, K as getPluginRegistrations, N as isPluginLoaded, O as isTaskCategory, Q as listPlugins, R as loadPluginModule, V as loadPluginModules, W as loadUserPermissions, X as matchPattern, Y as mergePermissionSets, Z as registerPluginHooks, _ as registerPluginTools, $ as resetAgentProfileRegistry, a0 as resolveCategory, a1 as saveUserPermissions, a2 as unloadAllPlugins, a3 as unloadPlugin, a4 as validatePluginManifest } from './registry-8eztoD_r.cjs';
5
+ export { A as AgentProfile, a as AgentProfileType, B as BUILTIN_AGENT_PROFILES, P as ProviderConfig, b as ProviderRegistry, R as RegisteredProvider, T as ToolPermissionRules, c as buildAgent, e as exploreAgent, l as librarianAgent, o as oracleAgent, p as planAgent } from './providerRegistry-xk_B1Ekv.cjs';
6
+ import { s as DeviceRpcHandler } from './types-7pYti-k9.cjs';
7
+ export { A as AgentExecutionLocation, a as AgentExecutionState, b as AttachmentBlob, C as CloudDeviceClient, c as CloudDeviceRecord, d as ConversationExecutionPlacement, D as Device, e as DeviceAccountBindingRequest, f as DeviceAuthorizer, g as DeviceCapabilities, h as DeviceConnectionGrant, i as DeviceConnectionGrantVerificationInput, j as DeviceNetworkListenOptions, k as DeviceNetworkPath, l as DeviceNetworkService, m as DevicePlatform, n as DeviceProtocolDirection, o as DeviceReachability, p as DeviceReachabilityState, q as DeviceRelayReservationToken, r as DeviceRelayReservationTokenVerificationInput, t as DeviceRpcHandlerInput, u as DeviceSyncTransport, v as DeviceTrustMode, w as DeviceTrustStore, E as ExchangeVersionVectorResult, L as LocalDeviceIdentity, x as LocalPairingRequestOptions, M as MemeLoopDuplexStream, y as MemeLoopProtocol, P as PairingSession, z as PairingSessionDirection, B as PairingSessionStatus, S as SyncResult, T as TrustedDeviceRecord } from './types-7pYti-k9.cjs';
8
+ export { A as AttachmentBlobWire, D as DEVICE_ORCHESTRATION_PROTOCOL, a as DEVICE_PAIRING_INVITE_PROTOCOL, b as DEVICE_PAIRING_INVITE_TTL_MS, c as DeviceOrchestrationStreamHandler, d as DeviceOrchestrationStreamHandlerInput, e as DeviceOrchestrationStreamHandlerOptions, f as DeviceOrchestrationTransportOptions, g as DevicePairingInvite, L as LIBP2P_RPC_REQUEST_TYPE, h as LIBP2P_RPC_RESPONSE_TYPE, i as LIBP2P_SYNC_REQUEST_TYPE, j as LIBP2P_SYNC_RESPONSE_TYPE, k as Libp2pDeviceSyncTransport, l as Libp2pDeviceSyncTransportOptions, m as Libp2pRpcRequest, n as Libp2pRpcResponse, o as Libp2pSyncMethod, p as Libp2pSyncRequest, q as Libp2pSyncResponse, r as LocalTrustDeviceAuthorizer, s as LocalTrustDeviceAuthorizerOptions, R as RemoteOrchestrationHandler, t as attachmentBlobFromWire, u as createDeviceOrchestrationStreamHandler, v as createDeviceOrchestrationTransport, w as createDevicePairingInvite, x as encodeDevicePairingInvite, y as isLibp2pRpcRequest, z as isLibp2pRpcResponse, B as isLibp2pSyncRequest, C as isLibp2pSyncResponse, E as parseDevicePairingInvite } from './pairingInvite-BXPWY3aM.cjs';
9
+ export { M as MemoryDeviceNetworkService, a as MemoryDeviceNetworkServiceOptions, s as syncCloudDevices } from './syncCloudDevices-Ds_Kcgrv.cjs';
10
+ import { aU as ControlStoreAuthorizationRequest, aR as ControlStore, aS as ControlStoreActor, af as AgentVolumeResource, bO as NodeTrustClass, co as StorageClassResource, ae as AgentVolumeReplicaStatus, cz as ToolAdmissionAction, cB as ToolAdmissionRule, cA as ToolAdmissionPolicy, cR as ToolOperationResource, cj as SecurityProfileResource, b3 as CredentialGrantResource, y as ToolOperationEffect, ap as AgentWorkloadResource, aq as AgentWorkloadResourceRequirements, cS as ToolOperationResult, bs as ModelClassManifest, bw as ModelEndpointManifest, aw as ArtifactDestination, d1 as VolumeAccessMode, aa as AgentVolumeClaimResource, cO as ToolOperationApprovalEvidence, m as IToolRegistry, cV as ToolOperationStatus, a0 as AgentRunResource, bx as ModelEndpointResource, bt as ModelClassResource, bG as NetworkAttachmentResource, bK as NetworkClassResource, b8 as DataClassification, aV as ControlStoreAuthorizer, aX as ControlStoreCreateOptions, aT as ControlStoreApplyOptions, a_ as ControlStoreStatusUpdateOptions, aQ as ControlLeaseRequest, aO as ControlLeaseGrant, aP as ControlLeaseIdentity, aW as ControlStoreCompactionResult, aZ as ControlStoreSnapshotResult, aY as ControlStoreHealth, cL as ToolExecutorResource, r as LoopScriptCheckpointStore } from './scriptDeploymentPipeline-BAeo1dPb.cjs';
11
+ export { N as AGENT_RUN_API_VERSION, O as AGENT_RUN_KIND, Q as AGENT_WORKLOAD_API_VERSION, R as AGENT_WORKLOAD_KIND, V as ARTIFACT_RECORD_API_VERSION, W as ARTIFACT_RECORD_KIND, X as AUDIT_RECORD_API_VERSION, Y as AUDIT_RECORD_KIND, z as AgentClient, A as AgentFrameworkContext, a as AgentInstance, b as AgentInstanceLatestStatus, a as AgentInstanceModel, c as AgentInstanceState, d as AgentLoopDefinition, e as AgentLoopGenerator, f as AgentLoopInput, g as AgentLoopRuntime, h as AgentLoopScriptPolicy, i as AgentLoopStep, _ as AgentRunCondition, $ as AgentRunManifest, a1 as AgentRunSpec, a2 as AgentRunStatus, a3 as AgentSnapshotManifest, a4 as AgentSnapshotResource, a5 as AgentSnapshotSpec, a6 as AgentSnapshotStatus, j as AgentToolLoopOptions, a8 as AgentTrustLevel, a9 as AgentVolumeClaimManifest, ab as AgentVolumeClaimSpec, ac as AgentVolumeClaimStatus, ad as AgentVolumeManifest, ag as AgentVolumeSpec, ah as AgentVolumeStatus, ai as AgentWorkloadCompletionPolicy, aj as AgentWorkloadCondition, ak as AgentWorkloadCredentialPolicy, al as AgentWorkloadManifest, am as AgentWorkloadModelPolicy, an as AgentWorkloadNetworkPolicy, ao as AgentWorkloadPlacement, ar as AgentWorkloadSpec, as as AgentWorkloadStatus, at as AgentWorkloadStoragePolicy, au as AgentWorkloadToolPolicy, av as AgentWorkloadVolumeClaim, ax as ArtifactRecordManifest, ay as ArtifactRecordResource, az as ArtifactRecordSpec, aA as ArtifactRecordStatus, aB as ArtifactReviewEvidence, aC as ArtifactReviewKind, aD as ArtifactTrust, aE as AuditRecordManifest, aF as AuditRecordResource, aG as AuditRecordSpec, aH as BUILTIN_RUNTIME_CLASSES, aJ as CREDENTIAL_GRANT_API_VERSION, aK as CREDENTIAL_GRANT_KIND, aL as CheckpointRecord, aM as CheckpointStore, aN as CheckpointSummary, a$ as ControlStoreVerb, b0 as CreateAgentRunOptions, b1 as CreateAgentWorkloadOptions, b2 as CredentialGrantManifest, b4 as CredentialGrantSpec, b5 as CredentialGrantStatus, b6 as DRIVER_MANIFEST_API_VERSION, b7 as DRIVER_MANIFEST_KIND, b9 as DriverManifestConformance, ba as DriverManifestManifest, bb as DriverManifestResource, bc as DriverManifestSpec, bd as DriverManifestStatus, I as IChatSyncAdapter, k as ILLMProvider, l as INetworkService, e2 as InMemoryCheckpointStore, bg as InfrastructureDriverType, L as LoopPlugin, n as LoopProfile, o as LoopProfilePluginEntry, p as LoopProfilePrompt, q as LoopProfileScriptReference, bh as MODEL_CALL_RECORD_API_VERSION, bi as MODEL_CALL_RECORD_KIND, bj as MODEL_CLASS_API_VERSION, bk as MODEL_CLASS_KIND, bl as MODEL_ENDPOINT_API_VERSION, bm as MODEL_ENDPOINT_KIND, M as MemeLoopLogger, bn as ModelCallRecordManifest, bo as ModelCallRecordResource, bp as ModelCallRecordSpec, bq as ModelCallRecordStatus, br as ModelClassCapabilities, bu as ModelClassSpec, bv as ModelClassStatus, by as ModelEndpointSpec, bz as ModelEndpointStatus, bA as ModelModality, bB as NETWORK_ATTACHMENT_API_VERSION, bC as NETWORK_ATTACHMENT_KIND, bD as NETWORK_CLASS_API_VERSION, bE as NETWORK_CLASS_KIND, bF as NetworkAttachmentManifest, bH as NetworkAttachmentSpec, bI as NetworkAttachmentStatus, bJ as NetworkClassManifest, bL as NetworkClassSpec, bM as NetworkClassStatus, bN as NetworkEgressRule, bP as POLICY_DECISION_API_VERSION, bQ as POLICY_DECISION_KIND, bR as PersistedPolicyDecisionKind, bS as PolicyDecisionManifest, bT as PolicyDecisionResource, bU as PolicyDecisionSpec, bV as PolicyDecisionStatus, bW as RemoteDeploymentRequest, bX as RemoteDeploymentResult, bY as RemoteDeploymentWorkloadOptions, bZ as RuntimeClassResource, b_ as RuntimeClassSpec, b$ as SECURITY_PROFILE_API_VERSION, c0 as SECURITY_PROFILE_KIND, c1 as SNAPSHOT_API_VERSION, c2 as SNAPSHOT_KIND, c3 as STORAGE_CLASS_API_VERSION, c4 as STORAGE_CLASS_KIND, c5 as SandboxSelectionResult, c6 as ScriptAdmissionDecision, c7 as ScriptAdmissionRequest, c8 as ScriptArtifactReference, c9 as ScriptArtifactStore, B as ScriptDeploymentClient, ca as ScriptDeploymentClientConfig, cb as ScriptDeploymentClientRequest, cc as ScriptDeploymentPipelineOptions, cd as ScriptDeploymentRequest, ce as ScriptDeploymentResult, S as ScriptLoadGate, cf as ScriptLoadGateConfig, s as ScriptLoadGateDecision, t as ScriptLoadGateRequest, cg as ScriptTrustClass, ch as ScriptValidationResult, ci as SecurityProfileManifest, ck as SecurityProfileSpec, cl as SecurityProfileStatus, cm as SessionStorage, e3 as SessionStorageOptions, cn as StorageClassManifest, cp as StorageClassSpec, cq as StorageClassStatus, cr as TOOL_CLASS_API_VERSION, cs as TOOL_CLASS_KIND, ct as TOOL_EXECUTOR_API_VERSION, cu as TOOL_EXECUTOR_KIND, cv as TOOL_OPERATION_API_VERSION, cw as TOOL_OPERATION_KIND, cD as ToolClassManifest, cE as ToolClassResource, cF as ToolClassSchema, cG as ToolClassSpec, cH as ToolClassStatus, cJ as ToolExecutorCapability, cK as ToolExecutorManifest, cM as ToolExecutorSpec, cN as ToolExecutorStatus, cP as ToolOperationManifest, cQ as ToolOperationPolicy, cT as ToolOperationRetryPolicy, cU as ToolOperationSpec, cW as ToolOperationToolReference, cX as ToolRiskLevel, cZ as VOLUME_API_VERSION, c_ as VOLUME_CLAIM_API_VERSION, c$ as VOLUME_CLAIM_KIND, d0 as VOLUME_KIND, d2 as WaitForConditionOptions, d4 as admitScript, d5 as agentRunReference, d6 as agentWorkloadReference, d7 as canonicalControlStoreValue, d8 as controlStoreApplyMatches, d9 as createAgentClient, da as createAgentRunManifest, db as createAgentWorkloadManifest, dc as createArtifactRecordManifest, dd as createAuditRecordManifest, de as createCheckpointRecord, df as createCredentialGrantManifest, dg as createDriverManifestManifest, u as createInstanceDeltaFromDefinition, dh as createModelCallRecordManifest, di as createModelClassManifest, dj as createModelEndpointManifest, dk as createNetworkAttachmentManifest, dl as createNetworkClassManifest, dm as createPolicyDecisionManifest, dn as createScriptDeploymentClient, dp as createScriptLoadGate, dq as createSecurityProfileManifest, dr as createSnapshotManifest, ds as createStorageClassManifest, dt as createToolClassManifest, du as createToolExecutorManifest, dv as createToolOperationManifest, dw as createVolumeClaimManifest, dx as createVolumeManifest, dy as defaultRequestedInterfacesForTrustClass, dz as deployGeneratedScript, dA as digestNormalizedScript, dB as isAgentRun, dC as isAgentWorkload, dD as isArtifactRecord, dE as isAuditRecord, dF as isCredentialGrant, dG as isDriverManifest, dH as isDriverManifestAdmitted, dI as isModelCallRecord, dJ as isModelClass, dK as isModelEndpoint, dL as isNetworkAttachment, dM as isNetworkClass, dN as isPolicyDecision, dO as isSecurityProfile, dP as isSnapshot, dQ as isStorageClass, dR as isToolClass, dS as isToolExecutor, dT as isToolOperation, v as isUserInitiatedConversation, dU as isVolume, dV as isVolumeClaim, dW as maxScriptBytesForTrustClass, dX as normalizeScript, dY as parseCheckpointRecord, dZ as remoteDeploymentToWorkloadManifest, d_ as selectRuntimeClass, d$ as serializeCheckpointRecord, e0 as validateScript, e1 as waitForCondition } from './scriptDeploymentPipeline-BAeo1dPb.cjs';
12
+ import { m as ArtifactReviewWriter, w as CredentialBrokerDriver, y as CredentialGrantHandle, I as CredentialManagementDriver, P as DriverRequestEnvelope, G as CredentialIssuePayload, s as AuditTelemetryManagementDriver, bn as PolicyApprovalManagementDriver, bo as PolicyDecision, O as DriverManifest, N as DriverConformanceTest, ba as ModelProviderHealth, b9 as ModelProviderDriver, Q as FakeArtifactManagementState, h as ArtifactInspector, k as ArtifactManagementStateSnapshot, i as ArtifactManagementCapabilities, c as ArtifactDestinationPolicy, j as ArtifactManagementDriver, bx as StorageProvisionPayload, bw as StorageManagementDriver, bB as ToolManagementDriver, bz as ToolExecutionDriver, aK as ManagedToolDescriptor, a1 as IdentityAttestationManagementDriver, bf as NetworkDriverCapabilities, be as NetworkDriver, bk as NetworkManagementDriver, bl as NetworkPreparePayload, ag as LoopRunStartRequest, aj as LoopRuntimeDriver } from './orchestration-portable-Bsf8YRfp.cjs';
13
+ export { A as ArtifactAdmissionDecision, b as ArtifactContentStore, d as ArtifactInspectionExecutor, e as ArtifactInspectionInput, f as ArtifactInspectionRequest, g as ArtifactInspectionResult, l as ArtifactPutPayload, n as ArtifactSanitizationResult, o as AttestedIdentity, p as AuditEffect, q as AuditProvenance, r as AuditTelemetryCapabilities, t as AuditTelemetryRecord, u as AuditTelemetryRecordKind, v as AuthorizedToolExecution, C as ControlStoreConformanceFactory, x as CredentialGrantClaims, z as CredentialGrantInspection, D as CredentialGrantProof, E as CredentialGrantScope, F as CredentialGrantVerification, H as CredentialManagementCapabilities, J as CredentialProofVerifier, K as DEFAULT_DESTINATION_POLICIES, L as DRIVER_REQUEST_API_VERSION, M as DriverConformanceSuite, R as FakeAuditTelemetryState, S as FakeCredentialManagementState, T as FakeDriverOptions, U as FakeIdentityAttestationState, V as FakeLoopRuntimeState, W as FakeModelManagementState, X as FakeNetworkManagementState, Y as FakePolicyApprovalState, Z as FakeStorageManagementState, _ as FakeToolManagementState, $ as GatewayMediatedLLMProviderOptions, a0 as IdentityAttestationCapabilities, a2 as IdentityChallenge, a3 as IdentityDomain, a4 as IdentityEnrollment, a5 as IdentityInspection, a6 as IdentitySession, a7 as InMemoryCredentialBrokerOptions, a8 as InMemoryModelAccessHandleBrokerOptions, a9 as InProcessLoopRuntimeDriverOptions, aa as InProcessToolExecutionDriverOptions, ab as IssueCredentialGrantRequest, ac as IssueModelAccessHandleRequest, ad as LegacyLLMProviderDriverOptions, ae as LoopRunHandle, af as LoopRunOutcome, ah as LoopRuntimeCapabilities, ai as LoopRuntimeCheckpoint, ak as LoopRuntimeManagementDriver, al as LoopRuntimePreparePayload, am as LoopRuntimePrepared, an as LoopRuntimeStartPayload, ao as ManagedArtifact, ap as ManagedArtifactMount, aq as ManagedCredentialAdapterStateStore, ar as ManagedCredentialBrokerAdapterOptions, as as ManagedCredentialGrant, at as ManagedCredentialMaterialization, au as ManagedLoopRunStatus, av as ManagedLoopRuntimeAdapterOptions, aw as ManagedLoopRuntimeExecutionRoute, ax as ManagedLoopRuntimeExecutionRouteOptions, ay as ManagedModelChunk, az as ManagedModelDescriptor, aA as ManagedModelEstimate, aB as ManagedModelGatewayAccess, aC as ManagedModelGatewayAdapterOptions, aD as ManagedModelRequest, aE as ManagedModelUsage, aF as ManagedNetworkAdapterOptions, aG as ManagedNetworkPolicy, aH as ManagedNetworkStatus, aI as ManagedReplicaHealth, aJ as ManagedServiceResolution, aL as ManagedToolEvidence, aM as ManagedToolExecution, aN as ManagedToolExecutionPhase, aO as ManagedToolOutputChunk, aP as ManagedVolume, aQ as ManagedVolumeBackup, aR as ManagedVolumePublication, aS as ManagedVolumeSnapshot, aT as ManagedVolumeStage, aU as ManagedVolumeStats, aV as ModelAccessHandle, aW as ModelAccessHandleBroker, aX as ModelAccessHandleBudget, aY as ModelAccessHandleClaims, aZ as ModelGateway, a_ as ModelGatewayCallRecord, a$ as ModelGatewayExecutor, b0 as ModelGatewayGenerateRequest, b1 as ModelGatewayOptions, b2 as ModelGatewayRecorder, b3 as ModelGenerateMessage, b4 as ModelGenerateRequest, b5 as ModelHandleSigner, b6 as ModelManagementCapabilities, b7 as ModelManagementDriver, b8 as ModelProviderDataPolicy, bb as ModelStreamChunk, bc as NetworkAttachRequest, bd as NetworkClassSatisfaction, bg as NetworkDriverHealth, bh as NetworkEnforceableFeature, bi as NetworkEnforcementLevel, bj as NetworkManagementCapabilities, bm as PolicyApprovalCapabilities, bp as PolicyDecisionKind, bq as PolicyDecisionOutcome, br as PolicyExplanation, bs as PreparedToolExecution, bt as ResolvedManagedNetworkRequest, bu as RuntimeClassRoutingDriverOptions, bv as StorageManagementCapabilities, by as ToolCatalogSnapshot, bA as ToolManagementCapabilities, bC as ToolOperationApprovalBroker, bD as ToolOperationApprovalDecision, bE as ToolOperationApprovalRequest, bF as VerifyModelAccessHandleOptions, bG as artifactTrustRank, bH as assertArtifactAdmission, bI as assertClassificationAllowed, bJ as assertDriverRequestEnvelope, bK as assertManagedNetworkPolicy, bL as assertNetworkPreparePayload, bM as assertNetworkUpdatePayload, bN as base64UrlDecode, bO as base64UrlEncode, bP as canArtifactEnter, bQ as canDriverSatisfyClass, bR as canonicalDriverValue, bS as classificationRank, bT as countManagedNetworkPolicyRules, bU as createArtifactManagementConformanceSuite, bV as createAuditTelemetryConformanceSuite, bW as createControlStoreConformanceSuite, bX as createCredentialManagementConformanceSuite, bY as createExternalOrchestrationDriverConformanceSuite, bZ as createFakeArtifactManagementDriver, b_ as createFakeArtifactManagementState, b$ as createFakeAuditTelemetryManagementDriver, c0 as createFakeAuditTelemetryState, c1 as createFakeCredentialManagementDriver, c2 as createFakeCredentialManagementState, c3 as createFakeIdentityAttestationManagementDriver, c4 as createFakeIdentityAttestationState, c5 as createFakeLoopRuntimeManagementDriver, c6 as createFakeLoopRuntimeState, c7 as createFakeModelManagementDriver, c8 as createFakeModelManagementState, c9 as createFakeModelProviderDriver, ca as createFakeNetworkDriver, cb as createFakeNetworkManagementDriver, cc as createFakeNetworkManagementState, cd as createFakePolicyApprovalManagementDriver, ce as createFakePolicyApprovalState, cf as createFakeStorageManagementDriver, cg as createFakeStorageManagementState, ch as createFakeToolExecutionDriver, ci as createFakeToolManagementDriver, cj as createFakeToolManagementState, ck as createGatewayMediatedLLMProvider, cl as createIdentityAttestationConformanceSuite, cm as createInMemoryCredentialBroker, cn as createInMemoryModelAccessHandleBroker, co as createInProcessLoopRuntimeDriver, cp as createInProcessToolExecutionDriver, cq as createLoopRuntimeManagementConformanceSuite, cr as createManagedCredentialBrokerAdapter, cs as createManagedLoopRuntimeAdapter, ct as createManagedLoopRuntimeExecutionRoute, cu as createManagedModelGatewayAdapter, cv as createManagedNetworkAdapter, cw as createModelGateway, cx as createModelManagementConformanceSuite, cy as createModelProviderDriverConformanceSuite, cz as createModelProviderDriverFromLLMProvider, cA as createNetworkDriverConformanceSuite, cB as createNetworkManagementConformanceSuite, cC as createPolicyApprovalConformanceSuite, cD as createRuntimeClassRoutingDriver, cE as createStorageManagementConformanceSuite, cF as createToolCatalogConformanceSuite, cG as createToolExecutionDriverConformanceSuite, cH as createToolManagementConformanceSuite, cI as deriveArtifactTrust, cJ as featuresRequiredByClass, cK as inspectAndRecordArtifact, cL as restoreArtifactManagementState, cM as runConformanceSuite, cN as snapshotArtifactManagementState } from './orchestration-portable-Bsf8YRfp.cjs';
14
+ export { F as FetchOrchestrationTransportOptions, N as NamespacedOrchestrationClientOptions, d as REMOTE_ORCHESTRATION_PROTOCOL, e as ReadOnlyOrchestrationClientOptions, f as RemoteOrchestrationClientOptions, g as RemoteOrchestrationOperation, R as RemoteOrchestrationRequest, a as RemoteOrchestrationResponse, c as RemoteOrchestrationTransport, b as RemoteOrchestrationTransportOptions, h as createFetchOrchestrationTransport, i as createNamespacedOrchestrationClient, j as createReadOnlyOrchestrationClient, k as createRemoteOrchestrationClient, l as createRemoteOrchestrationHandler } from './remoteClient-CBggnRy3.cjs';
15
+
16
+ /**
17
+ * Verifier-only protected transitions for ArtifactRecord (plan 24.52).
18
+ *
19
+ * Artifact review evidence (scan, sanitize, verify) can only be appended by
20
+ * verifier actors. Storage drivers, controllers, and workers cannot write
21
+ * review outcomes or unquarantine artifacts. This ensures that trust
22
+ * promotion is always grounded in an external, attested verification step.
23
+ */
24
+ interface VerifierOnlyTransitionOptions {
25
+ /** Actor ID prefix that identifies trusted verifiers. */
26
+ verifierActorPrefix?: string;
27
+ /** Allow quarantine by any actor (fail-safe). Default: true. */
28
+ allowAnyActorQuarantine?: boolean;
29
+ }
30
+ /**
31
+ * Create a ControlStore authorizer that enforces verifier-only transitions
32
+ * for ArtifactRecord resources.
33
+ *
34
+ * Rules:
35
+ * 1. Only verifier actors may append reviews or change quarantine status.
36
+ * 2. Review evidence must be bound to the current content hash.
37
+ * 3. Review evidence must record the verifier's actor ID.
38
+ * 4. Quarantine is fail-safe: any actor may quarantine, but only verifiers
39
+ * may unquarantine (by appending a passing verify review).
40
+ * 5. Non-verifier actors may still read and create ArtifactRecords.
41
+ */
42
+ declare function createVerifierOnlyAuthorizer(options?: VerifierOnlyTransitionOptions): (request: ControlStoreAuthorizationRequest) => void;
43
+ /**
44
+ * Check whether an actor ID belongs to a verifier.
45
+ */
46
+ declare function isVerifierActor(actorId: string, verifierPrefix?: string): boolean;
47
+
48
+ /**
49
+ * ControlStore-backed ArtifactReviewWriter (plan 24.47).
50
+ *
51
+ * Every review append or quarantine goes through ControlStore.updateStatus,
52
+ * protected by the verifier-only authorizer. The authorizer is injected so
53
+ * callers in different hosts can wire the verifier actor prefix appropriate
54
+ * to their trust model.
55
+ */
56
+ declare function createControlStoreArtifactReviewWriter(store: ControlStore, actor: ControlStoreActor, authorizer?: ReturnType<typeof createVerifierOnlyAuthorizer>): ArtifactReviewWriter;
57
+
58
+ /**
59
+ * Hostile artifact defenses (plan 24.48).
60
+ *
61
+ * Pure, portable sanitizers run by the artifact driver — OUTSIDE controller
62
+ * processes. Every function is bounded (explicit size limits) and returns
63
+ * structured findings; callers quarantine on hostile fixtures. Nothing here
64
+ * executes, renders, or mounts content.
65
+ */
66
+ interface SanitizerFinding {
67
+ kind: 'terminal-escape' | 'active-markup' | 'path-traversal' | 'archive-link' | 'archive-limit' | 'mime-confusion' | 'prompt-injection' | 'oversized';
68
+ detail: string;
69
+ }
70
+ interface SanitizedText {
71
+ text: string;
72
+ findings: SanitizerFinding[];
73
+ renderAs: 'plain-text';
74
+ }
75
+ /**
76
+ * Strip ANSI/OSC/control sequences from worker-produced text before display.
77
+ * Bounded: input beyond `maxLength` is truncated and reported.
78
+ */
79
+ declare function sanitizeTerminalText(input: string, options?: {
80
+ maxLength?: number;
81
+ }): SanitizedText;
82
+ /**
83
+ * Convert untrusted markup to an explicitly plain-text representation. The
84
+ * result must be displayed as text, never passed back through an HTML or
85
+ * Markdown renderer.
86
+ */
87
+ declare function sanitizeMarkup(input: string, options?: {
88
+ maxLength?: number;
89
+ }): SanitizedText;
90
+ interface ArchiveEntry {
91
+ path: string;
92
+ sizeBytes: number;
93
+ /** Compressed size when known (for ratio checks). */
94
+ compressedBytes?: number;
95
+ /** Entry is a symlink/hardlink (never extracted). */
96
+ link?: 'symlink' | 'hardlink';
97
+ }
98
+ interface ArchiveLimits {
99
+ maxFiles?: number;
100
+ maxTotalBytes?: number;
101
+ maxDepth?: number;
102
+ maxCompressionRatio?: number;
103
+ }
104
+ /** Normalize a path and reject absolute paths, drive letters, and traversal. */
105
+ declare function assertSafeArchivePath(path: string): string;
106
+ /** Validate an archive manifest without extracting; throws nothing, returns findings. */
107
+ declare function validateArchiveManifest(entries: ArchiveEntry[], limits?: ArchiveLimits): SanitizerFinding[];
108
+ /** Flag content whose declared MIME disagrees with its magic bytes. */
109
+ declare function detectMimeConfusion(declaredMime: string, content: Uint8Array): SanitizerFinding | null;
110
+ /**
111
+ * Heuristic prompt-injection markers for text derived from untrusted sources.
112
+ * A hit means the content must stay tainted/quarantined — absence of a hit is
113
+ * NOT proof of safety.
114
+ */
115
+ declare function scanForPromptInjection(text: string): SanitizerFinding[];
116
+ interface BoundedCollector {
117
+ push(chunk: Uint8Array): void;
118
+ bytes(): Uint8Array;
119
+ readonly size: number;
120
+ }
121
+ /** Accumulate a stream with a hard cap; throws `oversized` when exceeded. */
122
+ declare function createBoundedCollector(maxBytes: number): BoundedCollector;
123
+
124
+ interface ControllerReconcileRequest<TSpec = Record<string, unknown>, TStatus = OrchestrationResourceStatus> {
125
+ resource: OrchestrationResource<TSpec, TStatus>;
126
+ actor: ControlStoreActor;
127
+ leaseEpoch: string;
128
+ now: Date;
129
+ }
130
+ interface ControllerReconcileResult<TStatus extends OrchestrationResourceStatus = OrchestrationResourceStatus> {
131
+ /** New status to write; omit to leave status unchanged. */
132
+ status?: TStatus;
133
+ /** If true, the resource is ready; controller stops reconciling until it changes. */
134
+ ready?: boolean;
135
+ /** Optional requeue delay when the controller wants to try again later. */
136
+ requeueAfterMs?: number;
137
+ }
138
+ interface Controller<TSpec = Record<string, unknown>, TStatus extends OrchestrationResourceStatus = OrchestrationResourceStatus> {
139
+ reconcile(request: ControllerReconcileRequest<TSpec, TStatus>): Promise<ControllerReconcileResult<TStatus>>;
140
+ }
141
+ interface ControllerRunnerOptions<TSpec = Record<string, unknown>, TStatus extends OrchestrationResourceStatus = OrchestrationResourceStatus> {
142
+ /** Controller identity used for all ControlStore writes. */
143
+ actor: ControlStoreActor;
144
+ /** Lease name; controllers with the same name compete for the lease. */
145
+ leaseName: string;
146
+ /** Resource kind this controller reconciles (passed to ControlStore.watch). */
147
+ watchKind: string;
148
+ /** How long the lease is valid before it must be renewed. */
149
+ leaseTtlMs: number;
150
+ /** How often to renew the lease while running. */
151
+ leaseRenewIntervalMs?: number;
152
+ /** Initial backoff after a reconcile failure. */
153
+ retryBaseDelayMs?: number;
154
+ /** Maximum backoff after consecutive reconcile failures. */
155
+ retryMaxDelayMs?: number;
156
+ /** Filter which resources this controller reconciles. */
157
+ resourceFilter?: (resource: OrchestrationResource<TSpec, TStatus>) => boolean;
158
+ /** Injectable clock for deterministic tests. */
159
+ now?: () => Date;
160
+ /** Injectable sleep for deterministic tests. */
161
+ sleep?: (ms: number) => Promise<void>;
162
+ }
163
+ interface ControllerRunnerHandle {
164
+ /** Stop watching and release the lease. */
165
+ stop(): Promise<void>;
166
+ /** Wait until the runner has fully stopped. */
167
+ done(): Promise<void>;
168
+ }
169
+ /**
170
+ * Restart-safe generic controller runner.
171
+ *
172
+ * Watches a ControlStore query, acquires a lease, and calls `controller.reconcile`
173
+ * for each matching resource. On success it may update status and mark Ready.
174
+ * On failure it retries with exponential backoff. If the process crashes, the
175
+ * lease expires and another runner takes over; watch replay resumes from the
176
+ * last acknowledged resource version.
177
+ */
178
+ declare function createControllerRunner<TSpec = Record<string, unknown>, TStatus extends OrchestrationResourceStatus = OrchestrationResourceStatus>(store: ControlStore, controller: Controller<TSpec, TStatus>, options: ControllerRunnerOptions<TSpec, TStatus>): Promise<ControllerRunnerHandle>;
179
+
180
+ declare const FLEET_ROLLOUT_API_VERSION = "fleet.memeloop.io/v1alpha1";
181
+ declare const FLEET_ROLLOUT_KIND = "FleetRollout";
182
+ type RolloutStrategy = 'batch' | 'canary';
183
+ interface FleetRolloutSpec {
184
+ /** Target resource kind to roll out (e.g. AgentWorkload). */
185
+ targetKind: string;
186
+ /** Target namespace. */
187
+ targetNamespace?: string;
188
+ /** Label selector for target resources. */
189
+ selector?: Record<string, string>;
190
+ /** Rollout strategy. */
191
+ strategy: RolloutStrategy;
192
+ /** Batch size for batch strategy. */
193
+ batchSize?: number;
194
+ /** Canary stages for canary strategy. */
195
+ canaryStages?: Array<{
196
+ weight: number;
197
+ pauseDurationMs?: number;
198
+ }>;
199
+ /** Maximum unavailable resources during rollout. */
200
+ maxUnavailable?: number;
201
+ /** Maximum surge resources during rollout. */
202
+ maxSurge?: number;
203
+ /** Maximum concurrent target updates (default: 1 = sequential). */
204
+ maxConcurrency?: number;
205
+ /** Rollout deadline in milliseconds. */
206
+ deadlineMs?: number;
207
+ /** Pause rollout on failure threshold. */
208
+ pauseOnFailureThreshold?: number;
209
+ /**
210
+ * Pause when at least this many targets report drift — the host observed
211
+ * their actual state diverging from the desired template (§8.4/§8.8).
212
+ */
213
+ pauseOnDriftThreshold?: number;
214
+ /**
215
+ * Pause when at least this many targets carry host-reported security
216
+ * findings (§8.8). Fail-safe recommendation: 1 (any finding pauses).
217
+ */
218
+ pauseOnSecurityThreshold?: number;
219
+ /** Automatically rollback updated targets when failure threshold is reached. */
220
+ autoRollback?: boolean;
221
+ /**
222
+ * Aggregate budget for the whole rollout (§8.8 cost threshold). Usage is
223
+ * metered from per-target update results; the rollout pauses between
224
+ * batches/stages once a limit is reached (overshoot is bounded by the
225
+ * in-flight batch).
226
+ */
227
+ budget?: {
228
+ maxTokens?: number;
229
+ maxCost?: number;
230
+ };
231
+ /**
232
+ * Per-run budget cap for a single target (§8: bounded per-run model
233
+ * budget). A target whose reported usage exceeds the cap counts as a
234
+ * failure with a budget reason.
235
+ */
236
+ perTargetBudget?: {
237
+ maxTokens?: number;
238
+ maxCost?: number;
239
+ };
240
+ }
241
+ /** Metered model usage reported by a target update (tokens/cost). */
242
+ interface TargetUsage {
243
+ tokens?: number;
244
+ cost?: number;
245
+ }
246
+ /** Result of updating one target; usage feeds rollout budget accounting. */
247
+ interface TargetUpdateResult {
248
+ usage?: TargetUsage;
249
+ }
250
+ interface RolloutEvidenceEntry {
251
+ resourceName: string;
252
+ outcome: 'success' | 'failure' | 'skipped';
253
+ message?: string;
254
+ timestamp: string;
255
+ /** Metered model usage for this target's run. */
256
+ usage?: TargetUsage;
257
+ }
258
+ /** Sum metered usage across evidence entries (idempotent accounting). */
259
+ declare function sumEvidenceUsage(evidence: readonly RolloutEvidenceEntry[] | undefined): {
260
+ tokens: number;
261
+ cost: number;
262
+ };
263
+ interface FleetRolloutStatus {
264
+ phase?: 'Pending' | 'Rolling' | 'Paused' | 'Completed' | 'Failed' | 'RolledBack';
265
+ currentBatch?: number;
266
+ currentCanaryStage?: number;
267
+ updatedReplicas?: number;
268
+ readyReplicas?: number;
269
+ availableReplicas?: number;
270
+ unavailableReplicas?: number;
271
+ observedGeneration?: number;
272
+ startedAt?: string;
273
+ completedAt?: string;
274
+ pausedAt?: string;
275
+ pauseReason?: string;
276
+ failedAt?: string;
277
+ failureReason?: string;
278
+ deadlineExceeded?: boolean;
279
+ rollbackReason?: string;
280
+ /** Aggregate metered usage across all processed targets (§8 cost). */
281
+ consumedBudget?: {
282
+ tokens: number;
283
+ cost: number;
284
+ };
285
+ evidence?: RolloutEvidenceEntry[];
286
+ }
287
+ type FleetRolloutResource = OrchestrationResource<FleetRolloutSpec>;
288
+ interface RolloutTarget {
289
+ name: string;
290
+ namespace?: string;
291
+ generation: number;
292
+ available: boolean;
293
+ /** Host observation: actual state diverged from the desired template (§8.4). */
294
+ drifted?: boolean;
295
+ /** Host-reported security finding on this target (§8.8). */
296
+ securityFlagged?: boolean;
297
+ }
298
+ interface FleetRolloutControllerOptions {
299
+ actor: ControlStoreActor;
300
+ listTargets: (rollout: FleetRolloutResource) => Promise<RolloutTarget[]>;
301
+ updateTarget: (rollout: FleetRolloutResource, target: RolloutTarget) => Promise<TargetUpdateResult | undefined>;
302
+ rollbackTarget: (rollout: FleetRolloutResource, target: RolloutTarget) => Promise<void>;
303
+ now?: () => Date;
304
+ }
305
+ /**
306
+ * Create a controller that manages FleetRollout resources.
307
+ *
308
+ * The controller implements batch and canary rollout strategies with
309
+ * maxUnavailable, pause on failure, deadline, and rollback support.
310
+ */
311
+ declare function createFleetRolloutController(_store: ControlStore, options: FleetRolloutControllerOptions): Controller<FleetRolloutSpec>;
312
+
313
+ /**
314
+ * Replicated storage controller (plan 24.45).
315
+ *
316
+ * Pure decision logic plus a thin executor over an injected transport:
317
+ * - Authoritative replicas are placed only on trusted nodes and spread across
318
+ * fault domains.
319
+ * - Every replica's content hash is verified against the volume's contentHash
320
+ * (the source of truth); mismatches and unreadable replicas are rebuilt
321
+ * from the primary.
322
+ * - Transfers originate only from the fenced primary; primary changes bump a
323
+ * monotonically increasing epoch so stale primaries cannot serve data.
324
+ * - Loss and corruption converge to the desired replica count.
325
+ */
326
+ interface ReplicationNode {
327
+ nodeId: string;
328
+ faultDomain?: string;
329
+ trust: NodeTrustClass;
330
+ }
331
+ /**
332
+ * Host-owned immutable point-in-time view of the fenced primary. The handle
333
+ * is ephemeral authority and must never be persisted in ControlStore.
334
+ */
335
+ interface ReplicationSnapshot {
336
+ snapshotHandle: string;
337
+ contentHash: string;
338
+ }
339
+ interface ReplicationTransport {
340
+ /** Compute a replica's content hash from trusted storage; null when unreadable/missing. */
341
+ readReplicaHash(volume: AgentVolumeResource, nodeId: string): Promise<string | null>;
342
+ /**
343
+ * Atomically compare the previous fence and persist the newly elected
344
+ * primary fence. Repeating the exact same transition must succeed so a
345
+ * controller can recover when its subsequent ControlStore CAS loses a race.
346
+ */
347
+ commitPrimaryFence(volume: AgentVolumeResource, previous: {
348
+ nodeId?: string;
349
+ epoch: number;
350
+ }, next: {
351
+ nodeId: string;
352
+ epoch: number;
353
+ }): Promise<void>;
354
+ /**
355
+ * Capture a storage-native, internally verified immutable snapshot from the
356
+ * active primary. The transport must reject a stale epoch and make an exact
357
+ * retry idempotent.
358
+ */
359
+ capturePrimarySnapshot(volume: AgentVolumeResource, nodeId: string, epoch: number): Promise<ReplicationSnapshot>;
360
+ /**
361
+ * Idempotently transfer the exact captured snapshot, atomically rejecting
362
+ * an epoch that is not the active primary fence.
363
+ */
364
+ transferReplica(volume: AgentVolumeResource, snapshot: ReplicationSnapshot, fromNodeId: string, toNodeId: string, epoch: number): Promise<void>;
365
+ /** Idempotently release the ephemeral snapshot after reconciliation. */
366
+ releaseSnapshot(volume: AgentVolumeResource, snapshot: ReplicationSnapshot): Promise<void>;
367
+ }
368
+ interface ReplicationContext extends ReplicationTransport {
369
+ nodes: ReplicationNode[];
370
+ now?: () => string;
371
+ }
372
+ type ReplicationAction = {
373
+ type: 'elect-primary';
374
+ nodeId: string;
375
+ epoch: number;
376
+ } | {
377
+ type: 'mark-degraded';
378
+ nodeId: string;
379
+ reason: string;
380
+ } | {
381
+ type: 'mark-offline';
382
+ nodeId: string;
383
+ } | {
384
+ type: 'place-replica';
385
+ nodeId: string;
386
+ fromNodeId: string;
387
+ } | {
388
+ type: 'rebuild-replica';
389
+ nodeId: string;
390
+ fromNodeId: string;
391
+ };
392
+ interface ReplicationResult {
393
+ volume: AgentVolumeResource;
394
+ actions: ReplicationAction[];
395
+ }
396
+ /**
397
+ * Choose target nodes for new replicas, preferring fault domains not already
398
+ * covered by existing replicas and skipping nodes that already host one.
399
+ * Authoritative storage never uses restricted or quarantine nodes.
400
+ */
401
+ declare function planReplicaPlacement(existing: AgentVolumeReplicaStatus[], candidates: ReplicationNode[], count: number): ReplicationNode[];
402
+ /**
403
+ * Reconcile one volume to its desired replica state. Reads and verifies all
404
+ * replicas, elects/fences a primary, rebuilds corrupt or lost replicas, and
405
+ * converges to the class's desired factor when autoRebuild is enabled.
406
+ */
407
+ declare function reconcileVolumeReplication(volume: AgentVolumeResource, storageClass: StorageClassResource, context: ReplicationContext): Promise<ReplicationResult>;
408
+
409
+ /**
410
+ * Dependencies for the replication controller beyond what ReplicationTransport covers.
411
+ */
412
+ interface ReplicationControllerDeps {
413
+ store: ControlStore;
414
+ getStorageClass: (volume: AgentVolumeResource) => Promise<StorageClassResource | null>;
415
+ listNodes: () => Promise<ReplicationNode[]>;
416
+ /**
417
+ * The transport must durably commit the elected epoch before accepting a
418
+ * transfer. ControlStore status is the observable mirror, not the native
419
+ * data-plane fencing authority.
420
+ */
421
+ transport: ReplicationTransport;
422
+ actor: ControlStoreActor;
423
+ }
424
+ /**
425
+ * Create a controller runner that reconciles AgentVolume resources through
426
+ * the pure reconcileVolumeReplication with a transport-owned primary fence.
427
+ *
428
+ * Each reconcile reads the latest volume from the store. The injected
429
+ * transport durably commits a new primary epoch before any transfer can use
430
+ * it. The resulting mirrored status is then written through `updateStatus`
431
+ * with resourceVersion CAS; stale writes are retried by the runner.
432
+ */
433
+ declare function createReplicationController(deps: ReplicationControllerDeps): Promise<ControllerRunnerHandle>;
434
+
435
+ /**
436
+ * ControlStore-backed AgentOrchestrationClient (plan 24.14).
437
+ *
438
+ * Adapts the trusted controller store to the Agent-facing facade so script
439
+ * deployment (and later other facade consumers) can run against the real
440
+ * store instead of test fakes. Actor identity is bound by the host at
441
+ * construction; callers cannot choose it.
442
+ *
443
+ * Apply delegates to the store's atomic declarative update: create when
444
+ * absent, return an equal spec idempotently, or CAS a changed desired spec
445
+ * while preserving identity/status and advancing generation.
446
+ */
447
+ interface ControlStoreOrchestrationClientOptions {
448
+ /** Resource kinds reported by getCapabilities (default: workload-related kinds). */
449
+ resourceKinds?: string[];
450
+ }
451
+ declare function createControlStoreOrchestrationClient(store: ControlStore, actor: ControlStoreActor, options?: ControlStoreOrchestrationClientOptions): AgentOrchestrationClient;
452
+
453
+ interface ToolAdmissionDecision {
454
+ action: ToolAdmissionAction;
455
+ source: 'rule' | 'default';
456
+ reason?: string;
457
+ matchedRule?: ToolAdmissionRule;
458
+ }
459
+ /**
460
+ * Default trusted admission posture per node trust class. Trusted nodes keep
461
+ * the historical allow-by-default posture; restricted and quarantine nodes
462
+ * deny everything unless an explicit rule allows it.
463
+ */
464
+ declare function defaultAdmissionPolicyForTrustClass(trustClass: NodeTrustClass): ToolAdmissionPolicy;
465
+ /**
466
+ * Resolve the effective trusted admission policy for a workload from its
467
+ * SecurityProfile and the node's trust class. Profile rules are evaluated
468
+ * first (they can allow specific tools on restricted nodes); the trust-class
469
+ * default applies after. For restricted/quarantine the resolved default is
470
+ * forced to `deny` — a profile cannot override it.
471
+ */
472
+ declare function resolveAdmissionPolicy(profile: Pick<SecurityProfileResource, 'spec'> | undefined, trustClass: NodeTrustClass): ToolAdmissionPolicy;
473
+ /**
474
+ * Model-facing implied permission default for a trust class. Used by the
475
+ * AgentToolLoop permission gate when no explicit wildcard rule exists.
476
+ */
477
+ declare function defaultPermissionActionForTrustClass(trustClass: NodeTrustClass | undefined): PermissionAction;
478
+ declare function evaluateToolAdmission(policy: ToolAdmissionPolicy, operation: Pick<ToolOperationResource, 'spec'>): ToolAdmissionDecision;
479
+
480
+ interface CredentialBrokerEndpoint {
481
+ nodeId: string;
482
+ brokerClass: string;
483
+ healthy: boolean;
484
+ audiences: string[];
485
+ methods?: string[];
486
+ /** Exact targets or prefix patterns ending in `*`. */
487
+ targets?: string[];
488
+ activeGrants?: number;
489
+ maxGrants?: number;
490
+ }
491
+ interface CredentialGrantPlacementRequirements {
492
+ brokerClass?: string;
493
+ requiredNode?: string;
494
+ /** Host admission denial; binding becomes terminal Failed. */
495
+ denyReason?: string;
496
+ }
497
+ interface CredentialGrantBindingControllerOptions {
498
+ listBrokers(): Promise<CredentialBrokerEndpoint[]>;
499
+ requirementsForGrant?(grant: CredentialGrantResource): Promise<CredentialGrantPlacementRequirements>;
500
+ now?: () => Date;
501
+ }
502
+ /** Independently selects a healthy broker that can honor the complete scope. */
503
+ declare function createCredentialGrantBindingController(options: CredentialGrantBindingControllerOptions): Controller<CredentialGrantResource['spec']>;
504
+ interface CredentialHandleVault {
505
+ /** The token remains outside ControlStore; handleRef is safe to persist. */
506
+ put(handleReference: string, handle: CredentialGrantHandle): Promise<void>;
507
+ get(handleReference: string): Promise<CredentialGrantHandle | undefined>;
508
+ delete(handleReference: string): Promise<void>;
509
+ }
510
+ interface CredentialGrantExecutionControllerOptions {
511
+ nodeId: string;
512
+ getBroker(brokerClass: string, nodeId: string): Promise<CredentialBrokerDriver | undefined>;
513
+ vault: CredentialHandleVault;
514
+ managed?: {
515
+ getDriver(brokerClass: string, nodeId: string): Promise<CredentialManagementDriver | undefined>;
516
+ createIssueRequest(input: {
517
+ grant: CredentialGrantResource;
518
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
519
+ leaseEpoch: string;
520
+ }): Promise<DriverRequestEnvelope<CredentialIssuePayload>>;
521
+ };
522
+ now?: () => Date;
523
+ }
524
+ /** Persists a fencing claim before issuing a worker-visible credential. */
525
+ declare function createCredentialGrantExecutionController(options: CredentialGrantExecutionControllerOptions): Controller<CredentialGrantResource['spec']>;
526
+ declare function revokeCredentialGrant(grant: CredentialGrantResource, broker: CredentialBrokerDriver, vault: CredentialHandleVault): Promise<void>;
527
+ interface CredentialGrantLifecycleControllerOptions {
528
+ nodeId: string;
529
+ getBroker(brokerClass: string, nodeId: string): Promise<CredentialBrokerDriver | undefined>;
530
+ vault: CredentialHandleVault;
531
+ managed?: {
532
+ getDriver(brokerClass: string, nodeId: string): Promise<CredentialManagementDriver | undefined>;
533
+ createRevokeRequest(input: {
534
+ grant: CredentialGrantResource;
535
+ grantHandle: string;
536
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
537
+ leaseEpoch: string;
538
+ }): Promise<DriverRequestEnvelope<{
539
+ grantHandle: string;
540
+ }>>;
541
+ };
542
+ isRunTerminal(grant: CredentialGrantResource): Promise<boolean>;
543
+ now?: () => Date;
544
+ }
545
+ /** Revokes issued grants on Run termination or expiry, including after restart. */
546
+ declare function createCredentialGrantLifecycleController(options: CredentialGrantLifecycleControllerOptions): Controller<CredentialGrantResource['spec']>;
547
+
548
+ interface ControlStoreAuditTelemetryAdapterOptions {
549
+ store: ControlStore;
550
+ name: string;
551
+ authorizeRequest(request: DriverRequestEnvelope): boolean | Promise<boolean>;
552
+ now?: () => Date;
553
+ maxRecordsPerResource?: number;
554
+ maxAttributes?: number;
555
+ persistence: 'host' | 'external';
556
+ threatAssumptions: string[];
557
+ }
558
+ /**
559
+ * ControlStore-backed production audit sink. A short ControlStore lease
560
+ * serializes a named stream across processes; immutable AuditRecord resources
561
+ * retain idempotency, fencing, quota, and hash-chain evidence across restarts.
562
+ */
563
+ declare function createControlStoreAuditTelemetryAdapter(options: ControlStoreAuditTelemetryAdapterOptions): AuditTelemetryManagementDriver;
564
+
565
+ interface PolicyEvaluation {
566
+ outcome: 'allow' | 'deny';
567
+ reasons: string[];
568
+ obligations?: string[];
569
+ }
570
+ interface ControlStorePolicyApprovalAdapterOptions {
571
+ store: ControlStore;
572
+ name: string;
573
+ authorizeRequest(request: DriverRequestEnvelope): boolean | Promise<boolean>;
574
+ evaluateResourceAdmission?(request: Parameters<PolicyApprovalManagementDriver['admitResource']>[0]): PolicyEvaluation | Promise<PolicyEvaluation>;
575
+ evaluatePlacement?(request: Parameters<PolicyApprovalManagementDriver['authorizePlacement']>[0]): PolicyEvaluation | Promise<PolicyEvaluation>;
576
+ evaluateToolOperation?(request: Parameters<PolicyApprovalManagementDriver['authorizeToolOperation']>[0], approval: PolicyDecision | undefined): PolicyEvaluation | Promise<PolicyEvaluation>;
577
+ evaluateTransition?(request: Parameters<PolicyApprovalManagementDriver['verifyTransition']>[0]): PolicyEvaluation | Promise<PolicyEvaluation>;
578
+ maxApprovalTtlMs?: number;
579
+ now?: () => Date;
580
+ persistence: 'host' | 'external';
581
+ threatAssumptions: string[];
582
+ }
583
+ /**
584
+ * Durable production Policy/Approval adapter. Policy outcomes come only from
585
+ * host-injected evaluators or authenticated admin/verifier requests; caller
586
+ * payloads contain no allow bit.
587
+ */
588
+ declare function createControlStorePolicyApprovalAdapter(options: ControlStorePolicyApprovalAdapterOptions): PolicyApprovalManagementDriver;
589
+
590
+ /**
591
+ * Plan 24.61: record/replay fixtures, capability negotiation, cancel/backpressure,
592
+ * crash/adoption, idempotency/fencing, downgrade, and security conformance tests.
593
+ *
594
+ * These helpers are interface-agnostic: each takes the small set of driver
595
+ * operations it needs, so the same suites apply to network, model-provider,
596
+ * tool-execution, storage, and credential drivers.
597
+ */
598
+
599
+ interface RecordedInteraction {
600
+ method: string;
601
+ arguments: unknown[];
602
+ result?: unknown;
603
+ error?: string;
604
+ recordedAt: string;
605
+ }
606
+ interface DriverFixture {
607
+ name: string;
608
+ driverKind: DriverManifest['kind'];
609
+ interactions: RecordedInteraction[];
610
+ }
611
+ /**
612
+ * Wrap a driver and record every method call into a fixture. The fixture can
613
+ * be serialized to JSON and checked into the repo as a portable conformance
614
+ * artifact.
615
+ */
616
+ declare function createRecordingDriver<T extends object>(driver: T, kind: DriverManifest['kind'], name: string): {
617
+ driver: T;
618
+ fixture: () => DriverFixture;
619
+ };
620
+ /**
621
+ * Create a driver that replays a recorded fixture. Each method call returns
622
+ * the recorded result (or throws the recorded error) in order. A call that
623
+ * does not match the next recorded interaction fails the replay.
624
+ */
625
+ declare function createReplayingDriver(fixture: DriverFixture): Record<string, unknown>;
626
+ /**
627
+ * Verify a driver's reported capabilities satisfy the required capability set.
628
+ * Returns the list of missing capabilities (empty when negotiation succeeds).
629
+ */
630
+ declare function negotiateCapabilities(reported: Record<string, boolean | string | number>, required: Record<string, boolean | string | number>): string[];
631
+ declare function createCapabilityNegotiationTests(options: {
632
+ getCapabilities: (driver: unknown) => Promise<Record<string, boolean | string | number>>;
633
+ requiredCapabilities: Record<string, boolean | string | number>;
634
+ }): DriverConformanceTest[];
635
+ declare function createCancellationTests(options: {
636
+ startLongOperation: (driver: unknown, signal: AbortSignal) => Promise<unknown>;
637
+ }): DriverConformanceTest[];
638
+ declare function createBackpressureTests(options: {
639
+ submit: (driver: unknown) => Promise<unknown>;
640
+ concurrencyLimit: number;
641
+ }): DriverConformanceTest[];
642
+ declare function createAdoptionTests(options: {
643
+ createResource: (driver: unknown) => Promise<string>;
644
+ recreateDriver: () => unknown;
645
+ listResources: (driver: unknown) => Promise<string[]>;
646
+ }): DriverConformanceTest[];
647
+ declare function createIdempotencyTests(options: {
648
+ submitWithIdempotencyKey: (driver: unknown, key: string) => Promise<unknown>;
649
+ }): DriverConformanceTest[];
650
+ declare function createFencingTests(options: {
651
+ operateWithFence: (driver: unknown, fenceToken: number) => Promise<unknown>;
652
+ }): DriverConformanceTest[];
653
+ declare function createDowngradeTests(options: {
654
+ callWithVersion: (driver: unknown, version: string) => Promise<unknown>;
655
+ supportedVersion: string;
656
+ }): DriverConformanceTest[];
657
+ declare function createSecurityTests(options: {
658
+ callAsActor: (driver: unknown, actorId: string) => Promise<unknown>;
659
+ unauthorizedActorId: string;
660
+ authorizedActorId: string;
661
+ }): DriverConformanceTest[];
662
+
663
+ interface ExternalToolContract {
664
+ /** Exact portable tool identity implemented by the external runtime. */
665
+ kind: string;
666
+ name: string;
667
+ /** Host-authoritative effect. A caller cannot downgrade this value. */
668
+ effect: ToolOperationEffect;
669
+ /** Portable JSON Schema applied without coercion, defaults, or field removal. */
670
+ inputSchema: Record<string, unknown>;
671
+ /** Portable JSON Schema for the untrusted runtime's returned value. */
672
+ outputSchema: Record<string, unknown>;
673
+ /** Optional content digest callers may pin through `toolRef.schemaDigest`. */
674
+ schemaDigest?: string;
675
+ /** Host-owned hard resource ceiling for the one-shot executor. */
676
+ resources: {
677
+ cpuMillicores: number;
678
+ memoryBytes: number;
679
+ };
680
+ /** Exact immutable/tagged image references admitted to implement this contract. */
681
+ runtimeImages: string[];
682
+ }
683
+ /** Validate a driver-published catalog once at construction/discovery time. */
684
+ declare function assertExternalToolContracts(contracts: readonly ExternalToolContract[]): void;
685
+ /**
686
+ * Bind an externally placed operation to the driver/runtime's trusted
687
+ * declaration before any native API call or adoption lookup.
688
+ */
689
+ declare function assertExternalToolOperationContract(operation: ToolOperationResource, contracts: readonly ExternalToolContract[] | undefined, runtimeImage: string | undefined): ExternalToolContract;
690
+ /** Validate the value returned by an external runtime before persistence. */
691
+ declare function assertExternalToolOperationResult(contract: ExternalToolContract, value: unknown): void;
692
+ /** Contracts implemented by the bundled minimal worker-runtime image. */
693
+ declare function createMinimalExternalRuntimeToolContracts(runtimeImage: string): ExternalToolContract[];
694
+
695
+ interface ExternalWorkloadRuntimeContract {
696
+ /** Matches `AgentWorkload.spec.runtimeClass`; `default` matches omission. */
697
+ runtimeClass: string;
698
+ /** Host-selected image. Production deployments should pin a manifest digest. */
699
+ image: string;
700
+ /** Host-selected entrypoint override, if the image default is insufficient. */
701
+ command?: string[];
702
+ /** Host-selected non-secret container environment. */
703
+ environment?: Record<string, string>;
704
+ /** Default and maximum enforced CPU/memory allocation. */
705
+ resources: {
706
+ cpuMillicores: number;
707
+ memoryBytes: number;
708
+ };
709
+ }
710
+ declare function assertExternalWorkloadRuntimeContracts(contracts: readonly ExternalWorkloadRuntimeContract[]): void;
711
+ /**
712
+ * Resolve only host-published runtime configuration. Legacy annotations are
713
+ * rejected because they let a workload replace the trusted worker process.
714
+ */
715
+ declare function resolveExternalWorkloadRuntime(workload: AgentWorkloadResource, contracts: readonly ExternalWorkloadRuntimeContract[] | undefined): ExternalWorkloadRuntimeContract;
716
+ /** Apply host maxima and safe defaults to portable workload requirements. */
717
+ declare function resolveExternalWorkloadResources(workload: AgentWorkloadResource, contract: ExternalWorkloadRuntimeContract): AgentWorkloadResourceRequirements;
718
+
719
+ interface ExternalRuntimeResult {
720
+ phase: 'Completed' | 'Failed' | 'Cancelled';
721
+ summary?: string;
722
+ result?: ToolOperationResult;
723
+ error?: OrchestrationErrorData;
724
+ }
725
+ /** Parse the last structured worker-result line from a bounded log tail. */
726
+ declare function parseExternalRuntimeResult(logTail: string): ExternalRuntimeResult | undefined;
727
+ /**
728
+ * External orchestrator driver contract (24.62).
729
+ *
730
+ * Every external orchestrator (Docker Swarm, Kubernetes/K3s, Nomad, etc.)
731
+ * implements this portable contract so that the memeloop control plane can
732
+ * map AgentWorkload and ToolOperation resources without importing any
733
+ * backend SDK into core or the default CLI.
734
+ *
735
+ * Driver packages (memeloop-swarm, memeloop-k8s, etc.) are separate optional
736
+ * Node packages that import this contract from `memeloop` and register
737
+ * themselves through the ControlStore's driver manifest system.
738
+ */
739
+ interface ExternalPlacementResult {
740
+ /** External orchestrator's native resource identifier (service name, pod name, job name). */
741
+ externalId: string;
742
+ /** The node where the workload or operation was placed. */
743
+ nodeName: string;
744
+ /** Provider-specific metadata (e.g. Docker service ID, K8s UID). */
745
+ providerMetadata?: Record<string, string>;
746
+ }
747
+ interface ExternalStatusResult {
748
+ externalId: string;
749
+ phase: 'Pending' | 'Running' | 'Succeeded' | 'Failed' | 'Cancelled' | 'Unknown';
750
+ message?: string;
751
+ /** Structured, validated `MEMELOOP_RESULT` recovered from the worker. */
752
+ runtimeResult?: ExternalRuntimeResult;
753
+ /** When the external orchestrator last reported this status. */
754
+ observedAt: string;
755
+ /** Resource usage reported by the external runtime. */
756
+ resources?: {
757
+ cpuCores?: number;
758
+ memoryBytes?: number;
759
+ };
760
+ }
761
+ interface ExternalDriverCapabilities {
762
+ name: string;
763
+ version: string;
764
+ /** What the driver manages: workloads, tool-operations, or both. */
765
+ manages: Array<'AgentWorkload' | 'ToolOperation'>;
766
+ /** Whether the driver supports co-located scheduling (workload + tool on same node). */
767
+ supportsColocation: boolean;
768
+ /**
769
+ * Whether repeated placement of the same immutable MemeLoop resource UID
770
+ * adopts the native object. Required for crash-safe controller recovery.
771
+ */
772
+ supportsAdoption: boolean;
773
+ /** Maximum concurrent workloads this driver can handle. */
774
+ maxConcurrency?: number;
775
+ /**
776
+ * Trusted tool/runtime contracts. Required for every externally placed
777
+ * ToolOperation; an empty/absent catalog makes tool placement fail closed.
778
+ */
779
+ toolContracts?: ExternalToolContract[];
780
+ /** Host-owned runtimeClass-to-container bindings for AgentWorkloads. */
781
+ workloadRuntimes?: ExternalWorkloadRuntimeContract[];
782
+ }
783
+ interface ExternalWorkloadPlacementContext {
784
+ /** Admitted source resolved from the content-addressed artifact store. */
785
+ scriptSource?: string;
786
+ /**
787
+ * Single-use worker bootstrap secret. Drivers must materialize it through
788
+ * their native secret mechanism as a read-only file, never argv, ordinary
789
+ * environment, labels, annotations, provider metadata, or ControlStore.
790
+ */
791
+ workerBootstrap?: ExternalWorkerBootstrapSecret;
792
+ /** Portable cancellation for placement requests. */
793
+ signal?: AbortSignal;
794
+ }
795
+ interface ExternalWorkerBootstrapSecret {
796
+ apiVersion: 'worker.memeloop.io/v1alpha1';
797
+ gatewayUrl: string;
798
+ gatewayPublicKey: string;
799
+ gatewayKeyFingerprint: string;
800
+ /** Optional PEM CA certificate for an internal HTTPS worker gateway. */
801
+ gatewayCaCertificate?: string;
802
+ enrollmentName: string;
803
+ bootstrapToken: string;
804
+ }
805
+ /**
806
+ * Portable external orchestrator driver.
807
+ *
808
+ * Implementations translate between memeloop orchestration resources and
809
+ * the external orchestrator's native API. The control plane never calls
810
+ * Docker/K8s SDKs directly — it always goes through this contract.
811
+ */
812
+ interface ExternalOrchestrationDriver {
813
+ /** Return capabilities so the control plane knows what to route. */
814
+ getCapabilities(): Promise<ExternalDriverCapabilities>;
815
+ /** Place an AgentWorkload on the external orchestrator. */
816
+ placeWorkload(workload: AgentWorkloadResource, actor: ControlStoreActor, context?: ExternalWorkloadPlacementContext): Promise<ExternalPlacementResult>;
817
+ /** Get the current status of a placed workload. */
818
+ getWorkloadStatus(externalId: string): Promise<ExternalStatusResult>;
819
+ /** Stop and remove a placed workload. */
820
+ stopWorkload(externalId: string, actor: ControlStoreActor): Promise<void>;
821
+ /** Execute a ToolOperation on the external orchestrator. */
822
+ executeToolOperation(operation: ToolOperationResource, actor: ControlStoreActor): Promise<ExternalPlacementResult>;
823
+ /** Get the current status of a tool operation execution. */
824
+ getToolOperationStatus(externalId: string): Promise<ExternalStatusResult>;
825
+ /** Cancel a running tool operation. */
826
+ cancelToolOperation(externalId: string, actor: ControlStoreActor): Promise<void>;
827
+ /** List all workloads currently managed by this driver. */
828
+ listWorkloads(): Promise<ExternalStatusResult[]>;
829
+ /** List all tool operations currently managed by this driver. */
830
+ listToolOperations(): Promise<ExternalStatusResult[]>;
831
+ /** Health check for the driver connection. */
832
+ getHealth(): Promise<{
833
+ healthy: boolean;
834
+ detail?: string;
835
+ checkedAt: string;
836
+ }>;
837
+ }
838
+
839
+ /**
840
+ * Local model endpoint registration (plan 24.36).
841
+ *
842
+ * A worker advertises the models its ModelProviderDriver can serve as
843
+ * ModelClass + ModelEndpoint manifests. Advertisement carries digest, health,
844
+ * capacity, modalities, data policy, and node trust so the scheduler can
845
+ * place model calls without contacting the node. Local model output is data
846
+ * only — it can never authorize tool admission, which is host-bound.
847
+ */
848
+ interface LocalModelAdvertisementOptions {
849
+ nodeId: string;
850
+ trust: 'trusted' | 'restricted' | 'quarantine';
851
+ /** Prefix for opaque endpoint handles (default `local://<nodeId>`). */
852
+ endpointPrefix?: string;
853
+ capacity?: {
854
+ maxConcurrent?: number;
855
+ tokensPerMinute?: number;
856
+ };
857
+ dataPolicy?: {
858
+ classification?: string;
859
+ retention?: string;
860
+ };
861
+ }
862
+ interface LocalModelAdvertisement {
863
+ modelClasses: ModelClassManifest[];
864
+ endpoints: ModelEndpointManifest[];
865
+ health: ModelProviderHealth;
866
+ }
867
+ /**
868
+ * Build declarative manifests for every model the driver serves. Endpoint
869
+ * handles are opaque (`<prefix>/<provider>/<model>`) and never embed
870
+ * credentials or URLs.
871
+ */
872
+ declare function describeLocalModelEndpoints(driver: ModelProviderDriver, options: LocalModelAdvertisementOptions): Promise<LocalModelAdvertisement>;
873
+ type ModelEndpointTrust = 'trusted' | 'restricted' | 'quarantine';
874
+ interface ModelSelectionRequirements {
875
+ /** Required ModelClass name. */
876
+ modelClassName: string;
877
+ /** Required model digest; endpoints with a mismatching digest are excluded. */
878
+ modelDigest?: string;
879
+ /** Minimum acceptable node trust (default `quarantine` — any node qualifies). */
880
+ minimumTrust?: ModelEndpointTrust;
881
+ /** Exclude endpoints whose status reports unhealthy (default true). */
882
+ requireHealthy?: boolean;
883
+ /** Required spare concurrency. */
884
+ minConcurrent?: number;
885
+ }
886
+ interface SelectableModelEndpoint {
887
+ manifest: ModelEndpointManifest;
888
+ status?: {
889
+ healthy?: boolean;
890
+ };
891
+ }
892
+ /**
893
+ * Pick the best endpoint for a model call: filters by class name, digest,
894
+ * trust, health, and capacity, then prefers the highest-capacity endpoint.
895
+ * Returns null when nothing qualifies — the caller must surface a scheduling
896
+ * failure rather than silently falling back to an unvetted endpoint.
897
+ */
898
+ declare function selectModelEndpoint(endpoints: SelectableModelEndpoint[], requirements: ModelSelectionRequirements): ModelEndpointManifest | null;
899
+
900
+ interface ManagedArtifactDriverAdapterOptions {
901
+ state: FakeArtifactManagementState;
902
+ inspector: ArtifactInspector;
903
+ authorizeRequest(request: DriverRequestEnvelope): boolean | Promise<boolean>;
904
+ persistState(snapshot: ArtifactManagementStateSnapshot): Promise<void>;
905
+ name: string;
906
+ maxArtifactBytes?: number;
907
+ inspectionIsolation: Exclude<ArtifactManagementCapabilities['inspectionIsolation'], 'none'>;
908
+ persistence: Exclude<ArtifactManagementCapabilities['persistence'], 'process'>;
909
+ reviewer?: string;
910
+ threatAssumptions: string[];
911
+ now?: () => Date;
912
+ destinationPolicies?: Partial<Record<ArtifactDestination, ArtifactDestinationPolicy>>;
913
+ }
914
+ /**
915
+ * Production boundary over the fully tested artifact state engine.
916
+ *
917
+ * Calls are serialized so an asynchronous isolated inspector cannot race
918
+ * mutations. Every accepted request (including one that fails after fencing)
919
+ * is flushed through the host's atomic persistence port before the lock is
920
+ * released.
921
+ */
922
+ declare function createManagedArtifactDriverAdapter(options: ManagedArtifactDriverAdapterOptions): ArtifactManagementDriver;
923
+
924
+ interface StorageDriverCapabilities {
925
+ name: string;
926
+ accessModes: VolumeAccessMode[];
927
+ snapshots: boolean;
928
+ encryption: boolean;
929
+ /** The host stack has a wired replica transport/controller. */
930
+ replication?: boolean;
931
+ /** The host stack has a wired durable backup implementation. */
932
+ backup?: boolean;
933
+ maxVolumeBytes?: number;
934
+ }
935
+ /** Shared claim/class capability gate used at binding and immediately pre-effect. */
936
+ declare function storageDriverSatisfiesClass(capability: StorageDriverCapabilities, claim: AgentVolumeClaimResource, storageClass: StorageClassResource): boolean;
937
+ interface StorageProvisionRequest {
938
+ claim: AgentVolumeClaimResource;
939
+ storageClass: StorageClassResource;
940
+ }
941
+ interface StorageProvisionResult {
942
+ /** Opaque and stable for the claim UID. */
943
+ driverHandle: string;
944
+ capacityBytes?: number;
945
+ topology?: {
946
+ nodeId?: string;
947
+ zone?: string;
948
+ };
949
+ }
950
+ interface StoragePublishRequest {
951
+ volume: AgentVolumeResource;
952
+ nodeId: string;
953
+ workloadUid: string;
954
+ readOnly: boolean;
955
+ }
956
+ interface StoragePublishResult {
957
+ /** Opaque and stable for volume/workload/node. */
958
+ publishHandle: string;
959
+ /** Host path or runtime-native mount descriptor; never parsed by core. */
960
+ mountPath: string;
961
+ }
962
+ /** CSI-like host port. Provision/publish/delete/unpublish must be idempotent. */
963
+ interface StorageDriver {
964
+ getCapabilities(): Promise<StorageDriverCapabilities>;
965
+ getHealth(): Promise<{
966
+ healthy: boolean;
967
+ detail?: string;
968
+ checkedAt: string;
969
+ }>;
970
+ provision(request: StorageProvisionRequest): Promise<StorageProvisionResult>;
971
+ delete(volume: AgentVolumeResource): Promise<void>;
972
+ publish(request: StoragePublishRequest): Promise<StoragePublishResult>;
973
+ getPublished(publishHandle: string): Promise<StoragePublishResult | undefined>;
974
+ unpublish(publishHandle: string): Promise<void>;
975
+ }
976
+
977
+ interface ManagedStorageAdapterStateStore {
978
+ get(key: string): Promise<unknown>;
979
+ put(key: string, value: unknown): Promise<void>;
980
+ delete(key: string): Promise<void>;
981
+ }
982
+ interface ManagedStorageDriverAdapterOptions {
983
+ authorizeRequest(request: DriverRequestEnvelope): boolean | Promise<boolean>;
984
+ resolveProvisionInput(request: DriverRequestEnvelope<StorageProvisionPayload>): Promise<{
985
+ claim: AgentVolumeClaimResource;
986
+ storageClass: StorageClassResource;
987
+ }>;
988
+ resolveVolume(volumeHandle: string, request: DriverRequestEnvelope): Promise<AgentVolumeResource | undefined>;
989
+ stateStore?: ManagedStorageAdapterStateStore;
990
+ stableStageHandleFor?(request: DriverRequestEnvelope<{
991
+ volumeHandle: string;
992
+ nodeId: string;
993
+ }>): string;
994
+ threatAssumptions: string[];
995
+ now?: () => Date;
996
+ }
997
+ /**
998
+ * Production bridge for the existing CSI-like StorageDriver. Unsupported data
999
+ * management operations fail explicitly instead of fabricating capabilities.
1000
+ */
1001
+ declare function createManagedStorageDriverAdapter(driver: StorageDriver, options: ManagedStorageDriverAdapterOptions): StorageManagementDriver;
1002
+
1003
+ /** Build content-addressed descriptors from the schemas actually registered by the host. */
1004
+ declare function createManagedToolDescriptors(registry: IToolRegistry, nodeId: string): Promise<ManagedToolDescriptor[]>;
1005
+ interface ManagedToolPolicyDecision {
1006
+ handle: string;
1007
+ policyDigest: string;
1008
+ approval?: ToolOperationApprovalEvidence;
1009
+ }
1010
+ interface ManagedToolExecutionRouteOptions {
1011
+ descriptors: ManagedToolDescriptor[];
1012
+ resolveOperation(resourceUid: string): Promise<ToolOperationResource | undefined>;
1013
+ authorizeOperation(operation: ToolOperationResource, signal?: AbortSignal): Promise<ManagedToolPolicyDecision>;
1014
+ authorizeRequest(request: DriverRequestEnvelope): boolean | Promise<boolean>;
1015
+ createRequest<T>(input: {
1016
+ method: string;
1017
+ payload: T;
1018
+ operation: ToolOperationResource;
1019
+ actor: ControllerReconcileRequest['actor'];
1020
+ leaseEpoch: string;
1021
+ idempotencyKey: string;
1022
+ payloadFields: string[];
1023
+ }): DriverRequestEnvelope<T>;
1024
+ name: string;
1025
+ maxOutputBytes?: number;
1026
+ maxOutputChunks?: number;
1027
+ now?: () => Date;
1028
+ threatAssumptions: string[];
1029
+ }
1030
+ interface ManagedToolExecutionRoute {
1031
+ managementDriver: ToolManagementDriver;
1032
+ executionDriver: ToolExecutionDriver;
1033
+ }
1034
+ /**
1035
+ * Round-trip the existing ToolExecutionDriver through the complete managed
1036
+ * lifecycle while keeping live results and approval evidence host-local.
1037
+ */
1038
+ declare function createManagedToolExecutionRoute(narrowDriver: ToolExecutionDriver, options: ManagedToolExecutionRouteOptions): ManagedToolExecutionRoute;
1039
+
1040
+ /**
1041
+ * Dedicated outbound worker protocol (plan §13).
1042
+ *
1043
+ * This protocol is deliberately smaller than ResourceClient. A worker can
1044
+ * interact only with its own assignment/run through method-specific gateway
1045
+ * handlers; it cannot list/watch control state, acquire leases, discover
1046
+ * peers, or mutate Node/verification/promotion resources.
1047
+ */
1048
+ declare const WORKER_PROTOCOL_VERSION = "worker.memeloop.io/v1alpha1";
1049
+ declare const WORKER_PROTOCOL_METHODS: readonly ["assignment.pull", "assignment.ack", "session.heartbeat", "event.submit", "capability.request", "artifact.upload", "operation.complete", "operation.fail", "operation.cancel"];
1050
+ type WorkerProtocolMethod = typeof WORKER_PROTOCOL_METHODS[number];
1051
+ interface WorkerRunBinding {
1052
+ uid: string;
1053
+ attempt: number;
1054
+ epoch: number;
1055
+ }
1056
+ interface WorkerProtocolRequest {
1057
+ apiVersion: typeof WORKER_PROTOCOL_VERSION;
1058
+ requestId: string;
1059
+ sessionName: string;
1060
+ sequence: number;
1061
+ nonce: string;
1062
+ deadline: string;
1063
+ audience: string;
1064
+ run: WorkerRunBinding;
1065
+ method: WorkerProtocolMethod;
1066
+ target: string;
1067
+ policyDigest: string;
1068
+ payload: unknown;
1069
+ /** Signature over canonicalWorkerProtocolRequestBytes(request). */
1070
+ signature: string;
1071
+ }
1072
+ type WorkerProtocolResponse = {
1073
+ apiVersion: typeof WORKER_PROTOCOL_VERSION;
1074
+ requestId: string;
1075
+ ok: true;
1076
+ payload: unknown;
1077
+ receivedAt: string;
1078
+ } | {
1079
+ apiVersion: typeof WORKER_PROTOCOL_VERSION;
1080
+ requestId: string;
1081
+ ok: false;
1082
+ error: OrchestrationErrorData;
1083
+ receivedAt: string;
1084
+ };
1085
+ interface WorkerBootstrapSessionDescriptor {
1086
+ apiVersion: typeof WORKER_PROTOCOL_VERSION;
1087
+ sessionName: string;
1088
+ audience: string;
1089
+ expiresAt: string;
1090
+ run: WorkerRunBinding;
1091
+ policyDigest: string;
1092
+ allowedMethods: WorkerProtocolMethod[];
1093
+ allowedTargets?: string[];
1094
+ workerKeyFingerprint: string;
1095
+ gatewayKeyFingerprint: string;
1096
+ issuedAt: string;
1097
+ }
1098
+ interface SignedWorkerBootstrapSessionDescriptor extends WorkerBootstrapSessionDescriptor {
1099
+ /** Gateway signature over canonicalWorkerBootstrapDescriptorBytes(...). */
1100
+ gatewaySignature: string;
1101
+ }
1102
+ interface WorkerGatewaySession {
1103
+ name: string;
1104
+ workerKeyFingerprint: string;
1105
+ workerPublicKey: string;
1106
+ audience: string;
1107
+ protocol: typeof WORKER_PROTOCOL_VERSION;
1108
+ expiresAt: string;
1109
+ revoked: boolean;
1110
+ run: WorkerRunBinding;
1111
+ policyDigest: string;
1112
+ allowedMethods: WorkerProtocolMethod[];
1113
+ allowedTargets?: string[];
1114
+ }
1115
+ interface WorkerProtocolReplayProtector {
1116
+ /**
1117
+ * Atomically accept exactly the next sequence and a fresh nonce.
1118
+ * Production implementations must persist this state; returning false
1119
+ * fails closed on replay, gaps, or uncertain state.
1120
+ */
1121
+ consume(sessionName: string, sequence: number, nonce: string): Promise<boolean>;
1122
+ }
1123
+ interface WorkerProtocolGatewayOptions {
1124
+ resolveSession: (sessionName: string) => Promise<WorkerGatewaySession | undefined>;
1125
+ replayProtector: WorkerProtocolReplayProtector;
1126
+ verifySignature: (request: {
1127
+ session: WorkerGatewaySession;
1128
+ message: Uint8Array;
1129
+ signature: string;
1130
+ }) => Promise<boolean>;
1131
+ dispatch: (request: {
1132
+ requestId: string;
1133
+ session: WorkerGatewaySession;
1134
+ method: WorkerProtocolMethod;
1135
+ target: string;
1136
+ payload: unknown;
1137
+ signal: AbortSignal;
1138
+ }) => Promise<unknown>;
1139
+ now?: () => Date;
1140
+ maxClockSkewMs?: number;
1141
+ maxRequestsPerMinute?: number;
1142
+ methodPayloadLimits?: Partial<Record<WorkerProtocolMethod, number>>;
1143
+ maxResponseBytes?: number;
1144
+ onAudit?: (event: WorkerProtocolAuditEvent) => Promise<void> | void;
1145
+ /** Trusted host diagnostics; never serialized to the worker response. */
1146
+ onError?: (error: unknown) => void;
1147
+ }
1148
+ interface WorkerProtocolAuditEvent {
1149
+ requestId: string;
1150
+ sessionName: string;
1151
+ method: string;
1152
+ target: string;
1153
+ /** Policy snapshot from the verified request/session binding. */
1154
+ policyDigest: string;
1155
+ accepted: boolean;
1156
+ code?: OrchestrationErrorData['code'];
1157
+ receivedAt: string;
1158
+ }
1159
+ /** Canonical bytes signed by the worker; excludes only the signature field. */
1160
+ declare function canonicalWorkerProtocolRequestBytes(request: Omit<WorkerProtocolRequest, 'signature'> | WorkerProtocolRequest): Uint8Array;
1161
+ /** Canonical bytes signed by the pinned gateway after enrollment. */
1162
+ declare function canonicalWorkerBootstrapDescriptorBytes(descriptor: WorkerBootstrapSessionDescriptor | SignedWorkerBootstrapSessionDescriptor): Uint8Array;
1163
+ /**
1164
+ * Create the trusted-side protocol gateway. Session resolution, signature
1165
+ * verification, replay state, and effects are all injected host ports.
1166
+ */
1167
+ declare function createWorkerProtocolGateway(options: WorkerProtocolGatewayOptions): {
1168
+ handle(request: WorkerProtocolRequest, signal?: AbortSignal): Promise<WorkerProtocolResponse>;
1169
+ };
1170
+ /** In-memory replay fixture. Production gateways must use durable state. */
1171
+ declare function createInMemoryWorkerReplayProtector(): WorkerProtocolReplayProtector;
1172
+
1173
+ declare const WORKER_ENROLLMENT_API_VERSION = "security.memeloop.io/v1alpha1";
1174
+ declare const WORKER_ENROLLMENT_KIND = "WorkerEnrollment";
1175
+ declare const WORKER_SESSION_API_VERSION = "security.memeloop.io/v1alpha1";
1176
+ declare const WORKER_SESSION_KIND = "WorkerSession";
1177
+ /**
1178
+ * WorkerEnrollment: one-time bootstrap record for a worker identity.
1179
+ * Created by a trusted controller or admin; never by the worker itself.
1180
+ */
1181
+ interface WorkerEnrollmentSpec {
1182
+ /** Node this worker is enrolled on. */
1183
+ nodeRef: {
1184
+ apiVersion: string;
1185
+ kind: string;
1186
+ name: string;
1187
+ namespace?: string;
1188
+ };
1189
+ /** Trust class assigned at enrollment time; immutable after creation. */
1190
+ trustClass: NodeTrustClass;
1191
+ /** Pinned gateway URL and public-key fingerprint known before bootstrap. */
1192
+ expectedGateway: string;
1193
+ gatewayKeyFingerprint: string;
1194
+ /** Narrow protocol/session scope fixed by the trusted enrolling actor. */
1195
+ audience: string;
1196
+ allowedProtocol: string;
1197
+ run: WorkerRunBinding;
1198
+ policyDigest: string;
1199
+ allowedMethods: WorkerProtocolMethod[];
1200
+ allowedTargets?: string[];
1201
+ /** One-time bootstrap token hash; the raw token is only shown once. */
1202
+ bootstrapTokenHash: string;
1203
+ /** Enrolling actor (controller or admin). */
1204
+ enrolledBy: string;
1205
+ /** Expiry of the enrollment record itself. */
1206
+ expiresAt: string;
1207
+ }
1208
+ interface WorkerEnrollmentStatus extends OrchestrationResourceStatus {
1209
+ phase?: 'Pending' | 'Bound' | 'Expired' | 'Revoked';
1210
+ /** Fingerprint of the worker's ephemeral public key, set after binding. */
1211
+ workerKeyFingerprint?: string;
1212
+ boundAt?: string;
1213
+ revokedAt?: string;
1214
+ revokeReason?: string;
1215
+ }
1216
+ /**
1217
+ * WorkerSession: ephemeral identity session bound to a worker key.
1218
+ * Created after a worker proves possession of the bootstrap token.
1219
+ */
1220
+ interface WorkerSessionSpec {
1221
+ enrollmentRef: {
1222
+ apiVersion: string;
1223
+ kind: string;
1224
+ name: string;
1225
+ namespace?: string;
1226
+ };
1227
+ /** Fingerprint of the worker's ephemeral public key. */
1228
+ workerKeyFingerprint: string;
1229
+ /** Encoded ephemeral public key used for per-message signature checks. */
1230
+ workerPublicKey: string;
1231
+ audience: string;
1232
+ allowedProtocol: string;
1233
+ run: WorkerRunBinding;
1234
+ policyDigest: string;
1235
+ allowedMethods: WorkerProtocolMethod[];
1236
+ allowedTargets?: string[];
1237
+ /** Session TTL in milliseconds. */
1238
+ ttlMs: number;
1239
+ }
1240
+ interface WorkerSessionStatus extends OrchestrationResourceStatus {
1241
+ phase?: 'Active' | 'Expired' | 'Revoked';
1242
+ issuedAt?: string;
1243
+ expiresAt?: string;
1244
+ lastProofAt?: string;
1245
+ revokedAt?: string;
1246
+ revokeReason?: string;
1247
+ /** Durable replay fence for the dedicated worker protocol. */
1248
+ lastSequence?: number;
1249
+ /** Bounded recent nonce window; sequence remains the primary fence. */
1250
+ recentNonces?: string[];
1251
+ }
1252
+ type WorkerEnrollmentResource = Omit<OrchestrationResource<WorkerEnrollmentSpec>, 'status'> & {
1253
+ status?: WorkerEnrollmentStatus;
1254
+ };
1255
+ type WorkerSessionResource = Omit<OrchestrationResource<WorkerSessionSpec>, 'status'> & {
1256
+ status?: WorkerSessionStatus;
1257
+ };
1258
+ interface BindWorkerSessionRequest {
1259
+ /** Raw, single-use bootstrap token. It must never be persisted or logged. */
1260
+ bootstrapToken: string;
1261
+ /** Fingerprint of the ephemeral public key proved by the worker. */
1262
+ workerKeyFingerprint: string;
1263
+ /** Encoded ephemeral public key; public, but never worker-selected authority. */
1264
+ workerPublicKey: string;
1265
+ /** Pinned gateway identity serving this bootstrap request. */
1266
+ gatewayKeyFingerprint: string;
1267
+ /** Gateway-issued one-time challenge and the worker's signature over it. */
1268
+ proof: {
1269
+ challenge: string;
1270
+ signature: string;
1271
+ };
1272
+ /** Requested session lifetime. It is capped by the enrollment expiry. */
1273
+ ttlMs: number;
1274
+ /**
1275
+ * Host cryptographic verifier. Core deliberately does not prescribe a
1276
+ * password-hash implementation; the verifier compares the raw token with
1277
+ * the enrollment's persisted hash in constant-time.
1278
+ */
1279
+ verifyBootstrapToken: (token: string, expectedHash: string) => Promise<boolean> | boolean;
1280
+ /** Verify key fingerprint and proof-of-possession, consuming the challenge. */
1281
+ verifyWorkerProof: (request: {
1282
+ enrollmentName: string;
1283
+ workerKeyFingerprint: string;
1284
+ workerPublicKey: string;
1285
+ challenge: string;
1286
+ signature: string;
1287
+ }) => Promise<boolean> | boolean;
1288
+ }
1289
+ declare function createWorkerEnrollmentManifest(name: string, spec: WorkerEnrollmentSpec): {
1290
+ apiVersion: string;
1291
+ kind: string;
1292
+ metadata: {
1293
+ name: string;
1294
+ };
1295
+ spec: WorkerEnrollmentSpec;
1296
+ };
1297
+ declare function createWorkerSessionManifest(name: string, spec: WorkerSessionSpec): {
1298
+ apiVersion: string;
1299
+ kind: string;
1300
+ metadata: {
1301
+ name: string;
1302
+ };
1303
+ spec: WorkerSessionSpec;
1304
+ };
1305
+ declare function isWorkerEnrollment(resource: OrchestrationResource<unknown, unknown>): resource is WorkerEnrollmentResource;
1306
+ declare function isWorkerSession(resource: OrchestrationResource<unknown, unknown>): resource is WorkerSessionResource;
1307
+ /**
1308
+ * Enroll a new worker: create a WorkerEnrollment with a one-time bootstrap token.
1309
+ * Only callable by trusted controller or admin actors.
1310
+ */
1311
+ declare function enrollWorker(store: ControlStore, actor: ControlStoreActor, name: string, spec: WorkerEnrollmentSpec): Promise<WorkerEnrollmentResource>;
1312
+ /**
1313
+ * Bind a worker to its enrollment: the worker proves possession of the
1314
+ * bootstrap token and receives a WorkerSession with an ephemeral identity.
1315
+ */
1316
+ declare function bindWorkerSession(store: ControlStore, actor: ControlStoreActor, enrollmentName: string, request: BindWorkerSessionRequest, now?: () => Date): Promise<WorkerSessionResource>;
1317
+ /**
1318
+ * Revoke a worker session, preventing further use of the ephemeral identity.
1319
+ */
1320
+ declare function revokeWorkerSession(store: ControlStore, actor: ControlStoreActor, sessionName: string, reason: string, now?: () => Date): Promise<void>;
1321
+ /**
1322
+ * Check whether a worker session is currently valid (active and not expired).
1323
+ */
1324
+ declare function isWorkerSessionValid(session: WorkerSessionResource, now?: Date): boolean;
1325
+
1326
+ interface ManagedWorkerIdentityRequestFactoryInput<T> {
1327
+ method: string;
1328
+ payload: T;
1329
+ enrollment: WorkerEnrollmentResource;
1330
+ actor: ControlStoreActor;
1331
+ idempotencyKey: string;
1332
+ payloadFields: string[];
1333
+ }
1334
+ interface ManagedWorkerIdentityAdapterOptions {
1335
+ store: ControlStore;
1336
+ actor: ControlStoreActor;
1337
+ authorizeRequest(request: DriverRequestEnvelope): boolean | Promise<boolean>;
1338
+ createRequest<T>(input: ManagedWorkerIdentityRequestFactoryInput<T>): DriverRequestEnvelope<T>;
1339
+ maxChallengeTtlMs?: number;
1340
+ maxSessionTtlMs?: number;
1341
+ now?: () => Date;
1342
+ name: string;
1343
+ threatAssumptions: string[];
1344
+ }
1345
+ interface ManagedWorkerIdentityRoute {
1346
+ driver: IdentityAttestationManagementDriver;
1347
+ bindWorkerSession(enrollmentName: string, request: BindWorkerSessionRequest): Promise<WorkerSessionResource>;
1348
+ }
1349
+ /**
1350
+ * Put the existing one-time WorkerEnrollment/WorkerSession Ed25519 flow behind
1351
+ * the general Identity/Attestation contract without claiming hardware
1352
+ * attestation or crash-persistent pending proof material.
1353
+ */
1354
+ declare function createManagedWorkerIdentityAdapter(options: ManagedWorkerIdentityAdapterOptions): ManagedWorkerIdentityRoute;
1355
+
1356
+ /**
1357
+ * ModelEndpoint registration heartbeat (plan 24.36).
1358
+ *
1359
+ * A node runs one registrar per ModelProviderDriver. Each heartbeat tick
1360
+ * re-describes the driver's models, upserts ModelClass/ModelEndpoint
1361
+ * resources into the ControlStore, and refreshes endpoint `status.healthy`
1362
+ * and `status.heartbeat` so the scheduler can place model calls on live
1363
+ * endpoints. Endpoints the driver stops serving are deleted; when the driver
1364
+ * cannot be interrogated or the registrar stops, owned endpoints are marked
1365
+ * unhealthy (fail-safe: never advertise a possibly-dead model as healthy).
1366
+ *
1367
+ * The actor identity is host-bound; scripts and model output cannot choose
1368
+ * it. Endpoint specs are immutable here because ControlStore intentionally
1369
+ * exposes no spec-update verb — identity changes require delete + recreate.
1370
+ */
1371
+ interface ModelEndpointRegistrarOptions {
1372
+ /** Host-bound actor identity used for every ControlStore write. */
1373
+ actor: ControlStoreActor;
1374
+ /** Advertisement identity/policy (nodeId, trust, capacity, data policy). */
1375
+ advertisement: LocalModelAdvertisementOptions;
1376
+ /** Heartbeat interval in milliseconds (default 30_000). */
1377
+ heartbeatIntervalMs?: number;
1378
+ /** CAS attempts per status write before giving up (default 3). */
1379
+ statusWriteAttempts?: number;
1380
+ /** Start the background loop immediately (default true). */
1381
+ autoStart?: boolean;
1382
+ /** Injectable clock for deterministic tests. */
1383
+ now?: () => Date;
1384
+ /** Injectable sleep for deterministic tests. */
1385
+ sleep?: (ms: number) => Promise<void>;
1386
+ /** Observes swallowed tick errors; the loop keeps running regardless. */
1387
+ onError?: (error: unknown) => void;
1388
+ }
1389
+ interface ModelEndpointRegistrarHandle {
1390
+ /** Run one registration + heartbeat pass (serialized with the loop). */
1391
+ refresh(): Promise<void>;
1392
+ /** Stop the loop and mark owned endpoints unhealthy (best-effort). */
1393
+ stop(): Promise<void>;
1394
+ }
1395
+ declare function createModelEndpointRegistrar(store: ControlStore, driver: ModelProviderDriver, options: ModelEndpointRegistrarOptions): ModelEndpointRegistrarHandle;
1396
+
1397
+ /**
1398
+ * Condition type raised on a ToolOperation whose executor crashed or
1399
+ * disconnected after a side effect may have occurred. While this condition is
1400
+ * `True`, controllers must follow the recorded reconciliation decision instead
1401
+ * of blindly repeating the operation.
1402
+ */
1403
+ declare const TOOL_OPERATION_CONDITION_EFFECT_UNKNOWN = "EffectUnknown";
1404
+ /**
1405
+ * Evidence gathered by driver/controller inspection after an executor crash or
1406
+ * disconnect. Evidence is produced by the trusted side (driver checkpoints,
1407
+ * verifier probes, artifact records), never by the possibly-failed executor's
1408
+ * own claim alone.
1409
+ */
1410
+ interface UnknownEffectEvidence {
1411
+ /**
1412
+ * The executor produced a result before the disconnect and only the
1413
+ * completion acknowledgement was lost. The caller is responsible for
1414
+ * attaching the observed result when applying the decision.
1415
+ */
1416
+ resultObserved?: boolean;
1417
+ /** Reference to independent verification evidence (artifact, verifier run). */
1418
+ evidenceRef?: string;
1419
+ /** ISO timestamp of the observed disconnect/crash. */
1420
+ disconnectedAt?: string;
1421
+ }
1422
+ type UnknownEffectAction = 'retry' | 'succeeded' | 'verification-required' | 'manual-intervention';
1423
+ interface UnknownEffectDecision {
1424
+ action: UnknownEffectAction;
1425
+ reason: string;
1426
+ }
1427
+ /**
1428
+ * Decide how to reconcile an operation whose effect is unknown. The decision
1429
+ * never blindly repeats destructive work:
1430
+ *
1431
+ * 1. An observed result means only the ack was lost → `succeeded`.
1432
+ * 2. `read` effects have no side effects → `retry` (within attempt budget).
1433
+ * 3. `retry.nonRetryable` operations are never repeated → `manual-intervention`.
1434
+ * 4. Operations with an `idempotencyKey` dedupe at the executor/store, so a
1435
+ * repeated delivery is safe → `retry` (within attempt budget).
1436
+ * 5. Everything else requires independent verification before any retry →
1437
+ * `verification-required`.
1438
+ */
1439
+ declare function reconcileUnknownEffect(operation: ToolOperationResource, evidence: UnknownEffectEvidence): UnknownEffectDecision;
1440
+ /**
1441
+ * Apply a reconciliation decision to an operation, producing the next status:
1442
+ *
1443
+ * - `retry` → back to `Pending` (requeue) with the EffectUnknown condition.
1444
+ * - `succeeded` → `Completed` (caller attaches the observed result separately).
1445
+ * - `verification-required` / `manual-intervention` → stays `Running` with the
1446
+ * EffectUnknown condition; the operation is not repeated until a verifier or
1447
+ * operator clears the condition.
1448
+ */
1449
+ declare function applyUnknownEffectDecision(operation: ToolOperationResource, decision: UnknownEffectDecision, at?: string): ToolOperationResource;
1450
+
1451
+ interface RegisteredExternalOrchestrationDriver {
1452
+ name: string;
1453
+ driver: ExternalOrchestrationDriver;
1454
+ capabilities: ExternalDriverCapabilities;
1455
+ }
1456
+ interface ExternalOrchestrationControllerOptions {
1457
+ actor: ControlStoreActor;
1458
+ drivers: RegisteredExternalOrchestrationDriver[];
1459
+ pollIntervalMs?: number;
1460
+ statusWriteAttempts?: number;
1461
+ sleep?: (ms: number) => Promise<void>;
1462
+ now?: () => Date;
1463
+ /** Resolve admitted script content without persisting it in ControlStore. */
1464
+ resolveScriptSource?: (scriptReference: string) => Promise<string | undefined>;
1465
+ /** Create a short-lived, single-use bootstrap secret at placement time. */
1466
+ createWorkerBootstrap?: (workload: AgentWorkloadResource, runReference: OrchestrationResourceReference) => Promise<ExternalWorkerBootstrapSecret | undefined>;
1467
+ /**
1468
+ * Host-bound policy/approval authority for external tool effects. The
1469
+ * controller fails closed when this hook is absent.
1470
+ */
1471
+ authorizeToolOperation?: (operation: ToolOperationResource, signal?: AbortSignal) => Promise<{
1472
+ approval?: NonNullable<ToolOperationStatus['approval']>;
1473
+ }>;
1474
+ /**
1475
+ * Host-bound admission for external workload placement. The returned
1476
+ * durable decision identity is persisted before the native side effect.
1477
+ */
1478
+ authorizeWorkloadPlacement?: (workload: AgentWorkloadResource, driver: RegisteredExternalOrchestrationDriver, signal?: AbortSignal) => Promise<{
1479
+ decisionHandle: string;
1480
+ policyDigest: string;
1481
+ }>;
1482
+ onError?: (error: unknown) => void;
1483
+ }
1484
+ interface ExternalOrchestrationControllerHandle {
1485
+ stop(): Promise<void>;
1486
+ }
1487
+ /**
1488
+ * Reconcile explicitly external AgentWorkloads and ToolOperations through
1489
+ * registered optional drivers. Placement identity is persisted before status
1490
+ * polling, so controller restart adopts the native resource rather than
1491
+ * creating a second effect. Driver implementations must make placement
1492
+ * idempotent by MemeLoop resource UID.
1493
+ */
1494
+ declare function createExternalOrchestrationController(store: ControlStore, options: ExternalOrchestrationControllerOptions): ExternalOrchestrationControllerHandle;
1495
+
1496
+ interface ModelEndpointBindingControllerOptions {
1497
+ actor: ControlStoreActor;
1498
+ getWorkload(run: AgentRunResource): Promise<AgentWorkloadResource | null>;
1499
+ listEndpoints(): Promise<ModelEndpointResource[]>;
1500
+ getModelClass(endpoint: ModelEndpointResource): Promise<ModelClassResource | null>;
1501
+ /** Existing bindings used as conservative live capacity reservations. */
1502
+ listRuns?: () => Promise<AgentRunResource[]>;
1503
+ /** Maximum endpoint heartbeat age accepted for placement (default 90s). */
1504
+ endpointHeartbeatTtlMs?: number;
1505
+ /** Clock used only for the persisted binding timestamp. */
1506
+ now?: () => Date;
1507
+ }
1508
+ /**
1509
+ * Independently binds a Pending AgentRun to a live ModelEndpoint. The
1510
+ * controller re-evaluates every hard policy requirement itself and persists
1511
+ * the lease epoch before workload execution may consume the endpoint.
1512
+ */
1513
+ declare function createModelEndpointBindingController(options: ModelEndpointBindingControllerOptions): Controller<AgentRunResource['spec']>;
1514
+
1515
+ interface NetworkAttachmentNode {
1516
+ nodeId: string;
1517
+ healthy: boolean;
1518
+ capabilities: NetworkDriverCapabilities[];
1519
+ /** Conservative number of attachments not yet reflected by the driver. */
1520
+ activeAttachments?: number;
1521
+ maxAttachments?: number;
1522
+ }
1523
+ interface NetworkAttachmentBindingControllerOptions {
1524
+ getNetworkClass(attachment: NetworkAttachmentResource): Promise<NetworkClassResource | null>;
1525
+ getWorkload?(attachment: NetworkAttachmentResource): Promise<AgentWorkloadResource | null>;
1526
+ listNodes(): Promise<NetworkAttachmentNode[]>;
1527
+ now?: () => Date;
1528
+ }
1529
+ /**
1530
+ * Selects the node-local NetworkDriver independently from workload execution.
1531
+ * NetworkClass capability checks are hard filters; best-effort degradation is
1532
+ * allowed only when the class itself explicitly opts into it.
1533
+ */
1534
+ declare function createNetworkAttachmentBindingController(options: NetworkAttachmentBindingControllerOptions): Controller<NetworkAttachmentResource['spec']>;
1535
+ interface NetworkAttachmentExecutionControllerOptions {
1536
+ nodeId: string;
1537
+ getNetworkClass(attachment: NetworkAttachmentResource): Promise<NetworkClassResource | null>;
1538
+ getDriver(name: string): Promise<NetworkDriver | undefined>;
1539
+ sandboxRef?(attachment: NetworkAttachmentResource): Promise<string>;
1540
+ managed?: {
1541
+ getDriver(name: string): Promise<NetworkManagementDriver | undefined>;
1542
+ createPrepareRequest(input: {
1543
+ attachment: NetworkAttachmentResource;
1544
+ networkClass: NetworkClassResource;
1545
+ sandboxHandle: string;
1546
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
1547
+ leaseEpoch: string;
1548
+ }): Promise<DriverRequestEnvelope<NetworkPreparePayload>>;
1549
+ createReleaseRequest(input: {
1550
+ attachment: NetworkAttachmentResource;
1551
+ networkHandle: string;
1552
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
1553
+ leaseEpoch: string;
1554
+ }): Promise<DriverRequestEnvelope<{
1555
+ networkHandle: string;
1556
+ }>>;
1557
+ };
1558
+ now?: () => Date;
1559
+ }
1560
+ /**
1561
+ * Executes a bound attachment on its selected node. prepare() implementations
1562
+ * must be idempotent for an attachment UID. The persisted Preparing claim
1563
+ * prevents a new controller epoch from repeating a possibly completed effect.
1564
+ */
1565
+ declare function createNetworkAttachmentExecutionController(options: NetworkAttachmentExecutionControllerOptions): Controller<NetworkAttachmentResource['spec']>;
1566
+
1567
+ interface RunVolumeControllerOptions {
1568
+ nodeId: string;
1569
+ getWorkload(run: AgentRunResource): Promise<AgentWorkloadResource | null>;
1570
+ getClaim(name: string, namespace?: string): Promise<AgentVolumeClaimResource | null>;
1571
+ getVolume(claim: AgentVolumeClaimResource): Promise<AgentVolumeResource | null>;
1572
+ getDriver(name: string): Promise<StorageDriver | undefined>;
1573
+ managed?: {
1574
+ getDriver(name: string): Promise<StorageManagementDriver | undefined>;
1575
+ createStageRequest(input: {
1576
+ run: AgentRunResource;
1577
+ volume: AgentVolumeResource;
1578
+ nodeId: string;
1579
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
1580
+ leaseEpoch: string;
1581
+ }): Promise<DriverRequestEnvelope<{
1582
+ volumeHandle: string;
1583
+ nodeId: string;
1584
+ }>>;
1585
+ createPublishRequest(input: {
1586
+ run: AgentRunResource;
1587
+ stageHandle: string;
1588
+ workloadUid: string;
1589
+ readOnly: boolean;
1590
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
1591
+ leaseEpoch: string;
1592
+ }): Promise<DriverRequestEnvelope<{
1593
+ stageHandle: string;
1594
+ workloadUid: string;
1595
+ readOnly: boolean;
1596
+ }>>;
1597
+ createUnpublishRequest(input: {
1598
+ run: AgentRunResource;
1599
+ publishHandle: string;
1600
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
1601
+ leaseEpoch: string;
1602
+ }): Promise<DriverRequestEnvelope<{
1603
+ publishHandle: string;
1604
+ }>>;
1605
+ createUnstageRequest(input: {
1606
+ run: AgentRunResource;
1607
+ stageHandle: string;
1608
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
1609
+ leaseEpoch: string;
1610
+ }): Promise<DriverRequestEnvelope<{
1611
+ stageHandle: string;
1612
+ }>>;
1613
+ };
1614
+ recordPublished?(volume: AgentVolumeResource, workload: AgentWorkloadResource, nodeId: string): Promise<void>;
1615
+ recordUnpublished?(volume: AgentVolumeResource, workload: AgentWorkloadResource, nodeId: string): Promise<void>;
1616
+ now?: () => Date;
1617
+ }
1618
+ /** Publishes independently provisioned claims to a bound Run's workload node. */
1619
+ declare function createRunVolumeController(options: RunVolumeControllerOptions): Controller<AgentRunResource['spec']>;
1620
+
1621
+ interface SchedulerNode {
1622
+ name: string;
1623
+ trustClass: NodeTrustClass;
1624
+ faultDomain: string;
1625
+ /** Explicit false removes the node from scheduling immediately. */
1626
+ healthy?: boolean;
1627
+ /** When reported, the node must include `worker` to accept workloads. */
1628
+ roles?: string[];
1629
+ /** Trusted verifier assessment, never a worker self-report. */
1630
+ attested?: boolean;
1631
+ /** Host registry confirms every selected driver has passing conformance evidence. */
1632
+ driverConformancePassed?: boolean;
1633
+ capacity?: {
1634
+ cpuMillicores?: number;
1635
+ memoryBytes?: number;
1636
+ gpuCount?: number;
1637
+ diskBytes?: number;
1638
+ bandwidthKbps?: number;
1639
+ };
1640
+ labels?: Record<string, string>;
1641
+ /** Taints that repel workloads unless they explicitly tolerate them. */
1642
+ taints?: string[];
1643
+ /**
1644
+ * Maximum data classification this node is allowed to process.
1645
+ * Defaults to 'restricted' for trusted, 'internal' for restricted, 'public' for quarantine.
1646
+ */
1647
+ maxDataClassification?: DataClassification;
1648
+ /** Residency labels in which this node may process data. */
1649
+ dataResidency?: string[];
1650
+ /** Runtime classes backed by an admitted runtime driver on this node. */
1651
+ availableRuntimeClasses?: string[];
1652
+ /** Healthy tool executor classes available on this node. */
1653
+ availableToolClasses?: string[];
1654
+ /** Available model endpoints on this node (by model class name). */
1655
+ availableModelClasses?: string[];
1656
+ /** Network classes and the boundary/egress modes they can enforce. */
1657
+ networkCapabilities?: Array<{
1658
+ networkClass: string;
1659
+ enforcementLevel: 'none' | 'process' | 'namespace' | 'host' | 'external';
1660
+ egress?: Array<'none' | 'same-node' | 'restricted' | 'open'>;
1661
+ }>;
1662
+ /** Storage classes provisionable or publishable on this node. */
1663
+ availableStorageClasses?: string[];
1664
+ /** Existing claims local/publishable to this node. */
1665
+ availableVolumeClaims?: string[];
1666
+ /** Credential broker capabilities; these are policy metadata, never handles. */
1667
+ credentialCapabilities?: Array<{
1668
+ brokerClass: string;
1669
+ audiences?: string[];
1670
+ targets?: string[];
1671
+ }>;
1672
+ /** Content-addressed data already present on this node, used only for scoring. */
1673
+ localArtifactReferences?: string[];
1674
+ localCheckpointReferences?: string[];
1675
+ /** Active target count for each rollout batch on this fault domain. */
1676
+ rolloutLoad?: Record<string, number>;
1677
+ /** Spare concurrency slots. */
1678
+ spareConcurrency?: number;
1679
+ }
1680
+ interface SchedulingDecision {
1681
+ nodeName: string;
1682
+ score: number;
1683
+ reasons: string[];
1684
+ }
1685
+ interface Scheduler {
1686
+ schedule(workload: AgentWorkloadResource, nodes: SchedulerNode[]): SchedulingDecision | null;
1687
+ }
1688
+ interface BindingControllerOptions {
1689
+ actor: ControlStoreActor;
1690
+ scheduler: Scheduler;
1691
+ listNodes: () => Promise<SchedulerNode[]>;
1692
+ authorizePlacement?(input: {
1693
+ workload: AgentWorkloadResource;
1694
+ node: SchedulerNode;
1695
+ actor: ControlStoreActor;
1696
+ leaseEpoch: string;
1697
+ }): Promise<{
1698
+ outcome: 'allow' | 'deny';
1699
+ decisionHandle: string;
1700
+ policyDigest: string;
1701
+ reasons: string[];
1702
+ }>;
1703
+ }
1704
+ /**
1705
+ * Create a controller that binds AgentWorkloads to Nodes.
1706
+ *
1707
+ * The controller watches AgentWorkloads in Pending phase, runs the scheduler
1708
+ * to select a node, and updates the workload status with the binding through
1709
+ * ControlStore CAS. The lease epoch is included in the status update for
1710
+ * fencing.
1711
+ *
1712
+ * Per §7.2 and §23, restricted nodes are the preferred fleet-worker class and
1713
+ * are allowed for ordinary worker workloads. Only quarantine-designated
1714
+ * workloads may run on quarantine nodes.
1715
+ */
1716
+ declare function createBindingController(_store: ControlStore, options: BindingControllerOptions): Controller<AgentWorkloadResource['spec']>;
1717
+ /**
1718
+ * Capacity scheduler with trust, data-classification, taint/toleration,
1719
+ * model-capability, and anti-affinity filters.
1720
+ *
1721
+ * Trust filtering (§7.2, §23):
1722
+ * - Restricted nodes are allowed for ordinary/restricted workloads.
1723
+ * - Quarantine nodes are only candidates for quarantine-designated workloads.
1724
+ * - Trusted nodes are always eligible (unless filtered by other criteria).
1725
+ *
1726
+ * Data classification filtering:
1727
+ * - Workloads with sensitive data are not scheduled on nodes whose
1728
+ * `maxDataClassification` is lower than the workload's classification.
1729
+ * - Quarantine nodes default to `public`-only.
1730
+ *
1731
+ * Scoring favors trusted nodes, higher capacity, and data locality.
1732
+ */
1733
+ declare function createCapacityScheduler(): Scheduler;
1734
+
1735
+ /**
1736
+ * Enforce AuditRecord append-only semantics in the protected ControlStore
1737
+ * write transaction. Only the actor stamped into immutable evidence may
1738
+ * create it; no status, apply, delete, or resource lease mutation is valid.
1739
+ */
1740
+ declare function createAuditRecordAuthorizer(): (request: ControlStoreAuthorizationRequest) => void;
1741
+
1742
+ type IdentityRevocationReason = 'security-incident' | 'credential-rotation' | 'policy-violation' | 'manual';
1743
+ interface IdentityRevocationRecord {
1744
+ enrollmentName: string;
1745
+ sessionNames: string[];
1746
+ reason: IdentityRevocationReason;
1747
+ revokedBy: string;
1748
+ revokedAt: string;
1749
+ evidence?: string;
1750
+ }
1751
+ interface IdentityPromotionRequest {
1752
+ /** The quarantine enrollment to promote from. */
1753
+ sourceEnrollmentName: string;
1754
+ /** New trust class for the promoted identity. */
1755
+ targetTrustClass: 'trusted' | 'restricted';
1756
+ /** Evidence from trusted verification (e.g. reimage attestation). */
1757
+ verificationEvidence: string;
1758
+ /** Verifier actor ID that performed the verification. */
1759
+ verifiedBy: string;
1760
+ /** Approval actor ID that authorized the promotion. */
1761
+ approvedBy: string;
1762
+ }
1763
+ /**
1764
+ * Permanently revoke a quarantine identity and all its sessions.
1765
+ * Once revoked, the identity cannot be re-enabled; promotion requires
1766
+ * creating a new enrollment through trusted verification.
1767
+ */
1768
+ declare function revokeQuarantineIdentity(store: ControlStore, actor: ControlStoreActor, enrollmentName: string, reason: IdentityRevocationReason, evidence?: string, now?: () => Date): Promise<IdentityRevocationRecord>;
1769
+ /**
1770
+ * Promote a quarantine identity to a new ordinary identity after trusted
1771
+ * verification. The old quarantine enrollment is permanently revoked, and a
1772
+ * new enrollment is created with the target trust class.
1773
+ */
1774
+ declare function promoteIdentity(store: ControlStore, actor: ControlStoreActor, request: IdentityPromotionRequest, now?: () => Date): Promise<WorkerEnrollmentResource>;
1775
+ /**
1776
+ * Check whether an identity is permanently revoked.
1777
+ */
1778
+ declare function isIdentityRevoked(store: ControlStore, enrollmentName: string): Promise<boolean>;
1779
+
1780
+ declare const NODE_API_VERSION = "memeloop/v1";
1781
+ declare const NODE_KIND = "Node";
1782
+ interface NodeSpec {
1783
+ nodeId: string;
1784
+ faultDomain: string;
1785
+ capacity?: {
1786
+ cpuMillicores?: number;
1787
+ memoryBytes?: number;
1788
+ gpuCount?: number;
1789
+ };
1790
+ labels?: Record<string, string>;
1791
+ }
1792
+ interface NodeStatus {
1793
+ trustClass: NodeTrustClass;
1794
+ trustEvidence?: string;
1795
+ trustVerifiedBy?: string;
1796
+ trustVerifiedAt?: string;
1797
+ conditions?: Array<{
1798
+ type: string;
1799
+ status: 'True' | 'False' | 'Unknown';
1800
+ reason: string;
1801
+ lastTransitionTime: string;
1802
+ }>;
1803
+ }
1804
+ /**
1805
+ * Create a ControlStore authorizer that enforces immutable Node trust admission.
1806
+ *
1807
+ * Rules:
1808
+ * 1. Node trustClass can only be set at creation time in spec.
1809
+ * 2. After creation, trustClass can only be changed by a verifier actor
1810
+ * providing signed evidence, and only through status updates.
1811
+ * 3. A node cannot modify its own trustClass.
1812
+ * 4. Restricted/quarantine nodes cannot acquire leases for forbidden roles.
1813
+ * 5. Any attempt to use a self-report or label update to change trustClass
1814
+ * is rejected.
1815
+ */
1816
+ declare function createNodeTrustAuthorizer(): (request: ControlStoreAuthorizationRequest) => void;
1817
+ /**
1818
+ * Validate that a Node resource's spec does not attempt to self-assert
1819
+ * trust status through labels or annotations.
1820
+ */
1821
+ declare function validateNodeSpec(spec: NodeSpec): void;
1822
+ /**
1823
+ * Check whether a node with the given trust class is allowed to perform
1824
+ * a sensitive role. This is a pure function for use by schedulers and
1825
+ * admission controllers outside the ControlStore authorizer.
1826
+ */
1827
+ declare function isNodeAllowedForRole(trustClass: NodeTrustClass, role: string): boolean;
1828
+
1829
+ /**
1830
+ * Protect durable PolicyDecision evidence in the same ControlStore
1831
+ * transaction as its write. Decisions are create-only; only an authenticated
1832
+ * admin may resolve the status of a pending approval.
1833
+ */
1834
+ declare function createPolicyDecisionAuthorizer(): (request: ControlStoreAuthorizationRequest) => void;
1835
+
1836
+ /**
1837
+ * Quarantine gateway request mediation (plan 24.40).
1838
+ *
1839
+ * All checks run on the trusted gateway side, outside worker control. The
1840
+ * gateway is the worker's only network endpoint — it never receives ordinary
1841
+ * peer topology, sync, or device-directory access through this channel. Every
1842
+ * outbound request is validated for method, scheme, port, host allowlist,
1843
+ * SSRF (literal and DNS-resolved private addresses), redirect targets, body
1844
+ * size, per-method limits, and per-worker rate limits; revoked workers are
1845
+ * rejected before any validation.
1846
+ */
1847
+ interface QuarantineGatewayPolicy {
1848
+ /** Allowed HTTP methods (default GET/HEAD/POST). */
1849
+ allowedMethods?: string[];
1850
+ /** Allowed URL schemes (default ['https']). */
1851
+ allowedSchemes?: string[];
1852
+ /** Allowed ports (default [443]). */
1853
+ allowedPorts?: number[];
1854
+ /** Hostname suffix allowlist; when set, only matching hosts pass. */
1855
+ allowedHosts?: string[];
1856
+ /** Allow private/loopback/link-local targets (default false — SSRF blocked). */
1857
+ allowPrivateNetworks?: boolean;
1858
+ /** Maximum followed redirects, each re-validated (default 0). */
1859
+ maxRedirects?: number;
1860
+ /** Global request body cap in bytes (default 1 MiB). */
1861
+ maxBodyBytes?: number;
1862
+ /** Per-method overrides. */
1863
+ methodLimits?: Record<string, {
1864
+ maxBodyBytes?: number;
1865
+ requestsPerMinute?: number;
1866
+ }>;
1867
+ /** Default per-worker+method rate limit (default 60/minute). */
1868
+ defaultRateLimitPerMinute?: number;
1869
+ /** Response body cap in bytes for the executor (default 8 MiB). */
1870
+ maxResponseBytes?: number;
1871
+ }
1872
+ interface GatewayHttpRequest {
1873
+ workerId: string;
1874
+ method: string;
1875
+ url: string;
1876
+ /** Declared request body size in bytes (0/undefined for bodyless). */
1877
+ bodyBytes?: number;
1878
+ }
1879
+ interface GatewayValidationContext {
1880
+ /** Injected DNS resolver returning IP literals for a hostname. */
1881
+ resolveHostname?: (hostname: string) => Promise<string[]>;
1882
+ /** Trusted revocation check for worker sessions. */
1883
+ isRevoked?: (workerId: string) => boolean;
1884
+ /** Rate limiter state; one shared limiter per gateway. */
1885
+ rateLimiter?: GatewayRateLimiter;
1886
+ now?: () => number;
1887
+ }
1888
+ type GatewayValidationResult = {
1889
+ ok: true;
1890
+ normalizedUrl: string;
1891
+ hostname: string;
1892
+ addresses: string[];
1893
+ } | {
1894
+ ok: false;
1895
+ error: OrchestrationErrorData;
1896
+ };
1897
+ /** True when the IP literal is loopback, private, link-local, or otherwise non-public. */
1898
+ declare function isPrivateIp(address: string): boolean;
1899
+ interface GatewayRateLimiter {
1900
+ /** True when the request is within budget; false when limited. */
1901
+ consume(key: string, perMinute: number): boolean;
1902
+ }
1903
+ /** Token-bucket rate limiter with an injectable clock (trusted-side state). */
1904
+ declare function createGatewayRateLimiter(now?: () => number): GatewayRateLimiter;
1905
+ /** Revocation list for quarantine worker sessions (trusted-side state). */
1906
+ declare function createWorkerRevocationList(): {
1907
+ revoke(workerId: string): void;
1908
+ isRevoked(workerId: string): boolean;
1909
+ };
1910
+ /**
1911
+ * Validate one gateway request. Order matters: revocation first, then cheap
1912
+ * syntactic checks, then SSRF (literal before DNS), then rate limits, so a
1913
+ * revoked or malformed request never costs a DNS lookup.
1914
+ */
1915
+ declare function validateGatewayRequest(request: GatewayHttpRequest, policy: QuarantineGatewayPolicy, context?: GatewayValidationContext): Promise<GatewayValidationResult>;
1916
+ /** Validate a redirect target with the same policy; redirect chains are bounded by the caller. */
1917
+ declare function validateRedirectTarget(request: Omit<GatewayHttpRequest, 'method' | 'bodyBytes'> & {
1918
+ method?: string;
1919
+ }, location: string, policy: QuarantineGatewayPolicy, context?: GatewayValidationContext): Promise<GatewayValidationResult>;
1920
+
1921
+ /**
1922
+ * Secret redaction for logs, status, checkpoints, and crash diagnostics.
1923
+ *
1924
+ * Hosts must run any value through `redactSecrets` before it crosses into
1925
+ * persistent or observable surfaces. Redaction covers both secret-shaped keys
1926
+ * (apiKey, authorization, ...) and secret-shaped values (provider key formats,
1927
+ * model access handles). Redaction is best-effort defense in depth — the
1928
+ * primary guarantee comes from never passing secrets to untrusted contexts in
1929
+ * the first place.
1930
+ */
1931
+ interface SecretRedactionOptions {
1932
+ /** Extra key-name patterns treated as secret. */
1933
+ additionalKeyPatterns?: RegExp[];
1934
+ /** Extra value patterns treated as secret. */
1935
+ additionalValuePatterns?: RegExp[];
1936
+ /** Replacement text (default `[REDACTED]`). */
1937
+ replacement?: string;
1938
+ }
1939
+ /**
1940
+ * Deep-clone `value` with secrets masked. Secret-shaped keys are replaced
1941
+ * wholesale; strings are scanned for secret-shaped values. Handles Map/Set
1942
+ * via their entries; class instances are traversed as plain objects.
1943
+ */
1944
+ declare function redactSecrets<T>(value: T, options?: SecretRedactionOptions): T;
1945
+ /**
1946
+ * True when the value contains a secret-shaped key or value. Useful as a
1947
+ * final assertion before persisting worker-visible artifacts.
1948
+ */
1949
+ declare function containsSecrets(value: unknown, options?: SecretRedactionOptions): boolean;
1950
+
1951
+ declare const WORKLOAD_CAPABILITY_GRANT_API_VERSION = "security.memeloop.io/v1alpha1";
1952
+ declare const WORKLOAD_CAPABILITY_GRANT_KIND = "WorkloadCapabilityGrant";
1953
+ interface WorkloadCapabilityBudget {
1954
+ maxRequests: number;
1955
+ maxInputBytes?: number;
1956
+ maxOutputBytes?: number;
1957
+ maxTokens?: number;
1958
+ maxCost?: number;
1959
+ }
1960
+ interface WorkloadCapabilityGrantSpec {
1961
+ /** Stable identity included in the signed claims; must equal metadata.name. */
1962
+ grantId: string;
1963
+ sessionRef: {
1964
+ apiVersion: string;
1965
+ kind: 'WorkerSession';
1966
+ name: string;
1967
+ };
1968
+ run: WorkerRunBinding;
1969
+ workerKeyFingerprint: string;
1970
+ /** Pinned gateway/channel identity, never a worker-provided label. */
1971
+ channelBinding: string;
1972
+ audience: string;
1973
+ protocol: string;
1974
+ protocolMethod: WorkerProtocolMethod;
1975
+ capability: string;
1976
+ target: string;
1977
+ policyDigest: string;
1978
+ budget: WorkloadCapabilityBudget;
1979
+ issuedAt: string;
1980
+ expiresAt: string;
1981
+ issuedBy: string;
1982
+ /** Gateway signature over canonicalWorkloadCapabilityGrantBytes(spec). */
1983
+ signature: string;
1984
+ }
1985
+ interface WorkloadCapabilityGrantStatus extends OrchestrationResourceStatus {
1986
+ phase?: 'Authorized' | 'Consumed' | 'Revoked' | 'Expired' | 'Failed';
1987
+ consumedAt?: string;
1988
+ revokedAt?: string;
1989
+ reason?: string;
1990
+ }
1991
+ type WorkloadCapabilityGrantResource = Omit<OrchestrationResource<WorkloadCapabilityGrantSpec>, 'status'> & {
1992
+ status?: WorkloadCapabilityGrantStatus;
1993
+ };
1994
+ interface IssueWorkloadCapabilityGrantRequest {
1995
+ grantId: string;
1996
+ session: WorkerGatewaySession;
1997
+ channelBinding: string;
1998
+ protocolMethod: WorkerProtocolMethod;
1999
+ capability: string;
2000
+ target: string;
2001
+ budget: WorkloadCapabilityBudget;
2002
+ ttlMs: number;
2003
+ }
2004
+ interface WorkloadCapabilityGrantRequirements {
2005
+ grantId: string;
2006
+ sessionName: string;
2007
+ run: WorkerRunBinding;
2008
+ workerKeyFingerprint: string;
2009
+ channelBinding: string;
2010
+ audience: string;
2011
+ protocol: string;
2012
+ protocolMethod: WorkerProtocolMethod;
2013
+ capability: string;
2014
+ target: string;
2015
+ policyDigest: string;
2016
+ }
2017
+ declare function canonicalWorkloadCapabilityGrantBytes(spec: WorkloadCapabilityGrantSpec | Omit<WorkloadCapabilityGrantSpec, 'signature'>): Uint8Array;
2018
+ declare function createWorkloadCapabilityGrantManifest(name: string, spec: WorkloadCapabilityGrantSpec): {
2019
+ apiVersion: typeof WORKLOAD_CAPABILITY_GRANT_API_VERSION;
2020
+ kind: typeof WORKLOAD_CAPABILITY_GRANT_KIND;
2021
+ metadata: {
2022
+ name: string;
2023
+ };
2024
+ spec: WorkloadCapabilityGrantSpec;
2025
+ };
2026
+ declare function isWorkloadCapabilityGrant(resource: {
2027
+ apiVersion?: string;
2028
+ kind?: string;
2029
+ }): resource is WorkloadCapabilityGrantResource;
2030
+ /** Issue and durably record one host-authorized capability grant. */
2031
+ declare function issueWorkloadCapabilityGrant(store: ControlStore, actor: ControlStoreActor, request: IssueWorkloadCapabilityGrantRequest, sign: (message: Uint8Array) => Promise<string> | string, now?: () => Date): Promise<WorkloadCapabilityGrantResource>;
2032
+ /** Verify signature, expiry, lifecycle, and every authority-bearing claim. */
2033
+ declare function verifyWorkloadCapabilityGrant(grant: WorkloadCapabilityGrantResource, requirements: WorkloadCapabilityGrantRequirements, verify: (message: Uint8Array, signature: string) => Promise<boolean> | boolean, now?: () => Date): Promise<void>;
2034
+ /** Atomically consume a single-use grant before invoking the capability. */
2035
+ declare function consumeWorkloadCapabilityGrant(store: ControlStore, actor: ControlStoreActor, grant: WorkloadCapabilityGrantResource, now?: () => Date): Promise<WorkloadCapabilityGrantResource>;
2036
+
2037
+ interface QuorumMember {
2038
+ id: string;
2039
+ peerUrls: string[];
2040
+ isLearner: boolean;
2041
+ }
2042
+ interface QuorumTopology {
2043
+ members: QuorumMember[];
2044
+ leaderId?: string;
2045
+ term: number;
2046
+ }
2047
+ /**
2048
+ * Serializable point-in-time state of a QuorumControlStore. Portable core
2049
+ * cannot write files, so persistence flows through `exportSnapshot()` /
2050
+ * `restoreSnapshot()`; the host decides where bytes live. Live leases and
2051
+ * their timers are ephemeral and intentionally excluded; per-name fencing
2052
+ * epochs are preserved so a restored store never re-issues epoch 1.
2053
+ */
2054
+ interface QuorumControlStoreSnapshot {
2055
+ revision: number;
2056
+ compactedRevision?: number;
2057
+ term: number;
2058
+ voters: string[];
2059
+ learners: string[];
2060
+ quorumSize: number;
2061
+ leaseEpochs: Record<string, number>;
2062
+ resources: Array<{
2063
+ key: string;
2064
+ resource: OrchestrationResource;
2065
+ revision: number;
2066
+ deleted: boolean;
2067
+ }>;
2068
+ idempotency?: Array<{
2069
+ key: string;
2070
+ requestDigest: string;
2071
+ response: unknown;
2072
+ }>;
2073
+ watchEvents?: Array<{
2074
+ key: string;
2075
+ event: OrchestrationResourceWatchEvent;
2076
+ }>;
2077
+ createdAt: string;
2078
+ }
2079
+ interface QuorumControlStoreOptions {
2080
+ memberId: string;
2081
+ isLearner?: boolean;
2082
+ authorizer?: ControlStoreAuthorizer;
2083
+ quorumSize?: number;
2084
+ voters?: string[];
2085
+ /** Retained resumable resource events before automatic compaction. */
2086
+ maxWatchEvents?: number;
2087
+ }
2088
+ /**
2089
+ * In-process quorum ControlStore (plan 24.59).
2090
+ *
2091
+ * Implements full ControlStore semantics: multi-voter consensus, learner
2092
+ * replication, CAS updates, lease management with epochs, watch subscriptions
2093
+ * with revision tracking, compaction, and snapshot. Loss-of-quorum writes
2094
+ * are rejected with UNAVAILABLE.
2095
+ *
2096
+ * A production etcd-backed adapter is planned as a separate package.
2097
+ */
2098
+ declare class QuorumControlStore implements ControlStore {
2099
+ private isLearner;
2100
+ private readonly authorizer?;
2101
+ private quorumSize;
2102
+ private readonly voters;
2103
+ private readonly learners;
2104
+ private readonly memberId;
2105
+ private readonly data;
2106
+ private readonly idempotency;
2107
+ private revision;
2108
+ private readonly leases;
2109
+ /** Monotonic fencing epoch per lease name; survives release/expiry and restore. */
2110
+ private readonly leaseEpochs;
2111
+ private readonly watchers;
2112
+ private watcherIdSeq;
2113
+ private readonly watchHistory;
2114
+ private compactedRevision;
2115
+ private readonly maxWatchEvents;
2116
+ private readonly leaseTimers;
2117
+ private closed;
2118
+ private term;
2119
+ constructor(options: QuorumControlStoreOptions);
2120
+ private nextRevision;
2121
+ private manifestKey;
2122
+ private refKey;
2123
+ private queryPrefix;
2124
+ private matchQuery;
2125
+ private checkQuorum;
2126
+ private notify;
2127
+ get<TSpec, TStatus>(reference: OrchestrationResourceReference): Promise<OrchestrationResource<TSpec, TStatus> | null>;
2128
+ list<TSpec, TStatus>(query: OrchestrationResourceQuery): Promise<OrchestrationResourceList<TSpec, TStatus>>;
2129
+ watch<TSpec, TStatus>(query: OrchestrationResourceQuery, options?: OrchestrationWatchOptions): AsyncIterable<OrchestrationWatchEvent<TSpec, TStatus>>;
2130
+ create<TSpec, TStatus>(actor: ControlStoreActor, resource: OrchestrationResourceManifest<TSpec>, options?: ControlStoreCreateOptions): Promise<OrchestrationResource<TSpec, TStatus>>;
2131
+ apply<TSpec, TStatus>(actor: ControlStoreActor, resource: OrchestrationResourceManifest<TSpec>, options?: ControlStoreApplyOptions): Promise<OrchestrationResource<TSpec, TStatus>>;
2132
+ updateStatus<TSpec, TStatus>(actor: ControlStoreActor, reference: OrchestrationResourceReference, status: TStatus, options: ControlStoreStatusUpdateOptions): Promise<OrchestrationResource<TSpec, TStatus>>;
2133
+ delete(actor: ControlStoreActor, reference: OrchestrationResourceReference, options?: OrchestrationDeleteOptions): Promise<OrchestrationDeleteResult>;
2134
+ acquireLease(actor: ControlStoreActor, request: ControlLeaseRequest): Promise<ControlLeaseGrant>;
2135
+ renewLease(actor: ControlStoreActor, id: ControlLeaseIdentity, ttlMs: number): Promise<ControlLeaseGrant>;
2136
+ releaseLease(actor: ControlStoreActor, id: ControlLeaseIdentity): Promise<void>;
2137
+ compact(throughResourceVersion: string): Promise<ControlStoreCompactionResult>;
2138
+ snapshot(_targetPath: string): Promise<ControlStoreSnapshotResult>;
2139
+ /** Serialize the full store state. Excludes live leases/timers; preserves fencing epochs. */
2140
+ exportSnapshot(): QuorumControlStoreSnapshot;
2141
+ /** Replace the store state with a snapshot previously produced by exportSnapshot(). */
2142
+ restoreSnapshot(snapshot: QuorumControlStoreSnapshot): void;
2143
+ getHealth(): Promise<ControlStoreHealth>;
2144
+ close(): Promise<void>;
2145
+ getTopology(): Promise<QuorumTopology>;
2146
+ /** Recompute quorum as a majority of the current voter set (etcd semantics). */
2147
+ private recomputeQuorum;
2148
+ private leaseReference;
2149
+ addVoter(m: QuorumMember): Promise<void>;
2150
+ removeVoter(id: string): Promise<void>;
2151
+ /**
2152
+ * Add an observer that receives no vote and does not count toward quorum
2153
+ * (§17.3: a second node starts as observer, never a fragile two-voter
2154
+ * configuration; promotion is an explicit later step).
2155
+ */
2156
+ addLearner(m: QuorumMember): Promise<void>;
2157
+ removeLearner(id: string): Promise<void>;
2158
+ promoteLearner(id: string): Promise<void>;
2159
+ private expireLease;
2160
+ private clearLeaseTimer;
2161
+ }
2162
+
2163
+ interface ToolExecutorSelection {
2164
+ executor: ToolExecutorResource;
2165
+ nodeId: string;
2166
+ score: number;
2167
+ reasons: string[];
2168
+ }
2169
+ /** Select a healthy, schema-compatible executor without loading its implementation. */
2170
+ declare function selectToolExecutor(operation: ToolOperationResource, executors: ToolExecutorResource[]): ToolExecutorSelection | null;
2171
+ interface ToolOperationBindingControllerOptions {
2172
+ actor: ControlStoreActor;
2173
+ listExecutors: () => Promise<ToolExecutorResource[]>;
2174
+ retryAfterMs?: number;
2175
+ }
2176
+ /**
2177
+ * Independently bind pending ToolOperations to declarative ToolExecutors.
2178
+ * Explicit external-orchestrator operations remain owned by that controller.
2179
+ */
2180
+ declare function createToolOperationBindingController(options: ToolOperationBindingControllerOptions): Controller<ToolOperationResource['spec']>;
2181
+ interface ToolOperationExecutionControllerOptions {
2182
+ actor: ControlStoreActor;
2183
+ nodeId: string;
2184
+ driver: ToolExecutionDriver;
2185
+ }
2186
+ interface ToolOperationExecutionController extends Controller<ToolOperationResource['spec']> {
2187
+ /** Cooperatively abort one currently executing operation. */
2188
+ cancel(operation: Pick<ToolOperationResource, 'metadata'>): boolean;
2189
+ /** Abort all local effects during runtime shutdown. */
2190
+ cancelAll(): number;
2191
+ /** Diagnostic count only; no operation inputs/results are exposed. */
2192
+ activeCount(): number;
2193
+ }
2194
+ /**
2195
+ * Execute operations assigned to one node. Claiming and effect execution are
2196
+ * deliberately separate reconciles so the claim is durable before any side
2197
+ * effect starts.
2198
+ */
2199
+ declare function createToolOperationExecutionController(options: ToolOperationExecutionControllerOptions): ToolOperationExecutionController;
2200
+
2201
+ interface StorageDriverEndpoint {
2202
+ nodeId: string;
2203
+ healthy: boolean;
2204
+ capabilities: StorageDriverCapabilities[];
2205
+ trust: NodeTrustClass;
2206
+ labels?: Record<string, string>;
2207
+ activeVolumes?: number;
2208
+ maxVolumes?: number;
2209
+ availableBytes?: number;
2210
+ }
2211
+ interface VolumeClaimBindingControllerOptions {
2212
+ getStorageClass(claim: AgentVolumeClaimResource): Promise<StorageClassResource | null>;
2213
+ listDrivers(): Promise<StorageDriverEndpoint[]>;
2214
+ requiredNodeForClaim?(claim: AgentVolumeClaimResource): Promise<string | undefined>;
2215
+ now?: () => Date;
2216
+ }
2217
+ /** Independently binds a claim to a healthy provisioner endpoint. */
2218
+ declare function createVolumeClaimBindingController(options: VolumeClaimBindingControllerOptions): Controller<AgentVolumeClaimResource['spec']>;
2219
+ interface VolumeClaimExecutionControllerOptions {
2220
+ nodeId: string;
2221
+ getStorageClass(claim: AgentVolumeClaimResource): Promise<StorageClassResource | null>;
2222
+ getDriver(name: string): Promise<StorageDriver | undefined>;
2223
+ managed?: {
2224
+ getDriver(name: string): Promise<StorageManagementDriver | undefined>;
2225
+ createProvisionRequest(input: {
2226
+ claim: AgentVolumeClaimResource;
2227
+ storageClass: StorageClassResource;
2228
+ actor: Parameters<Controller['reconcile']>[0]['actor'];
2229
+ leaseEpoch: string;
2230
+ }): Promise<DriverRequestEnvelope<StorageProvisionPayload>>;
2231
+ };
2232
+ ensureVolume(claim: AgentVolumeClaimResource, storageClass: StorageClassResource, provisioned: StorageProvisionResult): Promise<AgentVolumeResource>;
2233
+ now?: () => Date;
2234
+ }
2235
+ /** Persists a fencing claim before idempotent volume provisioning. */
2236
+ declare function createVolumeClaimExecutionController(options: VolumeClaimExecutionControllerOptions): Controller<AgentVolumeClaimResource['spec']>;
2237
+
2238
+ /**
2239
+ * Workload execution controller (Phase 4.2 / plan 24.14).
2240
+ *
2241
+ * Watches AgentWorkloads, and for each one the binding controller (24.56)
2242
+ * has scheduled onto THIS node (`status.phase === 'Scheduling'` with
2243
+ * `status.assignedNode === nodeId`), creates an AgentRun and executes it
2244
+ * through the injected LoopRuntimeDriver. Terminal outcomes are written to
2245
+ * both the run and the workload. Deleting a running workload cancels its
2246
+ * execution. Executions on other nodes are ignored — remote nodes run their
2247
+ * own controller instance.
2248
+ */
2249
+ interface WorkloadExecutionControllerOptions {
2250
+ /** Host-bound actor identity for all ControlStore writes. */
2251
+ actor: ControlStoreActor;
2252
+ /** Only execute workloads bound to this node name. */
2253
+ nodeId: string;
2254
+ /** Stable only for this daemon lifetime; changes after restart. */
2255
+ controllerInstanceId?: string;
2256
+ /** Resolve a `spec.scriptReference` (content digest) to admitted source. */
2257
+ resolveScriptSource?: (scriptReference: string) => Promise<string | undefined>;
2258
+ /** Message delivered to the loop (default: workload name). */
2259
+ messageForWorkload?: (workload: AgentWorkloadResource) => string;
2260
+ /** CAS attempts per status write (default 3). */
2261
+ statusWriteAttempts?: number;
2262
+ /** Maximum wait for an independently scheduled ModelEndpoint (default 30s). */
2263
+ modelBindingTimeoutMs?: number;
2264
+ /** Maximum wait for an independently prepared NetworkAttachment (default 30s). */
2265
+ networkAttachmentTimeoutMs?: number;
2266
+ /** Maximum wait for independently published volumes (default 30s). */
2267
+ volumeBindingTimeoutMs?: number;
2268
+ /** Resolve publish handles into ephemeral host mount paths. */
2269
+ resolveVolumeMounts?: (workload: AgentWorkloadResource, run: AgentRunResource) => Promise<NonNullable<LoopRunStartRequest['volumeMounts']>>;
2270
+ /** Poll interval while waiting for model binding (default 25ms). */
2271
+ dependencyPollIntervalMs?: number;
2272
+ /** Revalidate selected endpoint heartbeat age before launch (default 90s). */
2273
+ modelEndpointHeartbeatTtlMs?: number;
2274
+ /** Injectable sleep for watch-retry backoff in tests. */
2275
+ sleep?: (ms: number) => Promise<void>;
2276
+ /** Observes swallowed errors; the controller keeps watching regardless. */
2277
+ onError?: (error: unknown) => void;
2278
+ }
2279
+ interface WorkloadExecutionControllerHandle {
2280
+ stop(): Promise<void>;
2281
+ }
2282
+ declare function createWorkloadExecutionController(store: ControlStore, driver: LoopRuntimeDriver, options: WorkloadExecutionControllerOptions): WorkloadExecutionControllerHandle;
2283
+
2284
+ declare const LOOP_CHECKPOINT_API_VERSION = "loops.memeloop.io/v1alpha1";
2285
+ declare const LOOP_CHECKPOINT_KIND = "LoopCheckpoint";
2286
+ interface LoopCheckpointSpec {
2287
+ conversationId: string;
2288
+ key: string;
2289
+ result: unknown;
2290
+ /** SHA-256 hex digest of the serialised result. Verified on load. */
2291
+ digest: string;
2292
+ createdAt: string;
2293
+ }
2294
+ type LoopCheckpointResource = OrchestrationResource<LoopCheckpointSpec>;
2295
+ declare function createControlStoreLoopCheckpointStore(store: ControlStore, actor: ControlStoreActor, now?: () => Date): LoopScriptCheckpointStore;
2296
+
2297
+ /**
2298
+ * TiddlyWiki HTTP storage driver (plan 24.44).
2299
+ *
2300
+ * Portable: depends only on an injectable `fetch` (browser and Node 18+).
2301
+ * Every tiddler write is a compare-and-swap: the driver reads the current
2302
+ * ETag, writes with `If-Match`, and retries a bounded number of times on
2303
+ * 412/409 before failing with CONFLICT. Blobs are stored inline as base64 up
2304
+ * to `maxInlineBlobBytes`; larger payloads are rejected with guidance to use
2305
+ * an external BlobStore, keeping tiddlers small.
2306
+ *
2307
+ * Credentials are materialized per request by a trusted resolver from an
2308
+ * opaque handle. Raw credentials never enter this portable driver.
2309
+ */
2310
+ interface TiddlyWikiCredentialResolver {
2311
+ resolveHeaders(handle: string, request: {
2312
+ url: string;
2313
+ method: string;
2314
+ }): Promise<Record<string, string>>;
2315
+ }
2316
+ interface TiddlyWikiHttpStorageOptions {
2317
+ /** Wiki base URL, e.g. `http://localhost:8080`. */
2318
+ baseUrl: string;
2319
+ /** TiddlyWeb recipe (default `default`). */
2320
+ recipe?: string;
2321
+ /** Injectable fetch implementation. */
2322
+ fetchImpl?: typeof fetch;
2323
+ /** Opaque CredentialGrant handle and trusted materialization port. */
2324
+ credentialHandle?: string;
2325
+ credentialResolver?: TiddlyWikiCredentialResolver;
2326
+ /** Maximum inline blob size in bytes (default 256 KiB). */
2327
+ maxInlineBlobBytes?: number;
2328
+ /** CAS retry budget per write (default 3). */
2329
+ maxCasAttempts?: number;
2330
+ }
2331
+ declare class TiddlyWikiHttpStorage implements FullAgentStorage {
2332
+ private readonly baseUrl;
2333
+ private readonly recipe;
2334
+ private readonly fetchImpl;
2335
+ private readonly credentialHandle?;
2336
+ private readonly credentialResolver?;
2337
+ private readonly maxInlineBlobBytes;
2338
+ private readonly maxCasAttempts;
2339
+ constructor(options: TiddlyWikiHttpStorageOptions);
2340
+ private eventTitle;
2341
+ private metaTitle;
2342
+ private blobTitle;
2343
+ private definitionTitle;
2344
+ private instanceTitle;
2345
+ private imTitle;
2346
+ private tiddlerUrl;
2347
+ private filterUrl;
2348
+ private headers;
2349
+ /** GET a tiddler; returns null on 404. Includes the ETag when the server sends one. */
2350
+ private readTiddler;
2351
+ /** CAS write: If-Match when an ETag is known; bounded retries on 412/409. */
2352
+ private writeTiddler;
2353
+ private listByPrefix;
2354
+ private parsePayload;
2355
+ listConversations(options?: ListConversationsOptions): Promise<ConversationMeta[]>;
2356
+ getMessages(conversationId: string, _options?: GetMessagesOptions): Promise<ChatMessage[]>;
2357
+ appendMessage(message: ChatMessage): Promise<void>;
2358
+ insertMessagesIfAbsent(messages: ChatMessage[]): Promise<void>;
2359
+ getMaxLamportClockForConversation(conversationId: string): Promise<number>;
2360
+ upsertConversationMetadata(meta: ConversationMeta): Promise<void>;
2361
+ getConversationMeta(conversationId: string): Promise<ConversationMeta | null>;
2362
+ saveAttachment(reference: AttachmentReference, data: Uint8Array): Promise<void>;
2363
+ getAttachment(contentHash: string): Promise<AttachmentReference | null>;
2364
+ readAttachmentData(contentHash: string): Promise<Uint8Array | null>;
2365
+ getAgentDefinition(id: string): Promise<AgentDefinition | null>;
2366
+ saveAgentDefinition(definition: AgentDefinition & {
2367
+ id: string;
2368
+ }): Promise<void>;
2369
+ saveAgentInstance(meta: AgentInstanceMeta): Promise<void>;
2370
+ getImBinding(channelId: string, imUserId: string): Promise<IMChannelBinding | null>;
2371
+ setImBinding(record: IMChannelBinding): Promise<void>;
2372
+ }
2373
+
2374
+ /**
2375
+ * Headless agent management contracts.
2376
+ *
2377
+ * Environment-neutral interfaces for managing agent definitions, agent instances,
2378
+ * conversations, prompt previews, and scheduled tasks.
2379
+ *
2380
+ * Designed to be consumed by:
2381
+ * - Desktop (via Electron IPC adapters)
2382
+ * - Cloud (via REST API adapters)
2383
+ * - CLI (via Ink + local or remote adapters)
2384
+ */
2385
+
2386
+ /** Attachment metadata for a wiki tiddler selected in the composer. */
2387
+ interface WikiTiddlerAttachment {
2388
+ workspaceName: string;
2389
+ tiddlerTitle: string;
2390
+ }
2391
+ /** Data passed when a wiki tiddler chip is clicked in a message. */
2392
+ interface WikiTiddlerClickData {
2393
+ workspaceId: string;
2394
+ workspaceName: string;
2395
+ tiddlerTitle: string;
2396
+ renderedContent?: string;
2397
+ }
2398
+ /** Storage contract for agent definition CRUD and template queries. */
2399
+ interface AgentDefinitionRepository {
2400
+ createAgentDef(agent: AgentDefinition): Promise<AgentDefinition>;
2401
+ updateAgentDef(agent: Partial<AgentDefinition> & {
2402
+ id: string;
2403
+ }): Promise<AgentDefinition>;
2404
+ getAgentDefs(): Promise<AgentDefinition[]>;
2405
+ getAgentDef(id?: string): Promise<AgentDefinition | undefined>;
2406
+ getAgentTemplates(): Promise<AgentDefinition[]>;
2407
+ deleteAgentDef(id: string): Promise<void>;
2408
+ }
2409
+ /** Observable agent runtime metadata exposed to the UI layer. */
2410
+ interface AgentRuntimeView {
2411
+ id: string;
2412
+ name: string;
2413
+ agentDefId: string;
2414
+ status: {
2415
+ state: 'idle' | 'working' | 'completed' | 'failed' | 'canceled' | 'input-required';
2416
+ progress?: string;
2417
+ };
2418
+ aiApiConfig?: AgentDefinition['aiApiConfig'];
2419
+ /** If applicable, the agent definition merged with instance overrides. */
2420
+ definition?: AgentDefinition;
2421
+ }
2422
+ /** Subscription callback for agent updates. */
2423
+ type AgentUpdateListener = (update: Partial<AgentRuntimeView>) => void;
2424
+ /** Client contract for creating, controlling, and subscribing to agent instances. */
2425
+ interface AgentInstanceClient {
2426
+ /**
2427
+ * Create a new agent instance from a definition.
2428
+ * @param agentDefinitionId The definition ID to instantiate from
2429
+ * @param options Optional creation flags (e.g. { preview: true })
2430
+ */
2431
+ createAgent(agentDefinitionId: string, options?: {
2432
+ preview?: boolean;
2433
+ }): Promise<{
2434
+ id: string;
2435
+ }>;
2436
+ /**
2437
+ * Fetch a full agent runtime view (messages excluded, available via conversation client).
2438
+ */
2439
+ fetchAgent(agentId: string): Promise<AgentRuntimeView>;
2440
+ /**
2441
+ * Update an agent instance with partial data.
2442
+ */
2443
+ updateAgent(agentId: string, data: Partial<AgentDefinition>): Promise<AgentRuntimeView>;
2444
+ /**
2445
+ * Cancel the current operation for an agent instance.
2446
+ */
2447
+ cancelAgent(agentId: string): Promise<void>;
2448
+ /**
2449
+ * Delete an agent instance and its associated conversation.
2450
+ */
2451
+ deleteAgent(agentId: string): Promise<void>;
2452
+ /**
2453
+ * Subscribe to live updates for an agent instance.
2454
+ * Returns an unsubscribe function.
2455
+ */
2456
+ subscribeToUpdates(agentId: string, listener: AgentUpdateListener): () => void;
2457
+ /**
2458
+ * Get the framework (handler) ID for an agent instance.
2459
+ */
2460
+ getAgentFrameworkId(agentId: string): Promise<string>;
2461
+ /**
2462
+ * Get the JSON Schema for the framework configuration.
2463
+ */
2464
+ getFrameworkConfigSchema(frameworkId: string): Promise<Record<string, unknown>>;
2465
+ }
2466
+ /** Client contract for conversation operations on an agent instance. */
2467
+ interface AgentConversationClient {
2468
+ /** Load all messages for an agent's conversation. */
2469
+ getMessages(agentId: string): Promise<ChatMessage[]>;
2470
+ /** Send a user message to the agent. Returns the list of message IDs that were appended. */
2471
+ sendMessage(agentId: string, content: string, file?: File, wikiTiddlers?: WikiTiddlerAttachment[]): Promise<void>;
2472
+ /** Subscribe to new message notifications. */
2473
+ subscribeToMessages(agentId: string, listener: (message: ChatMessage) => void): () => void;
2474
+ /** Delete an agent turn — removes the user message and all subsequent agent responses. */
2475
+ deleteTurn(userMessageId: string): Promise<string | undefined>;
2476
+ /** Retry an agent turn — delete agent responses and re-send the user message. */
2477
+ retryTurn(userMessageId: string): Promise<void>;
2478
+ }
2479
+ /** Progress callback for prompt preview generation. */
2480
+ interface PromptPreviewProgress {
2481
+ progress: number;
2482
+ step: string;
2483
+ currentPlugin?: string;
2484
+ }
2485
+ /** Result of a prompt preview generation. */
2486
+ interface PromptPreviewResult {
2487
+ flatPrompts: unknown[];
2488
+ processedPrompts: unknown[];
2489
+ }
2490
+ /** Client contract for generating prompt previews. */
2491
+ interface PromptPreviewClient {
2492
+ /**
2493
+ * Generate a preview of the prompt tree for the given agent state.
2494
+ * @param agentFrameworkConfig The agent's framework configuration
2495
+ * @param messages Current conversation messages
2496
+ * @param inputText Optional input text to include in the preview
2497
+ * @param onProgress Optional progress callback
2498
+ */
2499
+ generatePreview(agentFrameworkConfig: AgentFrameworkConfig, messages: ChatMessage[], inputText?: string, onProgress?: (progress: PromptPreviewProgress) => void): Promise<PromptPreviewResult | null>;
2500
+ }
2501
+ /** Scheduled task input. */
2502
+ interface CreateScheduledTaskInput {
2503
+ agentInstanceId: string;
2504
+ agentDefinitionId: string;
2505
+ name: string;
2506
+ scheduleKind: 'interval' | 'cron' | 'at';
2507
+ schedule: {
2508
+ kind: 'interval';
2509
+ intervalSeconds: number;
2510
+ } | {
2511
+ kind: 'cron';
2512
+ expression: string;
2513
+ timezone?: string;
2514
+ } | {
2515
+ kind: 'at';
2516
+ wakeAtISO: string;
2517
+ };
2518
+ payload?: {
2519
+ message: string;
2520
+ };
2521
+ activeHoursStart?: string;
2522
+ activeHoursEnd?: string;
2523
+ createdBy?: string;
2524
+ enabled?: boolean;
2525
+ }
2526
+ /** Scheduled task model. */
2527
+ interface ScheduledTask {
2528
+ id: string;
2529
+ agentInstanceId: string;
2530
+ agentDefinitionId: string;
2531
+ name: string;
2532
+ schedule: CreateScheduledTaskInput['schedule'];
2533
+ payload?: {
2534
+ message?: string;
2535
+ };
2536
+ activeHoursStart?: string;
2537
+ activeHoursEnd?: string;
2538
+ enabled: boolean;
2539
+ createdBy?: string;
2540
+ }
2541
+ /** Client contract for managing scheduled tasks. */
2542
+ interface ScheduledTaskClient {
2543
+ listScheduledTasksForAgent(agentInstanceId: string): Promise<ScheduledTask[]>;
2544
+ createScheduledTask(input: CreateScheduledTaskInput): Promise<ScheduledTask>;
2545
+ updateScheduledTask(id: string, input: Partial<CreateScheduledTaskInput>): Promise<ScheduledTask>;
2546
+ deleteScheduledTask(id: string): Promise<void>;
2547
+ getCronPreviewDates(expression: string, timezone?: string, count?: number): Promise<string[]>;
2548
+ }
2549
+ /** State for the "Create New Agent" wizard. */
2550
+ interface AgentCreationState {
2551
+ /** Current step index in the creation wizard. */
2552
+ currentStep: number;
2553
+ /** Agent name entered by the user. */
2554
+ agentName: string;
2555
+ /** Selected template definition, if any. */
2556
+ selectedTemplate: AgentDefinition | null;
2557
+ /** Temporary agent definition being built. */
2558
+ temporaryAgentDefinition: AgentDefinition | null;
2559
+ /** ID of the preview agent instance created for testing. */
2560
+ previewAgentId: string | null;
2561
+ /** Whether a loading operation is in progress. */
2562
+ isLoading: boolean;
2563
+ /** JSON Schema for the selected agent framework, if loaded. */
2564
+ promptSchema: Record<string, unknown> | null;
2565
+ }
2566
+ /** State for the "Edit Agent Definition" view. */
2567
+ interface AgentDefinitionEditorState {
2568
+ /** The agent definition being edited. */
2569
+ agentDefinition: AgentDefinition | null;
2570
+ /** Agent name. */
2571
+ agentName: string;
2572
+ /** ID of the preview agent instance. */
2573
+ previewAgentId: string | null;
2574
+ /** Whether a loading operation is in progress. */
2575
+ isLoading: boolean;
2576
+ /** Whether a save operation is in progress. */
2577
+ isSaving: boolean;
2578
+ /** JSON Schema for the selected agent framework, if loaded. */
2579
+ promptSchema: Record<string, unknown> | null;
2580
+ }
2581
+ /** State for the prompt preview/edit dialog. */
2582
+ interface PromptPreviewDialogState {
2583
+ open: boolean;
2584
+ baseMode: 'preview' | 'edit';
2585
+ activeTab: 'flat' | 'tree';
2586
+ loading: boolean;
2587
+ progress: number;
2588
+ currentStep: string;
2589
+ currentPlugin: string | null;
2590
+ result: PromptPreviewResult | null;
2591
+ lastUpdated: Date | null;
2592
+ formFieldsToScrollTo: string[];
2593
+ }
2594
+
2595
+ /**
2596
+ * AgentSessionController — headless controller for an active agent conversation session.
2597
+ *
2598
+ * Manages agent runtime state, message sending, streaming, delete/retry turns,
2599
+ * and subscription to live agent updates.
2600
+ *
2601
+ * No React, DOM, Electron, MUI, Zustand, or RxJS dependency.
2602
+ */
2603
+
2604
+ /** Read-only snapshot of the session state. */
2605
+ interface AgentSessionSnapshot {
2606
+ agent: AgentRuntimeView | null;
2607
+ loading: boolean;
2608
+ error: Error | null;
2609
+ messages: ChatMessage[];
2610
+ orderedMessageIds: string[];
2611
+ streamingMessageIds: Set<string>;
2612
+ }
2613
+ /** Listener for snapshot changes. */
2614
+ type AgentSessionListener = (snapshot: AgentSessionSnapshot) => void;
2615
+ /** Options for creating an AgentSessionController. */
2616
+ interface AgentSessionControllerOptions {
2617
+ agentInstanceClient: AgentInstanceClient;
2618
+ conversationClient: AgentConversationClient;
2619
+ /** Polling interval in ms for agent status updates. Default 500. */
2620
+ pollInterval?: number;
2621
+ }
2622
+ /**
2623
+ * Headless controller for an agent conversation session.
2624
+ *
2625
+ * Call {@link start} to load an agent, then {@link subscribe} to receive snapshot
2626
+ * updates. Use {@link sendMessage}, {@link deleteTurn}, {@link retryTurn}, {@link cancel}
2627
+ * to drive the conversation.
2628
+ *
2629
+ * Host UI frameworks (React, Ink) subscribe via {@link subscribe} and render
2630
+ * the snapshot.
2631
+ */
2632
+ declare class AgentSessionController {
2633
+ private readonly options;
2634
+ private listener;
2635
+ private snapshot;
2636
+ private unsubAgentUpdates;
2637
+ private unsubMessages;
2638
+ private pollingTimer;
2639
+ private agentId;
2640
+ constructor(options: AgentSessionControllerOptions);
2641
+ /**
2642
+ * Start a session for the given agent ID.
2643
+ * Fetches the agent, subscribes to live updates, and loads messages.
2644
+ */
2645
+ start(agentId: string): Promise<void>;
2646
+ /** Stop the session and clean up subscriptions. */
2647
+ stop(): void;
2648
+ /** Send a user message. */
2649
+ sendMessage(content: string, file?: File, wikiTiddlers?: WikiTiddlerAttachment[]): Promise<void>;
2650
+ /** Cancel the current agent operation. */
2651
+ cancel(): Promise<void>;
2652
+ /** Delete a turn starting at the given user message ID. */
2653
+ deleteTurn(userMessageId: string): Promise<string | undefined>;
2654
+ /** Retry a turn starting at the given user message ID. */
2655
+ retryTurn(userMessageId: string): Promise<void>;
2656
+ /** Subscribe to snapshot changes. Returns unsubscribe function. */
2657
+ subscribe(listener: AgentSessionListener): () => void;
2658
+ /** Get current snapshot without subscribing. */
2659
+ getSnapshot(): AgentSessionSnapshot;
2660
+ private emitPartial;
2661
+ private handleAgentUpdate;
2662
+ private handleNewMessage;
2663
+ private startPolling;
2664
+ private stopPolling;
2665
+ }
2666
+
2667
+ /**
2668
+ * AgentDefinitionEditorController — headless controller for editing an agent definition.
2669
+ *
2670
+ * Manages definition loading, autosave, schema loading, preview agent lifecycle,
2671
+ * and scheduled task CRUD.
2672
+ *
2673
+ * No React, DOM, Electron, MUI, Zustand, or RxJS dependency.
2674
+ */
2675
+
2676
+ /** Partial state emitted to the listener. */
2677
+ type EditorStateChange = Partial<AgentDefinitionEditorState>;
2678
+ /** Listener for editor state changes. */
2679
+ type EditorStateListener = (change: EditorStateChange) => void;
2680
+ /** Schedule editor sub-state for the UI layer. */
2681
+ interface ScheduleEditorState {
2682
+ mode: 'none' | 'interval' | 'daily' | 'cron';
2683
+ intervalValue: number;
2684
+ intervalUnit: 's' | 'min' | 'h';
2685
+ dailyTime: string;
2686
+ activeHoursStart: string;
2687
+ activeHoursEnd: string;
2688
+ cronExpression: string;
2689
+ timezone: string;
2690
+ message: string;
2691
+ existingTaskId?: string;
2692
+ }
2693
+ /** Options for creating an AgentDefinitionEditorController. */
2694
+ interface AgentDefinitionEditorControllerOptions {
2695
+ definitionRepository: AgentDefinitionRepository;
2696
+ agentInstanceClient: AgentInstanceClient;
2697
+ scheduledTaskClient: ScheduledTaskClient;
2698
+ /** Debounce interval for autosave in ms. Default 1000. */
2699
+ autosaveDebounceMs?: number;
2700
+ }
2701
+ /**
2702
+ * Headless controller for editing an agent definition.
2703
+ *
2704
+ * Call {@link loadDefinition} to start, then {@link subscribe} for state updates.
2705
+ */
2706
+ declare class AgentDefinitionEditorController {
2707
+ private readonly options;
2708
+ private listener;
2709
+ private state;
2710
+ private autosaveTimer;
2711
+ constructor(options: AgentDefinitionEditorControllerOptions);
2712
+ /** Load an agent definition and its prompt schema. */
2713
+ loadDefinition(definitionId: string): Promise<void>;
2714
+ /** Update the agent definition field. Triggers debounced autosave. */
2715
+ updateDefinition(change: Partial<AgentDefinition> & {
2716
+ id: string;
2717
+ }): void;
2718
+ /** Force an immediate save to the repository. */
2719
+ saveNow(): Promise<void>;
2720
+ /** Reload the prompt schema for a framework ID. */
2721
+ reloadSchema(frameworkId: string): Promise<void>;
2722
+ /** Get or create a preview agent instance tied to this definition. */
2723
+ private findOrCreatePreviewAgent;
2724
+ loadScheduledTasks(): Promise<ScheduledTask[]>;
2725
+ saveScheduledTask(input: CreateScheduledTaskInput): Promise<ScheduledTask>;
2726
+ deleteScheduledTask(taskId: string): Promise<void>;
2727
+ subscribe(listener: EditorStateListener): () => void;
2728
+ getState(): AgentDefinitionEditorState;
2729
+ private emit;
2730
+ private scheduleAutosave;
2731
+ }
2732
+
2733
+ /**
2734
+ * AgentCreationController — headless controller for the "Create New Agent" wizard.
2735
+ *
2736
+ * Manages creation wizard state: current step, template selection, temporary
2737
+ * agent definition lifecycle, and preview agent setup.
2738
+ *
2739
+ * No React, DOM, Electron, MUI, Zustand, or RxJS dependency.
2740
+ */
2741
+
2742
+ /** Listener for creation state changes. */
2743
+ type CreationStateListener = (state: AgentCreationState) => void;
2744
+ /** Options for creating an AgentCreationController. */
2745
+ interface AgentCreationControllerOptions {
2746
+ definitionRepository: AgentDefinitionRepository;
2747
+ agentInstanceClient: AgentInstanceClient;
2748
+ /** Default framework ID for new agents. */
2749
+ defaultFrameworkId?: string;
2750
+ }
2751
+ /**
2752
+ * Headless controller for the agent creation wizard.
2753
+ *
2754
+ * Call {@link start}, {@link selectTemplate}, {@link nextStep}, etc. to drive
2755
+ * the wizard. Subscribe via {@link subscribe} for state updates.
2756
+ */
2757
+ declare class AgentCreationController {
2758
+ private readonly options;
2759
+ private listener;
2760
+ private state;
2761
+ constructor(options: AgentCreationControllerOptions);
2762
+ /** Initialize the creation wizard, optionally from a saved tab state. */
2763
+ start(definitionId?: string, templateDefinitionId?: string): Promise<void>;
2764
+ /** Select a template for the new agent. */
2765
+ selectTemplate(template: AgentDefinition): void;
2766
+ /** Update the agent name. */
2767
+ setAgentName(name: string): void;
2768
+ /** Advance to the next wizard step. */
2769
+ nextStep(): void;
2770
+ /** Go back to the previous wizard step. */
2771
+ previousStep(): void;
2772
+ /** Set the current wizard step directly. */
2773
+ setStep(step: number): void;
2774
+ /** Update the temporary agent definition. */
2775
+ updateTemporaryDefinition(change: Partial<AgentDefinition>): void;
2776
+ /** Set the prompt schema for the selected framework. */
2777
+ setPromptSchema(schema: Record<string, unknown> | null): void;
2778
+ /**
2779
+ * Create a preview agent instance for the chat-preview step.
2780
+ * Should be called when entering step 2 (or the chat preview step).
2781
+ */
2782
+ createPreviewAgent(definitionId: string): Promise<void>;
2783
+ /**
2784
+ * Finalize creation: persist the temporary definition and create the actual
2785
+ * agent instance. Returns the final agent instance ID, or null on failure.
2786
+ */
2787
+ finalize(): Promise<string | null>;
2788
+ /** Clean up temporary resources. */
2789
+ cleanup(): Promise<void>;
2790
+ subscribe(listener: CreationStateListener): () => void;
2791
+ getState(): AgentCreationState;
2792
+ private emit;
2793
+ }
2794
+
2795
+ /**
2796
+ * PromptPreviewController — headless controller for generating prompt previews.
2797
+ *
2798
+ * Manages preview dialog state, progress tracking, and result accumulation.
2799
+ *
2800
+ * No React, DOM, Electron, MUI, Zustand, or RxJS dependency.
2801
+ */
2802
+
2803
+ /** Listener for preview dialog state changes. */
2804
+ type PreviewDialogListener = (state: PromptPreviewDialogState) => void;
2805
+ /** Options for creating a PromptPreviewController. */
2806
+ interface PromptPreviewControllerOptions {
2807
+ previewClient: PromptPreviewClient;
2808
+ }
2809
+ /**
2810
+ * Headless controller for the prompt preview/edit dialog.
2811
+ *
2812
+ * Call {@link open}, {@link close}, {@link generate} to drive the dialog.
2813
+ * Subscribe via {@link subscribe} for state updates.
2814
+ */
2815
+ declare class PromptPreviewController {
2816
+ private readonly options;
2817
+ private listener;
2818
+ private state;
2819
+ constructor(options: PromptPreviewControllerOptions);
2820
+ /** Open the dialog with an optional base mode. */
2821
+ open(baseMode?: 'preview' | 'edit'): void;
2822
+ /** Close the dialog. */
2823
+ close(): void;
2824
+ /** Set the active tab in the dialog. */
2825
+ setActiveTab(tab: 'flat' | 'tree'): void;
2826
+ /** Set form fields to scroll to (for edit mode navigation). */
2827
+ setFormFieldsToScrollTo(fieldPaths: string[]): void;
2828
+ /**
2829
+ * Generate a preview of the prompt tree.
2830
+ * @param agentFrameworkConfig The agent's framework configuration
2831
+ * @param messages Current conversation messages
2832
+ * @param inputText Optional input text to include in the preview
2833
+ */
2834
+ generate(agentFrameworkConfig: AgentFrameworkConfig, messages: ChatMessage[], inputText?: string): Promise<PromptPreviewResult | null>;
2835
+ subscribe(listener: PreviewDialogListener): () => void;
2836
+ getState(): PromptPreviewDialogState;
2837
+ private emit;
2838
+ }
2839
+
2840
+ interface AgentRuntimeDeviceRpcHandlerOptions {
2841
+ runtime: Pick<MemeLoopRuntime, 'createAgent' | 'sendMessage' | 'cancelAgent'>;
2842
+ storage: IAgentStorage;
2843
+ getAgentDefinitions?: () => AgentDefinition[] | Promise<AgentDefinition[]>;
2844
+ localNodeId?: string;
2845
+ }
2846
+ declare function createAgentRuntimeDeviceRpcHandler(options: AgentRuntimeDeviceRpcHandlerOptions): DeviceRpcHandler;
2847
+
2848
+ declare const PEER_DRIVER_PROTOCOL_VERSION = "memeloop-peer-driver/v1";
2849
+ type PeerDriverScope = 'runtime' | 'model' | 'tool';
2850
+ interface PeerDriverAssignment {
2851
+ /** Protocol version for forward compatibility. */
2852
+ version: typeof PEER_DRIVER_PROTOCOL_VERSION;
2853
+ /** Scoped driver domain. */
2854
+ scope: PeerDriverScope;
2855
+ /** Assignment ID for idempotency and tracking. */
2856
+ assignmentId: string;
2857
+ /** Target operation within the scope. */
2858
+ operation: string;
2859
+ /** Operation parameters. */
2860
+ parameters: unknown;
2861
+ /** Optional timeout in milliseconds. */
2862
+ timeoutMs?: number;
2863
+ }
2864
+ interface PeerDriverStatus {
2865
+ version: typeof PEER_DRIVER_PROTOCOL_VERSION;
2866
+ assignmentId: string;
2867
+ state: 'accepted' | 'running' | 'completed' | 'failed';
2868
+ result?: unknown;
2869
+ error?: string;
2870
+ completedAt?: string;
2871
+ }
2872
+ interface PeerDriverTransportOptions {
2873
+ /** Send a raw RPC to a peer. */
2874
+ sendRpc: (peerId: string, method: string, parameters: unknown) => Promise<unknown>;
2875
+ /** Default timeout for assignments. */
2876
+ defaultTimeoutMs?: number;
2877
+ }
2878
+ interface PeerDriverRequestContext {
2879
+ /** Authenticated transport identity; never sourced from request parameters. */
2880
+ remotePeerId: string;
2881
+ }
2882
+ /**
2883
+ * Create a scoped peer driver transport that exchanges versioned assignments
2884
+ * and status through the device network. LLMs and callers use scoped
2885
+ * operations (runtime/model/tool) instead of raw node IDs and RPC methods.
2886
+ */
2887
+ declare function createPeerDriverTransport(options: PeerDriverTransportOptions): {
2888
+ submitAssignment: (peerId: string, assignment: Omit<PeerDriverAssignment, "version">) => Promise<PeerDriverStatus>;
2889
+ getAssignmentStatus: (peerId: string, assignmentId: string) => Promise<PeerDriverStatus>;
2890
+ cancelAssignment: (peerId: string, assignmentId: string) => Promise<PeerDriverStatus>;
2891
+ };
2892
+ /**
2893
+ * Create a DeviceRpcHandler that routes scoped driver protocol calls to the
2894
+ * appropriate local handlers.
2895
+ */
2896
+ declare function createPeerDriverRpcHandler(handlers: {
2897
+ onSubmit?: (assignment: PeerDriverAssignment, context: PeerDriverRequestContext) => Promise<PeerDriverStatus>;
2898
+ onStatus?: (assignmentId: string, context: PeerDriverRequestContext) => Promise<PeerDriverStatus>;
2899
+ onCancel?: (assignmentId: string, context: PeerDriverRequestContext) => Promise<PeerDriverStatus>;
2900
+ }): DeviceRpcHandler;
2901
+
2902
+ /**
2903
+ * IM 接入框架(平台无关):适配器负责验签/解析;ChannelManager 负责会话路由。
2904
+ */
2905
+
2906
+ /** 平台 Webhook 解析后的统一入站消息 */
2907
+ interface ImInboundMessage {
2908
+ channelId: string;
2909
+ platform: IMPlatformType;
2910
+ imUserId: string;
2911
+ text: string;
2912
+ /** 平台原始结构,便于调试或扩展富媒体 */
2913
+ raw: unknown;
2914
+ }
2915
+ interface ImWebhookContext {
2916
+ headers: Record<string, string | string[] | undefined>;
2917
+ body: Uint8Array;
2918
+ /** GET/POST query(如企业微信密文回调的 msg_signature、timestamp、nonce) */
2919
+ query?: Record<string, string>;
2920
+ }
2921
+ /**
2922
+ * 单平台适配器:verify 失败应返回 false;parse 失败返回 null。
2923
+ */
2924
+ interface IIMAdapter {
2925
+ readonly platform: IMPlatformType;
2926
+ verify(context: ImWebhookContext): boolean;
2927
+ parse(channelId: string, context: ImWebhookContext): ImInboundMessage | null;
2928
+ }
2929
+ /** 将 Agent 输出格式化为 IM 可发送的纯文本 */
2930
+ interface IIMMessageRenderer {
2931
+ renderPlainText(content: string): string;
2932
+ /** 单行工具调用摘要(IM 默认不展示完整工具参数/结果) */
2933
+ renderToolCallSummary(toolName: string, arguments_: unknown): string;
2934
+ /**
2935
+ * 工具结果摘要(返回 null 表示隐藏)。
2936
+ * 规则摘要优先:避免把大结果刷到 IM。
2937
+ */
2938
+ renderToolResultSummary(toolName: string, result: unknown): string | null;
2939
+ renderToolApproval(toolName: string, arguments_: unknown): string;
2940
+ renderAskQuestion(question: string, options?: string[]): string;
2941
+ /** IM 默认隐藏 thinking,若要显示由实现自行决定。 */
2942
+ renderThinking(content: string): string | null;
2943
+ renderError(error: string): string;
2944
+ renderTodoList(todos: Array<{
2945
+ id: string;
2946
+ text: string;
2947
+ done?: boolean;
2948
+ }>): string;
2949
+ }
2950
+ /** 节点侧驱动 Agent 的最小能力(避免循环依赖 MemeLoopRuntime 类型) */
2951
+ interface ImAgentDriver {
2952
+ createAgent(options: {
2953
+ definitionId: string;
2954
+ initialMessage?: string;
2955
+ }): Promise<{
2956
+ conversationId: string;
2957
+ }>;
2958
+ sendMessage(options: {
2959
+ conversationId: string;
2960
+ message: string;
2961
+ }): Promise<void>;
2962
+ }
2963
+
2964
+ /**
2965
+ * 管理 IM 用户与会话的绑定;可选 `storage` 使用 IAgentStorage 的 IM 绑定持久化。
2966
+ */
2967
+ declare class IMChannelManager {
2968
+ private readonly storage?;
2969
+ private readonly bindings;
2970
+ constructor(storage?: {
2971
+ getImBinding?(c: string, u: string): Promise<IMChannelBinding | null>;
2972
+ setImBinding?(r: IMChannelBinding): Promise<void>;
2973
+ } | undefined);
2974
+ private key;
2975
+ getBinding(channelId: string, imUserId: string): Promise<IMChannelBinding | undefined>;
2976
+ setBinding(record: IMChannelBinding): Promise<void>;
2977
+ /**
2978
+ * 处理入站文本:无 binding 时创建会话并发送首条用户消息。
2979
+ */
2980
+ dispatchInbound(message: ImInboundMessage, driver: ImAgentDriver, options: {
2981
+ defaultDefinitionId: string;
2982
+ }): Promise<{
2983
+ conversationId: string;
2984
+ }>;
2985
+ switchConversation(channelId: string, imUserId: string, conversationId: string): Promise<void>;
2986
+ }
2987
+ declare function pickAdapter(adapters: IIMAdapter[], platform: string): IIMAdapter | undefined;
2988
+
2989
+ /** Plan §20.6.1 — chunk assistant text before sending to IM APIs. */
2990
+ declare function imPlatformMaxMessageChars(platform: string): number;
2991
+
2992
+ interface ImSlashCommandContext {
2993
+ rawText: string;
2994
+ channelId: string;
2995
+ imUserId: string;
2996
+ manager: IMChannelManager;
2997
+ storage: IAgentStorage;
2998
+ driver: ImAgentDriver;
2999
+ runtime: MemeLoopRuntime;
3000
+ defaultDefinitionId: string;
3001
+ }
3002
+ /**
3003
+ * Plan §20.6.4 — parse `/list`, `/switch`, `/new`, `/agent`, `/status`, `/cancel` locally (no LLM).
3004
+ */
3005
+ declare function tryHandleImSlashCommand(context: ImSlashCommandContext): Promise<{
3006
+ handled: boolean;
3007
+ messages: string[];
3008
+ }>;
3009
+
3010
+ /** 通用文本/Markdown 友好输出(IM 端以纯文本展示) */
3011
+ declare class TextMessageRenderer implements IIMMessageRenderer {
3012
+ renderPlainText(content: string): string;
3013
+ renderToolCallSummary(toolName: string, arguments_: unknown): string;
3014
+ renderToolResultSummary(toolName: string, result: unknown): string | null;
3015
+ renderToolApproval(toolName: string, arguments_: unknown): string;
3016
+ renderAskQuestion(question: string, options?: string[]): string;
3017
+ renderThinking(_content: string): string | null;
3018
+ renderError(error: string): string;
3019
+ renderTodoList(todos: Array<{
3020
+ id: string;
3021
+ text: string;
3022
+ done?: boolean;
3023
+ }>): string;
3024
+ }
3025
+
3026
+ type ImStreamFlush = (text: string) => Promise<void>;
3027
+ /**
3028
+ * Subscribe to `runtime` agent updates and forward assistant text + light tool summaries to IM,
3029
+ * flushing when the buffer reaches the platform limit (plan §20.6.1).
3030
+ */
3031
+ declare function streamRuntimeAgentReplyToIm(options: {
3032
+ runtime: MemeLoopRuntime;
3033
+ conversationId: string;
3034
+ platform: string;
3035
+ renderer: TextMessageRenderer;
3036
+ flush: ImStreamFlush;
3037
+ }): Promise<void>;
3038
+
3039
+ /**
3040
+ * IM 会话控制工具(计划 20.4):在带 IM binding 的会话中注入。
3041
+ * 这里仅导出工具 schema 描述,实际注册由上层 ToolRegistry 完成。
3042
+ */
3043
+ declare const imToolDefinitions: readonly [{
3044
+ readonly name: "im.listConversations";
3045
+ readonly description: "列出可切换的会话(由 memeloop-cli registerImSessionTools 注册,仅 IM 来源会话可用)。";
3046
+ }, {
3047
+ readonly name: "im.switchConversation";
3048
+ readonly description: "切换当前 IM 用户绑定的活跃会话。参数:{ conversationId: string }";
3049
+ }, {
3050
+ readonly name: "im.newConversation";
3051
+ readonly description: "创建新会话并切换绑定。参数:{ definitionId?: string }";
3052
+ }, {
3053
+ readonly name: "im.summarizeHistory";
3054
+ readonly description: "返回当前会话最近消息的纯文本摘要(规则拼接,非 LLM)。参数:{ maxMessages?: number }";
3055
+ }];
3056
+ interface ImToolsRuntime {
3057
+ channelId: string;
3058
+ imUserId: string;
3059
+ manager: IMChannelManager;
3060
+ driver: ImAgentDriver;
3061
+ defaultDefinitionId: string;
3062
+ }
3063
+ /** 供工具实现层调用的命令式 API(避免在 core 内耦合 defineTool) */
3064
+ declare function imSwitchConversation(rt: ImToolsRuntime, conversationId: string): Promise<void>;
3065
+
3066
+ export { type AgentConversationClient, AgentCreationController, type AgentCreationControllerOptions, type AgentCreationState, AgentDefinition, AgentDefinitionEditorController, type AgentDefinitionEditorControllerOptions, type AgentDefinitionEditorState, type AgentDefinitionRepository, AgentFrameworkConfig, type AgentInstanceClient, AgentInstanceMeta, AgentOrchestrationClient, AgentRunResource, type AgentRuntimeDeviceRpcHandlerOptions, type AgentRuntimeView, AgentSessionController, type AgentSessionControllerOptions, type AgentSessionListener, type AgentSessionSnapshot, type AgentUpdateListener, AgentVolumeClaimResource, AgentVolumeReplicaStatus, AgentVolumeResource, AgentWorkloadResource, AgentWorkloadResourceRequirements, type ArchiveEntry, type ArchiveLimits, ArtifactDestination, ArtifactDestinationPolicy, ArtifactInspector, ArtifactManagementCapabilities, ArtifactManagementDriver, ArtifactManagementStateSnapshot, ArtifactReviewWriter, AttachmentReference, AuditTelemetryManagementDriver, type BindWorkerSessionRequest, type BindingControllerOptions, type BoundedCollector, ChatMessage, ControlLeaseGrant, ControlLeaseIdentity, ControlLeaseRequest, ControlStore, ControlStoreActor, ControlStoreApplyOptions, type ControlStoreAuditTelemetryAdapterOptions, ControlStoreAuthorizationRequest, ControlStoreAuthorizer, ControlStoreCompactionResult, ControlStoreCreateOptions, ControlStoreHealth, type ControlStoreOrchestrationClientOptions, type ControlStorePolicyApprovalAdapterOptions, ControlStoreSnapshotResult, ControlStoreStatusUpdateOptions, type Controller, type ControllerReconcileRequest, type ControllerReconcileResult, type ControllerRunnerHandle, type ControllerRunnerOptions, ConversationMeta, type CreateScheduledTaskInput, type CreationStateListener, CredentialBrokerDriver, type CredentialBrokerEndpoint, type CredentialGrantBindingControllerOptions, type CredentialGrantExecutionControllerOptions, CredentialGrantHandle, type CredentialGrantLifecycleControllerOptions, type CredentialGrantPlacementRequirements, CredentialGrantResource, type CredentialHandleVault, CredentialIssuePayload, CredentialManagementDriver, DataClassification, DeviceRpcHandler, DriverConformanceTest, type DriverFixture, DriverManifest, DriverRequestEnvelope, type EditorStateChange, type EditorStateListener, type ExternalDriverCapabilities, type ExternalOrchestrationControllerHandle, type ExternalOrchestrationControllerOptions, type ExternalOrchestrationDriver, type ExternalPlacementResult, type ExternalRuntimeResult, type ExternalStatusResult, type ExternalToolContract, type ExternalWorkerBootstrapSecret, type ExternalWorkloadPlacementContext, type ExternalWorkloadRuntimeContract, FLEET_ROLLOUT_API_VERSION, FLEET_ROLLOUT_KIND, FakeArtifactManagementState, type FleetRolloutControllerOptions, type FleetRolloutResource, type FleetRolloutSpec, type FleetRolloutStatus, type GatewayHttpRequest, type GatewayRateLimiter, type GatewayValidationContext, type GatewayValidationResult, GetMessagesOptions, IAgentStorage, type IIMAdapter, type IIMMessageRenderer, IMChannelBinding, IMChannelManager, IMPlatformType, IToolRegistry, IdentityAttestationManagementDriver, type IdentityPromotionRequest, type IdentityRevocationReason, type IdentityRevocationRecord, type ImAgentDriver, type ImInboundMessage, type ImSlashCommandContext, type ImStreamFlush, type ImToolsRuntime, type ImWebhookContext, type IssueWorkloadCapabilityGrantRequest, LOOP_CHECKPOINT_API_VERSION, LOOP_CHECKPOINT_KIND, ListConversationsOptions, type LocalModelAdvertisement, type LocalModelAdvertisementOptions, type LoopCheckpointResource, type LoopCheckpointSpec, LoopRunStartRequest, LoopRuntimeDriver, LoopScriptCheckpointStore, type ManagedArtifactDriverAdapterOptions, type ManagedStorageAdapterStateStore, type ManagedStorageDriverAdapterOptions, ManagedToolDescriptor, type ManagedToolExecutionRoute, type ManagedToolExecutionRouteOptions, type ManagedToolPolicyDecision, type ManagedWorkerIdentityAdapterOptions, type ManagedWorkerIdentityRequestFactoryInput, type ManagedWorkerIdentityRoute, ModelClassManifest, ModelClassResource, type ModelEndpointBindingControllerOptions, ModelEndpointManifest, type ModelEndpointRegistrarHandle, type ModelEndpointRegistrarOptions, ModelEndpointResource, type ModelEndpointTrust, ModelProviderDriver, ModelProviderHealth, type ModelSelectionRequirements, NODE_API_VERSION, NODE_KIND, type NetworkAttachmentBindingControllerOptions, type NetworkAttachmentExecutionControllerOptions, type NetworkAttachmentNode, NetworkAttachmentResource, NetworkClassResource, NetworkDriver, NetworkDriverCapabilities, NetworkManagementDriver, NetworkPreparePayload, type NodeSpec, type NodeStatus, NodeTrustClass, OrchestrationDeleteOptions, OrchestrationDeleteResult, OrchestrationErrorData, OrchestrationResource, OrchestrationResourceList, OrchestrationResourceManifest, OrchestrationResourceQuery, OrchestrationResourceReference, OrchestrationResourceStatus, OrchestrationResourceWatchEvent, OrchestrationWatchEvent, OrchestrationWatchOptions, PEER_DRIVER_PROTOCOL_VERSION, type PeerDriverAssignment, type PeerDriverRequestContext, type PeerDriverScope, type PeerDriverStatus, type PeerDriverTransportOptions, PermissionAction, PolicyApprovalManagementDriver, PolicyDecision, type PolicyEvaluation, type PreviewDialogListener, type PromptPreviewClient, PromptPreviewController, type PromptPreviewControllerOptions, type PromptPreviewDialogState, type PromptPreviewProgress, type PromptPreviewResult, type QuarantineGatewayPolicy, QuorumControlStore, type QuorumControlStoreOptions, type QuorumControlStoreSnapshot, type QuorumMember, type QuorumTopology, type RecordedInteraction, type RegisteredExternalOrchestrationDriver, type ReplicationAction, type ReplicationContext, type ReplicationControllerDeps, type ReplicationNode, type ReplicationResult, type ReplicationSnapshot, type ReplicationTransport, type RolloutEvidenceEntry, type RolloutStrategy, type RolloutTarget, type RunVolumeControllerOptions, type SanitizedText, type SanitizerFinding, type ScheduleEditorState, type ScheduledTask, type ScheduledTaskClient, type Scheduler, type SchedulerNode, type SchedulingDecision, type SecretRedactionOptions, SecurityProfileResource, type SelectableModelEndpoint, type SignedWorkerBootstrapSessionDescriptor, StorageClassResource, type StorageDriver, type StorageDriverCapabilities, type StorageDriverEndpoint, StorageManagementDriver, StorageProvisionPayload, type StorageProvisionRequest, type StorageProvisionResult, type StoragePublishRequest, type StoragePublishResult, TOOL_OPERATION_CONDITION_EFFECT_UNKNOWN, type TargetUpdateResult, type TargetUsage, TextMessageRenderer, TiddlyWikiHttpStorage, type TiddlyWikiHttpStorageOptions, ToolAdmissionAction, type ToolAdmissionDecision, ToolAdmissionPolicy, ToolAdmissionRule, ToolExecutionDriver, ToolExecutorResource, type ToolExecutorSelection, ToolManagementDriver, ToolOperationApprovalEvidence, type ToolOperationBindingControllerOptions, ToolOperationEffect, type ToolOperationExecutionController, type ToolOperationExecutionControllerOptions, ToolOperationResource, ToolOperationResult, ToolOperationStatus, type UnknownEffectAction, type UnknownEffectDecision, type UnknownEffectEvidence, type VerifierOnlyTransitionOptions, VolumeAccessMode, type VolumeClaimBindingControllerOptions, type VolumeClaimExecutionControllerOptions, WORKER_ENROLLMENT_API_VERSION, WORKER_ENROLLMENT_KIND, WORKER_PROTOCOL_METHODS, WORKER_PROTOCOL_VERSION, WORKER_SESSION_API_VERSION, WORKER_SESSION_KIND, WORKLOAD_CAPABILITY_GRANT_API_VERSION, WORKLOAD_CAPABILITY_GRANT_KIND, type WikiTiddlerAttachment, type WikiTiddlerClickData, type WorkerBootstrapSessionDescriptor, type WorkerEnrollmentResource, type WorkerEnrollmentSpec, type WorkerEnrollmentStatus, type WorkerGatewaySession, type WorkerProtocolAuditEvent, type WorkerProtocolGatewayOptions, type WorkerProtocolMethod, type WorkerProtocolReplayProtector, type WorkerProtocolRequest, type WorkerProtocolResponse, type WorkerRunBinding, type WorkerSessionResource, type WorkerSessionSpec, type WorkerSessionStatus, type WorkloadCapabilityBudget, type WorkloadCapabilityGrantRequirements, type WorkloadCapabilityGrantResource, type WorkloadCapabilityGrantSpec, type WorkloadCapabilityGrantStatus, type WorkloadExecutionControllerHandle, type WorkloadExecutionControllerOptions, applyUnknownEffectDecision, assertExternalToolContracts, assertExternalToolOperationContract, assertExternalToolOperationResult, assertExternalWorkloadRuntimeContracts, assertSafeArchivePath, bindWorkerSession, canonicalWorkerBootstrapDescriptorBytes, canonicalWorkerProtocolRequestBytes, canonicalWorkloadCapabilityGrantBytes, consumeWorkloadCapabilityGrant, containsSecrets, createAdoptionTests, createAgentRuntimeDeviceRpcHandler, createAuditRecordAuthorizer, createBackpressureTests, createBindingController, createBoundedCollector, createCancellationTests, createCapabilityNegotiationTests, createCapacityScheduler, createControlStoreArtifactReviewWriter, createControlStoreAuditTelemetryAdapter, createControlStoreLoopCheckpointStore, createControlStoreOrchestrationClient, createControlStorePolicyApprovalAdapter, createControllerRunner, createCredentialGrantBindingController, createCredentialGrantExecutionController, createCredentialGrantLifecycleController, createDowngradeTests, createExternalOrchestrationController, createFencingTests, createFleetRolloutController, createGatewayRateLimiter, createIdempotencyTests, createInMemoryWorkerReplayProtector, createManagedArtifactDriverAdapter, createManagedStorageDriverAdapter, createManagedToolDescriptors, createManagedToolExecutionRoute, createManagedWorkerIdentityAdapter, createMinimalExternalRuntimeToolContracts, createModelEndpointBindingController, createModelEndpointRegistrar, createNetworkAttachmentBindingController, createNetworkAttachmentExecutionController, createNodeTrustAuthorizer, createPeerDriverRpcHandler, createPeerDriverTransport, createPolicyDecisionAuthorizer, createRecordingDriver, createReplayingDriver, createReplicationController, createRunVolumeController, createSecurityTests, createToolOperationBindingController, createToolOperationExecutionController, createVerifierOnlyAuthorizer, createVolumeClaimBindingController, createVolumeClaimExecutionController, createWorkerEnrollmentManifest, createWorkerProtocolGateway, createWorkerRevocationList, createWorkerSessionManifest, createWorkloadCapabilityGrantManifest, createWorkloadExecutionController, defaultAdmissionPolicyForTrustClass, defaultPermissionActionForTrustClass, describeLocalModelEndpoints, detectMimeConfusion, enrollWorker, evaluateToolAdmission, imPlatformMaxMessageChars, imSwitchConversation, imToolDefinitions, isIdentityRevoked, isNodeAllowedForRole, isPrivateIp, isVerifierActor, isWorkerEnrollment, isWorkerSession, isWorkerSessionValid, isWorkloadCapabilityGrant, issueWorkloadCapabilityGrant, negotiateCapabilities, parseExternalRuntimeResult, pickAdapter, planReplicaPlacement, promoteIdentity, reconcileUnknownEffect, reconcileVolumeReplication, redactSecrets, resolveAdmissionPolicy, resolveExternalWorkloadResources, resolveExternalWorkloadRuntime, revokeCredentialGrant, revokeQuarantineIdentity, revokeWorkerSession, sanitizeMarkup, sanitizeTerminalText, scanForPromptInjection, selectModelEndpoint, selectToolExecutor, storageDriverSatisfiesClass, streamRuntimeAgentReplyToIm, sumEvidenceUsage, tryHandleImSlashCommand, validateArchiveManifest, validateGatewayRequest, validateNodeSpec, validateRedirectTarget, verifyWorkloadCapabilityGrant };