privateer-agent 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/bin/privateer-launch.mjs +144 -68
- package/bin/privateer-subagent.mjs +35 -22
- package/extensions/privateer-brand.ts +14 -1
- package/extensions/privateer-gate.ts +20 -28
- package/extensions/privateer-media.ts +20 -0
- package/extensions/privateer-privacy.ts +3 -3
- package/package.json +16 -7
- package/patches/@earendil-works+pi-coding-agent+0.80.3.patch +876 -5
- package/src/acp/run.ts +16 -19
- package/src/channels/run.ts +18 -27
- package/src/cli/chat.ts +61 -18
- package/src/config/hosted.ts +34 -0
- package/src/config/moat.ts +236 -0
- package/src/config/moatManifest.json +26 -0
- package/src/config/moatManifest.ts +71 -0
- package/src/harbor/index.ts +49 -113
- package/src/outbox/cloudOutbox.ts +95 -0
- package/src/permissions/classify.ts +113 -0
- package/src/providers/account.ts +88 -4
- package/src/providers/defaultModel.ts +66 -11
- package/src/remote/extensionsControl.ts +12 -24
- package/src/remote/liveTaskSession.ts +15 -24
- package/src/remote/relayClient.ts +39 -0
- package/src/remote/remoteBridge.ts +65 -0
- package/src/tools/media.ts +554 -0
- package/src/tools/relayFileTools.ts +10 -11
- package/src/tools/videoCompose.ts +579 -0
- package/src/tools/web.ts +12 -8
- package/src/config/harborDaemon.ts +0 -31
- package/src/config/inlineMoat.ts +0 -67
package/src/config/inlineMoat.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// "Did this process already build its own permission gate in code?" — a process-level
|
|
2
|
-
// marker, set by every non-TUI entry that passes makePermissionGate() as an inline
|
|
3
|
-
// extension factory, and read by the shipped gate extension so it doesn't install a
|
|
4
|
-
// SECOND one on top.
|
|
5
|
-
//
|
|
6
|
-
// The problem it solves: ~/.privateer/agent/extensions holds discovery shims for the
|
|
7
|
-
// interactive TUI's extensions (installed by bin/privateer-launch.mjs). Pi discovers
|
|
8
|
-
// them into every session built against that agentDir, and merges them with inline
|
|
9
|
-
// factories — discovered FIRST, factories appended after (core/resource-loader.js).
|
|
10
|
-
// extensions/privateer-gate.ts is one of those shims and it installs its own gate,
|
|
11
|
-
// wired to the module-level RemoteBridge that only `/remote-access` ever attaches a
|
|
12
|
-
// relay to. In a harbor / channels process that bridge is permanently unattached, so
|
|
13
|
-
// the discovered copy believes every turn is LOCAL — and its cwd is process.cwd()
|
|
14
|
-
// (the daemon's, not the session's) with a module-level allowlist shared across
|
|
15
|
-
// concurrent sessions. What that costs depends on whether `session_start` fired,
|
|
16
|
-
// which in Pi only happens if something calls bindExtensions():
|
|
17
|
-
// • a live task spawn DOES bind (for the relayed select/confirm), so the copy sees
|
|
18
|
-
// ctx.mode "print", flips itself to bypass, and only intervenes on dangerous
|
|
19
|
-
// shell / destructive / secret-exfil actions — where it asks through ctx.ui,
|
|
20
|
-
// which the spawn relays to the app as a SECOND dialog on top of the session
|
|
21
|
-
// gate's own approval for the same call;
|
|
22
|
-
// • the harbor's headless runs (routines, workflows, submitted tasks) and the
|
|
23
|
-
// channels runner never bind, so session_start never fires, the copy stays in
|
|
24
|
-
// "default" mode with no UI, and defaultLocalAsk fails closed — DENYING every
|
|
25
|
-
// gated tool before the session's real approver is ever consulted.
|
|
26
|
-
// Neither is what these entries want: they each wire a gate that knows their cwd and
|
|
27
|
-
// their approver.
|
|
28
|
-
//
|
|
29
|
-
// INVARIANT: set this ONLY from a path that installs makePermissionGate() itself.
|
|
30
|
-
// Marking a process that doesn't would leave its sessions ungated.
|
|
31
|
-
//
|
|
32
|
-
// `privateer acp` solves the same collision differently — `noExtensions: true`, so
|
|
33
|
-
// nothing is discovered at all (see src/acp/run.ts) — and needs no marker.
|
|
34
|
-
//
|
|
35
|
-
// An env var rather than a module singleton on purpose: discovered extensions load
|
|
36
|
-
// through jiti with its module cache off, so they may hold a SEPARATE copy of our
|
|
37
|
-
// modules. process.env is the one piece of state both copies are guaranteed to share.
|
|
38
|
-
// It is inherited by child processes, which is why the shim pairs this check with
|
|
39
|
-
// isSubagentChild() — a subagent child loads the moat explicitly (`-e`) and must keep
|
|
40
|
-
// its own gate. See bin/privateer-subagent.mjs.
|
|
41
|
-
//
|
|
42
|
-
// IMPORT-SAFETY: no Pi imports, no node builtins — safe to load from anywhere.
|
|
43
|
-
|
|
44
|
-
const ENV = "PRIVATEER_INLINE_MOAT";
|
|
45
|
-
|
|
46
|
-
/** Called once by an entry that loads the moat as an in-code factory. Idempotent. */
|
|
47
|
-
export function markInlineMoat(): void {
|
|
48
|
-
process.env[ENV] = "1";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** True in a process whose sessions already carry their own in-code permission gate. */
|
|
52
|
-
export function inlineMoat(): boolean {
|
|
53
|
-
return process.env[ENV] === "1";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Should a DISCOVERED gate extension install its permission gate in this process?
|
|
58
|
-
*
|
|
59
|
-
* No when the session already has one from an inline factory — EXCEPT in a subagent
|
|
60
|
-
* child, which inherits the parent's environment but loads this extension explicitly
|
|
61
|
-
* (`-e`, bin/privateer-subagent.mjs) as its ONLY moat. Getting that carve-out wrong
|
|
62
|
-
* runs a harbor task's children with no gate at all, so it is a parameter rather than
|
|
63
|
-
* an env read here: the caller passes isSubagentChild() and the matrix is testable.
|
|
64
|
-
*/
|
|
65
|
-
export function discoveredGateApplies(isSubagentChild: boolean): boolean {
|
|
66
|
-
return !inlineMoat() || isSubagentChild;
|
|
67
|
-
}
|