@lucid-agents/taskmarket 1.16.0 → 1.17.1

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 (128) hide show
  1. package/THIRD_PARTY_NOTICES.md +14 -0
  2. package/dist/THIRD_PARTY_NOTICES.md +3108 -0
  3. package/dist/agent-compatibility.json +54 -0
  4. package/dist/budget-view-XKZC3GY5.js +36 -0
  5. package/dist/channels-Q7XMSUSO.js +29 -0
  6. package/dist/chunk-3S63AB3C.js +16068 -0
  7. package/dist/chunk-73RXOYME.js +185 -0
  8. package/dist/chunk-EIHZYRIU.js +1099 -0
  9. package/dist/chunk-F5SS4NUF.js +1062 -0
  10. package/dist/chunk-JAZ5BWPB.js +181 -0
  11. package/dist/chunk-MI2GPMCZ.js +154 -0
  12. package/dist/chunk-OKZ2NRYZ.js +133 -0
  13. package/dist/chunk-S7SJMJ2I.js +38 -0
  14. package/dist/chunk-YM4S6IE4.js +15 -0
  15. package/dist/compatibility-KUYGZSUC.js +19 -0
  16. package/dist/doctor-BY2PBHS7.js +216 -0
  17. package/dist/errors-2L357HGA.js +8 -0
  18. package/dist/index.js +1186 -13492
  19. package/dist/launch-DE65XO5C.js +22476 -0
  20. package/dist/pi/CHANGELOG.md +5689 -0
  21. package/dist/pi/README.md +718 -0
  22. package/dist/pi/dist/bundle/chunks/anthropic-messages-VWZZOSJQ.js +6 -0
  23. package/dist/pi/dist/bundle/chunks/anthropic.js +75 -0
  24. package/dist/pi/dist/bundle/chunks/azure-openai-responses-BJLAM6CD.js +2 -0
  25. package/dist/pi/dist/bundle/chunks/bedrock-converse-stream.js +74 -0
  26. package/dist/pi/dist/bundle/chunks/chunk-4L3WN2XY.js +2 -0
  27. package/dist/pi/dist/bundle/chunks/chunk-6CYCI3EJ.js +12 -0
  28. package/dist/pi/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
  29. package/dist/pi/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  30. package/dist/pi/dist/bundle/chunks/chunk-AXIIZGTV.js +2 -0
  31. package/dist/pi/dist/bundle/chunks/chunk-CLNPYIDP.js +42 -0
  32. package/dist/pi/dist/bundle/chunks/chunk-DRQDKNXA.js +2 -0
  33. package/dist/pi/dist/bundle/chunks/chunk-GMWCTUPB.js +2 -0
  34. package/dist/pi/dist/bundle/chunks/chunk-IDDQWTHI.js +2 -0
  35. package/dist/pi/dist/bundle/chunks/chunk-JVUZSMYM.js +1547 -0
  36. package/dist/pi/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  37. package/dist/pi/dist/bundle/chunks/chunk-NUHFSC37.js +25 -0
  38. package/dist/pi/dist/bundle/chunks/chunk-OUXLLA64.js +11 -0
  39. package/dist/pi/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  40. package/dist/pi/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  41. package/dist/pi/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  42. package/dist/pi/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
  43. package/dist/pi/dist/bundle/chunks/chunk-TRDNDS6A.js +4 -0
  44. package/dist/pi/dist/bundle/chunks/chunk-U6ZMQKGD.js +50 -0
  45. package/dist/pi/dist/bundle/chunks/chunk-UAQELI3K.js +2 -0
  46. package/dist/pi/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
  47. package/dist/pi/dist/bundle/chunks/chunk-XDUWOHPL.js +6 -0
  48. package/dist/pi/dist/bundle/chunks/chunk-XNGRGP62.js +2 -0
  49. package/dist/pi/dist/bundle/chunks/github-copilot.js +2 -0
  50. package/dist/pi/dist/bundle/chunks/google-generative-ai-Q2K7FBDI.js +2 -0
  51. package/dist/pi/dist/bundle/chunks/google-vertex-7UJBF4S7.js +2 -0
  52. package/dist/pi/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +13 -0
  53. package/dist/pi/dist/bundle/chunks/image-resize-worker.js +2 -0
  54. package/dist/pi/dist/bundle/chunks/kimi-coding.js +2 -0
  55. package/dist/pi/dist/bundle/chunks/lib-HGQMNYVT.js +9 -0
  56. package/dist/pi/dist/bundle/chunks/mistral-conversations-4M6BZBX6.js +5 -0
  57. package/dist/pi/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +3 -0
  58. package/dist/pi/dist/bundle/chunks/node-KG362ECQ.js +16 -0
  59. package/dist/pi/dist/bundle/chunks/node-TWVVAGPO.js +2 -0
  60. package/dist/pi/dist/bundle/chunks/openai-codex-responses-R6VYZTVY.js +10 -0
  61. package/dist/pi/dist/bundle/chunks/openai-codex.js +75 -0
  62. package/dist/pi/dist/bundle/chunks/openai-completions-EKZT2IH2.js +7 -0
  63. package/dist/pi/dist/bundle/chunks/openai-responses-TFDINO6W.js +2 -0
  64. package/dist/pi/dist/bundle/chunks/openrouter-images-N4XVVFSD.js +2 -0
  65. package/dist/pi/dist/bundle/chunks/openrouter.js +75 -0
  66. package/dist/pi/dist/bundle/chunks/pi-messages-PML4SPVJ.js +8 -0
  67. package/dist/pi/dist/bundle/chunks/radius.js +75 -0
  68. package/dist/pi/dist/bundle/chunks/src-UK77SYZE.js +4 -0
  69. package/dist/pi/dist/bundle/chunks/xai.js +2 -0
  70. package/dist/pi/dist/bundle/cli.js +3 -0
  71. package/dist/pi/dist/bundle/index.js +2 -0
  72. package/dist/pi/dist/bundle/rpc-entry.js +3 -0
  73. package/dist/pi/dist/core/export-html/template.css +1066 -0
  74. package/dist/pi/dist/core/export-html/template.html +55 -0
  75. package/dist/pi/dist/core/export-html/template.js +1864 -0
  76. package/dist/pi/dist/core/export-html/vendor/highlight.min.js +1213 -0
  77. package/dist/pi/dist/core/export-html/vendor/marked.min.js +78 -0
  78. package/dist/pi/dist/modes/interactive/assets/clankolas.png +0 -0
  79. package/dist/pi/dist/modes/interactive/theme/dark.json +91 -0
  80. package/dist/pi/dist/modes/interactive/theme/light.json +90 -0
  81. package/dist/pi/dist/modes/interactive/theme/theme-schema.json +356 -0
  82. package/dist/pi/docs/compaction.md +418 -0
  83. package/dist/pi/docs/containerization.md +156 -0
  84. package/dist/pi/docs/custom-provider.md +777 -0
  85. package/dist/pi/docs/development.md +90 -0
  86. package/dist/pi/docs/environment-variables.md +99 -0
  87. package/dist/pi/docs/extensions.md +3023 -0
  88. package/dist/pi/docs/index.md +84 -0
  89. package/dist/pi/docs/json.md +98 -0
  90. package/dist/pi/docs/keybindings.md +239 -0
  91. package/dist/pi/docs/llama-cpp.md +101 -0
  92. package/dist/pi/docs/models.md +574 -0
  93. package/dist/pi/docs/packages.md +228 -0
  94. package/dist/pi/docs/prompt-templates.md +96 -0
  95. package/dist/pi/docs/providers.md +317 -0
  96. package/dist/pi/docs/quickstart.md +167 -0
  97. package/dist/pi/docs/rpc.md +1618 -0
  98. package/dist/pi/docs/sdk.md +1224 -0
  99. package/dist/pi/docs/security.md +59 -0
  100. package/dist/pi/docs/session-format.md +438 -0
  101. package/dist/pi/docs/sessions.md +145 -0
  102. package/dist/pi/docs/settings.md +369 -0
  103. package/dist/pi/docs/shell-aliases.md +13 -0
  104. package/dist/pi/docs/skills.md +232 -0
  105. package/dist/pi/docs/terminal-setup.md +192 -0
  106. package/dist/pi/docs/termux.md +127 -0
  107. package/dist/pi/docs/themes.md +322 -0
  108. package/dist/pi/docs/tmux.md +63 -0
  109. package/dist/pi/docs/tui.md +961 -0
  110. package/dist/pi/docs/usage.md +311 -0
  111. package/dist/pi/docs/windows.md +39 -0
  112. package/dist/pi/package.json +15 -0
  113. package/dist/pi/vendor/chord-context.js +96 -0
  114. package/dist/pi/vendor/jiti/LICENSE +21 -0
  115. package/dist/pi/vendor/jiti/dist/babel.cjs +257 -0
  116. package/dist/pi/vendor/jiti/dist/jiti.cjs +1 -0
  117. package/dist/pi/vendor/jiti/lib/jiti.cjs +30 -0
  118. package/dist/pi/vendor/jiti/package.json +6 -0
  119. package/dist/pi/vendor/photon-node/LICENSE.md +201 -0
  120. package/dist/pi/vendor/photon-node/package.json +6 -0
  121. package/dist/pi/vendor/photon-node/photon_rs.js +4521 -0
  122. package/dist/pi/vendor/photon-node/photon_rs_bg.wasm +0 -0
  123. package/dist/pi-extensions/lockdown.cjs +433 -0
  124. package/dist/pi-extensions/remote-tools.cjs +22320 -0
  125. package/dist/pi-extensions/xgate.cjs +2565 -0
  126. package/dist/reconcile-VEMPNIAO.js +83 -0
  127. package/dist/status-3Q55PBFC.js +18 -0
  128. package/package.json +13 -2
