@avow-finance/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 (267) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +122 -2
  3. package/dist/agent-entry.d.ts +15 -0
  4. package/dist/agent-entry.d.ts.map +1 -0
  5. package/dist/agent-entry.js +11 -0
  6. package/dist/agent-entry.js.map +1 -0
  7. package/dist/agent-key.d.ts +34 -0
  8. package/dist/agent-key.d.ts.map +1 -0
  9. package/dist/agent-key.js +33 -0
  10. package/dist/agent-key.js.map +1 -0
  11. package/dist/agent.d.ts +261 -0
  12. package/dist/agent.d.ts.map +1 -0
  13. package/dist/agent.js +493 -0
  14. package/dist/agent.js.map +1 -0
  15. package/dist/avow-api.d.ts +78 -0
  16. package/dist/avow-api.d.ts.map +1 -0
  17. package/dist/avow-api.js +2 -0
  18. package/dist/avow-api.js.map +1 -0
  19. package/dist/contest.d.ts +135 -0
  20. package/dist/contest.d.ts.map +1 -0
  21. package/dist/contest.js +186 -0
  22. package/dist/contest.js.map +1 -0
  23. package/dist/http.d.ts +161 -0
  24. package/dist/http.d.ts.map +1 -0
  25. package/dist/http.js +311 -0
  26. package/dist/http.js.map +1 -0
  27. package/dist/index.d.ts +38 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +38 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/job/accept.d.ts +84 -0
  32. package/dist/job/accept.d.ts.map +1 -0
  33. package/dist/job/accept.js +136 -0
  34. package/dist/job/accept.js.map +1 -0
  35. package/dist/job/customer.d.ts +43 -0
  36. package/dist/job/customer.d.ts.map +1 -0
  37. package/dist/job/customer.js +83 -0
  38. package/dist/job/customer.js.map +1 -0
  39. package/dist/job/quote.d.ts +34 -0
  40. package/dist/job/quote.d.ts.map +1 -0
  41. package/dist/job/quote.js +37 -0
  42. package/dist/job/quote.js.map +1 -0
  43. package/dist/lock.d.ts +269 -0
  44. package/dist/lock.d.ts.map +1 -0
  45. package/dist/lock.js +283 -0
  46. package/dist/lock.js.map +1 -0
  47. package/dist/moderato.d.ts +27 -0
  48. package/dist/moderato.d.ts.map +1 -0
  49. package/dist/moderato.js +34 -0
  50. package/dist/moderato.js.map +1 -0
  51. package/dist/node/cli.d.ts +3 -0
  52. package/dist/node/cli.d.ts.map +1 -0
  53. package/dist/node/cli.js +346 -0
  54. package/dist/node/cli.js.map +1 -0
  55. package/dist/node/connect.d.ts +15 -0
  56. package/dist/node/connect.d.ts.map +1 -0
  57. package/dist/node/connect.js +91 -0
  58. package/dist/node/connect.js.map +1 -0
  59. package/dist/node/eval.d.ts +3 -0
  60. package/dist/node/eval.d.ts.map +1 -0
  61. package/dist/node/eval.js +67 -0
  62. package/dist/node/eval.js.map +1 -0
  63. package/dist/node/first-run.d.ts +50 -0
  64. package/dist/node/first-run.d.ts.map +1 -0
  65. package/dist/node/first-run.js +149 -0
  66. package/dist/node/first-run.js.map +1 -0
  67. package/dist/node/job.d.ts +50 -0
  68. package/dist/node/job.d.ts.map +1 -0
  69. package/dist/node/job.js +176 -0
  70. package/dist/node/job.js.map +1 -0
  71. package/dist/node/mailbox.d.ts +19 -0
  72. package/dist/node/mailbox.d.ts.map +1 -0
  73. package/dist/node/mailbox.js +81 -0
  74. package/dist/node/mailbox.js.map +1 -0
  75. package/dist/node/mcp.d.ts +74 -0
  76. package/dist/node/mcp.d.ts.map +1 -0
  77. package/dist/node/mcp.js +367 -0
  78. package/dist/node/mcp.js.map +1 -0
  79. package/dist/node/platform.d.ts +35 -0
  80. package/dist/node/platform.d.ts.map +1 -0
  81. package/dist/node/platform.js +102 -0
  82. package/dist/node/platform.js.map +1 -0
  83. package/dist/node/runner-session.d.ts +41 -0
  84. package/dist/node/runner-session.d.ts.map +1 -0
  85. package/dist/node/runner-session.js +100 -0
  86. package/dist/node/runner-session.js.map +1 -0
  87. package/dist/node/runner.d.ts +63 -0
  88. package/dist/node/runner.d.ts.map +1 -0
  89. package/dist/node/runner.js +341 -0
  90. package/dist/node/runner.js.map +1 -0
  91. package/dist/node/service-child.d.ts +2 -0
  92. package/dist/node/service-child.d.ts.map +1 -0
  93. package/dist/node/service-child.js +40 -0
  94. package/dist/node/service-child.js.map +1 -0
  95. package/dist/node/service-excerpt.d.ts +21 -0
  96. package/dist/node/service-excerpt.d.ts.map +1 -0
  97. package/dist/node/service-excerpt.js +32 -0
  98. package/dist/node/service-excerpt.js.map +1 -0
  99. package/dist/node/service-process.d.ts +12 -0
  100. package/dist/node/service-process.d.ts.map +1 -0
  101. package/dist/node/service-process.js +132 -0
  102. package/dist/node/service-process.js.map +1 -0
  103. package/dist/node/session-input.d.ts +12 -0
  104. package/dist/node/session-input.d.ts.map +1 -0
  105. package/dist/node/session-input.js +42 -0
  106. package/dist/node/session-input.js.map +1 -0
  107. package/dist/node/session-view.d.ts +20 -0
  108. package/dist/node/session-view.d.ts.map +1 -0
  109. package/dist/node/session-view.js +198 -0
  110. package/dist/node/session-view.js.map +1 -0
  111. package/dist/node-agent.d.ts +2 -0
  112. package/dist/node-agent.d.ts.map +1 -0
  113. package/dist/node-agent.js +6 -0
  114. package/dist/node-agent.js.map +1 -0
  115. package/dist/node.d.ts +2 -0
  116. package/dist/node.d.ts.map +1 -0
  117. package/dist/node.js +9 -0
  118. package/dist/node.js.map +1 -0
  119. package/dist/sandbox/agent.d.ts +187 -0
  120. package/dist/sandbox/agent.d.ts.map +1 -0
  121. package/dist/sandbox/agent.js +468 -0
  122. package/dist/sandbox/agent.js.map +1 -0
  123. package/dist/sandbox/business-store.d.ts +19 -0
  124. package/dist/sandbox/business-store.d.ts.map +1 -0
  125. package/dist/sandbox/business-store.js +19 -0
  126. package/dist/sandbox/business-store.js.map +1 -0
  127. package/dist/sandbox/business.d.ts +70 -0
  128. package/dist/sandbox/business.d.ts.map +1 -0
  129. package/dist/sandbox/business.js +115 -0
  130. package/dist/sandbox/business.js.map +1 -0
  131. package/dist/sandbox/connect.d.ts +64 -0
  132. package/dist/sandbox/connect.d.ts.map +1 -0
  133. package/dist/sandbox/connect.js +182 -0
  134. package/dist/sandbox/connect.js.map +1 -0
  135. package/dist/sandbox/deployment.d.ts +14 -0
  136. package/dist/sandbox/deployment.d.ts.map +1 -0
  137. package/dist/sandbox/deployment.js +38 -0
  138. package/dist/sandbox/deployment.js.map +1 -0
  139. package/dist/sandbox/keys.d.ts +45 -0
  140. package/dist/sandbox/keys.d.ts.map +1 -0
  141. package/dist/sandbox/keys.js +132 -0
  142. package/dist/sandbox/keys.js.map +1 -0
  143. package/dist/sandbox/mailbox.d.ts +90 -0
  144. package/dist/sandbox/mailbox.d.ts.map +1 -0
  145. package/dist/sandbox/mailbox.js +400 -0
  146. package/dist/sandbox/mailbox.js.map +1 -0
  147. package/dist/sandbox/mandate.d.ts +84 -0
  148. package/dist/sandbox/mandate.d.ts.map +1 -0
  149. package/dist/sandbox/mandate.js +107 -0
  150. package/dist/sandbox/mandate.js.map +1 -0
  151. package/dist/sandbox/namespace.d.ts +16 -0
  152. package/dist/sandbox/namespace.d.ts.map +1 -0
  153. package/dist/sandbox/namespace.js +16 -0
  154. package/dist/sandbox/namespace.js.map +1 -0
  155. package/dist/sandbox/session.d.ts +60 -0
  156. package/dist/sandbox/session.d.ts.map +1 -0
  157. package/dist/sandbox/session.js +94 -0
  158. package/dist/sandbox/session.js.map +1 -0
  159. package/dist/sandbox/setup.d.ts +136 -0
  160. package/dist/sandbox/setup.d.ts.map +1 -0
  161. package/dist/sandbox/setup.js +490 -0
  162. package/dist/sandbox/setup.js.map +1 -0
  163. package/dist/sandbox/store.d.ts +69 -0
  164. package/dist/sandbox/store.d.ts.map +1 -0
  165. package/dist/sandbox/store.js +115 -0
  166. package/dist/sandbox/store.js.map +1 -0
  167. package/dist/sandbox/supplier-key.d.ts +73 -0
  168. package/dist/sandbox/supplier-key.d.ts.map +1 -0
  169. package/dist/sandbox/supplier-key.js +180 -0
  170. package/dist/sandbox/supplier-key.js.map +1 -0
  171. package/dist/sandbox/suppliers.d.ts +7 -0
  172. package/dist/sandbox/suppliers.d.ts.map +1 -0
  173. package/dist/sandbox/suppliers.js +29 -0
  174. package/dist/sandbox/suppliers.js.map +1 -0
  175. package/dist/sandbox/terms.d.ts +32 -0
  176. package/dist/sandbox/terms.d.ts.map +1 -0
  177. package/dist/sandbox/terms.js +58 -0
  178. package/dist/sandbox/terms.js.map +1 -0
  179. package/dist/sandbox/vault.d.ts +24 -0
  180. package/dist/sandbox/vault.d.ts.map +1 -0
  181. package/dist/sandbox/vault.js +54 -0
  182. package/dist/sandbox/vault.js.map +1 -0
  183. package/dist/send.d.ts +122 -0
  184. package/dist/send.d.ts.map +1 -0
  185. package/dist/send.js +328 -0
  186. package/dist/send.js.map +1 -0
  187. package/dist/service-entry.d.ts +6 -0
  188. package/dist/service-entry.d.ts.map +1 -0
  189. package/dist/service-entry.js +6 -0
  190. package/dist/service-entry.js.map +1 -0
  191. package/dist/session/anthropic.d.ts +17 -0
  192. package/dist/session/anthropic.d.ts.map +1 -0
  193. package/dist/session/anthropic.js +215 -0
  194. package/dist/session/anthropic.js.map +1 -0
  195. package/dist/session/charge.d.ts +13 -0
  196. package/dist/session/charge.d.ts.map +1 -0
  197. package/dist/session/charge.js +33 -0
  198. package/dist/session/charge.js.map +1 -0
  199. package/dist/session/data.d.ts +8 -0
  200. package/dist/session/data.d.ts.map +1 -0
  201. package/dist/session/data.js +20 -0
  202. package/dist/session/data.js.map +1 -0
  203. package/dist/session/eval.d.ts +41 -0
  204. package/dist/session/eval.d.ts.map +1 -0
  205. package/dist/session/eval.js +281 -0
  206. package/dist/session/eval.js.map +1 -0
  207. package/dist/session/executor.d.ts +80 -0
  208. package/dist/session/executor.d.ts.map +1 -0
  209. package/dist/session/executor.js +381 -0
  210. package/dist/session/executor.js.map +1 -0
  211. package/dist/session/fixture-world.d.ts +29 -0
  212. package/dist/session/fixture-world.d.ts.map +1 -0
  213. package/dist/session/fixture-world.js +708 -0
  214. package/dist/session/fixture-world.js.map +1 -0
  215. package/dist/session/live-world.d.ts +22 -0
  216. package/dist/session/live-world.d.ts.map +1 -0
  217. package/dist/session/live-world.js +329 -0
  218. package/dist/session/live-world.js.map +1 -0
  219. package/dist/session/ollama.d.ts +29 -0
  220. package/dist/session/ollama.d.ts.map +1 -0
  221. package/dist/session/ollama.js +177 -0
  222. package/dist/session/ollama.js.map +1 -0
  223. package/dist/session/provider.d.ts +79 -0
  224. package/dist/session/provider.d.ts.map +1 -0
  225. package/dist/session/provider.js +19 -0
  226. package/dist/session/provider.js.map +1 -0
  227. package/dist/session/scripted.d.ts +45 -0
  228. package/dist/session/scripted.d.ts.map +1 -0
  229. package/dist/session/scripted.js +236 -0
  230. package/dist/session/scripted.js.map +1 -0
  231. package/dist/session/selection.d.ts +37 -0
  232. package/dist/session/selection.d.ts.map +1 -0
  233. package/dist/session/selection.js +104 -0
  234. package/dist/session/selection.js.map +1 -0
  235. package/dist/session/service-check.d.ts +48 -0
  236. package/dist/session/service-check.d.ts.map +1 -0
  237. package/dist/session/service-check.js +86 -0
  238. package/dist/session/service-check.js.map +1 -0
  239. package/dist/session/service.d.ts +128 -0
  240. package/dist/session/service.d.ts.map +1 -0
  241. package/dist/session/service.js +150 -0
  242. package/dist/session/service.js.map +1 -0
  243. package/dist/session/session.d.ts +95 -0
  244. package/dist/session/session.d.ts.map +1 -0
  245. package/dist/session/session.js +312 -0
  246. package/dist/session/session.js.map +1 -0
  247. package/dist/session/toolbox.d.ts +69 -0
  248. package/dist/session/toolbox.d.ts.map +1 -0
  249. package/dist/session/toolbox.js +391 -0
  250. package/dist/session/toolbox.js.map +1 -0
  251. package/dist/session/tools.d.ts +45 -0
  252. package/dist/session/tools.d.ts.map +1 -0
  253. package/dist/session/tools.js +137 -0
  254. package/dist/session/tools.js.map +1 -0
  255. package/dist/session/world.d.ts +188 -0
  256. package/dist/session/world.d.ts.map +1 -0
  257. package/dist/session/world.js +2 -0
  258. package/dist/session/world.js.map +1 -0
  259. package/dist/sign.d.ts +19 -0
  260. package/dist/sign.d.ts.map +1 -0
  261. package/dist/sign.js +33 -0
  262. package/dist/sign.js.map +1 -0
  263. package/dist/supplier.d.ts +41 -0
  264. package/dist/supplier.d.ts.map +1 -0
  265. package/dist/supplier.js +57 -0
  266. package/dist/supplier.js.map +1 -0
  267. package/package.json +56 -3
