@getstackrun/sdk 3.0.0 → 4.4.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 (247) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +366 -22
  3. package/dist/agent-auth.js +5 -6
  4. package/dist/agent-auth.js.map +1 -1
  5. package/dist/browser-bootstrap.js +2 -2
  6. package/dist/browser-bootstrap.js.map +1 -1
  7. package/dist/client.d.ts +88 -3
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +237 -42
  10. package/dist/client.js.map +1 -1
  11. package/dist/control-socket-server.d.ts +134 -0
  12. package/dist/control-socket-server.d.ts.map +1 -0
  13. package/dist/control-socket-server.js +108 -0
  14. package/dist/control-socket-server.js.map +1 -0
  15. package/dist/credentials-file.d.ts +7 -0
  16. package/dist/credentials-file.d.ts.map +1 -1
  17. package/dist/credentials-file.js +57 -2
  18. package/dist/credentials-file.js.map +1 -1
  19. package/dist/errors.d.ts +316 -0
  20. package/dist/errors.d.ts.map +1 -1
  21. package/dist/errors.js +572 -0
  22. package/dist/errors.js.map +1 -1
  23. package/dist/index.d.ts +130 -28
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +157 -29
  26. package/dist/index.js.map +1 -1
  27. package/dist/network-install-key.d.ts +56 -0
  28. package/dist/network-install-key.d.ts.map +1 -0
  29. package/dist/network-install-key.js +92 -0
  30. package/dist/network-install-key.js.map +1 -0
  31. package/dist/network-install.d.ts +134 -0
  32. package/dist/network-install.d.ts.map +1 -0
  33. package/dist/network-install.js +70 -0
  34. package/dist/network-install.js.map +1 -0
  35. package/dist/service-mcp.d.ts +49 -0
  36. package/dist/service-mcp.d.ts.map +1 -0
  37. package/dist/service-mcp.js +122 -0
  38. package/dist/service-mcp.js.map +1 -0
  39. package/dist/services/accounts.d.ts +1548 -0
  40. package/dist/services/accounts.d.ts.map +1 -0
  41. package/dist/services/accounts.js +724 -0
  42. package/dist/services/accounts.js.map +1 -0
  43. package/dist/services/agent-identity.d.ts +58 -0
  44. package/dist/services/agent-identity.d.ts.map +1 -0
  45. package/dist/services/agent-identity.js +50 -0
  46. package/dist/services/agent-identity.js.map +1 -0
  47. package/dist/services/agents.d.ts +79 -4
  48. package/dist/services/agents.d.ts.map +1 -1
  49. package/dist/services/agents.js +30 -3
  50. package/dist/services/agents.js.map +1 -1
  51. package/dist/services/audit.d.ts +5 -0
  52. package/dist/services/audit.d.ts.map +1 -1
  53. package/dist/services/audit.js +5 -0
  54. package/dist/services/audit.js.map +1 -1
  55. package/dist/services/billing.d.ts +67 -0
  56. package/dist/services/billing.d.ts.map +1 -0
  57. package/dist/services/billing.js +42 -0
  58. package/dist/services/billing.js.map +1 -0
  59. package/dist/services/brain.d.ts +122 -0
  60. package/dist/services/brain.d.ts.map +1 -0
  61. package/dist/services/brain.js +40 -0
  62. package/dist/services/brain.js.map +1 -0
  63. package/dist/services/calendar.d.ts +256 -0
  64. package/dist/services/calendar.d.ts.map +1 -0
  65. package/dist/services/calendar.js +75 -0
  66. package/dist/services/calendar.js.map +1 -0
  67. package/dist/services/catalogue.d.ts +185 -0
  68. package/dist/services/catalogue.d.ts.map +1 -0
  69. package/dist/services/catalogue.js +31 -0
  70. package/dist/services/catalogue.js.map +1 -0
  71. package/dist/services/chat-channels.d.ts +82 -0
  72. package/dist/services/chat-channels.d.ts.map +1 -0
  73. package/dist/services/chat-channels.js +42 -0
  74. package/dist/services/chat-channels.js.map +1 -0
  75. package/dist/services/control-policies.d.ts +409 -0
  76. package/dist/services/control-policies.d.ts.map +1 -0
  77. package/dist/services/control-policies.js +101 -0
  78. package/dist/services/control-policies.js.map +1 -0
  79. package/dist/services/control-socket.d.ts +201 -0
  80. package/dist/services/control-socket.d.ts.map +1 -0
  81. package/dist/services/control-socket.js +165 -0
  82. package/dist/services/control-socket.js.map +1 -0
  83. package/dist/services/credentials.d.ts +2 -1
  84. package/dist/services/credentials.d.ts.map +1 -1
  85. package/dist/services/credentials.js +3 -2
  86. package/dist/services/credentials.js.map +1 -1
  87. package/dist/services/detector-config.d.ts +13 -12
  88. package/dist/services/detector-config.d.ts.map +1 -1
  89. package/dist/services/detector-config.js +13 -12
  90. package/dist/services/detector-config.js.map +1 -1
  91. package/dist/services/drive.d.ts +257 -0
  92. package/dist/services/drive.d.ts.map +1 -0
  93. package/dist/services/drive.js +167 -0
  94. package/dist/services/drive.js.map +1 -0
  95. package/dist/services/dropoffs.d.ts +5 -1
  96. package/dist/services/dropoffs.d.ts.map +1 -1
  97. package/dist/services/dropoffs.js +3 -1
  98. package/dist/services/dropoffs.js.map +1 -1
  99. package/dist/services/evidence-packs.d.ts +5 -3
  100. package/dist/services/evidence-packs.d.ts.map +1 -1
  101. package/dist/services/evidence-packs.js +6 -4
  102. package/dist/services/evidence-packs.js.map +1 -1
  103. package/dist/services/flagged-content.d.ts +30 -0
  104. package/dist/services/flagged-content.d.ts.map +1 -0
  105. package/dist/services/flagged-content.js +24 -0
  106. package/dist/services/flagged-content.js.map +1 -0
  107. package/dist/services/governance.d.ts +69 -0
  108. package/dist/services/governance.d.ts.map +1 -0
  109. package/dist/services/governance.js +39 -0
  110. package/dist/services/governance.js.map +1 -0
  111. package/dist/services/identity.d.ts +44 -4
  112. package/dist/services/identity.d.ts.map +1 -1
  113. package/dist/services/identity.js +54 -6
  114. package/dist/services/identity.js.map +1 -1
  115. package/dist/services/inbound-webhooks.d.ts +12 -1
  116. package/dist/services/inbound-webhooks.d.ts.map +1 -1
  117. package/dist/services/inbound-webhooks.js +7 -0
  118. package/dist/services/inbound-webhooks.js.map +1 -1
  119. package/dist/services/intents.d.ts +9 -3
  120. package/dist/services/intents.d.ts.map +1 -1
  121. package/dist/services/intents.js +11 -7
  122. package/dist/services/intents.js.map +1 -1
  123. package/dist/services/llm.d.ts +73 -1
  124. package/dist/services/llm.d.ts.map +1 -1
  125. package/dist/services/llm.js +63 -1
  126. package/dist/services/llm.js.map +1 -1
  127. package/dist/services/making.d.ts +263 -0
  128. package/dist/services/making.d.ts.map +1 -0
  129. package/dist/services/making.js +114 -0
  130. package/dist/services/making.js.map +1 -0
  131. package/dist/services/meetings.d.ts +183 -0
  132. package/dist/services/meetings.d.ts.map +1 -0
  133. package/dist/services/meetings.js +148 -0
  134. package/dist/services/meetings.js.map +1 -0
  135. package/dist/services/memory.d.ts +288 -0
  136. package/dist/services/memory.d.ts.map +1 -0
  137. package/dist/services/memory.js +116 -0
  138. package/dist/services/memory.js.map +1 -0
  139. package/dist/services/message-access.d.ts +50 -0
  140. package/dist/services/message-access.d.ts.map +1 -0
  141. package/dist/services/message-access.js +36 -0
  142. package/dist/services/message-access.js.map +1 -0
  143. package/dist/services/missions.d.ts +93 -7
  144. package/dist/services/missions.d.ts.map +1 -1
  145. package/dist/services/missions.js +31 -3
  146. package/dist/services/missions.js.map +1 -1
  147. package/dist/services/network.d.ts +266 -0
  148. package/dist/services/network.d.ts.map +1 -0
  149. package/dist/services/network.js +209 -0
  150. package/dist/services/network.js.map +1 -0
  151. package/dist/services/partner-accounts.d.ts +215 -0
  152. package/dist/services/partner-accounts.d.ts.map +1 -0
  153. package/dist/services/partner-accounts.js +133 -0
  154. package/dist/services/partner-accounts.js.map +1 -0
  155. package/dist/services/passport-header-verify.js +1 -1
  156. package/dist/services/passport-header-verify.js.map +1 -1
  157. package/dist/services/passport-session.js +1 -1
  158. package/dist/services/passport-session.js.map +1 -1
  159. package/dist/services/passports.d.ts +6 -4
  160. package/dist/services/passports.d.ts.map +1 -1
  161. package/dist/services/passports.js +5 -4
  162. package/dist/services/passports.js.map +1 -1
  163. package/dist/services/payments.d.ts +126 -0
  164. package/dist/services/payments.d.ts.map +1 -0
  165. package/dist/services/payments.js +66 -0
  166. package/dist/services/payments.js.map +1 -0
  167. package/dist/services/pii-config.d.ts +7 -17
  168. package/dist/services/pii-config.d.ts.map +1 -1
  169. package/dist/services/pii-config.js +9 -19
  170. package/dist/services/pii-config.js.map +1 -1
  171. package/dist/services/post.d.ts +240 -0
  172. package/dist/services/post.d.ts.map +1 -0
  173. package/dist/services/post.js +99 -0
  174. package/dist/services/post.js.map +1 -0
  175. package/dist/services/proxy.d.ts +22 -5
  176. package/dist/services/proxy.d.ts.map +1 -1
  177. package/dist/services/proxy.js +33 -4
  178. package/dist/services/proxy.js.map +1 -1
  179. package/dist/services/rentahuman.d.ts +92 -0
  180. package/dist/services/rentahuman.d.ts.map +1 -0
  181. package/dist/services/rentahuman.js +53 -0
  182. package/dist/services/rentahuman.js.map +1 -0
  183. package/dist/services/scan.d.ts +1 -1
  184. package/dist/services/scan.d.ts.map +1 -1
  185. package/dist/services/scan.js +1 -1
  186. package/dist/services/scan.js.map +1 -1
  187. package/dist/services/services.d.ts +29 -2
  188. package/dist/services/services.d.ts.map +1 -1
  189. package/dist/services/services.js +55 -1
  190. package/dist/services/services.js.map +1 -1
  191. package/dist/services/skills.d.ts +1 -1
  192. package/dist/services/skills.js +1 -1
  193. package/dist/services/team.d.ts +13 -1
  194. package/dist/services/team.d.ts.map +1 -1
  195. package/dist/services/team.js +12 -0
  196. package/dist/services/team.js.map +1 -1
  197. package/dist/services/trust.d.ts +39 -0
  198. package/dist/services/trust.d.ts.map +1 -0
  199. package/dist/services/trust.js +35 -0
  200. package/dist/services/trust.js.map +1 -0
  201. package/dist/services/usage.d.ts +1 -1
  202. package/dist/services/usage.js +1 -1
  203. package/dist/services/wake.d.ts +257 -0
  204. package/dist/services/wake.d.ts.map +1 -0
  205. package/dist/services/wake.js +80 -0
  206. package/dist/services/wake.js.map +1 -0
  207. package/dist/services/website.d.ts +188 -0
  208. package/dist/services/website.d.ts.map +1 -0
  209. package/dist/services/website.js +135 -0
  210. package/dist/services/website.js.map +1 -0
  211. package/dist/sign-claim.d.ts +1 -1
  212. package/dist/sign-claim.js +2 -2
  213. package/dist/types.d.ts +292 -51
  214. package/dist/types.d.ts.map +1 -1
  215. package/dist/verify-agent-identity.d.ts +73 -0
  216. package/dist/verify-agent-identity.d.ts.map +1 -0
  217. package/dist/verify-agent-identity.js +106 -0
  218. package/dist/verify-agent-identity.js.map +1 -0
  219. package/dist/verify-network.d.ts +159 -0
  220. package/dist/verify-network.d.ts.map +1 -0
  221. package/dist/verify-network.js +153 -0
  222. package/dist/verify-network.js.map +1 -0
  223. package/dist/wake-webhook.d.ts +57 -0
  224. package/dist/wake-webhook.d.ts.map +1 -0
  225. package/dist/wake-webhook.js +60 -0
  226. package/dist/wake-webhook.js.map +1 -0
  227. package/dist/wallet-key.d.ts +30 -0
  228. package/dist/wallet-key.d.ts.map +1 -0
  229. package/dist/wallet-key.js +108 -0
  230. package/dist/wallet-key.js.map +1 -0
  231. package/dist/webhook.d.ts +63 -0
  232. package/dist/webhook.d.ts.map +1 -0
  233. package/dist/webhook.js +136 -0
  234. package/dist/webhook.js.map +1 -0
  235. package/dist/x402-pay.d.ts +139 -0
  236. package/dist/x402-pay.d.ts.map +1 -0
  237. package/dist/x402-pay.js +235 -0
  238. package/dist/x402-pay.js.map +1 -0
  239. package/package.json +3 -1
  240. package/dist/services/partner-connect.d.ts +0 -64
  241. package/dist/services/partner-connect.d.ts.map +0 -1
  242. package/dist/services/partner-connect.js +0 -42
  243. package/dist/services/partner-connect.js.map +0 -1
  244. package/dist/services/partner-tenants.d.ts +0 -126
  245. package/dist/services/partner-tenants.d.ts.map +0 -1
  246. package/dist/services/partner-tenants.js +0 -79
  247. package/dist/services/partner-tenants.js.map +0 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 STACK (getstack.run)