@@ -0,0 +1,185 @@
1
+ import { createRequire as __tmCreateRequire } from 'node:module'; import { fileURLToPath as __tmFileURLToPath } from 'node:url'; import { dirname as __tmDirname } from 'node:path'; const require = __tmCreateRequire(import.meta.url); const __tmFilename = __tmFileURLToPath(import.meta.url); const __tmDirnameValue = __tmDirname(__tmFilename);
2
+
3
+ // src/lib/agent/budget-view.ts
4
+ var AGENT_VIEW_VERSION = 1;
5
+ var USDC_DECIMALS = 6;
6
+ function formatUsdc(atomic) {
7
+ let value;
8
+ try {
9
+ value = typeof atomic === "bigint" ? atomic : BigInt(atomic);
10
+ } catch {
11
+ return "$?";
12
+ }
13
+ const negative = value < 0n;
14
+ const abs = negative ? -value : value;
15
+ const scale = 10n ** BigInt(USDC_DECIMALS);
16
+ const fraction = (abs % scale).toString().padStart(USDC_DECIMALS, "0").replace(/0+$/, "");
17
+ return `${negative ? "-" : ""}$${abs / scale}.${fraction.padEnd(2, "0")}`;
18
+ }
19
+ function formatCredits(value) {
20
+ const number = Number(value);
21
+ if (!Number.isFinite(number)) return value;
22
+ return number >= 100 ? number.toFixed(0) : number.toFixed(1);
23
+ }
24
+ function usdcToAtomic(value) {
25
+ const match = /^(\d{1,12})(?:\.(\d{1,6}))?$/.exec(value.trim().replace(/^\$/, ""));
26
+ if (!match) return void 0;
27
+ return (BigInt(match[1]) * 10n ** BigInt(USDC_DECIMALS) + BigInt((match[2] ?? "").padEnd(USDC_DECIMALS, "0"))).toString();
28
+ }
29
+ function burnRate(debits) {
30
+ let seconds = 0;
31
+ let credits = 0;
32
+ for (const debit of debits) {
33
+ if (!(debit.seconds > 0)) continue;
34
+ seconds += debit.seconds;
35
+ credits += Number(debit.credits);
36
+ if (seconds >= 3600) break;
37
+ }
38
+ if (seconds === 0 || !Number.isFinite(credits)) return null;
39
+ return (credits * 3600 / seconds).toFixed(4);
40
+ }
41
+ function computeLow(input) {
42
+ if (input.warning === "low_credit" || input.warning === "credit_exhausted") return true;
43
+ if (input.availableCredits === null) return false;
44
+ const available = Number(input.availableCredits);
45
+ if (input.thresholdCredits !== void 0 && available < Number(input.thresholdCredits)) {
46
+ return true;
47
+ }
48
+ return input.burnCreditsPerHour !== null && available < Number(input.burnCreditsPerHour);
49
+ }
50
+ function remainingBudget(view) {
51
+ const channels = view.channels.filter((channel) => channel.state === "open" && !channel.retired).reduce(
52
+ (sum, channel) => sum + BigInt(channel.amounts.refundable) + BigInt(channel.amounts.lifetimeRoom),
53
+ 0n
54
+ );
55
+ if (!view.budget) return channels;
56
+ const left = BigInt(view.budget.cap) - BigInt(view.budget.used);
57
+ const budget = left > 0n ? left : 0n;
58
+ return channels < budget ? channels : budget;
59
+ }
60
+ function blockingPurchases(view) {
61
+ const ids = new Set(view.unresolved);
62
+ for (const channel of view.channels) {
63
+ if (channel.pendingOperation?.kind === "payment") ids.add(channel.pendingOperation.id);
64
+ }
65
+ return [...ids];
66
+ }
67
+ function statusBarText(view) {
68
+ const parts = [];
69
+ parts.push(view.lastTurn ? `turn ${formatUsdc(view.lastTurn.chargedAtomic)}` : "turn -");
70
+ const active = view.channels.filter((channel) => !channel.retired);
71
+ if (active.length > 0) {
72
+ const open = active.some((channel) => channel.state === "open");
73
+ parts.push(
74
+ open ? `budget ${formatUsdc(remainingBudget(view))} left` : `channel ${active[0].state.replace("_", " ")}`
75
+ );
76
+ }
77
+ const compute = view.compute;
78
+ if (compute?.configured && compute.availableCredits !== null) {
79
+ const burn = compute.burnCreditsPerHour !== null ? ` at ${formatCredits(compute.burnCreditsPerHour)}/h` : "";
80
+ parts.push(
81
+ `compute ${formatCredits(compute.availableCredits)} cr${burn}${compute.low ? " LOW: /credits" : ""}`
82
+ );
83
+ } else if (compute && !compute.configured) {
84
+ parts.push("compute: not set up");
85
+ }
86
+ const blocking = blockingPurchases(view);
87
+ if (blocking.length > 0) {
88
+ const id = blocking[0].length > 12 ? `${blocking[0].slice(0, 12)}...` : blocking[0];
89
+ parts.push(`purchase ${id} unresolved: new turns blocked, see /budget`);
90
+ }
91
+ return parts.join(" | ");
92
+ }
93
+ function channelLines(channel) {
94
+ const a = channel.amounts;
95
+ return [
96
+ `Channel ${channel.rail}${channel.retired ? " (retired)" : ""} ${channel.channelId} (${channel.network}, ${channel.route}): ${channel.state.replace("_", " ")}`,
97
+ ` Locked ${formatUsdc(a.locked)} (deposited, not spent); charged ${formatUsdc(a.charged)}; pending vouchers ${formatUsdc(a.pending)}; refunded ${formatUsdc(a.refunded)}`,
98
+ ` Refundable ${formatUsdc(a.refundable)}: what further turns can use and a close returns`,
99
+ ` Budget ${formatUsdc(a.budget)}; ${formatUsdc(a.lifetimeRoom)} may still be deposited; next deposit ${formatUsdc(a.depositTarget)}${Number(a.depositing) > 0 ? `; ${formatUsdc(a.depositing)} being deposited` : ""}`,
100
+ ...channel.pendingOperation ? [
101
+ channel.pendingOperation.kind === "payment" ? ` Purchase ${channel.pendingOperation.id} is unresolved and blocks new turns: taskmarket agent reconcile ${channel.pendingOperation.id}` : ` A refund or withdrawal (${channel.pendingOperation.id}) is unresolved: taskmarket agent close checks it again`
102
+ ] : [],
103
+ ...channel.blockingDivergences.length > 0 ? [
104
+ ` Blocked: the journal, the router and the chain disagree (${channel.blockingDivergences.join(", ")})`
105
+ ] : []
106
+ ];
107
+ }
108
+ function budgetLines(view) {
109
+ const lines = [
110
+ `This session: ${view.session.turns} paid turn${view.session.turns === 1 ? "" : "s"}, ${formatUsdc(view.session.chargedAtomic)}${view.lastTurn ? `; last turn ${formatUsdc(view.lastTurn.chargedAtomic)}` : ""}`
111
+ ];
112
+ for (const channel of view.channels) lines.push(...channelLines(channel));
113
+ for (const allocation of view.allocations) {
114
+ lines.push(
115
+ `Allocation ${allocation.allocationId} (${allocation.exposure})${allocation.closed ? ", closed" : ""}: used ${formatUsdc(allocation.used.total)} of ${formatUsdc(allocation.caps.amount)}${allocation.caps.perDay ? `; today ${formatUsdc(allocation.used.today)} of ${formatUsdc(allocation.caps.perDay)}` : ""}`
116
+ );
117
+ }
118
+ for (const id of blockingPurchases(view)) {
119
+ lines.push(uncertainPurchaseMessage(id));
120
+ }
121
+ const compute = view.compute;
122
+ if (compute) lines.push(...computeLines(compute));
123
+ return lines;
124
+ }
125
+ function computeLines(compute) {
126
+ if (!compute.configured) {
127
+ return ["Compute credit: not set up; run taskmarket agent credits setup"];
128
+ }
129
+ if (compute.error !== void 0 || compute.availableCredits === null) {
130
+ return [`Compute credit: unavailable (${compute.error ?? "not read"})`];
131
+ }
132
+ return [
133
+ `Compute credit: ${formatCredits(compute.availableCredits)} available${compute.burnCreditsPerHour !== null ? `, burning ${formatCredits(compute.burnCreditsPerHour)} an hour while the sandbox runs` : ""}${compute.low ? ". Low: buy more with /credits" : ""}`,
134
+ ...compute.pendingPurchases > 0 ? [
135
+ ` ${compute.pendingPurchases} purchase(s) not settled yet: taskmarket agent credits reconcile`
136
+ ] : [],
137
+ ...compute.autoTopUp ? [
138
+ ` Auto-top-up: $${compute.autoTopUp.amountUsd} below ${compute.autoTopUp.thresholdCredits} credits, at most ${compute.autoTopUp.maxChunksPerDay} a day`
139
+ ] : []
140
+ ];
141
+ }
142
+ var LOST_RESPONSE_TEXT = "It was charged, and the response cannot be recovered or regenerated: xgate delivers it live only and keeps no copy. Asking again is a new paid turn.";
143
+ function uncertainPurchaseMessage(invocationId) {
144
+ return `The outcome of purchase ${invocationId} is unknown. It is never sent again, and new turns on its channel are blocked until it is reconciled: taskmarket agent reconcile ${invocationId}. If it was charged, its response cannot be recovered or regenerated.`;
145
+ }
146
+ var CHARGED_UNDELIVERED = /* @__PURE__ */ new Set([
147
+ "result_too_large",
148
+ "response_rejected",
149
+ "invalid_response",
150
+ "response_hook_failed"
151
+ ]);
152
+ function purchaseFailureNotice(failure) {
153
+ if (failure.pending) {
154
+ return {
155
+ level: "warning",
156
+ text: uncertainPurchaseMessage(failure.invocationId || "(unknown)")
157
+ };
158
+ }
159
+ const charged = failure.payment?.chargedAtomic;
160
+ if (charged !== void 0 || CHARGED_UNDELIVERED.has(failure.code)) {
161
+ return {
162
+ level: "error",
163
+ text: `This turn was paid${charged !== void 0 ? ` (${formatUsdc(charged)})` : ""} but its response was lost (${failure.code}). ${LOST_RESPONSE_TEXT}`
164
+ };
165
+ }
166
+ return void 0;
167
+ }
168
+
169
+ export {
170
+ AGENT_VIEW_VERSION,
171
+ formatUsdc,
172
+ formatCredits,
173
+ usdcToAtomic,
174
+ burnRate,
175
+ computeLow,
176
+ remainingBudget,
177
+ blockingPurchases,
178
+ statusBarText,
179
+ channelLines,
180
+ budgetLines,
181
+ computeLines,
182
+ LOST_RESPONSE_TEXT,
183
+ uncertainPurchaseMessage,
184
+ purchaseFailureNotice
185
+ };