@ziptie-soft/orca-local-decider 0.0.0 → 1.0.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/CHANGELOG.md +26 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +346 -1
- package/images/cover.png +0 -0
- package/images/icon.png +0 -0
- package/orca-plugin.json +218 -0
- package/package.json +45 -5
- package/src/agent-terminals.ts +88 -0
- package/src/bounded.ts +22 -0
- package/src/breaker.ts +28 -0
- package/src/core/canonical.ts +24 -0
- package/src/core/guard.ts +503 -0
- package/src/core/ids.ts +2 -0
- package/src/core/input-cap.ts +71 -0
- package/src/core/permission-input.ts +42 -0
- package/src/core/shell.ts +586 -0
- package/src/core/subject.ts +244 -0
- package/src/core/truncate.ts +203 -0
- package/src/gate.ts +155 -0
- package/src/gateway.ts +289 -0
- package/src/guard-result.ts +28 -0
- package/src/hook-watch.ts +76 -0
- package/src/launch-command.ts +274 -0
- package/src/launcher/launch.ts +892 -0
- package/src/launcher/local-token.ts +26 -0
- package/src/launcher/socket-path.ts +24 -0
- package/src/launcher/transport.ts +141 -0
- package/src/orca-types.ts +107 -0
- package/src/panel/model.ts +205 -0
- package/src/panel/orca-panel.d.ts +90 -0
- package/src/panel/panel.tsx +278 -0
- package/src/panel-api.ts +83 -0
- package/src/panel-protocol.ts +86 -0
- package/src/routing.ts +204 -0
- package/src/send-guard.ts +43 -0
- package/src/settings.ts +82 -0
- package/src/status.ts +146 -0
- package/src/turn-key.ts +13 -0
- package/src/turn-outcome.ts +199 -0
- package/src/worker.ts +521 -0
- package/src/workspaces.ts +87 -0
- package/src/wrapper-env.ts +19 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (2026-12-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **gateway:** decide a tool call once when several clients ask about it ([416394c](https://github.com/ziptie-soft/local-decider/commit/416394cbfc2317aebfb09f414dbfabad37987244))
|
|
9
|
+
* **gateway:** let one Orca routing preset name a model per agent ([7eaa357](https://github.com/ziptie-soft/local-decider/commit/7eaa357ba568e3b63cfbfa903d9dec1deb9083fd))
|
|
10
|
+
* **orca-plugin:** add a settings panel and command-risk mode controls ([8f1d3fc](https://github.com/ziptie-soft/local-decider/commit/8f1d3fc62d1b3b18ece02e03e8d08162cb673785))
|
|
11
|
+
* **orca-plugin:** add a status bar setting, fix panel states and add an Orca install guide ([819377a](https://github.com/ziptie-soft/local-decider/commit/819377aa29b2dfdef147785f0616bee3027169f3))
|
|
12
|
+
* **orca-plugin:** add an Orca plugin that refuses risky Claude Code tool calls ([ebf0c1f](https://github.com/ziptie-soft/local-decider/commit/ebf0c1f755c0beb479f2e2e1b5bee67db3f7bc4f))
|
|
13
|
+
* **orca-plugin:** keep agent hooks working under PTY wrappers ([3e950f3](https://github.com/ziptie-soft/local-decider/commit/3e950f3dcdae80211b47fb31ef054740d94a5c35))
|
|
14
|
+
* **orca-plugin:** notify when an Orca agent's turn needs attention ([60a27fd](https://github.com/ziptie-soft/local-decider/commit/60a27fdcd06ba9098a3172543c0073ed3d84365f))
|
|
15
|
+
* **orca-plugin:** offer the local-decider MCP server to Orca agents ([248187f](https://github.com/ziptie-soft/local-decider/commit/248187fe9c0f3a2e91df6b8e384186015c7b79cd))
|
|
16
|
+
* **orca-plugin:** publish the Orca plugin to npm ([d0a5b78](https://github.com/ziptie-soft/local-decider/commit/d0a5b7868ce25abc3250dbd92a3d9f03f9b006a7))
|
|
17
|
+
* **orca-plugin:** refuse risky shell commands sent to Orca terminals ([1298fc6](https://github.com/ziptie-soft/local-decider/commit/1298fc607213d53f950c22cd3e3f0f81dcd53aa6))
|
|
18
|
+
* **orca-plugin:** route agent launches to a model tier ([7a6971d](https://github.com/ziptie-soft/local-decider/commit/7a6971d13aaacdd85331f327bcdabea7f11c39f8))
|
|
19
|
+
* **orca-plugin:** share an agent's end-of-turn decision with its harness hooks ([2aac168](https://github.com/ziptie-soft/local-decider/commit/2aac168546e5446afebd78e2ffc4ad921b7b9c6a))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **orca-plugin:** back off routing after a failed decision and bound per-terminal state ([74dc529](https://github.com/ziptie-soft/local-decider/commit/74dc5299aed93e2b05b5fd956e4558dd66604bd6))
|
|
25
|
+
* **orca-plugin:** guard a terminal again once its agent has exited ([96679cc](https://github.com/ziptie-soft/local-decider/commit/96679cc634e29c45f309db74d69ba9029f4f9be7))
|
|
26
|
+
* **orca-plugin:** honour Mode off in routing and tighten the send guard ([c333b1a](https://github.com/ziptie-soft/local-decider/commit/c333b1a0817f6c66c4d3e25549407373b6853599))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1 +1,346 @@
|
|
|
1
|
-
#
|
|
1
|
+
# local-decider for Orca
|
|
2
|
+
|
|
3
|
+
An [Orca](https://onorca.dev) plugin that checks every Claude Code tool call made in an Orca
|
|
4
|
+
terminal and refuses the risky ones. Checks happen before the call runs, using a deterministic guard
|
|
5
|
+
and the local-decider `command-risk` policy, which a small decision model answers on your own
|
|
6
|
+
machine. It also refuses risky shell commands that Orca or another plugin types into a terminal,
|
|
7
|
+
routes each agent Orca launches to a model tier (`routing`), notifies you when an agent's turn
|
|
8
|
+
needs your attention (`turn-outcome`), and offers the local-decider MCP server to Orca's agents.
|
|
9
|
+
|
|
10
|
+
> **Unofficial.** This plugin is not affiliated with, endorsed by, or sponsored by Stably (Orca),
|
|
11
|
+
> Anthropic or the other projects named in [NOTICE](NOTICE).
|
|
12
|
+
|
|
13
|
+
## What it does
|
|
14
|
+
|
|
15
|
+
The plugin hooks Orca's `agent.tool.before` event. For a Claude Code call to `Bash`, `Edit`,
|
|
16
|
+
`Write`, `MultiEdit`, `NotebookEdit` or any `mcp__*` tool, it acts in this order:
|
|
17
|
+
|
|
18
|
+
1. **Guard.** It checks a shell command against local-decider's deterministic rules: force-push to
|
|
19
|
+
`main`, piping a download into a shell, `rm -rf` on system folders, and the like. A hit refuses
|
|
20
|
+
the call, and Claude Code sees the reason.
|
|
21
|
+
2. **Model.** Otherwise it asks the gateway for a `command-risk` decision. An enforced `deny`
|
|
22
|
+
refuses the call.
|
|
23
|
+
3. **Pass.** Everything else goes on to Claude Code's own permission prompt, unchanged.
|
|
24
|
+
|
|
25
|
+
The plugin can only refuse a call, never approve one: Orca still asks the person as usual. Every
|
|
26
|
+
failure passes the call: a gateway that is down, slow, too old or misconfigured; a thrown error;
|
|
27
|
+
or a call that would go past Orca's 2 s hook limit. After a failed call the plugin leaves the
|
|
28
|
+
gateway alone for 30 s, so agents never wait on it.
|
|
29
|
+
|
|
30
|
+
Only Claude Code waits for Orca's hook. Orca reports calls from other agents only after they run,
|
|
31
|
+
so the plugin skips them. Agents on SSH or WSL hosts are not hooked by Orca yet.
|
|
32
|
+
|
|
33
|
+
`command-risk` ships in `shadow` mode, so until you switch it to `act` the model's verdicts are
|
|
34
|
+
only logged, and only the guard refuses calls. Use the **Enforce command-risk (act)** and
|
|
35
|
+
**Record command-risk only (shadow)** commands to switch it (see below).
|
|
36
|
+
|
|
37
|
+
**Keep When unsure on `pass` with `act`.** The reference model can rate harmless commands such as
|
|
38
|
+
`ls -la` as `ask`. With `act` plus **When unsure** = `deny`, those commands would be refused. With
|
|
39
|
+
`pass`, they fall to Claude Code's own prompt.
|
|
40
|
+
|
|
41
|
+
## Terminal sends
|
|
42
|
+
|
|
43
|
+
The plugin also hooks Orca's `terminal.send` event, which fires when Orca, its CLI
|
|
44
|
+
(`orca terminal send`) or a plugin is about to type text into a terminal. A person typing is never
|
|
45
|
+
hooked. When the text is submitted (`enter`) or holds a line break, as driving input, the plugin
|
|
46
|
+
checks it against the same deterministic guard and refuses a hit, so a script or another agent
|
|
47
|
+
cannot push a risky shell command into a terminal. The guard only checks: the model is not asked.
|
|
48
|
+
Text that goes to a terminal an agent runs in, and orchestration or launch text, is a prompt for an
|
|
49
|
+
agent and is skipped; the other hooks cover it. The plugin learns which terminals run an agent from
|
|
50
|
+
`agent.status.changed` and, before skipping one, confirms with `agents.list` that its agent is
|
|
51
|
+
still there: once the agent has exited, the terminal is a shell again and its text is checked.
|
|
52
|
+
That lookup waits 300 ms at most and keeps the skip on any failure. **Mode** `off` turns this off
|
|
53
|
+
too, and any failure passes the send.
|
|
54
|
+
|
|
55
|
+
## Routing
|
|
56
|
+
|
|
57
|
+
The plugin also hooks Orca's `agent.launch.before` event. When Orca is about to start Claude Code
|
|
58
|
+
or Codex with a prompt, the plugin asks the gateway's `routing` policy which preset fits the
|
|
59
|
+
prompt, and sets the agent's model and reasoning effort to that preset's target. Map the presets
|
|
60
|
+
for the `orca` harness in `~/.config/local-decider/config.yaml`:
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
routing:
|
|
64
|
+
presets:
|
|
65
|
+
orca:
|
|
66
|
+
fast: { model: claude/haiku, models: [codex/gpt-6.1-mini], thinking: low }
|
|
67
|
+
standard: { model: claude/sonnet, models: [codex/gpt-6.1] }
|
|
68
|
+
deep: { model: claude/opus, thinking: high }
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
or with the CLI (repeat `--also` for more models):
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
local-decider routing map orca fast claude/haiku --also codex/gpt-6.1-mini --thinking low
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A model is written `<agent>/<model>`. `models` lists up to 8 further `<agent>/<model>` entries, so
|
|
78
|
+
one preset can route both agents: a launch takes the first of `model`, then `models`, whose agent
|
|
79
|
+
is the one being started (`claude/…` for Claude Code, `codex/…` for Codex). A preset with no entry
|
|
80
|
+
for the launching agent is skipped, because routing never switches the CLI (`deep` above routes
|
|
81
|
+
Claude Code only). `thinking` is shared by both agents and becomes `--effort` for Claude Code and
|
|
82
|
+
`model_reasoning_effort` for Codex. A preset's `mode` and `profile` are ignored, so a route never
|
|
83
|
+
changes the agent's permissions.
|
|
84
|
+
|
|
85
|
+
A route is applied only when:
|
|
86
|
+
|
|
87
|
+
- the gateway's `routing` policy is in `act` (`local-decider policies mode routing act`);
|
|
88
|
+
- the gateway answers within 1.8 s, inside Orca's 2 s hook limit;
|
|
89
|
+
- the launch command is the plain quoted form Orca writes. Anything else launches unchanged.
|
|
90
|
+
|
|
91
|
+
In `shadow` the decision is only logged, and the launch does not wait for it. Each outcome
|
|
92
|
+
(`route:fast → claude/haiku, effort low`, `skipped: …`, `(shadow, not applied)`) shows as
|
|
93
|
+
**Last route** in the panel and in `orca plugin logs`. The **Routing** setting turns it off.
|
|
94
|
+
Launches without a prompt, and agents other than Claude Code and Codex, are never routed.
|
|
95
|
+
|
|
96
|
+
Whether or not a launch is routed, the plugin adds `LIG_DISABLE=1` to the environment of every
|
|
97
|
+
agent Orca launches (unless Mode is `off` or the launch already sets it), so the `lig` PTY wrapper
|
|
98
|
+
stays out of the way; see [Troubleshooting](#troubleshooting).
|
|
99
|
+
|
|
100
|
+
## End of turn
|
|
101
|
+
|
|
102
|
+
The plugin also listens to Orca's `agent.status.changed` event. When an agent's status goes from
|
|
103
|
+
`working` to `done` or `waiting` in a terminal, the plugin reads the last 200 lines of that
|
|
104
|
+
terminal (`terminal.read`) and asks the gateway's `turn-outcome` policy whether the turn is
|
|
105
|
+
`done`, `needs_input`, `stuck` or `failed`. When the decision is enforced and its action is
|
|
106
|
+
`notify`, Orca shows a notification, such as `local-decider: <agent title> needs input`. The
|
|
107
|
+
notification holds only the answer and a fixed line (or the decision's reason, if the gateway sends
|
|
108
|
+
one), never terminal text.
|
|
109
|
+
|
|
110
|
+
`turn-outcome` ships in `shadow`: decisions are only recorded, and no notification appears. To get
|
|
111
|
+
notifications, switch it to `act` with `local-decider policies mode turn-outcome act`. That mode is
|
|
112
|
+
gateway-wide, so it applies to every client of the gateway (Paseo, Claude Code, Codex).
|
|
113
|
+
|
|
114
|
+
A turn the person stopped (the agent's outcome is `cancellation`, `superseded` or `interruption`)
|
|
115
|
+
is skipped, a repeated `done` does nothing, and a terminal gets at most one decision every 30 s. The
|
|
116
|
+
terminal text is sent only to the gateway, which redacts secrets before it reaches the engine. The
|
|
117
|
+
**End of turn** setting turns this off; so does **Mode** `off`. Any failure, such as a terminal
|
|
118
|
+
that cannot be read, drops the turn without a notification.
|
|
119
|
+
|
|
120
|
+
For a step-by-step setup, including the gateway and an engine, see
|
|
121
|
+
[docs/install-orca.ai.md](../../docs/install-orca.ai.md).
|
|
122
|
+
|
|
123
|
+
## Requirements
|
|
124
|
+
|
|
125
|
+
- Orca 1.4.276 or newer.
|
|
126
|
+
- The local-decider gateway on the same machine, with an engine. The `orca` harness needs a
|
|
127
|
+
gateway released after 3.4.0. See the [install guide](../../docs/install.md). With an
|
|
128
|
+
older gateway, only the guard works and the status bar shows `ld: rejected`.
|
|
129
|
+
|
|
130
|
+
## Install
|
|
131
|
+
|
|
132
|
+
Before the first release, or to try unreleased changes, install from `master`:
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
orca plugin install https://github.com/ziptie-soft/local-decider/tree/master/packages/orca-plugin
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
After a release, install the newest release:
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
orca plugin install ziptie-soft/local-decider
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Or add this repository's catalog, which Orca then installs and updates from:
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
orca plugin catalog add ziptie-soft/local-decider
|
|
148
|
+
orca plugin install ziptie-soft.local-decider
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Once the plugin is listed in Orca's community catalog, `orca plugin install
|
|
152
|
+
ziptie-soft.local-decider` works without `catalog add`.
|
|
153
|
+
|
|
154
|
+
Each release is also published to npm as `@ziptie-soft/orca-local-decider`. To install from npm,
|
|
155
|
+
unpack it and install the folder:
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
npm pack @ziptie-soft/orca-local-decider
|
|
159
|
+
tar -xzf ziptie-soft-orca-local-decider-*.tgz
|
|
160
|
+
orca plugin install ./package
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The plugin runs code, so a CLI install stops with `approval_required` and prints the same
|
|
164
|
+
command with `--approve <fingerprint>`. Run that command once you have checked the access
|
|
165
|
+
below. `catalog add` asks for its own approval the same way. The Orca app asks in a dialog
|
|
166
|
+
instead.
|
|
167
|
+
|
|
168
|
+
Orca shows what the plugin needs before enabling it:
|
|
169
|
+
|
|
170
|
+
- It runs its own code in a worker (`trusted-worker`).
|
|
171
|
+
- `workspace:read` maps a workspace to its folder, to tell the policy which project a call belongs
|
|
172
|
+
to.
|
|
173
|
+
- `agent:read` follows which terminals agents run in (the `agent.status.changed` event).
|
|
174
|
+
- `terminal:read` reads the last lines of an agent's terminal when its turn ends, to tell whether it
|
|
175
|
+
needs you (see End of turn). The text goes only to the local gateway.
|
|
176
|
+
- `notifications:show` shows an Orca notification when a turn needs your attention.
|
|
177
|
+
- `settings:own` reads the settings below.
|
|
178
|
+
- A **local-decider** panel in the right sidebar (see Panel).
|
|
179
|
+
- An MCP server, `local-decider`, offered to the agents Orca launches (see MCP server).
|
|
180
|
+
|
|
181
|
+
An update that adds access or contributions, such as the panel and the two mode commands, asks for
|
|
182
|
+
approval again before Orca enables it. The CLI reports `approval_stale` and exits with code 3; the
|
|
183
|
+
app shows the dialog.
|
|
184
|
+
|
|
185
|
+
## MCP server
|
|
186
|
+
|
|
187
|
+
The plugin offers the gateway's MCP server to the agents Orca launches. Orca lists it as
|
|
188
|
+
`local-decider` under **From plugins** in Settings → MCP servers and starts it with
|
|
189
|
+
`local-decider mcp`, a stdio server that proxies to the running gateway. Agents get two tools:
|
|
190
|
+
|
|
191
|
+
- `decide` asks the local decision model a fixed-choice question through a policy. The answer is
|
|
192
|
+
advisory and never enforced.
|
|
193
|
+
- `policies` lists the policies an agent can call, with the input keys and questions of each.
|
|
194
|
+
|
|
195
|
+
The server needs `local-decider` on the agent's `PATH` and a running gateway. To turn it off, switch
|
|
196
|
+
the `local-decider` entry off in Orca's Settings → MCP servers. The plugin's own checks are
|
|
197
|
+
unaffected. [docs/mcp.md](../../docs/mcp.md) describes the tools, their inputs and results.
|
|
198
|
+
|
|
199
|
+
## Settings
|
|
200
|
+
|
|
201
|
+
The plugin's settings are on its page in Orca's plugin settings:
|
|
202
|
+
|
|
203
|
+
| Setting | Default | Meaning |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| Mode | `guard` | `guard` refuses what the built-in guard flags and asks the gateway's `command-risk` decision; whether that decision can refuse is the gateway's mode. `off` turns the plugin off. |
|
|
206
|
+
| When unsure | `pass` | What to do when a call can't be checked (a shell command too large or nested too deeply) or when the gateway's `command-risk`, in `act` mode, would ask. `pass` leaves it to Claude Code's prompt; `deny` refuses it. |
|
|
207
|
+
| Status bar item | `problems` | `problems` shows the item only when the gateway is offline, down, degraded or refusing the plugin; `always` shows an icon while all is well; `off` never shows it. The panel and the commands work in every mode. |
|
|
208
|
+
| Gateway URL | empty | Empty uses the local gateway: its socket under `~/.local/share/local-decider/run/`, else `http://127.0.0.1:8765`. |
|
|
209
|
+
| Decision timeout (ms) | `1500` | How long one decision may take, from 200 to 1700 ms. |
|
|
210
|
+
| Start the gateway | on | Start an installed gateway when the plugin loads and the gateway is not running. |
|
|
211
|
+
| Load the model when Orca starts | off | Load the gateway's model at start-up so the first decision is not cold. Needs a local gateway and its control token. |
|
|
212
|
+
| Routing | `on` | `on` asks the gateway's `routing` policy for the model of each agent Orca launches (see Routing); `off` never changes a launch. |
|
|
213
|
+
| End of turn | `on` | `on` asks the gateway's `turn-outcome` policy how each agent turn ended (see End of turn); `off` never reads a terminal. |
|
|
214
|
+
|
|
215
|
+
The bearer token, if your gateway needs one, comes from `LOCAL_DECIDER_TOKEN` in Orca's
|
|
216
|
+
environment. It is sent only to https or loopback URLs, never logged and never stored in settings.
|
|
217
|
+
The plugin installs a gateway only when `LOCAL_DECIDER_AUTOINSTALL=1` is set; read the risk in
|
|
218
|
+
[security.md](../../docs/security.md) first.
|
|
219
|
+
|
|
220
|
+
## Panel
|
|
221
|
+
|
|
222
|
+
The **local-decider** panel sits in the right sidebar (the lightning-bolt icon). It talks to the
|
|
223
|
+
gateway only through the plugin's worker, so it never sees a token. Its sections:
|
|
224
|
+
|
|
225
|
+
- **Header:** the gateway's health and a Refresh button.
|
|
226
|
+
- **Offline:** a Start button and the last launch message, when the gateway is not running.
|
|
227
|
+
- **Gateway:** URL and transport, version, engine and model, latency, the last decision, the last
|
|
228
|
+
route and the last start, with **Load model** and **Unload model** buttons.
|
|
229
|
+
- **Command risk:** the gateway's mode (off, shadow or act) with an Apply button.
|
|
230
|
+
- **Last 7 days:** decisions, enforced, actions, errors and latency, loaded on demand.
|
|
231
|
+
- **This plugin:** the plugin's own settings, read-only, and an **Agent hooks** row while a launched
|
|
232
|
+
Claude Code agent has sent no status (see Troubleshooting). Change the settings in Settings →
|
|
233
|
+
Plugins → local-decider.
|
|
234
|
+
- **More settings:** the CLI commands for engine choice, benchmarks, the binary variant and stats.
|
|
235
|
+
|
|
236
|
+
Changing the mode or loading the model needs a local gateway and its control token. Without them
|
|
237
|
+
the buttons are disabled and say why. **The mode switch is gateway-wide: it changes command-risk
|
|
238
|
+
for every client of this gateway, including Claude Code hooks, Codex, pi and Paseo.**
|
|
239
|
+
|
|
240
|
+
## Status and commands
|
|
241
|
+
|
|
242
|
+
The status bar item follows the **Status bar item** setting. By default (`problems`) it stays
|
|
243
|
+
hidden while all is well (the gateway answers, or has not been checked yet) and appears only on a
|
|
244
|
+
problem: `ld: offline`, `ld: down` or `ld: degraded` when the gateway doesn't answer well,
|
|
245
|
+
`ld: rejected` when it answers but refuses the plugin's calls (an old gateway, or a wrong token).
|
|
246
|
+
With `always` it shows an icon alone while all is well, green while the gateway only records
|
|
247
|
+
(`shadow`) and accent-coloured while it enforces (`act`); hover it to see that the guard is on and
|
|
248
|
+
the gateway's `command-risk` mode. With `off`, or while the plugin's Mode is `off`, it never
|
|
249
|
+
shows. Changes take effect at once.
|
|
250
|
+
Clicking it runs **local-decider: Show status**, which lists the mode, the gateway (with its
|
|
251
|
+
`command-risk` mode, engine and model) and the last decision; the command works from the command
|
|
252
|
+
palette even when the item is hidden.
|
|
253
|
+
**local-decider: Start the gateway** starts an installed gateway. Messages go to
|
|
254
|
+
`orca plugin logs`.
|
|
255
|
+
|
|
256
|
+
**local-decider: Enforce command-risk (act)** and **local-decider: Record command-risk only
|
|
257
|
+
(shadow)** switch the gateway's `command-risk` mode. The switch is gateway-wide: it applies to
|
|
258
|
+
every client of that gateway, not just Orca, and the gateway keeps it across restarts. It needs a
|
|
259
|
+
local gateway and the control token the gateway keeps in its config directory
|
|
260
|
+
(`~/.config/local-decider/control-token`); the plugin sends the token only over the Unix socket or
|
|
261
|
+
to a loopback host, and never logs it. Against a remote gateway, switch the mode there.
|
|
262
|
+
|
|
263
|
+
The plugin switches the base `command-risk` mode. That mode also governs an active
|
|
264
|
+
`command-risk-binary` variant, which only supplies the questions, rules and thresholds.
|
|
265
|
+
|
|
266
|
+
## With the Claude Code plugin
|
|
267
|
+
|
|
268
|
+
Install both this plugin and the local-decider Claude Code and Codex plugin
|
|
269
|
+
(`plugins/local-decider`). They cover different things:
|
|
270
|
+
|
|
271
|
+
- This plugin adds launch routing, the `terminal.send` guard, end-of-turn checks, the panel and
|
|
272
|
+
the MCP server.
|
|
273
|
+
- The Claude Code and Codex plugin checks tool calls inside the agent (its `PreToolUse` hook), so
|
|
274
|
+
it also covers agents typed into an Orca terminal and agents behind a PTY wrapper.
|
|
275
|
+
|
|
276
|
+
Both ask the gateway about the same tool call and send the same call id, so the gateway decides
|
|
277
|
+
it once: the second request reuses the first one's engine answer and there is no second model run.
|
|
278
|
+
Each request still applies its own mode and rules. The decision log marks the reused request
|
|
279
|
+
`sharedCall`, and stats count the tool call once.
|
|
280
|
+
|
|
281
|
+
The end-of-turn check is decided once too when both ask: they send a turn key made from the Orca
|
|
282
|
+
pane (`ORCA_PANE_KEY`), so the second request reuses the first one's engine answer. This plugin
|
|
283
|
+
waits about 1.5 s after a turn ends so its notification uses the hooks' transcript-based answer.
|
|
284
|
+
Codex tool calls are decided by the Codex plugin only, because Orca waits for Claude Code's tool
|
|
285
|
+
hook alone.
|
|
286
|
+
|
|
287
|
+
## Troubleshooting
|
|
288
|
+
|
|
289
|
+
**The plugin never sees an agent's tool calls**, and Orca's agent status for that pane stays empty.
|
|
290
|
+
Orca accepts hooks only from the pane's own agent process. A PTY wrapper started from your shell's
|
|
291
|
+
start-up files (a session recorder, a terminal proxy, an auto-started multiplexer such as `lig`)
|
|
292
|
+
puts its own PTY between the pane and the agent, so Orca drops that agent's hooks, this plugin's
|
|
293
|
+
included.
|
|
294
|
+
|
|
295
|
+
What the plugin does by itself:
|
|
296
|
+
|
|
297
|
+
- For every agent Orca launches, it adds `LIG_DISABLE=1` to the launch environment, which is the
|
|
298
|
+
`lig` wrapper's own off switch. Other wrappers are not touched, and a value the launch already
|
|
299
|
+
sets is kept.
|
|
300
|
+
- When a launched Claude Code agent sends no status within 60 s, it logs once per terminal
|
|
301
|
+
`local-decider: no agent status from terminal <id> after 60 s; a PTY wrapper in the shell
|
|
302
|
+
start-up may hide its hooks` (see `orca plugin logs`) and shows **Agent hooks: not seen from N
|
|
303
|
+
launched agents** in the panel's **This plugin** section, until a status arrives from that
|
|
304
|
+
terminal.
|
|
305
|
+
|
|
306
|
+
What is left to you:
|
|
307
|
+
|
|
308
|
+
- Install the Claude Code and Codex plugin (`plugins/local-decider`) first, for agents you start
|
|
309
|
+
by typing `claude` or `codex` in an Orca terminal. Its hooks run inside the agent, so a wrapper
|
|
310
|
+
cannot hide them and tool calls stay checked. Orca's agent status, the end-of-turn checks and
|
|
311
|
+
the Orca-side guard still need the wrapper skipped (below).
|
|
312
|
+
- Agents you start by typing `claude` in an Orca terminal do not go through the launch hook, so
|
|
313
|
+
the plugin cannot set `LIG_DISABLE` for them.
|
|
314
|
+
- Wrappers other than `lig`.
|
|
315
|
+
|
|
316
|
+
The plugin cannot do this itself: it cannot change a shell that is already running, and editing a
|
|
317
|
+
person's shell files is out of bounds for a plugin. Skip the wrapper inside Orca panes, which set
|
|
318
|
+
`ORCA_PANE_KEY`. In fish:
|
|
319
|
+
|
|
320
|
+
```fish
|
|
321
|
+
if status is-interactive; and test -z "$ORCA_PANE_KEY"
|
|
322
|
+
# start the wrapper here
|
|
323
|
+
end
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
For `lig`, one line placed before the line that starts it (for example in
|
|
327
|
+
`~/.config/fish/conf.d/00-lig.fish`):
|
|
328
|
+
|
|
329
|
+
```fish
|
|
330
|
+
set -q ORCA_PANE_KEY; and set -gx LIG_DISABLE 1
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Development
|
|
334
|
+
|
|
335
|
+
The worker runs from `src/worker.ts`, which Orca transpiles when it loads. There is no build step
|
|
336
|
+
and nothing to install: shared code from `packages/core` and `packages/launcher` is copied
|
|
337
|
+
verbatim into `src/core/` and `src/launcher/`, and `test/package-deps.test.ts` keeps the copies
|
|
338
|
+
identical.
|
|
339
|
+
|
|
340
|
+
```sh
|
|
341
|
+
pnpm --filter @ziptie-soft/orca-local-decider test
|
|
342
|
+
pnpm --filter @ziptie-soft/orca-local-decider typecheck
|
|
343
|
+
orca plugin validate packages/orca-plugin
|
|
344
|
+
orca plugin dev load packages/orca-plugin
|
|
345
|
+
orca plugin dev hook packages/orca-plugin agent.tool.before --data '{"agent":"claude","workspaceId":null,"tool":"Bash","input":{"command":"git push --force origin main"}}'
|
|
346
|
+
```
|
package/images/cover.png
ADDED
|
Binary file
|
package/images/icon.png
ADDED
|
Binary file
|