anon-pi 0.5.0 → 0.6.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 CHANGED
@@ -39,11 +39,14 @@ anon-pi # bare: pick a project (or a shell, or a new project) from
39
39
  anon-pi recon # or launch straight into a project
40
40
  ```
41
41
 
42
+ The **first time** you launch anon-pi with no config yet, it welcomes you and runs `init` automatically before launching (so you never hit a bare "set `ANON_PI_PROXY`" wall on day one). You can also run `anon-pi init` yourself any time to reconfigure. (If you drive config purely by env — you export `ANON_PI_PROXY` yourself — the auto-onboarding is skipped.)
43
+
42
44
  `init` is interactive and re-runnable. It:
43
45
 
44
46
  1. **Proxy** — probes common SOCKS ports, confirms SOCKS5 with a real handshake, shows the findings (evidence only, it never labels the exit provider), then runs `netcage verify` and shows the real EXIT IP as proof it is not your host IP. You confirm on that evidence.
45
- 2. **Local model** — captures the `host:port` of your model, probes reachability, and generates the machine's `models.json`.
47
+ 2. **Local model** — captures the `host:port` of your model, probes it, then **imports models**. It merges two sources, both scoped to that endpoint: the provider in your own `~/.pi/agent/models.json` whose URL matches it (marked `[configured]` — your hand-tuned entries, with their `contextWindow`/`maxTokens`/etc.), and the endpoint's live `/v1/models` (marked `[server]`). You pick which to import (Enter/`c` = all configured, `a` = all, numbers, or `s` = skip) and which is the **default**. Because only the provider served by this endpoint (the one `--allow-direct` hole) is read, no other provider — and no other key — can ever enter the seed. It writes `models.json` + a settings seed that sets the default model. If the matching provider carries a real-looking apiKey, init **refuses** (it would put a host credential into the anon home) unless you pass `--force-allow-local-llm-api-key`.
46
48
  3. **Image** — pick a shipped `Dockerfile` (built via `podman build`), an existing image ref, or skip.
49
+ 4. **Projects root** — the host folder mounted at `/projects` (where bare `anon-pi` looks for projects). Defaults to `~/.anon-pi/projects/`; point it at your own dev folder if you want to jail pi into files you edit with host tools (`--mount <parent>` still overrides it per-launch).
47
50
 
48
51
  It then writes `~/.anon-pi/config.json` + the `default` machine. It **never destroys** an existing home; it pre-fills your current values and only adds/updates config + the default machine.
49
52
 
@@ -219,7 +222,7 @@ A community image also exists ([`gni/pi-coding-agent-container`](https://github.
219
222
 
220
223
  ### Extensions, skills, and their services go in the image
221
224
 
222
- anon-pi deliberately generates **only your local model's `models.json`**, never copies your extensions or skills. That is on purpose: your extension set is an identity fingerprint, extensions run code and can leak, and many need a runtime that a copied folder cannot carry (for example `pi-webveil` needs a running SearXNG). The right home for capabilities is the **image**, installed once, reviewably, into the STAGING dir so anon-pi promotes them into a fresh machine home:
225
+ anon-pi deliberately seeds **only your local model** (the `models.json` provider for the one `--allow-direct` endpoint, plus the default-model selection) — never your extensions or skills, and never any other provider from your config. That is on purpose: your extension set is an identity fingerprint, extensions run code and can leak, and many need a runtime that a copied folder cannot carry (for example `pi-webveil` needs a running SearXNG). The right home for capabilities is the **image**, installed once, reviewably, into the STAGING dir so anon-pi promotes them into a fresh machine home:
223
226
 
224
227
  ```dockerfile
225
228
  FROM node:24-bookworm-slim
package/dist/anon-pi.d.ts CHANGED
@@ -46,10 +46,25 @@ export declare const CONTAINER_STAGE_DIR = "/opt/anon-pi-seed/agent";
46
46
  * staged defaults. Read-only: the container never writes back to the host seed.
47
47
  */
48
48
  export declare const CONTAINER_MODELS_SEED = "/anon-pi-seed/models.json";
