@rivet-dev/agentos-core 0.0.0-abc-fixes-1.d8c4d95 → 0.0.0-agent-acp-codex-session-benchmark.62b1f46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -48
- package/dist/agent-os.d.ts +215 -161
- package/dist/agent-os.js +1300 -2576
- package/dist/agentos-package.d.ts +27 -0
- package/dist/agentos-package.js +21 -0
- package/dist/base-filesystem.d.ts +1 -16
- package/dist/base-filesystem.js +1 -173
- package/dist/cron/cron-manager.d.ts +39 -14
- package/dist/cron/cron-manager.js +289 -128
- package/dist/cron/errors.d.ts +8 -0
- package/dist/cron/errors.js +16 -0
- package/dist/cron/index.d.ts +1 -3
- package/dist/cron/index.js +1 -2
- package/dist/cron/types.d.ts +2 -2
- package/dist/default-software.d.ts +8 -0
- package/dist/default-software.js +10 -0
- package/dist/filesystem-snapshot.d.ts +1 -1
- package/dist/filesystem-snapshot.js +1 -1
- package/dist/generated/AcpLimitsConfig.d.ts +4 -0
- package/dist/generated/AcpLimitsConfig.js +2 -0
- package/dist/generated/CreateVmConfig.d.ts +29 -0
- package/dist/generated/FsPermissionRule.d.ts +6 -0
- package/dist/generated/FsPermissionRule.js +1 -0
- package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
- package/dist/generated/FsPermissionRuleSet.js +1 -0
- package/dist/generated/FsPermissionScope.d.ts +3 -0
- package/dist/generated/FsPermissionScope.js +1 -0
- package/dist/generated/HttpLimitsConfig.d.ts +3 -0
- package/dist/generated/HttpLimitsConfig.js +2 -0
- package/dist/generated/JsModuleResolution.d.ts +1 -0
- package/dist/generated/JsModuleResolution.js +2 -0
- package/dist/generated/JsRuntimeConfig.d.ts +31 -0
- package/dist/generated/JsRuntimeConfig.js +1 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +8 -0
- package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
- package/dist/generated/JsRuntimePlatform.d.ts +1 -0
- package/dist/generated/JsRuntimePlatform.js +2 -0
- package/dist/generated/MountPluginDescriptor.d.ts +4 -0
- package/dist/generated/MountPluginDescriptor.js +2 -0
- package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
- package/dist/generated/NativeRootFilesystemConfig.js +1 -0
- package/dist/generated/PatternPermissionRule.d.ts +6 -0
- package/dist/generated/PatternPermissionRule.js +1 -0
- package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
- package/dist/generated/PatternPermissionRuleSet.js +1 -0
- package/dist/generated/PatternPermissionScope.d.ts +3 -0
- package/dist/generated/PatternPermissionScope.js +1 -0
- package/dist/generated/PermissionMode.d.ts +1 -0
- package/dist/generated/PermissionMode.js +2 -0
- package/dist/generated/PermissionsPolicy.d.ts +10 -0
- package/dist/generated/PermissionsPolicy.js +1 -0
- package/dist/generated/PluginLimitsConfig.d.ts +4 -0
- package/dist/generated/PluginLimitsConfig.js +2 -0
- package/dist/generated/PythonLimitsConfig.d.ts +6 -0
- package/dist/generated/PythonLimitsConfig.js +2 -0
- package/dist/generated/ResourceLimitsConfig.d.ts +25 -0
- package/dist/generated/ResourceLimitsConfig.js +2 -0
- package/dist/generated/RootFilesystemConfig.d.ts +9 -0
- package/dist/generated/RootFilesystemConfig.js +1 -0
- package/dist/generated/RootFilesystemEntry.d.ts +13 -0
- package/dist/generated/RootFilesystemEntry.js +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
- package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryKind.js +2 -0
- package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
- package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
- package/dist/generated/RootFilesystemMode.d.ts +1 -0
- package/dist/generated/RootFilesystemMode.js +2 -0
- package/dist/generated/ToolLimitsConfig.d.ts +10 -0
- package/dist/generated/ToolLimitsConfig.js +2 -0
- package/dist/generated/VmDnsConfig.d.ts +6 -0
- package/dist/generated/VmDnsConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +18 -0
- package/dist/generated/VmLimitsConfig.js +1 -0
- package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
- package/dist/generated/VmListenPolicyConfig.js +2 -0
- package/dist/generated/WasmLimitsConfig.d.ts +7 -0
- package/dist/generated/WasmLimitsConfig.js +2 -0
- package/dist/host-dir-mount.d.ts +5 -5
- package/dist/host-dir-mount.js +4 -4
- package/dist/host-tools-zod.js +27 -7
- package/dist/host-tools.d.ts +2 -9
- package/dist/host-tools.js +0 -18
- package/dist/index.d.ts +7 -4
- package/dist/index.js +6 -4
- package/dist/layers.d.ts +3 -3
- package/dist/layers.js +19 -10
- package/dist/memory-filesystem.d.ts +39 -0
- package/dist/memory-filesystem.js +375 -0
- package/dist/options-schema.d.ts +452 -0
- package/dist/options-schema.js +269 -0
- package/dist/overlay-filesystem.d.ts +1 -1
- package/dist/overlay-filesystem.js +3 -3
- package/dist/packages.d.ts +10 -123
- package/dist/packages.js +3 -329
- package/dist/runtime.d.ts +41 -184
- package/dist/sidecar/agentos-protocol.d.ts +232 -29
- package/dist/sidecar/agentos-protocol.js +456 -120
- package/dist/sidecar/binary.d.ts +2 -2
- package/dist/sidecar/binary.js +2 -2
- package/dist/sidecar/native-process-client.d.ts +5 -3
- package/dist/sidecar/native-process-client.js +5 -3
- package/dist/sidecar/permissions.d.ts +4 -3
- package/dist/sidecar/permissions.js +6 -23
- package/dist/sidecar/rpc-client.d.ts +74 -86
- package/dist/sidecar/rpc-client.js +422 -1418
- package/dist/test/file-system.d.ts +1 -1
- package/dist/test/file-system.js +3 -1
- package/dist/test/runtime.d.ts +2 -3
- package/dist/test/runtime.js +1 -1
- package/dist/test/terminal-harness.d.ts +5 -4
- package/dist/test/terminal-harness.js +12 -7
- package/dist/types.d.ts +12 -5
- package/package.json +37 -41
- package/dist/agents.d.ts +0 -63
- package/dist/agents.js +0 -42
- package/dist/cron/parse-schedule.d.ts +0 -25
- package/dist/cron/parse-schedule.js +0 -66
- package/dist/cron/schedule-driver.d.ts +0 -19
- package/dist/cron/timer-driver.d.ts +0 -17
- package/dist/cron/timer-driver.js +0 -61
- package/dist/runtime-compat.d.ts +0 -475
- package/dist/runtime-compat.js +0 -2010
- package/dist/sidecar/cargo.d.ts +0 -2
- package/dist/sidecar/cargo.js +0 -142
- package/fixtures/AGENTOS_SYSTEM_PROMPT.md +0 -21
- /package/dist/{cron/schedule-driver.js → generated/CreateVmConfig.js} +0 -0
|
@@ -1,157 +1,318 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { InvalidScheduleError, PastScheduleError } from "./errors.js";
|
|
2
|
+
const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
3
|
+
class TimerCronAlarmDriver {
|
|
4
|
+
timer = null;
|
|
5
|
+
set(alarm, wake) {
|
|
6
|
+
this.clear();
|
|
7
|
+
if (alarm.nextAlarmMs === undefined)
|
|
8
|
+
return;
|
|
9
|
+
const delay = Math.min(MAX_TIMER_DELAY_MS, Math.max(0, alarm.nextAlarmMs - Date.now()));
|
|
10
|
+
this.timer = setTimeout(() => {
|
|
11
|
+
this.timer = null;
|
|
12
|
+
if (delay === MAX_TIMER_DELAY_MS) {
|
|
13
|
+
this.set(alarm, wake);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
void wake(alarm.generation).catch((error) => {
|
|
17
|
+
console.error("[agent-os] cron wake failed", error);
|
|
18
|
+
});
|
|
19
|
+
}, delay);
|
|
20
|
+
this.timer.unref?.();
|
|
21
|
+
}
|
|
22
|
+
dispose() {
|
|
23
|
+
this.clear();
|
|
24
|
+
}
|
|
25
|
+
clear() {
|
|
26
|
+
if (this.timer !== null) {
|
|
27
|
+
clearTimeout(this.timer);
|
|
28
|
+
this.timer = null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
10
31
|
}
|
|
11
32
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
33
|
+
* Thin cron host adapter. The sidecar owns grammar, defaults, job/run state,
|
|
34
|
+
* overlap policy, counts, missed-fire coalescing, and alarm generations. This
|
|
35
|
+
* class only arms the host clock and routes actions containing host resources.
|
|
14
36
|
*/
|
|
15
37
|
export class CronManager {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
callback: () => this.executeJob(id),
|
|
32
|
-
});
|
|
33
|
-
const state = {
|
|
34
|
-
id,
|
|
35
|
-
schedule: options.schedule,
|
|
36
|
-
action: options.action,
|
|
37
|
-
overlap,
|
|
38
|
-
handle,
|
|
39
|
-
lastRun: undefined,
|
|
40
|
-
nextRun: resolved.nextRun,
|
|
41
|
-
runCount: 0,
|
|
42
|
-
running: false,
|
|
43
|
-
queued: false,
|
|
44
|
-
};
|
|
45
|
-
this.jobs.set(id, state);
|
|
46
|
-
return { id, cancel: () => this.cancel(id) };
|
|
38
|
+
transport;
|
|
39
|
+
session;
|
|
40
|
+
sidecarVm;
|
|
41
|
+
alarmDriver;
|
|
42
|
+
listeners = new Set();
|
|
43
|
+
callbacks = new Map();
|
|
44
|
+
callbackByJob = new Map();
|
|
45
|
+
callbackSequence = 0;
|
|
46
|
+
alarmGeneration = 0;
|
|
47
|
+
disposed = false;
|
|
48
|
+
constructor(transport, session, sidecarVm, alarmDriver = new TimerCronAlarmDriver()) {
|
|
49
|
+
this.transport = transport;
|
|
50
|
+
this.session = session;
|
|
51
|
+
this.sidecarVm = sidecarVm;
|
|
52
|
+
this.alarmDriver = alarmDriver;
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
async schedule(options) {
|
|
55
|
+
this.ensureActive();
|
|
56
|
+
let callbackId;
|
|
57
|
+
const action = (() => {
|
|
58
|
+
if (options.action.type !== "callback")
|
|
59
|
+
return options.action;
|
|
60
|
+
callbackId = this.allocateCallbackId();
|
|
61
|
+
this.callbacks.set(callbackId, {
|
|
62
|
+
fn: options.action.fn,
|
|
63
|
+
scheduled: false,
|
|
64
|
+
activeRuns: 0,
|
|
65
|
+
});
|
|
66
|
+
return { type: "callback", callbackId };
|
|
67
|
+
})();
|
|
68
|
+
try {
|
|
69
|
+
const response = await this.transport.scheduleCron(this.session, this.sidecarVm, {
|
|
70
|
+
...(options.id === undefined ? {} : { id: options.id }),
|
|
71
|
+
schedule: options.schedule,
|
|
72
|
+
action,
|
|
73
|
+
...(options.overlap === undefined
|
|
74
|
+
? {}
|
|
75
|
+
: { overlap: options.overlap }),
|
|
67
76
|
});
|
|
77
|
+
this.replaceJobCallback(response.id, callbackId);
|
|
78
|
+
this.applyAlarm(response.alarm);
|
|
79
|
+
return {
|
|
80
|
+
id: response.id,
|
|
81
|
+
cancel: () => this.cancel(response.id),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (callbackId !== undefined)
|
|
86
|
+
this.releaseCallback(callbackId);
|
|
87
|
+
throw normalizeScheduleError(options.schedule, error);
|
|
68
88
|
}
|
|
69
|
-
return result;
|
|
70
89
|
}
|
|
71
|
-
|
|
72
|
-
this.
|
|
90
|
+
async cancel(id) {
|
|
91
|
+
this.ensureActive();
|
|
92
|
+
const response = await this.transport.cancelCronJob(this.session, this.sidecarVm, id);
|
|
93
|
+
if (response.cancelled)
|
|
94
|
+
this.replaceJobCallback(id, undefined);
|
|
95
|
+
this.applyAlarm(response.alarm);
|
|
73
96
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.driver.dispose();
|
|
97
|
+
async list() {
|
|
98
|
+
this.ensureActive();
|
|
99
|
+
const response = await this.transport.listCronJobs(this.session, this.sidecarVm);
|
|
100
|
+
this.applyAlarm(response.alarm);
|
|
101
|
+
return response.jobs.map((job) => this.toJobInfo(job));
|
|
80
102
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
handler(event);
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
// Event handler errors must not crash the manager.
|
|
88
|
-
}
|
|
89
|
-
}
|
|
103
|
+
onEvent(handler) {
|
|
104
|
+
this.ensureActive();
|
|
105
|
+
this.listeners.add(handler);
|
|
90
106
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!state)
|
|
107
|
+
dispose() {
|
|
108
|
+
if (this.disposed)
|
|
94
109
|
return;
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
this.disposed = true;
|
|
111
|
+
this.alarmDriver.dispose();
|
|
112
|
+
this.listeners.clear();
|
|
113
|
+
this.callbacks.clear();
|
|
114
|
+
this.callbackByJob.clear();
|
|
115
|
+
}
|
|
116
|
+
async wake(generation) {
|
|
117
|
+
if (this.disposed)
|
|
97
118
|
return;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
const dispatch = await this.transport.wakeCron(this.session, this.sidecarVm, generation);
|
|
120
|
+
this.consumeDispatch(dispatch);
|
|
121
|
+
}
|
|
122
|
+
consumeDispatch(dispatch) {
|
|
123
|
+
if (this.disposed)
|
|
101
124
|
return;
|
|
125
|
+
this.applyAlarm(dispatch.alarm);
|
|
126
|
+
for (const event of dispatch.events)
|
|
127
|
+
this.emit(event);
|
|
128
|
+
for (const run of dispatch.runs) {
|
|
129
|
+
void this.executeRun(run).catch((error) => {
|
|
130
|
+
console.error("[agent-os] cron completion failed", error);
|
|
131
|
+
});
|
|
102
132
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const startTime = Date.now();
|
|
133
|
+
}
|
|
134
|
+
async executeRun(run) {
|
|
135
|
+
let errorMessage;
|
|
136
|
+
let callbackId;
|
|
108
137
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
138
|
+
const action = decodeWireAction(run.action);
|
|
139
|
+
if (action.type !== "callback") {
|
|
140
|
+
throw new Error(`sidecar returned non-host cron action to client: ${action.type}`);
|
|
141
|
+
}
|
|
142
|
+
callbackId = action.callbackId;
|
|
143
|
+
const route = this.callbacks.get(callbackId);
|
|
144
|
+
if (!route) {
|
|
145
|
+
throw new Error(`cron callback route not found: ${callbackId}`);
|
|
146
|
+
}
|
|
147
|
+
route.activeRuns++;
|
|
148
|
+
await route.fn();
|
|
116
149
|
}
|
|
117
150
|
catch (error) {
|
|
118
|
-
|
|
119
|
-
type: "cron:error",
|
|
120
|
-
jobId: state.id,
|
|
121
|
-
time: new Date(),
|
|
122
|
-
error: error,
|
|
123
|
-
});
|
|
151
|
+
errorMessage = error instanceof Error ? error.message : String(error);
|
|
124
152
|
}
|
|
125
153
|
finally {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
154
|
+
if (callbackId !== undefined) {
|
|
155
|
+
const route = this.callbacks.get(callbackId);
|
|
156
|
+
if (route) {
|
|
157
|
+
route.activeRuns = Math.max(0, route.activeRuns - 1);
|
|
158
|
+
this.releaseCallback(callbackId);
|
|
159
|
+
}
|
|
132
160
|
}
|
|
133
161
|
}
|
|
162
|
+
// VM disposal removes the sidecar scheduler and its active runs. Do not
|
|
163
|
+
// issue a completion request against a transport that is being torn down.
|
|
164
|
+
if (this.disposed)
|
|
165
|
+
return;
|
|
166
|
+
const dispatch = await this.transport.completeCronRun(this.session, this.sidecarVm, run.runId, errorMessage);
|
|
167
|
+
this.consumeDispatch(dispatch);
|
|
134
168
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
169
|
+
toJobInfo(job) {
|
|
170
|
+
const wireAction = decodeWireAction(job.action);
|
|
171
|
+
const action = wireAction.type === "callback"
|
|
172
|
+
? {
|
|
173
|
+
type: "callback",
|
|
174
|
+
fn: this.callbacks.get(wireAction.callbackId)?.fn ?? missingCallback,
|
|
175
|
+
}
|
|
176
|
+
: wireAction;
|
|
177
|
+
return {
|
|
178
|
+
id: job.id,
|
|
179
|
+
schedule: job.schedule,
|
|
180
|
+
action,
|
|
181
|
+
overlap: job.overlap,
|
|
182
|
+
...(job.lastRunMs === undefined
|
|
183
|
+
? {}
|
|
184
|
+
: { lastRun: new Date(job.lastRunMs) }),
|
|
185
|
+
...(job.nextRunMs === undefined
|
|
186
|
+
? {}
|
|
187
|
+
: { nextRun: new Date(job.nextRunMs) }),
|
|
188
|
+
runCount: job.runCount,
|
|
189
|
+
running: job.running,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
emit(event) {
|
|
193
|
+
let publicEvent;
|
|
194
|
+
if (event.kind === "fire") {
|
|
195
|
+
publicEvent = {
|
|
196
|
+
type: "cron:fire",
|
|
197
|
+
jobId: event.jobId,
|
|
198
|
+
time: new Date(event.timeMs),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
else if (event.kind === "complete") {
|
|
202
|
+
if (event.durationMs === undefined) {
|
|
203
|
+
throw new Error("sidecar complete cron event is missing durationMs");
|
|
146
204
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
205
|
+
publicEvent = {
|
|
206
|
+
type: "cron:complete",
|
|
207
|
+
jobId: event.jobId,
|
|
208
|
+
time: new Date(event.timeMs),
|
|
209
|
+
durationMs: event.durationMs,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
if (event.error === undefined) {
|
|
214
|
+
throw new Error("sidecar error cron event is missing error");
|
|
150
215
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
216
|
+
publicEvent = {
|
|
217
|
+
type: "cron:error",
|
|
218
|
+
jobId: event.jobId,
|
|
219
|
+
time: new Date(event.timeMs),
|
|
220
|
+
error: new Error(event.error),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
for (const listener of this.listeners) {
|
|
224
|
+
try {
|
|
225
|
+
listener(publicEvent);
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
console.warn("[agent-os] cron event listener failed", error);
|
|
154
229
|
}
|
|
155
230
|
}
|
|
156
231
|
}
|
|
232
|
+
applyAlarm(alarm) {
|
|
233
|
+
if (alarm.generation < this.alarmGeneration)
|
|
234
|
+
return;
|
|
235
|
+
this.alarmGeneration = alarm.generation;
|
|
236
|
+
this.alarmDriver.set(alarm, (generation) => this.wake(generation));
|
|
237
|
+
}
|
|
238
|
+
replaceJobCallback(jobId, callbackId) {
|
|
239
|
+
const previous = this.callbackByJob.get(jobId);
|
|
240
|
+
if (previous !== undefined && previous !== callbackId) {
|
|
241
|
+
this.callbackByJob.delete(jobId);
|
|
242
|
+
const route = this.callbacks.get(previous);
|
|
243
|
+
if (route)
|
|
244
|
+
route.scheduled = false;
|
|
245
|
+
this.releaseCallback(previous);
|
|
246
|
+
}
|
|
247
|
+
if (callbackId !== undefined) {
|
|
248
|
+
const route = this.callbacks.get(callbackId);
|
|
249
|
+
if (!route)
|
|
250
|
+
throw new Error(`cron callback route not found: ${callbackId}`);
|
|
251
|
+
route.scheduled = true;
|
|
252
|
+
this.callbackByJob.set(jobId, callbackId);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
releaseCallback(callbackId) {
|
|
256
|
+
const route = this.callbacks.get(callbackId);
|
|
257
|
+
if (route && !route.scheduled && route.activeRuns === 0) {
|
|
258
|
+
this.callbacks.delete(callbackId);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
allocateCallbackId() {
|
|
262
|
+
this.callbackSequence++;
|
|
263
|
+
if (!Number.isSafeInteger(this.callbackSequence)) {
|
|
264
|
+
throw new Error("cron callback id counter exhausted; recreate the VM");
|
|
265
|
+
}
|
|
266
|
+
return `host-cron-callback-${this.callbackSequence}`;
|
|
267
|
+
}
|
|
268
|
+
ensureActive() {
|
|
269
|
+
if (this.disposed)
|
|
270
|
+
throw new Error("cron manager is disposed");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function decodeWireAction(value) {
|
|
274
|
+
if (!value || typeof value !== "object") {
|
|
275
|
+
throw new TypeError("sidecar returned an invalid cron action");
|
|
276
|
+
}
|
|
277
|
+
const action = value;
|
|
278
|
+
if (action.type === "callback" && typeof action.callbackId === "string") {
|
|
279
|
+
return { type: "callback", callbackId: action.callbackId };
|
|
280
|
+
}
|
|
281
|
+
if (action.type === "exec" &&
|
|
282
|
+
typeof action.command === "string" &&
|
|
283
|
+
(action.args === undefined ||
|
|
284
|
+
(Array.isArray(action.args) &&
|
|
285
|
+
action.args.every((arg) => typeof arg === "string")))) {
|
|
286
|
+
return {
|
|
287
|
+
type: "exec",
|
|
288
|
+
command: action.command,
|
|
289
|
+
...(action.args === undefined ? {} : { args: action.args }),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
if (action.type === "session" &&
|
|
293
|
+
typeof action.agentType === "string" &&
|
|
294
|
+
typeof action.prompt === "string") {
|
|
295
|
+
return {
|
|
296
|
+
type: "session",
|
|
297
|
+
agentType: action.agentType,
|
|
298
|
+
prompt: action.prompt,
|
|
299
|
+
...(action.options === undefined
|
|
300
|
+
? {}
|
|
301
|
+
: {
|
|
302
|
+
options: action.options,
|
|
303
|
+
}),
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
throw new TypeError("sidecar returned an invalid cron action");
|
|
307
|
+
}
|
|
308
|
+
function normalizeScheduleError(schedule, error) {
|
|
309
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
310
|
+
if (message.includes("[invalid_schedule]"))
|
|
311
|
+
return new InvalidScheduleError(schedule);
|
|
312
|
+
if (message.includes("[past_schedule]"))
|
|
313
|
+
return new PastScheduleError(schedule);
|
|
314
|
+
return error;
|
|
315
|
+
}
|
|
316
|
+
async function missingCallback() {
|
|
317
|
+
throw new Error("cron callback route is unavailable");
|
|
157
318
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class InvalidScheduleError extends Error {
|
|
2
|
+
schedule;
|
|
3
|
+
constructor(schedule) {
|
|
4
|
+
super(`Invalid schedule "${schedule}". Expected a cron expression or an ISO-like one-shot timestamp.`);
|
|
5
|
+
this.name = "InvalidScheduleError";
|
|
6
|
+
this.schedule = schedule;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class PastScheduleError extends Error {
|
|
10
|
+
schedule;
|
|
11
|
+
constructor(schedule) {
|
|
12
|
+
super(`One-shot schedule "${schedule}" is already in the past.`);
|
|
13
|
+
this.name = "PastScheduleError";
|
|
14
|
+
this.schedule = schedule;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/dist/cron/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export { CronManager } from "./cron-manager.js";
|
|
2
|
-
export { InvalidScheduleError, PastScheduleError, } from "./
|
|
3
|
-
export type { ScheduleDriver, ScheduleEntry, ScheduleHandle, } from "./schedule-driver.js";
|
|
4
|
-
export { TimerScheduleDriver } from "./timer-driver.js";
|
|
2
|
+
export { InvalidScheduleError, PastScheduleError, } from "./errors.js";
|
|
5
3
|
export type { CronAction, CronEvent, CronEventHandler, CronJob, CronJobInfo, CronJobOptions, } from "./types.js";
|
package/dist/cron/index.js
CHANGED
package/dist/cron/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CreateSessionOptions } from "../agent-os.js";
|
|
2
|
-
import type { AgentType } from "../
|
|
2
|
+
import type { AgentType } from "../types.js";
|
|
3
3
|
export type CronAction = {
|
|
4
4
|
type: "session";
|
|
5
5
|
agentType: AgentType;
|
|
@@ -25,7 +25,7 @@ export interface CronJobOptions {
|
|
|
25
25
|
}
|
|
26
26
|
export interface CronJob {
|
|
27
27
|
id: string;
|
|
28
|
-
cancel(): void
|
|
28
|
+
cancel(): Promise<void>;
|
|
29
29
|
}
|
|
30
30
|
export interface CronJobInfo {
|
|
31
31
|
id: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SoftwarePackageRef } from "@agentos-software/manifest";
|
|
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`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveDefaultSoftware(): SoftwarePackageRef[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import common from "@agentos-software/common";
|
|
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`.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveDefaultSoftware() {
|
|
9
|
+
return [common].flat();
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { JsRuntimeConfig } from "./JsRuntimeConfig.js";
|
|
2
|
+
import type { NativeRootFilesystemConfig } from "./NativeRootFilesystemConfig.js";
|
|
3
|
+
import type { PermissionsPolicy } from "./PermissionsPolicy.js";
|
|
4
|
+
import type { RootFilesystemConfig } from "./RootFilesystemConfig.js";
|
|
5
|
+
import type { VmDnsConfig } from "./VmDnsConfig.js";
|
|
6
|
+
import type { VmLimitsConfig } from "./VmLimitsConfig.js";
|
|
7
|
+
import type { VmListenPolicyConfig } from "./VmListenPolicyConfig.js";
|
|
8
|
+
/**
|
|
9
|
+
* Canonical Rust-side VM config. Unknown fields must stay rejected here and by
|
|
10
|
+
* TypeScript thin-client option validation. Update both when an explicit wire
|
|
11
|
+
* option changes the generated VM config.
|
|
12
|
+
*/
|
|
13
|
+
export type CreateVmConfig = {
|
|
14
|
+
cwd?: string;
|
|
15
|
+
env?: Record<string, string>;
|
|
16
|
+
rootFilesystem?: RootFilesystemConfig;
|
|
17
|
+
permissions?: PermissionsPolicy;
|
|
18
|
+
limits?: VmLimitsConfig;
|
|
19
|
+
dns?: VmDnsConfig;
|
|
20
|
+
nativeRoot?: NativeRootFilesystemConfig;
|
|
21
|
+
listen?: VmListenPolicyConfig;
|
|
22
|
+
loopbackExemptPorts?: Array<number>;
|
|
23
|
+
jsRuntime?: JsRuntimeConfig;
|
|
24
|
+
/**
|
|
25
|
+
* VM-scoped instructions applied to every ACP session. Session-specific
|
|
26
|
+
* instructions are combined with these by the ACP sidecar adapter.
|
|
27
|
+
*/
|
|
28
|
+
agentAdditionalInstructions?: string;
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type JsModuleResolution = "node" | "relative" | "none";
|