@rivet-dev/agentos-core 0.2.22 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +9 -9
  2. package/dist/agent-os.d.ts +71 -198
  3. package/dist/agent-os.js +480 -1206
  4. package/dist/agentos-package.d.ts +15 -4
  5. package/dist/agentos-package.js +1 -22
  6. package/dist/cron/cron-manager.js +0 -27
  7. package/dist/cron/types.d.ts +0 -12
  8. package/dist/default-software/coreutils.aospkg +4 -0
  9. package/dist/default-software/default-software.json +10 -0
  10. package/dist/default-software/diffutils.aospkg +0 -0
  11. package/dist/default-software/findutils.aospkg +0 -0
  12. package/dist/default-software/gawk.aospkg +0 -0
  13. package/dist/default-software/grep.aospkg +0 -0
  14. package/dist/default-software/gzip.aospkg +0 -0
  15. package/dist/default-software/sed.aospkg +0 -0
  16. package/dist/default-software/tar.aospkg +0 -0
  17. package/dist/default-software.d.ts +6 -5
  18. package/dist/default-software.js +17 -6
  19. package/dist/generated/VmLimitsConfig.d.ts +0 -2
  20. package/dist/host-dir-mount.d.ts +1 -1
  21. package/dist/host-dir-mount.js +1 -1
  22. package/dist/language-execution.d.ts +6 -2
  23. package/dist/options-schema.d.ts +10 -48
  24. package/dist/options-schema.js +10 -47
  25. package/dist/output-replay.d.ts +18 -0
  26. package/dist/output-replay.js +75 -0
  27. package/dist/packages.d.ts +0 -9
  28. package/dist/packages.js +0 -39
  29. package/dist/process-forest.d.ts +7 -0
  30. package/dist/process-forest.js +24 -0
  31. package/dist/runtime-compat.d.ts +13 -0
  32. package/dist/runtime-compat.js +3 -9
  33. package/dist/sidecar/binary.d.ts +1 -1
  34. package/dist/sidecar/binary.js +4 -4
  35. package/dist/sidecar/native-process-client.d.ts +1 -1
  36. package/dist/sidecar/rpc-client.d.ts +12 -18
  37. package/dist/sidecar/rpc-client.js +385 -188
  38. package/dist/types.d.ts +3 -11
  39. package/package.json +9 -45
  40. package/dist/generated/AcpLimitsConfig.d.ts +0 -20
  41. package/dist/generated/AcpLimitsConfig.js +0 -2
  42. package/dist/json-rpc.d.ts +0 -50
  43. package/dist/json-rpc.js +0 -22
  44. package/dist/session-api.d.ts +0 -180
  45. package/dist/session-api.js +0 -1
  46. package/dist/sidecar/agentos-protocol.d.ts +0 -719
  47. package/dist/sidecar/agentos-protocol.js +0 -1331
@@ -0,0 +1,24 @@
1
+ export function buildProcessForest(records, project) {
2
+ const keys = new Set(records.map((record) => record.key));
3
+ const children = new Map();
4
+ const roots = [];
5
+ for (const record of records) {
6
+ if (record.parentKey !== null && keys.has(record.parentKey)) {
7
+ const siblings = children.get(record.parentKey) ?? [];
8
+ siblings.push(record);
9
+ children.set(record.parentKey, siblings);
10
+ }
11
+ else {
12
+ roots.push(record);
13
+ }
14
+ }
15
+ const seen = new Set();
16
+ const visit = (record) => {
17
+ seen.add(record.key);
18
+ const descendants = (children.get(record.key) ?? [])
19
+ .filter((child) => !seen.has(child.key))
20
+ .map(visit);
21
+ return project(record.info, descendants);
22
+ };
23
+ return roots.map(visit);
24
+ }
@@ -104,6 +104,8 @@ export interface ProcessInfo {
104
104
  }