49
+ /**
50
+ * Where anon-pi mounts the generated settings SEED (the local-model default
51
+ * selection: defaultProvider/defaultModel/enabledModels) read-only, so the
52
+ * first-launch seed can MERGE it into the fresh home's settings.json (never
53
+ * clobbering image-staged packages/extensions).
54
+ */
55
+ export declare const CONTAINER_SETTINGS_SEED = "/anon-pi-seed/settings.json";
49
56
  /** Marker file written into the agent dir after seeding; holds the seed version. */
50
57
  export declare const SEED_MARKER = ".anon-pi-seed";
51
- /** The single file the host-side seed carries: pi's model/provider registry. */
58
+ /** The file the host-side seed carries: pi's model/provider registry. */
52
59
  export declare const MODELS_FILE = "models.json";
60
+ /** pi's settings file (holds defaultModel/defaultProvider/enabledModels + more). */
61
+ export declare const SETTINGS_FILE = "settings.json";
62
+ /**
63
+ * The settings SEED file anon-pi writes next to a machine (the local-model
64
+ * selection fragment). Distinct name so it never collides with a real
65
+ * settings.json; the seed MERGES it into the home's settings on first launch.
66
+ */
67
+ export declare const SETTINGS_SEED_FILE = "settings-seed.json";
53
68
  /**
54
69
  * containerRunCmd builds the container command: on a FRESH home (no seed
55
70
  * marker), promote the image's staged defaults + the mounted models.json into
@@ -83,6 +98,12 @@ export interface AnonPiEnv {
83
98
  llmDirect?: string;
84
99
  /** XDG_CONFIG_HOME, if set (used to derive the default anon-pi home). */
85
100
  xdgConfigHome?: string;
101
+ /**
102
+ * The host pi agent dir (PI_CODING_AGENT_DIR), used ONLY to locate the host
103
+ * `~/.pi/agent/models.json` that `init` reads the matching local provider
104
+ * from. Defaults to ~/.pi/agent. Never written.
105
+ */
106
+ piAgentDir?: string;
86
107
  /**
87
108
  * Absolute path to the Dockerfile.pi that ships with anon-pi, used only to
88
109
  * make the missing-image error's build command concrete. cli.ts resolves it
@@ -378,6 +399,12 @@ export interface LaunchIntent {
378
399
  * starts with no models; you add them in-session).
379
400
  */
380
401
  modelsSeed?: string;
402
+ /**
403
+ * The settings SEED to mount read-only for the first-launch seed (the
404
+ * local-model default selection, e.g. <machine-dir>/settings-seed.json).
405
+ * Omitted => no settings seed (no default model is pre-selected).
406
+ */
407
+ settingsSeed?: string;
381
408
  /** The seed version stamped into a fresh home's marker. Default SEED_VERSION. */
382
409
  seedVersion?: string;
383
410
  }
@@ -708,21 +735,133 @@ export declare const LOCAL_PROVIDER_API = "openai-completions";
708
735
  */
709
736
  export declare const LOCAL_PROVIDER_API_KEY = "none";
