@tpsdev-ai/agent 0.5.3 → 0.6.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 (64) hide show
  1. package/dist/bin.js +47 -2
  2. package/dist/bin.js.map +1 -1
  3. package/dist/config.d.ts +2 -1
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +8 -0
  6. package/dist/config.js.map +1 -1
  7. package/dist/index.d.ts +4 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +4 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/io/flair.d.ts +43 -0
  12. package/dist/io/flair.d.ts.map +1 -0
  13. package/dist/io/flair.js +143 -0
  14. package/dist/io/flair.js.map +1 -0
  15. package/dist/io/mail.d.ts +24 -2
  16. package/dist/io/mail.d.ts.map +1 -1
  17. package/dist/io/mail.js +168 -15
  18. package/dist/io/mail.js.map +1 -1
  19. package/dist/lib/signEnvelope.d.ts +67 -0
  20. package/dist/lib/signEnvelope.d.ts.map +1 -0
  21. package/dist/lib/signEnvelope.js +244 -0
  22. package/dist/lib/signEnvelope.js.map +1 -0
  23. package/dist/llm/provider.d.ts +21 -1
  24. package/dist/llm/provider.d.ts.map +1 -1
  25. package/dist/llm/provider.js +422 -23
  26. package/dist/llm/provider.js.map +1 -1
  27. package/dist/runtime/agent.d.ts +2 -0
  28. package/dist/runtime/agent.d.ts.map +1 -1
  29. package/dist/runtime/agent.js +50 -3
  30. package/dist/runtime/agent.js.map +1 -1
  31. package/dist/runtime/event-loop.d.ts +44 -2
  32. package/dist/runtime/event-loop.d.ts.map +1 -1
  33. package/dist/runtime/event-loop.js +478 -56
  34. package/dist/runtime/event-loop.js.map +1 -1
  35. package/dist/runtime/types.d.ts +27 -1
  36. package/dist/runtime/types.d.ts.map +1 -1
  37. package/dist/telemetry/events.d.ts +57 -0
  38. package/dist/telemetry/events.d.ts.map +1 -0
  39. package/dist/telemetry/events.js +37 -0
  40. package/dist/telemetry/events.js.map +1 -0
  41. package/dist/tools/edit.d.ts.map +1 -1
  42. package/dist/tools/edit.js +94 -16
  43. package/dist/tools/edit.js.map +1 -1
  44. package/package.json +10 -2
  45. package/src/bin.ts +56 -3
  46. package/src/config.ts +10 -1
  47. package/src/index.ts +8 -0
  48. package/src/io/flair.ts +183 -0
  49. package/src/io/mail.ts +184 -19
  50. package/src/lib/signEnvelope.ts +332 -0
  51. package/src/llm/provider.ts +454 -22
  52. package/src/runtime/agent.ts +55 -3
  53. package/src/runtime/event-loop.ts +523 -44
  54. package/src/runtime/types.ts +32 -1
  55. package/src/telemetry/events.ts +101 -0
  56. package/src/tools/edit.ts +108 -17
  57. package/test/bin-launch-id.test.ts +104 -0
  58. package/test/core-loop.test.ts +240 -0
  59. package/test/events.test.ts +33 -0
  60. package/test/flair-context.test.ts +102 -0
  61. package/test/governance.test.ts +103 -2
  62. package/test/io.test.ts +8 -8
  63. package/test/provider.test.ts +471 -0
  64. package/test/security/mail-trust.test.ts +266 -0
