@rivet-dev/agentos 0.2.14 → 0.2.16-rc.1
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/assets/inspector-tabs-app/assets/agentos-hero-logo-E3fapwXM.svg +74 -0
- package/assets/inspector-tabs-app/assets/filesystem-Ce_1E-AG.js +1 -0
- package/assets/inspector-tabs-app/assets/index-AMqbzdhN.js +126 -0
- package/assets/inspector-tabs-app/assets/index-tcfmhW06.css +1 -0
- package/assets/inspector-tabs-app/assets/sed-BwsOyU9v.svg +1 -0
- package/assets/inspector-tabs-app/assets/system-AIh54aFR.js +2 -0
- package/assets/inspector-tabs-app/assets/transcript-D07sAUKE.js +1 -0
- package/assets/inspector-tabs-app/assets/useSuspenseQuery-BXmNSEVQ.js +1 -0
- package/assets/inspector-tabs-app/assets/vm-boot-gate-CzDOFOZU.js +1 -0
- package/assets/inspector-tabs-app/assets/vm-status-badges-CnUikLsX.js +5 -0
- package/assets/inspector-tabs-app/index.html +2 -2
- package/dist/index.d.ts +242 -20
- package/dist/index.js +646 -85
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/assets/inspector-tabs-app/assets/badge-BmCA5T7W.js +0 -1
- package/assets/inspector-tabs-app/assets/filesystem-Ddl1E2J2.js +0 -1
- package/assets/inspector-tabs-app/assets/index-BGua85-g.js +0 -125
- package/assets/inspector-tabs-app/assets/index-Dt5XhJ9h.css +0 -1
- package/assets/inspector-tabs-app/assets/mounts-DGpRABb5.js +0 -1
- package/assets/inspector-tabs-app/assets/processes-kG2x8aAp.js +0 -1
- package/assets/inspector-tabs-app/assets/scroll-area-DzEUZzTZ.js +0 -1
- package/assets/inspector-tabs-app/assets/software-CIIxhwyc.js +0 -1
- package/assets/inspector-tabs-app/assets/transcript-DEti4eM2.js +0 -1
- package/assets/inspector-tabs-app/assets/useSuspenseQuery-DmE5ZTv0.js +0 -1
package/dist/index.js
CHANGED
|
@@ -2,10 +2,12 @@ import "./chunk-V6TY7KAL.js";
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { setup as rivetkitSetup } from "rivetkit";
|
|
5
|
-
|
|
5
|
+
export * from "@rivet-dev/agentos-core";
|
|
6
6
|
|
|
7
7
|
// src/actor.ts
|
|
8
8
|
import crypto from "crypto";
|
|
9
|
+
import { dirname, join } from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
9
11
|
import {
|
|
10
12
|
AgentOs
|
|
11
13
|
} from "@rivet-dev/agentos-core";
|
|
@@ -69,6 +71,21 @@ var optionResolvers = /* @__PURE__ */ new WeakMap();
|
|
|
69
71
|
var vmStartResolvers = /* @__PURE__ */ new WeakMap();
|
|
70
72
|
var vmStopResolvers = /* @__PURE__ */ new WeakMap();
|
|
71
73
|
var vmDisposedResolvers = /* @__PURE__ */ new WeakMap();
|
|
74
|
+
var HEALTH_WARNINGS_CAP = 50;
|
|
75
|
+
var HEALTH_AGENT_EXITS_CAP = 50;
|
|
76
|
+
var healthBuffers = /* @__PURE__ */ new Map();
|
|
77
|
+
function healthBuffersFor(actorId) {
|
|
78
|
+
let buffers = healthBuffers.get(actorId);
|
|
79
|
+
if (!buffers) {
|
|
80
|
+
buffers = { warnings: [], agentExits: [] };
|
|
81
|
+
healthBuffers.set(actorId, buffers);
|
|
82
|
+
}
|
|
83
|
+
return buffers;
|
|
84
|
+
}
|
|
85
|
+
function pushCapped(buffer, item, cap) {
|
|
86
|
+
buffer.push(item);
|
|
87
|
+
while (buffer.length > cap) buffer.shift();
|
|
88
|
+
}
|
|
72
89
|
function runtimeFor(c) {
|
|
73
90
|
let runtime = runtimes.get(c.actorId);
|
|
74
91
|
if (!runtime) {
|
|
@@ -135,6 +152,18 @@ async function ensureVm(c, options) {
|
|
|
135
152
|
msg: "agent-os agent adapter exited unexpectedly",
|
|
136
153
|
...event2
|
|
137
154
|
});
|
|
155
|
+
pushCapped(
|
|
156
|
+
healthBuffersFor(c.actorId).agentExits,
|
|
157
|
+
{
|
|
158
|
+
ts: Date.now(),
|
|
159
|
+
sessionId: event2.sessionId,
|
|
160
|
+
agentType: event2.agentType,
|
|
161
|
+
exitCode: event2.exitCode,
|
|
162
|
+
restart: event2.restart,
|
|
163
|
+
restartCount: event2.restartCount
|
|
164
|
+
},
|
|
165
|
+
HEALTH_AGENT_EXITS_CAP
|
|
166
|
+
);
|
|
138
167
|
c.broadcast("agentExit", event2);
|
|
139
168
|
try {
|
|
140
169
|
resolvedOptions.onAgentExit?.(event2);
|
|
@@ -146,6 +175,26 @@ async function ensureVm(c, options) {
|
|
|
146
175
|
});
|
|
147
176
|
}
|
|
148
177
|
},
|
|
178
|
+
onLimitWarning: (warning) => {
|
|
179
|
+
c.log.warn({
|
|
180
|
+
msg: "agent-os runtime limit is near capacity",
|
|
181
|
+
...warning
|
|
182
|
+
});
|
|
183
|
+
pushCapped(
|
|
184
|
+
healthBuffersFor(c.actorId).warnings,
|
|
185
|
+
{ ts: Date.now(), ...warning },
|
|
186
|
+
HEALTH_WARNINGS_CAP
|
|
187
|
+
);
|
|
188
|
+
try {
|
|
189
|
+
options?.onLimitWarning?.(warning);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
c.log.error({
|
|
192
|
+
msg: "agent-os onLimitWarning hook failed",
|
|
193
|
+
limit: warning.limit,
|
|
194
|
+
error
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
},
|
|
149
198
|
rootFilesystem: {
|
|
150
199
|
type: "native",
|
|
151
200
|
plugin: {
|
|
@@ -162,12 +211,12 @@ async function ensureVm(c, options) {
|
|
|
162
211
|
});
|
|
163
212
|
try {
|
|
164
213
|
for (const row of mountRows) {
|
|
165
|
-
await vm.
|
|
214
|
+
await vm.filesystem.mount(
|
|
166
215
|
JSON.parse(row.descriptor_json)
|
|
167
216
|
);
|
|
168
217
|
}
|
|
169
218
|
for (const row of softwareRows) {
|
|
170
|
-
await vm.
|
|
219
|
+
await vm.software.link(
|
|
171
220
|
JSON.parse(row.descriptor_json)
|
|
172
221
|
);
|
|
173
222
|
}
|
|
@@ -215,6 +264,7 @@ async function ensureVm(c, options) {
|
|
|
215
264
|
}
|
|
216
265
|
}
|
|
217
266
|
async function disposeVm(c, reason) {
|
|
267
|
+
if (reason === "destroy") healthBuffers.delete(c.actorId);
|
|
218
268
|
const runtime = runtimes.get(c.actorId);
|
|
219
269
|
if (!runtime) return;
|
|
220
270
|
const vm = runtime.vm;
|
|
@@ -408,6 +458,76 @@ function releaseFetchStream(c, streamId) {
|
|
|
408
458
|
runtime.fetchStreamHolds.get(streamId)?.();
|
|
409
459
|
runtime.fetchStreamHolds.delete(streamId);
|
|
410
460
|
}
|
|
461
|
+
function decodeActorData(value) {
|
|
462
|
+
if (value === void 0) return void 0;
|
|
463
|
+
if (typeof value !== "object" || value === null || !("encoding" in value) || !("data" in value)) {
|
|
464
|
+
throw new UserError("stdin must be tagged UTF-8 or base64 actor data", {
|
|
465
|
+
code: "agentos_execution_invalid_actor_data"
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
const input = value;
|
|
469
|
+
if (typeof input.data !== "string") {
|
|
470
|
+
throw new UserError("actor data must contain a string", {
|
|
471
|
+
code: "agentos_execution_invalid_actor_data"
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
if (input.encoding === "utf8") return input.data;
|
|
475
|
+
if (input.encoding === "base64")
|
|
476
|
+
return new Uint8Array(Buffer.from(input.data, "base64"));
|
|
477
|
+
throw new UserError("actor data encoding must be utf8 or base64", {
|
|
478
|
+
code: "agentos_execution_invalid_actor_data"
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function actorExecutionArgs(args) {
|
|
482
|
+
return args.map((arg) => {
|
|
483
|
+
if (typeof arg !== "object" || arg === null || Array.isArray(arg))
|
|
484
|
+
return arg;
|
|
485
|
+
const options = arg;
|
|
486
|
+
for (const field of ["signal", "onStdout", "onStderr"]) {
|
|
487
|
+
if (options[field] !== void 0) {
|
|
488
|
+
throw new UserError(`${field} is not available on actor actions`, {
|
|
489
|
+
code: "agentos_execution_non_serializable_option"
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const normalized = { ...options };
|
|
494
|
+
if ("stdin" in normalized)
|
|
495
|
+
normalized.stdin = decodeActorData(normalized.stdin);
|
|
496
|
+
return normalized;
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function actorSpawnArgs(options) {
|
|
500
|
+
return options === void 0 ? [] : actorExecutionArgs([options]);
|
|
501
|
+
}
|
|
502
|
+
async function runActorExecution(c, operation, options) {
|
|
503
|
+
const vm = await ensureVm(c, options);
|
|
504
|
+
return c.keepAwake(operation(vm));
|
|
505
|
+
}
|
|
506
|
+
async function runActorSpawn(c, operation, options) {
|
|
507
|
+
const vm = await ensureVm(c, options);
|
|
508
|
+
const process = await operation(vm);
|
|
509
|
+
const unsubscribeOutput = vm.onProcessOutput(
|
|
510
|
+
process.pid,
|
|
511
|
+
(event2) => c.broadcast("processOutput", event2)
|
|
512
|
+
);
|
|
513
|
+
const unsubscribeExit = vm.onProcessExit(
|
|
514
|
+
process.pid,
|
|
515
|
+
(event2) => c.broadcast("processExit", event2)
|
|
516
|
+
);
|
|
517
|
+
void c.keepAwake(
|
|
518
|
+
vm.process.wait(process.pid).finally(() => {
|
|
519
|
+
unsubscribeOutput();
|
|
520
|
+
unsubscribeExit();
|
|
521
|
+
})
|
|
522
|
+
).catch(
|
|
523
|
+
(error) => c.log.error({
|
|
524
|
+
msg: "agent-os process wait failed",
|
|
525
|
+
pid: process.pid,
|
|
526
|
+
error
|
|
527
|
+
})
|
|
528
|
+
);
|
|
529
|
+
return process;
|
|
530
|
+
}
|
|
411
531
|
function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubscriptions = DEFAULT_MAX_SESSION_SUBSCRIPTIONS, maxDynamicMounts = DEFAULT_MAX_DYNAMIC_MOUNTS, maxLinkedSoftware = DEFAULT_MAX_LINKED_SOFTWARE) {
|
|
412
532
|
const defaultPreviewTtlSeconds = preview.defaultExpiresInSeconds ?? DEFAULT_PREVIEW_TTL_SECONDS;
|
|
413
533
|
const maxPreviewTtlSeconds = preview.maxExpiresInSeconds ?? MAX_PREVIEW_TTL_SECONDS;
|
|
@@ -438,10 +558,10 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
438
558
|
code: "agentos_linked_software_invalid_config"
|
|
439
559
|
});
|
|
440
560
|
}
|
|
441
|
-
|
|
561
|
+
const flat = {
|
|
442
562
|
readFile: async (c, ...args) => {
|
|
443
563
|
try {
|
|
444
|
-
return await (await ensureVm(c, options)).readFile(...args);
|
|
564
|
+
return await (await ensureVm(c, options)).filesystem.readFile(...args);
|
|
445
565
|
} catch (error) {
|
|
446
566
|
c.log.error({
|
|
447
567
|
msg: "agent-os readFile action failed",
|
|
@@ -451,56 +571,249 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
451
571
|
throw error;
|
|
452
572
|
}
|
|
453
573
|
},
|
|
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,
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
574
|
+
writeFile: async (c, ...args) => (await ensureVm(c, options)).filesystem.writeFile(...args),
|
|
575
|
+
readFiles: async (c, ...args) => (await ensureVm(c, options)).filesystem.readFiles(...args),
|
|
576
|
+
writeFiles: async (c, ...args) => (await ensureVm(c, options)).filesystem.writeFiles(...args),
|
|
577
|
+
stat: async (c, ...args) => (await ensureVm(c, options)).filesystem.stat(...args),
|
|
578
|
+
mkdir: async (c, ...args) => (await ensureVm(c, options)).filesystem.mkdir(...args),
|
|
579
|
+
readdir: async (c, ...args) => (await ensureVm(c, options)).filesystem.readdir(...args),
|
|
580
|
+
readdirEntries: async (c, ...args) => (await ensureVm(c, options)).filesystem.readdirEntries(...args),
|
|
581
|
+
readdirRecursive: async (c, ...args) => (await ensureVm(c, options)).filesystem.readdirRecursive(...args),
|
|
582
|
+
exists: async (c, ...args) => (await ensureVm(c, options)).filesystem.exists(...args),
|
|
583
|
+
move: async (c, ...args) => (await ensureVm(c, options)).filesystem.move(...args),
|
|
584
|
+
remove: async (c, ...args) => (await ensureVm(c, options)).filesystem.remove(...args),
|
|
585
|
+
exec: async (c, command, actorOptions) => runActorExecution(
|
|
586
|
+
c,
|
|
587
|
+
(vm) => vm.process.exec(
|
|
588
|
+
command,
|
|
589
|
+
...actorExecutionArgs([actorOptions])
|
|
590
|
+
),
|
|
591
|
+
options
|
|
592
|
+
),
|
|
593
|
+
execArgv: async (c, command, args = [], actorOptions) => runActorExecution(
|
|
594
|
+
c,
|
|
595
|
+
(vm) => vm.process.execFile(
|
|
596
|
+
command,
|
|
597
|
+
args,
|
|
598
|
+
...actorExecutionArgs([actorOptions])
|
|
599
|
+
),
|
|
600
|
+
options
|
|
601
|
+
),
|
|
602
|
+
spawn: async (c, command, args = [], actorOptions) => runActorSpawn(
|
|
603
|
+
c,
|
|
604
|
+
(vm) => vm.process.spawn(
|
|
605
|
+
command,
|
|
606
|
+
args,
|
|
607
|
+
...actorSpawnArgs(actorOptions)
|
|
608
|
+
),
|
|
609
|
+
options
|
|
610
|
+
),
|
|
611
|
+
createContext: async (c, contextId) => (await ensureVm(c, options)).createContext(contextId),
|
|
612
|
+
executeJavaScript: async (c, source, actorOptions) => runActorExecution(
|
|
613
|
+
c,
|
|
614
|
+
(vm) => vm.javascript.execute(
|
|
615
|
+
source,
|
|
616
|
+
...actorExecutionArgs([actorOptions])
|
|
617
|
+
),
|
|
618
|
+
options
|
|
619
|
+
),
|
|
620
|
+
evaluateJavaScript: async (c, expression, actorOptions) => runActorExecution(
|
|
621
|
+
c,
|
|
622
|
+
(vm) => vm.javascript.evaluate(
|
|
623
|
+
expression,
|
|
624
|
+
...actorExecutionArgs([actorOptions])
|
|
625
|
+
),
|
|
626
|
+
options
|
|
627
|
+
),
|
|
628
|
+
executeJavaScriptFile: async (c, path, actorOptions) => runActorExecution(
|
|
629
|
+
c,
|
|
630
|
+
(vm) => vm.javascript.executeFile(
|
|
631
|
+
path,
|
|
632
|
+
...actorExecutionArgs([actorOptions])
|
|
633
|
+
),
|
|
634
|
+
options
|
|
635
|
+
),
|
|
636
|
+
spawnJavaScript: async (c, source, actorOptions) => runActorSpawn(
|
|
637
|
+
c,
|
|
638
|
+
(vm) => vm.javascript.spawn(
|
|
639
|
+
source,
|
|
640
|
+
...actorSpawnArgs(actorOptions)
|
|
641
|
+
),
|
|
642
|
+
options
|
|
643
|
+
),
|
|
644
|
+
spawnJavaScriptFile: async (c, path, actorOptions) => runActorSpawn(
|
|
645
|
+
c,
|
|
646
|
+
(vm) => vm.javascript.spawnFile(
|
|
647
|
+
path,
|
|
648
|
+
...actorSpawnArgs(actorOptions)
|
|
649
|
+
),
|
|
650
|
+
options
|
|
651
|
+
),
|
|
652
|
+
executeTypeScript: async (c, source, actorOptions) => runActorExecution(
|
|
653
|
+
c,
|
|
654
|
+
(vm) => vm.typescript.execute(
|
|
655
|
+
source,
|
|
656
|
+
...actorExecutionArgs([actorOptions])
|
|
657
|
+
),
|
|
658
|
+
options
|
|
659
|
+
),
|
|
660
|
+
evaluateTypeScript: async (c, expression, actorOptions) => runActorExecution(
|
|
661
|
+
c,
|
|
662
|
+
(vm) => vm.typescript.evaluate(
|
|
663
|
+
expression,
|
|
664
|
+
...actorExecutionArgs([actorOptions])
|
|
665
|
+
),
|
|
666
|
+
options
|
|
667
|
+
),
|
|
668
|
+
executeTypeScriptFile: async (c, path, actorOptions) => runActorExecution(
|
|
669
|
+
c,
|
|
670
|
+
(vm) => vm.typescript.executeFile(
|
|
671
|
+
path,
|
|
672
|
+
...actorExecutionArgs([actorOptions])
|
|
673
|
+
),
|
|
674
|
+
options
|
|
675
|
+
),
|
|
676
|
+
spawnTypeScript: async (c, source, actorOptions) => runActorSpawn(
|
|
677
|
+
c,
|
|
678
|
+
(vm) => vm.typescript.spawn(
|
|
679
|
+
source,
|
|
680
|
+
...actorSpawnArgs(actorOptions)
|
|
681
|
+
),
|
|
682
|
+
options
|
|
683
|
+
),
|
|
684
|
+
spawnTypeScriptFile: async (c, path, actorOptions) => runActorSpawn(
|
|
685
|
+
c,
|
|
686
|
+
(vm) => vm.typescript.spawnFile(
|
|
687
|
+
path,
|
|
688
|
+
...actorSpawnArgs(actorOptions)
|
|
689
|
+
),
|
|
690
|
+
options
|
|
691
|
+
),
|
|
692
|
+
checkTypeScript: async (c, source, actorOptions) => runActorExecution(
|
|
693
|
+
c,
|
|
694
|
+
(vm) => vm.typescript.check(
|
|
695
|
+
source,
|
|
696
|
+
...actorExecutionArgs([actorOptions])
|
|
697
|
+
),
|
|
698
|
+
options
|
|
699
|
+
),
|
|
700
|
+
checkTypeScriptProject: async (c, actorOptions) => runActorExecution(
|
|
701
|
+
c,
|
|
702
|
+
(vm) => vm.typescript.checkProject(
|
|
703
|
+
...actorExecutionArgs([actorOptions])
|
|
704
|
+
),
|
|
705
|
+
options
|
|
706
|
+
),
|
|
707
|
+
installNpmPackages: async (c, ...args) => runActorExecution(
|
|
708
|
+
c,
|
|
709
|
+
(vm) => vm.javascript.npm.install(...actorExecutionArgs(args)),
|
|
710
|
+
options
|
|
711
|
+
),
|
|
712
|
+
executeNpmScript: async (c, script, actorOptions) => runActorExecution(
|
|
713
|
+
c,
|
|
714
|
+
(vm) => vm.javascript.npm.runScript(
|
|
715
|
+
script,
|
|
716
|
+
...actorExecutionArgs([actorOptions])
|
|
717
|
+
),
|
|
718
|
+
options
|
|
719
|
+
),
|
|
720
|
+
executeNpmPackage: async (c, packageSpec, actorOptions) => runActorExecution(
|
|
721
|
+
c,
|
|
722
|
+
(vm) => vm.javascript.npm.runPackage(
|
|
723
|
+
packageSpec,
|
|
724
|
+
...actorExecutionArgs([actorOptions])
|
|
725
|
+
),
|
|
726
|
+
options
|
|
727
|
+
),
|
|
728
|
+
executePython: async (c, source, actorOptions) => runActorExecution(
|
|
729
|
+
c,
|
|
730
|
+
(vm) => vm.python.execute(
|
|
731
|
+
source,
|
|
732
|
+
...actorExecutionArgs([actorOptions])
|
|
733
|
+
),
|
|
734
|
+
options
|
|
735
|
+
),
|
|
736
|
+
evaluatePython: async (c, expression, actorOptions) => runActorExecution(
|
|
737
|
+
c,
|
|
738
|
+
(vm) => vm.python.evaluate(
|
|
739
|
+
expression,
|
|
740
|
+
...actorExecutionArgs([actorOptions])
|
|
741
|
+
),
|
|
742
|
+
options
|
|
743
|
+
),
|
|
744
|
+
executePythonFile: async (c, path, actorOptions) => runActorExecution(
|
|
745
|
+
c,
|
|
746
|
+
(vm) => vm.python.executeFile(
|
|
747
|
+
path,
|
|
748
|
+
...actorExecutionArgs([actorOptions])
|
|
749
|
+
),
|
|
750
|
+
options
|
|
751
|
+
),
|
|
752
|
+
executePythonModule: async (c, module, actorOptions) => runActorExecution(
|
|
753
|
+
c,
|
|
754
|
+
(vm) => vm.python.executeModule(
|
|
755
|
+
module,
|
|
756
|
+
...actorExecutionArgs([actorOptions])
|
|
757
|
+
),
|
|
758
|
+
options
|
|
759
|
+
),
|
|
760
|
+
spawnPython: async (c, source, actorOptions) => runActorSpawn(
|
|
761
|
+
c,
|
|
762
|
+
(vm) => vm.python.spawn(source, ...actorSpawnArgs(actorOptions)),
|
|
763
|
+
options
|
|
764
|
+
),
|
|
765
|
+
spawnPythonFile: async (c, path, actorOptions) => runActorSpawn(
|
|
766
|
+
c,
|
|
767
|
+
(vm) => vm.python.spawnFile(
|
|
768
|
+
path,
|
|
769
|
+
...actorSpawnArgs(actorOptions)
|
|
770
|
+
),
|
|
771
|
+
options
|
|
772
|
+
),
|
|
773
|
+
spawnPythonModule: async (c, module, actorOptions) => runActorSpawn(
|
|
774
|
+
c,
|
|
775
|
+
(vm) => vm.python.spawnModule(
|
|
776
|
+
module,
|
|
777
|
+
...actorSpawnArgs(actorOptions)
|
|
778
|
+
),
|
|
779
|
+
options
|
|
780
|
+
),
|
|
781
|
+
installPythonPackages: async (c, ...args) => runActorExecution(
|
|
782
|
+
c,
|
|
783
|
+
(vm) => vm.python.install(...actorExecutionArgs(args)),
|
|
784
|
+
options
|
|
785
|
+
),
|
|
786
|
+
getContext: async (c, ...args) => (await ensureVm(c, options)).contexts.get(...args),
|
|
787
|
+
listContexts: async (c) => (await ensureVm(c, options)).contexts.list(),
|
|
788
|
+
resetContext: async (c, ...args) => (await ensureVm(c, options)).contexts.reset(...args),
|
|
789
|
+
deleteContext: async (c, ...args) => (await ensureVm(c, options)).contexts.delete(...args),
|
|
790
|
+
waitProcess: async (c, ...args) => (await ensureVm(c, options)).process.wait(...args),
|
|
791
|
+
killProcess: async (c, ...args) => (await ensureVm(c, options)).process.kill(...args),
|
|
792
|
+
signalProcess: async (c, ...args) => (await ensureVm(c, options)).process.signal(...args),
|
|
793
|
+
listProcesses: async (c) => (await ensureVm(c, options)).process.list(),
|
|
794
|
+
processTree: async (c) => (await ensureVm(c, options)).process.tree(),
|
|
795
|
+
getProcess: async (c, ...args) => (await ensureVm(c, options)).process.get(...args),
|
|
796
|
+
writeProcessStdin: async (c, ...args) => (await ensureVm(c, options)).process.writeStdin(...args),
|
|
797
|
+
closeProcessStdin: async (c, ...args) => (await ensureVm(c, options)).process.closeStdin(...args),
|
|
798
|
+
resizeProcessPty: async (c, ...args) => (await ensureVm(c, options)).process.resizePty(...args),
|
|
799
|
+
readProcessOutput: async (c, ...args) => {
|
|
800
|
+
const replay = await (await ensureVm(c, options)).process.readOutput(
|
|
801
|
+
...args
|
|
473
802
|
);
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
(event2) =>
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
})
|
|
483
|
-
|
|
484
|
-
(error) => c.log.error({
|
|
485
|
-
msg: "agent-os process wait failed",
|
|
486
|
-
pid: process.pid,
|
|
487
|
-
error
|
|
488
|
-
})
|
|
489
|
-
);
|
|
490
|
-
return process;
|
|
803
|
+
return {
|
|
804
|
+
...replay,
|
|
805
|
+
events: replay.events.map((event2) => ({
|
|
806
|
+
...event2,
|
|
807
|
+
chunk: {
|
|
808
|
+
encoding: "base64",
|
|
809
|
+
data: Buffer.from(event2.chunk).toString("base64")
|
|
810
|
+
}
|
|
811
|
+
}))
|
|
812
|
+
};
|
|
491
813
|
},
|
|
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
814
|
openShell: async (c, ...args) => {
|
|
502
815
|
const vm = await ensureVm(c, options);
|
|
503
|
-
const shell = vm.
|
|
816
|
+
const shell = vm.terminal.open(...args);
|
|
504
817
|
const unsubscribeData = vm.onShellData(
|
|
505
818
|
shell.shellId,
|
|
506
819
|
(event2) => c.broadcast("shellData", event2)
|
|
@@ -514,7 +827,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
514
827
|
(event2) => c.broadcast("shellExit", event2)
|
|
515
828
|
);
|
|
516
829
|
void c.keepAwake(
|
|
517
|
-
vm.
|
|
830
|
+
vm.terminal.wait(shell.shellId).finally(() => {
|
|
518
831
|
unsubscribeData();
|
|
519
832
|
unsubscribeStderr();
|
|
520
833
|
unsubscribeExit();
|
|
@@ -528,11 +841,11 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
528
841
|
);
|
|
529
842
|
return shell;
|
|
530
843
|
},
|
|
531
|
-
writeShell: async (c, ...args) => (await ensureVm(c, options)).
|
|
532
|
-
resizeShell: async (c, ...args) => (await ensureVm(c, options)).
|
|
533
|
-
closeShell: async (c, ...args) => (await ensureVm(c, options)).
|
|
534
|
-
waitShell: async (c, ...args) => (await ensureVm(c, options)).
|
|
535
|
-
httpRequest: async (c, ...args) => (await ensureVm(c, options)).httpRequest(...args),
|
|
844
|
+
writeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.write(...args),
|
|
845
|
+
resizeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.resize(...args),
|
|
846
|
+
closeShell: async (c, ...args) => (await ensureVm(c, options)).terminal.close(...args),
|
|
847
|
+
waitShell: async (c, ...args) => (await ensureVm(c, options)).terminal.wait(...args),
|
|
848
|
+
httpRequest: async (c, ...args) => (await ensureVm(c, options)).network.httpRequest(...args),
|
|
536
849
|
vmFetch: async (c, port, url, requestOptions) => {
|
|
537
850
|
const vm = await ensureVm(c, options);
|
|
538
851
|
const body = requestOptions?.body instanceof Uint8Array ? Buffer.from(requestOptions.body) : requestOptions?.body;
|
|
@@ -598,18 +911,50 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
598
911
|
}
|
|
599
912
|
},
|
|
600
913
|
scheduleCron: async (c, cronOptions) => {
|
|
601
|
-
const job = (await ensureVm(c, options)).
|
|
914
|
+
const job = (await ensureVm(c, options)).cron.schedule(
|
|
602
915
|
cronOptions
|
|
603
916
|
);
|
|
604
917
|
return { id: job.id };
|
|
605
918
|
},
|
|
606
|
-
listCronJobs: async (c) => (await ensureVm(c, options)).
|
|
607
|
-
cancelCronJob: async (c, ...args) => (await ensureVm(c, options)).
|
|
608
|
-
listAgents: async (c) => (await ensureVm(c, options)).
|
|
919
|
+
listCronJobs: async (c) => (await ensureVm(c, options)).cron.list(),
|
|
920
|
+
cancelCronJob: async (c, ...args) => (await ensureVm(c, options)).cron.cancel(...args),
|
|
921
|
+
listAgents: async (c) => (await ensureVm(c, options)).agents.list(),
|
|
922
|
+
// Observe-only: reports VM liveness and the post-mortem buffers without
|
|
923
|
+
// ever booting the VM (deliberately no ensureVm).
|
|
924
|
+
health: async (c) => {
|
|
925
|
+
const runtime = runtimes.get(c.actorId);
|
|
926
|
+
const buffers = healthBuffersFor(c.actorId);
|
|
927
|
+
let booted = false;
|
|
928
|
+
let sessions = null;
|
|
929
|
+
let sidecar = null;
|
|
930
|
+
if (runtime?.vm) {
|
|
931
|
+
const vm = await Promise.race([
|
|
932
|
+
runtime.vm.catch(() => null),
|
|
933
|
+
Promise.resolve(null)
|
|
934
|
+
]);
|
|
935
|
+
if (vm) {
|
|
936
|
+
booted = true;
|
|
937
|
+
sessions = runtime.subscribedSessions.size;
|
|
938
|
+
const description = vm.sidecar.describe();
|
|
939
|
+
sidecar = {
|
|
940
|
+
state: description.state,
|
|
941
|
+
activeVmCount: description.activeVmCount
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return {
|
|
946
|
+
booted,
|
|
947
|
+
sessions,
|
|
948
|
+
sidecar,
|
|
949
|
+
warnings: [...buffers.warnings],
|
|
950
|
+
agentExits: [...buffers.agentExits],
|
|
951
|
+
stderrTail: []
|
|
952
|
+
};
|
|
953
|
+
},
|
|
609
954
|
openSession: async (c, input) => {
|
|
610
955
|
const vm = await ensureVm(c, options);
|
|
611
956
|
try {
|
|
612
|
-
await vm.
|
|
957
|
+
await vm.sessions.open(input);
|
|
613
958
|
} catch (error) {
|
|
614
959
|
const message = error instanceof Error ? error.message : String(error);
|
|
615
960
|
const causeCode = typeof error?.code === "string" ? error.code : void 0;
|
|
@@ -633,15 +978,19 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
633
978
|
maxSessionSubscriptions
|
|
634
979
|
);
|
|
635
980
|
},
|
|
636
|
-
getSession: async (c, ...args) => (await ensureVm(c, options)).
|
|
637
|
-
listSessions: async (c, ...args) => (await ensureVm(c, options)).
|
|
981
|
+
getSession: async (c, ...args) => (await ensureVm(c, options)).sessions.get(...args),
|
|
982
|
+
listSessions: async (c, ...args) => (await ensureVm(c, options)).sessions.list(...args),
|
|
638
983
|
deleteSession: async (c, ...args) => {
|
|
639
|
-
const result = await (await ensureVm(c, options)).
|
|
984
|
+
const result = await (await ensureVm(c, options)).sessions.delete(
|
|
985
|
+
...args
|
|
986
|
+
);
|
|
640
987
|
untrackSessionEvents(c, args[0]?.sessionId ?? "main");
|
|
641
988
|
return result;
|
|
642
989
|
},
|
|
643
990
|
unloadSession: async (c, ...args) => {
|
|
644
|
-
const result = await (await ensureVm(c, options)).
|
|
991
|
+
const result = await (await ensureVm(c, options)).sessions.unload(
|
|
992
|
+
...args
|
|
993
|
+
);
|
|
645
994
|
untrackSessionEvents(c, args[0]?.sessionId ?? "main");
|
|
646
995
|
return result;
|
|
647
996
|
},
|
|
@@ -650,7 +999,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
650
999
|
const sessionId = input.sessionId ?? "main";
|
|
651
1000
|
trackSessionEvents(c, vm, sessionId, hooks, maxSessionSubscriptions);
|
|
652
1001
|
try {
|
|
653
|
-
return await c.keepAwake(vm.prompt(input));
|
|
1002
|
+
return await c.keepAwake(vm.sessions.prompt(input));
|
|
654
1003
|
} catch (error) {
|
|
655
1004
|
const message = error instanceof Error ? error.message : String(error);
|
|
656
1005
|
const causeCode = typeof error?.code === "string" ? error.code : void 0;
|
|
@@ -666,13 +1015,13 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
666
1015
|
});
|
|
667
1016
|
}
|
|
668
1017
|
},
|
|
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)).
|
|
673
|
-
setSessionConfigOption: async (c, ...args) => (await ensureVm(c, options)).
|
|
674
|
-
getSessionCapabilities: async (c, ...args) => (await ensureVm(c, options)).
|
|
675
|
-
getSessionAgentInfo: async (c, ...args) => (await ensureVm(c, options)).
|
|
1018
|
+
cancelPrompt: async (c, ...args) => (await ensureVm(c, options)).sessions.cancelPrompt(...args),
|
|
1019
|
+
respondPermission: async (c, ...args) => (await ensureVm(c, options)).sessions.respondPermission(...args),
|
|
1020
|
+
readHistory: async (c, ...args) => (await ensureVm(c, options)).sessions.readHistory(...args),
|
|
1021
|
+
getSessionConfig: async (c, ...args) => (await ensureVm(c, options)).sessions.getConfig(...args),
|
|
1022
|
+
setSessionConfigOption: async (c, ...args) => (await ensureVm(c, options)).sessions.setConfigOption(...args),
|
|
1023
|
+
getSessionCapabilities: async (c, ...args) => (await ensureVm(c, options)).sessions.getCapabilities(...args),
|
|
1024
|
+
getSessionAgentInfo: async (c, ...args) => (await ensureVm(c, options)).sessions.getAgentInfo(...args),
|
|
676
1025
|
createPreviewUrl: async (c, port, ttlSeconds = defaultPreviewTtlSeconds) => {
|
|
677
1026
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
678
1027
|
throw new UserError(
|
|
@@ -728,7 +1077,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
728
1077
|
token
|
|
729
1078
|
);
|
|
730
1079
|
},
|
|
731
|
-
exportRootFilesystem: async (c, ...args) => (await ensureVm(c, options)).
|
|
1080
|
+
exportRootFilesystem: async (c, ...args) => (await ensureVm(c, options)).filesystem.export(...args),
|
|
732
1081
|
mountFs: async (c, descriptor) => {
|
|
733
1082
|
await assertActorCollectionCapacity(
|
|
734
1083
|
c,
|
|
@@ -739,7 +1088,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
739
1088
|
"maxDynamicMounts"
|
|
740
1089
|
);
|
|
741
1090
|
const vm = await ensureVm(c, options);
|
|
742
|
-
await vm.
|
|
1091
|
+
await vm.filesystem.mount(descriptor);
|
|
743
1092
|
try {
|
|
744
1093
|
await c.db.execute(
|
|
745
1094
|
"INSERT INTO agentos_actor_dynamic_mounts (path, descriptor_json) VALUES (?, ?) ON CONFLICT(path) DO UPDATE SET descriptor_json = excluded.descriptor_json",
|
|
@@ -748,7 +1097,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
748
1097
|
);
|
|
749
1098
|
} catch (error) {
|
|
750
1099
|
try {
|
|
751
|
-
await vm.
|
|
1100
|
+
await vm.filesystem.unmount(descriptor.path);
|
|
752
1101
|
} catch (rollbackError) {
|
|
753
1102
|
c.log.error({
|
|
754
1103
|
msg: "agent-os dynamic mount rollback failed",
|
|
@@ -765,7 +1114,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
765
1114
|
path
|
|
766
1115
|
);
|
|
767
1116
|
const vm = await ensureVm(c, options);
|
|
768
|
-
await vm.
|
|
1117
|
+
await vm.filesystem.unmount(path);
|
|
769
1118
|
try {
|
|
770
1119
|
await c.db.execute(
|
|
771
1120
|
"DELETE FROM agentos_actor_dynamic_mounts WHERE path = ?",
|
|
@@ -774,7 +1123,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
774
1123
|
} catch (error) {
|
|
775
1124
|
if (rows[0]) {
|
|
776
1125
|
try {
|
|
777
|
-
await vm.
|
|
1126
|
+
await vm.filesystem.mount(
|
|
778
1127
|
JSON.parse(rows[0].descriptor_json)
|
|
779
1128
|
);
|
|
780
1129
|
} catch (rollbackError) {
|
|
@@ -788,8 +1137,8 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
788
1137
|
throw error;
|
|
789
1138
|
}
|
|
790
1139
|
},
|
|
791
|
-
listMounts: async (c) => (await ensureVm(c, options)).listMounts(),
|
|
792
|
-
listSoftware: async (c) => (await ensureVm(c, options)).
|
|
1140
|
+
listMounts: async (c) => (await ensureVm(c, options)).filesystem.listMounts(),
|
|
1141
|
+
listSoftware: async (c) => (await ensureVm(c, options)).software.list(),
|
|
793
1142
|
linkSoftware: async (c, descriptor) => {
|
|
794
1143
|
await assertActorCollectionCapacity(
|
|
795
1144
|
c,
|
|
@@ -805,7 +1154,7 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
805
1154
|
JSON.stringify(descriptor)
|
|
806
1155
|
);
|
|
807
1156
|
try {
|
|
808
|
-
await (await ensureVm(c, options)).
|
|
1157
|
+
await (await ensureVm(c, options)).software.link(descriptor);
|
|
809
1158
|
} catch (error) {
|
|
810
1159
|
try {
|
|
811
1160
|
await c.db.execute(
|
|
@@ -823,6 +1172,181 @@ function createAgentOsActions(options, hooks = {}, preview = {}, maxSessionSubsc
|
|
|
823
1172
|
}
|
|
824
1173
|
}
|
|
825
1174
|
};
|
|
1175
|
+
const nested = {
|
|
1176
|
+
createContext: flat.createContext,
|
|
1177
|
+
process: {
|
|
1178
|
+
exec: flat.exec,
|
|
1179
|
+
execFile: flat.execArgv,
|
|
1180
|
+
spawn: flat.spawn,
|
|
1181
|
+
get: flat.getProcess,
|
|
1182
|
+
list: flat.listProcesses,
|
|
1183
|
+
tree: flat.processTree,
|
|
1184
|
+
wait: flat.waitProcess,
|
|
1185
|
+
signal: flat.signalProcess,
|
|
1186
|
+
kill: flat.killProcess,
|
|
1187
|
+
writeStdin: flat.writeProcessStdin,
|
|
1188
|
+
closeStdin: flat.closeProcessStdin,
|
|
1189
|
+
resizePty: flat.resizeProcessPty,
|
|
1190
|
+
readOutput: flat.readProcessOutput
|
|
1191
|
+
},
|
|
1192
|
+
javascript: {
|
|
1193
|
+
execute: flat.executeJavaScript,
|
|
1194
|
+
evaluate: flat.evaluateJavaScript,
|
|
1195
|
+
executeFile: flat.executeJavaScriptFile,
|
|
1196
|
+
spawn: flat.spawnJavaScript,
|
|
1197
|
+
spawnFile: flat.spawnJavaScriptFile,
|
|
1198
|
+
npm: {
|
|
1199
|
+
install: flat.installNpmPackages,
|
|
1200
|
+
runScript: flat.executeNpmScript,
|
|
1201
|
+
runPackage: flat.executeNpmPackage
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1204
|
+
typescript: {
|
|
1205
|
+
execute: flat.executeTypeScript,
|
|
1206
|
+
evaluate: flat.evaluateTypeScript,
|
|
1207
|
+
executeFile: flat.executeTypeScriptFile,
|
|
1208
|
+
spawn: flat.spawnTypeScript,
|
|
1209
|
+
spawnFile: flat.spawnTypeScriptFile,
|
|
1210
|
+
check: flat.checkTypeScript,
|
|
1211
|
+
checkProject: flat.checkTypeScriptProject
|
|
1212
|
+
},
|
|
1213
|
+
python: {
|
|
1214
|
+
execute: flat.executePython,
|
|
1215
|
+
evaluate: flat.evaluatePython,
|
|
1216
|
+
executeFile: flat.executePythonFile,
|
|
1217
|
+
executeModule: flat.executePythonModule,
|
|
1218
|
+
spawn: flat.spawnPython,
|
|
1219
|
+
spawnFile: flat.spawnPythonFile,
|
|
1220
|
+
spawnModule: flat.spawnPythonModule,
|
|
1221
|
+
install: flat.installPythonPackages
|
|
1222
|
+
},
|
|
1223
|
+
contexts: {
|
|
1224
|
+
get: flat.getContext,
|
|
1225
|
+
list: flat.listContexts,
|
|
1226
|
+
reset: flat.resetContext,
|
|
1227
|
+
delete: flat.deleteContext
|
|
1228
|
+
},
|
|
1229
|
+
terminal: {
|
|
1230
|
+
open: flat.openShell,
|
|
1231
|
+
write: flat.writeShell,
|
|
1232
|
+
resize: flat.resizeShell,
|
|
1233
|
+
wait: flat.waitShell,
|
|
1234
|
+
close: flat.closeShell
|
|
1235
|
+
},
|
|
1236
|
+
filesystem: {
|
|
1237
|
+
readFile: flat.readFile,
|
|
1238
|
+
writeFile: flat.writeFile,
|
|
1239
|
+
readFiles: flat.readFiles,
|
|
1240
|
+
writeFiles: flat.writeFiles,
|
|
1241
|
+
stat: flat.stat,
|
|
1242
|
+
mkdir: flat.mkdir,
|
|
1243
|
+
readdir: flat.readdir,
|
|
1244
|
+
readdirEntries: flat.readdirEntries,
|
|
1245
|
+
readdirRecursive: flat.readdirRecursive,
|
|
1246
|
+
exists: flat.exists,
|
|
1247
|
+
move: flat.move,
|
|
1248
|
+
remove: flat.remove,
|
|
1249
|
+
export: flat.exportRootFilesystem,
|
|
1250
|
+
mount: flat.mountFs,
|
|
1251
|
+
unmount: flat.unmountFs,
|
|
1252
|
+
listMounts: flat.listMounts
|
|
1253
|
+
},
|
|
1254
|
+
network: {
|
|
1255
|
+
httpRequest: flat.httpRequest
|
|
1256
|
+
},
|
|
1257
|
+
software: {
|
|
1258
|
+
list: flat.listSoftware,
|
|
1259
|
+
link: flat.linkSoftware
|
|
1260
|
+
},
|
|
1261
|
+
agents: {
|
|
1262
|
+
list: flat.listAgents
|
|
1263
|
+
},
|
|
1264
|
+
sessions: {
|
|
1265
|
+
open: flat.openSession,
|
|
1266
|
+
get: flat.getSession,
|
|
1267
|
+
list: flat.listSessions,
|
|
1268
|
+
delete: flat.deleteSession,
|
|
1269
|
+
unload: flat.unloadSession,
|
|
1270
|
+
prompt: flat.prompt,
|
|
1271
|
+
cancelPrompt: flat.cancelPrompt,
|
|
1272
|
+
respondPermission: flat.respondPermission,
|
|
1273
|
+
readHistory: flat.readHistory,
|
|
1274
|
+
getConfig: flat.getSessionConfig,
|
|
1275
|
+
setConfigOption: flat.setSessionConfigOption,
|
|
1276
|
+
getCapabilities: flat.getSessionCapabilities,
|
|
1277
|
+
getAgentInfo: flat.getSessionAgentInfo
|
|
1278
|
+
},
|
|
1279
|
+
cron: {
|
|
1280
|
+
schedule: flat.scheduleCron,
|
|
1281
|
+
list: flat.listCronJobs,
|
|
1282
|
+
cancel: flat.cancelCronJob
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
return {
|
|
1286
|
+
...nested,
|
|
1287
|
+
// Legacy flat actions from the pre-language-execution API. Keep these
|
|
1288
|
+
// as aliases to the canonical nested handlers.
|
|
1289
|
+
readFile: nested.filesystem.readFile,
|
|
1290
|
+
writeFile: nested.filesystem.writeFile,
|
|
1291
|
+
readFiles: nested.filesystem.readFiles,
|
|
1292
|
+
writeFiles: nested.filesystem.writeFiles,
|
|
1293
|
+
stat: nested.filesystem.stat,
|
|
1294
|
+
mkdir: nested.filesystem.mkdir,
|
|
1295
|
+
readdir: nested.filesystem.readdir,
|
|
1296
|
+
readdirEntries: nested.filesystem.readdirEntries,
|
|
1297
|
+
readdirRecursive: nested.filesystem.readdirRecursive,
|
|
1298
|
+
exists: nested.filesystem.exists,
|
|
1299
|
+
move: nested.filesystem.move,
|
|
1300
|
+
remove: nested.filesystem.remove,
|
|
1301
|
+
exportRootFilesystem: nested.filesystem.export,
|
|
1302
|
+
mountFs: nested.filesystem.mount,
|
|
1303
|
+
unmountFs: nested.filesystem.unmount,
|
|
1304
|
+
listMounts: nested.filesystem.listMounts,
|
|
1305
|
+
exec: async (c, ...args) => (await ensureVm(c, options)).exec(...args),
|
|
1306
|
+
execArgv: async (c, ...args) => (await ensureVm(c, options)).execArgv(...args),
|
|
1307
|
+
spawn: nested.process.spawn,
|
|
1308
|
+
waitProcess: nested.process.wait,
|
|
1309
|
+
killProcess: nested.process.kill,
|
|
1310
|
+
listProcesses: nested.process.list,
|
|
1311
|
+
processTree: nested.process.tree,
|
|
1312
|
+
getProcess: nested.process.get,
|
|
1313
|
+
writeProcessStdin: nested.process.writeStdin,
|
|
1314
|
+
closeProcessStdin: nested.process.closeStdin,
|
|
1315
|
+
openShell: nested.terminal.open,
|
|
1316
|
+
writeShell: nested.terminal.write,
|
|
1317
|
+
resizeShell: nested.terminal.resize,
|
|
1318
|
+
closeShell: nested.terminal.close,
|
|
1319
|
+
waitShell: nested.terminal.wait,
|
|
1320
|
+
httpRequest: nested.network.httpRequest,
|
|
1321
|
+
vmFetch: flat.vmFetch,
|
|
1322
|
+
vmFetchStreamStart: flat.vmFetchStreamStart,
|
|
1323
|
+
vmFetchStreamRead: flat.vmFetchStreamRead,
|
|
1324
|
+
vmFetchStreamCancel: flat.vmFetchStreamCancel,
|
|
1325
|
+
scheduleCron: nested.cron.schedule,
|
|
1326
|
+
listCronJobs: nested.cron.list,
|
|
1327
|
+
cancelCronJob: nested.cron.cancel,
|
|
1328
|
+
listAgents: nested.agents.list,
|
|
1329
|
+
openSession: nested.sessions.open,
|
|
1330
|
+
getSession: nested.sessions.get,
|
|
1331
|
+
listSessions: nested.sessions.list,
|
|
1332
|
+
deleteSession: nested.sessions.delete,
|
|
1333
|
+
unloadSession: nested.sessions.unload,
|
|
1334
|
+
prompt: nested.sessions.prompt,
|
|
1335
|
+
cancelPrompt: nested.sessions.cancelPrompt,
|
|
1336
|
+
respondPermission: nested.sessions.respondPermission,
|
|
1337
|
+
readHistory: nested.sessions.readHistory,
|
|
1338
|
+
getSessionConfig: nested.sessions.getConfig,
|
|
1339
|
+
setSessionConfigOption: nested.sessions.setConfigOption,
|
|
1340
|
+
getSessionCapabilities: nested.sessions.getCapabilities,
|
|
1341
|
+
getSessionAgentInfo: nested.sessions.getAgentInfo,
|
|
1342
|
+
listSoftware: nested.software.list,
|
|
1343
|
+
linkSoftware: nested.software.link,
|
|
1344
|
+
// Preview URLs are RivetKit-specific and intentionally stay flat.
|
|
1345
|
+
createPreviewUrl: flat.createPreviewUrl,
|
|
1346
|
+
expirePreviewUrl: flat.expirePreviewUrl,
|
|
1347
|
+
// Observe-only runtime health, also RivetKit-specific.
|
|
1348
|
+
health: flat.health
|
|
1349
|
+
};
|
|
826
1350
|
}
|
|
827
1351
|
var agentOsOptionKeys = [
|
|
828
1352
|
"software",
|
|
@@ -890,6 +1414,40 @@ function assertNoReservedKeys(kind, custom, builtIns) {
|
|
|
890
1414
|
throw new Error(`agentOS() ${kind} name is reserved: ${key}`);
|
|
891
1415
|
}
|
|
892
1416
|
}
|
|
1417
|
+
var INSPECTOR_TABS_ASSET_DIR = join(
|
|
1418
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
1419
|
+
"..",
|
|
1420
|
+
"assets",
|
|
1421
|
+
"inspector-tabs-app"
|
|
1422
|
+
);
|
|
1423
|
+
var AGENTOS_INSPECTOR_CONFIG = {
|
|
1424
|
+
tabs: [
|
|
1425
|
+
{
|
|
1426
|
+
id: "transcript",
|
|
1427
|
+
label: "Transcript",
|
|
1428
|
+
source: INSPECTOR_TABS_ASSET_DIR,
|
|
1429
|
+
icon: "comments"
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
id: "filesystem",
|
|
1433
|
+
label: "Filesystem",
|
|
1434
|
+
source: INSPECTOR_TABS_ASSET_DIR,
|
|
1435
|
+
icon: "folder-tree"
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
id: "system",
|
|
1439
|
+
label: "System",
|
|
1440
|
+
source: INSPECTOR_TABS_ASSET_DIR,
|
|
1441
|
+
icon: "layer-group"
|
|
1442
|
+
},
|
|
1443
|
+
// Processes/software/mounts live as sections inside the System tab.
|
|
1444
|
+
// `metadata` is dashboard-owned and not hideable (the schema only
|
|
1445
|
+
// accepts the six built-in ids below), so it stays.
|
|
1446
|
+
...["workflow", "database", "state", "queue", "connections", "console"].map(
|
|
1447
|
+
(id) => ({ id, hidden: true })
|
|
1448
|
+
)
|
|
1449
|
+
]
|
|
1450
|
+
};
|
|
893
1451
|
function createAgentOS(config = {}) {
|
|
894
1452
|
const split = splitConfig(config);
|
|
895
1453
|
const actorConfig = split.actorConfig;
|
|
@@ -945,6 +1503,11 @@ function createAgentOS(config = {}) {
|
|
|
945
1503
|
...actorConfig.options,
|
|
946
1504
|
enableActorRuntimeSocket: true
|
|
947
1505
|
},
|
|
1506
|
+
// Register the custom agent-os inspector tabs (and hide the built-in
|
|
1507
|
+
// rivetkit tabs) so the dashboard renders the agent-os UI. Without
|
|
1508
|
+
// this the shipped tab assets are never surfaced. A caller-supplied
|
|
1509
|
+
// inspector config wins.
|
|
1510
|
+
inspector: actorConfig.inspector ?? AGENTOS_INSPECTOR_CONFIG,
|
|
948
1511
|
db: db({ onMigrate: migrateAgentOsActorTables }),
|
|
949
1512
|
events: { ...actorConfig.events ?? {}, ...builtInEvents },
|
|
950
1513
|
actions: { ...actorConfig.actions ?? {}, ...actions },
|
|
@@ -1011,7 +1574,7 @@ function createAgentOS(config = {}) {
|
|
|
1011
1574
|
request.headers.forEach((value, key) => {
|
|
1012
1575
|
requestHeaders[key] = value;
|
|
1013
1576
|
});
|
|
1014
|
-
const response = await vm.httpRequest({
|
|
1577
|
+
const response = await vm.network.httpRequest({
|
|
1015
1578
|
port: rows[0].port,
|
|
1016
1579
|
path: `${target.pathname}${target.search}`,
|
|
1017
1580
|
method: request.method,
|
|
@@ -1041,8 +1604,6 @@ export {
|
|
|
1041
1604
|
createAgentOS as agentOS,
|
|
1042
1605
|
createAgentOS,
|
|
1043
1606
|
createAgentOsActions,
|
|
1044
|
-
defineSoftware,
|
|
1045
|
-
nodeModulesMount,
|
|
1046
1607
|
setup
|
|
1047
1608
|
};
|
|
1048
1609
|
//# sourceMappingURL=index.js.map
|