@agentvalet/client 0.1.2 → 0.2.1

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 CHANGED
@@ -28,7 +28,8 @@ npx @agentvalet/register
28
28
  ```
29
29
 
30
30
  This generates an RSA keypair **locally** — the private key never leaves your
31
- machine — registers the public half, and writes `~/.agentvalet/agent.key`.
31
+ machine — registers the public half, and records the agent id and key path in
32
+ `~/.agentvalet/config.json` (and `./.env.agentvalet`), which `fromEnv()` reads.
32
33
 
33
34
  ## Use it
34
35
 
@@ -62,8 +63,13 @@ outside it.
62
63
 
63
64
  `fromEnv()` reads `AGENTVALET_AGENT_ID` / `AGENTVALET_OWNER_ID` (or the bare
64
65
  `AGENT_ID` / `OWNER_ID` the CLI writes) and finds the key via
65
- `AGENT_PRIVATE_KEY_B64`, `AGENT_PRIVATE_KEY_PATH`, `AGENT_PRIVATE_KEY`, or
66
- `~/.agentvalet/agent.key`. To wire it up explicitly:
66
+ `AGENT_PRIVATE_KEY_B64`, `AGENT_PRIVATE_KEY_PATH` (alias
67
+ `AGENTVALET_PRIVATE_KEY_PATH`), `AGENT_PRIVATE_KEY`, or `~/.agentvalet/agent.key`.
68
+ Env vars always win. When no agent id is set in the environment it falls back, in
69
+ order, to `./.env.agentvalet`, `~/.agentvalet/config.json` and
70
+ `~/.agentvalet/agent.json`, taking the agent id, owner id, proxy URL and key path
71
+ from the same file. An agent saved under a label (`~/.agentvalet/<label>/`) is
72
+ never picked automatically: set the env vars for it. To wire it up explicitly:
67
73
 
68
74
  ```typescript