3
+ Copyright (c) 2026 Tomi Lupsakko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -6,6 +6,10 @@ Official JavaScript / TypeScript SDK for [STACK](https://getstack.run) - the run
6
6
 
7
7
  STACK sits between your agent and everything it touches. Short-lived, scoped passports replace long-lived API keys. Every outbound call routes through a proxy that enforces scope and parameter constraints. A hash-chained audit log records every decision. A single call kills any passport globally in under 60 seconds.
8
8
 
9
+ ## Docs for agents
10
+
11
+ How-to guides for every STACK service and for controls are published as markdown. The list is at https://getstack.run/llms.txt, and one service's guide is at https://getstack.run/docs/account/<service>.md (for example https://getstack.run/docs/account/email.md).
12
+
9
13
  ## Install
10
14
 
11
15
  ```bash
@@ -26,7 +30,6 @@ npx -y @getstackrun/cli auth login
26
30
  import { Stack } from '@getstackrun/sdk';
27
31
 
28
32
  // No constructor args — reads ~/.stack/credentials.json (OAuth refresh token).
29
- // Falls back to STACK_API_KEY env var or constructor { apiKey } for CI.
30
33
  const stack = new Stack();
31
34
 
32
35
  // 1. Register an agent (one-time)
@@ -56,8 +59,12 @@ await agentStack.proxy.request({
56
59
  method: 'POST',
57
60
  url: 'https://slack.com/api/chat.postMessage',
58
61
  body: { channel: 'C0123', text: 'Ticket resolved' },
59
- passport_token: passport.token,
60
- });
62
+ connection: 'Work', // only when the service has several connections: a name (any case) or an scon_ id
63
+ }, { passportToken: passport.token });
64
+
65
+ // A second connection of a service needs its own name; rename one at any time.
66
+ await stack.services.connectCustom({ name: 'Acme', credential: key, allowed_hosts: ['api.acme.example'], connection_name: 'Personal' });
67
+ await stack.services.rename('scon_...', 'Work');
61
68
 
62
69
  // 5. Complete the Mission when done. This also revokes its passport.
63
70
  await agentStack.missions.complete(mission_id);
@@ -65,11 +72,12 @@ await agentStack.missions.complete(mission_id);
65
72
 
66
73
  ## Authentication
67
74
 
68
- Three sources, resolved in priority order:
75
+ The SDK resolves a credential in this order:
76
+
77
+ 1. **`~/.stack/credentials.json`** - an OAuth refresh token written by `npx @getstackrun/cli auth login`, exchanged for a short-lived access token
78
+ 2. **Interactive browser login** - only in a terminal, when there is no stored sign-in
69
79
 
70
- 1. **Explicit `apiKey`** on the constructor or `STACK_API_KEY` env var (legacy `sk_live_*` path, preserved for CI)
71
- 2. **`agent_id`** option (Phase 2) — every request signed with the agent's local keypair
72
- 3. **`~/.stack/credentials.json`** — OAuth refresh token written by `stack-cli auth login`
80
+ With the `agent_id` option set, every request instead carries a fresh 60-second JWT signed with that agent's local keypair.
73
81
 
74
82
  If the SDK performs its own first-run browser login, its default OAuth scope
75
83
  covers the core agent runtime rather than every SDK method. A deliberate
@@ -77,7 +85,7 @@ management flow can request an exact broader set with
77
85
  `new Stack({ oauthScope: 'team:read team:write' })`. This option applies only
78
86
  to a new interactive login; refresh tokens cannot widen an existing family.
79
87
 
80
- See [/docs/security/stack-auth](https://getstack.run/docs/security/stack-auth) for the full auth model and [/docs/security/agent-keys](https://getstack.run/docs/security/agent-keys) for the per-agent keypair story.
88
+ See [the auth model](https://getstack.run/docs/security/stack-auth) for the full auth model and [the agent keys page](https://getstack.run/docs/security/agent-keys) for the per-agent keypair story.
81
89
 
82
90
  ## Offline passport verification
83
91
 
@@ -101,41 +109,377 @@ For revocation-aware verdicts, combine with a short cache against `POST /v1/pass
101
109
 
102
110
  ## What the SDK wraps
103
111
 
104
- | Service | Typical use |
112
+ `new Stack()` exposes one property per API area.
113
+
114
+ | Property | Typical use |
105
115
  |---|---|
106
- | `stack.agents` | Register, list, update, delete agents |
107
- | `stack.passports` | Issue, verify, delegate, refresh, revoke |
108
- | `stack.services` | Connect OAuth / custom credentials, grant agent access |
116
+ | `stack.agents` | Register (a new agent starts `logged`), set up an agent with its first grants and hosts as one approval, list, update, delete, unblock agents; dismiss an agent's open warnings; read an agent's permissions |
117
+ | `stack.passports` | Issue, verify, delegate, refresh, revoke passports; checkpoints, checkouts and review decisions |
118
+ | `stack.missions` | Start (open and issue a passport in one call), open, renew, complete, revoke Missions; activity and Operator reviews |
119
+ | `stack.authority` | Authority principals, proofs, bindings, receivers and evidence reads |
120
+ | `stack.services` | Connect OAuth / custom credentials, one-time connect links (`createConnectLink`, `getConnectLink`, `listConnectLinks`), grant agent access |
109
121
  | `stack.credentials` | Retrieve decrypted credentials (agent-side) |
110
- | `stack.proxy` | Make outbound HTTP calls; scope + constraints enforced server-side |
122
+ | `stack.proxy` | Make outbound HTTP calls; scope and constraints enforced server-side; read an operation's delivery state |
123
+ | `stack.llm` | LLM gateway: Anthropic and OpenAI call shapes, any OpenRouter model and endpoint (`openrouter.request(method, path, options)` and `openrouter.requestBytes(...)` for an answer that is a file; `openrouter.chat.completions` stays), images on your own OpenAI key (`openai.images.generate`), plus usage queries. On an agent account's STACK key, `maxCostCents` is the most a call holds (a cost above it is taken from the account's credit at once) and the call is charged what OpenRouter reports it cost |
111
124
  | `stack.dropoffs` | Schema-validated, encrypted agent-to-agent data transfer |
