@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
@@ -7,17 +7,28 @@
7
7
  * projection. Package metadata lives in `<dir>/agentos-package.json`.
8
8
  *
9
9
  * This module is therefore only the client-facing package-dir surface plus the
10
- * `/opt/agentos` path constants used for agent-config wiring.
10
+ * `/opt/agentos` path constants used for package wiring.
11
11
  *
12
12
  * See `website/src/content/docs/docs/architecture/packages-and-command-resolution.mdx`.
13
13
  */
14
- import type { AgentosPackageManifest, PackageAgentDescriptor, PackageRef as ManifestPackageRef } from "@agentos-software/manifest";
14
+ export interface PackageProvidesFileDescriptor {
15
+ source: string;
16
+ target: string;
17
+ }
18
+ export interface PackageProvidesDescriptor {
19
+ env?: Record<string, string>;
20
+ files?: PackageProvidesFileDescriptor[];
21
+ }
22
+ export interface AgentosPackageManifest {
23
+ name: string;
24
+ version: string;
25
+ provides?: PackageProvidesDescriptor;
26
+ }
15
27
  /** Root of the agentOS package tree inside the VM. */
16
28
  export declare const OPT_AGENTOS_ROOT = "/opt/agentos";
17
29
  /** The symlink farm on `$PATH` (commands link here). */
18
30
  export declare const OPT_AGENTOS_BIN = "/opt/agentos/bin";
19
- export type AgentBlock = PackageAgentDescriptor;
20
- export type PackageRef = ManifestPackageRef;
31
+ export type PackageRef = string;
21
32
  export type SoftwarePackageRef = {
22
33
  packagePath: string;
23
34
  };
@@ -7,7 +7,7 @@
7
7
  * projection. Package metadata lives in `<dir>/agentos-package.json`.
8
8
  *
9
9
  * This module is therefore only the client-facing package-dir surface plus the
10
- * `/opt/agentos` path constants used for agent-config wiring.
10
+ * `/opt/agentos` path constants used for package wiring.
11
11
  *
12
12
  * See `website/src/content/docs/docs/architecture/packages-and-command-resolution.mdx`.
13
13
  */
@@ -60,23 +60,6 @@ function validateAgentosPackageManifest(value, source) {
60
60
  name: value.name,
61
61
  version: value.version,
62
62
  };
63
- if (value.agent !== undefined) {
64
- if (!isPlainObject(value.agent) ||
65
- typeof value.agent.acpEntrypoint !== "string") {
66
- throw new Error(`Invalid agentOS package manifest at ${source}: invalid agent.acpEntrypoint`);
67
- }
68
- manifest.agent = {
69
- acpEntrypoint: value.agent.acpEntrypoint,
70
- ...(isStringRecord(value.agent.env) ? { env: value.agent.env } : {}),
71
- ...(Array.isArray(value.agent.launchArgs) &&
72
- value.agent.launchArgs.every((arg) => typeof arg === "string")
73
- ? { launchArgs: value.agent.launchArgs }
74
- : {}),
75
- ...(typeof value.agent.snapshot === "boolean"
76
- ? { snapshot: value.agent.snapshot }
77
- : {}),
78
- };
79
- }
80
63
  if (value.provides !== undefined) {
81
64
  manifest.provides = value.provides;
82
65
  }
