@vibesdotdev/agent-execution 0.0.0-stage → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +53 -2
  3. package/dist/code-session/agent-code-session.consumer.descriptor.d.ts +68 -0
  4. package/dist/code-session/agent-code-session.consumer.descriptor.d.ts.map +1 -0
  5. package/dist/code-session/agent-code-session.consumer.descriptor.js +31 -0
  6. package/dist/code-session/agent-code-session.consumer.descriptor.js.map +1 -0
  7. package/dist/code-session/agent-code-session.consumer.plugin.d.ts +18 -0
  8. package/dist/code-session/agent-code-session.consumer.plugin.d.ts.map +1 -0
  9. package/dist/code-session/agent-code-session.consumer.plugin.js +47 -0
  10. package/dist/code-session/agent-code-session.consumer.plugin.js.map +1 -0
  11. package/dist/code-session/agent-code-session.descriptor.d.ts +163 -0
  12. package/dist/code-session/agent-code-session.descriptor.d.ts.map +1 -0
  13. package/dist/code-session/agent-code-session.descriptor.js +129 -0
  14. package/dist/code-session/agent-code-session.descriptor.js.map +1 -0
  15. package/dist/code-session/agent-code-session.impl.consumer.d.ts +224 -0
  16. package/dist/code-session/agent-code-session.impl.consumer.d.ts.map +1 -0
  17. package/dist/code-session/agent-code-session.impl.consumer.js +2131 -0
  18. package/dist/code-session/agent-code-session.impl.consumer.js.map +1 -0
  19. package/dist/code-session/agent-code-session.kind.d.ts +15 -0
  20. package/dist/code-session/agent-code-session.kind.d.ts.map +1 -0
  21. package/dist/code-session/agent-code-session.kind.js +17 -0
  22. package/dist/code-session/agent-code-session.kind.js.map +1 -0
  23. package/dist/code-session/agent-code-session.plugin.d.ts +17 -0
  24. package/dist/code-session/agent-code-session.plugin.d.ts.map +1 -0
  25. package/dist/code-session/agent-code-session.plugin.js +28 -0
  26. package/dist/code-session/agent-code-session.plugin.js.map +1 -0
  27. package/dist/code-session/billing/gates.d.ts +52 -0
  28. package/dist/code-session/billing/gates.d.ts.map +1 -0
  29. package/dist/code-session/billing/gates.js +75 -0
  30. package/dist/code-session/billing/gates.js.map +1 -0
  31. package/dist/code-session/client/index.d.ts +2 -0
  32. package/dist/code-session/client/index.d.ts.map +1 -0
  33. package/dist/code-session/client/index.js +2 -0
  34. package/dist/code-session/client/index.js.map +1 -0
  35. package/dist/code-session/client/resolve.d.ts +20 -0
  36. package/dist/code-session/client/resolve.d.ts.map +1 -0
  37. package/dist/code-session/client/resolve.js +145 -0
  38. package/dist/code-session/client/resolve.js.map +1 -0
  39. package/dist/code-session/docs/agent-code-session.docs.descriptor.d.ts +4 -0
  40. package/dist/code-session/docs/agent-code-session.docs.descriptor.d.ts.map +1 -0
  41. package/dist/code-session/docs/agent-code-session.docs.descriptor.js +109 -0
  42. package/dist/code-session/docs/agent-code-session.docs.descriptor.js.map +1 -0
  43. package/dist/code-session/git-credential.d.ts +87 -0
  44. package/dist/code-session/git-credential.d.ts.map +1 -0
  45. package/dist/code-session/git-credential.js +107 -0
  46. package/dist/code-session/git-credential.js.map +1 -0
  47. package/dist/code-session/host-target.d.ts +76 -0
  48. package/dist/code-session/host-target.d.ts.map +1 -0
  49. package/dist/code-session/host-target.js +81 -0
  50. package/dist/code-session/host-target.js.map +1 -0
  51. package/dist/code-session/index.d.ts +20 -0
  52. package/dist/code-session/index.d.ts.map +1 -0
  53. package/dist/code-session/index.js +20 -0
  54. package/dist/code-session/index.js.map +1 -0
  55. package/dist/code-session/interfaces/code-session.d.ts +448 -0
  56. package/dist/code-session/interfaces/code-session.d.ts.map +1 -0
  57. package/dist/code-session/interfaces/code-session.js +373 -0
  58. package/dist/code-session/interfaces/code-session.js.map +1 -0
  59. package/dist/code-session/operation-lease.d.ts +48 -0
  60. package/dist/code-session/operation-lease.d.ts.map +1 -0
  61. package/dist/code-session/operation-lease.js +73 -0
  62. package/dist/code-session/operation-lease.js.map +1 -0
  63. package/dist/code-session/remote-setup-custody.d.ts +59 -0
  64. package/dist/code-session/remote-setup-custody.d.ts.map +1 -0
  65. package/dist/code-session/remote-setup-custody.js +78 -0
  66. package/dist/code-session/remote-setup-custody.js.map +1 -0
  67. package/dist/code-session/remote-workspace-fs.d.ts +119 -0
  68. package/dist/code-session/remote-workspace-fs.d.ts.map +1 -0
  69. package/dist/code-session/remote-workspace-fs.js +257 -0
  70. package/dist/code-session/remote-workspace-fs.js.map +1 -0
  71. package/dist/code-session/session-metadata.d.ts +40 -0
  72. package/dist/code-session/session-metadata.d.ts.map +1 -0
  73. package/dist/code-session/session-metadata.js +69 -0
  74. package/dist/code-session/session-metadata.js.map +1 -0
  75. package/dist/code-session-relay/agent-code-session-relay.descriptor.d.ts +78 -0
  76. package/dist/code-session-relay/agent-code-session-relay.descriptor.d.ts.map +1 -0
  77. package/dist/code-session-relay/agent-code-session-relay.descriptor.js +38 -0
  78. package/dist/code-session-relay/agent-code-session-relay.descriptor.js.map +1 -0
  79. package/dist/code-session-relay/agent-code-session-relay.impl.d.ts +120 -0
  80. package/dist/code-session-relay/agent-code-session-relay.impl.d.ts.map +1 -0
  81. package/dist/code-session-relay/agent-code-session-relay.impl.js +1392 -0
  82. package/dist/code-session-relay/agent-code-session-relay.impl.js.map +1 -0
  83. package/dist/code-session-relay/agent-code-session-relay.plugin.d.ts +14 -0
  84. package/dist/code-session-relay/agent-code-session-relay.plugin.d.ts.map +1 -0
  85. package/dist/code-session-relay/agent-code-session-relay.plugin.js +25 -0
  86. package/dist/code-session-relay/agent-code-session-relay.plugin.js.map +1 -0
  87. package/dist/code-session-relay/index.d.ts +13 -0
  88. package/dist/code-session-relay/index.d.ts.map +1 -0
  89. package/dist/code-session-relay/index.js +13 -0
  90. package/dist/code-session-relay/index.js.map +1 -0
  91. package/dist/code-session-relay/relay-dial.d.ts +72 -0
  92. package/dist/code-session-relay/relay-dial.d.ts.map +1 -0
  93. package/dist/code-session-relay/relay-dial.js +177 -0
  94. package/dist/code-session-relay/relay-dial.js.map +1 -0
  95. package/dist/index.d.ts +10 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +10 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/sandbox/agent-sandbox.consumer.descriptor.d.ts +35 -0
  100. package/dist/sandbox/agent-sandbox.consumer.descriptor.d.ts.map +1 -0
  101. package/dist/sandbox/agent-sandbox.consumer.descriptor.js +19 -0
  102. package/dist/sandbox/agent-sandbox.consumer.descriptor.js.map +1 -0
  103. package/dist/sandbox/agent-sandbox.consumer.plugin.d.ts +9 -0
  104. package/dist/sandbox/agent-sandbox.consumer.plugin.d.ts.map +1 -0
  105. package/dist/sandbox/agent-sandbox.consumer.plugin.js +33 -0
  106. package/dist/sandbox/agent-sandbox.consumer.plugin.js.map +1 -0
  107. package/dist/sandbox/agent-sandbox.descriptor.d.ts +76 -0
  108. package/dist/sandbox/agent-sandbox.descriptor.d.ts.map +1 -0
  109. package/dist/sandbox/agent-sandbox.descriptor.js +57 -0
  110. package/dist/sandbox/agent-sandbox.descriptor.js.map +1 -0
  111. package/dist/sandbox/agent-sandbox.impl.consumer.d.ts +15 -0
  112. package/dist/sandbox/agent-sandbox.impl.consumer.d.ts.map +1 -0
  113. package/dist/sandbox/agent-sandbox.impl.consumer.js +23 -0
  114. package/dist/sandbox/agent-sandbox.impl.consumer.js.map +1 -0
  115. package/dist/sandbox/agent-sandbox.kind.d.ts +14 -0
  116. package/dist/sandbox/agent-sandbox.kind.d.ts.map +1 -0
  117. package/dist/sandbox/agent-sandbox.kind.js +16 -0
  118. package/dist/sandbox/agent-sandbox.kind.js.map +1 -0
  119. package/dist/sandbox/agent-sandbox.plugin.d.ts +15 -0
  120. package/dist/sandbox/agent-sandbox.plugin.d.ts.map +1 -0
  121. package/dist/sandbox/agent-sandbox.plugin.js +25 -0
  122. package/dist/sandbox/agent-sandbox.plugin.js.map +1 -0
  123. package/dist/sandbox/client/resolve.d.ts +21 -0
  124. package/dist/sandbox/client/resolve.d.ts.map +1 -0
  125. package/dist/sandbox/client/resolve.js +103 -0
  126. package/dist/sandbox/client/resolve.js.map +1 -0
  127. package/dist/sandbox/docs/agent-sandbox.docs.descriptor.d.ts +4 -0
  128. package/dist/sandbox/docs/agent-sandbox.docs.descriptor.d.ts.map +1 -0
  129. package/dist/sandbox/docs/agent-sandbox.docs.descriptor.js +75 -0
  130. package/dist/sandbox/docs/agent-sandbox.docs.descriptor.js.map +1 -0
  131. package/dist/sandbox/index.d.ts +15 -0
  132. package/dist/sandbox/index.d.ts.map +1 -0
  133. package/dist/sandbox/index.js +14 -0
  134. package/dist/sandbox/index.js.map +1 -0
  135. package/dist/sandbox/interfaces/sandbox.d.ts +61 -0
  136. package/dist/sandbox/interfaces/sandbox.d.ts.map +1 -0
  137. package/dist/sandbox/interfaces/sandbox.js +54 -0
  138. package/dist/sandbox/interfaces/sandbox.js.map +1 -0
  139. package/dist/schemas/code-session-resolution.d.ts +20 -0
  140. package/dist/schemas/code-session-resolution.d.ts.map +1 -0
  141. package/dist/schemas/code-session-resolution.js +11 -0
  142. package/dist/schemas/code-session-resolution.js.map +1 -0
  143. package/dist/schemas/session-operation.d.ts +73 -0
  144. package/dist/schemas/session-operation.d.ts.map +1 -0
  145. package/dist/schemas/session-operation.js +47 -0
  146. package/dist/schemas/session-operation.js.map +1 -0
  147. package/dist/schemas/voice.d.ts +87 -0
  148. package/dist/schemas/voice.d.ts.map +1 -0
  149. package/dist/schemas/voice.js +70 -0
  150. package/dist/schemas/voice.js.map +1 -0
  151. package/dist/voice/agent-voice.consumer.descriptor.d.ts +43 -0
  152. package/dist/voice/agent-voice.consumer.descriptor.d.ts.map +1 -0
  153. package/dist/voice/agent-voice.consumer.descriptor.js +20 -0
  154. package/dist/voice/agent-voice.consumer.descriptor.js.map +1 -0
  155. package/dist/voice/agent-voice.consumer.plugin.d.ts +4 -0
  156. package/dist/voice/agent-voice.consumer.plugin.d.ts.map +1 -0
  157. package/dist/voice/agent-voice.consumer.plugin.js +13 -0
  158. package/dist/voice/agent-voice.consumer.plugin.js.map +1 -0
  159. package/dist/voice/agent-voice.descriptor.d.ts +82 -0
  160. package/dist/voice/agent-voice.descriptor.d.ts.map +1 -0
  161. package/dist/voice/agent-voice.descriptor.js +79 -0
  162. package/dist/voice/agent-voice.descriptor.js.map +1 -0
  163. package/dist/voice/agent-voice.impl.consumer.d.ts +35 -0
  164. package/dist/voice/agent-voice.impl.consumer.d.ts.map +1 -0
  165. package/dist/voice/agent-voice.impl.consumer.js +50 -0
  166. package/dist/voice/agent-voice.impl.consumer.js.map +1 -0
  167. package/dist/voice/agent-voice.kind.d.ts +67 -0
  168. package/dist/voice/agent-voice.kind.d.ts.map +1 -0
  169. package/dist/voice/agent-voice.kind.js +26 -0
  170. package/dist/voice/agent-voice.kind.js.map +1 -0
  171. package/dist/voice/agent-voice.plugin.d.ts +4 -0
  172. package/dist/voice/agent-voice.plugin.d.ts.map +1 -0
  173. package/dist/voice/agent-voice.plugin.js +18 -0
  174. package/dist/voice/agent-voice.plugin.js.map +1 -0
  175. package/dist/voice/client.d.ts +38 -0
  176. package/dist/voice/client.d.ts.map +1 -0
  177. package/dist/voice/client.js +29 -0
  178. package/dist/voice/client.js.map +1 -0
  179. package/dist/voice/index.d.ts +14 -0
  180. package/dist/voice/index.d.ts.map +1 -0
  181. package/dist/voice/index.js +14 -0
  182. package/dist/voice/index.js.map +1 -0
  183. package/dist/voice/pipeline.d.ts +66 -0
  184. package/dist/voice/pipeline.d.ts.map +1 -0
  185. package/dist/voice/pipeline.js +330 -0
  186. package/dist/voice/pipeline.js.map +1 -0
  187. package/dist/voice/session.d.ts +29 -0
  188. package/dist/voice/session.d.ts.map +1 -0
  189. package/dist/voice/session.js +78 -0
  190. package/dist/voice/session.js.map +1 -0
  191. package/package.json +279 -4