710
737
  /**
711
- * PURE: synthesize a barebones pi `models.json` from a single `llm` endpoint
712
- * (a URL, `ip:port`, or bare ip). It normalises the endpoint with `hostPortKey`
713
- * (drops scheme/path/user:pass@, lowercases) and returns a models.json carrying
714
- * exactly ONE local provider pointed at that endpoint.
738
+ * apiKey values that are NOT real secrets (safe to carry into the anonymized
739
+ * seed verbatim). Anything else is treated as a REAL secret: `init` refuses to
740
+ * seed it (which would put a host credential into the anon home) unless the
741
+ * operator passes `--force-allow-local-llm-api-key`.
742
+ */
743
+ export declare const BENIGN_API_KEYS: ReadonlySet<string>;
744
+ /** PURE: whether an apiKey looks like a REAL secret (i.e. not in the benign set). */
745
+ export declare function apiKeyLooksReal(apiKey: string | undefined): boolean;
746
+ /**
747
+ * A pi model entry as anon-pi seeds it for the local provider. pi keys a model
748
+ * by `id`; `name` is the display label and `cost` is all-zero (a LAN model is
749
+ * free). A "server"-sourced entry is minimal (id/name/cost); a "configured"
750
+ * entry (imported from the host models.json) preserves whatever extra fields it
751
+ * carried (`contextWindow`, `maxTokens`, `reasoning`, `input`, ...) via the
752
+ * index signature.
753
+ */
754
+ export interface GeneratedModel {
755
+ id: string;
756
+ name: string;
757
+ cost?: {
758
+ input: number;
759
+ output: number;
760
+ cacheRead: number;
761
+ cacheWrite: number;
762
+ };
763
+ [k: string]: unknown;
764
+ }
765
+ /**
766
+ * PURE: a candidate model for the `init` picker. `configured` means it came from
767
+ * the host `~/.pi/agent/models.json` provider that matches the endpoint (a
768
+ * well-tuned entry with its real config); otherwise it was only reported by the
769
+ * endpoint's `/v1/models` (a bare id we synthesize a minimal entry for). The
770
+ * picker marks configured ones so the user knows which are more likely correct.
771
+ */
772
+ export interface ModelCandidate {
773
+ id: string;
774
+ configured: boolean;
775
+ /** The full pi model entry to seed (rich for configured, minimal otherwise). */
776
+ entry: GeneratedModel;
777
+ }
778
+ /**
779
+ * PURE: turn a discovered model `id` into a minimal-but-valid pi model entry.
780
+ * `name` defaults to the id; a LAN model is free, so every cost is 0.
781
+ */
782
+ export declare function localModelEntry(id: string): GeneratedModel;
783
+ /**
784
+ * PURE: extract the model ids from a parsed OpenAI-compatible `/v1/models`
785
+ * response (`{ data: [{ id }, ...] }`, as llama.cpp / vLLM / LM Studio serve).
786
+ * Tolerates a bare array, a `models` key, missing/garbage input (returns []), so
787
+ * `init` can feed whatever the endpoint returned straight in.
788
+ */
789
+ export declare function parseModelsListing(raw: unknown): string[];
790
+ /** The result of scanning a host models.json for the endpoint's provider. */
791
+ export interface HostProviderMatch {
792
+ /** The matching provider's models as full pi entries (verbatim host config). */
793
+ models: GeneratedModel[];
794
+ /** The matching provider's apiKey (verbatim), for the benign/real check. */
795
+ apiKey?: string;
796
+ /** True iff that apiKey looks like a REAL secret (init refuses without --force). */
797
+ apiKeyLooksReal: boolean;
798
+ }
799
+ /**
800
+ * PURE: find, in a parsed host `~/.pi/agent/models.json`, the provider whose
801
+ * `baseUrl` points at `llmEndpoint` (matched via hostPortKey), and return ONLY
802
+ * that provider's models + apiKey. This is the anonymity-critical scoping: the
803
+ * ONLY provider considered is the one served by the `--allow-direct` endpoint,
804
+ * so no other provider (etherplay/google/a paid API) — and no other provider's
805
+ * key — can ever enter the seed. Returns undefined when no provider matches.
715
806
  *
716
- * This REPLACES the old `import`-from-host-models.json flow: it reads NO host pi
717
- * config, so no other provider, no paid API key, no session identity can leak
718
- * into the seed. Endpoint in -> object out; `init` / seed-if-fresh write the
719
- * result into the machine home.
807
+ * The `--allow-direct` target and this match both go through hostPortKey, so a
808
+ * URL / ip:port / bare-ip host config all match the same endpoint.
809
+ */
810
+ export declare function pickLocalProviderModels(hostModels: PiModelsFile, llmEndpoint: string): HostProviderMatch | undefined;
811
+ /**
812
+ * PURE: merge the host-config models (rich, `configured: true`) with the
813
+ * endpoint's live `/v1/models` ids (`configured: false` for any the host did not
814
+ * already carry), into ONE deduped, sorted candidate list. Host config wins on
815
+ * an id present in both (it has the real config). Every candidate here is served
816
+ * by the endpoint, so every one is `--allow-direct`-reachable; the merge just
817
+ * unions "what you already configured" with "what the server also offers".
818
+ */
819
+ export declare function mergeModelSources(hostModels: readonly GeneratedModel[], serverIds: readonly string[]): ModelCandidate[];
820
+ /**
821
+ * PURE: synthesize a pi `models.json` for the local provider from an endpoint
822
+ * and the CHOSEN model entries. It normalises the endpoint with hostPortKey and
823
+ * returns a models.json carrying exactly ONE provider (named LOCAL_PROVIDER_NAME
824
+ * — a neutral name, no host fingerprint) pointed at that endpoint.
825
+ *
826
+ * `apiKey` defaults to the benign LOCAL_PROVIDER_API_KEY. A caller may pass the
827
+ * host provider's real key ONLY under an explicit force flag; the benign/real
828
+ * decision (and the refusal) lives in `init`, not here — this pure function just
829
+ * writes what it is given.
720
830
  *
721
- * The baseUrl is `http://<host[:port]>/v1` (the OpenAI-compatible convention the
722
- * completions api uses); the api dialect + benign apiKey are the LOCAL_PROVIDER_*
723
- * constants.
831
+ * Accepts either full model entries (from the host config) or bare id strings
832
+ * (which it turns into minimal entries). Empty models => a provider pointed at
833
+ * the endpoint with no pickable model (the degraded fallback).
834
+ */
835
+ export declare function generateModelsJson(llmEndpoint: string, models?: readonly (GeneratedModel | string)[], apiKey?: string): PiModelsFile;
836
+ /** The pi settings.json keys anon-pi sets for the local-model default selection. */
837
+ export interface ModelSelection {
838
+ defaultProvider: string;
839
+ defaultModel: string;
840
+ enabledModels: string[];
841
+ }
842
+ /**
843
+ * PURE: the model-selection settings.json fragment for the seeded local
844
+ * provider: `defaultProvider` = LOCAL_PROVIDER_NAME, `defaultModel` = the chosen
845
+ * default id, `enabledModels` = `local/<id>` for each imported model (pi's
846
+ * `<provider>/<id>` convention). The caller MERGES this into any existing
847
+ * settings so image-staged settings (packages/extensions) are preserved.
848
+ */
849
+ export declare function generateModelSelection(modelIds: readonly string[], defaultId: string): ModelSelection;
850
+ /**
851
+ * PURE: shallow-merge the local-model selection into an existing (parsed)
852
+ * settings.json object, returning the merged object. Only the three selection
853
+ * keys are overwritten; every other key the user/image had (packages,
854
+ * extensions, thinking level, ...) is preserved. `existing` undefined/garbage is
855
+ * treated as `{}`.
856
+ */
857
+ export declare function mergeModelSelection(existing: unknown, selection: ModelSelection): Record<string, unknown>;
858
+ /**
859
+ * The host `~/.pi/agent/models.json` path `init` reads the matching local
860
+ * provider from. Uses the container-less host HOME (or PI_CODING_AGENT_DIR when
861
+ * the user relocated pi's agent dir). This is READ-ONLY (init copies only the
862
+ * ONE matching provider's models); it is never written.
724
863
  */
