charness 3.10.0 → 3.11.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 (157) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +2 -1
  3. package/agent-plugin/skills/charness-manager/SKILL.md +6 -5
  4. package/dist/bot.d.ts.map +1 -1
  5. package/dist/bot.js +176 -135
  6. package/dist/bot.js.map +1 -1
  7. package/dist/connectors/telegram/commands/botCore.d.ts +1 -0
  8. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  9. package/dist/connectors/telegram/commands/claudeAccounts.js +3 -3
  10. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  11. package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
  12. package/dist/connectors/telegram/commands/runners.js +11 -5
  13. package/dist/connectors/telegram/commands/runners.js.map +1 -1
  14. package/dist/connectors/telegram/foldedMessage.d.ts +24 -0
  15. package/dist/connectors/telegram/foldedMessage.d.ts.map +1 -0
  16. package/dist/connectors/telegram/foldedMessage.js +39 -0
  17. package/dist/connectors/telegram/foldedMessage.js.map +1 -0
  18. package/dist/connectors/telegram/inbound.d.ts +24 -1
  19. package/dist/connectors/telegram/inbound.d.ts.map +1 -1
  20. package/dist/connectors/telegram/inbound.js +77 -1
  21. package/dist/connectors/telegram/inbound.js.map +1 -1
  22. package/dist/connectors/telegram/renderAgentHtml.d.ts +15 -0
  23. package/dist/connectors/telegram/renderAgentHtml.d.ts.map +1 -1
  24. package/dist/connectors/telegram/renderAgentHtml.js +11 -1
  25. package/dist/connectors/telegram/renderAgentHtml.js.map +1 -1
  26. package/dist/connectors/telegram/unpinMessages.d.ts +12 -0
  27. package/dist/connectors/telegram/unpinMessages.d.ts.map +1 -0
  28. package/dist/connectors/telegram/unpinMessages.js +44 -0
  29. package/dist/connectors/telegram/unpinMessages.js.map +1 -0
  30. package/dist/i18n/de.d.ts.map +1 -1
  31. package/dist/i18n/de.js +11 -3
  32. package/dist/i18n/de.js.map +1 -1
  33. package/dist/i18n/en.d.ts.map +1 -1
  34. package/dist/i18n/en.js +11 -3
  35. package/dist/i18n/en.js.map +1 -1
  36. package/dist/i18n/es.d.ts.map +1 -1
  37. package/dist/i18n/es.js +11 -3
  38. package/dist/i18n/es.js.map +1 -1
  39. package/dist/i18n/fr.d.ts.map +1 -1
  40. package/dist/i18n/fr.js +11 -3
  41. package/dist/i18n/fr.js.map +1 -1
  42. package/dist/i18n/hi.d.ts.map +1 -1
  43. package/dist/i18n/hi.js +11 -3
  44. package/dist/i18n/hi.js.map +1 -1
  45. package/dist/i18n/ja.d.ts.map +1 -1
  46. package/dist/i18n/ja.js +11 -3
  47. package/dist/i18n/ja.js.map +1 -1
  48. package/dist/i18n/ka.d.ts.map +1 -1
  49. package/dist/i18n/ka.js +11 -3
  50. package/dist/i18n/ka.js.map +1 -1
  51. package/dist/i18n/pt.d.ts.map +1 -1
  52. package/dist/i18n/pt.js +11 -3
  53. package/dist/i18n/pt.js.map +1 -1
  54. package/dist/i18n/ru.d.ts.map +1 -1
  55. package/dist/i18n/ru.js +11 -3
  56. package/dist/i18n/ru.js.map +1 -1
  57. package/dist/i18n/uk.d.ts.map +1 -1
  58. package/dist/i18n/uk.js +11 -3
  59. package/dist/i18n/uk.js.map +1 -1
  60. package/dist/i18n/uz.d.ts.map +1 -1
  61. package/dist/i18n/uz.js +11 -3
  62. package/dist/i18n/uz.js.map +1 -1
  63. package/dist/i18n/zh.d.ts.map +1 -1
  64. package/dist/i18n/zh.js +11 -3
  65. package/dist/i18n/zh.js.map +1 -1
  66. package/dist/outputTrace.d.ts +6 -0
  67. package/dist/outputTrace.d.ts.map +1 -1
  68. package/dist/outputTrace.js +13 -0
  69. package/dist/outputTrace.js.map +1 -1
  70. package/dist/runnerUtility/guiAgentHeal.js +2 -2
  71. package/dist/runnerUtility/guiAgentHeal.js.map +1 -1
  72. package/dist/runnerUtility/isolatedCommand.d.ts +0 -2
  73. package/dist/runnerUtility/isolatedCommand.d.ts.map +1 -1
  74. package/dist/runnerUtility/isolatedCommand.js +4 -11
  75. package/dist/runnerUtility/isolatedCommand.js.map +1 -1
  76. package/dist/scheduler/checkRun.d.ts +9 -10
  77. package/dist/scheduler/checkRun.d.ts.map +1 -1
  78. package/dist/scheduler/checkRun.js +8 -16
  79. package/dist/scheduler/checkRun.js.map +1 -1
  80. package/dist/scheduler/checkStatus.d.ts +2 -5
  81. package/dist/scheduler/checkStatus.d.ts.map +1 -1
  82. package/dist/scheduler/checkStatus.js +6 -11
  83. package/dist/scheduler/checkStatus.js.map +1 -1
  84. package/dist/scheduler/delivery.d.ts +79 -37
  85. package/dist/scheduler/delivery.d.ts.map +1 -1
  86. package/dist/scheduler/delivery.js +117 -68
  87. package/dist/scheduler/delivery.js.map +1 -1
  88. package/dist/scheduler/mcpSurface.d.ts +6 -2
  89. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  90. package/dist/scheduler/mcpSurface.js +39 -15
  91. package/dist/scheduler/mcpSurface.js.map +1 -1
  92. package/dist/scheduler/recurrence.d.ts +32 -0
  93. package/dist/scheduler/recurrence.d.ts.map +1 -1
  94. package/dist/scheduler/recurrence.js +56 -18
  95. package/dist/scheduler/recurrence.js.map +1 -1
  96. package/dist/scheduler/scheduleText.d.ts +7 -0
  97. package/dist/scheduler/scheduleText.d.ts.map +1 -0
  98. package/dist/scheduler/scheduleText.js +55 -0
  99. package/dist/scheduler/scheduleText.js.map +1 -0
  100. package/dist/scheduler/store.d.ts +8 -2
  101. package/dist/scheduler/store.d.ts.map +1 -1
  102. package/dist/scheduler/store.js +25 -4
  103. package/dist/scheduler/store.js.map +1 -1
  104. package/dist/scheduler/types.d.ts +4 -10
  105. package/dist/scheduler/types.d.ts.map +1 -1
  106. package/dist/scheduler/workerWatch.d.ts +24 -9
  107. package/dist/scheduler/workerWatch.d.ts.map +1 -1
  108. package/dist/scheduler/workerWatch.js +29 -11
  109. package/dist/scheduler/workerWatch.js.map +1 -1
  110. package/dist/utils/claudeUsage.d.ts +3 -0
  111. package/dist/utils/claudeUsage.d.ts.map +1 -1
  112. package/dist/utils/claudeUsage.js +8 -1
  113. package/dist/utils/claudeUsage.js.map +1 -1
  114. package/dist/utils/claudeUsageRefresher.d.ts +27 -3
  115. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
  116. package/dist/utils/claudeUsageRefresher.js +113 -14
  117. package/dist/utils/claudeUsageRefresher.js.map +1 -1
  118. package/dist/utils/forwardedMark.d.ts +54 -0
  119. package/dist/utils/forwardedMark.d.ts.map +1 -0
  120. package/dist/utils/forwardedMark.js +80 -0
  121. package/dist/utils/forwardedMark.js.map +1 -0
  122. package/dist/utils/limitHeldPrompts.d.ts +8 -2
  123. package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
  124. package/dist/utils/limitHeldPrompts.js +11 -4
  125. package/dist/utils/limitHeldPrompts.js.map +1 -1
  126. package/dist/utils/messageContext.d.ts +54 -0
  127. package/dist/utils/messageContext.d.ts.map +1 -0
  128. package/dist/utils/messageContext.js +58 -0
  129. package/dist/utils/messageContext.js.map +1 -0
  130. package/dist/utils/openCodeUsage.d.ts +10 -3
  131. package/dist/utils/openCodeUsage.d.ts.map +1 -1
  132. package/dist/utils/openCodeUsage.js +19 -5
  133. package/dist/utils/openCodeUsage.js.map +1 -1
  134. package/dist/utils/replyQuote.d.ts +11 -26
  135. package/dist/utils/replyQuote.d.ts.map +1 -1
  136. package/dist/utils/replyQuote.js +9 -31
  137. package/dist/utils/replyQuote.js.map +1 -1
  138. package/dist/utils/stripControlCharacters.d.ts +8 -0
  139. package/dist/utils/stripControlCharacters.d.ts.map +1 -0
  140. package/dist/utils/stripControlCharacters.js +16 -0
  141. package/dist/utils/stripControlCharacters.js.map +1 -0
  142. package/dist/utils/telegramError.d.ts +6 -0
  143. package/dist/utils/telegramError.d.ts.map +1 -1
  144. package/dist/utils/telegramError.js +30 -0
  145. package/dist/utils/telegramError.js.map +1 -1
  146. package/dist/utils/topicRequest.d.ts +13 -0
  147. package/dist/utils/topicRequest.d.ts.map +1 -1
  148. package/dist/utils/topicRequest.js +10 -0
  149. package/dist/utils/topicRequest.js.map +1 -1
  150. package/dist/utils/usageRefreshBudget.d.ts.map +1 -1
  151. package/dist/utils/usageRefreshBudget.js +4 -10
  152. package/dist/utils/usageRefreshBudget.js.map +1 -1
  153. package/dist/utils/waitUpTo.d.ts +8 -0
  154. package/dist/utils/waitUpTo.d.ts.map +1 -0
  155. package/dist/utils/waitUpTo.js +20 -0
  156. package/dist/utils/waitUpTo.js.map +1 -0
  157. package/package.json +1 -1
