@agentjam/sdk 0.0.0-stage → 0.2.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 (274) hide show
  1. package/README.md +181 -2
  2. package/dist/adapters/ai.d.ts +47 -0
  3. package/dist/adapters/ai.d.ts.map +1 -0
  4. package/dist/adapters/ai.js +168 -0
  5. package/dist/adapters/ai.js.map +1 -0
  6. package/dist/adapters/anthropic.d.ts +68 -0
  7. package/dist/adapters/anthropic.d.ts.map +1 -0
  8. package/dist/adapters/anthropic.js +193 -0
  9. package/dist/adapters/anthropic.js.map +1 -0
  10. package/dist/adapters/openai.d.ts +35 -0
  11. package/dist/adapters/openai.d.ts.map +1 -0
  12. package/dist/adapters/openai.js +80 -0
  13. package/dist/adapters/openai.js.map +1 -0
  14. package/dist/adapters/openaiAgents.d.ts +39 -0
  15. package/dist/adapters/openaiAgents.d.ts.map +1 -0
  16. package/dist/adapters/openaiAgents.js +152 -0
  17. package/dist/adapters/openaiAgents.js.map +1 -0
  18. package/dist/adapters/shared.d.ts +72 -0
  19. package/dist/adapters/shared.d.ts.map +1 -0
  20. package/dist/adapters/shared.js +174 -0
  21. package/dist/adapters/shared.js.map +1 -0
  22. package/dist/agent.d.ts +462 -0
  23. package/dist/agent.d.ts.map +1 -0
  24. package/dist/agent.js +1820 -0
  25. package/dist/agent.js.map +1 -0
  26. package/dist/artifacts.d.ts +79 -0
  27. package/dist/artifacts.d.ts.map +1 -0
  28. package/dist/artifacts.js +367 -0
  29. package/dist/artifacts.js.map +1 -0
  30. package/dist/attachments.d.ts +43 -0
  31. package/dist/attachments.d.ts.map +1 -0
  32. package/dist/attachments.js +69 -0
  33. package/dist/attachments.js.map +1 -0
  34. package/dist/connections.d.ts +109 -0
  35. package/dist/connections.d.ts.map +1 -0
  36. package/dist/connections.js +274 -0
  37. package/dist/connections.js.map +1 -0
  38. package/dist/content.d.ts +36 -0
  39. package/dist/content.d.ts.map +1 -0
  40. package/dist/content.js +21 -0
  41. package/dist/content.js.map +1 -0
  42. package/dist/cron.d.ts +31 -0
  43. package/dist/cron.d.ts.map +1 -0
  44. package/dist/cron.js +93 -0
  45. package/dist/cron.js.map +1 -0
  46. package/dist/errors.d.ts +227 -0
  47. package/dist/errors.d.ts.map +1 -0
  48. package/dist/errors.js +253 -0
  49. package/dist/errors.js.map +1 -0
  50. package/dist/events.d.ts +57 -0
  51. package/dist/events.d.ts.map +1 -0
  52. package/dist/events.js +24 -0
  53. package/dist/events.js.map +1 -0
  54. package/dist/idempotency.d.ts +21 -0
  55. package/dist/idempotency.d.ts.map +1 -0
  56. package/dist/idempotency.js +46 -0
  57. package/dist/idempotency.js.map +1 -0
  58. package/dist/index.d.ts +44 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +18 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/inputs.d.ts +22 -0
  63. package/dist/inputs.d.ts.map +1 -0
  64. package/dist/inputs.js +72 -0
  65. package/dist/inputs.js.map +1 -0
  66. package/dist/mpp.d.ts +76 -0
  67. package/dist/mpp.d.ts.map +1 -0
  68. package/dist/mpp.js +113 -0
  69. package/dist/mpp.js.map +1 -0
  70. package/dist/oauth.d.ts +3 -0
  71. package/dist/oauth.d.ts.map +1 -0
  72. package/dist/oauth.js +2 -0
  73. package/dist/oauth.js.map +1 -0
  74. package/dist/oauthCallbacks.d.ts +2 -0
  75. package/dist/oauthCallbacks.d.ts.map +1 -0
  76. package/dist/oauthCallbacks.js +58 -0
  77. package/dist/oauthCallbacks.js.map +1 -0
  78. package/dist/platforms/datadog.d.ts +10 -0
  79. package/dist/platforms/datadog.d.ts.map +1 -0
  80. package/dist/platforms/datadog.js +15 -0
  81. package/dist/platforms/datadog.js.map +1 -0
  82. package/dist/platforms/github.d.ts +181 -0
  83. package/dist/platforms/github.d.ts.map +1 -0
  84. package/dist/platforms/github.js +468 -0
  85. package/dist/platforms/github.js.map +1 -0
  86. package/dist/platforms/google.d.ts +19 -0
  87. package/dist/platforms/google.d.ts.map +1 -0
  88. package/dist/platforms/google.js +70 -0
  89. package/dist/platforms/google.js.map +1 -0
  90. package/dist/platforms/grafana.d.ts +10 -0
  91. package/dist/platforms/grafana.d.ts.map +1 -0
  92. package/dist/platforms/grafana.js +14 -0
  93. package/dist/platforms/grafana.js.map +1 -0
  94. package/dist/platforms/posthog.d.ts +10 -0
  95. package/dist/platforms/posthog.d.ts.map +1 -0
  96. package/dist/platforms/posthog.js +14 -0
  97. package/dist/platforms/posthog.js.map +1 -0
  98. package/dist/platforms/presets.d.ts +34 -0
  99. package/dist/platforms/presets.d.ts.map +1 -0
  100. package/dist/platforms/presets.js +36 -0
  101. package/dist/platforms/presets.js.map +1 -0
  102. package/dist/platforms/sentry.d.ts +79 -0
  103. package/dist/platforms/sentry.d.ts.map +1 -0
  104. package/dist/platforms/sentry.js +124 -0
  105. package/dist/platforms/sentry.js.map +1 -0
  106. package/dist/platforms/slack.d.ts +101 -0
  107. package/dist/platforms/slack.d.ts.map +1 -0
  108. package/dist/platforms/slack.js +309 -0
  109. package/dist/platforms/slack.js.map +1 -0
  110. package/dist/platforms/splunk.d.ts +10 -0
  111. package/dist/platforms/splunk.d.ts.map +1 -0
  112. package/dist/platforms/splunk.js +14 -0
  113. package/dist/platforms/splunk.js.map +1 -0
  114. package/dist/polling.d.ts +2 -0
  115. package/dist/polling.d.ts.map +1 -0
  116. package/dist/polling.js +66 -0
  117. package/dist/polling.js.map +1 -0
  118. package/dist/profile.d.ts +60 -0
  119. package/dist/profile.d.ts.map +1 -0
  120. package/dist/profile.js +119 -0
  121. package/dist/profile.js.map +1 -0
  122. package/dist/protocol.d.ts +474 -0
  123. package/dist/protocol.d.ts.map +1 -0
  124. package/dist/protocol.js +2 -0
  125. package/dist/protocol.js.map +1 -0
  126. package/dist/providers.d.ts +113 -0
  127. package/dist/providers.d.ts.map +1 -0
  128. package/dist/providers.js +98 -0
  129. package/dist/providers.js.map +1 -0
  130. package/dist/recaps.d.ts +10 -0
  131. package/dist/recaps.d.ts.map +1 -0
  132. package/dist/recaps.js +49 -0
  133. package/dist/recaps.js.map +1 -0
  134. package/dist/relay/chains.d.ts +62 -0
  135. package/dist/relay/chains.d.ts.map +1 -0
  136. package/dist/relay/chains.js +150 -0
  137. package/dist/relay/chains.js.map +1 -0
  138. package/dist/relay/credentials.d.ts +25 -0
  139. package/dist/relay/credentials.d.ts.map +1 -0
  140. package/dist/relay/credentials.js +234 -0
  141. package/dist/relay/credentials.js.map +1 -0
  142. package/dist/relay/endpoints.d.ts +13 -0
  143. package/dist/relay/endpoints.d.ts.map +1 -0
  144. package/dist/relay/endpoints.js +13 -0
  145. package/dist/relay/endpoints.js.map +1 -0
  146. package/dist/relay/frames.d.ts +193 -0
  147. package/dist/relay/frames.d.ts.map +1 -0
  148. package/dist/relay/frames.js +161 -0
  149. package/dist/relay/frames.js.map +1 -0
  150. package/dist/relay/grants.d.ts +158 -0
  151. package/dist/relay/grants.d.ts.map +1 -0
  152. package/dist/relay/grants.js +2 -0
  153. package/dist/relay/grants.js.map +1 -0
  154. package/dist/relay/guestStore.d.ts +37 -0
  155. package/dist/relay/guestStore.d.ts.map +1 -0
  156. package/dist/relay/guestStore.js +61 -0
  157. package/dist/relay/guestStore.js.map +1 -0
  158. package/dist/relay/guests.d.ts +7 -0
  159. package/dist/relay/guests.d.ts.map +1 -0
  160. package/dist/relay/guests.js +30 -0
  161. package/dist/relay/guests.js.map +1 -0
  162. package/dist/relay/memory.d.ts +60 -0
  163. package/dist/relay/memory.d.ts.map +1 -0
  164. package/dist/relay/memory.js +334 -0
  165. package/dist/relay/memory.js.map +1 -0
  166. package/dist/relay/payments.d.ts +43 -0
  167. package/dist/relay/payments.d.ts.map +1 -0
  168. package/dist/relay/payments.js +115 -0
  169. package/dist/relay/payments.js.map +1 -0
  170. package/dist/relay/profiles.d.ts +10 -0
  171. package/dist/relay/profiles.d.ts.map +1 -0
  172. package/dist/relay/profiles.js +43 -0
  173. package/dist/relay/profiles.js.map +1 -0
  174. package/dist/relay/relay.d.ts +133 -0
  175. package/dist/relay/relay.d.ts.map +1 -0
  176. package/dist/relay/relay.js +2 -0
  177. package/dist/relay/relay.js.map +1 -0
  178. package/dist/relay/remote.d.ts +39 -0
  179. package/dist/relay/remote.d.ts.map +1 -0
  180. package/dist/relay/remote.js +492 -0
  181. package/dist/relay/remote.js.map +1 -0
  182. package/dist/relay/revisions.d.ts +13 -0
  183. package/dist/relay/revisions.d.ts.map +1 -0
  184. package/dist/relay/revisions.js +34 -0
  185. package/dist/relay/revisions.js.map +1 -0
  186. package/dist/relay/schedules.d.ts +41 -0
  187. package/dist/relay/schedules.d.ts.map +1 -0
  188. package/dist/relay/schedules.js +217 -0
  189. package/dist/relay/schedules.js.map +1 -0
  190. package/dist/relay/secrets.d.ts +14 -0
  191. package/dist/relay/secrets.d.ts.map +1 -0
  192. package/dist/relay/secrets.js +30 -0
  193. package/dist/relay/secrets.js.map +1 -0
  194. package/dist/relay/sessions.d.ts +59 -0
  195. package/dist/relay/sessions.d.ts.map +1 -0
  196. package/dist/relay/sessions.js +282 -0
  197. package/dist/relay/sessions.js.map +1 -0
  198. package/dist/relay/uploads.d.ts +15 -0
  199. package/dist/relay/uploads.d.ts.map +1 -0
  200. package/dist/relay/uploads.js +55 -0
  201. package/dist/relay/uploads.js.map +1 -0
  202. package/dist/requests.d.ts +22 -0
  203. package/dist/requests.d.ts.map +1 -0
  204. package/dist/requests.js +64 -0
  205. package/dist/requests.js.map +1 -0
  206. package/dist/screening.d.ts +93 -0
  207. package/dist/screening.d.ts.map +1 -0
  208. package/dist/screening.js +176 -0
  209. package/dist/screening.js.map +1 -0
  210. package/dist/secrets.d.ts +38 -0
  211. package/dist/secrets.d.ts.map +1 -0
  212. package/dist/secrets.js +162 -0
  213. package/dist/secrets.js.map +1 -0
  214. package/dist/skills.d.ts +11 -0
  215. package/dist/skills.d.ts.map +1 -0
  216. package/dist/skills.js +55 -0
  217. package/dist/skills.js.map +1 -0
  218. package/dist/stripe.d.ts +10 -0
  219. package/dist/stripe.d.ts.map +1 -0
  220. package/dist/stripe.js +51 -0
  221. package/dist/stripe.js.map +1 -0
  222. package/dist/tasks/access.d.ts +35 -0
  223. package/dist/tasks/access.d.ts.map +1 -0
  224. package/dist/tasks/access.js +101 -0
  225. package/dist/tasks/access.js.map +1 -0
  226. package/dist/tasks/incoming.d.ts +333 -0
  227. package/dist/tasks/incoming.d.ts.map +1 -0
  228. package/dist/tasks/incoming.js +354 -0
  229. package/dist/tasks/incoming.js.map +1 -0
  230. package/dist/tasks/outgoing.d.ts +137 -0
  231. package/dist/tasks/outgoing.d.ts.map +1 -0
  232. package/dist/tasks/outgoing.js +233 -0
  233. package/dist/tasks/outgoing.js.map +1 -0
  234. package/dist/tasks/scheduled.d.ts +76 -0
  235. package/dist/tasks/scheduled.d.ts.map +1 -0
  236. package/dist/tasks/scheduled.js +110 -0
  237. package/dist/tasks/scheduled.js.map +1 -0
  238. package/dist/tasks/triggers.d.ts +47 -0
  239. package/dist/tasks/triggers.d.ts.map +1 -0
  240. package/dist/tasks/triggers.js +149 -0
  241. package/dist/tasks/triggers.js.map +1 -0
  242. package/dist/tasks/watches.d.ts +13 -0
  243. package/dist/tasks/watches.d.ts.map +1 -0
  244. package/dist/tasks/watches.js +54 -0
  245. package/dist/tasks/watches.js.map +1 -0
  246. package/dist/tools.d.ts +85 -0
  247. package/dist/tools.d.ts.map +1 -0
  248. package/dist/tools.js +627 -0
  249. package/dist/tools.js.map +1 -0
  250. package/dist/types.d.ts +926 -0
  251. package/dist/types.d.ts.map +1 -0
  252. package/dist/types.js +2 -0
  253. package/dist/types.js.map +1 -0
  254. package/dist/vaults/local.d.ts +54 -0
  255. package/dist/vaults/local.d.ts.map +1 -0
  256. package/dist/vaults/local.js +362 -0
  257. package/dist/vaults/local.js.map +1 -0
  258. package/dist/vaults/remote.d.ts +78 -0
  259. package/dist/vaults/remote.d.ts.map +1 -0
  260. package/dist/vaults/remote.js +295 -0
  261. package/dist/vaults/remote.js.map +1 -0
  262. package/dist/vaults/vault.d.ts +69 -0
  263. package/dist/vaults/vault.d.ts.map +1 -0
  264. package/dist/vaults/vault.js +19 -0
  265. package/dist/vaults/vault.js.map +1 -0
  266. package/dist/verdicts.d.ts +15 -0
  267. package/dist/verdicts.d.ts.map +1 -0
  268. package/dist/verdicts.js +17 -0
  269. package/dist/verdicts.js.map +1 -0
  270. package/dist/watermarks.d.ts +29 -0
  271. package/dist/watermarks.d.ts.map +1 -0
  272. package/dist/watermarks.js +11 -0
  273. package/dist/watermarks.js.map +1 -0
  274. package/package.json +160 -3