package/dist/io/mail.js CHANGED
@@ -1,5 +1,7 @@
1
- import { existsSync, mkdirSync, readdirSync, renameSync, readFileSync } from "node:fs";
1
+ import { existsSync, mkdirSync, readdirSync, renameSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
+ import { sanitizeError } from "../telemetry/events.js";
4
+ import { verifyEnvelope } from "../lib/signEnvelope.js";
3
5
  /**
4
6
  * Maildir-compatible mail client.
5
7
  * Reads from mailDir/inbox/new and moves processed messages to mailDir/inbox/cur.
@@ -7,39 +9,190 @@ import { join } from "node:path";
7
9
  */
8
10
  export class MailClient {
9
11
  mailDir;
12
+ events;
13
+ agentId;
14
+ flairClient;
10
15
  inboxNew;
11
16
  inboxCur;
17
+ inboxDlq;
12
18
  outboxNew;
13
- constructor(mailDir) {
19
+ constructor(mailDir, events, agentId = "unknown", flairClient) {
14
20
  this.mailDir = mailDir;
15
- this.inboxNew = join(mailDir, "inbox", "new");
16
- this.inboxCur = join(mailDir, "inbox", "cur");
17
- this.outboxNew = join(mailDir, "outbox", "new");
18
- // Ensure directories exist
19
- for (const dir of [this.inboxNew, this.inboxCur, this.outboxNew]) {
21
+ this.events = events;
22
+ this.agentId = agentId;
23
+ this.flairClient = flairClient;
24
+ this.inboxNew = join(mailDir, agentId, "new");
25
+ this.inboxCur = join(mailDir, agentId, "cur");
26
+ this.inboxDlq = join(mailDir, agentId, "dlq");
27
+ this.outboxNew = join(mailDir, agentId, "outbox");
28
+ for (const dir of [this.inboxNew, this.inboxCur, this.inboxDlq, this.outboxNew]) {
20
29
  mkdirSync(dir, { recursive: true });
21
30
  }
22
31
  }
23
- /** Return all messages in inbox/new and move them to inbox/cur. */
32
+ /**
33
+ * Return all messages in inbox/new and move them to inbox/cur.
34
+ * When a FlairClient is provided, signed envelopes are verified
35
+ * before promotion; invalid/malformed messages go to dlq/.
36
+ */
24
37
  async checkNewMail() {
25
38
  if (!existsSync(this.inboxNew))
26
39
  return [];
27
40
  const files = readdirSync(this.inboxNew).filter((f) => !f.startsWith(".") && !f.includes("/") && !f.includes("\\"));
28
41
  const messages = [];
29
42
  for (const file of files) {
43
+ const started = Date.now();
30
44
  const srcPath = join(this.inboxNew, file);
31
- const dstPath = join(this.inboxCur, file);
32
- const body = readFileSync(srcPath, "utf-8");
33
- renameSync(srcPath, dstPath);
34
- messages.push({ filename: file, body, receivedAt: new Date() });
45
+ try {
46
+ const body = readFileSync(srcPath, "utf-8");
47
+ // Envelope verification (strict when FlairClient is available).
48
+ if (this.flairClient) {
49
+ const verifyResult = await this.verifyMailBody(body, file);
50
+ if (!verifyResult.pass) {
51
+ const dlqPath = join(this.inboxDlq, file);
52
+ renameSync(srcPath, dlqPath);
53
+ writeFileSync(join(this.inboxDlq, `${file}.reject`), verifyResult.reason, "utf-8");
54
+ this.events?.emit({
55
+ type: "mail.receive",
56
+ agent: this.agentId,
57
+ status: "rejected",
58
+ from: verifyResult.from ?? "unknown",
59
+ durationMs: Date.now() - started,
60
+ error: verifyResult.reason,
61
+ });
62
+ continue;
63
+ }
64
+ }
65
+ // Promote to cur/
66
+ const dstPath = join(this.inboxCur, file);
67
+ renameSync(srcPath, dstPath);
68
+ let headers = {};
69
+ let from = "unknown";
70
+ try {
71
+ const parsed = JSON.parse(body);
72
+ headers = parsed.headers ?? {};
73
+ from = parsed.from ?? "unknown";
74
+ }
75
+ catch { }
76
+ messages.push({ filename: file, body, receivedAt: new Date(), headers, from });
77
+ this.events?.emit({
78
+ type: "mail.receive",
79
+ agent: this.agentId,
80
+ status: "ok",
81
+ from,
82
+ durationMs: Date.now() - started,
83
+ });
84
+ }
85
+ catch (err) {
86
+ this.events?.emit({
87
+ type: "mail.receive",
88
+ agent: this.agentId,
89
+ status: "error",
90
+ from: "unknown",
91
+ durationMs: Date.now() - started,
92
+ error: sanitizeError(err),
93
+ });
94
+ }
35
95
  }
36
96
  return messages;
37
97
  }
38
98
  /** Write a message to outbox/new for relay delivery. */
39
99
  async sendMail(to, body) {
40
- const { writeFileSync } = await import("node:fs");
41
- const filename = `${Date.now()}-${Math.random().toString(36).slice(2)}.json`;
42
- writeFileSync(join(this.outboxNew, filename), JSON.stringify({ to, body, sentAt: new Date().toISOString() }, null, 2), "utf-8");
100
+ const started = Date.now();
101
+ try {
102
+ const { writeFileSync } = await import("node:fs");
103
+ const filename = `${Date.now()}-${Math.random().toString(36).slice(2)}.json`;
104
+ writeFileSync(join(this.outboxNew, filename), JSON.stringify({ to, body, sentAt: new Date().toISOString() }, null, 2), "utf-8");
105
+ this.events?.emit({
106
+ type: "mail.send",
107
+ agent: this.agentId,
108
+ to,
109
+ status: "ok",
110
+ durationMs: Date.now() - started,
111
+ });
112
+ }
113
+ catch (err) {
114
+ this.events?.emit({
115
+ type: "mail.send",
116
+ agent: this.agentId,
117
+ to,
118
+ status: "error",
119
+ durationMs: Date.now() - started,
120
+ error: sanitizeError(err),
121
+ });
122
+ throw err;
123
+ }
124
+ }
125
+ /** Deliver all messages in outbox to recipient inboxes (local relay). */
126
+ deliverOutbox() {
127
+ if (!existsSync(this.outboxNew))
128
+ return;
129
+ const files = readdirSync(this.outboxNew).filter(f => !f.startsWith("."));
130
+ for (const file of files) {
131
+ const srcPath = join(this.outboxNew, file);
132
+ try {
133
+ const raw = readFileSync(srcPath, "utf-8");
134
+ const msg = JSON.parse(raw);
135
+ if (!msg.to || !/^[a-zA-Z0-9_-]{1,64}$/.test(msg.to)) {
136
+ continue; // skip invalid recipients
137
+ }
138
+ const recipientInbox = join(this.mailDir, msg.to, "new");
139
+ mkdirSync(recipientInbox, { recursive: true });
140
+ const destFile = `${msg.sentAt.replace(/[:.]/g, "-")}-${file}`;
141
+ renameSync(srcPath, join(recipientInbox, destFile));
142
+ }
143
+ catch {
144
+ // Leave in outbox on error
145
+ }
146
+ }
147
+ }
148
+ /**
149
+ * Verify a mail body against the v1 signed envelope spec.
150
+ * Returns { pass: true } if verified, or { pass: false, reason: "..." } on failure.
151
+ * Requires flairClient to be set.
152
+ */
153
+ async verifyMailBody(body, filename) {
154
+ const client = this.flairClient;
155
+ // 1. Parse the mail file as JSON
156
+ let mailMsg;
157
+ try {
158
+ mailMsg = JSON.parse(body);
159
+ }
160
+ catch {
161
+ return { pass: false, reason: "json parse error: invalid JSON" };
162
+ }
163
+ if (!mailMsg.body || typeof mailMsg.body !== "string") {
164
+ return { pass: false, reason: "json parse error: missing body field" };
165
+ }
166
+ // 2. Parse the body field as an envelope
167
+ let envelope;
168
+ try {
169
+ envelope = JSON.parse(mailMsg.body);
170
+ }
171
+ catch {
172
+ return { pass: false, reason: "json parse error: invalid envelope body", from: mailMsg.from };
173
+ }
174
+ if (envelope == null || typeof envelope !== "object" || Array.isArray(envelope)) {
175
+ return { pass: false, reason: "unsigned envelope (v1 required)", from: mailMsg.from };
176
+ }
177
+ const env = envelope;
178
+ if (typeof env.v !== "number" ||
179
+ !Array.isArray(env.delegationChain) ||
180
+ typeof env.signature !== "string") {
181
+ return { pass: false, reason: "unsigned envelope (v1 required)", from: mailMsg.from };
182
+ }
183
+ // 3. Verify the envelope using the canonical verifyEnvelope
184
+ try {
185
+ const vr = await verifyEnvelope(env, client);
186
+ if (!vr.ok) {
187
+ return { pass: false, reason: vr.reason, from: mailMsg.from };
188
+ }
189
+ }
190
+ catch (err) {
191
+ // verifyEnvelope threw (e.g. Flair network error).
192
+ // Don't drop the message — pass it through and log.
193
+ console.warn(`[MailClient] verifyEnvelope error for ${filename}: ${err?.message ?? err}`);
194
+ }
195
+ return { pass: true };
43
196
  }
44
197
  }
45
198
  //# sourceMappingURL=mail.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mail.js","sourceRoot":"","sources":["../../src/io/mail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQjC;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAKO;IAJpB,QAAQ,CAAS;IACjB,QAAQ,CAAS;IACjB,SAAS,CAAS;IAE1B,YAA4B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAChD,2BAA2B;QAC3B,KAAK,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACjE,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,mEAAmE;IACnE,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MAAM,EAAE,iCAAiC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;QACxF,CAAC;QAED,MAAM,GAAG,GAAG,QAAmC,CAAC;QAChD,IACE,OAAO,GAAG,CAAC,CAAC,KAAK,QAAQ;YACzB,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;YACnC,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ,EACjC,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,iCAAiC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;QACxF,CAAC;QAED,4DAA4D;QAC5D,IAAI,CAAC;YACH,MAAM,EAAE,GAAG,MAAM,cAAc,CAAC,GAAU,EAAE,MAAM,CAAC,CAAC;YACpD,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACX,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;YAChE,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,mDAAmD;YACnD,oDAAoD;YACpD,OAAO,CAAC,IAAI,CAAC,yCAAyC,QAAQ,KAAK,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;QAC5F,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * signEnvelope — Ed25519 signature over TPS mail envelope + delegation chain.
3
+ *
4
+ * Signs every agent-kind entry in the delegation chain whose signature is
5
+ * null/missing, then signs the outer envelope. Uses JCS (RFC 8785)
6
+ * canonicalization for deterministic byte-level signing input.
7
+ */
8
+ export interface ChainEntry {
9
+ agent: string;
10
+ kind: "human" | "agent";
11
+ timestamp: string;
12
+ rationale: string;
13
+ signature: string | null;
14
+ }
15
+ export interface Envelope {
16
+ v: number;
17
+ from: string;
18
+ to: string;
19
+ subject?: string;
20
+ body: string;
21
+ messageId: string;
22
+ timestamp: string;
23
+ delegationChain: ChainEntry[];
24
+ signature?: string;
25
+ }
26
+ /**
27
+ * Sign an envelope:
28
+ * - For each agent-kind chain entry whose signature is null/missing, generate
29
+ * sig over jcs({ prior: chain[0..i], entry: { ...entry, signature: undefined } })
30
+ * using the agent's privkey.
31
+ * - Then compute outer sig over jcs({ ...envelope, signature: undefined })
32
+ * using the LAST chain entry's privkey (which must equal envelope.from).
33
+ *
34
+ * Caller passes privkeys by agent name. For PR-1 simplicity, accept a map:
35
+ * keysByAgent: { [agentName: string]: Buffer (32-byte Ed25519 seed) }
36
+ *
37
+ * Returns envelope with chain entry sigs and outer sig populated.
38
+ * Mutates a copy, does not mutate input.
39
+ */
40
+ export declare function signEnvelope(envelope: Envelope, keysByAgent: Record<string, Buffer>): Envelope;
41
+ export interface FlairClient {
42
+ getAgent(name: string): Promise<{
43
+ publicKey: Buffer;
44
+ } | null>;
45
+ }
46
+ export interface VerifyOk {
47
+ ok: true;
48
+ }
49
+ export interface VerifyReject {
50
+ ok: false;
51
+ reason: string;
52
+ }
53
+ /**
54
+ * Verify a signed envelope:
55
+ * - v must be 1
56
+ * - delegationChain must be non-empty and length <= 16
57
+ * - last chain entry's agent must equal envelope.from
58
+ * - outer signature must verify against envelope.from's pubkey over
59
+ * jcs({ ...envelope, signature: undefined })
60
+ * - each agent-kind chain entry's signature must verify against that
61
+ * agent's pubkey over jcs({ prior: chain[0..i], entry: { ...entry, signature: undefined } })
62
+ * - each human-kind entry must have signature === null
63
+ *
64
+ * Pure function with DI'd flairClient — no Flair HTTP coupling.
65
+ */
66
+ export declare function verifyEnvelope(envelope: Envelope, flairClient: FlairClient): Promise<VerifyOk | VerifyReject>;
67
+ //# sourceMappingURL=signEnvelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signEnvelope.d.ts","sourceRoot":"","sources":["../../src/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3
+ *
4
+ * Signs every agent-kind entry in the delegation chain whose signature is
5
+ * null/missing, then signs the outer envelope. Uses JCS (RFC 8785)
6
+ * canonicalization for deterministic byte-level signing input.
7
+ */
8
+ import * as ed from "@noble/ed25519";
9
+ import { createHash } from "node:crypto";
10
+ import canonicalize from "canonicalize";
11
+ // Ensure sync sha512 is wired (same pattern as identity.ts).
12
+ import { hashes } from "@noble/ed25519";
13
+ hashes.sha512 = (message) => {
14
+ return new Uint8Array(createHash("sha512").update(message).digest());
15
+ };
16
+ // ─── Helpers ────────────────────────────────────────────────────────────────
17
+ function base64Encode(buf) {
18
+ return Buffer.from(buf).toString("base64");
19
+ }
20
+ function base64Decode(s) {
21
+ return new Uint8Array(Buffer.from(s, "base64"));
22
+ }
23
+ /**
24
+ * Sign payload bytes with an Ed25519 seed (32 bytes).
25
+ * Returns a 64-byte signature.
26
+ */
27
+ function signPayload(payload, seed) {
28
+ return ed.sign(payload, seed);
29
+ }
30
+ /**
31
+ * Verify an Ed25519 signature against a payload and public key.
32
+ */
33
+ function verifyPayload(payload, signature, publicKey) {
34
+ try {
35
+ return ed.verify(signature, payload, publicKey);
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ }
41
+ /**
42
+ * Decode a "ed25519:<base64>" signature string into raw bytes.
43
+ * Returns null if the signature is null/undefined or malformed.
44
+ */
45
+ function decodeSignature(sig) {
46
+ if (sig == null)
47
+ return null;
48
+ const prefix = "ed25519:";
49
+ if (!sig.startsWith(prefix))
50
+ return null;
51
+ try {
52
+ return base64Decode(sig.slice(prefix.length));
53
+ }
54
+ catch {
55
+ return null;
56
+ }
57
+ }
58
+ /**
59
+ * Deep-clone an envelope so we never mutate the input.
60
+ */
61
+ function cloneEnvelope(e) {
62
+ return JSON.parse(JSON.stringify(e));
63
+ }
64
+ // ─── Core ───────────────────────────────────────────────────────────────────
65
+ /**
66
+ * Sign an envelope:
67
+ * - For each agent-kind chain entry whose signature is null/missing, generate
68
+ * sig over jcs({ prior: chain[0..i], entry: { ...entry, signature: undefined } })
69
+ * using the agent's privkey.
70
+ * - Then compute outer sig over jcs({ ...envelope, signature: undefined })
71
+ * using the LAST chain entry's privkey (which must equal envelope.from).
72
+ *
73
+ * Caller passes privkeys by agent name. For PR-1 simplicity, accept a map:
74
+ * keysByAgent: { [agentName: string]: Buffer (32-byte Ed25519 seed) }
75
+ *
76
+ * Returns envelope with chain entry sigs and outer sig populated.
77
+ * Mutates a copy, does not mutate input.
78
+ */
79
+ export function signEnvelope(envelope, keysByAgent) {
80
+ const chain = envelope.delegationChain;
81
+ // ── Validation ────────────────────────────────────────────────────────
82
+ // 1. Chain tip must match envelope.from
83
+ const chainTip = chain[chain.length - 1];
84
+ if (!chainTip || chainTip.agent !== envelope.from) {
85
+ throw new Error(`Envelope from "${envelope.from}" must equal delegation chain tip agent "${chainTip?.agent ?? "(empty chain)"}"`);
86
+ }
87
+ // 2. Check human entries don't have signatures
88
+ for (const entry of chain) {
89
+ if (entry.kind === "human" && entry.signature !== null) {
90
+ throw new Error(`Human-kind chain entry for "${entry.agent}" must have null signature`);
91
+ }
92
+ }
93
+ // 3. Collect all agents that need a private key
94
+ const agentsNeedingKey = new Set();
95
+ for (const entry of chain) {
96
+ if (entry.kind === "agent" && entry.signature === null) {
97
+ agentsNeedingKey.add(entry.agent);
98
+ }
99
+ }
100
+ // Outer sig always needs envelope.from's key
101
+ agentsNeedingKey.add(envelope.from);
102
+ for (const agent of agentsNeedingKey) {
103
+ if (!keysByAgent[agent]) {
104
+ throw new Error(`Missing private key for agent "${agent}"`);
105
+ }
106
+ }
107
+ // ── Sign chain entries ────────────────────────────────────────────────
108
+ const result = cloneEnvelope(envelope);
109
+ const resultChain = result.delegationChain;
110
+ for (let i = 0; i < resultChain.length; i++) {
111
+ const entry = resultChain[i];
112
+ if (entry.kind !== "agent")
113
+ continue;
114
+ if (entry.signature !== null)
115
+ continue; // idempotent: skip already-signed
116
+ // Build signing payload: { prior: chain[0..i], entry: { ...entry, signature: undefined } }
117
+ const prior = resultChain.slice(0, i);
118
+ const entryForSig = {
119
+ agent: entry.agent,
120
+ kind: entry.kind,
121
+ timestamp: entry.timestamp,
122
+ rationale: entry.rationale,
123
+ signature: undefined,
124
+ };
125
+ const payload = { prior, entry: entryForSig };
126
+ const canonical = canonicalize(payload);
127
+ if (canonical === undefined) {
128
+ throw new Error(`Failed to canonicalize chain entry payload for agent "${entry.agent}"`);
129
+ }
130
+ const payloadBuf = new TextEncoder().encode(canonical);
131
+ const seed = new Uint8Array(keysByAgent[entry.agent]);
132
+ const sig = signPayload(payloadBuf, seed);
133
+ entry.signature = `ed25519:${base64Encode(sig)}`;
134
+ }
135
+ // ── Sign outer envelope ───────────────────────────────────────────────
136
+ const { signature: _, ...envelopeWithoutSig } = result;
137
+ const canonical = canonicalize(envelopeWithoutSig);
138
+ if (canonical === undefined) {
139
+ throw new Error("Failed to canonicalize outer envelope");
140
+ }
141
+ const payloadBuf = new TextEncoder().encode(canonical);
142
+ const fromSeed = new Uint8Array(keysByAgent[envelope.from]);
143
+ const outerSig = signPayload(payloadBuf, fromSeed);
144
+ result.signature = `ed25519:${base64Encode(outerSig)}`;
145
+ return result;
146
+ }
147
+ /**
148
+ * Verify a signed envelope:
149
+ * - v must be 1
150
+ * - delegationChain must be non-empty and length <= 16
151
+ * - last chain entry's agent must equal envelope.from
152
+ * - outer signature must verify against envelope.from's pubkey over
153
+ * jcs({ ...envelope, signature: undefined })
154
+ * - each agent-kind chain entry's signature must verify against that
155
+ * agent's pubkey over jcs({ prior: chain[0..i], entry: { ...entry, signature: undefined } })
156
+ * - each human-kind entry must have signature === null
157
+ *
158
+ * Pure function with DI'd flairClient — no Flair HTTP coupling.
159
+ */
160
+ export async function verifyEnvelope(envelope, flairClient) {
161
+ // 1. Version check
162
+ if (envelope.v !== 1) {
163
+ return { ok: false, reason: "unsupported version" };
164
+ }
165
+ // 2. Chain must exist and be non-empty
166
+ const chain = envelope.delegationChain;
167
+ if (!chain || chain.length === 0) {
168
+ return { ok: false, reason: "missing chain" };
169
+ }
170
+ // 3. Chain length limit
171
+ if (chain.length > 16) {
172
+ return { ok: false, reason: "chain too long" };
173
+ }
174
+ // 4. Chain tip must match envelope.from
175
+ if (chain[chain.length - 1].agent !== envelope.from) {
176
+ return { ok: false, reason: "chain tip / from mismatch" };
177
+ }
178
+ // 5. Human entries must have null signature
179
+ for (const entry of chain) {
180
+ if (entry.kind === "human" && entry.signature !== null) {
181
+ return { ok: false, reason: "human entry must have null signature" };
182
+ }
183
+ }
184
+ // 6. Resolve all agent pubkeys from Flair
185
+ const pubkeys = new Map();
186
+ const agentsToResolve = new Set();
187
+ for (const entry of chain) {
188
+ if (entry.kind === "agent")
189
+ agentsToResolve.add(entry.agent);
190
+ }
191
+ agentsToResolve.add(envelope.from);
192
+ for (const agent of agentsToResolve) {
193
+ const info = await flairClient.getAgent(agent);
194
+ if (!info) {
195
+ return { ok: false, reason: `agent ${agent} not found in Flair` };
196
+ }
197
+ pubkeys.set(agent, info.publicKey);
198
+ }
199
+ // 7. Verify each agent-kind chain entry signature
200
+ for (let i = 0; i < chain.length; i++) {
201
+ const entry = chain[i];
202
+ if (entry.kind !== "agent")
203
+ continue;
204
+ const sigBytes = decodeSignature(entry.signature);
205
+ if (!sigBytes) {
206
+ return { ok: false, reason: `chain entry ${i} signature invalid` };
207
+ }
208
+ const prior = chain.slice(0, i);
209
+ const entryForSig = {
210
+ agent: entry.agent,
211
+ kind: entry.kind,
212
+ timestamp: entry.timestamp,
213
+ rationale: entry.rationale,
214
+ signature: undefined,
215
+ };
216
+ const payload = { prior, entry: entryForSig };
217
+ const canonical = canonicalize(payload);
218
+ if (canonical === undefined) {
219
+ return { ok: false, reason: `chain entry ${i} signature invalid` };
220
+ }
221
+ const payloadBuf = new TextEncoder().encode(canonical);
222
+ const pubKey = pubkeys.get(entry.agent);
223
+ if (!verifyPayload(payloadBuf, sigBytes, new Uint8Array(pubKey))) {
224
+ return { ok: false, reason: `chain entry ${i} signature invalid` };
225
+ }
226
+ }
227
+ // 8. Verify outer signature
228
+ const sigBytes = decodeSignature(envelope.signature);
229
+ if (!sigBytes) {
230
+ return { ok: false, reason: "outer signature invalid" };
231
+ }
232
+ const { signature: _, ...envelopeWithoutSig } = envelope;
233
+ const canonical = canonicalize(envelopeWithoutSig);
234
+ if (canonical === undefined) {
235
+ return { ok: false, reason: "outer signature invalid" };
236
+ }
237
+ const payloadBuf = new TextEncoder().encode(canonical);
238
+ const fromPubKey = pubkeys.get(envelope.from);
239
+ if (!verifyPayload(payloadBuf, sigBytes, new Uint8Array(fromPubKey))) {
240
+ return { ok: false, reason: "outer signature invalid" };
241
+ }
242
+ return { ok: true };
243
+ }
244
+ //# sourceMappingURL=signEnvelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signEnvelope.js","sourceRoot":"","sources":["../../src/lib/signEnvelope.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,6DAA6D;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,MAAM,CAAC,MAAM,GAAG,CAAC,OAAmB,EAAE,EAAE;IACtC,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACvE,CAAC,CAAC;AAwBF,+EAA+E;AAE/E,SAAS,YAAY,CAAC,GAAe;IACnC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,YAAY,CAAC,CAAS;IAC7B,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;;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S,EAAE,CAAC,EAAE,GAAG,kBAAkB,EAAE,GAAG,QAAQ,CAAC;IACzD,MAAM,SAAS,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;IACnD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC;IAC1D,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC;IAC/C,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QACrE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,yBAAyB,EAAE,CAAC;IAC1D,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
@@ -1,12 +1,25 @@
1
1
  import type { LLMConfig, CompletionRequest, CompletionResponse, ToolSpec } from "../runtime/types.js";
2
+ import type { EventLogger } from "../telemetry/events.js";
2
3
  type ProviderKind = LLMConfig["provider"];
4
+ interface OAuthCredentials {
5
+ provider: string;
6
+ refreshToken: string;
7
+ accessToken: string;
8
+ expiresAt: number;
9
+ clientId: string;
10
+ scopes: string;
11
+ }
12
+ export declare function refreshAnthropicOAuthToken(creds: OAuthCredentials): Promise<OAuthCredentials>;
13
+ export declare function refreshGoogleOAuthToken(creds: OAuthCredentials): Promise<OAuthCredentials>;
3
14
  /**
4
15
  * Routes completion requests to the configured provider and normalizes
5
16
  * tool-call responses into a common shape.
6
17
  */
7
18
  export declare class ProviderManager {
8
19
  private readonly config;
9
- constructor(config: LLMConfig);
20
+ private readonly events?;
21
+ private readonly agentId;
22
+ constructor(config: LLMConfig, events?: EventLogger | undefined, agentId?: string);
10
23
  complete(request: CompletionRequest): Promise<CompletionResponse>;
11
24
  private toolSetForAnthropic;
12
25
  private toolSetForOpenAI;
@@ -15,6 +28,13 @@ export declare class ProviderManager {
15
28
  private mapOpenAIResponse;
16
29
  private mapOllamaResponse;
17
30
  private safeJson;
31
+ /** Build messages array, using raw assistant messages when available */
32
+ private buildMessages;
33
+ /**
34
+ * Route LLM request through the TPS localhost proxy.
35
+ * The proxy holds API keys; agent authenticates with Ed25519.
36
+ */
37
+ private completeViaProxy;
18
38
  private completeAnthropic;
19
39
  private completeGoogle;
20
40
  private completeOpenAI;
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/llm/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAElB,QAAQ,EAET,MAAM,qBAAqB,CAAC;AAE7B,KAAK,YAAY,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;AAE1C;;;GAGG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,SAAS;IAExC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAevE,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,oBAAoB;IA0B5B,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,QAAQ;YAaF,iBAAiB;YA+BjB,cAAc;YAoDd,cAAc;YA2Bd,cAAc;IAsBrB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ;IAY7F,kBAAkB,CAAC,QAAQ,EAAE,YAAY,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK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