@@ -168,11 +168,12 @@ function fetchChatGptUsage(credential, options = {}) {
168
168
  parse: (body) => parseChatGptUsageResponse(body, nowMs),
169
169
  fetchImpl: options.fetchImpl,
170
170
  timeoutMs: options.timeoutMs,
171
+ signal: options.signal,
171
172
  });
172
173
  }
173
174
  /** The subscription usage readers by provider id; a provider not here shows only its auth kind. */
174
175
  exports.openCodeUsageReaders = {
175
- [exports.chatGptProviderId]: (credential) => fetchChatGptUsage(credential),
176
+ [exports.chatGptProviderId]: (credential, signal) => fetchChatGptUsage(credential, { signal }),
176
177
  };
177
178
  /**
178
179
  * @description The poller of OpenCode providers' usage. For each provider in `auth.json`: an API key or an unknown record
@@ -194,7 +195,7 @@ function createOpenCodeUsagePoller(deps) {
194
195
  return;
195
196
  log(`[usage] OpenCode ${providerId}: usage unavailable (${reason})`);
196
197
  }
197
- async function pollSubscription(providerId, credential, previous) {
198
+ async function pollSubscription(providerId, credential, previous, signal) {
198
199
  const reader = readers[providerId];
199
200
  if (reader === undefined) {
200
201
  saveIfChanged(providerId, previous, { authKind: 'subscription' });
@@ -212,7 +213,9 @@ function createOpenCodeUsagePoller(deps) {
212
213
  markStale('token expired');
213
214
  return;
214
215
  }
215
- const result = await reader(credential);
216
+ const result = await reader(credential, signal);
217
+ if (signal?.aborted)
218
+ return;
216
219
  if (!result.ok) {
217
220
  markStale(result.error);
218
221
  return;
@@ -235,7 +238,7 @@ function createOpenCodeUsagePoller(deps) {
235
238
  saveIfChanged(providerId, previous, { authKind: credential.kind });
236
239
  }
237
240
  else if (checkNeedsPoll(previous, options.maxAgeMs)) {
238
- await pollSubscription(providerId, credential, previous);
241
+ await pollSubscription(providerId, credential, previous, options.signal);
239
242
  }
240
243
  }
241
244
  catch (e) {
@@ -243,6 +246,17 @@ function createOpenCodeUsagePoller(deps) {
243
246
  }
244
247
  }));
245
248
  }
246
- return { refreshAll };
249
+ function markAllStale(reason) {
250
+ const credentials = deps.readCredentials();
251
+ if (credentials === null)
252
+ return;
253
+ for (const [providerId, credential] of Object.entries(credentials)) {
254
+ if (credential.kind !== 'subscription' || readers[providerId] === undefined)
255
+ continue;
256
+ const previous = deps.getRecord(providerId);
257
+ saveIfChanged(providerId, previous, { authKind: 'subscription', usage: (0, claudeUsage_1.markClaudeUsageSnapshotStale)(previous?.usage, reason, now()) });
258
+ }
259
+ }
260
+ return { refreshAll, markAllStale };
247
261
  }
248
262
  //# sourceMappingURL=openCodeUsage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"openCodeUsage.js","sourceRoot":"","sources":["../../src/utils/openCodeUsage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DH,4DAaC;AAGD,0DAMC;AAkCD,8DAaC;AAMD,8CAkBC;AAmCD,8DAsDC;AAhPD,uCAAyB;AACzB,+CASuB;AAEV,QAAA,oBAAoB,GAAG,4CAA4C,CAAC;AAEjF,gEAAgE;AACnD,QAAA,iBAAiB,GAAG,QAAQ,CAAC;AAc1C,oGAAoG;AACpG,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,CAAC;AAcxC,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,YA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AAC,EAAE,CAAC,CAAC;QACzI,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AACtC,CAAC"}
@@ -5,12 +5,10 @@
5
5
  * agent-active topic.
6
6
  *
7
7
  * The block is plain English (agent-facing, NOT i18n) and mirrors the
8
- * thread-context preamble in shape: the bot just prepends it to the prompt body
9
- * ({@link getPromptWithReplyQuote}) in `forwardPromptToAgent`, the single choke
10
- * point for direct texts and voice transcripts, and where a prompt leaves as
11
- * finished text: the startup buffering of both, and a file or album announcement.
12
- * It rides the per-message body (like the `/timestamps` line), NOT the
13
- * once-per-change preamble marker.
8
+ * thread-context preamble in shape: the bot prepends it to the prompt body with
9
+ * the one fold rule of `messageContext.ts` (`getPromptWithMessageContext`), next
10
+ * to the forwarded mark, in `forwardPromptToAgent` and wherever a prompt leaves
11
+ * as finished text.
14
12
  *
15
13
  * These helpers take STRUCTURAL input (no telegraf imports) so they are fully
16
14
  * unit-testable; the bridge that reads a real telegraf message lives in the
@@ -56,11 +54,18 @@ export interface ReplyQuoteSource {
56
54
  isServiceMessage: boolean;
57
55
  /** Whether the replied-to message is the bot's own (`reply_to_message.from?.id === bot.botInfo.id`). */
