memeloop 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/README.md +63 -0
  2. package/dist/browser.cjs +1413 -0
  3. package/dist/browser.cjs.map +1 -0
  4. package/dist/browser.d.cts +3066 -0
  5. package/dist/browser.d.ts +3066 -0
  6. package/dist/browser.js +43 -0
  7. package/dist/chunk-426CJUZP.js +630 -0
  8. package/dist/chunk-426CJUZP.js.map +1 -0
  9. package/dist/chunk-44YHBKDL.js +382 -0
  10. package/dist/chunk-44YHBKDL.js.map +1 -0
  11. package/dist/chunk-7ZDTB4VZ.js +63 -0
  12. package/dist/chunk-7ZDTB4VZ.js.map +1 -0
  13. package/dist/chunk-AZFYDWIN.js +98 -0
  14. package/dist/chunk-AZFYDWIN.js.map +1 -0
  15. package/dist/chunk-BGPU4RR7.js +367 -0
  16. package/dist/chunk-BGPU4RR7.js.map +1 -0
  17. package/dist/chunk-CCEFAOSH.js +496 -0
  18. package/dist/chunk-CCEFAOSH.js.map +1 -0
  19. package/dist/chunk-FWSY5HOA.js +63 -0
  20. package/dist/chunk-FWSY5HOA.js.map +1 -0
  21. package/dist/chunk-GYIOMQMY.js +8726 -0
  22. package/dist/chunk-GYIOMQMY.js.map +1 -0
  23. package/dist/chunk-HVB2BR3H.js +42 -0
  24. package/dist/chunk-HVB2BR3H.js.map +1 -0
  25. package/dist/chunk-K6P63KD4.js +68 -0
  26. package/dist/chunk-K6P63KD4.js.map +1 -0
  27. package/dist/chunk-MRKY4HGF.js +205 -0
  28. package/dist/chunk-MRKY4HGF.js.map +1 -0
  29. package/dist/chunk-QFHAAIIM.js +2657 -0
  30. package/dist/chunk-QFHAAIIM.js.map +1 -0
  31. package/dist/chunk-VZKQX5PP.js +1 -0
  32. package/dist/chunk-VZKQX5PP.js.map +1 -0
  33. package/dist/chunk-WAI6BODI.js +175 -0
  34. package/dist/chunk-WAI6BODI.js.map +1 -0
  35. package/dist/chunk-XHRBV6I3.js +3637 -0
  36. package/dist/chunk-XHRBV6I3.js.map +1 -0
  37. package/dist/chunk-YMNXDNDW.js +798 -0
  38. package/dist/chunk-YMNXDNDW.js.map +1 -0
  39. package/dist/conversation.cjs +208 -0
  40. package/dist/conversation.cjs.map +1 -0
  41. package/dist/conversation.d.cts +100 -0
  42. package/dist/conversation.d.ts +100 -0
  43. package/dist/conversation.js +21 -0
  44. package/dist/conversation.js.map +1 -0
  45. package/dist/device-network-portable.cjs +702 -0
  46. package/dist/device-network-portable.cjs.map +1 -0
  47. package/dist/device-network-portable.d.cts +110 -0
  48. package/dist/device-network-portable.d.ts +110 -0
  49. package/dist/device-network-portable.js +53 -0
  50. package/dist/device-network-portable.js.map +1 -0
  51. package/dist/device-network.cjs +906 -0
  52. package/dist/device-network.cjs.map +1 -0
  53. package/dist/device-network.d.cts +6 -0
  54. package/dist/device-network.d.ts +6 -0
  55. package/dist/device-network.js +59 -0
  56. package/dist/device-network.js.map +1 -0
  57. package/dist/fetchProvider-BpcGVSOG.d.cts +91 -0
  58. package/dist/fetchProvider-Cm0sO4Tl.d.ts +91 -0
  59. package/dist/index.cjs +27957 -5459
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +94 -1320
  62. package/dist/index.d.ts +94 -1320
  63. package/dist/index.js +10576 -2386
  64. package/dist/index.js.map +1 -1
  65. package/dist/interface-IrKBFtL1.d.cts +493 -0
  66. package/dist/interface-IrKBFtL1.d.ts +493 -0
  67. package/dist/llm-providers.cjs +43 -8
  68. package/dist/llm-providers.cjs.map +1 -1
  69. package/dist/llm-providers.d.cts +2 -1
  70. package/dist/llm-providers.d.ts +2 -1
  71. package/dist/llm-providers.js +4 -2
  72. package/dist/llm-providers.js.map +1 -1
  73. package/dist/loop-api.cjs +5177 -2050
  74. package/dist/loop-api.cjs.map +1 -1
  75. package/dist/loop-api.d.cts +11 -5
  76. package/dist/loop-api.d.ts +11 -5
  77. package/dist/loop-api.js +84 -49
  78. package/dist/mobile.cjs +2625 -0
  79. package/dist/mobile.cjs.map +1 -0
  80. package/dist/mobile.d.cts +6 -0
  81. package/dist/mobile.d.ts +6 -0
  82. package/dist/mobile.js +22 -0
  83. package/dist/mobile.js.map +1 -0
  84. package/dist/orchestration-portable-Bsf8YRfp.d.cts +2192 -0
  85. package/dist/orchestration-portable-Zw0g5tbj.d.ts +2192 -0
  86. package/dist/orchestration-portable.cjs +9553 -0
  87. package/dist/orchestration-portable.cjs.map +1 -0
  88. package/dist/orchestration-portable.d.cts +5 -0
  89. package/dist/orchestration-portable.d.ts +5 -0
  90. package/dist/orchestration-portable.js +290 -0
  91. package/dist/orchestration-portable.js.map +1 -0
  92. package/dist/pairingInvite-BXPWY3aM.d.cts +149 -0
  93. package/dist/pairingInvite-Cuz0wuq9.d.ts +149 -0
  94. package/dist/promptConcat-WTN-uHcz.d.cts +516 -0
  95. package/dist/promptConcat-deDSWZE3.d.ts +516 -0
  96. package/dist/providerRegistry-9trr5aoK.d.ts +86 -0
  97. package/dist/providerRegistry-xk_B1Ekv.d.cts +86 -0
  98. package/dist/registry-8eztoD_r.d.cts +393 -0
  99. package/dist/registry-DV24sI-3.d.ts +393 -0
  100. package/dist/remoteClient-B_spK019.d.ts +87 -0
  101. package/dist/remoteClient-CBggnRy3.d.cts +87 -0
  102. package/dist/runtime-SKSXVYIM.js +18 -0
  103. package/dist/runtime-SKSXVYIM.js.map +1 -0
  104. package/dist/scriptDeploymentPipeline-BAeo1dPb.d.cts +2463 -0
  105. package/dist/scriptDeploymentPipeline-DsnT0AG6.d.ts +2463 -0
  106. package/dist/syncCloudDevices-BEqwgrhD.d.ts +49 -0
  107. package/dist/syncCloudDevices-Ds_Kcgrv.d.cts +49 -0
  108. package/dist/types-7pYti-k9.d.cts +255 -0
  109. package/dist/types-CdFVSntj.d.ts +255 -0
  110. package/package.json +110 -35
  111. package/dist/anthropic.cjs +0 -72
  112. package/dist/anthropic.cjs.map +0 -1
  113. package/dist/anthropic.d.cts +0 -21
  114. package/dist/anthropic.d.ts +0 -21
  115. package/dist/anthropic.js +0 -21
  116. package/dist/anthropic.js.map +0 -1
  117. package/dist/azure.cjs +0 -72
  118. package/dist/azure.cjs.map +0 -1
  119. package/dist/azure.d.cts +0 -21
  120. package/dist/azure.d.ts +0 -21
  121. package/dist/azure.js +0 -21
  122. package/dist/azure.js.map +0 -1
  123. package/dist/chunk-3CN7DFBL.js +0 -4894
  124. package/dist/chunk-3CN7DFBL.js.map +0 -1
  125. package/dist/chunk-4AZ4D7U5.js +0 -32
  126. package/dist/chunk-4AZ4D7U5.js.map +0 -1
  127. package/dist/chunk-6ON4XSOV.js +0 -63
  128. package/dist/chunk-6ON4XSOV.js.map +0 -1
  129. package/dist/chunk-DJQNGIXX.js +0 -4793
  130. package/dist/chunk-DJQNGIXX.js.map +0 -1
  131. package/dist/chunk-FKQP6AOQ.js +0 -32
  132. package/dist/chunk-FKQP6AOQ.js.map +0 -1
  133. package/dist/chunk-OVJ7JJBA.js +0 -35
  134. package/dist/chunk-OVJ7JJBA.js.map +0 -1
  135. package/dist/chunk-P4UZ7IXC.js +0 -42
  136. package/dist/chunk-YHJ2AEFR.js +0 -4933
  137. package/dist/chunk-YHJ2AEFR.js.map +0 -1
  138. package/dist/chunk-YVK7RYRO.js +0 -4973
  139. package/dist/chunk-YVK7RYRO.js.map +0 -1
  140. package/dist/code-assistant.json +0 -114
  141. package/dist/cohere.cjs +0 -72
  142. package/dist/cohere.cjs.map +0 -1
  143. package/dist/cohere.d.cts +0 -21
  144. package/dist/cohere.d.ts +0 -21
  145. package/dist/cohere.js +0 -21
  146. package/dist/cohere.js.map +0 -1
  147. package/dist/deepseek.cjs +0 -72
  148. package/dist/deepseek.cjs.map +0 -1
  149. package/dist/deepseek.d.cts +0 -21
  150. package/dist/deepseek.d.ts +0 -21
  151. package/dist/deepseek.js +0 -21
  152. package/dist/deepseek.js.map +0 -1
  153. package/dist/dist-65U7OYRG.js +0 -1257
  154. package/dist/dist-65U7OYRG.js.map +0 -1
  155. package/dist/fetchProvider-Cu4WkU5O.d.cts +0 -819
  156. package/dist/fetchProvider-Cu4WkU5O.d.ts +0 -819
  157. package/dist/frontend-ui-ux.json +0 -105
  158. package/dist/general-assistant.json +0 -95
  159. package/dist/git-master.json +0 -51
  160. package/dist/google-vertex.cjs +0 -72
  161. package/dist/google-vertex.cjs.map +0 -1
  162. package/dist/google-vertex.d.cts +0 -21
  163. package/dist/google-vertex.d.ts +0 -21
  164. package/dist/google-vertex.js +0 -21
  165. package/dist/google-vertex.js.map +0 -1
  166. package/dist/google.cjs +0 -72
  167. package/dist/google.cjs.map +0 -1
  168. package/dist/google.d.cts +0 -21
  169. package/dist/google.d.ts +0 -21
  170. package/dist/google.js +0 -21
  171. package/dist/google.js.map +0 -1
  172. package/dist/groq.cjs +0 -72
  173. package/dist/groq.cjs.map +0 -1
  174. package/dist/groq.d.cts +0 -21
  175. package/dist/groq.d.ts +0 -21
  176. package/dist/groq.js +0 -21
  177. package/dist/groq.js.map +0 -1
  178. package/dist/index.d.mts +0 -3203
  179. package/dist/index.mjs +0 -7064
  180. package/dist/index.mjs.map +0 -1
  181. package/dist/mistral.cjs +0 -72
  182. package/dist/mistral.cjs.map +0 -1
  183. package/dist/mistral.d.cts +0 -21
  184. package/dist/mistral.d.ts +0 -21
  185. package/dist/mistral.js +0 -21
  186. package/dist/mistral.js.map +0 -1
  187. package/dist/multipart-parser-EJCXIUHC.js +0 -372
  188. package/dist/multipart-parser-EJCXIUHC.js.map +0 -1
  189. package/dist/openai.cjs +0 -72
  190. package/dist/openai.cjs.map +0 -1
  191. package/dist/openai.d.cts +0 -21
  192. package/dist/openai.d.ts +0 -21
  193. package/dist/openai.js +0 -21
  194. package/dist/openai.js.map +0 -1
  195. package/dist/perplexity.cjs +0 -72
  196. package/dist/perplexity.cjs.map +0 -1
  197. package/dist/perplexity.d.cts +0 -21
  198. package/dist/perplexity.d.ts +0 -21
  199. package/dist/perplexity.js +0 -21
  200. package/dist/perplexity.js.map +0 -1
  201. package/dist/playwright.json +0 -52
  202. package/dist/promptConcat-BJdazTg5.d.cts +0 -1832
  203. package/dist/promptConcat-BJdazTg5.d.ts +0 -1832
  204. package/dist/promptConcat-CAkpni_8.d.cts +0 -1834
  205. package/dist/promptConcat-CAkpni_8.d.ts +0 -1834
  206. package/dist/promptConcat-CfH5-GAE.d.cts +0 -1036
  207. package/dist/promptConcat-ChcAZOOL.d.ts +0 -1036
  208. package/dist/promptConcat-G5TnJVRy.d.cts +0 -1800
  209. package/dist/promptConcat-G5TnJVRy.d.ts +0 -1800
  210. package/dist/promptConcat-L72eowzp.d.ts +0 -1090
  211. package/dist/promptConcat-eLHdN7K8.d.cts +0 -1090
  212. package/dist/src-VTSXKG72.js +0 -1409
  213. package/dist/src-VTSXKG72.js.map +0 -1
  214. package/dist/togetherai.cjs +0 -72
  215. package/dist/togetherai.cjs.map +0 -1
  216. package/dist/togetherai.d.cts +0 -21
  217. package/dist/togetherai.d.ts +0 -21
  218. package/dist/togetherai.js +0 -21
  219. package/dist/togetherai.js.map +0 -1
  220. package/dist/types-B0Jm2l38.d.cts +0 -767
  221. package/dist/types-B0Jm2l38.d.ts +0 -767
  222. package/dist/xai.cjs +0 -72
  223. package/dist/xai.cjs.map +0 -1
  224. package/dist/xai.d.cts +0 -21
  225. package/dist/xai.d.ts +0 -21
  226. package/dist/xai.js +0 -21
  227. package/dist/xai.js.map +0 -1
  228. /package/dist/{chunk-P4UZ7IXC.js.map → browser.js.map} +0 -0