725
- export declare function generateModelsJson(llmEndpoint: string): PiModelsFile;
864
+ export declare function resolveHostModelsPath(env: AnonPiEnv): string;
726
865
  /**
727
866
  * A pi provider entry (as it appears under models.json `providers[name]`). Only
728
867
  * the fields anon-pi reads are typed; the rest is preserved verbatim.
@@ -1 +1 @@
1
- {"version":3,"file":"anon-pi.d.ts","sourceRoot":"","sources":["../src/anon-pi.ts"],"names":[],"mappings":"AAqCA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,cAAc,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,8BAA8B,CAAC;AAEjE,oFAAoF;AACpF,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAE3C,gFAAgF;AAChF,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAc3D;AAED,oFAAoF;AACpF,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACzB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,KAAK,CAAC,E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wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CAoFxE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAOlE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,QAAQ,EAAE,MAAM,GACd,MAAM,CASR;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,SAAS,CAaX;AAED,uEAAuE;AACvE,eAAO,MAAM,IAAI,uyFA2ChB,CAAC"}
package/dist/anon-pi.js CHANGED
@@ -81,10 +81,25 @@ export const CONTAINER_STAGE_DIR = '/opt/anon-pi-seed/agent';
81
81
  * staged defaults. Read-only: the container never writes back to the host seed.
82
82
  */