@@ -0,0 +1,373 @@
1
+ /**
2
+ * Code Session interface — the contract every `agent/code-session` impl
3
+ * (consumer Bun-on-a-Host, cloud Cloudflare Sandbox) satisfies.
4
+ *
5
+ * Node-free / Playwright-free at the type level so the cloud adapter can import
6
+ * it without dragging a Node-only impl into a workerd bundle. Git op shapes
7
+ * follow the `git/operations` contract in `@vibesdotdev/git-operations` so
8
+ * consumer + cloud agree on result shapes.
9
+ */
10
+ import * as z from 'zod/v4';
11
+ import { CapabilityError, CaughtFailureSchema, valueFreeFailure } from '@vibesdotdev/kernel';
12
+ import { CodeSessionRuntimeConfigSchema } from "../agent-code-session.descriptor.js";
13
+ import { SessionHostTargetSchema } from "../host-target.js";
14
+ const RequestIdentifierSchema = z.string().trim().min(1).max(512);
15
+ const RequestPathSchema = z.string().min(1).max(8_192);
16
+ const RequestTextSchema = z.string().max(16 * 1024 * 1024);
17
+ const RequestEnvironmentSchema = z.record(z.string().trim().min(1).max(256), z.string().max(64 * 1024));
18
+ const GitNetworkOperationSchema = z.enum(['clone', 'fetch', 'pull', 'push']);
19
+ function requestInvalid(field, caught) {
20
+ return new CapabilityError('The code-session request is invalid.', 'INVALID_INPUT', {
21
+ reason: 'code-session-request-invalid',
22
+ retryable: false,
23
+ details: { field },
24
+ cause: valueFreeFailure(CaughtFailureSchema.parse(caught))
25
+ });
26
+ }
27
+ /**
28
+ * Parse one public request exactly once, including hostile proxy/accessor failures.
29
+ * An own `__proto__` key is not a field of any request: it refuses here, whatever
30
+ * the schema library's strict-object handling of it.
31
+ */
32
+ function parseRequest(schema, value, field) {
33
+ try {
34
+ if (Object(value) === value && Object.hasOwn(Object(value), '__proto__')) {
35
+ throw new TypeError('The request carries an own __proto__ key.');
36
+ }
37
+ return schema.parse(value);
38
+ }
39
+ catch (caught) {
40
+ throw requestInvalid(field, caught);
41
+ }
42
+ }
43
+ /**
44
+ * A transient clone/push credential. Injected via a git credential helper in the
45
+ * process env for the single clone invocation — NEVER embedded in the clone URL
46
+ * (which would persist into `.git/config`) and never logged. Resolved by the
47
+ * caller from the repo's `credentialId` (provider `resolveCloneCredential`).
48
+ */
49
+ export const CodeSessionCloneCredentialSchema = z
50
+ .object({
51
+ username: z.string().min(1).max(1_024).optional(),
52
+ token: z.string().min(1).max(64 * 1024),
53
+ /** Discriminant the canonical credential builder switches on. */
54
+ kind: z.literal('token').optional(),
55
+ repositoryId: RequestIdentifierSchema.optional(),
56
+ /** Exact canonical HTTPS remote, e.g. `https://host/owner/name.git`. */
57
+ remoteUrl: z.string().min(1).max(8_192).optional(),
58
+ operations: z.array(GitNetworkOperationSchema).min(1).max(4).optional(),
59
+ /** Absolute Unix epoch in MILLISECONDS. */
60
+ expiresAtEpochMs: z.number().int().positive().finite().optional()
61
+ })
62
+ .strict()
63
+ .superRefine((credential, context) => {
64
+ const leaseFields = [
65
+ credential.repositoryId,
66
+ credential.remoteUrl,
67
+ credential.operations,
68
+ credential.expiresAtEpochMs
69
+ ];
70
+ const present = leaseFields.filter((value) => value !== undefined).length;
71
+ if (present !== 0 && present !== leaseFields.length) {
72
+ context.addIssue({
73
+ code: 'custom',
74
+ message: 'credential lease fields must be supplied together'
75
+ });
76
+ }
77
+ });
78
+ /** What to clone/check out when a session initializes. */
79
+ const CallableSchema = z.function();
80
+ const OnAllocatedSchema = z.custom((value) => CallableSchema.safeParse(value).success);
81
+ export const CodeSessionInitializeInputSchema = z
82
+ .object({
83
+ /** Stable identity for one create attempt across retries. */
84
+ operationId: RequestIdentifierSchema.optional(),
85
+ /** Existing caller-owned workspace to adopt. */
86
+ workspacePath: RequestPathSchema.optional(),
87
+ repositoryId: RequestIdentifierSchema.optional(),
88
+ cloneUrl: z.string().min(1).max(8_192).optional(),
89
+ cloneCredential: CodeSessionCloneCredentialSchema.optional(),
90
+ checkoutRef: z.string().trim().min(1).max(1_024).optional(),
91
+ hostTarget: SessionHostTargetSchema.optional(),
92
+ initialEnv: RequestEnvironmentSchema.optional(),
93
+ exposedPorts: z.array(z.string().trim().min(1).max(32)).max(256).optional(),
94
+ onAllocated: OnAllocatedSchema.optional(),
95
+ runtimeConfig: CodeSessionRuntimeConfigSchema.optional(),
96
+ sessionId: z.string().trim().min(1).max(512).optional(),
97
+ ephemeral: z.boolean().optional()
98
+ })
99
+ .strict();
100
+ export const CodeSessionCreateOrGetInputSchema = CodeSessionInitializeInputSchema.extend({
101
+ /** Required durable identity for one allocation attempt across retries. */
102
+ operationId: RequestIdentifierSchema
103
+ });
104
+ export function parseCodeSessionInitializeInput(value) {
105
+ return parseRequest(CodeSessionInitializeInputSchema, value, 'initialize');
106
+ }
107
+ export function parseCodeSessionCreateOrGetInput(value) {
108
+ return parseRequest(CodeSessionCreateOrGetInputSchema, value, 'createOrGet');
109
+ }
110
+ export { CodeSessionOperationStageSchema, CodeSessionOperationCleanupSchema, PersistedCodeSessionOperationSchema } from "../../schemas/session-operation.js";
111
+ export const CodeSessionHandleSchema = z
112
+ .object({
113
+ sessionId: z.string().trim().min(1).max(512),
114
+ operationId: RequestIdentifierSchema.optional(),
115
+ workspacePath: RequestPathSchema,
116
+ workspaceOwnership: z.enum(['owned', 'borrowed']).optional(),
117
+ createdAt: z.string().min(1).max(64).optional(),
118
+ previewUrl: z.string().min(1).max(8_192).optional(),
119
+ hostTarget: SessionHostTargetSchema,
120
+ repositoryId: RequestIdentifierSchema.optional(),
121
+ ephemeral: z.boolean().optional()
122
+ })
123
+ .strict();
124
+ const AbortSignalSchema = z.instanceof(AbortSignal);
125
+ export const RunCommandInputSchema = z
126
+ .object({
127
+ command: z.array(z.string().min(1).max(32_768)).min(1).max(1_024),
128
+ cwd: RequestPathSchema.optional(),
129
+ env: RequestEnvironmentSchema.optional(),
130
+ background: z.boolean().optional(),
131
+ timeoutMs: z.number().int().positive().finite().optional(),
132
+ signal: AbortSignalSchema.optional()
133
+ })
134
+ .strict();
135
+ export const RunCommandResultSchema = z
136
+ .object({
137
+ exitCode: z.number().int().nullable(),
138
+ stdout: z.string(),
139
+ stderr: z.string(),
140
+ timedOut: z.boolean(),
141
+ durationMs: z.number().finite().nonnegative(),
142
+ procId: z.string().trim().min(1).max(512).optional(),
143
+ running: z.boolean().optional(),
144
+ aborted: z.boolean().optional()
145
+ })
146
+ .strict();
147
+ export const PatchFileInputSchema = z
148
+ .object({ path: RequestPathSchema, diff: RequestTextSchema })
149
+ .strict();
150
+ export const GitApplyInputSchema = z
151
+ .object({ diff: RequestTextSchema, check: z.boolean().optional() })
152
+ .strict();
153
+ export const GitApplyResultSchema = z
154
+ .object({
155
+ ok: z.boolean(),
156
+ stdout: z.string(),
157
+ stderr: z.string(),
158
+ exitCode: z.number().int().nullable()
159
+ })
160
+ .strict();
161
+ export const GitStatusResultSchema = z
162
+ .object({
163
+ staged: z.array(z.string()),
164
+ unstaged: z.array(z.string()),
165
+ untracked: z.array(z.string()),
166
+ branch: z.string()
167
+ })
168
+ .strict();
169
+ export const GitCommitInputSchema = z
170
+ .object({
171
+ message: z.string().trim().min(1).max(64 * 1024),
172
+ author: z.string().trim().min(1).max(1_024).optional(),
173
+ paths: z.array(RequestPathSchema).max(16_384).optional()
174
+ })
175
+ .strict();
176
+ /** Native foreground lifetime, kept separate from the serializable Git input. */
177
+ export const GitCommitOptionsSchema = z.object({ signal: AbortSignalSchema.optional() }).strict();
178
+ export const GitCommitResultSchema = z
179
+ .object({ hash: z.string().trim().min(1).max(512), message: z.string() })
180
+ .strict();
181
+ export const GitPushInputSchema = z
182
+ .object({
183
+ remote: z.string().trim().min(1).max(1_024).optional(),
184
+ branch: z.string().trim().min(1).max(1_024).optional(),
185
+ setUpstream: z.boolean().optional(),
186
+ credential: CodeSessionCloneCredentialSchema.optional()
187
+ })
188
+ .strict();
189
+ export function parsePushCredentialResolver(value) {
190
+ return parseRequest(z.custom((candidate) => CallableSchema.safeParse(candidate).success), value, 'pushCredentialResolver');
191
+ }
192
+ export const ExposePortInputSchema = z
193
+ .object({ port: z.string().trim().min(1).max(32) })
194
+ .strict();
195
+ export const ExposePortResultSchema = z
196
+ .object({ port: z.string().min(1).max(32), previewUrl: z.string().min(1).max(8_192) })
197
+ .strict();
198
+ export const BackgroundProcessInfoSchema = z
199
+ .object({
200
+ procId: z.string().trim().min(1).max(512),
201
+ command: z.array(z.string()),
202
+ cwd: RequestPathSchema.optional(),
203
+ running: z.boolean().nullable(),
204
+ startedAt: z.string().min(1).max(64),
205
+ pid: z.number().int().nonnegative().optional(),
206
+ exitCode: z.number().int().nullable().optional()
207
+ })
208
+ .strict();
209
+ /** Where a background process's output is read from: output after `since`, a cursor from an earlier read. */
210
+ export const BackgroundProcessReadInputSchema = z
211
+ .object({ since: z.number().int().nonnegative().optional() })
212
+ .strict();
213
+ /** A bounded wait for a background process's exit; the deadline never stops the process. */
214
+ export const BackgroundProcessWaitInputSchema = BackgroundProcessReadInputSchema.extend({
215
+ timeoutMs: z.number().int().positive().finite()
216
+ }).strict();
217
+ /**
218
+ * A background process's output since a cursor and its state. `cursor` is the
219
+ * monotonic count of output chunks it has produced: pass it as the next `since`
220
+ * to read only newer output. `timedOut` is true only for a wait whose deadline
221
+ * passed before the process ended.
222
+ */
223
+ export const BackgroundProcessOutputSchema = z
224
+ .object({
225
+ procId: z.string().trim().min(1).max(512),
226
+ stdout: z.string(),
227
+ stderr: z.string(),
228
+ cursor: z.number().int().nonnegative(),
229
+ running: z.boolean().nullable(),
230
+ exitCode: z.number().int().nullable(),
231
+ timedOut: z.boolean()
232
+ })
233
+ .strict();
234
+ export function parseCodeSessionId(value) {
235
+ return parseRequest(z.string().trim().min(1).max(512), value, 'sessionId');
236
+ }
237
+ export function parseCodeSessionPath(value, field = 'path') {
238
+ return parseRequest(RequestPathSchema, value, field);
239
+ }
240
+ export function parseCodeSessionText(value, field) {
241
+ return parseRequest(RequestTextSchema, value, field);
242
+ }
243
+ export function parseRunCommandInput(value) {
244
+ return parseRequest(RunCommandInputSchema, value, 'command');
245
+ }
246
+ export function parsePatchFileInput(value) {
247
+ return parseRequest(PatchFileInputSchema, value, 'patch');
248
+ }
249
+ export function parseGitApplyInput(value) {
250
+ return parseRequest(GitApplyInputSchema, value, 'gitApply');
251
+ }
252
+ export function parseGitCommitInput(value) {
253
+ return parseRequest(GitCommitInputSchema, value, 'gitCommit');
254
+ }
255
+ export function parseGitCommitOptions(value) {
256
+ return parseRequest(GitCommitOptionsSchema, value, 'gitCommitOptions');
257
+ }
258
+ export function parseGitPushInput(value) {
259
+ return parseRequest(GitPushInputSchema, value, 'gitPush');
260
+ }
261
+ export function parseExposePortInput(value) {
262
+ return parseRequest(ExposePortInputSchema, value, 'exposePort');
263
+ }
264
+ export function parseProcessId(value) {
265
+ return parseRequest(z.string().trim().min(1).max(512), value, 'procId');
266
+ }
267
+ export function parseBackgroundProcessReadInput(value) {
268
+ return parseRequest(BackgroundProcessReadInputSchema, value, 'backgroundRead');
269
+ }
270
+ export function parseBackgroundProcessWaitInput(value) {
271
+ return parseRequest(BackgroundProcessWaitInputSchema, value, 'backgroundWait');
272
+ }
273
+ export function parseProcessSignal(value) {
274
+ return parseRequest(z.string().trim().min(1).max(64).optional(), value, 'signal');
275
+ }
276
+ export function parseWriteFileInput(path, content) {
277
+ return parseRequest(z.object({ path: RequestPathSchema, content: RequestTextSchema }).strict(), { path, content }, 'writeFile');
278
+ }
279
+ /** Fields that define one code-session allocation, excluding credentials and callbacks. */
280
+ export const CodeSessionOperationConfigurationSchema = z
281
+ .object({
282
+ authorityId: RequestIdentifierSchema.optional(),
283
+ workspacePath: RequestPathSchema.optional(),
284
+ repositoryId: RequestIdentifierSchema.optional(),
285
+ cloneUrl: z.string().min(1).max(8_192).optional(),
286
+ checkoutRef: z.string().trim().min(1).max(1_024).optional(),
287
+ hostTarget: SessionHostTargetSchema.optional(),
288
+ initialEnv: RequestEnvironmentSchema.optional(),
289
+ exposedPorts: z.array(z.string().trim().min(1).max(32)).max(256).optional(),
290
+ runtimeConfig: CodeSessionRuntimeConfigSchema.optional(),
291
+ ephemeral: z.boolean().optional(),
292
+ cloneCredentialBinding: z
293
+ .object({
294
+ username: z.string().min(1).max(1_024).optional(),
295
+ repositoryId: RequestIdentifierSchema.optional(),
296
+ remoteUrl: z.string().min(1).max(8_192).optional(),
297
+ operations: z.array(GitNetworkOperationSchema).max(4).optional()
298
+ })
299
+ .strict()
300
+ .optional()
301
+ })
302
+ .strict();
303
+ import { JsonObjectSchema, JsonValueSchema } from '@vibesdotdev/kernel/schemas/json';
304
+ function canonicalOperationValue(value) {
305
+ if (Array.isArray(value))
306
+ return value.map(canonicalOperationValue);
307
+ const object = JsonObjectSchema.safeParse(value);
308
+ if (object.success) {
309
+ return Object.fromEntries(Object.entries(object.data)
310
+ .sort(([left], [right]) => left.localeCompare(right))
311
+ .map(([key, entry]) => [key, canonicalOperationValue(entry)]));
312
+ }
313
+ return value;
314
+ }
315
+ function hex(bytes) {
316
+ return [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
317
+ }
318
+ /**
319
+ * Hash the immutable, non-secret allocation configuration shared by consumer,
320
+ * relay, and cloud implementations. Clone credentials and callbacks are
321
+ * intentionally absent so a retry can carry a refreshed credential without
322
+ * becoming a different operation.
323
+ */
324
+ export async function codeSessionOperationFingerprint(input, options = {}) {
325
+ const admittedInput = parseCodeSessionInitializeInput(input);
326
+ const admittedOptions = parseRequest(z.object({ authorityId: RequestIdentifierSchema.optional() }).strict(), options, 'fingerprintOptions');
327
+ const configuration = {
328
+ authorityId: admittedOptions.authorityId,
329
+ workspacePath: admittedInput.workspacePath,
330
+ repositoryId: admittedInput.repositoryId,
331
+ cloneUrl: admittedInput.cloneUrl,
332
+ checkoutRef: admittedInput.checkoutRef,
333
+ hostTarget: admittedInput.hostTarget,
334
+ initialEnv: admittedInput.initialEnv,
335
+ exposedPorts: admittedInput.exposedPorts
336
+ ? [...admittedInput.exposedPorts].sort()
337
+ : undefined,
338
+ runtimeConfig: admittedInput.runtimeConfig,
339
+ ephemeral: admittedInput.ephemeral,
340
+ cloneCredentialBinding: admittedInput.cloneCredential
341
+ ? {
342
+ username: admittedInput.cloneCredential.username,
343
+ repositoryId: admittedInput.cloneCredential.repositoryId,
344
+ remoteUrl: admittedInput.cloneCredential.remoteUrl,
345
+ operations: admittedInput.cloneCredential.operations
346
+ ? [...admittedInput.cloneCredential.operations].sort()
347
+ : undefined
348
+ }
349
+ : undefined
350
+ };
351
+ const admittedConfiguration = parseRequest(CodeSessionOperationConfigurationSchema, configuration, 'operationConfiguration');
352
+ const json = JsonValueSchema.parse(JSON.parse(JSON.stringify(admittedConfiguration)));
353
+ const bytes = new TextEncoder().encode(JSON.stringify(canonicalOperationValue(json)));
354
+ const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes);
355
+ return `sha256:${hex(new Uint8Array(digest))}`;
356
+ }
357
+ /** Stable filesystem/provider key for an operation id without exposing it in a path. */
358
+ export const CodeSessionOperationIdSchema = z.string().trim().min(1).max(512);
359
+ export async function codeSessionOperationKey(operationId) {
360
+ const admitted = parseRequest(CodeSessionOperationIdSchema, operationId, 'operationId');
361
+ const digest = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(admitted));
362
+ return hex(new Uint8Array(digest));
363
+ }
364
+ /**
365
+ * The name of a code-session child's TMPDIR under its host's temp root: a
366
+ * prefix of the workspace key. Tools bind Unix sockets under TMPDIR, and a
367
+ * socket path holds at most 104 bytes on macOS (108 on Linux), so the
368
+ * directory stays short; HOME keeps the full key in the profile root.
369
+ */
370
+ export function codeSessionTempName(key) {
371
+ return key.slice(0, 12);
372
+ }
373
+ //# sourceMappingURL=code-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-session.js","sourceRoot":"","sources":["../../../src/code-session/interfaces/code-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,8BAA8B,EAE9B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACN,uBAAuB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAClE,MAAM,iB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,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Operation-lease timing for code-session preparation, on the owning
3
+ * runtime's lifecycle (RC07).
4
+ *
5
+ * A code-session operation is claimed by creating a directory and kept by a
6
+ * lease file its holder renews. Both halves wait on another process whose
7
+ * only signal is a file appearing (a peer's claim record, or its lease going
8
+ * away): no owner event exists for either, so each wait polls, bounded by
9
+ * `runtime.lifecycle.wait` and paced by `runtime.lifecycle.delay`. Disposal of
10
+ * the runtime or the caller's signal ends the wait; nothing keeps its own
11
+ * timer.
12
+ */
13
+ import type { getLogger } from '@vibesdotdev/logging';
14
+ import { type RuntimeLifecycle } from '@vibesdotdev/kernel';
15
+ /** The logger of the runtime that owns the operation (C083a): the caller hands it, there is no ambient one. */
16
+ type OperationLogger = Pick<ReturnType<typeof getLogger>, 'warn'>;
17
+ /**
18
+ * Poll `check` every `intervalMs` until it answers, for at most `timeoutMs`.
19
+ * Resolves the answer. Deadline, cancellation and failed checks propagate as
20
+ * their typed runtime failures; a caller must not reinterpret timeout as
21
+ * absence.
22
+ */
23
+ export declare function pollUntil<T>(lifecycle: RuntimeLifecycle, check: () => Promise<T | null>, options: {
24
+ intervalMs: number;
25
+ timeoutMs: number;
26
+ reason: string;
27
+ signal?: AbortSignal;
28
+ }): Promise<T>;
29
+ /**
30
+ * Renew a held lease every `periodMs` while `run` holds it.
31
+ *
32
+ * A one-shot lifecycle timer re-armed after each renewal settles, not a
33
+ * lifecycle interval: the heartbeat lives exactly as long as this operation,
34
+ * so a finite host (a CLI `code-session` command), where an autonomous
35
+ * interval is refused, still keeps the lease it holds. A failed renewal is
36
+ * logged at warn with the operation it risks (the lease may lapse and another
37
+ * holder may reconcile the operation); it never fails `run`, and the next
38
+ * tick renews again. The heartbeat stops when `run` settles or the runtime is
39
+ * disposed.
40
+ */
41
+ export declare function withLeaseHeartbeat<T>(lifecycle: RuntimeLifecycle, options: {
42
+ periodMs: number;
43
+ operationId: string;
44
+ renew: () => Promise<void>;
45
+ logger: OperationLogger;
46
+ }, run: () => Promise<T>): Promise<T>;
47
+ export {};
48
+ //# sourceMappingURL=operation-lease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-lease.d.ts","sourceRoot":"","sources":["../../src/code-session/operation-lease.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAyC,KAAK,gBAAgB,EAA2B,MAAM,qBAAqB,CAAC;AAE5H,+GAA+G;AAC/G,KAAK,eAAe,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;AAElE;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAChC,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,EAC9B,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GACtF,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACzC,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,EACvG,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Operation-lease timing for code-session preparation, on the owning
3
+ * runtime's lifecycle (RC07).
4
+ *
5
+ * A code-session operation is claimed by creating a directory and kept by a
6
+ * lease file its holder renews. Both halves wait on another process whose
7
+ * only signal is a file appearing (a peer's claim record, or its lease going
8
+ * away): no owner event exists for either, so each wait polls, bounded by
9
+ * `runtime.lifecycle.wait` and paced by `runtime.lifecycle.delay`. Disposal of
10
+ * the runtime or the caller's signal ends the wait; nothing keeps its own
11
+ * timer.
12
+ */
13
+ import { CaughtFailureSchema, valueFreeFailure } from '@vibesdotdev/kernel';
14
+ /**
15
+ * Poll `check` every `intervalMs` until it answers, for at most `timeoutMs`.
16
+ * Resolves the answer. Deadline, cancellation and failed checks propagate as
17
+ * their typed runtime failures; a caller must not reinterpret timeout as
18
+ * absence.
19
+ */
20
+ export async function pollUntil(lifecycle, check, options) {
21
+ const waitOptions = { timeoutMs: options.timeoutMs, reason: options.reason };
22
+ if (options.signal)
23
+ waitOptions.signal = options.signal;
24
+ return lifecycle.wait(async (signal) => {
25
+ for (;;) {
26
+ const answer = await check();
27
+ if (answer !== null)
28
+ return answer;
29
+ await lifecycle.delay(options.intervalMs, signal);
30
+ }
31
+ }, waitOptions);
32
+ }
33
+ /**
34
+ * Renew a held lease every `periodMs` while `run` holds it.
35
+ *
36
+ * A one-shot lifecycle timer re-armed after each renewal settles, not a
37
+ * lifecycle interval: the heartbeat lives exactly as long as this operation,
38
+ * so a finite host (a CLI `code-session` command), where an autonomous
39
+ * interval is refused, still keeps the lease it holds. A failed renewal is
40
+ * logged at warn with the operation it risks (the lease may lapse and another
41
+ * holder may reconcile the operation); it never fails `run`, and the next
42
+ * tick renews again. The heartbeat stops when `run` settles or the runtime is
43
+ * disposed.
44
+ */
45
+ export async function withLeaseHeartbeat(lifecycle, options, run) {
46
+ let stopped = false;
47
+ let disarm;
48
+ const arm = () => {
49
+ if (stopped || lifecycle.signal.aborted)
50
+ return;
51
+ disarm = lifecycle.timeout(() => {
52
+ disarm = undefined;
53
+ void options.renew().then(arm, (caught) => {
54
+ const failure = valueFreeFailure(CaughtFailureSchema.parse(caught));
55
+ options.logger.warn('code-session operation lease renewal failed; the lease may lapse', {
56
+ operationId: options.operationId,
57
+ failure
58
+ });
59
+ arm();
60
+ return failure;
61
+ });
62
+ }, options.periodMs);
63
+ };
64
+ arm();
65
+ try {
66
+ return await run();
67
+ }
68
+ finally {
69
+ stopped = true;
70
+ disarm?.();
71
+ }
72
+ }
73
+ //# sourceMappingURL=operation-lease.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-lease.js","sourceRoot":"","sources":["../../src/code-session/operation-lease.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAkD,MAAM,qBAAqB,CAAC;AAK5H;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,SAA2B,EAC3B,KAA8B,EAC9B,OAAwF;IAExF,MAAM,WAAW,GAAuB,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IACjG,IAAI,OAAO,CAAC,MAAM;QAAE,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACxD,OAAO,SAAS,CAAC,IAAI,CACpB,KAAK,EAAE,MAAM,EAAE,EAAE;QAChB,SAAS,CAAC;YACT,MAAM,MAAM,GAAG,MAAM,KAAK,EAAE,CAAC;YAC7B,IAAI,MAAM,KAAK,IAAI;gBAAE,OAAO,MAAM,CAAC;YACnC,MAAM,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACnD,CAAC;IACF,CAAC,EACD,WAAW,CACX,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,SAA2B,EAC3B,OAAuG,EACvG,GAAqB;IAErB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,MAAgC,CAAC;IACrC,MAAM,GAAG,GAAG,GAAS,EAAE;QACtB,IAAI,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO;QAChD,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE;YAC/B,MAAM,GAAG,SAAS,CAAC;YACnB,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE;gBACzC,MAAM,OAAO,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;gBACpE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,kEAAkE,EAAE;oBACvF,WAAW,EAAE,OAAO,CAAC,WAAW;oBAChC,OAAO;iBACP,CAAC,CAAC;gBACH,GAAG,EAAE,CAAC;gBACN,OAAO,OAAO,CAAC;YAChB,CAAC,CAAC,CAAC;QACJ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC,CAAC;IACF,GAAG,EAAE,CAAC;IACN,IAAI,CAAC;QACJ,OAAO,MAAM,GAAG,EAAE,CAAC;IACpB,CAAC;YAAS,CAAC;QACV,OAAO,GAAG,IAAI,CAAC;QACf,MAAM,EAAE,EAAE,CAAC;IACZ,CAAC;AACF,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Per-runtime custody of in-flight remote process setups (consumer code session).
3
+ *
4
+ * A remote spawn is owned from dispatch until its handle is delivered or its
5
+ * cancellation cleanup settles (`acquireWireProcess`). The consumer plugin's
6
+ * `onDispose` drains this custody: it cancels every in-flight setup and refuses
7
+ * new work. It never waits for the remote side (no bounded-wait port exists
8
+ * before RC07, C13) and never deletes an unresolved record: a setup whose cleanup
9
+ * is not confirmed at disposal fails disposal, typed, while its late-result
10
+ * observer stays attached so a late port is still killed once and observed.
11
+ */
12
+ import { type RuntimeRef } from '@vibesdotdev/kernel';
13
+ import { BaseRuntimeClient } from '@vibesdotdev/kernel/client';
14
+ import type { WireProcessAcquisition } from '@vibesdotdev/kernel/execution';
15
+ export declare class RemoteSetupCustody {
16
+ private readonly pending;
17
+ private readonly unresolved;
18
+ private disposed;
19
+ /** Refuse new remote work once the owning runtime is disposing. */
20
+ admit(): void;
21
+ /** Retain `acquisition` until it is terminal; only confirmed outcomes release it. */
22
+ retain(acquisition: WireProcessAcquisition): WireProcessAcquisition;
23
+ /** Cancel every in-flight setup; fail typed while any cleanup is unconfirmed. */
24
+ dispose(): void;
25
+ }
26
+ export declare const remoteSetupCustodyDescriptor: {
27
+ id: string;
28
+ kind: "runtime/client";
29
+ name?: string | undefined;
30
+ tags?: string[] | undefined;
31
+ hardware?: string[] | undefined;
32
+ enabled?: boolean | undefined;
33
+ priority?: number | undefined;
34
+ capabilityId?: string | undefined;
35
+ requiredContext?: string[] | undefined;
36
+ optionalContext?: string[] | undefined;
37
+ config?: unknown;
38
+ retention?: string | {
39
+ reason: string;
40
+ maxAgeDays?: number | undefined;
41
+ maxEntries?: number | undefined;
42
+ maxBytes?: number | undefined;
43
+ cascadeFrom?: string | undefined;
44
+ ageField?: string | undefined;
45
+ enforcedBy?: string | undefined;
46
+ } | undefined;
47
+ configManifestId?: string | undefined;
48
+ baseUrl?: string | undefined;
49
+ description?: string | undefined;
50
+ };
51
+ /** The kernel owns this client and drains its acquisitions at disposal. */
52
+ export declare class RemoteSetupCustodyClient extends BaseRuntimeClient {
53
+ readonly custody: RemoteSetupCustody;
54
+ protected onDispose(): void;
55
+ }
56
+ /** Synchronous access after the consumer plugin has activated the client. */
57
+ export declare function remoteSetupCustody(runtime: RuntimeRef): RemoteSetupCustody;
58
+ export default RemoteSetupCustodyClient;
59
+ //# sourceMappingURL=remote-setup-custody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-setup-custody.d.ts","sourceRoot":"","sources":["../../src/code-session/remote-setup-custody.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAmC,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAoD,MAAM,4BAA4B,CAAC;AACjH,OAAO,KAAK,EAA6B,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvG,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAC7D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqC;IAChE,OAAO,CAAC,QAAQ,CAAS;IAEzB,mEAAmE;IACnE,KAAK,IAAI,IAAI;IAQb,qFAAqF;IACrF,MAAM,CAAC,WAAW,EAAE,sBAAsB,GAAG,sBAAsB;IAWnE,iFAAiF;IACjF,OAAO,IAAI,IAAI;CAUf;AAGD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;CAEvC,CAAC;AAEH,2EAA2E;AAC3E,qBAAa,wBAAyB,SAAQ,iBAAiB;IAC9D,QAAQ,CAAC,OAAO,qBAA4B;cAEzB,SAAS,IAAI,IAAI;CAGpC;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,CAa1E;AAED,eAAe,wBAAwB,CAAC"}