@circuitwall/jarela 2.5.1 → 2.5.2

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 (184) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +5 -5
  3. package/.next/standalone/.next/build-manifest.json +2 -2
  4. package/.next/standalone/.next/prerender-manifest.json +3 -3
  5. package/.next/standalone/.next/react-loadable-manifest.json +2 -2
  6. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  13. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  14. package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
  15. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +8 -1
  20. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
  21. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +8 -1
  22. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +8 -1
  24. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +8 -1
  26. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +8 -1
  28. package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +7 -0
  30. package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js +7 -0
  32. package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/v1/credentials/route.js +7 -0
  34. package/.next/standalone/.next/server/app/api/v1/credentials/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js +8 -1
  36. package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js +7 -0
  38. package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js +7 -0
  40. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js +8 -1
  42. package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js +8 -1
  44. package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/v1/events/route.js +8 -1
  46. package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +8 -1
  48. package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +8 -1
  50. package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +8 -1
  52. package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +8 -1
  54. package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/v1/extensions/route.js +8 -1
  56. package/.next/standalone/.next/server/app/api/v1/extensions/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js +8 -1
  58. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js +8 -1
  60. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +8 -1
  62. package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.nft.json +1 -1
  63. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js +7 -0
  64. package/.next/standalone/.next/server/app/api/v1/health/probes/route.js.nft.json +1 -1
  65. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js +7 -0
  66. package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js.nft.json +1 -1
  67. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +22 -1
  68. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +22 -1
  69. package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +22 -1
  70. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +19 -2
  71. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +19 -2
  72. package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +19 -2
  73. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js +12 -2
  74. package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js.nft.json +1 -1
  75. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js +7 -0
  76. package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js.nft.json +1 -1
  77. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js +7 -0
  78. package/.next/standalone/.next/server/app/api/v1/packages/install/route.js.nft.json +1 -1
  79. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js +7 -0
  80. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js.nft.json +1 -1
  81. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js +7 -0
  82. package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js.nft.json +1 -1
  83. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js +7 -0
  84. package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js.nft.json +1 -1
  85. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js +12 -2
  86. package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js.nft.json +1 -1
  87. package/.next/standalone/.next/server/app/api/v1/packages/route.js +12 -2
  88. package/.next/standalone/.next/server/app/api/v1/packages/route.js.nft.json +1 -1
  89. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +8 -1
  90. package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.nft.json +1 -1
  91. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +7 -0
  92. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.nft.json +1 -1
  93. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js +7 -0
  94. package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js.nft.json +1 -1
  95. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js +7 -0
  96. package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js.nft.json +1 -1
  97. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js +8 -1
  98. package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js.nft.json +1 -1
  99. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js +7 -0
  100. package/.next/standalone/.next/server/app/api/v1/system/restart/route.js.nft.json +1 -1
  101. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +52 -45
  102. package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.nft.json +1 -1
  103. package/.next/standalone/.next/server/app/api/v1/tools/route.js +8 -1
  104. package/.next/standalone/.next/server/app/api/v1/tools/route.js.nft.json +1 -1
  105. package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
  106. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js +8 -1
  107. package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js.nft.json +1 -1
  108. package/.next/standalone/.next/server/app/api/v1/watchers/route.js +8 -1
  109. package/.next/standalone/.next/server/app/api/v1/watchers/route.js.nft.json +1 -1
  110. package/.next/standalone/.next/server/app/page.js +72982 -72980
  111. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  112. package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  113. package/.next/standalone/.next/server/app-paths-manifest.json +5 -5
  114. package/.next/standalone/.next/server/chunks/1433.js +1 -1
  115. package/.next/standalone/.next/server/chunks/210.js +6 -6
  116. package/.next/standalone/.next/server/chunks/2471.js +17 -17
  117. package/.next/standalone/.next/server/chunks/3524.js +31 -15
  118. package/.next/standalone/.next/server/chunks/3566.js +1 -1
  119. package/.next/standalone/.next/server/chunks/4189.js +1 -1
  120. package/.next/standalone/.next/server/chunks/{9590.js → 423.js} +10 -3
  121. package/.next/standalone/.next/server/chunks/4508.js +2 -2
  122. package/.next/standalone/.next/server/chunks/4596.js +5 -2
  123. package/.next/standalone/.next/server/chunks/46.js +7 -0
  124. package/.next/standalone/.next/server/chunks/540.js +29 -5
  125. package/.next/standalone/.next/server/chunks/5585.js +41 -3
  126. package/.next/standalone/.next/server/chunks/5908.js +10 -10
  127. package/.next/standalone/.next/server/chunks/{3399.js → 6058.js} +882 -400
  128. package/.next/standalone/.next/server/chunks/{9164.js → 6190.js} +13777 -13530
  129. package/.next/standalone/.next/server/chunks/6649.js +1 -1
  130. package/.next/standalone/.next/server/chunks/{1388.js → 8842.js} +5961 -5793
  131. package/.next/standalone/.next/server/chunks/9032.js +5 -5
  132. package/.next/standalone/.next/server/chunks/{7547.js → 9217.js} +485 -3
  133. package/.next/standalone/.next/server/instrumentation.js +7 -0
  134. package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
  135. package/.next/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  136. package/.next/standalone/.next/server/middleware.js +7 -0
  137. package/.next/standalone/.next/server/pages/404.html +1 -1
  138. package/.next/standalone/.next/server/pages/500.html +1 -1
  139. package/.next/standalone/.next/server/preview-props.json +3 -3
  140. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  141. package/.next/standalone/.next/static/chunks/app/{page-dd05bcb5f5b81157.js → page-4112e14360a9909e.js} +1576 -1574
  142. package/.next/standalone/docs/adoption/changesets.json +139 -0
  143. package/.next/standalone/package.json +2 -1
  144. package/CHANGELOG.md +38 -0
  145. package/browser-extension/background.js +5 -539
  146. package/browser-extension/lib/form-editing.mjs +541 -0
  147. package/components/chat/MessageBubble.tsx +4 -736
  148. package/components/chat/MessageContent.tsx +749 -0
  149. package/components/layout/MenuPanel.tsx +1 -1
  150. package/hooks/useSSE.test.ts +46 -0
  151. package/lib/agents/llm.ts +1 -1
  152. package/lib/agents/output-validator/validator.test.ts +4 -0
  153. package/lib/agents/output-validator/validator.ts +1 -1
  154. package/lib/agents/prompt-registry.test.ts +11 -0
  155. package/lib/agents/prompt-registry.ts +13 -0
  156. package/lib/agents/retry-prompts.ts +17 -0
  157. package/lib/agents/run-retry.ts +671 -0
  158. package/lib/agents/run-thread.retry.test.ts +176 -2
  159. package/lib/agents/run-thread.test.ts +6 -6
  160. package/lib/agents/run-thread.ts +9 -717
  161. package/lib/agents/stream-collector.test.ts +28 -4
  162. package/lib/agents/stream-collector.ts +5 -28
  163. package/lib/agents/tool-outcomes.ts +61 -0
  164. package/lib/documents/remote/confluence.test.ts +65 -0
  165. package/lib/documents/remote/confluence.ts +35 -9
  166. package/lib/documents/remote/jira.ts +1 -1
  167. package/lib/health/probes.test.ts +32 -0
  168. package/lib/health/probes.ts +29 -14
  169. package/lib/integrations/atlassian/manifest.ts +5 -3
  170. package/lib/integrations/github/manifest.ts +7 -4
  171. package/lib/integrations/gmail-oauth.ts +16 -1
  172. package/lib/integrations/microsoft-oauth.ts +17 -2
  173. package/lib/integrations/outlook/manifest.ts +10 -8
  174. package/lib/stores/integrations.ts +1 -0
  175. package/lib/tools/communications/calendar-aliases.test.ts +77 -1
  176. package/lib/tools/communications/gmail.test.ts +13 -0
  177. package/lib/tools/communications/ms-graph.test.ts +26 -3
  178. package/lib/tools/communications/ms-graph.ts +9 -11
  179. package/lib/tools/communications/outlook-calendar.ts +94 -17
  180. package/lib/tools/packages/default-packages/atlassian.ts +8 -2
  181. package/package.json +2 -1
  182. package/scripts/standalone-footprint.mjs +1 -1
  183. /package/.next/standalone/.next/static/{XFZTDssHBZKKX2mzH2ld0 → VZXMorlOmSmi3dUr7K5UX}/_buildManifest.js +0 -0
  184. /package/.next/standalone/.next/static/{XFZTDssHBZKKX2mzH2ld0 → VZXMorlOmSmi3dUr7K5UX}/_ssgManifest.js +0 -0