83
83
  export const CONTAINER_MODELS_SEED = '/anon-pi-seed/models.json';
84
+ /**
85
+ * Where anon-pi mounts the generated settings SEED (the local-model default
86
+ * selection: defaultProvider/defaultModel/enabledModels) read-only, so the
87
+ * first-launch seed can MERGE it into the fresh home's settings.json (never
88
+ * clobbering image-staged packages/extensions).
89
+ */
90
+ export const CONTAINER_SETTINGS_SEED = '/anon-pi-seed/settings.json';
84
91
  /** Marker file written into the agent dir after seeding; holds the seed version. */
85
92
  export const SEED_MARKER = '.anon-pi-seed';
86
- /** The single file the host-side seed carries: pi's model/provider registry. */
93
+ /** The file the host-side seed carries: pi's model/provider registry. */
87
94
  export const MODELS_FILE = 'models.json';
95
+ /** pi's settings file (holds defaultModel/defaultProvider/enabledModels + more). */
96
+ export const SETTINGS_FILE = 'settings.json';
97
+ /**
98
+ * The settings SEED file anon-pi writes next to a machine (the local-model
99
+ * selection fragment). Distinct name so it never collides with a real
100
+ * settings.json; the seed MERGES it into the home's settings on first launch.
101
+ */
102
+ export const SETTINGS_SEED_FILE = 'settings-seed.json';
88
103
  /**
89
104
  * containerRunCmd builds the container command: on a FRESH home (no seed
90
105
  * marker), promote the image's staged defaults + the mounted models.json into
@@ -598,6 +613,12 @@ export function resolveRunPlan(intent, homeFresh) {
598
613
  if (modelsSeed !== undefined) {
599
614
  netcageArgs.push('-v', `${modelsSeed}:${CONTAINER_MODELS_SEED}:ro`);
600
615
  }
616
+ // The generated settings SEED (the local-model default selection) read-only,
617
+ // when present; the seed-if-fresh MERGES it into the home's settings.json.
618
+ const settingsSeed = nonEmpty(intent.settingsSeed);
619
+ if (settingsSeed !== undefined) {
620
+ netcageArgs.push('-v', `${settingsSeed}:${CONTAINER_SETTINGS_SEED}:ro`);
621
+ }
601
622
  // The jail cwd.
602
623
  netcageArgs.push('-w', cwd);
603
624
  // The image, then the command: a marker-guarded seed-if-fresh then the tool.
@@ -632,10 +653,23 @@ export function resolveRunPlan(intent, homeFresh) {
632
653
  function containerSeedThen(seedVersion, exec) {
633
654
  const agent = CONTAINER_AGENT_DIR;
634
655
  const marker = `${agent}/${SEED_MARKER}`;
656
+ const settings = `${agent}/${SETTINGS_FILE}`;
657
+ // Merge the settings SEED (the local-model default selection) into the home's
658
+ // settings.json, overwriting ONLY the three selection keys so any staged
659
+ // packages/extensions survive. Done with a node one-liner (pi is a node app,
660
+ // so node is on PATH). The seed path + target are shell-quoted single args.
661
+ const mergeSettings = `{ [ -f "${CONTAINER_SETTINGS_SEED}" ] && node -e '` +
662
+ `const fs=require("fs");` +
663
+ `const seed=JSON.parse(fs.readFileSync(process.argv[1],"utf8"));` +
664
+ `let cur={};try{cur=JSON.parse(fs.readFileSync(process.argv[2],"utf8"))}catch(e){}` +
665
+ `cur.defaultProvider=seed.defaultProvider;cur.defaultModel=seed.defaultModel;cur.enabledModels=seed.enabledModels;` +
666
+ `fs.writeFileSync(process.argv[2],JSON.stringify(cur,null,"\\t")+"\\n")` +
667
+ `' "${CONTAINER_SETTINGS_SEED}" "${settings}" || true; }`;
635
668
  return (`mkdir -p "${agent}" && ` +
636
669
  `if [ ! -f "${marker}" ]; then ` +
637
670
  `{ [ -d "${CONTAINER_STAGE_DIR}" ] && cp -a "${CONTAINER_STAGE_DIR}/." "${agent}/" || true; } && ` +
638
671
  `{ [ -f "${CONTAINER_MODELS_SEED}" ] && cp "${CONTAINER_MODELS_SEED}" "${agent}/${MODELS_FILE}" || true; } && ` +
672
+ `${mergeSettings} && ` +
639
673
  `printf '%s\\n' "${seedVersion}" > "${marker}"; ` +
640
674
  `fi && ` +
641
675
  `${exec}`);
@@ -893,30 +927,210 @@ export const LOCAL_PROVIDER_API = 'openai-completions';
893
927
  */