58
56
  fromBot: boolean;
57
+ /**
58
+ * Who first wrote the replied-to message when it was itself FORWARDED into the topic (`describeForwardedOrigin`
59
+ * of its `forward_origin`): `from` is then only who forwarded it, and the quote must not pass its words for theirs.
60
+ */
61
+ replyForwardedFrom?: string;
59
62
  }
60
63
  /** The resolved quote: the content to render plus who authored it. */
61
64
  export interface ExtractedReplyQuote {
62
65
  quotedText: string;
63
66
  fromBot: boolean;
67
+ /** Who first wrote the quoted message, when it was forwarded into the topic. */
68
+ forwardedFrom?: string;
64
69
  }
65
70
  /**
66
71
  * @description Decide whether a genuine reply carries quotable content and, if
@@ -88,24 +93,4 @@ export declare function extractReplyQuote(source: ReplyQuoteSource | undefined):
88
93
  * counts real content, not the prefixes.
89
94
  */
90
95
  export declare function buildReplyQuoteBlock(quote: ExtractedReplyQuote | null): string | null;
91
- /**
92
- * @description Lead a prompt with its reply-quote block — the ONE folding rule,
93
- * shared by the live forward (`forwardPromptToAgent`) and a prompt buffered
94
- * behind a session start, whose replay forwards the buffered text as is: a reply
95
- * made while the agent boots must reach it exactly like one made after.
96
- *
97
- * The prompt is returned unchanged when there is no block, or when it is not an
98
- * agent prompt at all:
99
- * - a slash command is a control token for the agent, which a block ahead of
100
- * it would corrupt into plain text (`isSlashCommand` classifies the user's
101
- * own text — the caller may have extended it, held prompts ride after it);
102
- * - a terminal topic's input is a shell command line, and typed into a shell
103
- * the block's `> ` lines run as redirections that overwrite a file named by
104
- * the quote's first word. A typed reply there never carries a block either.
105
- */
106
- export declare function getPromptWithReplyQuote(prompt: string, quote: {
107
- block: string | undefined;
108
- isSlashCommand: boolean;
109
- isShellInput: boolean;
110
- }): string;
111
96
  //# sourceMappingURL=replyQuote.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"replyQuote.d.ts","sourceRoot":"","sources":["../../src/utils/replyQuote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAcvC;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,oGAAoG;IACpG,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iGAAiG;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qFAAqF;IACrF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC,qCAAqC;IACrC,cAAc,CAAC,EAAE,MAAM,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,CAAC,EAAE,MAAM,CAAC;IACtB,uDAAuD;IACvD,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC,qCAAqC;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,wGAAwG;IACxG,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,sEAAsE;AACtE,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,mBAAmB,GAAG,IAAI,CAelG;AAcD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAYrF"}