@@ -289,7 +289,7 @@ export function MenuPanel({
289
289
 
290
290
  return (
291
291
  <div
292
- className="glass-elevated fixed right-0 bottom-0 w-full sm:w-[26rem] max-w-full border-l border-border/60 z-40 flex flex-col pb-safe"
292
+ className="glass-elevated fixed right-0 bottom-0 w-full sm:w-[26rem] max-w-full border-l border-border/60 z-[60] flex flex-col pb-safe"
293
293
  style={{ top: "calc(3rem + var(--app-safe-top))" }}
294
294
  >
295
295
  {/* Common navigation — the day-to-day surface. */}
@@ -110,6 +110,52 @@ describe("useSSE contract", () => {
110
110
  expect(result.current.streamingContent).not.toContain("flagged reply");
111
111
  });
112
112
 
113
+ it.each(["success", "failure"])("keeps the comparison visible while correction is pending (%s)", async (outcome) => {
114
+ const table = "| Option | Cost |\n| --- | --- |\n| A | 10 |\n| B | 20 |\n| C | 30 |\n| D | 40 |\n| E | 50 |";
115
+ const draft = `${table}\nI saved the comparison.`;
116
+ const corrected = `${table}\nThe comparison has not been saved.`;
117
+ let release!: () => void;
118
+ const gate = new Promise<void>((resolve) => { release = resolve; });
119
+ subscribeRunMock.mockReturnValue({
120
+ async *[Symbol.asyncIterator]() {
121
+ yield JSON.stringify({ type: "text_delta", delta: draft });
122
+ yield JSON.stringify({ type: "tool_call", id: "read-1", name: "memory_read", arguments: {} });
123
+ yield JSON.stringify({ type: "tool_result", id: "read-1", name: "memory_read", result: null });
124
+ yield JSON.stringify({ type: "status", label: "Checking answer..." });
125
+ await gate;
126
+ if (outcome === "failure") {
127
+ yield JSON.stringify({ type: "error", code: "correction_failed", message: "Correction failed; draft remains unverified." });
128
+ return;
129
+ }
130
+ yield JSON.stringify({ type: "reset_text" });
131
+ yield JSON.stringify({ type: "text_delta", delta: corrected });
132
+ yield JSON.stringify({ type: "done" });
133
+ },
134
+ });
135
+ submitRunMock.mockResolvedValue({ accepted: true });
136
+ const onDone = vi.fn();
137
+ const { result } = renderHook(() => useSSE(onDone));
138
+ let run!: Promise<{ accepted: boolean }>;
139
+ try {
140
+ act(() => { run = result.current.start("comparison-thread", "Compare five options."); });
141
+ await waitFor(() => expect(result.current.streamingContent).toBe(draft));
142
+ expect(result.current.streaming).toBe(true);
143
+ expect(onDone).not.toHaveBeenCalled();
144
+ expect(result.current.toolEvents).toHaveLength(2);
145
+
146
+ await act(async () => { release(); await run; });
147
+ expect(result.current.streaming).toBe(false);
148
+ expect(result.current.streamingContent).toBe(outcome === "success" ? corrected : draft);
149
+ expect(result.current.streamingContent).toContain(table);
150
+ expect(onDone).toHaveBeenCalledTimes(1);
151
+ expect(result.current.toolEvents).toHaveLength(2);
152
+ expect(result.current.error).toBe(outcome === "failure" ? "Correction failed; draft remains unverified." : null);
153
+ } finally {
154
+ release();
155
+ await act(async () => { await run; });
156
+ }
157
+ });
158
+
113
159
  it("records tool_progress events alongside tool_call/tool_result (ADR-0073)", async () => {
114
160
  submitRunMock.mockResolvedValue({ accepted: true });
115
161
  subscribeRunMock.mockReturnValue(streamWithProgress());
package/lib/agents/llm.ts CHANGED
@@ -450,7 +450,7 @@ async function* streamWithConfigImpl(
450
450
  }
451
451
  yield {
452
452
  type: "tool_result",
453
- data: { id: chunk.tool_call_id, name: chunk.name ?? "", result },
453
+ data: { id: chunk.tool_call_id, name: chunk.name ?? "", result, status: chunk.status },
454
454
  };
455
455
  // Next AI text should be visually separated from the pre-tool prose.
456
456
  needsParagraphBreak = true;
@@ -206,6 +206,10 @@ describe("validateAssistantOutput", () => {
206
206
  });
207
207
 
208
208
  describe("summary_without_action", () => {
209
+ it("allows an ordinary summary that makes no action claim", () => {
210
+ expect(validateAssistantOutput("## Summary\nOption A costs 10 units; option B costs 20 units.", [], [])).toEqual({ ok: true });
211
+ });
212
+
209
213
  it("flags 'Summary of changes' in zero-tool turn", () => {
210
214
  const r = validateAssistantOutput(
211
215
  "## Summary of changes\nI made the following edits...",
@@ -4,7 +4,7 @@ import type { ValidationResult } from "./types";
4
4
  import { isWriteToolNameSegment } from "@/lib/agents/action-vocabulary";
5
5
 
6
6
  const SUMMARY_PATTERNS: RegExp[] = [
7
- /^#{1,6}\s*Summary(?:\s+of\s+changes)?\b/im,
7
+ /^#{1,6}\s*Summary\s+of\s+changes\b/im,
8
8
  /\bI(?:'ve|\s+have)\s+completed\b/i,
9
9
  /\bWhat\s+I\s+did\b/i,
10
10
  ];
@@ -137,6 +137,7 @@ describe("prompt registry coverage", () => {
137
137
  "lib/agents/prepare/system-prompt.ts",
138
138
  "lib/agents/harness/presets.ts",
139
139
  "lib/lifecycle/system-signals.ts",
140
+ "lib/agents/retry-prompts.ts",
140
141
  ];
141
142
  for (const source of declaring) {
142
143
  expect(registered, `${source} declares a prompt but is not in prompt-registry.ts`).toContain(source);
@@ -159,6 +160,16 @@ describe("prompt registry coverage", () => {
159
160
  }
160
161
  });
161
162
 
163
+ it("requires correction retries to preserve the complete answer", () => {
164
+ for (const id of ["agent.retry-fabrication", "agent.retry-citation"]) {
165
+ const prompt = staticPrompts.find((entry) => entry.id === id)?.text ?? "";
166
+ expect(prompt).toContain("complete corrected answer to the original user request");
167
+ expect(prompt).toContain("Preserve all valid explanations, calculations, tables, and conclusions");
168
+ expect(prompt).toContain("Do not return only a correction or a tool confirmation");
169
+ expect(prompt).not.toContain("Do NOT restate");
170
+ }
171
+ });
172
+
162
173
  it("keeps prompt ids unique", () => {
163
174
  const ids = staticPrompts.map((p) => p.id);
164
175
  expect(new Set(ids).size).toBe(ids.length);
@@ -19,6 +19,7 @@ import { SYSTEM_SIGNAL_WAKE_PROMPT } from "@/lib/lifecycle/system-signals";
19
19
  import { buildConversationSummaryMessages, type SummaryTopicSegment } from "@/lib/agents/conversation-summary";
20
20
  import { buildTopicGroupingMessages, buildTopicRecapMessages } from "@/lib/agents/compaction-pipeline";
21
21
  import type { ProviderMessage } from "@/lib/providers/types";
22
+ import { buildFabricationNudge, buildCitationRetryNudge } from "./retry-prompts";
22
23
 
23
24
  export interface StaticPrompt {
24
25
  id: string;
@@ -57,6 +58,18 @@ export function listStaticPrompts(): StaticPrompt[] {
57
58
  const channelGroup = renderMessages(buildTopicGroupingMessages(sampleNewMessages, [sampleTopic], "scheduled_task"));
58
59
  const channelRecap = renderMessages(buildTopicRecapMessages({ title: sampleTopic.title, continues: "t1", seqs: [50, 51] }, sampleTopic, sampleNewMessages, "scheduled_task"));
59
60
  const prompts: StaticPrompt[] = [
61
+ {
62
+ id: "agent.retry-fabrication",
63
+ source: "lib/agents/retry-prompts.ts",
64
+ purpose: "Repairs an unsupported action claim while retaining the complete substantive answer.",
65
+ text: buildFabricationNudge("Example action claim has no confirmed tool result"),
66
+ },
67
+ {
68
+ id: "agent.retry-citation",
69
+ source: "lib/agents/retry-prompts.ts",
70
+ purpose: "Repairs unsupported citations while retaining the complete substantive answer.",
71
+ text: buildCitationRetryNudge([{ text: "Example claim", reason: "No verified source" }]),
72
+ },
60
73
  {
61
74
  id: "agent.system-signal-wakeup",
62
75
  source: "lib/lifecycle/system-signals.ts",
@@ -0,0 +1,17 @@
1
+ export interface CitationRepairClaim {
2
+ text: string;
3
+ reason: string;
4
+ }
5
+
6
+ const COMPLETE_ANSWER_REPAIR = "Return a complete corrected answer to the original user request. Preserve all valid explanations, calculations, tables, and conclusions. Correct unsupported action claims: call the missing tool if the user authorized that action, or state honestly that it was not performed. Do not return only a correction or a tool confirmation. Your completed answer will replace the draft; the user must not lose the substantive answer.";
7
+
8
+ export function buildFabricationNudge(reason: string): string {
9
+ return `\u21bb Auto-retry: output validator flagged your reply${reason ? ` \u2014 ${reason}` : ""}. ${COMPLETE_ANSWER_REPAIR}`;
10
+ }
11
+
12
+ export function buildCitationRetryNudge(claims: readonly CitationRepairClaim[]): string {
13
+ const details = claims.slice(0, 5).map((claim, index) =>
14
+ ` ${index + 1}. ${claim.text}${claim.reason ? ` \u2014 ${claim.reason}` : ""}`,
15
+ ).join("\n");
16
+ return `\u21bb Auto-retry: the citation audit flagged ${claims.length} high-impact claim${claims.length === 1 ? "" : "s"} without a verified source:\n${details}\n\nFix each claim in exactly ONE of these three ways:\n (a) cite an existing source from the manifest by appending the marker \`[N]\` to the claim,\n (b) call a tool now (file_read, web_search, fetch_webpage, memory_read) to actually ground the claim before stating it,\n (c) rephrase plainly: drop the specific number/fact, or say "I don't have a source for this" so the claim is no longer load-bearing.\n\n${COMPLETE_ANSWER_REPAIR} Do NOT invent a marker number that isn't in the manifest.`;
17
+ }