@themoltnet/pi-extension 0.1.0 → 0.3.0
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 +1 -1
- package/dist/index.d.ts +233 -9
- package/dist/index.js +9846 -391
- package/package.json +12 -6
- package/dist/commands/index.d.ts +0 -5
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js +0 -4
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/moltnet-reflect.d.ts +0 -3
- package/dist/commands/moltnet-reflect.d.ts.map +0 -1
- package/dist/commands/moltnet-reflect.js +0 -36
- package/dist/commands/moltnet-reflect.js.map +0 -1
- package/dist/commands/resolve-issue.d.ts +0 -3
- package/dist/commands/resolve-issue.d.ts.map +0 -1
- package/dist/commands/resolve-issue.js +0 -82
- package/dist/commands/resolve-issue.js.map +0 -1
- package/dist/commands/sandbox.d.ts +0 -3
- package/dist/commands/sandbox.d.ts.map +0 -1
- package/dist/commands/sandbox.js +0 -20
- package/dist/commands/sandbox.js.map +0 -1
- package/dist/commands/types.d.ts +0 -33
- package/dist/commands/types.d.ts.map +0 -1
- package/dist/commands/types.js +0 -2
- package/dist/commands/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/moltnet-tools.d.ts +0 -13
- package/dist/moltnet-tools.d.ts.map +0 -1
- package/dist/moltnet-tools.js +0 -126
- package/dist/moltnet-tools.js.map +0 -1
- package/dist/snapshot.d.ts +0 -41
- package/dist/snapshot.d.ts.map +0 -1
- package/dist/snapshot.js +0 -251
- package/dist/snapshot.js.map +0 -1
- package/dist/tool-operations.d.ts +0 -13
- package/dist/tool-operations.d.ts.map +0 -1
- package/dist/tool-operations.js +0 -142
- package/dist/tool-operations.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vm-manager.d.ts +0 -48
- package/dist/vm-manager.d.ts.map +0 -1
- package/dist/vm-manager.js +0 -222
- package/dist/vm-manager.js.map +0 -1
package/README.md
CHANGED
|
@@ -119,4 +119,4 @@ import {
|
|
|
119
119
|
} from '@themoltnet/pi-extension';
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
See `tools/src/
|
|
122
|
+
See `tools/src/tasks/fulfill-brief.ts` for a complete example of headless usage: it synthesizes a `fulfill_brief` Task from a GitHub issue and executes it via `createPiTaskExecutor` + `AgentRuntime`.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,233 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { BashOperations } from '@mariozechner/pi-coding-agent';
|
|
2
|
+
import { connect } from '@themoltnet/sdk';
|
|
3
|
+
import { EditOperations } from '@mariozechner/pi-coding-agent';
|
|
4
|
+
import { ExtensionAPI } from '@mariozechner/pi-coding-agent';
|
|
5
|
+
import { ReadOperations } from '@mariozechner/pi-coding-agent';
|
|
6
|
+
import { Task } from '../../../tasks/dist/index.d.ts';
|
|
7
|
+
import { TaskOutput } from '../../../tasks/dist/index.d.ts';
|
|
8
|
+
import { TaskReporter } from '../../../agent-runtime/dist/index.d.ts';
|
|
9
|
+
import { ToolDefinition } from '@mariozechner/pi-coding-agent';
|
|
10
|
+
import { VM } from '@earendil-works/gondolin';
|
|
11
|
+
import { WriteOperations } from '@mariozechner/pi-coding-agent';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Apply agent env vars to the host process, mirroring `moltnet start`.
|
|
15
|
+
* Resolves relative paths (e.g. GIT_CONFIG_GLOBAL) against the repo root.
|
|
16
|
+
*/
|
|
17
|
+
export declare function activateAgentEnv(agentEnv: Record<string, string | undefined>, repoRoot: string): void;
|
|
18
|
+
|
|
19
|
+
export declare function buildPiJudgeRecipeManifest(inputs: PiJudgeRecipeInputs): PiJudgeRecipeManifest;
|
|
20
|
+
|
|
21
|
+
export declare function computePiJudgeRecipeCid(inputs: PiJudgeRecipeInputs): PiJudgeRecipeCid;
|
|
22
|
+
|
|
23
|
+
export declare function createGondolinBashOps(vm: VM, localCwd: string): BashOperations;
|
|
24
|
+
|
|
25
|
+
export declare function createGondolinEditOps(vm: VM, localCwd: string): EditOperations;
|
|
26
|
+
|
|
27
|
+
export declare function createGondolinReadOps(vm: VM, localCwd: string): ReadOperations;
|
|
28
|
+
|
|
29
|
+
export declare function createGondolinWriteOps(vm: VM, localCwd: string): WriteOperations;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create all MoltNet tool definitions, ready to pass to `pi.registerTool()`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createMoltNetTools(config: MoltNetToolsConfig): ToolDefinition<any, any>[];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Factory that builds a pi-specific `executeTask` function suitable for
|
|
38
|
+
* injection into `AgentRuntime`. The returned function caches the resolved
|
|
39
|
+
* checkpoint across tasks so the second task hits the snapshot cache.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createPiTaskExecutor(opts: ExecutePiTaskOptions): (task: Task, reporter: TaskReporter) => Promise<TaskOutput>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Ensure a cached snapshot exists, building one if needed.
|
|
45
|
+
* Returns the absolute path to the qcow2 checkpoint file.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ensureSnapshot(options?: EnsureSnapshotOptions): Promise<string>;
|
|
48
|
+
|
|
49
|
+
export declare interface EnsureSnapshotOptions {
|
|
50
|
+
config?: SnapshotConfig;
|
|
51
|
+
onProgress?: (message: string) => void;
|
|
52
|
+
/** Max number of old snapshots to keep (default 1). */
|
|
53
|
+
maxCached?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Run one attempt of `task` in a freshly-resumed Gondolin VM. Owns the full
|
|
58
|
+
* lifecycle: resume VM → wire tools → pi session → close VM. Always returns
|
|
59
|
+
* a `TaskOutput` (failures surface as `status: 'failed'`); throws only on
|
|
60
|
+
* unrecoverable setup errors.
|
|
61
|
+
*/
|
|
62
|
+
export declare function executePiTask(task: Task, reporter: TaskReporter, opts: ExecutePiTaskOptions): Promise<TaskOutput>;
|
|
63
|
+
|
|
64
|
+
export declare interface ExecutePiTaskOptions {
|
|
65
|
+
/** MoltNet agent whose credentials the VM boots with. */
|
|
66
|
+
agentName: string;
|
|
67
|
+
/** Host cwd that the VM mounts at /workspace (defaults to `process.cwd()`). */
|
|
68
|
+
mountPath?: string;
|
|
69
|
+
/** LLM selection. */
|
|
70
|
+
provider: string;
|
|
71
|
+
model: string;
|
|
72
|
+
/** Extra hosts to allow in the sandbox egress policy. */
|
|
73
|
+
extraAllowedHosts?: string[];
|
|
74
|
+
/** Sandbox overrides (env, VFS shadows, resources). */
|
|
75
|
+
sandboxConfig?: SandboxConfig;
|
|
76
|
+
/** Forwarded to `buildPromptForTask` for per-type builders. */
|
|
77
|
+
promptExtras?: Record<string, unknown>;
|
|
78
|
+
/** Snapshot progress callback; defaults to stderr logging. */
|
|
79
|
+
onSnapshotProgress?: (message: string) => void;
|
|
80
|
+
/** Attempt number; defaults to 1. */
|
|
81
|
+
attemptN?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Optional pre-resolved checkpoint path. If omitted, `ensureSnapshot` is
|
|
84
|
+
* invoked. Useful for batch execution where the caller wants to cache
|
|
85
|
+
* across tasks.
|
|
86
|
+
*/
|
|
87
|
+
checkpointPath?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Resolve the main worktree root (where .moltnet/ lives — it's untracked,
|
|
92
|
+
* only exists in the main worktree, not in git worktrees).
|
|
93
|
+
*/
|
|
94
|
+
export declare function findMainWorktree(): string;
|
|
95
|
+
|
|
96
|
+
export declare function loadCredentials(agentDir: string): VmCredentials;
|
|
97
|
+
|
|
98
|
+
export declare interface ManagedVm {
|
|
99
|
+
vm: VM;
|
|
100
|
+
credentials: VmCredentials;
|
|
101
|
+
mountPath: string;
|
|
102
|
+
guestWorkspace: string;
|
|
103
|
+
agentDir: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare type MoltNetAgent = Awaited<ReturnType<typeof connect>>;
|
|
107
|
+
|
|
108
|
+
declare function moltnetExtension(pi: ExtensionAPI): void;
|
|
109
|
+
export default moltnetExtension;
|
|
110
|
+
|
|
111
|
+
declare interface MoltNetToolsConfig {
|
|
112
|
+
getAgent(): MoltNetAgent | null;
|
|
113
|
+
getDiaryId(): string | null;
|
|
114
|
+
getSessionErrors(): readonly TrackedError[];
|
|
115
|
+
clearSessionErrors(): void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
declare interface PiJudgeRecipeCid {
|
|
119
|
+
cid: string;
|
|
120
|
+
manifest: PiJudgeRecipeManifest;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
declare interface PiJudgeRecipeInputs {
|
|
124
|
+
judgePrompt: string;
|
|
125
|
+
rubric: string;
|
|
126
|
+
skillFragment?: string | null;
|
|
127
|
+
implementationSource?: string | null;
|
|
128
|
+
promptAsset?: string | null;
|
|
129
|
+
rubricAsset?: string | null;
|
|
130
|
+
skillSourcePath?: string | null;
|
|
131
|
+
overrides?: Partial<PiJudgeRecipeVersions>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare interface PiJudgeRecipeManifest {
|
|
135
|
+
kind: 'pi-judge-recipe/v1';
|
|
136
|
+
versions: PiJudgeRecipeVersions;
|
|
137
|
+
assets: {
|
|
138
|
+
promptAsset: string | null;
|
|
139
|
+
rubricAsset: string | null;
|
|
140
|
+
skillSourcePath: string | null;
|
|
141
|
+
};
|
|
142
|
+
hashes: {
|
|
143
|
+
judgePromptSha256: string;
|
|
144
|
+
rubricSha256: string;
|
|
145
|
+
skillFragmentSha256: string | null;
|
|
146
|
+
implementationSha256: string | null;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
declare interface PiJudgeRecipeVersions {
|
|
151
|
+
pi: string | null;
|
|
152
|
+
piExtension: string | null;
|
|
153
|
+
sdk: string | null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare function resolvePiJudgeRecipeVersions(): PiJudgeRecipeVersions;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Resume a VM from a checkpoint, inject credentials, configure egress +
|
|
160
|
+
* TLS. Returns the managed VM handle.
|
|
161
|
+
*/
|
|
162
|
+
export declare function resumeVm(config: VmConfig): Promise<ManagedVm>;
|
|
163
|
+
|
|
164
|
+
export declare interface SandboxConfig {
|
|
165
|
+
/** Snapshot build settings. */
|
|
166
|
+
snapshot?: {
|
|
167
|
+
/** Shell commands to run after the base setup. */
|
|
168
|
+
setupCommands?: string[];
|
|
169
|
+
/** Additional hosts to allow network access during build. */
|
|
170
|
+
allowedHosts?: string[];
|
|
171
|
+
/** Overlay disk size (default '3G'). */
|
|
172
|
+
overlaySize?: string;
|
|
173
|
+
};
|
|
174
|
+
/** VFS shadow settings — hide host paths from the guest. */
|
|
175
|
+
vfs?: {
|
|
176
|
+
/** Paths (relative to workspace root) to shadow from the host mount. */
|
|
177
|
+
shadow?: string[];
|
|
178
|
+
/** What to do with writes to shadowed paths: 'deny' or 'tmpfs' (default 'tmpfs'). */
|
|
179
|
+
shadowMode?: 'deny' | 'tmpfs';
|
|
180
|
+
};
|
|
181
|
+
/** Environment variable overrides for the guest VM (applied on top of defaults). */
|
|
182
|
+
env?: Record<string, string>;
|
|
183
|
+
/** VM resource allocation. */
|
|
184
|
+
resources?: {
|
|
185
|
+
/** Memory size in qemu syntax (default '1G'). */
|
|
186
|
+
memory?: string;
|
|
187
|
+
/** CPU count (default 2). */
|
|
188
|
+
cpus?: number;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Extract snapshot-specific config for backwards compat with ensureSnapshot. */
|
|
193
|
+
export declare type SnapshotConfig = NonNullable<SandboxConfig['snapshot']>;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Map a host-side absolute path to a guest-side /workspace path.
|
|
197
|
+
* Throws if the path escapes the workspace.
|
|
198
|
+
*/
|
|
199
|
+
export declare function toGuestPath(localCwd: string, localPath: string): string;
|
|
200
|
+
|
|
201
|
+
declare interface TrackedError {
|
|
202
|
+
toolName: string;
|
|
203
|
+
toolCallId: string;
|
|
204
|
+
input: Record<string, unknown>;
|
|
205
|
+
error: string;
|
|
206
|
+
timestamp: number;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export declare interface VmConfig {
|
|
210
|
+
/** Absolute path to the qcow2 checkpoint. */
|
|
211
|
+
checkpointPath: string;
|
|
212
|
+
/** MoltNet agent name (used to resolve credentials). */
|
|
213
|
+
agentName: string;
|
|
214
|
+
/** Host directory to mount at /workspace in the VM. */
|
|
215
|
+
mountPath: string;
|
|
216
|
+
/** Additional hosts to allow in egress policy. */
|
|
217
|
+
extraAllowedHosts?: string[];
|
|
218
|
+
/** Full sandbox config (vfs shadows, env overrides). */
|
|
219
|
+
sandboxConfig?: SandboxConfig;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export declare interface VmCredentials {
|
|
223
|
+
moltnetJson: string;
|
|
224
|
+
agentEnvRaw: string;
|
|
225
|
+
piAuthJson: string;
|
|
226
|
+
agentEnv: Record<string, string | undefined>;
|
|
227
|
+
gitconfig: string | null;
|
|
228
|
+
sshPrivateKey: string | null;
|
|
229
|
+
sshPublicKey: string | null;
|
|
230
|
+
allowedSigners: string | null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export { }
|