69
75
  const av = new AgentValet({
@@ -184,6 +190,53 @@ It's absent when there's nothing to act on — a connection you pinned, a platfo
184
190
  with one connection, or a lookup that failed — so treat its absence as "no
185
191
  alternatives", never as "this is definitely the right account".
186
192
 
193
+ ## One identity per subagent
194
+
195
+ If your orchestrator fans work out to subagents, don't hand them your key. Mint
196
+ each one a child identity: a bearer token that is scope-attenuated, time-boxed,
197
+ independently revocable, and audited under its own agent id.
198
+
199
+ ```typescript
200
+ const child = await av.issueChild(
201
+ [{ platform: "github", scopes: ["github:issues.read"] }],
202
+ { name: "triage-worker", ttlSeconds: 600 },
203
+ );
204
+
205
+ // Hand the subagent the token and nothing else.
206
+ const sub = child.client(); // or AgentValet.fromBearer(child.bearerToken)
207
+ await sub.call({ platform: "github", endpoint: "/issues", scope: "github:issues.read" });
208
+ ```
209
+
210
+ The proxy attenuates every grant against what *you* currently hold — you cannot
211
+ delegate more than you have — and refuses the whole call if the intersection is
212
+ empty. `child.granted` is what it actually issued, which is not necessarily what
213
+ you asked for. Revoking or suspending the parent contains every child on its
214
+ next call.
215
+
216
+ Bounds that are enforced server-side, and that you should design around rather
217
+ than discover:
218
+
219
+ | | |
220
+ |---|---|
221
+ | Delegation depth | 1 — a child cannot mint children. `issueChild()` on a bearer client throws `ConfigError` locally. |
222
+ | TTL | 60–3600s, default 900. **No refresh endpoint** — a longer run must re-mint from the parent. |
223
+ | Live children | 25 per parent. |
224
+ | Grants per call | 25. |
225
+
226
+ ## Tagging a run
227
+
228
+ `sessionId` tags everything a client does, so an audit reader can group one run —
229
+ or tell a parent's calls from its children's.
230
+
231
+ ```typescript
232
+ const av = AgentValet.fromEnv({ sessionId: `run:${runId}` });
233
+ ```
234
+
235
+ It rides the signed assertion as a `session_id` claim, or `X-AV-Session` in
236
+ bearer mode, and also reads from `AGENTVALET_SESSION_ID`. **Attribution only** —
237
+ the proxy never branches an authorization decision on it, and it is not verified
238
+ to belong to the calling agent. Don't treat it as a security boundary.
239
+
187
240
  ## Self-hosting
188
241
 
189
242
  Point `proxyUrl` at your own deployment. Everything else is identical.
@@ -0,0 +1,51 @@
1
+ import type { AgentValet } from "./client.js";
2
+ /** One platform's worth of authority to hand down. Attenuated server-side
3
+ * against what the parent itself currently holds — you cannot delegate more
4
+ * than you have, and the proxy rejects the whole call if the intersection is
5
+ * empty (`no_scopes_after_attenuation`). */
6
+ export interface ChildGrant {
7
+ platform: string;
8
+ scopes: string[];
9
+ /** Pin the child to one connection when the platform has several. Omitted
10
+ * from the wire entirely when absent — the proxy's per-connection rows win
11
+ * over the platform-wide row, so a stray null would change the selection. */
12
+ connectionId?: string;
13
+ }
14
+ /** What the proxy actually granted, after attenuation. Not necessarily what
15
+ * was asked for — always the intersection with the parent's live grants. */
16
+ export interface GrantedScope {
17
+ platform: string;
18
+ scopes: string[];
19
+ require_approval: boolean;
20
+ }
21
+ /**
22
+ * A time-boxed, scope-attenuated bearer identity for a subagent.
23
+ *
24
+ * Hand `bearerToken` to the subagent and nothing else — not this client, not
25
+ * your private key. The token IS the identity: already attenuated, already
26
+ * expiring, independently revocable, and audited under its own agent id.
27
+ *
28
+ * Server-side bounds worth knowing before you design around this:
29
+ * - delegation depth is capped at 1, so a child cannot mint children;
30
+ * - the TTL is 60..3600s and there is NO refresh endpoint — a run longer
31
+ * than the TTL must re-mint from the parent;
32
+ * - a parent may hold at most 25 live children at once.
33
+ */
34
+ export declare class ChildIdentity {
35
+ readonly childAgentId: string;
36
+ readonly bearerToken: string;
37
+ /** ISO-8601. After this the token is dead and cannot be renewed. */
38
+ readonly expiresAt: string;
39
+ readonly granted: GrantedScope[];
40
+ private readonly buildClient;
41
+ constructor(childAgentId: string, bearerToken: string,
42
+ /** ISO-8601. After this the token is dead and cannot be renewed. */
43
+ expiresAt: string, granted: GrantedScope[], buildClient: (bearerToken: string) => AgentValet);
44
+ /**
45
+ * A bearer-mode client for this child. Inherits the issuing client's
46
+ * proxyUrl, fetch and timeouts — a child pointed at a different host than
47
+ * the parent that minted it would simply 401.
48
+ */
49
+ client(): AgentValet;
50
+ }
51
+ //# sourceMappingURL=child.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"child.d.ts","sourceRoot":"","sources":["../src/child.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;6CAG6C;AAC7C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;kFAE8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;6EAC6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAa;IAEtB,QAAQ,CAAC,YAAY,EAAE,MAAM;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,EAAE;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW;gBALnB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM;IAC5B,oEAAoE;IAC3D,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,YAAY,EAAE,EACf,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,UAAU;IAGnE;;;;OAIG;IACH,MAAM,IAAI,UAAU;CAGrB"}
package/dist/child.js ADDED
@@ -0,0 +1,48 @@
1
+ // packages/client/src/child.ts
2
+ //
3
+ // Child identities minted via AgentValet.issueChild().
4
+ //
5
+ // Mirrors packages/python-client/src/agentvalet/child.py, including the reason
6
+ // it is a separate module: client.ts needs ChildIdentity as a return type and
7
+ // ChildIdentity needs AgentValet for .client(). Python breaks that cycle with a
8
+ // deferred import; ESM lets us do the same with a dynamic import, but a plain
9
+ // factory injected at construction time is cheaper and keeps the type graph
10
+ // acyclic — so the client hands ChildIdentity the builder it should use.
11
+ /**
12
+ * A time-boxed, scope-attenuated bearer identity for a subagent.
13
+ *
14
+ * Hand `bearerToken` to the subagent and nothing else — not this client, not
15
+ * your private key. The token IS the identity: already attenuated, already
16
+ * expiring, independently revocable, and audited under its own agent id.
17
+ *
18
+ * Server-side bounds worth knowing before you design around this:
19
+ * - delegation depth is capped at 1, so a child cannot mint children;
20
+ * - the TTL is 60..3600s and there is NO refresh endpoint — a run longer
21
+ * than the TTL must re-mint from the parent;
22
+ * - a parent may hold at most 25 live children at once.
23
+ */
24
+ export class ChildIdentity {
25
+ childAgentId;
26
+ bearerToken;
27
+ expiresAt;
28
+ granted;
29
+ buildClient;
30
+ constructor(childAgentId, bearerToken,
31
+ /** ISO-8601. After this the token is dead and cannot be renewed. */
32
+ expiresAt, granted, buildClient) {
33
+ this.childAgentId = childAgentId;
34
+ this.bearerToken = bearerToken;
35
+ this.expiresAt = expiresAt;
36
+ this.granted = granted;
37
+ this.buildClient = buildClient;
38
+ }
39
+ /**
40
+ * A bearer-mode client for this child. Inherits the issuing client's
41
+ * proxyUrl, fetch and timeouts — a child pointed at a different host than
42
+ * the parent that minted it would simply 401.
43
+ */
44
+ client() {
45
+ return this.buildClient(this.bearerToken);
46
+ }
47
+ }
48
+ //# sourceMappingURL=child.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"child.js","sourceRoot":"","sources":["../src/child.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;AACF,uDAAuD;AACvD,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAC9E,4EAA4E;AAC5E,yEAAyE;AAyBzE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IAEb;IACA;IAEA;IACA;IACQ;IANnB,YACW,YAAoB,EACpB,WAAmB;IAC5B,oEAAoE;IAC3D,SAAiB,EACjB,OAAuB,EACf,WAAgD;QALxD,iBAAY,GAAZ,YAAY,CAAQ;QACpB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,cAAS,GAAT,SAAS,CAAQ;QACjB,YAAO,GAAP,OAAO,CAAgB;QACf,gBAAW,GAAX,WAAW,CAAqC;IAChE,CAAC;IAEJ;;;;OAIG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;CACF"}
package/dist/client.d.ts CHANGED
@@ -1,9 +1,20 @@
1
1
  import { type FetchLike } from "./http.js";
2
+ import { ChildIdentity, type ChildGrant } from "./child.js";
2
3
  export interface AgentValetOptions {
3
4
  agentId: string;
4
5
  ownerId: string;
5
6
  /** RS256 private key, PEM (PKCS#8). */
6
7
  privateKey: string;
8
+ /**
9
+ * Forensic attribution tag for everything this client does. Rides the signed
10
+ * assertion as a `session_id` claim, or the `X-AV-Session` header in bearer
11
+ * mode. Free text, `[A-Za-z0-9._:-]{1,128}`.
12
+ *
13
+ * Attribution ONLY. The proxy never branches an authorization decision on
14
+ * it, and it is not verified to belong to the calling agent — do not treat
15
+ * it as a security boundary.
16
+ */
17
+ sessionId?: string;
7
18
  /** Defaults to https://api.agentvalet.ai. */
8
19
  proxyUrl?: string;
9
20
  /** Per-request network timeout. Default 15s. */
@@ -27,6 +38,9 @@ export interface AgentValetOptions {
27
38
  endpoint: string;
28
39
  }) => void;
29
40
  }
41
+ /** Options for a bearer-mode client. It has no keypair: the token carries the
42
+ * identity, so agentId/ownerId/privateKey are neither needed nor accepted. */
43
+ export type BearerOptions = Omit<Partial<AgentValetOptions>, "privateKey">;
30
44
  export interface CallRequest {
31
45
  platform: string;
32
46
  endpoint: string;
@@ -44,19 +58,40 @@ export declare class AgentValet {
44
58
  readonly agentId: string;
45
59
  readonly ownerId: string;
46
60
  readonly proxyUrl: string;
61
+ /** Forensic tag sent with every request, or undefined if unset. */
62
+ readonly sessionId: string | undefined;
47
63
  private readonly privateKeyPem;
64
+ /** Set only in bearer mode (a child identity). Mutually exclusive with a key. */
65
+ private readonly bearerToken;
48
66
  private readonly timeoutMs;
49
67
  private readonly approvalTimeoutMs;
50
68
  private readonly approvalPollMs;
51
69
  private readonly doFetch;
52
70
  private readonly onApprovalPending?;
53
71
  private importedKey;
54
- constructor(opts: AgentValetOptions);
72
+ constructor(opts: AgentValetOptions & {
73
+ bearerToken?: string;
74
+ });
55
75
  /**
56
- * Builds a client from the environment. Works out of the box on a machine
57
- * that has run `npx @agentvalet/register`. See env.ts for the accepted names.
76
+ * Builds a client from the environment. Env vars win; when no agent id is
77
+ * set there, falls back to the identity files `npx @agentvalet/register` and
78
+ * the Python `agentvalet register` write (see identityFromDisk() in env.ts),
79
+ * signing with the key path recorded beside that identity.
58
80
  */
59
81
  static fromEnv(overrides?: Partial<AgentValetOptions>): AgentValet;
82
+ /**
83
+ * Builds a client authenticated with a pre-issued bearer token.
84
+ *
85
+ * This is how a subagent uses the token from `issueChild()`: no agentId,
86
+ * ownerId, or private key — the token itself carries the (already
87
+ * attenuated, already time-boxed) identity, and it is sent verbatim as
88
+ * `Authorization: Bearer <token>` on every call instead of being signed
89
+ * fresh per request. Everything else behaves identically.
90
+ *
91
+ * A bearer-mode client cannot call `issueChild()` — the server caps
92
+ * delegation depth at 1.
93
+ */
94
+ static fromBearer(bearerToken: string, overrides?: BearerOptions): AgentValet;
60
95
  /**
61
96
  * Calls an approved platform through the broker. Returns the upstream SaaS
62
97
  * response body, parsed.
@@ -103,7 +138,34 @@ export declare class AgentValet {
103
138
  status: "approved" | "denied" | "pending";
104
139
  requestToken: string;
105
140
  }>;
106
- /** Signs a short-lived (60s) RS256 assertion of this agent's identity. */
141
+ /**
142
+ * Mints a time-boxed, scope-attenuated bearer identity for a subagent.
143
+ *
144
+ * The proxy attenuates every grant against what THIS agent currently holds —
145
+ * you cannot hand out more than you have — and refuses outright if the
146
+ * intersection is empty (`no_scopes_after_attenuation`). Revoking or
147
+ * suspending this agent contains every child it minted on their next call.
148
+ *
149
+ * Give `bearerToken` to the subagent and nothing else: not this client, not
150
+ * your private key. Build its client with `child.client()` or
151
+ * `AgentValet.fromBearer(child.bearerToken)`.
152
+ *
153
+ * @throws ConfigError on a bearer-mode client (depth cap is 1, so this fails
154
+ * locally before any network call), or on locally-invalid grants/TTL.
155
+ * @throws ProxyError if the proxy refused — `.status` and `.body` carry the
156
+ * code (`agent_not_active`, `delegation_depth_exceeded`, the 25-live-child
157
+ * cap, `as_signing_unavailable`, ...).
158
+ */
159
+ issueChild(grants: ChildGrant[], opts?: {
160
+ name?: string;
161
+ ttlSeconds?: number;
162
+ }): Promise<ChildIdentity>;
163
+ /**
164
+ * Signs a short-lived (60s) RS256 assertion of this agent's identity.
165
+ *
166
+ * Not available in bearer mode — a child has no key to sign with; it sends
167
+ * its pre-issued token as-is on every request.
168
+ */
107
169
  signJWT(): Promise<string>;
108
170
  private authedFetch;
109
171
  private getJson;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAwBA,OAAO,EAA+D,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAcxG,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE;QACzB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,KAAK,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,GAAG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G,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7E,OAAO,CAAC;QAAE,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IA8B/E;;;;;;;;;;;;;;;;;OAiBG;IACG,UAAU,CACd,MAAM,EAAE,UAAU,EAAE,EACpB,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GAChD,OAAO,CAAC,aAAa,CAAC;IA6BzB;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;YA8BlB,WAAW;YAkCX,OAAO;CAMtB"}
package/dist/client.js CHANGED
@@ -13,7 +13,8 @@
13
13
  import { SignJWT, importPKCS8 } from "jose";
14
14
  import { AccessDeniedError, ApprovalDeniedError, ApprovalExpiredError, ApprovalTimeoutError, ConfigError, ProxyError, UpstreamError, } from "./errors.js";
15
15
  import { diagnoseNetworkError, fetchWithTimeout, sleep, tryParseJson } from "./http.js";
16
- import { DEFAULT_PROXY_URL, agentIdFromEnv, ownerIdFromEnv, privateKeyFromEnv, proxyUrlFromEnv, } from "./env.js";
16
+ import { CHILD_TTL_DEFAULT_S, buildIssueChildBody, identityFromBearer, interpretIssueChildResponse, validateSessionId, } from "./protocol.js";
17
+ import { DEFAULT_PROXY_URL, agentIdFromEnv, identityFromDisk, ownerIdFromEnv, privateKeyFromEnv, proxyUrlFromEnv, sessionIdFromEnv, } from "./env.js";
17
18
  /** Matches the mcp-server's budget: under Claude Desktop's 60s tool timeout. */
18
19
  const DEFAULT_APPROVAL_TIMEOUT_MS = 50_000;
19
20
  const DEFAULT_APPROVAL_POLL_MS = 2_000;
@@ -22,7 +23,11 @@ export class AgentValet {
22
23
  agentId;
23
24
  ownerId;
24
25
  proxyUrl;
26
+ /** Forensic tag sent with every request, or undefined if unset. */
27
+ sessionId;
25
28
  privateKeyPem;
29
+ /** Set only in bearer mode (a child identity). Mutually exclusive with a key. */
30
+ bearerToken;
26
31
  timeoutMs;
27
32
  approvalTimeoutMs;
28
33
  approvalPollMs;
@@ -30,15 +35,21 @@ export class AgentValet {
30
35
  onApprovalPending;
31
36
  importedKey = null;
32
37
  constructor(opts) {
33
- if (!opts.agentId)
34
- throw new ConfigError("agentId is required");
35
- if (!opts.ownerId)
36
- throw new ConfigError("ownerId is required");
37
- if (!opts.privateKey)
38
- throw new ConfigError("privateKey is required");
38
+ // Bearer mode skips the keypair checks — the token IS the identity, and
39
+ // ids are recovered from its payload rather than supplied by the caller.
40
+ if (!opts.bearerToken) {
41
+ if (!opts.agentId)
42
+ throw new ConfigError("agentId is required");
43
+ if (!opts.ownerId)
44
+ throw new ConfigError("ownerId is required");
45
+ if (!opts.privateKey)
46
+ throw new ConfigError("privateKey is required");
47
+ }
48
+ this.bearerToken = opts.bearerToken ?? null;
39
49
  this.agentId = opts.agentId;
40
50
  this.ownerId = opts.ownerId;
41
51
  this.privateKeyPem = opts.privateKey;
52
+ this.sessionId = validateSessionId(opts.sessionId);
42
53
  this.proxyUrl = (opts.proxyUrl ?? DEFAULT_PROXY_URL).replace(/\/$/, "");
43
54
  this.timeoutMs = opts.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
44
55
  this.approvalTimeoutMs = opts.approvalTimeoutMs ?? DEFAULT_APPROVAL_TIMEOUT_MS;
@@ -47,22 +58,56 @@ export class AgentValet {
47
58
  this.onApprovalPending = opts.onApprovalPending;
48
59
  }
49
60
  /**
50
- * Builds a client from the environment. Works out of the box on a machine
51
- * that has run `npx @agentvalet/register`. See env.ts for the accepted names.
61
+ * Builds a client from the environment. Env vars win; when no agent id is
62
+ * set there, falls back to the identity files `npx @agentvalet/register` and
63
+ * the Python `agentvalet register` write (see identityFromDisk() in env.ts),
64
+ * signing with the key path recorded beside that identity.
52
65
  */
53
66
  static fromEnv(overrides = {}) {
54
- const agentId = overrides.agentId ?? agentIdFromEnv();
55
- const ownerId = overrides.ownerId ?? ownerIdFromEnv();
67
+ const envAgentId = overrides.agentId ?? agentIdFromEnv();
68
+ const disk = envAgentId ? null : identityFromDisk();
69
+ const agentId = envAgentId ?? disk?.agentId ?? null;
70
+ const ownerId = overrides.ownerId ?? ownerIdFromEnv() ?? disk?.ownerId ?? null;
56
71
  if (!agentId || !ownerId) {
57
- throw new ConfigError("AgentValet identity not found in the environment. Set AGENTVALET_AGENT_ID and " +
58
- "AGENTVALET_OWNER_ID (or AGENT_ID / OWNER_ID), or run `npx @agentvalet/register`.");
72
+ throw new ConfigError("AgentValet identity not found. Set AGENTVALET_AGENT_ID and AGENTVALET_OWNER_ID " +
73
+ "(or AGENT_ID / OWNER_ID), or run `npx @agentvalet/register` to write " +
74
+ "~/.agentvalet/config.json." +
75
+ (disk ? ` (${disk.source} names an agent but no owner id.)` : ""));
59
76
  }
60
77
  return new AgentValet({
61
78
  ...overrides,
62
79
  agentId,
63
80
  ownerId,
64
- privateKey: overrides.privateKey ?? privateKeyFromEnv(),
65
- proxyUrl: overrides.proxyUrl ?? proxyUrlFromEnv(),
81
+ privateKey: overrides.privateKey ?? privateKeyFromEnv(disk?.keyPath),
82
+ proxyUrl: overrides.proxyUrl ?? proxyUrlFromEnv(disk?.proxyUrl),
83
+ sessionId: overrides.sessionId ?? sessionIdFromEnv() ?? undefined,
84
+ });
85
+ }
86
+ /**
87
+ * Builds a client authenticated with a pre-issued bearer token.
88
+ *
89
+ * This is how a subagent uses the token from `issueChild()`: no agentId,
90
+ * ownerId, or private key — the token itself carries the (already
91
+ * attenuated, already time-boxed) identity, and it is sent verbatim as
92
+ * `Authorization: Bearer <token>` on every call instead of being signed
93
+ * fresh per request. Everything else behaves identically.
94
+ *
95
+ * A bearer-mode client cannot call `issueChild()` — the server caps
96
+ * delegation depth at 1.
97
+ */
98
+ static fromBearer(bearerToken, overrides = {}) {
99
+ if (!bearerToken)
100
+ throw new ConfigError("bearerToken is required");
101
+ // The token already names its own subject. Recover it so anything that has
102
+ // to identify the caller (evaluate(), logging) works in bearer mode too;
103
+ // an explicit override always wins.
104
+ const derived = identityFromBearer(bearerToken);
105
+ return new AgentValet({
106
+ ...overrides,
107
+ bearerToken,
108
+ agentId: overrides.agentId ?? derived.agentId ?? "",
109
+ ownerId: overrides.ownerId ?? derived.ownerId ?? "",
110
+ privateKey: "",
66
111
  });
67
112
  }
68
113
  // ---- core ---------------------------------------------------------------
@@ -222,9 +267,58 @@ export class AgentValet {
222
267
  }
223
268
  return { status: "pending", requestToken: token };
224
269
  }
270
+ // ---- delegation ---------------------------------------------------------
271
+ /**
272
+ * Mints a time-boxed, scope-attenuated bearer identity for a subagent.
273
+ *
274
+ * The proxy attenuates every grant against what THIS agent currently holds —
275
+ * you cannot hand out more than you have — and refuses outright if the
276
+ * intersection is empty (`no_scopes_after_attenuation`). Revoking or
277
+ * suspending this agent contains every child it minted on their next call.
278
+ *
279
+ * Give `bearerToken` to the subagent and nothing else: not this client, not
280
+ * your private key. Build its client with `child.client()` or
281
+ * `AgentValet.fromBearer(child.bearerToken)`.
282
+ *
283
+ * @throws ConfigError on a bearer-mode client (depth cap is 1, so this fails
284
+ * locally before any network call), or on locally-invalid grants/TTL.
285
+ * @throws ProxyError if the proxy refused — `.status` and `.body` carry the
286
+ * code (`agent_not_active`, `delegation_depth_exceeded`, the 25-live-child
287
+ * cap, `as_signing_unavailable`, ...).
288
+ */
289
+ async issueChild(grants, opts = {}) {
290
+ if (this.bearerToken !== null) {
291
+ throw new ConfigError("issueChild cannot be called on a bearer-mode client — the server enforces delegation " +
292
+ "depth 1, so a child identity cannot itself mint children. Call issueChild from the " +
293
+ "keypair-authenticated parent agent instead.");
294
+ }
295
+ const body = buildIssueChildBody(grants, opts.name, opts.ttlSeconds ?? CHILD_TTL_DEFAULT_S);
296
+ const res = await this.authedFetch("/v1/agents/children", {
297
+ method: "POST",
298
+ body: JSON.stringify(body),
299
+ });
300
+ return interpretIssueChildResponse(res.status, await res.text(), (token) => AgentValet.fromBearer(token, {
301
+ proxyUrl: this.proxyUrl,
302
+ timeoutMs: this.timeoutMs,
303
+ approvalTimeoutMs: this.approvalTimeoutMs,
304
+ approvalPollMs: this.approvalPollMs,
305
+ fetch: this.doFetch,
306
+ onApprovalPending: this.onApprovalPending,
307
+ sessionId: this.sessionId,
308
+ }));
309
+ }
225
310
  // ---- transport ----------------------------------------------------------
226
- /** Signs a short-lived (60s) RS256 assertion of this agent's identity. */
311
+ /**
312
+ * Signs a short-lived (60s) RS256 assertion of this agent's identity.
313
+ *
314
+ * Not available in bearer mode — a child has no key to sign with; it sends
315
+ * its pre-issued token as-is on every request.
316
+ */
227
317
  async signJWT() {
318
+ if (this.bearerToken !== null) {
319
+ throw new ConfigError("signJWT() is not available on a bearer-mode client — it authenticates with a " +
320
+ "pre-issued bearer token, not a signed assertion.");
321
+ }
228
322
  if (!this.importedKey) {
229
323
  try {
230
324
  this.importedKey = await importPKCS8(this.privateKeyPem, "RS256");
@@ -233,7 +327,14 @@ export class AgentValet {
233
327
  throw new ConfigError(`Private key is not a valid PKCS#8 RS256 PEM: ${err instanceof Error ? err.message : err}`);
234
328
  }
235
329
  }
236
- return new SignJWT({ agent_id: this.agentId, owner_id: this.ownerId })
330
+ return new SignJWT({
331
+ agent_id: this.agentId,
332
+ owner_id: this.ownerId,
333
+ // Omitted entirely when unset. A present-but-invalid claim resolves to
334
+ // null server-side WITHOUT falling back to the header, so sending an
335
+ // empty string here would silently cost the attribution.
336
+ ...(this.sessionId ? { session_id: this.sessionId } : {}),
337
+ })
237
338
  .setProtectedHeader({ alg: "RS256" })
238
339
  .setIssuedAt()
239
340
  .setExpirationTime("60s")
@@ -242,11 +343,18 @@ export class AgentValet {
242
343
  async authedFetch(path, init) {
243
344
  const url = `${this.proxyUrl}${path}`;
244
345
  const once = async () => {
245
- const token = await this.signJWT();
346
+ // Bearer mode has nothing to re-sign: the child token is fixed for its
347
+ // whole 60..3600s life. Its session tag rides a header instead of a claim.
348
+ const token = this.bearerToken ?? (await this.signJWT());
246
349
  try {
247
350
  return await fetchWithTimeout(this.doFetch, url, {
248
351
  ...init,
249
- headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", ...init.headers },
352
+ headers: {
353
+ Authorization: `Bearer ${token}`,
354
+ "Content-Type": "application/json",
355
+ ...(this.bearerToken && this.sessionId ? { "X-AV-Session": this.sessionId } : {}),
356
+ ...init.headers,
357
+ },
250
358
  }, this.timeoutMs);
251
359
  }
252
360
  catch (err) {
@@ -255,8 +363,11 @@ export class AgentValet {
255
363
  };
256
364
  const res = await once();
257
365
  // Retry once on 401 — the JWT may have been minted either side of a clock
258
- // skew boundary. Same one-shot retry the mcp-server does.
259
- return res.status === 401 ? once() : res;
366
+ // skew boundary. Same one-shot retry the mcp-server does. Pointless in
367
+ // bearer mode (the token is fixed), so don't burn a second round trip.
368
+ if (res.status !== 401 || this.bearerToken !== null)
369
+ return res;
370
+ return once();
260
371
  }
261
372
  async getJson(path) {
262
373
  const res = await this.authedFetch(path, { method: "GET" });
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,EAAE;AACF,6EAA6E;AAC7E,wEAAwE;AACxE,yEAAyE;AACzE,2EAA2E;AAC3E,sEAAsE;AACtE,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAAwE;AACxE,8BAA8B;AAE9B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAE5C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,KAAK,EAAE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CAAC,WAAW,KAAK,IAAI;YAAE,OAAO,GAAG,CAAC;QAChE,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,OAAO,CAAI,IAAY;QACnC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACpD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAM,CAAC;IAC3C,CAAC;CACF"}
package/dist/env.d.ts CHANGED
@@ -1,16 +1,46 @@
1
1
  export declare const DEFAULT_PROXY_URL = "https://api.agentvalet.ai";
2
2
  export declare function agentIdFromEnv(): string | null;
3
3
  export declare function ownerIdFromEnv(): string | null;
4
- export declare function proxyUrlFromEnv(): string;
4
+ /** Optional forensic attribution tag — AGENTVALET_SESSION_ID / SESSION_ID.
5
+ * Matches the Python client, so a mixed-language fleet tags one run alike. */
6
+ export declare function sessionIdFromEnv(): string | null;
7
+ /** AGENTVALET_API_URL is the name `.env.agentvalet` uses; accepted as an alias.
8
+ * `fallback` (e.g. from an identity file) is used only when no env var is set. */
9
+ export declare function proxyUrlFromEnv(fallback?: string | null): string;
5
10
  /**
6
11
  * Resolves the RS256 private key PEM, in precedence order:
7
12
  * 1. AGENT_PRIVATE_KEY_B64 — base64-encoded PEM (12-factor / container safe)
8
- * 2. AGENT_PRIVATE_KEY_PATH — path to a PEM file
13
+ * 2. AGENT_PRIVATE_KEY_PATH — path to a PEM file (AGENTVALET_PRIVATE_KEY_PATH,
14
+ * the name `.env.agentvalet` uses, is an alias)
9
15
  * 3. AGENT_PRIVATE_KEY — raw multi-line PEM, or \n-escaped single line
10
- * 4. ~/.agentvalet/agent.key — written by `npx @agentvalet/register`
16
+ * 4. `fallbackPath` — the key path recorded beside an on-disk identity
17
+ * 5. ~/.agentvalet/agent.key — written by `npx @agentvalet/register`
11
18
  *
12
19
  * Same order and same formats as the mcp-server's pem.ts, so a dev who already
13
20
  * has the MCP server working can construct the SDK with no new setup.
14
21
  */
15
- export declare function privateKeyFromEnv(): string;
22
+ export declare function privateKeyFromEnv(fallbackPath?: string | null): string;
23
+ export interface DiskIdentity {
24
+ agentId: string;
25
+ ownerId: string | null;
26
+ /** Key file written beside this identity; null = use ~/.agentvalet/agent.key. */
27
+ keyPath: string | null;
28
+ proxyUrl: string | null;
29
+ /** File the identity came from, for error messages. */
30
+ source: string;
31
+ }
32
+ /**
33
+ * The identity the registration flows leave on disk. First hit wins:
34
+ * 1. <cwd>/.env.agentvalet written by `npx @agentvalet/register` (project-level)
35
+ * 2. ~/.agentvalet/config.json written by the Node CLI and the Python
36
+ * `agentvalet register`; the most recent registration
37
+ * 3. ~/.agentvalet/agent.json written by `agentvalet-register claim` (unlabelled)
38
+ * Each source yields an agent id together with the key path written beside it,
39
+ * never mixed with another source's. Labelled agents (~/.agentvalet/<label>/)
40
+ * are not guessed at: point AGENT_PRIVATE_KEY_PATH etc. at them explicitly.
41
+ */
42
+ export declare function identityFromDisk(opts?: {
43
+ cwd?: string;
44
+ home?: string;
45
+ }): DiskIdentity | null;
16
46
  //# sourceMappingURL=env.d.ts.map
package/dist/env.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAmB7D,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAiC1C"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAmB7D,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAE9C;AAED;+EAC+E;AAC/E,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEhD;AAED;mFACmF;AACnF,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAIhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CA8CtE;AAUD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,iFAAiF;IACjF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;CAChB;AAqCD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACzC,YAAY,GAAG,IAAI,CAoDrB"}
package/dist/env.js CHANGED
@@ -5,9 +5,12 @@
5
5
  // Accepts BOTH naming conventions already in the wild: the bare names the
6
6
  // mcp-server/MCPB write (AGENT_ID, OWNER_ID, PROXY_URL, AGENT_PRIVATE_KEY*)
7
7
  // and AGENTVALET_-prefixed aliases, which is what the docs and the
8
- // credentials-not-configured message tell people to set. A machine that has
9
- // been through `npx @agentvalet/register` already satisfies the bare set, so
10
- // fromEnv() works with zero extra config there.
8
+ // credentials-not-configured message tell people to set.
9
+ //
10
+ // Env vars always win. When no agent id is set in the environment, fromEnv()
11
+ // falls back to the identity files the registration flows write (see
12
+ // identityFromDisk()), so a machine that has run `npx @agentvalet/register`
13
+ // or the Python `agentvalet register` works with zero extra config.
11
14
  import { readFileSync } from "node:fs";
12
15
  import { homedir } from "node:os";
13
16
  import { join } from "node:path";
@@ -37,24 +40,33 @@ export function agentIdFromEnv() {
37
40
  export function ownerIdFromEnv() {
38
41
  return readEither("OWNER_ID");
39
42
  }
40
- export function proxyUrlFromEnv() {
41
- return (readEither("PROXY_URL") ?? DEFAULT_PROXY_URL).replace(/\/$/, "");
43
+ /** Optional forensic attribution tag — AGENTVALET_SESSION_ID / SESSION_ID.
44
+ * Matches the Python client, so a mixed-language fleet tags one run alike. */
45
+ export function sessionIdFromEnv() {
46
+ return readEither("SESSION_ID");
47
+ }
48
+ /** AGENTVALET_API_URL is the name `.env.agentvalet` uses; accepted as an alias.
49
+ * `fallback` (e.g. from an identity file) is used only when no env var is set. */
50
+ export function proxyUrlFromEnv(fallback) {
51
+ return (readEither("PROXY_URL") ?? readEnv("AGENTVALET_API_URL") ?? fallback ?? DEFAULT_PROXY_URL).replace(/\/$/, "");
42
52
  }
43
53
  /**
44
54
  * Resolves the RS256 private key PEM, in precedence order:
45
55
  * 1. AGENT_PRIVATE_KEY_B64 — base64-encoded PEM (12-factor / container safe)
46
- * 2. AGENT_PRIVATE_KEY_PATH — path to a PEM file
56
+ * 2. AGENT_PRIVATE_KEY_PATH — path to a PEM file (AGENTVALET_PRIVATE_KEY_PATH,
57
+ * the name `.env.agentvalet` uses, is an alias)
47
58
  * 3. AGENT_PRIVATE_KEY — raw multi-line PEM, or \n-escaped single line
48
- * 4. ~/.agentvalet/agent.key — written by `npx @agentvalet/register`
59
+ * 4. `fallbackPath` — the key path recorded beside an on-disk identity
60
+ * 5. ~/.agentvalet/agent.key — written by `npx @agentvalet/register`
49
61
  *
50
62
  * Same order and same formats as the mcp-server's pem.ts, so a dev who already
51
63
  * has the MCP server working can construct the SDK with no new setup.
52
64
  */
53
- export function privateKeyFromEnv() {
65
+ export function privateKeyFromEnv(fallbackPath) {
54
66
  const b64 = readEither("AGENT_PRIVATE_KEY_B64");
55
67
  if (b64)
56
68
  return Buffer.from(b64, "base64").toString("utf-8").trim();
57
- const path = readEither("AGENT_PRIVATE_KEY_PATH");
69
+ const path = readEither("AGENT_PRIVATE_KEY_PATH") ?? readEnv("AGENTVALET_PRIVATE_KEY_PATH");
58
70
  if (path) {
59
71
  try {
60
72
  return readFileSync(path, "utf-8").trim();
@@ -73,6 +85,17 @@ export function privateKeyFromEnv() {
73
85
  }
74
86
  return unescaped;
75
87
  }
88
+ if (fallbackPath) {
89
+ // Paired with the on-disk agent id. Failing loudly beats silently signing
90
+ // with the default key, which may belong to a different agent.
91
+ try {
92
+ return readFileSync(fallbackPath, "utf-8").trim();
93
+ }
94
+ catch (err) {
95
+ throw new ConfigError(`Cannot read the agent key at ${fallbackPath} (named by your AgentValet identity file): ` +
96
+ `${err instanceof Error ? err.message : err}`);
97
+ }
98
+ }
76
99
  const diskKey = readDiskKey();
77
100
  if (diskKey)
78
101
  return diskKey;
@@ -87,4 +110,99 @@ function readDiskKey() {
87
110
  return null;
88
111
  }
89
112
  }
113
+ function readText(path) {
114
+ try {
115
+ return readFileSync(path, "utf-8");
116
+ }
117
+ catch {
118
+ return null;
119
+ }
120
+ }
121
+ function readJson(path) {
122
+ const text = readText(path);
123
+ if (text === null)
124
+ return null;
125
+ try {
126
+ const v = JSON.parse(text);
127
+ return v && typeof v === "object" ? v : null;
128
+ }
129
+ catch {
130
+ return null;
131
+ }
132
+ }
133
+ function str(v) {
134
+ return typeof v === "string" && v.trim() !== "" ? v.trim() : null;
135
+ }
136
+ function parseDotEnv(text) {
137
+ const out = {};
138
+ for (const line of text.split(/\r?\n/)) {
139
+ const t = line.trim();
140
+ if (!t || t.startsWith("#"))
141
+ continue;
142
+ const eq = t.indexOf("=");
143
+ if (eq === -1)
144
+ continue;
145
+ out[t.slice(0, eq).trim()] = t.slice(eq + 1).trim().replace(/^(["'])(.*)\1$/, "$2");
146
+ }
147
+ return out;
148
+ }
149
+ /**
150
+ * The identity the registration flows leave on disk. First hit wins:
151
+ * 1. <cwd>/.env.agentvalet written by `npx @agentvalet/register` (project-level)
152
+ * 2. ~/.agentvalet/config.json written by the Node CLI and the Python
153
+ * `agentvalet register`; the most recent registration
154
+ * 3. ~/.agentvalet/agent.json written by `agentvalet-register claim` (unlabelled)
155
+ * Each source yields an agent id together with the key path written beside it,
156
+ * never mixed with another source's. Labelled agents (~/.agentvalet/<label>/)
157
+ * are not guessed at: point AGENT_PRIVATE_KEY_PATH etc. at them explicitly.
158
+ */
159
+ export function identityFromDisk(opts = {}) {
160
+ const cwd = opts.cwd ?? process.cwd();
161
+ const avDir = join(opts.home ?? homedir(), ".agentvalet");
162
+ const envFile = join(cwd, ".env.agentvalet");
163
+ const envText = readText(envFile);
164
+ if (envText !== null) {
165
+ const v = parseDotEnv(envText);
166
+ const agentId = str(v["AGENTVALET_AGENT_ID"]);
167
+ if (agentId) {
168
+ return {
169
+ agentId,
170
+ ownerId: str(v["AGENTVALET_OWNER_ID"]),
171
+ keyPath: str(v["AGENTVALET_PRIVATE_KEY_PATH"]),
172
+ proxyUrl: str(v["AGENTVALET_API_URL"]),
173
+ source: envFile,
174
+ };
175
+ }
176
+ }
177
+ const configFile = join(avDir, "config.json");
178
+ const cfg = readJson(configFile);
179
+ if (cfg) {
180
+ // Every register flow rewrites lastAgentId/lastKeyPath as a pair; the
181
+ // Node `onboard` flow leaves agentId/keyPath stale, so the "last" pair wins.
182
+ const last = str(cfg.lastAgentId);
183
+ const agentId = last ?? str(cfg.agentId);
184
+ if (agentId) {
185
+ return {
186
+ agentId,
187
+ ownerId: str(cfg.ownerId),
188
+ keyPath: last ? str(cfg.lastKeyPath) : str(cfg.keyPath),
189
+ proxyUrl: str(cfg.apiUrl) ?? str(cfg.proxyUrl),
190
+ source: configFile,
191
+ };
192
+ }
193
+ }
194
+ const agentFile = join(avDir, "agent.json");
195
+ const ident = readJson(agentFile);
196
+ const claimedId = ident ? str(ident.agent_id) : null;
197
+ if (ident && claimedId) {
198
+ return {
199
+ agentId: claimedId,
200
+ ownerId: str(ident.owner_id),
201
+ keyPath: join(avDir, "agent.key"),
202
+ proxyUrl: str(ident.proxy_url),
203
+ source: agentFile,
204
+ };
205
+ }
206
+ return null;
207
+ }
90
208
  //# sourceMappingURL=env.js.map
package/dist/env.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,EAAE;AACF,mDAAmD;AACnD,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,mEAAmE;AACnE,4EAA4E;AAC5E,6EAA6E;AAC7E,gDAAgD;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,2BAA2B,CAAC;AAE7D,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACjC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACnB,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC1B,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACvD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,2EAA2E;AAC3E,S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,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC;YAC9B,MAAM,EAAE,SAAS;SAClB,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  export { AgentValet } from "./client.js";
2
- export type { AgentValetOptions, CallRequest } from "./client.js";
2
+ export type { AgentValetOptions, BearerOptions, CallRequest } from "./client.js";
3
+ export { ChildIdentity } from "./child.js";
4
+ export type { ChildGrant, GrantedScope } from "./child.js";
5
+ export { CHILD_MAX_GRANTS, CHILD_TTL_DEFAULT_S, CHILD_TTL_MAX_S, CHILD_TTL_MIN_S, } from "./protocol.js";
3
6
  export { AgentValetError, AccessDeniedError, ApprovalDeniedError, ApprovalExpiredError, ApprovalTimeoutError, ConfigError, NetworkError, ProxyError, UpstreamError, } from "./errors.js";
4
7
  export { DEFAULT_PROXY_URL } from "./env.js";
5
8
  export type { FetchLike } from "./http.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGjF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -6,6 +6,9 @@
6
6
  // @agentvalet/mcp-server instead and call use_platform. This package is for
7
7
  // agents that aren't MCP: LangChain tools, cron jobs, plain Node services.
8
8
  export { AgentValet } from "./client.js";
9
+ // Delegation — mint a scope-attenuated, time-boxed identity per subagent.
10
+ export { ChildIdentity } from "./child.js";
11
+ export { CHILD_MAX_GRANTS, CHILD_TTL_DEFAULT_S, CHILD_TTL_MAX_S, CHILD_TTL_MIN_S, } from "./protocol.js";
9
12
  export { AgentValetError, AccessDeniedError, ApprovalDeniedError, ApprovalExpiredError, ApprovalTimeoutError, ConfigError, NetworkError, ProxyError, UpstreamError, } from "./errors.js";
10
13
  export { DEFAULT_PROXY_URL } from "./env.js";
11
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;AACF,oEAAoE;AACpE,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,2EAA2E;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;AACF,oEAAoE;AACpE,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,2EAA2E;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,0EAA0E;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { ChildIdentity, type ChildGrant } from "./child.js";
2
+ import type { AgentValet } from "./client.js";
3
+ /** The proxy's own bound (apps/proxy/src/routes/agent-children.ts). Checked
4
+ * client-side too so a typo costs a local throw, not a round trip and a 400. */
5
+ export declare const CHILD_TTL_MIN_S = 60;
6
+ export declare const CHILD_TTL_MAX_S = 3600;
7
+ export declare const CHILD_TTL_DEFAULT_S = 900;
8
+ /** Each grant costs the proxy a permissions query; it rejects >25. */
9
+ export declare const CHILD_MAX_GRANTS = 25;
10
+ /**
11
+ * Rejects an out-of-charset session id before it ever reaches the wire.
12
+ *
13
+ * This has to fail loud. The proxy resolves the session as
14
+ * `jwtSessionId ?? header` — a claim that is PRESENT but invalid resolves to
15
+ * null and does NOT fall back to a valid header, so a malformed id silently
16
+ * costs you the attribution you thought you had.
17
+ */
18
+ export declare function validateSessionId(sessionId: string | undefined): string | undefined;
19
+ export interface IssueChildBody {
20
+ ttl_seconds: number;
21
+ grants: Array<{
22
+ platform: string;
23
+ scopes: string[];
24
+ connection_id?: string;
25
+ }>;
26
+ name?: string;
27
+ }
28
+ /** Wire body for POST /v1/agents/children. Optional fields are omitted rather
29
+ * than sent as null — the route distinguishes absent from null. */
30
+ export declare function buildIssueChildBody(grants: ChildGrant[], name: string | undefined, ttlSeconds: number): IssueChildBody;
31
+ /**
32
+ * Turns a /v1/agents/children reply into a ChildIdentity.
33
+ *
34
+ * The route's non-2xx bodies (`no_scopes_after_attenuation`, `agent_not_active`,
35
+ * `delegation_depth_exceeded`, `as_signing_unavailable`, the child cap) describe
36
+ * an issuance outcome, not the grant-check/owner-decision outcomes the specific
37
+ * error types model. There is nothing endpoint-specific to attach, so this
38
+ * reuses ProxyError — `.status` and `.body` carry the code to branch on.
39
+ */
40
+ export declare function interpretIssueChildResponse(status: number, text: string, buildClient: (bearerToken: string) => AgentValet): ChildIdentity;
41
+ /**
42
+ * Reads the agent/owner id out of a bearer token's payload.
43
+ *
44
+ * A child bearer is a JWT carrying its own agent_id (and sub, and owner_id).
45
+ * Without this the client has no idea who it is, which breaks anything that
46
+ * has to name the subject — evaluate() would send an empty subject.id and the
47
+ * proxy answers 400.
48
+ *
49
+ * **This is not a security check.** The signature is not verified and must not
50
+ * be trusted; the server is the sole authority on whether a token is valid.
51
+ * Anything unparseable yields {} rather than throwing: failing locally would
52
+ * replace a clear 401 from the server with a confusing client-side crash.
53
+ */
54
+ export declare function identityFromBearer(token: string): {
55
+ agentId?: string;
56
+ ownerId?: string;
57
+ };
58
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAqB,MAAM,YAAY,CAAC;AAC/E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C;iFACiF;AACjF,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,eAAe,OAAO,CAAC;AACpC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,KAAK,CAAC;AASnC;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQnF;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;oEACoE;AACpE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAAE,EACpB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,UAAU,EAAE,MAAM,GACjB,cAAc,CA0BhB;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,UAAU,GAC/C,aAAa,CAgBf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAkBxF"}
@@ -0,0 +1,121 @@
1
+ // packages/client/src/protocol.ts
2
+ //
3
+ // Pure protocol logic — no I/O. What we send, and what a reply means.
4
+ //
5
+ // Mirrors packages/python-client/src/agentvalet/_protocol.py. Keeping the
6
+ // decisions here (rather than inline in client.ts) is what makes the two SDKs
7
+ // auditable against each other: if a branch exists in one and not the other,
8
+ // this is the file where the difference shows up.
9
+ import { ChildIdentity } from "./child.js";
10
+ import { ConfigError, ProxyError } from "./errors.js";
11
+ import { tryParseJson } from "./http.js";
12
+ /** The proxy's own bound (apps/proxy/src/routes/agent-children.ts). Checked
13
+ * client-side too so a typo costs a local throw, not a round trip and a 400. */
14
+ export const CHILD_TTL_MIN_S = 60;
15
+ export const CHILD_TTL_MAX_S = 3600;
16
+ export const CHILD_TTL_DEFAULT_S = 900;
17
+ /** Each grant costs the proxy a permissions query; it rejects >25. */
18
+ export const CHILD_MAX_GRANTS = 25;
19
+ /**
20
+ * Matches the Python client. Deliberately loose (dots, colons, underscores,
21
+ * hyphens) so it accepts both a bare UUID and a namespaced trace id like
22
+ * `run:2026-08-21:abcd`.
23
+ */
24
+ const SESSION_ID_RE = /^[A-Za-z0-9._:-]{1,128}$/;
25
+ /**
26
+ * Rejects an out-of-charset session id before it ever reaches the wire.
27
+ *
28
+ * This has to fail loud. The proxy resolves the session as
29
+ * `jwtSessionId ?? header` — a claim that is PRESENT but invalid resolves to
30
+ * null and does NOT fall back to a valid header, so a malformed id silently
31
+ * costs you the attribution you thought you had.
32
+ */
33
+ export function validateSessionId(sessionId) {
34
+ if (sessionId === undefined)
35
+ return undefined;
36
+ if (!SESSION_ID_RE.test(sessionId)) {
37
+ throw new ConfigError(`sessionId ${JSON.stringify(sessionId)} is invalid — must match [A-Za-z0-9._:-]{1,128}.`);
38
+ }
39
+ return sessionId;
40
+ }
41
+ /** Wire body for POST /v1/agents/children. Optional fields are omitted rather
42
+ * than sent as null — the route distinguishes absent from null. */
43
+ export function buildIssueChildBody(grants, name, ttlSeconds) {
44
+ if (!Array.isArray(grants) || grants.length === 0) {
45
+ throw new ConfigError("issueChild requires at least one grant.");
46
+ }
47
+ if (grants.length > CHILD_MAX_GRANTS) {
48
+ throw new ConfigError(`issueChild accepts at most ${CHILD_MAX_GRANTS} grants (got ${grants.length}).`);
49
+ }
50
+ if (!Number.isInteger(ttlSeconds) || ttlSeconds < CHILD_TTL_MIN_S || ttlSeconds > CHILD_TTL_MAX_S) {
51
+ throw new ConfigError(`ttlSeconds must be an integer ${CHILD_TTL_MIN_S}..${CHILD_TTL_MAX_S} (got ${ttlSeconds}). ` +
52
+ "There is no refresh endpoint — a longer run must re-mint from the parent.");
53
+ }
54
+ const body = {
55
+ ttl_seconds: ttlSeconds,
56
+ grants: grants.map((g) => ({
57
+ platform: g.platform,
58
+ scopes: g.scopes,
59
+ ...(g.connectionId ? { connection_id: g.connectionId } : {}),
60
+ })),
61
+ };
62
+ if (name)
63
+ body.name = name;
64
+ return body;
65
+ }
66
+ /**
67
+ * Turns a /v1/agents/children reply into a ChildIdentity.
68
+ *
69
+ * The route's non-2xx bodies (`no_scopes_after_attenuation`, `agent_not_active`,
70
+ * `delegation_depth_exceeded`, `as_signing_unavailable`, the child cap) describe
71
+ * an issuance outcome, not the grant-check/owner-decision outcomes the specific
72
+ * error types model. There is nothing endpoint-specific to attach, so this
73
+ * reuses ProxyError — `.status` and `.body` carry the code to branch on.
74
+ */
75
+ export function interpretIssueChildResponse(status, text, buildClient) {
76
+ if (status < 200 || status >= 300)
77
+ throw new ProxyError(status, text);
78
+ const payload = tryParseJson(text);
79
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
80
+ throw new ProxyError(status, text);
81
+ }
82
+ const p = payload;
83
+ return new ChildIdentity(String(p.child_agent_id ?? ""), String(p.bearer_token ?? ""), String(p.expires_at ?? ""), Array.isArray(p.granted) ? p.granted : [], buildClient);
84
+ }
85
+ /**
86
+ * Reads the agent/owner id out of a bearer token's payload.
87
+ *
88
+ * A child bearer is a JWT carrying its own agent_id (and sub, and owner_id).
89
+ * Without this the client has no idea who it is, which breaks anything that
90
+ * has to name the subject — evaluate() would send an empty subject.id and the
91
+ * proxy answers 400.
92
+ *
93
+ * **This is not a security check.** The signature is not verified and must not
94
+ * be trusted; the server is the sole authority on whether a token is valid.
95
+ * Anything unparseable yields {} rather than throwing: failing locally would
96
+ * replace a clear 401 from the server with a confusing client-side crash.
97
+ */
98
+ export function identityFromBearer(token) {
99
+ let claims;
100
+ try {
101
+ const parts = token.split(".");
102
+ if (parts.length !== 3)
103
+ return {};
104
+ const decoded = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf-8"));
105
+ if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded))
106
+ return {};
107
+ claims = decoded;
108
+ }
109
+ catch {
110
+ return {};
111
+ }
112
+ const out = {};
113
+ const agentId = claims.agent_id ?? claims.av_agent_id ?? claims.sub;
114
+ const ownerId = claims.owner_id ?? claims.av_owner_id;
115
+ if (typeof agentId === "string" && agentId)
116
+ out.agentId = agentId;
117
+ if (typeof ownerId === "string" && ownerId)
118
+ out.ownerId = ownerId;
119
+ return out;
120
+ }
121
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,EAAE;AACF,sEAAsE;AACtE,EAAE;AACF,0EAA0E;AAC1E,8EAA8E;AAC9E,6EAA6E;AAC7E,kDAAkD;AAElD,OAAO,EAAE,aAAa,EAAsC,MAAM,YAAY,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC;iFACiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC;;;;GAIG;AACH,MAAM,aAAa,GAAG,0BAA0B,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAA6B;IAC7D,IAAI,SAAS,KAA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AAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACjF,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,OAAO,EAAE,CAAC;QACzF,MAAM,GAAG,OAAkC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAA2C,EAAE,CAAC;IACvD,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,GAAG,CAAC;IACpE,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,WAAW,CAAC;IACtD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO;QAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IAClE,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO;QAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IAClE,OAAO,GAAG,CAAC;AACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/client",
3
- "version": "0.1.2",
3
+ "version": "0.2.1",
4
4
  "description": "AgentValet client SDK \u2014 call approved SaaS platforms from any Node agent. Signs the agent JWT, brokers through the AgentValet proxy, and waits out owner approvals.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",