charness 4.0.1 → 4.1.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 (274) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/DEVELOPMENT.md +3 -2
  3. package/SETUP.md +34 -8
  4. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  5. package/dist/adapters/claudeCliAdapter.js +3 -2
  6. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  7. package/dist/adapters/claudeJsonStreamAdapter.d.ts +61 -5
  8. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  9. package/dist/adapters/claudeJsonStreamAdapter.js +147 -18
  10. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  11. package/dist/adapters/openCodeAdapter.d.ts +1 -0
  12. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  13. package/dist/adapters/openCodeAdapter.js +11 -0
  14. package/dist/adapters/openCodeAdapter.js.map +1 -1
  15. package/dist/bot.d.ts.map +1 -1
  16. package/dist/bot.js +430 -297
  17. package/dist/bot.js.map +1 -1
  18. package/dist/connectors/jira/answerSink.d.ts +8 -0
  19. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  20. package/dist/connectors/jira/answerSink.js +15 -0
  21. package/dist/connectors/jira/answerSink.js.map +1 -1
  22. package/dist/connectors/jira/config.d.ts +16 -0
  23. package/dist/connectors/jira/config.d.ts.map +1 -1
  24. package/dist/connectors/jira/config.js +21 -2
  25. package/dist/connectors/jira/config.js.map +1 -1
  26. package/dist/connectors/jira/connector.d.ts +10 -3
  27. package/dist/connectors/jira/connector.d.ts.map +1 -1
  28. package/dist/connectors/jira/connector.js +21 -3
  29. package/dist/connectors/jira/connector.js.map +1 -1
  30. package/dist/connectors/jira/inbound.d.ts +200 -18
  31. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  32. package/dist/connectors/jira/inbound.js +814 -43
  33. package/dist/connectors/jira/inbound.js.map +1 -1
  34. package/dist/connectors/jira/prompt.d.ts +46 -0
  35. package/dist/connectors/jira/prompt.d.ts.map +1 -1
  36. package/dist/connectors/jira/prompt.js +123 -15
  37. package/dist/connectors/jira/prompt.js.map +1 -1
  38. package/dist/connectors/jira/trigger.d.ts +27 -4
  39. package/dist/connectors/jira/trigger.d.ts.map +1 -1
  40. package/dist/connectors/jira/trigger.js +35 -1
  41. package/dist/connectors/jira/trigger.js.map +1 -1
  42. package/dist/connectors/jira/triggerLog.d.ts +60 -5
  43. package/dist/connectors/jira/triggerLog.d.ts.map +1 -1
  44. package/dist/connectors/jira/triggerLog.js +116 -7
  45. package/dist/connectors/jira/triggerLog.js.map +1 -1
  46. package/dist/connectors/telegram/answerSink.d.ts +12 -0
  47. package/dist/connectors/telegram/answerSink.d.ts.map +1 -1
  48. package/dist/connectors/telegram/answerSink.js +23 -0
  49. package/dist/connectors/telegram/answerSink.js.map +1 -1
  50. package/dist/connectors/telegram/botApiConnection.d.ts +2 -1
  51. package/dist/connectors/telegram/botApiConnection.d.ts.map +1 -1
  52. package/dist/connectors/telegram/botApiConnection.js +19 -1
  53. package/dist/connectors/telegram/botApiConnection.js.map +1 -1
  54. package/dist/connectors/telegram/commands/botCore.d.ts +13 -5
  55. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  56. package/dist/connectors/telegram/commands/runners.d.ts +29 -2
  57. package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
  58. package/dist/connectors/telegram/commands/runners.js +84 -45
  59. package/dist/connectors/telegram/commands/runners.js.map +1 -1
  60. package/dist/connectors/telegram/outbound.d.ts +1 -1
  61. package/dist/connectors/telegram/outbound.d.ts.map +1 -1
  62. package/dist/connectors/telegram/outbound.js +3 -1
  63. package/dist/connectors/telegram/outbound.js.map +1 -1
  64. package/dist/connectors/telegram/outputBacklogGlue.d.ts +1 -1
  65. package/dist/connectors/telegram/outputBacklogGlue.js +1 -1
  66. package/dist/connectors/telegram/outputFlushPlan.d.ts +23 -8
  67. package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -1
  68. package/dist/connectors/telegram/outputFlushPlan.js +22 -13
  69. package/dist/connectors/telegram/outputFlushPlan.js.map +1 -1
  70. package/dist/connectors/telegram/pinnedNoticeSlot.d.ts +31 -0
  71. package/dist/connectors/telegram/pinnedNoticeSlot.d.ts.map +1 -0
  72. package/dist/connectors/telegram/pinnedNoticeSlot.js +43 -0
  73. package/dist/connectors/telegram/pinnedNoticeSlot.js.map +1 -0
  74. package/dist/connectors/telegram/sendOutcome.d.ts +50 -0
  75. package/dist/connectors/telegram/sendOutcome.d.ts.map +1 -0
  76. package/dist/connectors/telegram/sendOutcome.js +49 -0
  77. package/dist/connectors/telegram/sendOutcome.js.map +1 -0
  78. package/dist/connectors/telegram/telegramFailureRetry.d.ts +17 -0
  79. package/dist/connectors/telegram/telegramFailureRetry.d.ts.map +1 -0
  80. package/dist/connectors/telegram/telegramFailureRetry.js +29 -0
  81. package/dist/connectors/telegram/telegramFailureRetry.js.map +1 -0
  82. package/dist/connectors/telegram/unpinMessages.d.ts +1 -1
  83. package/dist/connectors/telegram/unpinMessages.d.ts.map +1 -1
  84. package/dist/connectors/telegram/unpinMessages.js +3 -18
  85. package/dist/connectors/telegram/unpinMessages.js.map +1 -1
  86. package/dist/hooks/claudeSkillsRestoreHook.d.ts +105 -0
  87. package/dist/hooks/claudeSkillsRestoreHook.d.ts.map +1 -0
  88. package/dist/hooks/claudeSkillsRestoreHook.js +276 -0
  89. package/dist/hooks/claudeSkillsRestoreHook.js.map +1 -0
  90. package/dist/i18n/de.d.ts.map +1 -1
  91. package/dist/i18n/de.js +4 -0
  92. package/dist/i18n/de.js.map +1 -1
  93. package/dist/i18n/en.d.ts.map +1 -1
  94. package/dist/i18n/en.js +4 -0
  95. package/dist/i18n/en.js.map +1 -1
  96. package/dist/i18n/es.d.ts.map +1 -1
  97. package/dist/i18n/es.js +4 -0
  98. package/dist/i18n/es.js.map +1 -1
  99. package/dist/i18n/fr.d.ts.map +1 -1
  100. package/dist/i18n/fr.js +4 -0
  101. package/dist/i18n/fr.js.map +1 -1
  102. package/dist/i18n/hi.d.ts.map +1 -1
  103. package/dist/i18n/hi.js +4 -0
  104. package/dist/i18n/hi.js.map +1 -1
  105. package/dist/i18n/ja.d.ts.map +1 -1
  106. package/dist/i18n/ja.js +4 -0
  107. package/dist/i18n/ja.js.map +1 -1
  108. package/dist/i18n/ka.d.ts.map +1 -1
  109. package/dist/i18n/ka.js +4 -0
  110. package/dist/i18n/ka.js.map +1 -1
  111. package/dist/i18n/pt.d.ts.map +1 -1
  112. package/dist/i18n/pt.js +4 -0
  113. package/dist/i18n/pt.js.map +1 -1
  114. package/dist/i18n/ru.d.ts.map +1 -1
  115. package/dist/i18n/ru.js +4 -0
  116. package/dist/i18n/ru.js.map +1 -1
  117. package/dist/i18n/uk.d.ts.map +1 -1
  118. package/dist/i18n/uk.js +4 -0
  119. package/dist/i18n/uk.js.map +1 -1
  120. package/dist/i18n/uz.d.ts.map +1 -1
  121. package/dist/i18n/uz.js +4 -0
  122. package/dist/i18n/uz.js.map +1 -1
  123. package/dist/i18n/zh.d.ts.map +1 -1
  124. package/dist/i18n/zh.js +4 -0
  125. package/dist/i18n/zh.js.map +1 -1
  126. package/dist/i18n.d.ts.map +1 -1
  127. package/dist/i18n.js +2 -1
  128. package/dist/i18n.js.map +1 -1
  129. package/dist/platform/outbound.d.ts +4 -1
  130. package/dist/platform/outbound.d.ts.map +1 -1
  131. package/dist/platform/outbound.js.map +1 -1
  132. package/dist/rateLimiter.d.ts +33 -1
  133. package/dist/rateLimiter.d.ts.map +1 -1
  134. package/dist/rateLimiter.js +91 -5
  135. package/dist/rateLimiter.js.map +1 -1
  136. package/dist/requests/requestHeader.d.ts.map +1 -1
  137. package/dist/requests/requestHeader.js +1 -0
  138. package/dist/requests/requestHeader.js.map +1 -1
  139. package/dist/requests/types.d.ts +4 -1
  140. package/dist/requests/types.d.ts.map +1 -1
  141. package/dist/requests/wakeUpEngine.d.ts +31 -1
  142. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  143. package/dist/requests/wakeUpEngine.js +94 -2
  144. package/dist/requests/wakeUpEngine.js.map +1 -1
  145. package/dist/requests/wakeUpRules.d.ts +7 -0
  146. package/dist/requests/wakeUpRules.d.ts.map +1 -1
  147. package/dist/requests/wakeUpRules.js +14 -0
  148. package/dist/requests/wakeUpRules.js.map +1 -1
  149. package/dist/runnerUtility/pueueDaemon.d.ts +7 -13
  150. package/dist/runnerUtility/pueueDaemon.d.ts.map +1 -1
  151. package/dist/runnerUtility/pueueDaemon.js +8 -27
  152. package/dist/runnerUtility/pueueDaemon.js.map +1 -1
  153. package/dist/scheduler/engine.d.ts +17 -4
  154. package/dist/scheduler/engine.d.ts.map +1 -1
  155. package/dist/scheduler/engine.js +55 -10
  156. package/dist/scheduler/engine.js.map +1 -1
  157. package/dist/scheduler/mcpBoot.d.ts +6 -2
  158. package/dist/scheduler/mcpBoot.d.ts.map +1 -1
  159. package/dist/scheduler/mcpBoot.js +7 -1
  160. package/dist/scheduler/mcpBoot.js.map +1 -1
  161. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  162. package/dist/scheduler/mcpSurface.js +18 -9
  163. package/dist/scheduler/mcpSurface.js.map +1 -1
  164. package/dist/selfUpdate/selfCheck.d.ts.map +1 -1
  165. package/dist/selfUpdate/selfCheck.js +1 -1
  166. package/dist/selfUpdate/selfCheck.js.map +1 -1
  167. package/dist/sendErrorClassifier.d.ts +6 -0
  168. package/dist/sendErrorClassifier.d.ts.map +1 -1
  169. package/dist/sendErrorClassifier.js +9 -0
  170. package/dist/sendErrorClassifier.js.map +1 -1
  171. package/dist/startupPromptBuffer.d.ts +8 -8
  172. package/dist/startupPromptBuffer.d.ts.map +1 -1
  173. package/dist/startupPromptBuffer.js +7 -5
  174. package/dist/startupPromptBuffer.js.map +1 -1
  175. package/dist/testTimings.d.ts +6 -3
  176. package/dist/testTimings.d.ts.map +1 -1
  177. package/dist/testTimings.js +7 -2
  178. package/dist/testTimings.js.map +1 -1
  179. package/dist/threadRouting.d.ts +23 -0
  180. package/dist/threadRouting.d.ts.map +1 -1
  181. package/dist/threadRouting.js +28 -0
  182. package/dist/threadRouting.js.map +1 -1
  183. package/dist/trackers/taskAgentSlots.d.ts +42 -3
  184. package/dist/trackers/taskAgentSlots.d.ts.map +1 -1
  185. package/dist/trackers/taskAgentSlots.js +31 -11
  186. package/dist/trackers/taskAgentSlots.js.map +1 -1
  187. package/dist/types.d.ts +16 -0
  188. package/dist/types.d.ts.map +1 -1
  189. package/dist/utils/agentPlugin.d.ts +7 -0
  190. package/dist/utils/agentPlugin.d.ts.map +1 -1
  191. package/dist/utils/agentPlugin.js +12 -0
  192. package/dist/utils/agentPlugin.js.map +1 -1
  193. package/dist/utils/claudeCompactHook.d.ts +73 -10
  194. package/dist/utils/claudeCompactHook.d.ts.map +1 -1
  195. package/dist/utils/claudeCompactHook.js +96 -17
  196. package/dist/utils/claudeCompactHook.js.map +1 -1
  197. package/dist/utils/claudeProfiles.d.ts +8 -0
  198. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  199. package/dist/utils/claudeProfiles.js +12 -2
  200. package/dist/utils/claudeProfiles.js.map +1 -1
  201. package/dist/utils/claudeTranscriptEpoch.d.ts +15 -0
  202. package/dist/utils/claudeTranscriptEpoch.d.ts.map +1 -0
  203. package/dist/utils/claudeTranscriptEpoch.js +120 -0
  204. package/dist/utils/claudeTranscriptEpoch.js.map +1 -0
  205. package/dist/utils/clearStatusCoalescer.d.ts +24 -0
  206. package/dist/utils/clearStatusCoalescer.d.ts.map +1 -0
  207. package/dist/utils/clearStatusCoalescer.js +25 -0
  208. package/dist/utils/clearStatusCoalescer.js.map +1 -0
  209. package/dist/utils/compactOnIdle.d.ts +91 -34
  210. package/dist/utils/compactOnIdle.d.ts.map +1 -1
  211. package/dist/utils/compactOnIdle.js +149 -31
  212. package/dist/utils/compactOnIdle.js.map +1 -1
  213. package/dist/utils/fileSendPlan.d.ts +30 -8
  214. package/dist/utils/fileSendPlan.d.ts.map +1 -1
  215. package/dist/utils/fileSendPlan.js +37 -12
  216. package/dist/utils/fileSendPlan.js.map +1 -1
  217. package/dist/utils/fileSendService.d.ts +1 -1
  218. package/dist/utils/fileSendService.d.ts.map +1 -1
  219. package/dist/utils/fileSendService.js +9 -1
  220. package/dist/utils/fileSendService.js.map +1 -1
  221. package/dist/utils/groupOutputBacklog.d.ts +90 -0
  222. package/dist/utils/groupOutputBacklog.d.ts.map +1 -0
  223. package/dist/utils/groupOutputBacklog.js +134 -0
  224. package/dist/utils/groupOutputBacklog.js.map +1 -0
  225. package/dist/utils/imageDimensions.d.ts +32 -0
  226. package/dist/utils/imageDimensions.d.ts.map +1 -0
  227. package/dist/utils/imageDimensions.js +181 -0
  228. package/dist/utils/imageDimensions.js.map +1 -0
  229. package/dist/utils/jsonStreamHost.d.ts +35 -9
  230. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  231. package/dist/utils/jsonStreamHost.js +59 -16
  232. package/dist/utils/jsonStreamHost.js.map +1 -1
  233. package/dist/utils/lostWork.d.ts +8 -2
  234. package/dist/utils/lostWork.d.ts.map +1 -1
  235. package/dist/utils/lostWork.js +9 -5
  236. package/dist/utils/lostWork.js.map +1 -1
  237. package/dist/utils/messageSendService.d.ts +26 -3
  238. package/dist/utils/messageSendService.d.ts.map +1 -1
  239. package/dist/utils/messageSendService.js +35 -3
  240. package/dist/utils/messageSendService.js.map +1 -1
  241. package/dist/utils/openCodeCompactPlugin.d.ts +33 -0
  242. package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -1
  243. package/dist/utils/openCodeCompactPlugin.js +192 -1
  244. package/dist/utils/openCodeCompactPlugin.js.map +1 -1
  245. package/dist/utils/promptDelivery.d.ts +11 -2
  246. package/dist/utils/promptDelivery.d.ts.map +1 -1
  247. package/dist/utils/promptDelivery.js +3 -3
  248. package/dist/utils/promptDelivery.js.map +1 -1
  249. package/dist/utils/skillsRestore.d.ts +235 -0
  250. package/dist/utils/skillsRestore.d.ts.map +1 -0
  251. package/dist/utils/skillsRestore.js +515 -0
  252. package/dist/utils/skillsRestore.js.map +1 -0
  253. package/dist/utils/statusFlushDecision.js +1 -1
  254. package/dist/utils/streamedCompactionSummary.d.ts +4 -4
  255. package/dist/utils/streamedCompactionSummary.js +5 -5
  256. package/dist/utils/streamedCompactionSummary.js.map +1 -1
  257. package/dist/utils/streamedOutputLanding.d.ts +14 -0
  258. package/dist/utils/streamedOutputLanding.d.ts.map +1 -0
  259. package/dist/utils/streamedOutputLanding.js +45 -0
  260. package/dist/utils/streamedOutputLanding.js.map +1 -0
  261. package/dist/utils/typingLoopBackstop.d.ts +8 -7
  262. package/dist/utils/typingLoopBackstop.d.ts.map +1 -1
  263. package/dist/utils/typingLoopBackstop.js +6 -5
  264. package/dist/utils/typingLoopBackstop.js.map +1 -1
  265. package/npm-shrinkwrap.json +2 -2
  266. package/package.json +1 -1
  267. package/dist/utils/clearThreadOutputQueues.d.ts +0 -44
  268. package/dist/utils/clearThreadOutputQueues.d.ts.map +0 -1
  269. package/dist/utils/clearThreadOutputQueues.js +0 -39
  270. package/dist/utils/clearThreadOutputQueues.js.map +0 -1
  271. package/dist/utils/groupFinalizePlan.d.ts +0 -36
  272. package/dist/utils/groupFinalizePlan.d.ts.map +0 -1
  273. package/dist/utils/groupFinalizePlan.js +0 -31
  274. package/dist/utils/groupFinalizePlan.js.map +0 -1
