@rivet-dev/agentos 0.2.14 → 0.2.15

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/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import "./chunk-V6TY7KAL.js";
2
2
 
3
3
  // src/index.ts
4
4
  import { setup as rivetkitSetup } from "rivetkit";
5
- import { defineSoftware, nodeModulesMount } from "@rivet-dev/agentos-core";
5
+ export * from "@rivet-dev/agentos-core";
6
6
 
7
7
  // src/actor.ts
8
8
  import crypto from "crypto";
@@ -162,12 +162,12 @@ async function ensureVm(c, options) {
162
162
  });
163
163
  try {
164
164
  for (const row of mountRows) {
165
- await vm.mountFs(
165
+ await vm.filesystem.mount(
166
166
  JSON.parse(row.descriptor_json)
167
167
  );
168
168
  }
169
169
  for (const row of softwareRows) {
170
- await vm.linkSoftware(
170
+ await vm.software.link(
171
171
  JSON.parse(row.descriptor_json)
172
172
  );
173
173
  }
@@ -408,6 +408,76 @@ function releaseFetchStream(c, streamId) {
408
408
  runtime.fetchStreamHolds.get(streamId)?.();
409
409
  runtime.fetchStreamHolds.delete(streamId);
410
410
  }
411
+ function decodeActorData(value) {
412
+ if (value === void 0) return void 0;
413
+ if (typeof value !== "object" || value === null || !("encoding" in value) || !("data" in value)) {
414
+ throw new UserError("stdin must be tagged UTF-8 or base64 actor data", {
415
+ code: "agentos_execution_invalid_actor_data"
416
+ });
417
+ }
418
+ const input = value;
419
+ if (typeof input.data !== "string") {
420
+ throw new UserError("actor data must contain a string", {
421
+ code: "agentos_execution_invalid_actor_data"
422
+ });
423
+ }
424
+ if (input.encoding === "utf8") return input.data;
425
+ if (input.encoding === "base64")
426
+ return new Uint8Array(Buffer.from(input.data, "base64"));
427
+ throw new UserError("actor data encoding must be utf8 or base64", {
428
+ code: "agentos_execution_invalid_actor_data"
429
+ });
430
+ }
431
+ function actorExecutionArgs(args) {
432
+ return args.map((arg) => {
433
+ if (typeof arg !== "object" || arg === null || Array.isArray(arg))
434
+ return arg;
435
+ const options = arg;
436
+ for (const field of ["signal", "onStdout", "onStderr"]) {
437
+ if (options[field] !== void 0) {
438
+ throw new UserError(`${field} is not available on actor actions`, {
439
+ code: "agentos_execution_non_serializable_option"
440
+ });
441
+ }
442
+ }
443
+ const normalized = { ...options };
444
+ if ("stdin" in normalized)
445
+ normalized.stdin = decodeActorData(normalized.stdin);
446
+ return normalized;
447
+ });
448
+ }
449
+ function actorSpawnArgs(options) {
450
+ return options === void 0 ? [] : actorExecutionArgs([options]);
451
+ }
452
+ async function runActorExecution(c, operation, options) {
453
+ const vm = await ensureVm(c, options);
454
+ return c.keepAwake(operation(vm));
455
+ }
456
+ async function runActorSpawn(c, operation, options) {
457
+ const vm = await ensureVm(c, options);
458
+ const process = await operation(vm);
459
+ const unsubscribeOutput = vm.onProcessOutput(
460
+ process.pid,
461
+ (event2) => c.broadcast("processOutput", event2)
462
+ );
463
+ const unsubscribeExit = vm.onProcessExit(
464
+ process.pid,
465
+ (event2) => c.broadcast("processExit", event2)
466
+ );
467
+ void c.keepAwake(
468
+ vm.process.wait(process.pid).finally(() => {
469
+ unsubscribeOutput();
470
+ unsubscribeExit();
471
+ })
472
+ ).catch(
473
+ (error) => c.log.error({
474
+ msg: "agent-os process wait failed",
475
+ pid: process.pid,
476
+ error
477
+ })
478
+ );
479
+ return process;
480
+ }
411
481
  function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubscriptions = DEFAULT_MAX_SESSION_SUBSCRIPTIONS, maxDynamicMounts = DEFAULT_MAX_DYNAMIC_MOUNTS, maxLinkedSoftware = DEFAULT_MAX_LINKED_SOFTWARE) {
412
482
  const defaultPreviewTtlSeconds = preview.defaultExpiresInSeconds ?? DEFAULT_PREVIEW_TTL_SECONDS;
413
483
  const maxPreviewTtlSeconds = preview.maxExpiresInSeconds ?? MAX_PREVIEW_TTL_SECONDS;
@@ -438,10 +508,10 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
438
508
  code: "agentos_linked_software_invalid_config"
439
509
  });
440
510
  }
