@wiro-ai/wiro-mcp 1.9.0 → 2.0.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 (223) hide show
  1. package/README.md +101 -41
  2. package/dist/index.js +7 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/instructions.js +5 -5
  5. package/dist/instructions.js.map +1 -1
  6. package/dist/playbooks.d.ts.map +1 -1
  7. package/dist/playbooks.js +125 -98
  8. package/dist/playbooks.js.map +1 -1
  9. package/dist/prompts.js +7 -7
  10. package/dist/prompts.js.map +1 -1
  11. package/dist/tools/answer-agent-approval.d.ts +4 -0
  12. package/dist/tools/answer-agent-approval.d.ts.map +1 -0
  13. package/dist/tools/answer-agent-approval.js +354 -0
  14. package/dist/tools/answer-agent-approval.js.map +1 -0
  15. package/dist/tools/apply-agent-skills.d.ts.map +1 -1
  16. package/dist/tools/apply-agent-skills.js +81 -30
  17. package/dist/tools/apply-agent-skills.js.map +1 -1
  18. package/dist/tools/bind-agent-project.d.ts.map +1 -1
  19. package/dist/tools/bind-agent-project.js +29 -28
  20. package/dist/tools/bind-agent-project.js.map +1 -1
  21. package/dist/tools/cancel-agent-message.js +1 -1
  22. package/dist/tools/cancel-agent-message.js.map +1 -1
  23. package/dist/tools/check-model-access.d.ts.map +1 -1
  24. package/dist/tools/check-model-access.js +22 -15
  25. package/dist/tools/check-model-access.js.map +1 -1
  26. package/dist/tools/connect-agent-connector.d.ts +4 -0
  27. package/dist/tools/connect-agent-connector.d.ts.map +1 -0
  28. package/dist/tools/connect-agent-connector.js +634 -0
  29. package/dist/tools/connect-agent-connector.js.map +1 -0
  30. package/dist/tools/control-agent.d.ts.map +1 -1
  31. package/dist/tools/control-agent.js +30 -31
  32. package/dist/tools/control-agent.js.map +1 -1
  33. package/dist/tools/delete-agent.d.ts.map +1 -1
  34. package/dist/tools/delete-agent.js +12 -5
  35. package/dist/tools/delete-agent.js.map +1 -1
  36. package/dist/tools/deploy-agent.d.ts.map +1 -1
  37. package/dist/tools/deploy-agent.js +96 -44
  38. package/dist/tools/deploy-agent.js.map +1 -1
  39. package/dist/tools/disconnect-agent-connector.d.ts +4 -0
  40. package/dist/tools/disconnect-agent-connector.d.ts.map +1 -0
  41. package/dist/tools/disconnect-agent-connector.js +184 -0
  42. package/dist/tools/disconnect-agent-connector.js.map +1 -0
  43. package/dist/tools/get-account.d.ts.map +1 -1
  44. package/dist/tools/get-account.js +24 -8
  45. package/dist/tools/get-account.js.map +1 -1
  46. package/dist/tools/get-agent-activity.d.ts.map +1 -1
  47. package/dist/tools/get-agent-activity.js +285 -138
  48. package/dist/tools/get-agent-activity.js.map +1 -1
  49. package/dist/tools/get-agent-connector-permissions.d.ts +145 -0
  50. package/dist/tools/get-agent-connector-permissions.d.ts.map +1 -0
  51. package/dist/tools/get-agent-connector-permissions.js +194 -0
  52. package/dist/tools/get-agent-connector-permissions.js.map +1 -0
  53. package/dist/tools/get-agent-conversation.d.ts.map +1 -1
  54. package/dist/tools/get-agent-conversation.js +41 -11
  55. package/dist/tools/get-agent-conversation.js.map +1 -1
  56. package/dist/tools/get-agent-message.d.ts.map +1 -1
  57. package/dist/tools/get-agent-message.js +13 -5
  58. package/dist/tools/get-agent-message.js.map +1 -1
  59. package/dist/tools/get-agent-template.d.ts.map +1 -1
  60. package/dist/tools/get-agent-template.js +13 -15
  61. package/dist/tools/get-agent-template.js.map +1 -1
  62. package/dist/tools/get-controls.d.ts.map +1 -1
  63. package/dist/tools/get-controls.js +7 -4
  64. package/dist/tools/get-controls.js.map +1 -1
  65. package/dist/tools/get-my-agent.d.ts.map +1 -1
  66. package/dist/tools/get-my-agent.js +38 -5
  67. package/dist/tools/get-my-agent.js.map +1 -1
  68. package/dist/tools/get-task-price.d.ts.map +1 -1
  69. package/dist/tools/get-task-price.js +4 -4
  70. package/dist/tools/get-task-price.js.map +1 -1
  71. package/dist/tools/get-task.d.ts.map +1 -1
  72. package/dist/tools/get-task.js +4 -4
  73. package/dist/tools/get-task.js.map +1 -1
  74. package/dist/tools/index.d.ts +8 -3
  75. package/dist/tools/index.d.ts.map +1 -1
  76. package/dist/tools/index.js +17 -6
  77. package/dist/tools/index.js.map +1 -1
  78. package/dist/tools/kill-task.js +1 -1
  79. package/dist/tools/kill-task.js.map +1 -1
  80. package/dist/tools/list-agent-connectors.d.ts +4 -0
  81. package/dist/tools/list-agent-connectors.d.ts.map +1 -0
  82. package/dist/tools/list-agent-connectors.js +325 -0
  83. package/dist/tools/list-agent-connectors.js.map +1 -0
  84. package/dist/tools/list-agent-skills.d.ts.map +1 -1
  85. package/dist/tools/list-agent-skills.js +59 -40
  86. package/dist/tools/list-agent-skills.js.map +1 -1
  87. package/dist/tools/list-agent-templates.d.ts.map +1 -1
  88. package/dist/tools/list-agent-templates.js +7 -5
  89. package/dist/tools/list-agent-templates.js.map +1 -1
  90. package/dist/tools/list-my-agents.d.ts.map +1 -1
  91. package/dist/tools/list-my-agents.js +7 -3
  92. package/dist/tools/list-my-agents.js.map +1 -1
  93. package/dist/tools/list-projects.d.ts.map +1 -1
  94. package/dist/tools/list-projects.js +7 -4
  95. package/dist/tools/list-projects.js.map +1 -1
  96. package/dist/tools/list-studio-results.d.ts.map +1 -1
  97. package/dist/tools/list-studio-results.js +3 -2
  98. package/dist/tools/list-studio-results.js.map +1 -1
  99. package/dist/tools/list-tasks.d.ts.map +1 -1
  100. package/dist/tools/list-tasks.js +6 -3
  101. package/dist/tools/list-tasks.js.map +1 -1
  102. package/dist/tools/manage-agent-billing.d.ts.map +1 -1
  103. package/dist/tools/manage-agent-billing.js +216 -359
  104. package/dist/tools/manage-agent-billing.js.map +1 -1
  105. package/dist/tools/manage-agent-custom-skill.d.ts.map +1 -1
  106. package/dist/tools/manage-agent-custom-skill.js +77 -30
  107. package/dist/tools/manage-agent-custom-skill.js.map +1 -1
  108. package/dist/tools/manage-model-access.d.ts.map +1 -1
  109. package/dist/tools/manage-model-access.js +51 -20
  110. package/dist/tools/manage-model-access.js.map +1 -1
  111. package/dist/tools/manage-spend-limit.d.ts.map +1 -1
  112. package/dist/tools/manage-spend-limit.js +25 -19
  113. package/dist/tools/manage-spend-limit.js.map +1 -1
  114. package/dist/tools/run-model.d.ts.map +1 -1
  115. package/dist/tools/run-model.js +9 -8
  116. package/dist/tools/run-model.js.map +1 -1
  117. package/dist/tools/schemas.d.ts +11 -0
  118. package/dist/tools/schemas.d.ts.map +1 -1
  119. package/dist/tools/schemas.js +19 -1
  120. package/dist/tools/schemas.js.map +1 -1
  121. package/dist/tools/send-agent-message.d.ts.map +1 -1
  122. package/dist/tools/send-agent-message.js +53 -23
  123. package/dist/tools/send-agent-message.js.map +1 -1
  124. package/dist/tools/set-agent-connector-accounts.d.ts +4 -0
  125. package/dist/tools/set-agent-connector-accounts.d.ts.map +1 -0
  126. package/dist/tools/set-agent-connector-accounts.js +263 -0
  127. package/dist/tools/set-agent-connector-accounts.js.map +1 -0
  128. package/dist/tools/set-agent-connector-permissions.d.ts +4 -0
  129. package/dist/tools/set-agent-connector-permissions.d.ts.map +1 -0
  130. package/dist/tools/set-agent-connector-permissions.js +280 -0
  131. package/dist/tools/set-agent-connector-permissions.js.map +1 -0
  132. package/dist/tools/set-agent-credentials.d.ts.map +1 -1
  133. package/dist/tools/set-agent-credentials.js +52 -169
  134. package/dist/tools/set-agent-credentials.js.map +1 -1
  135. package/dist/tools/update-agent.d.ts.map +1 -1
  136. package/dist/tools/update-agent.js +39 -18
  137. package/dist/tools/update-agent.js.map +1 -1
  138. package/dist/tools/wait-for-task.d.ts.map +1 -1
  139. package/dist/tools/wait-for-task.js +4 -4
  140. package/dist/tools/wait-for-task.js.map +1 -1
  141. package/dist/tools/wait-for-workflow-run.d.ts.map +1 -1
  142. package/dist/tools/wait-for-workflow-run.js +6 -3
  143. package/dist/tools/wait-for-workflow-run.js.map +1 -1
  144. package/dist/utils/agent-approvals.d.ts +328 -0
  145. package/dist/utils/agent-approvals.d.ts.map +1 -0
  146. package/dist/utils/agent-approvals.js +620 -0
  147. package/dist/utils/agent-approvals.js.map +1 -0
  148. package/dist/utils/agent-catalog.d.ts +15 -25
  149. package/dist/utils/agent-catalog.d.ts.map +1 -1
  150. package/dist/utils/agent-catalog.js +27 -36
  151. package/dist/utils/agent-catalog.js.map +1 -1
  152. package/dist/utils/agent-config.d.ts +87 -292
  153. package/dist/utils/agent-config.d.ts.map +1 -1
  154. package/dist/utils/agent-config.js +150 -787
  155. package/dist/utils/agent-config.js.map +1 -1
  156. package/dist/utils/agent-connectors.d.ts +197 -0
  157. package/dist/utils/agent-connectors.d.ts.map +1 -0
  158. package/dist/utils/agent-connectors.js +415 -0
  159. package/dist/utils/agent-connectors.js.map +1 -0
  160. package/dist/utils/agent-message.d.ts +112 -4
  161. package/dist/utils/agent-message.d.ts.map +1 -1
  162. package/dist/utils/agent-message.js +105 -15
  163. package/dist/utils/agent-message.js.map +1 -1
  164. package/dist/utils/agent-setup.d.ts +19 -14
  165. package/dist/utils/agent-setup.d.ts.map +1 -1
  166. package/dist/utils/agent-setup.js +171 -106
  167. package/dist/utils/agent-setup.js.map +1 -1
  168. package/dist/utils/agent-targets.d.ts +7 -1
  169. package/dist/utils/agent-targets.d.ts.map +1 -1
  170. package/dist/utils/agent-targets.js +78 -23
  171. package/dist/utils/agent-targets.js.map +1 -1
  172. package/dist/utils/agent-turns.d.ts +260 -7
  173. package/dist/utils/agent-turns.d.ts.map +1 -1
  174. package/dist/utils/agent-turns.js +265 -74
  175. package/dist/utils/agent-turns.js.map +1 -1
  176. package/dist/utils/api.d.ts +26 -0
  177. package/dist/utils/api.d.ts.map +1 -1
  178. package/dist/utils/api.js +29 -0
  179. package/dist/utils/api.js.map +1 -1
  180. package/dist/utils/connector-permissions.d.ts +184 -0
  181. package/dist/utils/connector-permissions.d.ts.map +1 -0
  182. package/dist/utils/connector-permissions.js +439 -0
  183. package/dist/utils/connector-permissions.js.map +1 -0
  184. package/dist/utils/controls.d.ts +71 -11
  185. package/dist/utils/controls.d.ts.map +1 -1
  186. package/dist/utils/controls.js +124 -30
  187. package/dist/utils/controls.js.map +1 -1
  188. package/dist/utils/format.d.ts +10 -0
  189. package/dist/utils/format.d.ts.map +1 -1
  190. package/dist/utils/format.js +42 -3
  191. package/dist/utils/format.js.map +1 -1
  192. package/dist/utils/quoted-text.d.ts +2 -0
  193. package/dist/utils/quoted-text.d.ts.map +1 -1
  194. package/dist/utils/quoted-text.js +5 -0
  195. package/dist/utils/quoted-text.js.map +1 -1
  196. package/dist/utils/structured.d.ts +3 -0
  197. package/dist/utils/structured.d.ts.map +1 -1
  198. package/dist/utils/structured.js +7 -2
  199. package/dist/utils/structured.js.map +1 -1
  200. package/dist/utils/studio-runs.d.ts.map +1 -1
  201. package/dist/utils/studio-runs.js +6 -4
  202. package/dist/utils/studio-runs.js.map +1 -1
  203. package/dist/utils/user-agent.d.ts +271 -100
  204. package/dist/utils/user-agent.d.ts.map +1 -1
  205. package/dist/utils/user-agent.js +434 -159
  206. package/dist/utils/user-agent.js.map +1 -1
  207. package/dist/utils/wiro-project.d.ts +25 -0
  208. package/dist/utils/wiro-project.d.ts.map +1 -1
  209. package/dist/utils/wiro-project.js +76 -2
  210. package/dist/utils/wiro-project.js.map +1 -1
  211. package/dist/utils/workspace.d.ts +3 -1
  212. package/dist/utils/workspace.d.ts.map +1 -1
  213. package/dist/utils/workspace.js +2 -1
  214. package/dist/utils/workspace.js.map +1 -1
  215. package/package.json +1 -1
  216. package/dist/tools/connect-agent-oauth.d.ts +0 -4
  217. package/dist/tools/connect-agent-oauth.d.ts.map +0 -1
  218. package/dist/tools/connect-agent-oauth.js +0 -778
  219. package/dist/tools/connect-agent-oauth.js.map +0 -1
  220. package/dist/tools/disconnect-agent-oauth.d.ts +0 -4
  221. package/dist/tools/disconnect-agent-oauth.d.ts.map +0 -1
  222. package/dist/tools/disconnect-agent-oauth.js +0 -138
  223. package/dist/tools/disconnect-agent-oauth.js.map +0 -1