@@ -39,7 +39,9 @@ export type DiscreteMessageItem = string | {
39
39
  * attempted but did not land (a partial delivery stays `ok`), so a caller can
40
40
  * tell a partial delivery from a full one without parsing `summary`.
41
41
  * `sentMessageIds` are the TEXT messages that landed, in order — what a caller
42
- * pins or edits afterwards (an answer's pin, S8); attachments are not listed.
42
+ * pins or edits afterwards (an answer's pin, S8); attachments are not listed. A
43
+ * batch that ended on a delivery of unknown outcome (`deliveryUnknown`) lists the
44
+ * ones that landed before it.
43
45
  */
44
46
  export type SendMessagesToThreadResult = {
45
47
  ok: true;
@@ -53,6 +55,7 @@ export type SendMessagesToThreadResult = {
53
55
  ok: false;
54
56
  kind: 'deliveryUnknown';
55
57
  error: string;
58
+ sentMessageIds: number[];
56
59
  };
57
60
  export type SendMessagesToThread = (threadKey: string, args: SendMessagesToThreadOptions) => Promise<SendMessagesToThreadResult>;
58
61
  export interface SendMessagesToThreadOptions {
@@ -78,6 +81,13 @@ export interface SendMessagesToThreadOptions {
78
81
  * topic with notifications).
79
82
  */
80
83
  export declare const maxDiscreteMessages = 50;
84
+ /**
85
+ * @description A text message whose delivery outcome is unknown: the platform did not answer within its deadline, so it may or
86
+ * may not be in the topic. `sendChunk` throws it; the batch ends as `deliveryUnknown`, and the message is never sent again.
87
+ */
88
+ export declare class MessageDeliveryUnknownError extends Error {
89
+ constructor();
90
+ }
81
91
  export interface SendMessagesToThreadDeps<TTarget> {
82
92
  /** Map the scope-resolved thread key string to the concrete send target. */
83
93
  resolveTarget(threadKey: string): {
@@ -91,7 +101,8 @@ export interface SendMessagesToThreadDeps<TTarget> {
91
101
  * Send ONE already-split chunk as its own permanent message; resolves the sent
92
102
  * message id, `null` when it did not land. The caller wires this to the bot's
93
103
  * paced HTML-with-plain-fallback send so ordering / rate-limiting / `/clear`
94
- * tracking are reused.
104
+ * tracking are reused. Throws {@link MessageDeliveryUnknownError} when the
105
+ * outcome is unknown (it must not be sent again).
95
106
  */
96
107
  sendChunk(target: TTarget, chunk: string, signal?: AbortSignal): Promise<number | null>;
97
108
  /**
@@ -111,6 +122,14 @@ export interface SendMessagesToThreadDeps<TTarget> {
111
122
  maxMessageLength: number;
112
123
  /** Rendered-length measure so an over-cap RENDERED message is split like normal output. */
113
124
  measureRendered(chunk: string): number;
125
+ /**
126
+ * Land what the agent streamed before this call into the topic — the text its backend still batches and the output the topic
127
+ * still debounces or is sending — so the messages of this call are posted BELOW it. The agent writes its text, then calls the
128
+ * tool: without this the text, held back for a moment, would appear under the messages it led up to. A landing that fails is
129
+ * logged and never holds the messages back, and one that does not end within `streamedOutputLandingLimitMs` is given up on:
130
+ * a send that hangs must not hold the agent's tool call.
131
+ */
132
+ landStreamedOutput(target: TTarget): Promise<void>;
114
133
  }
115
134
  /**
116
135
  * @description Build the discrete-message sender. Each item is delivered as its
@@ -123,6 +142,9 @@ export interface SendMessagesToThreadDeps<TTarget> {
123
142
  * and letting that escape hid how many messages had already landed (the agent's
124
143
  * natural retry then posted them twice).
125
144
  *
145
+ * The agent's streamed text lands first ({@link SendMessagesToThreadDeps.landStreamedOutput}): the messages are the last thing the
146
+ * agent has written when they are posted, so they are posted last — the answer of `answer_request` rides this sender too.
147
+ *
126
148
  * Items are validated up front (an all-empty object → error, nothing sent) so
127
149
  * the service mirrors the MCP schema's all-or-nothing rejection. Failure is NOT
128
150
  * swallowed: if every send failed the result is an ERROR (with any attachment
@@ -132,7 +154,8 @@ export interface SendMessagesToThreadDeps<TTarget> {
132
154
  * attachment kinds taken from what the file pipeline reports it SENT, never from
133
155
  * the extension. An attachment whose delivery outcome is unknown terminates the
134
156
  * batch with a `deliveryUnknown` result so the agent does not blindly retry
135
- * (mirrors `send_file_to_user`).
157
+ * (mirrors `send_file_to_user`); so does a text message whose outcome is unknown
158
+ * ({@link MessageDeliveryUnknownError}).
136
159
  */
137
160
  export declare function createSendMessagesToThread<TTarget>(deps: SendMessagesToThreadDeps<TTarget>): SendMessagesToThread;
138
161
  //# sourceMappingURL=messageSendService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messageSendService.d.ts","sourceRoot":"","sources":["../../src/utils/messageSendService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,mBAAmB,CAAC;AAGpF;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAC3B,MAAM,GACN;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC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O,EAChD,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,GACtC,oBAAoB,CA0GtB"}
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.maxDiscreteMessages = void 0;
3
+ exports.MessageDeliveryUnknownError = exports.maxDiscreteMessages = void 0;
4
4
  exports.createSendMessagesToThread = createSendMessagesToThread;
5
5
  const utils_1 = require("../utils");
6
+ const streamedOutputLanding_1 = require("./streamedOutputLanding");
6
7
  const sentKindsSummary_1 = require("./sentKindsSummary");
7
8
  /**
8
9
  * Upper bound on how many discrete messages one call may deliver. A per-item
@@ -11,6 +12,17 @@ const sentKindsSummary_1 = require("./sentKindsSummary");
11
12
  * topic with notifications).
12
13
  */
13
14
  exports.maxDiscreteMessages = 50;
15
+ /**
16
+ * @description A text message whose delivery outcome is unknown: the platform did not answer within its deadline, so it may or
17
+ * may not be in the topic. `sendChunk` throws it; the batch ends as `deliveryUnknown`, and the message is never sent again.
18
+ */
19
+ class MessageDeliveryUnknownError extends Error {
20
+ constructor() {
21
+ super('the platform did not confirm the message in time; it may or may not be in the topic');
22
+ this.name = 'MessageDeliveryUnknownError';
23
+ }
24
+ }
25
+ exports.MessageDeliveryUnknownError = MessageDeliveryUnknownError;
14
26
  /** Trim a value and report whether anything non-blank remains. */
15
27
  function getNonBlank(value) {
16
28
  if (value === undefined)
@@ -66,6 +78,9 @@ function buildCancelledResult(landed) {
66
78
  * and letting that escape hid how many messages had already landed (the agent's
67
79
  * natural retry then posted them twice).
68
80
  *
81
+ * The agent's streamed text lands first ({@link SendMessagesToThreadDeps.landStreamedOutput}): the messages are the last thing the
82
+ * agent has written when they are posted, so they are posted last — the answer of `answer_request` rides this sender too.
83
+ *
69
84
  * Items are validated up front (an all-empty object → error, nothing sent) so
70
85
  * the service mirrors the MCP schema's all-or-nothing rejection. Failure is NOT
71
86
  * swallowed: if every send failed the result is an ERROR (with any attachment
@@ -75,7 +90,8 @@ function buildCancelledResult(landed) {
75
90
  * attachment kinds taken from what the file pipeline reports it SENT, never from
76
91
  * the extension. An attachment whose delivery outcome is unknown terminates the
77
92
  * batch with a `deliveryUnknown` result so the agent does not blindly retry
78
- * (mirrors `send_file_to_user`).
93
+ * (mirrors `send_file_to_user`); so does a text message whose outcome is unknown
94
+ * ({@link MessageDeliveryUnknownError}).
79
95
  */
80
96
  function createSendMessagesToThread(deps) {
81
97
  return async (threadKey, { messages, authorizedWorkDir, signal }) => {
@@ -90,6 +106,7 @@ function createSendMessagesToThread(deps) {
90
106
  if (!resolved.ok)
91
107
  return { ok: false, error: resolved.error };
92
108
  const { target } = resolved;
109
+ await (0, streamedOutputLanding_1.landStreamedOutputWithinLimit)(() => deps.landStreamedOutput(target), threadKey);
93
110
  let attempted = 0;
94
111
  let landed = 0;
95
112
  const deliveredKinds = [];
@@ -135,6 +152,7 @@ function createSendMessagesToThread(deps) {
135
152
  kind: 'deliveryUnknown',
136
153
  error: `Delivered ${formatMessageCount(landed)} before an attachment's delivery ` +
137
154
  `outcome became unknown: ${fileResult.error}`,
155
+ sentMessageIds,
138
156
  };
139
157
  }
140
158
  else {
@@ -145,7 +163,21 @@ function createSendMessagesToThread(deps) {
145
163
  const chunks = deps.splitMessage(item.text, deps.maxMessageLength, deps.measureRendered);
146
164
  for (const chunk of chunks) {
147
165
  attempted += 1;
148
- const messageId = await deps.sendChunk(target, chunk, signal);
166
+ let messageId;
167
+ try {
168
+ messageId = await deps.sendChunk(target, chunk, signal);
169
+ }
170
+ catch (error) {
171
+ if (!(error instanceof MessageDeliveryUnknownError))
172
+ throw error;
173
+ // Like an attachment of unknown fate: the batch ends here, and the caller is told not to send it again.
174
+ return {
175
+ ok: false,
176
+ kind: 'deliveryUnknown',
177
+ error: `Delivered ${formatMessageCount(landed)} before a message's delivery outcome became unknown: ${error.message}`,
178
+ sentMessageIds,
179
+ };
180
+ }
149
181
  if (messageId === null)
150
182
  continue;
151
183
  landed += 1;
@@ -1 +1 @@
1
- {"version":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AAC,CAAC;gBAC5B,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QAED,MAAM,qBAAqB,GACzB,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,uBAAuB,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAE3F,IAAI,SAAS,GAAG,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YAClC,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EACH,2EAA2E;oBAC3E,qBAAqB;aACxB,CAAC;QACJ,CAAC;QACD,MAAM,oBAAoB,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAA,kCAAe,EAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtF,MAAM,OAAO,GACX,CAAC,MAAM,KAAK,SAAS;YACnB,CAAC,CAAC,aAAa,kBAAkB,CAAC,MAAM,CAAC,GAAG,oBAAoB,GAAG;YACnE,CAAC,CAAC,aAAa,MAAM,OAAO,SAAS,cAAc,SAAS,GAAG,MAAM,mBAAmB,oBAAoB,GAAG,CAAC;YAClH,qBAAqB,CAAC;QACxB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC;IACrF,CAAC,CAAC;AACJ,CAAC"}
@@ -41,6 +41,22 @@
41
41
  * therefore leaves the resume guidance out of its instruction when the folder's
42
42
  * instance has the CURRENT plugin ({@link checkHasOpenCodeCompactPlugin} over
43
43
  * `GET /config`), and keeps it otherwise.
44
+ *
45
+ * The same plugin gives a session its skills back after every compaction (plan `2026-11-12-skills-reload-after-compaction`,
46
+ * S4): nothing reloads a skill there by itself, so the summary used to drop its text entirely. Its
47
+ * `experimental.chat.messages.transform` hook runs before every model request of the session's loop (measured on the fork
48
+ * build: the overflow compaction's synthetic "Continue…" request, the first request after a manual compaction and after a
49
+ * server restart all carried the part it added) and over the in-memory list only — nothing it adds is stored, sent over SSE
50
+ * or shown. Once the list holds a finished summary it adds ONE synthetic text part, the restore ({@link
51
+ * buildOpenCodeCompactPluginSource}), to the compaction's own user message — right before the summary, a fixed place, so
52
+ * every later request starts the same and the prompt cache holds. Within one turn the fork converts a message once and
53
+ * reuses that while the message IDS stay an unchanged prefix (`appendOnlyModelMessages`, verified in the fork's
54
+ * `session/prompt.ts`: the snapshot starts over only on a compaction, a sub-task and an overflow): a restore rebuilt in the
55
+ * same turn — the lookups of the first one did not answer in time — would never reach the provider. So the message the part
56
+ * rides on carries an id tagged with the restore's revision (in memory only; the provider never sees message ids): a new
57
+ * text, a new id, a fresh conversion; the same text, the same id, the same prefix. The compaction's own request runs the hook too, but
58
+ * the fork hides the earlier summaries from it (measured on the first and on a second compaction), so it holds none and is
59
+ * left as it is.
44
60
  */
45
61
  /** OpenCode requires a path plugin to export an id. */
46
62
  export declare const openCodeCompactPluginId = "charness-compaction";
@@ -65,6 +81,11 @@ export declare function getOpenCodeCompactPluginContext(isWithInstructionGaps: b
65
81
  * time means ON, like one that fails: the section is asked for, as before the switch.
66
82
  */
67
83
  export declare const openCodeAncestryLookupTimeoutMs = 2000;
84
+ /**
85
+ * How long the restore waits for the session's stored history: longer than the other lookups, since a long session's whole
86
+ * history is a big answer and the read runs once per compaction (a whole restore is kept for the summary's later requests).
87
+ */
88
+ export declare const openCodeHistoryLookupTimeoutMs = 10000;
68
89
  /**
69
90
  * @description The plugin module source: a v1 plugin (`default` export with `id` + `server`). Before a compaction it looks for
70
91
  * the flag the bot keeps for the session (`utils/compactSelfReviewFlags.ts`): present ⇒ `/compact_self_review` is off for the
@@ -76,6 +97,18 @@ export declare const openCodeAncestryLookupTimeoutMs = 2000;
76
97
  * {@link maxSessionAncestryDepth} levels: a topic's sub-agents follow the topic. A folder with no flag in it at all costs no
77
98
  * request. A session id that is not a plain id, a lookup that fails or is not answered within
78
99
  * {@link openCodeAncestryLookupTimeoutMs}, or any read failure means ON: the section is asked for, as before the switch.
100
+ *
101
+ * Before every model request (`experimental.chat.messages.transform`) it gives the skills back once the list holds a finished
102
+ * summary: the skills of the session's stored history (`client.session.messages`, every compaction so far) and of the
103
+ * summary's block, the server's current text of each (`GET /skill`; the plugin's client is the v1 SDK, which has no method for
104
+ * it, so the request goes through its inner client, which carries the folder and the password — measured on the fork build),
105
+ * a skill whose call is already after the summary only named, a name only the block holds (with the history known) given a
106
+ * "load it" line. A restore whose lookups both answered is kept for the summary, so every later request gets the same text;
107
+ * one that is not whole (a lookup failed or timed out) serves its request only, is logged to the server log once per summary,
108
+ * and the next request asks again. The history waits up to {@link openCodeHistoryLookupTimeoutMs}, the skill list up to
109
+ * {@link openCodeAncestryLookupTimeoutMs}: a history that does not come is replaced by the calls the list itself holds, a
110
+ * skill list that does not come leaves "load it with the skill tool" lines. Should the SDK's inner client be gone, the skill
111
+ * list is fetched from the server directly (logged once). Nothing ever throws out of it or holds the request longer.
79
112
  */
80
113
  export declare function buildOpenCodeCompactPluginSource(input: {
81
114
  context: string;
@@ -1 +1 @@
1
- {"version":3,"file":"openCodeCompactPlugin.d.ts","sourceRoot":"","sources":["../../src/utils/openCodeCompactPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAUH,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAW7D;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,+BAA+B,CAAC;AAChF,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AAEvE;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,qBAAqB,EAAE,OAAO,GAAG,MAAM,CAEtF;AASD;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,OAAO,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE;IAAE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H,wBAAgB,+BAA+B,CAAC,qBAAqB,EAAE,OAAO,GAAG,MAAM,CAEtF;AASD;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,OAAO,CAAC;AAQpD;;;GAGG;AACH,eAAO,MAAM,8BAA8B,QAAS,CAAC;AAmBrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,6BAA6B,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAwL1H;AAUD;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED,oHAAoH;AACpH,eAAO,MAAM,6BAA6B,QAA8E,CAAC;AAEzH,6GAA6G;AAC7G,wBAAgB,8BAA8B,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAG7E;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAM3E;AAED;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;AAErE;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;CACxB,GAAG,uBAAuB,CAG1B;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAKhF;AAED,uDAAuD;AACvD,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAmD5E;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,GAAE,MAAoD,GAC9D,0BAA0B,CAwB5B"}
@@ -42,12 +42,28 @@
42
42
  * therefore leaves the resume guidance out of its instruction when the folder's
43
43
  * instance has the CURRENT plugin ({@link checkHasOpenCodeCompactPlugin} over
44
44
  * `GET /config`), and keeps it otherwise.
45
+ *
46
+ * The same plugin gives a session its skills back after every compaction (plan `2026-11-12-skills-reload-after-compaction`,
47
+ * S4): nothing reloads a skill there by itself, so the summary used to drop its text entirely. Its
48
+ * `experimental.chat.messages.transform` hook runs before every model request of the session's loop (measured on the fork
49
+ * build: the overflow compaction's synthetic "Continue…" request, the first request after a manual compaction and after a
50
+ * server restart all carried the part it added) and over the in-memory list only — nothing it adds is stored, sent over SSE
51
+ * or shown. Once the list holds a finished summary it adds ONE synthetic text part, the restore ({@link
52
+ * buildOpenCodeCompactPluginSource}), to the compaction's own user message — right before the summary, a fixed place, so
53
+ * every later request starts the same and the prompt cache holds. Within one turn the fork converts a message once and
54
+ * reuses that while the message IDS stay an unchanged prefix (`appendOnlyModelMessages`, verified in the fork's
55
+ * `session/prompt.ts`: the snapshot starts over only on a compaction, a sub-task and an overflow): a restore rebuilt in the
56
+ * same turn — the lookups of the first one did not answer in time — would never reach the provider. So the message the part
57
+ * rides on carries an id tagged with the restore's revision (in memory only; the provider never sees message ids): a new
58
+ * text, a new id, a fresh conversion; the same text, the same id, the same prefix. The compaction's own request runs the hook too, but
59
+ * the fork hides the earlier summaries from it (measured on the first and on a second compaction), so it holds none and is
60
+ * left as it is.
45
61
  */
46
62
  var __importDefault = (this && this.__importDefault) || function (mod) {
47
63
  return (mod && mod.__esModule) ? mod : { "default": mod };
48
64
  };
49
65
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.openCodeCompactPluginFileName = exports.openCodeAncestryLookupTimeoutMs = exports.legacyOpenCodeCompactPluginId = exports.legacyOpenCodeCompactPluginFileName = exports.openCodeCompactPluginId = void 0;
66
+ exports.openCodeCompactPluginFileName = exports.openCodeHistoryLookupTimeoutMs = exports.openCodeAncestryLookupTimeoutMs = exports.legacyOpenCodeCompactPluginId = exports.legacyOpenCodeCompactPluginFileName = exports.openCodeCompactPluginId = void 0;
51
67
  exports.getOpenCodeCompactPluginContext = getOpenCodeCompactPluginContext;
52
68
  exports.buildOpenCodeCompactPluginSource = buildOpenCodeCompactPluginSource;
53
69
  exports.getOpenCodeCompactPluginFileName = getOpenCodeCompactPluginFileName;
@@ -61,6 +77,7 @@ const fs_1 = __importDefault(require("fs"));
61
77
  const os_1 = __importDefault(require("os"));
62
78
  const path_1 = __importDefault(require("path"));
63
79
  const compactOnIdle_1 = require("./compactOnIdle");
80
+ const skillsRestore_1 = require("./skillsRestore");
64
81
  const compactSelfReviewFlags_1 = require("./compactSelfReviewFlags");
65
82
  const legacyNames_1 = require("../legacyNames");
66
83
  /** OpenCode requires a path plugin to export an id. */
@@ -100,6 +117,31 @@ const maxSessionAncestryDepth = 8;
100
117
  * time means ON, like one that fails: the section is asked for, as before the switch.
101
118
  */
102
119
  exports.openCodeAncestryLookupTimeoutMs = 2000;
120
+ /** The id of the part the restore adds: one per message, so a list the hook sees twice never gets two. */
121
+ const skillsRestorePartId = 'prt_charness_skills_restore';
122
+ /** How many sessions' restores a plugin instance keeps (one per summary): a long-lived server must not grow without end. */
123
+ const maxCachedSkillsRestores = 64;
124
+ /**
125
+ * How long the restore waits for the session's stored history: longer than the other lookups, since a long session's whole
126
+ * history is a big answer and the read runs once per compaction (a whole restore is kept for the summary's later requests).
127
+ */
128
+ exports.openCodeHistoryLookupTimeoutMs = 10_000;
129
+ /**
130
+ * The functions of the restore the plugin carries as source (`toString()`): the bot's own, written self-contained so that
131
+ * the plugin and the bot can never disagree on the block, the skills or the words. `__name` is a no-op stand-in for the
132
+ * helper the test runner's transform injects into function bodies; the built `dist/` needs none. Their text is the COMPILED
133
+ * one, so the plugin's source — and its hashed file name — follows the compiler: a process run through `tsx` names another
134
+ * file than the built bot (a test that hands the built bot a plugin name takes it from `dist/`).
135
+ */
136
+ const embeddedSkillsRestoreFunctions = [
137
+ compactOnIdle_1.readSkillsBlockLineName,
138
+ compactOnIdle_1.parseSkillsBlock,
139
+ skillsRestore_1.getOpenCodeLoadedSkills,
140
+ skillsRestore_1.planOpenCodeSkillsRestore,
141
+ skillsRestore_1.renderSkillsRestoreList,
142
+ skillsRestore_1.renderSkillsRestoreSection,
143
+ skillsRestore_1.buildSkillsRestoreText,
144
+ ];
103
145
  /**
104
146
  * @description The plugin module source: a v1 plugin (`default` export with `id` + `server`). Before a compaction it looks for
105
147
  * the flag the bot keeps for the session (`utils/compactSelfReviewFlags.ts`): present ⇒ `/compact_self_review` is off for the
@@ -111,6 +153,18 @@ exports.openCodeAncestryLookupTimeoutMs = 2000;
111
153
  * {@link maxSessionAncestryDepth} levels: a topic's sub-agents follow the topic. A folder with no flag in it at all costs no
112
154
  * request. A session id that is not a plain id, a lookup that fails or is not answered within
113
155
  * {@link openCodeAncestryLookupTimeoutMs}, or any read failure means ON: the section is asked for, as before the switch.
156
+ *
157
+ * Before every model request (`experimental.chat.messages.transform`) it gives the skills back once the list holds a finished
158
+ * summary: the skills of the session's stored history (`client.session.messages`, every compaction so far) and of the
159
+ * summary's block, the server's current text of each (`GET /skill`; the plugin's client is the v1 SDK, which has no method for
160
+ * it, so the request goes through its inner client, which carries the folder and the password — measured on the fork build),
161
+ * a skill whose call is already after the summary only named, a name only the block holds (with the history known) given a
162
+ * "load it" line. A restore whose lookups both answered is kept for the summary, so every later request gets the same text;
163
+ * one that is not whole (a lookup failed or timed out) serves its request only, is logged to the server log once per summary,
164
+ * and the next request asks again. The history waits up to {@link openCodeHistoryLookupTimeoutMs}, the skill list up to
165
+ * {@link openCodeAncestryLookupTimeoutMs}: a history that does not come is replaced by the calls the list itself holds, a
166
+ * skill list that does not come leaves "load it with the skill tool" lines. Should the SDK's inner client be gone, the skill
167
+ * list is fetched from the server directly (logged once). Nothing ever throws out of it or holds the request longer.
114
168
  */
115
169
  function buildOpenCodeCompactPluginSource(input) {
116
170
  return [
@@ -149,12 +203,149 @@ function buildOpenCodeCompactPluginSource(input) {
149
203
  ' }',
150
204
  ' return false;',
151
205
  '};',
206
+ // The skills restore: the bot's own functions, then the hook's glue.
207
+ 'const __name = (target) => target;',
208
+ ...embeddedSkillsRestoreFunctions.map((restoreFunction) => restoreFunction.toString()),
209
+ `const restoreTexts = ${JSON.stringify(skillsRestore_1.skillsRestoreTexts)};`,
210
+ `const restoreToolName = ${JSON.stringify(skillsRestore_1.openCodeSkillToolName)};`,
211
+ `const skillsBlockMarkers = ${JSON.stringify({ start: compactOnIdle_1.compactionSkillsBlockStartMarker, end: compactOnIdle_1.compactionSkillsBlockEndMarker, maxNameLength: compactOnIdle_1.compactionSkillsBlockMaxNameLength })};`,
212
+ `const restorePartId = ${JSON.stringify(skillsRestorePartId)};`,
213
+ `const maxCachedRestores = ${maxCachedSkillsRestores};`,
214
+ `const historyLookupTimeoutMs = ${exports.openCodeHistoryLookupTimeoutMs};`,
215
+ 'const restoreCache = new Map();',
216
+ 'const loggedFallbackKeys = new Set();',
217
+ 'let isInnerClientMissingLogged = false;',
218
+ // A server answer, or a rejection when it does not come in time (the timer is always cleared; a late answer is ignored).
219
+ 'const askServer = async (request, timeoutMs) => {',
220
+ ' let timer;',
221
+ ' try {',
222
+ ' const timeout = new Promise((_resolve, reject) => { timer = setTimeout(() => reject(new Error("the server did not answer in time")), timeoutMs); });',
223
+ ' return await Promise.race([request(), timeout]);',
224
+ ' } finally {',
225
+ ' clearTimeout(timer);',
226
+ ' }',
227
+ '};',
228
+ 'const logToServer = (client, message) => {',
229
+ ' try { Promise.resolve(client?.app?.log?.({ body: { service: "charness-compaction", level: "info", message } })).catch(() => {}); } catch {}',
230
+ '};',
231
+ 'const readHistory = async (client, sessionID) => {',
232
+ ' try {',
233
+ ' const answer = await askServer(() => client.session.messages({ path: { id: sessionID } }), historyLookupTimeoutMs);',
234
+ ' return Array.isArray(answer?.data) ? answer.data : null;',
235
+ ' } catch { return null; }',
236
+ '};',
237
+ // The server itself, asked the way its own client asks it: the folder, and the password the server was started with.
238
+ 'const fetchSkillsDirectly = async (pluginContext) => {',
239
+ ' const url = new URL("/skill", pluginContext.serverUrl);',
240
+ ' if (typeof pluginContext.directory === "string") url.searchParams.set("directory", pluginContext.directory);',
241
+ ' const password = process.env.OPENCODE_SERVER_PASSWORD;',
242
+ ' const headers = password ? { Authorization: `Basic ${Buffer.from(`${process.env.OPENCODE_SERVER_USERNAME || "opencode"}:${password}`).toString("base64")}` } : {};',
243
+ ' const response = await fetch(url, { headers });',
244
+ ' if (!response.ok) throw new Error(`GET /skill answered ${response.status}`);',
245
+ ' return { data: await response.json() };',
246
+ '};',
247
+ 'const readAvailableSkills = async (pluginContext) => {',
248
+ ' const client = pluginContext?.client;',
249
+ ' const hasInnerClient = typeof client?._client?.get === "function";',
250
+ ' if (!hasInnerClient && !isInnerClientMissingLogged) {',
251
+ ' isInnerClientMissingLogged = true;',
252
+ ' logToServer(client, "skills restore: the plugin client has no inner client for GET /skill (an SDK change?); asking the server directly");',
253
+ ' }',
254
+ ' try {',
255
+ ' const answer = await askServer(() => (hasInnerClient ? client._client.get({ url: "/skill" }) : fetchSkillsDirectly(pluginContext)), lookupTimeoutMs);',
256
+ ' if (!Array.isArray(answer?.data)) return null;',
257
+ ' return answer.data.filter((skill) => typeof skill?.name === "string" && typeof skill.location === "string" && typeof skill.content === "string");',
258
+ ' } catch { return null; }',
259
+ '};',
260
+ // A summary whose block and the session's history disagree is worth a line in the server log (the model forgot or mangled a
261
+ // name, or listed skills it could load); the restore goes by the history then.
262
+ 'const logBlockMismatch = (client, sessionID, blockNames, loaded) => {',
263
+ ' if (loaded === null || blockNames.length === 0) return;',
264
+ ' const blockOnly = blockNames.filter((name) => !loaded.some((mention) => mention.name === name));',
265
+ ' const historyOnly = loaded.map((mention) => mention.name).filter((name) => !blockNames.includes(name));',
266
+ ' if (blockOnly.length === 0 && historyOnly.length === 0) return;',
267
+ ' logToServer(client, `skills restore of ${sessionID}: the summary block names [${blockOnly.join(", ")}] the history does not show, the history shows [${historyOnly.join(", ")}] the block leaves out`);',
268
+ '};',
269
+ 'const findFinishedSummaryIndex = (messages) => {',
270
+ ' for (let index = messages.length - 1; index >= 0; index -= 1) {',
271
+ ' const info = messages[index]?.info;',
272
+ ' if (info?.role === "assistant" && info.summary === true && info.finish && !info.error) return index;',
273
+ ' }',
274
+ ' return -1;',
275
+ '};',
276
+ // The restore and whether it is whole: both lookups answered. Only a whole one is kept for the summary's later requests.
277
+ 'const buildRestore = async (pluginContext, messages, summaryIndex) => {',
278
+ ' const client = pluginContext?.client;',
279
+ ' const summary = messages[summaryIndex];',
280
+ ' const sessionID = summary.info.sessionID;',
281
+ ' const summaryText = (summary.parts ?? []).filter((part) => part?.type === "text" && typeof part.text === "string").map((part) => part.text).join("\\n");',
282
+ ' const blockNames = parseSkillsBlock(summaryText, skillsBlockMarkers.start, skillsBlockMarkers.end, skillsBlockMarkers.maxNameLength) ?? [];',
283
+ ' const inContextNames = getOpenCodeLoadedSkills(messages.slice(summaryIndex + 1)).map((mention) => mention.name);',
284
+ ' const [history, available] = await Promise.all([readHistory(client, sessionID), readAvailableSkills(pluginContext)]);',
285
+ ' const loaded = getOpenCodeLoadedSkills(history ?? messages);',
286
+ ' const isWhole = history !== null && available !== null;',
287
+ ' const cacheKey = `${sessionID}:${summary.info.id}`;',
288
+ // A summary whose lookups recovered no longer needs its fallback mark; the marks are bounded like the cache.
289
+ ' if (isWhole) {',
290
+ ' loggedFallbackKeys.delete(cacheKey);',
291
+ ' logBlockMismatch(client, sessionID, blockNames, loaded);',
292
+ ' } else if (!loggedFallbackKeys.has(cacheKey)) {',
293
+ ' loggedFallbackKeys.add(cacheKey);',
294
+ ' if (loggedFallbackKeys.size > maxCachedRestores) loggedFallbackKeys.delete(loggedFallbackKeys.values().next().value);',
295
+ ' const missing = [history === null ? "the history" : null, available === null ? "the skill list" : null].filter(Boolean).join(" and ");',
296
+ ' logToServer(client, `skills restore of ${sessionID}: ${missing} did not answer; this request gets what is known, the next one asks again`);',
297
+ ' }',
298
+ ' const entries = planOpenCodeSkillsRestore({ loaded, blockNames, inContextNames, available, isHistoryKnown: history !== null });',
299
+ ' return { text: buildSkillsRestoreText(entries, restoreTexts, restoreToolName), isWhole };',
300
+ '};',
301
+ // A short, stable revision of a restore text (FNV-1a): the same text, the same revision.
302
+ 'const getRestoreRevision = (text) => {',
303
+ ' let hash = 0x811c9dc5;',
304
+ ' for (let index = 0; index < text.length; index += 1) {',
305
+ ' hash ^= text.charCodeAt(index);',
306
+ ' hash = Math.imul(hash, 0x01000193);',
307
+ ' }',
308
+ ' return (hash >>> 0).toString(16).padStart(8, "0");',
309
+ '};',
310
+ 'const restoreSkills = async (pluginContext, messages) => {',
311
+ ' if (!Array.isArray(messages)) return;',
312
+ ' const summaryIndex = findFinishedSummaryIndex(messages);',
313
+ ' if (summaryIndex < 0) return;',
314
+ ' const summary = messages[summaryIndex];',
315
+ ' const targetIndex = messages.findIndex((message) => message?.info?.role === "user" && message.info.id === summary.info.parentID);',
316
+ ' const target = messages[targetIndex];',
317
+ ' if (!target || !Array.isArray(target.parts) || target.parts.some((part) => part?.id === restorePartId)) return;',
318
+ ' const cacheKey = `${summary.info.sessionID}:${summary.info.id}`;',
319
+ ' let text = restoreCache.get(cacheKey);',
320
+ ' if (text === undefined) {',
321
+ ' const restore = await buildRestore(pluginContext, messages, summaryIndex);',
322
+ ' text = restore.text;',
323
+ ' if (restore.isWhole) {',
324
+ ' restoreCache.set(cacheKey, text);',
325
+ ' if (restoreCache.size > maxCachedRestores) restoreCache.delete(restoreCache.keys().next().value);',
326
+ ' }',
327
+ ' }',
328
+ ' if (text === "") return;',
329
+ // A COPY of the compaction's message, its id tagged with the restore's revision: the fork keeps a turn's conversion and
330
+ // reuses it while the message ids stay an unchanged prefix, so a restore rebuilt in the same turn (a lookup that answered
331
+ // late) must change an id to reach the provider; the same restore keeps the same id (and the prompt cache). A copy, so the
332
+ // message object the loop may hold elsewhere keeps its stored id.
333
+ ' const revisedID = `${target.info.id}_charness_skills_${getRestoreRevision(text)}`;',
334
+ ' messages[targetIndex] = {',
335
+ ' ...target,',
336
+ ' info: { ...target.info, id: revisedID },',
337
+ ' parts: [...target.parts, { id: restorePartId, sessionID: summary.info.sessionID, messageID: revisedID, type: "text", synthetic: true, text }],',
338
+ ' };',
339
+ '};',
152
340
  'export default {',
153
341
  ` id: ${JSON.stringify(exports.openCodeCompactPluginId)},`,
154
342
  ' server: async (pluginContext) => ({',
155
343
  ' "experimental.session.compacting": async (input, output) => {',
156
344
  ' output.context.push((await checkIsSelfReviewOff(pluginContext?.client, input?.sessionID)) ? contextWithoutInstructionGaps : context);',
157
345
  ' },',
346
+ ' "experimental.chat.messages.transform": async (_input, output) => {',
347
+ ' try { await restoreSkills(pluginContext, output?.messages); } catch {}',
348
+ ' },',
158
349
  ' }),',
159
350
  '};',
160
351
  '',
@@ -1 +1 @@
1
- {"version":3,"file":"openCodeCompactPlugin.js","sourceRoot":"","sources":["../../src/utils/openCodeCompactPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;;;;;;AAoCH,0EAEC;AA6BD,4EA+CC;AAeD,4EAGC;AAMD,wEAGC;AAUD,sEAMC;AAcD,gEAMC;AAMD,4EAKC;AA+DD,oEA0BC;AAnRD,oDAA4B;AAC5B,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,mDAA8D;AAC9D,qEAAqG;AACrG,gDAAuE;AAEvE,uDAAuD;AAC1C,QAAA,uBAAuB,GAAG,qBAAqB,CAAC;AAE7D,kEAAkE;AAClE,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AAE5D,oHAAoH;AACpH,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAE1C,mHAAmH;AACnH,MAAM,oCAAoC,GAAG,IAAI,MAAM,CAAC,IAAI,6BAA6B,gBAAgB,+BAA+B,WAAW,CAAC,CAAC;AAErJ;;;;GAIG;AACU,QAAA,mCAAmC,GAAG,4BAA4B,CAAC;AACnE,QAAA,6BAA6B,GAAG,yBAAyB,CAAC;AAEvE;;;;;GAKG;AACH,SAAgB,+BAA+B,CAAC,q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AM,CAAC,CAAC,mBAAmB,CAAC,CAAC;YAC7D,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,oCAAoC,CAAC,SAAS,CAAC,CAAC;IAChD,OAAO,oBAAoB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC"}
@@ -9,9 +9,18 @@ import type { BufferedPromptSettled, StartupPromptBuffer } from '../startupPromp
9
9
  */
10
10
  export interface PromptDeliveryDeps {
11
11
  startupBuffer: Pick<StartupPromptBuffer, 'addPrompt'>;
12
- forwardPrompt: (key: SessionKey, text: string) => Promise<LatePromptOutcome>;
12
+ forwardPrompt: (key: SessionKey, text: string, options: PromptDeliveryOptions) => Promise<LatePromptOutcome>;
13
13
  announceQueued: (key: SessionKey) => Promise<void>;
14
14
  }
15
+ /**
16
+ * @name PromptDeliveryOptions
17
+ * @description `isPersonInput` — a person typed, spoke or sent it (a topic's text, voice, file or album): its forward does not
18
+ * wait for the write into the agent (the topic's update queue must not hang on it), and a write that fails is told to them.
19
+ * Every other prompt — a wake-up, a scheduled run, a retry's nudge, a tracker's post — waits for it, buffered or not.
20
+ */
21
+ export interface PromptDeliveryOptions {
22
+ isPersonInput?: boolean;
23
+ }
15
24
  /**
16
25
  * @name PromptDelivery
17
26
  * @description Where {@link deliverPromptOrBuffer} put the prompt: `forwarded` to the
@@ -46,7 +55,7 @@ export type PromptDelivery = 'forwarded' | 'buffered' | 'noSession';
46
55
  * A failed "queued" notice is logged and does not change the answer: the prompt was
47
56
  * buffered before the notice went out.
48
57
  */
49
- export declare function deliverPromptOrBuffer(deps: PromptDeliveryDeps, key: SessionKey, text: string, isStarting: boolean, onBufferedSettled?: BufferedPromptSettled): Promise<PromptDelivery>;
58
+ export declare function deliverPromptOrBuffer(deps: PromptDeliveryDeps, key: SessionKey, text: string, isStarting: boolean, onBufferedSettled?: BufferedPromptSettled, options?: PromptDeliveryOptions): Promise<PromptDelivery>;
50
59
  /**
51
60
  * @name LatePromptRoute
52
61
  * @description How a prompt decided on when it ARRIVED is delivered once its handler is ready to forward it:
@@ -1 +1 @@
1
- {"version":3,"file":"promptDelivery.d.ts","sourceRoot":"","sources":["../../src/utils/promptDelivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEzF;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACtD,aAAa,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC7E,cAAc,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,kBAAkB,EACxB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,OAAO,EACnB,iBAAiB,CAAC,EAAE,qBAAqB,GACxC,OAAO,CAAC,cAAc,CAAC,CAkBzB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAErE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,YAAY,EAAE,OAAO,CAAC;IAAC,eAAe,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,eAAe,CAIrI;AAED,4HAA4H;AAC5H,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE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CAAC,IAAI,CAAC,CAAC;CAC5D;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,CAAC;AAEnF;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAelG"}
@@ -29,13 +29,13 @@ const sessionKeyCodec_1 = require("../connectors/telegram/sessionKeyCodec");
29
29
  * A failed "queued" notice is logged and does not change the answer: the prompt was
30
30
  * buffered before the notice went out.
31
31
  */
32
- async function deliverPromptOrBuffer(deps, key, text, isStarting, onBufferedSettled) {
32
+ async function deliverPromptOrBuffer(deps, key, text, isStarting, onBufferedSettled, options = {}) {
33
33
  if (!isStarting) {
34
34
  // Only `noSession` is told apart: a forward that re-routed the prompt behind a stop window itself registered no
35
35
  // `onBufferedSettled`, so it reads as forwarded, as it always did.
36
- return (await deps.forwardPrompt(key, text)) === 'noSession' ? 'noSession' : 'forwarded';
36
+ return (await deps.forwardPrompt(key, text, options)) === 'noSession' ? 'noSession' : 'forwarded';
37
37
  }
38
- const isFirstBuffered = deps.startupBuffer.addPrompt((0, sessionKey_1.keyToString)(key), text, onBufferedSettled);
38
+ const isFirstBuffered = deps.startupBuffer.addPrompt((0, sessionKey_1.keyToString)(key), text, onBufferedSettled, options.isPersonInput === true);
39
39
  if (isFirstBuffered && (0, sessionKeyCodec_1.checkIsTelegramKey)(key)) {
40
40
  // The prompt IS buffered by now (and its settle callback registered), so a notice that fails must not
41
41
  // read as a delivery that failed: a caller keeping something until the prompt reached a session would
@@ -1 +1 @@
1
- {"version":3,"file":"promptDelivery.js","sourceRoot":"","sources":["../../src/utils/promptDelivery.ts"],"names":[],"mappings":";;AAoDA,sDAwBC;AAqBD,gDAIC;AAwCD,8CAeC;AA5JD,8CAA6D;AAC7D,4EAA4E;AA2B5E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,KAAK,UAAU,qBAAqB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