@@ -0,0 +1,2463 @@
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
+ type ToolCallingMatch = {
1778
+ found: false;
1779
+ } | {
1780
+ found: true;
1781
+ toolId: string;
1782
+ parameters: Record<string, unknown>;
1783
+ originalText: string;
1784
+ };
1785
+ declare function matchToolCalling(responseText: string): ToolCallingMatch;
1786
+ declare function matchAllToolCallings(responseText: string): {
1787
+ calls: Array<ToolCallingMatch & {
1788
+ found: true;
1789
+ }>;
1790
+ parallel: boolean;
1791
+ };
1792
+
1793
+ /**
1794
+ * TidGi-Desktop `agentInstance/tools/types.ts` 迁移并适配 memeloop(无 tapable,用 HookSlot.promise 串行执行)。
1795
+ */
1796
+
1797
+ /** 供 defineTool / 审批使用:agent 视图包含完整 AgentInstance。 */
1798
+ type DefineToolAgentFrameworkContext = AgentFrameworkContext & {
1799
+ agent: AgentInstanceModel;
1800
+ };
1801
+ type ToolApprovalMode = 'auto' | 'confirm';
1802
+ interface ToolApprovalConfig {
1803
+ mode: ToolApprovalMode;
1804
+ allowPatterns?: string[];
1805
+ denyPatterns?: string[];
1806
+ timeoutMs?: number;
1807
+ }
1808
+ type ApprovalDecision = 'allow' | 'deny' | 'pending';
1809
+ interface ToolApprovalRequest {
1810
+ approvalId: string;
1811
+ agentId: string;
1812
+ toolName: string;
1813
+ parameters: Record<string, unknown>;
1814
+ originalText?: string;
1815
+ created: Date;
1816
+ }
1817
+ type YieldNextRoundTarget = 'human' | 'self' | `agent:${string}`;
1818
+ interface ToolActions {
1819
+ yieldNextRoundTo?: YieldNextRoundTarget;
1820
+ newUserMessage?: string;
1821
+ toolCalling?: ToolCallingMatch;
1822
+ }
1823
+ interface BaseToolContext {
1824
+ agentFrameworkContext: DefineToolAgentFrameworkContext;
1825
+ metadata?: Record<string, unknown>;
1826
+ actions?: ToolActions;
1827
+ }
1828
+ /** 与 TidGi IPromptConcatTool 对齐的插件行 */
1829
+ interface FrameworkPluginToolConfig {
1830
+ id: string;
1831
+ toolId: string;
1832
+ enabled?: boolean;
1833
+ caption?: string;
1834
+ content?: string;
1835
+ forbidOverrides?: boolean;
1836
+ approval?: ToolApprovalConfig;
1837
+ timeoutMs?: number;
1838
+ [key: string]: unknown;
1839
+ }
1840
+ interface PromptConcatHookContext extends BaseToolContext {
1841
+ messages: ChatMessage[];
1842
+ prompts: IPrompt[];
1843
+ toolConfig: FrameworkPluginToolConfig;
1844
+ pluginIndex?: number;
1845
+ }
1846
+ interface AgentResponse {
1847
+ id: string;
1848
+ text?: string;
1849
+ enabled?: boolean;
1850
+ children?: AgentResponse[];
1851
+ }
1852
+ interface PostProcessContext extends PromptConcatHookContext {
1853
+ llmResponse: string;
1854
+ responses?: AgentResponse[];
1855
+ }
1856
+ /** 流式响应子集(memeloop ILLMProvider 聚合为最终文本后注入) */
1857
+ interface AIStreamResponseSubset {
1858
+ status: 'update' | 'done';
1859
+ content: string;
1860
+ }
1861
+ interface AIResponseContext extends BaseToolContext {
1862
+ toolConfig: FrameworkPluginToolConfig;
1863
+ agentFrameworkConfig?: {
1864
+ plugins?: FrameworkPluginToolConfig[];
1865
+ };
1866
+ response: AIStreamResponseSubset;
1867
+ requestId?: string;
1868
+ isFinal?: boolean;
1869
+ }
1870
+ interface UserMessageContext extends BaseToolContext {
1871
+ content: {
1872
+ text: string;
1873
+ file?: unknown;
1874
+ wikiTiddlers?: Array<{
1875
+ workspaceName: string;
1876
+ tiddlerTitle: string;
1877
+ }>;
1878
+ };
1879
+ messageId: string;
1880
+ timestamp: Date;
1881
+ }
1882
+ interface AgentStatusContext extends BaseToolContext {
1883
+ status: {
1884
+ state: 'working' | 'completed' | 'failed' | 'canceled';
1885
+ modified: Date;
1886
+ };
1887
+ }
1888
+ interface ToolExecutionContext extends BaseToolContext {
1889
+ toolResult: {
1890
+ success: boolean;
1891
+ data?: string;
1892
+ error?: string;
1893
+ metadata?: Record<string, unknown>;
1894
+ };
1895
+ toolInfo: {
1896
+ toolId: string;
1897
+ parameters: Record<string, unknown>;
1898
+ originalText?: string;
1899
+ };
1900
+ requestId?: string;
1901
+ }
1902
+ /**
1903
+ * Hook 槽:与 tapable AsyncSeriesHook 一致 — `tapAsync` 注册,`promise(ctx)` 串行触发。
1904
+ */
1905
+ type TapAsyncHandler = {
1906
+ bivarianceHack(context: unknown, callback: () => void): void;
1907
+ }['bivarianceHack'];
1908
+ interface HookSlot {
1909
+ tapAsync(name: string, function_: TapAsyncHandler): void;
1910
+ promise(context: unknown): Promise<void>;
1911
+ }
1912
+ interface PromptConcatHooks {
1913
+ processPrompts: HookSlot;
1914
+ finalizePrompts: HookSlot;
1915
+ postProcess: HookSlot;
1916
+ userMessageReceived: HookSlot;
1917
+ agentStatusChanged: HookSlot;
1918
+ toolExecuted: HookSlot;
1919
+ responseUpdate: HookSlot;
1920
+ responseComplete: HookSlot;
1921
+ }
1922
+ type PromptConcatTool = (hooks: PromptConcatHooks) => void;
1923
+
1924
+ interface CheckpointRecord {
1925
+ conversationId: string;
1926
+ messages: ChatMessage[];
1927
+ savedAt: string;
1928
+ messageCount: number;
1929
+ lastMessagePreview: string;
1930
+ }
1931
+ interface CheckpointSummary {
1932
+ conversationId: string;
1933
+ savedAt: string;
1934
+ messageCount: number;
1935
+ lastMessagePreview: string;
1936
+ }
1937
+ interface CheckpointStore {
1938
+ saveCheckpoint(conversationId: string, messages: ChatMessage[]): Promise<CheckpointRecord>;
1939
+ loadCheckpoint(conversationId: string): Promise<CheckpointRecord | null>;
1940
+ listCheckpoints(): Promise<CheckpointSummary[]>;
1941
+ deleteCheckpoint(conversationId: string): Promise<boolean>;
1942
+ }
1943
+ interface SessionStorageOptions {
1944
+ records?: CheckpointRecord[];
1945
+ }
1946
+ declare function createCheckpointRecord(conversationId: string, messages: ChatMessage[], savedAt?: string): CheckpointRecord;
1947
+ declare function parseCheckpointRecord(raw: string): CheckpointRecord | null;
1948
+ declare function serializeCheckpointRecord(record: CheckpointRecord): string;
1949
+ declare class InMemoryCheckpointStore implements CheckpointStore {
1950
+ private readonly records;
1951
+ constructor(options?: SessionStorageOptions);
1952
+ saveCheckpoint(conversationId: string, messages: ChatMessage[]): Promise<CheckpointRecord>;
1953
+ loadCheckpoint(conversationId: string): Promise<CheckpointRecord | null>;
1954
+ listCheckpoints(): Promise<CheckpointSummary[]>;
1955
+ deleteCheckpoint(conversationId: string): Promise<boolean>;
1956
+ }
1957
+ declare class SessionStorage extends InMemoryCheckpointStore {
1958
+ }
1959
+
1960
+ interface MemeLoopLogger {
1961
+ debug?(message: string, ...arguments_: unknown[]): void;
1962
+ info?(message: string, ...arguments_: unknown[]): void;
1963
+ warn?(message: string, ...arguments_: unknown[]): void;
1964
+ error?(message: string, ...arguments_: unknown[]): void;
1965
+ }
1966
+ interface ILLMProvider {
1967
+ name: string;
1968
+ /**
1969
+ * Serializable default model identity used by orchestration resources.
1970
+ * `model` may be an SDK object or factory and must never be persisted.
1971
+ */
1972
+ modelId?: string;
1973
+ model?: unknown;
1974
+ chat(request: unknown): AsyncIterable<unknown> | Promise<unknown>;
1975
+ }
1976
+ interface IToolRegistry {
1977
+ registerTool(id: string, impl: unknown, parameterSchema?: unknown, effect?: ToolOperationEffect): void;
1978
+ getTool(id: string): unknown | undefined;
1979
+ listTools(): string[];
1980
+ /**
1981
+ * Instance-local schema lookup. Managed catalogs use this when available so
1982
+ * one embedded runtime cannot inherit another runtime's process-global schema.
1983
+ */
1984
+ getToolParameterSchema?: (id: string) => unknown | undefined;
1985
+ /** Host-authoritative effect classification; omitted tools default to conservative execute. */
1986
+ getToolEffect?: (id: string) => ToolOperationEffect | undefined;
1987
+ /** Prompt-concat plugin registry, isolated per runtime. Falls back to the process-level default registry. */
1988
+ getPromptPlugins?: () => Map<string, (hooks: PromptConcatHooks) => void>;
1989
+ }
1990
+ interface IChatSyncAdapter {
1991
+ start(): Promise<void>;
1992
+ stop(): Promise<void>;
1993
+ }
1994
+ interface INetworkService {
1995
+ start(): Promise<void>;
1996
+ stop(): Promise<void>;
1997
+ }
1998
+ interface AgentToolLoopOptions {
1999
+ /** Maximum LLM-to-tool round-trips. `0` means unlimited, still capped internally. */
2000
+ maxIterations?: number;
2001
+ /** Whether to parse `<tool_use>` / `<function_call>` and execute through `IToolRegistry` (default true). */
2002
+ enableToolLoop?: boolean;
2003
+ /** Cancellation check, e.g. when the user stops a run. */
2004
+ isCancelled?: (conversationId: string) => boolean;
2005
+ /** Attachment injection for promptConcat, aligned with `PromptConcatOptions`. */
2006
+ readAttachmentFile?: (path: string) => Promise<Uint8Array>;
2007
+ /** Omit history older than this many milliseconds when building LLM input. `0` disables trimming. */
2008
+ maxHistoryAgeMs?: number;
2009
+ /**
2010
+ * When `defineTool` / plugins are configured, fall back to `IToolRegistry` for tool calls not handled by `onResponseComplete`.
2011
+ */
2012
+ fallbackRegistryTools?: boolean;
2013
+ /**
2014
+ * Tool permission rules (default allow).
2015
+ * Supports wildcards such as "terminal.*" and "file.read".
2016
+ */
2017
+ toolPermissions?: {
2018
+ default?: 'allow' | 'ask' | 'deny';
2019
+ rules?: Array<{
2020
+ pattern: string;
2021
+ action: 'allow' | 'ask' | 'deny';
2022
+ }>;
2023
+ perAgent?: Record<string, {
2024
+ default?: 'allow' | 'ask' | 'deny';
2025
+ rules?: Array<{
2026
+ pattern: string;
2027
+ action: 'allow' | 'ask' | 'deny';
2028
+ }>;
2029
+ }>;
2030
+ };
2031
+ /** Threshold for repeated identical tool+input calls (default 3). */
2032
+ doomLoopThreshold?: number;
2033
+ /**
2034
+ * Timeout for a single ToolOperation executed through the orchestration
2035
+ * facade (default 60_000ms). Covers the full lifecycle from apply until a
2036
+ * terminal phase, including scheduling and remote execution.
2037
+ */
2038
+ toolOperationTimeoutMs?: number;
2039
+ /**
2040
+ * Host-bound trust class of the node running this loop. Restricted and
2041
+ * quarantine nodes default the model-facing tool permission layer to deny
2042
+ * when no explicit wildcard rule exists. Bound by the host at assembly
2043
+ * time; never self-reported by the workload or model.
2044
+ */
2045
+ trustClass?: NodeTrustClass;
2046
+ /** History compaction window: keep the most recent N turns plus the last user message. */
2047
+ contextCompaction?: {
2048
+ maxMessages?: number;
2049
+ replayLastUserMessage?: boolean;
2050
+ };
2051
+ /**
2052
+ * Auto-compaction: when message count exceeds threshold, summarizes old
2053
+ * conversation turns via truncation or LLM summarization. Default: disabled.
2054
+ */
2055
+ autoCompact?: {
2056
+ /** Trigger compaction when message count exceeds this (default: 50) */
2057
+ threshold?: number;
2058
+ /** Number of recent turns to preserve (default: 4) */
2059
+ recentTurnsToKeep?: number;
2060
+ /** Maximum token estimate before compaction; 0 disables token-based compaction */
2061
+ maxTokens?: number;
2062
+ };
2063
+ /** Session checkpoint: save conversation history after each turn for resume. */
2064
+ sessionCheckpoint?: {
2065
+ /** Enable checkpoint saves. Default: false. */
2066
+ enabled?: boolean;
2067
+ /** Store provided by the runtime host. */
2068
+ store?: CheckpointStore;
2069
+ /** Custom checkpoint directory (default: ~/.memeloop/sessions/) */
2070
+ directory?: string;
2071
+ };
2072
+ /**
2073
+ * After a tool returns `__memeloopToolResult.awaitSessionId`, AgentToolLoop waits here before the next LLM round.
2074
+ */
2075
+ waitForTerminalSession?: (sessionId: string) => Promise<{
2076
+ exitCode: number | null;
2077
+ truncatedOutput: string;
2078
+ }>;
2079
+ }
2080
+ interface AgentFrameworkContext {
2081
+ storage: IAgentStorage;
2082
+ llmProvider: ILLMProvider;
2083
+ tools: IToolRegistry;
2084
+ syncAdapters: IChatSyncAdapter[];
2085
+ network: INetworkService;
2086
+ /** Policy-scoped declarative manager facade shared by Agent loops and Agent-facing tools. */
2087
+ orchestration?: AgentOrchestrationClient;
2088
+ /**
2089
+ * Host-bound script deployment configuration (plan 24.14). Loop runtimes
2090
+ * build a `ctx.scriptClient` from it; scripts never see the raw config,
2091
+ * so trust class and interface ceilings stay host-controlled.
2092
+ */
2093
+ scriptDeployment?: ScriptDeploymentClientConfig;
2094
+ /** Trusted controller state store; Agent-facing loop scripts receive only its checkpoint adapter. */
2095
+ controlStore?: ControlStore;
2096
+ /** Durable milestones used by script-backed loops such as quality-gate. */
2097
+ loopCheckpoints?: LoopScriptCheckpointStore;
2098
+ /** Let host runtimes preserve platform-specific message aliases/metadata while core owns the loop. */
2099
+ normalizeMessage?: (message: ChatMessage) => ChatMessage;
2100
+ /**
2101
+ * Notify a host about an in-memory streaming message. The core invokes this
2102
+ * with the same message ID used for the immutable final persisted message.
2103
+ */
2104
+ onTransientMessage?: (message: ChatMessage) => void | Promise<void>;
2105
+ /** AgentToolLoop ReAct behavior, migrated from the TidGi-Desktop agentToolLoop integration. */
2106
+ agentToolLoop?: AgentToolLoopOptions;
2107
+ /**
2108
+ * Host-injected runner used by `createMemeLoopRuntime` after a user sends a message.
2109
+ */
2110
+ runAgentToolLoop?: (input: AgentLoopInput) => AgentLoopGenerator;
2111
+ /** Run a child agent for orchestration loops such as AgentAgentLoop. */
2112
+ runChildAgent?: AgentLoopRuntime['runChildAgent'];
2113
+ /** Policy for loading script-backed loops. Defaults to bundled scripts + import specifiers only. */
2114
+ loopScriptPolicy?: AgentLoopScriptPolicy;
2115
+ /**
2116
+ * Build the agent view supplied to defineTool hooks for a conversation.
2117
+ */
2118
+ resolveAgentRuntimeView?: (conversationId: string, messages: ChatMessage[]) => Promise<AgentInstanceModel>;
2119
+ /** Current agent view for defineTool / TidGi compatibility. */
2120
+ agent?: {
2121
+ id: string;
2122
+ messages: ChatMessage[];
2123
+ };
2124
+ /** Persist a `ChatMessage` if the runtime host supplies this hook. */
2125
+ persistAgentMessage?: (message: ChatMessage) => Promise<void>;
2126
+ /** Cancellation markers written by `createMemeLoopRuntime`. */
2127
+ conversationCancellation?: Set<string>;
2128
+ /** Resolve an AgentDefinition from host-specific sources. */
2129
+ resolveAgentDefinition?: (definitionId: string) => Promise<AgentDefinition | null>;
2130
+ /** Fallback logger used when the host does not inject one. */
2131
+ logger?: MemeLoopLogger;
2132
+ /** TidGi defineTool compatibility: legacy plugins call this without arguments. */
2133
+ isCancelled?: () => boolean;
2134
+ }
2135
+ type AgentInstanceState = 'submitted' | 'working' | 'input-required' | 'completed' | 'canceled' | 'failed' | 'unknown';
2136
+ interface AgentInstanceLatestStatus {
2137
+ state: AgentInstanceState;
2138
+ message?: ChatMessage;
2139
+ /** Human-readable sub-status for the header — shown while agent is working. */
2140
+ progress?: string;
2141
+ created?: Date;
2142
+ modified?: Date;
2143
+ }
2144
+ interface AgentInstanceModel extends Omit<AgentDefinition, 'name'> {
2145
+ agentDefId: string;
2146
+ name?: string;
2147
+ agentFrameworkConfig?: AgentFrameworkConfig;
2148
+ messages: ChatMessage[];
2149
+ status: AgentInstanceLatestStatus;
2150
+ created: Date;
2151
+ modified?: Date;
2152
+ closed?: boolean;
2153
+ volatile?: boolean;
2154
+ isDelegatedAgentRun?: boolean;
2155
+ parentAgentRunId?: string;
2156
+ }
2157
+
2158
+ declare function isUserInitiatedConversation(meta: ConversationMeta): boolean;
2159
+ declare function createInstanceDeltaFromDefinition(definition: AgentDefinition, overrides: Partial<AgentDefinition>): Partial<AgentDefinition>;
2160
+
2161
+ interface RuntimeClassSpec {
2162
+ /** Module isolation level. */
2163
+ isolation: 'none' | 'process' | 'container';
2164
+ /** CPU limit in millicores (1000 = 1 core). */
2165
+ cpuLimitMillis?: number;
2166
+ /** Memory limit in bytes. */
2167
+ memoryLimitBytes?: number;
2168
+ /** Wall-clock time limit in milliseconds. */
2169
+ timeLimitMs?: number;
2170
+ /** Whether the runtime supports cancellation signals. */
2171
+ supportsCancellation: boolean;
2172
+ /** Supported trust classes for this runtime. */
2173
+ supportedTrustClasses: ScriptTrustClass[];
2174
+ /** Whether network access is allowed (outbound-only for quarantine). */
2175
+ networkAccess: 'none' | 'outbound-only' | 'full';
2176
+ }
2177
+ interface RuntimeClassResource {
2178
+ apiVersion: 'execution.memeloop.io/v1alpha1';
2179
+ kind: 'RuntimeClass';
2180
+ metadata: {
2181
+ name: string;
2182
+ namespace?: string;
2183
+ };
2184
+ spec: RuntimeClassSpec;
2185
+ }
2186
+ declare const BUILTIN_RUNTIME_CLASSES: Record<string, RuntimeClassSpec>;
2187
+ interface SandboxSelectionResult {
2188
+ runtimeClass: string;
2189
+ isolation: RuntimeClassSpec['isolation'];
2190
+ cpuLimitMillis: number;
2191
+ memoryLimitBytes: number;
2192
+ timeLimitMs: number;
2193
+ networkAccess: RuntimeClassSpec['networkAccess'];
2194
+ }
2195
+ /**
2196
+ * Select the most restrictive RuntimeClass capable of hosting the given
2197
+ * trust class. Throws when no available RuntimeClass supports the trust
2198
+ * class — there is no silent fallback (24.18).
2199
+ */
2200
+ declare function selectRuntimeClass(trustClass: ScriptTrustClass, available?: string[]): SandboxSelectionResult;
2201
+ /**
2202
+ * Reference to a content-addressed ArtifactRecord holding the script source
2203
+ * (plan 24.15/24.47). Remote deployments never carry raw script source
2204
+ * strings; the target node resolves the artifact by identity and verifies
2205
+ * it against `contentDigest` before loading.
2206
+ */
2207
+ interface ScriptArtifactReference {
2208
+ /** API version of the artifact resource (`artifacts.memeloop.io/v1alpha1`). */
2209
+ apiVersion: string;
2210
+ /** Resource kind; always `ArtifactRecord`. */
2211
+ kind: 'ArtifactRecord';
2212
+ /** Artifact resource name. */
2213
+ name: string;
2214
+ /** Artifact namespace, if any. */
2215
+ namespace?: string;
2216
+ /**
2217
+ * Content digest (`sha256:<hex>`) of the NORMALIZED script source. The
2218
+ * remote node must verify the fetched artifact content against this
2219
+ * digest before admission.
2220
+ */
2221
+ contentDigest: string;
2222
+ }
2223
+ interface RemoteDeploymentRequest {
2224
+ /**
2225
+ * Content-addressed reference to the script artifact. Raw script source
2226
+ * is never transported inside a deployment request.
2227
+ */
2228
+ artifactRef: ScriptArtifactReference;
2229
+ /** Trust class assigned by admission. */
2230
+ trustClass: ScriptTrustClass;
2231
+ /** Desired lifecycle. */
2232
+ lifecycle: 'run-once' | 'service' | 'schedule';
2233
+ /** Runtime class to use. */
2234
+ runtimeClass: string;
2235
+ /** Node selector for scheduling. */
2236
+ nodeSelector?: Record<string, string>;
2237
+ /** Environment variables (never credentials). */
2238
+ env?: Record<string, string>;
2239
+ /** Network attachment requirements enforced before the script starts. */
2240
+ networkPolicy?: AgentWorkloadNetworkPolicy;
2241
+ /** Existing claims to publish before the script starts. */
2242
+ storagePolicy?: AgentWorkloadStoragePolicy;
2243
+ }
2244
+ interface RemoteDeploymentResult {
2245
+ /** Workload name created on the target node. */
2246
+ workloadName: string;
2247
+ /** Node the workload was placed on. */
2248
+ nodeName: string;
2249
+ /** When the deployment was requested. */
2250
+ requestedAt: string;
2251
+ }
2252
+
2253
+ /**
2254
+ * Generated-script deployment pipeline (plans 24.14–24.19, 24.47).
2255
+ *
2256
+ * Connects the full security chain for remote/generated scripts:
2257
+ *
2258
+ * normalizeScript → validateScript (Acorn AST) → admitScript (trust-class
2259
+ * policy) → ArtifactRecord manifest (content-addressed) → persist via the
2260
+ * injected artifact store port → selectRuntimeClass →
2261
+ * RemoteDeploymentRequest (artifactRef only — raw source is never carried).
2262
+ *
2263
+ * Also provides {@link createScriptLoadGate}, the production
2264
+ * {@link ScriptLoadGate} implementation for the in-process script loading
2265
+ * path (`loopAPI/scriptLoader`): validate (AST) → admit → assign
2266
+ * trustClass/RuntimeClass before any `import()` executes.
2267
+ *
2268
+ * Everything here is pure and portable; artifact persistence sits behind the
2269
+ * {@link ScriptArtifactStore} port so the CLI can back it with real storage.
2270
+ */
2271
+
2272
+ /**
2273
+ * Port: persists a script ArtifactRecord manifest plus its normalized
2274
+ * content. Implementations (e.g. CLI storage) must store content addressed
2275
+ * by `manifest.spec.contentHash` and must not trust content whose hash does
2276
+ * not match the manifest.
2277
+ */
2278
+ interface ScriptArtifactStore {
2279
+ putArtifact(manifest: ArtifactRecordManifest, normalizedContent: string): Promise<void> | void;
2280
+ }
2281
+ /** Input for {@link deployGeneratedScript}. */
2282
+ interface ScriptDeploymentRequest {
2283
+ /** Raw generated `.mjs` source (normalized internally). */
2284
+ source: string;
2285
+ /** Trust class of the author (the Agent that generated the script). */
2286
+ authorTrust: ScriptTrustClass;
2287
+ /** Interfaces the script requests (loop-runtime, model-provider, ...). */
2288
+ requestedInterfaces: string[];
2289
+ /** Desired lifecycle for the remote workload. */
2290
+ lifecycle: 'run-once' | 'service' | 'schedule';
2291
+ /** Node selector for scheduling. */
2292
+ nodeSelector?: Record<string, string>;
2293
+ /** Environment variables (never credentials). */
2294
+ env?: Record<string, string>;
2295
+ /** Network attachment requirements for the deployed workload. */
2296
+ networkPolicy?: AgentWorkloadNetworkPolicy;
2297
+ /** Existing volume claims required by the deployed workload. */
2298
+ storagePolicy?: AgentWorkloadStoragePolicy;
2299
+ /** Optional checkpoint digest the script expects to resume from. */
2300
+ expectedCheckpointDigest?: string;
2301
+ /** API version of the expected checkpoint (plan 24.19). */
2302
+ checkpointApiVersion?: string;
2303
+ /** Namespace for the ArtifactRecord and deployment. */
2304
+ namespace?: string;
2305
+ }
2306
+ /** Tunables for {@link deployGeneratedScript}. */
2307
+ interface ScriptDeploymentPipelineOptions {
2308
+ /** Artifact persistence port; when omitted the manifest is built but not persisted. */
2309
+ artifactStore?: ScriptArtifactStore;
2310
+ /** RuntimeClass names available for selection (defaults to all built-ins). */
2311
+ availableRuntimeClasses?: string[];
2312
+ }
2313
+ /** Result of {@link deployGeneratedScript}; `deployed` gates artifact/deployment presence. */
2314
+ interface ScriptDeploymentResult {
2315
+ /** Whether a deployment request was produced. */
2316
+ deployed: boolean;
2317
+ /** Human-readable outcome (validation/admission/enforcement reason). */
2318
+ reason: string;
2319
+ /** AST validation outcome (always present). */
2320
+ validation: ScriptValidationResult;
2321
+ /** Admission decision (present once validation passed). */
2322
+ admission?: ScriptAdmissionDecision;
2323
+ /** Content-addressed artifact manifest (present when deployed). */
2324
+ artifact?: ArtifactRecordManifest;
2325
+ /** Selected RuntimeClass (present when deployed). */
2326
+ runtimeClass?: SandboxSelectionResult;
2327
+ /** Deployment request referencing the artifact by digest (present when deployed). */
2328
+ deployment?: RemoteDeploymentRequest;
2329
+ /** Applied AgentWorkload (present when deployed through an orchestration facade). */
2330
+ workload?: AgentWorkloadResource;
2331
+ }
2332
+ interface RemoteDeploymentWorkloadOptions {
2333
+ /** Workload name (defaults to the content-addressed artifact name). */
2334
+ name?: string;
2335
+ namespace?: string;
2336
+ ownerReferences?: OrchestrationOwnerReference[];
2337
+ }
2338
+ /**
2339
+ * Translate a {@link RemoteDeploymentRequest} into an AgentWorkload manifest
2340
+ * the binding controller (24.56) can schedule. The script declares placement
2341
+ * and lifecycle; the scheduler — never the script — selects the node.
2342
+ */
2343
+ declare function remoteDeploymentToWorkloadManifest(deployment: RemoteDeploymentRequest, options?: RemoteDeploymentWorkloadOptions): AgentWorkloadManifest;
2344
+ /**
2345
+ * Run the full generated-script security chain and produce a remote
2346
+ * deployment request. Never throws for script-content problems — invalid or
2347
+ * inadmissible scripts yield `deployed: false` with a structured reason.
2348
+ *
2349
+ * Checkpoint compatibility (plan 24.19) is enforced here: when the caller
2350
+ * expects to resume a checkpoint and admission found it incompatible, no
2351
+ * deployment is produced (an explicit converter or restart policy would be
2352
+ * required first).
2353
+ */
2354
+ declare function deployGeneratedScript(request: ScriptDeploymentRequest, options?: ScriptDeploymentPipelineOptions): Promise<ScriptDeploymentResult>;
2355
+ /** Configuration for {@link createScriptLoadGate}. */
2356
+ interface ScriptLoadGateConfig {
2357
+ /** Trust class to assign admitted scripts (plan 24.17). */
2358
+ authorTrust: ScriptTrustClass;
2359
+ /** Interfaces admitted scripts may request. */
2360
+ requestedInterfaces: string[];
2361
+ /** RuntimeClass names available for selection (defaults to all built-ins). */
2362
+ availableRuntimeClasses?: string[];
2363
+ /** Optional checkpoint digest admitted scripts expect to resume from. */
2364
+ expectedCheckpointDigest?: string;
2365
+ /** API version of the expected checkpoint (plan 24.19). */
2366
+ checkpointApiVersion?: string;
2367
+ }
2368
+ /**
2369
+ * Create the production {@link ScriptLoadGate}: every non-builtin source is
2370
+ * validated (Acorn AST), admitted under the configured trust-class policy,
2371
+ * and assigned a RuntimeClass before the loader is allowed to `import()` it.
2372
+ * The gate verifies that the digest computed by the loader matches the
2373
+ * digest of the source it validated, so the admitted bytes are exactly the
2374
+ * imported bytes.
2375
+ */
2376
+ declare function createScriptLoadGate(config: ScriptLoadGateConfig): ScriptLoadGate;
2377
+ /**
2378
+ * Host-bound configuration for {@link createScriptDeploymentClient}.
2379
+ * Trust and interface ceilings come from the host, never from the calling
2380
+ * script — a script cannot elevate its own trust class or widen the
2381
+ * interface set beyond what the host configured.
2382
+ */
2383
+ interface ScriptDeploymentClientConfig {
2384
+ /** Trust class the host assigns to deployments from this context. */
2385
+ authorTrust: ScriptTrustClass;
2386
+ /**
2387
+ * Interface ceiling for deployments (defaults to the widest set
2388
+ * admissible for `authorTrust`). Scripts may request a narrower subset;
2389
+ * anything wider is rejected by admission.
2390
+ */
2391
+ requestedInterfaces?: string[];
2392
+ /** RuntimeClass names available for selection (defaults to all built-ins). */
2393
+ availableRuntimeClasses?: string[];
2394
+ /** Artifact persistence port; when omitted manifests are built but not persisted. */
2395
+ artifactStore?: ScriptArtifactStore;
2396
+ /** Default namespace for produced ArtifactRecords and deployments. */
2397
+ namespace?: string;
2398
+ /**
2399
+ * Orchestration facade. When present, `deploy` also applies an
2400
+ * AgentWorkload so the scheduler binds a node (plan 24.14); when absent,
2401
+ * `deploy` only produces the deployment request and the readiness/deletion
2402
+ * methods reject with UNSUPPORTED.
2403
+ */
2404
+ orchestration?: AgentOrchestrationClient;
2405
+ /** Field manager for applied workloads (default `memeloop/script-deployment`). */
2406
+ fieldManager?: string;
2407
+ }
2408
+ /** Request a script makes through the deployment client. */
2409
+ interface ScriptDeploymentClientRequest {
2410
+ /** Raw generated `.mjs` source (normalized internally). */
2411
+ source: string;
2412
+ /** Desired lifecycle for the remote workload. */
2413
+ lifecycle: 'run-once' | 'service' | 'schedule';
2414
+ /** Optional narrower interface subset (must stay within the host ceiling). */
2415
+ requestedInterfaces?: string[];
2416
+ /** Node selector for scheduling. */
2417
+ nodeSelector?: Record<string, string>;
2418
+ /** Environment variables (never credentials). */
2419
+ env?: Record<string, string>;
2420
+ /** Network attachment requirements for the deployed workload. */
2421
+ networkPolicy?: AgentWorkloadNetworkPolicy;
2422
+ /** Existing volume claims required by the deployed workload. */
2423
+ storagePolicy?: AgentWorkloadStoragePolicy;
2424
+ /** Optional checkpoint digest the script expects to resume from. */
2425
+ expectedCheckpointDigest?: string;
2426
+ /** API version of the expected checkpoint (plan 24.19). */
2427
+ checkpointApiVersion?: string;
2428
+ /** Namespace override (defaults to the configured namespace). */
2429
+ namespace?: string;
2430
+ }
2431
+ /** Agent-facing handle for declarative script deployment (plan 24.14). */
2432
+ interface ScriptDeploymentClient {
2433
+ /**
2434
+ * Validate, admit, persist, and package a generated script as a
2435
+ * {@link RemoteDeploymentRequest} referencing its ArtifactRecord by
2436
+ * digest. When an orchestration facade is configured, also applies the
2437
+ * AgentWorkload so the scheduler binds a node. Never throws for
2438
+ * script-content problems — inadmissible scripts yield `deployed: false`
2439
+ * with a structured reason.
2440
+ */
2441
+ deploy(request: ScriptDeploymentClientRequest): Promise<ScriptDeploymentResult>;
2442
+ /**
2443
+ * Wait until the scheduler has bound the deployment's workload
2444
+ * (`Scheduled=True` condition written by the binding controller).
2445
+ */
2446
+ waitForScheduled(name: string, options?: WaitForConditionOptions & {
2447
+ namespace?: string;
2448
+ }): Promise<{
2449
+ observedResourceVersion: string;
2450
+ matched: true;
2451
+ }>;
2452
+ /** Delete the deployment's workload. */
2453
+ deleteDeployment(name: string, namespace?: string): Promise<void>;
2454
+ }
2455
+ /**
2456
+ * Create the Agent-facing deployment client injected into `.mjs` scripts
2457
+ * as `ctx.scriptClient` (plan 24.14). The script declares placement and
2458
+ * lifecycle; trust, interface ceilings, and persistence are bound by the
2459
+ * host. The scheduler — not the script — selects the target node.
2460
+ */
2461
+ declare function createScriptDeploymentClient(config: ScriptDeploymentClientConfig): ScriptDeploymentClient;
2462
+
2463
+ export { type AgentRunManifest as $, type AgentFrameworkContext as A, type ScriptDeploymentClient as B, type ToolApprovalConfig as C, type ApprovalDecision as D, type ToolApprovalRequest as E, type PromptConcatHookContext as F, type DefineToolAgentFrameworkContext as G, type PostProcessContext as H, type IChatSyncAdapter as I, type AIResponseContext as J, type PromptConcatHooks as K, type LoopPlugin as L, type MemeLoopLogger as M, AGENT_RUN_API_VERSION as N, AGENT_RUN_KIND as O, type PromptConcatTool as P, AGENT_WORKLOAD_API_VERSION as Q, AGENT_WORKLOAD_KIND as R, type ScriptLoadGate as S, type ToolCallingMatch as T, type AIStreamResponseSubset as U, ARTIFACT_RECORD_API_VERSION as V, ARTIFACT_RECORD_KIND as W, AUDIT_RECORD_API_VERSION as X, AUDIT_RECORD_KIND as Y, type AgentResponse as Z, type AgentRunCondition as _, type AgentInstanceModel as a, type ControlStoreVerb as a$, type AgentRunResource as a0, type AgentRunSpec as a1, type AgentRunStatus as a2, type AgentSnapshotManifest as a3, type AgentSnapshotResource as a4, type AgentSnapshotSpec as a5, type AgentSnapshotStatus as a6, type AgentStatusContext as a7, type AgentTrustLevel as a8, type AgentVolumeClaimManifest as a9, type ArtifactRecordStatus as aA, type ArtifactReviewEvidence as aB, type ArtifactReviewKind as aC, type ArtifactTrust as aD, type AuditRecordManifest as aE, type AuditRecordResource as aF, type AuditRecordSpec as aG, BUILTIN_RUNTIME_CLASSES as aH, type BaseToolContext as aI, CREDENTIAL_GRANT_API_VERSION as aJ, CREDENTIAL_GRANT_KIND as aK, type CheckpointRecord as aL, type CheckpointStore as aM, type CheckpointSummary as aN, type ControlLeaseGrant as aO, type ControlLeaseIdentity as aP, type ControlLeaseRequest as aQ, type ControlStore as aR, type ControlStoreActor as aS, type ControlStoreApplyOptions as aT, type ControlStoreAuthorizationRequest as aU, type ControlStoreAuthorizer as aV, type ControlStoreCompactionResult as aW, type ControlStoreCreateOptions as aX, type ControlStoreHealth as aY, type ControlStoreSnapshotResult as aZ, type ControlStoreStatusUpdateOptions as a_, type AgentVolumeClaimResource as aa, type AgentVolumeClaimSpec as ab, type AgentVolumeClaimStatus as ac, type AgentVolumeManifest as ad, type AgentVolumeReplicaStatus as ae, type AgentVolumeResource as af, type AgentVolumeSpec as ag, type AgentVolumeStatus as ah, type AgentWorkloadCompletionPolicy as ai, type AgentWorkloadCondition as aj, type AgentWorkloadCredentialPolicy as ak, type AgentWorkloadManifest as al, type AgentWorkloadModelPolicy as am, type AgentWorkloadNetworkPolicy as an, type AgentWorkloadPlacement as ao, type AgentWorkloadResource as ap, type AgentWorkloadResourceRequirements as aq, type AgentWorkloadSpec as ar, type AgentWorkloadStatus as as, type AgentWorkloadStoragePolicy as at, type AgentWorkloadToolPolicy as au, type AgentWorkloadVolumeClaim as av, type ArtifactDestination as aw, type ArtifactRecordManifest as ax, type ArtifactRecordResource as ay, type ArtifactRecordSpec as az, type AgentInstanceLatestStatus as b, SECURITY_PROFILE_API_VERSION as b$, type CreateAgentRunOptions as b0, type CreateAgentWorkloadOptions as b1, type CredentialGrantManifest as b2, type CredentialGrantResource as b3, type CredentialGrantSpec as b4, type CredentialGrantStatus as b5, DRIVER_MANIFEST_API_VERSION as b6, DRIVER_MANIFEST_KIND as b7, type DataClassification as b8, type DriverManifestConformance as b9, type ModelModality as bA, NETWORK_ATTACHMENT_API_VERSION as bB, NETWORK_ATTACHMENT_KIND as bC, NETWORK_CLASS_API_VERSION as bD, NETWORK_CLASS_KIND as bE, type NetworkAttachmentManifest as bF, type NetworkAttachmentResource as bG, type NetworkAttachmentSpec as bH, type NetworkAttachmentStatus as bI, type NetworkClassManifest as bJ, type NetworkClassResource as bK, type NetworkClassSpec as bL, type NetworkClassStatus as bM, type NetworkEgressRule as bN, type NodeTrustClass as bO, POLICY_DECISION_API_VERSION as bP, POLICY_DECISION_KIND as bQ, type PersistedPolicyDecisionKind as bR, type PolicyDecisionManifest as bS, type PolicyDecisionResource as bT, type PolicyDecisionSpec as bU, type PolicyDecisionStatus as bV, type RemoteDeploymentRequest as bW, type RemoteDeploymentResult as bX, type RemoteDeploymentWorkloadOptions as bY, type RuntimeClassResource as bZ, type RuntimeClassSpec as b_, type DriverManifestManifest as ba, type DriverManifestResource as bb, type DriverManifestSpec as bc, type DriverManifestStatus as bd, type FrameworkPluginToolConfig as be, type HookSlot as bf, type InfrastructureDriverType as bg, MODEL_CALL_RECORD_API_VERSION as bh, MODEL_CALL_RECORD_KIND as bi, MODEL_CLASS_API_VERSION as bj, MODEL_CLASS_KIND as bk, MODEL_ENDPOINT_API_VERSION as bl, MODEL_ENDPOINT_KIND as bm, type ModelCallRecordManifest as bn, type ModelCallRecordResource as bo, type ModelCallRecordSpec as bp, type ModelCallRecordStatus as bq, type ModelClassCapabilities as br, type ModelClassManifest as bs, type ModelClassResource as bt, type ModelClassSpec as bu, type ModelClassStatus as bv, type ModelEndpointManifest as bw, type ModelEndpointResource as bx, type ModelEndpointSpec as by, type ModelEndpointStatus as bz, type AgentInstanceState as c, VOLUME_CLAIM_KIND as c$, SECURITY_PROFILE_KIND as c0, SNAPSHOT_API_VERSION as c1, SNAPSHOT_KIND as c2, STORAGE_CLASS_API_VERSION as c3, STORAGE_CLASS_KIND as c4, type SandboxSelectionResult as c5, type ScriptAdmissionDecision as c6, type ScriptAdmissionRequest as c7, type ScriptArtifactReference as c8, type ScriptArtifactStore as c9, type ToolAdmissionPolicy as cA, type ToolAdmissionRule as cB, type ToolApprovalMode as cC, type ToolClassManifest as cD, type ToolClassResource as cE, type ToolClassSchema as cF, type ToolClassSpec as cG, type ToolClassStatus as cH, type ToolExecutionContext as cI, type ToolExecutorCapability as cJ, type ToolExecutorManifest as cK, type ToolExecutorResource as cL, type ToolExecutorSpec as cM, type ToolExecutorStatus as cN, type ToolOperationApprovalEvidence as cO, type ToolOperationManifest as cP, type ToolOperationPolicy as cQ, type ToolOperationResource as cR, type ToolOperationResult as cS, type ToolOperationRetryPolicy as cT, type ToolOperationSpec as cU, type ToolOperationStatus as cV, type ToolOperationToolReference as cW, type ToolRiskLevel as cX, type UserMessageContext as cY, VOLUME_API_VERSION as cZ, VOLUME_CLAIM_API_VERSION as c_, type ScriptDeploymentClientConfig as ca, type ScriptDeploymentClientRequest as cb, type ScriptDeploymentPipelineOptions as cc, type ScriptDeploymentRequest as cd, type ScriptDeploymentResult as ce, type ScriptLoadGateConfig as cf, type ScriptTrustClass as cg, type ScriptValidationResult as ch, type SecurityProfileManifest as ci, type SecurityProfileResource as cj, type SecurityProfileSpec as ck, type SecurityProfileStatus as cl, SessionStorage as cm, type StorageClassManifest as cn, type StorageClassResource as co, type StorageClassSpec as cp, type StorageClassStatus as cq, TOOL_CLASS_API_VERSION as cr, TOOL_CLASS_KIND as cs, TOOL_EXECUTOR_API_VERSION as ct, TOOL_EXECUTOR_KIND as cu, TOOL_OPERATION_API_VERSION as cv, TOOL_OPERATION_KIND as cw, type TapAsyncHandler as cx, type ToolActions as cy, type ToolAdmissionAction as cz, type AgentLoopDefinition as d, serializeCheckpointRecord as d$, VOLUME_KIND as d0, type VolumeAccessMode as d1, type WaitForConditionOptions as d2, type YieldNextRoundTarget as d3, admitScript as d4, agentRunReference as d5, agentWorkloadReference as d6, canonicalControlStoreValue as d7, controlStoreApplyMatches as d8, createAgentClient as d9, digestNormalizedScript as dA, isAgentRun as dB, isAgentWorkload as dC, isArtifactRecord as dD, isAuditRecord as dE, isCredentialGrant as dF, isDriverManifest as dG, isDriverManifestAdmitted as dH, isModelCallRecord as dI, isModelClass as dJ, isModelEndpoint as dK, isNetworkAttachment as dL, isNetworkClass as dM, isPolicyDecision as dN, isSecurityProfile as dO, isSnapshot as dP, isStorageClass as dQ, isToolClass as dR, isToolExecutor as dS, isToolOperation as dT, isVolume as dU, isVolumeClaim as dV, maxScriptBytesForTrustClass as dW, normalizeScript as dX, parseCheckpointRecord as dY, remoteDeploymentToWorkloadManifest as dZ, selectRuntimeClass as d_, createAgentRunManifest as da, createAgentWorkloadManifest as db, createArtifactRecordManifest as dc, createAuditRecordManifest as dd, createCheckpointRecord as de, createCredentialGrantManifest as df, createDriverManifestManifest as dg, createModelCallRecordManifest as dh, createModelClassManifest as di, createModelEndpointManifest as dj, createNetworkAttachmentManifest as dk, createNetworkClassManifest as dl, createPolicyDecisionManifest as dm, createScriptDeploymentClient as dn, createScriptLoadGate as dp, createSecurityProfileManifest as dq, createSnapshotManifest as dr, createStorageClassManifest as ds, createToolClassManifest as dt, createToolExecutorManifest as du, createToolOperationManifest as dv, createVolumeClaimManifest as dw, createVolumeManifest as dx, defaultRequestedInterfacesForTrustClass as dy, deployGeneratedScript as dz, type AgentLoopGenerator as e, validateScript as e0, waitForCondition as e1, InMemoryCheckpointStore as e2, type SessionStorageOptions as e3, 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, matchAllToolCallings as w, matchToolCalling as x, type ToolOperationEffect as y, type AgentClient as z };