@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,149 @@
1
+ import { formatUsd } from '@avow-finance/spec';
2
+ import { JOB_COMMAND } from '../session/session.js';
3
+ /** How many steps a first run has, two of setup's and three of the agent session's. */
4
+ export const FIRST_RUN_STEPS = 5;
5
+ const PAUSED_SINCE = {
6
+ contested: 'the customer contested it',
7
+ referred: "Avow's records didn't support the report",
8
+ unanswered: "Avow didn't answer the report in time",
9
+ };
10
+ /** Where a cancelled job's charge stands, in one or two sentences. */
11
+ function chargeLine(ended, clock) {
12
+ const broke = 'The customer cancelled after work started.';
13
+ if ('refused' in ended.charge) {
14
+ return `${broke} Your code couldn't report the charge (${ended.charge.refused}), so the customer's reserve stands as it was.`;
15
+ }
16
+ const { amount, standing } = ended.charge;
17
+ const charge = `${formatUsd(amount)} charge`;
18
+ switch (standing.state) {
19
+ case 'confirmed':
20
+ return `${broke} Your code reported the ${charge} its terms allow, and Avow confirmed it from its record of the customer's signed cancellation. The customer can contest it until ${clock(standing.contestableUntil)}, which would pause it for a ruling, and it's payable to you then if it hasn't.`;
21
+ case 'paid':
22
+ return `${broke} The ${charge} was reported, confirmed and paid to your business.`;
23
+ case 'paused':
24
+ return `${broke} Your code reported the ${charge}, and it's paused for a ruling since ${PAUSED_SINCE[standing.cause]}. Nothing pays until a ruling is posted.`;
25
+ default:
26
+ return `${broke} Your code reported the ${charge}, and Avow hasn't answered the report yet.`;
27
+ }
28
+ }
29
+ const utc = (seconds) => `${new Date(Number(seconds) * 1000).toISOString().slice(11, 16)} UTC`;
30
+ /** How a job ended, in one line. */
31
+ export function outcomeLine(ended, clock = utc) {
32
+ if (ended?.kind === 'cancelled')
33
+ return chargeLine(ended, clock);
34
+ return ended?.kind === 'paid'
35
+ ? 'The job is done and paid. Both reserves come back by themselves at their release dates.'
36
+ : ended?.kind === 'refused'
37
+ ? `The customer refused the quote with ${ended.refusal.code}, so no work started.`
38
+ : ended?.kind === 'not_started'
39
+ ? `Your side didn't accept the job, with ${ended.code} at the ${ended.layer} layer, so no work started.`
40
+ : ended?.kind === 'stopped'
41
+ ? ended.why
42
+ : 'No quote went out, so the job ended there.';
43
+ }
44
+ export function firstRunGuide(deps) {
45
+ const { rail } = deps;
46
+ let stage = 'first job';
47
+ /** The transaction that carried the report of the charge, once there is one. */
48
+ let reportedIn = null;
49
+ /** What the first job's events said, for the line that closes step 3. */
50
+ const job = { price: null, reserves: [], releases: [], payment: null };
51
+ /** The first job's last line: what was paid, that nothing was prepaid, and when reserves return. */
52
+ function firstJobLine(outcome) {
53
+ if (outcome?.kind !== 'paid' || job.price === null || job.releases.length === 0) {
54
+ return outcomeLine(outcome);
55
+ }
56
+ const latest = job.releases.reduce((a, b) => (b > a ? b : a));
57
+ const set = job.reserves.length === 2
58
+ ? `The ${formatUsd(job.reserves[0])} and ${formatUsd(job.reserves[1])} set aside`
59
+ : 'What each side set aside';
60
+ return `Delivered, and paid ${formatUsd(job.price)} on delivery with nothing prepaid. ${set} never moved, and go back on their own by ${deps.clock(latest)}.`;
61
+ }
62
+ /** The code that held the agent to its rules, and one change to try. */
63
+ function yourCode(code) {
64
+ rail.stage('Your code');
65
+ rail.quiet(`${code.file} decided what your agent could book and when work could start. Your agent can't read or change it.`);
66
+ rail.code(code.excerpt.lines);
67
+ if (code.excerpt.budget !== null && code.excerpt.budget > 2) {
68
+ rail.quiet(`Try it. Set computeBudgetPerGpuHour to 2, save, and type job. Every firm offer costs more than that, so your agent books nothing and says why.`);
69
+ }
70
+ }
71
+ function end() {
72
+ if (deps.code)
73
+ yourCode(deps.code);
74
+ rail.quiet("You're set up. Type job for another order, job cancels for one the customer cancels, or ask your agent why it chose that compute.");
75
+ rail.quiet("npm run bypass tries your agent's key against the chain without Avow's SDK, and npm run mcp:claude-code lets Claude drive your agent. Ctrl+C ends the session.");
76
+ if (deps.modelHelp)
77
+ rail.quiet(deps.modelHelp);
78
+ }
79
+ return {
80
+ start() {
81
+ rail.step(3, FIRST_RUN_STEPS, 'Two commitments, nothing prepaid', "Avow's test customer offers your agent a job, paid on delivery. Each side sets aside only what breaking its promise would cost, and checks the other's commitment before it moves.");
82
+ },
83
+ watch(event) {
84
+ if (event.type === 'job_charge_reported')
85
+ reportedIn = event.transactionHash;
86
+ if (stage !== 'first job')
87
+ return;
88
+ if (event.type === 'job_order_received')
89
+ job.price = event.price;
90
+ else if (event.type === 'job_compute_secured' || event.type === 'job_commitment_checked') {
91
+ // The customer's reserve is said first, so it goes ahead of the compute reserve.
92
+ if (event.type === 'job_commitment_checked')
93
+ job.reserves.unshift(event.amount);
94
+ else
95
+ job.reserves.push(event.amount);
96
+ job.releases.push(event.releaseDate);
97
+ }
98
+ else if (event.type === 'job_paid')
99
+ job.payment = event.payment.transactionHash;
100
+ },
101
+ afterJob(outcome) {
102
+ if (stage === 'first job') {
103
+ rail.stepDone(firstJobLine(outcome), { keep: true });
104
+ if (outcome?.kind === 'paid' && job.payment && deps.transactionUrl) {
105
+ rail.quiet('The payment, on chain for anyone to check:');
106
+ rail.settle();
107
+ deps.write(`${rail.prefix}${deps.transactionUrl(job.payment)}\n`);
108
+ }
109
+ rail.step(4, FIRST_RUN_STEPS, 'A broken promise', 'A promise counts when breaking it costs something. On the next order the customer cancels after your work starts, and its reserve backs a charge for that. Type job and press Enter.');
110
+ stage = 'asking to cancel';
111
+ }
112
+ else if (stage === 'cancelling') {
113
+ rail.stepDone(outcome?.kind === 'cancelled'
114
+ ? outcomeLine(outcome, deps.clock)
115
+ : `That order ended another way. ${outcomeLine(outcome, deps.clock)}`, { keep: true });
116
+ if (reportedIn && deps.transactionUrl) {
117
+ rail.quiet('The report of the charge, on chain for anyone to check:');
118
+ rail.settle();
119
+ deps.write(`${rail.prefix}${deps.transactionUrl(reportedIn)}\n`);
120
+ }
121
+ rail.step(5, FIRST_RUN_STEPS, 'Break the chain', "While that window runs, see what holds the two commitments together. The customer's commitment depends on yours. Take the next order without booking compute and see what the customer does. Type job and press Enter.");
122
+ stage = 'asking';
123
+ }
124
+ else if (stage === 'breaking') {
125
+ rail.stepDone(outcome?.kind === 'refused'
126
+ ? "The customer refused, and nobody's money moved. Its commitment depends on your compute commitment, and it found none to check. Its check verifies the money and the terms behind your promise. It doesn't promise the compute gets delivered."
127
+ : `That order ended another way. ${outcomeLine(outcome, deps.clock)}`, { keep: true });
128
+ end();
129
+ stage = 'done';
130
+ }
131
+ },
132
+ withoutCompute: () => stage === 'breaking',
133
+ scenario: () => (stage === 'cancelling' ? 'cancels_late' : null),
134
+ input: {
135
+ inFlight: (what) => deps.input.inFlight(what),
136
+ async next() {
137
+ const line = await deps.input.next();
138
+ if (line !== null && JOB_COMMAND.test(line.trim())) {
139
+ if (stage === 'asking to cancel')
140
+ stage = 'cancelling';
141
+ else if (stage === 'asking')
142
+ stage = 'breaking';
143
+ }
144
+ return line;
145
+ },
146
+ },
147
+ };
148
+ }
149
+ //# sourceMappingURL=first-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-run.js","sourceRoot":"","sources":["../../src/node/first-run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyC,MAAM,oBAAoB,CAAA;AAGrF,OAAO,EAAE,WAAW,EAAqB,MAAM,uBAAuB,CAAA;AAGtE,uFAAuF;AACvF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AA0BhC,MAAM,YAAY,GAAG;IACnB,SAAS,EAAE,2BAA2B;IACtC,QAAQ,EAAE,0CAA0C;IACpD,UAAU,EAAE,uCAAuC;CAC3C,CAAA;AAEV,sEAAsE;AACtE,SAAS,UAAU,CACjB,KAAiD,EACjD,KAAsC;IAEtC,MAAM,KAAK,GAAG,4CAA4C,CAAA;IAC1D,IAAI,SAAS,IAAI,KAAK,CAA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I,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;YAC7C,KAAK,CAAC,IAAI;gBACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;gBACpC,IAAI,IAAI,KAAK,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;oBACnD,IAAI,KAAK,KAAK,kBAAkB;wBAAE,KAAK,GAAG,YAAY,CAAA;yBACjD,IAAI,KAAK,KAAK,QAAQ;wBAAE,KAAK,GAAG,UAAU,CAAA;gBACjD,CAAC;gBACD,OAAO,IAAI,CAAA;YACb,CAAC;SACF;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type SandboxDeployment } from '@avow-finance/spec';
2
+ import type { Look, Rail } from '@avow-finance/terminal';
3
+ import { type SandboxPrompts } from '../sandbox/setup.js';
4
+ import { type SandboxStore } from '../sandbox/store.js';
5
+ import { type SessionInput } from '../session/session.js';
6
+ import type { JobWorld } from '../session/world.js';
7
+ /**
8
+ * The job chapter in the terminal: `npm start` runs the agent session once setup is done, and
9
+ * `npm run job` runs one job with no input. Both pick the model as `selectProvider` does, say which
10
+ * model and who pays before the first call, and run against the live sandbox.
11
+ */
12
+ export declare const SERVICE_FILE = "service.ts";
13
+ /** The session's flags, read from the command line and the environment. */
14
+ export interface JobFlags {
15
+ provider: string | null;
16
+ model: string | null;
17
+ scripted: boolean;
18
+ /** `--details`: every tool call, receipt, address and link, as the screen shows them. */
19
+ details: boolean;
20
+ }
21
+ /** Reads `--provider`, `--model`, `--scripted` and `--details`, refusing anything else. */
22
+ export declare function readJobFlags(args: readonly string[], env: Readonly<Record<string, string | undefined>>): JobFlags | {
23
+ error: string;
24
+ };
25
+ export declare function runJobSession(o: {
26
+ mode: 'interactive' | 'one';
27
+ flags: JobFlags;
28
+ rail: Rail;
29
+ look: Look;
30
+ store: SandboxStore;
31
+ deployment: SandboxDeployment;
32
+ dir: string;
33
+ session: {
34
+ id: string;
35
+ };
36
+ nextRun: () => number;
37
+ prompts: Pick<SandboxPrompts, 'passphrase' | 'confirm'>;
38
+ input: SessionInput | null;
39
+ /** The world to run in, the live sandbox unless a test hands it another. */
40
+ world?: JobWorld;
41
+ write?: (text: string) => void;
42
+ /** The service file and the folder it's in, `service.ts` in the working directory by default. */
43
+ service?: {
44
+ file: string;
45
+ cwd: string;
46
+ };
47
+ /** A first run, which goes on from setup's two steps as steps 3 to 5 of 5. */
48
+ firstRun?: boolean;
49
+ }): Promise<number>;
50
+ //# sourceMappingURL=job.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../src/node/job.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAKxD,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAClF,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGtE,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAMnD;;;;GAIG;AAEH,eAAO,MAAM,YAAY,eAAe,CAAA;AAExC,2EAA2E;AAC3E,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;IACjB,yFAAyF;IACzF,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAChD,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CA0B9B;AAED,wBAAsB,aAAa,CAAC,CAAC,EAAE;IACrC,IAAI,EAAE,aAAa,GAAG,KAAK,CAAA;IAC3B,KAAK,EAAE,QAAQ,CAAA;IACf,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,YAAY,CAAA;IACnB,UAAU,EAAE,iBAAiB,CAAA;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;IACvB,OAAO,EAAE,MAAM,MAAM,CAAA;IACrB,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,GAAG,SAAS,CAAC,CAAA;IACvD,KAAK,EAAE,YAAY,GAAG,IAAI,CAAA;IAC1B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,iGAAiG;IACjG,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACvC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoHlB"}
@@ -0,0 +1,176 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { resolve } from 'node:path';
3
+ import { formatUsd, } from '@avow-finance/spec';
4
+ import { Account } from 'viem/tempo';
5
+ import { agentRequestKey } from '../http.js';
6
+ import { moderatoTransactionUrl } from '../moderato.js';
7
+ import { sessionReporter } from '../sandbox/agent.js';
8
+ import { cancelSandboxCommitment } from '../sandbox/setup.js';
9
+ import { loadAgentItem } from '../sandbox/store.js';
10
+ import { liveWorld } from '../session/live-world.js';
11
+ import { selectProvider } from '../session/selection.js';
12
+ import { runSession } from '../session/session.js';
13
+ import { firstRunGuide, outcomeLine } from './first-run.js';
14
+ import { serviceExcerpt } from './service-excerpt.js';
15
+ import { readServicePolicy, runCheckBeforeWork } from './service-process.js';
16
+ import { localClock, railView } from './session-view.js';
17
+ /**
18
+ * The job chapter in the terminal: `npm start` runs the agent session once setup is done, and
19
+ * `npm run job` runs one job with no input. Both pick the model as `selectProvider` does, say which
20
+ * model and who pays before the first call, and run against the live sandbox.
21
+ */
22
+ export const SERVICE_FILE = 'service.ts';
23
+ /** Reads `--provider`, `--model`, `--scripted` and `--details`, refusing anything else. */
24
+ export function readJobFlags(args, env) {
25
+ const flags = {
26
+ provider: env.AVOW_MODEL_PROVIDER?.trim() || null,
27
+ model: env.AVOW_MODEL?.trim() || null,
28
+ scripted: false,
29
+ details: false,
30
+ };
31
+ for (let i = 0; i < args.length; i++) {
32
+ const arg = args[i];
33
+ const [name, inline] = arg.split('=', 2);
34
+ const value = () => {
35
+ const v = inline ?? args[++i];
36
+ if (!v || v.startsWith('--'))
37
+ throw new Error(`${name} needs a value`);
38
+ return v;
39
+ };
40
+ try {
41
+ if (name === '--scripted')
42
+ flags.scripted = true;
43
+ else if (name === '--details')
44
+ flags.details = true;
45
+ else if (name === '--provider')
46
+ flags.provider = value();
47
+ else if (name === '--model')
48
+ flags.model = value();
49
+ else
50
+ return { error: `There's no option ${arg} here.` };
51
+ }
52
+ catch (error) {
53
+ return { error: error.message };
54
+ }
55
+ }
56
+ return flags;
57
+ }
58
+ export async function runJobSession(o) {
59
+ const { rail, store, deployment } = o;
60
+ const write = o.write ?? ((text) => void process.stdout.write(text));
61
+ const service = o.service ?? { file: SERVICE_FILE, cwd: process.cwd() };
62
+ const chosen = await selectProvider({ ...o.flags, env: process.env });
63
+ if (!chosen.ok) {
64
+ rail.fail(chosen.why);
65
+ for (const line of chosen.help)
66
+ rail.quiet(line);
67
+ return 1;
68
+ }
69
+ let world;
70
+ try {
71
+ world =
72
+ o.world ??
73
+ (await liveWorld({
74
+ store,
75
+ deployment,
76
+ cancelFree: async (booking, onLock) => {
77
+ // The developer sees what's being cancelled before the passphrase is asked for.
78
+ const left = Number((onLock.freeCancelBy - onLock.block.timestamp) / 60n);
79
+ const sure = await o.prompts.confirm(`Your agent asks to cancel booking ${booking.id}. Cancel it?`, [
80
+ `${booking.gpus} ${booking.offer.gpu} of ${booking.offer.id} from ${booking.offer.supplier}, with ${formatUsd(booking.reserve)} reserved.`,
81
+ `Free cancellation is still open, for about ${Math.max(left, 0)} more minutes, so cancelling gives the whole reserve back.`,
82
+ "Only your business's key can cancel on the lock, so it asks for your passphrase next.",
83
+ ]);
84
+ if (!sure)
85
+ return null;
86
+ return cancelSandboxCommitment({
87
+ commitmentId: booking.reference.commitmentId,
88
+ prompts: o.prompts,
89
+ store,
90
+ deployment,
91
+ });
92
+ },
93
+ }));
94
+ }
95
+ catch (error) {
96
+ rail.fail(error instanceof Error ? error.message : String(error));
97
+ return 1;
98
+ }
99
+ // The session's events go to the screen signed by the agent's key, as its runs' events do.
100
+ const agent = await loadAgentItem(store);
101
+ const post = agent
102
+ ? sessionReporter({
103
+ session: { id: o.session.id, run: 1 },
104
+ key: agentRequestKey(Account.fromSecp256k1(agent.agentKey, { access: agent.business.account })),
105
+ domain: {
106
+ chainId: deployment.chainId,
107
+ verifyingContract: agent.business.lock,
108
+ },
109
+ apiUrl: deployment.apiUrl,
110
+ fetch: (input, init) => fetch(input, init),
111
+ log: (line) => rail.quiet(line),
112
+ })
113
+ : () => { };
114
+ const brief = !o.flags.details;
115
+ const view = railView(rail, o.look, { fixture: world.kind === 'fixture', write, brief });
116
+ // A first run goes on from setup's two steps, with a guide for steps 3 to 5, and ends on the
117
+ // service file's deciding lines.
118
+ const guided = o.firstRun === true && o.mode === 'interactive' && o.input !== null;
119
+ const excerpt = guided
120
+ ? await readFile(resolve(service.cwd, service.file), 'utf8').then(serviceExcerpt, () => null)
121
+ : null;
122
+ const guide = guided && o.input !== null
123
+ ? firstRunGuide({
124
+ rail,
125
+ input: o.input,
126
+ clock: localClock,
127
+ write,
128
+ transactionUrl: world.kind === 'live' ? moderatoTransactionUrl : null,
129
+ modelHelp: chosen.fallback ? (chosen.fallback.help[0] ?? null) : null,
130
+ code: excerpt ? { file: service.file, excerpt } : null,
131
+ })
132
+ : null;
133
+ const emit = (event) => {
134
+ view.event(event);
135
+ if (world.kind === 'live')
136
+ post(event);
137
+ guide?.watch(event);
138
+ };
139
+ if (guide)
140
+ guide.start();
141
+ else if (o.mode === 'one')
142
+ rail.stage('One job, with no input');
143
+ // A guided run's Model line names the scripted decisions, and how to get a model comes at the end.
144
+ if (chosen.fallback && !guide) {
145
+ rail.quiet(chosen.fallback.why);
146
+ for (const line of chosen.fallback.help)
147
+ rail.quiet(line);
148
+ }
149
+ const result = await runSession({
150
+ world,
151
+ provider: chosen.provider,
152
+ readPolicy: () => readServicePolicy(service.file, service.cwd),
153
+ checkBeforeWork: async (job) => runCheckBeforeWork(service.file, job, await world.chainFor(job), service.cwd),
154
+ emit,
155
+ view,
156
+ input: guide ? guide.input : o.mode === 'one' ? null : o.input,
157
+ nextRun: o.nextRun,
158
+ brief,
159
+ ...(guide
160
+ ? {
161
+ afterJob: (outcome) => guide.afterJob(outcome),
162
+ withoutCompute: guide.withoutCompute,
163
+ scenario: guide.scenario,
164
+ }
165
+ : {}),
166
+ });
167
+ if (result.stopped)
168
+ return 1;
169
+ const ended = result.firstJob;
170
+ if (o.mode === 'one') {
171
+ rail.close(outcomeLine(ended, localClock));
172
+ return ended?.kind === 'paid' ? 0 : 1;
173
+ }
174
+ return 0;
175
+ }
176
+ //# sourceMappingURL=job.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.js","sourceRoot":"","sources":["../../src/node/job.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAEL,SAAS,GAGV,MAAM,oB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L,GAAG,CAAC,KAAK;YACP,CAAC,CAAC;gBACE,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAC9C,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;aACzB;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAA;IACF,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,CAAC,CAAA;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAA;IAC7B,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAA;QAC1C,OAAO,KAAK,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** What `avow-sandbox order` takes, read from its arguments, or why it can't run. */
2
+ export declare function readOrderArgs(args: readonly string[]): {
3
+ supplier: string;
4
+ expiresIn: bigint;
5
+ } | {
6
+ error: string;
7
+ };
8
+ /**
9
+ * `avow-sandbox order --supplier <id>`. Orders the demo job from another business and sees it
10
+ * through: waits for the quote, checks it, funds the commitment and waits for the acceptance. An
11
+ * order to that business this agent sent and didn't see through is picked up instead.
12
+ */
13
+ export declare function orderCommand(args: readonly string[]): Promise<void>;
14
+ /**
15
+ * `avow-sandbox listen`. Reads this business's inbox every few seconds and takes each order's next
16
+ * step, until stopped. Orders that arrive while it isn't running wait in the inbox until they lapse.
17
+ */
18
+ export declare function listenCommand(): Promise<void>;
19
+ //# sourceMappingURL=mailbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mailbox.d.ts","sourceRoot":"","sources":["../../src/node/mailbox.ts"],"names":[],"mappings":"AAIA,qFAAqF;AACrF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAc7D;AAKD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BzE;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAWnD"}
@@ -0,0 +1,81 @@
1
+ import { mailboxStatusAt } from '@avow-finance/spec';
2
+ import { MAILBOX_ORDER_SECONDS, sandboxMailbox } from '../sandbox/mailbox.js';
3
+ import { fileStore } from './platform.js';
4
+ /** What `avow-sandbox order` takes, read from its arguments, or why it can't run. */
5
+ export function readOrderArgs(args) {
6
+ let supplier = null;
7
+ let expiresIn = MAILBOX_ORDER_SECONDS;
8
+ for (let i = 0; i < args.length; i += 2) {
9
+ const flag = args[i];
10
+ const value = args[i + 1];
11
+ if (value === undefined || value.startsWith('--'))
12
+ return { error: `${flag} needs a value` };
13
+ if (flag === '--supplier')
14
+ supplier = value;
15
+ else if (flag === '--expires-in' && /^[1-9][0-9]{0,4}$/.test(value))
16
+ expiresIn = BigInt(value);
17
+ else if (flag === '--expires-in')
18
+ return { error: '--expires-in takes whole seconds' };
19
+ else
20
+ return { error: `order doesn't take ${flag}` };
21
+ }
22
+ if (!supplier)
23
+ return { error: 'order needs --supplier, the business ID of the agent that sells' };
24
+ return { supplier, expiresIn };
25
+ }
26
+ const describe = (order) => `${order.orderId} for ${order.supplierBusinessId}, ${mailboxStatusAt(order, BigInt(Math.floor(Date.now() / 1000)))}`;
27
+ /**
28
+ * `avow-sandbox order --supplier <id>`. Orders the demo job from another business and sees it
29
+ * through: waits for the quote, checks it, funds the commitment and waits for the acceptance. An
30
+ * order to that business this agent sent and didn't see through is picked up instead.
31
+ */
32
+ export async function orderCommand(args) {
33
+ const read = readOrderArgs(args);
34
+ if ('error' in read) {
35
+ console.error(read.error);
36
+ process.exit(1);
37
+ }
38
+ const stop = new AbortController();
39
+ process.once('SIGINT', () => stop.abort(new Error('Stopped waiting')));
40
+ const mailbox = await sandboxMailbox({ store: fileStore() });
41
+ // An order this agent sent before it stopped is seen through first, so none is sent twice.
42
+ const left = (await mailbox.unfinished()).find((r) => r.supplierBusinessId === read.supplier);
43
+ if (left)
44
+ console.log(`Picking up order ${left.orderId}, sent before this agent stopped.`);
45
+ const outcome = await mailbox.buy({
46
+ supplier: read.supplier,
47
+ ...(left ? { resume: left.orderId } : {}),
48
+ expiresIn: read.expiresIn,
49
+ signal: stop.signal,
50
+ onStep: (step) => {
51
+ if (step.step === 'ordered')
52
+ console.log(`Ordered ${describe(step.order)}. Nothing is reserved.`);
53
+ else if (step.step === 'quoted')
54
+ console.log('Quoted. Checking the terms and the booking they rely on.');
55
+ else if (step.step === 'reserved')
56
+ console.log('Funded. Waiting for the supplier to accept.');
57
+ else
58
+ console.log('Accepted.');
59
+ },
60
+ });
61
+ if (!outcome.ok) {
62
+ console.error(`Stopped at ${describe(outcome.order)}: ${outcome.reason}`);
63
+ process.exit(1);
64
+ }
65
+ }
66
+ /**
67
+ * `avow-sandbox listen`. Reads this business's inbox every few seconds and takes each order's next
68
+ * step, until stopped. Orders that arrive while it isn't running wait in the inbox until they lapse.
69
+ */
70
+ export async function listenCommand() {
71
+ const stop = new AbortController();
72
+ process.once('SIGINT', () => stop.abort());
73
+ const mailbox = await sandboxMailbox({ store: fileStore() });
74
+ console.log(`Listening for orders to ${mailbox.businessId}. Stop with Ctrl+C.`);
75
+ await mailbox.listen({
76
+ signal: stop.signal,
77
+ onStep: (order, step) => console.log(`${order.orderId}: ${step.step}`),
78
+ onError: (order, error) => console.error(`${order.orderId}: ${error instanceof Error ? error.message : String(error)}`),
79
+ });
80
+ }
81
+ //# sourceMappingURL=mailbox.js.map
@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CAAC,MAAM;QACnB,MAAM,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;QACtE,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACxB,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;KAC/F,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ import { SANDBOX_TOOLS } from '@avow-finance/spec';
3
+ /** The tools, kept to what shows the authority model and nothing more. */
4
+ export declare const MCP_TOOLS: readonly [{
5
+ readonly name: 'authority';
6
+ readonly description: "What your agent can commit right now. It has two limits. It holds at most so much in bookings at once, which Avow refuses past and the lock checks against Avow's approval. Its key moves at most so much a day, a limit the business set on chain. It names the suppliers the agent may book too.";
7
+ readonly inputSchema: {
8
+ readonly type: 'object';
9
+ readonly properties: {};
10
+ readonly additionalProperties: false;
11
+ };
12
+ }, {
13
+ readonly name: 'book';
14
+ readonly description: "Books GPU capacity with one of your agent's suppliers, backed by a reserve in your business's own lock. Avow checks the booking against the mandate and what the lock holds before any money moves, the agent's machine runs the open verifier, and the supplier accepts on the lock. A refusal comes back with its reason code, the layer that refused it, the amounts and when the same booking could pass. A reserve that never landed with no reason given comes back as a failure. Held reserves come back as bookings end or are cancelled, the key's daily limit starts again each day, Avow's relay can be limiting how much it takes for now, and anything else in the mandate changes only when the business signs a new one.";
15
+ readonly inputSchema: {
16
+ readonly type: 'object';
17
+ readonly properties: {
18
+ readonly reserve: {
19
+ readonly type: 'number';
20
+ readonly description: 'The reserve in dollars, such as 200';
21
+ };
22
+ readonly gpu: {
23
+ readonly type: 'string';
24
+ readonly description: 'The GPU model, H100 when left out';
25
+ };
26
+ readonly count: {
27
+ readonly type: 'integer';
28
+ readonly description: 'How many GPUs, 8 when left out';
29
+ };
30
+ readonly hours: {
31
+ readonly type: 'number';
32
+ readonly description: 'How many hours, 1 when left out';
33
+ };
34
+ readonly supplier: {
35
+ readonly type: 'string';
36
+ readonly description: "The supplier's business id, the agent's first supplier when left out";
37
+ };
38
+ };
39
+ readonly required: readonly ["reserve"];
40
+ readonly additionalProperties: false;
41
+ };
42
+ }, {
43
+ readonly name: 'commitments';
44
+ readonly description: 'Lists every commitment your agent made, with its state on the lock, whether the current authority made it, and a link anyone can open to check it.';
45
+ readonly inputSchema: {
46
+ readonly type: 'object';
47
+ readonly properties: {};
48
+ readonly additionalProperties: false;
49
+ };
50
+ }];
51
+ export interface ToolAnswer {
52
+ text: string;
53
+ structured: Record<string, unknown>;
54
+ isError: boolean;
55
+ }
56
+ /** The MCP agent for one folder, answering each tool call through the SDK's agent. */
57
+ export declare function mcpAgent(dir: string, options?: {
58
+ fetch?: typeof fetch;
59
+ }): {
60
+ call(name: string, args: Record<string, unknown>): Promise<ToolAnswer>;
61
+ };
62
+ /** Serves MCP over stdio, a JSON-RPC message per line, for the agent in `dir`. */
63
+ export declare function serve(dir: string, io?: {
64
+ input: NodeJS.ReadStream & {
65
+ fd: 0;
66
+ };
67
+ output: NodeJS.WriteStream & {
68
+ fd: 1;
69
+ };
70
+ }): void;
71
+ /** Where Claude Desktop keeps its MCP servers on this platform. */
72
+ export declare function claudeDesktopConfig(): string;
73
+ export { SANDBOX_TOOLS };
74
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/node/mcp.ts"],"names":[],"mappings":";AAcA,OAAO,EAGL,aAAa,EAId,MAAM,oBAAoB,CAAA;AA0B3B,0EAA0E;AAC1E,eAAO,MAAM,SAAS;mBAEZ,WAAW;0BAEf,oSAAoS;;uBAPlR,QAAQ;;;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