@themoltnet/pi-extension 0.38.12 → 0.38.14
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.ts +8 -0
- package/dist/index.js +37 -6
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createPiOtelExtension } from '@themoltnet/pi-runtime';
|
|
2
2
|
import { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
3
3
|
import { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
4
|
+
import { GondolinVmRetirement } from '@themoltnet/pi-runtime';
|
|
4
5
|
import { PiOtelOptions } from '@themoltnet/pi-runtime';
|
|
5
6
|
import { ProviderErrorRetryUi } from '@themoltnet/pi-runtime';
|
|
7
|
+
import { VM } from '@earendil-works/gondolin';
|
|
6
8
|
|
|
7
9
|
export { createPiOtelExtension }
|
|
8
10
|
|
|
@@ -13,4 +15,10 @@ export default moltnetExtension;
|
|
|
13
15
|
|
|
14
16
|
export { PiOtelOptions }
|
|
15
17
|
|
|
18
|
+
export declare function retirePiExtensionVm(config: {
|
|
19
|
+
activeVm: Pick<VM, 'close'>;
|
|
20
|
+
retirement: GondolinVmRetirement;
|
|
21
|
+
release: () => void;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
|
|
16
24
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { execFileSync } from "node:child_process";
|
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createBashTool, createEditTool, createFindTool, createGrepTool, createLsTool, createReadTool, createWriteTool } from "@earendil-works/pi-coding-agent";
|
|
5
|
-
import { HOST_EXEC_DEFAULT_BASE_ENV, activateAgentEnv, buildWorkspaceMountInstructions, createGondolinBashOps, createGondolinEditOps, createGondolinFindOps, createGondolinLsOps, createGondolinReadOps, createGondolinWriteOps, createMoltNetTools, createPiOtelExtension, ensureSnapshot, executeGondolinGrep, findMainWorktree, resumeVm } from "@themoltnet/pi-runtime";
|
|
5
|
+
import { HOST_EXEC_DEFAULT_BASE_ENV, activateAgentEnv, buildWorkspaceMountInstructions, createGondolinBashOps, createGondolinEditOps, createGondolinFindOps, createGondolinLsOps, createGondolinReadOps, createGondolinToolLifecycle, createGondolinWriteOps, createMoltNetTools, createPiOtelExtension, ensureSnapshot, executeGondolinGrep, findMainWorktree, resumeVm } from "@themoltnet/pi-runtime";
|
|
6
6
|
import { connect } from "@themoltnet/sdk/node";
|
|
7
7
|
//#region src/commands/moltnet-reflect.ts
|
|
8
8
|
var registerMoltnetReflectCommand = (pi, state) => {
|
|
@@ -157,6 +157,13 @@ function createPiProviderErrorRetryUi(ctx) {
|
|
|
157
157
|
}
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
+
async function retirePiExtensionVm(config) {
|
|
161
|
+
try {
|
|
162
|
+
if (!config.retirement.backendRetired) await config.activeVm.close();
|
|
163
|
+
} finally {
|
|
164
|
+
config.release();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
160
167
|
function moltnetExtension(pi) {
|
|
161
168
|
pi.registerFlag("agent", {
|
|
162
169
|
description: "MoltNet agent name (required — pass --agent <name>)",
|
|
@@ -255,6 +262,31 @@ function moltnetExtension(pi) {
|
|
|
255
262
|
})();
|
|
256
263
|
return vmStarting;
|
|
257
264
|
}
|
|
265
|
+
async function releaseRetiredVm(activeVm, retirement, ctx) {
|
|
266
|
+
try {
|
|
267
|
+
await retirePiExtensionVm({
|
|
268
|
+
activeVm,
|
|
269
|
+
retirement,
|
|
270
|
+
release: () => {
|
|
271
|
+
if (vm === activeVm) {
|
|
272
|
+
vm = null;
|
|
273
|
+
vmStarting = null;
|
|
274
|
+
guestWorkspace = initialGuestWorkspace;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
} finally {
|
|
279
|
+
ctx?.ui.setStatus("sandbox", ctx.ui.theme.fg("warning", "Sandbox: retired; restart pending"));
|
|
280
|
+
ctx?.ui.notify(`Sandbox retired after ${retirement.trigger}; the next tool call will start a fresh VM.`, "warning");
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
function createSandboxBashOperations(activeVm, ctx) {
|
|
284
|
+
const lifecycle = createGondolinToolLifecycle();
|
|
285
|
+
return createGondolinBashOps(activeVm, localCwd, guestWorkspace, {
|
|
286
|
+
lifecycle,
|
|
287
|
+
retireVm: (retirement) => releaseRetiredVm(activeVm, retirement, ctx)
|
|
288
|
+
});
|
|
289
|
+
}
|
|
258
290
|
pi.on("session_start", async (_event, ctx) => {
|
|
259
291
|
await ensureVm(ctx);
|
|
260
292
|
});
|
|
@@ -297,7 +329,7 @@ function moltnetExtension(pi) {
|
|
|
297
329
|
...localBash,
|
|
298
330
|
label: "bash (sandbox)",
|
|
299
331
|
async execute(id, params, signal, onUpdate, ctx) {
|
|
300
|
-
return createBashTool(localCwd, { operations:
|
|
332
|
+
return createBashTool(localCwd, { operations: createSandboxBashOperations(await ensureVm(ctx), ctx) }).execute(id, params, signal, onUpdate);
|
|
301
333
|
}
|
|
302
334
|
});
|
|
303
335
|
pi.registerTool({
|
|
@@ -318,9 +350,8 @@ function moltnetExtension(pi) {
|
|
|
318
350
|
return executeGondolinGrep(await ensureVm(ctx), localCwd, guestWorkspace, params, signal);
|
|
319
351
|
}
|
|
320
352
|
});
|
|
321
|
-
pi.on("user_bash", (_event,
|
|
322
|
-
|
|
323
|
-
return { operations: createGondolinBashOps(vm, localCwd, guestWorkspace) };
|
|
353
|
+
pi.on("user_bash", async (_event, ctx) => {
|
|
354
|
+
return { operations: createSandboxBashOperations(await ensureVm(ctx), ctx) };
|
|
324
355
|
});
|
|
325
356
|
const sessionErrors = [];
|
|
326
357
|
const moltnetTools = createMoltNetTools({
|
|
@@ -447,4 +478,4 @@ function moltnetExtension(pi) {
|
|
|
447
478
|
registerMoltnetReflectCommand(pi, state);
|
|
448
479
|
}
|
|
449
480
|
//#endregion
|
|
450
|
-
export { createPiOtelExtension, createPiProviderErrorRetryUi, moltnetExtension as default };
|
|
481
|
+
export { createPiOtelExtension, createPiProviderErrorRetryUi, moltnetExtension as default, retirePiExtensionVm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@themoltnet/pi-extension",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MoltNet pi extension — sandboxed tool execution in Gondolin VMs with MoltNet identity and persistent memory",
|
|
6
6
|
"keywords": [
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@earendil-works/gondolin": "^0.
|
|
37
|
-
"@themoltnet/
|
|
38
|
-
"@themoltnet/
|
|
39
|
-
"@themoltnet/
|
|
36
|
+
"@earendil-works/gondolin": "^0.12.0",
|
|
37
|
+
"@themoltnet/os-keyring": "0.2.0",
|
|
38
|
+
"@themoltnet/pi-runtime": "0.12.1",
|
|
39
|
+
"@themoltnet/sdk": "0.137.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@earendil-works/pi-ai": "0.79.4",
|