@@ -85,7 +68,3 @@ function validateAgentosPackageManifest(value, source) {
85
68
  function isPlainObject(value) {
86
69
  return typeof value === "object" && value !== null && !Array.isArray(value);
87
70
  }
88
- function isStringRecord(value) {
89
- return (isPlainObject(value) &&
90
- Object.values(value).every((entry) => typeof entry === "string"));
91
- }
@@ -2,15 +2,6 @@ import { randomUUID } from "node:crypto";
2
2
  import { resolveSchedule, validateScheduleForRegistration, } from "./parse-schedule.js";
3
3
  function describeAction(action) {
4
4
  switch (action.type) {
5
- case "session":
6
- return {
7
- type: "session",
8
- agentType: action.agentType,
9
- prompt: action.prompt,
10
- ...(action.options === undefined
11
- ? {}
12
- : { options: structuredClone(action.options) }),
13
- };
14
5
  case "exec":
15
6
  return {
16
7
  type: "exec",
@@ -159,24 +150,6 @@ export class CronManager {
159
150
  }
160
151
  async runAction(action) {
161
152
  switch (action.type) {
162
- case "session": {
163
- const sessionId = `cron-${randomUUID()}`;
164
- await this.vm.openSession({
165
- ...action.options,
166
- sessionId,
167
- agent: action.agentType,
168
- });
169
- try {
170
- await this.vm.prompt({
171
- sessionId,
172
- content: [{ type: "text", text: action.prompt }],
173
- });
174
- }
175
- finally {
176
- await this.vm.deleteSession({ sessionId });
177
- }
178
- break;
179
- }
180
153
  case "exec": {
181
154
  await this.vm.execArgv(action.command, action.args ?? []);
182
155
  break;
@@ -1,11 +1,4 @@
1
- import type { OpenSessionInput } from "../session-api.js";
2
- import type { AgentType } from "../types.js";
3
1
  export type CronAction = {
4
- type: "session";
5
- agentType: AgentType;
6
- prompt: string;
7
- options?: Omit<OpenSessionInput, "agent" | "sessionId">;
8
- } | {
9
2
  type: "exec";
10
3
  command: string;
11
4
  args?: string[];
@@ -18,11 +11,6 @@ export type CronAction = {
18
11
  * expose only their kind: the host closure is execution state, not job data.
19
12
  */
20
13
  export type CronActionInfo = {
21
- type: "session";
22
- agentType: AgentType;
23
- prompt: string;
24
- options?: Omit<OpenSessionInput, "agent" | "sessionId">;
25
- } | {
26
14
  type: "exec";
27
15
  command: string;
28
16
  args?: string[];
@@ -0,0 +1,4 @@
1
+ [diffend] Oversized file quarantined before diffing.
2
+ name: package/dist/default-software/coreutils.aospkg
3
+ size: 67400857 bytes
4
+ sha256: e269c2e6a04b2d0027e66d0efb49a2937304decc7963dcb66f394cdd5dad4186
@@ -0,0 +1,10 @@
1
+ [
2
+ "coreutils",
3
+ "sed",
4
+ "grep",
5
+ "gawk",
6
+ "findutils",
7
+ "diffutils",
8
+ "tar",
9
+ "gzip"
10
+ ]
Binary file
Binary file
@@ -1,8 +1,9 @@
1
- import type { SoftwarePackageRef } from "@agentos-software/manifest";
1
+ import type { SoftwarePackageRef } from "./agentos-package.js";
2
2
  /**
3
- * Default software for a bare `AgentOs.create()`: the `@agentos-software/common`
4
- * coreutils bundle, imported like any other package. The client makes NO
5
- * npm/node_modules assumptions (see root CLAUDE.md) — no dep scan, no
6
- * require.resolve. Opt out with `defaultSoftware: false`; add more via `software`.
3
+ * Default software for a bare `AgentOs.create()`. The build stages the list
4
+ * from `software/default-software.json` and its immutable `.aospkg` files into
5
+ * the Core package; runtime resolution never consults npm or scans
6
+ * node_modules. Opt out with `defaultSoftware: false`; add more trusted paths
7
+ * via `software`.
7
8
  */
8
9
  export declare function resolveDefaultSoftware(): SoftwarePackageRef[];
@@ -1,10 +1,21 @@
1
- import common from "@agentos-software/common";
1
+ import { readFileSync } from "node:fs";
2
2
  /**
3
- * Default software for a bare `AgentOs.create()`: the `@agentos-software/common`
4
- * coreutils bundle, imported like any other package. The client makes NO
5
- * npm/node_modules assumptions (see root CLAUDE.md) — no dep scan, no
6
- * require.resolve. Opt out with `defaultSoftware: false`; add more via `software`.
3
+ * Default software for a bare `AgentOs.create()`. The build stages the list
4
+ * from `software/default-software.json` and its immutable `.aospkg` files into
5
+ * the Core package; runtime resolution never consults npm or scans
6
+ * node_modules. Opt out with `defaultSoftware: false`; add more trusted paths
7
+ * via `software`.
7
8
  */
8
9
  export function resolveDefaultSoftware() {
9
- return [common].flat();
10
+ // Published consumers execute this module from dist/, while Vitest executes
11
+ // the TypeScript source directly. The build stages the same immutable
12
+ // artifacts in dist/default-software for both cases.
13
+ const moduleDirectory = new URL(".", import.meta.url);
14
+ const artifactDirectory = moduleDirectory.pathname.endsWith("/src/")
15
+ ? new URL("../dist/default-software/", moduleDirectory)
16
+ : new URL("./default-software/", moduleDirectory);
17
+ const names = JSON.parse(readFileSync(new URL("default-software.json", artifactDirectory), "utf8"));
18
+ return names.map((name) => ({
19
+ packagePath: new URL(`${name}.aospkg`, artifactDirectory).pathname,
20
+ }));
10
21
  }
@@ -1,4 +1,3 @@
1
- import type { AcpLimitsConfig } from "./AcpLimitsConfig.js";
2
1
  import type { HostFunctionLimitsConfig } from "./HostFunctionLimitsConfig.js";
3
2
  import type { HttpLimitsConfig } from "./HttpLimitsConfig.js";
4
3
  import type { JsRuntimeLimitsConfig } from "./JsRuntimeLimitsConfig.js";
@@ -12,7 +11,6 @@ export type VmLimitsConfig = {
12
11
  http?: HttpLimitsConfig;
13
12
  hostFunctions?: HostFunctionLimitsConfig;
14
13
  plugins?: PluginLimitsConfig;
15
- acp?: AcpLimitsConfig;
16
14
  jsRuntime?: JsRuntimeLimitsConfig;
17
15
  python?: PythonLimitsConfig;
18
16
  wasm?: WasmLimitsConfig;
@@ -36,7 +36,7 @@ export declare function hostDirMount(path: string, hostPath: string, opts?: {
36
36
  * This is the explicit replacement for the removed `moduleAccessCwd` option:
37
37
  * the VM's module resolver reads the mounted tree through the kernel VFS, so the
38
38
  * caller supplies exactly the `node_modules` directory whose packages should be
39
- * resolvable in the guest (e.g. the agent SDK + its transitive deps).
39
+ * resolvable in the guest (e.g. a guest library and its transitive deps).
40
40
  *
41
41
  * @param hostNodeModulesDir Absolute host path to a `node_modules` directory.
42
42
  * @param opts.readOnly Defaults to `true`; the mount is read-only.
@@ -31,7 +31,7 @@ export function hostDirMount(path, hostPath, opts) {
31
31
  * This is the explicit replacement for the removed `moduleAccessCwd` option:
32
32
  * the VM's module resolver reads the mounted tree through the kernel VFS, so the
33
33
  * caller supplies exactly the `node_modules` directory whose packages should be
34
- * resolvable in the guest (e.g. the agent SDK + its transitive deps).
34
+ * resolvable in the guest (e.g. a guest library and its transitive deps).
35
35
  *
36
36
  * @param hostNodeModulesDir Absolute host path to a `node_modules` directory.
37
37
  * @param opts.readOnly Defaults to `true`; the mount is read-only.
@@ -1,4 +1,6 @@
1
- import type { JsonValue } from "./session-api.js";
1
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
2
+ [key: string]: JsonValue;
3
+ };
2
4
  export type ExecutionSignal = "SIGHUP" | "SIGINT" | "SIGQUIT" | "SIGTERM" | "SIGKILL" | "SIGSTOP" | "SIGCONT" | "SIGUSR1" | "SIGUSR2";
3
5
  export interface LanguageExecutionOptions {
4
6
  contextId?: string;
@@ -168,8 +170,10 @@ export interface ProcessOutputEvent<TChunk = Uint8Array> {
168
170
  export interface OutputReplay<TChunk = Uint8Array> {
169
171
  pid: number;
170
172
  events: ProcessOutputEvent<TChunk>[];
171
- nextCursor: string;
173
+ nextCursor: number | null;
172
174
  hasMore: boolean;
173
175
  truncated: boolean;
176
+ /** Sidecar-confirmed exit, or null while completion is not known. */
177
+ exitCode: number | null;
174
178
  }
175
179
  export {};
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod/v4";
2
- import type { AgentExitHandler, AgentOsOptions, AgentStderrHandler, LimitWarningHandler, NativeMountConfig } from "./agent-os.js";
2
+ import type { AgentOsOptions, LimitWarningHandler, NativeMountConfig } from "./agent-os.js";
3
3
  import type { HostFunction, HostFunctionCollection, HostFunctionCollections } from "@rivet-dev/agentos-runtime-core/host-functions";
4
4
  export declare const permissionsSchema: z.ZodObject<{
5
5
  fs: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
@@ -106,6 +106,9 @@ export declare const permissionsSchema: z.ZodObject<{
106
106
  }, z.core.$strict>]>>;
107
107
  }, z.core.$strict>;
108
108
  export declare const agentOsLimitsSchema: z.ZodObject<{
109
+ agentosPackages: z.ZodOptional<z.ZodObject<{
110
+ maxMounts: z.ZodOptional<z.ZodNumber>;
111
+ }, z.core.$strict>>;
109
112
  resources: z.ZodOptional<z.ZodObject<{
110
113
  cpuCount: z.ZodOptional<z.ZodNumber>;
111
114
  maxProcesses: z.ZodOptional<z.ZodNumber>;
@@ -148,26 +151,6 @@ export declare const agentOsLimitsSchema: z.ZodObject<{
148
151
  maxPersistedManifestBytes: z.ZodOptional<z.ZodNumber>;
149
152
  maxPersistedManifestFileBytes: z.ZodOptional<z.ZodNumber>;
150
153
  }, z.core.$strict>>;
151
- acp: z.ZodOptional<z.ZodObject<{
152
- maxReadLineBytes: z.ZodOptional<z.ZodNumber>;
153
- stdoutBufferByteLimit: z.ZodOptional<z.ZodNumber>;
154
- maxCompletedMessageBytes: z.ZodOptional<z.ZodNumber>;
155
- maxTurnOutputBytes: z.ZodOptional<z.ZodNumber>;
156
- maxPromptBytes: z.ZodOptional<z.ZodNumber>;
157
- maxPromptBlocks: z.ZodOptional<z.ZodNumber>;
158
- maxFallbackContinuationBytes: z.ZodOptional<z.ZodNumber>;
159
- maxSessionHistoryBytes: z.ZodOptional<z.ZodNumber>;
160
- maxSessionHistoryEvents: z.ZodOptional<z.ZodNumber>;
161
- maxHistoryPageEntries: z.ZodOptional<z.ZodNumber>;
162
- maxSessionListEntries: z.ZodOptional<z.ZodNumber>;
163
- maxSessionsPerVm: z.ZodOptional<z.ZodNumber>;
164
- maxPromptsPerSession: z.ZodOptional<z.ZodNumber>;
165
- maxPromptsPerVm: z.ZodOptional<z.ZodNumber>;
166
- maxPendingPermissionsPerSession: z.ZodOptional<z.ZodNumber>;
167
- maxPendingPermissionsPerVm: z.ZodOptional<z.ZodNumber>;
168
- maxPermissionOutcomesPerSession: z.ZodOptional<z.ZodNumber>;
169
- maxPermissionOutcomesPerVm: z.ZodOptional<z.ZodNumber>;
170
- }, z.core.$strict>>;
171
154
  sqlite: z.ZodOptional<z.ZodObject<{
172
155
  maxResultBytes: z.ZodOptional<z.ZodNumber>;
173
156
  }, z.core.$strict>>;
@@ -311,18 +294,16 @@ export declare const agentOsOptionFieldSchemas: {
311
294
  members: z.ZodArray<z.ZodString>;
312
295
  }, z.core.$strict>>>;
313
296
  }, z.core.$strict>>;
297
+ readonly environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
314
298
  readonly software: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
315
299
  readonly defaultSoftware: z.ZodOptional<z.ZodBoolean>;
316
300
  readonly loopbackExemptPorts: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
317
301
  readonly allowedNodeBuiltins: z.ZodOptional<z.ZodArray<z.ZodString>>;
318
302
  readonly highResolutionTime: z.ZodOptional<z.ZodBoolean>;
319
- readonly database: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
320
- type: z.ZodLiteral<"actor_uds">;
321
- path: z.ZodString;
322
- }, z.core.$strict>, z.ZodObject<{
303
+ readonly database: z.ZodOptional<z.ZodObject<{
323
304
  type: z.ZodLiteral<"sqlite_file">;
324
305
  path: z.ZodString;
325
- }, z.core.$strict>], "type">>;
306
+ }, z.core.$strict>>;
326
307
  readonly rootFilesystem: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
327
308
  type: z.ZodOptional<z.ZodLiteral<"overlay">>;
328
309
  mode: z.ZodOptional<z.ZodEnum<{
@@ -482,6 +463,9 @@ export declare const agentOsOptionFieldSchemas: {
482
463
  handle: z.ZodUnknown;
483
464
  }, z.core.$strict>]>>;
484
465
  readonly limits: z.ZodOptional<z.ZodObject<{
466
+ agentosPackages: z.ZodOptional<z.ZodObject<{
467
+ maxMounts: z.ZodOptional<z.ZodNumber>;
468
+ }, z.core.$strict>>;
485
469
  resources: z.ZodOptional<z.ZodObject<{
486
470
  cpuCount: z.ZodOptional<z.ZodNumber>;
487
471
  maxProcesses: z.ZodOptional<z.ZodNumber>;
@@ -524,26 +508,6 @@ export declare const agentOsOptionFieldSchemas: {
524
508
  maxPersistedManifestBytes: z.ZodOptional<z.ZodNumber>;
525
509
  maxPersistedManifestFileBytes: z.ZodOptional<z.ZodNumber>;
526
510
  }, z.core.$strict>>;
527
- acp: z.ZodOptional<z.ZodObject<{
528
- maxReadLineBytes: z.ZodOptional<z.ZodNumber>;
529
- stdoutBufferByteLimit: z.ZodOptional<z.ZodNumber>;
530
- maxCompletedMessageBytes: z.ZodOptional<z.ZodNumber>;
531
- maxTurnOutputBytes: z.ZodOptional<z.ZodNumber>;
532
- maxPromptBytes: z.ZodOptional<z.ZodNumber>;
533
- maxPromptBlocks: z.ZodOptional<z.ZodNumber>;
534
- maxFallbackContinuationBytes: z.ZodOptional<z.ZodNumber>;
535
- maxSessionHistoryBytes: z.ZodOptional<z.ZodNumber>;
536
- maxSessionHistoryEvents: z.ZodOptional<z.ZodNumber>;
537
- maxHistoryPageEntries: z.ZodOptional<z.ZodNumber>;
538
- maxSessionListEntries: z.ZodOptional<z.ZodNumber>;
539
- maxSessionsPerVm: z.ZodOptional<z.ZodNumber>;
540
- maxPromptsPerSession: z.ZodOptional<z.ZodNumber>;
541
- maxPromptsPerVm: z.ZodOptional<z.ZodNumber>;
542
- maxPendingPermissionsPerSession: z.ZodOptional<z.ZodNumber>;
543
- maxPendingPermissionsPerVm: z.ZodOptional<z.ZodNumber>;
544
- maxPermissionOutcomesPerSession: z.ZodOptional<z.ZodNumber>;
545
- maxPermissionOutcomesPerVm: z.ZodOptional<z.ZodNumber>;
546
- }, z.core.$strict>>;
547
511
  sqlite: z.ZodOptional<z.ZodObject<{
548
512
  maxResultBytes: z.ZodOptional<z.ZodNumber>;
549
513
  }, z.core.$strict>>;
@@ -585,8 +549,6 @@ export declare const agentOsOptionFieldSchemas: {
585
549
  pendingEventBytes: z.ZodOptional<z.ZodNumber>;
586
550
  }, z.core.$strict>>;
587
551
  }, z.core.$strict>>;
588
- readonly onAgentStderr: z.ZodOptional<z.ZodCustom<AgentStderrHandler, AgentStderrHandler>>;
589
- readonly onAgentExit: z.ZodOptional<z.ZodCustom<AgentExitHandler, AgentExitHandler>>;
590
552
  readonly onLimitWarning: z.ZodOptional<z.ZodCustom<LimitWarningHandler, LimitWarningHandler>>;
591
553
  };
592
554
  export declare const agentOsOptionsSchema: z.ZodType<AgentOsOptions>;
@@ -90,6 +90,10 @@ export const permissionsSchema = z
90
90
  .strict();
91
91
  export const agentOsLimitsSchema = z
92
92
  .object({
93
+ agentosPackages: z
94
+ .object({ maxMounts: positiveInteger.optional() })
95
+ .strict()
96
+ .optional(),
93
97
  resources: z
94
98
  .object({
95
99
  cpuCount: positiveInteger.optional(),
@@ -143,29 +147,6 @@ export const agentOsLimitsSchema = z
143
147
  })
144
148
  .strict()
145
149
  .optional(),
146
- acp: z
147
- .object({
148
- maxReadLineBytes: positiveInteger.optional(),
149
- stdoutBufferByteLimit: positiveInteger.optional(),
150
- maxCompletedMessageBytes: positiveInteger.optional(),
151
- maxTurnOutputBytes: positiveInteger.optional(),
152
- maxPromptBytes: positiveInteger.optional(),
153
- maxPromptBlocks: positiveInteger.optional(),
154
- maxFallbackContinuationBytes: positiveInteger.optional(),
155
- maxSessionHistoryBytes: positiveInteger.optional(),
156
- maxSessionHistoryEvents: positiveInteger.optional(),
157
- maxHistoryPageEntries: positiveInteger.optional(),
158
- maxSessionListEntries: positiveInteger.optional(),
159
- maxSessionsPerVm: positiveInteger.optional(),
160
- maxPromptsPerSession: positiveInteger.optional(),
161
- maxPromptsPerVm: positiveInteger.optional(),
162
- maxPendingPermissionsPerSession: positiveInteger.optional(),
163
- maxPendingPermissionsPerVm: positiveInteger.optional(),
164
- maxPermissionOutcomesPerSession: positiveInteger.optional(),
165
- maxPermissionOutcomesPerVm: positiveInteger.optional(),
166
- })
167
- .strict()
168
- .optional(),
169
150
  sqlite: z
170
151
  .object({ maxResultBytes: positiveInteger.optional() })
171
152
  .strict()
@@ -346,26 +327,18 @@ export const hostFunctionsSchema = z.record(z.string(), hostFunctionCollectionSc
346
327
  */
347
328
  export const agentOsOptionFieldSchemas = {
348
329
  user: vmUserConfigSchema.optional(),
330
+ environment: z.record(z.string(), z.string()).optional(),
349
331
  software: z.array(z.unknown()).optional(),
350
332
  defaultSoftware: z.boolean().optional(),
351
333
  loopbackExemptPorts: z.array(z.number().int().min(0).max(65535)).optional(),
352
334
  allowedNodeBuiltins: stringArray.optional(),
353
335
  highResolutionTime: z.boolean().optional(),
354
336
  database: z
355
- .discriminatedUnion("type", [
356
- z
357
- .object({
358
- type: z.literal("actor_uds"),
359
- path: z.string().min(1),
360
- })
361
- .strict(),
362
- z
363
- .object({
364
- type: z.literal("sqlite_file"),
365
- path: z.string().min(1),
366
- })
367
- .strict(),
368
- ])
337
+ .object({
338
+ type: z.literal("sqlite_file"),
339
+ path: z.string().min(1),
340
+ })
341
+ .strict()
369
342
  .optional(),
370
343
  rootFilesystem: rootFilesystemConfigSchema.optional(),
371
344
  mounts: z.array(mountConfigSchema).optional(),
@@ -382,16 +355,6 @@ export const agentOsOptionFieldSchemas = {
382
355
  permissions: permissionsSchema.optional(),
383
356
  sidecar: sidecarConfigSchema.optional(),
384
357
  limits: agentOsLimitsSchema.optional(),
385
- onAgentStderr: z
386
- .custom((value) => typeof value === "function", {
387
- message: "Expected function",
388
- })
389
- .optional(),
390
- onAgentExit: z
391
- .custom((value) => typeof value === "function", {
392
- message: "Expected function",
393
- })
394
- .optional(),
395
358
  onLimitWarning: z
396
359
  .custom((value) => typeof value === "function", {
397
360
  message: "Expected function",
@@ -0,0 +1,18 @@
1
+ import type { OutputReplay, ProcessOutputEvent } from "./language-execution.js";
2
+ export declare const REPLAY_PAGE_EVENT_LIMIT = 256;
3
+ export declare const REPLAY_PAGE_BYTE_LIMIT: number;
4
+ export interface ReplayReadOptions {
5
+ after?: number;
6
+ maxEvents?: number;
7
+ maxBytes?: number;
8
+ }
9
+ /** Zero is a wire-only omission sentinel, never an accepted public bound. */
10
+ export declare function replayWirePageLimits(options: ReplayReadOptions): {
11
+ maxEvents: number;
12
+ maxBytes: number;
13
+ };
14
+ export declare function replayPageLimits(options: ReplayReadOptions): {
15
+ maxEvents: number;
16
+ maxBytes: number;
17
+ };
18
+ export declare function replayPage(pid: number, source: readonly ProcessOutputEvent[], options: ReplayReadOptions, truncatedBefore?: number, sourceHasMore?: boolean): OutputReplay;
@@ -0,0 +1,75 @@
1
+ export const REPLAY_PAGE_EVENT_LIMIT = 256;
2
+ export const REPLAY_PAGE_BYTE_LIMIT = 768 * 1024;
3
+ const MAX_WIRE_PAGE_VALUE = 0xffff_ffff;
4
+ /** Zero is a wire-only omission sentinel, never an accepted public bound. */
5
+ export function replayWirePageLimits(options) {
6
+ replayPageLimits(options);
7
+ return { maxEvents: options.maxEvents ?? 0, maxBytes: options.maxBytes ?? 0 };
8
+ }
9
+ function limitError(field, requested, limit, message) {
10
+ return Object.assign(new Error(message ??
11
+ `process.readOutput ${field} requested ${requested}; supported range is 1..=${limit}`), {
12
+ code: "ERR_AGENTOS_RESOURCE_LIMIT",
13
+ operation: "process.output.read",
14
+ limitName: field === "maxBytes"
15
+ ? "output_replay_page_bytes"
16
+ : "output_replay_page_events",
17
+ configuredLimit: limit,
18
+ requested,
19
+ configurationPath: field,
20
+ unit: field === "maxBytes" ? "bytes" : "events",
21
+ scope: "vm",
22
+ retryable: message !== undefined,
23
+ });
24
+ }
25
+ export function replayPageLimits(options) {
26
+ if (options.after !== undefined &&
27
+ (!Number.isSafeInteger(options.after) || options.after < 0)) {
28
+ throw Object.assign(new Error("invalid_input: output cursor must be a non-negative safe integer"), { code: "invalid_input" });
29
+ }
30
+ const maxEvents = options.maxEvents ?? REPLAY_PAGE_EVENT_LIMIT;
31
+ const maxBytes = options.maxBytes ?? REPLAY_PAGE_BYTE_LIMIT;
32
+ for (const [field, value] of [
33
+ ["maxEvents", maxEvents],
34
+ ["maxBytes", maxBytes],
35
+ ]) {
36
+ if (!Number.isSafeInteger(value) ||
37
+ value < 1 ||
38
+ value > MAX_WIRE_PAGE_VALUE)
39
+ throw limitError(field, value, MAX_WIRE_PAGE_VALUE);
40
+ }
41
+ return { maxEvents, maxBytes };
42
+ }
43
+ export function replayPage(pid, source, options, truncatedBefore, sourceHasMore = false) {
44
+ const { maxEvents, maxBytes } = replayPageLimits(options);
45
+ const events = [];
46
+ let bytes = 0;
47
+ let hasMore = sourceHasMore;
48
+ let nextCursor = options.after ?? null;
49
+ let gap = truncatedBefore;
50
+ for (const event of source) {
51
+ if (options.after !== undefined && event.sequence <= options.after)
52
+ continue;
53
+ if (events.length === maxEvents ||
54
+ bytes + event.chunk.byteLength > maxBytes) {
55
+ if (events.length === 0)
56
+ throw limitError("maxBytes", event.chunk.byteLength, maxBytes, `process.output.read next retained event requires ${event.chunk.byteLength} bytes, exceeding maxBytes=${maxBytes}; raise maxBytes to at least ${event.chunk.byteLength}`);
57
+ hasMore = true;
58
+ break;
59
+ }
60
+ bytes += event.chunk.byteLength;
61
+ events.push({ ...event, chunk: event.chunk.slice() });
62
+ nextCursor = event.sequence;
63
+ }
64
+ if (!hasMore && gap !== undefined)
65
+ nextCursor = Math.max(nextCursor ?? -1, gap);
66
+ return {
67
+ pid,
68
+ exitCode: null,
69
+ events,
70
+ nextCursor,
71
+ hasMore,
72
+ truncated: gap !== undefined &&
73
+ gap >= (options.after === undefined ? 0 : options.after + 1),
74
+ };
75
+ }
@@ -17,12 +17,3 @@ export interface SoftwareRoot {
17
17
  * the `/opt/agentos` projection.
18
18
  */
19
19
  export declare function defineSoftware<T extends SoftwareEntry>(desc: T): T;
20
- /**
21
- * Resolve the agent-SDK snapshot bundle (an esbuild IIFE at
22
- * `<dir>/dist/sdk-snapshot.js`) for the first snapshot-enabled agent package in
23
- * the software set. Returns its source so it can be evaluated once into the
24
- * per-sidecar V8 startup snapshot (`jsRuntime.snapshotUserlandCode`) and reused
25
- * across sessions. Returns `undefined` when no agent opts in (`agent.snapshot`)
26
- * or the bundle is absent -- the runtime then keeps the per-session import path.
27
- */
28
- export declare function resolveAgentSnapshotBundle(software: SoftwareInput[]): string | undefined;
package/dist/packages.js CHANGED
@@ -1,6 +1,3 @@
1
- import { existsSync, readFileSync, statSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { tryReadAgentosPackageManifest } from "./agentos-package.js";
4
1
  // ── defineSoftware ───────────────────────────────────────────────────
5
2
  /**
6
3
  * Define a software descriptor. A type-safe identity function that validates the
@@ -10,39 +7,3 @@ import { tryReadAgentosPackageManifest } from "./agentos-package.js";
10
7
  export function defineSoftware(desc) {
11
8
  return desc;
12
9
  }
13
- /**
14
- * Resolve the agent-SDK snapshot bundle (an esbuild IIFE at
15
- * `<dir>/dist/sdk-snapshot.js`) for the first snapshot-enabled agent package in
16
- * the software set. Returns its source so it can be evaluated once into the
17
- * per-sidecar V8 startup snapshot (`jsRuntime.snapshotUserlandCode`) and reused
18
- * across sessions. Returns `undefined` when no agent opts in (`agent.snapshot`)
19
- * or the bundle is absent -- the runtime then keeps the per-session import path.
20
- */
21
- export function resolveAgentSnapshotBundle(software) {
22
- const descriptors = software.flat();
23
- for (const entry of descriptors) {
24
- // Only transition package DIRS are readable host-side (their
25
- // agentos-package.json is the toolchain-input manifest). Packed
26
- // `.aospkg` refs carry the bundle inside the mount tar; the sidecar
27
- // reads it from the packed vbare manifest's snapshotBundlePath.
28
- const path = entry.packagePath;
29
- if (path === undefined || !statIsDirectory(path))
30
- continue;
31
- const manifest = tryReadAgentosPackageManifest(path);
32
- if (!manifest?.agent?.snapshot)
33
- continue;
34
- const bundlePath = join(path, "dist", "sdk-snapshot.js");
35
- if (existsSync(bundlePath)) {
36
- return readFileSync(bundlePath, "utf-8");
37
- }
38
- }
39
- return undefined;
40
- }
41
- function statIsDirectory(path) {
42
- try {
43
- return statSync(path).isDirectory();
44
- }
45
- catch {
46
- return false;
47
- }
48
- }
@@ -0,0 +1,7 @@
1
+ /** Internal topology stays separate from public, potentially overlapping display PIDs. */
2
+ export interface ProcessForestRecord<T> {
3
+ info: T;
4
+ key: string;
5
+ parentKey: string | null;
6
+ }
7
+ export declare function buildProcessForest<T, R>(records: ProcessForestRecord<T>[], project: (info: T, children: R[]) => R): R[];