@@ -6,12 +6,10 @@
6
6
  * agent-active topic.
7
7
  *
8
8
  * The block is plain English (agent-facing, NOT i18n) and mirrors the
9
- * thread-context preamble in shape: the bot just prepends it to the prompt body
10
- * ({@link getPromptWithReplyQuote}) in `forwardPromptToAgent`, the single choke
11
- * point for direct texts and voice transcripts, and where a prompt leaves as
12
- * finished text: the startup buffering of both, and a file or album announcement.
13
- * It rides the per-message body (like the `/timestamps` line), NOT the
14
- * once-per-change preamble marker.
9
+ * thread-context preamble in shape: the bot prepends it to the prompt body with
10
+ * the one fold rule of `messageContext.ts` (`getPromptWithMessageContext`), next
11
+ * to the forwarded mark, in `forwardPromptToAgent` and wherever a prompt leaves
12
+ * as finished text.
15
13
  *
16
14
  * These helpers take STRUCTURAL input (no telegraf imports) so they are fully
17
15
  * unit-testable; the bridge that reads a real telegraf message lives in the
@@ -21,7 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
19
  exports.replyQuoteMaxChars = void 0;
22
20
  exports.extractReplyQuote = extractReplyQuote;
23
21
  exports.buildReplyQuoteBlock = buildReplyQuoteBlock;
24
- exports.getPromptWithReplyQuote = getPromptWithReplyQuote;
25
22
  /**
26
23
  * Max length of the quoted content folded into the prompt. A very long replied-to
27
24
  * message (e.g. a big agent answer) would otherwise dominate the prompt; we cap
@@ -30,12 +27,12 @@ exports.getPromptWithReplyQuote = getPromptWithReplyQuote;
30
27
  exports.replyQuoteMaxChars = 4000;
31
28
  /** Header prefix of the injected block — recognisable, agent-facing English. */
32
29
  const replyQuoteHeaderPrefix = '[Replying to an earlier message · from: ';
30
+ /** Between who sent the replied-to message and who first wrote it, when it was a forward. */
31
+ const replyQuoteForwardedFromSeparator = ', forwarded from ';
33
32
  /** Marker appended when the quoted content is truncated to the cap. */
34
33
  const replyQuoteTruncationMarker = '… [truncated]';
35
34
  /** Prefix applied to every line of the quoted content (markdown blockquote). */
36
35
  const replyQuoteLinePrefix = '> ';