441
- return {
511
+ const flat = {
442
512
  readFile: async (c, ...args) => {
443
513
  try {
444
- return await (await ensureVm(c, options)).readFile(...args);
514
+ return await (await ensureVm(c, options)).filesystem.readFile(...args);
445
515
  } catch (error) {
446
516
  c.log.error({
447
517
  msg: "agent-os readFile action failed",
@@ -451,56 +521,249 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
451
521
  throw error;
452
522
  }
453
523
  },
454
- writeFile: async (c, ...args) => (await ensureVm(c, options)).writeFile(...args),
455
- readFiles: async (c, ...args) => (await ensureVm(c, options)).readFiles(...args),
456
- writeFiles: async (c, ...args) => (await ensureVm(c, options)).writeFiles(...args),
457
- stat: async (c, ...args) => (await ensureVm(c, options)).stat(...args),
458
- mkdir: async (c, ...args) => (await ensureVm(c, options)).mkdir(...args),
459
- readdir: async (c, ...args) => (await ensureVm(c, options)).readdir(...args),
460
- readdirEntries: async (c, ...args) => (await ensureVm(c, options)).readdirEntries(...args),
461
- readdirRecursive: async (c, ...args) => (await ensureVm(c, options)).readdirRecursive(...args),
462
- exists: async (c, ...args) => (await ensureVm(c, options)).exists(...args),
463
- move: async (c, ...args) => (await ensureVm(c, options)).move(...args),
464
- remove: async (c, ...args) => (await ensureVm(c, options)).remove(...args),
465
- exec: async (c, ...args) => (await ensureVm(c, options)).exec(...args),
466
- execArgv: async (c, ...args) => (await ensureVm(c, options)).execArgv(...args),
467
- spawn: async (c, ...args) => {
468
- const vm = await ensureVm(c, options);
469
- const process = vm.spawn(...args);
470
- const unsubscribeOutput = vm.onProcessOutput(
471
- process.pid,
472
- (event2) => c.broadcast("processOutput", event2)
473
- );
474
- const unsubscribeExit = vm.onProcessExit(
475
- process.pid,
476
- (event2) => c.broadcast("processExit", event2)
524
+ writeFile: async (c, ...args) => (await ensureVm(c, options)).filesystem.writeFile(...args),
525
+ readFiles: async (c, ...args) => (await ensureVm(c, options)).filesystem.readFiles(...args),
526
+ writeFiles: async (c, ...args) => (await ensureVm(c, options)).filesystem.writeFiles(...args),
527
+ stat: async (c, ...args) => (await ensureVm(c, options)).filesystem.stat(...args),
528
+ mkdir: async (c, ...args) => (await ensureVm(c, options)).filesystem.mkdir(...args),
529
+ readdir: async (c, ...args) => (await ensureVm(c, options)).filesystem.readdir(...args),
530
+ readdirEntries: async (c, ...args) => (await ensureVm(c, options)).filesystem.readdirEntries(...args),
531
+ readdirRecursive: async (c, ...args) => (await ensureVm(c, options)).filesystem.readdirRecursive(...args),
532
+ exists: async (c, ...args) => (await ensureVm(c, options)).filesystem.exists(...args),
533
+ move: async (c, ...args) => (await ensureVm(c, options)).filesystem.move(...args),
534
+ remove: async (c, ...args) => (await ensureVm(c, options)).filesystem.remove(...args),
535
+ exec: async (c, command, actorOptions) => runActorExecution(
536
+ c,
537
+ (vm) => vm.process.exec(
538
+ command,
539
+ ...actorExecutionArgs([actorOptions])
540
+ ),
541
+ options
542
+ ),
543
+ execArgv: async (c, command, args = [], actorOptions) => runActorExecution(
544
+ c,
545
+ (vm) => vm.process.execFile(
546
+ command,
547
+ args,
548
+ ...actorExecutionArgs([actorOptions])
549
+ ),
550
+ options
551
+ ),
552
+ spawn: async (c, command, args = [], actorOptions) => runActorSpawn(
553
+ c,
554
+ (vm) => vm.process.spawn(
555
+ command,
556
+ args,
557
+ ...actorSpawnArgs(actorOptions)
558
+ ),
559
+ options
560
+ ),
561
+ createContext: async (c, contextId) => (await ensureVm(c, options)).createContext(contextId),
562
+ executeJavaScript: async (c, source, actorOptions) => runActorExecution(
563
+ c,
564
+ (vm) => vm.javascript.execute(
565
+ source,
566
+ ...actorExecutionArgs([actorOptions])
567
+ ),
568
+ options
569
+ ),
570
+ evaluateJavaScript: async (c, expression, actorOptions) => runActorExecution(
571
+ c,
572
+ (vm) => vm.javascript.evaluate(
573
+ expression,
574
+ ...actorExecutionArgs([actorOptions])
575
+ ),
576
+ options
577
+ ),
578
+ executeJavaScriptFile: async (c, path, actorOptions) => runActorExecution(
579
+ c,
580
+ (vm) => vm.javascript.executeFile(
581
+ path,
582
+ ...actorExecutionArgs([actorOptions])
583
+ ),
584
+ options
585
+ ),
586
+ spawnJavaScript: async (c, source, actorOptions) => runActorSpawn(
587
+ c,
588
+ (vm) => vm.javascript.spawn(
589
+ source,
590
+ ...actorSpawnArgs(actorOptions)
591
+ ),
592
+ options
593
+ ),
594
+ spawnJavaScriptFile: async (c, path, actorOptions) => runActorSpawn(
595
+ c,
596
+ (vm) => vm.javascript.spawnFile(
597
+ path,
598
+ ...actorSpawnArgs(actorOptions)
599
+ ),
600
+ options
601
+ ),
602
+ executeTypeScript: async (c, source, actorOptions) => runActorExecution(
603
+ c,
604
+ (vm) => vm.typescript.execute(
605
+ source,
606
+ ...actorExecutionArgs([actorOptions])
607
+ ),
608
+ options
609
+ ),
610
+ evaluateTypeScript: async (c, expression, actorOptions) => runActorExecution(
611
+ c,
612
+ (vm) => vm.typescript.evaluate(
613
+ expression,
614
+ ...actorExecutionArgs([actorOptions])
615
+ ),
616
+ options
617
+ ),
618
+ executeTypeScriptFile: async (c, path, actorOptions) => runActorExecution(
619
+ c,
620
+ (vm) => vm.typescript.executeFile(
621
+ path,
622
+ ...actorExecutionArgs([actorOptions])
623
+ ),
624
+ options
625
+ ),
626
+ spawnTypeScript: async (c, source, actorOptions) => runActorSpawn(
627
+ c,
628
+ (vm) => vm.typescript.spawn(
629
+ source,
630
+ ...actorSpawnArgs(actorOptions)
631
+ ),
632
+ options
633
+ ),
634
+ spawnTypeScriptFile: async (c, path, actorOptions) => runActorSpawn(
635
+ c,
636
+ (vm) => vm.typescript.spawnFile(
637
+ path,
638
+ ...actorSpawnArgs(actorOptions)
639
+ ),
640
+ options
641
+ ),
642
+ checkTypeScript: async (c, source, actorOptions) => runActorExecution(
643
+ c,
644
+ (vm) => vm.typescript.check(
645
+ source,
646
+ ...actorExecutionArgs([actorOptions])
647
+ ),
648
+ options
649
+ ),
650
+ checkTypeScriptProject: async (c, actorOptions) => runActorExecution(
651
+ c,
652
+ (vm) => vm.typescript.checkProject(
653
+ ...actorExecutionArgs([actorOptions])
654
+ ),
655
+ options
656
+ ),
657
+ installNpmPackages: async (c, ...args) => runActorExecution(
658
+ c,
659
+ (vm) => vm.javascript.npm.install(...actorExecutionArgs(args)),
660
+ options
661
+ ),
662
+ executeNpmScript: async (c, script, actorOptions) => runActorExecution(
663
+ c,
664
+ (vm) => vm.javascript.npm.runScript(
665
+ script,
666
+ ...actorExecutionArgs([actorOptions])
667
+ ),
668
+ options
669
+ ),
670
+ executeNpmPackage: async (c, packageSpec, actorOptions) => runActorExecution(
671
+ c,
672
+ (vm) => vm.javascript.npm.runPackage(
673
+ packageSpec,
674
+ ...actorExecutionArgs([actorOptions])
675
+ ),
676
+ options
677
+ ),
678
+ executePython: async (c, source, actorOptions) => runActorExecution(
679
+ c,
680
+ (vm) => vm.python.execute(
681
+ source,
682
+ ...actorExecutionArgs([actorOptions])
683
+ ),
684
+ options
685
+ ),
686
+ evaluatePython: async (c, expression, actorOptions) => runActorExecution(
687
+ c,
688
+ (vm) => vm.python.evaluate(
689
+ expression,
690
+ ...actorExecutionArgs([actorOptions])
691
+ ),
692
+ options
693
+ ),
694
+ executePythonFile: async (c, path, actorOptions) => runActorExecution(
695
+ c,
696
+ (vm) => vm.python.executeFile(
697
+ path,
698
+ ...actorExecutionArgs([actorOptions])
699
+ ),
700
+ options
701
+ ),
702
+ executePythonModule: async (c, module, actorOptions) => runActorExecution(
703
+ c,
704
+ (vm) => vm.python.executeModule(
705
+ module,
706
+ ...actorExecutionArgs([actorOptions])
707
+ ),
708
+ options
709
+ ),
710
+ spawnPython: async (c, source, actorOptions) => runActorSpawn(
711
+ c,
712
+ (vm) => vm.python.spawn(source, ...actorSpawnArgs(actorOptions)),
713
+ options
714
+ ),
715
+ spawnPythonFile: async (c, path, actorOptions) => runActorSpawn(
716
+ c,
717
+ (vm) => vm.python.spawnFile(
718
+ path,
719
+ ...actorSpawnArgs(actorOptions)
720
+ ),
721
+ options
722
+ ),
723
+ spawnPythonModule: async (c, module, actorOptions) => runActorSpawn(
724
+ c,
725
+ (vm) => vm.python.spawnModule(
726
+ module,
727
+ ...actorSpawnArgs(actorOptions)
728
+ ),
729
+ options
730
+ ),
731
+ installPythonPackages: async (c, ...args) => runActorExecution(
732
+ c,
733
+ (vm) => vm.python.install(...actorExecutionArgs(args)),
734
+ options
735
+ ),
736
+ getContext: async (c, ...args) => (await ensureVm(c, options)).contexts.get(...args),
737
+ listContexts: async (c) => (await ensureVm(c, options)).contexts.list(),
738
+ resetContext: async (c, ...args) => (await ensureVm(c, options)).contexts.reset(...args),
739
+ deleteContext: async (c, ...args) => (await ensureVm(c, options)).contexts.delete(...args),
740
+ waitProcess: async (c, ...args) => (await ensureVm(c, options)).process.wait(...args),
741
+ killProcess: async (c, ...args) => (await ensureVm(c, options)).process.kill(...args),
742
+ signalProcess: async (c, ...args) => (await ensureVm(c, options)).process.signal(...args),
743
+ listProcesses: async (c) => (await ensureVm(c, options)).process.list(),
744
+ processTree: async (c) => (await ensureVm(c, options)).process.tree(),
745
+ getProcess: async (c, ...args) => (await ensureVm(c, options)).process.get(...args),
746
+ writeProcessStdin: async (c, ...args) => (await ensureVm(c, options)).process.writeStdin(...args),
747
+ closeProcessStdin: async (c, ...args) => (await ensureVm(c, options)).process.closeStdin(...args),
748
+ resizeProcessPty: async (c, ...args) => (await ensureVm(c, options)).process.resizePty(...args),
749
+ readProcessOutput: async (c, ...args) => {
750
+ const replay = await (await ensureVm(c, options)).process.readOutput(
751
+ ...args
477
752
  );
478
- void c.keepAwake(
479
- vm.waitProcess(process.pid).finally(() => {
480
- unsubscribeOutput();
481
- unsubscribeExit();
482
- })
483
- ).catch(
484
- (error) => c.log.error({
485
- msg: "agent-os process wait failed",
486
- pid: process.pid,
487
- error
488
- })
489
- );
490
- return process;
753
+ return {
754
+ ...replay,
755
+ events: replay.events.map((event2) => ({
756
+ ...event2,
757
+ chunk: {
758
+ encoding: "base64",
759
+ data: Buffer.from(event2.chunk).toString("base64")
760
+ }
761
+ }))
762
+ };
491
763
  },
492
- waitProcess: async (c, ...args) => (await ensureVm(c, options)).waitProcess(...args),
493
- killProcess: async (c, ...args) => (await ensureVm(c, options)).killProcess(...args),
494
- stopProcess: async (c, ...args) => (await ensureVm(c, options)).stopProcess(...args),
495
- listProcesses: async (c) => (await ensureVm(c, options)).listProcesses(),
496
- allProcesses: async (c) => (await ensureVm(c, options)).allProcesses(),
497
- processTree: async (c) => (await ensureVm(c, options)).processTree(),
498
- getProcess: async (c, ...args) => (await ensureVm(c, options)).getProcess(...args),
499
- writeProcessStdin: async (c, ...args) => (await ensureVm(c, options)).writeProcessStdin(...args),
500
- closeProcessStdin: async (c, ...args) => (await ensureVm(c, options)).closeProcessStdin(...args),
501
764
  openShell: async (c, ...args) => {
502
765
  const vm = await ensureVm(c, options);
503
- const shell = vm.openShell(...args);
766
+ const shell = vm.terminal.open(...args);
504
767
  const unsubscribeData = vm.onShellData(
505
768
  shell.shellId,
506
769
  (event2) => c.broadcast("shellData", event2)
@@ -514,7 +777,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
514
777
  (event2) => c.broadcast("shellExit", event2)
515
778
  );
516
779
  void c.keepAwake(
517
- vm.waitShell(shell.shellId).finally(() => {
780
+ vm.terminal.wait(shell.shellId).finally(() => {
518
781
  unsubscribeData();
519
782
  unsubscribeStderr();
520
783
  unsubscribeExit();
@@ -528,11 +791,11 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
528
791
  );
529
792
  return shell;
530
793
  },
531
- writeShell: async (c, ...args) => (await ensureVm(c, options)).writeShell(...args),
532
- resizeShell: async (c, ...args) => (await ensureVm(c, options)).resizeShell(...args),
533
- closeShell: async (c, ...args) => (await ensureVm(c, options)).closeShell(...args),
534
- waitShell: async (c, ...args) => (await ensureVm(c, options)).waitShell(...args),
535
- httpRequest: async (c, ...args) => (await ensureVm(c, options)).httpRequest(...args),
794
+ writeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.write(...args),
795
+ resizeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.resize(...args),
796
+ closeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.close(...args),
797
+ waitShell: async (c, ...args) => (await ensureVm(c, options)).terminal.wait(...args),
798
+ httpRequest: async (c, ...args) => (await ensureVm(c, options)).network.httpRequest(...args),
536
799
  vmFetch: async (c, port, url, requestOptions) => {
537
800
  const vm = await ensureVm(c, options);
538
801
  const body = requestOptions?.body instanceof Uint8Array ? Buffer.from(requestOptions.body) : requestOptions?.body;
@@ -598,18 +861,18 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
598
861
  }
599
862
  },
600
863
  scheduleCron: async (c, cronOptions) => {
601
- const job = (await ensureVm(c, options)).scheduleCron(
864
+ const job = (await ensureVm(c, options)).cron.schedule(
602
865
  cronOptions
603
866
  );
604
867
  return { id: job.id };
605
868
  },
606
- listCronJobs: async (c) => (await ensureVm(c, options)).listCronJobs(),
607
- cancelCronJob: async (c, ...args) => (await ensureVm(c, options)).cancelCronJob(...args),
608
- listAgents: async (c) => (await ensureVm(c, options)).listAgents(),
869
+ listCronJobs: async (c) => (await ensureVm(c, options)).cron.list(),
870
+ cancelCronJob: async (c, ...args) => (await ensureVm(c, options)).cron.cancel(...args),
871
+ listAgents: async (c) => (await ensureVm(c, options)).agents.list(),
609
872
  openSession: async (c, input) => {
610
873
  const vm = await ensureVm(c, options);
611
874
  try {
612
- await vm.openSession(input);
875
+ await vm.sessions.open(input);
613
876
  } catch (error) {
614
877
  const message = error instanceof Error ? error.message : String(error);
615
878
  const causeCode = typeof error?.code === "string" ? error.code : void 0;
@@ -633,15 +896,19 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
633
896
  maxSessionSubscriptions
634
897
  );
635
898
  },
636
- getSession: async (c, ...args) => (await ensureVm(c, options)).getSession(...args),
637
- listSessions: async (c, ...args) => (await ensureVm(c, options)).listSessions(...args),
899
+ getSession: async (c, ...args) => (await ensureVm(c, options)).sessions.get(...args),
900
+ listSessions: async (c, ...args) => (await ensureVm(c, options)).sessions.list(...args),
638
901
  deleteSession: async (c, ...args) => {
639
- const result = await (await ensureVm(c, options)).deleteSession(...args);
902
+ const result = await (await ensureVm(c, options)).sessions.delete(
903
+ ...args
904
+ );
640
905
  untrackSessionEvents(c, args[0]?.sessionId ?? "main");
641
906
  return result;
642
907
  },
643
908
  unloadSession: async (c, ...args) => {
644
- const result = await (await ensureVm(c, options)).unloadSession(...args);
909
+ const result = await (await ensureVm(c, options)).sessions.unload(
910
+ ...args
911
+ );
645
912
  untrackSessionEvents(c, args[0]?.sessionId ?? "main");
646
913
  return result;
647
914
  },
@@ -650,7 +917,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
650
917
  const sessionId = input.sessionId ?? "main";
651
918
  trackSessionEvents(c, vm, sessionId, hooks, maxSessionSubscriptions);
652
919
  try {
653
- return await c.keepAwake(vm.prompt(input));
920
+ return await c.keepAwake(vm.sessions.prompt(input));
654
921
  } catch (error) {
655
922
  const message = error instanceof Error ? error.message : String(error);
656
923
  const causeCode = typeof error?.code === "string" ? error.code : void 0;
@@ -666,13 +933,13 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
666
933
  });
667
934
  }
668
935
  },
669
- cancelPrompt: async (c, ...args) => (await ensureVm(c, options)).cancelPrompt(...args),
670
- respondPermission: async (c, ...args) => (await ensureVm(c, options)).respondPermission(...args),
671
- readHistory: async (c, ...args) => (await ensureVm(c, options)).readHistory(...args),
672
- getSessionConfig: async (c, ...args) => (await ensureVm(c, options)).getSessionConfig(...args),
673
- setSessionConfigOption: async (c, ...args) => (await ensureVm(c, options)).setSessionConfigOption(...args),
674
- getSessionCapabilities: async (c, ...args) => (await ensureVm(c, options)).getSessionCapabilities(...args),
675
- getSessionAgentInfo: async (c, ...args) => (await ensureVm(c, options)).getSessionAgentInfo(...args),
936
+ cancelPrompt: async (c, ...args) => (await ensureVm(c, options)).sessions.cancelPrompt(...args),
937
+ respondPermission: async (c, ...args) => (await ensureVm(c, options)).sessions.respondPermission(...args),
938
+ readHistory: async (c, ...args) => (await ensureVm(c, options)).sessions.readHistory(...args),
939
+ getSessionConfig: async (c, ...args) => (await ensureVm(c, options)).sessions.getConfig(...args),
940
+ setSessionConfigOption: async (c, ...args) => (await ensureVm(c, options)).sessions.setConfigOption(...args),
941
+ getSessionCapabilities: async (c, ...args) => (await ensureVm(c, options)).sessions.getCapabilities(...args),
942
+ getSessionAgentInfo: async (c, ...args) => (await ensureVm(c, options)).sessions.getAgentInfo(...args),
676
943
  createPreviewUrl: async (c, port, ttlSeconds = defaultPreviewTtlSeconds) => {
677
944
  if (!Number.isInteger(port) || port < 1 || port > 65535)
678
945
  throw new UserError(
@@ -728,7 +995,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
728
995
  token
729
996
  );
730
997
  },
731
- exportRootFilesystem: async (c, ...args) => (await ensureVm(c, options)).exportRootFilesystem(...args),
998
+ exportRootFilesystem: async (c, ...args) => (await ensureVm(c, options)).filesystem.export(...args),
732
999
  mountFs: async (c, descriptor) => {
733
1000
  await assertActorCollectionCapacity(
734
1001
  c,
@@ -739,7 +1006,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
739
1006
  "maxDynamicMounts"
740
1007
  );
741
1008
  const vm = await ensureVm(c, options);
742
- await vm.mountFs(descriptor);
1009
+ await vm.filesystem.mount(descriptor);
743
1010
  try {
744
1011
  await c.db.execute(
745
1012
  "INSERT INTO agentos_actor_dynamic_mounts (path, descriptor_json) VALUES (?, ?) ON CONFLICT(path) DO UPDATE SET descriptor_json = excluded.descriptor_json",
@@ -748,7 +1015,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
748
1015
  );
749
1016
  } catch (error) {
750
1017
  try {
751
- await vm.unmountFs(descriptor.path);
1018
+ await vm.filesystem.unmount(descriptor.path);
752
1019
  } catch (rollbackError) {
753
1020
  c.log.error({
754
1021
  msg: "agent-os dynamic mount rollback failed",
@@ -765,7 +1032,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
765
1032
  path
766
1033
  );
767
1034
  const vm = await ensureVm(c, options);
768
- await vm.unmountFs(path);
1035
+ await vm.filesystem.unmount(path);
769
1036
  try {
770
1037
  await c.db.execute(
771
1038
  "DELETE FROM agentos_actor_dynamic_mounts WHERE path = ?",
@@ -774,7 +1041,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
774
1041
  } catch (error) {
775
1042
  if (rows[0]) {
776
1043
  try {
777
- await vm.mountFs(
1044
+ await vm.filesystem.mount(
778
1045
  JSON.parse(rows[0].descriptor_json)
779
1046
  );
780
1047
  } catch (rollbackError) {
@@ -788,8 +1055,8 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
788
1055
  throw error;
789
1056
  }
790
1057
  },
791
- listMounts: async (c) => (await ensureVm(c, options)).listMounts(),
792
- listSoftware: async (c) => (await ensureVm(c, options)).listSoftware(),
1058
+ listMounts: async (c) => (await ensureVm(c, options)).filesystem.listMounts(),
1059
+ listSoftware: async (c) => (await ensureVm(c, options)).software.list(),
793
1060
  linkSoftware: async (c, descriptor) => {
794
1061
  await assertActorCollectionCapacity(
795
1062
  c,
@@ -805,7 +1072,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
805
1072
  JSON.stringify(descriptor)
806
1073
  );
807
1074
  try {
808
- await (await ensureVm(c, options)).linkSoftware(descriptor);
1075
+ await (await ensureVm(c, options)).software.link(descriptor);
809
1076
  } catch (error) {
810
1077
  try {
811
1078
  await c.db.execute(
@@ -823,6 +1090,179 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
823
1090
  }
824
1091
  }
825
1092
  };
1093
+ const nested = {
1094
+ createContext: flat.createContext,
1095
+ process: {
1096
+ exec: flat.exec,
1097
+ execFile: flat.execArgv,
1098
+ spawn: flat.spawn,
1099
+ get: flat.getProcess,
1100
+ list: flat.listProcesses,
1101
+ tree: flat.processTree,
1102
+ wait: flat.waitProcess,
1103
+ signal: flat.signalProcess,
1104
+ kill: flat.killProcess,
1105
+ writeStdin: flat.writeProcessStdin,
1106
+ closeStdin: flat.closeProcessStdin,
1107
+ resizePty: flat.resizeProcessPty,
1108
+ readOutput: flat.readProcessOutput
1109
+ },
1110
+ javascript: {
1111
+ execute: flat.executeJavaScript,
1112
+ evaluate: flat.evaluateJavaScript,
1113
+ executeFile: flat.executeJavaScriptFile,
1114
+ spawn: flat.spawnJavaScript,
1115
+ spawnFile: flat.spawnJavaScriptFile,
1116
+ npm: {
1117
+ install: flat.installNpmPackages,
1118
+ runScript: flat.executeNpmScript,
1119
+ runPackage: flat.executeNpmPackage
1120
+ }
1121
+ },
1122
+ typescript: {
1123
+ execute: flat.executeTypeScript,
1124
+ evaluate: flat.evaluateTypeScript,
1125
+ executeFile: flat.executeTypeScriptFile,
1126
+ spawn: flat.spawnTypeScript,
1127
+ spawnFile: flat.spawnTypeScriptFile,
1128
+ check: flat.checkTypeScript,
1129
+ checkProject: flat.checkTypeScriptProject
1130
+ },
1131
+ python: {
1132
+ execute: flat.executePython,
1133
+ evaluate: flat.evaluatePython,
1134
+ executeFile: flat.executePythonFile,
1135
+ executeModule: flat.executePythonModule,
1136
+ spawn: flat.spawnPython,
1137
+ spawnFile: flat.spawnPythonFile,
1138
+ spawnModule: flat.spawnPythonModule,
1139
+ install: flat.installPythonPackages
1140
+ },
1141
+ contexts: {
1142
+ get: flat.getContext,
1143
+ list: flat.listContexts,
1144
+ reset: flat.resetContext,
1145
+ delete: flat.deleteContext
1146
+ },
1147
+ terminal: {
1148
+ open: flat.openShell,
1149
+ write: flat.writeShell,
1150
+ resize: flat.resizeShell,
1151
+ wait: flat.waitShell,
1152
+ close: flat.closeShell
1153
+ },
1154
+ filesystem: {
1155
+ readFile: flat.readFile,
1156
+ writeFile: flat.writeFile,
1157
+ readFiles: flat.readFiles,
1158
+ writeFiles: flat.writeFiles,
1159
+ stat: flat.stat,
1160
+ mkdir: flat.mkdir,
1161
+ readdir: flat.readdir,
1162
+ readdirEntries: flat.readdirEntries,
1163
+ readdirRecursive: flat.readdirRecursive,
1164
+ exists: flat.exists,
1165
+ move: flat.move,
1166
+ remove: flat.remove,
1167
+ export: flat.exportRootFilesystem,
1168
+ mount: flat.mountFs,
1169
+ unmount: flat.unmountFs,
1170
+ listMounts: flat.listMounts
1171
+ },
1172
+ network: {
1173
+ httpRequest: flat.httpRequest
1174
+ },
1175
+ software: {
1176
+ list: flat.listSoftware,
1177
+ link: flat.linkSoftware
1178
+ },
1179
+ agents: {
1180
+ list: flat.listAgents
1181
+ },
1182
+ sessions: {
1183
+ open: flat.openSession,
1184
+ get: flat.getSession,
1185
+ list: flat.listSessions,
1186
+ delete: flat.deleteSession,
1187
+ unload: flat.unloadSession,
1188
+ prompt: flat.prompt,
1189
+ cancelPrompt: flat.cancelPrompt,
1190
+ respondPermission: flat.respondPermission,
1191
+ readHistory: flat.readHistory,
1192
+ getConfig: flat.getSessionConfig,
1193
+ setConfigOption: flat.setSessionConfigOption,
1194
+ getCapabilities: flat.getSessionCapabilities,
1195
+ getAgentInfo: flat.getSessionAgentInfo
1196
+ },
1197
+ cron: {
1198
+ schedule: flat.scheduleCron,
1199
+ list: flat.listCronJobs,
1200
+ cancel: flat.cancelCronJob
1201
+ }
1202
+ };
1203
+ return {
1204
+ ...nested,
1205
+ // Legacy flat actions from the pre-language-execution API. Keep these
1206
+ // as aliases to the canonical nested handlers.
1207
+ readFile: nested.filesystem.readFile,
1208
+ writeFile: nested.filesystem.writeFile,
1209
+ readFiles: nested.filesystem.readFiles,
1210
+ writeFiles: nested.filesystem.writeFiles,
1211
+ stat: nested.filesystem.stat,
1212
+ mkdir: nested.filesystem.mkdir,
1213
+ readdir: nested.filesystem.readdir,
1214
+ readdirEntries: nested.filesystem.readdirEntries,
1215
+ readdirRecursive: nested.filesystem.readdirRecursive,
1216
+ exists: nested.filesystem.exists,
1217
+ move: nested.filesystem.move,
1218
+ remove: nested.filesystem.remove,
1219
+ exportRootFilesystem: nested.filesystem.export,
1220
+ mountFs: nested.filesystem.mount,
1221
+ unmountFs: nested.filesystem.unmount,
1222
+ listMounts: nested.filesystem.listMounts,
1223
+ exec: async (c, ...args) => (await ensureVm(c, options)).exec(...args),
1224
+ execArgv: async (c, ...args) => (await ensureVm(c, options)).execArgv(...args),
1225
+ spawn: nested.process.spawn,
1226
+ waitProcess: nested.process.wait,
1227
+ killProcess: nested.process.kill,
1228
+ listProcesses: nested.process.list,
1229
+ processTree: nested.process.tree,
1230
+ getProcess: nested.process.get,
1231
+ writeProcessStdin: nested.process.writeStdin,
1232
+ closeProcessStdin: nested.process.closeStdin,
1233
+ openShell: nested.terminal.open,
1234
+ writeShell: nested.terminal.write,
1235
+ resizeShell: nested.terminal.resize,
1236
+ closeShell: nested.terminal.close,
1237
+ waitShell: nested.terminal.wait,
1238
+ httpRequest: nested.network.httpRequest,
1239
+ vmFetch: flat.vmFetch,
1240
+ vmFetchStreamStart: flat.vmFetchStreamStart,
1241
+ vmFetchStreamRead: flat.vmFetchStreamRead,
1242
+ vmFetchStreamCancel: flat.vmFetchStreamCancel,
1243
+ scheduleCron: nested.cron.schedule,
1244
+ listCronJobs: nested.cron.list,
1245
+ cancelCronJob: nested.cron.cancel,
1246
+ listAgents: nested.agents.list,
1247
+ openSession: nested.sessions.open,
1248
+ getSession: nested.sessions.get,
1249
+ listSessions: nested.sessions.list,
1250
+ deleteSession: nested.sessions.delete,
1251
+ unloadSession: nested.sessions.unload,
1252
+ prompt: nested.sessions.prompt,
1253
+ cancelPrompt: nested.sessions.cancelPrompt,
1254
+ respondPermission: nested.sessions.respondPermission,
1255
+ readHistory: nested.sessions.readHistory,
1256
+ getSessionConfig: nested.sessions.getConfig,
1257
+ setSessionConfigOption: nested.sessions.setConfigOption,
1258
+ getSessionCapabilities: nested.sessions.getCapabilities,
1259
+ getSessionAgentInfo: nested.sessions.getAgentInfo,
1260
+ listSoftware: nested.software.list,
1261
+ linkSoftware: nested.software.link,
1262
+ // Preview URLs are RivetKit-specific and intentionally stay flat.
1263
+ createPreviewUrl: flat.createPreviewUrl,
1264
+ expirePreviewUrl: flat.expirePreviewUrl
1265
+ };
826
1266
  }
827
1267
  var agentOsOptionKeys = [
828
1268
  "software",
@@ -1011,7 +1451,7 @@ function createAgentOS(config = {}) {
1011
1451
  request.headers.forEach((value, key) => {
1012
1452
  requestHeaders[key] = value;
1013
1453
  });
1014
- const response = await vm.httpRequest({
1454
+ const response = await vm.network.httpRequest({
1015
1455
  port: rows[0].port,
1016
1456
  path: `${target.pathname}${target.search}`,
1017
1457
  method: request.method,
@@ -1041,8 +1481,6 @@ export {
1041
1481
  createAgentOS as agentOS,
1042
1482
  createAgentOS,
1043
1483
  createAgentOsActions,
1044
- defineSoftware,
1045
- nodeModulesMount,
1046
1484
  setup
1047
1485
  };
1048
1486
  //# sourceMappingURL=index.js.map