alineo 0.5.0 → 0.5.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/dist/index.d.mts +7 -0
- package/dist/index.mjs +67 -41
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1082,6 +1082,13 @@ export declare class Alineo {
|
|
|
1082
1082
|
runId?: string;
|
|
1083
1083
|
/** Wire a `Memory` instance onto the returned agent — see `Alineo.memory`. */
|
|
1084
1084
|
memory?: Memory;
|
|
1085
|
+
/**
|
|
1086
|
+
* Don't probe the bridge before returning, and accept a Paused sandbox. For a paused
|
|
1087
|
+
* sandbox, whose frozen bridge can't answer until `agent.sandbox.resume()` — check it
|
|
1088
|
+
* yourself after resuming (`agent.adapter.waitReady()`), and fall back to
|
|
1089
|
+
* `Alineo.resume()` if it's gone.
|
|
1090
|
+
*/
|
|
1091
|
+
skipReadyCheck?: boolean;
|
|
1085
1092
|
}): Promise<Alineo>;
|
|
1086
1093
|
/**
|
|
1087
1094
|
* Connect to an already-running sandbox WITHOUT touching its Pi bridge — unlike
|
package/dist/index.mjs
CHANGED
|
@@ -1113,41 +1113,61 @@ async function loadAgent(specInput, opts) {
|
|
|
1113
1113
|
teamId: spec.teamId
|
|
1114
1114
|
});
|
|
1115
1115
|
console.log(`[agent] sandbox ready ${elapsed(t1)} (${sb.sandboxId})`);
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
console.log(`[agent]
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1116
|
+
const created = sb;
|
|
1117
|
+
try {
|
|
1118
|
+
console.log(`[agent] installing Pi CLI...`);
|
|
1119
|
+
const t2 = Date.now();
|
|
1120
|
+
await adapter.install(created, spec);
|
|
1121
|
+
console.log(`[agent] Pi CLI ready ${elapsed(t2)}`);
|
|
1122
|
+
for (const step of spec.setup ?? []) {
|
|
1123
|
+
console.log(`[agent] setup: ${step.name}...`);
|
|
1124
|
+
const ts = Date.now();
|
|
1125
|
+
const cmd = step.cwd ? `cd ${step.cwd} && ${step.run}` : step.run;
|
|
1126
|
+
await created.exec(cmd);
|
|
1127
|
+
console.log(`[agent] setup done ${elapsed(ts)} (${step.name})`);
|
|
1128
|
+
}
|
|
1129
|
+
console.log(`[agent] checkpointing...`);
|
|
1130
|
+
const t3 = Date.now();
|
|
1131
|
+
const snapshotId = await created.checkpoint();
|
|
1132
|
+
await store.save({
|
|
1133
|
+
specName: spec.name,
|
|
1134
|
+
setupHash,
|
|
1135
|
+
snapshotId,
|
|
1136
|
+
createdAt: Date.now()
|
|
1137
|
+
});
|
|
1138
|
+
console.log(`[agent] checkpoint done ${elapsed(t3)}`);
|
|
1139
|
+
} catch (err) {
|
|
1140
|
+
await created.close().catch(() => {});
|
|
1141
|
+
await egressGate?.stop().catch(() => {});
|
|
1142
|
+
throw err;
|
|
1126
1143
|
}
|
|
1127
|
-
console.log(`[agent] checkpointing...`);
|
|
1128
|
-
const t3 = Date.now();
|
|
1129
|
-
const snapshotId = await sb.checkpoint();
|
|
1130
|
-
await store.save({
|
|
1131
|
-
specName: spec.name,
|
|
1132
|
-
setupHash,
|
|
1133
|
-
snapshotId,
|
|
1134
|
-
createdAt: Date.now()
|
|
1135
|
-
});
|
|
1136
|
-
console.log(`[agent] checkpoint done ${elapsed(t3)}`);
|
|
1137
1144
|
}
|
|
1138
1145
|
if (!sb) throw new Error("internal error: sandbox was neither restored nor created");
|
|
1139
1146
|
egressGate?.bind(sb);
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1147
|
+
try {
|
|
1148
|
+
for (const cb of credentialBindings) {
|
|
1149
|
+
if (cb.approval === "hold") continue;
|
|
1150
|
+
await sb.credentials.set(cb.name, cb.value, cb.binding, cb.source);
|
|
1151
|
+
}
|
|
1152
|
+
resolvedEnv.ALINEO_SANDBOX_ID = sb.sandboxId;
|
|
1153
|
+
await adapter.configure(sb, spec, resolvedEnv);
|
|
1154
|
+
console.log(`[agent] starting bridge...`);
|
|
1155
|
+
const t4 = Date.now();
|
|
1156
|
+
await adapter.startBridge(sb);
|
|
1157
|
+
await adapter.waitReady();
|
|
1158
|
+
console.log(`[agent] bridge ready ${elapsed(t4)}`);
|
|
1159
|
+
} catch (err) {
|
|
1160
|
+
await sb.close().catch(() => {});
|
|
1161
|
+
await egressGate?.stop().catch(() => {});
|
|
1162
|
+
if (!fromSnapshot) throw err;
|
|
1163
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
1164
|
+
console.log(`[agent] restored snapshot didn't start (${reason}) — discarding it and rebuilding...`);
|
|
1165
|
+
await store.delete(spec.name);
|
|
1166
|
+
return loadAgent(specInput, {
|
|
1167
|
+
...opts,
|
|
1168
|
+
rebuild: true
|
|
1169
|
+
});
|
|
1143
1170
|
}
|
|
1144
|
-
resolvedEnv.ALINEO_SANDBOX_ID = sb.sandboxId;
|
|
1145
|
-
await adapter.configure(sb, spec, resolvedEnv);
|
|
1146
|
-
console.log(`[agent] starting bridge...`);
|
|
1147
|
-
const t4 = Date.now();
|
|
1148
|
-
await adapter.startBridge(sb);
|
|
1149
|
-
await adapter.waitReady();
|
|
1150
|
-
console.log(`[agent] bridge ready ${elapsed(t4)}`);
|
|
1151
1171
|
console.log(`[agent] total ${elapsed(t0)}${fromSnapshot ? " (from snapshot)" : ""}`);
|
|
1152
1172
|
return {
|
|
1153
1173
|
sandbox: sb,
|
|
@@ -1280,14 +1300,15 @@ async function reattachAgent(sandboxId, opts) {
|
|
|
1280
1300
|
runId,
|
|
1281
1301
|
resourceId: spec.resourceId ?? spec.name,
|
|
1282
1302
|
teamId: spec.teamId,
|
|
1283
|
-
resources: spec.resources ?? config.defaults.resources
|
|
1303
|
+
resources: spec.resources ?? config.defaults.resources,
|
|
1304
|
+
allowPaused: opts.skipReadyCheck === true
|
|
1284
1305
|
});
|
|
1285
1306
|
console.log(`[agent] connected ${elapsed(t1)}`);
|
|
1286
1307
|
const adapter = new PiAdapter();
|
|
1287
1308
|
await adapter.reattachBridge(sb);
|
|
1288
1309
|
const t2 = Date.now();
|
|
1289
|
-
await adapter.waitReady(5e3);
|
|
1290
|
-
console.log(`[agent] bridge reattached ${elapsed(t2)}`);
|
|
1310
|
+
if (!opts.skipReadyCheck) await adapter.waitReady(5e3);
|
|
1311
|
+
console.log(`[agent] bridge reattached ${elapsed(t2)}${opts.skipReadyCheck ? " (not probed)" : ""}`);
|
|
1291
1312
|
console.log(`[agent] total ${elapsed(t0)}`);
|
|
1292
1313
|
return {
|
|
1293
1314
|
sandbox: sb,
|
|
@@ -1357,15 +1378,20 @@ async function spawnChild(self, childSpecPath, opts = {}) {
|
|
|
1357
1378
|
teamId: childSpec.teamId
|
|
1358
1379
|
});
|
|
1359
1380
|
console.log(`[agent] fork ready ${elapsed(t0)} (${forkedSb.sandboxId})`);
|
|
1360
|
-
for (const { name, value, binding, source } of childCredentialBindings) await forkedSb.credentials.set(name, value, binding, source);
|
|
1361
1381
|
const adapter = new PiAdapter();
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1382
|
+
try {
|
|
1383
|
+
for (const { name, value, binding, source } of childCredentialBindings) await forkedSb.credentials.set(name, value, binding, source);
|
|
1384
|
+
childEnv.ALINEO_SANDBOX_ID = forkedSb.sandboxId;
|
|
1385
|
+
await adapter.configure(forkedSb, childSpec, childEnv);
|
|
1386
|
+
console.log(`[agent] starting bridge...`);
|
|
1387
|
+
const t1 = Date.now();
|
|
1388
|
+
await adapter.startBridge(forkedSb, Object.keys(self.env));
|
|
1389
|
+
await adapter.waitReady();
|
|
1390
|
+
console.log(`[agent] bridge ready ${elapsed(t1)}`);
|
|
1391
|
+
} catch (err) {
|
|
1392
|
+
await forkedSb.close().catch(() => {});
|
|
1393
|
+
throw err;
|
|
1394
|
+
}
|
|
1369
1395
|
return {
|
|
1370
1396
|
sandbox: forkedSb,
|
|
1371
1397
|
spec: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alineo",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@alineo-labs/core": "0.4.1",
|
|
32
32
|
"@alineo-labs/memory": "0.2.2",
|
|
33
|
-
"@alineo-labs/sandbox": "0.4.
|
|
33
|
+
"@alineo-labs/sandbox": "0.4.2",
|
|
34
34
|
"zod": "^4.4.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|