37
- /** Separator between the block and the prompt it leads. */
38
- const replyQuotePromptSeparator = '\n\n';
39
36
  /**
40
37
  * @description Decide whether a genuine reply carries quotable content and, if
41
38
  * so, extract it.
@@ -69,7 +66,7 @@ function extractReplyQuote(source) {
69
66
  if (!text && !attachmentLine)
70
67
  return null;
71
68
  const quotedText = [attachmentLine, text].filter((line) => !!line).join('\n');
72
- return { quotedText, fromBot: source.fromBot };
69
+ return { quotedText, fromBot: source.fromBot, ...(source.replyForwardedFrom ? { forwardedFrom: source.replyForwardedFrom } : {}) };
73
70
  }
74
71
  /**
75
72
  * @description The quote's line naming a replied-to file — `[photo]`,
@@ -95,28 +92,9 @@ function buildReplyQuoteBlock(quote) {
95
92
  if (content.length > exports.replyQuoteMaxChars) {
96
93
  content = `${content.slice(0, exports.replyQuoteMaxChars)}${replyQuoteTruncationMarker}`;
97
94
  }
98
- const header = `${replyQuoteHeaderPrefix}${quote.fromBot ? 'assistant' : 'user'}]`;
95
+ const forwardedFrom = quote.forwardedFrom ? `${replyQuoteForwardedFromSeparator}${quote.forwardedFrom}` : '';
96
+ const header = `${replyQuoteHeaderPrefix}${quote.fromBot ? 'assistant' : 'user'}${forwardedFrom}]`;
99
97
  const quotedLines = content.split('\n').map((line) => `${replyQuoteLinePrefix}${line}`);
100
98
  return [header, ...quotedLines].join('\n');
101
99
  }
102
- /**
103
- * @description Lead a prompt with its reply-quote block — the ONE folding rule,
104
- * shared by the live forward (`forwardPromptToAgent`) and a prompt buffered
105
- * behind a session start, whose replay forwards the buffered text as is: a reply
106
- * made while the agent boots must reach it exactly like one made after.
107
- *
108
- * The prompt is returned unchanged when there is no block, or when it is not an
109
- * agent prompt at all:
110
- * - a slash command is a control token for the agent, which a block ahead of
111
- * it would corrupt into plain text (`isSlashCommand` classifies the user's
112
- * own text — the caller may have extended it, held prompts ride after it);
113
- * - a terminal topic's input is a shell command line, and typed into a shell
114
- * the block's `> ` lines run as redirections that overwrite a file named by
115
- * the quote's first word. A typed reply there never carries a block either.
116
- */
117
- function getPromptWithReplyQuote(prompt, quote) {
118
- if (!quote.block || quote.isSlashCommand || quote.isShellInput)
119
- return prompt;
120
- return `${quote.block}${replyQuotePromptSeparator}${prompt}`;
121
- }
122
100
  //# sourceMappingURL=replyQuote.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"replyQuote.js","sourceRoot":"","sources":["../../src/utils/replyQuote.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAkFH,8CAeC;AAoBD,oDAWC;AAiBD,0DAMC;AArJD;;;;GAIG;AACU,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAEvC,gFAAgF;AAChF,MAAM,sBAAsB,GAAG,0CAA0C,CAAC;AAE1E,uEAAuE;AACvE,MAAM,0BAA0B,GAAG,eAAe,CAAC;AAEnD,gFAAgF;AAChF,MAAM,oBAAoB,GAAG,IAAI,CAAC;A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a,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,gCAAgC,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7G,MAAM,MAAM,GAAG,GAAG,sBAAsB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,GAAG,aAAa,GAAG,CAAC;IACnG,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,oBAAoB,GAAG,IAAI,EAAE,CAAC,CAAC;IACxF,OAAO,CAAC,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @description Text from outside the process (a runner's output, a name a stranger chose) made safe to print or to put in a
3
+ * prompt: every character a terminal could act on, or that could disguise what is shown, is taken out. Node built-ins only
4
+ * (none at all): the runner's root step, which runs from a copy of the package without `node_modules`, imports it too.
5
+ */
6
+ /** @description `text` with every character that a terminal could act on, or that could disguise what is printed, taken out; newlines and tabs stay. */
7
+ export declare function stripControlCharacters(text: string): string;
8
+ //# sourceMappingURL=stripControlCharacters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripControlCharacters.d.ts","sourceRoot":"","sources":["../../src/utils/stripControlCharacters.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wJAAwJ;AACxJ,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3D"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * @description Text from outside the process (a runner's output, a name a stranger chose) made safe to print or to put in a
4
+ * prompt: every character a terminal could act on, or that could disguise what is shown, is taken out. Node built-ins only
5
+ * (none at all): the runner's root step, which runs from a copy of the package without `node_modules`, imports it too.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.stripControlCharacters = stripControlCharacters;
9
+ /** Everything that is a control character (C0, DEL, C1 — escape sequences start with one), the bidirectional overrides and isolates, and the line and paragraph separators. */
10
+ const unsafeCharacterPattern = /[\p{Cc}\u200e\u200f\u202a-\u202e\u2066-\u2069\u2028\u2029]/gu;
11
+ const keptControlCharacters = new Set(['\n', '\t']);
12
+ /** @description `text` with every character that a terminal could act on, or that could disguise what is printed, taken out; newlines and tabs stay. */
13
+ function stripControlCharacters(text) {
14
+ return text.replace(unsafeCharacterPattern, (character) => (keptControlCharacters.has(character) ? character : ''));
15
+ }
16
+ //# sourceMappingURL=stripControlCharacters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripControlCharacters.js","sourceRoot":"","sources":["../../src/utils/stripControlCharacters.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAOH,wDAEC;AAPD,+KAA+K;AAC/K,MAAM,sBAAsB,GAAG,8DAA8D,CAAC;AAC9F,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEpD,wJAAwJ;AACxJ,SAAgB,sBAAsB,CAAC,IAAY;IACjD,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtH,CAAC"}
@@ -5,6 +5,12 @@ export declare function checkIsStaleAnswerCallbackQueryError(err: unknown): bool
5
5
  * (older than 48 hours, no right) — that message stays.