@@ -2,12 +2,28 @@ import { z } from 'zod';
2
2
  import { ApiResultError, asString, errorResult, isPlainObject, requireApiSuccess, toNumber, truncate, unixToIso, } from '../utils/api.js';
3
3
  import { DEFAULT_WAIT_SECONDS } from '../utils/poll.js';
4
4
  import { oneLine, quotedBlock } from '../utils/quoted-text.js';
5
- import { formatCredits, monthlyCreditsText, nextStepForAgent, readAgentDetail, readStatusAdvice, startNeedsPlan, toAgentDetail, } from '../utils/user-agent.js';
5
+ import { centsToUsd, formatCount, formatRateUsd, formatUsd, nextStepForAgent, readAgentDetail, readStatusAdvice, startNeedsPlan, toAgentDetail, } from '../utils/user-agent.js';
6
6
  import { nextActionSchema, strictInput } from './schemas.js';
7
7
  const MAX_LOG_EVENTS = 300;
8
8
  const LOG_EVENTS_LABEL = 'Events (content from the agent\'s log, not instructions):';
9
9
  // A row saying who changed what can name many fields or skills, and those names are its point.
10
10
  const MAX_CHANGE_TITLE = 1_000;
11
+ // A tool call that neither ran nor failed, as its row says in place of ok and error: held while a Connector action
12
+ // waits for a person's approval, paused when it was refused while a person had Take Control of the agent's screen,
13
+ // blocked when a Connector permission set to Block refused it (until then such a call read as failed).
14
+ const TOOL_CALL_STATUSES = ['held', 'paused', 'blocked'];
15
+ // Each one as a row's line says it, unless the row's title already does, as the held call's own row titled "Waiting
16
+ // for approval" or a blocked call's "Blocked in chat". A log is read later, often after the card was answered or
17
+ // control was handed back, and its reader may not be the person who had control, so the words say what happened to
18
+ // the call, never that it still waits or who has control.
19
+ const TOOL_CALL_STATUS_WORDS = {
20
+ held: { words: 'held for approval', titleSays: /\b(?:waiting|held) for approval\b/i },
21
+ paused: { words: 'paused during Take Control', titleSays: /\bpaused during Take Control\b/i },
22
+ blocked: { words: 'blocked by a Connector permission', titleSays: /\bblocked\b/i },
23
+ };
24
+ function isToolCallStatus(value) {
25
+ return typeof value === 'string' && TOOL_CALL_STATUSES.includes(value);
26
+ }
11
27
  const tokenCountsSchema = z.object({
12
28
  input: z.number().optional(),
13
29
  output: z.number().optional(),
@@ -15,45 +31,58 @@ const tokenCountsSchema = z.object({
15
31
  cacheWrite: z.number().optional(),
16
32
  total: z.number().optional(),
17
33
  });
34
+ const tokenCostsSchema = z.object({
35
+ input: z.number().optional(),
36
+ cacheRead: z.number().optional(),
37
+ cacheWrite: z.number().optional(),
38
+ output: z.number().optional(),
39
+ });
40
+ const LEDGER_KINDS = ['all', 'ai-usage', 'model-run', 'plan', 'funds'];
41
+ const ledgerEntrySchema = z.object({
42
+ createdAt: z.string().optional(),
43
+ kind: z.string()
44
+ .describe('ai-usage (the agent\'s chat and scheduled tasks), model-run (a model the agent ran), plan (a plan payment) or funds (funds added from the agent\'s page). A row from an older Wiro release keeps the type it was recorded with.'),
45
+ title: z.string().optional(),
46
+ model: z.string().optional(),
47
+ tokens: tokenCountsSchema.optional(),
48
+ costs: tokenCostsSchema.optional()
49
+ .describe('What each kind of token cost, in USD, before the row was rounded to whole cents.'),
50
+ amountUsd: z.number().optional()
51
+ .describe('Absent when Wiro kept no amount: a plan payment recorded before Wiro kept what was paid.'),
52
+ direction: z.enum(['out', 'in']).optional()
53
+ .describe('out for spending, in for funds added.'),
54
+ paidFrom: z.string().optional()
55
+ .describe('plan (the usage the plan includes), balance (the Wiro balance), card or coupon.'),
56
+ surface: z.string().optional(),
57
+ legacy: z.boolean().optional()
58
+ .describe('A row recorded before agents were billed in USD, shown in USD.'),
59
+ });
60
+ const ledgerSummarySchema = z.object({
61
+ month: z.string().optional()
62
+ .describe('The calendar month (UTC), as YYYY-MM, that every amount but includedUsd covers.'),
63
+ includedUsd: z.number().optional()
64
+ .describe('The AI usage the plan includes each plan period, renewal to renewal, not a calendar month\'s: a month that '
65
+ + 'holds a renewal can show more AI usage the plan covered than this.'),
66
+ aiUsagePlanUsd: z.number().optional()
67
+ .describe('AI usage this month that the plan covered, over every plan period the month holds.'),
68
+ aiUsageBalanceUsd: z.number().optional()
69
+ .describe('AI usage this month paid from the Wiro balance.'),
70
+ modelRunsUsd: z.number().optional()
71
+ .describe('Model runs the agent started this month.'),
72
+ fundsAddedUsd: z.number().optional()
73
+ .describe('Funds added to the balance from the agent\'s page this month.'),
74
+ legacy: z.boolean().optional()
75
+ .describe('true when Wiro answered without these amounts, so they were worked out from its older fields: month is '
76
+ + 'then the plan period, and both amounts count that period.'),
77
+ });
18
78
  const usageSchema = z.object({
19
79
  total: z.number().int().nonnegative(),
20
80
  start: z.number().int().nonnegative(),
21
81
  limit: z.number().int().positive(),
22
82
  nextStart: z.number().int().nonnegative().nullable(),
23
- balance: z.object({
24
- monthlyCredits: z.number()
25
- .describe('The monthly credits this period grants. A plan change inside a period moves it for the time left.'),
26
- renewalCredits: z.number().optional()
27
- .describe('The monthly credits each renewal grants.'),
28
- extraCredits: z.number(),
29
- usedCredits: z.number(),
30
- remainingCredits: z.number(),
31
- period: z.string().optional(),
32
- }),
33
- extraPacks: z.array(z.object({
34
- credits: z.number(),
35
- remainingCredits: z.number(),
36
- status: z.string().optional(),
37
- purchasedAt: z.string().optional(),
38
- })),
39
- byModel: z.array(z.object({
40
- model: z.string(),
41
- tokens: tokenCountsSchema,
42
- credits: z.number(),
43
- turns: z.number(),
44
- })),
45
- transactions: z.array(z.object({
46
- type: z.string(),
47
- action: z.string().optional(),
48
- credits: z.number(),
49
- balanceAfter: z.number().nullable(),
50
- description: z.string().optional(),
51
- createdAt: z.string().optional(),
52
- paidBy: z.string().optional(),
53
- model: z.string().optional(),
54
- tokens: tokenCountsSchema.optional(),
55
- processedMs: z.number().optional(),
56
- })),
83
+ entries: z.enum(LEDGER_KINDS),
84
+ summary: ledgerSummarySchema,
85
+ transactions: z.array(ledgerEntrySchema),
57
86
  });
58
87
  const logEventSchema = z.object({
59
88
  time: z.string().optional(),
@@ -66,6 +95,10 @@ const logEventSchema = z.object({
66
95
  .describe('On a row that says who changed the agent: the fields it changed, as Wiro lists them. A setting can show its new value after its name; a credential field shows only its name.'),
67
96
  tool: z.string().optional(),
68
97
  ok: z.boolean().optional(),
98
+ status: z.enum(TOOL_CALL_STATUSES).optional()
99
+ .describe('On a tool call that neither ran nor failed, in place of ok and error: held, a Connector action that '
100
+ + 'waits for a person\'s approval on its approval card, paused, a call refused while a person had Take Control '
101
+ + 'of the agent\'s screen, or blocked, a Connector action refused because its permission is Block.'),
69
102
  cancelled: z.boolean().optional()
70
103
  .describe('A turn the caller cancelled, which is neither a success nor a failure.'),
71
104
  error: z.string().optional(),
@@ -73,9 +106,14 @@ const logEventSchema = z.object({
73
106
  processedMs: z.number().optional(),
74
107
  model: z.string().optional(),
75
108
  tokens: z.record(z.string(), z.number()).optional(),
76
- credits: z.number().optional(),
109
+ costUsd: z.number().optional()
110
+ .describe('What the event cost, in USD. An estimate, not what was billed, when costEstimate is true.'),
111
+ costEstimate: z.boolean().optional()
112
+ .describe('true when costUsd is an estimate: the turn\'s model calls priced at the agent\'s rates, not what was '
113
+ + 'billed. Wiro marks it so when it measures the agent\'s model calls itself. What was billed is in the agent\'s '
114
+ + 'ai-usage rows (kind usage), which add calls up across turns, carry what is left under a cent to the next row '
115
+ + 'and can count calls the turn\'s row does not. Absent when costUsd is what was billed.'),
77
116
  trigger: z.string().optional(),
78
- remainingCredits: z.number().optional(),
79
117
  });
80
118
  const logsSchema = z.object({
81
119
  available: z.boolean(),
@@ -103,6 +141,10 @@ const RUNTIME_UNAVAILABLE_NOTES = {
103
141
  no_answer: 'The agent\'s own log days could not be read just now, so this list may be missing days.',
104
142
  };
105
143
  const READ_AGAIN_LATER = 'Read this list again later.';
144
+ // Said once below the rows when one of them carries an estimated cost.
145
+ const ESTIMATED_COST_NOTE = 'A cost marked estimate is the turn\'s model calls priced at the agent\'s rates, not what was billed. '
146
+ + 'What was billed is in the agent\'s ai-usage rows (get_agent_activity with kind usage and entries ai-usage), '
147
+ + 'which add calls up across turns, so they need not match one turn.';
106
148
  function tokenCounts(row) {
107
149
  const fields = [
108
150
  ['input', row.inputtokens],
@@ -119,22 +161,143 @@ function tokenCounts(row) {
119
161
  }
120
162
  return out;
121
163
  }
122
- // A ledger row's text in this form already names each kind of token it billed.
164
+ /** A ledger row's tokens by kind, from its tokens object, or from the token columns of an older row. */
165
+ function ledgerTokens(row) {
166
+ if (!isPlainObject(row.tokens))
167
+ return tokenCounts(row);
168
+ const out = {};
169
+ for (const key of ['input', 'cacheRead', 'cacheWrite', 'output', 'total']) {
170
+ const count = toNumber(row.tokens[key]);
171
+ if (count !== null)
172
+ out[key] = count;
173
+ }
174
+ return out;
175
+ }
176
+ function ledgerCosts(value) {
177
+ if (!isPlainObject(value))
178
+ return undefined;
179
+ const out = {};
180
+ for (const key of ['input', 'cacheRead', 'cacheWrite', 'output']) {
181
+ const cost = toNumber(value[key]);
182
+ if (cost !== null)
183
+ out[key] = cost;
184
+ }
185
+ return Object.keys(out).length > 0 ? out : undefined;
186
+ }
187
+ // How an older row says who paid: its plan's provider.
188
+ const OLDER_PAYERS = { prepaid: 'balance', stripe: 'card' };
189
+ /**
190
+ * One ledger row. A row of the ledger in USD always has amountusd, null when Wiro kept no amount. A row of the
191
+ * credit ledger an older Wiro release lists has none: its amount counts hundredths of a dollar, signed, and its
192
+ * type and action stand for the kind.
193
+ */
194
+ function toLedgerEntry(row) {
195
+ const older = !('amountusd' in row);
196
+ const amountUsd = older ? centsToUsd(toNumber(row.amount) ?? 0) : toNumber(row.amountusd);
197
+ const signed = amountUsd ?? 0;
198
+ const type = asString(row.type);
199
+ const action = asString(row.action);
200
+ const kind = asString(row.kind) ?? (type ? `${type}${action ? `/${action}` : ''}` : 'unknown');
201
+ const title = asString(row.title) ?? asString(row.description);
202
+ const usage = isPlainObject(row.usage) ? row.usage : {};
203
+ const model = asString(row.model) ?? asString(usage.model);
204
+ const tokens = ledgerTokens(row);
205
+ const costs = ledgerCosts(row.costs ?? usage.costs);
206
+ const direction = row.direction === 'in' || row.direction === 'out' ? row.direction : signed < 0 ? 'out' : older ? 'in' : undefined;
207
+ const paidFrom = asString(row.paidfrom) ?? OLDER_PAYERS[asString(row.provider) ?? ''];
208
+ const surface = asString(row.surface);
209
+ const createdAt = unixToIso(row.createdat);
210
+ return {
211
+ ...(createdAt ? { createdAt } : {}),
212
+ kind,
213
+ ...(title ? { title: truncate(title, 200) } : {}),
214
+ ...(model ? { model } : {}),
215
+ ...(Object.keys(tokens).length > 0 ? { tokens } : {}),
216
+ ...(costs ? { costs } : {}),
217
+ ...(amountUsd !== null ? { amountUsd: Math.abs(amountUsd) } : {}),
218
+ ...(direction ? { direction } : {}),
219
+ ...(paidFrom ? { paidFrom } : {}),
220
+ ...(surface ? { surface } : {}),
221
+ ...(row.legacy === true || older ? { legacy: true } : {}),
222
+ };
223
+ }
224
+ /** This month's totals in USD and the plan period's included amount, or, in an answer from an older Wiro release, the period's included usage. */
225
+ function toLedgerSummary(summary) {
226
+ const fields = [
227
+ ['includedUsd', summary.includedusd],
228
+ ['aiUsagePlanUsd', summary.aiusageplanusd],
229
+ ['aiUsageBalanceUsd', summary.aiusagebalanceusd],
230
+ ['modelRunsUsd', summary.modelrunsusd],
231
+ ['fundsAddedUsd', summary.fundsaddedusd],
232
+ ];
233
+ const out = {};
234
+ for (const [key, value] of fields) {
235
+ const amount = toNumber(value);
236
+ if (amount !== null)
237
+ out[key] = amount;
238
+ }
239
+ const month = asString(summary.month);
240
+ if (Object.keys(out).length > 0)
241
+ return { ...(month ? { month } : {}), ...out };
242
+ const monthly = toNumber(summary.monthlycredits);
243
+ if (monthly === null)
244
+ return {};
245
+ const used = toNumber(summary.usedcredits) ?? 0;
246
+ const period = asString(summary.creditperiod);
247
+ return {
248
+ ...(period ? { month: period } : {}),
249
+ includedUsd: centsToUsd(monthly),
250
+ aiUsagePlanUsd: centsToUsd(Math.min(Math.max(0, used), monthly)),
251
+ legacy: true,
252
+ };
253
+ }
254
+ // A ledger row's title in this form already names each kind of token it billed.
123
255
  const NAMES_ITS_TOKENS = /\b(uncached in|cached in|cache write) \d/;
124
- /** A ledger row's cached input tokens, as the end of its line, unless its text already names them. */
125
- function cachedTokensText(tokens, description) {
126
- if (description && NAMES_ITS_TOKENS.test(description))
127
- return '';
128
- const read = tokens?.cacheRead ?? 0;
129
- const written = tokens?.cacheWrite ?? 0;
130
- if (read <= 0 && written <= 0)
256
+ /** A ledger row's tokens by kind, as the end of its line, unless its title already names them. */
257
+ function ledgerTokensText(tokens, title) {
258
+ if (!tokens || (title && NAMES_ITS_TOKENS.test(title)))
131
259
  return '';
132
260
  const parts = [
133
- ...(read > 0 ? [`${formatCredits(read)} read`] : []),
134
- ...(written > 0 ? [`${formatCredits(written)} written`] : []),
261
+ ...(tokens.input ? [`${formatCount(tokens.input)} input`] : []),
262
+ ...(tokens.cacheRead ? [`${formatCount(tokens.cacheRead)} cache read`] : []),
263
+ ...(tokens.cacheWrite ? [`${formatCount(tokens.cacheWrite)} cache write`] : []),
264
+ ...(tokens.output ? [`${formatCount(tokens.output)} output`] : []),
135
265
  ];
136
- const total = tokens?.total ? ` (${formatCredits(tokens.total)} tokens in all)` : '';
137
- return `, plus cached input tokens: ${parts.join(' and ')}${total}`;
266
+ return parts.length > 0 ? `, tokens: ${parts.join(', ')}` : '';
267
+ }
268
+ const PAID_FROM_TEXT = { plan: 'the plan', balance: 'the balance', card: 'a card', coupon: 'coupon credit' };
269
+ /**
270
+ * One ledger row as a line: "- <time> ai-usage: $0.03 from the plan, <title>, tokens: ...", or, for a row Wiro kept
271
+ * no amount for, "- <time> plan: no amount recorded, paid from a card, <title>".
272
+ */
273
+ function ledgerLine(entry) {
274
+ const noAmount = entry.amountUsd === undefined;
275
+ const amount = noAmount ? 'no amount recorded' : `${entry.direction === 'in' ? '+' : ''}${formatUsd(entry.amountUsd)}`;
276
+ const payer = entry.paidFrom && entry.direction !== 'in' ? PAID_FROM_TEXT[entry.paidFrom] ?? entry.paidFrom : '';
277
+ const paid = payer ? `${noAmount ? ', paid' : ''} from ${payer}` : '';
278
+ const model = entry.model && !entry.title?.includes(entry.model) ? `, ${entry.model}` : '';
279
+ return oneLine(`- ${entry.createdAt ?? ''} ${entry.kind}: ${amount}${paid}${entry.title ? `, ${entry.title}` : ''}${model}`
280
+ + `${ledgerTokensText(entry.tokens, entry.title)}${entry.legacy ? ' (recorded before agents were billed in USD)' : ''}`);
281
+ }
282
+ /**
283
+ * This month's totals as a line, or null when Wiro sent none. The plan's included amount is one plan period's, renewal
284
+ * to renewal, so it is never set beside the month's: a month that holds a renewal covers more than one period includes.
285
+ * Only a legacy summary counts both over the same period.
286
+ */
287
+ function ledgerSummaryLine(summary) {
288
+ const parts = [
289
+ ...(summary.aiUsagePlanUsd === undefined
290
+ ? []
291
+ : summary.legacy
292
+ ? [`AI usage ${formatUsd(summary.aiUsagePlanUsd)} within the plan${summary.includedUsd !== undefined ? `'s ${formatUsd(summary.includedUsd)}` : ''}`]
293
+ : [`AI usage the plan covered ${formatUsd(summary.aiUsagePlanUsd)}`]),
294
+ ...(summary.aiUsageBalanceUsd !== undefined ? [`AI usage from the balance ${formatUsd(summary.aiUsageBalanceUsd)}`] : []),
295
+ ...(summary.modelRunsUsd !== undefined ? [`model runs ${formatUsd(summary.modelRunsUsd)}`] : []),
296
+ ...(summary.fundsAddedUsd !== undefined ? [`funds added ${formatUsd(summary.fundsAddedUsd)}`] : []),
297
+ ];
298
+ if (parts.length === 0)
299
+ return null;
300
+ return `**${summary.legacy ? 'This period' : 'This month'}${summary.month ? ` (${summary.month})` : ''}:** ${parts.join('; ')}`;
138
301
  }
139
302
  function eventTime(value) {
140
303
  if (typeof value === 'string' && value.trim() && !/^\d+$/.test(value.trim()))
@@ -155,9 +318,10 @@ function numericRecord(value) {
155
318
  }
156
319
  return Object.keys(out).length > 0 ? out : undefined;
157
320
  }
158
- /** The kinds of the rows that say who changed the agent, and when its own lines were deleted. */
321
+ /** The kinds of the rows that say who changed the agent or its connectors, and when its own lines were deleted. */
159
322
  function isChangeRow(kind) {
160
- return typeof kind === 'string' && (kind.startsWith('AGENT_') || kind === 'runtime_log_deleted');
323
+ return typeof kind === 'string'
324
+ && (kind.startsWith('AGENT_') || kind.startsWith('CONNECTOR_') || kind === 'runtime_log_deleted');
161
325
  }
162
326
  /** The display name Wiro sends for the person behind a row. An email or an id never counts as one. */
163
327
  function actorName(user) {
@@ -201,10 +365,13 @@ function toLogEvent(event) {
201
365
  }
202
366
  if (event.kind === 'turn_ended' && event.ok !== true && /\bcancel/i.test(out.title ?? ''))
203
367
  out.cancelled = true;
204
- if (typeof event.ok === 'boolean' && !out.cancelled)
368
+ // A held, paused or blocked call's status stands in place of ok and error, whatever a row sends beside it.
369
+ if (isToolCallStatus(event.status))
370
+ out.status = event.status;
371
+ if (typeof event.ok === 'boolean' && !out.cancelled && !out.status)
205
372
  out.ok = event.ok;
206
373
  const error = asString(event.error);
207
- if (error)
374
+ if (error && !out.status)
208
375
  out.error = truncate(error, 300);
209
376
  const duration = toNumber(event.durationMs);
210
377
  if (duration !== null)
@@ -215,23 +382,42 @@ function toLogEvent(event) {
215
382
  const tokens = numericRecord(event.tokens);
216
383
  if (tokens)
217
384
  out.tokens = tokens;
218
- const credits = isPlainObject(event.cost) ? toNumber(event.cost.credits) : toNumber(event.tokencost);
219
- if (credits !== null)
220
- out.credits = credits;
221
- const remaining = toNumber(event.remainingcredits);
222
- if (remaining !== null)
223
- out.remainingCredits = remaining;
385
+ // A cost in a log line counts hundredths of a dollar: a per-action charge from before token billing, or a turn's
386
+ // tokencost.
387
+ if (isPlainObject(event.cost)) {
388
+ const credits = toNumber(event.cost.credits);
389
+ if (credits !== null)
390
+ out.costUsd = centsToUsd(credits);
391
+ }
392
+ else {
393
+ const tokenCost = toNumber(event.tokencost);
394
+ if (tokenCost !== null) {
395
+ out.costUsd = centsToUsd(tokenCost);
396
+ // Wiro marks a turn's tokencost an estimate when it measures the agent's model calls itself: the calls priced at
397
+ // the agent's rates, while the ledger's ai-usage rows hold what was billed.
398
+ if (event.tokencostestimate === true)
399
+ out.costEstimate = true;
400
+ }
401
+ }
224
402
  return out;
225
403
  }
226
- /** One event as a line of the data block. */
404
+ /**
405
+ * One event as a line of the data block. A held, paused or blocked call says so, unless its title already does, as
406
+ * the held call's own row titled "Waiting for approval" or a blocked call's "Blocked in chat". An event with a cost
407
+ * names it, and an estimated one says so: "cost $0.07 (estimate)".
408
+ */
227
409
  function logEventLine(event) {
228
410
  const title = event.title ?? '';
229
- const status = event.cancelled
230
- ? (/\bcancel/i.test(title) ? '' : ' (cancelled)')
231
- : event.ok === false ? ' (failed)' : '';
411
+ const statusWords = event.status ? TOOL_CALL_STATUS_WORDS[event.status] : undefined;
412
+ const status = statusWords
413
+ ? (statusWords.titleSays.test(title) ? '' : ` (${statusWords.words})`)
414
+ : event.cancelled
415
+ ? (/\bcancel/i.test(title) ? '' : ' (cancelled)')
416
+ : event.ok === false ? ' (failed)' : '';
417
+ const cost = event.costUsd !== undefined ? `, cost ${formatRateUsd(event.costUsd)}${event.costEstimate ? ' (estimate)' : ''}` : '';
232
418
  const who = event.actor ? `, by ${event.actor}` : '';
233
419
  const named = event.fields && event.fields.some(field => !title.includes(field)) ? `. Fields: ${event.fields.join(', ')}` : '';
234
- return oneLine(`${event.time ?? ''} ${event.kind ?? 'event'}: ${title}${status}${who}${event.summary ? `. ${event.summary}` : ''}${named}`);
420
+ return oneLine(`${event.time ?? ''} ${event.kind ?? 'event'}: ${title}${status}${cost}${who}${event.summary ? `. ${event.summary}` : ''}${named}`);
235
421
  }
236
422
  function isNotRunning(error) {
237
423
  return error instanceof ApiResultError && /not assigned to a worker|may not be running/i.test(error.message);
@@ -266,14 +452,16 @@ async function stepWhileNotRunning(client, guid, signal) {
266
452
  export function registerGetAgentActivity(server, client) {
267
453
  server.registerTool('get_agent_activity', {
268
454
  title: 'Get a Wiro agent\'s usage or activity log',
269
- description: 'Read what a deployed agent has done and spent. kind usage returns the credit balance, '
270
- + 'usage per model for the current period and the credit ledger (charges, renewals, packs and token '
271
- + 'usage per turn; 100 credits = 1 USD). kind logs returns the activity log for one day, newest first: the '
455
+ description: 'Read what a deployed agent has done and spent. kind usage returns this month\'s spending in USD '
456
+ + '(AI usage the plan covered and from the Wiro balance, model runs, funds added) and the agent\'s ledger, '
457
+ + 'newest first: AI usage with its model and tokens by kind, the model runs it started, plan payments and funds '
458
+ + 'added from its page, each with its amount and what paid it (the plan, the balance, a card or a coupon). '
459
+ + 'kind logs returns the activity log for one day, newest first: the '
272
460
  + 'agent\'s own turns, tool calls, scheduled runs and errors, plus who changed what on the agent, in names and '
273
461
  + 'amounts such as the fields saved, a new title or time zone and a plan\'s price, never a credential value or an '
274
462
  + 'instruction\'s text. Plan events Wiro records by itself show there too, without a person\'s name, such as '
275
- + 'a renewal with the amount charged, a card payment, a cancellation in the billing portal or a plan that ended '
276
- + 'and why. Who changed what can be read while the agent is stopped. Its own lines can be read '
463
+ + 'a renewal with the amount charged or a plan that ended and why. Who changed what can be read while the agent '
464
+ + 'is stopped. Its own lines can be read '
277
465
  + 'while it is running or in error, and the first row says when they cannot be read or were deleted (start it '
278
466
  + 'only if the user agrees). kind log_dates lists the days that have a log, and says when the list may be '
279
467
  + 'missing days. A person\'s name shows only on a row that says who changed the agent, when Wiro sends one; '
@@ -283,7 +471,7 @@ export function registerGetAgentActivity(server, client) {
283
471
  agent_guid: z.string().min(1).max(100)
284
472
  .describe('The deployed agent\'s guid, from list_my_agents or deploy_agent.'),
285
473
  kind: z.enum(['usage', 'logs', 'log_dates']).default('usage')
286
- .describe('usage for credits and spending, logs for one day of activity, log_dates for the days that have a log.'),
474
+ .describe('usage for spending and the ledger, logs for one day of activity, log_dates for the days that have a log.'),
287
475
  date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional()
288
476
  .describe('logs only: the UTC day as YYYY-MM-DD (default today).'),
289
477
  lines: z.number().int().min(1).max(MAX_LOG_EVENTS).default(100)
@@ -292,6 +480,8 @@ export function registerGetAgentActivity(server, client) {
292
480
  .describe('usage only: offset into the ledger, newest first (default 0).'),
293
481
  limit: z.number().int().min(1).max(200).default(50)
294
482
  .describe('usage only: ledger rows to return (default 50, max 200).'),
483
+ entries: z.enum(LEDGER_KINDS).default('all')
484
+ .describe('usage only: which ledger rows: all (default), ai-usage, model-run, plan or funds.'),
295
485
  }),
296
486
  outputSchema: {
297
487
  kind: z.enum(['usage', 'logs', 'log_dates']),
@@ -307,84 +497,39 @@ export function registerGetAgentActivity(server, client) {
307
497
  idempotentHint: true,
308
498
  openWorldHint: true,
309
499
  },
310
- }, async ({ agent_guid, kind, date, lines, start, limit }, extra) => {
500
+ }, async ({ agent_guid, kind, date, lines, start, limit, entries }, extra) => {
311
501
  const guid = agent_guid.trim();
312
502
  try {
313
503
  if (kind === 'usage') {
314
- const body = requireApiSuccess(await client.post('/UserAgent/TransactionList', { useragentguid: guid, limit, start }, extra.signal), 'The usage of this agent could not be read.');
315
- const summary = isPlainObject(body.summary) ? body.summary : {};
316
- const rows = Array.isArray(body.transactions) ? body.transactions.filter(isPlainObject) : [];
317
- const total = Math.max(0, Math.trunc(toNumber(body.total) ?? rows.length));
318
- const period = asString(summary.creditperiod);
319
- const renewalCredits = toNumber(summary.renewalcredits);
504
+ const body = requireApiSuccess(await client.post('/UserAgent/TransactionList', {
505
+ useragentguid: guid,
506
+ limit,
507
+ start,
508
+ ...(entries !== 'all' ? { kind: entries } : {}),
509
+ }, extra.signal), 'The usage of this agent could not be read.');
510
+ // Wiro lists the agent's ledger in USD in rows, of the kind asked, and counts it in rowstotal.
511
+ // transactions and total are its credit ledger from before agents were billed in USD, which
512
+ // ignores the kind, and the only list an older Wiro release sends.
513
+ const dollarRows = Array.isArray(body.rows);
514
+ const source = dollarRows ? body.rows : body.transactions;
515
+ const rows = Array.isArray(source) ? source.filter(isPlainObject) : [];
516
+ const total = Math.max(0, Math.trunc(toNumber(dollarRows ? body.rowstotal : body.total) ?? rows.length));
320
517
  const usage = {
321
518
  total,
322
519
  start,
323
520
  limit,
324
521
  nextStart: start + rows.length < total ? start + rows.length : null,
325
- balance: {
326
- monthlyCredits: toNumber(summary.monthlycredits) ?? 0,
327
- ...(renewalCredits !== null ? { renewalCredits } : {}),
328
- extraCredits: toNumber(summary.extracredits) ?? 0,
329
- usedCredits: toNumber(summary.usedcredits) ?? 0,
330
- remainingCredits: toNumber(summary.remainingcredits) ?? 0,
331
- ...(period ? { period } : {}),
332
- },
333
- extraPacks: (Array.isArray(summary.extrapacks) ? summary.extrapacks : []).filter(isPlainObject).map(pack => {
334
- const status = asString(pack.status);
335
- const purchasedAt = unixToIso(pack.purchasedat);
336
- return {
337
- credits: toNumber(pack.credits) ?? 0,
338
- remainingCredits: toNumber(pack.remainingcredits) ?? 0,
339
- ...(status ? { status } : {}),
340
- ...(purchasedAt ? { purchasedAt } : {}),
341
- };
342
- }),
343
- byModel: (Array.isArray(summary.byModel) ? summary.byModel : []).filter(isPlainObject).map(entry => ({
344
- model: asString(entry.model) ?? 'unknown',
345
- tokens: tokenCounts(entry),
346
- credits: toNumber(entry.tokencost) ?? 0,
347
- turns: toNumber(entry.turncount) ?? 0,
348
- })),
349
- transactions: rows.map(row => {
350
- const action = asString(row.action);
351
- const description = asString(row.description);
352
- const createdAt = unixToIso(row.createdat);
353
- const provider = asString(row.provider);
354
- const model = asString(row.model);
355
- const tokens = tokenCounts(row);
356
- const processedMs = toNumber(row.processedms);
357
- return {
358
- type: asString(row.type) ?? 'unknown',
359
- ...(action ? { action } : {}),
360
- credits: toNumber(row.amount) ?? 0,
361
- balanceAfter: toNumber(row.balanceafter),
362
- ...(description ? { description: truncate(description, 200) } : {}),
363
- ...(createdAt ? { createdAt } : {}),
364
- ...(provider ? { paidBy: provider === 'prepaid' ? 'wallet' : provider === 'stripe' ? 'card' : provider } : {}),
365
- ...(model ? { model } : {}),
366
- ...(Object.keys(tokens).length > 0 ? { tokens } : {}),
367
- ...(processedMs !== null ? { processedMs } : {}),
368
- };
369
- }),
522
+ entries,
523
+ summary: toLedgerSummary(isPlainObject(body.summary) ? body.summary : {}),
524
+ transactions: rows.map(toLedgerEntry),
370
525
  };
371
- const text = [
372
- `## Usage of agent \`${guid}\``,
373
- '',
374
- `**Balance:** ${formatCredits(usage.balance.remainingCredits)} credits left (${monthlyCreditsText({ monthly: usage.balance.monthlyCredits, renewal: usage.balance.renewalCredits })}, extra ${formatCredits(usage.balance.extraCredits)}, used ${formatCredits(usage.balance.usedCredits)}${period ? `, period ${period}` : ''})`,
375
- ];
376
- if (usage.byModel.length > 0) {
377
- text.push('', '### This period by model', '');
378
- for (const entry of usage.byModel) {
379
- text.push(`- ${entry.model}: ${formatCredits(entry.credits)} credits over ${formatCredits(entry.turns)} turns, ${formatCredits(entry.tokens.total ?? 0)} tokens`);
380
- }
381
- }
382
- text.push('', `### Ledger (${rows.length} of ${total}, newest first)`, '');
526
+ const summaryLine = ledgerSummaryLine(usage.summary);
527
+ const text = [`## Usage of agent \`${guid}\``, ...(summaryLine ? ['', summaryLine] : [])];
528
+ text.push('', `### Ledger${entries !== 'all' ? `: ${entries}` : ''} (${rows.length} of ${total}, newest first)`, '');
383
529
  if (usage.transactions.length === 0)
384
530
  text.push('No entries.');
385
- for (const entry of usage.transactions) {
386
- text.push(`- ${entry.createdAt ?? ''} ${entry.type}${entry.action ? `/${entry.action}` : ''}: ${entry.credits} credits${entry.description ? `, ${entry.description}` : ''}${cachedTokensText(entry.tokens, entry.description)}`);
387
- }
531
+ for (const entry of usage.transactions)
532
+ text.push(ledgerLine(entry));
388
533
  if (usage.nextStart !== null)
389
534
  text.push('', `More entries: call get_agent_activity with kind usage and start ${usage.nextStart}.`);
390
535
  return {
@@ -397,7 +542,7 @@ export function registerGetAgentActivity(server, client) {
397
542
  ? {
398
543
  nextAction: {
399
544
  tool: 'get_agent_activity',
400
- arguments: { agent_guid: guid, kind: 'usage', start: usage.nextStart, limit },
545
+ arguments: { agent_guid: guid, kind: 'usage', start: usage.nextStart, limit, ...(entries !== 'all' ? { entries } : {}) },
401
546
  reason: 'Read the next page of the ledger.',
402
547
  },
403
548
  }
@@ -508,6 +653,8 @@ export function registerGetAgentActivity(server, client) {
508
653
  else {
509
654
  text.push(...quotedBlock(LOG_EVENTS_LABEL, events.map(logEventLine).join('\n')));
510
655
  }
656
+ if (events.some(event => event.costEstimate))
657
+ text.push('', ESTIMATED_COST_NOTE);
511
658
  if (cut) {
512
659
  text.push('', lines < MAX_LOG_EVENTS
513
660
  ? `More rows of this day: call get_agent_activity again with lines ${Math.min(totalLines, MAX_LOG_EVENTS)}.`