@rivet-dev/agentos-runtime-core 0.0.0-chdir-fix.3d9feab
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.
- package/README.md +7 -0
- package/commands/[ +0 -0
- package/commands/_stubs +0 -0
- package/commands/arch +0 -0
- package/commands/awk +0 -0
- package/commands/b2sum +0 -0
- package/commands/base32 +0 -0
- package/commands/base64 +0 -0
- package/commands/basename +0 -0
- package/commands/basenc +0 -0
- package/commands/bash +0 -0
- package/commands/cat +0 -0
- package/commands/chcon +0 -0
- package/commands/chgrp +0 -0
- package/commands/chmod +0 -0
- package/commands/chown +0 -0
- package/commands/chroot +0 -0
- package/commands/cksum +0 -0
- package/commands/codex +0 -0
- package/commands/codex-exec +0 -0
- package/commands/column +0 -0
- package/commands/comm +0 -0
- package/commands/cp +0 -0
- package/commands/curl +0 -0
- package/commands/cut +0 -0
- package/commands/date +0 -0
- package/commands/dd +0 -0
- package/commands/df +0 -0
- package/commands/diff +0 -0
- package/commands/dir +0 -0
- package/commands/dircolors +0 -0
- package/commands/dirname +0 -0
- package/commands/du +0 -0
- package/commands/echo +0 -0
- package/commands/egrep +0 -0
- package/commands/env +0 -0
- package/commands/envsubst +0 -0
- package/commands/expand +0 -0
- package/commands/expr +0 -0
- package/commands/factor +0 -0
- package/commands/false +0 -0
- package/commands/fd +0 -0
- package/commands/fgrep +0 -0
- package/commands/file +0 -0
- package/commands/find +0 -0
- package/commands/fmt +0 -0
- package/commands/fold +0 -0
- package/commands/git +0 -0
- package/commands/git-remote-http +0 -0
- package/commands/git-remote-https +0 -0
- package/commands/grep +0 -0
- package/commands/groups +0 -0
- package/commands/gunzip +0 -0
- package/commands/gzip +0 -0
- package/commands/head +0 -0
- package/commands/hostid +0 -0
- package/commands/hostname +0 -0
- package/commands/http-test +0 -0
- package/commands/http_get +0 -0
- package/commands/id +0 -0
- package/commands/install +0 -0
- package/commands/join +0 -0
- package/commands/jq +0 -0
- package/commands/kill +0 -0
- package/commands/link +0 -0
- package/commands/ln +0 -0
- package/commands/logname +0 -0
- package/commands/ls +0 -0
- package/commands/md5sum +0 -0
- package/commands/mkdir +0 -0
- package/commands/mkfifo +0 -0
- package/commands/mknod +0 -0
- package/commands/mktemp +0 -0
- package/commands/more +0 -0
- package/commands/mv +0 -0
- package/commands/nice +0 -0
- package/commands/nl +0 -0
- package/commands/nohup +0 -0
- package/commands/nproc +0 -0
- package/commands/numfmt +0 -0
- package/commands/od +0 -0
- package/commands/paste +0 -0
- package/commands/pathchk +0 -0
- package/commands/pinky +0 -0
- package/commands/printenv +0 -0
- package/commands/printf +0 -0
- package/commands/ptx +0 -0
- package/commands/pwd +0 -0
- package/commands/readlink +0 -0
- package/commands/realpath +0 -0
- package/commands/rev +0 -0
- package/commands/rg +0 -0
- package/commands/rm +0 -0
- package/commands/rmdir +0 -0
- package/commands/runcon +0 -0
- package/commands/sed +0 -0
- package/commands/seq +0 -0
- package/commands/sh +0 -0
- package/commands/sha1sum +0 -0
- package/commands/sha224sum +0 -0
- package/commands/sha256sum +0 -0
- package/commands/sha384sum +0 -0
- package/commands/sha512sum +0 -0
- package/commands/shred +0 -0
- package/commands/shuf +0 -0
- package/commands/sleep +0 -0
- package/commands/sort +0 -0
- package/commands/spawn-test-host +0 -0
- package/commands/split +0 -0
- package/commands/sqlite3 +0 -0
- package/commands/stat +0 -0
- package/commands/stdbuf +0 -0
- package/commands/strings +0 -0
- package/commands/stty +0 -0
- package/commands/sum +0 -0
- package/commands/sync +0 -0
- package/commands/tac +0 -0
- package/commands/tail +0 -0
- package/commands/tar +0 -0
- package/commands/tee +0 -0
- package/commands/test +0 -0
- package/commands/timeout +0 -0
- package/commands/touch +0 -0
- package/commands/tr +0 -0
- package/commands/tree +0 -0
- package/commands/true +0 -0
- package/commands/truncate +0 -0
- package/commands/tsort +0 -0
- package/commands/tty +0 -0
- package/commands/uname +0 -0
- package/commands/unexpand +0 -0
- package/commands/uniq +0 -0
- package/commands/unlink +0 -0
- package/commands/unzip +0 -0
- package/commands/uptime +0 -0
- package/commands/users +0 -0
- package/commands/vdir +0 -0
- package/commands/wc +0 -0
- package/commands/which +0 -0
- package/commands/who +0 -0
- package/commands/whoami +0 -0
- package/commands/xargs +0 -0
- package/commands/xu +0 -0
- package/commands/yes +0 -0
- package/commands/yq +0 -0
- package/commands/zcat +0 -0
- package/commands/zip +0 -0
- package/dist/binary.d.ts +4 -0
- package/dist/binary.js +25 -0
- package/dist/bytes.d.ts +2 -0
- package/dist/bytes.js +6 -0
- package/dist/callbacks.d.ts +41 -0
- package/dist/callbacks.js +94 -0
- package/dist/cargo.d.ts +2 -0
- package/dist/cargo.js +142 -0
- package/dist/correlation.d.ts +7 -0
- package/dist/correlation.js +46 -0
- package/dist/descriptors.d.ts +84 -0
- package/dist/descriptors.js +60 -0
- package/dist/event-buffer.d.ts +90 -0
- package/dist/event-buffer.js +313 -0
- package/dist/ext.d.ts +7 -0
- package/dist/ext.js +13 -0
- package/dist/filesystem.d.ts +41 -0
- package/dist/filesystem.js +70 -0
- package/dist/frame-payload-codec.d.ts +8 -0
- package/dist/frame-payload-codec.js +14 -0
- package/dist/frame-rpc.d.ts +45 -0
- package/dist/frame-rpc.js +98 -0
- package/dist/frame-stream.d.ts +34 -0
- package/dist/frame-stream.js +109 -0
- package/dist/framing.d.ts +8 -0
- package/dist/framing.js +23 -0
- package/dist/generated/AcpLimitsConfig.d.ts +4 -0
- package/dist/generated/AcpLimitsConfig.js +2 -0
- package/dist/generated/CreateVmConfig.d.ts +26 -0
- package/dist/generated/CreateVmConfig.js +1 -0
- package/dist/generated/FsPermissionRule.d.ts +6 -0
- package/dist/generated/FsPermissionRule.js +1 -0
- package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
- package/dist/generated/FsPermissionRuleSet.js +1 -0
- package/dist/generated/FsPermissionScope.d.ts +3 -0
- package/dist/generated/FsPermissionScope.js +1 -0
- package/dist/generated/HttpLimitsConfig.d.ts +3 -0
- package/dist/generated/HttpLimitsConfig.js +2 -0
- package/dist/generated/JsModuleResolution.d.ts +1 -0
- package/dist/generated/JsModuleResolution.js +2 -0
- package/dist/generated/JsRuntimeConfig.d.ts +31 -0
- package/dist/generated/JsRuntimeConfig.js +1 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +11 -0
- package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
- package/dist/generated/JsRuntimePlatform.d.ts +1 -0
- package/dist/generated/JsRuntimePlatform.js +2 -0
- package/dist/generated/MountPluginDescriptor.d.ts +4 -0
- package/dist/generated/MountPluginDescriptor.js +2 -0
- package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
- package/dist/generated/NativeRootFilesystemConfig.js +1 -0
- package/dist/generated/PatternPermissionRule.d.ts +6 -0
- package/dist/generated/PatternPermissionRule.js +1 -0
- package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
- package/dist/generated/PatternPermissionRuleSet.js +1 -0
- package/dist/generated/PatternPermissionScope.d.ts +3 -0
- package/dist/generated/PatternPermissionScope.js +1 -0
- package/dist/generated/PermissionMode.d.ts +1 -0
- package/dist/generated/PermissionMode.js +2 -0
- package/dist/generated/PermissionsPolicy.d.ts +10 -0
- package/dist/generated/PermissionsPolicy.js +1 -0
- package/dist/generated/PluginLimitsConfig.d.ts +4 -0
- package/dist/generated/PluginLimitsConfig.js +2 -0
- package/dist/generated/PythonLimitsConfig.d.ts +6 -0
- package/dist/generated/PythonLimitsConfig.js +2 -0
- package/dist/generated/ResourceLimitsConfig.d.ts +24 -0
- package/dist/generated/ResourceLimitsConfig.js +2 -0
- package/dist/generated/RootFilesystemConfig.d.ts +9 -0
- package/dist/generated/RootFilesystemConfig.js +1 -0
- package/dist/generated/RootFilesystemEntry.d.ts +13 -0
- package/dist/generated/RootFilesystemEntry.js +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
- package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryKind.js +2 -0
- package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
- package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
- package/dist/generated/RootFilesystemMode.d.ts +1 -0
- package/dist/generated/RootFilesystemMode.js +2 -0
- package/dist/generated/ToolLimitsConfig.d.ts +10 -0
- package/dist/generated/ToolLimitsConfig.js +2 -0
- package/dist/generated/VmDnsConfig.d.ts +6 -0
- package/dist/generated/VmDnsConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +18 -0
- package/dist/generated/VmLimitsConfig.js +1 -0
- package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
- package/dist/generated/VmListenPolicyConfig.js +2 -0
- package/dist/generated/WasmLimitsConfig.d.ts +7 -0
- package/dist/generated/WasmLimitsConfig.js +2 -0
- package/dist/generated-protocol.d.ts +1196 -0
- package/dist/generated-protocol.js +3286 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +28 -0
- package/dist/json.d.ts +2 -0
- package/dist/json.js +20 -0
- package/dist/kernel-proxy.d.ts +166 -0
- package/dist/kernel-proxy.js +1787 -0
- package/dist/native-client.d.ts +46 -0
- package/dist/native-client.js +136 -0
- package/dist/node-runtime-options-schema.d.ts +117 -0
- package/dist/node-runtime-options-schema.js +121 -0
- package/dist/node-runtime.d.ts +593 -0
- package/dist/node-runtime.js +914 -0
- package/dist/numbers.d.ts +1 -0
- package/dist/numbers.js +8 -0
- package/dist/ownership.d.ts +18 -0
- package/dist/ownership.js +77 -0
- package/dist/permissions.d.ts +29 -0
- package/dist/permissions.js +68 -0
- package/dist/process.d.ts +22 -0
- package/dist/process.js +97 -0
- package/dist/protocol-client.d.ts +65 -0
- package/dist/protocol-client.js +242 -0
- package/dist/protocol-frames.d.ts +68 -0
- package/dist/protocol-frames.js +139 -0
- package/dist/protocol-maps.d.ts +31 -0
- package/dist/protocol-maps.js +273 -0
- package/dist/protocol-schema.d.ts +10 -0
- package/dist/protocol-schema.js +11 -0
- package/dist/request-payloads.d.ts +171 -0
- package/dist/request-payloads.js +269 -0
- package/dist/response-payloads.d.ts +186 -0
- package/dist/response-payloads.js +250 -0
- package/dist/sidecar-client.d.ts +17 -0
- package/dist/sidecar-client.js +1 -0
- package/dist/sidecar-errors.d.ts +30 -0
- package/dist/sidecar-errors.js +47 -0
- package/dist/sidecar-process.d.ts +360 -0
- package/dist/sidecar-process.js +1007 -0
- package/dist/state.d.ts +40 -0
- package/dist/state.js +43 -0
- package/dist/test-runtime.d.ts +566 -0
- package/dist/test-runtime.js +2170 -0
- package/dist/vm-config.d.ts +31 -0
- package/dist/vm-config.js +1 -0
- package/package.json +204 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { fromGeneratedRootFilesystemEntry, } from "./filesystem.js";
|
|
2
|
+
import { fromGeneratedExtEnvelope } from "./ext.js";
|
|
3
|
+
import { bigIntToSafeNumber } from "./numbers.js";
|
|
4
|
+
import { fromGeneratedFilesystemOperation, fromGeneratedGuestFilesystemOperation, fromGeneratedRootFilesystemEntryEncoding, fromGeneratedSignalDispositionAction, } from "./protocol-maps.js";
|
|
5
|
+
import { fromGeneratedGuestFilesystemStat, fromGeneratedProcessSnapshotEntry, fromGeneratedSocketStateEntry, } from "./state.js";
|
|
6
|
+
export function fromGeneratedResponsePayload(payload) {
|
|
7
|
+
switch (payload.tag) {
|
|
8
|
+
case "AuthenticatedResponse":
|
|
9
|
+
return {
|
|
10
|
+
type: "authenticated",
|
|
11
|
+
sidecar_id: payload.val.sidecarId,
|
|
12
|
+
connection_id: payload.val.connectionId,
|
|
13
|
+
max_frame_bytes: payload.val.maxFrameBytes,
|
|
14
|
+
};
|
|
15
|
+
case "SessionOpenedResponse":
|
|
16
|
+
return {
|
|
17
|
+
type: "session_opened",
|
|
18
|
+
session_id: payload.val.sessionId,
|
|
19
|
+
owner_connection_id: payload.val.ownerConnectionId,
|
|
20
|
+
};
|
|
21
|
+
case "VmCreatedResponse":
|
|
22
|
+
return { type: "vm_created", vm_id: payload.val.vmId };
|
|
23
|
+
case "VmDisposedResponse":
|
|
24
|
+
return { type: "vm_disposed", vm_id: payload.val.vmId };
|
|
25
|
+
case "RootFilesystemBootstrappedResponse":
|
|
26
|
+
return {
|
|
27
|
+
type: "root_filesystem_bootstrapped",
|
|
28
|
+
entry_count: payload.val.entryCount,
|
|
29
|
+
};
|
|
30
|
+
case "VmConfiguredResponse":
|
|
31
|
+
return {
|
|
32
|
+
type: "vm_configured",
|
|
33
|
+
applied_mounts: payload.val.appliedMounts,
|
|
34
|
+
applied_software: payload.val.appliedSoftware,
|
|
35
|
+
projected_commands: payload.val.projectedCommands.map((command) => ({
|
|
36
|
+
name: command.name,
|
|
37
|
+
guest_path: command.guestPath,
|
|
38
|
+
})),
|
|
39
|
+
agents: payload.val.agents.map(fromGeneratedAgentosProjectedAgent),
|
|
40
|
+
};
|
|
41
|
+
case "PackageLinkedResponse":
|
|
42
|
+
return {
|
|
43
|
+
type: "package_linked",
|
|
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
|
+
};
|
|
50
|
+
case "ProvidedCommandsResponse":
|
|
51
|
+
return {
|
|
52
|
+
type: "provided_commands_response",
|
|
53
|
+
packages: payload.val.packages.map((pkg) => ({
|
|
54
|
+
package_name: pkg.packageName,
|
|
55
|
+
commands: [...pkg.commands],
|
|
56
|
+
})),
|
|
57
|
+
};
|
|
58
|
+
case "HostCallbacksRegisteredResponse":
|
|
59
|
+
return {
|
|
60
|
+
type: "host_callbacks_registered",
|
|
61
|
+
registration: payload.val.registration,
|
|
62
|
+
command_count: payload.val.commandCount,
|
|
63
|
+
};
|
|
64
|
+
case "LayerCreatedResponse":
|
|
65
|
+
return { type: "layer_created", layer_id: payload.val.layerId };
|
|
66
|
+
case "LayerSealedResponse":
|
|
67
|
+
return { type: "layer_sealed", layer_id: payload.val.layerId };
|
|
68
|
+
case "SnapshotImportedResponse":
|
|
69
|
+
return { type: "snapshot_imported", layer_id: payload.val.layerId };
|
|
70
|
+
case "SnapshotExportedResponse":
|
|
71
|
+
return {
|
|
72
|
+
type: "snapshot_exported",
|
|
73
|
+
layer_id: payload.val.layerId,
|
|
74
|
+
entries: payload.val.entries.map(fromGeneratedRootFilesystemEntry),
|
|
75
|
+
};
|
|
76
|
+
case "OverlayCreatedResponse":
|
|
77
|
+
return { type: "overlay_created", layer_id: payload.val.layerId };
|
|
78
|
+
case "GuestFilesystemResultResponse":
|
|
79
|
+
return {
|
|
80
|
+
type: "guest_filesystem_result",
|
|
81
|
+
operation: fromGeneratedGuestFilesystemOperation(payload.val.operation),
|
|
82
|
+
path: payload.val.path,
|
|
83
|
+
...(payload.val.content !== null
|
|
84
|
+
? { content: payload.val.content }
|
|
85
|
+
: {}),
|
|
86
|
+
...(payload.val.encoding !== null
|
|
87
|
+
? {
|
|
88
|
+
encoding: fromGeneratedRootFilesystemEntryEncoding(payload.val.encoding),
|
|
89
|
+
}
|
|
90
|
+
: {}),
|
|
91
|
+
...(payload.val.entries !== null
|
|
92
|
+
? {
|
|
93
|
+
entries: payload.val.entries.map((entry) => ({
|
|
94
|
+
name: entry.name,
|
|
95
|
+
path: entry.path,
|
|
96
|
+
isDirectory: entry.isDirectory,
|
|
97
|
+
isSymbolicLink: entry.isSymbolicLink,
|
|
98
|
+
size: entry.size,
|
|
99
|
+
})),
|
|
100
|
+
}
|
|
101
|
+
: {}),
|
|
102
|
+
...(payload.val.stat !== null
|
|
103
|
+
? { stat: fromGeneratedGuestFilesystemStat(payload.val.stat) }
|
|
104
|
+
: {}),
|
|
105
|
+
...(payload.val.exists !== null ? { exists: payload.val.exists } : {}),
|
|
106
|
+
...(payload.val.target !== null ? { target: payload.val.target } : {}),
|
|
107
|
+
};
|
|
108
|
+
case "GuestKernelResultResponse":
|
|
109
|
+
return {
|
|
110
|
+
type: "guest_kernel_result",
|
|
111
|
+
payload: payload.val.payload,
|
|
112
|
+
};
|
|
113
|
+
case "RootFilesystemSnapshotResponse":
|
|
114
|
+
return {
|
|
115
|
+
type: "root_filesystem_snapshot",
|
|
116
|
+
entries: payload.val.entries.map(fromGeneratedRootFilesystemEntry),
|
|
117
|
+
};
|
|
118
|
+
case "ProcessStartedResponse":
|
|
119
|
+
return {
|
|
120
|
+
type: "process_started",
|
|
121
|
+
process_id: payload.val.processId,
|
|
122
|
+
...(payload.val.pid !== null ? { pid: payload.val.pid } : {}),
|
|
123
|
+
};
|
|
124
|
+
case "StdinWrittenResponse":
|
|
125
|
+
return {
|
|
126
|
+
type: "stdin_written",
|
|
127
|
+
process_id: payload.val.processId,
|
|
128
|
+
accepted_bytes: bigIntToSafeNumber(payload.val.acceptedBytes, "stdin_written.accepted_bytes"),
|
|
129
|
+
};
|
|
130
|
+
case "PtyResizedResponse":
|
|
131
|
+
return {
|
|
132
|
+
type: "pty_resized",
|
|
133
|
+
process_id: payload.val.processId,
|
|
134
|
+
cols: payload.val.cols,
|
|
135
|
+
rows: payload.val.rows,
|
|
136
|
+
};
|
|
137
|
+
case "StdinClosedResponse":
|
|
138
|
+
return { type: "stdin_closed", process_id: payload.val.processId };
|
|
139
|
+
case "ProcessKilledResponse":
|
|
140
|
+
return { type: "process_killed", process_id: payload.val.processId };
|
|
141
|
+
case "ProcessSnapshotResponse":
|
|
142
|
+
return {
|
|
143
|
+
type: "process_snapshot",
|
|
144
|
+
processes: payload.val.processes.map(fromGeneratedProcessSnapshotEntry),
|
|
145
|
+
};
|
|
146
|
+
case "ResourceSnapshotResponse":
|
|
147
|
+
return {
|
|
148
|
+
type: "resource_snapshot",
|
|
149
|
+
running_processes: bigIntToSafeNumber(payload.val.runningProcesses, "resource_snapshot.running_processes"),
|
|
150
|
+
exited_processes: bigIntToSafeNumber(payload.val.exitedProcesses, "resource_snapshot.exited_processes"),
|
|
151
|
+
fd_tables: bigIntToSafeNumber(payload.val.fdTables, "resource_snapshot.fd_tables"),
|
|
152
|
+
open_fds: bigIntToSafeNumber(payload.val.openFds, "resource_snapshot.open_fds"),
|
|
153
|
+
pipes: bigIntToSafeNumber(payload.val.pipes, "resource_snapshot.pipes"),
|
|
154
|
+
pipe_buffered_bytes: bigIntToSafeNumber(payload.val.pipeBufferedBytes, "resource_snapshot.pipe_buffered_bytes"),
|
|
155
|
+
ptys: bigIntToSafeNumber(payload.val.ptys, "resource_snapshot.ptys"),
|
|
156
|
+
pty_buffered_input_bytes: bigIntToSafeNumber(payload.val.ptyBufferedInputBytes, "resource_snapshot.pty_buffered_input_bytes"),
|
|
157
|
+
pty_buffered_output_bytes: bigIntToSafeNumber(payload.val.ptyBufferedOutputBytes, "resource_snapshot.pty_buffered_output_bytes"),
|
|
158
|
+
sockets: bigIntToSafeNumber(payload.val.sockets, "resource_snapshot.sockets"),
|
|
159
|
+
socket_listeners: bigIntToSafeNumber(payload.val.socketListeners, "resource_snapshot.socket_listeners"),
|
|
160
|
+
socket_connections: bigIntToSafeNumber(payload.val.socketConnections, "resource_snapshot.socket_connections"),
|
|
161
|
+
socket_buffered_bytes: bigIntToSafeNumber(payload.val.socketBufferedBytes, "resource_snapshot.socket_buffered_bytes"),
|
|
162
|
+
socket_datagram_queue_len: bigIntToSafeNumber(payload.val.socketDatagramQueueLen, "resource_snapshot.socket_datagram_queue_len"),
|
|
163
|
+
queue_snapshots: payload.val.queueSnapshots.map((queue) => ({
|
|
164
|
+
name: queue.name,
|
|
165
|
+
category: queue.category,
|
|
166
|
+
depth: bigIntToSafeNumber(queue.depth, "resource_snapshot.queue.depth"),
|
|
167
|
+
high_water: bigIntToSafeNumber(queue.highWater, "resource_snapshot.queue.high_water"),
|
|
168
|
+
capacity: bigIntToSafeNumber(queue.capacity, "resource_snapshot.queue.capacity"),
|
|
169
|
+
fill_percent: bigIntToSafeNumber(queue.fillPercent, "resource_snapshot.queue.fill_percent"),
|
|
170
|
+
})),
|
|
171
|
+
};
|
|
172
|
+
case "ListenerSnapshotResponse":
|
|
173
|
+
return {
|
|
174
|
+
type: "listener_snapshot",
|
|
175
|
+
...(payload.val.listener !== null
|
|
176
|
+
? { listener: fromGeneratedSocketStateEntry(payload.val.listener) }
|
|
177
|
+
: {}),
|
|
178
|
+
};
|
|
179
|
+
case "BoundUdpSnapshotResponse":
|
|
180
|
+
return {
|
|
181
|
+
type: "bound_udp_snapshot",
|
|
182
|
+
...(payload.val.socket !== null
|
|
183
|
+
? { socket: fromGeneratedSocketStateEntry(payload.val.socket) }
|
|
184
|
+
: {}),
|
|
185
|
+
};
|
|
186
|
+
case "SignalStateResponse":
|
|
187
|
+
return {
|
|
188
|
+
type: "signal_state",
|
|
189
|
+
process_id: payload.val.processId,
|
|
190
|
+
handlers: Object.fromEntries([...payload.val.handlers].map(([signal, registration]) => [
|
|
191
|
+
String(signal),
|
|
192
|
+
{
|
|
193
|
+
action: fromGeneratedSignalDispositionAction(registration.action),
|
|
194
|
+
mask: Array.from(registration.mask),
|
|
195
|
+
flags: registration.flags,
|
|
196
|
+
},
|
|
197
|
+
])),
|
|
198
|
+
};
|
|
199
|
+
case "ZombieTimerCountResponse":
|
|
200
|
+
return {
|
|
201
|
+
type: "zombie_timer_count",
|
|
202
|
+
count: bigIntToSafeNumber(payload.val.count, "zombie_timer_count.count"),
|
|
203
|
+
};
|
|
204
|
+
case "FilesystemResultResponse":
|
|
205
|
+
return {
|
|
206
|
+
type: "filesystem_result",
|
|
207
|
+
operation: fromGeneratedFilesystemOperation(payload.val.operation),
|
|
208
|
+
status: payload.val.status,
|
|
209
|
+
payload_size_bytes: bigIntToSafeNumber(payload.val.payloadSizeBytes, "filesystem_result.payload_size_bytes"),
|
|
210
|
+
};
|
|
211
|
+
case "PermissionDecisionResponse":
|
|
212
|
+
throw new Error("unsupported bare response payload tag: permission_decision");
|
|
213
|
+
case "PersistenceStateResponse":
|
|
214
|
+
return {
|
|
215
|
+
type: "persistence_state",
|
|
216
|
+
key: payload.val.key,
|
|
217
|
+
found: payload.val.found,
|
|
218
|
+
payload_size_bytes: bigIntToSafeNumber(payload.val.payloadSizeBytes, "persistence_state.payload_size_bytes"),
|
|
219
|
+
};
|
|
220
|
+
case "PersistenceFlushedResponse":
|
|
221
|
+
return {
|
|
222
|
+
type: "persistence_flushed",
|
|
223
|
+
key: payload.val.key,
|
|
224
|
+
committed_bytes: bigIntToSafeNumber(payload.val.committedBytes, "persistence_flushed.committed_bytes"),
|
|
225
|
+
};
|
|
226
|
+
case "RejectedResponse":
|
|
227
|
+
return {
|
|
228
|
+
type: "rejected",
|
|
229
|
+
code: payload.val.code,
|
|
230
|
+
message: payload.val.message,
|
|
231
|
+
};
|
|
232
|
+
case "VmFetchResponse":
|
|
233
|
+
return {
|
|
234
|
+
type: "vm_fetch_result",
|
|
235
|
+
response_json: payload.val.responseJson,
|
|
236
|
+
};
|
|
237
|
+
case "ExtEnvelope":
|
|
238
|
+
return {
|
|
239
|
+
type: "ext_result",
|
|
240
|
+
envelope: fromGeneratedExtEnvelope(payload.val),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function fromGeneratedAgentosProjectedAgent(agent) {
|
|
245
|
+
return {
|
|
246
|
+
id: agent.id,
|
|
247
|
+
acp_entrypoint: agent.acpEntrypoint,
|
|
248
|
+
adapter_entrypoint: agent.adapterEntrypoint,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
setSidecarRequestHandler(handler: LiveSidecarRequestHandler | null): void;
|
|
7
|
+
onEvent(handler: (event: LiveEventFrame) => void): () => void;
|
|
8
|
+
sendRequest(input: {
|
|
9
|
+
ownership: LiveOwnershipScope;
|
|
10
|
+
payload: LiveRequestPayload;
|
|
11
|
+
}): Promise<LiveResponseFrame>;
|
|
12
|
+
waitForEvent(matcher: LiveSidecarEventSelector | ((event: LiveEventFrame) => boolean), timeoutMs?: number, options?: {
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}): Promise<LiveEventFrame>;
|
|
15
|
+
failPermanently(error: Error): void;
|
|
16
|
+
dispose(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare class SidecarProcessExited extends Error {
|
|
2
|
+
readonly exitCode: number | null;
|
|
3
|
+
readonly signal: string | null;
|
|
4
|
+
readonly stderr: string;
|
|
5
|
+
constructor(options: {
|
|
6
|
+
exitCode: number | null;
|
|
7
|
+
signal: string | null;
|
|
8
|
+
stderr: string;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The silence watchdog fired: the sidecar produced no protocol frames at all —
|
|
13
|
+
* not even its 10s liveness heartbeats — for the full silence window, so the
|
|
14
|
+
* process is dead or wedged (not merely busy: a busy sidecar still heartbeats
|
|
15
|
+
* from a dedicated thread). The host kills the sidecar and rejects every
|
|
16
|
+
* in-flight request with this error.
|
|
17
|
+
*/
|
|
18
|
+
export declare class SidecarSilenceTimeout extends Error {
|
|
19
|
+
readonly silenceMs: number;
|
|
20
|
+
readonly stderr: string;
|
|
21
|
+
constructor(options: {
|
|
22
|
+
silenceMs: number;
|
|
23
|
+
stderr: string;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export declare class SidecarProcessError extends Error {
|
|
27
|
+
readonly childError: Error;
|
|
28
|
+
readonly stderr: string;
|
|
29
|
+
constructor(error: Error, stderr: string);
|
|
30
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function formatSidecarStderrSuffix(stderr) {
|
|
2
|
+
return stderr ? `\nstderr:\n${stderr}` : "";
|
|
3
|
+
}
|
|
4
|
+
export class SidecarProcessExited extends Error {
|
|
5
|
+
exitCode;
|
|
6
|
+
signal;
|
|
7
|
+
stderr;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
const reason = options.signal !== null
|
|
10
|
+
? `signal ${options.signal}`
|
|
11
|
+
: options.exitCode !== null
|
|
12
|
+
? `code ${options.exitCode}`
|
|
13
|
+
: "disconnect";
|
|
14
|
+
super(`sidecar process exited with ${reason}${formatSidecarStderrSuffix(options.stderr)}`);
|
|
15
|
+
this.name = "SidecarProcessExited";
|
|
16
|
+
this.exitCode = options.exitCode;
|
|
17
|
+
this.signal = options.signal;
|
|
18
|
+
this.stderr = options.stderr;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The silence watchdog fired: the sidecar produced no protocol frames at all —
|
|
23
|
+
* not even its 10s liveness heartbeats — for the full silence window, so the
|
|
24
|
+
* process is dead or wedged (not merely busy: a busy sidecar still heartbeats
|
|
25
|
+
* from a dedicated thread). The host kills the sidecar and rejects every
|
|
26
|
+
* in-flight request with this error.
|
|
27
|
+
*/
|
|
28
|
+
export class SidecarSilenceTimeout extends Error {
|
|
29
|
+
silenceMs;
|
|
30
|
+
stderr;
|
|
31
|
+
constructor(options) {
|
|
32
|
+
super(`sidecar unresponsive: no protocol frames or heartbeats for ${Math.round(options.silenceMs)}ms; killing sidecar${formatSidecarStderrSuffix(options.stderr)}`);
|
|
33
|
+
this.name = "SidecarSilenceTimeout";
|
|
34
|
+
this.silenceMs = options.silenceMs;
|
|
35
|
+
this.stderr = options.stderr;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class SidecarProcessError extends Error {
|
|
39
|
+
childError;
|
|
40
|
+
stderr;
|
|
41
|
+
constructor(error, stderr) {
|
|
42
|
+
super(`sidecar process error: ${error.message}${formatSidecarStderrSuffix(stderr)}`);
|
|
43
|
+
this.name = "SidecarProcessError";
|
|
44
|
+
this.childError = error;
|
|
45
|
+
this.stderr = stderr;
|
|
46
|
+
}
|
|
47
|
+
}
|