@rivet-dev/agentos-runtime-core 0.0.0-agent-acp-codex-session-benchmark.62b1f46

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 (272) hide show
  1. package/README.md +7 -0
  2. package/commands/[ +0 -0
  3. package/commands/_stubs +0 -0
  4. package/commands/arch +0 -0
  5. package/commands/awk +0 -0
  6. package/commands/b2sum +0 -0
  7. package/commands/base32 +0 -0
  8. package/commands/base64 +0 -0
  9. package/commands/basename +0 -0
  10. package/commands/basenc +0 -0
  11. package/commands/bash +0 -0
  12. package/commands/cat +0 -0
  13. package/commands/chcon +0 -0
  14. package/commands/chgrp +0 -0
  15. package/commands/chmod +0 -0
  16. package/commands/chown +0 -0
  17. package/commands/chroot +0 -0
  18. package/commands/cksum +0 -0
  19. package/commands/codex +0 -0
  20. package/commands/codex-exec +0 -0
  21. package/commands/column +0 -0
  22. package/commands/comm +0 -0
  23. package/commands/cp +0 -0
  24. package/commands/curl +0 -0
  25. package/commands/cut +0 -0
  26. package/commands/date +0 -0
  27. package/commands/dd +0 -0
  28. package/commands/df +0 -0
  29. package/commands/diff +0 -0
  30. package/commands/dir +0 -0
  31. package/commands/dircolors +0 -0
  32. package/commands/dirname +0 -0
  33. package/commands/du +0 -0
  34. package/commands/echo +0 -0
  35. package/commands/egrep +0 -0
  36. package/commands/env +0 -0
  37. package/commands/envsubst +0 -0
  38. package/commands/expand +0 -0
  39. package/commands/expr +0 -0
  40. package/commands/factor +0 -0
  41. package/commands/false +0 -0
  42. package/commands/fd +0 -0
  43. package/commands/fgrep +0 -0
  44. package/commands/file +0 -0
  45. package/commands/find +0 -0
  46. package/commands/fmt +0 -0
  47. package/commands/fold +0 -0
  48. package/commands/git +0 -0
  49. package/commands/git-remote-http +0 -0
  50. package/commands/git-remote-https +0 -0
  51. package/commands/grep +0 -0
  52. package/commands/groups +0 -0
  53. package/commands/gunzip +0 -0
  54. package/commands/gzip +0 -0
  55. package/commands/head +0 -0
  56. package/commands/hostid +0 -0
  57. package/commands/hostname +0 -0
  58. package/commands/http-test +0 -0
  59. package/commands/http_get +0 -0
  60. package/commands/id +0 -0
  61. package/commands/install +0 -0
  62. package/commands/join +0 -0
  63. package/commands/jq +0 -0
  64. package/commands/kill +0 -0
  65. package/commands/link +0 -0
  66. package/commands/ln +0 -0
  67. package/commands/logname +0 -0
  68. package/commands/ls +0 -0
  69. package/commands/md5sum +0 -0
  70. package/commands/mkdir +0 -0
  71. package/commands/mkfifo +0 -0
  72. package/commands/mknod +0 -0
  73. package/commands/mktemp +0 -0
  74. package/commands/more +0 -0
  75. package/commands/mv +0 -0
  76. package/commands/nice +0 -0
  77. package/commands/nl +0 -0
  78. package/commands/nohup +0 -0
  79. package/commands/nproc +0 -0
  80. package/commands/numfmt +0 -0
  81. package/commands/od +0 -0
  82. package/commands/paste +0 -0
  83. package/commands/pathchk +0 -0
  84. package/commands/pinky +0 -0
  85. package/commands/printenv +0 -0
  86. package/commands/printf +0 -0
  87. package/commands/ptx +0 -0
  88. package/commands/pwd +0 -0
  89. package/commands/readlink +0 -0
  90. package/commands/realpath +0 -0
  91. package/commands/rev +0 -0
  92. package/commands/rg +0 -0
  93. package/commands/rm +0 -0
  94. package/commands/rmdir +0 -0
  95. package/commands/runcon +0 -0
  96. package/commands/sed +0 -0
  97. package/commands/seq +0 -0
  98. package/commands/sh +0 -0
  99. package/commands/sha1sum +0 -0
  100. package/commands/sha224sum +0 -0
  101. package/commands/sha256sum +0 -0
  102. package/commands/sha384sum +0 -0
  103. package/commands/sha512sum +0 -0
  104. package/commands/shred +0 -0
  105. package/commands/shuf +0 -0
  106. package/commands/sleep +0 -0
  107. package/commands/sort +0 -0
  108. package/commands/spawn-test-host +0 -0
  109. package/commands/split +0 -0
  110. package/commands/sqlite3 +0 -0
  111. package/commands/stat +0 -0
  112. package/commands/stdbuf +0 -0
  113. package/commands/strings +0 -0
  114. package/commands/stty +0 -0
  115. package/commands/sum +0 -0
  116. package/commands/sync +0 -0
  117. package/commands/tac +0 -0
  118. package/commands/tail +0 -0
  119. package/commands/tar +0 -0
  120. package/commands/tee +0 -0
  121. package/commands/test +0 -0
  122. package/commands/timeout +0 -0
  123. package/commands/touch +0 -0
  124. package/commands/tr +0 -0
  125. package/commands/tree +0 -0
  126. package/commands/true +0 -0
  127. package/commands/truncate +0 -0
  128. package/commands/tsort +0 -0
  129. package/commands/tty +0 -0
  130. package/commands/uname +0 -0
  131. package/commands/unexpand +0 -0
  132. package/commands/uniq +0 -0
  133. package/commands/unlink +0 -0
  134. package/commands/unzip +0 -0
  135. package/commands/uptime +0 -0
  136. package/commands/users +0 -0
  137. package/commands/vdir +0 -0
  138. package/commands/wc +0 -0
  139. package/commands/which +0 -0
  140. package/commands/who +0 -0
  141. package/commands/whoami +0 -0
  142. package/commands/xargs +0 -0
  143. package/commands/xu +0 -0
  144. package/commands/yes +0 -0
  145. package/commands/yq +0 -0
  146. package/commands/zcat +0 -0
  147. package/commands/zip +0 -0
  148. package/dist/binary.d.ts +4 -0
  149. package/dist/binary.js +25 -0
  150. package/dist/bytes.d.ts +2 -0
  151. package/dist/bytes.js +6 -0
  152. package/dist/callbacks.d.ts +41 -0
  153. package/dist/callbacks.js +94 -0
  154. package/dist/correlation.d.ts +7 -0
  155. package/dist/correlation.js +52 -0
  156. package/dist/descriptors.d.ts +81 -0
  157. package/dist/descriptors.js +57 -0
  158. package/dist/event-buffer.d.ts +98 -0
  159. package/dist/event-buffer.js +333 -0
  160. package/dist/ext.d.ts +7 -0
  161. package/dist/ext.js +13 -0
  162. package/dist/filesystem.d.ts +33 -0
  163. package/dist/filesystem.js +52 -0
  164. package/dist/frame-payload-codec.d.ts +8 -0
  165. package/dist/frame-payload-codec.js +14 -0
  166. package/dist/frame-rpc.d.ts +45 -0
  167. package/dist/frame-rpc.js +98 -0
  168. package/dist/frame-stream.d.ts +34 -0
  169. package/dist/frame-stream.js +109 -0
  170. package/dist/framing.d.ts +8 -0
  171. package/dist/framing.js +23 -0
  172. package/dist/generated/AcpLimitsConfig.d.ts +4 -0
  173. package/dist/generated/AcpLimitsConfig.js +2 -0
  174. package/dist/generated/CreateVmConfig.d.ts +26 -0
  175. package/dist/generated/CreateVmConfig.js +1 -0
  176. package/dist/generated/FsPermissionRule.d.ts +6 -0
  177. package/dist/generated/FsPermissionRule.js +1 -0
  178. package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
  179. package/dist/generated/FsPermissionRuleSet.js +1 -0
  180. package/dist/generated/FsPermissionScope.d.ts +3 -0
  181. package/dist/generated/FsPermissionScope.js +1 -0
  182. package/dist/generated/HttpLimitsConfig.d.ts +3 -0
  183. package/dist/generated/HttpLimitsConfig.js +2 -0
  184. package/dist/generated/JsModuleResolution.d.ts +1 -0
  185. package/dist/generated/JsModuleResolution.js +2 -0
  186. package/dist/generated/JsRuntimeConfig.d.ts +31 -0
  187. package/dist/generated/JsRuntimeConfig.js +1 -0
  188. package/dist/generated/JsRuntimeLimitsConfig.d.ts +8 -0
  189. package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
  190. package/dist/generated/JsRuntimePlatform.d.ts +1 -0
  191. package/dist/generated/JsRuntimePlatform.js +2 -0
  192. package/dist/generated/MountPluginDescriptor.d.ts +4 -0
  193. package/dist/generated/MountPluginDescriptor.js +2 -0
  194. package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
  195. package/dist/generated/NativeRootFilesystemConfig.js +1 -0
  196. package/dist/generated/PatternPermissionRule.d.ts +6 -0
  197. package/dist/generated/PatternPermissionRule.js +1 -0
  198. package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
  199. package/dist/generated/PatternPermissionRuleSet.js +1 -0
  200. package/dist/generated/PatternPermissionScope.d.ts +3 -0
  201. package/dist/generated/PatternPermissionScope.js +1 -0
  202. package/dist/generated/PermissionMode.d.ts +1 -0
  203. package/dist/generated/PermissionMode.js +2 -0
  204. package/dist/generated/PermissionsPolicy.d.ts +10 -0
  205. package/dist/generated/PermissionsPolicy.js +1 -0
  206. package/dist/generated/PluginLimitsConfig.d.ts +4 -0
  207. package/dist/generated/PluginLimitsConfig.js +2 -0
  208. package/dist/generated/PythonLimitsConfig.d.ts +6 -0
  209. package/dist/generated/PythonLimitsConfig.js +2 -0
  210. package/dist/generated/ResourceLimitsConfig.d.ts +24 -0
  211. package/dist/generated/ResourceLimitsConfig.js +2 -0
  212. package/dist/generated/RootFilesystemConfig.d.ts +9 -0
  213. package/dist/generated/RootFilesystemConfig.js +1 -0
  214. package/dist/generated/RootFilesystemEntry.d.ts +13 -0
  215. package/dist/generated/RootFilesystemEntry.js +1 -0
  216. package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
  217. package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
  218. package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
  219. package/dist/generated/RootFilesystemEntryKind.js +2 -0
  220. package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
  221. package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
  222. package/dist/generated/RootFilesystemMode.d.ts +1 -0
  223. package/dist/generated/RootFilesystemMode.js +2 -0
  224. package/dist/generated/ToolLimitsConfig.d.ts +10 -0
  225. package/dist/generated/ToolLimitsConfig.js +2 -0
  226. package/dist/generated/VmDnsConfig.d.ts +6 -0
  227. package/dist/generated/VmDnsConfig.js +2 -0
  228. package/dist/generated/VmLimitsConfig.d.ts +18 -0
  229. package/dist/generated/VmLimitsConfig.js +1 -0
  230. package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
  231. package/dist/generated/VmListenPolicyConfig.js +2 -0
  232. package/dist/generated/WasmLimitsConfig.d.ts +7 -0
  233. package/dist/generated/WasmLimitsConfig.js +2 -0
  234. package/dist/generated-protocol.d.ts +1452 -0
  235. package/dist/generated-protocol.js +3936 -0
  236. package/dist/index.d.ts +27 -0
  237. package/dist/index.js +26 -0
  238. package/dist/json.d.ts +2 -0
  239. package/dist/json.js +20 -0
  240. package/dist/native-client.d.ts +47 -0
  241. package/dist/native-client.js +136 -0
  242. package/dist/numbers.d.ts +1 -0
  243. package/dist/numbers.js +8 -0
  244. package/dist/ownership.d.ts +18 -0
  245. package/dist/ownership.js +77 -0
  246. package/dist/permissions.d.ts +29 -0
  247. package/dist/permissions.js +68 -0
  248. package/dist/process.d.ts +22 -0
  249. package/dist/process.js +97 -0
  250. package/dist/protocol-client.d.ts +67 -0
  251. package/dist/protocol-client.js +270 -0
  252. package/dist/protocol-frames.d.ts +68 -0
  253. package/dist/protocol-frames.js +139 -0
  254. package/dist/protocol-maps.d.ts +31 -0
  255. package/dist/protocol-maps.js +273 -0
  256. package/dist/protocol-schema.d.ts +10 -0
  257. package/dist/protocol-schema.js +11 -0
  258. package/dist/request-payloads.d.ts +207 -0
  259. package/dist/request-payloads.js +357 -0
  260. package/dist/response-payloads.d.ts +268 -0
  261. package/dist/response-payloads.js +402 -0
  262. package/dist/sidecar-client.d.ts +19 -0
  263. package/dist/sidecar-client.js +1 -0
  264. package/dist/sidecar-errors.d.ts +44 -0
  265. package/dist/sidecar-errors.js +62 -0
  266. package/dist/sidecar-process.d.ts +434 -0
  267. package/dist/sidecar-process.js +1252 -0
  268. package/dist/state.d.ts +42 -0
  269. package/dist/state.js +45 -0
  270. package/dist/vm-config.d.ts +31 -0
  271. package/dist/vm-config.js +1 -0
  272. package/package.json +189 -0
@@ -0,0 +1,402 @@
1
+ import { fromGeneratedRootFilesystemEntry, } from "./filesystem.js";
2
+ import { fromGeneratedExtEnvelope } from "./ext.js";
3
+ import * as protocol from "./generated-protocol.js";
4
+ import { parseJsonUtf8 } from "./json.js";
5
+ import { bigIntToSafeNumber } from "./numbers.js";
6
+ import { fromGeneratedFilesystemOperation, fromGeneratedGuestFilesystemOperation, fromGeneratedRootFilesystemEntryEncoding, fromGeneratedSignalDispositionAction, } from "./protocol-maps.js";
7
+ import { fromGeneratedGuestFilesystemStat, fromGeneratedProcessSnapshotEntry, fromGeneratedSocketStateEntry, } from "./state.js";
8
+ export function fromGeneratedResponsePayload(payload) {
9
+ switch (payload.tag) {
10
+ case "AuthenticatedResponse":
11
+ return {
12
+ type: "authenticated",
13
+ sidecar_id: payload.val.sidecarId,
14
+ connection_id: payload.val.connectionId,
15
+ max_frame_bytes: payload.val.maxFrameBytes,
16
+ };
17
+ case "SessionOpenedResponse":
18
+ return {
19
+ type: "session_opened",
20
+ session_id: payload.val.sessionId,
21
+ owner_connection_id: payload.val.ownerConnectionId,
22
+ };
23
+ case "SessionClosedResponse":
24
+ return {
25
+ type: "session_closed",
26
+ session_id: payload.val.sessionId,
27
+ };
28
+ case "VmCreatedResponse":
29
+ return {
30
+ type: "vm_created",
31
+ vm_id: payload.val.vmId,
32
+ guest_cwd: payload.val.guestCwd,
33
+ guest_env: Object.fromEntries(payload.val.guestEnv),
34
+ process_route_retention: bigIntToSafeNumber(payload.val.processRouteRetention, "vm_created.process_route_retention"),
35
+ };
36
+ case "VmInitializedResponse":
37
+ return {
38
+ type: "vm_initialized",
39
+ vm_id: payload.val.vmId,
40
+ guest_cwd: payload.val.guestCwd,
41
+ guest_env: Object.fromEntries(payload.val.guestEnv),
42
+ process_route_retention: bigIntToSafeNumber(payload.val.processRouteRetention, "vm_initialized.process_route_retention"),
43
+ applied_mounts: payload.val.appliedMounts,
44
+ projected_commands: payload.val.projectedCommands.map((command) => ({
45
+ name: command.name,
46
+ guest_path: command.guestPath,
47
+ })),
48
+ agents: payload.val.agents.map(fromGeneratedAgentosProjectedAgent),
49
+ host_callbacks: payload.val.hostCallbacks.map((registration) => ({
50
+ registration: registration.registration,
51
+ command_count: registration.commandCount,
52
+ })),
53
+ };
54
+ case "VmDisposedResponse":
55
+ return { type: "vm_disposed", vm_id: payload.val.vmId };
56
+ case "RootFilesystemBootstrappedResponse":
57
+ return {
58
+ type: "root_filesystem_bootstrapped",
59
+ entry_count: payload.val.entryCount,
60
+ };
61
+ case "VmConfiguredResponse":
62
+ return {
63
+ type: "vm_configured",
64
+ applied_mounts: payload.val.appliedMounts,
65
+ projected_commands: payload.val.projectedCommands.map((command) => ({
66
+ name: command.name,
67
+ guest_path: command.guestPath,
68
+ })),
69
+ agents: payload.val.agents.map(fromGeneratedAgentosProjectedAgent),
70
+ };
71
+ case "PackageLinkedResponse":
72
+ return {
73
+ type: "package_linked",
74
+ projected_commands: payload.val.projectedCommands.map((command) => ({
75
+ name: command.name,
76
+ guest_path: command.guestPath,
77
+ })),
78
+ agents: payload.val.agents.map(fromGeneratedAgentosProjectedAgent),
79
+ };
80
+ case "ProvidedCommandsResponse":
81
+ return {
82
+ type: "provided_commands_response",
83
+ packages: payload.val.packages.map((pkg) => ({
84
+ package_name: pkg.packageName,
85
+ commands: [...pkg.commands],
86
+ })),
87
+ };
88
+ case "CronScheduledResponse":
89
+ return {
90
+ type: "cron_scheduled",
91
+ id: payload.val.id,
92
+ alarm: fromGeneratedCronAlarm(payload.val.alarm),
93
+ };
94
+ case "CronJobsResponse":
95
+ return {
96
+ type: "cron_jobs",
97
+ jobs: payload.val.jobs.map(fromGeneratedCronJobEntry),
98
+ alarm: fromGeneratedCronAlarm(payload.val.alarm),
99
+ };
100
+ case "CronCancelledResponse":
101
+ return {
102
+ type: "cron_cancelled",
103
+ id: payload.val.id,
104
+ cancelled: payload.val.cancelled,
105
+ alarm: fromGeneratedCronAlarm(payload.val.alarm),
106
+ };
107
+ case "CronWakeResponse":
108
+ return {
109
+ type: "cron_wake",
110
+ alarm: fromGeneratedCronAlarm(payload.val.alarm),
111
+ runs: payload.val.runs.map(fromGeneratedCronRun),
112
+ events: payload.val.events.map(fromGeneratedCronEvent),
113
+ };
114
+ case "CronRunCompletedResponse":
115
+ return {
116
+ type: "cron_run_completed",
117
+ alarm: fromGeneratedCronAlarm(payload.val.alarm),
118
+ runs: payload.val.runs.map(fromGeneratedCronRun),
119
+ events: payload.val.events.map(fromGeneratedCronEvent),
120
+ };
121
+ case "CronStateExportedResponse":
122
+ return {
123
+ type: "cron_state_exported",
124
+ state: payload.val.state,
125
+ };
126
+ case "CronStateImportedResponse":
127
+ return {
128
+ type: "cron_state_imported",
129
+ alarm: fromGeneratedCronAlarm(payload.val.alarm),
130
+ runs: payload.val.runs.map(fromGeneratedCronRun),
131
+ events: payload.val.events.map(fromGeneratedCronEvent),
132
+ };
133
+ case "HostCallbacksRegisteredResponse":
134
+ return {
135
+ type: "host_callbacks_registered",
136
+ registration: payload.val.registration,
137
+ command_count: payload.val.commandCount,
138
+ };
139
+ case "LayerCreatedResponse":
140
+ return { type: "layer_created", layer_id: payload.val.layerId };
141
+ case "LayerSealedResponse":
142
+ return { type: "layer_sealed", layer_id: payload.val.layerId };
143
+ case "SnapshotImportedResponse":
144
+ return { type: "snapshot_imported", layer_id: payload.val.layerId };
145
+ case "SnapshotExportedResponse":
146
+ return {
147
+ type: "snapshot_exported",
148
+ layer_id: payload.val.layerId,
149
+ entries: payload.val.entries.map(fromGeneratedRootFilesystemEntry),
150
+ };
151
+ case "OverlayCreatedResponse":
152
+ return { type: "overlay_created", layer_id: payload.val.layerId };
153
+ case "GuestFilesystemResultResponse":
154
+ return {
155
+ type: "guest_filesystem_result",
156
+ operation: fromGeneratedGuestFilesystemOperation(payload.val.operation),
157
+ path: payload.val.path,
158
+ ...(payload.val.content !== null
159
+ ? { content: payload.val.content }
160
+ : {}),
161
+ ...(payload.val.encoding !== null
162
+ ? {
163
+ encoding: fromGeneratedRootFilesystemEntryEncoding(payload.val.encoding),
164
+ }
165
+ : {}),
166
+ ...(payload.val.entries !== null
167
+ ? {
168
+ entries: payload.val.entries.map((entry) => ({
169
+ name: entry.name,
170
+ path: entry.path,
171
+ isDirectory: entry.isDirectory,
172
+ isSymbolicLink: entry.isSymbolicLink,
173
+ size: entry.size,
174
+ })),
175
+ }
176
+ : {}),
177
+ ...(payload.val.stat !== null
178
+ ? { stat: fromGeneratedGuestFilesystemStat(payload.val.stat) }
179
+ : {}),
180
+ ...(payload.val.exists !== null ? { exists: payload.val.exists } : {}),
181
+ ...(payload.val.target !== null ? { target: payload.val.target } : {}),
182
+ };
183
+ case "GuestKernelResultResponse":
184
+ return {
185
+ type: "guest_kernel_result",
186
+ payload: payload.val.payload,
187
+ };
188
+ case "RootFilesystemSnapshotResponse":
189
+ return {
190
+ type: "root_filesystem_snapshot",
191
+ entries: payload.val.entries.map(fromGeneratedRootFilesystemEntry),
192
+ };
193
+ case "ProcessStartedResponse":
194
+ return {
195
+ type: "process_started",
196
+ process_id: payload.val.processId,
197
+ ...(payload.val.pid !== null ? { pid: payload.val.pid } : {}),
198
+ };
199
+ case "StdinWrittenResponse":
200
+ return {
201
+ type: "stdin_written",
202
+ process_id: payload.val.processId,
203
+ accepted_bytes: bigIntToSafeNumber(payload.val.acceptedBytes, "stdin_written.accepted_bytes"),
204
+ };
205
+ case "PtyResizedResponse":
206
+ return {
207
+ type: "pty_resized",
208
+ process_id: payload.val.processId,
209
+ cols: payload.val.cols,
210
+ rows: payload.val.rows,
211
+ };
212
+ case "StdinClosedResponse":
213
+ return { type: "stdin_closed", process_id: payload.val.processId };
214
+ case "ProcessKilledResponse":
215
+ return { type: "process_killed", process_id: payload.val.processId };
216
+ case "ProcessSnapshotResponse":
217
+ return {
218
+ type: "process_snapshot",
219
+ processes: payload.val.processes.map(fromGeneratedProcessSnapshotEntry),
220
+ };
221
+ case "ResourceSnapshotResponse":
222
+ return {
223
+ type: "resource_snapshot",
224
+ running_processes: bigIntToSafeNumber(payload.val.runningProcesses, "resource_snapshot.running_processes"),
225
+ exited_processes: bigIntToSafeNumber(payload.val.exitedProcesses, "resource_snapshot.exited_processes"),
226
+ fd_tables: bigIntToSafeNumber(payload.val.fdTables, "resource_snapshot.fd_tables"),
227
+ open_fds: bigIntToSafeNumber(payload.val.openFds, "resource_snapshot.open_fds"),
228
+ pipes: bigIntToSafeNumber(payload.val.pipes, "resource_snapshot.pipes"),
229
+ pipe_buffered_bytes: bigIntToSafeNumber(payload.val.pipeBufferedBytes, "resource_snapshot.pipe_buffered_bytes"),
230
+ ptys: bigIntToSafeNumber(payload.val.ptys, "resource_snapshot.ptys"),
231
+ pty_buffered_input_bytes: bigIntToSafeNumber(payload.val.ptyBufferedInputBytes, "resource_snapshot.pty_buffered_input_bytes"),
232
+ pty_buffered_output_bytes: bigIntToSafeNumber(payload.val.ptyBufferedOutputBytes, "resource_snapshot.pty_buffered_output_bytes"),
233
+ sockets: bigIntToSafeNumber(payload.val.sockets, "resource_snapshot.sockets"),
234
+ socket_listeners: bigIntToSafeNumber(payload.val.socketListeners, "resource_snapshot.socket_listeners"),
235
+ socket_connections: bigIntToSafeNumber(payload.val.socketConnections, "resource_snapshot.socket_connections"),
236
+ socket_buffered_bytes: bigIntToSafeNumber(payload.val.socketBufferedBytes, "resource_snapshot.socket_buffered_bytes"),
237
+ socket_datagram_queue_len: bigIntToSafeNumber(payload.val.socketDatagramQueueLen, "resource_snapshot.socket_datagram_queue_len"),
238
+ queue_snapshots: payload.val.queueSnapshots.map((queue) => ({
239
+ name: queue.name,
240
+ category: queue.category,
241
+ depth: bigIntToSafeNumber(queue.depth, "resource_snapshot.queue.depth"),
242
+ high_water: bigIntToSafeNumber(queue.highWater, "resource_snapshot.queue.high_water"),
243
+ capacity: bigIntToSafeNumber(queue.capacity, "resource_snapshot.queue.capacity"),
244
+ fill_percent: bigIntToSafeNumber(queue.fillPercent, "resource_snapshot.queue.fill_percent"),
245
+ })),
246
+ };
247
+ case "ListenerSnapshotResponse":
248
+ return {
249
+ type: "listener_snapshot",
250
+ ...(payload.val.listener !== null
251
+ ? { listener: fromGeneratedSocketStateEntry(payload.val.listener) }
252
+ : {}),
253
+ };
254
+ case "BoundUdpSnapshotResponse":
255
+ return {
256
+ type: "bound_udp_snapshot",
257
+ ...(payload.val.socket !== null
258
+ ? { socket: fromGeneratedSocketStateEntry(payload.val.socket) }
259
+ : {}),
260
+ };
261
+ case "SignalStateResponse":
262
+ return {
263
+ type: "signal_state",
264
+ process_id: payload.val.processId,
265
+ handlers: Object.fromEntries([...payload.val.handlers].map(([signal, registration]) => [
266
+ String(signal),
267
+ {
268
+ action: fromGeneratedSignalDispositionAction(registration.action),
269
+ mask: Array.from(registration.mask),
270
+ flags: registration.flags,
271
+ },
272
+ ])),
273
+ };
274
+ case "ZombieTimerCountResponse":
275
+ return {
276
+ type: "zombie_timer_count",
277
+ count: bigIntToSafeNumber(payload.val.count, "zombie_timer_count.count"),
278
+ };
279
+ case "FilesystemResultResponse":
280
+ return {
281
+ type: "filesystem_result",
282
+ operation: fromGeneratedFilesystemOperation(payload.val.operation),
283
+ status: payload.val.status,
284
+ payload_size_bytes: bigIntToSafeNumber(payload.val.payloadSizeBytes, "filesystem_result.payload_size_bytes"),
285
+ };
286
+ case "PermissionDecisionResponse":
287
+ throw new Error("unsupported bare response payload tag: permission_decision");
288
+ case "PersistenceStateResponse":
289
+ return {
290
+ type: "persistence_state",
291
+ key: payload.val.key,
292
+ found: payload.val.found,
293
+ payload_size_bytes: bigIntToSafeNumber(payload.val.payloadSizeBytes, "persistence_state.payload_size_bytes"),
294
+ };
295
+ case "PersistenceFlushedResponse":
296
+ return {
297
+ type: "persistence_flushed",
298
+ key: payload.val.key,
299
+ committed_bytes: bigIntToSafeNumber(payload.val.committedBytes, "persistence_flushed.committed_bytes"),
300
+ };
301
+ case "RejectedResponse":
302
+ return {
303
+ type: "rejected",
304
+ code: payload.val.code,
305
+ message: payload.val.message,
306
+ };
307
+ case "VmFetchResponse":
308
+ return {
309
+ type: "vm_fetch_result",
310
+ response_json: payload.val.responseJson,
311
+ };
312
+ case "ExtEnvelope":
313
+ return {
314
+ type: "ext_result",
315
+ envelope: fromGeneratedExtEnvelope(payload.val),
316
+ };
317
+ }
318
+ }
319
+ function fromGeneratedCronAlarm(value) {
320
+ return {
321
+ generation: bigIntToSafeNumber(value.generation, "cron_alarm.generation"),
322
+ ...(value.nextAlarmMs === null
323
+ ? {}
324
+ : {
325
+ next_alarm_ms: bigIntToSafeNumber(value.nextAlarmMs, "cron_alarm.next_alarm_ms"),
326
+ }),
327
+ };
328
+ }
329
+ function fromGeneratedCronOverlap(value) {
330
+ switch (value) {
331
+ case protocol.CronOverlap.Allow:
332
+ return "allow";
333
+ case protocol.CronOverlap.Skip:
334
+ return "skip";
335
+ case protocol.CronOverlap.Queue:
336
+ return "queue";
337
+ }
338
+ }
339
+ function fromGeneratedCronJobEntry(value) {
340
+ return {
341
+ id: value.id,
342
+ schedule: value.schedule,
343
+ action: parseJsonUtf8(value.action, "cron_job.action"),
344
+ overlap: fromGeneratedCronOverlap(value.overlap),
345
+ ...(value.lastRunMs === null
346
+ ? {}
347
+ : {
348
+ last_run_ms: bigIntToSafeNumber(value.lastRunMs, "cron_job.last_run_ms"),
349
+ }),
350
+ ...(value.nextRunMs === null
351
+ ? {}
352
+ : {
353
+ next_run_ms: bigIntToSafeNumber(value.nextRunMs, "cron_job.next_run_ms"),
354
+ }),
355
+ run_count: bigIntToSafeNumber(value.runCount, "cron_job.run_count"),
356
+ running: value.running,
357
+ };
358
+ }
359
+ function fromGeneratedCronRun(value) {
360
+ return {
361
+ run_id: value.runId,
362
+ job_id: value.jobId,
363
+ action: parseJsonUtf8(value.action, "cron_run.action"),
364
+ };
365
+ }
366
+ function fromGeneratedCronEvent(value) {
367
+ const kind = (() => {
368
+ switch (value.kind) {
369
+ case protocol.CronEventKind.Fire:
370
+ return "fire";
371
+ case protocol.CronEventKind.Complete:
372
+ return "complete";
373
+ case protocol.CronEventKind.Error:
374
+ return "error";
375
+ }
376
+ })();
377
+ return {
378
+ kind,
379
+ job_id: value.jobId,
380
+ time_ms: bigIntToSafeNumber(value.timeMs, "cron_event.time_ms"),
381
+ ...(value.durationMs === null
382
+ ? {}
383
+ : {
384
+ duration_ms: bigIntToSafeNumber(value.durationMs, "cron_event.duration_ms"),
385
+ }),
386
+ ...(value.error === null ? {} : { error: value.error }),
387
+ };
388
+ }
389
+ export function fromGeneratedCronDispatch(value) {
390
+ return {
391
+ alarm: fromGeneratedCronAlarm(value.alarm),
392
+ runs: value.runs.map(fromGeneratedCronRun),
393
+ events: value.events.map(fromGeneratedCronEvent),
394
+ };
395
+ }
396
+ function fromGeneratedAgentosProjectedAgent(agent) {
397
+ return {
398
+ id: agent.id,
399
+ acp_entrypoint: agent.acpEntrypoint,
400
+ adapter_entrypoint: agent.adapterEntrypoint,
401
+ };
402
+ }
@@ -0,0 +1,19 @@
1
+ import type { LiveSidecarEventSelector } from "./event-buffer.js";
2
+ import type { LiveOwnershipScope } from "./ownership.js";
3
+ import type { LiveEventFrame, LiveResponseFrame, LiveSidecarRequestHandler } from "./protocol-frames.js";
4
+ import type { LiveRequestPayload } from "./request-payloads.js";
5
+ export interface SidecarProcessTransport {
6
+ registerSidecarRequestHandler(ownership: LiveOwnershipScope, handler: LiveSidecarRequestHandler): () => void;
7
+ onEvent(handler: (event: LiveEventFrame) => void, ownership?: LiveOwnershipScope): () => void;
8
+ sendRequest(input: {
9
+ ownership: LiveOwnershipScope;
10
+ payload: LiveRequestPayload;
11
+ /** Runs synchronously while the response frame is routed, before later frames. */
12
+ onResponse?: (response: LiveResponseFrame) => void;
13
+ }): Promise<LiveResponseFrame>;
14
+ waitForEvent(matcher: LiveSidecarEventSelector | ((event: LiveEventFrame) => boolean), timeoutMs?: number, options?: {
15
+ signal?: AbortSignal;
16
+ }): Promise<LiveEventFrame>;
17
+ failPermanently(error: Error): void;
18
+ dispose(): Promise<void>;
19
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,44 @@
1
+ import type { LiveOwnershipScope } from "./ownership.js";
2
+ import type { LiveResponseFrame } from "./protocol-frames.js";
3
+ /** A sidecar-owned request failure, preserving its stable code and wire context. */
4
+ export declare class SidecarRequestRejected extends Error {
5
+ readonly code: string;
6
+ readonly requestId: number;
7
+ readonly ownership: LiveOwnershipScope;
8
+ readonly response: LiveResponseFrame;
9
+ constructor(options: {
10
+ code: string;
11
+ message: string;
12
+ response: LiveResponseFrame;
13
+ });
14
+ }
15
+ export declare class SidecarProcessExited extends Error {
16
+ readonly exitCode: number | null;
17
+ readonly signal: string | null;
18
+ readonly stderr: string;
19
+ constructor(options: {
20
+ exitCode: number | null;
21
+ signal: string | null;
22
+ stderr: string;
23
+ });
24
+ }
25
+ /**
26
+ * The silence watchdog fired: the sidecar produced no protocol frames at all —
27
+ * not even its 10s liveness heartbeats — for the full silence window, so the
28
+ * process is dead or wedged (not merely busy: a busy sidecar still heartbeats
29
+ * from a dedicated thread). The host kills the sidecar and rejects every
30
+ * in-flight request with this error.
31
+ */
32
+ export declare class SidecarSilenceTimeout extends Error {
33
+ readonly silenceMs: number;
34
+ readonly stderr: string;
35
+ constructor(options: {
36
+ silenceMs: number;
37
+ stderr: string;
38
+ });
39
+ }
40
+ export declare class SidecarProcessError extends Error {
41
+ readonly childError: Error;
42
+ readonly stderr: string;
43
+ constructor(error: Error, stderr: string);
44
+ }
@@ -0,0 +1,62 @@
1
+ function formatSidecarStderrSuffix(stderr) {
2
+ return stderr ? `\nstderr:\n${stderr}` : "";
3
+ }
4
+ /** A sidecar-owned request failure, preserving its stable code and wire context. */
5
+ export class SidecarRequestRejected extends Error {
6
+ code;
7
+ requestId;
8
+ ownership;
9
+ response;
10
+ constructor(options) {
11
+ super(options.message);
12
+ this.name = "SidecarRequestRejected";
13
+ this.code = options.code;
14
+ this.requestId = options.response.request_id;
15
+ this.ownership = options.response.ownership;
16
+ this.response = options.response;
17
+ }
18
+ }
19
+ export class SidecarProcessExited extends Error {
20
+ exitCode;
21
+ signal;
22
+ stderr;
23
+ constructor(options) {
24
+ const reason = options.signal !== null
25
+ ? `signal ${options.signal}`
26
+ : options.exitCode !== null
27
+ ? `code ${options.exitCode}`
28
+ : "disconnect";
29
+ super(`sidecar process exited with ${reason}${formatSidecarStderrSuffix(options.stderr)}`);
30
+ this.name = "SidecarProcessExited";
31
+ this.exitCode = options.exitCode;
32
+ this.signal = options.signal;
33
+ this.stderr = options.stderr;
34
+ }
35
+ }
36
+ /**
37
+ * The silence watchdog fired: the sidecar produced no protocol frames at all —
38
+ * not even its 10s liveness heartbeats — for the full silence window, so the
39
+ * process is dead or wedged (not merely busy: a busy sidecar still heartbeats
40
+ * from a dedicated thread). The host kills the sidecar and rejects every
41
+ * in-flight request with this error.
42
+ */
43
+ export class SidecarSilenceTimeout extends Error {
44
+ silenceMs;
45
+ stderr;
46
+ constructor(options) {
47
+ super(`sidecar unresponsive: no protocol frames or heartbeats for ${Math.round(options.silenceMs)}ms; killing sidecar${formatSidecarStderrSuffix(options.stderr)}`);
48
+ this.name = "SidecarSilenceTimeout";
49
+ this.silenceMs = options.silenceMs;
50
+ this.stderr = options.stderr;
51
+ }
52
+ }
53
+ export class SidecarProcessError extends Error {
54
+ childError;
55
+ stderr;
56
+ constructor(error, stderr) {
57
+ super(`sidecar process error: ${error.message}${formatSidecarStderrSuffix(stderr)}`);
58
+ this.name = "SidecarProcessError";
59
+ this.childError = error;
60
+ this.stderr = stderr;
61
+ }
62
+ }