105
105
  export interface ManagedProcess {
106
106
  pid: number;
107
+ /** Internal sidecar routing identity for output replay. */
108
+ readonly processId?: string;
107
109
  writeStdin(data: Uint8Array | string): Promise<void>;
108
110
  closeStdin(): Promise<void>;
109
111
  kill(signal?: number): void;
@@ -155,11 +157,22 @@ export interface RunResult<T = unknown> {
155
157
  errorMessage?: string;
156
158
  }
157
159
  export interface KernelSpawnOptions extends ExecOptions {
160
+ /** Internal sidecar replay identity; absent for local/synthetic output. */
161
+ onStdout?: (data: Uint8Array, metadata?: {
162
+ sequence?: number;
163
+ timestampMs?: number;
164
+ }) => void;
165
+ onStderr?: (data: Uint8Array, metadata?: {
166
+ sequence?: number;
167
+ timestampMs?: number;
168
+ }) => void;
158
169
  stdio?: "pipe" | "inherit";
159
170
  stdinFd?: number;
160
171
  stdoutFd?: number;
161
172
  stderrFd?: number;
162
173
  streamStdin?: boolean;
174
+ /** Internal: ask the sidecar to retain bounded output for pull-based replay. */
175
+ retainOutput?: boolean;
163
176
  }
164
177
  export type KernelExecOptions = ExecOptions;
165
178
  export type KernelExecResult = ExecResult;
@@ -62,7 +62,7 @@ const KERNEL_POSIX_BOOTSTRAP_DIRS = [
62
62
  "/var/tmp",
63
63
  ];
64
64
  const REPO_ROOT = fileURLToPath(new URL("../../..", import.meta.url));
65
- const SIDECAR_BINARY = path.join(REPO_ROOT, "target/debug/agentos-sidecar");
65
+ const SIDECAR_BINARY = path.join(REPO_ROOT, "target/debug/agentos-native-sidecar");
66
66
  const SIDECAR_BUILD_INPUTS = [
67
67
  path.join(REPO_ROOT, "Cargo.toml"),
68
68
  path.join(REPO_ROOT, "Cargo.lock"),
@@ -70,8 +70,6 @@ const SIDECAR_BUILD_INPUTS = [
70
70
  path.join(REPO_ROOT, "crates/build-support"),
71
71
  path.join(REPO_ROOT, "crates/execution"),
72
72
  path.join(REPO_ROOT, "crates/kernel"),
73
- path.join(REPO_ROOT, "crates/agentos-protocol"),
74
- path.join(REPO_ROOT, "crates/agentos-sidecar"),
75
73
  path.join(REPO_ROOT, "crates/native-sidecar"),
76
74
  path.join(REPO_ROOT, "crates/native-sidecar-core"),
77
75
  path.join(REPO_ROOT, "crates/sidecar-protocol"),
@@ -588,8 +586,6 @@ export const WASMVM_COMMANDS = Object.freeze([
588
586
  "users",
589
587
  "uptime",
590
588
  "stty",
591
- "codex",
592
- "codex-exec",
593
589
  ]);
594
590
  export const DEFAULT_FIRST_PARTY_TIERS = Object.freeze({
595
591
  sh: "full",
@@ -600,8 +596,6 @@ export const DEFAULT_FIRST_PARTY_TIERS = Object.freeze({
600
596
  nice: "full",
601
597
  nohup: "full",
602
598
  stdbuf: "full",
603
- codex: "full",
604
- "codex-exec": "full",
605
599
  git: "full",
606
600
  "git-remote-http": "full",
607
601
  "git-remote-https": "full",
@@ -839,13 +833,13 @@ function ensureNativeSidecarBinary() {
839
833
  if (sidecarBinaryNeedsBuild()) {
840
834
  const cargoBinary = findCargoBinary();
841
835
  if (cargoBinary) {
842
- execFileSync(cargoBinary, ["build", "-q", "-p", "agentos-sidecar"], {
836
+ execFileSync(cargoBinary, ["build", "-q", "-p", "agentos-native-sidecar"], {
843
837
  cwd: REPO_ROOT,
844
838
  stdio: "pipe",
845
839
  });
846
840
  }
847
841
  else if (!fsSync.existsSync(SIDECAR_BINARY)) {
848
- execFileSync(resolveCargoBinary(), ["build", "-q", "-p", "agentos-sidecar"], {
842
+ execFileSync(resolveCargoBinary(), ["build", "-q", "-p", "agentos-native-sidecar"], {
849
843
  cwd: REPO_ROOT,
850
844
  stdio: "pipe",
851
845
  });
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Honors `AGENTOS_SIDECAR_BIN` as an absolute-path override, otherwise
5
5
  * resolves the platform-specific binary shipped by the
6
- * `@rivet-dev/agentos-sidecar` package. In-repo developer builds use the local
6
+ * `@rivet-dev/agentos-runtime-sidecar` package. In-repo developer builds use the local
7
7
  * cargo build path instead and never reach this function.
8
8
  */
9
9
  export declare function resolvePublishedSidecarBinary(): string;
@@ -5,7 +5,7 @@ import { createRequire } from "node:module";
5
5
  *
6
6
  * Honors `AGENTOS_SIDECAR_BIN` as an absolute-path override, otherwise
7
7
  * resolves the platform-specific binary shipped by the
8
- * `@rivet-dev/agentos-sidecar` package. In-repo developer builds use the local
8
+ * `@rivet-dev/agentos-runtime-sidecar` package. In-repo developer builds use the local
9
9
  * cargo build path instead and never reach this function.
10
10
  */
11
11
  export function resolvePublishedSidecarBinary() {
@@ -19,12 +19,12 @@ export function resolvePublishedSidecarBinary() {
19
19
  const require = createRequire(import.meta.url);
20
20
  let mod;
21
21
  try {
22
- mod = require("@rivet-dev/agentos-sidecar");
22
+ mod = require("@rivet-dev/agentos-runtime-sidecar");
23
23
  }
24
24
  catch (error) {
25
- throw new Error("failed to resolve the Agent OS sidecar binary: the @rivet-dev/agentos-sidecar " +
25
+ throw new Error("failed to resolve the agentOS runtime sidecar binary: the @rivet-dev/agentos-runtime-sidecar " +
26
26
  "package is not installed. Install it, or set AGENTOS_SIDECAR_BIN to a local " +
27
- `agentos-sidecar binary. (${error.message})`);
27
+ `agentos-native-sidecar binary. (${error.message})`);
28
28
  }
29
29
  return mod.getSidecarPath();
30
30
  }
@@ -2,5 +2,5 @@ import "@rivet-dev/agentos-runtime-core/native-client";
2
2
  import { SidecarProcess } from "@rivet-dev/agentos-runtime-core/sidecar-client";
3
3
  export { SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
4
4
  export declare const NativeSidecarProcessClient: typeof SidecarProcess;
5
- export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarEventSelector, SidecarFsPermissionRule, SidecarLinkPackageResult, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedAgent, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarSpawnOptions, SidecarSpawnOptions as NativeSidecarSpawnOptions, SidecarZombieTimerCount, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
5
+ export type { AuthenticatedSession, CreatedVm, ExtEnvelope, GuestFilesystemStat, RootFilesystemEntry, RootFilesystemLowerDescriptor, SidecarEventSelector, SidecarFsPermissionRule, SidecarLinkPackageResult, SidecarMountDescriptor, SidecarMountPluginDescriptor, SidecarPatternPermissionRule, SidecarPermissionMode, SidecarPermissionScope, SidecarPermissionsPolicy, SidecarProcessSnapshotEntry, SidecarProjectedModuleDescriptor, SidecarRegisteredHostCallbackDefinition, SidecarRegisteredHostCallbackExample, SidecarRequestFrame, SidecarRequestHandler, SidecarRequestPayload, SidecarResponseFrame, SidecarResponsePayload, SidecarRulePermissions, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSignalState, SidecarSocketStateEntry, SidecarSoftwareDescriptor, SidecarSpawnOptions, SidecarSpawnOptions as NativeSidecarSpawnOptions, SidecarZombieTimerCount, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
6
6
  export type { SidecarVmConfiguredResponse as SidecarConfigureVmResult, } from "@rivet-dev/agentos-runtime-core/sidecar-client";
@@ -1,6 +1,7 @@
1
1
  import type { RootFilesystemConfig as VmConfigRootFilesystemConfig, RootFilesystemEntry as VmConfigRootFilesystemEntry, RootFilesystemLowerDescriptor as VmConfigRootFilesystemLowerDescriptor } from "@rivet-dev/agentos-runtime-core/vm-config";
2
2
  import type { NativeMountConfig, PlainMountConfig, RootFilesystemConfig } from "../agent-os.js";
3
3
  import type { RootSnapshotExport } from "../layers.js";
4
+ import type { ProcessForestRecord } from "../process-forest.js";
4
5
  import type { ConnectTerminalOptions, KernelExecOptions, KernelExecResult, KernelSpawnOptions, ManagedProcess, OpenShellOptions, ProcessInfo, ShellHandle, VirtualFileSystem, VirtualStat } from "../runtime-compat.js";
5
6
  import type { AuthenticatedSession, CreatedVm, SidecarPermissionsPolicy, SidecarProcess, SidecarSignalHandlerRegistration } from "./native-process-client.js";
6
7
  export declare function toSidecarSignalName(signal: number): string;
@@ -36,11 +37,9 @@ interface NativeSidecarKernelProxyOptions {
36
37
  commandPermissions?: Parameters<SidecarProcess["configureVm"]>[2]["commandPermissions"];
37
38
  loopbackExemptPorts?: number[];
38
39
  /**
39
- * The boot `configureVm` payload pieces beyond mounts/permissions. Rust
40
- * `configure_vm` rebuilds the whole VM configuration from each payload, so
41
- * every runtime mount reconfigure must resend these or a post-boot
42
- * `mountFs()` silently drops the `/opt/agentos` package projections and
43
- * host-function shim commands applied at boot.
40
+ * Boot `configureVm` fields beyond mounts/permissions. Reconfiguration
41
+ * replaces the boot package set; the sidecar retains packages added with
42
+ * `linkPackage` until an explicit `unlinkPackage`.
44
43
  */
45
44
  packages?: Parameters<SidecarProcess["configureVm"]>[2]["packages"];
46
45
  packagesMountAt?: string;
@@ -74,7 +73,7 @@ export declare class NativeSidecarKernelProxy {
74
73
  private readonly permissions;
75
74
  private readonly commandPermissions;
76
75
  private readonly loopbackExemptPorts;
77
- private packages;
76
+ private readonly packages;
78
77
  private readonly packagesMountAt;
79
78
  private readonly hostFunctionShimCommands;
80
79
  private readonly commandDrivers;
@@ -102,15 +101,7 @@ export declare class NativeSidecarKernelProxy {
102
101
  createRootView(): VirtualFileSystem;
103
102
  get zombieTimerCount(): number;
104
103
  registerCommandGuestPaths(commandGuestPaths: ReadonlyMap<string, string>): void;
105
- /**
106
- * Record a runtime-linked package (`linkSoftware`) so mount reconfigures
107
- * resend it. Rust `configure_vm` rebuilds the whole VM configuration from
108
- * each payload, so a linked package omitted here would be silently
109
- * unprojected from `/opt/agentos` by the next `mountFs`/`unmountFs`.
110
- */
111
- registerLinkedPackage(descriptor: {
112
- path: string;
113
- }): void;
104
+ unregisterCommandGuestPaths(commandNames: readonly string[]): void;
114
105
  dispose(): Promise<void>;
115
106
  /** Test-only snapshot of the per-VM tracking collection sizes. */
116
107
  __trackingSizesForTest(): {
@@ -173,6 +164,8 @@ export declare class NativeSidecarKernelProxy {
173
164
  private reconfigureSidecarMounts;
174
165
  private waitForMountReconfigure;
175
166
  snapshotProcesses(): ProcessInfo[];
167
+ /** Internal, host-side topology; never part of the guest or public DTO wire. */
168
+ snapshotProcessTopology(): ProcessForestRecord<ProcessInfo>[];
176
169
  findListener(request: {
177
170
  host?: string;
178
171
  port?: number;
@@ -191,6 +184,8 @@ export declare class NativeSidecarKernelProxy {
191
184
  private drainTrailingProcessOutput;
192
185
  private startTrackedProcess;
193
186
  private runEventPump;
187
+ /** Internal: replay carries the same authoritative exit proof as a live event. */
188
+ reconcileReplayExit(processId: string, exitCode: number): void;
194
189
  private finishProcess;
195
190
  private releaseProcessTrackingAfterDrain;
196
191
  private waitForTrackedProcess;
@@ -198,7 +193,6 @@ export declare class NativeSidecarKernelProxy {
198
193
  private flushPendingStdin;
199
194
  private closeTrackedStdin;
200
195
  private handleBackgroundProcessError;
201
- private recordCompletedProcessError;
202
196
  private emitBackgroundProcessError;
203
197
  private readdirRecursiveLocal;
204
198
  private removePathLocal;
@@ -214,7 +208,7 @@ export declare class NativeSidecarKernelProxy {
214
208
  private assertLocalWritable;
215
209
  private updateTrackedProcessSnapshot;
216
210
  }
217
- export type { AuthenticatedSession, CreatedVm, GuestFilesystemStat, RootFilesystemEntry, SidecarConfigureVmResult, SidecarEventSelector, SidecarLinkPackageResult, SidecarPermissionsPolicy, SidecarProjectedAgent, SidecarRegisteredHostCallbackDefinition, SidecarRequestFrame, SidecarResponsePayload, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSocketStateEntry, SidecarSpawnOptions, } from "./native-process-client.js";
211
+ export type { AuthenticatedSession, CreatedVm, GuestFilesystemStat, RootFilesystemEntry, SidecarConfigureVmResult, SidecarEventSelector, SidecarLinkPackageResult, SidecarPermissionsPolicy, SidecarRegisteredHostCallbackDefinition, SidecarRequestFrame, SidecarResponsePayload, SidecarSessionState, SidecarSignalHandlerRegistration, SidecarSocketStateEntry, SidecarSpawnOptions, } from "./native-process-client.js";
218
212
  export { NativeSidecarProcessClient, SidecarEventBufferOverflow, SidecarProcess, SidecarProcessError, SidecarProcessExited, } from "./native-process-client.js";
219
213
  export type AgentOsSidecarPlacement = {
220
214
  kind: "shared";
@@ -299,7 +293,7 @@ export declare class AgentOsSidecarClient {
299
293
  private readonly sessions;
300
294
  private disposed;
301
295
  constructor(options: AgentOsSidecarClientOptions);
302
- /** Open a physical sidecar ownership scope, not a durable ACP session. */
296
+ /** Open a physical sidecar ownership scope for one client connection. */
303
297
  createOwnershipSession(options?: AgentOsSidecarSessionOptions): Promise<AgentOsSidecarSessionHandle>;
304
298
  listSessions(): AgentOsSidecarSessionLifecycle[];
305
299
  requireSessionLifecycle(sessionId: string): AgentOsSidecarSessionLifecycle;