@themoltnet/pi-extension 0.23.1 → 0.24.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/README.md +29 -9
- package/dist/index.js +25 -13
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -37,15 +37,35 @@ mirrored path `/home/agent/.moltnet/<name>/`.
|
|
|
37
37
|
|
|
38
38
|
### What gets injected and where
|
|
39
39
|
|
|
40
|
-
| Host path
|
|
41
|
-
|
|
|
42
|
-
| `.moltnet/<name>/moltnet.json`
|
|
43
|
-
| `.moltnet/<name>/env`
|
|
44
|
-
| `.moltnet/<name>/gitconfig`
|
|
45
|
-
| `.moltnet/<name>/ssh/id_ed25519`
|
|
46
|
-
| `.moltnet/<name>/ssh/id_ed25519.pub`
|
|
47
|
-
| `.moltnet/<name>/ssh/allowed_signers`
|
|
48
|
-
| `~/.pi/agent/auth.json`
|
|
40
|
+
| Host path | Guest path | Purpose |
|
|
41
|
+
| ----------------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------ |
|
|
42
|
+
| `.moltnet/<name>/moltnet.json` | `/home/agent/.moltnet/<name>/moltnet.json` | API endpoint + GitHub App config |
|
|
43
|
+
| `.moltnet/<name>/env` | `/home/agent/.moltnet/<name>/env` | Agent env vars (`MOLTNET_AGENT_NAME`, `MOLTNET_DIARY_ID`, …) |
|
|
44
|
+
| `.moltnet/<name>/gitconfig` | `/home/agent/.moltnet/<name>/gitconfig` | git user identity + SSH commit signing |
|
|
45
|
+
| `.moltnet/<name>/ssh/id_ed25519` | `/home/agent/.moltnet/<name>/ssh/id_ed25519` | SSH private key (commit signing + push auth) |
|
|
46
|
+
| `.moltnet/<name>/ssh/id_ed25519.pub` | `/home/agent/.moltnet/<name>/ssh/id_ed25519.pub` | SSH public key |
|
|
47
|
+
| `.moltnet/<name>/ssh/allowed_signers` | `/home/agent/.moltnet/<name>/ssh/allowed_signers` | git `gpg.ssh.allowedSignersFile` |
|
|
48
|
+
| `$PI_CODING_AGENT_DIR/auth.json` or `~/.pi/agent/auth.json` | `/home/agent/.pi/agent/auth.json` | pi OAuth token (from `pi login` on the host) |
|
|
49
|
+
|
|
50
|
+
## Pi config directory
|
|
51
|
+
|
|
52
|
+
Pi resolves its host-side config from `PI_CODING_AGENT_DIR` when that
|
|
53
|
+
environment variable is set. Otherwise it uses Pi's default
|
|
54
|
+
`~/.pi/agent` directory.
|
|
55
|
+
|
|
56
|
+
`pi-extension` follows that same rule for host-side auth discovery before it
|
|
57
|
+
mirrors `auth.json` into the VM. It does not choose a repository-local Pi
|
|
58
|
+
directory by itself. Embedders such as `@themoltnet/agent-daemon` may set
|
|
59
|
+
`PI_CODING_AGENT_DIR` before creating sessions to make Pi use committed
|
|
60
|
+
repo-local config such as `.pi/settings.json` and `.pi/models.json`.
|
|
61
|
+
|
|
62
|
+
Recommended file split for repo-local Pi config:
|
|
63
|
+
|
|
64
|
+
| File | Commit? | Notes |
|
|
65
|
+
| ------------------- | ------- | ------------------------------------------------------------------------------------------- |
|
|
66
|
+
| `.pi/settings.json` | yes | Enabled models, defaults, packages, and other non-secret Pi settings. |
|
|
67
|
+
| `.pi/models.json` | yes | Provider/model registry. Reference keys by env var name, e.g. `"apiKey": "OLLAMA_API_KEY"`. |
|
|
68
|
+
| `.pi/auth.json` | no | Local subscription OAuth/API-key auth blob. Keep gitignored. |
|
|
49
69
|
|
|
50
70
|
### Path remapping
|
|
51
71
|
|
package/dist/index.js
CHANGED
|
@@ -8824,8 +8824,7 @@ async function resumeVm(config) {
|
|
|
8824
8824
|
signal: config.signal
|
|
8825
8825
|
});
|
|
8826
8826
|
if (creds.gitconfig) {
|
|
8827
|
-
const
|
|
8828
|
-
const vmGitconfig = creds.gitconfig.replace(/signingKey\s*=\s*.+/g, `signingKey = ${vmSigningKey}`);
|
|
8827
|
+
const vmGitconfig = rewriteGitconfigPaths(creds.gitconfig, vmSshDir, vmAgentDir);
|
|
8829
8828
|
await vm.fs.writeFile(`${vmAgentDir}/gitconfig`, vmGitconfig, {
|
|
8830
8829
|
mode: 420,
|
|
8831
8830
|
signal: config.signal
|
|
@@ -8848,17 +8847,6 @@ async function resumeVm(config) {
|
|
|
8848
8847
|
signal: config.signal
|
|
8849
8848
|
});
|
|
8850
8849
|
await vm.exec("chown -R agent:agent /home/agent/.pi /home/agent/.moltnet", { signal: config.signal });
|
|
8851
|
-
const gitCredHelperPath = `${vmSshDir}/git-credential-moltnet`;
|
|
8852
|
-
const credHelperScript = `#!/bin/sh
|
|
8853
|
-
echo "username=x-access-token"
|
|
8854
|
-
echo "password=$(moltnet github token --credentials ${vmSshDir}/moltnet.json)"
|
|
8855
|
-
`;
|
|
8856
|
-
await vm.fs.writeFile(gitCredHelperPath, credHelperScript, {
|
|
8857
|
-
mode: 493,
|
|
8858
|
-
signal: config.signal
|
|
8859
|
-
});
|
|
8860
|
-
await vmRun(vm, "git credential helper", `git config --global credential.helper ${gitCredHelperPath} && \
|
|
8861
|
-
git config --global url."https://github.com/".insteadOf "git@github.com:"`, config.signal);
|
|
8862
8850
|
return {
|
|
8863
8851
|
vm,
|
|
8864
8852
|
credentials: creds,
|
|
@@ -8877,6 +8865,30 @@ echo "password=$(moltnet github token --credentials ${vmSshDir}/moltnet.json)"
|
|
|
8877
8865
|
}
|
|
8878
8866
|
}
|
|
8879
8867
|
/**
|
|
8868
|
+
* Rewrite host-absolute paths inside an agent gitconfig to VM-local
|
|
8869
|
+
* equivalents before injecting it into the guest.
|
|
8870
|
+
*
|
|
8871
|
+
* Two rewrites:
|
|
8872
|
+
* - `signingKey = <host path>` → `<vmSshDir>/id_ed25519`
|
|
8873
|
+
* - `... credential-helper --credentials <host moltnet.json>`
|
|
8874
|
+
* → `<vmAgentDir>/moltnet.json`
|
|
8875
|
+
*
|
|
8876
|
+
* The credential-helper line is generated host-side by `moltnet github setup`
|
|
8877
|
+
* with a host-absolute `--credentials` path; inside the guest that path is
|
|
8878
|
+
* invalid, so it must point at the VM-side moltnet.json. The `insteadOf`
|
|
8879
|
+
* rewrite rule and every other line are workspace-independent and pass through
|
|
8880
|
+
* unchanged. A gitconfig without a credential helper is rewritten only for
|
|
8881
|
+
* `signingKey`.
|
|
8882
|
+
*
|
|
8883
|
+
* This is the single source of truth for git push auth in the guest: the
|
|
8884
|
+
* injected gitconfig carries the tokenless mint-on-demand helper, so the VM
|
|
8885
|
+
* no longer hand-rolls a credential-helper script or runs an imperative
|
|
8886
|
+
* `git config --global ... insteadOf` against the guest $HOME.
|
|
8887
|
+
*/
|
|
8888
|
+
function rewriteGitconfigPaths(gitconfig, vmSshDir, vmAgentDir) {
|
|
8889
|
+
return gitconfig.replace(/signingKey\s*=\s*.+/g, `signingKey = ${vmSshDir}/id_ed25519`).replace(/(moltnet github credential-helper --credentials )\S+/g, `$1${vmAgentDir}/moltnet.json`);
|
|
8890
|
+
}
|
|
8891
|
+
/**
|
|
8880
8892
|
* Rewrite host-absolute paths inside moltnet.json to VM-local equivalents.
|
|
8881
8893
|
*
|
|
8882
8894
|
* Fields rewritten:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@themoltnet/pi-extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
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": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@earendil-works/gondolin": "^0.9.1",
|
|
37
37
|
"@opentelemetry/api": "^1.9.0",
|
|
38
38
|
"typebox": "^1.2.8",
|
|
39
|
-
"@themoltnet/
|
|
40
|
-
"@themoltnet/
|
|
39
|
+
"@themoltnet/agent-runtime": "0.25.0",
|
|
40
|
+
"@themoltnet/sdk": "0.108.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@earendil-works/pi-coding-agent": ">=0.74.0",
|