6
6
  */
7
7
  export declare function checkIsMessageNotFoundError(err: unknown): boolean;
8
+ /**
9
+ * @description Whether an error is the network's rather than a Bot API answer or a bug of ours: node-fetch's `FetchError`
10
+ * (any of its types — a system error, a timeout), a Node socket / DNS error code, or the «socket hang up» / «network timeout»
11
+ * wording. A `TypeError` from our own code, a thrown string and the like are NOT: nothing about the network can fix them.
12
+ */
13
+ export declare function checkIsNetworkError(err: unknown): boolean;
8
14
  /**
9
15
  * @description Whether a failed Bot API call is worth trying again later: Telegram never answered (a dropped connection, a
10
16
  * timeout — the error carries no Bot API answer), asked the bot to slow down (429) or failed on its side (5xx). Any other answer
@@ -1 +1 @@
1
- {"version":3,"file":"telegramError.d.ts","sourceRoot":"","sources":["../../src/utils/telegramError.ts"],"names":[],"mappings":"AAcA,wBAAgB,oCAAoC,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAS1E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIjE;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKnE"}
1
+ {"version":3,"file":"telegramError.d.ts","sourceRoot":"","sources":["../../src/utils/telegramError.ts"],"names":[],"mappings":"AAcA,wBAAgB,oCAAoC,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAS1E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIjE;AAmBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKzD;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKnE"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkIsStaleAnswerCallbackQueryError = checkIsStaleAnswerCallbackQueryError;
4
4
  exports.checkIsMessageNotFoundError = checkIsMessageNotFoundError;
5
+ exports.checkIsNetworkError = checkIsNetworkError;
5
6
  exports.checkIsRetryableTelegramError = checkIsRetryableTelegramError;
6
7
  function checkIsRecord(value) {
7
8
  return typeof value === 'object' && value !== null;
@@ -26,6 +27,35 @@ function checkIsMessageNotFoundError(err) {
26
27
  const e = err;
27
28
  return e.response?.error_code === 400 && /message to (delete|edit) not found/i.test(e.response.description ?? '');
28
29
  }
30
+ /** Node's socket and DNS error codes for a request that could not reach Telegram, or that it never answered. */
31
+ const networkErrorCodes = new Set([
32
+ 'ECONNRESET',
33
+ 'ECONNREFUSED',
34
+ 'ECONNABORTED',
35
+ 'ETIMEDOUT',
36
+ 'EPIPE',
37
+ 'EAI_AGAIN',
38
+ 'ENOTFOUND',
39
+ 'ENETUNREACH',
40
+ 'EHOSTUNREACH',
41
+ 'UND_ERR_CONNECT_TIMEOUT',
42
+ ]);
43
+ /** What node-fetch (Telegraf's HTTP client) and Node say for a connection that closed or a request that timed out. */
44
+ const networkErrorMessagePattern = /socket hang up|network timeout/i;
45
+ /**
46
+ * @description Whether an error is the network's rather than a Bot API answer or a bug of ours: node-fetch's `FetchError`
47
+ * (any of its types — a system error, a timeout), a Node socket / DNS error code, or the «socket hang up» / «network timeout»
48
+ * wording. A `TypeError` from our own code, a thrown string and the like are NOT: nothing about the network can fix them.
49
+ */
50
+ function checkIsNetworkError(err) {
51
+ if (!checkIsRecord(err))
52
+ return false;
53
+ if (err.name === 'FetchError')
54
+ return true;
55
+ if (typeof err.code === 'string' && networkErrorCodes.has(err.code))
56
+ return true;
57
+ return err instanceof Error && networkErrorMessagePattern.test(err.message);
58
+ }
29
59
  /**
30
60
  * @description Whether a failed Bot API call is worth trying again later: Telegram never answered (a dropped connection, a
31
61
  * timeout — the error carries no Bot API answer), asked the bot to slow down (429) or failed on its side (5xx). Any other answer
@@ -1 +1 @@
1
- {"version":3,"file":"telegramError.js","sourceRoot":"","sources":["../../src/utils/telegramError.ts"],"names":[],"mappings":";;AAcA,oFASC;AAOD,kEAIC;AAQD,sEAKC;AArCD,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAgB,oCAAoC,CAAC,GAAY;IAC/D,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,OAAO,GAAG,YAAY,KAAK,IAAI,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,6BAA6B,CAAC,GAAY;IACxD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,SAAS,GAAI,GAAyB,CAAC,QAAQ,EAAE,UAAU,CAAC;IAClE,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzC,OAAO,SAAS,KAAK,GAAG,IAAI,SAAS,IAAI,GAAG,CAAC;AAC/C,CAAC"}
@@ -58,4 +58,17 @@ export declare function getTopicRequestOrigin(intake: TopicRequestIntake): Reque
58
58
  * replaced — the header asks for only what this one adds.
59
59
  */
60
60
  export declare function buildTopicRequestHeader(requestId: string, source: TopicRequestSource, view: TopicView, supersededRequestIds?: readonly string[]): string;