894
928
  export const LOCAL_PROVIDER_API_KEY = 'none';
895
929
  /**
896
- * PURE: synthesize a barebones pi `models.json` from a single `llm` endpoint
897
- * (a URL, `ip:port`, or bare ip). It normalises the endpoint with `hostPortKey`
898
- * (drops scheme/path/user:pass@, lowercases) and returns a models.json carrying
899
- * exactly ONE local provider pointed at that endpoint.
930
+ * apiKey values that are NOT real secrets (safe to carry into the anonymized
931
+ * seed verbatim). Anything else is treated as a REAL secret: `init` refuses to
932
+ * seed it (which would put a host credential into the anon home) unless the
933
+ * operator passes `--force-allow-local-llm-api-key`.
934
+ */
935
+ export const BENIGN_API_KEYS = new Set([
936
+ '',
937
+ 'none',
938
+ 'ollama',
939
+ 'no-key',
940
+ 'nokey',
941
+ 'local',
942
+ 'dummy',
943
+ 'sk-no-key-required',
944
+ ]);
945
+ /** PURE: whether an apiKey looks like a REAL secret (i.e. not in the benign set). */
946
+ export function apiKeyLooksReal(apiKey) {
947
+ if (apiKey === undefined)
948
+ return false;
949
+ return !BENIGN_API_KEYS.has(apiKey.trim().toLowerCase());
950
+ }
951
+ /**
952
+ * PURE: turn a discovered model `id` into a minimal-but-valid pi model entry.
953
+ * `name` defaults to the id; a LAN model is free, so every cost is 0.
954
+ */
955
+ export function localModelEntry(id) {
956
+ return {
957
+ id,
958
+ name: id,
959
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
960
+ };
961
+ }
962
+ /**
963
+ * PURE: extract the model ids from a parsed OpenAI-compatible `/v1/models`
964
+ * response (`{ data: [{ id }, ...] }`, as llama.cpp / vLLM / LM Studio serve).
965
+ * Tolerates a bare array, a `models` key, missing/garbage input (returns []), so
966
+ * `init` can feed whatever the endpoint returned straight in.
967
+ */
968
+ export function parseModelsListing(raw) {
969
+ const rows = Array.isArray(raw)
970
+ ? raw
971
+ : raw && typeof raw === 'object'
972
+ ? (raw.data ??
973
+ raw.models ??
974
+ [])
975
+ : [];
976
+ if (!Array.isArray(rows))
977
+ return [];
978
+ const ids = [];
979
+ for (const r of rows) {
980
+ if (typeof r === 'string') {
981
+ if (r.trim() !== '')
982
+ ids.push(r.trim());
983
+ }
984
+ else if (r && typeof r === 'object') {
985
+ const id = r.id;
986
+ if (typeof id === 'string' && id.trim() !== '')
987
+ ids.push(id.trim());
988
+ }
989
+ }
990
+ return ids;
991
+ }
992
+ /**
993
+ * PURE: find, in a parsed host `~/.pi/agent/models.json`, the provider whose
994
+ * `baseUrl` points at `llmEndpoint` (matched via hostPortKey), and return ONLY
995
+ * that provider's models + apiKey. This is the anonymity-critical scoping: the
996
+ * ONLY provider considered is the one served by the `--allow-direct` endpoint,
997
+ * so no other provider (etherplay/google/a paid API) — and no other provider's
998
+ * key — can ever enter the seed. Returns undefined when no provider matches.
900
999
  *
901
- * This REPLACES the old `import`-from-host-models.json flow: it reads NO host pi
902
- * config, so no other provider, no paid API key, no session identity can leak
903
- * into the seed. Endpoint in -> object out; `init` / seed-if-fresh write the
904
- * result into the machine home.
1000
+ * The `--allow-direct` target and this match both go through hostPortKey, so a
1001
+ * URL / ip:port / bare-ip host config all match the same endpoint.
1002
+ */
1003
+ export function pickLocalProviderModels(hostModels, llmEndpoint) {
1004
+ const providers = hostModels.providers ?? {};
1005
+ const want = hostPortKey(llmEndpoint);
1006
+ for (const p of Object.values(providers)) {
1007
+ if (!p || typeof p !== 'object' || !p.baseUrl)
1008
+ continue;
1009
+ if (hostPortKey(p.baseUrl) !== want)
1010
+ continue;
1011
+ const models = [];
1012
+ for (const m of p.models ?? []) {
1013
+ if (m && typeof m === 'object') {
1014
+ const id = m.id;
1015
+ if (typeof id === 'string' && id.trim() !== '') {
1016
+ models.push({ ...m, id: id.trim() });
1017
+ }
1018
+ }
1019
+ else if (typeof m === 'string' && m.trim() !== '') {
1020
+ models.push(localModelEntry(m.trim()));
1021
+ }
1022
+ }
1023
+ return {
1024
+ models,
1025
+ apiKey: p.apiKey,
1026
+ apiKeyLooksReal: apiKeyLooksReal(p.apiKey),
1027
+ };
1028
+ }
1029
+ return undefined;
1030
+ }
1031
+ /**
1032
+ * PURE: merge the host-config models (rich, `configured: true`) with the
1033
+ * endpoint's live `/v1/models` ids (`configured: false` for any the host did not
1034
+ * already carry), into ONE deduped, sorted candidate list. Host config wins on
1035
+ * an id present in both (it has the real config). Every candidate here is served
1036
+ * by the endpoint, so every one is `--allow-direct`-reachable; the merge just
1037
+ * unions "what you already configured" with "what the server also offers".
1038
+ */
1039
+ export function mergeModelSources(hostModels, serverIds) {
1040
+ const byId = new Map();
1041
+ for (const m of hostModels) {
1042
+ const id = m.id.trim();
1043
+ if (id === '')
1044
+ continue;
1045
+ byId.set(id, { id, configured: true, entry: { ...m, id } });
1046
+ }
1047
+ for (const raw of serverIds) {
1048
+ const id = raw.trim();
1049
+ if (id === '' || byId.has(id))
1050
+ continue;
1051
+ byId.set(id, { id, configured: false, entry: localModelEntry(id) });
1052
+ }
1053
+ return Array.from(byId.values()).sort((a, b) => a.id.localeCompare(b.id));
1054
+ }
1055
+ /**
1056
+ * PURE: synthesize a pi `models.json` for the local provider from an endpoint
1057
+ * and the CHOSEN model entries. It normalises the endpoint with hostPortKey and
1058
+ * returns a models.json carrying exactly ONE provider (named LOCAL_PROVIDER_NAME
1059
+ * — a neutral name, no host fingerprint) pointed at that endpoint.
1060
+ *
1061
+ * `apiKey` defaults to the benign LOCAL_PROVIDER_API_KEY. A caller may pass the
1062
+ * host provider's real key ONLY under an explicit force flag; the benign/real
1063
+ * decision (and the refusal) lives in `init`, not here — this pure function just
1064
+ * writes what it is given.
905
1065
  *
906
- * The baseUrl is `http://<host[:port]>/v1` (the OpenAI-compatible convention the
907
- * completions api uses); the api dialect + benign apiKey are the LOCAL_PROVIDER_*
908
- * constants.
1066
+ * Accepts either full model entries (from the host config) or bare id strings
1067
+ * (which it turns into minimal entries). Empty models => a provider pointed at
1068
+ * the endpoint with no pickable model (the degraded fallback).
909
1069
  */
