memeloop 0.0.1 → 0.1.1

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-2C6BJZI3.js +382 -0
  8. package/dist/chunk-2C6BJZI3.js.map +1 -0
  9. package/dist/chunk-426CJUZP.js +630 -0
  10. package/dist/chunk-426CJUZP.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-K6P63KD4.js +68 -0
  24. package/dist/chunk-K6P63KD4.js.map +1 -0
  25. package/dist/chunk-KFS2EJT6.js +42 -0
  26. package/dist/chunk-KFS2EJT6.js.map +1 -0
  27. package/dist/chunk-MAJWHAKR.js +3637 -0
  28. package/dist/chunk-MAJWHAKR.js.map +1 -0
  29. package/dist/chunk-MRKY4HGF.js +205 -0
  30. package/dist/chunk-MRKY4HGF.js.map +1 -0
  31. package/dist/chunk-T7FSXWFR.js +2744 -0
  32. package/dist/chunk-T7FSXWFR.js.map +1 -0
  33. package/dist/chunk-VZKQX5PP.js +1 -0
  34. package/dist/chunk-VZKQX5PP.js.map +1 -0
  35. package/dist/chunk-WAI6BODI.js +175 -0
  36. package/dist/chunk-WAI6BODI.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-WWnWnQFP.d.ts +91 -0
  58. package/dist/fetchProvider-toTHy5Nu.d.cts +91 -0
  59. package/dist/index.cjs +28051 -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 +10616 -2420
  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 +5227 -2010
  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 +86 -49
  78. package/dist/mobile.cjs +2711 -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-BHB_YrNN.d.ts +2192 -0
  85. package/dist/orchestration-portable-mvYBvGBb.d.cts +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-0WNFTg4l.d.ts +516 -0
  95. package/dist/promptConcat-D6wr5V-V.d.cts +516 -0
  96. package/dist/providerRegistry-Bi6pAvSj.d.ts +86 -0
  97. package/dist/providerRegistry-CPsktuiX.d.cts +86 -0
  98. package/dist/registry-D0kbxksn.d.cts +393 -0
  99. package/dist/registry-DDbvhlhs.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-PGWR6FIV.js +18 -0
  103. package/dist/runtime-PGWR6FIV.js.map +1 -0
  104. package/dist/scriptDeploymentPipeline-CXJcC82H.d.ts +2464 -0
  105. package/dist/scriptDeploymentPipeline-yG1ZhVVI.d.cts +2464 -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,2464 @@
