privateer-agent 0.6.10 → 0.8.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.
Files changed (59) hide show
  1. package/README.md +20 -20
  2. package/SECURITY.md +1 -1
  3. package/bin/{privateer-daemon.mjs → privateer-harbor.mjs} +7 -7
  4. package/bin/privateer-launch.mjs +7 -6
  5. package/bin/privateer-subagent.mjs +1 -1
  6. package/extensions/privateer-brand.ts +1 -1
  7. package/extensions/privateer-connect.ts +2 -2
  8. package/extensions/privateer-tools.ts +1 -1
  9. package/package.json +4 -2
  10. package/src/auth/privateer.ts +2 -2
  11. package/src/channels/run.ts +16 -7
  12. package/src/channels/status.ts +7 -7
  13. package/src/cli/chat.ts +39 -5
  14. package/src/cli/{daemonCli.ts → harborCli.ts} +14 -14
  15. package/src/config/hosted.ts +5 -5
  16. package/src/crypto/accountTrust.ts +2 -2
  17. package/src/crypto/accountVerify.ts +1 -1
  18. package/src/{daemon → harbor}/index.ts +81 -44
  19. package/src/harbor/ipc.ts +175 -0
  20. package/src/{daemon → harbor}/service.ts +61 -28
  21. package/src/main.ts +1 -1
  22. package/src/mcp/catalog.ts +106 -0
  23. package/src/providers/account.ts +58 -11
  24. package/src/providers/catalog.ts +8 -6
  25. package/src/providers/defaultModel.ts +1 -1
  26. package/src/providers/phala/aci-verifier/VENDORED.md +23 -0
  27. package/src/providers/phala/aci-verifier/crypto.ts +95 -0
  28. package/src/providers/phala/aci-verifier/digest.ts +116 -0
  29. package/src/providers/phala/aci-verifier/e2ee-channel.ts +242 -0
  30. package/src/providers/phala/aci-verifier/e2ee.ts +73 -0
  31. package/src/providers/phala/aci-verifier/errors.ts +41 -0
  32. package/src/providers/phala/aci-verifier/index.ts +87 -0
  33. package/src/providers/phala/aci-verifier/jcs.ts +69 -0
  34. package/src/providers/phala/aci-verifier/receipt.ts +139 -0
  35. package/src/providers/phala/aci-verifier/report.ts +126 -0
  36. package/src/providers/phala/aci-verifier/types.ts +139 -0
  37. package/src/providers/phala/sse.ts +43 -0
  38. package/src/providers/phala/webcrypto-globals.d.ts +17 -0
  39. package/src/providers/phalaSeal.ts +200 -0
  40. package/src/providers/sealedShim.ts +295 -0
  41. package/src/remote/channelsControl.ts +8 -8
  42. package/src/remote/controlAuth.ts +1 -1
  43. package/src/remote/liveTaskSession.ts +15 -7
  44. package/src/remote/mcpControl.ts +2 -2
  45. package/src/remote/relayClient.ts +41 -21
  46. package/src/remote/remoteBridge.ts +17 -7
  47. package/src/remote/routinesControl.ts +7 -7
  48. package/src/remote/workflowsControl.ts +6 -6
  49. package/src/routines/delivery.ts +6 -6
  50. package/src/routines/schema.ts +3 -3
  51. package/src/routines/store.ts +3 -3
  52. package/src/routines/trigger.ts +1 -1
  53. package/src/tools/routine.ts +8 -8
  54. package/src/util/fileMentions.ts +232 -0
  55. package/src/workflows/expr.ts +1 -1
  56. package/src/workflows/runner.ts +3 -3
  57. package/src/workflows/schema.ts +1 -1
  58. package/src/workflows/store.ts +1 -1
  59. package/src/daemon/ipc.ts +0 -127
