worktrust 0.11.10 → 0.11.11
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/CHANGELOG.md +19 -0
- package/README.md +3 -3
- package/engine-release.json +1 -1
- package/package-release.json +1 -1
- package/package.json +1 -1
- package/remote-adapter-codex.mjs +49 -6
- package/remote-adapter-opencode.mjs +63 -10
- package/remote-daemon.mjs +5 -2
- package/remote-inventory.mjs +12 -2
- package/remote-protocol.mjs +119 -20
- package/remote-sessions.mjs +15 -15
- package/remote-steering.mjs +60 -0
- package/session-readers.mjs +12 -2
- package/transcript-readers.mjs +5 -5
- package/worktrust.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
The WorkTrust CLI, newest first. What the tool is and how to use it: [README.md](README.md).
|
|
4
4
|
|
|
5
|
+
## 0.11.11: faster file sending, another model in the same chat, and no release from a phone for Codex and OpenCode
|
|
6
|
+
|
|
7
|
+
**Files travel faster.** Remote Agent checks and encodes a file's pieces without decoding them first and gives the
|
|
8
|
+
computer room to breathe between them, so a large picture or document from your phone arrives sooner and the CLI stays
|
|
9
|
+
responsive while it does. What travels over the wire is the same as before.
|
|
10
|
+
|
|
11
|
+
**Another model of the same agent, in the same chat.** From a phone that offers it, a running Claude Code, Codex or
|
|
12
|
+
OpenCode session can continue on another of that agent's own models: Claude Code resumes its own session with the new
|
|
13
|
+
model, Codex takes it from the next turn, OpenCode from its next run. The computer checks the model against the list its
|
|
14
|
+
agent reported; a model it did not list is refused, and another agent is always a new chat. A terminal session never
|
|
15
|
+
switches. A phone that does not ask for it sees exactly what it saw before.
|
|
16
|
+
|
|
17
|
+
**No release from a phone, for Codex and OpenCode too.** A Codex or OpenCode session steered from your phone can no
|
|
18
|
+
longer run a ship script, a deploy script, `psql` or a release, whatever your own desk settings allow. Codex: while your
|
|
19
|
+
own Codex rules allow a command that is not one WorkTrust reviewed, a remote Codex session does not start (Codex offers no
|
|
20
|
+
way to set them aside for one session), and its approvals always come to your phone. OpenCode: your own and the project's
|
|
21
|
+
shell allows are denied for the remote run, beside a fixed list; a settings file that cannot be read gives that run no
|
|
22
|
+
shell at all. This computer's keyboard keeps every one of them. Nothing it measures changes: the measure rules stay 4.
|
|
23
|
+
|
|
5
24
|
## 0.11.10: one scan to connect, a look before you sign in, and no release from a phone
|
|
6
25
|
|
|
7
26
|
**One QR connects a computer.** `npx -y worktrust remote app` draws one code. Scanned in the WorkTrust app (Scan ›
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ computer in WorkTrust under Sources, Devices. More under [Undo](#undo).
|
|
|
67
67
|
On a computer that is not connected yet:
|
|
68
68
|
|
|
69
69
|
```
|
|
70
|
-
WorkTrust CLI 0.11.
|
|
70
|
+
WorkTrust CLI 0.11.11
|
|
71
71
|
Not connected yet
|
|
72
72
|
|
|
73
73
|
> 1 Look at this computer npx worktrust look
|
|
@@ -84,13 +84,13 @@ On a computer that is not connected yet:
|
|
|
84
84
|
Once it is connected (80 columns; on a wide terminal each row's sentence stands on the row itself, as a fourth column):
|
|
85
85
|
|
|
86
86
|
```
|
|
87
|
-
WorkTrust CLI 0.11.
|
|
87
|
+
WorkTrust CLI 0.11.11
|
|
88
88
|
Account you@example.com
|
|
89
89
|
This computer imac · connected since 2026-11-03
|
|
90
90
|
Remote Agent approved, 2 connections
|
|
91
91
|
Sharing session hook on · AI apps on (7) · Remote Agent approved
|
|
92
92
|
|
|
93
|
-
1 Update WorkTrust · up to date (0.11.
|
|
93
|
+
1 Update WorkTrust · up to date (0.11.11) npx worktrust update
|
|
94
94
|
> 2 Check this computer npx worktrust
|
|
95
95
|
3 Remote Agent › npx worktrust remote …
|
|
96
96
|
4 Import earlier history › npx worktrust history …
|
package/engine-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"fa16b61ad179999c5c5365255182acf69bcba1eb5f5ce7b0e1e18c11f56130ae","cli-look.mjs":"1bcc1314f53a4b886d19ac7a4eb4010b5e86d9e00b8e880ccbcd43f515c6dfd9","cli-menu-remote.mjs":"8e933adf5c849f28cd1fcec879ff8480794a15d34a6be25585e68454d8512bf6","cli-menu.mjs":"67928264a9cb7fcf4a4bb2ee546cba1eee36c180ea76bd669834c33d9508fc89","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","folder-picker.mjs":"daeb379626d5716f91f588064c6b4083618279320c006c177960cc93f056d96a","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"171f4abb0d603d58446129e007de9e9dc0f707bde33b1b4481a134376ed301c8","node-guide.mjs":"5bf52c5028b07a80ec4d41be365eb025dfce74328f41f928a26ce6737b1f9cc4","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"d0558bb123a29a934db1bf8162e7c3f37e8ccde4c502178d47e9b4cbb3a0491b","remote-adapter-codex.mjs":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"fa16b61ad179999c5c5365255182acf69bcba1eb5f5ce7b0e1e18c11f56130ae","cli-look.mjs":"1bcc1314f53a4b886d19ac7a4eb4010b5e86d9e00b8e880ccbcd43f515c6dfd9","cli-menu-remote.mjs":"8e933adf5c849f28cd1fcec879ff8480794a15d34a6be25585e68454d8512bf6","cli-menu.mjs":"67928264a9cb7fcf4a4bb2ee546cba1eee36c180ea76bd669834c33d9508fc89","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","folder-picker.mjs":"daeb379626d5716f91f588064c6b4083618279320c006c177960cc93f056d96a","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"171f4abb0d603d58446129e007de9e9dc0f707bde33b1b4481a134376ed301c8","node-guide.mjs":"5bf52c5028b07a80ec4d41be365eb025dfce74328f41f928a26ce6737b1f9cc4","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"d0558bb123a29a934db1bf8162e7c3f37e8ccde4c502178d47e9b4cbb3a0491b","remote-adapter-codex.mjs":"0370611044e6f5f6ef3ca370e0f6ef237468f01ecc890b019da8167730eb75eb","remote-adapter-opencode.mjs":"062c571cc4ab972412044066c236a9f20794cfb841c66cc9c0e9e5ec1133699e","remote-adapter-terminal.mjs":"c047a362474abb90b7968b8a624358af40a989ad137166a03bc955409ff1dc82","remote-admin.mjs":"ac4d434c0a374159b27accac3fdd0324ff96ffe32227fba054cc62d00e58d35b","remote-agent-switch.mjs":"7ff5448f29f05a47d7298d730b21243a1bcf8a215b434a0c7fbf5f3cb0889041","remote-approval-bridge.mjs":"092f17b7969e4f35bea064315d04dcde1faa6a3fd3e737dcc05aece82c7a37c4","remote-approvals.mjs":"63847226e398f9eb5b8d3989ba2b2436fbedd898385eb5f2f63bbdf07fbe6852","remote-attachments.mjs":"2e9c1277329a45cf26c0c62abda632cf0ab9fad78d0504416ecee9805220e16c","remote-cdp.mjs":"70e333a1ebe845e872cc3a703a0a507391f8ce59640bdbd662bdad55eeff216b","remote-changes.mjs":"2141fece4961a5bc1bb1b046f78222812617457b1ba6452275eac6a897e62e19","remote-claude-events.mjs":"58822471203c6a1b66cf81c115c4d713657c3dea5c7b98df959f894ee5b2e704","remote-claude-progress.mjs":"2ca626d3dbc16d8d570abe1df6477b7e44ffb43c1d9145228ec5ea1928e415ca","remote-cli.mjs":"fa3ada1e8845855789d61daac8c69853d81dcde25dfbffc223d6fed17c7efa94","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-connections.mjs":"1863863930f6df968084571be16c2382fbb0ba3ae64e26a9f9c90a7f9bf0b157","remote-countdown.mjs":"85cf2d01fe5ca49895e08a3d5de346bb5e4a8dd31b9fda3fd9f9534d9e1e47cf","remote-daemon.mjs":"e7e02ded144990ab45da66466804f58f764ba187b729fa040c8743acca6f6f0e","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-inventory.mjs":"98a65a066772ef183f405a1455c02db6827f06e80ed601796c65c19f9be10f09","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"3108375501ead2c2c78bce1435cc2a9fe6d2af1d7ff1fb42e12ff3e0f5d9af9c","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"f42bfb9c0b19ba3363c7b1c3d98cbd01c2bc7856acd763bf9e8ee53fefeccf2a","remote-pipeline-config.mjs":"00cde6a61ce21144c51ac56fce42fee159aa9dba6586218a7ea790ce4a6bd40b","remote-pipeline-parsers.mjs":"43ca0d332d7bc883c4759a754a555815ae5dfe133446b91ba9f2e48a350fa20f","remote-pipeline.mjs":"b856ead989b29ddb618ef69bbacd104bae2b02c9d1c5214291d08ce469a8b24e","remote-policy.mjs":"16ea015ad5de3c357bce730ea8ea98571dc981d8591fb5156b1941b2c557a381","remote-preview.mjs":"fe504ad6f83dcb4a4ebdcc018686a9a5a900c47cdf8c45b75e7d02e2f3056155","remote-projects.mjs":"ec8c530ad3e880bca21a4d4078ecd68b6aaafcc442b50087127868d952034d5f","remote-protocol.mjs":"a48c96b30172004623a228d126309623280456793cc26c1ac232e737717e26c7","remote-qr.mjs":"73e7743c33e35b1b01d6df3260e876beab419179265aa201a101596b4a813d86","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"5dce92062a4e5073b17860223bf1fc7362a23c620d81c8df535b8a580f590fe8","remote-screen-approvals.mjs":"c43ab286d36a38d17639d155782ffa017f1a9b6806a09b82ed0142a1290b6000","remote-screen-push.mjs":"4ee8bd48d24b2c87581e9f33d8354a86381f7febd82f89ed509a7a87c1442608","remote-screen-states.mjs":"7c3c86a584bebf52461f3cab39c05ea2a13910061704d48fc622956e842940f7","remote-service.mjs":"a3a5502e0f6f43b04e37ee778f43d88f4c219776439cfed0d8fa0b511e0c9637","remote-session-list.mjs":"494fdbe20f0542806ac6c42ad149c52e2d3ace23a3a7567f96dc7e80d092c727","remote-sessions.mjs":"c4055a1e08e929319f10b309ab5a9c42b78127b744f4df7d128bdc7d10ea951c","remote-settings.mjs":"ca16f39416a457bd5ceb1df847596e1b4bcd2894310eb6514664a619dee4981f","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"593447f3b7abbf3b91237d6d8a1aebcce9fbddc5ea5874341241ee45d83e5196","remote-store.mjs":"592a87f0ab8f53cc8eee1318a309310e27cb01d4549caebad6d51c3fad1b75ac","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"6ab51824890a18768d23cedc499f3840b2b02a8ed651463c1fe2d74dd352a361","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","session-readers.mjs":"14cbd2c92d87511b396feaa54710f00d5e3929b55e01dc559f39c5def13777a2","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"3dfdd9d2189063f24dbd5c2abec6bb21e2bb36f22b89d0d84282e12216022670","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"5cb20c2f9d99969633b0060309232d0df362a4a6fd57659cbdc8fda4b774cd52"},"format":"worktrust-package/1","kind":"engine","version":"0.11.11"},"signature":"vphOIdR8gnHB45NrqKmca56qlXQCC_3lGcpvj4wc3smtaIApiRGzYQi9jgG44uHRi4_zQOemuzqbEKvKw7svDg"}
|
package/package-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CHANGELOG.md":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CHANGELOG.md":"33d0abeeb265d7acd6d8c4d6b4256c2c77238262d1a5bd114f7ffce910724148","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"eb210c9cab5dbb6a2c293a003a7604e7fb6e5f7b95ab22b382171dc7adeed41a","README.md":"897ec58b3ae18d0997b97378f4de0119c4aca5f012ca12436b39c483679eea76","SECURITY.md":"6a798d875f48ae84c3a677397e5611e03b94215944952e0f61e13f6cfc949745","chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"fa16b61ad179999c5c5365255182acf69bcba1eb5f5ce7b0e1e18c11f56130ae","cli-look.mjs":"1bcc1314f53a4b886d19ac7a4eb4010b5e86d9e00b8e880ccbcd43f515c6dfd9","cli-menu-remote.mjs":"8e933adf5c849f28cd1fcec879ff8480794a15d34a6be25585e68454d8512bf6","cli-menu.mjs":"67928264a9cb7fcf4a4bb2ee546cba1eee36c180ea76bd669834c33d9508fc89","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"703167caac49c4f0a0413ef6f159be0757f222c7292520ac874774051573e5ab","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","folder-picker.mjs":"daeb379626d5716f91f588064c6b4083618279320c006c177960cc93f056d96a","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"171f4abb0d603d58446129e007de9e9dc0f707bde33b1b4481a134376ed301c8","node-guide.mjs":"5bf52c5028b07a80ec4d41be365eb025dfce74328f41f928a26ce6737b1f9cc4","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"d990b5a01958c88c33f2ba12994b854c058a079b08220636859c49d177ed5b2f","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"d0558bb123a29a934db1bf8162e7c3f37e8ccde4c502178d47e9b4cbb3a0491b","remote-adapter-codex.mjs":"0370611044e6f5f6ef3ca370e0f6ef237468f01ecc890b019da8167730eb75eb","remote-adapter-opencode.mjs":"062c571cc4ab972412044066c236a9f20794cfb841c66cc9c0e9e5ec1133699e","remote-adapter-terminal.mjs":"c047a362474abb90b7968b8a624358af40a989ad137166a03bc955409ff1dc82","remote-admin.mjs":"ac4d434c0a374159b27accac3fdd0324ff96ffe32227fba054cc62d00e58d35b","remote-agent-switch.mjs":"7ff5448f29f05a47d7298d730b21243a1bcf8a215b434a0c7fbf5f3cb0889041","remote-approval-bridge.mjs":"092f17b7969e4f35bea064315d04dcde1faa6a3fd3e737dcc05aece82c7a37c4","remote-approvals.mjs":"63847226e398f9eb5b8d3989ba2b2436fbedd898385eb5f2f63bbdf07fbe6852","remote-attachments.mjs":"2e9c1277329a45cf26c0c62abda632cf0ab9fad78d0504416ecee9805220e16c","remote-cdp.mjs":"70e333a1ebe845e872cc3a703a0a507391f8ce59640bdbd662bdad55eeff216b","remote-changes.mjs":"2141fece4961a5bc1bb1b046f78222812617457b1ba6452275eac6a897e62e19","remote-claude-events.mjs":"58822471203c6a1b66cf81c115c4d713657c3dea5c7b98df959f894ee5b2e704","remote-claude-progress.mjs":"2ca626d3dbc16d8d570abe1df6477b7e44ffb43c1d9145228ec5ea1928e415ca","remote-cli.mjs":"fa3ada1e8845855789d61daac8c69853d81dcde25dfbffc223d6fed17c7efa94","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-connections.mjs":"1863863930f6df968084571be16c2382fbb0ba3ae64e26a9f9c90a7f9bf0b157","remote-countdown.mjs":"85cf2d01fe5ca49895e08a3d5de346bb5e4a8dd31b9fda3fd9f9534d9e1e47cf","remote-daemon.mjs":"e7e02ded144990ab45da66466804f58f764ba187b729fa040c8743acca6f6f0e","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-inventory.mjs":"98a65a066772ef183f405a1455c02db6827f06e80ed601796c65c19f9be10f09","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"3108375501ead2c2c78bce1435cc2a9fe6d2af1d7ff1fb42e12ff3e0f5d9af9c","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"f42bfb9c0b19ba3363c7b1c3d98cbd01c2bc7856acd763bf9e8ee53fefeccf2a","remote-pipeline-config.mjs":"00cde6a61ce21144c51ac56fce42fee159aa9dba6586218a7ea790ce4a6bd40b","remote-pipeline-parsers.mjs":"43ca0d332d7bc883c4759a754a555815ae5dfe133446b91ba9f2e48a350fa20f","remote-pipeline.mjs":"b856ead989b29ddb618ef69bbacd104bae2b02c9d1c5214291d08ce469a8b24e","remote-policy.mjs":"16ea015ad5de3c357bce730ea8ea98571dc981d8591fb5156b1941b2c557a381","remote-preview.mjs":"fe504ad6f83dcb4a4ebdcc018686a9a5a900c47cdf8c45b75e7d02e2f3056155","remote-projects.mjs":"ec8c530ad3e880bca21a4d4078ecd68b6aaafcc442b50087127868d952034d5f","remote-protocol.mjs":"a48c96b30172004623a228d126309623280456793cc26c1ac232e737717e26c7","remote-qr.mjs":"73e7743c33e35b1b01d6df3260e876beab419179265aa201a101596b4a813d86","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"5dce92062a4e5073b17860223bf1fc7362a23c620d81c8df535b8a580f590fe8","remote-screen-approvals.mjs":"c43ab286d36a38d17639d155782ffa017f1a9b6806a09b82ed0142a1290b6000","remote-screen-push.mjs":"4ee8bd48d24b2c87581e9f33d8354a86381f7febd82f89ed509a7a87c1442608","remote-screen-states.mjs":"7c3c86a584bebf52461f3cab39c05ea2a13910061704d48fc622956e842940f7","remote-service.mjs":"a3a5502e0f6f43b04e37ee778f43d88f4c219776439cfed0d8fa0b511e0c9637","remote-session-list.mjs":"494fdbe20f0542806ac6c42ad149c52e2d3ace23a3a7567f96dc7e80d092c727","remote-sessions.mjs":"c4055a1e08e929319f10b309ab5a9c42b78127b744f4df7d128bdc7d10ea951c","remote-settings.mjs":"ca16f39416a457bd5ceb1df847596e1b4bcd2894310eb6514664a619dee4981f","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"593447f3b7abbf3b91237d6d8a1aebcce9fbddc5ea5874341241ee45d83e5196","remote-store.mjs":"592a87f0ab8f53cc8eee1318a309310e27cb01d4549caebad6d51c3fad1b75ac","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"6ab51824890a18768d23cedc499f3840b2b02a8ed651463c1fe2d74dd352a361","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","session-readers.mjs":"14cbd2c92d87511b396feaa54710f00d5e3929b55e01dc559f39c5def13777a2","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"3dfdd9d2189063f24dbd5c2abec6bb21e2bb36f22b89d0d84282e12216022670","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"5cb20c2f9d99969633b0060309232d0df362a4a6fd57659cbdc8fda4b774cd52"},"format":"worktrust-package/1","kind":"npm","version":"0.11.11"},"signature":"uEUw7UtAUairrKuQidJDfMFPGZH6gYoTJYEb6xSC18Sf0HJOUc7w9PMZTCotikJr4VEWIde1nAkDSFXK0wlcAw"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worktrust",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.11",
|
|
4
4
|
"description": "Couple this computer to WorkTrust: approve a code in your browser, and every AI app here reports what you built. Metadata only, no dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/remote-adapter-codex.mjs
CHANGED
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
* without a prompt (else Codex asks by `mcpServer/elicitation/request`), and the server's instructions reach the agent.
|
|
23
23
|
*/
|
|
24
24
|
import { spawn } from "node:child_process";
|
|
25
|
-
import { chmodSync, realpathSync, writeFileSync } from "node:fs";
|
|
26
|
-
import {
|
|
25
|
+
import { chmodSync, readdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
26
|
+
import { homedir } from "node:os";
|
|
27
|
+
import { isAbsolute, join } from "node:path";
|
|
27
28
|
import { changePaths, codexApprovalAsTool, refusalFor } from "./remote-codex-events.mjs";
|
|
28
29
|
import { PLAN_TOOL_NAMES } from "./remote-approval-bridge.mjs";
|
|
30
|
+
import { REVIEWED_COMMANDS } from "./remote-policy.mjs";
|
|
29
31
|
|
|
30
32
|
const MODEL = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
|
|
31
33
|
const THREAD = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -68,12 +70,49 @@ export function writeBridgeSession(file, { socket, token }) {
|
|
|
68
70
|
return file;
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
/**
|
|
74
|
+
* THE PERSON'S OWN CODEX RULES ARE DESK GRANTS (S0 for Codex, release 33; PROTOCOL.md §Approvals). Codex reads its execpolicy
|
|
75
|
+
* `.rules` files (`$CODEX_HOME/rules/`, else ~/.codex/rules/, and a project's `.codex/rules/`) whatever a session asks, and a
|
|
76
|
+
* `prefix_rule` whose decision is `allow` (the default when none is named) runs that command outside the sandbox without
|
|
77
|
+
* asking: a desk's "always allow `zsh …/ships/*`" would run a ship script from a phone prompt. `codex exec` has
|
|
78
|
+
* `--ignore-rules`; `codex app-server` (0.154.0) has no such flag and no config key that unloads them, so there is NO way to
|
|
79
|
+
* deny them per session. So the files are only READ here, at the session's start, never written: every allow that is not a
|
|
80
|
+
* reviewed command (remote-policy.mjs REVIEWED_COMMANDS, matched by its words) is returned, and a remote Codex session is
|
|
81
|
+
* refused while any is there (remote-sessions.mjs, `not_allowed`): then every command it runs is one the phone approved or
|
|
82
|
+
* one Codex itself deems read-only. A folder that cannot be read (other than missing) or a rule that cannot be read as a
|
|
83
|
+
* plain list of words counts as an allow: unknown is never allowed.
|
|
84
|
+
*/
|
|
85
|
+
export function codexDeskGrants({ env = process.env, home = homedir(), projectPath = null, read = (f) => readFileSync(f, "utf8"), list = (d) => readdirSync(d) } = {}) {
|
|
86
|
+
const dirs = [join(env.CODEX_HOME || join(env.HOME || home, ".codex"), "rules"), ...(projectPath ? [join(projectPath, ".codex", "rules")] : [])];
|
|
87
|
+
const reviewed = new Set(REVIEWED_COMMANDS);
|
|
88
|
+
const out = [];
|
|
89
|
+
for (const dir of dirs) {
|
|
90
|
+
let names;
|
|
91
|
+
try { names = list(dir).filter((n) => n.endsWith(".rules")).sort(); } catch (error) { if (error?.code !== "ENOENT") out.push(`${dir}: unreadable`); continue; }
|
|
92
|
+
for (const name of names) {
|
|
93
|
+
let text;
|
|
94
|
+
try { text = read(join(dir, name)); } catch { out.push(`${name}: unreadable`); continue; }
|
|
95
|
+
const code = text.replace(/#[^\n]*/g, "");
|
|
96
|
+
for (const m of code.matchAll(/prefix_rule\s*\(([\s\S]*?)\)\s*(?=prefix_rule|$)/g)) {
|
|
97
|
+
const decision = /decision\s*=\s*"([a-z]+)"/.exec(m[1])?.[1] ?? "allow";
|
|
98
|
+
if (decision === "prompt" || decision === "forbidden") continue;
|
|
99
|
+
const words = /pattern\s*=\s*\[([^\[\]]*)\]/.exec(m[1])?.[1];
|
|
100
|
+
const line = words !== undefined && /^\s*("[^"\\]*"\s*,\s*)*"[^"\\]*"\s*,?\s*$/.test(words) ? [...words.matchAll(/"([^"\\]*)"/g)].map((w) => w[1]).join(" ") : null;
|
|
101
|
+
if (line === null || !reviewed.has(line)) out.push(`${name}: ${line ?? "a rule that is not a plain list of words"}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
|
|
71
108
|
/** thread/start or thread/resume parameters from the protocol's closed options. */
|
|
72
109
|
export function threadParams({ cwd, model, mode, resume }) {
|
|
73
110
|
if (mode !== "ask" && mode !== "plan") throw new Error("the protocol offers the ask and plan modes only");
|
|
74
111
|
if (model !== null && !MODEL.test(model)) throw new Error("not a model name");
|
|
75
112
|
if (resume !== null && !isCodexThreadId(resume)) throw new Error("a resume id is Codex's own thread id");
|
|
76
|
-
|
|
113
|
+
// approvalsReviewer "user" (S0 for Codex, release 33): the person's config may route approvals to Codex's own reviewing
|
|
114
|
+
// subagent (`approvals_reviewer = "auto_review"`, which approves by itself); a remote session's go to the phone, always.
|
|
115
|
+
const common = { cwd, approvalPolicy: "untrusted", approvalsReviewer: "user", sandbox: mode === "plan" ? "read-only" : "workspace-write", ...(model ? { model } : {}) };
|
|
77
116
|
return resume ? { method: "thread/resume", params: { threadId: resume, ...common } } : { method: "thread/start", params: common };
|
|
78
117
|
}
|
|
79
118
|
|
|
@@ -81,15 +120,17 @@ const text = (t) => [{ type: "text", text: t }];
|
|
|
81
120
|
|
|
82
121
|
/**
|
|
83
122
|
* o: { file, cwd, env, model, mode, resume, plans?, onMessage(msg), onThread(threadId), onExit(how), approve(tool, input) → Promise<boolean> }.
|
|
84
|
-
* → { pid, alive, write(text), steer(text) → Promise<{ ok }>, interrupt() → Promise<boolean>, stop(), close() }.
|
|
123
|
+
* → { pid, alive, write(text), steer(text) → Promise<{ ok }>, interrupt() → Promise<boolean>, setModel(model), stop(), close() }.
|
|
124
|
+
* setModel (release 33): the next `turn/start` carries `model`, which the app-server takes "for this turn and subsequent turns"
|
|
125
|
+
* (its own JSON schema, 0.154.0); the thread and the process stay.
|
|
85
126
|
*/
|
|
86
127
|
export function startCodex(o) {
|
|
87
128
|
const child = spawn(o.file, codexArgs({ cwd: o.cwd, plans: o.plans ?? null }), { cwd: o.cwd, env: o.env, stdio: ["pipe", "pipe", "pipe"], detached: process.platform !== "win32", windowsHide: true });
|
|
88
|
-
let buffer = "", exited = false, nextId = 1, threadId = null, turnId = null, ready = false;
|
|
129
|
+
let buffer = "", exited = false, nextId = 1, threadId = null, turnId = null, ready = false, switched = null;
|
|
89
130
|
const waiting = new Map(), queue = [], fileChanges = {};
|
|
90
131
|
const send = (msg) => { if (!exited) child.stdin.write(`${JSON.stringify(msg)}\n`); };
|
|
91
132
|
const call = (method, params) => new Promise((resolve) => { if (exited) { resolve({ error: { message: "codex exited" } }); return; } const id = nextId++; waiting.set(id, resolve); send({ id, method, params }); });
|
|
92
|
-
const turn = (t) => call("turn/start", { threadId, input: text(t) });
|
|
133
|
+
const turn = (t) => call("turn/start", { threadId, input: text(t), ...(switched ? { model: switched } : {}) });
|
|
93
134
|
async function answer(msg) {
|
|
94
135
|
// An MCP server's question (a tool call to approve, a form): the planning tools never ask (approval_mode above), and
|
|
95
136
|
// nothing else of an MCP server is the phone's to answer. Declined in the elicitation's own shape.
|
|
@@ -142,6 +183,8 @@ export function startCodex(o) {
|
|
|
142
183
|
/** Words into the running turn, guarded by its id: a turn that just ended refuses them, and they wait for the next. */
|
|
143
184
|
async steer(t) { if (!ready || !turnId) return { ok: false }; const r = await call("turn/steer", { threadId, expectedTurnId: turnId, input: text(t) }); return { ok: !r.error }; },
|
|
144
185
|
async interrupt() { if (!ready || !turnId) return false; const r = await call("turn/interrupt", { threadId, turnId }); return !r.error; },
|
|
186
|
+
/** Another of Codex's own models from the next turn on (a name the computer listed and checked; never free text). */
|
|
187
|
+
setModel(model) { if (typeof model !== "string" || !MODEL.test(model)) throw new Error("not a model name"); switched = model; },
|
|
145
188
|
async stop(graceMs = 3000) {
|
|
146
189
|
if (exited) return;
|
|
147
190
|
if (turnId) await Promise.race([this.interrupt(), new Promise((r) => setTimeout(r, 1000))]);
|
|
@@ -25,8 +25,10 @@
|
|
|
25
25
|
*/
|
|
26
26
|
import { spawn } from "node:child_process";
|
|
27
27
|
import { randomBytes } from "node:crypto";
|
|
28
|
-
import { realpathSync } from "node:fs";
|
|
29
|
-
import {
|
|
28
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
29
|
+
import { homedir } from "node:os";
|
|
30
|
+
import { isAbsolute, join, relative } from "node:path";
|
|
31
|
+
import { REVIEWED_COMMANDS } from "./remote-policy.mjs";
|
|
30
32
|
|
|
31
33
|
const MODEL = /^[A-Za-z0-9][A-Za-z0-9._:/@+#-]{0,127}$/;
|
|
32
34
|
const SESSION = /^ses_[0-9a-f]{12}[0-9A-Za-z]{14}$/;
|
|
@@ -47,7 +49,51 @@ export function openCodeArgs({ sessionRef, model, mode }) {
|
|
|
47
49
|
if (!isOpenCodeSessionId(sessionRef)) throw new Error("an OpenCode session id is ses_ and 26 characters");
|
|
48
50
|
if (model !== null && !MODEL.test(model)) throw new Error("not a model name");
|
|
49
51
|
if (mode !== "ask" && mode !== "plan") throw new Error("the protocol offers the ask and plan modes only");
|
|
50
|
-
|
|
52
|
+
// The agent is always named (release 33): a person's `default_agent` could otherwise pick one of their own, with its rules.
|
|
53
|
+
return ["run", "--format", "json", "--session", sessionRef, ...(model ? ["--model", model] : []), "--agent", mode === "plan" ? "plan" : "build"];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* NO SHIP SCRIPT FROM A PHONE, FOR OPENCODE (S0, release 33; PROTOCOL.md §Approvals). The run's own config sits above the
|
|
58
|
+
* person's and the project's, but OpenCode merges configs key by key: a `permission.bash` OBJECT of ours keeps every key of
|
|
59
|
+
* theirs it does not name, so a desk grant such as `"zsh /Users/…/ships/*": "allow"` would still run without asking. So
|
|
60
|
+
* the person's global config (`$OPENCODE_CONFIG`, `$XDG_CONFIG_HOME/opencode/opencode.json[c]`, else ~/.config/opencode/)
|
|
61
|
+
* and the project's own `opencode.json[c]` are only READ at the session's start, never written, and each bash pattern they
|
|
62
|
+
* allow (in `permission.bash` and in any agent's) that is not a reviewed command comes back under the same key as `deny`;
|
|
63
|
+
* the fixed list (OPENCODE_DENY) is denied besides. A file that is there but cannot be read or parsed: the allows are not
|
|
64
|
+
* known, so the session gets no shell at all (`unreadable`). Missing files deny nothing more.
|
|
65
|
+
*/
|
|
66
|
+
export const OPENCODE_DENY = Object.freeze(["zsh *", "bash *", "sh *", "SHIP_YES=1 *", "node scripts/deploy-production.mjs*", "node scripts/mobile-update.mjs*", "gh release*", "gh workflow*", "psql*", "git push*", "npm publish*", "pnpm publish*", "vercel *", "eas *", "sudo *", "curl *", "wget *"]);
|
|
67
|
+
|
|
68
|
+
/** JSON with comments and trailing commas (OpenCode's .jsonc) as JSON; strings are kept as they are. */
|
|
69
|
+
export function jsoncText(text) {
|
|
70
|
+
let out = "", i = 0;
|
|
71
|
+
while (i < text.length) {
|
|
72
|
+
const c = text[i];
|
|
73
|
+
if (c === '"') { const end = /"(?:[^"\\]|\\.)*"/y; end.lastIndex = i; const m = end.exec(text); if (!m) return null; out += m[0]; i += m[0].length; continue; }
|
|
74
|
+
if (c === "/" && text[i + 1] === "/") { while (i < text.length && text[i] !== "\n") i += 1; continue; }
|
|
75
|
+
if (c === "/" && text[i + 1] === "*") { const end = text.indexOf("*/", i + 2); if (end < 0) return null; i = end + 2; continue; }
|
|
76
|
+
out += c; i += 1;
|
|
77
|
+
}
|
|
78
|
+
return out.replace(/,(\s*[}\]])/g, "$1");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function openCodeDeskDenies({ env = process.env, home = homedir(), projectPath = null, read = (f) => readFileSync(f, "utf8") } = {}) {
|
|
82
|
+
const base = env.XDG_CONFIG_HOME || join(env.HOME || home, ".config");
|
|
83
|
+
const files = [...(env.OPENCODE_CONFIG ? [env.OPENCODE_CONFIG] : []), join(base, "opencode", "opencode.json"), join(base, "opencode", "opencode.jsonc"), ...(projectPath ? [join(projectPath, "opencode.json"), join(projectPath, "opencode.jsonc")] : [])];
|
|
84
|
+
const reviewed = new Set(REVIEWED_COMMANDS.flatMap((line) => [line, `${line} *`, `${line}*`]));
|
|
85
|
+
const denies = new Set(), edits = new Set();
|
|
86
|
+
for (const file of files) {
|
|
87
|
+
let text;
|
|
88
|
+
try { text = read(file); } catch (error) { if (error?.code === "ENOENT") continue; return { denies: [], edits: [], unreadable: true }; }
|
|
89
|
+
let config;
|
|
90
|
+
try { const clean = jsoncText(text); config = clean === null ? null : JSON.parse(clean); } catch { config = null; }
|
|
91
|
+
if (!config || typeof config !== "object") return { denies: [], edits: [], unreadable: true };
|
|
92
|
+
const bashes = [config.permission?.bash, ...Object.values(config.agent ?? {}).map((a) => a?.permission?.bash)];
|
|
93
|
+
for (const bash of bashes) if (bash && typeof bash === "object") for (const [pattern, decision] of Object.entries(bash)) if (decision === "allow" && pattern !== "*" && !reviewed.has(pattern)) denies.add(pattern);
|
|
94
|
+
for (const edit of [config.permission?.edit, ...Object.values(config.agent ?? {}).map((a) => a?.permission?.edit)]) if (edit && typeof edit === "object") for (const [pattern, decision] of Object.entries(edit)) if (decision === "allow" && pattern !== "*") edits.add(pattern);
|
|
95
|
+
}
|
|
96
|
+
return { denies: [...denies].sort(), edits: [...edits].sort(), unreadable: false };
|
|
51
97
|
}
|
|
52
98
|
|
|
53
99
|
const SECRET_READS = ["*.env", "*.env.*", "*.envrc", "*.netrc", "*.npmrc", "*.pypirc", "*.git-credentials", "*.pem", "*.key", "*.p12", "*.pfx", "*id_rsa*", "*id_ed25519*", "*id_ecdsa*", "*credentials*", "*secret*"];
|
|
@@ -57,12 +103,15 @@ const noWildcard = (text) => typeof text === "string" && text.length > 0 && !/[*
|
|
|
57
103
|
* `{ tool: "Edit", path }` (relative to the project), allowed by their exact text on top of "ask". String values replace
|
|
58
104
|
* whatever a person's or a repository's config set for the same key (OpenCode merges configs key by key).
|
|
59
105
|
*/
|
|
60
|
-
export function permissionConfig(mode, allow = []) {
|
|
106
|
+
export function permissionConfig(mode, allow = [], desk = { denies: [], unreadable: false }) {
|
|
61
107
|
const read = Object.fromEntries([["*", "allow"], ...SECRET_READS.map((p) => [p, "deny"])]);
|
|
62
108
|
const bash = allow.filter((a) => a.tool === "Bash" && noWildcard(a.command)), edit = allow.filter((a) => a.tool === "Edit" && noWildcard(a.path));
|
|
109
|
+
// S0 (release 33): the fixed denies and the person's own allows as denies, last, so they outrank every allow; no shell at all
|
|
110
|
+
// when the person's config could not be read.
|
|
63
111
|
const permission = { "*": "ask", read, glob: "allow", grep: "allow", list: "allow", todowrite: "allow", external_directory: "deny", question: "deny", doom_loop: "deny",
|
|
64
|
-
bash:
|
|
65
|
-
|
|
112
|
+
bash: desk.unreadable ? "deny" : Object.fromEntries([["*", "ask"], ...bash.map((a) => [a.command, "allow"]), ...[...OPENCODE_DENY, ...desk.denies].map((p) => [p, "deny"])]),
|
|
113
|
+
// A path the person allows at the desk asks here (their key, our value): only the phone's approval of this run allows one.
|
|
114
|
+
edit: mode === "plan" ? "deny" : edit.length ? Object.fromEntries([["*", "ask"], ...(desk.edits ?? []).map((p) => [p, "ask"]), ...edit.map((a) => [a.path, "allow"])]) : "ask" };
|
|
66
115
|
return { permission, agent: { build: { permission }, plan: { permission: { ...permission, edit: "deny" } } } };
|
|
67
116
|
}
|
|
68
117
|
|
|
@@ -94,15 +143,17 @@ const MAX_FOLLOW_UPS = 3;
|
|
|
94
143
|
|
|
95
144
|
/**
|
|
96
145
|
* o: { file, cwd, env, model, mode, sessionRef, onMessage(line), onExit(how), approve(tool, input) → Promise<boolean> }.
|
|
97
|
-
* → { pid, alive, write(text), interrupt() → Promise<boolean>, stop(), close() }. A turn is one run and its
|
|
98
|
-
* onMessage hears each JSON line and `wt.turn_started` / `wt.turn_ended` around them.
|
|
146
|
+
* → { pid, alive, write(text), interrupt() → Promise<boolean>, setModel(model), stop(), close() }. A turn is one run and its
|
|
147
|
+
* follow-ups; onMessage hears each JSON line and `wt.turn_started` / `wt.turn_ended` around them. setModel (release 33): the
|
|
148
|
+
* next run's `--model`, the same `--session`.
|
|
99
149
|
*/
|
|
100
150
|
export function startOpenCode(o) {
|
|
101
|
-
|
|
151
|
+
let args = openCodeArgs({ sessionRef: o.sessionRef, model: o.model, mode: o.mode });
|
|
152
|
+
const desk = openCodeDeskDenies({ env: o.env, projectPath: o.cwd }); // read once, at the session's start (S0)
|
|
102
153
|
let child = null, closed = false, interrupted = false, busy = false, exited = false;
|
|
103
154
|
const queue = [];
|
|
104
155
|
const runOnce = (text, allow) => new Promise((resolve) => {
|
|
105
|
-
const env = { ...o.env, OPENCODE_CONFIG_CONTENT: JSON.stringify(permissionConfig(o.mode, allow)) };
|
|
156
|
+
const env = { ...o.env, OPENCODE_CONFIG_CONTENT: JSON.stringify(permissionConfig(o.mode, allow, desk)) };
|
|
106
157
|
const run = child = spawn(o.file, args, { cwd: o.cwd, env, stdio: ["pipe", "pipe", "pipe"], detached: process.platform !== "win32", windowsHide: true });
|
|
107
158
|
const asks = [];
|
|
108
159
|
let buffer = "";
|
|
@@ -154,6 +205,8 @@ export function startOpenCode(o) {
|
|
|
154
205
|
alive: () => !closed,
|
|
155
206
|
sessionRef: () => o.sessionRef,
|
|
156
207
|
write: (t) => { if (closed) return; if (busy) queue.push(t); else turn(t); },
|
|
208
|
+
/** Another of OpenCode's own models from the next run on, checked as the first one was (openCodeArgs throws on anything else). */
|
|
209
|
+
setModel(model) { args = openCodeArgs({ sessionRef: o.sessionRef, model, mode: o.mode }); },
|
|
157
210
|
/** End the running turn: OpenCode cancels its session's work on SIGINT and exits; the session stays for the next prompt. */
|
|
158
211
|
async interrupt() { if (!child) return false; interrupted = true; await halt(3000); return true; },
|
|
159
212
|
async stop(graceMs = 3000) {
|
package/remote-daemon.mjs
CHANGED
|
@@ -38,9 +38,11 @@ export function createDaemonCore(o) {
|
|
|
38
38
|
* unknown keys, so every other channel gets the inventory without them. Kept per phone for the daemon's life; a phone
|
|
39
39
|
* asks again on every inventory.get.
|
|
40
40
|
*/
|
|
41
|
-
const extendedPeers = new Set();
|
|
41
|
+
const extendedPeers = new Set(), switchPeers = new Set(); // release 33: `model_switch` only for a phone that asked for it
|
|
42
42
|
const EXTENDED_KEYS = ["agent_options", "modes_allowed", "admin", "folders", "connections"];
|
|
43
|
-
const
|
|
43
|
+
const withoutSwitch = (body) => (body.agent_options ? { ...body, agent_options: body.agent_options.map(({ model_switch: _drop, ...o }) => o) } : body);
|
|
44
|
+
const bodyFor = (channel, record) => (record.type !== "device.inventory" ? record.body
|
|
45
|
+
: extendedPeers.has(channel.peer_device_id) ? (switchPeers.has(channel.peer_device_id) ? record.body : withoutSwitch(record.body))
|
|
44
46
|
: Object.fromEntries(Object.entries(record.body).filter(([key]) => !EXTENDED_KEYS.includes(key))));
|
|
45
47
|
|
|
46
48
|
function sealAll(record) {
|
|
@@ -181,6 +183,7 @@ export function createDaemonCore(o) {
|
|
|
181
183
|
if (settings.paused !== null && !DEVICE_COMMANDS.has(env.type)) return "remote_paused";
|
|
182
184
|
if (env.type === "inventory.get") {
|
|
183
185
|
if (payload.extended === true && env.sender_device_id) extendedPeers.add(env.sender_device_id);
|
|
186
|
+
if (payload.extended === true && payload.model_switch === true && env.sender_device_id) switchPeers.add(env.sender_device_id); // kept, as extendedPeers
|
|
184
187
|
if (payload.device_name && env.sender_device_id) rememberName(env.sender_device_id, payload.device_name);
|
|
185
188
|
emit(null, "device.inventory", inventoryBody(payload.refresh_models));
|
|
186
189
|
return "taken";
|
package/remote-inventory.mjs
CHANGED
|
@@ -89,12 +89,22 @@ export function agentOptionsOf(inv) {
|
|
|
89
89
|
const f = inv.features?.["claude-code"] ?? {};
|
|
90
90
|
return inv.reports.filter((r) => r.installed && r.capabilities.start).map((r) => {
|
|
91
91
|
const base = r.capabilities.permission_modes.map((m) => (m === "plan" ? "plan" : "manual"));
|
|
92
|
-
|
|
92
|
+
const model_switch = modelSwitchOf(r);
|
|
93
|
+
if (r.adapter !== "claude-code" || r.mode !== "structured") return { adapter: r.adapter, mode: r.mode, agent_modes: P.AGENT_MODES.filter((m) => base.includes(m)), efforts: [], extra_projects: 0, model_switch };
|
|
93
94
|
const modes = new Set([...base, ...(f.editMode ? ["edit"] : []), ...(f.autoMode ? ["auto"] : [])]);
|
|
94
|
-
return { adapter: r.adapter, mode: r.mode, agent_modes: P.AGENT_MODES.filter((m) => modes.has(m)), efforts: [...(f.efforts ?? [])], extra_projects: f.addDir ? P.MAX_EXTRA_PROJECTS : 0 };
|
|
95
|
+
return { adapter: r.adapter, mode: r.mode, agent_modes: P.AGENT_MODES.filter((m) => modes.has(m)), efforts: [...(f.efforts ?? [])], extra_projects: f.addDir ? P.MAX_EXTRA_PROJECTS : 0, model_switch };
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
|
|
99
|
+
/**
|
|
100
|
+
* WHETHER A RUNNING SESSION OF THIS REPORT MAY CONTINUE ON ANOTHER OF ITS MODELS (release 33; remote-model-switch.mjs): a
|
|
101
|
+
* structured session of Claude Code that can resume by id (its own `--resume` with another `--model`), Codex (`turn/start`
|
|
102
|
+
* takes `model`) and OpenCode (each run takes `--model`), and only where the agent listed models to choose from. A terminal
|
|
103
|
+
* session never: nothing the phone composed is typed into it. Sent only to a phone that asked `model_switch` (remote-daemon.mjs).
|
|
104
|
+
*/
|
|
105
|
+
export const modelSwitchOf = (r) => r.mode === "structured" && Array.isArray(r.models) && r.models.length > 0
|
|
106
|
+
&& ((r.adapter === "claude-code" && r.capabilities.resume_by_id === true) || r.adapter === "codex" || r.adapter === "opencode");
|
|
107
|
+
|
|
98
108
|
/** The model aliases Claude Code's own --model help names, in its order; none when the help names none. */
|
|
99
109
|
export function claudeAliases(help) {
|
|
100
110
|
const block = /--model <model>([\s\S]*?)(?=\n\s{2}-|\n\s*\n|$)/.exec(help ?? "")?.[1]?.replace(/\s+/g, " ") ?? "";
|
package/remote-protocol.mjs
CHANGED
|
@@ -83,25 +83,41 @@ export const refuse = (code , detail )
|
|
|
83
83
|
*/
|
|
84
84
|
|
|
85
85
|
const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
86
|
-
|
|
86
|
+
/** Each alphabet character's code, for encoding into a byte array (one fromCharCode per block, not one string per byte). */
|
|
87
|
+
const CODES = Uint8Array.from(ALPHABET, (c) => c.charCodeAt(0));
|
|
88
|
+
/** Each ASCII code's 6-bit value, -1 outside the alphabet. */
|
|
89
|
+
const VALUES = new Int8Array(128).fill(-1);
|
|
90
|
+
for (let i = 0; i < ALPHABET.length; i += 1) VALUES[ALPHABET.charCodeAt(i)] = i;
|
|
91
|
+
/** The whole alphabet, anchored at both ends (no `m` flag: `$` is the end of the input, never before a newline). */
|
|
92
|
+
const BASE64URL_TEXT = /^[A-Za-z0-9_-]*$/;
|
|
93
|
+
const BLOCK = 8192;
|
|
87
94
|
|
|
88
95
|
/** base64url, no padding. */
|
|
89
96
|
export function toBase64Url(bytes ) {
|
|
90
|
-
|
|
97
|
+
const out = new Uint8Array(Math.ceil((bytes.length * 4) / 3));
|
|
98
|
+
let o = 0;
|
|
91
99
|
let i = 0;
|
|
92
100
|
for (; i + 2 < bytes.length; i += 3) {
|
|
93
101
|
const n = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2] ;
|
|
94
|
-
out
|
|
102
|
+
out[o++] = CODES[(n >> 18) & 63] ;
|
|
103
|
+
out[o++] = CODES[(n >> 12) & 63] ;
|
|
104
|
+
out[o++] = CODES[(n >> 6) & 63] ;
|
|
105
|
+
out[o++] = CODES[n & 63] ;
|
|
95
106
|
}
|
|
96
107
|
const rest = bytes.length - i;
|
|
97
108
|
if (rest === 1) {
|
|
98
109
|
const n = bytes[i] << 16;
|
|
99
|
-
out
|
|
110
|
+
out[o++] = CODES[(n >> 18) & 63] ;
|
|
111
|
+
out[o++] = CODES[(n >> 12) & 63] ;
|
|
100
112
|
} else if (rest === 2) {
|
|
101
113
|
const n = (bytes[i] << 16) | (bytes[i + 1] << 8);
|
|
102
|
-
out
|
|
114
|
+
out[o++] = CODES[(n >> 18) & 63] ;
|
|
115
|
+
out[o++] = CODES[(n >> 12) & 63] ;
|
|
116
|
+
out[o++] = CODES[(n >> 6) & 63] ;
|
|
103
117
|
}
|
|
104
|
-
|
|
118
|
+
let text = "";
|
|
119
|
+
for (let at = 0; at < o; at += BLOCK) text += String.fromCharCode.apply(null, out.subarray(at, Math.min(o, at + BLOCK)) );
|
|
120
|
+
return text;
|
|
105
121
|
}
|
|
106
122
|
|
|
107
123
|
/**
|
|
@@ -109,14 +125,16 @@ export function toBase64Url(bytes ) {
|
|
|
109
125
|
* exactly one string decodes to a given byte string; a signature over the string then means one thing).
|
|
110
126
|
*/
|
|
111
127
|
export function fromBase64Url(text ) {
|
|
112
|
-
|
|
113
|
-
|
|
128
|
+
const length = text.length;
|
|
129
|
+
if (length % 4 === 1) return null;
|
|
130
|
+
const out = new Uint8Array(Math.floor((length * 3) / 4));
|
|
114
131
|
let o = 0;
|
|
115
132
|
let acc = 0;
|
|
116
133
|
let bits = 0;
|
|
117
|
-
for (
|
|
118
|
-
const
|
|
119
|
-
|
|
134
|
+
for (let i = 0; i < length; i += 1) {
|
|
135
|
+
const code = text.charCodeAt(i);
|
|
136
|
+
const v = code < 128 ? VALUES[code] : -1;
|
|
137
|
+
if (v < 0) return null;
|
|
120
138
|
acc = (acc << 6) | v;
|
|
121
139
|
bits += 6;
|
|
122
140
|
if (bits >= 8) {
|
|
@@ -129,16 +147,61 @@ export function fromBase64Url(text ) {
|
|
|
129
147
|
return out;
|
|
130
148
|
}
|
|
131
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Whether `text` is canonical base64url (exactly what fromBase64Url accepts) of the stated size, WITHOUT decoding it
|
|
152
|
+
* (release 33; docs/OPEN.md "Rust was measured and not taken"): a 512 KiB attachment chunk was decoded only to be
|
|
153
|
+
* measured, about 110 ms on the phone and 96 ms of the relay's event loop per frame. The length gives the size, one
|
|
154
|
+
* anchored pattern the alphabet, and the last character's low bits the canonical form: of a length 2 past a multiple of
|
|
155
|
+
* four the last character carries 2 bits (its low 4 must be 0), of 3 past it carries 4 (its low 2 must be 0).
|
|
156
|
+
* scripts/lib/remote-protocol-bytes-cases.mjs proves the same accept and refuse set as decoding, over both builds.
|
|
157
|
+
*/
|
|
132
158
|
export function isBase64Url(text , bytes ) {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
return
|
|
159
|
+
const length = text.length;
|
|
160
|
+
const tail = length % 4;
|
|
161
|
+
if (tail === 1) return false;
|
|
162
|
+
const size = Math.floor((length * 3) / 4);
|
|
163
|
+
if (bytes?.exact !== undefined && size !== bytes.exact) return false;
|
|
164
|
+
if (bytes?.max !== undefined && size > bytes.max) return false;
|
|
165
|
+
if (!BASE64URL_TEXT.test(text)) return false;
|
|
166
|
+
if (tail === 0) return true;
|
|
167
|
+
const last = VALUES[text.charCodeAt(length - 1)] ;
|
|
168
|
+
return (last & (tail === 2 ? 15 : 3)) === 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** A lone surrogate, high without a low after it or low without a high before it (code units: no `u` flag). */
|
|
172
|
+
const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
173
|
+
|
|
174
|
+
/** Whether a string has a UTF-8 form (no lone surrogate): the engine's own check where it has one, else the pattern. */
|
|
175
|
+
export function wellFormed(text ) {
|
|
176
|
+
const native = (text ).isWellFormed;
|
|
177
|
+
return typeof native === "function" ? native.call(text) : !LONE_SURROGATE.test(text);
|
|
138
178
|
}
|
|
139
179
|
|
|
140
|
-
|
|
180
|
+
// The host's encoder, declared here because this package names no DOM or Node library (a bare `typeof` is safe when absent).
|
|
181
|
+
|
|
182
|
+
let nativeEncoder ;
|
|
183
|
+
function encoder() {
|
|
184
|
+
if (nativeEncoder === undefined) {
|
|
185
|
+
nativeEncoder = typeof TextEncoder === "function" ? new TextEncoder() : null;
|
|
186
|
+
}
|
|
187
|
+
return nativeEncoder;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* UTF-8 encode. Lone surrogates are refused: they have no UTF-8 form and would otherwise round-trip lossy (TextEncoder
|
|
192
|
+
* alone would replace them with U+FFFD, so the check comes first). The engine's TextEncoder where it has one (release
|
|
193
|
+
* 33: the per-character loop cost about 11 ms per attachment chunk), the portable loop elsewhere; both give the same
|
|
194
|
+
* bytes (scripts/lib/remote-protocol-bytes-cases.mjs).
|
|
195
|
+
*/
|
|
141
196
|
export function utf8Encode(text ) {
|
|
197
|
+
const native = encoder();
|
|
198
|
+
if (!native) return utf8EncodePortable(text);
|
|
199
|
+
if (!wellFormed(text)) throw new TypeError("lone surrogate");
|
|
200
|
+
return native.encode(text);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** UTF-8 encode without TextEncoder (an engine that has none); the same bytes and the same refusal as utf8Encode. */
|
|
204
|
+
export function utf8EncodePortable(text ) {
|
|
142
205
|
const out = [];
|
|
143
206
|
for (let i = 0; i < text.length; i += 1) {
|
|
144
207
|
let cp = text.charCodeAt(i);
|
|
@@ -219,8 +282,8 @@ export function canonicalJson(value ) {
|
|
|
219
282
|
if (value === null) return "null";
|
|
220
283
|
switch (typeof value) {
|
|
221
284
|
case "string":
|
|
222
|
-
// Lone surrogates are refused here too, so the string has a UTF-8 form.
|
|
223
|
-
|
|
285
|
+
// Lone surrogates are refused here too, so the string has a UTF-8 form (checked, not encoded: release 33).
|
|
286
|
+
if (!wellFormed(value)) throw new TypeError("lone surrogate");
|
|
224
287
|
return JSON.stringify(value);
|
|
225
288
|
case "boolean":
|
|
226
289
|
return value ? "true" : "false";
|
|
@@ -589,6 +652,13 @@ export const AGENT_OPTIONS_SPEC = object({
|
|
|
589
652
|
efforts: list(oneOf(AGENT_EFFORTS), AGENT_EFFORTS.length),
|
|
590
653
|
/** How many extra projects a session of this adapter may reach; 0: single-project. */
|
|
591
654
|
extra_projects: int(0, MAX_EXTRA_PROJECTS),
|
|
655
|
+
/**
|
|
656
|
+
* Release 33 (owner, 2026-11-13: option A): a running session of this adapter can continue on another of ITS OWN listed
|
|
657
|
+
* models (agent.prompt `model`): Claude Code by its own `--resume` with another `--model`, Codex by `turn/start`'s model,
|
|
658
|
+
* OpenCode by the next run's `--model`. Only in an inventory for a phone that asked `inventory.get` `model_switch`
|
|
659
|
+
* (an older phone refuses the unknown key); absent or false: another model is a new chat, as before.
|
|
660
|
+
*/
|
|
661
|
+
model_switch: optional(bool()),
|
|
592
662
|
});
|
|
593
663
|
|
|
594
664
|
export const CAPABILITIES_SPEC = object({
|
|
@@ -2317,7 +2387,16 @@ export const COMMAND_PAYLOAD_SPECS = {
|
|
|
2317
2387
|
* ends; with `interrupt: true` (only where the adapter reports interrupt) the computer ends the running turn first and
|
|
2318
2388
|
* runs this prompt next (2026-11-07).
|
|
2319
2389
|
*/
|
|
2320
|
-
"agent.prompt": object({
|
|
2390
|
+
"agent.prompt": object({
|
|
2391
|
+
text: text(MAX_PROMPT_CHARS, 1), interrupt: optional(bool()), attachments: optional(list(id("att"), MAX_ATTACHMENTS_PER_PROMPT)),
|
|
2392
|
+
/**
|
|
2393
|
+
* Release 33 (owner, 2026-11-13: option A): another model of the SAME agent for this turn and the turns after it, from
|
|
2394
|
+
* the session's adapter's own listed models; sent only to a computer whose extended inventory says `model_switch` for
|
|
2395
|
+
* that adapter (an older computer refuses the unknown key and runs nothing). The computer checks it again
|
|
2396
|
+
* (checkModelSwitch) against its own list and its adapter; another agent is never a model: it is a new chat.
|
|
2397
|
+
*/
|
|
2398
|
+
model: optional(text(128, 1)),
|
|
2399
|
+
}),
|
|
2321
2400
|
/**
|
|
2322
2401
|
* Words for an agent in the middle of a turn: redirect without stopping. Where the adapter reports steer_mode `live`
|
|
2323
2402
|
* they enter the running turn (accepted with `landed: "running_turn"` once the agent read them); `queued`, they run as
|
|
@@ -2374,6 +2453,11 @@ export const COMMAND_PAYLOAD_SPECS = {
|
|
|
2374
2453
|
* computer refuses the field with `extended` and the phone asks again without both.
|
|
2375
2454
|
*/
|
|
2376
2455
|
device_name: optional(text(MAX_DEVICE_NAME, 1)),
|
|
2456
|
+
/**
|
|
2457
|
+
* Release 33: this phone reads `agent_options[].model_switch` and may send agent.prompt `model`. Only with `extended`.
|
|
2458
|
+
* An older computer refuses the unknown field; the phone then asks again with `extended` alone (client-core.ts).
|
|
2459
|
+
*/
|
|
2460
|
+
model_switch: optional(bool()),
|
|
2377
2461
|
}),
|
|
2378
2462
|
/** This computer's remote settings, each optional. Pausing from the phone is soft; `worktrust remote disable` at the
|
|
2379
2463
|
* desk is the hard off, which no message can undo. */
|
|
@@ -2532,6 +2616,7 @@ export function validateCommandPayload (type , value
|
|
|
2532
2616
|
if (type === "inventory.get") {
|
|
2533
2617
|
const i = payload ;
|
|
2534
2618
|
if (i.device_name !== undefined && (i.extended !== true || !deviceNameOk(i.device_name))) return refuse("payload", "$payload.device_name: printable words, with extended");
|
|
2619
|
+
if (i.model_switch !== undefined && i.extended !== true) return refuse("payload", "$payload.model_switch: with extended");
|
|
2535
2620
|
}
|
|
2536
2621
|
if (type === "attachment.put") { const bad = attachmentRule(payload ); if (bad) return refuse("payload", `$payload: ${bad}`); }
|
|
2537
2622
|
if (type === "preview.render") { const bad = previewRule(payload ); if (bad) return refuse("payload", `$payload: ${bad}`); }
|
|
@@ -3276,6 +3361,20 @@ export function checkStart(payload , report
|
|
|
3276
3361
|
return null;
|
|
3277
3362
|
}
|
|
3278
3363
|
|
|
3364
|
+
/**
|
|
3365
|
+
* ANOTHER MODEL OF THE SAME AGENT, CHECKED AT THE COMPUTER (release 33; owner, 2026-11-13: option A). An agent.prompt
|
|
3366
|
+
* `model` is taken only when the session's own report (its adapter and mode) is installed and lists that model, and the
|
|
3367
|
+
* computer's own options for it say `model_switch` (its agent's resume or turn takes another model). → null, or
|
|
3368
|
+
* `unsupported` (no switch for this adapter or mode, a terminal session among them) or `unknown_model` (not listed).
|
|
3369
|
+
* A model is never trusted from a phone, and another agent is never a model: the payload has no adapter.
|
|
3370
|
+
*/
|
|
3371
|
+
export function checkModelSwitch(model , report , options ) {
|
|
3372
|
+
if (!report || !report.installed || !report.capabilities.start || report.mode !== "structured") return "unsupported";
|
|
3373
|
+
if (!options || options.adapter !== report.adapter || options.mode !== report.mode || options.model_switch !== true) return "unsupported";
|
|
3374
|
+
if (!isModelReported(report, model)) return "unknown_model";
|
|
3375
|
+
return null;
|
|
3376
|
+
}
|
|
3377
|
+
|
|
3279
3378
|
/**
|
|
3280
3379
|
* THE 0.11.7 START OPTIONS, CHECKED AT THE COMPUTER (owner, 2026-11-12): the agent mode, the effort and the extra
|
|
3281
3380
|
* projects of an agent.start, against the options the computer itself offers for that adapter (`options`, from its own
|
package/remote-sessions.mjs
CHANGED
|
@@ -17,13 +17,13 @@ import { allowedModes, startChoice } from "./remote-settings.mjs";
|
|
|
17
17
|
import { claudeArgs, isClaudeSessionId, removeQuietly, startClaude, writeMcpConfig } from "./remote-adapter-claude-code.mjs";
|
|
18
18
|
import { backgroundJobs, emptyClaudeState, endClaudeRun, mapClaudeLine } from "./remote-claude-events.mjs";
|
|
19
19
|
import { collectChanges, snapshotChanges } from "./remote-changes.mjs";
|
|
20
|
-
import { isCodexThreadId, startCodex, writeBridgeSession } from "./remote-adapter-codex.mjs";
|
|
20
|
+
import { codexDeskGrants, isCodexThreadId, startCodex, writeBridgeSession } from "./remote-adapter-codex.mjs";
|
|
21
21
|
import { emptyCodexState, mapCodexMessage, unwrapShell } from "./remote-codex-events.mjs";
|
|
22
22
|
import { isOpenCodeSessionId, mintOpenCodeSessionId } from "./remote-adapter-opencode.mjs";
|
|
23
23
|
import { emptyOpenCodeState } from "./remote-opencode-events.mjs";
|
|
24
24
|
import { spawnOpenCode } from "./remote-opencode-session.mjs";
|
|
25
25
|
import { createCoalescer } from "./remote-coalesce.mjs";
|
|
26
|
-
import { accept, announceQueue, claudeReplay, codexLanded, dropWaiting, interruptedEnd, interruptOf, steerLive, steerModeOf } from "./remote-steering.mjs";
|
|
26
|
+
import { accept, announceQueue, claudeReplay, codexLanded, dropWaiting, interruptedEnd, interruptOf, modelRefusal, steerLive, steerModeOf, switchModel } from "./remote-steering.mjs";
|
|
27
27
|
import { classifyAction } from "./remote-policy.mjs";
|
|
28
28
|
import { activeRows, listSessions, statusReport } from "./remote-session-list.mjs";
|
|
29
29
|
|
|
@@ -46,10 +46,12 @@ export function createSessions(ctx) {
|
|
|
46
46
|
};
|
|
47
47
|
const mark = (s) => s.agent_ref && appendSteered({ v: 1, steered: "remote", adapter: s.adapter, agent_session_ref: s.agent_ref, remote_session_id: s.session_id, project_id: s.project_id, how: s.how, first_steered_at: s.first, last_steered_at: ctx.now() });
|
|
48
48
|
const advance = (s, kind) => { if (s.command_id) ctx.journal.advance(s.command_id, { kind }, ctx.now()); };
|
|
49
|
+
const deskGranted = (adapter, projectPath) => adapter === "codex" && codexDeskGrants({ env: ctx.agentEnv(), projectPath }).length > 0; // read at each start
|
|
49
50
|
|
|
50
51
|
function nextTurn(s) {
|
|
51
52
|
// A Claude Code steer not yet read may become a turn of its own: the next prompt waits until it was (P3-7).
|
|
52
|
-
if (s.turnOpen || s.queue.length === 0 || !s.run?.alive() || (s.adapter !== "codex" && s.steers.length > 0)) return;
|
|
53
|
+
if (s.switching || s.turnOpen || s.queue.length === 0 || !s.run?.alive() || (s.adapter !== "codex" && s.steers.length > 0)) return;
|
|
54
|
+
if (s.queue[0].model !== undefined && s.queue[0].model !== s.model && switchModel(ctx, s, s.queue[0].model, { respawn: () => spawnAgent(s, s.agent_ref), resumeTurns: () => nextTurn(s) }) === "later") return;
|
|
53
55
|
const item = s.queue.shift();
|
|
54
56
|
s.waiting = item;
|
|
55
57
|
s.turnOpen = true;
|
|
@@ -173,7 +175,7 @@ export function createSessions(ctx) {
|
|
|
173
175
|
if (!s.stopping) taskEnded(s, "failed"); // an agent that exits before its task's turn ended did not do the task
|
|
174
176
|
s.turnOpen = false;
|
|
175
177
|
s.run = null;
|
|
176
|
-
dropWaiting(ctx, s); // a revived session never runs words sent to the agent that died
|
|
178
|
+
if (!s.switching) dropWaiting(ctx, s); // a revived session never runs words sent to the agent that died (a model switch's restart keeps them)
|
|
177
179
|
ctx.onActivity?.();
|
|
178
180
|
}
|
|
179
181
|
|
|
@@ -189,8 +191,7 @@ export function createSessions(ctx) {
|
|
|
189
191
|
onThread: (id) => { s.agent_ref = id; mark(s); ctx.journal.recordSession({ session_id: s.session_id, agent_session_ref: id }); },
|
|
190
192
|
approve: async (tool, input) => (await ctx.approvals.request(s, tool, input))?.behavior === "allow" });
|
|
191
193
|
ctx.journal.recordSession({ session_id: s.session_id, pid: s.run.pid ?? null });
|
|
192
|
-
s.ledgerTimer = setInterval(() => { if (s.turnOpen) mark(s); }, LEDGER_EVERY_MS);
|
|
193
|
-
s.ledgerTimer.unref?.();
|
|
194
|
+
s.ledgerTimer = setInterval(() => { if (s.turnOpen) mark(s); }, LEDGER_EVERY_MS); s.ledgerTimer.unref?.();
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
function spawnAgent(s, resume) {
|
|
@@ -203,8 +204,7 @@ export function createSessions(ctx) {
|
|
|
203
204
|
mark(s); // the ledger names the session before the agent writes a line
|
|
204
205
|
s.run = startClaude({ file: ctx.inventory().files["claude-code"], cwd: s.projectPath, env: ctx.agentEnv(), args, onLine: (line) => onLine(s, line), onExit: (how) => onExit(s, how) });
|
|
205
206
|
ctx.journal.recordSession({ session_id: s.session_id, pid: s.run.pid ?? null, agent_session_ref: s.agent_ref }); // a later daemon ends it if this one dies (P2-b)
|
|
206
|
-
s.ledgerTimer = setInterval(() => { if (s.turnOpen) mark(s); }, LEDGER_EVERY_MS);
|
|
207
|
-
s.ledgerTimer.unref?.();
|
|
207
|
+
s.ledgerTimer = setInterval(() => { if (s.turnOpen) mark(s); }, LEDGER_EVERY_MS); s.ledgerTimer.unref?.();
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
function start(env, payload) {
|
|
@@ -215,8 +215,8 @@ export function createSessions(ctx) {
|
|
|
215
215
|
if (!project) return "not_found";
|
|
216
216
|
const refused = P.checkStart(payload, adapterOf(ctx.inventory(), payload.adapter)); if (refused) return refused;
|
|
217
217
|
const choice = startChoice(payload, project.project_id, ctx.inventory(), ctx.settings(), known); if (typeof choice === "string") return choice;
|
|
218
|
-
if (!AGENT_ID[payload.adapter]) return "unsupported";
|
|
219
|
-
if (payload.
|
|
218
|
+
if (!AGENT_ID[payload.adapter] || (payload.resume !== null && !AGENT_ID[payload.adapter](payload.resume))) return "unsupported";
|
|
219
|
+
if (deskGranted(payload.adapter, project.path)) return "not_allowed"; // S0: Codex's own allow rules cannot be denied per session
|
|
220
220
|
const s = { session_id: env.session_id, project_id: project.project_id, projectPath: project.path, adapter: payload.adapter, model: payload.model, mode: payload.permission_mode,
|
|
221
221
|
agent_ref: payload.resume ?? (payload.adapter === "codex" ? null : payload.adapter === "opencode" ? mintOpenCodeSessionId(ctx.now(), ctx.random) : randomUUID()), how: "started", first: ctx.now(), queue: [], state: FRESH_STATE[payload.adapter](),
|
|
222
222
|
coalesce: createCoalescer({ now: ctx.now }), attention: null, command_id: null, waiting: null, turnOpen: false, run: null, steers: [], interrupting: false, ownTurn: null, task: env.task === true, tokens: P.NO_TOKENS, subagents: new Map(), turnStartedAt: null, name: payload.name ?? null, active: 0, countedTurn: null,
|
|
@@ -234,11 +234,11 @@ export function createSessions(ctx) {
|
|
|
234
234
|
/** A known session whose agent is gone (a daemon restart) resumes by the agent's own id. */
|
|
235
235
|
function revive(sessionId) {
|
|
236
236
|
let s = live.get(sessionId);
|
|
237
|
-
if (s?.run) return s;
|
|
237
|
+
if (s?.run || s?.switching) return s; // a model switch restarts it on its own
|
|
238
238
|
const saved = s ?? ctx.journal.session(sessionId);
|
|
239
239
|
if (!saved || saved.closed) return null;
|
|
240
240
|
const known = ctx.projects(), project = known.find((p) => p.project_id === saved.project_id), ref = s?.agent_ref ?? saved.agent_session_ref;
|
|
241
|
-
if (!project || !AGENT_ID[saved.adapter]?.(ref)) return null;
|
|
241
|
+
if (!project || !AGENT_ID[saved.adapter]?.(ref) || deskGranted(saved.adapter, project.path)) return null;
|
|
242
242
|
const agentMode = s?.agentMode ?? saved.agent_mode ?? null; // within today's ceiling, or it stays down (0.11.7)
|
|
243
243
|
if (agentMode && !allowedModes(ctx.settings()).includes(agentMode)) return null;
|
|
244
244
|
const extras = (s?.extraIds ?? saved.extra_project_ids ?? []).map((id) => known.find((p) => p.project_id === id)).filter(Boolean);
|
|
@@ -246,8 +246,7 @@ export function createSessions(ctx) {
|
|
|
246
246
|
s = s ?? { session_id: sessionId, project_id: saved.project_id, projectPath: project.path, adapter: saved.adapter, model: saved.model ?? null, mode: saved.mode ?? "ask", agent_ref: ref, how: "started", first: ctx.now(), queue: [], state: FRESH_STATE[saved.adapter](),
|
|
247
247
|
coalesce: createCoalescer({ now: ctx.now }), attention: null, command_id: null, waiting: null, turnOpen: false, run: null, steers: [], interrupting: false, ownTurn: null, task: false, tokens: P.NO_TOKENS, subagents: new Map(), turnStartedAt: null, name: saved.name ?? null, active: saved.active_ms ?? null, countedTurn: null,
|
|
248
248
|
agentMode, effort: saved.effort ?? null, extraIds: extras.map((p) => p.project_id), extraPaths: extras.map((p) => p.path) };
|
|
249
|
-
live.set(sessionId, s);
|
|
250
|
-
spawnAgent(s, s.agent_ref);
|
|
249
|
+
live.set(sessionId, s); spawnAgent(s, s.agent_ref);
|
|
251
250
|
return s;
|
|
252
251
|
}
|
|
253
252
|
|
|
@@ -275,7 +274,8 @@ export function createSessions(ctx) {
|
|
|
275
274
|
const report = adapterOf(ctx.inventory(), s.adapter);
|
|
276
275
|
const named = ctx.attachments ? ctx.attachments.referenceText(s.session_id, payload.attachments) : payload.attachments?.length ? null : ""; // null: refused, never ""
|
|
277
276
|
if (named === null) return "not_found"; // a file it names is not here whole: never a prompt without its file
|
|
278
|
-
const
|
|
277
|
+
const refusedModel = payload.model === undefined ? null : modelRefusal(ctx, s, payload.model); if (refusedModel) return refusedModel;
|
|
278
|
+
const item = { text: payload.text + named, command_id, received_at: ctx.now(), ...(payload.model !== undefined ? { model: payload.model } : {}) };
|
|
279
279
|
if (type === "agent.steer" && steerModeOf(report) === "none") return "unsupported";
|
|
280
280
|
mark(s);
|
|
281
281
|
if (type === "agent.steer" && s.turnOpen && steerModeOf(report) === "live" && (await steerLive(ctx, s, item))) return null;
|
package/remote-steering.mjs
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* Pure helpers over a session record `s`; the sessions module owns the agent processes.
|
|
16
16
|
*/
|
|
17
17
|
import * as P from "./remote-protocol.mjs";
|
|
18
|
+
import { agentOptionsOf } from "./remote-inventory.mjs";
|
|
18
19
|
|
|
19
20
|
/** Tell the phone where each waiting command stands, once per change of place. */
|
|
20
21
|
export function announceQueue(ctx, s, reason = "turn_running") {
|
|
@@ -95,3 +96,62 @@ export function interruptedEnd(ctx, s, event) {
|
|
|
95
96
|
/** What the adapter reports for words sent mid-turn (the phone offers only this). */
|
|
96
97
|
export const steerModeOf = (report) => (report ? P.steerOffered(report.capabilities) : "none");
|
|
97
98
|
export const interruptOf = (report) => Boolean(report && P.interruptOffered(report.capabilities));
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* ANOTHER MODEL OF THE SAME AGENT INSIDE A SESSION (release 33; owner, 2026-11-13: option A; docs/remote-agents/PROTOCOL.md
|
|
102
|
+
* "A model is chosen per session"). An agent.prompt may carry `model`: one of the session's OWN adapter's listed models,
|
|
103
|
+
* for that turn and the turns after it. Another agent is never a model (the payload names no adapter): it is a new chat,
|
|
104
|
+
* with no hand-over. Verified per adapter from the adapters themselves (2026-11-14):
|
|
105
|
+
*
|
|
106
|
+
* Claude Code its own resume with another model flag: the idle process ends and starts again with
|
|
107
|
+
* `--resume <its own session id> --model <model>` (claudeArgs takes both; `--model` is "Model for the current
|
|
108
|
+
* session" in 2.1.322's help). NOT run against a live model here: the restart is proven on a fake Claude Code.
|
|
109
|
+
* Codex `turn/start` carries `model`: "Override the model for this turn and subsequent turns" (the app-server's own
|
|
110
|
+
* JSON schema, `codex app-server generate-json-schema`, 0.154.0); the thread and its process stay.
|
|
111
|
+
* OpenCode one process per run, `--session <id> --model <p/m>`: the next run takes the new model. NOT VERIFIED on a
|
|
112
|
+
* real install (OpenCode is not on the build machine), as the adapter itself says.
|
|
113
|
+
* terminal no switch: nothing is typed into a terminal session that the phone composed (a `/model` would be one).
|
|
114
|
+
*
|
|
115
|
+
* modelRefusal(ctx, s, model) on receipt: null, or why the prompt is refused (it then runs nothing)
|
|
116
|
+
* switchModel(ctx, s, model, o) at the turn's start: "now" (switched in place) or "later" (Claude Code restarts;
|
|
117
|
+
* o.respawn() then o.resumeTurns() run when its process is gone)
|
|
118
|
+
*
|
|
119
|
+
* The check is the protocol's own (checkModelSwitch) against the computer's CURRENT report and its own options, never the
|
|
120
|
+
* phone's: a model the agent did not list, or a switch for an adapter whose options do not say `model_switch`, is refused.
|
|
121
|
+
*/
|
|
122
|
+
/** → null when the session may continue on `model`, else the reject reason (unsupported, unknown_model). */
|
|
123
|
+
export function modelRefusal(ctx, s, model) {
|
|
124
|
+
const inv = ctx.inventory();
|
|
125
|
+
const report = P.reportFor(inv.reports, s.adapter, "structured");
|
|
126
|
+
const options = agentOptionsOf(inv).find((o) => o.adapter === s.adapter && o.mode === "structured") ?? null;
|
|
127
|
+
return P.checkModelSwitch(model, report, options);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Switch the session to `model` before its next turn. Codex and OpenCode take it in place (`run.setModel`). Claude Code's
|
|
132
|
+
* process is idle here (a turn starts only when none is open), so it ends and comes back on its own session id with the new
|
|
133
|
+
* model; the queue is held aside meanwhile and nothing waiting is dropped (`s.switching`, remote-sessions.mjs onExit).
|
|
134
|
+
*/
|
|
135
|
+
export function switchModel(ctx, s, model, o) {
|
|
136
|
+
const record = () => { s.model = model; ctx.journal.recordSession({ session_id: s.session_id, model }); ctx.onSessionsChanged?.(); };
|
|
137
|
+
if (typeof s.run?.setModel === "function") { s.run.setModel(model); record(); return "now"; }
|
|
138
|
+
if (s.adapter !== "claude-code") throw new Error("this adapter has no model switch"); // modelRefusal kept it out
|
|
139
|
+
s.switching = true;
|
|
140
|
+
s.stopping = true;
|
|
141
|
+
const held = s.queue.splice(0);
|
|
142
|
+
(async () => {
|
|
143
|
+
try {
|
|
144
|
+
await s.run?.stop();
|
|
145
|
+
s.stopping = false;
|
|
146
|
+
record();
|
|
147
|
+
o.respawn(); // spawnAgent(s, s.agent_ref): the ledger names the session first, then --resume <id> --model <model>
|
|
148
|
+
} catch {
|
|
149
|
+
s.stopping = false;
|
|
150
|
+
}
|
|
151
|
+
s.queue.unshift(...held, ...s.queue.splice(0)); // what arrived during the restart waits behind what was held
|
|
152
|
+
s.switching = false;
|
|
153
|
+
if (!s.run) dropWaiting(ctx, s); // the agent did not come back: what waited is cancelled, never left hanging
|
|
154
|
+
o.resumeTurns();
|
|
155
|
+
})();
|
|
156
|
+
return "later";
|
|
157
|
+
}
|
package/session-readers.mjs
CHANGED
|
@@ -24,6 +24,16 @@ import { join } from "node:path";
|
|
|
24
24
|
* line at a time; re-iterable (each pass opens the file again); null only when the file cannot be opened.
|
|
25
25
|
*/
|
|
26
26
|
const CHUNK_BYTES = 8 << 20;
|
|
27
|
+
/**
|
|
28
|
+
* The read buffer for one file, sized to what is left of it (CLI 0.11.11; docs/OPEN.md "Rust was measured and not taken"):
|
|
29
|
+
* 8 MB allocated for every file cost about 3.4 s over 10,000 small rollouts. At least 64 KiB, so a file that grows while
|
|
30
|
+
* it is read (a live transcript) still reads in sensible steps; at most CHUNK_BYTES; CHUNK_BYTES when fstat fails.
|
|
31
|
+
*/
|
|
32
|
+
function readBufferFor(fd, from = 0) {
|
|
33
|
+
let left = CHUNK_BYTES;
|
|
34
|
+
try { left = fstatSync(fd).size - from + 1; } catch { left = CHUNK_BYTES; }
|
|
35
|
+
return Buffer.allocUnsafe(Math.min(CHUNK_BYTES, Math.max(64 << 10, left)));
|
|
36
|
+
}
|
|
27
37
|
/**
|
|
28
38
|
* A READ THAT FAILS IS COUNTED, NEVER SILENT (0.10.32): a transcript that exists and cannot be opened or read to its end
|
|
29
39
|
* is one failure. The run keeps the count in sessions.json (`npx worktrust status` says it) and tells WorkTrust the
|
|
@@ -70,11 +80,11 @@ function* chunkedLines(file, from = 0, at = null, expect = null) {
|
|
|
70
80
|
if (!same) { if (at) at.moved = true; return; }
|
|
71
81
|
}
|
|
72
82
|
}
|
|
73
|
-
const buffer =
|
|
83
|
+
const buffer = readBufferFor(fd, from);
|
|
74
84
|
let pending = [], position = from, lineStart = from;
|
|
75
85
|
for (;;) {
|
|
76
86
|
let n;
|
|
77
|
-
try { n = readSync(fd, buffer, 0,
|
|
87
|
+
try { n = readSync(fd, buffer, 0, buffer.length, position); } catch { READ_FAILURES.n += 1; if (at) at.failed = true; return; }
|
|
78
88
|
if (n <= 0) break;
|
|
79
89
|
READ_BYTES.n += n;
|
|
80
90
|
const chunk = buffer.subarray(0, n);
|
package/transcript-readers.mjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* counter's named rules and the hook's measure(), whose payloads are fixed allowlists of numbers,
|
|
14
14
|
* dates and enum values (log-session.mjs, "WHAT CANNOT LEAVE").
|
|
15
15
|
*/
|
|
16
|
-
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
17
17
|
import { createHash } from "node:crypto";
|
|
18
18
|
import { spawnSync } from "node:child_process";
|
|
19
19
|
import { homedir } from "node:os";
|
|
@@ -252,16 +252,16 @@ export function* codexLines(records) {
|
|
|
252
252
|
*/
|
|
253
253
|
const EFFORT_LEVELS = new Set(["low", "medium", "high", "xhigh", "max"]);
|
|
254
254
|
/**
|
|
255
|
-
* A FILE'S LINES, 8 MB AT A TIME (0.10.32
|
|
256
|
-
*
|
|
257
|
-
* Null when the file cannot be opened; a read that fails halfway ends
|
|
255
|
+
* A FILE'S LINES, 8 MB AT A TIME (0.10.32; a buffer sized to the file, 64 KiB to 8 MB, since 0.11.11): a whole-file read
|
|
256
|
+
* throws past Node's longest string (about 512 MB), which is how the owner's Claude Code session went unmeasured from
|
|
257
|
+
* 2026-10-18; a rollout is read the same way. Null when the file cannot be opened; a read that fails halfway ends there.
|
|
258
258
|
*/
|
|
259
259
|
export function streamedLines(file) {
|
|
260
260
|
try { closeSync(openSync(file, "r")); } catch { return null; }
|
|
261
261
|
return { *[Symbol.iterator]() {
|
|
262
262
|
let fd; try { fd = openSync(file, "r"); } catch { return; }
|
|
263
263
|
try {
|
|
264
|
-
const decoder = new StringDecoder("utf8"), buffer = Buffer.allocUnsafe(8 << 20);
|
|
264
|
+
const decoder = new StringDecoder("utf8"), buffer = Buffer.allocUnsafe(Math.min(8 << 20, Math.max(64 << 10, (() => { try { return fstatSync(fd).size + 1; } catch { return 8 << 20; } })())));
|
|
265
265
|
let rest = "";
|
|
266
266
|
for (;;) {
|
|
267
267
|
let n; try { n = readSync(fd, buffer, 0, buffer.length, null); } catch { return; }
|
package/worktrust.mjs
CHANGED
|
@@ -83,7 +83,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
|
|
|
83
83
|
const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
|
|
84
84
|
const has = (name) => args.includes(`--${name}`);
|
|
85
85
|
/** This CLI's version, said to the door so the app can tell which computer runs an old one (check-cli-package holds it equal to package.json). */
|
|
86
|
-
const CLI_VERSION = "0.11.
|
|
86
|
+
const CLI_VERSION = "0.11.11";
|
|
87
87
|
/**
|
|
88
88
|
* HOW THIS CLI MEASURES, AS A NUMBER OF ITS OWN (0.10.31; owner, 2026-10-28: 0.10.30 offered a re-measure it had no reason
|
|
89
89
|
* to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
|