@@ -0,0 +1,43 @@
1
+ import type { ReasonCode } from '@avow-finance/spec';
2
+ import { type DeliveryReport, type JobOffer, type OrderAnswer, type OrderScenario, type OrderState, type QuoteRequest, type SupplierProfile, type TestCustomerProfile } from '@avow-finance/spec';
3
+ import { type AvowRequestConfig } from '../http.js';
4
+ /** The test customer's refusal of a GET, or an answer to one that doesn't read. */
5
+ export declare class TestCustomerError extends Error {
6
+ readonly status: number;
7
+ readonly reason: ReasonCode | null;
8
+ constructor(message: string, status: number, reason: ReasonCode | null);
9
+ }
10
+ /**
11
+ * Avow's test customer as the developer's job process reaches it. Orders arrive by pull: the
12
+ * process asks for one, quotes it, polls it while the customer checks the quote and reserves, and
13
+ * reports delivery. Every POST is signed with the supplier's signing key under the customer's lock,
14
+ * and resent with the same bytes until the customer answers, as `avowRequests` does for Avow's API.
15
+ */
16
+ export interface TestCustomer {
17
+ /** The customer's profile, labelled as Avow's test customer, read when the client connected. */
18
+ readonly profile: TestCustomerProfile;
19
+ /**
20
+ * Asks for a new order for this supplier, the developer's business as Avow registered it. With a
21
+ * scenario, the customer plays it out on that order.
22
+ */
23
+ order(supplier: SupplierProfile, scenario?: OrderScenario): Promise<JobOffer>;
24
+ /** Sends the quote for an order. The customer answers while it checks it. */
25
+ quote(orderId: string, quote: QuoteRequest): Promise<OrderAnswer>;
26
+ /** Where an order stands now. */
27
+ state(orderId: string): Promise<OrderState>;
28
+ /** Reports the job delivered, handing over its result. The customer answers, then pays. */
29
+ delivery(orderId: string, report: DeliveryReport): Promise<OrderAnswer>;
30
+ }
31
+ /** What a test customer client needs: the signed-request settings and the chain expected. */
32
+ export interface TestCustomerConfig extends AvowRequestConfig {
33
+ /** The chain the customer's lock has to be on. */
34
+ chainId: number;
35
+ }
36
+ /**
37
+ * Connects to Avow's test customer at `config.baseUrl`, the sandbox deployment's `customerUrl`,
38
+ * with `config.key` the supplier's signing key. It reads the customer's profile first and refuses
39
+ * one on another chain. An offer has to name the supplier that asked for it and the customer the
40
+ * profile names, and an order's state has to be the order asked about.
41
+ */
42
+ export declare function connectTestCustomer(config: TestCustomerConfig): Promise<TestCustomer>;
43
+ //# sourceMappingURL=customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../src/job/customer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,UAAU,EAOf,KAAK,YAAY,EACjB,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,iBAAiB,EAAgB,MAAM,YAAY,CAAA;AAEjE,mFAAmF;AACnF,qBAAa,iBAAkB,SAAQ,KAAK;IAGxC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAHpC,YACE,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,GAAG,IAAI,EAInC;CACF;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,gGAAgG;IAChG,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAA;IACrC;;;OAGG;IACH,KAAK,CAAC,QAAQ,EAAE,eAAe,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC7E,6EAA6E;IAC7E,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IACjE,iCAAiC;IACjC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAC3C,2FAA2F;IAC3F,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CACxE;AAED,6FAA6F;AAC7F,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAA;CAChB;AAyBD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAmD3F"}
@@ -0,0 +1,83 @@
1
+ import { parseApiError, parseJobOffer, parseOrderAnswer, parseOrderState, parseTestCustomerProfile, TEST_CUSTOMER_PATHS, } from '@avow-finance/spec';
2
+ import { avowRequests } from '../http.js';
3
+ /** The test customer's refusal of a GET, or an answer to one that doesn't read. */
4
+ export class TestCustomerError extends Error {
5
+ status;
6
+ reason;
7
+ constructor(message, status, reason) {
8
+ super(message);
9
+ this.status = status;
10
+ this.reason = reason;
11
+ this.name = 'TestCustomerError';
12
+ }
13
+ }
14
+ /** Reads a GET's JSON, throwing the customer's refusal or an unreadable answer as an error. */
15
+ async function getJson(url, fetchOnce, read) {
16
+ const answer = await fetchOnce(url, {
17
+ redirect: 'error',
18
+ headers: { accept: 'application/json' },
19
+ });
20
+ const json = await answer.json().catch(() => null);
21
+ if (!answer.ok) {
22
+ const refusal = parseApiError(json);
23
+ const message = refusal?.message ?? `The test customer answered ${answer.status}`;
24
+ throw new TestCustomerError(message, answer.status, refusal?.reason ?? null);
25
+ }
26
+ const parsed = read(json);
27
+ if (!parsed.ok) {
28
+ throw new TestCustomerError(`The answer at ${url} doesn't read`, answer.status, parsed.reason);
29
+ }
30
+ return parsed.value;
31
+ }
32
+ /**
33
+ * Connects to Avow's test customer at `config.baseUrl`, the sandbox deployment's `customerUrl`,
34
+ * with `config.key` the supplier's signing key. It reads the customer's profile first and refuses
35
+ * one on another chain. An offer has to name the supplier that asked for it and the customer the
36
+ * profile names, and an order's state has to be the order asked about.
37
+ */
38
+ export async function connectTestCustomer(config) {
39
+ const fetchOnce = config.fetch ?? fetch;
40
+ const origin = new URL(config.baseUrl).origin;
41
+ const profile = await getJson(`${origin}${TEST_CUSTOMER_PATHS.profile}`, fetchOnce, parseTestCustomerProfile);
42
+ if (profile.chainId !== config.chainId) {
43
+ throw new Error(`The test customer is on chain ${profile.chainId}, not ${config.chainId}`);
44
+ }
45
+ const send = avowRequests(config);
46
+ const domain = { chainId: profile.chainId, verifyingContract: profile.lock };
47
+ const fromThisCustomer = (businessId) => businessId === profile.businessId;
48
+ return {
49
+ profile,
50
+ order: (supplier, scenario) => send({
51
+ domain,
52
+ path: TEST_CUSTOMER_PATHS.orders,
53
+ body: scenario ? { supplier, scenario } : { supplier },
54
+ read: (json) => {
55
+ const offer = parseJobOffer(json);
56
+ if (!offer.ok)
57
+ return offer;
58
+ const ours = offer.value.supplierBusinessId === supplier.businessId &&
59
+ fromThisCustomer(offer.value.customer.businessId);
60
+ return ours ? offer : { ok: false, reason: 'message.invalid' };
61
+ },
62
+ }),
63
+ quote: (orderId, quote) => send({
64
+ domain,
65
+ path: TEST_CUSTOMER_PATHS.quote(orderId),
66
+ body: quote,
67
+ read: parseOrderAnswer,
68
+ }),
69
+ state: (orderId) => getJson(`${origin}${TEST_CUSTOMER_PATHS.order(orderId)}`, fetchOnce, (json) => {
70
+ const state = parseOrderState(json);
71
+ if (!state.ok)
72
+ return state;
73
+ return state.value.orderId === orderId ? state : { ok: false, reason: 'message.invalid' };
74
+ }),
75
+ delivery: (orderId, report) => send({
76
+ domain,
77
+ path: TEST_CUSTOMER_PATHS.delivery(orderId),
78
+ body: report,
79
+ read: parseOrderAnswer,
80
+ }),
81
+ };
82
+ }
83
+ //# sourceMappingURL=customer.js.map
@@ -0,0 +1 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AAC;YAC3C,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,gBAAgB;SACvB,CAAC;KACL,CAAA;AACH,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type BuyerSideReference, type GpuReservationTerms, type JobBuyer, type JobOffer, type QuoteRequest, type RequestKey, type SupplierProfile } from '@avow-finance/spec';
2
+ /** The compute a job relies on: the business's own booking of it, with its terms and salt. */
3
+ export interface ComputeBooking {
4
+ /** The booking, on the buyer side of the business's own lock. */
5
+ reference: BuyerSideReference;
6
+ terms: GpuReservationTerms;
7
+ salt: `0x${string}`;
8
+ }
9
+ export interface JobQuoteInput {
10
+ /** The order, Avow's test customer's offer or another business's order from the mailbox. */
11
+ offer: Pick<JobOffer, 'terms' | 'commitmentId'>;
12
+ /** The buyer, which the agreement names with its agent's mandate. */
13
+ customer: JobBuyer;
14
+ /** The developer's business, as Avow registered it as a supplier. */
15
+ supplier: SupplierProfile;
16
+ /** The supplier's signing key, which signs the terms agreement. */
17
+ signingKey: RequestKey;
18
+ /**
19
+ * The compute booking the quote names, or null for a quote that names none, which the customer
20
+ * refuses as `dependency.required`, as Avow would.
21
+ */
22
+ compute: ComputeBooking | null;
23
+ /** When the agreement lapses, in unix seconds. The customer refuses one valid too long. */
24
+ expiry: bigint;
25
+ }
26
+ /**
27
+ * Quotes an order. The quote's terms are the offer's, with the compute booking added as the one
28
+ * booking they rely on, which makes them version 3. The salt is new, and the signing key signs the
29
+ * terms agreement naming the offer's commitment id, the customer as buyer under its mandate, this
30
+ * business as supplier and the job category. The quote shows the compute booking's subject, which
31
+ * holds no price, so the customer can check the booking fits the job.
32
+ */
33
+ export declare function quoteJob(input: JobQuoteInput): Promise<QuoteRequest>;
34
+ //# sourceMappingURL=quote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/job/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAIvB,KAAK,mBAAmB,EAExB,KAAK,QAAQ,EACb,KAAK,QAAQ,EAEb,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EAKrB,MAAM,oBAAoB,CAAA;AAG3B,8FAA8F;AAC9F,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,SAAS,EAAE,kBAAkB,CAAA;IAC7B,KAAK,EAAE,mBAAmB,CAAA;IAC1B,IAAI,EAAE,KAAK,MAAM,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,4FAA4F;IAC5F,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,cAAc,CAAC,CAAA;IAC/C,qEAAqE;IACrE,QAAQ,EAAE,QAAQ,CAAA;IAClB,qEAAqE;IACrE,QAAQ,EAAE,eAAe,CAAA;IACzB,mEAAmE;IACnE,UAAU,EAAE,UAAU,CAAA;IACtB;;;OAGG;IACH,OAAO,EAAE,cAAc,GAAG,IAAI,CAAA;IAC9B,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAA;CACf;AAID;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA2B1E"}
@@ -0,0 +1,37 @@
1
+ import { chainedJobTerms, digestOf, discloseSection, JOB_CATEGORY, newSalt, termsAgreementTypedData, termsHash, toWire, } from '@avow-finance/spec';
2
+ import { hexToBigInt, toHex } from 'viem';
3
+ const randomUint = () => hexToBigInt(toHex(crypto.getRandomValues(new Uint8Array(16))));
4
+ /**
5
+ * Quotes an order. The quote's terms are the offer's, with the compute booking added as the one
6
+ * booking they rely on, which makes them version 3. The salt is new, and the signing key signs the
7
+ * terms agreement naming the offer's commitment id, the customer as buyer under its mandate, this
8
+ * business as supplier and the job category. The quote shows the compute booking's subject, which
9
+ * holds no price, so the customer can check the booking fits the job.
10
+ */
11
+ export async function quoteJob(input) {
12
+ const { offer, customer, compute } = input;
13
+ if (input.signingKey.address.toLowerCase() !== input.supplier.signingKey.toLowerCase()) {
14
+ throw new Error("The key given isn't the supplier's signing key");
15
+ }
16
+ const terms = compute
17
+ ? chainedJobTerms(offer.terms, [
18
+ { on: compute.reference, condition: 'accepted', disclosed: 'subject' },
19
+ ])
20
+ : offer.terms;
21
+ const salt = newSalt();
22
+ const agreement = {
23
+ commitmentId: offer.commitmentId,
24
+ termsHash: termsHash(terms, salt),
25
+ category: JOB_CATEGORY,
26
+ buyerBusinessId: customer.businessId,
27
+ supplierBusinessId: input.supplier.businessId,
28
+ mandateHash: customer.mandateHash,
29
+ nonce: randomUint(),
30
+ expiry: input.expiry,
31
+ };
32
+ const domain = { chainId: customer.chainId, verifyingContract: customer.lock };
33
+ const supplierSignature = await input.signingKey.signDigest(digestOf(termsAgreementTypedData(agreement, domain)));
34
+ const disclosed = compute ? [toWire(discloseSection(compute.terms, compute.salt, 'subject'))] : [];
35
+ return { terms, salt, agreement, supplierSignature, disclosed };
36
+ }
37
+ //# sourceMappingURL=quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote.js","sourceRoot":"","sources":["../../src/job/quote.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,QAAQ,EACR,eAAe,EAEf,YAAY,EAGZ,OAAO,EAKP,uBAAuB,EACvB,SAAS,EACT,MAAM,GACP,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AA4BzC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAEvF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,KAAoB;IACjD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;IAC1C,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,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AAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAA;AACjE,CAAC"}
package/dist/lock.d.ts ADDED
@@ -0,0 +1,269 @@
1
+ import { type Approval, type AvowDomain, type ContestStatement, type Side, type Signed } from '@avow-finance/spec';
2
+ import { FACTORY_ABI, type LockedBacking } from '@avow-finance/verifier';
3
+ import { type Address, type Chain, type Client, type Hex, type Transport } from 'viem';
4
+ /**
5
+ * The lock function an agent's key calls to fund a reserve, as the testnet lock declares it. The
6
+ * lock is unaudited testnet code, and a new factory can change this interface. Knowing it grants
7
+ * nothing, since on each call the lock checks Avow's signature over every field of the approval,
8
+ * the calling account and key, the supplier, the caps and the expiry.
9
+ */
10
+ export declare const RESERVE_ABI: readonly [{
11
+ readonly type: 'function';
12
+ readonly name: 'reserve';
13
+ readonly inputs: readonly [{
14
+ readonly name: 'a';
15
+ readonly type: 'tuple';
16
+ readonly components: readonly [{
17
+ readonly name: 'commitmentId';
18
+ readonly type: 'bytes32';
19
+ }, {
20
+ readonly name: 'side';
21
+ readonly type: 'uint8';
22
+ }, {
23
+ readonly name: 'token';
24
+ readonly type: 'address';
25
+ }, {
26
+ readonly name: 'amount';
27
+ readonly type: 'uint256';
28
+ }, {
29
+ readonly name: 'supplier';
30
+ readonly type: 'address';
31
+ }, {
32
+ readonly name: 'supplierSigner';
33
+ readonly type: 'address';
34
+ }, {
35
+ readonly name: 'payee';
36
+ readonly type: 'address';
37
+ }, {
38
+ readonly name: 'freeCancelBy';
39
+ readonly type: 'uint64';
40
+ }, {
41
+ readonly name: 'acceptBy';
42
+ readonly type: 'uint64';
43
+ }, {
44
+ readonly name: 'chargeDeadline';
45
+ readonly type: 'uint64';
46
+ }, {
47
+ readonly name: 'releaseDate';
48
+ readonly type: 'uint64';
49
+ }, {
50
+ readonly name: 'contestWindow';
51
+ readonly type: 'uint64';
52
+ }, {
53
+ readonly name: 'charges';
54
+ readonly type: 'tuple[]';
55
+ readonly components: readonly [{
56
+ readonly name: 'kind';
57
+ readonly type: 'uint8';
58
+ }, {
59
+ readonly name: 'most';
60
+ readonly type: 'uint256';
61
+ }, {
62
+ readonly name: 'earliest';
63
+ readonly type: 'uint64';
64
+ }];
65
+ }, {
66
+ readonly name: 'day90SupplierShareBps';
67
+ readonly type: 'uint16';
68
+ }, {
69
+ readonly name: 'arbiter';
70
+ readonly type: 'address';
71
+ }, {
72
+ readonly name: 'termsHash';
73
+ readonly type: 'bytes32';
74
+ }, {
75
+ readonly name: 'mandateHash';
76
+ readonly type: 'bytes32';
77
+ }, {
78
+ readonly name: 'capPerCommitment';
79
+ readonly type: 'uint256';
80
+ }, {
81
+ readonly name: 'capOpenReserves';
82
+ readonly type: 'uint256';
83
+ }, {
84
+ readonly name: 'fundingKey';
85
+ readonly type: 'address';
86
+ }, {
87
+ readonly name: 'nonce';
88
+ readonly type: 'uint256';
89
+ }, {
90
+ readonly name: 'expiry';
91
+ readonly type: 'uint64';
92
+ }];
93
+ }, {
94
+ readonly name: 'avowSignature';
95
+ readonly type: 'bytes';
96
+ }];
97
+ readonly outputs: readonly [];
98
+ readonly stateMutability: 'nonpayable';
99
+ }];
100
+ /**
101
+ * The selector of `reserve`, the only lock function an agent's key may call. `agentKeyTerms`
102
+ * takes it as the key's one lock selector.
103
+ */
104
+ export declare const RESERVE_SELECTOR: Hex;
105
+ /**
106
+ * The calls a business account's root key makes on its own lock and on the factory, as the testnet
107
+ * contracts declare them. Approving a supplier lets an agent reserve for it, and only the account's
108
+ * root key can do it. Cancelling before free cancellation ends takes a reserve back in full, and
109
+ * contesting a charge pauses it until someone rules.
110
+ */
111
+ export declare const ADMINISTRATOR_ABI: readonly [{
112
+ readonly type: 'function';
113
+ readonly name: 'approveSupplier';
114
+ readonly inputs: readonly [{
115
+ readonly name: 'supplier';
116
+ readonly type: 'address';
117
+ }];
118
+ readonly outputs: readonly [];
119
+ readonly stateMutability: 'nonpayable';
120
+ }, {
121
+ readonly type: 'function';
122
+ readonly name: 'removeSupplier';
123
+ readonly inputs: readonly [{
124
+ readonly name: 'supplier';
125
+ readonly type: 'address';
126
+ }];
127
+ readonly outputs: readonly [];
128
+ readonly stateMutability: 'nonpayable';
129
+ }, {
130
+ readonly type: 'function';
131
+ readonly name: 'approvedSupplier';
132
+ readonly inputs: readonly [{
133
+ readonly name: 'supplier';
134
+ readonly type: 'address';
135
+ }];
136
+ readonly outputs: readonly [{
137
+ readonly name: '';
138
+ readonly type: 'bool';
139
+ }];
140
+ readonly stateMutability: 'view';
141
+ }, {
142
+ readonly type: 'function';
143
+ readonly name: 'cancelFree';
144
+ readonly inputs: readonly [{
145
+ readonly name: 'commitmentId';
146
+ readonly type: 'bytes32';
147
+ }, {
148
+ readonly name: 'side';
149
+ readonly type: 'uint8';
150
+ }];
151
+ readonly outputs: readonly [];
152
+ readonly stateMutability: 'nonpayable';
153
+ }, {
154
+ readonly type: 'function';
155
+ readonly name: 'contest';
156
+ readonly inputs: readonly [{
157
+ readonly name: 'commitmentId';
158
+ readonly type: 'bytes32';
159
+ }, {
160
+ readonly name: 'side';
161
+ readonly type: 'uint8';
162
+ }, {
163
+ readonly name: 'reportNumber';
164
+ readonly type: 'uint8';
165
+ }, {
166
+ readonly name: 'reasonCode';
167
+ readonly type: 'uint16';
168
+ }, {
169
+ readonly name: 'statementHash';
170
+ readonly type: 'bytes32';
171
+ }];
172
+ readonly outputs: readonly [];
173
+ readonly stateMutability: 'nonpayable';
174
+ }];
175
+ /**
176
+ * The lock factory's functions. The verifier defines them once, and the SDK passes the same
177
+ * definition on, so an agent and a supplier never read the factory through two different ABIs.
178
+ */
179
+ export { FACTORY_ABI };
180
+ /**
181
+ * The lock's running total of what each mandate's open reserves hold. The lock refuses a reserve
182
+ * that would take it above the cap on open reserves that Avow's approval carries, and Avow's
183
+ * reserve check reads the same total before it approves one.
184
+ */
185
+ export declare const OPEN_RESERVES_ABI: readonly [{
186
+ readonly type: 'function';
187
+ readonly name: 'openReserves';
188
+ readonly inputs: readonly [{
189
+ readonly name: 'mandateHash';
190
+ readonly type: 'bytes32';
191
+ }];
192
+ readonly outputs: readonly [{
193
+ readonly name: '';
194
+ readonly type: 'uint256';
195
+ }];
196
+ readonly stateMutability: 'view';
197
+ }];
198
+ /** What the lock holds in open reserves under one mandate, in the token's base units. */
199
+ export declare function readOpenReserves(client: Client<Transport, Chain>, lock: Address, mandateHash: Hex): Promise<bigint>;
200
+ /** One call in a Tempo transaction. */
201
+ export interface Call {
202
+ to: Address;
203
+ data: Hex;
204
+ }
205
+ /**
206
+ * The two calls that fund a reserve in one transaction. The first approves the lock to pull the
207
+ * approval's amount of its token, and the second calls `reserve` with Avow's approval and
208
+ * signature.
209
+ */
210
+ export declare function reserveCalls(approval: Signed<Approval>, d: AvowDomain): Call[];
211
+ /** The call that creates a business account's lock from the factory. */
212
+ export declare function createLockCall(factory: Address, account: Address): Call;
213
+ /** The call, from the business account's root key, that lets its agents reserve for a supplier. */
214
+ export declare function approveSupplierCall(lock: Address, supplier: Address): Call;
215
+ /**
216
+ * The call, from the business account's root key, that stops its agents reserving for a supplier.
217
+ * A commitment already reserved for that supplier stays as it is.
218
+ */
219
+ export declare function removeSupplierCall(lock: Address, supplier: Address): Call;
220
+ /**
221
+ * The call, from the business account's root key, that cancels a commitment on the lock before
222
+ * free cancellation ends and gives the whole reserve back. It cancels the buyer's side, the only
223
+ * side a lock holds a reserve for in this release. Until then Avow refuses to record a
224
+ * cancellation, with `commitment.cancel_on_lock`, since the business cancels on the lock without
225
+ * anyone else's signature.
226
+ */
227
+ export declare function cancelFreeCall(lock: Address, commitmentId: Hex): Call;
228
+ /**
229
+ * The call, from the business account's root key, that contests the charge or report a statement
230
+ * names. It carries the statement's reason code and its hash, which the lock logs in its `Paused`
231
+ * event, and throws on a statement the spec's format refuses.
232
+ */
233
+ export declare function contestCall(lock: Address, statement: ContestStatement): Call;
234
+ /**
235
+ * Whether the lock takes `cancelFreeCall` for a commitment at `now`, by the chain's clock. It takes
236
+ * it for a reserve the supplier hasn't accepted, or one accepted with no report standing, until
237
+ * free cancellation ends, whatever the agent's mandate permits.
238
+ */
239
+ export declare function cancelsFree(held: LockedBacking, now: bigint): boolean;
240
+ /**
241
+ * The lock's `trigger`, as the testnet lock declares it, with the error it reverts with when no
242
+ * step is due. It takes whichever step is due for one side of a commitment once a deadline has
243
+ * passed. It returns a reserve the supplier never accepted, releases a kept reserve at its release
244
+ * date, times out a charge report Avow didn't confirm or refer in time, pays a confirmed charge
245
+ * once its contest window closes and applies a posted ruling once its delay has passed. At day 90
246
+ * it resolves a paused charge nobody ruled on, paying a confirmed charge at the day-90 share and
247
+ * returning an unconfirmed one to the business in full. Anyone can send it, since the lock pays
248
+ * only the parties it recorded.
249
+ */
250
+ export declare const TRIGGER_ABI: readonly [{
251
+ readonly type: 'function';
252
+ readonly name: 'trigger';
253
+ readonly inputs: readonly [{
254
+ readonly name: 'commitmentId';
255
+ readonly type: 'bytes32';
256
+ }, {
257
+ readonly name: 'side';
258
+ readonly type: 'uint8';
259
+ }];
260
+ readonly outputs: readonly [];
261
+ readonly stateMutability: 'nonpayable';
262
+ }, {
263
+ readonly type: 'error';
264
+ readonly name: 'NothingDue';
265
+ readonly inputs: readonly [];
266
+ }];
267
+ /** The call that takes the step due for one side of a commitment, from any account. */
268
+ export declare function triggerCall(lock: Address, commitmentId: Hex, side: Side): Call;
269
+ //# sourceMappingURL=lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../src/lock.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,UAAU,EAGf,KAAK,gBAAgB,EAGrB,KAAK,IAAI,EACT,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACxE,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EAEX,KAAK,GAAG,EACR,KAAK,SAAS,EAEf,MAAM,MAAM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