package/src/daemon/ipc.ts DELETED
@@ -1,127 +0,0 @@
1
- import { createServer, createConnection, type Socket, type Server } from "node:net";
2
- import { existsSync, unlinkSync, chmodSync } from "node:fs";
3
- import { join } from "node:path";
4
- import { globalDir } from "../config/paths.ts";
5
- import type { Routine } from "../routines/schema.ts";
6
-
7
- // The CLI/TUI talks to the resident daemon over a unix domain socket. The protocol
8
- // is one JSON request per connection, answered with one JSON response, both
9
- // newline-terminated. Kept tiny and local — nothing crosses the machine boundary.
10
-
11
- export function daemonSocketPath(): string {
12
- return join(globalDir(), "daemon.sock");
13
- }
14
-
15
- export type IpcRequest =
16
- | { cmd: "status" }
17
- | { cmd: "list" }
18
- | { cmd: "add"; routine: Routine }
19
- | { cmd: "remove"; idOrName: string }
20
- | { cmd: "pause"; idOrName: string }
21
- | { cmd: "resume"; idOrName: string }
22
- | { cmd: "run-now"; idOrName: string }
23
- | { cmd: "reload" };
24
-
25
- export interface IpcResponse {
26
- ok: boolean;
27
- message?: string;
28
- routines?: Routine[];
29
- // Daemon liveness/uptime for `status`.
30
- pid?: number;
31
- uptimeSec?: number;
32
- }
33
-
34
- export type IpcHandler = (req: IpcRequest) => Promise<IpcResponse> | IpcResponse;
35
-
36
- // Start the daemon-side socket server. Returns the Server so the caller can close it.
37
- export function startIpcServer(handler: IpcHandler): Server {
38
- const path = daemonSocketPath();
39
- // A stale socket file from a previous crash would block bind; remove it first.
40
- if (existsSync(path)) {
41
- try {
42
- unlinkSync(path);
43
- } catch {
44
- /* ignore — bind will surface a clearer error */
45
- }
46
- }
47
- const server = createServer((sock: Socket) => {
48
- let buf = "";
49
- sock.on("data", (chunk) => {
50
- buf += chunk.toString("utf8");
51
- const nl = buf.indexOf("\n");
52
- if (nl < 0) return; // wait for the full line
53
- const line = buf.slice(0, nl);
54
- void (async () => {
55
- let res: IpcResponse;
56
- try {
57
- res = await handler(JSON.parse(line) as IpcRequest);
58
- } catch (err) {
59
- res = { ok: false, message: err instanceof Error ? err.message : String(err) };
60
- }
61
- sock.end(JSON.stringify(res) + "\n");
62
- })();
63
- });
64
- sock.on("error", () => sock.destroy());
65
- });
66
- server.listen(path, () => {
67
- try {
68
- chmodSync(path, 0o600); // owner-only IPC endpoint
69
- } catch {
70
- /* non-POSIX — best effort */
71
- }
72
- });
73
- return server;
74
- }
75
-
76
- // Client side: send one request, resolve with the response. Rejects if the daemon
77
- // isn't running (no socket / connection refused) so callers can offer to start it.
78
- export function sendToDaemon(req: IpcRequest, timeoutMs = 5_000): Promise<IpcResponse> {
79
- const path = daemonSocketPath();
80
- return new Promise<IpcResponse>((resolve, reject) => {
81
- if (!existsSync(path)) {
82
- reject(new DaemonNotRunningError());
83
- return;
84
- }
85
- const sock = createConnection(path);
86
- let buf = "";
87
- const timer = setTimeout(() => {
88
- sock.destroy();
89
- reject(new Error("daemon did not respond in time"));
90
- }, timeoutMs);
91
- sock.on("connect", () => sock.end(JSON.stringify(req) + "\n"));
92
- sock.on("data", (chunk) => {
93
- buf += chunk.toString("utf8");
94
- });
95
- sock.on("end", () => {
96
- clearTimeout(timer);
97
- try {
98
- resolve(JSON.parse(buf.trim()) as IpcResponse);
99
- } catch {
100
- reject(new Error("malformed response from daemon"));
101
- }
102
- });
103
- sock.on("error", (err: NodeJS.ErrnoException) => {
104
- clearTimeout(timer);
105
- // ECONNREFUSED means a stale socket file with no listener behind it.
106
- if (err.code === "ENOENT" || err.code === "ECONNREFUSED") reject(new DaemonNotRunningError());
107
- else reject(err);
108
- });
109
- });
110
- }
111
-
112
- export class DaemonNotRunningError extends Error {
113
- constructor() {
114
- super("Privateer daemon is not running. Start it with `privateer daemon`.");
115
- this.name = "DaemonNotRunningError";
116
- }
117
- }
118
-
119
- // Convenience: is the daemon reachable right now?
120
- export async function daemonIsRunning(): Promise<boolean> {
121
- try {
122
- const res = await sendToDaemon({ cmd: "status" }, 2_000);
123
- return res.ok;
124
- } catch {
125
- return false;
126
- }
127
- }