910
- export function generateModelsJson(llmEndpoint) {
1070
+ export function generateModelsJson(llmEndpoint, models = [], apiKey = LOCAL_PROVIDER_API_KEY) {
911
1071
  const hostPort = hostPortKey(llmEndpoint);
1072
+ const entries = [];
1073
+ const seen = new Set();
1074
+ for (const m of models) {
1075
+ const entry = typeof m === 'string' ? localModelEntry(m.trim()) : m;
1076
+ const id = entry.id.trim();
1077
+ if (id === '' || seen.has(id))
1078
+ continue;
1079
+ seen.add(id);
1080
+ entries.push({ ...entry, id });
1081
+ }
1082
+ entries.sort((a, b) => a.id.localeCompare(b.id));
912
1083
  const provider = {
913
1084
  api: LOCAL_PROVIDER_API,
914
- apiKey: LOCAL_PROVIDER_API_KEY,
1085
+ apiKey,
915
1086
  baseUrl: `http://${hostPort}/v1`,
916
- models: [],
1087
+ models: entries,
917
1088
  };
918
1089
  return { providers: { [LOCAL_PROVIDER_NAME]: provider } };
919
1090
  }
1091
+ /**
1092
+ * PURE: the model-selection settings.json fragment for the seeded local
1093
+ * provider: `defaultProvider` = LOCAL_PROVIDER_NAME, `defaultModel` = the chosen
1094
+ * default id, `enabledModels` = `local/<id>` for each imported model (pi's
1095
+ * `<provider>/<id>` convention). The caller MERGES this into any existing
1096
+ * settings so image-staged settings (packages/extensions) are preserved.
1097
+ */
1098
+ export function generateModelSelection(modelIds, defaultId) {
1099
+ const ids = Array.from(new Set(modelIds.map((m) => m.trim()).filter((m) => m !== ''))).sort((a, b) => a.localeCompare(b));
1100
+ return {
1101
+ defaultProvider: LOCAL_PROVIDER_NAME,
1102
+ defaultModel: defaultId.trim(),
1103
+ enabledModels: ids.map((id) => `${LOCAL_PROVIDER_NAME}/${id}`),
1104
+ };
1105
+ }
1106
+ /**
1107
+ * PURE: shallow-merge the local-model selection into an existing (parsed)
1108
+ * settings.json object, returning the merged object. Only the three selection
1109
+ * keys are overwritten; every other key the user/image had (packages,
1110
+ * extensions, thinking level, ...) is preserved. `existing` undefined/garbage is
1111
+ * treated as `{}`.
1112
+ */
1113
+ export function mergeModelSelection(existing, selection) {
1114
+ const base = existing && typeof existing === 'object'
1115
+ ? { ...existing }
1116
+ : {};
1117
+ base.defaultProvider = selection.defaultProvider;
1118
+ base.defaultModel = selection.defaultModel;
1119
+ base.enabledModels = selection.enabledModels;
1120
+ return base;
1121
+ }
1122
+ /**
1123
+ * The host `~/.pi/agent/models.json` path `init` reads the matching local
1124
+ * provider from. Uses the container-less host HOME (or PI_CODING_AGENT_DIR when
1125
+ * the user relocated pi's agent dir). This is READ-ONLY (init copies only the
1126
+ * ONE matching provider's models); it is never written.
1127
+ */
1128
+ export function resolveHostModelsPath(env) {
1129
+ const agentDir = env.piAgentDir && env.piAgentDir.trim() !== ''
1130
+ ? env.piAgentDir
1131
+ : join(env.home, '.pi', 'agent');
1132
+ return join(agentDir, MODELS_FILE);
1133
+ }
920
1134
  // --- `anon-pi init` onboarding: the PURE proxy detect/verify DECISIONS --------
921
1135
  //
922
1136
  // `anon-pi init` onboards HONESTLY (this is an anonymity tool): its proxy step
@@ -1331,6 +1545,7 @@ export function envFromProcess(penv) {
1331
1545
  image: penv.ANON_PI_IMAGE,
1332
1546
  llmDirect: penv.ANON_PI_LLM,
1333
1547
  xdgConfigHome: penv.XDG_CONFIG_HOME,
1548
+ piAgentDir: penv.PI_CODING_AGENT_DIR,
1334
1549
  dockerfilePath: shippedDockerfilePath(),
1335
1550
  webveilDockerfilePath: shippedWebveilDockerfilePath(),
1336
1551
  };