anon-pi 0.2.0 → 0.4.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/Dockerfile.pi +29 -19
- package/README.md +33 -14
- package/dist/anon-pi.d.ts +93 -24
- package/dist/anon-pi.d.ts.map +1 -1
- package/dist/anon-pi.js +197 -64
- package/dist/anon-pi.js.map +1 -1
- package/dist/cli.js +43 -9
- package/dist/cli.js.map +1 -1
- package/examples/Dockerfile.pi-webveil +15 -9
- package/package.json +1 -1
- package/src/anon-pi.ts +231 -71
- package/src/cli.ts +56 -8
package/dist/anon-pi.js
CHANGED
|
@@ -24,26 +24,55 @@ import { fileURLToPath } from 'node:url';
|
|
|
24
24
|
/** The container path the workdir is mounted at (pi's cwd). */
|
|
25
25
|
export const CONTAINER_WORKDIR = '/work';
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* extensions.
|
|
27
|
+
* The container path pi uses as its config+state home. anon-pi mounts a
|
|
28
|
+
* PERSISTENT host dir here (Model B), so everything pi writes, sessions,
|
|
29
|
+
* history, settings (your model choice), `pi install`ed extensions, downloaded
|
|
30
|
+
* bin/fd, survives across launches. Statefulness is the default; --ephemeral
|
|
31
|
+
* mounts a throwaway dir here instead.
|
|
33
32
|
*/
|
|
34
|
-
export const
|
|
33
|
+
export const CONTAINER_AGENT_DIR = '/root/.pi/agent';
|
|
35
34
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
35
|
+
* Where the image STAGES its first-launch defaults (extensions + trust.json).
|
|
36
|
+
* NOT the agent dir, so it never conflicts with the persistent mount. The
|
|
37
|
+
* entrypoint promotes these into the mounted agent dir only when the home is
|
|
38
|
+
* FRESH (Model C seed-if-fresh).
|
|
40
39
|
*/
|
|
41
|
-
export const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
export const CONTAINER_STAGE_DIR = '/opt/anon-pi-seed/agent';
|
|
41
|
+
/**
|
|
42
|
+
* Where anon-pi mounts the canonical models.json (from `import`) read-only, so
|
|
43
|
+
* the first-launch seed can copy it into the fresh home alongside the image's
|
|
44
|
+
* staged defaults. Read-only: the container never writes back to the host seed.
|
|
45
|
+
*/
|
|
46
|
+
export const CONTAINER_MODELS_SEED = '/anon-pi-seed/models.json';
|
|
47
|
+
/** Marker file written into the agent dir after seeding; holds the seed version. */
|
|
48
|
+
export const SEED_MARKER = '.anon-pi-seed';
|
|
49
|
+
/** The single file the host-side seed carries: pi's model/provider registry. */
|
|
45
50
|
export const MODELS_FILE = 'models.json';
|
|
46
|
-
|
|
51
|
+
/**
|
|
52
|
+
* containerRunCmd builds the container command: on a FRESH home (no seed
|
|
53
|
+
* marker), promote the image's staged defaults + the mounted models.json into
|
|
54
|
+
* the persistent agent dir and stamp the marker; then exec pi. On a seeded home
|
|
55
|
+
* it does nothing but exec pi, so pi's persisted state (incl. anything you
|
|
56
|
+
* `pi install`ed or models pi added) is used as-is and NEVER clobbered.
|
|
57
|
+
*
|
|
58
|
+
* seedVersion is written into the marker so a future image can re-seed changed
|
|
59
|
+
* defaults on a version bump; v1 only seeds when the marker is absent.
|
|
60
|
+
*/
|
|
61
|
+
export function containerRunCmd(seedVersion) {
|
|
62
|
+
const agent = CONTAINER_AGENT_DIR;
|
|
63
|
+
const marker = `${agent}/${SEED_MARKER}`;
|
|
64
|
+
return (`mkdir -p "${agent}" && ` +
|
|
65
|
+
`if [ ! -f "${marker}" ]; then ` +
|
|
66
|
+
// image-staged defaults (extensions, trust.json), if the image provides them
|
|
67
|
+
`{ [ -d "${CONTAINER_STAGE_DIR}" ] && cp -a "${CONTAINER_STAGE_DIR}/." "${agent}/" || true; } && ` +
|
|
68
|
+
// the host-imported models.json, if mounted
|
|
69
|
+
`{ [ -f "${CONTAINER_MODELS_SEED}" ] && cp "${CONTAINER_MODELS_SEED}" "${agent}/${MODELS_FILE}" || true; } && ` +
|
|
70
|
+
`printf '%s\\n' "${seedVersion}" > "${marker}"; ` +
|
|
71
|
+
`fi && ` +
|
|
72
|
+
`exec pi`);
|
|
73
|
+
}
|
|
74
|
+
/** The seed version anon-pi stamps when it seeds a fresh home (bump to re-seed). */
|
|
75
|
+
export const SEED_VERSION = '1';
|
|
47
76
|
/** A user-facing error whose message is meant to be printed verbatim (no stack). */
|
|
48
77
|
export class AnonPiError extends Error {
|
|
49
78
|
}
|
|
@@ -56,12 +85,33 @@ export function resolveAnonPiHome(env) {
|
|
|
56
85
|
: join(env.home, '.config');
|
|
57
86
|
return join(base, 'anon-pi');
|
|
58
87
|
}
|
|
59
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* The CANONICAL host seed dir holding models.json (written by `anon-pi import`).
|
|
90
|
+
* Mounted read-only so the first-launch seed can copy models.json into a fresh
|
|
91
|
+
* persistent home. Workdir-independent (import does not need a workdir).
|
|
92
|
+
*/
|
|
60
93
|
export function resolveConfigSeed(env) {
|
|
61
94
|
if (env.configSeed)
|
|
62
95
|
return resolve(env.configSeed);
|
|
63
96
|
return join(resolveAnonPiHome(env), 'agent');
|
|
64
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Encode an absolute path into a directory name using pi's OWN convention (see
|
|
100
|
+
* pi coding-agent session-manager: `--${cwd without leading slash, / \ : -> -}--`),
|
|
101
|
+
* so an anon-pi state dir is readable and matches pi's mental model (no opaque
|
|
102
|
+
* hash). e.g. /home/u/dev/x -> --home-u-dev-x--
|
|
103
|
+
*/
|
|
104
|
+
export function pathSlug(absPath) {
|
|
105
|
+
return `--${absPath.replace(/^[/\\]/, '').replace(/[/\\:]/g, '-')}--`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The persistent per-workdir state dir on the host (mounted at the container's
|
|
109
|
+
* ~/.pi/agent). Keyed by the workdir via pi's path-slug convention:
|
|
110
|
+
* <anonPiHome>/state/<slug>/agent
|
|
111
|
+
*/
|
|
112
|
+
export function stateAgentDir(env, absWorkdir) {
|
|
113
|
+
return join(resolveAnonPiHome(env), 'state', pathSlug(absWorkdir), 'agent');
|
|
114
|
+
}
|
|
65
115
|
/**
|
|
66
116
|
* Normalise a proxy-less host:port key from an ANON_PI_LLM value or a provider
|
|
67
117
|
* baseUrl, so `192.168.1.150:8080` matches `http://192.168.1.150:8080/v1`.
|
|
@@ -133,15 +183,25 @@ export function resolveSourceModelsPath(env) {
|
|
|
133
183
|
/**
|
|
134
184
|
* Build the run plan from the environment + the (optional) workdir arg. PURE: it
|
|
135
185
|
* resolves paths and composes the netcage argv, performing NO filesystem writes
|
|
136
|
-
* or spawns. It THROWS AnonPiError for the
|
|
137
|
-
*
|
|
186
|
+
* or spawns. It THROWS AnonPiError for the required inputs (image, llm, proxy).
|
|
187
|
+
*
|
|
188
|
+
* Statefulness (Model B): a persistent per-workdir host dir is mounted at the
|
|
189
|
+
* container's ~/.pi/agent, so pi's sessions/history/settings/extensions persist.
|
|
190
|
+
* First-launch seed (Model C): when that home is FRESH, the container run
|
|
191
|
+
* command promotes the image's staged defaults + the imported models.json into
|
|
192
|
+
* it and stamps a marker; thereafter pi OWNS the home and nothing is clobbered.
|
|
193
|
+
*
|
|
194
|
+
* `modelsSeedExists` reports whether the canonical import models.json exists (so
|
|
195
|
+
* it is mounted for the seed); `stateExists` reports whether this workdir's
|
|
196
|
+
* state home already exists (so `fresh` is known).
|
|
138
197
|
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
198
|
+
* --ephemeral mounts NO writable state: pi writes to the container's own
|
|
199
|
+
* filesystem, which netcage runs with `--rm`, so it is destroyed when the
|
|
200
|
+
* container exits. Nothing writable ever touches a host path; there is no
|
|
201
|
+
* cleanup and no leftover-on-crash. (The read-only models.json seed is still
|
|
202
|
+
* mounted; it is a single file anon-pi never writes to.)
|
|
143
203
|
*/
|
|
144
|
-
export function buildRunPlan(env, workdirArg,
|
|
204
|
+
export function buildRunPlan(env, workdirArg, modelsSeedExists, stateExists) {
|
|
145
205
|
if (!env.image || env.image.trim() === '') {
|
|
146
206
|
// dockerfilePath is injected (cli.ts resolves the shipped Dockerfile.pi via
|
|
147
207
|
// import.meta.url; tests pass a fixed path). Every command is emitted
|
|
@@ -149,6 +209,7 @@ export function buildRunPlan(env, workdirArg, seedModelsExists) {
|
|
|
149
209
|
// leading spaces into the Dockerfile and break the EOF terminator, so we
|
|
150
210
|
// point at the shipped file instead of printing a heredoc.
|
|
151
211
|
const df = env.dockerfilePath ?? 'Dockerfile.pi';
|
|
212
|
+
const wv = env.webveilDockerfilePath ?? 'examples/Dockerfile.pi-webveil';
|
|
152
213
|
throw new AnonPiError('anon-pi: set ANON_PI_IMAGE to a container image that has `pi` on its PATH.\n' +
|
|
153
214
|
'\n' +
|
|
154
215
|
'No image yet? A ready Dockerfile.pi ships with anon-pi (it installs the\n' +
|
|
@@ -157,53 +218,88 @@ export function buildRunPlan(env, workdirArg, seedModelsExists) {
|
|
|
157
218
|
`podman build -t localhost/anon-pi-pi:latest -f "${df}" "$(dirname "${df}")"\n` +
|
|
158
219
|
'export ANON_PI_IMAGE=localhost/anon-pi-pi:latest\n' +
|
|
159
220
|
'\n' +
|
|
221
|
+
'Or the fuller example with the pi-webveil extension + a local SearXNG\n' +
|
|
222
|
+
'(anonymized web search):\n' +
|
|
223
|
+
'\n' +
|
|
224
|
+
`podman build -t localhost/anon-pi-webveil:latest -f "${wv}" "$(dirname "${wv}")"\n` +
|
|
225
|
+
'export ANON_PI_IMAGE=localhost/anon-pi-webveil:latest\n' +
|
|
226
|
+
'\n' +
|
|
160
227
|
'See the README (Providing a pi image) for details and a community-image note.');
|
|
161
228
|
}
|
|
162
229
|
if (!env.llmDirect || env.llmDirect.trim() === '') {
|
|
163
230
|
throw new AnonPiError('anon-pi: set ANON_PI_LLM to the RFC1918/link-local IP[:port] of the local model pi should reach directly (e.g. ANON_PI_LLM=192.168.1.150:8080). All other egress stays forced through the proxy.');
|
|
164
231
|
}
|
|
232
|
+
if (!env.proxy || env.proxy.trim() === '') {
|
|
233
|
+
// No default: this is an anonymity tool, so the proxy is REQUIRED and never
|
|
234
|
+
// guessed (mirrors netcage, which fails closed without --proxy). A silent
|
|
235
|
+
// default would anonymize through the wrong endpoint, or fail deep in the
|
|
236
|
+
// jail with a confusing DNS error, if the guessed proxy is not actually up.
|
|
237
|
+
throw new AnonPiError('anon-pi: set ANON_PI_PROXY to your socks5h proxy. anon-pi has no default:\n' +
|
|
238
|
+
'the proxy is what makes the session anonymous, so it is never guessed.\n' +
|
|
239
|
+
'\n' +
|
|
240
|
+
'Pick the one you run (copy-paste), then re-run anon-pi:\n' +
|
|
241
|
+
'\n' +
|
|
242
|
+
'# Tor (system tor / Tor Browser bundle default port)\n' +
|
|
243
|
+
'export ANON_PI_PROXY=socks5h://127.0.0.1:9050\n' +
|
|
244
|
+
'\n' +
|
|
245
|
+
'# wireproxy -> a WireGuard VPN (Mullvad, Proton, ...); use YOUR configured\n' +
|
|
246
|
+
'# [Socks5] BindAddress port (1080 in wireproxy examples):\n' +
|
|
247
|
+
'export ANON_PI_PROXY=socks5h://127.0.0.1:1080\n' +
|
|
248
|
+
'\n' +
|
|
249
|
+
'# an SSH dynamic-forward (ssh -D 1080 host) or any other socks5h endpoint\n' +
|
|
250
|
+
'export ANON_PI_PROXY=socks5h://127.0.0.1:1080\n' +
|
|
251
|
+
'\n' +
|
|
252
|
+
'Only socks5h:// is accepted (plain socks5:// resolves DNS locally and leaks).');
|
|
253
|
+
}
|
|
165
254
|
const home = env.home;
|
|
166
255
|
if (!home || home.trim() === '') {
|
|
167
256
|
throw new AnonPiError('anon-pi: could not resolve HOME.');
|
|
168
257
|
}
|
|
169
258
|
const raw = workdirArg && workdirArg.trim() !== '' ? workdirArg : process.cwd();
|
|
170
259
|
const workdir = isAbsolute(raw) ? raw : resolve(raw);
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
260
|
+
// Persistent per-workdir state home, unless --ephemeral (no writable mount).
|
|
261
|
+
const ephemeral = env.ephemeral === true;
|
|
262
|
+
const stateDir = ephemeral ? '' : stateAgentDir(env, workdir);
|
|
263
|
+
// Ephemeral home is always fresh (the container's throwaway layer); a
|
|
264
|
+
// persistent home is fresh iff its dir is absent.
|
|
265
|
+
const fresh = ephemeral ? true : !stateExists(stateDir);
|
|
266
|
+
// The canonical imported models.json is mounted (read-only) for the seed only
|
|
267
|
+
// when it exists; pi can also start with no models and you add them in-session.
|
|
268
|
+
const modelsSeed = join(resolveConfigSeed(env), MODELS_FILE);
|
|
269
|
+
const haveModelsSeed = modelsSeedExists(modelsSeed);
|
|
270
|
+
const proxy = env.proxy.trim();
|
|
271
|
+
// netcage's --allow-direct wants a bare IP[:port]/CIDR (no scheme/path), but a
|
|
272
|
+
// user naturally sets ANON_PI_LLM to a URL (http://192.168.1.150:8080). Strip
|
|
273
|
+
// it to host:port with the same helper `import` uses to match providers, so a
|
|
274
|
+
// URL, an ip:port, or a bare ip all work.
|
|
275
|
+
const directTarget = hostPortKey(env.llmDirect);
|
|
276
|
+
const seedVersion = env.seedVersion ?? SEED_VERSION;
|
|
185
277
|
const netcageArgs = [
|
|
186
278
|
'run',
|
|
187
279
|
'--proxy',
|
|
188
280
|
proxy,
|
|
189
281
|
'--allow-direct',
|
|
190
|
-
|
|
282
|
+
directTarget,
|
|
191
283
|
'-it',
|
|
192
284
|
'-v',
|
|
193
285
|
workdir, // netcage defaults a target-less -v to /work and cwd to /work
|
|
194
|
-
'-v',
|
|
195
|
-
// Mount the seed READ-ONLY at a neutral path; the run command copies
|
|
196
|
-
// models.json into the container's own ~/.pi/agent so image extensions
|
|
197
|
-
// survive (see CONTAINER_RUN_CMD).
|
|
198
|
-
`${configSeed}:${CONTAINER_SEED_DIR}:ro`,
|
|
199
|
-
env.image,
|
|
200
|
-
'sh',
|
|
201
|
-
'-c',
|
|
202
|
-
CONTAINER_RUN_CMD,
|
|
203
286
|
];
|
|
287
|
+
// Persistent mode ONLY: mount the per-workdir state home at ~/.pi/agent
|
|
288
|
+
// (Model B). --ephemeral mounts nothing writable: pi writes to the container's
|
|
289
|
+
// own --rm layer, gone on exit, no host state.
|
|
290
|
+
if (!ephemeral) {
|
|
291
|
+
netcageArgs.push('-v', `${stateDir}:${CONTAINER_AGENT_DIR}`);
|
|
292
|
+
}
|
|
293
|
+
// Mount the imported models.json read-only for the first-launch seed, if any.
|
|
294
|
+
if (haveModelsSeed) {
|
|
295
|
+
netcageArgs.push('-v', `${modelsSeed}:${CONTAINER_MODELS_SEED}:ro`);
|
|
296
|
+
}
|
|
297
|
+
netcageArgs.push(env.image, 'sh', '-c', containerRunCmd(seedVersion));
|
|
204
298
|
return {
|
|
205
299
|
workdir,
|
|
206
|
-
|
|
300
|
+
stateDir,
|
|
301
|
+
configSeed: haveModelsSeed ? modelsSeed : '',
|
|
302
|
+
fresh,
|
|
207
303
|
netcageArgs,
|
|
208
304
|
};
|
|
209
305
|
}
|
|
@@ -214,13 +310,24 @@ export function buildRunPlan(env, workdirArg, seedModelsExists) {
|
|
|
214
310
|
* build command concrete.
|
|
215
311
|
*/
|
|
216
312
|
export function shippedDockerfilePath() {
|
|
313
|
+
return shippedFile('Dockerfile.pi');
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Absolute path to the fuller pi-webveil + SearXNG example that ships with
|
|
317
|
+
* anon-pi (examples/Dockerfile.pi-webveil), or undefined if not found.
|
|
318
|
+
*/
|
|
319
|
+
export function shippedWebveilDockerfilePath() {
|
|
320
|
+
return shippedFile(join('examples', 'Dockerfile.pi-webveil'));
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Resolve a file shipped in the package root, from this module's location
|
|
324
|
+
* (package root is one level up from dist/anon-pi.js). Returns undefined if it
|
|
325
|
+
* cannot be found or import.meta.url is unavailable.
|
|
326
|
+
*/
|
|
327
|
+
function shippedFile(rel) {
|
|
217
328
|
try {
|
|
218
329
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
219
|
-
|
|
220
|
-
for (const p of [
|
|
221
|
-
join(here, '..', 'Dockerfile.pi'),
|
|
222
|
-
join(here, 'Dockerfile.pi'),
|
|
223
|
-
]) {
|
|
330
|
+
for (const p of [join(here, '..', rel), join(here, rel)]) {
|
|
224
331
|
if (existsSync(p))
|
|
225
332
|
return p;
|
|
226
333
|
}
|
|
@@ -241,16 +348,25 @@ export function envFromProcess(penv) {
|
|
|
241
348
|
llmDirect: penv.ANON_PI_LLM,
|
|
242
349
|
xdgConfigHome: penv.XDG_CONFIG_HOME,
|
|
243
350
|
dockerfilePath: shippedDockerfilePath(),
|
|
351
|
+
webveilDockerfilePath: shippedWebveilDockerfilePath(),
|
|
244
352
|
sourceModels: penv.ANON_PI_SOURCE_MODELS,
|
|
245
353
|
piAgentDir: penv.PI_CODING_AGENT_DIR,
|
|
354
|
+
ephemeral: isTruthy(penv.ANON_PI_EPHEMERAL),
|
|
246
355
|
};
|
|
247
356
|
}
|
|
357
|
+
/** Whether an env-var string is set to a truthy value (1/true/yes, any case). */
|
|
358
|
+
function isTruthy(v) {
|
|
359
|
+
if (!v)
|
|
360
|
+
return false;
|
|
361
|
+
const s = v.trim().toLowerCase();
|
|
362
|
+
return s === '1' || s === 'true' || s === 'yes' || s === 'on';
|
|
363
|
+
}
|
|
248
364
|
/** The --help text (kept here so it is covered by the same module). */
|
|
249
365
|
export const HELP = `anon-pi - launch pi inside a netcage (anonymized egress + one direct local model)
|
|
250
366
|
|
|
251
367
|
USAGE
|
|
252
368
|
anon-pi [WORKDIR] launch pi jailed, working in WORKDIR (default: cwd)
|
|
253
|
-
anon-pi import
|
|
369
|
+
anon-pi import seed models.json from your local model
|
|
254
370
|
|
|
255
371
|
WORKDIR the host folder pi works in (mounted at ${CONTAINER_WORKDIR}; pi's cwd). Files pi
|
|
256
372
|
writes there land on the host.
|
|
@@ -258,28 +374,45 @@ USAGE
|
|
|
258
374
|
WHAT IT DOES
|
|
259
375
|
Runs pi inside netcage with all web/DNS egress forced through the socks5h
|
|
260
376
|
proxy (fail-closed) and ONE direct hole to your local model (ANON_PI_LLM).
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
377
|
+
|
|
378
|
+
STATEFUL by default: a persistent per-workdir home
|
|
379
|
+
(<ANON_PI_HOME>/state/<workdir>/agent) is mounted at the container's
|
|
380
|
+
~/.pi/agent, so your conversations, history, settings (model choice), and any
|
|
381
|
+
extensions you \`pi install\` persist across launches. Re-running in the same
|
|
382
|
+
folder resumes it. On a FRESH home, the image's staged defaults (extensions,
|
|
383
|
+
trust) and your imported models.json are seeded in once; after that pi owns the
|
|
384
|
+
home and nothing is overwritten. Requires \`netcage\`.
|
|
385
|
+
|
|
386
|
+
--ephemeral (or ANON_PI_EPHEMERAL=1): mount NO writable state; pi writes to the
|
|
387
|
+
container's own --rm layer, gone on exit. Nothing writable touches the host,
|
|
388
|
+
no cleanup, no leftover-on-crash.
|
|
389
|
+
|
|
390
|
+
--fresh: delete this workdir's persistent state home first, so the (possibly
|
|
391
|
+
rebuilt) image's defaults + your imported models.json are re-seeded. Use it
|
|
392
|
+
after rebuilding your image to pick up new extensions/config.
|
|
264
393
|
|
|
265
394
|
import
|
|
266
395
|
Reads your host ~/.pi/agent/models.json, picks the provider whose baseUrl
|
|
267
|
-
serves ANON_PI_LLM, and writes JUST that provider to the seed
|
|
396
|
+
serves ANON_PI_LLM, and writes JUST that provider to the canonical seed
|
|
268
397
|
(<ANON_PI_CONFIG>/models.json). No other provider's API keys, no sessions, no
|
|
269
|
-
identity.
|
|
398
|
+
identity. It SEEDS a fresh home; models you later add inside pi persist and are
|
|
399
|
+
never clobbered. Re-run with --force to overwrite the canonical seed.
|
|
270
400
|
|
|
271
401
|
ENVIRONMENT
|
|
272
402
|
ANON_PI_IMAGE (required for run) image with \`pi\` on PATH. No image yet?
|
|
273
403
|
Running anon-pi without it prints a ready-to-build
|
|
274
404
|
Dockerfile.pi recipe; see the README (Providing a pi image).
|
|
275
405
|
ANON_PI_LLM (required) RFC1918/link-local IP[:port] of the local model
|
|
276
|
-
ANON_PI_PROXY socks5h URL (
|
|
406
|
+
ANON_PI_PROXY (required) socks5h URL of your proxy (Tor/wireproxy/ssh -D).
|
|
407
|
+
No default: the proxy is what anonymizes, so it is never guessed.
|
|
408
|
+
ANON_PI_EPHEMERAL set to 1 for a throwaway (non-persistent) session
|
|
277
409
|
ANON_PI_HOME anon-pi home (default $XDG_CONFIG_HOME/anon-pi or ~/.config/anon-pi)
|
|
278
|
-
ANON_PI_CONFIG seed dir holding models.json (default <ANON_PI_HOME>/agent)
|
|
410
|
+
ANON_PI_CONFIG canonical seed dir holding models.json (default <ANON_PI_HOME>/agent)
|
|
279
411
|
ANON_PI_SOURCE_MODELS (import) host models.json to read (default ~/.pi/agent/models.json)
|
|
280
412
|
|
|
281
|
-
|
|
282
|
-
anon-pi
|
|
413
|
+
RESET A SESSION
|
|
414
|
+
anon-pi --fresh [WORKDIR] drop the session home and re-seed on this launch.
|
|
415
|
+
Or delete it by hand: rm -rf <ANON_PI_HOME>/state/<workdir-slug>/agent
|
|
283
416
|
|
|
284
417
|
PLATFORM
|
|
285
418
|
Linux only (via netcage's netns/nft jail). On macOS/Windows it works only
|
package/dist/anon-pi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anon-pi.js","sourceRoot":"","sources":["../src/anon-pi.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,+EAA+E;AAC/E,EAAE;AACF,sCAAsC;AACtC,8EAA8E;AAC9E,iFAAiF;AACjF,yEAAyE;AACzE,+EAA+E;AAC/E,kCAAkC;AAClC,gFAAgF;AAChF,sEAAsE;AACtE,6EAA6E;AAC7E,kFAAkF;AAClF,2EAA2E;AAC3E,kFAAkF;AAClF,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,SAAS,EAAE,IAAI,CAAC,WAAW;QAC3B,aAAa,EAAE,IAAI,CAAC,eAAe;QACnC,cAAc,EAAE,qBAAqB,EAAE;QACvC,qBAAqB,EAAE,4BAA4B,EAAE;QACrD,YAAY,EAAE,IAAI,CAAC,qBAAqB;QACxC,UAAU,EAAE,IAAI,CAAC,mBAAmB;QACpC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC;KAC3C,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,SAAS,QAAQ,CAAC,CAAqB;IACtC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACrB,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC;AAC/D,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,IAAI,GAAG;;;;;;sDAMkC,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDtE,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
// it layers onto the image's config (extensions survive).
|
|
8
8
|
// anon-pi import generate the seed models.json from the host models.json,
|
|
9
9
|
// carrying only the provider that serves ANON_PI_LLM.
|
|
10
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
11
11
|
import { spawnSync } from 'node:child_process';
|
|
12
|
-
import { join } from 'node:path';
|
|
13
|
-
import { AnonPiError, buildRunPlan, envFromProcess, HELP, MODELS_FILE, pickProviderForLlm, resolveConfigSeed, resolveSourceModelsPath, } from './anon-pi.js';
|
|
12
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
13
|
+
import { AnonPiError, buildRunPlan, envFromProcess, HELP, MODELS_FILE, pickProviderForLlm, resolveConfigSeed, resolveSourceModelsPath, stateAgentDir, } from './anon-pi.js';
|
|
14
14
|
function main(argv) {
|
|
15
15
|
const args = argv.slice(2);
|
|
16
16
|
if (args.includes('--help') || args.includes('-h')) {
|
|
@@ -25,11 +25,14 @@ function main(argv) {
|
|
|
25
25
|
}
|
|
26
26
|
// --- anon-pi [WORKDIR] : launch pi jailed -----------------------------------
|
|
27
27
|
function runLaunch(args) {
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
// argv
|
|
28
|
+
// One optional positional (the workdir) + the --ephemeral / --fresh flags.
|
|
29
|
+
// Reject other flags so a typo is not silently swallowed: anon-pi owns the
|
|
30
|
+
// netcage argv.
|
|
31
|
+
const known = new Set(['--ephemeral', '--eph', '--fresh']);
|
|
32
|
+
const ephemeralFlag = args.includes('--ephemeral') || args.includes('--eph');
|
|
33
|
+
const freshFlag = args.includes('--fresh');
|
|
31
34
|
const positionals = args.filter((a) => !a.startsWith('-'));
|
|
32
|
-
const flags = args.filter((a) => a.startsWith('-'));
|
|
35
|
+
const flags = args.filter((a) => a.startsWith('-') && !known.has(a));
|
|
33
36
|
if (flags.length > 0) {
|
|
34
37
|
process.stderr.write(`anon-pi: unknown option(s): ${flags.join(' ')}\nRun \`anon-pi --help\`.\n`);
|
|
35
38
|
return 2;
|
|
@@ -38,10 +41,30 @@ function runLaunch(args) {
|
|
|
38
41
|
process.stderr.write('anon-pi: too many arguments (expected at most one WORKDIR).\nRun `anon-pi --help`.\n');
|
|
39
42
|
return 2;
|
|
40
43
|
}
|
|
44
|
+
if (freshFlag && ephemeralFlag) {
|
|
45
|
+
process.stderr.write('anon-pi: --fresh has no effect with --ephemeral (an ephemeral session is always fresh and never persisted).\nRun `anon-pi --help`.\n');
|
|
46
|
+
return 2;
|
|
47
|
+
}
|
|
41
48
|
const env = envFromProcess(process.env);
|
|
49
|
+
if (ephemeralFlag)
|
|
50
|
+
env.ephemeral = true;
|
|
51
|
+
// --fresh: delete this workdir's persistent state home BEFORE planning, so the
|
|
52
|
+
// home is fresh and the image's (possibly rebuilt) defaults + models.json are
|
|
53
|
+
// re-seeded on this launch. No-op for --ephemeral (handled above).
|
|
54
|
+
if (freshFlag && !env.ephemeral) {
|
|
55
|
+
const raw = positionals[0] && positionals[0].trim() !== ''
|
|
56
|
+
? positionals[0]
|
|
57
|
+
: process.cwd();
|
|
58
|
+
const wd = isAbsolute(raw) ? raw : resolve(raw);
|
|
59
|
+
const stateDir = stateAgentDir(env, wd);
|
|
60
|
+
if (existsSync(stateDir)) {
|
|
61
|
+
rmSync(stateDir, { recursive: true, force: true });
|
|
62
|
+
process.stderr.write(`anon-pi: --fresh removed ${stateDir}\n`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
42
65
|
let plan;
|
|
43
66
|
try {
|
|
44
|
-
plan = buildRunPlan(env, positionals[0], existsSync);
|
|
67
|
+
plan = buildRunPlan(env, positionals[0], existsSync, existsSync);
|
|
45
68
|
}
|
|
46
69
|
catch (e) {
|
|
47
70
|
if (e instanceof AnonPiError) {
|
|
@@ -56,8 +79,19 @@ function runLaunch(args) {
|
|
|
56
79
|
'(https://github.com/wighawag/netcage). Linux only.\n');
|
|
57
80
|
return 1;
|
|
58
81
|
}
|
|
59
|
-
// Ensure the workdir exists (a fresh named folder is fine).
|
|
60
82
|
mkdirSync(plan.workdir, { recursive: true });
|
|
83
|
+
if (env.ephemeral) {
|
|
84
|
+
// No host state dir: pi writes to the container's own --rm layer, so the
|
|
85
|
+
// session leaves NO trace on the host and there is nothing to clean up.
|
|
86
|
+
process.stderr.write('anon-pi: ephemeral session (nothing persisted; no host state)\n');
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Persistent mode: create the per-workdir state home to mount.
|
|
90
|
+
mkdirSync(plan.stateDir, { recursive: true });
|
|
91
|
+
if (plan.fresh) {
|
|
92
|
+
process.stderr.write(`anon-pi: new session home ${plan.stateDir} (seeding on first launch)\n`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
61
95
|
// Hand off to netcage with inherited stdio so -it is a real interactive TTY.
|
|
62
96
|
const res = spawnSync('netcage', plan.netcageArgs, { stdio: 'inherit' });
|
|
63
97
|
if (res.error) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,6BAA6B;AAC7B,+EAA+E;AAC/E,iFAAiF;AACjF,6EAA6E;AAC7E,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,4EAA4E;AAE5E,OAAO,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,6BAA6B;AAC7B,+EAA+E;AAC/E,iFAAiF;AACjF,6EAA6E;AAC7E,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,4EAA4E;AAE5E,OAAO,EACN,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,EACN,WAAW,EACX,YAAY,EACZ,cAAc,EACd,IAAI,EACJ,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,aAAa,GAEb,MAAM,cAAc,CAAC;AAEtB,SAAS,IAAI,CAAC,IAAc;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3B,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;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CACzF,CAAC;IACF,OAAO,CAAC,CAAC;AACV,CAAC;AAED,SAAS,UAAU;IAClB,MAAM,KAAK,GAAG,SAAS,CACtB,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAClD,CAAC,IAAI,EAAE,SAAS,CAAC,EACjB;QACC,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;KACnC,CACD,CAAC;IACF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,uCAAuC;IACvC,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAC,KAAK,EAAE,QAAQ,EAAC,CAAC,CAAC;IAClE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC;AAED,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -36,9 +36,15 @@ RUN apt-get update \
|
|
|
36
36
|
uwsgi uwsgi-plugin-python3 \
|
|
37
37
|
&& rm -rf /var/lib/apt/lists/*
|
|
38
38
|
|
|
39
|
-
# --- pi + the pi-webveil extension
|
|
39
|
+
# --- pi + the pi-webveil extension --------------------------------------------
|
|
40
|
+
# Install pi globally, then install the extension into the STAGING dir
|
|
41
|
+
# (PI_CODING_AGENT_DIR), NOT ~/.pi/agent: anon-pi mounts a persistent home over
|
|
42
|
+
# ~/.pi/agent and promotes the staging dir into it on first launch. Installing
|
|
43
|
+
# straight into ~/.pi/agent would be shadowed by that mount.
|
|
40
44
|
RUN npm install -g --ignore-scripts @earendil-works/pi-coding-agent
|
|
41
|
-
|
|
45
|
+
ENV ANON_PI_STAGE=/opt/anon-pi-seed/agent
|
|
46
|
+
RUN mkdir -p "$ANON_PI_STAGE" \
|
|
47
|
+
&& PI_CODING_AGENT_DIR="$ANON_PI_STAGE" pi install npm:pi-webveil
|
|
42
48
|
|
|
43
49
|
# --- SearXNG in a venv -------------------------------------------------------
|
|
44
50
|
ENV SEARXNG_HOME=/opt/searxng
|
|
@@ -59,18 +65,18 @@ RUN mkdir -p /etc/searxng \
|
|
|
59
65
|
> /etc/searxng/settings.yml
|
|
60
66
|
ENV SEARXNG_SETTINGS_PATH=/etc/searxng/settings.yml
|
|
61
67
|
|
|
62
|
-
# webveil.json
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
# webveil.json + trust.json go in the STAGING dir (promoted into the persistent
|
|
69
|
+
# home on first launch). webveil points at the Unix socket, backend hop DIRECT
|
|
70
|
+
# (netcage anonymizes it): no webveil-side proxy config is needed in-jail because
|
|
71
|
+
# netcage forces every process's egress through the proxy.
|
|
72
|
+
RUN printf '%s\n' \
|
|
67
73
|
'{' \
|
|
68
74
|
' "backend": "searxng",' \
|
|
69
75
|
' "baseUrl": "unix:/run/searxng/socket",' \
|
|
70
76
|
' "egress": { "mode": "direct" }' \
|
|
71
77
|
'}' \
|
|
72
|
-
> /
|
|
73
|
-
&& printf '{"/work": true}\n' > /
|
|
78
|
+
> "$ANON_PI_STAGE/webveil.json" \
|
|
79
|
+
&& printf '{"/work": true}\n' > "$ANON_PI_STAGE/trust.json"
|
|
74
80
|
|
|
75
81
|
# --- entrypoint: start SearXNG (HTTP over the Unix socket), then exec CMD ------
|
|
76
82
|
# anon-pi passes `sh -c 'cp ... && exec pi'` as the CMD; a Dockerfile ENTRYPOINT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anon-pi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Launch pi inside a netcage: anonymized web egress through a socks5h proxy, one direct hole for a local model, seeded pi config on the host.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"keywords": [
|