1
+ import { u as OrchestrationResourceManifest, v as OrchestrationOwnerReference, w as OrchestrationTypeMeta, x as OrchestrationObjectMetadata, y as OrchestrationResourceStatus, O as OrchestrationErrorData, t as AgentOrchestrationClient, z as OrchestrationResourceReference, B as OrchestrationGetOptions, E as OrchestrationResource, F as OrchestrationResourceQuery, J as OrchestrationListOptions, K as OrchestrationResourceList, N as OrchestrationWatchOptions, P as OrchestrationWatchEvent, Q as OrchestrationDeleteOptions, R as OrchestrationDeleteResult, b as ChatMessage, S as AgentFrameworkConfig, r as AiAPIConfig, U as IPrompt, I as IAgentStorage, m as AgentDefinition, C as ConversationMeta } from './interface-IrKBFtL1.cjs';
2
+
3
+ declare const AGENT_WORKLOAD_API_VERSION = "workload.memeloop.io/v1alpha1";
4
+ declare const AGENT_WORKLOAD_KIND = "AgentWorkload";
5
+ declare const AGENT_RUN_API_VERSION = "run.memeloop.io/v1alpha1";
6
+ declare const AGENT_RUN_KIND = "AgentRun";
7
+ /**
8
+ * Host-asserted trust classification of a node or workload. The trust class
9
+ * is bound by the host; it is never self-reported by the workload, the model,
10
+ * or a `.mjs` script.
11
+ */
12
+ type NodeTrustClass = 'trusted' | 'restricted' | 'quarantine';
13
+ type AgentTrustLevel = NodeTrustClass;
14
+ /** Ordered data classifications; higher ranks are more sensitive. */
15
+ type DataClassification = 'public' | 'internal' | 'confidential' | 'restricted';
16
+ type ToolAdmissionAction = 'allow' | 'deny' | 'require-approval';
17
+ /**
18
+ * Declarative trusted-admission rule. Rules are evaluated in order; the first
19
+ * matching rule wins (firewall semantics). A rule matches when `toolPattern`
20
+ * matches the tool reference name and either `effects` is omitted (all
21
+ * effects) or contains the operation effect.
22
+ */
23
+ interface ToolAdmissionRule {
24
+ toolPattern: string;
25
+ effects?: ToolOperationEffect[];
26
+ action: ToolAdmissionAction;
27
+ reason?: string;
28
+ }
29
+ interface ToolAdmissionPolicy {
30
+ /** Applied when no rule matches. Restricted/quarantine profiles resolve to `deny` regardless of this field. */
31
+ defaultAction: ToolAdmissionAction;
32
+ rules?: ToolAdmissionRule[];
33
+ }
34
+ interface AgentWorkloadModelPolicy {
35
+ modelClass?: string;
36
+ allowedModelNames?: string[];
37
+ budget?: {
38
+ maxTokens?: number;
39
+ maxCost?: number;
40
+ };
41
+ }
42
+ interface AgentWorkloadToolPolicy {
43
+ allowedToolClasses?: string[];
44
+ /** Tool classes that must have a healthy executor on the selected node. */
45
+ requiredToolClasses?: string[];
46
+ allowedToolIds?: string[];
47
+ defaultAction?: 'allow' | 'ask' | 'deny';
48
+ rules?: Array<{
49
+ pattern: string;
50
+ action: 'allow' | 'ask' | 'deny';
51
+ }>;
52
+ }
53
+ interface AgentWorkloadNetworkPolicy {
54
+ networkClass?: string;
55
+ egress?: 'none' | 'same-node' | 'restricted' | 'open';
56
+ /** Minimum boundary that must enforce this policy before the workload binds. */
57
+ minimumEnforcement?: 'none' | 'process' | 'namespace' | 'host' | 'external';
58
+ }
59
+ interface AgentWorkloadVolumeClaim {
60
+ name: string;
61
+ claimRef: string;
62
+ }
63
+ interface AgentWorkloadStoragePolicy {
64
+ storageClass?: string;
65
+ volumes?: AgentWorkloadVolumeClaim[];
66
+ }
67
+ interface AgentWorkloadCredentialPolicy {
68
+ /** Credential broker class required on the selected node. */
69
+ brokerClass?: string;
70
+ /** Audiences for which the node must be able to request scoped grants. */
71
+ audiences?: string[];
72
+ /** Target classes for which scoped grants may be issued. */
73
+ targets?: string[];
74
+ }
75
+ interface AgentWorkloadResourceRequirements {
76
+ cpuMillicores?: number;
77
+ memoryBytes?: number;
78
+ gpuCount?: number;
79
+ diskBytes?: number;
80
+ bandwidthKbps?: number;
81
+ }
82
+ interface AgentWorkloadPlacement {
83
+ /**
84
+ * Registered external-orchestrator driver name. When set, the external
85
+ * orchestration controller owns placement and the local node binder skips
86
+ * this workload. External placement is always explicit; there is no silent
87
+ * spillover from the local runtime.
88
+ */
89
+ orchestrator?: string;
90
+ nodeSelector?: Record<string, string>;
91
+ requiredNode?: string;
92
+ antiAffinity?: string[];
93
+ /** Soft co-location preference; never overrides a hard security filter. */
94
+ preferredNode?: string;
95
+ /** Taints the workload tolerates. Nodes with taints not listed here are filtered out. */
96
+ tolerations?: string[];
97
+ /**
98
+ * Maximum data classification the workload may carry. Nodes with a lower
99
+ * `maxDataClassification` than the workload's effective classification are
100
+ * filtered out. Quarantine nodes are always treated as `public`-only.
101
+ */
102
+ dataClassification?: DataClassification;
103
+ /** Allowed residency labels (for example `local`, `cn`, or `eu-west`). */
104
+ dataResidency?: string[];
105
+ /** Require a currently verified node attestation. */
106
+ requireAttestation?: boolean;
107
+ /** Fleet batch constraints enforced before a target binds. */
108
+ rollout?: {
109
+ batchId: string;
110
+ excludedFaultDomains?: string[];
111
+ maxConcurrentPerFaultDomain?: number;
112
+ };
113
+ }
114
+ type AgentWorkloadCompletionPolicy = 'complete' | 'detach' | 'daemon';
115
+ interface AgentWorkloadSpec {
116
+ profileId?: string;
117
+ scriptReference?: string;
118
+ promptReference?: string;
119
+ trust?: AgentTrustLevel;
120
+ /** RuntimeClass selected for script workloads (plan 24.18); declarative only. */
121
+ runtimeClass?: string;
122
+ /**
123
+ * Non-secret environment variables for the workload (plan 24.14 `env`).
124
+ * Secret-shaped values are rejected at admission (deployGeneratedScript)
125
+ * and stripped again at launch (plan 24.35), so specs persisted in the
126
+ * ControlStore never carry provider keys.
127
+ */
128
+ env?: Record<string, string>;
129
+ /** Name of a SecurityProfile resource governing admission and model access. */
130
+ securityProfileRef?: string;
131
+ placement?: AgentWorkloadPlacement;
132
+ modelPolicy?: AgentWorkloadModelPolicy;
133
+ toolPolicy?: AgentWorkloadToolPolicy;
134
+ networkPolicy?: AgentWorkloadNetworkPolicy;
135
+ storagePolicy?: AgentWorkloadStoragePolicy;
136
+ credentialPolicy?: AgentWorkloadCredentialPolicy;
137
+ resources?: AgentWorkloadResourceRequirements;
138
+ /** Content-addressed artifacts whose locality may influence placement. */
139
+ artifactReferences?: string[];
140
+ /** Durable checkpoint whose locality may influence placement. */
141
+ checkpointReference?: string;
142
+ completionPolicy?: AgentWorkloadCompletionPolicy;
143
+ ownerReferences?: OrchestrationOwnerReference[];
144
+ }
145
+ interface AgentWorkloadStatus extends OrchestrationResourceStatus {
146
+ phase?: 'Pending' | 'Scheduling' | 'Running' | 'Completed' | 'Failed';
147
+ /** Node the binding controller scheduled this workload onto. */
148
+ assignedNode?: string;
149
+ /** Durable trusted policy decision that authorized the current binding. */
150
+ placementDecisionRef?: string;
151
+ /** Policy snapshot digest bound to placementDecisionRef. */
152
+ placementPolicyDigest?: string;
153
+ /** External driver selected for this workload, when any. */
154
+ assignedDriver?: string;
155
+ /** Opaque native workload identifier returned by the external driver. */
156
+ externalId?: string;
157
+ /** Non-secret, string-only backend metadata used for diagnostics/adoption. */
158
+ externalMetadata?: Record<string, string>;
159
+ runs?: Array<{
160
+ apiVersion: string;
161
+ kind: string;
162
+ name?: string;
163
+ namespace?: string;
164
+ uid?: string;
165
+ }>;
166
+ lastRunResult?: string;
167
+ }
168
+ interface AgentWorkloadCondition {
169
+ type: string;
170
+ status: 'True' | 'False' | 'Unknown';
171
+ }
172
+ type AgentWorkloadManifest = OrchestrationResourceManifest<AgentWorkloadSpec>;
173
+ interface AgentWorkloadResource extends OrchestrationTypeMeta {
174
+ metadata: OrchestrationObjectMetadata;
175
+ spec: AgentWorkloadSpec;
176
+ status?: AgentWorkloadStatus;
177
+ }
178
+ interface AgentRunSpec {
179
+ workloadRef: {
180
+ apiVersion: string;
181
+ kind: string;
182
+ name?: string;
183
+ namespace?: string;
184
+ uid?: string;
185
+ };
186
+ promptReference?: string;
187
+ retry?: number;
188
+ timeoutMs?: number;
189
+ }
190
+ interface AgentRunStatus extends OrchestrationResourceStatus {
191
+ phase?: 'Pending' | 'Starting' | 'Running' | 'Completed' | 'Failed' | 'Cancelled';
192
+ /**
193
+ * Durable claim written before invoking a LoopRuntimeDriver. A different
194
+ * daemon instance that observes Starting/Running must adopt through a
195
+ * managed driver or fail UNKNOWN_EFFECT; it must never blindly start again.
196
+ */
197
+ runtimeExecutionClaim?: {
198
+ controllerInstanceId: string;
199
+ claimedAt: string;
200
+ };
201
+ /** Independently selected serving endpoint for this run's model calls. */
202
+ assignedModelEndpoint?: {
203
+ apiVersion: string;
204
+ kind: string;
205
+ name: string;
206
+ namespace?: string;
207
+ uid: string;
208
+ };
209
+ /** Fences the model binding decision to the controller leadership epoch. */
210
+ modelBinding?: {
211
+ leaseEpoch: string;
212
+ endpointResourceVersion: string;
213
+ boundAt: string;
214
+ };
215
+ /** NetworkAttachment that must reach Attached before this run starts. */
216
+ networkAttachmentRef?: {
217
+ apiVersion: string;
218
+ kind: string;
219
+ name: string;
220
+ namespace?: string;
221
+ uid: string;
222
+ };
223
+ volumePhase?: 'Pending' | 'Publishing' | 'Ready' | 'Releasing' | 'Released' | 'Failed';
224
+ volumePublishClaim?: {
225
+ leaseEpoch: string;
226
+ claimedAt: string;
227
+ };
228
+ volumeBindings?: Array<{
229
+ name: string;
230
+ claimRef: {
231
+ name: string;
232
+ uid: string;
233
+ };
234
+ volumeRef: {
235
+ name: string;
236
+ uid: string;
237
+ };
238
+ assignedDriver: string;
239
+ assignedNode: string;
240
+ /** Managed node-stage handle used for ordered publish cleanup. */
241
+ stageHandle?: string;
242
+ publishHandle: string;
243
+ readOnly: boolean;
244
+ }>;
245
+ volumeReleaseRequestedAt?: string;
246
+ volumeError?: OrchestrationErrorData;
247
+ outputReference?: string;
248
+ summary?: string;
249
+ exitCode?: number;
250
+ }
251
+ interface AgentRunCondition {
252
+ type: string;
253
+ status: 'True' | 'False' | 'Unknown';
254
+ }
255
+ type AgentRunManifest = OrchestrationResourceManifest<AgentRunSpec>;
256
+ interface AgentRunResource extends OrchestrationTypeMeta {
257
+ metadata: OrchestrationObjectMetadata;
258
+ spec: AgentRunSpec;
259
+ status?: AgentRunStatus;
260
+ }
261
+ declare function createAgentWorkloadManifest(name: string, spec: AgentWorkloadSpec): AgentWorkloadManifest;
262
+ declare function createAgentRunManifest(name: string, spec: AgentRunSpec): AgentRunManifest;
263
+ declare function isAgentWorkload(resource: {
264
+ apiVersion?: string;
265
+ kind?: string;
266
+ }): resource is AgentWorkloadResource;
267
+ declare function isAgentRun(resource: {
268
+ apiVersion?: string;
269
+ kind?: string;
270
+ }): resource is AgentRunResource;
271
+ declare function agentWorkloadReference(name: string, namespace?: string): {
272
+ apiVersion: string;
273
+ kind: string;
274
+ name: string;
275
+ namespace?: string;
276
+ };
277
+ declare const TOOL_OPERATION_API_VERSION = "execution.memeloop.io/v1alpha1";
278
+ declare const TOOL_OPERATION_KIND = "ToolOperation";
279
+ type ToolOperationEffect = 'read' | 'create' | 'update' | 'delete' | 'execute' | 'unknown';
280
+ interface ToolOperationToolReference {
281
+ apiVersion?: string;
282
+ kind: string;
283
+ name: string;
284
+ namespace?: string;
285
+ /** Expected input/output schema digest; executors with another digest are rejected. */
286
+ schemaDigest?: string;
287
+ }
288
+ interface ToolOperationRetryPolicy {
289
+ maxAttempts?: number;
290
+ nonRetryable?: boolean;
291
+ fencingToken?: string;
292
+ }
293
+ interface ToolOperationPolicy {
294
+ requireApproval?: boolean;
295
+ auditLevel?: 'none' | 'metadata' | 'payload';
296
+ }
297
+ interface ToolOperationSpec {
298
+ toolRef: ToolOperationToolReference;
299
+ arguments?: Record<string, unknown>;
300
+ effect: ToolOperationEffect;
301
+ idempotencyKey?: string;
302
+ timeoutMs?: number;
303
+ retry?: ToolOperationRetryPolicy;
304
+ policy?: ToolOperationPolicy;
305
+ /** Explicit registered external-orchestrator driver selection. */
306
+ placement?: {
307
+ orchestrator?: string;
308
+ requiredNode?: string;
309
+ preferredNode?: string;
310
+ nodeSelector?: Record<string, string>;
311
+ minimumTrust?: NodeTrustClass;
312
+ };
313
+ }
314
+ interface ToolOperationResult {
315
+ value?: unknown;
316
+ error?: OrchestrationErrorData;
317
+ evidenceRef?: string;
318
+ }
319
+ interface ToolOperationApprovalEvidence {
320
+ approvalId: string;
321
+ decision: 'allow' | 'deny';
322
+ /** Trusted human/service identity. Model-provided identities are invalid. */
323
+ actor: string;
324
+ decidedAt: string;
325
+ reason?: string;
326
+ }
327
+ interface ToolOperationStatus extends OrchestrationResourceStatus {
328
+ phase?: 'Pending' | 'Running' | 'Completed' | 'Failed' | 'Cancelled';
329
+ result?: ToolOperationResult;
330
+ attempts?: number;
331
+ startedAt?: string;
332
+ completedAt?: string;
333
+ /** Trusted approval evidence returned by the host-bound approval driver. */
334
+ approval?: ToolOperationApprovalEvidence;
335
+ assignedDriver?: string;
336
+ assignedNode?: string;
337
+ assignedExecutor?: {
338
+ apiVersion: string;
339
+ kind: string;
340
+ name: string;
341
+ namespace?: string;
342
+ uid?: string;
343
+ };
344
+ /**
345
+ * Durable claim written before a local effect starts. A different fencing
346
+ * epoch observing Running must reconcile unknown effect instead of blindly
347
+ * repeating the operation.
348
+ */
349
+ executionClaim?: {
350
+ leaseEpoch: string;
351
+ claimedAt: string;
352
+ };
353
+ externalId?: string;
354
+ externalMetadata?: Record<string, string>;
355
+ }
356
+ type ToolOperationManifest = OrchestrationResourceManifest<ToolOperationSpec>;
357
+ interface ToolOperationResource extends OrchestrationTypeMeta {
358
+ metadata: OrchestrationObjectMetadata;
359
+ spec: ToolOperationSpec;
360
+ status?: ToolOperationStatus;
361
+ }
362
+ declare function createToolOperationManifest(name: string, spec: ToolOperationSpec): ToolOperationManifest;
363
+ declare function isToolOperation(resource: {
364
+ apiVersion?: string;
365
+ kind?: string;
366
+ }): resource is ToolOperationResource;
367
+ declare function agentRunReference(name: string, namespace?: string): {
368
+ apiVersion: string;
369
+ kind: string;
370
+ name: string;
371
+ namespace?: string;
372
+ };
373
+ declare const TOOL_CLASS_API_VERSION = "tool.memeloop.io/v1alpha1";
374
+ declare const TOOL_CLASS_KIND = "ToolClass";
375
+ declare const TOOL_EXECUTOR_API_VERSION = "tool.memeloop.io/v1alpha1";
376
+ declare const TOOL_EXECUTOR_KIND = "ToolExecutor";
377
+ type ToolRiskLevel = 'none' | 'low' | 'medium' | 'high' | 'critical';
378
+ interface ToolClassSchema {
379
+ input: Record<string, unknown>;
380
+ output?: Record<string, unknown>;
381
+ required?: string[];
382
+ }
383
+ interface ToolClassSpec {
384
+ description?: string;
385
+ version?: string;
386
+ schema: ToolClassSchema;
387
+ schemaDigest?: string;
388
+ risk?: ToolRiskLevel;
389
+ effects?: ToolOperationEffect[];
390
+ allowedTargets?: string[];
391
+ categories?: string[];
392
+ }
393
+ interface ToolClassStatus extends OrchestrationResourceStatus {
394
+ endpointCount?: number;
395
+ healthyEndpointCount?: number;
396
+ }
397
+ type ToolClassManifest = OrchestrationResourceManifest<ToolClassSpec>;
398
+ interface ToolClassResource extends OrchestrationTypeMeta {
399
+ metadata: OrchestrationObjectMetadata;
400
+ spec: ToolClassSpec;
401
+ status?: ToolClassStatus;
402
+ }
403
+ interface ToolExecutorCapability {
404
+ toolClassRef: {
405
+ apiVersion: string;
406
+ kind: string;
407
+ name: string;
408
+ };
409
+ schemaDigest: string;
410
+ effects?: ToolOperationEffect[];
411
+ endpoint: string;
412
+ capacity?: {
413
+ maxConcurrent?: number;
414
+ queueDepth?: number;
415
+ };
416
+ health?: {
417
+ lastHeartbeat?: string;
418
+ healthy: boolean;
419
+ };
420
+ }
421
+ interface ToolExecutorSpec {
422
+ nodeId?: string;
423
+ selectors?: Record<string, string>;
424
+ capabilities: ToolExecutorCapability[];
425
+ trust?: 'trusted' | 'restricted' | 'quarantine';
426
+ }
427
+ interface ToolExecutorStatus extends OrchestrationResourceStatus {
428
+ heartbeat?: string;
429
+ healthy?: boolean;
430
+ }
431
+ type ToolExecutorManifest = OrchestrationResourceManifest<ToolExecutorSpec>;
432
+ interface ToolExecutorResource extends OrchestrationTypeMeta {
433
+ metadata: OrchestrationObjectMetadata;
434
+ spec: ToolExecutorSpec;
435
+ status?: ToolExecutorStatus;
436
+ }
437
+ declare function createToolClassManifest(name: string, spec: ToolClassSpec): ToolClassManifest;
438
+ declare function createToolExecutorManifest(name: string, spec: ToolExecutorSpec): ToolExecutorManifest;
439
+ declare function isToolClass(resource: {
440
+ apiVersion?: string;
441
+ kind?: string;
442
+ }): resource is ToolClassResource;
443
+ declare function isToolExecutor(resource: {
444
+ apiVersion?: string;
445
+ kind?: string;
446
+ }): resource is ToolExecutorResource;
447
+ declare const MODEL_CLASS_API_VERSION = "models.memeloop.io/v1alpha1";
448
+ declare const MODEL_CLASS_KIND = "ModelClass";
449
+ declare const MODEL_ENDPOINT_API_VERSION = "models.memeloop.io/v1alpha1";
450
+ declare const MODEL_ENDPOINT_KIND = "ModelEndpoint";
451
+ declare const MODEL_CALL_RECORD_API_VERSION = "models.memeloop.io/v1alpha1";
452
+ declare const MODEL_CALL_RECORD_KIND = "ModelCallRecord";
453
+ type ModelModality = 'text' | 'vision' | 'audio' | 'embedding';
454
+ interface ModelClassCapabilities {
455
+ streaming?: boolean;
456
+ toolUse?: boolean;
457
+ jsonMode?: boolean;
458
+ systemPrompt?: boolean;
459
+ }
460
+ /**
461
+ * Declarative model catalog entry. Carries identity, digest, capabilities,
462
+ * residency, and cost metadata only — raw provider SDK clients, base URLs with
463
+ * embedded credentials, and API keys must never appear here.
464
+ */
465
+ interface ModelClassSpec {
466
+ description?: string;
467
+ /** Provider family identifier, e.g. `openai`, `anthropic`, `ollama`. */
468
+ provider: string;
469
+ /** Provider model name, e.g. `gpt-4o-mini`, `qwen2.5:7b`. */
470
+ model: string;
471
+ version?: string;
472
+ /** Content digest: local weights hash or provider snapshot identifier. */
473
+ digest?: string;
474
+ modalities?: ModelModality[];
475
+ contextWindow?: number;
476
+ maxOutputTokens?: number;
477
+ capabilities?: ModelClassCapabilities;
478
+ /** `local`, `cloud`, or a region/zone label constraining data residency. */
479
+ dataResidency?: string;
480
+ cost?: {
481
+ inputPerMillion?: number;
482
+ outputPerMillion?: number;
483
+ currency?: string;
484
+ };
485
+ }
486
+ interface ModelClassStatus extends OrchestrationResourceStatus {
487
+ endpointCount?: number;
488
+ healthyEndpointCount?: number;
489
+ }
490
+ type ModelClassManifest = OrchestrationResourceManifest<ModelClassSpec>;
491
+ interface ModelClassResource extends OrchestrationTypeMeta {
492
+ metadata: OrchestrationObjectMetadata;
493
+ spec: ModelClassSpec;
494
+ status?: ModelClassStatus;
495
+ }
496
+ /**
497
+ * Schedulable model serving endpoint. The endpoint string is an opaque driver
498
+ * handle (e.g. `ollama://node-1/qwen2.5:7b` or `gateway://default`) and must
499
+ * not embed credentials.
500
+ */
501
+ interface ModelEndpointSpec {
502
+ modelClassRef: {
503
+ apiVersion: string;
504
+ kind: string;
505
+ name: string;
506
+ };
507
+ /** Must match the referenced ModelClass digest for schedulability. */
508
+ modelDigest?: string;
509
+ nodeId?: string;
510
+ trust?: 'trusted' | 'restricted' | 'quarantine';
511
+ endpoint: string;
512
+ capacity?: {
513
+ maxConcurrent?: number;
514
+ tokensPerMinute?: number;
515
+ };
516
+ dataPolicy?: {
517
+ classification?: string;
518
+ retention?: string;
519
+ };
520
+ }
521
+ interface ModelEndpointStatus extends OrchestrationResourceStatus {
522
+ healthy?: boolean;
523
+ heartbeat?: string;
524
+ activeCalls?: number;
525
+ }
526
+ type ModelEndpointManifest = OrchestrationResourceManifest<ModelEndpointSpec>;
527
+ interface ModelEndpointResource extends OrchestrationTypeMeta {
528
+ metadata: OrchestrationObjectMetadata;
529
+ spec: ModelEndpointSpec;
530
+ status?: ModelEndpointStatus;
531
+ }
532
+ /**
533
+ * Audit and usage record for a single model call. Records carry usage and
534
+ * classification metadata, never raw prompts, completions, or credentials.
535
+ */
536
+ interface ModelCallRecordSpec {
537
+ modelClassRef: {
538
+ apiVersion: string;
539
+ kind: string;
540
+ name: string;
541
+ };
542
+ /** Immutable model artifact/provider snapshot selected for this call. */
543
+ modelDigest?: string;
544
+ endpointRef?: {
545
+ apiVersion: string;
546
+ kind: string;
547
+ name: string;
548
+ };
549
+ runRef?: OrchestrationOwnerReference;
550
+ /** Immutable attempt number from the authorizing ModelAccessHandle. */
551
+ runAttempt?: number;
552
+ /** Bound actor identity asserted by the host, not self-reported. */
553
+ caller?: string;
554
+ /** Name of the ModelAccessHandle authorizing this call. */
555
+ accessHandleRef?: string;
556
+ /** Admission/policy snapshot bound into the authorizing handle. */
557
+ policyDigest?: string;
558
+ inputClassification?: string;
559
+ outputClassification?: string;
560
+ }
561
+ interface ModelCallRecordStatus extends OrchestrationResourceStatus {
562
+ phase?: 'Running' | 'Completed' | 'Failed' | 'Cancelled';
563
+ usage?: {
564
+ inputTokens?: number;
565
+ outputTokens?: number;
566
+ cost?: number;
567
+ currency?: string;
568
+ };
569
+ latencyMs?: number;
570
+ startedAt?: string;
571
+ completedAt?: string;
572
+ error?: OrchestrationErrorData;
573
+ }
574
+ type ModelCallRecordManifest = OrchestrationResourceManifest<ModelCallRecordSpec>;
575
+ interface ModelCallRecordResource extends OrchestrationTypeMeta {
576
+ metadata: OrchestrationObjectMetadata;
577
+ spec: ModelCallRecordSpec;
578
+ status?: ModelCallRecordStatus;
579
+ }
580
+ declare function createModelClassManifest(name: string, spec: ModelClassSpec): ModelClassManifest;
581
+ declare function createModelEndpointManifest(name: string, spec: ModelEndpointSpec): ModelEndpointManifest;
582
+ declare function createModelCallRecordManifest(name: string, spec: ModelCallRecordSpec): ModelCallRecordManifest;
583
+ declare function isModelClass(resource: {
584
+ apiVersion?: string;
585
+ kind?: string;
586
+ }): resource is ModelClassResource;
587
+ declare function isModelEndpoint(resource: {
588
+ apiVersion?: string;
589
+ kind?: string;
590
+ }): resource is ModelEndpointResource;
591
+ declare function isModelCallRecord(resource: {
592
+ apiVersion?: string;
593
+ kind?: string;
594
+ }): resource is ModelCallRecordResource;
595
+ declare const SECURITY_PROFILE_API_VERSION = "security.memeloop.io/v1alpha1";
596
+ declare const SECURITY_PROFILE_KIND = "SecurityProfile";
597
+ /**
598
+ * Reusable security posture referenced by workloads. The profile is applied
599
+ * by trusted admission, never by the workload itself: for restricted and
600
+ * quarantine trust classes the resolved tool-admission default is forced to
601
+ * `deny` regardless of `toolAdmission.defaultAction`.
602
+ */
603
+ interface SecurityProfileSpec {
604
+ description?: string;
605
+ /** Trust class this profile applies to. */
606
+ trustClass: NodeTrustClass;
607
+ /** Tool admission overlay merged over the trust-class default policy. */
608
+ toolAdmission?: ToolAdmissionPolicy;
609
+ /** Model access constraints for workloads under this profile. */
610
+ modelPolicy?: {
611
+ allowedModelClasses?: string[];
612
+ maxInputClassification?: DataClassification;
613
+ };
614
+ }
615
+ interface SecurityProfileStatus extends OrchestrationResourceStatus {
616
+ /** Number of workloads currently referencing this profile. */
617
+ workloadCount?: number;
618
+ }
619
+ type SecurityProfileManifest = OrchestrationResourceManifest<SecurityProfileSpec>;
620
+ interface SecurityProfileResource extends OrchestrationTypeMeta {
621
+ metadata: OrchestrationObjectMetadata;
622
+ spec: SecurityProfileSpec;
623
+ status?: SecurityProfileStatus;
624
+ }
625
+ declare function createSecurityProfileManifest(name: string, spec: SecurityProfileSpec): SecurityProfileManifest;
626
+ declare function isSecurityProfile(resource: {
627
+ apiVersion?: string;
628
+ kind?: string;
629
+ }): resource is SecurityProfileResource;
630
+ declare const POLICY_DECISION_API_VERSION = "security.memeloop.io/v1alpha1";
631
+ declare const POLICY_DECISION_KIND = "PolicyDecision";
632
+ type PersistedPolicyDecisionKind = 'resource-admission' | 'placement' | 'tool-operation' | 'approval' | 'transition';
633
+ /** Immutable decision evidence; only a pending approval's status may resolve. */
634
+ interface PolicyDecisionSpec {
635
+ subjectRef: {
636
+ apiVersion: string;
637
+ kind: string;
638
+ name: string;
639
+ namespace?: string;
640
+ uid: string;
641
+ generation: number;
642
+ };
643
+ decisionKind: PersistedPolicyDecisionKind;
644
+ policyDigest: string;
645
+ inputDigest: string;
646
+ requestFingerprint: string;
647
+ idempotencyKey: string;
648
+ fencingEpoch: number;
649
+ requestedBy: string;
650
+ reasons: string[];
651
+ obligations: string[];
652
+ decidedAt: string;
653
+ initialOutcome: 'allow' | 'deny' | 'pending';
654
+ approval?: {
655
+ subjectDigest: string;
656
+ requestedBy: string;
657
+ requestedAt: string;
658
+ expiresAt: string;
659
+ };
660
+ }
661
+ interface PolicyDecisionStatus extends OrchestrationResourceStatus {
662
+ outcome: 'allow' | 'deny' | 'pending';
663
+ decidedBy: string;
664
+ decidedAt: string;
665
+ reasons: string[];
666
+ resolutionInputDigest?: string;
667
+ }
668
+ type PolicyDecisionManifest = OrchestrationResourceManifest<PolicyDecisionSpec>;
669
+ interface PolicyDecisionResource extends OrchestrationTypeMeta {
670
+ metadata: OrchestrationObjectMetadata;
671
+ spec: PolicyDecisionSpec;
672
+ status?: PolicyDecisionStatus;
673
+ }
674
+ declare function createPolicyDecisionManifest(name: string, spec: PolicyDecisionSpec): PolicyDecisionManifest;
675
+ declare function isPolicyDecision(resource: {
676
+ apiVersion?: string;
677
+ kind?: string;
678
+ }): resource is PolicyDecisionResource;
679
+ declare const AUDIT_RECORD_API_VERSION = "audit.memeloop.io/v1alpha1";
680
+ declare const AUDIT_RECORD_KIND = "AuditRecord";
681
+ /**
682
+ * Immutable, metadata-only audit/telemetry evidence. The record digest covers
683
+ * every field except itself and links to the preceding record in the named
684
+ * stream. Raw request/response bodies and credentials have no representation.
685
+ */
686
+ interface AuditRecordSpec {
687
+ stream: string;
688
+ sequence: number;
689
+ resourceUid: string;
690
+ recordKind: 'audit' | 'event' | 'metric' | 'trace';
691
+ receivedAt: string;
692
+ actor: {
693
+ id: string;
694
+ kind: 'controller' | 'verifier' | 'admin';
695
+ };
696
+ policyDigest: string;
697
+ capabilityDigest: string;
698
+ effect: 'read' | 'create' | 'update' | 'delete' | 'execute' | 'decision' | 'security';
699
+ provenance: {
700
+ source: 'controller' | 'gateway' | 'driver' | 'worker' | 'operator';
701
+ producer: string;
702
+ subject?: string;
703
+ };
704
+ attributes: Record<string, string>;
705
+ data: {
706
+ kind: 'audit';
707
+ action: string;
708
+ outcome: 'success' | 'denied' | 'failure';
709
+ reasonCode?: string;
710
+ } | {
711
+ kind: 'event';
712
+ name: string;
713
+ severity: 'debug' | 'info' | 'warning' | 'error' | 'critical';
714
+ } | {
715
+ kind: 'metric';
716
+ name: string;
717
+ value: number;
718
+ unit: string;
719
+ } | {
720
+ kind: 'trace';
721
+ name: string;
722
+ traceId: string;
723
+ spanId: string;
724
+ durationMs: number;
725
+ status: 'ok' | 'error';
726
+ };
727
+ previousDigest?: string;
728
+ recordDigest: string;
729
+ requestFingerprint: string;
730
+ idempotencyDigest: string;
731
+ fencingEpoch: number;
732
+ }
733
+ type AuditRecordManifest = OrchestrationResourceManifest<AuditRecordSpec>;
734
+ interface AuditRecordResource extends OrchestrationTypeMeta {
735
+ metadata: OrchestrationObjectMetadata;
736
+ spec: AuditRecordSpec;
737
+ status?: OrchestrationResourceStatus;
738
+ }
739
+ declare function createAuditRecordManifest(name: string, spec: AuditRecordSpec): AuditRecordManifest;
740
+ declare function isAuditRecord(resource: {
741
+ apiVersion?: string;
742
+ kind?: string;
743
+ }): resource is AuditRecordResource;
744
+ declare const NETWORK_CLASS_API_VERSION = "network.memeloop.io/v1alpha1";
745
+ declare const NETWORK_CLASS_KIND = "NetworkClass";
746
+ declare const NETWORK_ATTACHMENT_API_VERSION = "network.memeloop.io/v1alpha1";
747
+ declare const NETWORK_ATTACHMENT_KIND = "NetworkAttachment";
748
+ interface NetworkEgressRule {
749
+ /** Host, domain suffix, or CIDR, e.g. `api.openai.com` or `10.0.0.0/8`. */
750
+ target: string;
751
+ ports?: number[];
752
+ protocol?: 'tcp' | 'udp' | 'http' | 'https' | 'any';
753
+ action: 'allow' | 'deny';
754
+ }
755
+ /**
756
+ * CNI-like network desired state. `enforcement: required` means the workload
757
+ * must not start unless the driver can enforce every configured feature;
758
+ * `best-effort` allows partial enforcement with recorded degradation.
759
+ */
760
+ interface NetworkClassSpec {
761
+ description?: string;
762
+ /** NetworkDriver name responsible for this class. */
763
+ driver: string;
764
+ dns?: {
765
+ policy?: 'default' | 'none' | 'custom';
766
+ servers?: string[];
767
+ searchDomains?: string[];
768
+ };
769
+ proxy?: {
770
+ httpProxy?: string;
771
+ httpsProxy?: string;
772
+ noProxy?: string[];
773
+ /** When true, traffic bypassing the proxy must be blocked. */
774
+ mandatory?: boolean;
775
+ };
776
+ ingress?: {
777
+ defaultAction?: 'allow' | 'deny';
778
+ allow?: Array<{
779
+ from?: string;
780
+ ports?: number[];
781
+ }>;
782
+ };
783
+ egress?: {
784
+ defaultAction: 'allow' | 'deny';
785
+ rules?: NetworkEgressRule[];
786
+ };
787
+ serviceAccess?: {
788
+ allowControlPlane?: boolean;
789
+ allowClusterServices?: boolean;
790
+ allowModelGateway?: boolean;
791
+ };
792
+ bandwidth?: {
793
+ ingressKbps?: number;
794
+ egressKbps?: number;
795
+ };
796
+ dataPolicy?: {
797
+ classification?: DataClassification;
798
+ retention?: string;
799
+ };
800
+ enforcement: 'required' | 'best-effort';
801
+ }
802
+ interface NetworkClassStatus extends OrchestrationResourceStatus {
803
+ attachmentCount?: number;
804
+ }
805
+ type NetworkClassManifest = OrchestrationResourceManifest<NetworkClassSpec>;
806
+ interface NetworkClassResource extends OrchestrationTypeMeta {
807
+ metadata: OrchestrationObjectMetadata;
808
+ spec: NetworkClassSpec;
809
+ status?: NetworkClassStatus;
810
+ }
811
+ interface NetworkAttachmentSpec {
812
+ networkClassRef: {
813
+ apiVersion: string;
814
+ kind: string;
815
+ name: string;
816
+ };
817
+ workloadRef?: OrchestrationOwnerReference;
818
+ /** Exact AgentRun whose sandbox and authority this attachment belongs to. */
819
+ runRef?: OrchestrationOwnerReference;
820
+ nodeId?: string;
821
+ }
822
+ interface NetworkAttachmentStatus extends OrchestrationResourceStatus {
823
+ phase?: 'Pending' | 'Preparing' | 'Attached' | 'Failed' | 'Detached';
824
+ /** Node and driver selected independently from workload execution. */
825
+ assignedNode?: string;
826
+ assignedDriver?: string;
827
+ /** Fences the placement decision and the NetworkClass version it validated. */
828
+ binding?: {
829
+ leaseEpoch: string;
830
+ networkClassResourceVersion: string;
831
+ boundAt: string;
832
+ };
833
+ /**
834
+ * Durable claim written before prepare() may create host-side state.
835
+ * A new lease epoch must not blindly repeat an unconfirmed prepare.
836
+ */
837
+ executionClaim?: {
838
+ leaseEpoch: string;
839
+ claimedAt: string;
840
+ };
841
+ /** Opaque driver handle; consumers must never parse it. */
842
+ handle?: string;
843
+ addresses?: string[];
844
+ routes?: string[];
845
+ dns?: {
846
+ servers?: string[];
847
+ };
848
+ /** Features the driver could not enforce under a best-effort class. */
849
+ degraded?: string[];
850
+ attachedAt?: string;
851
+ /** Set by the workload owner after execution; the node driver must release before Detached. */
852
+ releaseRequestedAt?: string;
853
+ detachedAt?: string;
854
+ error?: OrchestrationErrorData;
855
+ }
856
+ type NetworkAttachmentManifest = OrchestrationResourceManifest<NetworkAttachmentSpec>;
857
+ interface NetworkAttachmentResource extends OrchestrationTypeMeta {
858
+ metadata: OrchestrationObjectMetadata;
859
+ spec: NetworkAttachmentSpec;
860
+ status?: NetworkAttachmentStatus;
861
+ }
862
+ declare function createNetworkClassManifest(name: string, spec: NetworkClassSpec): NetworkClassManifest;
863
+ declare function createNetworkAttachmentManifest(name: string, spec: NetworkAttachmentSpec): NetworkAttachmentManifest;
864
+ declare function isNetworkClass(resource: {
865
+ apiVersion?: string;
866
+ kind?: string;
867
+ }): resource is NetworkClassResource;
868
+ declare function isNetworkAttachment(resource: {
869
+ apiVersion?: string;
870
+ kind?: string;
871
+ }): resource is NetworkAttachmentResource;
872
+ declare const STORAGE_CLASS_API_VERSION = "storage.memeloop.io/v1alpha1";
873
+ declare const STORAGE_CLASS_KIND = "StorageClass";
874
+ declare const VOLUME_CLAIM_API_VERSION = "storage.memeloop.io/v1alpha1";
875
+ declare const VOLUME_CLAIM_KIND = "AgentVolumeClaim";
876
+ declare const VOLUME_API_VERSION = "storage.memeloop.io/v1alpha1";
877
+ declare const VOLUME_KIND = "AgentVolume";
878
+ declare const SNAPSHOT_API_VERSION = "storage.memeloop.io/v1alpha1";
879
+ declare const SNAPSHOT_KIND = "AgentSnapshot";
880
+ type VolumeAccessMode = 'ReadWriteOnce' | 'ReadOnlyMany' | 'ReadWriteMany';
881
+ /** CSI-like storage class: provisioning and replication policy. */
882
+ interface StorageClassSpec {
883
+ description?: string;
884
+ /** StorageDriver name responsible for this class. */
885
+ driver: string;
886
+ replication?: {
887
+ /** Desired replica count across fault domains (1 = no replication). */
888
+ factor?: number;
889
+ /** Fault-domain labels replicas must be spread across (e.g. `node`, `zone`). */
890
+ faultDomains?: string[];
891
+ /** Rebuild replicas automatically after loss. */
892
+ autoRebuild?: boolean;
893
+ };
894
+ encryption?: {
895
+ enabled?: boolean;
896
+ /** Reference to a key in the credential domain (never key material). */
897
+ keyRef?: string;
898
+ };
899
+ allowedAccessModes?: VolumeAccessMode[];
900
+ snapshotSupport?: boolean;
901
+ backup?: {
902
+ /** Cron-like schedule expression evaluated by the backup controller. */
903
+ schedule?: string;
904
+ retentionCount?: number;
905
+ };
906
+ dataPolicy?: {
907
+ classification?: DataClassification;
908
+ retention?: string;
909
+ };
910
+ }
911
+ interface StorageClassStatus extends OrchestrationResourceStatus {
912
+ volumeCount?: number;
913
+ healthyVolumeCount?: number;
914
+ }
915
+ type StorageClassManifest = OrchestrationResourceManifest<StorageClassSpec>;
916
+ interface StorageClassResource extends OrchestrationTypeMeta {
917
+ metadata: OrchestrationObjectMetadata;
918
+ spec: StorageClassSpec;
919
+ status?: StorageClassStatus;
920
+ }
921
+ /** PVC-like claim: a workload's request for storage. */
922
+ interface AgentVolumeClaimSpec {
923
+ storageClassRef: {
924
+ apiVersion: string;
925
+ kind: string;
926
+ name: string;
927
+ };
928
+ accessMode: VolumeAccessMode;
929
+ sizeBytes?: number;
930
+ selector?: Record<string, string>;
931
+ /** Restore from a snapshot when provisioning. */
932
+ dataSourceRef?: {
933
+ apiVersion: string;
934
+ kind: string;
935
+ name: string;
936
+ };
937
+ }
938
+ interface AgentVolumeClaimStatus extends OrchestrationResourceStatus {
939
+ phase?: 'Pending' | 'Provisioning' | 'Bound' | 'Lost' | 'Failed';
940
+ assignedNode?: string;
941
+ assignedDriver?: string;
942
+ binding?: {
943
+ leaseEpoch: string;
944
+ storageClassResourceVersion: string;
945
+ boundAt: string;
946
+ };
947
+ provisionClaim?: {
948
+ leaseEpoch: string;
949
+ claimedAt: string;
950
+ };
951
+ volumeRef?: {
952
+ apiVersion: string;
953
+ kind: string;
954
+ name: string;
955
+ uid?: string;
956
+ };
957
+ error?: OrchestrationErrorData;
958
+ }
959
+ type AgentVolumeClaimManifest = OrchestrationResourceManifest<AgentVolumeClaimSpec>;
960
+ interface AgentVolumeClaimResource extends OrchestrationTypeMeta {
961
+ metadata: OrchestrationObjectMetadata;
962
+ spec: AgentVolumeClaimSpec;
963
+ status?: AgentVolumeClaimStatus;
964
+ }
965
+ interface AgentVolumeReplicaStatus {
966
+ nodeId: string;
967
+ state: 'healthy' | 'degraded' | 'rebuilding' | 'offline';
968
+ /** Verified content hash of this replica (must equal the volume contentHash). */
969
+ contentHash?: string;
970
+ updatedAt?: string;
971
+ }
972
+ /** PV-like provisioned volume. `driverHandle` is opaque and never parsed by consumers. */
973
+ interface AgentVolumeSpec {
974
+ storageClassRef: {
975
+ apiVersion: string;
976
+ kind: string;
977
+ name: string;
978
+ };
979
+ claimRef?: OrchestrationOwnerReference;
980
+ /** Opaque driver handle for the provisioned volume. */
981
+ driverHandle: string;
982
+ capacityBytes?: number;
983
+ topology?: {
984
+ nodeId?: string;
985
+ zone?: string;
986
+ };
987
+ accessModes?: VolumeAccessMode[];
988
+ }
989
+ interface AgentVolumeStatus extends OrchestrationResourceStatus {
990
+ phase?: 'Pending' | 'Available' | 'Bound' | 'Published' | 'Failed';
991
+ replicas?: AgentVolumeReplicaStatus[];
992
+ /** Last verified content hash; the replication source of truth. */
993
+ contentHash?: string;
994
+ /** Current primary replica node; transfers originate only from the primary. */
995
+ primaryNodeId?: string;
996
+ /** Monotonically increasing fencing epoch, bumped on every primary change. */
997
+ primaryEpoch?: number;
998
+ publishedTo?: Array<{
999
+ nodeId?: string;
1000
+ workloadRef?: OrchestrationOwnerReference;
1001
+ }>;
1002
+ health?: 'healthy' | 'degraded' | 'rebuilding' | 'failed';
1003
+ }
1004
+ type AgentVolumeManifest = OrchestrationResourceManifest<AgentVolumeSpec>;
1005
+ interface AgentVolumeResource extends OrchestrationTypeMeta {
1006
+ metadata: OrchestrationObjectMetadata;
1007
+ spec: AgentVolumeSpec;
1008
+ status?: AgentVolumeStatus;
1009
+ }
1010
+ /** Point-in-time snapshot of a volume; restorable into new claims. */
1011
+ interface AgentSnapshotSpec {
1012
+ sourceVolumeRef: {
1013
+ apiVersion: string;
1014
+ kind: string;
1015
+ name: string;
1016
+ };
1017
+ snapshotClass?: string;
1018
+ }
1019
+ interface AgentSnapshotStatus extends OrchestrationResourceStatus {
1020
+ phase?: 'Pending' | 'Ready' | 'Failed';
1021
+ readyToUse?: boolean;
1022
+ restoreSizeBytes?: number;
1023
+ /** Opaque driver handle for the snapshot. */
1024
+ driverHandle?: string;
1025
+ createdAt?: string;
1026
+ }
1027
+ type AgentSnapshotManifest = OrchestrationResourceManifest<AgentSnapshotSpec>;
1028
+ interface AgentSnapshotResource extends OrchestrationTypeMeta {
1029
+ metadata: OrchestrationObjectMetadata;
1030
+ spec: AgentSnapshotSpec;
1031
+ status?: AgentSnapshotStatus;
1032
+ }
1033
+ declare function createStorageClassManifest(name: string, spec: StorageClassSpec): StorageClassManifest;
1034
+ declare function createVolumeClaimManifest(name: string, spec: AgentVolumeClaimSpec): AgentVolumeClaimManifest;
1035
+ declare function createVolumeManifest(name: string, spec: AgentVolumeSpec): AgentVolumeManifest;
1036
+ declare function createSnapshotManifest(name: string, spec: AgentSnapshotSpec): AgentSnapshotManifest;
1037
+ declare function isStorageClass(resource: {
1038
+ apiVersion?: string;
1039
+ kind?: string;
1040
+ }): resource is StorageClassResource;
1041
+ declare function isVolumeClaim(resource: {
1042
+ apiVersion?: string;
1043
+ kind?: string;
1044
+ }): resource is AgentVolumeClaimResource;
1045
+ declare function isVolume(resource: {
1046
+ apiVersion?: string;
1047
+ kind?: string;
1048
+ }): resource is AgentVolumeResource;
1049
+ declare function isSnapshot(resource: {
1050
+ apiVersion?: string;
1051
+ kind?: string;
1052
+ }): resource is AgentSnapshotResource;
1053
+ declare const CREDENTIAL_GRANT_API_VERSION = "security.memeloop.io/v1alpha1";
1054
+ declare const CREDENTIAL_GRANT_KIND = "CredentialGrant";
1055
+ /**
1056
+ * JIT credential authorization (plan 24.46). The resource records grant
1057
+ * metadata only — the opaque handle lives in the credential domain and raw
1058
+ * secret material never appears in spec or status.
1059
+ */
1060
+ interface CredentialGrantSpec {
1061
+ runRef: {
1062
+ apiVersion: string;
1063
+ kind: string;
1064
+ name: string;
1065
+ uid: string;
1066
+ };
1067
+ attempt: number;
1068
+ /** Fingerprint of the worker's ephemeral public key. */
1069
+ workerKey: string;
1070
+ /** Target system the credential acts on (e.g. `ssh://node-7`, `model:openai/gpt-4o`). */
1071
+ target: string;
1072
+ /** Operation the credential authorizes (e.g. `exec`, `generate`, `read`). */
1073
+ method: string;
1074
+ /** Audience the resulting handle is valid for. */
1075
+ audience: string;
1076
+ policyDigest: string;
1077
+ budget?: {
1078
+ maxCalls?: number;
1079
+ maxCost?: number;
1080
+ currency?: string;
1081
+ };
1082
+ /** Requested TTL in milliseconds; the broker caps it. */
1083
+ ttlMs?: number;
1084
+ }
1085
+ interface CredentialGrantStatus extends OrchestrationResourceStatus {
1086
+ phase?: 'Pending' | 'Issuing' | 'Issued' | 'Renewed' | 'Revoked' | 'Expired' | 'Failed';
1087
+ assignedNode?: string;
1088
+ assignedBroker?: string;
1089
+ binding?: {
1090
+ leaseEpoch: string;
1091
+ boundAt: string;
1092
+ };
1093
+ issuanceClaim?: {
1094
+ leaseEpoch: string;
1095
+ claimedAt: string;
1096
+ };
1097
+ /** Opaque handle reference in the credential domain — never the handle itself. */
1098
+ handleRef?: string;
1099
+ issuedAt?: string;
1100
+ expiresAt?: string;
1101
+ renewedAt?: string;
1102
+ revokedAt?: string;
1103
+ /** Exposure assessment used to decide post-task rotation. */
1104
+ exposure?: 'none' | 'worker-visible' | 'potentially-exposed';
1105
+ rotationRequired?: boolean;
1106
+ rotationReason?: string;
1107
+ error?: OrchestrationErrorData;
1108
+ }
1109
+ type CredentialGrantManifest = OrchestrationResourceManifest<CredentialGrantSpec>;
1110
+ interface CredentialGrantResource extends OrchestrationTypeMeta {
1111
+ metadata: OrchestrationObjectMetadata;
1112
+ spec: CredentialGrantSpec;
1113
+ status?: CredentialGrantStatus;
1114
+ }
1115
+ declare function createCredentialGrantManifest(name: string, spec: CredentialGrantSpec): CredentialGrantManifest;
1116
+ declare function isCredentialGrant(resource: {
1117
+ apiVersion?: string;
1118
+ kind?: string;
1119
+ }): resource is CredentialGrantResource;
1120
+ declare const ARTIFACT_RECORD_API_VERSION = "artifacts.memeloop.io/v1alpha1";
1121
+ declare const ARTIFACT_RECORD_KIND = "ArtifactRecord";
1122
+ type ArtifactTrust = 'trusted' | 'restricted' | 'quarantine' | 'untrusted';
1123
+ type ArtifactDestination = 'prompt' | 'volume' | 'backup' | 'knowledge';
1124
+ type ArtifactReviewKind = 'scan' | 'sanitize' | 'verify';
1125
+ interface ArtifactReviewEvidence {
1126
+ kind: ArtifactReviewKind;
1127
+ outcome: 'passed' | 'failed';
1128
+ reviewer: string;
1129
+ contentHash: string;
1130
+ policyDigest: string;
1131
+ destinations: ArtifactDestination[];
1132
+ /** Narrow properties certified by the reviewer; never implies general trust. */
1133
+ properties?: string[];
1134
+ recordedAt: string;
1135
+ }
1136
+ /**
1137
+ * Content-addressed artifact with provenance and trust (plan 24.47). Derived
1138
+ * content inherits the lowest trust of its inputs; untrusted or unverified
1139
+ * content cannot enter trusted prompts, volumes, backups, or knowledge
1140
+ * ingestion without explicit policy and a verifier pass.
1141
+ */
1142
+ interface ArtifactRecordSpec {
1143
+ /** Content hash (e.g. `sha256:...`); the storage address. */
1144
+ contentHash: string;
1145
+ sizeBytes?: number;
1146
+ mimeType?: string;
1147
+ /** Producing run and its trust at production time. */
1148
+ producer?: {
1149
+ runRef?: OrchestrationOwnerReference;
1150
+ trust: ArtifactTrust;
1151
+ };
1152
+ /** Parent artifacts this one derives from. */
1153
+ parents?: Array<{
1154
+ apiVersion: string;
1155
+ kind: string;
1156
+ name: string;
1157
+ }>;
1158
+ trust: ArtifactTrust;
1159
+ }
1160
+ interface ArtifactRecordStatus extends OrchestrationResourceStatus {
1161
+ /** Append-only evidence written only by the trusted artifact review actor. */
1162
+ reviews?: ArtifactReviewEvidence[];
1163
+ quarantined?: boolean;
1164
+ quarantineReason?: string;
1165
+ /** Downstream artifact names derived from this one (lineage). */
1166
+ derivedBy?: string[];
1167
+ }
1168
+ type ArtifactRecordManifest = OrchestrationResourceManifest<ArtifactRecordSpec>;
1169
+ interface ArtifactRecordResource extends OrchestrationTypeMeta {
1170
+ metadata: OrchestrationObjectMetadata;
1171
+ spec: ArtifactRecordSpec;
1172
+ status?: ArtifactRecordStatus;
1173
+ }
1174
+ declare function createArtifactRecordManifest(name: string, spec: ArtifactRecordSpec): ArtifactRecordManifest;
1175
+ declare function isArtifactRecord(resource: {
1176
+ apiVersion?: string;
1177
+ kind?: string;
1178
+ }): resource is ArtifactRecordResource;
1179
+ declare const DRIVER_MANIFEST_API_VERSION = "drivers.memeloop.io/v1alpha1";
1180
+ declare const DRIVER_MANIFEST_KIND = "DriverManifest";
1181
+ type InfrastructureDriverType = 'control-store' | 'loop-runtime' | 'tool-catalog' | 'tool-execution' | 'model-provider' | 'network' | 'storage' | 'credential' | 'artifact' | 'identity-attestation' | 'policy-approval' | 'audit-telemetry' | 'external-orchestrator';
1182
+ type DriverManifestConformance = {
1183
+ suiteVersion: string;
1184
+ status: 'not-run';
1185
+ } | {
1186
+ suiteVersion: string;
1187
+ status: 'failed';
1188
+ failedAt: string;
1189
+ failure: string;
1190
+ } | {
1191
+ suiteVersion: string;
1192
+ status: 'passed';
1193
+ passedAt: string;
1194
+ /** Content digest of the exact golden fixture/result bundle. */
1195
+ fixtureDigest: string;
1196
+ };
1197
+ /**
1198
+ * Control-plane representation of a registered driver (plan §11, 24.62).
1199
+ * A RuntimeClass/NetworkClass/ModelClass/scheduler can only reference a
1200
+ * driver whose manifest is registered and conformance-checked; external
1201
+ * orchestrator drivers register through the CLI discovery loader.
1202
+ */
1203
+ interface DriverManifestSpec {
1204
+ driverType: InfrastructureDriverType;
1205
+ /** Driver package version (from getCapabilities or the package manifest). */
1206
+ version: string;
1207
+ execution: {
1208
+ location: 'controller' | 'node' | 'worker' | 'external';
1209
+ transport: 'in-process' | 'stdio' | 'utility-process' | 'http' | 'peer-rpc' | 'container-api' | 'other';
1210
+ };
1211
+ supportedTrustClasses: NodeTrustClass[];
1212
+ resourceKinds: string[];
1213
+ capabilities: Record<string, boolean | string | number>;
1214
+ downgradeBehavior: 'reject' | 'explicit-degrade';
1215
+ requiredHostPrivileges: string[];
1216
+ isolation: {
1217
+ boundary: 'none' | 'process' | 'namespace' | 'host' | 'external';
1218
+ threatAssumptions: string[];
1219
+ };
1220
+ configuration: {
1221
+ /** Stable reference to the schema used to validate non-secret configuration. */
1222
+ schemaRef: string;
1223
+ /** Names of opaque SecretRef fields; never secret values. */
1224
+ secretRefs: string[];
1225
+ };
1226
+ health: {
1227
+ mode: 'method' | 'endpoint';
1228
+ endpoint?: string;
1229
+ };
1230
+ lifecycle: {
1231
+ discoverable: boolean;
1232
+ hotReload: boolean;
1233
+ gracefulShutdown: boolean;
1234
+ };
1235
+ conformance: DriverManifestConformance;
1236
+ supportsCancellation: boolean;
1237
+ supportsBackpressure: boolean;
1238
+ supportsAdoption: boolean;
1239
+ supportsFencing: boolean;
1240
+ /** External orchestrators: the resource kinds this driver manages. */
1241
+ manages?: Array<'AgentWorkload' | 'ToolOperation'>;
1242
+ /** External orchestrators: co-located scheduling support. */
1243
+ supportsColocation?: boolean;
1244
+ }
1245
+ interface DriverManifestStatus extends OrchestrationResourceStatus {
1246
+ phase?: 'Pending' | 'Ready' | 'Failed';
1247
+ registeredAt?: string;
1248
+ error?: OrchestrationErrorData;
1249
+ }
1250
+ type DriverManifestManifest = OrchestrationResourceManifest<DriverManifestSpec>;
1251
+ interface DriverManifestResource extends OrchestrationTypeMeta {
1252
+ metadata: OrchestrationObjectMetadata;
1253
+ spec: DriverManifestSpec;
1254
+ status?: DriverManifestStatus;
1255
+ }
1256
+ declare function createDriverManifestManifest(name: string, spec: DriverManifestSpec): DriverManifestManifest;
1257
+ declare function isDriverManifest(resource: {
1258
+ apiVersion?: string;
1259
+ kind?: string;
1260
+ }): resource is DriverManifestResource;
1261
+ /** A class may only select a manifest whose current conformance evidence passed. */
1262
+ declare function isDriverManifestAdmitted(resource: DriverManifestResource): boolean;
1263
+
1264
+ interface CreateAgentWorkloadOptions {
1265
+ name?: string;
1266
+ generateName?: string;
1267
+ namespace?: string;
1268
+ profileId?: string;
1269
+ scriptReference?: string;
1270
+ promptReference?: string;
1271
+ trust?: AgentTrustLevel;
1272
+ placement?: AgentWorkloadPlacement;
1273
+ modelPolicy?: AgentWorkloadModelPolicy;
1274
+ toolPolicy?: AgentWorkloadToolPolicy;
1275
+ networkPolicy?: AgentWorkloadNetworkPolicy;
1276
+ storagePolicy?: AgentWorkloadStoragePolicy;
1277
+ completionPolicy?: AgentWorkloadCompletionPolicy;
1278
+ ownerReferences?: OrchestrationOwnerReference[];
1279
+ idempotencyKey?: string;
1280
+ }
1281
+ interface CreateAgentRunOptions {
1282
+ name?: string;
1283
+ generateName?: string;
1284
+ namespace?: string;
1285
+ workloadName: string;
1286
+ workloadNamespace?: string;
1287
+ promptReference?: string;
1288
+ retry?: number;
1289
+ timeoutMs?: number;
1290
+ idempotencyKey?: string;
1291
+ }
1292
+ interface WaitForConditionOptions {
1293
+ timeout?: number;
1294
+ interval?: number;
1295
+ signal?: AbortSignal;
1296
+ /** Host cancellation hook for runtimes that expose a boolean marker instead of AbortSignal. */
1297
+ isCancelled?: () => boolean;
1298
+ }
1299
+ interface AgentClient {
1300
+ createWorkload(options: CreateAgentWorkloadOptions): Promise<AgentWorkloadResource>;
1301
+ getWorkload(name: string, namespace?: string): Promise<AgentWorkloadResource | null>;
1302
+ deleteWorkload(name: string, namespace?: string): Promise<void>;
1303
+ waitForWorkloadCondition(name: string, condition: AgentWorkloadCondition, options?: WaitForConditionOptions): Promise<{
1304
+ observedResourceVersion: string;
1305
+ matched: true;
1306
+ }>;
1307
+ createRun(options: CreateAgentRunOptions): Promise<AgentRunResource>;
1308
+ getRun(name: string, namespace?: string): Promise<AgentRunResource | null>;
1309
+ deleteRun(name: string, namespace?: string): Promise<void>;
1310
+ waitForRunCondition(name: string, condition: AgentRunCondition, options?: WaitForConditionOptions): Promise<{
1311
+ observedResourceVersion: string;
1312
+ matched: true;
1313
+ }>;
1314
+ }
1315
+ declare function waitForCondition<TResource extends {
1316
+ metadata?: {
1317
+ resourceVersion?: string;
1318
+ };
1319
+ status?: {
1320
+ conditions?: Array<{
1321
+ type: string;
1322
+ status: 'True' | 'False' | 'Unknown';
1323
+ }>;
1324
+ };
1325
+ }>(get: () => Promise<TResource | null>, condition: {
1326
+ type: string;
1327
+ status: 'True' | 'False' | 'Unknown';
1328
+ }, options: WaitForConditionOptions): Promise<{
1329
+ observedResourceVersion: string;
1330
+ matched: true;
1331
+ }>;
1332
+ declare function createAgentClient(client: AgentOrchestrationClient, defaultNamespace?: string): AgentClient;
1333
+
1334
+ type ControlStoreVerb = 'create' | 'apply' | 'update-status' | 'delete' | 'acquire-lease' | 'renew-lease' | 'release-lease';
1335
+ interface ControlStoreActor {
1336
+ id: string;
1337
+ kind: 'controller' | 'verifier' | 'admin';
1338
+ properties?: string[];
1339
+ }
1340
+ interface ControlStoreAuthorizationRequest {
1341
+ actor: ControlStoreActor;
1342
+ verb: ControlStoreVerb;
1343
+ reference: OrchestrationResourceReference;
1344
+ current?: OrchestrationResource;
1345
+ proposedResource?: OrchestrationResourceManifest;
1346
+ proposedStatus?: OrchestrationResourceStatus;
1347
+ }
1348
+ interface ControlStoreAuthorizer {
1349
+ /** Must return synchronously so authorization and the protected write share one transaction. */
1350
+ authorize(request: ControlStoreAuthorizationRequest): void;
1351
+ }
1352
+ interface ControlStoreCreateOptions {
1353
+ idempotencyKey?: string;
1354
+ dryRun?: boolean;
1355
+ }
1356
+ interface ControlStoreApplyOptions {
1357
+ /** Required when changing an existing spec; omitted only for create/same-spec retry. */
1358
+ resourceVersion?: string;
1359
+ idempotencyKey?: string;
1360
+ dryRun?: boolean;
1361
+ }
1362
+ interface ControlStoreStatusUpdateOptions {
1363
+ /** Exact compare-and-swap precondition. */
1364
+ resourceVersion: string;
1365
+ idempotencyKey?: string;
1366
+ dryRun?: boolean;
1367
+ }
1368
+ interface ControlLeaseRequest {
1369
+ name: string;
1370
+ holder: string;
1371
+ ttlMs: number;
1372
+ }
1373
+ interface ControlLeaseIdentity {
1374
+ name: string;
1375
+ holder: string;
1376
+ leaseId: string;
1377
+ epoch: string;
1378
+ }
1379
+ interface ControlLeaseGrant extends ControlLeaseIdentity {
1380
+ acquiredAt: string;
1381
+ renewedAt: string;
1382
+ expiresAt: string;
1383
+ resourceVersion: string;
1384
+ }
1385
+ interface ControlStoreCompactionResult {
1386
+ compactedThrough: string;
1387
+ resourceVersion: string;
1388
+ }
1389
+ interface ControlStoreSnapshotResult {
1390
+ resourceVersion: string;
1391
+ createdAt: string;
1392
+ }
1393
+ interface ControlStoreHealth {
1394
+ healthy: boolean;
1395
+ resourceVersion: string;
1396
+ detail?: string;
1397
+ }
1398
+ /**
1399
+ * Trusted controller-facing state store. Agent-facing clients never receive
1400
+ * status, lease, compaction, snapshot, or actor-selection capabilities.
1401
+ */
1402
+ interface ControlStore {
1403
+ get<TSpec = Record<string, unknown>, TStatus = OrchestrationResourceStatus>(reference: OrchestrationResourceReference, options?: OrchestrationGetOptions): Promise<OrchestrationResource<TSpec, TStatus> | null>;
1404
+ list<TSpec = Record<string, unknown>, TStatus = OrchestrationResourceStatus>(query: OrchestrationResourceQuery, options?: OrchestrationListOptions): Promise<OrchestrationResourceList<TSpec, TStatus>>;
1405
+ watch<TSpec = Record<string, unknown>, TStatus = OrchestrationResourceStatus>(query: OrchestrationResourceQuery, options?: OrchestrationWatchOptions): AsyncIterable<OrchestrationWatchEvent<TSpec, TStatus>>;
1406
+ create<TSpec = Record<string, unknown>, TStatus = OrchestrationResourceStatus>(actor: ControlStoreActor, resource: OrchestrationResourceManifest<TSpec>, options?: ControlStoreCreateOptions): Promise<OrchestrationResource<TSpec, TStatus>>;
1407
+ apply<TSpec = Record<string, unknown>, TStatus = OrchestrationResourceStatus>(actor: ControlStoreActor, resource: OrchestrationResourceManifest<TSpec>, options?: ControlStoreApplyOptions): Promise<OrchestrationResource<TSpec, TStatus>>;
1408
+ updateStatus<TSpec = Record<string, unknown>, TStatus = OrchestrationResourceStatus>(actor: ControlStoreActor, reference: OrchestrationResourceReference, status: TStatus, options: ControlStoreStatusUpdateOptions): Promise<OrchestrationResource<TSpec, TStatus>>;
1409
+ delete(actor: ControlStoreActor, reference: OrchestrationResourceReference, options?: OrchestrationDeleteOptions): Promise<OrchestrationDeleteResult>;
1410
+ acquireLease(actor: ControlStoreActor, request: ControlLeaseRequest): Promise<ControlLeaseGrant>;
1411
+ renewLease(actor: ControlStoreActor, identity: ControlLeaseIdentity, ttlMs: number): Promise<ControlLeaseGrant>;
1412
+ releaseLease(actor: ControlStoreActor, identity: ControlLeaseIdentity): Promise<void>;
1413
+ compact(throughResourceVersion: string): Promise<ControlStoreCompactionResult>;
1414
+ snapshot(targetPath: string): Promise<ControlStoreSnapshotResult>;
1415
+ getHealth(): Promise<ControlStoreHealth>;
1416
+ close(): Promise<void>;
1417
+ }
1418
+ /** Key-order-independent structural form used by every ControlStore backend. */
1419
+ declare function canonicalControlStoreValue(value: unknown): string;
1420
+ /** Whether an apply manifest is already represented by the stored resource. */
1421
+ declare function controlStoreApplyMatches(current: OrchestrationResource, proposed: OrchestrationResourceManifest): boolean;
1422
+
1423
+ /**
1424
+ * Generated-script validation and normalization (plan 24.16).
1425
+ *
1426
+ * Validates Agent-generated .mjs scripts before they are scheduled:
1427
+ * - Syntax check via a real JavaScript parser (Acorn) — regexes could be
1428
+ * fooled by comments/strings/regex literals; an AST cannot.
1429
+ * - Required export shape: the default export must be an async generator
1430
+ * function (inline or via an identifier bound to one in the same module).
1431
+ * - Import extraction from the AST: static `import` declarations, re-exports
1432
+ * (`export ... from`), and string-literal dynamic `import()` arguments.
1433
+ * Non-literal dynamic imports are rejected because they defeat admission.
1434
+ * - Forbidden imports: no Node builtins except 'node:events'.
1435
+ * - Size limits.
1436
+ * - Canonical SHA-256 digest for provenance. The digest commits to the
1437
+ * NORMALIZED source (see {@link normalizeScript}), so semantically
1438
+ * identical scripts with different line endings share one digest.
1439
+ *
1440
+ * Security note: this runs in the controller process, but never executes
1441
+ * the script. Execution is delegated to the sandbox from plan 24.48.
1442
+ */
1443
+ interface ScriptValidationResult {
1444
+ valid: boolean;
1445
+ /**
1446
+ * Canonical SHA-256 hex digest of the NORMALIZED source
1447
+ * (`normalizeScript(source)`). The digest commits to the normalized form,
1448
+ * not the raw bytes, so CRLF/LF variants of the same script are equal.
1449
+ */
1450
+ digest: string;
1451
+ /** Detected imports, from the AST (static, re-export, literal dynamic). */
1452
+ imports: string[];
1453
+ /** Whether the script's default export is an async generator function. */
1454
+ hasDefaultExport: boolean;
1455
+ /**
1456
+ * Whether the script contains a dynamic `import()` whose argument is not
1457
+ * a string literal. Such scripts are always invalid: the import target
1458
+ * cannot be known statically, which defeats admission control.
1459
+ */
1460
+ hasNonLiteralDynamicImport: boolean;
1461
+ /** Human-readable errors if invalid. */
1462
+ errors: string[];
1463
+ /** Normalized source size in bytes. */
1464
+ sizeBytes: number;
1465
+ }
1466
+ /**
1467
+ * Compute the canonical SHA-256 hex digest of an already-normalized script.
1468
+ * Callers with raw source must pass it through {@link normalizeScript} first
1469
+ * (or use {@link validateScript}, which normalizes internally).
1470
+ */
1471
+ declare function digestNormalizedScript(normalizedSource: string): Promise<string>;
1472
+ /**
1473
+ * Validate a script string using a real AST parse (Acorn).
1474
+ * Returns a structured result; never throws.
1475
+ */
1476
+ declare function validateScript(source: string): Promise<ScriptValidationResult>;
1477
+ /**
1478
+ * Normalize a script to a canonical form for digest stability.
1479
+ * Strips BOM, normalizes line endings to LF, and trims trailing whitespace.
1480
+ * Idempotent: `normalizeScript(normalizeScript(s)) === normalizeScript(s)`.
1481
+ * The canonical digest in {@link validateScript} commits to this form.
1482
+ */
1483
+ declare function normalizeScript(source: string): string;
1484
+
1485
+ /**
1486
+ * Script admission policy and checkpoint compatibility (plan 24.17, 24.19).
1487
+ *
1488
+ * - Admission: trust class, author, imports, resource limits, approval
1489
+ * - Compatibility: script digest/API version vs checkpoint schema
1490
+ *
1491
+ * Quarantine scripts cannot enable arbitrary network imports or plugin loading.
1492
+ * A changed script cannot resume an incompatible checkpoint without explicit
1493
+ * converter or restart policy.
1494
+ */
1495
+
1496
+ type ScriptTrustClass = 'trusted' | 'restricted' | 'quarantine';
1497
+ interface ScriptAdmissionRequest {
1498
+ /** The validated script result. */
1499
+ script: ScriptValidationResult;
1500
+ /** Trust class of the author (e.g., the Agent that generated the script). */
1501
+ authorTrust: ScriptTrustClass;
1502
+ /** Requested interfaces the script wants to use. */
1503
+ requestedInterfaces: string[];
1504
+ /** Optional checkpoint digest the script expects to resume from. */
1505
+ expectedCheckpointDigest?: string;
1506
+ /** The checkpoint's API version (for compatibility check). */
1507
+ checkpointApiVersion?: string;
1508
+ }
1509
+ interface ScriptAdmissionDecision {
1510
+ admitted: boolean;
1511
+ reason: string;
1512
+ /** Which interfaces are approved for this script. */
1513
+ approvedInterfaces: string[];
1514
+ /** Whether the checkpoint is compatible. */
1515
+ checkpointCompatible: boolean;
1516
+ /** If not admitted, whether the author can retry with changes. */
1517
+ retryable: boolean;
1518
+ }
1519
+ /**
1520
+ * The full interface set a host may grant to scripts authored under the
1521
+ * given trust class — a defensive copy of the trust profile's allowlist.
1522
+ *
1523
+ * Hosts wiring a {@link ../loopAPI/types.ScriptLoadGate} or a deployment
1524
+ * pipeline should pass these as `requestedInterfaces`; {@link admitScript}
1525
+ * rejects any request outside the trust profile, so this is the widest set
1526
+ * that can ever be approved for that class. Callers may pass a narrower
1527
+ * subset to further restrict a specific runtime.
1528
+ */
1529
+ declare function defaultRequestedInterfacesForTrustClass(trustClass: ScriptTrustClass): string[];
1530
+ /** Maximum script size in bytes admitted for the given trust class. */
1531
+ declare function maxScriptBytesForTrustClass(trustClass: ScriptTrustClass): number;
1532
+ /**
1533
+ * Decide whether a generated script may be admitted for execution.
1534
+ */
1535
+ declare function admitScript(request: ScriptAdmissionRequest): ScriptAdmissionDecision;
1536
+
1537
+ /**
1538
+ * Unified loop contract for all agent loop types.
1539
+ * Replaces the old AgentToolLoopInput / AgentToolLoopStep naming entirely.
1540
+ */
1541
+
1542
+ /** Standard input for any agent loop. */
1543
+ interface AgentLoopInput {
1544
+ conversationId: string;
1545
+ message: string;
1546
+ /** Host-prepared user message, used when the platform needs metadata/attachments on the turn root. */
1547
+ userMessage?: Omit<Partial<ChatMessage>, 'conversationId' | 'role'> & {
1548
+ content?: string;
1549
+ };
1550
+ /** If provided, these messages are loaded as conversation history on resume. */
1551
+ resumeSession?: ChatMessage[];
1552
+ }
1553
+ /** Standard output step yielded by any agent loop. */
1554
+ interface AgentLoopStep {
1555
+ type: 'thinking' | 'tool' | 'message' | 'permission_request';
1556
+ data: unknown;
1557
+ }
1558
+ /** Async iterable signature shared by all loop runners. */
1559
+ type AgentLoopGenerator = AsyncIterable<AgentLoopStep>;
1560
+ /** Describes a registered loop type. */
1561
+ interface AgentLoopDefinition {
1562
+ /** Unique id, e.g. "agent-tool-loop" or "agent-agent-loop". */
1563
+ id: string;
1564
+ /** Human-readable display name. */
1565
+ name: string;
1566
+ /** Short description of this loop's behaviour. */
1567
+ description: string;
1568
+ /** Factory: create a loop runner function for the given context. */
1569
+ createRunner: (context: {
1570
+ [key: string]: unknown;
1571
+ }) => (input: AgentLoopInput) => AgentLoopGenerator;
1572
+ }
1573
+ type LoopProfileScriptReference = {
1574
+ kind: 'builtin';
1575
+ id: string;
1576
+ } | {
1577
+ kind: 'specifier';
1578
+ specifier: string;
1579
+ } | {
1580
+ kind: 'source';
1581
+ source: string;
1582
+ name?: string;
1583
+ };
1584
+ /**
1585
+ * Request handed to a {@link ScriptLoadGate} before a data-URL/source script
1586
+ * is imported into the current process. The source has already been
1587
+ * normalized; the digest commits to the normalized form (plan 24.16).
1588
+ */
1589
+ interface ScriptLoadGateRequest {
1590
+ /** Normalized script source (`normalizeScript` output). */
1591
+ normalizedSource: string;
1592
+ /** Canonical SHA-256 hex digest of the normalized source. */
1593
+ digest: string;
1594
+ /** The original script reference being loaded. */
1595
+ reference: LoopProfileScriptReference;
1596
+ /** Script type label for diagnostics (e.g. "AgentAgentLoop script"). */
1597
+ scriptType: string;
1598
+ }
1599
+ /** Admission decision returned by a {@link ScriptLoadGate}. */
1600
+ interface ScriptLoadGateDecision {
1601
+ /** Whether the script may be imported into this process. */
1602
+ allowed: boolean;
1603
+ /** Human-readable denial reason (required when `allowed` is false). */
1604
+ reason?: string;
1605
+ /** Trust class assigned by admission (plan 24.17). */
1606
+ trustClass?: ScriptTrustClass;
1607
+ /** RuntimeClass name selected for the script (plan 24.18). */
1608
+ runtimeClass?: string;
1609
+ /** Whether the script may resume its expected checkpoint (plan 24.19). */
1610
+ checkpointCompatible?: boolean;
1611
+ }
1612
+ /**
1613
+ * Port: host-injected admission gate for script loading. Every non-builtin
1614
+ * script source must pass this gate before `import()`; when no gate is
1615
+ * configured the loader fails closed (denies all non-builtin sources).
1616
+ */
1617
+ interface ScriptLoadGate {
1618
+ admitScriptLoad(request: ScriptLoadGateRequest): Promise<ScriptLoadGateDecision> | ScriptLoadGateDecision;
1619
+ }
1620
+ interface AgentLoopScriptPolicy {
1621
+ allowBuiltin?: boolean;
1622
+ allowFile?: boolean;
1623
+ allowNetwork?: boolean;
1624
+ allowSource?: boolean;
1625
+ allowSpecifier?: boolean;
1626
+ importModule?: (specifier: string) => Promise<unknown>;
1627
+ /**
1628
+ * Host-provided admission gate for non-builtin script sources. When
1629
+ * omitted, all non-builtin sources are denied (fail-closed).
1630
+ */
1631
+ scriptLoadGate?: ScriptLoadGate;
1632
+ }
1633
+ /** Capability extension point for a loop. */
1634
+ interface LoopPlugin {
1635
+ /** Unique plugin id, e.g. "fullReplacement" or "wikiTools". */
1636
+ id: string;
1637
+ /** Which loop id this plugin targets, or "*" for all loops. */
1638
+ targetLoopId?: string;
1639
+ /** Optional schema to validate against profile config. */
1640
+ schema?: Record<string, unknown>;
1641
+ /** Install the plugin into the given context. Mutates the context in place. */
1642
+ install?: (context: {
1643
+ [key: string]: unknown;
1644
+ }, config?: Record<string, unknown>) => void;
1645
+ }
1646
+ /** A complete agent profile that describes which loop, which .mjs script, prompts, plugins, and hooks to use. */
1647
+ interface LoopProfile {
1648
+ /** Unique profile id, e.g. "memeloop:general-assistant". */
1649
+ id: string;
1650
+ /** Display name. */
1651
+ name: string;
1652
+ /** Description. */
1653
+ description: string;
1654
+ /** Which loop to run. Defaults to "agent-tool-loop" if omitted. */
1655
+ loopId?: string;
1656
+ /** Structured reference to the loop script. Prefer this over `script` for new profiles. */
1657
+ scriptReference?: LoopProfileScriptReference;
1658
+ /** Legacy alias for `scriptReference`. */
1659
+ scriptRef?: LoopProfileScriptReference;
1660
+ /** Legacy path/specifier to the .mjs loop script. */
1661
+ script?: string;
1662
+ /** System prompt (concise form; detailed prompts go to `prompts`). */
1663
+ systemPrompt?: string;
1664
+ /** Tool allowlist IDs. */
1665
+ tools?: string[];
1666
+ /** Agent-level tool configuration. */
1667
+ agentTools?: Array<{
1668
+ toolId: string;
1669
+ enabled?: boolean;
1670
+ parameters?: Record<string, unknown>;
1671
+ tags?: string[];
1672
+ }>;
1673
+ /** Full agent framework configuration. */
1674
+ agentFrameworkConfig?: AgentFrameworkConfig;
1675
+ /** System prompt(s) for the agent. */
1676
+ prompts?: LoopProfilePrompt[];
1677
+ /** Tool / prompt / response plugin configs. */
1678
+ plugins?: LoopProfilePluginEntry[];
1679
+ /** Hook plugin configs. */
1680
+ hookPlugins?: LoopProfilePluginEntry[];
1681
+ /** Model configuration. */
1682
+ modelConfig?: {
1683
+ provider?: string;
1684
+ model?: string;
1685
+ temperature?: number;
1686
+ maxTokens?: number;
1687
+ };
1688
+ /** Host-specific AI API config override. */
1689
+ aiApiConfig?: AiAPIConfig;
1690
+ /** Periodic auto-wake configuration. */
1691
+ heartbeat?: {
1692
+ enabled: boolean;
1693
+ intervalSeconds: number;
1694
+ message: string;
1695
+ activeHoursStart?: string;
1696
+ activeHoursEnd?: string;
1697
+ };
1698
+ /** Host-specific handler / framework ID. */
1699
+ agentFrameworkID?: string;
1700
+ /** Host-specific avatar or icon URL. */
1701
+ avatarUrl?: string;
1702
+ /** Tool permission configuration. */
1703
+ permissions?: {
1704
+ default?: 'allow' | 'ask' | 'deny';
1705
+ rules?: Array<{
1706
+ pattern: string;
1707
+ action: 'allow' | 'ask' | 'deny';
1708
+ }>;
1709
+ perAgent?: Record<string, {
1710
+ default?: string;
1711
+ rules?: Array<{
1712
+ pattern: string;
1713
+ action: string;
1714
+ }>;
1715
+ }>;
1716
+ };
1717
+ /** Open schema for host-specific or loop-specific configuration. */
1718
+ schema?: Record<string, unknown>;
1719
+ /** Arbitrary metadata. */
1720
+ metadata?: Record<string, unknown>;
1721
+ /** Version string. */
1722
+ version?: string;
1723
+ }
1724
+ interface LoopProfilePrompt {
1725
+ id: string;
1726
+ role: string;
1727
+ text: string;
1728
+ caption?: string;
1729
+ children?: LoopProfilePrompt[];
1730
+ }
1731
+ interface LoopProfilePluginEntry {
1732
+ /** Plugin id registered in the plugin registry. */
1733
+ id: string;
1734
+ /** Whether this plugin is enabled. */
1735
+ enabled?: boolean;
1736
+ /** Plugin-specific configuration. */
1737
+ config?: Record<string, unknown>;
1738
+ }
1739
+ /** Minimal runtime context passed to a loop runner. */
1740
+ interface AgentLoopRuntime {
1741
+ /** Resolve a profile by id. */
1742
+ resolveProfile: (profileId: string) => Promise<LoopProfile | null>;
1743
+ /** Policy-scoped declarative manager facade available to this loop. */
1744
+ orchestration?: AgentOrchestrationClient;
1745
+ /** Host-bound script deployment configuration used to build `ctx.scriptClient` (plan 24.14). */
1746
+ scriptDeployment?: ScriptDeploymentClientConfig;
1747
+ /** Run a child agent (or sub-loop) and return its result. */
1748
+ runChildAgent: (input: {
1749
+ profileId: string;
1750
+ prompt: string;
1751
+ conversationId: string;
1752
+ }) => AgentLoopGenerator;
1753
+ /** Log an event for observability. */
1754
+ log: (event: string, data?: Record<string, unknown>) => void;
1755
+ /** Read/write persistent state for this run. */
1756
+ state: {
1757
+ get: <T>(key: string) => Promise<T | undefined>;
1758
+ set: (key: string, value: unknown) => Promise<void>;
1759
+ update: (key: string, updater: (previous: unknown) => unknown) => Promise<void>;
1760
+ };
1761
+ /** Checkpoint a completed step so it can be skipped on resume. */
1762
+ checkpoint: (key: string, result: unknown) => Promise<void>;
1763
+ /** Load a previously completed step after process restart. */
1764
+ loadCheckpoint: <T>(key: string) => Promise<T | undefined>;
1765
+ /** Emit a progress step upstream. */
1766
+ emit: (step: AgentLoopStep) => void;
1767
+ /** Signal whether the run has been cancelled. */
1768
+ signal: {
1769
+ cancelled: boolean;
1770
+ };
1771
+ }
1772
+ interface LoopScriptCheckpointStore {
1773
+ saveCheckpoint(conversationId: string, key: string, result: unknown): Promise<void>;
1774
+ loadCheckpoint<T>(conversationId: string, key: string): Promise<T | undefined>;
1775
+ }
1776
+
1777
+ declare const TOOL_PARAMETER_PARSE_ERROR_KEY = "__memeloopToolParameterParseError";
1778
+ type ToolCallingMatch = {
1779
+ found: false;
1780
+ } | {
1781
+ found: true;
1782
+ toolId: string;
1783
+ parameters: Record<string, unknown>;
1784
+ originalText: string;
1785
+ };
1786
+ declare function matchToolCalling(responseText: string): ToolCallingMatch;
1787
+ declare function matchAllToolCallings(responseText: string): {
1788
+ calls: Array<ToolCallingMatch & {
1789
+ found: true;
1790
+ }>;
1791
+ parallel: boolean;
1792
+ };
1793
+
1794
+ /**
1795
+ * TidGi-Desktop `agentInstance/tools/types.ts` 迁移并适配 memeloop(无 tapable,用 HookSlot.promise 串行执行)。
1796
+ */
1797
+
1798
+ /** 供 defineTool / 审批使用:agent 视图包含完整 AgentInstance。 */
1799
+ type DefineToolAgentFrameworkContext = AgentFrameworkContext & {
1800
+ agent: AgentInstanceModel;
1801
+ };
1802
+ type ToolApprovalMode = 'auto' | 'confirm';
1803
+ interface ToolApprovalConfig {
1804
+ mode: ToolApprovalMode;
1805
+ allowPatterns?: string[];
1806
+ denyPatterns?: string[];
1807
+ timeoutMs?: number;
1808
+ }
1809
+ type ApprovalDecision = 'allow' | 'deny' | 'pending';
1810
+ interface ToolApprovalRequest {
1811
+ approvalId: string;
1812
+ agentId: string;
1813
+ toolName: string;
1814
+ parameters: Record<string, unknown>;
1815
+ originalText?: string;
1816
+ created: Date;
1817
+ }
1818
+ type YieldNextRoundTarget = 'human' | 'self' | `agent:${string}`;
1819
+ interface ToolActions {
1820
+ yieldNextRoundTo?: YieldNextRoundTarget;
1821
+ newUserMessage?: string;
1822
+ toolCalling?: ToolCallingMatch;
1823
+ }
1824
+ interface BaseToolContext {
1825
+ agentFrameworkContext: DefineToolAgentFrameworkContext;
1826
+ metadata?: Record<string, unknown>;
1827
+ actions?: ToolActions;
1828
+ }
1829
+ /** 与 TidGi IPromptConcatTool 对齐的插件行 */
1830
+ interface FrameworkPluginToolConfig {
1831
+ id: string;
1832
+ toolId: string;
1833
+ enabled?: boolean;
1834
+ caption?: string;
1835
+ content?: string;
1836
+ forbidOverrides?: boolean;
1837
+ approval?: ToolApprovalConfig;
1838
+ timeoutMs?: number;
1839
+ [key: string]: unknown;
1840
+ }
1841
+ interface PromptConcatHookContext extends BaseToolContext {
1842
+ messages: ChatMessage[];
1843
+ prompts: IPrompt[];
1844
+ toolConfig: FrameworkPluginToolConfig;
1845
+ pluginIndex?: number;
1846
+ }
1847
+ interface AgentResponse {
1848
+ id: string;
1849
+ text?: string;
1850
+ enabled?: boolean;
1851
+ children?: AgentResponse[];
1852
+ }
1853
+ interface PostProcessContext extends PromptConcatHookContext {
1854
+ llmResponse: string;
1855
+ responses?: AgentResponse[];
1856
+ }
1857
+ /** 流式响应子集(memeloop ILLMProvider 聚合为最终文本后注入) */
1858
+ interface AIStreamResponseSubset {
1859
+ status: 'update' | 'done';
1860
+ content: string;
1861
+ }
1862
+ interface AIResponseContext extends BaseToolContext {
1863
+ toolConfig: FrameworkPluginToolConfig;
1864
+ agentFrameworkConfig?: {
1865
+ plugins?: FrameworkPluginToolConfig[];
1866
+ };
1867
+ response: AIStreamResponseSubset;
1868
+ requestId?: string;
1869
+ isFinal?: boolean;
1870
+ }
1871
+ interface UserMessageContext extends BaseToolContext {
1872
+ content: {
1873
+ text: string;
1874
+ file?: unknown;
1875
+ wikiTiddlers?: Array<{
1876
+ workspaceName: string;
1877
+ tiddlerTitle: string;
1878
+ }>;
1879
+ };
1880
+ messageId: string;
1881
+ timestamp: Date;
1882
+ }
1883
+ interface AgentStatusContext extends BaseToolContext {
1884
+ status: {
1885
+ state: 'working' | 'completed' | 'failed' | 'canceled';
1886
+ modified: Date;
1887
+ };
1888
+ }
1889
+ interface ToolExecutionContext extends BaseToolContext {
1890
+ toolResult: {
1891
+ success: boolean;
1892
+ data?: string;
1893
+ error?: string;
1894
+ metadata?: Record<string, unknown>;
1895
+ };
1896
+ toolInfo: {
1897
+ toolId: string;
1898
+ parameters: Record<string, unknown>;
1899
+ originalText?: string;
1900
+ };
1901
+ requestId?: string;
1902
+ }
1903
+ /**
1904
+ * Hook 槽:与 tapable AsyncSeriesHook 一致 — `tapAsync` 注册,`promise(ctx)` 串行触发。
1905
+ */
1906
+ type TapAsyncHandler = {
1907
+ bivarianceHack(context: unknown, callback: () => void): void;
1908
+ }['bivarianceHack'];
1909
+ interface HookSlot {
1910
+ tapAsync(name: string, function_: TapAsyncHandler): void;
1911
+ promise(context: unknown): Promise<void>;
1912
+ }
1913
+ interface PromptConcatHooks {
1914
+ processPrompts: HookSlot;
1915
+ finalizePrompts: HookSlot;
1916
+ postProcess: HookSlot;
1917
+ userMessageReceived: HookSlot;
1918
+ agentStatusChanged: HookSlot;
1919
+ toolExecuted: HookSlot;
1920
+ responseUpdate: HookSlot;
1921
+ responseComplete: HookSlot;
1922
+ }
1923
+ type PromptConcatTool = (hooks: PromptConcatHooks) => void;
1924
+
1925
+ interface CheckpointRecord {
1926
+ conversationId: string;
1927
+ messages: ChatMessage[];
1928
+ savedAt: string;
1929
+ messageCount: number;
1930
+ lastMessagePreview: string;
1931
+ }
1932
+ interface CheckpointSummary {
1933
+ conversationId: string;
1934
+ savedAt: string;
1935
+ messageCount: number;
1936
+ lastMessagePreview: string;
1937
+ }
1938
+ interface CheckpointStore {
1939
+ saveCheckpoint(conversationId: string, messages: ChatMessage[]): Promise<CheckpointRecord>;
1940
+ loadCheckpoint(conversationId: string): Promise<CheckpointRecord | null>;
1941
+ listCheckpoints(): Promise<CheckpointSummary[]>;
1942
+ deleteCheckpoint(conversationId: string): Promise<boolean>;
1943
+ }
1944
+ interface SessionStorageOptions {
1945
+ records?: CheckpointRecord[];
1946
+ }
1947
+ declare function createCheckpointRecord(conversationId: string, messages: ChatMessage[], savedAt?: string): CheckpointRecord;
1948
+ declare function parseCheckpointRecord(raw: string): CheckpointRecord | null;
1949
+ declare function serializeCheckpointRecord(record: CheckpointRecord): string;
1950
+ declare class InMemoryCheckpointStore implements CheckpointStore {
1951
+ private readonly records;
1952
+ constructor(options?: SessionStorageOptions);
1953
+ saveCheckpoint(conversationId: string, messages: ChatMessage[]): Promise<CheckpointRecord>;
1954
+ loadCheckpoint(conversationId: string): Promise<CheckpointRecord | null>;
1955
+ listCheckpoints(): Promise<CheckpointSummary[]>;
1956
+ deleteCheckpoint(conversationId: string): Promise<boolean>;
1957
+ }
1958
+ declare class SessionStorage extends InMemoryCheckpointStore {
1959
+ }
1960
+
1961
+ interface MemeLoopLogger {
1962
+ debug?(message: string, ...arguments_: unknown[]): void;
1963
+ info?(message: string, ...arguments_: unknown[]): void;
1964
+ warn?(message: string, ...arguments_: unknown[]): void;
1965
+ error?(message: string, ...arguments_: unknown[]): void;
1966
+ }
1967
+ interface ILLMProvider {
1968
+ name: string;
1969
+ /**
1970
+ * Serializable default model identity used by orchestration resources.
1971
+ * `model` may be an SDK object or factory and must never be persisted.
1972
+ */
1973
+ modelId?: string;
1974
+ model?: unknown;
1975
+ chat(request: unknown): AsyncIterable<unknown> | Promise<unknown>;
1976
+ }
1977
+ interface IToolRegistry {
1978
+ registerTool(id: string, impl: unknown, parameterSchema?: unknown, effect?: ToolOperationEffect): void;
1979
+ getTool(id: string): unknown | undefined;
1980
+ listTools(): string[];
1981
+ /**
1982
+ * Instance-local schema lookup. Managed catalogs use this when available so
1983
+ * one embedded runtime cannot inherit another runtime's process-global schema.
1984
+ */
1985
+ getToolParameterSchema?: (id: string) => unknown | undefined;
1986
+ /** Host-authoritative effect classification; omitted tools default to conservative execute. */
1987
+ getToolEffect?: (id: string) => ToolOperationEffect | undefined;
1988
+ /** Prompt-concat plugin registry, isolated per runtime. Falls back to the process-level default registry. */
1989
+ getPromptPlugins?: () => Map<string, (hooks: PromptConcatHooks) => void>;
1990
+ }
1991
+ interface IChatSyncAdapter {
1992
+ start(): Promise<void>;
1993
+ stop(): Promise<void>;
1994
+ }
1995
+ interface INetworkService {
1996
+ start(): Promise<void>;
1997
+ stop(): Promise<void>;
1998
+ }
1999
+ interface AgentToolLoopOptions {
2000
+ /** Maximum LLM-to-tool round-trips. `0` means unlimited, still capped internally. */
2001
+ maxIterations?: number;
2002
+ /** Whether to parse `<tool_use>` / `<function_call>` and execute through `IToolRegistry` (default true). */
2003
+ enableToolLoop?: boolean;
2004
+ /** Cancellation check, e.g. when the user stops a run. */
2005
+ isCancelled?: (conversationId: string) => boolean;
2006
+ /** Attachment injection for promptConcat, aligned with `PromptConcatOptions`. */
2007
+ readAttachmentFile?: (path: string) => Promise<Uint8Array>;
2008
+ /** Omit history older than this many milliseconds when building LLM input. `0` disables trimming. */
2009
+ maxHistoryAgeMs?: number;
2010
+ /**
2011
+ * When `defineTool` / plugins are configured, fall back to `IToolRegistry` for tool calls not handled by `onResponseComplete`.
2012
+ */
2013
+ fallbackRegistryTools?: boolean;
2014
+ /**
2015
+ * Tool permission rules (default allow).
2016
+ * Supports wildcards such as "terminal.*" and "file.read".
2017
+ */
2018
+ toolPermissions?: {
2019
+ default?: 'allow' | 'ask' | 'deny';
2020
+ rules?: Array<{
2021
+ pattern: string;
2022
+ action: 'allow' | 'ask' | 'deny';
2023
+ }>;
2024
+ perAgent?: Record<string, {
2025
+ default?: 'allow' | 'ask' | 'deny';
2026
+ rules?: Array<{
2027
+ pattern: string;
2028
+ action: 'allow' | 'ask' | 'deny';
2029
+ }>;
2030
+ }>;
2031
+ };
2032
+ /** Threshold for repeated identical tool+input calls (default 3). */
2033
+ doomLoopThreshold?: number;
2034
+ /**
2035
+ * Timeout for a single ToolOperation executed through the orchestration
2036
+ * facade (default 60_000ms). Covers the full lifecycle from apply until a
2037
+ * terminal phase, including scheduling and remote execution.
2038
+ */
2039
+ toolOperationTimeoutMs?: number;
2040
+ /**
2041
+ * Host-bound trust class of the node running this loop. Restricted and
2042
+ * quarantine nodes default the model-facing tool permission layer to deny
2043
+ * when no explicit wildcard rule exists. Bound by the host at assembly
2044
+ * time; never self-reported by the workload or model.
2045
+ */
2046
+ trustClass?: NodeTrustClass;
2047
+ /** History compaction window: keep the most recent N turns plus the last user message. */
2048
+ contextCompaction?: {
2049
+ maxMessages?: number;
2050
+ replayLastUserMessage?: boolean;
2051
+ };
2052
+ /**
2053
+ * Auto-compaction: when message count exceeds threshold, summarizes old
2054
+ * conversation turns via truncation or LLM summarization. Default: disabled.
2055
+ */
2056
+ autoCompact?: {
2057
+ /** Trigger compaction when message count exceeds this (default: 50) */
2058
+ threshold?: number;
2059
+ /** Number of recent turns to preserve (default: 4) */
2060
+ recentTurnsToKeep?: number;
2061
+ /** Maximum token estimate before compaction; 0 disables token-based compaction */
2062
+ maxTokens?: number;
2063
+ };
2064
+ /** Session checkpoint: save conversation history after each turn for resume. */
2065
+ sessionCheckpoint?: {
2066
+ /** Enable checkpoint saves. Default: false. */
2067
+ enabled?: boolean;
2068
+ /** Store provided by the runtime host. */
2069
+ store?: CheckpointStore;
2070
+ /** Custom checkpoint directory (default: ~/.memeloop/sessions/) */
2071
+ directory?: string;
2072
+ };
2073
+ /**
2074
+ * After a tool returns `__memeloopToolResult.awaitSessionId`, AgentToolLoop waits here before the next LLM round.
2075
+ */
2076
+ waitForTerminalSession?: (sessionId: string) => Promise<{
2077
+ exitCode: number | null;
2078
+ truncatedOutput: string;
2079
+ }>;
2080
+ }
2081
+ interface AgentFrameworkContext {
2082
+ storage: IAgentStorage;
2083
+ llmProvider: ILLMProvider;
2084
+ tools: IToolRegistry;
2085
+ syncAdapters: IChatSyncAdapter[];
2086
+ network: INetworkService;
2087
+ /** Policy-scoped declarative manager facade shared by Agent loops and Agent-facing tools. */
2088
+ orchestration?: AgentOrchestrationClient;
2089
+ /**
2090
+ * Host-bound script deployment configuration (plan 24.14). Loop runtimes
2091
+ * build a `ctx.scriptClient` from it; scripts never see the raw config,
2092
+ * so trust class and interface ceilings stay host-controlled.
2093
+ */
2094
+ scriptDeployment?: ScriptDeploymentClientConfig;
2095
+ /** Trusted controller state store; Agent-facing loop scripts receive only its checkpoint adapter. */
2096
+ controlStore?: ControlStore;
2097
+ /** Durable milestones used by script-backed loops such as quality-gate. */
2098
+ loopCheckpoints?: LoopScriptCheckpointStore;
2099
+ /** Let host runtimes preserve platform-specific message aliases/metadata while core owns the loop. */
2100
+ normalizeMessage?: (message: ChatMessage) => ChatMessage;
2101
+ /**
2102
+ * Notify a host about an in-memory streaming message. The core invokes this
2103
+ * with the same message ID used for the immutable final persisted message.
2104
+ */
2105
+ onTransientMessage?: (message: ChatMessage) => void | Promise<void>;
2106
+ /** AgentToolLoop ReAct behavior, migrated from the TidGi-Desktop agentToolLoop integration. */
2107
+ agentToolLoop?: AgentToolLoopOptions;
2108
+ /**
2109
+ * Host-injected runner used by `createMemeLoopRuntime` after a user sends a message.
2110
+ */
2111
+ runAgentToolLoop?: (input: AgentLoopInput) => AgentLoopGenerator;
2112
+ /** Run a child agent for orchestration loops such as AgentAgentLoop. */
2113
+ runChildAgent?: AgentLoopRuntime['runChildAgent'];
2114
+ /** Policy for loading script-backed loops. Defaults to bundled scripts + import specifiers only. */
2115
+ loopScriptPolicy?: AgentLoopScriptPolicy;
2116
+ /**
2117
+ * Build the agent view supplied to defineTool hooks for a conversation.
2118
+ */
2119
+ resolveAgentRuntimeView?: (conversationId: string, messages: ChatMessage[]) => Promise<AgentInstanceModel>;
2120
+ /** Current agent view for defineTool / TidGi compatibility. */
2121
+ agent?: {
2122
+ id: string;
2123
+ messages: ChatMessage[];
2124
+ };
2125
+ /** Persist a `ChatMessage` if the runtime host supplies this hook. */
2126
+ persistAgentMessage?: (message: ChatMessage) => Promise<void>;
2127
+ /** Cancellation markers written by `createMemeLoopRuntime`. */
2128
+ conversationCancellation?: Set<string>;
2129
+ /** Resolve an AgentDefinition from host-specific sources. */
2130
+ resolveAgentDefinition?: (definitionId: string) => Promise<AgentDefinition | null>;
2131
+ /** Fallback logger used when the host does not inject one. */
2132
+ logger?: MemeLoopLogger;
2133
+ /** TidGi defineTool compatibility: legacy plugins call this without arguments. */
2134
+ isCancelled?: () => boolean;
2135
+ }
2136
+ type AgentInstanceState = 'submitted' | 'working' | 'input-required' | 'completed' | 'canceled' | 'failed' | 'unknown';
2137
+ interface AgentInstanceLatestStatus {
2138
+ state: AgentInstanceState;
2139
+ message?: ChatMessage;
2140
+ /** Human-readable sub-status for the header — shown while agent is working. */
2141
+ progress?: string;
2142
+ created?: Date;
2143
+ modified?: Date;
2144
+ }
2145
+ interface AgentInstanceModel extends Omit<AgentDefinition, 'name'> {
2146
+ agentDefId: string;
2147
+ name?: string;
2148
+ agentFrameworkConfig?: AgentFrameworkConfig;
2149
+ messages: ChatMessage[];
2150
+ status: AgentInstanceLatestStatus;
2151
+ created: Date;
2152
+ modified?: Date;
2153
+ closed?: boolean;
2154
+ volatile?: boolean;
2155
+ isDelegatedAgentRun?: boolean;
2156
+ parentAgentRunId?: string;
2157
+ }
2158
+
2159
+ declare function isUserInitiatedConversation(meta: ConversationMeta): boolean;
2160
+ declare function createInstanceDeltaFromDefinition(definition: AgentDefinition, overrides: Partial<AgentDefinition>): Partial<AgentDefinition>;
2161
+
2162
+ interface RuntimeClassSpec {
2163
+ /** Module isolation level. */
2164
+ isolation: 'none' | 'process' | 'container';
2165
+ /** CPU limit in millicores (1000 = 1 core). */
2166
+ cpuLimitMillis?: number;
2167
+ /** Memory limit in bytes. */
2168
+ memoryLimitBytes?: number;
2169
+ /** Wall-clock time limit in milliseconds. */
2170
+ timeLimitMs?: number;
2171
+ /** Whether the runtime supports cancellation signals. */
2172
+ supportsCancellation: boolean;
2173
+ /** Supported trust classes for this runtime. */
2174
+ supportedTrustClasses: ScriptTrustClass[];
2175
+ /** Whether network access is allowed (outbound-only for quarantine). */
2176
+ networkAccess: 'none' | 'outbound-only' | 'full';
2177
+ }
2178
+ interface RuntimeClassResource {
2179
+ apiVersion: 'execution.memeloop.io/v1alpha1';
2180
+ kind: 'RuntimeClass';
2181
+ metadata: {
2182
+ name: string;
2183
+ namespace?: string;
2184
+ };
2185
+ spec: RuntimeClassSpec;
2186
+ }
2187
+ declare const BUILTIN_RUNTIME_CLASSES: Record<string, RuntimeClassSpec>;
2188
+ interface SandboxSelectionResult {
2189
+ runtimeClass: string;
2190
+ isolation: RuntimeClassSpec['isolation'];
2191
+ cpuLimitMillis: number;
2192
+ memoryLimitBytes: number;
2193
+ timeLimitMs: number;
2194
+ networkAccess: RuntimeClassSpec['networkAccess'];
2195
+ }
2196
+ /**
2197
+ * Select the most restrictive RuntimeClass capable of hosting the given
2198
+ * trust class. Throws when no available RuntimeClass supports the trust
2199
+ * class — there is no silent fallback (24.18).
2200
+ */
2201
+ declare function selectRuntimeClass(trustClass: ScriptTrustClass, available?: string[]): SandboxSelectionResult;
2202
+ /**
2203
+ * Reference to a content-addressed ArtifactRecord holding the script source
2204
+ * (plan 24.15/24.47). Remote deployments never carry raw script source
2205
+ * strings; the target node resolves the artifact by identity and verifies
2206
+ * it against `contentDigest` before loading.
2207
+ */
2208
+ interface ScriptArtifactReference {
2209
+ /** API version of the artifact resource (`artifacts.memeloop.io/v1alpha1`). */
2210
+ apiVersion: string;
2211
+ /** Resource kind; always `ArtifactRecord`. */
2212
+ kind: 'ArtifactRecord';
2213
+ /** Artifact resource name. */
2214
+ name: string;
2215
+ /** Artifact namespace, if any. */
2216
+ namespace?: string;
2217
+ /**
2218
+ * Content digest (`sha256:<hex>`) of the NORMALIZED script source. The
2219
+ * remote node must verify the fetched artifact content against this
2220
+ * digest before admission.
2221
+ */
2222
+ contentDigest: string;
2223
+ }
2224
+ interface RemoteDeploymentRequest {
2225
+ /**
2226
+ * Content-addressed reference to the script artifact. Raw script source
2227
+ * is never transported inside a deployment request.
2228
+ */
2229
+ artifactRef: ScriptArtifactReference;
2230
+ /** Trust class assigned by admission. */
2231
+ trustClass: ScriptTrustClass;
2232
+ /** Desired lifecycle. */
2233
+ lifecycle: 'run-once' | 'service' | 'schedule';
2234
+ /** Runtime class to use. */
2235
+ runtimeClass: string;
2236
+ /** Node selector for scheduling. */
2237
+ nodeSelector?: Record<string, string>;
2238
+ /** Environment variables (never credentials). */
2239
+ env?: Record<string, string>;
2240
+ /** Network attachment requirements enforced before the script starts. */
2241
+ networkPolicy?: AgentWorkloadNetworkPolicy;
2242
+ /** Existing claims to publish before the script starts. */
2243
+ storagePolicy?: AgentWorkloadStoragePolicy;
2244
+ }
2245
+ interface RemoteDeploymentResult {
2246
+ /** Workload name created on the target node. */
2247
+ workloadName: string;
2248
+ /** Node the workload was placed on. */
2249
+ nodeName: string;
2250
+ /** When the deployment was requested. */
2251
+ requestedAt: string;
2252
+ }
2253
+
2254
+ /**
2255
+ * Generated-script deployment pipeline (plans 24.14–24.19, 24.47).
2256
+ *
2257
+ * Connects the full security chain for remote/generated scripts:
2258
+ *
2259
+ * normalizeScript → validateScript (Acorn AST) → admitScript (trust-class
2260
+ * policy) → ArtifactRecord manifest (content-addressed) → persist via the
2261
+ * injected artifact store port → selectRuntimeClass →
2262
+ * RemoteDeploymentRequest (artifactRef only — raw source is never carried).
2263
+ *
2264
+ * Also provides {@link createScriptLoadGate}, the production
2265
+ * {@link ScriptLoadGate} implementation for the in-process script loading
2266
+ * path (`loopAPI/scriptLoader`): validate (AST) → admit → assign
2267
+ * trustClass/RuntimeClass before any `import()` executes.
2268
+ *
2269
+ * Everything here is pure and portable; artifact persistence sits behind the
2270
+ * {@link ScriptArtifactStore} port so the CLI can back it with real storage.
2271
+ */
2272
+
2273
+ /**
2274
+ * Port: persists a script ArtifactRecord manifest plus its normalized
2275
+ * content. Implementations (e.g. CLI storage) must store content addressed
2276
+ * by `manifest.spec.contentHash` and must not trust content whose hash does
2277
+ * not match the manifest.
2278
+ */
2279
+ interface ScriptArtifactStore {
2280
+ putArtifact(manifest: ArtifactRecordManifest, normalizedContent: string): Promise<void> | void;
2281
+ }
2282
+ /** Input for {@link deployGeneratedScript}. */
2283
+ interface ScriptDeploymentRequest {
2284
+ /** Raw generated `.mjs` source (normalized internally). */
2285
+ source: string;
2286
+ /** Trust class of the author (the Agent that generated the script). */
2287
+ authorTrust: ScriptTrustClass;
2288
+ /** Interfaces the script requests (loop-runtime, model-provider, ...). */
2289
+ requestedInterfaces: string[];
2290
+ /** Desired lifecycle for the remote workload. */
2291
+ lifecycle: 'run-once' | 'service' | 'schedule';
2292
+ /** Node selector for scheduling. */
2293
+ nodeSelector?: Record<string, string>;
2294
+ /** Environment variables (never credentials). */
2295
+ env?: Record<string, string>;
2296
+ /** Network attachment requirements for the deployed workload. */
2297
+ networkPolicy?: AgentWorkloadNetworkPolicy;
2298
+ /** Existing volume claims required by the deployed workload. */
2299
+ storagePolicy?: AgentWorkloadStoragePolicy;
2300
+ /** Optional checkpoint digest the script expects to resume from. */
2301
+ expectedCheckpointDigest?: string;
2302
+ /** API version of the expected checkpoint (plan 24.19). */
2303
+ checkpointApiVersion?: string;
2304
+ /** Namespace for the ArtifactRecord and deployment. */
2305
+ namespace?: string;
2306
+ }
2307
+ /** Tunables for {@link deployGeneratedScript}. */
2308
+ interface ScriptDeploymentPipelineOptions {
2309
+ /** Artifact persistence port; when omitted the manifest is built but not persisted. */
2310
+ artifactStore?: ScriptArtifactStore;
2311
+ /** RuntimeClass names available for selection (defaults to all built-ins). */
2312
+ availableRuntimeClasses?: string[];
2313
+ }
2314
+ /** Result of {@link deployGeneratedScript}; `deployed` gates artifact/deployment presence. */
2315
+ interface ScriptDeploymentResult {
2316
+ /** Whether a deployment request was produced. */
2317
+ deployed: boolean;
2318
+ /** Human-readable outcome (validation/admission/enforcement reason). */
2319
+ reason: string;
2320
+ /** AST validation outcome (always present). */
2321
+ validation: ScriptValidationResult;
2322
+ /** Admission decision (present once validation passed). */
2323
+ admission?: ScriptAdmissionDecision;
2324
+ /** Content-addressed artifact manifest (present when deployed). */
2325
+ artifact?: ArtifactRecordManifest;
2326
+ /** Selected RuntimeClass (present when deployed). */
2327
+ runtimeClass?: SandboxSelectionResult;
2328
+ /** Deployment request referencing the artifact by digest (present when deployed). */
2329
+ deployment?: RemoteDeploymentRequest;
2330
+ /** Applied AgentWorkload (present when deployed through an orchestration facade). */
2331
+ workload?: AgentWorkloadResource;
2332
+ }
2333
+ interface RemoteDeploymentWorkloadOptions {
2334
+ /** Workload name (defaults to the content-addressed artifact name). */
2335
+ name?: string;
2336
+ namespace?: string;
2337
+ ownerReferences?: OrchestrationOwnerReference[];
2338
+ }
2339
+ /**
2340
+ * Translate a {@link RemoteDeploymentRequest} into an AgentWorkload manifest
2341
+ * the binding controller (24.56) can schedule. The script declares placement
2342
+ * and lifecycle; the scheduler — never the script — selects the node.
2343
+ */
2344
+ declare function remoteDeploymentToWorkloadManifest(deployment: RemoteDeploymentRequest, options?: RemoteDeploymentWorkloadOptions): AgentWorkloadManifest;
2345
+ /**
2346
+ * Run the full generated-script security chain and produce a remote
2347
+ * deployment request. Never throws for script-content problems — invalid or
2348
+ * inadmissible scripts yield `deployed: false` with a structured reason.
2349
+ *
2350
+ * Checkpoint compatibility (plan 24.19) is enforced here: when the caller
2351
+ * expects to resume a checkpoint and admission found it incompatible, no
2352
+ * deployment is produced (an explicit converter or restart policy would be
2353
+ * required first).
2354
+ */
2355
+ declare function deployGeneratedScript(request: ScriptDeploymentRequest, options?: ScriptDeploymentPipelineOptions): Promise<ScriptDeploymentResult>;
2356
+ /** Configuration for {@link createScriptLoadGate}. */
2357
+ interface ScriptLoadGateConfig {
2358
+ /** Trust class to assign admitted scripts (plan 24.17). */
2359
+ authorTrust: ScriptTrustClass;
2360
+ /** Interfaces admitted scripts may request. */
2361
+ requestedInterfaces: string[];
2362
+ /** RuntimeClass names available for selection (defaults to all built-ins). */
2363
+ availableRuntimeClasses?: string[];
2364
+ /** Optional checkpoint digest admitted scripts expect to resume from. */
2365
+ expectedCheckpointDigest?: string;
2366
+ /** API version of the expected checkpoint (plan 24.19). */
2367
+ checkpointApiVersion?: string;
2368
+ }
2369
+ /**
2370
+ * Create the production {@link ScriptLoadGate}: every non-builtin source is
2371
+ * validated (Acorn AST), admitted under the configured trust-class policy,
2372
+ * and assigned a RuntimeClass before the loader is allowed to `import()` it.
2373
+ * The gate verifies that the digest computed by the loader matches the
2374
+ * digest of the source it validated, so the admitted bytes are exactly the
2375
+ * imported bytes.
2376
+ */
2377
+ declare function createScriptLoadGate(config: ScriptLoadGateConfig): ScriptLoadGate;
2378
+ /**
2379
+ * Host-bound configuration for {@link createScriptDeploymentClient}.
2380
+ * Trust and interface ceilings come from the host, never from the calling
2381
+ * script — a script cannot elevate its own trust class or widen the
2382
+ * interface set beyond what the host configured.
2383
+ */
2384
+ interface ScriptDeploymentClientConfig {
2385
+ /** Trust class the host assigns to deployments from this context. */
2386
+ authorTrust: ScriptTrustClass;
2387
+ /**
2388
+ * Interface ceiling for deployments (defaults to the widest set
2389
+ * admissible for `authorTrust`). Scripts may request a narrower subset;
2390
+ * anything wider is rejected by admission.
2391
+ */
2392
+ requestedInterfaces?: string[];
2393
+ /** RuntimeClass names available for selection (defaults to all built-ins). */
2394
+ availableRuntimeClasses?: string[];
2395
+ /** Artifact persistence port; when omitted manifests are built but not persisted. */
2396
+ artifactStore?: ScriptArtifactStore;
2397
+ /** Default namespace for produced ArtifactRecords and deployments. */
2398
+ namespace?: string;
2399
+ /**
2400
+ * Orchestration facade. When present, `deploy` also applies an
2401
+ * AgentWorkload so the scheduler binds a node (plan 24.14); when absent,
2402
+ * `deploy` only produces the deployment request and the readiness/deletion
2403
+ * methods reject with UNSUPPORTED.
2404
+ */
2405
+ orchestration?: AgentOrchestrationClient;
2406
+ /** Field manager for applied workloads (default `memeloop/script-deployment`). */
2407
+ fieldManager?: string;
2408
+ }
2409
+ /** Request a script makes through the deployment client. */
2410
+ interface ScriptDeploymentClientRequest {
2411
+ /** Raw generated `.mjs` source (normalized internally). */
2412
+ source: string;
2413
+ /** Desired lifecycle for the remote workload. */
2414
+ lifecycle: 'run-once' | 'service' | 'schedule';
2415
+ /** Optional narrower interface subset (must stay within the host ceiling). */
2416
+ requestedInterfaces?: string[];
2417
+ /** Node selector for scheduling. */
2418
+ nodeSelector?: Record<string, string>;
2419
+ /** Environment variables (never credentials). */
2420
+ env?: Record<string, string>;
2421
+ /** Network attachment requirements for the deployed workload. */
2422
+ networkPolicy?: AgentWorkloadNetworkPolicy;
2423
+ /** Existing volume claims required by the deployed workload. */
2424
+ storagePolicy?: AgentWorkloadStoragePolicy;
2425
+ /** Optional checkpoint digest the script expects to resume from. */
2426
+ expectedCheckpointDigest?: string;
2427
+ /** API version of the expected checkpoint (plan 24.19). */
2428
+ checkpointApiVersion?: string;
2429
+ /** Namespace override (defaults to the configured namespace). */
2430
+ namespace?: string;
2431
+ }
2432
+ /** Agent-facing handle for declarative script deployment (plan 24.14). */
2433
+ interface ScriptDeploymentClient {
2434
+ /**
2435
+ * Validate, admit, persist, and package a generated script as a
2436
+ * {@link RemoteDeploymentRequest} referencing its ArtifactRecord by
2437
+ * digest. When an orchestration facade is configured, also applies the
2438
+ * AgentWorkload so the scheduler binds a node. Never throws for
2439
+ * script-content problems — inadmissible scripts yield `deployed: false`
2440
+ * with a structured reason.
2441
+ */
2442
+ deploy(request: ScriptDeploymentClientRequest): Promise<ScriptDeploymentResult>;
2443
+ /**
2444
+ * Wait until the scheduler has bound the deployment's workload
2445
+ * (`Scheduled=True` condition written by the binding controller).
2446
+ */
2447
+ waitForScheduled(name: string, options?: WaitForConditionOptions & {
2448
+ namespace?: string;
2449
+ }): Promise<{
2450
+ observedResourceVersion: string;
2451
+ matched: true;
2452
+ }>;
2453
+ /** Delete the deployment's workload. */
2454
+ deleteDeployment(name: string, namespace?: string): Promise<void>;
2455
+ }
2456
+ /**
2457
+ * Create the Agent-facing deployment client injected into `.mjs` scripts
2458
+ * as `ctx.scriptClient` (plan 24.14). The script declares placement and
2459
+ * lifecycle; trust, interface ceilings, and persistence are bound by the
2460
+ * host. The scheduler — not the script — selects the target node.
2461
+ */
2462
+ declare function createScriptDeploymentClient(config: ScriptDeploymentClientConfig): ScriptDeploymentClient;
2463
+
2464
+ export { type AgentRunCondition as $, type AgentFrameworkContext as A, type AgentClient as B, type ScriptDeploymentClient as C, type ToolApprovalConfig as D, type ApprovalDecision as E, type ToolApprovalRequest as F, type PromptConcatHookContext as G, type DefineToolAgentFrameworkContext as H, type IChatSyncAdapter as I, type PostProcessContext as J, type AIResponseContext as K, type LoopPlugin as L, type MemeLoopLogger as M, type PromptConcatHooks as N, AGENT_RUN_API_VERSION as O, type PromptConcatTool as P, AGENT_RUN_KIND as Q, AGENT_WORKLOAD_API_VERSION as R, type ScriptLoadGate as S, TOOL_PARAMETER_PARSE_ERROR_KEY as T, AGENT_WORKLOAD_KIND as U, type AIStreamResponseSubset as V, ARTIFACT_RECORD_API_VERSION as W, ARTIFACT_RECORD_KIND as X, AUDIT_RECORD_API_VERSION as Y, AUDIT_RECORD_KIND as Z, type AgentResponse as _, type AgentInstanceModel as a, type ControlStoreStatusUpdateOptions as a$, type AgentRunManifest as a0, type AgentRunResource as a1, type AgentRunSpec as a2, type AgentRunStatus as a3, type AgentSnapshotManifest as a4, type AgentSnapshotResource as a5, type AgentSnapshotSpec as a6, type AgentSnapshotStatus as a7, type AgentStatusContext as a8, type AgentTrustLevel as a9, type ArtifactRecordSpec as aA, type ArtifactRecordStatus as aB, type ArtifactReviewEvidence as aC, type ArtifactReviewKind as aD, type ArtifactTrust as aE, type AuditRecordManifest as aF, type AuditRecordResource as aG, type AuditRecordSpec as aH, BUILTIN_RUNTIME_CLASSES as aI, type BaseToolContext as aJ, CREDENTIAL_GRANT_API_VERSION as aK, CREDENTIAL_GRANT_KIND as aL, type CheckpointRecord as aM, type CheckpointStore as aN, type CheckpointSummary as aO, type ControlLeaseGrant as aP, type ControlLeaseIdentity as aQ, type ControlLeaseRequest as aR, type ControlStore as aS, type ControlStoreActor as aT, type ControlStoreApplyOptions as aU, type ControlStoreAuthorizationRequest as aV, type ControlStoreAuthorizer as aW, type ControlStoreCompactionResult as aX, type ControlStoreCreateOptions as aY, type ControlStoreHealth as aZ, type ControlStoreSnapshotResult as a_, type AgentVolumeClaimManifest as aa, type AgentVolumeClaimResource as ab, type AgentVolumeClaimSpec as ac, type AgentVolumeClaimStatus as ad, type AgentVolumeManifest as ae, type AgentVolumeReplicaStatus as af, type AgentVolumeResource as ag, type AgentVolumeSpec as ah, type AgentVolumeStatus as ai, type AgentWorkloadCompletionPolicy as aj, type AgentWorkloadCondition as ak, type AgentWorkloadCredentialPolicy as al, type AgentWorkloadManifest as am, type AgentWorkloadModelPolicy as an, type AgentWorkloadNetworkPolicy as ao, type AgentWorkloadPlacement as ap, type AgentWorkloadResource as aq, type AgentWorkloadResourceRequirements as ar, type AgentWorkloadSpec as as, type AgentWorkloadStatus as at, type AgentWorkloadStoragePolicy as au, type AgentWorkloadToolPolicy as av, type AgentWorkloadVolumeClaim as aw, type ArtifactDestination as ax, type ArtifactRecordManifest as ay, type ArtifactRecordResource as az, type AgentInstanceLatestStatus as b, type RuntimeClassSpec as b$, type ControlStoreVerb as b0, type CreateAgentRunOptions as b1, type CreateAgentWorkloadOptions as b2, type CredentialGrantManifest as b3, type CredentialGrantResource as b4, type CredentialGrantSpec as b5, type CredentialGrantStatus as b6, DRIVER_MANIFEST_API_VERSION as b7, DRIVER_MANIFEST_KIND as b8, type DataClassification as b9, type ModelEndpointStatus as bA, type ModelModality as bB, NETWORK_ATTACHMENT_API_VERSION as bC, NETWORK_ATTACHMENT_KIND as bD, NETWORK_CLASS_API_VERSION as bE, NETWORK_CLASS_KIND as bF, type NetworkAttachmentManifest as bG, type NetworkAttachmentResource as bH, type NetworkAttachmentSpec as bI, type NetworkAttachmentStatus as bJ, type NetworkClassManifest as bK, type NetworkClassResource as bL, type NetworkClassSpec as bM, type NetworkClassStatus as bN, type NetworkEgressRule as bO, type NodeTrustClass as bP, POLICY_DECISION_API_VERSION as bQ, POLICY_DECISION_KIND as bR, type PersistedPolicyDecisionKind as bS, type PolicyDecisionManifest as bT, type PolicyDecisionResource as bU, type PolicyDecisionSpec as bV, type PolicyDecisionStatus as bW, type RemoteDeploymentRequest as bX, type RemoteDeploymentResult as bY, type RemoteDeploymentWorkloadOptions as bZ, type RuntimeClassResource as b_, type DriverManifestConformance as ba, type DriverManifestManifest as bb, type DriverManifestResource as bc, type DriverManifestSpec as bd, type DriverManifestStatus as be, type FrameworkPluginToolConfig as bf, type HookSlot as bg, type InfrastructureDriverType as bh, MODEL_CALL_RECORD_API_VERSION as bi, MODEL_CALL_RECORD_KIND as bj, MODEL_CLASS_API_VERSION as bk, MODEL_CLASS_KIND as bl, MODEL_ENDPOINT_API_VERSION as bm, MODEL_ENDPOINT_KIND as bn, type ModelCallRecordManifest as bo, type ModelCallRecordResource as bp, type ModelCallRecordSpec as bq, type ModelCallRecordStatus as br, type ModelClassCapabilities as bs, type ModelClassManifest as bt, type ModelClassResource as bu, type ModelClassSpec as bv, type ModelClassStatus as bw, type ModelEndpointManifest as bx, type ModelEndpointResource as by, type ModelEndpointSpec as bz, type AgentInstanceState as c, VOLUME_CLAIM_API_VERSION as c$, SECURITY_PROFILE_API_VERSION as c0, SECURITY_PROFILE_KIND as c1, SNAPSHOT_API_VERSION as c2, SNAPSHOT_KIND as c3, STORAGE_CLASS_API_VERSION as c4, STORAGE_CLASS_KIND as c5, type SandboxSelectionResult as c6, type ScriptAdmissionDecision as c7, type ScriptAdmissionRequest as c8, type ScriptArtifactReference as c9, type ToolAdmissionAction as cA, type ToolAdmissionPolicy as cB, type ToolAdmissionRule as cC, type ToolApprovalMode as cD, type ToolClassManifest as cE, type ToolClassResource as cF, type ToolClassSchema as cG, type ToolClassSpec as cH, type ToolClassStatus as cI, type ToolExecutionContext as cJ, type ToolExecutorCapability as cK, type ToolExecutorManifest as cL, type ToolExecutorResource as cM, type ToolExecutorSpec as cN, type ToolExecutorStatus as cO, type ToolOperationApprovalEvidence as cP, type ToolOperationManifest as cQ, type ToolOperationPolicy as cR, type ToolOperationResource as cS, type ToolOperationResult as cT, type ToolOperationRetryPolicy as cU, type ToolOperationSpec as cV, type ToolOperationStatus as cW, type ToolOperationToolReference as cX, type ToolRiskLevel as cY, type UserMessageContext as cZ, VOLUME_API_VERSION as c_, type ScriptArtifactStore as ca, type ScriptDeploymentClientConfig as cb, type ScriptDeploymentClientRequest as cc, type ScriptDeploymentPipelineOptions as cd, type ScriptDeploymentRequest as ce, type ScriptDeploymentResult as cf, type ScriptLoadGateConfig as cg, type ScriptTrustClass as ch, type ScriptValidationResult as ci, type SecurityProfileManifest as cj, type SecurityProfileResource as ck, type SecurityProfileSpec as cl, type SecurityProfileStatus as cm, SessionStorage as cn, type StorageClassManifest as co, type StorageClassResource as cp, type StorageClassSpec as cq, type StorageClassStatus as cr, TOOL_CLASS_API_VERSION as cs, TOOL_CLASS_KIND as ct, TOOL_EXECUTOR_API_VERSION as cu, TOOL_EXECUTOR_KIND as cv, TOOL_OPERATION_API_VERSION as cw, TOOL_OPERATION_KIND as cx, type TapAsyncHandler as cy, type ToolActions as cz, type AgentLoopDefinition as d, selectRuntimeClass as d$, VOLUME_CLAIM_KIND as d0, VOLUME_KIND as d1, type VolumeAccessMode as d2, type WaitForConditionOptions as d3, type YieldNextRoundTarget as d4, admitScript as d5, agentRunReference as d6, agentWorkloadReference as d7, canonicalControlStoreValue as d8, controlStoreApplyMatches as d9, deployGeneratedScript as dA, digestNormalizedScript as dB, isAgentRun as dC, isAgentWorkload as dD, isArtifactRecord as dE, isAuditRecord as dF, isCredentialGrant as dG, isDriverManifest as dH, isDriverManifestAdmitted as dI, isModelCallRecord as dJ, isModelClass as dK, isModelEndpoint as dL, isNetworkAttachment as dM, isNetworkClass as dN, isPolicyDecision as dO, isSecurityProfile as dP, isSnapshot as dQ, isStorageClass as dR, isToolClass as dS, isToolExecutor as dT, isToolOperation as dU, isVolume as dV, isVolumeClaim as dW, maxScriptBytesForTrustClass as dX, normalizeScript as dY, parseCheckpointRecord as dZ, remoteDeploymentToWorkloadManifest as d_, createAgentClient as da, createAgentRunManifest as db, createAgentWorkloadManifest as dc, createArtifactRecordManifest as dd, createAuditRecordManifest as de, createCheckpointRecord as df, createCredentialGrantManifest as dg, createDriverManifestManifest as dh, createModelCallRecordManifest as di, createModelClassManifest as dj, createModelEndpointManifest as dk, createNetworkAttachmentManifest as dl, createNetworkClassManifest as dm, createPolicyDecisionManifest as dn, createScriptDeploymentClient as dp, createScriptLoadGate as dq, createSecurityProfileManifest as dr, createSnapshotManifest as ds, createStorageClassManifest as dt, createToolClassManifest as du, createToolExecutorManifest as dv, createToolOperationManifest as dw, createVolumeClaimManifest as dx, createVolumeManifest as dy, defaultRequestedInterfacesForTrustClass as dz, type AgentLoopGenerator as e, serializeCheckpointRecord as e0, validateScript as e1, waitForCondition as e2, InMemoryCheckpointStore as e3, type SessionStorageOptions as e4, type AgentLoopInput as f, type AgentLoopRuntime as g, type AgentLoopScriptPolicy as h, type AgentLoopStep as i, type AgentToolLoopOptions as j, type ILLMProvider as k, type INetworkService as l, type IToolRegistry as m, type LoopProfile as n, type LoopProfilePluginEntry as o, type LoopProfilePrompt as p, type LoopProfileScriptReference as q, type LoopScriptCheckpointStore as r, type ScriptLoadGateDecision as s, type ScriptLoadGateRequest as t, createInstanceDeltaFromDefinition as u, isUserInitiatedConversation as v, type ToolCallingMatch as w, matchAllToolCallings as x, matchToolCalling as y, type ToolOperationEffect as z };