@getstackrun/sdk 4.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 (240) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +326 -10
  3. package/dist/agent-auth.d.ts.map +1 -1
  4. package/dist/agent-auth.js +3 -4
  5. package/dist/agent-auth.js.map +1 -1
  6. package/dist/browser-bootstrap.js +1 -1
  7. package/dist/browser-bootstrap.js.map +1 -1
  8. package/dist/client.d.ts +86 -1
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/client.js +235 -40
  11. package/dist/client.js.map +1 -1
  12. package/dist/control-socket-server.d.ts +134 -0
  13. package/dist/control-socket-server.d.ts.map +1 -0
  14. package/dist/control-socket-server.js +108 -0
  15. package/dist/control-socket-server.js.map +1 -0
  16. package/dist/credentials-file.d.ts +7 -0
  17. package/dist/credentials-file.d.ts.map +1 -1
  18. package/dist/credentials-file.js +57 -2
  19. package/dist/credentials-file.js.map +1 -1
  20. package/dist/errors.d.ts +316 -0
  21. package/dist/errors.d.ts.map +1 -1
  22. package/dist/errors.js +572 -0
  23. package/dist/errors.js.map +1 -1
  24. package/dist/index.d.ts +126 -24
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +150 -22
  27. package/dist/index.js.map +1 -1
  28. package/dist/network-install-key.d.ts +56 -0
  29. package/dist/network-install-key.d.ts.map +1 -0
  30. package/dist/network-install-key.js +92 -0
  31. package/dist/network-install-key.js.map +1 -0
  32. package/dist/network-install.d.ts +134 -0
  33. package/dist/network-install.d.ts.map +1 -0
  34. package/dist/network-install.js +70 -0
  35. package/dist/network-install.js.map +1 -0
  36. package/dist/service-mcp.d.ts +49 -0
  37. package/dist/service-mcp.d.ts.map +1 -0
  38. package/dist/service-mcp.js +122 -0
  39. package/dist/service-mcp.js.map +1 -0
  40. package/dist/services/accounts.d.ts +1548 -0
  41. package/dist/services/accounts.d.ts.map +1 -0
  42. package/dist/services/accounts.js +724 -0
  43. package/dist/services/accounts.js.map +1 -0
  44. package/dist/services/agent-identity.d.ts +58 -0
  45. package/dist/services/agent-identity.d.ts.map +1 -0
  46. package/dist/services/agent-identity.js +50 -0
  47. package/dist/services/agent-identity.js.map +1 -0
  48. package/dist/services/agents.d.ts +78 -3
  49. package/dist/services/agents.d.ts.map +1 -1
  50. package/dist/services/agents.js +29 -2
  51. package/dist/services/agents.js.map +1 -1
  52. package/dist/services/audit.d.ts +5 -0
  53. package/dist/services/audit.d.ts.map +1 -1
  54. package/dist/services/audit.js +5 -0
  55. package/dist/services/audit.js.map +1 -1
  56. package/dist/services/billing.d.ts +67 -0
  57. package/dist/services/billing.d.ts.map +1 -0
  58. package/dist/services/billing.js +42 -0
  59. package/dist/services/billing.js.map +1 -0
  60. package/dist/services/brain.d.ts +122 -0
  61. package/dist/services/brain.d.ts.map +1 -0
  62. package/dist/services/brain.js +40 -0
  63. package/dist/services/brain.js.map +1 -0
  64. package/dist/services/calendar.d.ts +256 -0
  65. package/dist/services/calendar.d.ts.map +1 -0
  66. package/dist/services/calendar.js +75 -0
  67. package/dist/services/calendar.js.map +1 -0
  68. package/dist/services/catalogue.d.ts +185 -0
  69. package/dist/services/catalogue.d.ts.map +1 -0
  70. package/dist/services/catalogue.js +31 -0
  71. package/dist/services/catalogue.js.map +1 -0
  72. package/dist/services/chat-channels.d.ts +82 -0
  73. package/dist/services/chat-channels.d.ts.map +1 -0
  74. package/dist/services/chat-channels.js +42 -0
  75. package/dist/services/chat-channels.js.map +1 -0
  76. package/dist/services/control-policies.d.ts +409 -0
  77. package/dist/services/control-policies.d.ts.map +1 -0
  78. package/dist/services/control-policies.js +101 -0
  79. package/dist/services/control-policies.js.map +1 -0
  80. package/dist/services/control-socket.d.ts +201 -0
  81. package/dist/services/control-socket.d.ts.map +1 -0
  82. package/dist/services/control-socket.js +165 -0
  83. package/dist/services/control-socket.js.map +1 -0
  84. package/dist/services/credentials.d.ts +2 -1
  85. package/dist/services/credentials.d.ts.map +1 -1
  86. package/dist/services/credentials.js +3 -2
  87. package/dist/services/credentials.js.map +1 -1
  88. package/dist/services/detector-config.d.ts +13 -12
  89. package/dist/services/detector-config.d.ts.map +1 -1
  90. package/dist/services/detector-config.js +13 -12
  91. package/dist/services/detector-config.js.map +1 -1
  92. package/dist/services/drive.d.ts +257 -0
  93. package/dist/services/drive.d.ts.map +1 -0
  94. package/dist/services/drive.js +167 -0
  95. package/dist/services/drive.js.map +1 -0
  96. package/dist/services/dropoffs.d.ts +5 -1
  97. package/dist/services/dropoffs.d.ts.map +1 -1
  98. package/dist/services/dropoffs.js +3 -1
  99. package/dist/services/dropoffs.js.map +1 -1
  100. package/dist/services/evidence-packs.d.ts +4 -2
  101. package/dist/services/evidence-packs.d.ts.map +1 -1
  102. package/dist/services/evidence-packs.js +4 -2
  103. package/dist/services/evidence-packs.js.map +1 -1
  104. package/dist/services/flagged-content.d.ts +30 -0
  105. package/dist/services/flagged-content.d.ts.map +1 -0
  106. package/dist/services/flagged-content.js +24 -0
  107. package/dist/services/flagged-content.js.map +1 -0
  108. package/dist/services/governance.d.ts +69 -0
  109. package/dist/services/governance.d.ts.map +1 -0
  110. package/dist/services/governance.js +39 -0
  111. package/dist/services/governance.js.map +1 -0
  112. package/dist/services/identity.d.ts +44 -4
  113. package/dist/services/identity.d.ts.map +1 -1
  114. package/dist/services/identity.js +54 -6
  115. package/dist/services/identity.js.map +1 -1
  116. package/dist/services/inbound-webhooks.d.ts +12 -1
  117. package/dist/services/inbound-webhooks.d.ts.map +1 -1
  118. package/dist/services/inbound-webhooks.js +7 -0
  119. package/dist/services/inbound-webhooks.js.map +1 -1
  120. package/dist/services/intents.d.ts +8 -2
  121. package/dist/services/intents.d.ts.map +1 -1
  122. package/dist/services/intents.js +7 -3
  123. package/dist/services/intents.js.map +1 -1
  124. package/dist/services/llm.d.ts +73 -1
  125. package/dist/services/llm.d.ts.map +1 -1
  126. package/dist/services/llm.js +62 -0
  127. package/dist/services/llm.js.map +1 -1
  128. package/dist/services/making.d.ts +263 -0
  129. package/dist/services/making.d.ts.map +1 -0
  130. package/dist/services/making.js +114 -0
  131. package/dist/services/making.js.map +1 -0
  132. package/dist/services/meetings.d.ts +183 -0
  133. package/dist/services/meetings.d.ts.map +1 -0
  134. package/dist/services/meetings.js +148 -0
  135. package/dist/services/meetings.js.map +1 -0
  136. package/dist/services/memory.d.ts +288 -0
  137. package/dist/services/memory.d.ts.map +1 -0
  138. package/dist/services/memory.js +116 -0
  139. package/dist/services/memory.js.map +1 -0
  140. package/dist/services/message-access.d.ts +50 -0
  141. package/dist/services/message-access.d.ts.map +1 -0
  142. package/dist/services/message-access.js +36 -0
  143. package/dist/services/message-access.js.map +1 -0
  144. package/dist/services/missions.d.ts +93 -7
  145. package/dist/services/missions.d.ts.map +1 -1
  146. package/dist/services/missions.js +29 -1
  147. package/dist/services/missions.js.map +1 -1
  148. package/dist/services/network.d.ts +266 -0
  149. package/dist/services/network.d.ts.map +1 -0
  150. package/dist/services/network.js +209 -0
  151. package/dist/services/network.js.map +1 -0
  152. package/dist/services/partner-accounts.d.ts +215 -0
  153. package/dist/services/partner-accounts.d.ts.map +1 -0
  154. package/dist/services/partner-accounts.js +133 -0
  155. package/dist/services/partner-accounts.js.map +1 -0
  156. package/dist/services/passports.d.ts +3 -2
  157. package/dist/services/passports.d.ts.map +1 -1
  158. package/dist/services/passports.js +3 -2
  159. package/dist/services/passports.js.map +1 -1
  160. package/dist/services/payments.d.ts +126 -0
  161. package/dist/services/payments.d.ts.map +1 -0
  162. package/dist/services/payments.js +66 -0
  163. package/dist/services/payments.js.map +1 -0
  164. package/dist/services/pii-config.d.ts +7 -17
  165. package/dist/services/pii-config.d.ts.map +1 -1
  166. package/dist/services/pii-config.js +9 -19
  167. package/dist/services/pii-config.js.map +1 -1
  168. package/dist/services/post.d.ts +240 -0
  169. package/dist/services/post.d.ts.map +1 -0
  170. package/dist/services/post.js +99 -0
  171. package/dist/services/post.js.map +1 -0
  172. package/dist/services/proxy.d.ts +20 -2
  173. package/dist/services/proxy.d.ts.map +1 -1
  174. package/dist/services/proxy.js +31 -1
  175. package/dist/services/proxy.js.map +1 -1
  176. package/dist/services/rentahuman.d.ts +92 -0
  177. package/dist/services/rentahuman.d.ts.map +1 -0
  178. package/dist/services/rentahuman.js +53 -0
  179. package/dist/services/rentahuman.js.map +1 -0
  180. package/dist/services/scan.d.ts +1 -1
  181. package/dist/services/scan.d.ts.map +1 -1
  182. package/dist/services/scan.js +1 -1
  183. package/dist/services/scan.js.map +1 -1
  184. package/dist/services/services.d.ts +28 -2
  185. package/dist/services/services.d.ts.map +1 -1
  186. package/dist/services/services.js +49 -1
  187. package/dist/services/services.js.map +1 -1
  188. package/dist/services/team.d.ts +13 -1
  189. package/dist/services/team.d.ts.map +1 -1
  190. package/dist/services/team.js +12 -0
  191. package/dist/services/team.js.map +1 -1
  192. package/dist/services/trust.d.ts +39 -0
  193. package/dist/services/trust.d.ts.map +1 -0
  194. package/dist/services/trust.js +35 -0
  195. package/dist/services/trust.js.map +1 -0
  196. package/dist/services/usage.d.ts +1 -1
  197. package/dist/services/usage.js +1 -1
  198. package/dist/services/wake.d.ts +257 -0
  199. package/dist/services/wake.d.ts.map +1 -0
  200. package/dist/services/wake.js +80 -0
  201. package/dist/services/wake.js.map +1 -0
  202. package/dist/services/website.d.ts +188 -0
  203. package/dist/services/website.d.ts.map +1 -0
  204. package/dist/services/website.js +135 -0
  205. package/dist/services/website.js.map +1 -0
  206. package/dist/types.d.ts +259 -25
  207. package/dist/types.d.ts.map +1 -1
  208. package/dist/verify-agent-identity.d.ts +73 -0
  209. package/dist/verify-agent-identity.d.ts.map +1 -0
  210. package/dist/verify-agent-identity.js +106 -0
  211. package/dist/verify-agent-identity.js.map +1 -0
  212. package/dist/verify-network.d.ts +159 -0
  213. package/dist/verify-network.d.ts.map +1 -0
  214. package/dist/verify-network.js +153 -0
  215. package/dist/verify-network.js.map +1 -0
  216. package/dist/wake-webhook.d.ts +57 -0
  217. package/dist/wake-webhook.d.ts.map +1 -0
  218. package/dist/wake-webhook.js +60 -0
  219. package/dist/wake-webhook.js.map +1 -0
  220. package/dist/wallet-key.d.ts +30 -0
  221. package/dist/wallet-key.d.ts.map +1 -0
  222. package/dist/wallet-key.js +108 -0
  223. package/dist/wallet-key.js.map +1 -0
  224. package/dist/webhook.d.ts +63 -0
  225. package/dist/webhook.d.ts.map +1 -0
  226. package/dist/webhook.js +136 -0
  227. package/dist/webhook.js.map +1 -0
  228. package/dist/x402-pay.d.ts +139 -0
  229. package/dist/x402-pay.d.ts.map +1 -0
  230. package/dist/x402-pay.js +235 -0
  231. package/dist/x402-pay.js.map +1 -0
  232. package/package.json +2 -1
  233. package/dist/services/partner-connect.d.ts +0 -64
  234. package/dist/services/partner-connect.d.ts.map +0 -1
  235. package/dist/services/partner-connect.js +0 -42
  236. package/dist/services/partner-connect.js.map +0 -1
  237. package/dist/services/partner-tenants.d.ts +0 -126
  238. package/dist/services/partner-tenants.d.ts.map +0 -1
  239. package/dist/services/partner-tenants.js +0 -79
  240. package/dist/services/partner-tenants.js.map +0 -1