112
- | `stack.skills` | Publish + invoke marketplace skills |
113
- | `stack.identity` | Verification sessions, claims, providers |
125
+ | `stack.skills` | Publish and invoke marketplace skills; skill requests |
126
+ | `stack.intents` | Simulate, submit, approve and reject intents |
127
+ | `stack.fleets` | Fleet policies, workload enrollment and membership |
128
+ | `stack.identity` | Verification sessions, claims, providers, service requirements |
114
129
  | `stack.team` | Team members, roles, and service access |
115
130
  | `stack.deliveryMethods` | Email, SMS, webhook destinations |
116
131
  | `stack.notifications` | Rules mapping events to destinations |
117
- | `stack.securityEvents` | List, resolve real-time detector signals |
132
+ | `stack.securityEvents` | List and resolve real-time detector signals |
133
+ | `stack.detectorConfig` | Read and change detector configuration |
134
+ | `stack.piiConfig` | Read and change PII redaction configuration |
135
+ | `stack.scan` | Scan retrieved content for prompt injection |
136
+ | `stack.audit` | List audit entries, read the chain head, verify the hash chain |
137
+ | `stack.evidencePacks` | Export, read, download and list portable Signed records |
138
+ | `stack.usage` | Action usage against the plan allowance |
139
+ | `stack.governance` | Read one governance approval: `getApproval` (status, payload hash, link; a person decides it) |
140
+ | `stack.billing` | Agent-account subscriptions: platform and controls checkout, status, resume without controls |
141
+ | `stack.inboundWebhooks` | Hosted inbound webhooks scanned before they are forwarded |
142
+ | `stack.accounts` | Agent accounts: open, read, close; messages, mail (to several people, with copies and attachments, reply and forward) and texts, the agent's own Telegram bot, live calls (place one, or answer or decline one that rings on the account's number; held by the agent with `say`, `pressKeys`, `setCallVoice`, `hangUp` or the live WebSocket stream `live`, or by STACK's model with `on_behalf_of` and a `brief`; the account's call voice and voicemail greeting), paid tools, workspaces (a machine with a shell and git), browser and card checkout, wallet payments, your own mail domains |
143
+ | `stack.chatChannels` | The Telegram, text and Slack identities an owner approves small held payments from (within the limits set in the policy; off by default), and STACK's Slack app |
144
+ | `stack.website` | An agent account's website: publish a bundle (`siteFiles` builds one), add your own domain, price paths in USDC, suspend and resume, report a site |
145
+ | `stack.payments` | Getting paid: connect your own Stripe with a restricted key, payment links and checkout sessions, payments received on card and USDC |
146
+ | `stack.drive` | The agent drive: upload, list, read, update and delete files, and share one through a signed, expiring download link (every file is untrusted content) |
147
+ | `stack.messageAccess` | Whether agents read the messages of every message account of the customer or only their own, and whether they may only read; for the account and per agent (owner or admin) |
148
+ | `stack.memory` | Account memory, a graph of facts with the time each held (Graphiti's own tools): add an episode, add a fact, search entities and facts, read and delete episodes and facts; the owner turns it on or off |
149
+ | `stack.controlSocket` | Your own server decides your agents' actions and receives their record: addresses, signing secrets, checked action kinds, decisions made |
150
+ | `stack.network` | The STACK network: register self-hosted installs and their keys, stop a key or install at once, publish and follow revocations across companies, check countersigned passports and the STACK-verified statement |
151
+ | `stack.controlPolicies` | Policies for hosted controls: read, create, revise, delete, start from an agent's current access, simulate a call, read revisions |
152
+ | `stack.controlReviews` | Actions a policy held for a person: list and read (a person decides each through its approval link) |
153
+ | `stack.partner` | Partner operators only: `connect`, `connections`, `tenants`, `mintOutboundPassport` |
154
+
155
+ `stack.issuePassport(input)` issues a passport and returns a `PassportSession` that refreshes its token shortly before it expires.
156
+
157
+ ## The STACK network
158
+
159
+ A self-hosted install can have STACK countersign the passports it issues, so another company trusts them without trusting the install, and can use STACK's live detection rules and classifier. An install holds no account credential: it signs each request with its own key.
160
+
161
+ ```ts
162
+ import { Stack, InstallKey, InstallClient, verifyCountersignedPassport } from '@getstackrun/sdk';
163
+
164
+ // The owner, with their account credential: register the install and its key.
165
+ const install = await stack.network.installs.register('office');
166
+ const key = await InstallKey.generate();
167
+ await stack.network.installs.registerKey(install.id, key);
168
+ // Without a dashboard session this first throws GovernanceApprovalRequiredError: a person approves the key
169
+ // in a browser, then call again with { governanceApprovalId }. Keep the private key: await key.toPem().
170
+
171
+ // The install, with its own key.
172
+ const client = new InstallClient({ installId: install.id, key });
173
+ const rules = await client.rules(); // signed rule set, checked against STACK's keys
174
+ const verdict = await client.classify(retrievedContent); // the content leaves the install; STACK keeps none of it
175
+ const { countersignature } = await client.countersign({ passport, agent: 'support-bot' });
176
+
177
+ // A counterparty, with only STACK's public keys. No network to STACK needed.
178
+ const jwks = await stack.network.jwks();
179
+ await verifyCountersignedPassport({ countersignature, passport, jwks });
180
+ // A live answer, with revocation:
181
+ await stack.network.verify({ countersignature, passport });
182
+ ```
183
+
184
+ Offline checks (`verifyCountersignedPassport`, `verifyRevocationList`, `verifyVerifiedStatement`, `verifyDetectionRules`) cannot see a revocation made after issue; use `stack.network.verify` or the signed revocation list for that. Formats: `packages/shared/src/schemas/network.ts` and the test vectors in `spec/network/test-vectors.json`, in the STACK repository.
185
+
186
+ ## Control socket
187
+
188
+ Point your agents' actions at your own server: it is asked to allow or refuse each checked action, and an events address receives their whole record, signed. Changing an address, rotating a secret and anything that loosens a control is a decision a person approves first; without a dashboard session the call throws `GovernanceApprovalRequiredError`, and once the person approves at `approvalUrl` the same call goes through with `governanceApprovalId`.
189
+
190
+ ```ts
191
+ // The signing secret comes back once, when it is created. Store it now. (A browser sign-in, which is
192
+ // OAuth, is never given it: `secret` is null and `secret_reveal.url` is a single-use Console link where
193
+ // the signed-in person reads it once.)
194
+ const { secret } = await stack.controlSocket.setDecisionAddress(
195
+ { url: 'https://control.example.com/decide', timeout_ms: 1000 },
196
+ { governanceApprovalId }, // after a person approved the first attempt
197
+ );
198
+ const check = await stack.controlSocket.verify('decision'); // passes: your server now decides
199
+ await stack.controlSocket.setCheckedTypes(['email.send', 'card.checkout']);
200
+ const { decisions } = await stack.controlSocket.decisions.list({ verdict: 'deny', limit: 20 });
201
+ ```
202
+
203
+ `get`, `setDecisionAddress`, `setEventsAddress`, `clear`, `verify`, `test`, `rotateSecret`, `setMode` (`'none'` or `'hosted'`), `setOnUnavailable` (`'refuse'` or `'allow'`: what happens when your own server does not answer in time) and `setCheckedTypes` (a list, or `null` for every kind) and `decisions.list` / `decisions.get` cover the whole surface.
204
+
205
+ On your server, verify the request and sign the answer with the two helpers (Standard Webhooks, no dependency beyond `node:crypto`). Verify the raw body exactly as received:
206
+
207
+ ```ts
208
+ import { verifyControlSocketRequest, signControlSocketAnswer } from '@getstackrun/sdk';
209
+
210
+ app.post('/decide', async (req, reply) => {
211
+ const check = verifyControlSocketRequest({ headers: req.headers, body: req.rawBody, secret: process.env.STACK_CONTROL_SECRET! });
212
+ if (!check.ok) return reply.status(401).send();
213
+ const { request } = check;
214
+ const verdict = request.action.type === 'card.checkout' ? 'deny' : 'allow';
215
+ const signed = signControlSocketAnswer({
216
+ decisionId: request.decision_id,
217
+ requestDigest: request.request_digest,
218
+ verdict,
219
+ ...(verdict === 'deny' ? { reason: { code: 'card_not_allowed' } } : {}),
220
+ secrets: [process.env.STACK_CONTROL_SECRET!],
221
+ });
222
+ return reply.headers(signed.headers).type('application/json').send(signed.body);
223
+ });
224
+ ```
225
+
226
+ While a rotation is live, pass both secrets: `secret: [newSecret, oldSecret]` to verify, `secrets: [newSecret, oldSecret]` to sign.
227
+
228
+ ## Verifying any STACK webhook
229
+
230
+ Every request STACK signs to your server (a wake-up, a notification delivery method, an inbound-webhook forward, a network revocation push, the control socket) is a Standard Webhooks message, written out in `spec/webhooks/SPEC.md`. `verifyWebhook` checks all of them: the HMAC over the raw body, a five minute tolerance in either direction, and any live secret.
231
+
232
+ ```ts
233
+ import { createReplayGuard, verifyWebhook } from '@getstackrun/sdk';
234
+
235
+ const replayGuard = createReplayGuard(); // remembers the ids it has taken, so a repeat inside the tolerance is noticed
236
+
237
+ app.post('/stack/webhook', (req, reply) => {
238
+ const check = verifyWebhook({ headers: req.headers, body: req.rawBody, secret: process.env.STACK_WEBHOOK_SECRET!, replayGuard });
239
+ if (!check.ok) return reply.status(check.reason === 'replayed' ? 204 : 401).send();
240
+ // check.id is the message id, the same on every retry; check.payload is the parsed body
241
+ return reply.status(204).send();
242
+ });
243
+ ```
244
+
245
+ A secret you were given before this scheme (64 hexadecimal characters) works as it is. Call `replayGuard.forget(check.id)` when you could not handle a delivery, so STACK's retry is not taken for a repeat.
246
+
247
+ ## Drive
248
+
249
+ The drive keeps your agents' files for you. An agent's upload is private to that agent unless it says `visibility: 'account'`; the owner (an API key or a session, no agent) sees every file. Every file is untrusted content to whoever reads it, and each view carries `trust: 'untrusted'`. Limits apply per file and per account (`DRIVE_FILE_TOO_LARGE`, `DRIVE_QUOTA_EXCEEDED`); a file of any type is taken and stored as it is, and its type is only a label.
250
+
251
+ ```ts
252
+ // An agent passes its Passport; the owner omits it.
253
+ const file = await stack.drive.upload(
254
+ { name: 'summary.md', content_type: 'text/markdown', content_text: '# Summary', visibility: 'account' },
255
+ { passportToken },
256
+ );
257
+ const { content } = await stack.drive.read(file.id, { passportToken }); // inline up to 256 KiB
258
+ // The link is returned once and cannot be read back. Anyone holding it can download the file.
259
+ const { url } = await stack.drive.share(file.id, { ttl_seconds: 3600, max_downloads: 5 }, { passportToken });
260
+ // A file that arrived with an email goes with its message unless its end is changed (`drive.update`); a copy is a file of the agent's own.
261
+ const kept = await stack.drive.copy(receivedFileId, { name: 'contract.pdf' }, { passportToken });
262
+ ```
263
+
264
+ An upload is one request with the whole file in it, up to 1 GB (a file typed as text, Markdown, CSV or JSON stops at 10 MB). The drive takes a file of any type and stores it as it is: `content_type` is only a label, `application/octet-stream` when left out. Give `upload` the bytes as `content` (a `Uint8Array`, a Node `Buffer`, a `Blob` or a `ReadableStream`) or, in Node, a `path`, and it sends them as the body of one `PUT /v1/drive/files`. A path is streamed from disk and a stream as it is read, so a large file is never held in memory. The API computes the SHA-256 itself: there is no hash to give, no size to declare and no second call. Give a stream's length as `size_bytes` and it is sent as `Content-Length`, so a file that is too large is refused before it is read. The SDK does not retry an upload; call it again. Storage past the free amount is charged from the wallet at cost, so an upload that would take the drive past it answers 402 `INSUFFICIENT_BALANCE` unless the wallet can cover the storage past it.
265
+
266
+ ```ts
267
+ const file = await stack.drive.upload(
268
+ { name: 'backup.zip', content_type: 'application/zip', path: 'backup.zip' },
269
+ { passportToken, onProgress: ({ uploaded_bytes, total_bytes }) => console.log(uploaded_bytes, total_bytes) },
270
+ );
271
+ ```
272
+
273
+ Five uploads of one account run at once; a sixth is refused with 429 `DRIVE_TOO_MANY_UPLOADS` until one has finished. A program that cannot send a body itself, an agent that only has tools, asks for a one-time upload URL with `createUploadLink` (one metered action) and sends the bytes there with `uploadToLink(link, { path })` or `curl -T ./file '<url>'`. The URL is a secret, works once and lasts 30 minutes, and the PUT carries no credential; a used, expired or foreign URL answers 404 `DRIVE_UPLOAD_LINK_INVALID`. It is never put in an error.
274
+
275
+ If the wallet cannot pay for the storage past the free amount, the drive is read-only from that day: uploads, edits and new share links answer 409 `DRIVE_READ_ONLY`, while reading, downloading, listing and deleting still work and existing share links keep working. `list` shows it as `usage.storage_unpaid` (`since`, `delete_on`, `over_bytes`; `null` when in good standing). The owner is emailed on day 0, day 30 and day 60, and on day 90 the newest files past the free amount are deleted. Topping up the wallet to cover what is due, or deleting files until the drive is within its free amount, lifts the read-only state at once and ends the countdown.
276
+
277
+ `upload`, `createUploadLink`, `uploadToLink`, `list`, `get`, `read`, `update`, `delete`, `share`, `links` and `revokeLink` cover the whole surface. A share link allows the downloads you name (any number from one; 100 when you name none) and is refused with 409 `DRIVE_LINKS_PAUSED` while STACK has paused the account's links after a download spike. A drop-off hands files over too: `dropoffs.deposit(id, agentId, payload, { driveFiles: [file.id] })` opens them to the collector, and `dropoffs.collect` returns them as `drive_files`.
278
+
279
+ ## Email
280
+
281
+ ```ts
282
+ // To several people, with copies and attachments. A drive file goes by its id; a small file goes inline as base64.
283
+ await stack.accounts.sendEmail(accountId, {
284
+ to: ['ana@example.com', 'ben@example.com'],
285
+ cc: ['carol@example.com'],
286
+ bcc: ['audit@example.com'],
287
+ subject: 'Quarterly report',
288
+ body: 'The report is attached.',
289
+ attachments: [
290
+ { file_id: driveFileId },
291
+ { filename: 'notes.txt', content_type: 'text/plain', content_base64: 'aGVsbG8=' },
292
+ ],
293
+ }, { passportToken });
294
+
295
+ // Answer or forward an email the account received, by its message id.
296
+ await stack.accounts.replyEmail(accountId, messageId, { body: 'Thanks, done.', reply_all: true }, { passportToken });
297
+ await stack.accounts.forwardEmail(accountId, messageId, { to: 'dan@example.com', body: 'For your records.' }, { passportToken });
298
+ ```
118
299
 
119
- A handful of endpoints (audit export, chain-head, verify-chain, billing) are not yet wrapped — call them via `fetch` using the same API key. See [docs/api](https://getstack.run/docs).
300
+ The mail provider takes one To address, so the first `to` address is the message's To and any further ones are delivered as Cc. The answer (`AccountEmailSent`) lists `to`, `cc`, `bcc` and the `attachments` as sent. Attachments come to at most 25 MB in all, and inline files to at most 10 MB; a larger file is attached from the drive by `file_id` (`EMAIL_ATTACHMENTS_TOO_LARGE`, `EmailAttachmentsTooLargeError`). `replyEmail` answers in the received email's thread, quoting it unless `include_quote` is `false`, to the person who wrote it (every address its From names, when it names several), and with `reply_all` to everyone else it was sent to as well. With only `bcc` given, the To is the account's own address, and the account's own address may be a recipient like any other. `forwardEmail` sends a new email, in no thread, with the original's text unless `include_quote` is `false` and, unless `include_attachments` is `false`, the attachments that were kept. A message that is not a received email, was withheld, or names no sender throws `EmailMessageNotAnswerableError`. An address left out (an entry of the original that is not one plain address) is named in the answer's `dropped`. A subject is one line. An inline file may be of any type, as in the drive, an empty one included. A received email lists its attachments in `content.attachments`: each has a `file_id` (a drive file, private to the receiving agent and untrusted) or a `not_saved` reason; the email is kept either way. A received file is deleted with its message: `drive.copy` keeps it.
301
+
302
+ ### Search messages and message access
303
+
304
+ `stack.accounts.messages.search({ agentId, channel, sender, recipient, threadId, after, before, q, limit, cursor })` searches every message the caller may read, across the customer's message accounts and channels, newest first. Each hit is a summary without the body (`stack.accounts.messages.get` reads one). The window is the last 30 days unless `after` and `before` (ISO 8601 with an offset) say otherwise; a search on `q`, `sender`, `recipient` or `threadId` needs a window of at most 90 days. `stack.accounts.messages.readAttachment(accountId, messageId, fileId)` reads a file a message carries, with the same answer as `drive.read`; the content is untrusted. A memory fact learned from messages lists their ids in `source_message_ids`.
305
+
306
+ `stack.messageAccess` sets what agents may do with those messages, for the account and per agent (`get(agentId?)`, `set(values, agentId?)`, `clear(agentId, keys)`). `read_teammates` (default `true`) lets an agent read the messages of every message account of the customer; `false` limits it to its own. `messages_read_only` (default `false`), when `true`, lets an agent read but not send, reply, forward, text or post from any account. An agent's own value wins over the account's. Owner or admin only; an agent is refused, and a change applies at once with no approval.
307
+
308
+ ```ts
309
+ await stack.messageAccess.set({ read_teammates: false }, 'agt_one');
310
+ await stack.messageAccess.clear('agt_one', ['read_teammates']); // follows the account again
311
+ ```
312
+
313
+ ## Memory
314
+
315
+ Memory is what your agents know about your world, kept as a graph of entities and facts with the time each one held. It is Graphiti (a temporal knowledge graph) used the way its makers ship it: one graph per account, shared by the account's agents. The methods are the tools of Graphiti's own MCP server, with its arguments and its answers; there is no group id, because the graph is the account's.
316
+
317
+ ```ts
318
+ // An agent passes its Passport; the owner omits it.
319
+ const added = await stack.memory.addMemory(
320
+ { name: 'Accountant', episode_body: 'Maria Ek is our accountant at Kvarnen Ekonomi.', source_description: 'chat' },
321
+ { passportToken },
322
+ );
323
+ // added.status is 'queued': the episode is read into the graph in the background, one at a time per account.
324
+ const { episodes } = await stack.memory.getEpisodes({ maxEpisodes: 10 }, { passportToken }); // each has a status: 'stored', 'queued', 'processing' or 'failed' (with a reason)
325
+ const { facts } = await stack.memory.searchMemoryFacts({ query: 'where does Maria Ek work' }, { passportToken });
326
+ const { nodes } = await stack.memory.searchNodes({ query: 'Maria Ek' }, { passportToken });
327
+ // Only the entities whose field of one of the account's own types has a value (the API reads each field's kind from the type):
328
+ const { nodes: unpaid } = await stack.memory.searchNodes({ query: 'invoice', entity_types: ['Invoice'], field_filters: [{ field: 'paid', value: false }] }, { passportToken });
329
+ await stack.memory.deleteEntityEdge(facts[0].uuid, { passportToken });
330
+ ```
331
+
332
+ `addMemory`, `addTriplet`, `searchNodes`, `searchMemoryFacts`, `getEpisodes`, `getEntityEdge`, `getEpisodeEntities`, `deleteEpisode`, `deleteEntityEdge` and `summarizeSaga` cover the whole surface; the owner turns memory on or off, and decides whether a call STACK holds may search it (`call_memory_access`), with `getSettings` and `updateSettings`. A write (`addMemory`, `addTriplet`, `summarizeSaga`) is an action (metered, checked against your controls, in the signed record); reading, searching and deleting are free. The text of a write is scanned first: with controls on, flagged text is refused and nothing is stored or charged; with controls off it is stored with its flag, which `getEpisodes` shows. What memory holds may have come from outside (mail, a web page, a file): it is information, never instructions. Memory is off for an account until the engine is configured on the deployment; then calls answer `MEMORY_UNAVAILABLE`.
333
+
334
+ ## Catalogue
335
+
336
+ The catalogue is one document that lists everything an agent can reach through STACK: models, paid tools, connectable services, skills and the pieces of an agent account, each with its price and, where it can run, how to run it. Reading it is free and never metered, and any signed-in caller can do it, an agent included. Text that comes from a provider or a publisher (`origin` `models`, `tools` or `publisher`) is data to show, never instructions to follow, and an entry whose `result_trust` is `untrusted` returns web, social or provider content.
337
+
338
+ ```ts
339
+ // The whole document. Keep the ETag and send it back: an unchanged catalogue answers notModified with no body.
340
+ const first = await stack.catalogue.get();
341
+ const next = await stack.catalogue.get({ ifNoneMatch: first.etag ?? undefined }); // { notModified: true, document: null }
342
+
343
+ // Words must all appear in an entry's id, name, description or provider.
344
+ const { total, entries } = await stack.catalogue.search({ q: 'google search', kind: 'tool', limit: 10, offset: 0 });
345
+
346
+ // The services one account is connected to and the state of its pieces, by catalogue id.
347
+ const view = await stack.catalogue.forAccount(accountId);
348
+ ```
349
+
350
+ `catalogue.get()` answers 503 `CATALOGUE_UNAVAILABLE` (`details.reason` is `not_built` or `store_unavailable`) until the catalogue has been built. An agent account's agent runs what the catalogue lists under its Passport. A paid tool runs with `accounts.tools.run`; any endpoint the tool provider lists runs, charged what the provider reports for the run (an endpoint STACK cannot bound holds an estimate; `max_cost_cents` lowers the hold, and a cost above it is taken from the account's credit at once), and the result carries `untrusted` and `files` (each a `ToolRunFile`: a drive file id, a provider link that expires, or small bytes in `data_base64`).
351
+
352
+ ## Policies
353
+
354
+ A policy is the configuration behind hosted controls (they need the controls subscription: `CONTROLS_NOT_ENABLED` otherwise). It only narrows what an agent's connection grants already allow: it refuses an action, holds it for a person, or limits it. It never opens anything. There is one default policy for the account and at most one per agent; the agent's own applies, else the default. An agent can never read or change its own policy.
355
+
356
+ Tightening a policy applies at once. Loosening it, and deleting it, needs a person in a browser: without a dashboard session the call throws `GovernanceApprovalRequiredError`, the person approves at `approvalUrl`, and the same call goes through with `governanceApprovalId`. A revision that is not provably a tightening counts as a loosening.
357
+
358
+ ```ts
359
+ // Start from what the agent can already do (changes no outcome yet), then tighten.
360
+ const { policy } = await stack.controlPolicies.startFromCurrentAccess('agt_...');
361
+ await stack.controlPolicies.set(
362
+ 'agt_...',
363
+ { ...policy!.definition, spend: { max_per_action_cents: 500 }, review: { over_cents: 200 } },
364
+ { expectedRevision: policy!.revision },
365
+ );
366
+
367
+ // Try a call before it happens. Nothing is counted, held or sent.
368
+ const result = await stack.controlPolicies.simulate({
369
+ agent_id: 'agt_...',
370
+ call: { action: 'card.checkout', amount_cents: 900 },
371
+ });
372
+ // result.verdict is 'allow', 'review' or 'deny'; result.refusal names the rule.
373
+
374
+ // Actions held for a person wait here; the person decides at approval_url.
375
+ const { reviews } = await stack.controlReviews.list();
376
+ ```
377
+
378
+ `controlPolicies` has `list`, `get` (`'default'` or an agent id), `set` (`'default'` or an agent id, a definition, `{ expectedRevision }`: omit it to create, pass the revision you read to revise), `delete`, `startFromCurrentAccess`, `simulate` and `revisions`; `set`, `delete` and `startFromCurrentAccess` take `{ governanceApprovalId }`. `controlReviews` has `list` (`{ status: 'pending' | 'all', limit }`) and `get`. There is no call that decides a review.
379
+
380
+ ### Recipients set per job
381
+
382
+ A policy send rule can say its recipients are set per job: each Mission names who it may send to. Put `recipients: 'per_mission'` on an `allow` rule that names a send intent with a recipient field, and the rule allows a send only inside a Mission that pins every recipient field with an exact value, and only to those values. A Mission without the pin is refused (`recipients_not_pinned`); a send to someone else is refused (`recipient_not_allowed`). A delegated Passport carries the same Mission, so it carries the same recipients; the per-job rules of the agent the Mission was opened for apply to it too. A send rule that names no recipients and is not set per job is refused when written (`UnboundedSendRuleError`).
383
+
384
+ The account's own email, texts and calls take the same word. A policy's `recipients.email`, `recipients.sms` and `recipients.call` are each a list or `'per_mission'`. Under `'per_mission'` a send must name the stored message it answers with `reply_to_message` (`sendEmail`, `sendSms` and `calls.place` take it), and every recipient must be whoever wrote that message. A send that names no message is refused (`recipients_not_pinned`), a send to anyone else is refused (`recipient_not_allowed`), and an id that is not one of the account's received messages is 404. `replyEmail` answers the message in its path, so it takes no such field; `forwardEmail` is not covered. Changing a list to `'per_mission'` or back is a loosening and waits for a person in a browser; setting `'per_mission'` where there was no rule is a tightening.
385
+
386
+ ```ts
387
+ await stack.controlPolicies.set('agt_...', {
388
+ name: 'Support agent',
389
+ connections: {
390
+ mode: 'listed',
391
+ rules: [{
392
+ id: 'mail-per-job',
393
+ effect: 'allow',
394
+ recipients: 'per_mission',
395
+ access: { connection_id: 'scon_...', intents: [{ name: 'resend.send_email' }] },
396
+ }],
397
+ },
398
+ });
399
+
400
+ // Recipients: who this Mission may send to. A policy rule that leaves recipients to each Mission allows a send only to these.
401
+ const { mission_id } = await stack.missions.open({
402
+ agent_id: 'agt_...',
403
+ intent_summary: 'Answer one customer',
404
+ recipients: ['ana@example.com'],
405
+ });
406
+
407
+ // Reply to a message: pins the Mission to the sender of this message, so the agent can answer that person and no one else.
408
+ await stack.missions.start({
409
+ agent_id: 'agt_...',
410
+ mission: { intent_summary: 'Answer the incoming message', reply_to_message: 'msg_...' },
411
+ });
412
+
413
+ // Try a call with what a Mission pinned.
414
+ await stack.controlPolicies.simulate({
415
+ agent_id: 'agt_...',
416
+ call: { action: 'email.send', mission_id, target: { to: 'ana@example.com' } },
417
+ });
418
+ ```
419
+
420
+ `recipients` lists exact addresses, numbers or ids (an address may be in any case) and applies at every recipient field a send names. `recipient_pins` is `[{ path, op: 'eq' | 'in', value }]` with one pin per path: `path` is `'*'` (every recipient field a send names, a recipient inside the URL included: the path or one of its segments) or a request field such as `body.to`, `derived.email.recipients` or `url.pathname`; up to 64 pins and 1,000 recipients a list. `reply_to_message` is the id of a message the agent's account received, or of an incoming call it answered or declined (a readable email, text, voicemail or call, else 404 `NOT_FOUND`); it combines with `recipients` into one list. The owner adds to a running Mission's pins with `missions.addRecipients(missionId, { recipients, recipient_pins, reply_to_message })`, and `missions.get` returns them as `recipient_pins` (an array, or null).
421
+
422
+ A refused action reaches the agent as `ControlDeniedError`. Its `rule` says which rule of the policy refused (`section`, `rule`, `code`, never a value from the call), and an action held for a person carries `retry.ref`: once the person approves, send the same action again with the header `X-Control-Ref: <ref>`. A spend limit reached while paying throws `ControlLimitExceededError`, and a policy that allows a send without naming who receives it throws `UnboundedSendRuleError`.
120
423
 
121
424
  ## Error handling
122
425
 
123
- Every error is a `StackError` subclass with a stable machine code.
426
+ Every non-2xx API response is thrown as a `StackError` with the HTTP `status`, the API's stable machine `code` (`HTTP_<status>` when the response carries none), a `message` and optional `details`. `NOT_AUTHENTICATED` (401) means no credential could be resolved. Branch on `err.status` and `err.code`:
124
427
 
125
428
  ```ts
126
- import { Stack, StackError, PassportRevokedError, InsufficientCreditsError } from '@getstackrun/sdk';
429
+ import { StackError, MissionNotLiveError } from '@getstackrun/sdk';
127
430
 
128
431
  try {
129
432
  await stack.passports.verify(token);
130
433
  } catch (err) {
131
- if (err instanceof PassportRevokedError) {
434
+ if (err instanceof StackError && err.code === 'PASSPORT_REVOKED') {
132
435
  // issue a fresh passport
133
- } else if (err instanceof StackError) {
134
- console.error(err.code, err.statusCode, err.message);
436
+ } else {
437
+ throw err;
135
438
  }
136
439
  }
137
440
  ```
138
441
 
442
+ `@getstackrun/sdk` exports these error classes:
443
+
444
+ | Class | `code` | Notes |
445
+ |---|---|---|
446
+ | `StackError` | the API's | Base class; fields `code`, `status`, `details` |
447
+ | `MissionNotLiveError` | `MISSION_NOT_LIVE` | Thrown by `PassportSession.getToken()` when a refresh is refused because the passport's Mission is completed, revoked, expired or missing. Carries `missionId`, `state` and the original `refusal`. Retrying cannot succeed: open a new Mission and issue a new passport. |
448
+ | `NotFoundError` | `NOT_FOUND` | Status 404 subclass. The HTTP client does not throw it; API 404s arrive as `StackError` with `status === 404`. |
449
+ | `ForbiddenError` | `FORBIDDEN` | Status 403 subclass. Not thrown by the HTTP client; check `status === 403`. |
450
+ | `ValidationError` | `VALIDATION_ERROR` | Status 400 subclass. Not thrown by the HTTP client; check `status === 400`. |
451
+ | `GovernanceApprovalRequiredError` | `GOVERNANCE_APPROVAL_REQUIRED` | Thrown by the HTTP client. Carries `approvalId` and `approvalUrl`: a human approves at the link, then retry the same call with `governanceApprovalId`. |
452
+ | `GovernanceApprovalStateError` | `GOVERNANCE_APPROVAL_PENDING`, `_REJECTED`, `_EXPIRED` | Thrown by the HTTP client when a retry names an approval it cannot use. Carries `approvalId` and `approvalStatus` (`pending`, `rejected`, `expired`): wait while it is pending; otherwise make the call again without the approval to ask for a new one. |
453
+ | `AccountPieceNotReadyError` | `ACCOUNT_PIECE_NOT_READY` | Thrown by the HTTP client. Carries `accountId`, `piece` and `state`; read the account to see when the piece is ready. |
454
+ | `AgentBudgetExceededError` | `AGENT_BUDGET_EXCEEDED` | Thrown by the HTTP client. Carries `accountId` and `remainingCents`. |
455
+ | `ProviderCapacityUnavailableError` | `PROVIDER_CAPACITY_UNAVAILABLE` | Thrown by the HTTP client. A provider declined STACK's own account, or STACK paused its own spend at Twilio; nothing was charged. Carries `provider`; retry in a few minutes. |
456
+ | `BrowserTimeUsedUpError` | `BROWSER_TIME_USED_UP` | Thrown by the HTTP client. This month's browser time is spent; nothing was charged. Carries `provider`; browsers are available again when the month turns, so do not retry before. |
457
+ | `BrowserSessionLengthRefusedError` | `BROWSER_SESSION_LENGTH_REFUSED` | Thrown by the HTTP client. The browser plan does not allow a session this long; nothing was charged and retrying does not help. Carries `provider`. |
458
+ | `AccountCallFailedError` | `ACCOUNT_CALL_FAILED` | Thrown by the HTTP client. Carries `reason` and `retryable`: when `retryable`, the call may have been placed, so read the account's calls before retrying. |
459
+ | `DestinationNotAvailableError` | `DESTINATION_NOT_AVAILABLE` | Thrown by the HTTP client (422). Texts and calls to this number are not available: Twilio has no price for the destination (`reason` `no_price`) or does not allow it from the account's number (`reason` `refused_by_twilio`: its geographic permissions or high-risk number blocking). Nothing was charged. |
460
+ | `ToolPriceRefusedError` | `TOOL_PRICE_REFUSED` | Thrown by the HTTP client. A paid tool run refused before it is held (`max_results` out of range, an input too deep); nothing was held. Carries `reason`. |
461
+ | `ToolsUnavailableError` | `TOOLS_UNAVAILABLE` | Thrown by the HTTP client. Paid tools are unavailable on STACK's side; nothing was charged. Carries `reason`. |
462
+ | `ToolRunRejectedError` | `TOOL_RUN_REJECTED` | Thrown by the HTTP client. The tool provider refused the input; inspect the endpoint first. Carries `providerStatus`. |
463
+ | `BudgetNeedsControlsError` | `BUDGET_NEEDS_CONTROLS` | Thrown by the HTTP client. A per-agent monthly budget needs controls; open without one (prepaid credit is the limit) or turn controls on. |
464
+ | `PlatformSubscriptionRequiredError` | `PLATFORM_SUBSCRIPTION_REQUIRED` | Thrown by the HTTP client. Every agent call, an agent account's or not, needs the platform subscription trialing or active (an account that does not need one never does). Carries `subscriptionStatus`; the message says how to start the plan. |
465
+ | `RecipientOptedOutError` | `RECIPIENT_OPTED_OUT` | Thrown by the HTTP client. The number is on the do-not-contact list (it texted STOP), so texts and calls to it are refused. Carries `accountId`. The owner, an admin or the account's agent reads the list with `stack.accounts.optOuts.list()`; the owner or an admin takes a number off with `remove(id)`. |
466
+ | `SharedMailDailyLimitError` | `SHARED_MAIL_DAILY_LIMIT` | Thrown by the HTTP client. The day's recipients on the shared agent domain are used up (every To, Cc and Bcc address counts; 20 a day in a customer's first 14 days, then 100); it resets at midnight UTC. Carries `limit`. |
467
+ | `EmailAttachmentsTooLargeError` | `EMAIL_ATTACHMENTS_TOO_LARGE` | Thrown by the HTTP client. The attached files come to more than the mail provider takes in one email (25 MB); nothing was sent. Carries `totalBytes` and `limitBytes`. |
468
+ | `EmailMessageNotAnswerableError` | `EMAIL_MESSAGE_NOT_ANSWERABLE` | Thrown by the HTTP client on a reply or forward. The message is not a received email, was withheld, or names no sender; nothing was sent. Carries `reason` (`not_email`, `withheld`, `not_received` or `no_sender`). |
469
+ | `UnboundedSendRuleError` | `UNBOUNDED_SEND_RULE` | Thrown by the HTTP client. A policy allows a send without naming who receives it. Carries `rules`, one entry per offending rule with its `unboundPaths`; bind those fields, set the rule's recipients to `"per_mission"` so each Mission names them, or set the rule to review or deny. |
470
+ | `ControlDeniedError` | `CONTROL_DENIED` | Thrown by the HTTP client. Your controls refused the action; nothing was charged. Carries `decisionId`, `reasonCode` (`recipients_not_pinned` when the Mission does not name who it may send to, `recipient_not_allowed` for someone it did not name), `rule` (which policy rule refused: `policyId`, `policyRevision`, `section`, `rule`, `code`, `detail`; null when your own server refused) and `retry` (`ref`, `afterSeconds`) for an action held for a person. |
471
+ | `ControlLimitExceededError` | `CONTROL_LIMIT_EXCEEDED` | Thrown by the HTTP client. A limit of your policy was reached while the action was being paid for; nothing was reserved or charged. Carries `limit` (`window`, `unit`), `remaining` and `maxPerActionCents`. |
472
+ | `ControlsNotEnabledError` | `CONTROLS_NOT_ENABLED` | Thrown by the HTTP client. Policies need hosted controls, which are not on for this account. |
473
+ | `WebsitePublishRejectedError` | `WEBSITE_PUBLISH_REJECTED` | Thrown by the HTTP client. The publish scan found something STACK does not host, so nothing went live. Carries `findings` (`code`, `path`); a `scanner_unavailable` finding means retry later. |
474
+ | `WebsiteLimitExceededError` | `WEBSITE_LIMIT_EXCEEDED` | Thrown by the HTTP client. Carries `limit` and `max`. |
475
+ | `WebsiteSuspendedError` | `WEBSITE_SUSPENDED` | Thrown by the HTTP client. The site is suspended or taken down; carries `state` and `by`. |
476
+ | `WebsiteHostnameUnavailableError` | `WEBSITE_HOSTNAME_UNAVAILABLE` | Thrown by the HTTP client. The address is taken, is not a name STACK can serve, or is not proven yet; carries `reason`. |
477
+ | `ConnectionAmbiguousError` | `CONNECTION_AMBIGUOUS` | Thrown by the HTTP client, and by `serviceMcpUrlOf` when a service's connections have different MCP addresses. The service has several connections and the call named none; `connections` lists `{ id, name }`, repeat the call with `connection` set to one.
478
+ | `PaymentConnectionRequiredError` | `PAYMENT_CONNECTION_REQUIRED` | Thrown by the HTTP client. The account has no active Stripe connection; the customer connects their own Stripe first (`payments.startStripe`). |
479
+ | `StripeRequestFailedError` | `STRIPE_REQUEST_FAILED` | Thrown by the HTTP client. Stripe refused or failed a call made with the customer's key; nothing was created. Carries `kind` (`permission`, `rejected`, `unavailable`) and `providerStatus`. |
480
+
481
+ There is no revoked-passport or insufficient-credits class. `stack.passports.verify` throws a `StackError` with `code: 'PASSPORT_REVOKED'` (401) for a revoked passport (and `code: 'PASSPORT_INVALID'`, 401, for a token that is not a passport of this deployment), and `verifyPassportOffline` throws a plain `Error` when a token fails its checks.
482
+
139
483
  Full catalog: [docs/reference/errors](https://getstack.run/docs/reference/errors).
140
484
 
141
485
  ## Documentation
@@ -1,4 +1,4 @@
1
- // Phase 2 — agent-keypair runtime auth.
1
+ // agent-keypair runtime auth.
2
2
  //
3
3
  // When `new Stack({ agent_id })` is constructed, the SDK enters
4
4
  // agent-runtime mode: every API call is signed with a fresh 60-second
@@ -19,7 +19,7 @@
19
19
  // developer interaction.
20
20
  //
21
21
  // Threat model: the privkey lives on disk just like an OAuth refresh
22
- // token. Phase 3 (passkey-rooted) closes the laptop-decryption gap.
22
+ // token. (passkey-rooted) closes the laptop-decryption gap.
23
23
  // Until then, file-on-disk + chmod 600 is the same posture as `aws cli`.
24
24
  import { generateKeyPair, exportJWK, importJWK, SignJWT } from 'jose';
25
25
  import { sign as cryptoSign, randomBytes } from 'node:crypto';
@@ -90,7 +90,7 @@ export async function prepareFleetEnrollmentKey(policyId, idempotencyKey) {
90
90
  if (!stored) {
91
91
  const pair = await generateKeyPair('EdDSA', { crv: 'Ed25519', extractable: true });
92
92
  const candidate = { agent_id: keyId, publicKey: await exportJWK(pair.publicKey),
93
- privateKey: await exportJWK(pair.privateKey), enrolled_at: Date.now() / 1000 };
93
+ privateKey: await exportJWK(pair.privateKey), enrolled_at: Math.floor(Date.now() / 1000) };
94
94
  const path = await keyPath(keyId);
95
95
  await mkdir(dirname(path), { recursive: true });
96
96
  try {
@@ -254,8 +254,7 @@ async function enroll(args) {
254
254
  // session expired and they bailed out. Surface the original
255
255
  // error so the user knows what happened.
256
256
  throw new Error(`Browser approval for SDK agent enrollment failed (${e.message}). ` +
257
- `Either fix the issue and re-run, or run in CI mode with STACK_API_KEY set ` +
258
- `to use the silent enrollment path.`);
257
+ `Fix the issue and re-run.`, { cause: e });
259
258
  }
260
259
  }
261
260
  else {
@@ -307,7 +306,7 @@ async function enroll(args) {
307
306
  agent_id: args.agentId,
308
307
  publicKey: publicJwk,
309
308
  privateKey: privateJwk,
310
- enrolled_at: new Date(enrolled_at).getTime() / 1000,
309
+ enrolled_at: Math.floor(new Date(enrolled_at).getTime() / 1000),
311
310
  };
312
311
  await writeStoredKey(stored);
313
312
  return stored;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-auth.js","sourceRoot":"","sources":["../src/agent-auth.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,EAAE;AACF,gEAAgE;AAChE,sEAAsE;AACtE,6DAA6D;AAC7D,EAAE;AACF,kBAAkB;AAClB,kEAAkE;AAClE,uEAAuE;AACvE,uEAAuE;AACvE,uDAAuD;AACvD,8CAA8C;AAC9C,2DAA2D;AAC3D,mEAAmE;AACnE,8BAA8B;AAC9B,4DAA4D;AAC5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C,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;SACpC,SAAS,CAAC,gBAAgB,CAAC;SAC3B,UAAU,CAAC,OAAO,CAAC;SACnB,WAAW,CAAC,kBAAkB,CAAC;SAC/B,WAAW,CAAC,GAAG,CAAC;SAChB,YAAY,CAAC,GAAG,CAAC;SACjB,iBAAiB,CAAC,GAAG,GAAG,aAAa,CAAC;QACvC,+DAA+D;QAC/D,wEAAwE;QACxE,sEAAsE;SACrE,MAAM,CAAC,MAAM,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;SACrD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAIxC;IACC,IAAI,MAAM,GAAqB,IAAI,CAAC;IACpC,OAAO,KAAK,IAAI,EAAE;QAChB,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,MAAM,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QAC/G,CAAC;QACD,OAAO,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- // Phase 1 SDK first-run bootstrap (Authorization Code + PKCE with
1
+ // SDK first-run bootstrap (Authorization Code + PKCE with
2
2
  // localhost callback).
3
3
  //
4
4
  // When `new Stack()` is instantiated and there's no apiKey, no
@@ -79,7 +79,7 @@ export async function browserBootstrap(baseUrl, scope = SDK_DEFAULT_OAUTH_SCOPE)
79
79
  }),
80
80
  });
81
81
  if (!dcr.ok) {
82
- throw new Error(`STACK SDK: client registration failed (${dcr.status}). Try setting STACK_API_KEY or running \`stack-cli auth login\`.`);
82
+ throw new Error(`STACK SDK: client registration failed (${dcr.status}). Try running \`npx @getstackrun/cli auth login\`.`);
83
83
  }
84
84
  const { client_id } = (await dcr.json());
85
85
  // 2. PKCE pair.