61
+ /**
62
+ * @description The prompt a topic request keeps in the ledger (R21) — the one the bot posts AGAIN when the session never took
63
+ * the first post in: after a failed post, a restart, a usage-limit wait. `promptBody` is the message's text with its message
64
+ * context already folded in (reply quote, forwarded mark): a body kept raw would be replayed without them, and a forwarded
65
+ * message would come back as the operator's own words.
66
+ */
67
+ export declare function buildTopicRequestPrompt(input: {
68
+ requestId: string;
69
+ source: TopicRequestSource;
70
+ view: TopicView;
71
+ supersededRequestIds: readonly string[];
72
+ promptBody: string;
73
+ }): string;
61
74
  //# sourceMappingURL=topicRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"topicRequest.d.ts","sourceRoot":"","sources":["../../src/utils/topicRequest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GA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BAAkB;IACjC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,+FAA+F;AAC/F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GAAG,MAAM,CAE5E;AAYD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,GAAG,OAAO,CAE7F;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,aAAa,CAK/E;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,kBAAkB,EAC1B,IAAI,EAAE,SAAS,EACf,oBAAoB,GAAE,SAAS,MAAM,EAAO,GAC3C,MAAM,CAOR;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,IAAI,EAAE,SAAS,CAAC;IAChB,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAET"}
@@ -5,6 +5,7 @@ exports.getTopicRequesterId = getTopicRequesterId;
5
5
  exports.checkShouldOpenTopicRequest = checkShouldOpenTopicRequest;
6
6
  exports.getTopicRequestOrigin = getTopicRequestOrigin;
7
7
  exports.buildTopicRequestHeader = buildTopicRequestHeader;
8
+ exports.buildTopicRequestPrompt = buildTopicRequestPrompt;
8
9
  const requestHeader_1 = require("../requests/requestHeader");
9
10
  const requestGroup_1 = require("../requests/requestGroup");
10
11
  const topicView_1 = require("./topicView");
@@ -65,4 +66,13 @@ function buildTopicRequestHeader(requestId, source, view, supersededRequestIds =
65
66
  supersededRequestIds,
66
67
  });
67
68
  }
69
+ /**
70
+ * @description The prompt a topic request keeps in the ledger (R21) — the one the bot posts AGAIN when the session never took
71
+ * the first post in: after a failed post, a restart, a usage-limit wait. `promptBody` is the message's text with its message
72
+ * context already folded in (reply quote, forwarded mark): a body kept raw would be replayed without them, and a forwarded
73
+ * message would come back as the operator's own words.
74
+ */
75
+ function buildTopicRequestPrompt(input) {
76
+ return `${buildTopicRequestHeader(input.requestId, input.source, input.view, input.supersededRequestIds)}${input.promptBody}`;
77
+ }
68
78
  //# sourceMappingURL=topicRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"topicRequest.js","sourceRoot":"","sources":["../../src/utils/topicRequest.ts"],"names":[],"mappings":";;;AA2CA,kDAEC;AAmBD,kEAEC;AAOD,sDAKC;AASD,0DAYC;AA1FD,6DAA+D;AAC/D,2DAAqE;AAErE,2CAA0E;AAS1E,iFAAiF;AACpE,QAAA,2BAA2B,GAAG,QAAQ,CAAC;AAEpD;;;;GAIG;AACU,QAAA,qBAAqB,GAAG,WAAW,CAAC;AAajD,+FAA+F;AAC/F,SAAgB,mBAAmB,CAAC,IAAgC;IAClE,OAAO,IAAI,EAAE,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC;AAED,qEAAqE;AACrE,MAAM,8BAA8B,GAAiD;IACnF,IAAI,EAAE,yBAAyB;IAC/B,KAAK,EAAE,+BAA+B;IACtC,IAAI,EAAE,2BAA2B;IACjC,KAAK,EAAE,6BAA6B;IACpC,QAAQ,EAAE,mCAAmC;IAC7C,YAAY,EAAE,+BAA+B;CAC9C,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAAC,IAAe,EAAE,cAAuB;IAClF,OAAO,IAAA,mCAAuB,EAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,MAA0B;IAC9D,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC,cAAc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AAC,cAAc,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,MAA0B;IAC9D,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS;QACnE,UAAU,EAAE,EAAE,CAAC,mCAA2B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,wCAAyB,CAAC,EAAE,MAAM,CAAC,WAAW,EAAE;KAC9G,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,uBAAuB,CACrC,SAAiB,EACjB,MAA0B,EAC1B,IAAe,EACf,uBAA0C,EAAE;IAE5C,OAAO,IAAA,kCAAkB,EAAC;QACxB,SAAS;QACT,iBAAiB,EAAE,8BAA8B,CAAC,MAAM,CAAC;QACzD,iBAAiB,EAAE,CAAC,IAAA,8BAAkB,EAAC,IAAI,CAAC;QAC5C,oBAAoB;KACrB,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,KAMvC;IACC,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,oBAAoB,CAAC,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;AAChI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"usageRefreshBudget.d.ts","sourceRoot":"","sources":["../../src/utils/usageRefreshBudget.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAEhD;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAQxH"}