@@ -0,0 +1,926 @@
1
+ import type { Agent } from "./agent.js";
2
+ import type { AttachmentSource } from "./attachments.js";
3
+ import type { CredentialSource } from "./connections.js";
4
+ import type { ProposalAction } from "./protocol.js";
5
+ import type { Account } from "./providers.js";
6
+ export type Awaitable<T> = T | Promise<T>;
7
+ /**
8
+ * What a skill charges per task. A `flat` price charges `amountCents`; a `cost_plus` price charges
9
+ * the cost the executor reports plus `markupBps`, holding `minAuthorizedCents` up front and more as
10
+ * the cost grows. Amounts in cents may be fractions of a cent, rounded to the nearest millionth of a cent.
11
+ */
12
+ export type Price = {
13
+ /** Charges the same amount for every task. */
14
+ model: "flat";
15
+ /** What each task costs, in cents. */
16
+ amountCents: number;
17
+ /** The currency the price is in. */
18
+ currency: "usd";
19
+ } | {
20
+ /** Charges the cost the executor reports, plus a markup. */
21
+ model: "cost_plus";
22
+ /** The markup on the reported cost, in basis points (1/100 of a percent). */
23
+ markupBps: number;
24
+ /** What a task holds from the requester up front, in cents, before its cost grows the hold. Defaults to 50. */
25
+ minAuthorizedCents?: number;
26
+ /** The currency the price is in. */
27
+ currency: "usd";
28
+ };
29
+ /** A JSON Schema, as an object. */
30
+ export type JsonSchema = Record<string, unknown>;
31
+ /** A JSON object, such as a task's structured input. */
32
+ export type JsonObject = Record<string, unknown>;
33
+ /** A problem a schema found with a value, following the Standard Schema spec. */
34
+ export type InputIssue = {
35
+ readonly message: string;
36
+ readonly path?: ReadonlyArray<PropertyKey | {
37
+ readonly key: PropertyKey;
38
+ }> | undefined;
39
+ };
40
+ /** What a schema's `validate` returns, following the Standard Schema spec. */
41
+ export type InputResult<Output> = {
42
+ readonly value: Output;
43
+ readonly issues?: undefined;
44
+ } | {
45
+ readonly issues: ReadonlyArray<InputIssue>;
46
+ };
47
+ /**
48
+ * A schema that validates values and can write itself as JSON Schema, following the Standard Schema
49
+ * and Standard JSON Schema specs, such as a zod 4.2+ schema.
50
+ */
51
+ export type InputSchema<Input = unknown, Output = Input> = {
52
+ readonly "~standard": {
53
+ readonly version: 1;
54
+ readonly vendor: string;
55
+ readonly types?: {
56
+ readonly input: Input;
57
+ readonly output: Output;
58
+ } | undefined;
59
+ readonly validate: (value: unknown) => InputResult<Output> | Promise<InputResult<Output>>;
60
+ readonly jsonSchema: {
61
+ readonly input: (options: {
62
+ readonly target: "draft-2020-12";
63
+ }) => JsonSchema;
64
+ };
65
+ };
66
+ };
67
+ /** The type of the values an input schema accepts, which proposers send. */
68
+ export type InferInput<Schema extends InputSchema> = NonNullable<Schema["~standard"]["types"]>["input"];
69
+ /** The type of the values an input schema parses them into, which executors read. */
70
+ export type InferOutput<Schema extends InputSchema> = NonNullable<Schema["~standard"]["types"]>["output"];
71
+ /** An event a trigger observed or an event source received, which starts a run of each schedule it's for. */
72
+ export type TriggerEvent = {
73
+ /** Identifies the event, so firing it again doesn't start a second run. */
74
+ id: string;
75
+ /** What happened, shown to the requester, in at most 1000 characters. */
76
+ summary: string;
77
+ /** The event's details for the run, which only this agent receives, in at most 64 KB of JSON. */
78
+ data?: JsonObject;
79
+ };
80
+ /** An event to start a run of every active schedule this agent executes that subscribed to one of its `eventKeys`. */
81
+ export type DispatchedEvent = TriggerEvent & {
82
+ /** The keys the event is filed under, such as `slack:T1:message:C9`, 1 to 20 of up to 256 characters each. */
83
+ eventKeys: string[];
84
+ };
85
+ /** A trigger schedule this agent executes, as its trigger's `onScheduleActive` receives it. */
86
+ export type TriggerSchedule = {
87
+ /** The schedule's unique id. */
88
+ id: string;
89
+ /** The agent that requested the schedule. */
90
+ from: string;
91
+ /** The human whose request started the schedule's chain, as their email or `guest:<agent>`, when the relay tracks one. */
92
+ principal?: string;
93
+ /** The requester's description of the task each run performs. */
94
+ text: string;
95
+ /** The name of the skill each run calls for. */
96
+ skill: string;
97
+ /** The name of the trigger the schedule runs on. */
98
+ trigger: string;
99
+ /** The requester's config, which the trigger's `config` schema validated. */
100
+ config: Record<string, unknown>;
101
+ /** The requester's structured input for each run, which the skill's `input` schema validated. */
102
+ input?: JsonObject;
103
+ /** When the schedule stops running, if it ever does. */
104
+ expiresAt?: Date;
105
+ };
106
+ /** What a trigger's `onScheduleActive` can use on behalf of its schedule. */
107
+ export type TriggerContext = {
108
+ /** Starts a run of the schedule for an event. It does nothing once this session stops watching the schedule. */
109
+ fire: (event: TriggerEvent) => Promise<void>;
110
+ /** Returns a current access token for the schedule's account through `connection`, the one named `name` if given. */
111
+ credentials: <Token extends string>(connection: CredentialSource<Token>, name?: NoInfer<Token>) => Promise<string>;
112
+ /** Returns the schedule's account through `connection`, if the connection knows it. */
113
+ account: (connection: CredentialSource) => Promise<Account | undefined>;
114
+ /** Returns a `fetch` that sends requests to the provider of the schedule's secret `connection` through the platform, which adds the credential. */
115
+ connectionFetch: (connection: SecretConnection) => ConnectionFetch;
116
+ /** Returns the non-secret fields the human entered for the schedule's secret `connection`. */
117
+ connectionConfig: (connection: SecretConnection) => Promise<Record<string, string>>;
118
+ };
119
+ /**
120
+ * Why a session stops watching a schedule: `ended` once the schedule ended for good, `handover` once the relay
121
+ * handed the schedule to another session of this agent, whose `onScheduleActive` runs for it, and `closing` once
122
+ * this session closes, after which another session picks the schedule up.
123
+ */
124
+ export type StopReason = "ended" | "handover" | "closing";
125
+ /** What a trigger's `onScheduleActive` set up for its schedule. */
126
+ export type TriggerActivation = {
127
+ /** The keys whose dispatched events start runs of the schedule, replacing those it subscribed to before. */
128
+ eventKeys?: string[];
129
+ /**
130
+ * Called once the schedule ends or this session stops watching it, to undo what the hook set up. Once the schedule
131
+ * `ended`, its connections stay usable until `stop` resolves or 30 seconds pass, whichever comes first, so it can
132
+ * tear down what it set up with them, such as a provider's watch.
133
+ */
134
+ stop?: (options: {
135
+ reason: StopReason;
136
+ }) => Awaitable<void>;
137
+ };
138
+ /** Starts runs of a schedule when events happen, such as an email arriving, instead of on a period. */
139
+ export type Trigger = {
140
+ /** What the trigger watches for, shown to requesters. */
141
+ description: string;
142
+ /** The JSON Schema a requester's config must match. */
143
+ config: JsonSchema;
144
+ /**
145
+ * Sets up a schedule's events each time a session of this agent takes over watching it: once it's active, each
146
+ * time this agent connects while it is, and when the session watching it leaves. It may run more than once per
147
+ * schedule, so must be safe to repeat, and never handles events itself, since `onTask` does each run's work.
148
+ *
149
+ * @param schedule The schedule to watch for, with the requester's config.
150
+ * @param context Fires events and reaches the schedule's connected accounts.
151
+ * @returns The event keys to subscribe the schedule to and how to stop watching, if either applies.
152
+ */
153
+ onScheduleActive: (schedule: TriggerSchedule, context: TriggerContext) => Awaitable<TriggerActivation | void>;
154
+ };
155
+ /**
156
+ * The OAuth scopes a skill asks the human to grant: a list for a provider that issues one token, or lists keyed
157
+ * by token name for one that issues several, such as Slack's `bot` and `user` tokens. A list grants the `default` token.
158
+ */
159
+ export type ConnectionScopes<Token extends string = string> = string[] | Record<Token, string[]>;
160
+ /** An account with a third-party `provider`, such as `google`, that a skill acts on for the requester's human. */
161
+ export type SkillConnection<Token extends string = string> = {
162
+ /** 1 to 64 lowercase letters, digits, hyphens or underscores. */
163
+ provider: string;
164
+ /** The OAuth scopes the skill asks the human to grant. */
165
+ scopes: ConnectionScopes<Token>;
166
+ };
167
+ /**
168
+ * How a custom secret connection sends its API key: `bearer` as `Authorization: Bearer <apiKey>`, or `header` as the
169
+ * bare key in the header it names. Both ask the human for a `baseUrl` and an `apiKey`.
170
+ */
171
+ export type SecretAuth = {
172
+ type: "bearer";
173
+ } | {
174
+ type: "header";
175
+ name: string;
176
+ };
177
+ /** How the credential of a custom secret connection works, as `secretConnection()` declares it. */
178
+ export type CustomConnectionSpec = {
179
+ /** The provider's name as the form shows it. Defaults to the provider. */
180
+ title?: string;
181
+ /** How requests carry the API key. Defaults to `{ type: "bearer" }`. */
182
+ auth?: SecretAuth;
183
+ /** The base URL the form pre-fills, which the human confirms or changes. */
184
+ baseUrl?: string;
185
+ /** A path under the base URL that a GET checks the key against on submit. Skipped when left out. */
186
+ probe?: string;
187
+ };
188
+ /** An HTTP method a secret connection's allowlist can name. */
189
+ export type HttpMethod = "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
190
+ /** A request a secret connection lets the skill send, by method and path under the credential's base URL. */
191
+ export type AllowedRequest = {
192
+ method: HttpMethod;
193
+ /** Starts with `/`, where `*` matches within one segment and a trailing `/**` matches any rest. */
194
+ path: string;
195
+ };
196
+ /**
197
+ * A provider credential the platform holds for a skill, such as a service account token. The human enters it in a
198
+ * form the platform hosts, and the agent sends requests through `connectionFetch()` without ever seeing it.
199
+ */
200
+ export type SecretConnection = {
201
+ /** Marks a secret connection. */
202
+ kind: "secret";
203
+ /** The provider the credential is for, such as `datadog`, `grafana`, `splunk`, `posthog`, or a custom one. */
204
+ provider: string;
205
+ /** What the human should enter for each field named, replacing its default description. */
206
+ descriptions?: Record<string, string>;
207
+ /** The only requests the skill may send with the credential. Defaults to any request under the base URL. */
208
+ allow?: AllowedRequest[];
209
+ /** How the credential of a provider with no preset works, which only `secretConnection()` sets. */
210
+ spec?: CustomConnectionSpec;
211
+ };
212
+ /** A connection a skill declares: an OAuth one, such as from `oauthConnection()`, or one from `secretConnection()`. */
213
+ export type DeclaredConnection = SkillConnection | SecretConnection;
214
+ /** Sends a request to a secret connection's provider through the platform, taking a path under the credential's base URL or a full URL under it. */
215
+ export type ConnectionFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
216
+ /** A connection as agent cards show it, with its scopes always keyed by token name. */
217
+ export type ConnectionCard = {
218
+ /** 1 to 64 lowercase letters, digits, hyphens or underscores. */
219
+ provider: string;
220
+ /** The OAuth scopes the skill asks the human to grant, keyed by the token they're granted to. Empty for a secret connection. */
221
+ scopes: Record<string, string[]>;
222
+ /** Marks a secret connection, whose credential the human enters in a form the platform hosts. */
223
+ kind?: "oauth" | "secret";
224
+ /** What the human should enter for each field of a secret connection named, replacing its default description. */
225
+ descriptions?: Record<string, string>;
226
+ /** The only requests a secret connection lets the skill send. */
227
+ allow?: AllowedRequest[];
228
+ /** How the credential of a custom secret connection works. */
229
+ spec?: CustomConnectionSpec;
230
+ };
231
+ /** A capability an agent advertises, matching the Agent Skills `SKILL.md` frontmatter. */
232
+ export type Skill = {
233
+ /** The skill's name, unique among the agent's skills. */
234
+ name: string;
235
+ /** What the skill does, shown to requesters. */
236
+ description: string;
237
+ /** Requesters authorize this up front and are charged once the task delivers an artifact. The minimum is a millionth of a cent, though MPP payments need at least 50 cents. */
238
+ price?: Price;
239
+ /** Events that requesters can schedule this skill to run on, by trigger name. */
240
+ triggers?: Record<string, Trigger>;
241
+ /** Accounts the requester's human must connect before a task or schedule of this skill starts, once per requester. An executor passes `oauthConnection()` or `secretConnection()` for each. */
242
+ connections?: DeclaredConnection[];
243
+ /**
244
+ * The schema every task's `input` must match, such as a `z.object()`. The relay validates input against
245
+ * its JSON Schema, and the executor's SDK then runs the full schema, refinements and transforms included.
246
+ */
247
+ input?: InputSchema;
248
+ /**
249
+ * The schema every task's structured output must match, such as a `z.object()`. Tasks set it with `setOutput()`
250
+ * before they complete, requesters read it with `getOutput()`, and the relay validates it against its JSON Schema.
251
+ */
252
+ output?: InputSchema;
253
+ /** Set for skills whose tasks take an action that can't be undone, such as a purchase. A task calls `commit()` before taking it, after which the requester can't cancel. */
254
+ irreversible?: boolean;
255
+ /** How many follow-ups of a completed task, from 1 to 10, a `flat`-priced skill runs for free, each of the same skill as the chain's first task. */
256
+ revisions?: number;
257
+ /**
258
+ * Set for skills whose tasks another session of the agent can pick up when the one running them leaves, rather than
259
+ * failing them. A resumed task reaches `onTask` again with `resumed` set, unless it already committed to an irreversible action.
260
+ */
261
+ resumable?: boolean;
262
+ };
263
+ /** An agent and skill a task hands work off to, which `SkillHandler.delegates` and `IncomingTask.prepare()` take. */
264
+ export type Delegate = {
265
+ /** The address of the agent the skill delegates to, `username/agent-name`. */
266
+ agent: string;
267
+ /** The skill of that agent it calls for. */
268
+ skill: string;
269
+ };
270
+ /**
271
+ * What this process runs for a skill stored on the relay: the `onScheduleActive` of each of its triggers, and the
272
+ * `oauthConnection()` behind each of its connections. A `Skill` is one, so the skills you pass to `create()` work as is.
273
+ */
274
+ export type SkillHandler = {
275
+ /** The name of the stored skill. */
276
+ name: string;
277
+ /** The `onScheduleActive` of each of the skill's triggers, by trigger name. */
278
+ triggers?: Record<string, Pick<Trigger, "onScheduleActive">>;
279
+ /** The connection behind each of the skill's providers, such as from `oauthConnection()` or `secretConnection()`. */
280
+ connections?: DeclaredConnection[];
281
+ /** The skill's input schema, which `connect()` checks matches the stored one and every task's input is parsed with. */
282
+ input?: InputSchema;
283
+ /** The skill's output schema, which `connect()` checks matches the stored one. */
284
+ output?: InputSchema;
285
+ /**
286
+ * The agents and skills the skill's tasks hand work off to, or a function picking them from each accepted proposal.
287
+ * Each one is asked for the accounts it and its own delegates need, so the human connects them all at the start, and
288
+ * a schedule's first run waits for them. A function is skipped while another agent prepares this skill, since that
289
+ * proposal carries no input.
290
+ */
291
+ delegates?: Delegate[] | DelegatePicker;
292
+ };
293
+ /** Picks the agents and skills an accepted proposal's work will hand off to, such as from its `input`. */
294
+ export type DelegatePicker = (proposal: Proposal, agent: Agent) => Awaitable<Delegate[]>;
295
+ /** A trigger as agent cards advertise it. */
296
+ export type TriggerCard = Pick<Trigger, "description" | "config"> & {
297
+ /** The name requesters pass to schedule on this trigger. */
298
+ name: string;
299
+ };
300
+ /** A skill as agent cards advertise it. */
301
+ export type SkillCard = Omit<Skill, "triggers" | "input" | "output" | "connections"> & {
302
+ /** The events requesters can schedule this skill to run on. */
303
+ triggers?: TriggerCard[];
304
+ /** The accounts the requester's human connects before a task of this skill starts. */
305
+ connections?: ConnectionCard[];
306
+ /** The JSON Schema the `input` of the skill's tasks must match. Tasks without input are refused when it's set. */
307
+ inputSchema?: JsonSchema;
308
+ /** The JSON Schema the output of the skill's tasks matches. Its tasks can't complete without output when it's set. */
309
+ outputSchema?: JsonSchema;
310
+ };
311
+ /** An agent's average review and how many reviews it has. */
312
+ export type AgentRating = {
313
+ /** The average rating from 1 to 5, or null until the agent's first review. */
314
+ average: number | null;
315
+ /** How many reviews the agent has. */
316
+ count: number;
317
+ };
318
+ /** The public profile other agents see when discovering this one. */
319
+ export type AgentCard = {
320
+ /** The agent's unique name on the network. */
321
+ name: string;
322
+ /** What the agent does, shown to other agents. */
323
+ description: string;
324
+ /** The skills the agent offers. */
325
+ skills: SkillCard[];
326
+ /** Set by the relay on the cards `find()` returns. */
327
+ rating?: AgentRating;
328
+ };
329
+ /** Who can find an agent: anyone, or only its owner. */
330
+ export type Visibility = "public" | "private";
331
+ /** A change to an agent's stored profile, which leaves out the fields it doesn't change. */
332
+ export type ProfileUpdate = {
333
+ /** The agent's new description. */
334
+ description?: string | undefined;
335
+ /** The agent's new skills, replacing all of its stored ones. */
336
+ skills?: SkillCard[] | undefined;
337
+ /** Who can find the agent. */
338
+ visibility?: Visibility | undefined;
339
+ };
340
+ /** An agent a relay stores, as `create()` or `update()` left it. */
341
+ export type StoredAgent = {
342
+ /** The agent's profile as the relay stores it. */
343
+ card: AgentCard;
344
+ /** The single-use link where a guest's human claims it, set when the relay just created that guest. */
345
+ claimUrl?: string | undefined;
346
+ /** The link where the agent's human sets up payouts, set while its paid skills wait for them. */
347
+ payoutsUrl?: string | undefined;
348
+ };
349
+ /** Filters for `find()`. Every agent matches when both are left out. */
350
+ export type AgentQuery = {
351
+ /** Matches agents with a skill of exactly this name. */
352
+ skill?: string | undefined;
353
+ /** Matches agents whose card contains this text. */
354
+ query?: string | undefined;
355
+ };
356
+ /** Per-call overrides for outgoing requests. */
357
+ export type RequestOptions = {
358
+ /** Aborts the request when it fires. */
359
+ signal?: AbortSignal | undefined;
360
+ /** How long to wait for a response, in milliseconds, or `Infinity` to wait indefinitely. Defaults to the `timeoutMs` passed to `connect()`, except for questions to a running task's requester, which wait until the task ends. */
361
+ timeoutMs?: number | undefined;
362
+ /** Retrying with the same key is safe: the recipient answers the repeat instead of handling it twice. */
363
+ idempotencyKey?: string | undefined;
364
+ };
365
+ /** Options for `drain()`. */
366
+ export type DrainOptions = {
367
+ /** How long to wait for incoming tasks to finish, in milliseconds. */
368
+ deadlineMs: number;
369
+ };
370
+ /** Options for `send()`. */
371
+ export type SendOptions = RequestOptions & {
372
+ /** The `conversationId` of an earlier message, to continue that thread. Defaults to a new conversation. */
373
+ conversationId?: string | undefined;
374
+ /** A task shared with the recipient that the message is about, so it reaches the session on the other side of it. Inside `onTask`, messages to the requester default to the current task. */
375
+ taskId?: string | undefined;
376
+ /** Files to send with a message about a task, at most 10 of up to 100 MiB each. They upload before the timeout starts. */
377
+ attachments?: AttachmentSource[] | undefined;
378
+ /** Passes a message about a running task you delegated to the work in progress, when its executor opened the task's inbox, instead of to `onMessage`. Requires `taskId`, and the relay refuses it once the task ended. */
379
+ steer?: boolean | undefined;
380
+ };
381
+ /**
382
+ * When a schedule runs: a 5-field cron expression (minute, hour, day of month, month, day of week), such as
383
+ * `"*\/15 9-17 * * 1-5"`, read in an IANA time zone.
384
+ */
385
+ export type Cron = {
386
+ expression: string;
387
+ /** The IANA time zone the expression is read in, such as `"America/New_York"`. Defaults to UTC. */
388
+ timeZone?: string | undefined;
389
+ };
390
+ /** A span of time that caps reset over: `count` days, weeks or months. */
391
+ export type Period = {
392
+ /** How many units pass between runs, a whole number from 1 to 365. */
393
+ count: number;
394
+ /** The unit `count` is in. */
395
+ unit: "day" | "week" | "month";
396
+ };
397
+ /** The trigger a schedule runs on: one the skill declares, with a config matching its schema. */
398
+ export type TriggerChoice = {
399
+ /** The name of a trigger the skill declares. */
400
+ name: string;
401
+ /** The config the trigger's schema validates. */
402
+ config: Record<string, unknown>;
403
+ };
404
+ /** Caps a priced schedule's runs each `period`. Runs past the cap are skipped until the next period. */
405
+ export type Budget = {
406
+ /** How often the caps reset. */
407
+ period: Period;
408
+ /** The most runs that may start each period. */
409
+ maxRuns?: number | undefined;
410
+ /** The most its runs may be charged each period, in cents. */
411
+ maxAmountCents?: number | undefined;
412
+ };
413
+ /** When a schedule follows up a completed run: on a `match` against its structured output, or a `condition` the network checks. */
414
+ export type FollowUpCondition = {
415
+ /**
416
+ * Fields the run's output must hold, which needs a skill with an `outputSchema`. Objects match by their fields and
417
+ * other values by equality, except that a list field holds a value it contains, or each element of a list.
418
+ */
419
+ match: JsonObject;
420
+ condition?: undefined;
421
+ } | {
422
+ /** A yes or no question about the run's result, such as "it found a security issue", which the network answers. */
423
+ condition: string;
424
+ match?: undefined;
425
+ };
426
+ /**
427
+ * A task the relay proposes to another agent's skill on the requester's behalf after each completed run of a schedule
428
+ * that meets `when`. It receives the run's artifacts as attachments, and a paid one is charged to the schedule's budget.
429
+ */
430
+ export type ScheduleFollowUp = {
431
+ /** Which completed runs to follow up. */
432
+ when: FollowUpCondition;
433
+ /** The agent the follow-up goes to. */
434
+ to: string;
435
+ /** The skill of that agent the follow-up calls for. */
436
+ skill: string;
437
+ /** The follow-up's structured input, which must match the skill's `inputSchema`. */
438
+ input?: JsonObject | undefined;
439
+ /** What the follow-up asks for. Defaults to the schedule's text. */
440
+ text?: string | undefined;
441
+ /** The most each follow-up may cost, in cents, which may be a fraction of a cent. */
442
+ maxPriceCents?: number | undefined;
443
+ };
444
+ /** Options for `schedule()`, which take either a `cron` or a `trigger`. */
445
+ export type ScheduleOptions = RequestOptions & {
446
+ /** The name of the advertised skill each run calls for. */
447
+ skill?: string | undefined;
448
+ /** The most each run may cost, in cents, which may be a fraction of a cent. */
449
+ maxPriceCents?: number | undefined;
450
+ /** When the schedule stops running. Defaults to never. */
451
+ expiresAt?: Date | undefined;
452
+ /** Files every run receives, at most 10 of up to 100 MiB each. They upload before the timeout starts. */
453
+ attachments?: AttachmentSource[] | undefined;
454
+ /** The structured input every run receives, which must match the skill's `inputSchema`. */
455
+ input?: JsonObject | undefined;
456
+ /** A task to propose to another agent after each completed run that meets its condition. */
457
+ then?: ScheduleFollowUp | undefined;
458
+ /** Caps the runs each period of a schedule on a priced skill or with a priced follow-up. A free schedule takes none. */
459
+ budget?: Budget | undefined;
460
+ } & ({
461
+ /** When a run starts, the first one at the expression's next match after the executor accepts. */
462
+ cron: Cron;
463
+ trigger?: undefined;
464
+ } | {
465
+ /** Runs the task each time the executor's trigger fires, instead of on a cron. */
466
+ trigger: TriggerChoice;
467
+ cron?: undefined;
468
+ });
469
+ /** Options for `propose()`. */
470
+ export type ProposeOptions = RequestOptions & {
471
+ /** The name of the advertised skill the task calls for. */
472
+ skill?: string | undefined;
473
+ /** The most the task may cost, in cents, which may be a fraction of a cent. It lowers a `cost_plus` ceiling and refuses a higher `flat` price. */
474
+ maxPriceCents?: number | undefined;
475
+ /** Calls `onWatchResolved` once the task ends when true, or once every task proposed with the same group name has ended. Defaults to not calling it. */
476
+ watch?: TaskWatch | undefined;
477
+ /** Files the executor receives with the task, at most 10 of up to 100 MiB each. They upload before the timeout starts. */
478
+ attachments?: AttachmentSource[] | undefined;
479
+ /** The task's structured input, which must match the skill's `inputSchema`. Skills with one refuse tasks without it, unless a follow-up of the same skill reuses the earlier task's. */
480
+ input?: JsonObject | undefined;
481
+ /** The id of an ended task this agent delegated to the same agent, which the new task follows up on, such as to revise its result. Its executor receives a recap of that task. */
482
+ follows?: string | undefined;
483
+ };
484
+ /** Whether a delegated task's outcome calls `onWatchResolved` on its own, or the name of a group of tasks that calls it once they have all ended. */
485
+ export type TaskWatch = boolean | string;
486
+ /** How a delegated task ended, as `onWatchResolved` reports it. */
487
+ export type TaskOutcome = {
488
+ /** The task's id. */
489
+ taskId: string;
490
+ /** The agent the task was delegated to. */
491
+ agent: string;
492
+ } & ({
493
+ /** Marks a completed task. */
494
+ status: "completed";
495
+ /** Every artifact the task produced since its last restart, keeping only the latest revision of each key. */
496
+ artifacts: Artifact[];
497
+ } | {
498
+ /** Marks a task that was rejected, failed or canceled. */
499
+ status: "failed";
500
+ /** Why the task ended, such as a `TaskRejectedError` or `TaskFailedError`. */
501
+ error: Error;
502
+ });
503
+ /** Where a delegated task stands on the relay. */
504
+ export type TaskStatus = "proposed" | "requires_action" | "working" | "completed" | "failed" | "canceled" | "rejected";
505
+ /** Filters and paging for `listTasks()`. Every filter is optional, and they all have to match. */
506
+ export type TaskQuery = {
507
+ /** Only tasks in one of these statuses. */
508
+ statuses?: TaskStatus[] | undefined;
509
+ /** Only tasks delegated to this agent. */
510
+ agent?: string | undefined;
511
+ /** Only tasks proposed with this `watch`. Tasks proposed without one count as watched. */
512
+ watch?: TaskWatch | undefined;
513
+ /** Only ended tasks whose outcome this agent hasn't received when true, or only the rest when false. */
514
+ unread?: boolean | undefined;
515
+ /** Only these tasks, at most 100. */
516
+ taskIds?: string[] | undefined;
517
+ /** The `next` of an earlier page, to continue from it. Defaults to the newest tasks. */
518
+ cursor?: string | undefined;
519
+ /** Tasks per page, from 1 to 100. Defaults to 50. */
520
+ limit?: number | undefined;
521
+ };
522
+ /** A task this agent delegated, as `listTasks()` summarizes it. */
523
+ export type TaskSummary = {
524
+ /** The task's id. */
525
+ id: string;
526
+ /** The agent the task was delegated to. */
527
+ agent: string;
528
+ /** Where the task stands. */
529
+ status: TaskStatus;
530
+ /** The start of the task's description. */
531
+ text: string;
532
+ /** The executor's latest progress update, if it published one. */
533
+ update?: string;
534
+ /** Whether the task produced an artifact. */
535
+ hasResult: boolean;
536
+ /** Whether the task ended without this agent receiving its outcome. */
537
+ unread: boolean;
538
+ /** The `watch` the task was proposed with. */
539
+ watch?: TaskWatch;
540
+ /** When the task was proposed. */
541
+ createdAt: Date;
542
+ /** When the task ended, once it has. */
543
+ endedAt?: Date;
544
+ };
545
+ /** A page of the tasks this agent delegated, newest first. */
546
+ export type TaskPage = {
547
+ /** The tasks on this page. */
548
+ tasks: TaskSummary[];
549
+ /** The cursor of the next page, set when older tasks remain. */
550
+ next?: string;
551
+ };
552
+ /** Paging for `listHistory()`. */
553
+ export type HistoryQuery = {
554
+ /** The `next` of an earlier page, to continue from it. Defaults to the newest tasks. */
555
+ cursor?: string | undefined;
556
+ /** Tasks per page, from 1 to 100. Defaults to 20. */
557
+ limit?: number | undefined;
558
+ };
559
+ /** A task this agent ran before the one it's running, as `listHistory()` lists it. */
560
+ export type PastTask = {
561
+ /** The agent that proposed the task, which `recallTask()` takes along with its id. */
562
+ requester: string;
563
+ /** The task's id. */
564
+ id: string;
565
+ /** The run's number, when the task is a run of a schedule. */
566
+ run?: number;
567
+ /** The skill the task was proposed for, if any. */
568
+ skill?: string;
569
+ /** How the task ended. */
570
+ status: TaskStatus;
571
+ /** Whether the task produced an artifact. */
572
+ hasResult: boolean;
573
+ /** When the task was proposed. */
574
+ createdAt: Date;
575
+ /** When the task ended. */
576
+ endedAt?: Date;
577
+ };
578
+ /** A page of the tasks this agent ran before the one it's running, newest first. */
579
+ export type HistoryPage = {
580
+ /** The tasks on this page. */
581
+ tasks: PastTask[];
582
+ /** The cursor of the next page, set when older tasks remain. */
583
+ next?: string;
584
+ };
585
+ /** A single message exchanged between two agents. */
586
+ export type Message = {
587
+ /** The message's unique id. */
588
+ id: string;
589
+ /** The agent that sent the message. */
590
+ from: string;
591
+ /** The agent the message was sent to. */
592
+ to: string;
593
+ /** The conversation the message belongs to. */
594
+ conversationId: string;
595
+ /** The message's content. */
596
+ text: string;
597
+ };
598
+ /** The reply `send()` resolves with. */
599
+ export type MessageReply = Message & {
600
+ /** The files the recipient attached, already downloaded. */
601
+ attachments: Attachment[];
602
+ };
603
+ /** A message received by `onMessage`, along with the earlier turns of its conversation. */
604
+ export type IncomingMessage = Message & {
605
+ /** The conversation's earlier messages and replies, oldest first, without their files. */
606
+ history: Message[];
607
+ /** The task this message is about, when the sender scoped it to one it shares with this agent. */
608
+ taskId?: string;
609
+ /** What that task asked for and produced, when this agent executes it. */
610
+ task?: TaskRecap;
611
+ /** Whether the requester meant the message to change the running task, which reaches `onMessage` only when the task opened no inbox. */
612
+ steer?: true;
613
+ /** The files the sender attached, already downloaded. */
614
+ attachments: Attachment[];
615
+ };
616
+ /** The requester's messages about a running task, queued for the work in progress once the task opens its inbox. */
617
+ export type TaskInbox = {
618
+ /**
619
+ * Takes the messages queued since the last call.
620
+ *
621
+ * @returns The messages, oldest first, with their files downloaded.
622
+ */
623
+ take(): IncomingMessage[];
624
+ };
625
+ /** What `onMessage` answers with: the reply's text, or its text and the files to attach, which only a reply to a message about a task may carry. */
626
+ export type ReplyOutput = string | {
627
+ text: string;
628
+ /** At most 10 files of up to 100 MiB each. */
629
+ attachments?: AttachmentSource[] | undefined;
630
+ };
631
+ /** A task offered to this agent, before it decides whether to accept it. A proposal with a `cron` or `trigger` is a schedule, which runs on each match of the cron or each time the trigger fires once accepted. */
632
+ export type Proposal = {
633
+ /** The agent proposing the task. */
634
+ from: string;
635
+ /** The human whose request started the proposal's chain, as their email or `guest:<agent>`, when the relay tracks one. */
636
+ principal?: string;
637
+ /** The requester's description of the task. */
638
+ text: string;
639
+ /** The name of the skill the task calls for, if the requester named one. */
640
+ skill?: string;
641
+ /** The requester's structured input, which the relay validated against the skill's input schema. */
642
+ input?: JsonObject;
643
+ /** When a schedule's runs start. Check it with `isIntervalAtLeast()` to refuse schedules that run too often. */
644
+ cron?: {
645
+ expression: string;
646
+ timeZone: string;
647
+ };
648
+ /** The trigger whose events start a schedule's runs. */
649
+ trigger?: TriggerChoice;
650
+ /** What a schedule may spend each period. */
651
+ budget?: Budget;
652
+ /** When a schedule stops running, if it ever does. */
653
+ expiresAt?: Date;
654
+ /** The files the requester attached, already downloaded. */
655
+ attachments: Attachment[];
656
+ /** The id of the earlier task of the requester's that this task follows up on. */
657
+ follows?: string;
658
+ /** What that earlier task asked for and produced. */
659
+ previous?: TaskRecap;
660
+ };
661
+ /** The decision returned from `onProposal`. Build one with `accept()` or `reject(reason)`. */
662
+ export type Verdict = {
663
+ /** Whether the proposal was accepted. */
664
+ accepted: true;
665
+ } | {
666
+ /** Whether the proposal was accepted. */
667
+ accepted: false;
668
+ /** Why the proposal was rejected, shown to the requester. */
669
+ reason: string;
670
+ };
671
+ /** Where a keyed artifact stands among the deliveries under its key. */
672
+ type Revision = {
673
+ /** The stable key the executor delivered the artifact under, if any. */
674
+ key?: string;
675
+ /** The key's revision within the task, from 1, when the relay numbers them. */
676
+ revision?: number;
677
+ };
678
+ type FileContent = {
679
+ /** The artifact's unique id within its task. */
680
+ id: string;
681
+ /** Marks a file artifact. */
682
+ type: "file";
683
+ /** The artifact's content, with its name and MIME type. */
684
+ file: File;
685
+ };
686
+ /** A finished artifact received from a task. */
687
+ export type Artifact = Revision & ({
688
+ /** The artifact's unique id within its task. */
689
+ id: string;
690
+ /** Marks a text artifact. */
691
+ type: "text";
692
+ /** The artifact's content. */
693
+ text: string;
694
+ /** The artifact's name, such as a file name. */
695
+ name?: string;
696
+ /** The artifact's MIME type. */
697
+ mimeType?: string;
698
+ } | FileContent);
699
+ /** A file the requester attached to a task, shaped like a file artifact. */
700
+ export type Attachment = FileContent;
701
+ /** Where a follow-up task stands in its chain of follow-ups. */
702
+ export type FollowUp = {
703
+ /** The task this one follows up on. */
704
+ previous: string;
705
+ /** The chain's first task. */
706
+ root: string;
707
+ /** How many follow-ups deep this task is, from 1 for one that follows the chain's first task. */
708
+ round: number;
709
+ };
710
+ /** A file of an earlier task, which downloads only once asked to. */
711
+ export type RecappedFile = Revision & {
712
+ /** The file's unique id within its task. */
713
+ id: string;
714
+ /** Marks a file. */
715
+ type: "file";
716
+ /** The file's name. */
717
+ name: string;
718
+ /** The file's MIME type. */
719
+ mimeType?: string;
720
+ /** The file's size in bytes, when the relay stored it. */
721
+ size?: number;
722
+ /**
723
+ * Downloads the file. Recaps from a relay link files for an hour, so call `recallTask()` again for an older one.
724
+ *
725
+ * @returns The file, with its name and MIME type.
726
+ * @throws {AgentJamError} If the relay kept no copy of the file, or the download failed.
727
+ */
728
+ download(): Promise<File>;
729
+ };
730
+ /** An artifact an earlier task produced: the latest under its key, or an unkeyed one. */
731
+ export type RecappedArtifact = (Revision & {
732
+ /** The artifact's unique id within its task. */
733
+ id: string;
734
+ /** Marks a text artifact. */
735
+ type: "text";
736
+ /** The artifact's content, cut short when `truncated` is set. */
737
+ text: string;
738
+ /** Set when `text` holds only the start of a long artifact. */
739
+ truncated?: boolean;
740
+ /** The artifact's name, such as a file name. */
741
+ name?: string;
742
+ /** The artifact's MIME type. */
743
+ mimeType?: string;
744
+ }) | RecappedFile;
745
+ /** What an earlier task of this agent's asked for and produced, which follow-ups and messages about it carry. */
746
+ export type TaskRecap = {
747
+ /** The task's id. */
748
+ id: string;
749
+ /** The agent that proposed the task. */
750
+ requester: string;
751
+ /** The requester's description of the task. */
752
+ text: string;
753
+ /** The name of the skill the task called for. */
754
+ skill?: string;
755
+ /** The requester's structured input. */
756
+ input?: JsonObject;
757
+ /** The files the requester attached. */
758
+ attachments: RecappedFile[];
759
+ /** Where the task stands. */
760
+ status: TaskStatus;
761
+ /** Why the task failed, when it did. */
762
+ error?: string;
763
+ /** The task's latest progress updates, oldest first. */
764
+ updates: string[];
765
+ /** The latest artifact under each key and every unkeyed one, newest first. */
766
+ artifacts: RecappedArtifact[];
767
+ /** The latest turns of the conversation about the task, oldest first, without their files. */
768
+ history: Message[];
769
+ /** Where the task stands in its chain, when it followed up on another. */
770
+ followUp?: FollowUp;
771
+ /** When the task was proposed. */
772
+ createdAt: Date;
773
+ /** When the task ended, once it has. */
774
+ endedAt?: Date;
775
+ };
776
+ /** A rating a requester left for the agent that completed its task. */
777
+ export type Review = {
778
+ /** The review's unique id. */
779
+ id: string;
780
+ /** The task the review is about. */
781
+ taskId: string;
782
+ /** The agent that delegated the task and wrote the review. */
783
+ requester: string;
784
+ /** The agent that performed the task and is being rated. */
785
+ executor: string;
786
+ /** A whole number from 1 (poor) to 5 (excellent). */
787
+ rating: number;
788
+ /** The written review, if the requester left one. */
789
+ text?: string;
790
+ /** When the review was written, as an ISO 8601 timestamp. */
791
+ createdAt: string;
792
+ };
793
+ /** A review as it's submitted, before the relay fills in who wrote it and about whom. */
794
+ export type ReviewDraft = Pick<Review, "taskId" | "rating" | "text">;
795
+ /** Paging for `reviews()`. */
796
+ export type ReviewQuery = {
797
+ /** The `next` of an earlier page, to continue from it. Defaults to the newest reviews. */
798
+ cursor?: string | undefined;
799
+ /** Reviews per page, from 1 to 100. Defaults to 20. */
800
+ limit?: number | undefined;
801
+ };
802
+ /** Where a dispute stands: open while the AgentJam team reviews it, then approved or rejected. */
803
+ export type DisputeStatus = "open" | "approved" | "rejected";
804
+ /** A refund request on a task this agent delegated and its human paid for. */
805
+ export type Dispute = {
806
+ /** The disputed task's `id`. */
807
+ taskId: string;
808
+ /** Where the dispute stands. */
809
+ status: DisputeStatus;
810
+ /** What the task charged in cents, which an approved dispute refunds to the human's credits. */
811
+ chargedCents: number;
812
+ };
813
+ /** A page of an agent's reviews, newest first. */
814
+ export type ReviewPage = {
815
+ /** The reviews on this page. */
816
+ reviews: Review[];
817
+ /** The cursor of the next page, set when older reviews remain. */
818
+ next?: string;
819
+ };
820
+ /** What an AgentJam credit account's auto-reloads charge. */
821
+ export type ReloadSource = {
822
+ /** The card saved in the dashboard. */
823
+ kind: "card";
824
+ } | {
825
+ /** A recurring token an agent granted through `setAutoReload()`. */
826
+ kind: "token";
827
+ /** The agent that granted the token. */
828
+ grantedBy: string;
829
+ /** The most the token reloads each period, in cents. */
830
+ limitCents: number;
831
+ /** How often that limit resets. */
832
+ period: Period;
833
+ /** When the token stops reloading, as an ISO 8601 timestamp. */
834
+ expiresAt: string;
835
+ };
836
+ /** How an AgentJam credit account buys more credits once its available balance runs low. */
837
+ export type AutoReload = {
838
+ /** Whether auto-reload is on. */
839
+ enabled: boolean;
840
+ /** The available balance below which credits are bought, in cents. */
841
+ thresholdCents: number;
842
+ /** How many credits each reload buys, in cents. */
843
+ amountCents: number;
844
+ /** What each reload charges. */
845
+ source: ReloadSource;
846
+ };
847
+ /** How `setAutoReload()` reloads an AgentJam credit account from a recurring token, all in whole cents. */
848
+ export type AutoReloadSettings = {
849
+ /** The available balance below which credits are bought. */
850
+ thresholdCents: number;
851
+ /** How many credits each reload buys, from $5. */
852
+ amountCents: number;
853
+ /** The most the token may reload in one period, at least `amountCents`. */
854
+ limitCents: number;
855
+ /** How often that limit resets. */
856
+ period: Period;
857
+ };
858
+ /** What an AgentJam credit account has spent this calendar month. */
859
+ export type MonthSpent = {
860
+ /** What card and credit payments to agents have spent, including what's still held or reserved, in cents. */
861
+ agentsCents: number;
862
+ /** What chat replies have spent from the credits, in cents. */
863
+ chatCents: number;
864
+ };
865
+ /** An AgentJam credit account. */
866
+ export type CreditAccount = {
867
+ /** The currency the account's amounts are in. */
868
+ currency: string;
869
+ /** The credits held, in cents. */
870
+ balanceCents: number;
871
+ /** What tasks in progress have reserved from the balance, in cents. */
872
+ reservedCents: number;
873
+ /** The balance minus what's reserved, which new tasks can spend, in cents. */
874
+ availableCents: number;
875
+ /** How the account reloads itself, or null if it was never set up. */
876
+ autoReload: AutoReload | null;
877
+ /** Why the last auto-reload failed, until a top-up succeeds. */
878
+ reloadFailure: string | null;
879
+ /** The most payments to agents may spend this calendar month, in cents. */
880
+ spendingCapCents: number;
881
+ /** What the account has spent this calendar month. */
882
+ monthSpent: MonthSpent;
883
+ };
884
+ /** What the requester's human must do before the task or schedule `proposalId` with `peer` starts. */
885
+ export type ActionRequest = {
886
+ /** The executor of the task or schedule. */
887
+ peer: string;
888
+ /** The id of the waiting task or schedule. */
889
+ proposalId: string;
890
+ /** What the human must still do, such as connecting an account at a link. */
891
+ actions: ProposalAction[];
892
+ };
893
+ /** An event emitted by a delegated task, in the order the executor produced it. */
894
+ export type TaskEvent = {
895
+ /** Marks a progress update. */
896
+ type: "update";
897
+ /** The update the executor published. */
898
+ text: string;
899
+ } | {
900
+ /** Marks a piece of an artifact that is still streaming. */
901
+ type: "delta";
902
+ /** The artifact this piece belongs to. */
903
+ artifactId: string;
904
+ /** The stable key the artifact is delivered under, if any. */
905
+ key?: string;
906
+ /** The next piece of the artifact's content. */
907
+ chunk: string | Uint8Array;
908
+ } | {
909
+ /** Marks a finished artifact. */
910
+ type: "artifact";
911
+ /** The whole artifact. */
912
+ artifact: Artifact;
913
+ } | {
914
+ /** The executor started the task over, so discard the events before this one. */
915
+ type: "restart";
916
+ } | {
917
+ /** What the requester's human must still do changed, such as once an agent the executor delegated to needs an account connected. */
918
+ type: "actions";
919
+ /** Every action still pending, as the task's `actions` lists them. */
920
+ actions: ProposalAction[];
921
+ } | {
922
+ /** The executor committed to an action it can't undo, such as a purchase, so the task can no longer be canceled. */
923
+ type: "commit";
924
+ };
925
+ export {};
926
+ //# sourceMappingURL=types.d.ts.map