@@ -0,0 +1,92 @@
1
+ import { createHash, randomBytes } from 'node:crypto';
2
+ import { SignJWT, exportJWK, exportPKCS8, generateKeyPair, importPKCS8 } from 'jose';
3
+ // An install's key, and the two things it signs: the proof of possession that
4
+ // registers it, and the single-use request (the "install proof") that every
5
+ // call from the install to the network carries as its bearer value. Formats:
6
+ // `packages/shared/src/schemas/network.ts` in the STACK repository, and
7
+ // `docs/architecture/network.md`.
8
+ /** Who an install's signed requests are addressed to. */
9
+ export const NETWORK_AUDIENCE = 'stack:network';
10
+ export const NETWORK_INSTALL_PROOF_TYP = 'stack-install+jwt';
11
+ export const NETWORK_INSTALL_POP_TYP = 'stack-install-pop+jwt';
12
+ /** A proof lives this long by default, in seconds; the API accepts at most 120. */
13
+ export const INSTALL_PROOF_LIFETIME_SECONDS = 60;
14
+ /** RFC 7638 thumbprint of an Ed25519 public key: the key's id everywhere in the network. */
15
+ export function installKeyThumbprint(jwk) {
16
+ return createHash('sha256').update(`{"crv":"Ed25519","kty":"OKP","x":"${jwk.x}"}`).digest('base64url');
17
+ }
18
+ /** The digest a countersignature binds: base64url SHA-256 of the passport's compact serialisation, byte for byte as issued. */
19
+ export function passportDigest(passport) {
20
+ return createHash('sha256').update(passport, 'utf8').digest('base64url');
21
+ }
22
+ /**
23
+ * An install's signing key. Create one with {@link InstallKey.generate}, keep the
24
+ * private half in a file only the install can read ({@link InstallKey.toPem}), and
25
+ * register the public half with `stack.network.installs.registerKey`.
26
+ */
27
+ export class InstallKey {
28
+ privateKey;
29
+ publicJwk;
30
+ kid;
31
+ constructor(privateKey,
32
+ /** The public key, as the API takes it. */
33
+ publicJwk,
34
+ /** The key's thumbprint: its id in the network. */
35
+ kid) {
36
+ this.privateKey = privateKey;
37
+ this.publicJwk = publicJwk;
38
+ this.kid = kid;
39
+ }
40
+ /** A new key pair. The private half exists only in the returned object: write it out with `toPem()`. */
41
+ static async generate() {
42
+ const { privateKey } = await generateKeyPair('EdDSA', { crv: 'Ed25519', extractable: true });
43
+ return InstallKey.fromPrivate(privateKey);
44
+ }
45
+ /** Load a key from its PKCS#8 PEM, as written by `toPem()`. */
46
+ static async fromPem(pem) {
47
+ return InstallKey.fromPrivate(await importPKCS8(pem, 'EdDSA', { extractable: true }));
48
+ }
49
+ static async fromPrivate(privateKey) {
50
+ const jwk = await exportJWK(privateKey);
51
+ if (jwk.kty !== 'OKP' || jwk.crv !== 'Ed25519' || typeof jwk.x !== 'string') {
52
+ throw new Error('An install key is an Ed25519 key');
53
+ }
54
+ const publicJwk = { kty: 'OKP', crv: 'Ed25519', x: jwk.x };
55
+ return new InstallKey(privateKey, publicJwk, installKeyThumbprint(publicJwk));
56
+ }
57
+ /** The private key as PKCS#8 PEM. Secret: write it to a file with mode 0600 and never log it. */
58
+ async toPem() {
59
+ return exportPKCS8(this.privateKey);
60
+ }
61
+ /**
62
+ * The proof of possession that registers this key: a JWS over the challenge STACK
63
+ * issued, signed with the key being registered.
64
+ */
65
+ async signKeyProof(installId, nonce, options = {}) {
66
+ const iat = Math.floor((options.now ?? new Date()).getTime() / 1000);
67
+ return new SignJWT({ install: installId, nonce })
68
+ .setProtectedHeader({ alg: 'EdDSA', typ: NETWORK_INSTALL_POP_TYP, kid: this.kid })
69
+ .setIssuer(this.kid)
70
+ .setAudience(NETWORK_AUDIENCE)
71
+ .setIssuedAt(iat)
72
+ .setExpirationTime(iat + 120)
73
+ .sign(this.privateKey);
74
+ }
75
+ /**
76
+ * One signed request: a fresh `jti` every time, so a proof is good for exactly one
77
+ * call. `claims` carries `act` and the fields that action needs.
78
+ */
79
+ async signProof(installId, claims, options = {}) {
80
+ const iat = Math.floor((options.now ?? new Date()).getTime() / 1000);
81
+ return new SignJWT({ ...claims })
82
+ .setProtectedHeader({ alg: 'EdDSA', typ: NETWORK_INSTALL_PROOF_TYP, kid: this.kid })
83
+ .setIssuer(installId)
84
+ .setSubject(installId)
85
+ .setAudience(NETWORK_AUDIENCE)
86
+ .setIssuedAt(iat)
87
+ .setExpirationTime(iat + (options.lifetimeSeconds ?? INSTALL_PROOF_LIFETIME_SECONDS))
88
+ .setJti(randomBytes(18).toString('base64url'))
89
+ .sign(this.privateKey);
90
+ }
91
+ }
92
+ //# sourceMappingURL=network-install-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-install-key.js","sourceRoot":"","sources":["../src/network-install-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAErF,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAAwE;AACxE,kCAAkC;AAElC,yDAAyD;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAChD,MAAM,CAAC,MAAM,yBAAyB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AAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS,CACb,SAAiB,EACjB,MAA6D,EAC7D,UAAoD,EAAE;QAEtD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QACrE,OAAO,IAAI,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;aAC9B,kBAAkB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,yBAAyB,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC;aACnF,SAAS,CAAC,SAAS,CAAC;aACpB,UAAU,CAAC,SAAS,CAAC;aACrB,WAAW,CAAC,gBAAgB,CAAC;aAC7B,WAAW,CAAC,GAAG,CAAC;aAChB,iBAAiB,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,eAAe,IAAI,8BAA8B,CAAC,CAAC;aACpF,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;aAC7C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,134 @@
1
+ import { InstallKey } from './network-install-key.js';
2
+ import type { NetworkRevocation, NetworkRevocationKind, NetworkRevocationReason } from './services/network.js';
3
+ import { type DetectionRuleSet, type NetworkKeySource } from './verify-network.js';
4
+ export interface InstallClientOptions {
5
+ /** The install's id (`ins_...`), from `stack.network.installs.register`. */
6
+ installId: string;
7
+ /** The install's key. Load it with `InstallKey.fromPem`. */
8
+ key: InstallKey;
9
+ /** The API base URL. Defaults to `STACK_API_URL`, then https://api.getstack.run. */
10
+ baseUrl?: string;
11
+ /**
12
+ * STACK's public keys, for checking what STACK signs. Fetched from the API's
13
+ * `/v1/network/jwks.json` when omitted; pin them to trust nothing the network
14
+ * serves about itself.
15
+ */
16
+ keys?: NetworkKeySource;
17
+ }
18
+ /** What an agent declared for its passport and what it then did: what STACK grades for intent deviation. */
19
+ export interface IntentDeviationInput {
20
+ declared: {
21
+ summary: string;
22
+ services: string[];
23
+ };
24
+ observed: {
25
+ services_used: string[];
26
+ tool_calls: Array<{
27
+ service: string;
28
+ method: string;
29
+ target?: string;
30
+ }>;
31
+ actions_count: number;
32
+ summary?: string;
33
+ };
34
+ }
35
+ /** STACK's grade of a checkout: a score from 0 (matched the intent) to 1 (unrelated), and a flag from 0.4. */
36
+ export interface IntentDeviationResult {
37
+ request_id: string;
38
+ /** False when no model could grade it; `score` and `flag` are then null. */
39
+ graded: boolean;
40
+ score: number | null;
41
+ flag: {
42
+ severity: 'warning' | 'critical';
43
+ message: string;
44
+ } | null;
45
+ duration_ms: number;
46
+ }
47
+ export interface ClassifyResult {
48
+ verdict: 'clean' | 'suspicious' | 'critical';
49
+ request_id: string;
50
+ duration_ms: number;
51
+ rules_version: string;
52
+ /** The rule that fired, with up to about 80 characters of the text that matched. */
53
+ match: {
54
+ pattern_id: string;
55
+ severity: string;
56
+ field_path: string;
57
+ matched_excerpt: string;
58
+ encoding?: string;
59
+ } | null;
60
+ /** The model's verdict, when it ran. */
61
+ llm: {
62
+ verdict: string;
63
+ confidence: number;
64
+ reasoning: string;
65
+ model: string;
66
+ } | null;
67
+ /** Set when the model could not answer: the verdict is the pattern layers' alone. */
68
+ l3_degraded: {
69
+ reason: string;
70
+ duration_ms: number;
71
+ } | null;
72
+ }
73
+ export interface Countersignature {
74
+ id: string;
75
+ /** The compact JWS. Hand it, with the passport, to whoever needs to trust it. */
76
+ countersignature: string;
77
+ expires_at: string;
78
+ install: string;
79
+ passport_digest: string;
80
+ }
81
+ export interface FetchedRules extends DetectionRuleSet {
82
+ /** The signed statement as served, to keep alongside the rules. */
83
+ statement: string;
84
+ }
85
+ export declare class InstallClient {
86
+ private readonly options;
87
+ private readonly baseUrl;
88
+ private keysPromise;
89
+ constructor(options: InstallClientOptions);
90
+ /**
91
+ * The current detection rule set, checked against STACK's keys. Pass the highest
92
+ * `revision` you already run as `heldRevision`: a lower one is refused, and so is
93
+ * an expired set. Metered as one action.
94
+ */
95
+ rules(options?: {
96
+ heldRevision?: number;
97
+ }): Promise<FetchedRules>;
98
+ /**
99
+ * Send content to STACK's classifier and get a verdict. The content leaves the
100
+ * install: at most its first 2,500 and last 1,500 characters reach the model, and
101
+ * STACK keeps none of it. Metered as one action, plus the model call at cost.
102
+ */
103
+ classify(content: string | Record<string, unknown>, context?: 'email' | 'document' | 'webpage' | 'chat_log' | 'api_response' | 'calendar' | 'other'): Promise<ClassifyResult>;
104
+ /**
105
+ * Have STACK grade a checkout for intent deviation: what the agent declared against what it did. The declared intent
106
+ * and the observed behaviour leave the install, with no identifier; STACK keeps none of it. Metered as one action,
107
+ * plus the model call at cost. Signed with a proof for `classify`.
108
+ */
109
+ gradeIntentDeviation(input: IntentDeviationInput): Promise<IntentDeviationResult>;
110
+ /**
111
+ * Have STACK countersign a passport this install issued. Only the passport's digest
112
+ * is sent. The install's key must be the one that signed the passport. Ask again
113
+ * when you refresh the passport. Metered as one action.
114
+ */
115
+ countersign(input: {
116
+ passport: string;
117
+ agent?: string;
118
+ passportId?: string;
119
+ ttlSeconds?: number;
120
+ }): Promise<Countersignature>;
121
+ /**
122
+ * Publish a revocation of one of this install's passports (subject: its digest),
123
+ * agents, its key (subject: its thumbprint) or the install. Public: the subject
124
+ * and reason appear on the list counterparties read. Never metered.
125
+ */
126
+ publishRevocation(input: {
127
+ kind: NetworkRevocationKind;
128
+ subject: string;
129
+ reason?: NetworkRevocationReason;
130
+ }): Promise<NetworkRevocation>;
131
+ private keys;
132
+ private call;
133
+ }
134
+ //# sourceMappingURL=network-install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-install.d.ts","sourceRoot":"","sources":["../src/network-install.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAA2C,MAAM,0BAA0B,CAAC;AAC/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AO,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;IAInL;;;;OAIG;IACG,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIvF;;;;OAIG;IACG,WAAW,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAenI;;;;OAIG;IACG,iBAAiB,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,qBAAqB,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,uBAAuB,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAU9I,OAAO,CAAC,IAAI;YAME,IAAI;CAInB"}
@@ -0,0 +1,70 @@
1
+ import { sendUnauthenticated } from './client.js';
2
+ import { passportDigest } from './network-install-key.js';
3
+ import { verifyDetectionRules } from './verify-network.js';
4
+ export class InstallClient {
5
+ options;
6
+ baseUrl;
7
+ keysPromise = null;
8
+ constructor(options) {
9
+ this.options = options;
10
+ this.baseUrl = (options.baseUrl ?? process.env['STACK_API_URL'] ?? 'https://api.getstack.run').replace(/\/$/, '');
11
+ }
12
+ /**
13
+ * The current detection rule set, checked against STACK's keys. Pass the highest
14
+ * `revision` you already run as `heldRevision`: a lower one is refused, and so is
15
+ * an expired set. Metered as one action.
16
+ */
17
+ async rules(options = {}) {
18
+ const response = await this.call('POST', '/v1/network/detection/rules', 'rules', {}, {});
19
+ const rules = await verifyDetectionRules(response.statement, { ...(await this.keys()), ...options });
20
+ return { ...rules, statement: response.statement };
21
+ }
22
+ /**
23
+ * Send content to STACK's classifier and get a verdict. The content leaves the
24
+ * install: at most its first 2,500 and last 1,500 characters reach the model, and
25
+ * STACK keeps none of it. Metered as one action, plus the model call at cost.
26
+ */
27
+ async classify(content, context) {
28
+ return this.call('POST', '/v1/network/detection/classify', 'classify', {}, { content, ...(context ? { context } : {}) });
29
+ }
30
+ /**
31
+ * Have STACK grade a checkout for intent deviation: what the agent declared against what it did. The declared intent
32
+ * and the observed behaviour leave the install, with no identifier; STACK keeps none of it. Metered as one action,
33
+ * plus the model call at cost. Signed with a proof for `classify`.
34
+ */
35
+ async gradeIntentDeviation(input) {
36
+ return this.call('POST', '/v1/network/detection/intent-deviation', 'classify', {}, input);
37
+ }
38
+ /**
39
+ * Have STACK countersign a passport this install issued. Only the passport's digest
40
+ * is sent. The install's key must be the one that signed the passport. Ask again
41
+ * when you refresh the passport. Metered as one action.
42
+ */
43
+ async countersign(input) {
44
+ return this.call('POST', '/v1/network/countersignatures', 'countersign', {
45
+ pd: passportDigest(input.passport),
46
+ ...(input.passportId ? { pjti: input.passportId } : {}),
47
+ ...(input.agent ? { agent: input.agent } : {}),
48
+ ...(input.ttlSeconds !== undefined ? { ttl: input.ttlSeconds } : {}),
49
+ }, {});
50
+ }
51
+ /**
52
+ * Publish a revocation of one of this install's passports (subject: its digest),
53
+ * agents, its key (subject: its thumbprint) or the install. Public: the subject
54
+ * and reason appear on the list counterparties read. Never metered.
55
+ */
56
+ async publishRevocation(input) {
57
+ return this.call('POST', '/v1/network/revocations', 'revoke', { kind: input.kind, subject: input.subject, ...(input.reason ? { reason: input.reason } : {}) }, {});
58
+ }
59
+ keys() {
60
+ if (this.options.keys)
61
+ return Promise.resolve(this.options.keys);
62
+ this.keysPromise ??= sendUnauthenticated(`${this.baseUrl}/v1/network/jwks.json`, 'GET').then((jwks) => ({ jwks }));
63
+ return this.keysPromise;
64
+ }
65
+ async call(method, path, act, claims, body) {
66
+ const proof = await this.options.key.signProof(this.options.installId, { act, ...claims });
67
+ return sendUnauthenticated(`${this.baseUrl}${path}`, method, body, { Authorization: `Bearer ${proof}` });
68
+ }
69
+ }
70
+ //# sourceMappingURL=network-install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network-install.js","sourceRoot":"","sources":["../src/network-install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAc,cAAc,EAA2B,MAAM,0BAA0B,CAAC;AAE/F,OAAO,EAAE,oBAAoB,EAAgD,MAAM,qBAAqB,CAAC;AAsEzG,MAAM,OAAO,aAAa;IAIK;IAHZ,OAAO,CAAS;IACzB,WAAW,GAAqC,IAAI,CAAC;IAE7D,YAA6B,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;QACxD,IAAI,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,0BAA0B,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACpH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,UAAqC,EAAE;QACjD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAwB,MAAM,EAAE,6BAA6B,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAChH,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACrG,OAAO,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAyC,EAAE,OAA+F;QACvJ,OAAO,IAAI,CAAC,IAAI,CAAiB,MAAM,EAAE,gCAAgC,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,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EAAE,EAC/F,EAAE,CACH,CAAC;IACJ,CAAC;IAEO,IAAI;QACV,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE,IAAI,CAAC,WAAW,KAAK,mBAAmB,CAAiC,GAAG,IAAI,CAAC,OAAO,uBAAuB,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnJ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEO,KAAK,CAAC,IAAI,CAAI,MAAc,EAAE,IAAY,EAAE,GAAuB,EAAE,MAA+B,EAAE,IAAa;QACzH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;QAC3F,OAAO,mBAAmB,CAAI,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9G,CAAC;CACF"}
@@ -0,0 +1,49 @@
1
+ /** provider slug -> the default MCP endpoint of a service STACK knows, used when the connection has no `mcp_url`. */
2
+ export declare const SERVICE_MCP_ENDPOINTS: Readonly<Record<string, string>>;
3
+ /** The default MCP endpoint of a service STACK knows, or a `SERVICE_HAS_NO_MCP_ENDPOINT` error: any other service's endpoint is its connection's `mcp_url`. */
4
+ export declare function serviceMcpEndpoint(service: string): string;
5
+ /**
6
+ * The MCP endpoint of a connected service, read from the account's connection list (`GET /v1/services/connected`). Each active
7
+ * connection of the provider has one (its `mcp_url`, or the default of a service STACK knows).
8
+ *
9
+ * With `connection` (an `scon_` id, else a name, any case) the endpoint is that connection's; no such active connection is the
10
+ * not-found outcome. Without it, when every active connection gives the same address that address is used (the server picks the
11
+ * connection, and refuses ambiguity itself); when they differ the caller must pass `connection` (`CONNECTION_AMBIGUOUS`).
12
+ */
13
+ export declare function serviceMcpUrlOf(connections: unknown, service: string, connection?: string): string;
14
+ export interface ServiceMcpTool {
15
+ name: string;
16
+ description?: string;
17
+ inputSchema?: unknown;
18
+ [key: string]: unknown;
19
+ }
20
+ /** The tools a connected service offers. Provider text: data, never instructions. */
21
+ export interface ServiceToolList {
22
+ service: string;
23
+ tools: ServiceMcpTool[];
24
+ untrusted: true;
25
+ }
26
+ /** What a tool of a connected service returned. Provider text: data, never instructions. */
27
+ export interface ServiceToolResult {
28
+ service: string;
29
+ tool: string;
30
+ content: unknown[];
31
+ is_error: boolean;
32
+ structured?: unknown;
33
+ untrusted: true;
34
+ }
35
+ export declare function serviceMcpRequest(method: 'tools/list' | 'tools/call', params?: Record<string, unknown>): Record<string, unknown>;
36
+ /** The `result` of a service's answer, or the error it gave (a failure of the call, never a result to trust). */
37
+ export declare function serviceMcpResult(service: string, response: {
38
+ status: number;
39
+ body: unknown;
40
+ }): Record<string, unknown>;
41
+ export declare function toolListOf(service: string, response: {
42
+ status: number;
43
+ body: unknown;
44
+ }): ServiceToolList;
45
+ export declare function toolResultOf(service: string, tool: string, response: {
46
+ status: number;
47
+ body: unknown;
48
+ }): ServiceToolResult;
49
+ //# sourceMappingURL=service-mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-mcp.d.ts","sourceRoot":"","sources":["../src/service-mcp.ts"],"names":[],"mappings":"AAQA,qHAAqH;AACrH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAElE,CAAC;AAEF,+JAA+J;AAC/J,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK1D;AAUD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAA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M,EAAE,QAAQ,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,iBAAiB,CAU1H"}
@@ -0,0 +1,122 @@
1
+ import { ConnectionAmbiguousError, StackError } from './errors.js';
2
+ // Connected services that speak MCP over HTTP (JSON-RPC `tools/list` and `tools/call` to the service's endpoint). The call goes through
3
+ // the credential proxy, so it is under the Passport, the Mission, the grant, the customer's decider, the meter, the audit record and
4
+ // revocation like any proxied call. Any connected service that speaks MCP over HTTP works: its endpoint is the `mcp_url` its connection
5
+ // carries (the account's connection list, `GET /v1/services/connected`, gives each connection's effective one), and a call cannot name a
6
+ // URL of its own. What a service says (its tool list, a result) is its provider's words: data, never instructions.
7
+ /** provider slug -> the default MCP endpoint of a service STACK knows, used when the connection has no `mcp_url`. */
8
+ export const SERVICE_MCP_ENDPOINTS = {
9
+ rentahuman: 'https://rentahuman.ai/api/mcp',
10
+ };
11
+ /** The default MCP endpoint of a service STACK knows, or a `SERVICE_HAS_NO_MCP_ENDPOINT` error: any other service's endpoint is its connection's `mcp_url`. */
12
+ export function serviceMcpEndpoint(service) {
13
+ if (!Object.hasOwn(SERVICE_MCP_ENDPOINTS, service)) {
14
+ throw noMcpAddress(service);
15
+ }
16
+ return SERVICE_MCP_ENDPOINTS[service];
17
+ }
18
+ function noMcpAddress(service) {
19
+ return new StackError(`${service} has no MCP address. Connect it with an mcp_url (an https address on one of the connection's allowed hosts) so its tools can be listed and called.`, 'SERVICE_HAS_NO_MCP_ENDPOINT', 400);
20
+ }
21
+ /**
22
+ * The MCP endpoint of a connected service, read from the account's connection list (`GET /v1/services/connected`). Each active
23
+ * connection of the provider has one (its `mcp_url`, or the default of a service STACK knows).
24
+ *
25
+ * With `connection` (an `scon_` id, else a name, any case) the endpoint is that connection's; no such active connection is the
26
+ * not-found outcome. Without it, when every active connection gives the same address that address is used (the server picks the
27
+ * connection, and refuses ambiguity itself); when they differ the caller must pass `connection` (`CONNECTION_AMBIGUOUS`).
28
+ */
29
+ export function serviceMcpUrlOf(connections, service, connection) {
30
+ const active = [];
31
+ if (Array.isArray(connections)) {
32
+ for (const row of connections) {
33
+ if (typeof row !== 'object' || row === null)
34
+ continue;
35
+ const candidate = row;
36
+ if (candidate['provider'] === service && candidate['status'] === 'active')
37
+ active.push(candidate);
38
+ }
39
+ }
40
+ const urlOf = (row) => typeof row['mcp_url'] === 'string' && row['mcp_url'] !== ''
41
+ ? row['mcp_url']
42
+ : Object.hasOwn(SERVICE_MCP_ENDPOINTS, service)
43
+ ? SERVICE_MCP_ENDPOINTS[service]
44
+ : null;
45
+ if (connection !== undefined) {
46
+ const wanted = connection.trim().toLowerCase();
47
+ const chosen = active.find((row) => row['id'] === connection) ??
48
+ active.find((row) => typeof row['name'] === 'string' && row['name'].trim().toLowerCase() === wanted);
49
+ if (!chosen)
50
+ throw new StackError(`${service} has no active connection "${connection}".`, 'NOT_FOUND', 404);
51
+ const url = urlOf(chosen);
52
+ if (url === null)
53
+ throw noMcpAddress(service);
54
+ return url;
55
+ }
56
+ const urls = new Set(active.map(urlOf));
57
+ if (urls.size > 1) {
58
+ const names = active.map((row) => String(row['name'] ?? row['id'])).join(', ');
59
+ throw new ConnectionAmbiguousError(`${service} has several connections (${names}) with different MCP addresses. Pass connection with the id or name of the one to use.`, 409, { connections: active.map((row) => ({ id: row['id'], name: row['name'] })) });
60
+ }
61
+ const [only] = urls;
62
+ if (only)
63
+ return only;
64
+ throw noMcpAddress(service);
65
+ }
66
+ export function serviceMcpRequest(method, params) {
67
+ return { jsonrpc: '2.0', id: 1, method, ...(params ? { params } : {}) };
68
+ }
69
+ /** The JSON-RPC answer in an HTTP body: JSON, or the one `data:` event of an event stream. */
70
+ function jsonRpcOf(body) {
71
+ let value = body;
72
+ if (typeof value === 'string') {
73
+ const data = value
74
+ .split(/\r?\n/)
75
+ .filter((line) => line.startsWith('data:'))
76
+ .map((line) => line.slice(5).trim())
77
+ .filter(Boolean);
78
+ try {
79
+ value = JSON.parse(data.length > 0 ? data[data.length - 1] : value);
80
+ }
81
+ catch {
82
+ return null;
83
+ }
84
+ }
85
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
86
+ }
87
+ /** The `result` of a service's answer, or the error it gave (a failure of the call, never a result to trust). */
88
+ export function serviceMcpResult(service, response) {
89
+ if (response.status < 200 || response.status >= 300) {
90
+ throw new StackError(`${service} answered ${response.status}.`, 'SERVICE_MCP_HTTP_ERROR', response.status === 401 || response.status === 403 ? 403 : 502, { upstream_status: response.status });
91
+ }
92
+ const rpc = jsonRpcOf(response.body);
93
+ if (!rpc)
94
+ throw new StackError(`${service} did not answer in MCP.`, 'SERVICE_MCP_BAD_ANSWER', 502);
95
+ const error = rpc['error'];
96
+ if (typeof error === 'object' && error !== null) {
97
+ const record = error;
98
+ throw new StackError(`${service} refused the call: ${String(record['message'] ?? 'no reason given')}`, 'SERVICE_MCP_ERROR', 502, { upstream_code: record['code'] });
99
+ }
100
+ const result = rpc['result'];
101
+ if (typeof result !== 'object' || result === null || Array.isArray(result)) {
102
+ throw new StackError(`${service} did not answer in MCP.`, 'SERVICE_MCP_BAD_ANSWER', 502);
103
+ }
104
+ return result;
105
+ }
106
+ export function toolListOf(service, response) {
107
+ const result = serviceMcpResult(service, response);
108
+ const tools = Array.isArray(result['tools']) ? result['tools'].filter((t) => typeof t === 'object' && t !== null && typeof t.name === 'string') : [];
109
+ return { service, tools, untrusted: true };
110
+ }
111
+ export function toolResultOf(service, tool, response) {
112
+ const result = serviceMcpResult(service, response);
113
+ return {
114
+ service,
115
+ tool,
116
+ content: Array.isArray(result['content']) ? result['content'] : [],
117
+ is_error: result['isError'] === true,
118
+ ...(result['structuredContent'] !== undefined ? { structured: result['structuredContent'] } : {}),
119
+ untrusted: true,
120
+ };
121
+ }
122
+ //# sourceMappingURL=service-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-mcp.js","sourceRoot":"","sources":["../src/service-mcp.ts"],"names":[],"mappings":"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