1
+ {"version":3,"file":"usageRefreshBudget.d.ts","sourceRoot":"","sources":["../../src/utils/usageRefreshBudget.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAEhD;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAExH"}
@@ -5,23 +5,17 @@ exports.refreshUsageWithinBudget = refreshUsageWithinBudget;
5
5
  /**
6
6
  * @description How long a screen that shows usage waits for the usage refresh when it OPENS. One poll is ~0.5 s; a
7
7
  * slower one — a hung endpoint runs into the fetch's own 15 s timeout — keeps going in the background and the next
8
- * render shows its result. Shared by `/limits`, `/limits_autoswitch` and a pick made while a limit wait is armed (`bot.ts`), so
9
- * none is held by a slow endpoint.
8
+ * render shows its result. Shared by `/limits`, `/limits_autoswitch`, `/accounts`, the planning of the switch a topic makes
9
+ * when it hits a usage limit and a pick made while a limit wait is armed (`bot.ts`), so none is held by a slow endpoint.
10
10
  */
11
11
  const claudeUsageRefresher_1 = require("./claudeUsageRefresher");
12
+ const waitUpTo_1 = require("./waitUpTo");
12
13
  exports.limitsUsageRefreshBudgetMs = 2_000;
13
14
  /**
14
15
  * Refresh the usage snapshots (a snapshot younger than a minute is kept — the `/accounts` freshness), waiting at most
15
16
  * {@link limitsUsageRefreshBudgetMs}: the screen is never held by a slow usage endpoint.
16
17
  */
17
18
  async function refreshUsageWithinBudget(refresh) {
18
- let timer;
19
- const budget = new Promise((resolve) => { timer = setTimeout(resolve, exports.limitsUsageRefreshBudgetMs); });
20
- try {
21
- await Promise.race([refresh({ maxAgeMs: claudeUsageRefresher_1.claudeUsageOnDemandMaxAgeMs }), budget]);
22
- }
23
- finally {
24
- clearTimeout(timer);
25
- }
19
+ await (0, waitUpTo_1.waitUpTo)(refresh({ maxAgeMs: claudeUsageRefresher_1.claudeUsageOnDemandMaxAgeMs }), exports.limitsUsageRefreshBudgetMs);
26
20
  }
27
21
  //# sourceMappingURL=usageRefreshBudget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usageRefreshBudget.js","sourceRoot":"","sources":["../../src/utils/usageRefreshBudget.ts"],"names":[],"mappings":";;;AAcA,4DAQC;AAtBD;;;;;GAKG;AACH,iEAAqE;AAExD,QAAA,0BAA0B,GAAG,KAAK,CAAC;AAEhD;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAA0D;IACvG,IAAI,KAAiC,CAAC;IACtC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,kCAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5G,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,kDAA2B,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACnF,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"usageRefreshBudget.js","sourceRoot":"","sources":["../../src/utils/usageRefreshBudget.ts"],"names":[],"mappings":";;;AAeA,4DAEC;AAjBD;;;;;GAKG;AACH,iEAAqE;AACrE,yCAAsC;AAEzB,QAAA,0BAA0B,GAAG,KAAK,CAAC;AAEhD;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAAC,OAA0D;IACvG,MAAM,IAAA,mBAAQ,EAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,kDAA2B,EAAE,CAAC,EAAE,kCAA0B,CAAC,CAAC;AACjG,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @description Wait for a task, but never longer than a budget. `true` when the task finished inside the budget (a
3
+ * failure inside it is rethrown), `false` when the budget ended first — the task is NOT cancelled, it runs on, and a
4
+ * failure of it after the budget is swallowed here (the race already holds a handler on it), so the caller that gave
5
+ * up on it never meets it again as an unhandled rejection.
6
+ */
7
+ export declare function waitUpTo(task: Promise<void>, budgetMs: number): Promise<boolean>;
8
+ //# sourceMappingURL=waitUpTo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waitUpTo.d.ts","sourceRoot":"","sources":["../../src/utils/waitUpTo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQtF"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.waitUpTo = waitUpTo;
4
+ /**
5
+ * @description Wait for a task, but never longer than a budget. `true` when the task finished inside the budget (a
6
+ * failure inside it is rethrown), `false` when the budget ended first — the task is NOT cancelled, it runs on, and a
7
+ * failure of it after the budget is swallowed here (the race already holds a handler on it), so the caller that gave
8
+ * up on it never meets it again as an unhandled rejection.
9
+ */
10
+ async function waitUpTo(task, budgetMs) {
11
+ let timer;
12
+ const budget = new Promise((resolve) => { timer = setTimeout(() => resolve(false), budgetMs); });
13
+ try {
14
+ return await Promise.race([task.then(() => true), budget]);
15
+ }
16
+ finally {
17
+ clearTimeout(timer);
18
+ }
19
+ }
20
+ //# sourceMappingURL=waitUpTo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waitUpTo.js","sourceRoot":"","sources":["../../src/utils/waitUpTo.ts"],"names":[],"mappings":";;AAMA,4BAQC;AAdD;;;;;GAKG;AACI,KAAK,UAAU,QAAQ,CAAC,IAAmB,EAAE,QAAgB;IAClE,IAAI,KAAiC,CAAC;IACtC,MAAM,MAAM,GAAG,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxG,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "charness",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "license": "MIT",
5
5
  "author": "Sergei Solo",
6
6
  "description": "Harness for running Claude Code / OpenCode agents in the cloud or on your laptop, controlled from Telegram or Jira.",