chatroom-cli 1.94.2 → 1.96.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.
package/dist/index.js CHANGED
@@ -78205,6 +78205,7 @@ var init_participant = __esm(() => {
78205
78205
  ONLINE_OR_STARTING_STATUSES = new Set([
78206
78206
  "agent.waiting",
78207
78207
  "agent.requestStart",
78208
+ "agent.restart",
78208
78209
  "agent.started",
78209
78210
  "task.acknowledged",
78210
78211
  "task.inProgress",
@@ -79042,90 +79043,54 @@ var init_builder_to_planner = __esm(() => {
79042
79043
  init_role_guidance_disclosure();
79043
79044
  });
79044
79045
 
79046
+ // ../../services/backend/prompts/enhancer/defragmentation-reference.ts
79047
+ function renderDefragmentationHandoffReference() {
79048
+ return [
79049
+ "### Defragmentation workflow checklist",
79050
+ 'Complete the optional **Defragmentation** section when the planner check-in addresses a large or multi-surface system revision, including refactoring, consolidation, or consistency work. Write exactly "Not Applicable." only when no such revision is proposed.',
79051
+ "",
79052
+ "1. **Study surfaces** — map all call sites, use cases, and complexity variants before proposing slices; name every relevant file/module",
79053
+ "2. **Golden implementation** — build a standalone canonical solution first; introduce canonical domain entities/types only when the studied variants require them, then shared use cases, UI components, or utilities; do not patch duplicates in place",
79054
+ "3. **Migrate callers** — refactor all consumers to the golden path; each slice must be shippable end-to-end",
79055
+ "4. **Delete legacy** — remove old implementations only after migration is complete; no dead-code leftovers",
79056
+ "",
79057
+ "### Anti-patterns to flag",
79058
+ "- Incremental copy-paste fixes across N files without a golden SSOT",
79059
+ "- New abstraction without studying all existing variants",
79060
+ '- Leaving old code "for safety" after migration',
79061
+ "- Slices that add helpers/infra without a runnable end-to-end outcome",
79062
+ "- Parallel implementations coexisting without a deletion plan",
79063
+ "",
79064
+ "### Structural decisions",
79065
+ "- Identify SSOT locations for domain entities, shared use cases, and UI components",
79066
+ "- Align with `structural-decisions` glossary: folder structure, file naming, interface locations",
79067
+ "- Flag when the plan scatters the canonical implementation across unrelated modules"
79068
+ ].join(`
79069
+ `);
79070
+ }
79071
+
79045
79072
  // ../../services/backend/prompts/enhancer/webapp-ux-reference.ts
79046
79073
  function renderWebappUxHandoffReference() {
79047
79074
  return [
79048
79075
  "### UX review checklist",
79049
79076
  'Complete the optional **UX** section in your output when the planner proposes UI changes. Write exactly "Not Applicable." for non-UI tasks. Put code snippets in **Suggested edits** only.',
79050
79077
  "",
79051
- "1. **Flows** — primary action ≤3 clicks? simpler path exists?",
79052
- "2. **Patterns** — matches existing components? recommend one if multiple. mobile vs desktop (responsive variants vs separate mobile UI)?",
79053
- "3. **Layout** — compact title+menu row, description, trailing end-aligned CTA? unnecessary wrappers?",
79054
- "4. **Shortcuts** — consistent with project conventions? gaps or conflicts?",
79055
- "5. **States** — loading spinners/skeletons for async data? error messages on failure? empty states?",
79056
- "6. **Error boundaries** — risky subtrees wrapped so a throw does not crash the whole app? failure isolated from the shell?",
79057
- "7. **Alignment** — traced parent layout before leaf styles? position/height match siblings?",
79058
- '8. **Feedback** — immediate pending state on async actions (e.g. save button "Saving...")?',
79059
- "9. **Destructive actions** — confirmation dialog before delete/remove/archive/reset/clear or other irreversible/high-impact single actions?",
79060
- "10. **Bulk actions** — confirmation before batch/multi-item operations (with count or impact summary)?",
79061
- "",
79062
- "### Flow complexity",
79063
- "- Primary action ≤3 clicks from entry point",
79064
- "- Extend existing surfaces (palette, settings tab, row action) before new navigation",
79065
- "- Avoid nested modal chains and unjustified multi-step wizards",
79066
- "- Prefer inline actions over navigate-away-and-back",
79078
+ "1. **Flows** — is the primary path straightforward? simpler alternatives exist?",
79079
+ "2. **Patterns** — consistent with existing project components and conventions? recommend one when multiple exist.",
79080
+ "3. **Layout** — unnecessary complexity or wrappers? layout stable across loading/empty/error transitions (no layout shift when async content arrives or state changes)?",
79081
+ "4. **Shortcuts** — aligned with the project keyboard/shortcut conventions? gaps or conflicts?",
79082
+ "5. **States** — loading, error, and empty states explicitly handled for async surfaces (no blank panels, silent failures, or missing retry affordances)?",
79083
+ "6. **Error boundaries** — failures scoped so one subtree does not crash the whole app?",
79084
+ "7. **Feedback** — timely response for async user actions?",
79085
+ "8. **Interaction affordance** — clickable/interactive elements use pointer cursor (or the project's established equivalent) where applicable?",
79086
+ "9. **Destructive actions** — irreversible or high-impact single actions gated by confirmation?",
79087
+ "10. **Bulk actions** — batch/multi-item operations confirmed with scope or impact summary?",
79067
79088
  "",
79068
- "### Presentation & responsive patterns",
79069
- "- Reuse existing design-system components and established UI patterns before introducing new abstractions",
79070
- "- Match badge/button styling from similar surfaces in the app",
79071
- "- When multiple valid patterns exist, recommend one and explain tradeoff",
79072
- "- Use the project's standard breakpoint(s) for mobile vs desktop",
79073
- "- **Hide/show:** responsive utility classes or equivalent for alternate chrome per viewport",
79074
- "- **Mobile overlay:** full-screen or sheet overlay with backdrop when desktop uses persistent panels",
79075
- "- **Separate mobile UI:** dedicated mobile modal/picker when desktop uses side panel or split view",
79076
- "- **Shared responsive density:** same component with size/density variants per breakpoint",
79077
- "- **Command/search dialogs:** match existing modal/dialog styling; sensible max-width on small screens",
79078
- "",
79079
- "### Layout simplification",
79080
- "- Review card/section layouts for unnecessary rows, nested wrappers, or misaligned actions",
79081
- "- Prefer compact rows: title and overflow menu on one line via flex/grid",
79082
- "- Description on the next line; primary CTA on a trailing row aligned end",
79083
- "- Canonical simplified card pattern:",
79084
- " ```",
79085
- " <title> <overflow-menu>",
79086
- " <description>",
79087
- " <primary-cta aligned end>",
79088
- " ```",
79089
- "- Use header + action grid or equivalent flex `justify-between`",
79090
- "- Flag multi-row chrome that could collapse (menu on its own row, CTA misaligned vs similar cards)",
79091
- "",
79092
- "### Error & loading states",
79093
- "- Initial fetch: centered loader or skeleton for the content area",
79094
- "- Pagination/infinite scroll: inline loader at scroll edge",
79095
- "- Save/submit mutations: inline success/error feedback beside the trigger control",
79096
- "- Never leave blank panels on fetch failure — show error message or retry affordance",
79097
- "- Disable interactive controls while loading or pending",
79098
- "",
79099
- "### Error boundaries",
79100
- "- Wrap data-dependent or third-party subtrees with error boundaries so a single failure does not unmount the whole app",
79101
- "- Scope boundaries to the failing panel/section, not the entire shell",
79102
- "- Provide fallback UI with a recovery action (retry, reload, or navigate away)",
79103
- "",
79104
- "### Alignment & component hierarchy",
79105
- "- Before styling a leaf component, trace parent flex/grid context",
79106
- "- Match sibling heights and vertical rhythm",
79107
- "- Flag absolute positioning or fixed heights that fight parent layout",
79108
- "- When hierarchy is unclear, inspect the rendered component tree (e.g. DOM inspector or component test snapshot) before deciding leaf styles",
79109
- "",
79110
- "### Fast user feedback",
79111
- "- Async actions triggered by keyboard shortcut or click must show **immediate** UI response",
79112
- '- Canonical pattern: pending local state → button label changes (e.g. "Saving..."), control disabled while in flight',
79113
- "- Show inline error on failure; brief success confirmation optional",
79114
- "- Pair shortcut hints with pending state only when the action shows pending feedback",
79115
- "",
79116
- "### Destructive & bulk action safeguards",
79117
- "- **Destructive actions** (delete, remove, archive, reset, clear, disable) require an explicit confirmation step — never fire immediately from a menu item or button without a dialog",
79118
- "- Use the project's standard confirmation dialog/modal pattern",
79119
- "- Confirmation includes clear title + description of what will happen; primary action styled as destructive when appropriate",
79120
- "- **Bulk actions** (multi-select delete, batch disable, clear-all) require confirmation before execution — show how many items are affected",
79121
- '- Bulk confirm should summarize scope (e.g. "Delete 12 items?") and list material impact when non-obvious',
79122
- "- Flag plans that wire bulk/destructive handlers directly to mutations/API calls without a confirm gate",
79123
- "",
79124
- "### Keyboard shortcuts",
79125
- "- Align proposed shortcuts with the project's existing shortcut catalog and platform conventions (⌘ on macOS, Ctrl on Windows/Linux)",
79126
- "- Avoid conflicting bindings; document new shortcuts when introducing them",
79127
- "- Common patterns: modifier+letter for global commands, Enter to confirm in dialogs, Escape to cancel/close, Shift+Enter for multiline input where applicable",
79128
- "- Flag plans that add shortcuts without checking for conflicts or omit keyboard access for primary actions"
79089
+ "### Review principles",
79090
+ "- Ground feedback in the planner check-in and the project codebase — cite existing patterns rather than inventing generic UI preferences.",
79091
+ "- Flag missing states, layout-shift risk, and missing interaction affordances when the plan omits them; recommend consistency with established project conventions.",
79092
+ "- Do **not** prescribe style choices the project has not adopted (e.g. specific flex layouts, canonical card chrome, responsive utility patterns, button label copy).",
79093
+ "- When multiple valid patterns exist in the codebase, recommend one and explain the tradeoff."
79129
79094
  ].join(`
79130
79095
  `);
79131
79096
  }
@@ -79140,7 +79105,7 @@ function getEnhancerFeedbackTemplateBody() {
79140
79105
  <specific misreadings or missing constraints — what the user asked vs what the planner proposed>
79141
79106
  </handoff-overview>
79142
79107
 
79143
- <!-- UI collapses proofs, direction, ux, and notes by default; overview and action required are expanded -->
79108
+ <!-- UI collapses proofs, direction, ux, defragmentation, and notes by default; overview and action required are expanded -->
79144
79109
 
79145
79110
  <handoff-proofs>
79146
79111
  ## Reasoning review
@@ -79155,18 +79120,32 @@ function getEnhancerFeedbackTemplateBody() {
79155
79120
  <handoff-ux>
79156
79121
  <!-- Optional — write exactly "Not Applicable." when no UI changes are proposed -->
79157
79122
  <!-- When UI is proposed: specific findings tied to the planner's proposal. No code blocks (use Suggested edits). -->
79158
- - **Flows:** <specific finding — click count, nested modals, simpler alternatives>
79159
- - **Patterns:** <which existing pattern fits; recommend one if multiple; mobile vs desktop>
79160
- - **Layout:** <compact rows, trailing CTAs, unnecessary wrappers>
79123
+ - **Flows:** <click count, nested modals, simpler alternatives>
79124
+ - **Patterns:** <consistency with existing project components; recommend one when multiple>
79125
+ - **Layout:** <complexity, wrappers, layout stable across state transitions — no layout shift>
79161
79126
  - **Shortcuts:** <alignment with catalog; gaps or conflicts>
79162
- - **States:** <loading/error/empty coverage for async surfaces>
79127
+ - **States:** <loading/error/empty explicitly handled; no blank panels or silent failures>
79163
79128
  - **Error boundaries:** <error boundary placement; failure isolated from the whole app>
79164
- - **Alignment:** <hierarchy traced; position/height issues; inline snapshot consideration>
79165
- - **Feedback:** <immediate pending state on async actions; ⌘Enter + button state>
79166
- - **Destructive safeguards:** <single-item irreversible/high-impact actions gated by confirm dialog; cite missing confirms>
79167
- - **Bulk safeguards:** <batch/multi-item operations gated by confirm with count/impact summary; cite missing confirms>
79129
+ - **Feedback:** <timely response for async actions>
79130
+ - **Interaction affordance:** <pointer cursor or project equivalent on clickable elements where applicable>
79131
+ - **Destructive safeguards:** <confirmation before irreversible/high-impact actions>
79132
+ - **Bulk safeguards:** <confirmation with scope summary for batch operations>
79168
79133
  </handoff-ux>
79169
79134
 
79135
+ <handoff-defragmentation>
79136
+ <!-- Optional — write exactly "Not Applicable." when no large or multi-surface system revision is proposed -->
79137
+ <!-- When revision work is proposed: specific findings tied to the planner's proposal. No code blocks (use Suggested edits). -->
79138
+ - **Surfaces:** <call sites and modules identified; gaps in surface mapping>
79139
+ - **Golden path:** <whether planner builds standalone canonical implementation first>
79140
+ - **Domain model:** <canonical types/entities needed or "not needed">
79141
+ - **Shared components:** <shared abstractions planned (use cases, UI, utilities)>
79142
+ - **Slice ordering:** <study → golden → migrate → delete sequence respected?>
79143
+ - **Migration plan:** <how all callers move to golden path>
79144
+ - **Deletion plan:** <old implementations slated for removal>
79145
+ - **Duplication:** <existing duplicates to eliminate; risk of new duplication>
79146
+ - **Structural decisions:** <folder/module boundaries; SSOT locations>
79147
+ </handoff-defragmentation>
79148
+
79170
79149
  <handoff-notes>
79171
79150
  ## Knowledge gaps
79172
79151
  <specific facts, files, or research to verify — name what to check and why>
@@ -79205,10 +79184,12 @@ ${getHandoffReportTemplateIntro("Planning Feedback (Enhancer → Planner)")}
79205
79184
 
79206
79185
  The planner sent you three XML sections. Your job is **advisory adversarial review** — raise risks, challenge assumptions, align with user intent. Be **specific and targeted**: cite concrete claims, files, UX choices, and gaps from the check-in so the planner can improve the plan without re-synthesizing vague feedback.
79207
79186
 
79208
- Give **concrete, actionable recommendations** in every section. End with **Recommendations** (second-last: summarized suggestions, tradeoffs, and considerations) then **Suggested edits** (last: proposed edits to grounding and the builder-handoff with file paths and code snippets). For UI work, complete the optional **UX** section using the reference below. **Do not rewrite their full builder brief.** The planner makes the final call.
79187
+ Give **concrete, actionable recommendations** in every section. End with **Recommendations** (second-last: summarized suggestions, tradeoffs, and considerations) then **Suggested edits** (last: proposed edits to grounding and the builder-handoff with file paths and code snippets). For UI work, complete the optional **UX** section using the reference below. For large or multi-surface revision work, complete the optional **Defragmentation** section using its reference below. **Do not rewrite their full builder brief.** The planner makes the final call.
79209
79188
 
79210
79189
  ${renderWebappUxHandoffReference()}
79211
79190
 
79191
+ ${renderDefragmentationHandoffReference()}
79192
+
79212
79193
  \`\`\`markdown
79213
79194
  ${getEnhancerFeedbackTemplateBody()}
79214
79195
  \`\`\`
@@ -80254,6 +80235,24 @@ var init_generator = __esm(() => {
80254
80235
  init_review_guidelines();
80255
80236
  });
80256
80237
 
80238
+ // src/infrastructure/deps/create-convex-command-deps.ts
80239
+ async function createConvexCommandDeps() {
80240
+ const client4 = await getConvexClient();
80241
+ const backend2 = {
80242
+ mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
80243
+ query: (endpoint, args2) => client4.query(endpoint, args2)
80244
+ };
80245
+ const session2 = { getSessionId, getConvexUrl, getOtherSessionUrls };
80246
+ return {
80247
+ backend: backend2,
80248
+ session: session2
80249
+ };
80250
+ }
80251
+ var init_create_convex_command_deps = __esm(() => {
80252
+ init_storage();
80253
+ init_client2();
80254
+ });
80255
+
80257
80256
  // src/commands/handoff/index.ts
80258
80257
  var exports_handoff = {};
80259
80258
  __export(exports_handoff, {
@@ -80261,18 +80260,7 @@ __export(exports_handoff, {
80261
80260
  handoff: () => handoff
80262
80261
  });
80263
80262
  async function createDefaultDeps10() {
80264
- const client4 = await getConvexClient();
80265
- return {
80266
- backend: {
80267
- mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
80268
- query: (endpoint, args2) => client4.query(endpoint, args2)
80269
- },
80270
- session: {
80271
- getSessionId,
80272
- getConvexUrl,
80273
- getOtherSessionUrls
80274
- }
80275
- };
80263
+ return createConvexCommandDeps();
80276
80264
  }
80277
80265
  function handleHandoffError(err) {
80278
80266
  return exports_Effect.sync(() => {
@@ -80389,8 +80377,7 @@ var init_handoff = __esm(() => {
80389
80377
  init_values();
80390
80378
  init_esm();
80391
80379
  init_api3();
80392
- init_storage();
80393
- init_client2();
80380
+ init_create_convex_command_deps();
80394
80381
  init_services();
80395
80382
  init_error_formatting();
80396
80383
  });
@@ -81687,18 +81674,7 @@ __export(exports_skill, {
81687
81674
  activateSkill: () => activateSkill
81688
81675
  });
81689
81676
  async function createDefaultDeps15() {
81690
- const client4 = await getConvexClient();
81691
- return {
81692
- backend: {
81693
- mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
81694
- query: (endpoint, args2) => client4.query(endpoint, args2)
81695
- },
81696
- session: {
81697
- getSessionId,
81698
- getConvexUrl,
81699
- getOtherSessionUrls
81700
- }
81701
- };
81677
+ return createConvexCommandDeps();
81702
81678
  }
81703
81679
  function handleListSkillsError(err) {
81704
81680
  return exports_Effect.sync(() => {
@@ -81824,8 +81800,7 @@ var listSkillsEffect = (chatroomId, _options) => exports_Effect.gen(function* ()
81824
81800
  var init_skill = __esm(() => {
81825
81801
  init_esm();
81826
81802
  init_api3();
81827
- init_storage();
81828
- init_client2();
81803
+ init_create_convex_command_deps();
81829
81804
  init_services();
81830
81805
  init_convex_error();
81831
81806
  });
@@ -81883,6 +81858,111 @@ var init_send = __esm(() => {
81883
81858
  init_client2();
81884
81859
  });
81885
81860
 
81861
+ // ../../services/backend/src/domain/usecase/message/serialize-message.ts
81862
+ function attachmentContext(options) {
81863
+ return { chatroomId: options.chatroomId ?? "", role: options.role ?? "" };
81864
+ }
81865
+ function serializeLinearMessage(message, options) {
81866
+ const target = message.targetRole ? ` → ${message.targetRole}` : "";
81867
+ const attachments = message.attachments ? renderDeliveryAttachmentsBlock(message.attachments, attachmentContext(options)).join(`
81868
+ `) : "";
81869
+ return `${new Date(message._creationTime).toISOString()} | ${message.senderRole}${target}
81870
+ ${attachments ? `${attachments}
81871
+ ` : ""}
81872
+ ${message.content}`;
81873
+ }
81874
+ function serializeTaskOriginMessage(message) {
81875
+ return `<message sender="${escapeXmlAttribute(message.senderRole)}" message-id="${escapeXmlAttribute(message._id)}">
81876
+ <message-content>
81877
+ ${escapeXmlText(message.content)}
81878
+ </message-content>
81879
+ </message>`;
81880
+ }
81881
+ function serializeContextXmlMessage(message, options) {
81882
+ const indent = options.indent ?? " ";
81883
+ const attrs = contextMessageAttributes(message);
81884
+ const task = contextTaskBlock(message, indent);
81885
+ const attachmentLines = contextAttachmentLines(message, options, indent);
81886
+ return [
81887
+ `<message ${attrs}>`,
81888
+ task,
81889
+ ...attachmentLines,
81890
+ `${indent}Content:`,
81891
+ `${indent}<message-content>`,
81892
+ `${indent}${indent}${escapeXmlText(message.content)}`,
81893
+ `${indent}</message-content>`,
81894
+ `</message>`
81895
+ ].filter(Boolean).join(`
81896
+ `);
81897
+ }
81898
+ function contextMessageAttributes(message) {
81899
+ const target = message.targetRole ? ` to="${escapeXmlAttribute(message.targetRole)}"` : "";
81900
+ return `id="${escapeXmlAttribute(message._id)}" from="${escapeXmlAttribute(message.senderRole)}"${target} type="${escapeXmlAttribute(message.type)}"`;
81901
+ }
81902
+ function contextTaskBlock(message, indent) {
81903
+ if (!message.task)
81904
+ return "";
81905
+ return `
81906
+ ${indent}<task id="${escapeXmlAttribute(message.task._id)}" status="${escapeXmlAttribute(message.task.status)}">
81907
+ ${indent}${indent}${escapeXmlText(message.task.content)}
81908
+ ${indent}</task>`;
81909
+ }
81910
+ function contextAttachmentLines(message, options, indent) {
81911
+ if (!message.attachments)
81912
+ return [];
81913
+ return renderDeliveryAttachmentsBlock(message.attachments, attachmentContext(options)).map((line) => line ? indent + line : "");
81914
+ }
81915
+ function serializeMessage(message, options) {
81916
+ switch (options.profile) {
81917
+ case "linear":
81918
+ return serializeLinearMessage(message, options);
81919
+ case "task-origin":
81920
+ return serializeTaskOriginMessage(message);
81921
+ case "context-xml":
81922
+ return serializeContextXmlMessage(message, options);
81923
+ }
81924
+ }
81925
+ var init_serialize_message = __esm(() => {
81926
+ init_render_delivery_attachments();
81927
+ });
81928
+
81929
+ // ../../services/backend/src/domain/usecase/message/to-serializable-message.ts
81930
+ function normalizeDeliveryAttachments(input) {
81931
+ const attachments = {
81932
+ attachedTasks: input.attachedTasks?.map((item) => ({
81933
+ _id: item._id,
81934
+ content: item.content,
81935
+ status: item.status ?? item.backlogStatus ?? ""
81936
+ })),
81937
+ attachedBacklogItems: input.attachedBacklogItems?.map((item) => ({
81938
+ _id: item._id ?? item.id ?? "",
81939
+ content: item.content,
81940
+ status: item.status
81941
+ })),
81942
+ attachedMessages: input.attachedMessages,
81943
+ attachedSnippets: input.attachedSnippets
81944
+ };
81945
+ return Object.values(attachments).some((items) => items && items.length > 0) ? attachments : undefined;
81946
+ }
81947
+ function normalizeTask(input) {
81948
+ if (!input.taskId || input.taskStatus == null || input.taskContent == null)
81949
+ return;
81950
+ return { _id: input.taskId, status: input.taskStatus, content: input.taskContent };
81951
+ }
81952
+ function toSerializableMessage(input) {
81953
+ const attachments = normalizeDeliveryAttachments(input);
81954
+ return {
81955
+ _id: input._id,
81956
+ _creationTime: input._creationTime,
81957
+ senderRole: input.senderRole,
81958
+ targetRole: input.targetRole,
81959
+ type: input.type,
81960
+ content: input.content,
81961
+ ...attachments ? { attachments } : {},
81962
+ ...normalizeTask(input) ? { task: normalizeTask(input) } : {}
81963
+ };
81964
+ }
81965
+
81886
81966
  // src/commands/messages/messages-fs-service.ts
81887
81967
  import * as nodeFs2 from "node:fs/promises";
81888
81968
  function messageFilename(msg) {
@@ -81890,13 +81970,6 @@ function messageFilename(msg) {
81890
81970
  const receiver = msg.targetRole ?? "all";
81891
81971
  return `${sortPrefix}_${msg.senderRole}-to-${receiver}_${msg._id}.md`;
81892
81972
  }
81893
- function buildLinearMessageContent(msg) {
81894
- const ts = new Date(msg._creationTime).toISOString();
81895
- const receiver = msg.targetRole ? ` → ${msg.targetRole}` : "";
81896
- return `${ts} | ${msg.senderRole}${receiver}
81897
-
81898
- ${msg.content}`;
81899
- }
81900
81973
  var MessagesFsService, MessagesFsServiceLive, SORT_KEY_MAX = 9999999999999;
81901
81974
  var init_messages_fs_service = __esm(() => {
81902
81975
  init_esm();
@@ -82073,7 +82146,11 @@ var PAGE_SIZE = 50, SINCE_PAGE_SIZE = 500, ABSOLUTE_MAX = 5000, DEFAULT_LIMIT =
82073
82146
  const manifestEntries = [];
82074
82147
  for (const msg of messages) {
82075
82148
  const file = messageFilename(msg);
82076
- const content = buildLinearMessageContent(msg);
82149
+ const content = serializeMessage(toSerializableMessage(msg), {
82150
+ profile: "linear",
82151
+ chatroomId,
82152
+ role: options.role
82153
+ });
82077
82154
  const filePath = nodePath2.join(outputDir, file);
82078
82155
  yield* fs11.writeFile(filePath, content).pipe(exports_Effect.mapError((cause3) => ({
82079
82156
  _tag: "WriteFailed",
@@ -82131,6 +82208,7 @@ var PAGE_SIZE = 50, SINCE_PAGE_SIZE = 500, ABSOLUTE_MAX = 5000, DEFAULT_LIMIT =
82131
82208
  });
82132
82209
  });
82133
82210
  var init_download = __esm(() => {
82211
+ init_serialize_message();
82134
82212
  init_esm();
82135
82213
  init_messages_fs_service();
82136
82214
  init_api3();
@@ -82442,18 +82520,19 @@ __export(exports_context2, {
82442
82520
  inspectContext: () => inspectContext
82443
82521
  });
82444
82522
  async function createDefaultDeps18() {
82445
- const client4 = await getConvexClient();
82446
- return {
82447
- backend: {
82448
- mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
82449
- query: (endpoint, args2) => client4.query(endpoint, args2)
82450
- },
82451
- session: {
82452
- getSessionId,
82453
- getConvexUrl,
82454
- getOtherSessionUrls
82455
- }
82456
- };
82523
+ return createConvexCommandDeps();
82524
+ }
82525
+ function requireAuthenticatedChatroom(chatroomId) {
82526
+ return exports_Effect.gen(function* () {
82527
+ const sessionId = yield* requireSessionIdEffect(() => ({
82528
+ _tag: "NotAuthenticated"
82529
+ }));
82530
+ yield* validateChatroomIdEffect(chatroomId, (id3) => ({
82531
+ _tag: "InvalidChatroomId",
82532
+ id: id3
82533
+ }));
82534
+ return sessionId;
82535
+ });
82457
82536
  }
82458
82537
  function handleContextError(err) {
82459
82538
  return exports_Effect.sync(() => {
@@ -82506,13 +82585,7 @@ async function inspectContext(chatroomId, options, deps) {
82506
82585
  }
82507
82586
  var readContextEffect = (chatroomId, options) => exports_Effect.gen(function* () {
82508
82587
  const backend2 = yield* BackendService;
82509
- const sessionId = yield* requireSessionIdEffect(() => ({
82510
- _tag: "NotAuthenticated"
82511
- }));
82512
- yield* validateChatroomIdEffect(chatroomId, (id3) => ({
82513
- _tag: "InvalidChatroomId",
82514
- id: id3
82515
- }));
82588
+ const sessionId = yield* requireAuthenticatedChatroom(chatroomId);
82516
82589
  const context5 = yield* backend2.query(api.messages.getContextForRole, {
82517
82590
  sessionId,
82518
82591
  chatroomId,
@@ -82559,47 +82632,12 @@ var readContextEffect = (chatroomId, options) => exports_Effect.gen(function* ()
82559
82632
  \uD83D\uDCAC Chat History:`);
82560
82633
  console.log("─".repeat(60));
82561
82634
  for (const message of context5.messages) {
82562
- const toAttr = message.targetRole ? ` to="${message.targetRole}"` : "";
82563
- console.log(`<message id="${message._id}" from="${message.senderRole}"${toAttr} type="${message.type}">`);
82564
- if (message.taskId) {
82565
- console.log(` Task:`);
82566
- console.log(` ID: ${message.taskId}`);
82567
- if (message.taskStatus) {
82568
- console.log(` Status: ${message.taskStatus}`);
82569
- }
82570
- if (message.taskContent) {
82571
- const safeTaskContent = sanitizeForTerminal(message.taskContent);
82572
- console.log(` Content:`);
82573
- console.log(` <task-content>`);
82574
- console.log(safeTaskContent.split(`
82575
- `).map((l) => ` ${l}`).join(`
82576
- `));
82577
- console.log(` </task-content>`);
82578
- }
82579
- }
82580
- if (message.attachedTasks && message.attachedTasks.length > 0) {
82581
- console.log(` Attachments:`);
82582
- for (const task of message.attachedTasks) {
82583
- console.log(` \uD83D\uDD39 Task ID: ${task._id}`);
82584
- console.log(` Type: Task`);
82585
- const contentLines = sanitizeForTerminal(task.content).split(`
82586
- `);
82587
- console.log(` Content:`);
82588
- console.log(` <task-content>`);
82589
- for (const line of contentLines) {
82590
- console.log(` ${line}`);
82591
- }
82592
- console.log(` </task-content>`);
82593
- }
82594
- }
82595
- console.log(` Content:`);
82596
- console.log(` <message-content>`);
82597
- const safeMessageContent = sanitizeForTerminal(message.content);
82598
- console.log(safeMessageContent.split(`
82599
- `).map((l) => ` ${l}`).join(`
82600
- `));
82601
- console.log(` </message-content>`);
82602
- console.log(`</message>`);
82635
+ const serialized = serializeMessage(toSerializableMessage(message), {
82636
+ profile: "context-xml",
82637
+ chatroomId,
82638
+ role: options.role
82639
+ });
82640
+ console.log(sanitizeForTerminal(serialized));
82603
82641
  }
82604
82642
  console.log(`
82605
82643
  ` + "═".repeat(60));
@@ -82607,13 +82645,7 @@ var readContextEffect = (chatroomId, options) => exports_Effect.gen(function* ()
82607
82645
  });
82608
82646
  }), newContextEffect = (chatroomId, options) => exports_Effect.gen(function* () {
82609
82647
  const backend2 = yield* BackendService;
82610
- const sessionId = yield* requireSessionIdEffect(() => ({
82611
- _tag: "NotAuthenticated"
82612
- }));
82613
- yield* validateChatroomIdEffect(chatroomId, (id3) => ({
82614
- _tag: "InvalidChatroomId",
82615
- id: id3
82616
- }));
82648
+ const sessionId = yield* requireAuthenticatedChatroom(chatroomId);
82617
82649
  if (!options.content || options.content.trim().length === 0) {
82618
82650
  return yield* exports_Effect.fail({ _tag: "EmptyContent" });
82619
82651
  }
@@ -82724,11 +82756,11 @@ var readContextEffect = (chatroomId, options) => exports_Effect.gen(function* ()
82724
82756
  });
82725
82757
  });
82726
82758
  var init_context2 = __esm(() => {
82759
+ init_serialize_message();
82727
82760
  init_esm();
82728
82761
  init_format_new_context_error();
82729
82762
  init_api3();
82730
- init_storage();
82731
- init_client2();
82763
+ init_create_convex_command_deps();
82732
82764
  init_services();
82733
82765
  });
82734
82766
 
@@ -82857,18 +82889,7 @@ __export(exports_artifact, {
82857
82889
  createArtifact: () => createArtifact
82858
82890
  });
82859
82891
  async function createDefaultDeps20() {
82860
- const client4 = await getConvexClient();
82861
- return {
82862
- backend: {
82863
- mutation: (endpoint, args2) => client4.mutation(endpoint, args2),
82864
- query: (endpoint, args2) => client4.query(endpoint, args2)
82865
- },
82866
- session: {
82867
- getSessionId,
82868
- getConvexUrl,
82869
- getOtherSessionUrls
82870
- }
82871
- };
82892
+ return createConvexCommandDeps();
82872
82893
  }
82873
82894
  function handleArtifactError(err) {
82874
82895
  return exports_Effect.sync(() => {
@@ -83019,8 +83040,7 @@ var createArtifactEffect = (chatroomId, options) => exports_Effect.gen(function*
83019
83040
  var init_artifact = __esm(() => {
83020
83041
  init_esm();
83021
83042
  init_api3();
83022
- init_storage();
83023
- init_client2();
83043
+ init_create_convex_command_deps();
83024
83044
  init_services();
83025
83045
  init_file_content();
83026
83046
  artifactErrorHandlers = {
@@ -98511,9 +98531,11 @@ function parseAssignedTaskSignal(raw) {
98511
98531
  return assignedTaskSignalSchema.parse(raw);
98512
98532
  }
98513
98533
  function parseAssignedTaskPresenceSignal(raw) {
98534
+ const full = assignedTaskPresenceSignalSchema.safeParse(raw);
98535
+ if (full.success)
98536
+ return full.data;
98514
98537
  const delta = assignedTaskPresenceDeltaSchema.safeParse(raw);
98515
- const hasFullWireFields = typeof raw === "object" && raw !== null && "chatroomId" in raw && "presenceUpdatedAt" in raw;
98516
- if (delta.success && !hasFullWireFields) {
98538
+ if (delta.success) {
98517
98539
  const presenceUpdatedAt = Number(delta.data.presenceKey.split(":")[0]);
98518
98540
  const resolvedAt = Number.isFinite(presenceUpdatedAt) ? presenceUpdatedAt : 0;
98519
98541
  return {
@@ -99436,11 +99458,13 @@ async function runRestartOrchestrator(deps, event) {
99436
99458
  markRestartOrchestratorInFlight(chatroomId, role, event.correlationId);
99437
99459
  try {
99438
99460
  resetRoleDeliveryState(chatroomId, role);
99461
+ await emitPhase(deps, event, "reset");
99439
99462
  await deps.agentMgr.stop({
99440
99463
  chatroomId,
99441
99464
  role,
99442
99465
  reason: "user.restart"
99443
99466
  });
99467
+ await emitPhase(deps, event, "spawn");
99444
99468
  const spawnResult = await exports_Effect.runPromise(deps.agentMgr.ensureRunning({
99445
99469
  chatroomId,
99446
99470
  role,
@@ -99454,13 +99478,17 @@ async function runRestartOrchestrator(deps, event) {
99454
99478
  await emitPhase(deps, event, "failed", spawnResult.error ?? "spawn failed");
99455
99479
  return;
99456
99480
  }
99481
+ await emitPhase(deps, event, "await_session");
99457
99482
  const harnessSessionId = await waitForHarnessSessionId(deps, event, spawnResult.pid);
99458
99483
  if (!harnessSessionId) {
99459
99484
  await emitPhase(deps, event, "failed", "harnessSessionId timeout");
99460
99485
  return;
99461
99486
  }
99462
99487
  await forceNativeWaiting(deps, event);
99488
+ await emitPhase(deps, event, "ready");
99489
+ await emitPhase(deps, event, "deliver");
99463
99490
  const deliveredTaskIds = await deliverPendingTasks(deps, event);
99491
+ await emitPhase(deps, event, "completed");
99464
99492
  await deps.session.backend.mutation(api.machines.emitRestartCompleted, {
99465
99493
  sessionId: deps.session.sessionId,
99466
99494
  machineId: deps.session.machineId,
@@ -127310,13 +127338,13 @@ import { dirname as dirname15, join as join27 } from "node:path";
127310
127338
  import { fileURLToPath as fileURLToPath7 } from "node:url";
127311
127339
  function clientDistCandidates(here) {
127312
127340
  return [
127341
+ join27(here, "client/build"),
127313
127342
  join27(here, "../client/build"),
127314
- join27(here, "../src/daemon/local-web/client/build"),
127315
- join27(here, "../../../src/daemon/local-web/client/build")
127343
+ join27(here, "../src/daemon/local-web/client/build")
127316
127344
  ];
127317
127345
  }
127318
- function resolveClientDistDir() {
127319
- const candidates = clientDistCandidates(dirname15(fileURLToPath7(import.meta.url)));
127346
+ function resolveClientDistDir(here = dirname15(fileURLToPath7(import.meta.url))) {
127347
+ const candidates = clientDistCandidates(here);
127320
127348
  for (const dir of candidates) {
127321
127349
  if (existsSync9(join27(dir, "index.html")))
127322
127350
  return dir;
@@ -127598,7 +127626,7 @@ async function startLocalWebServer(config4, deps = {}) {
127598
127626
  throw new Error(`local-web must bind to 127.0.0.1 only (got ${config4.host})`);
127599
127627
  }
127600
127628
  const streamHub = deps.streamHub ?? createStreamHub();
127601
- const clientDistDir = resolveClientDistDir();
127629
+ const clientDistDir = deps.clientDistDir ?? resolveClientDistDir();
127602
127630
  const server2 = createServer((req, res) => {
127603
127631
  if (tryServeStatic(req, res, clientDistDir))
127604
127632
  return;
@@ -127633,8 +127661,14 @@ async function startLocalWebServer(config4, deps = {}) {
127633
127661
  streamHub,
127634
127662
  stop() {
127635
127663
  return new Promise((resolve8, reject) => {
127636
- io2.close();
127637
- server2.close((err) => err ? reject(err) : resolve8());
127664
+ io2.close((err) => {
127665
+ if (err) {
127666
+ reject(err);
127667
+ return;
127668
+ }
127669
+ resolve8();
127670
+ });
127671
+ server2.closeAllConnections();
127638
127672
  });
127639
127673
  }
127640
127674
  };
@@ -128935,4 +128969,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
128935
128969
  });
128936
128970
  program2.parse();
128937
128971
 
128938
- //# debugId=70FFCDEB51C1508364756E2164756E21
128972
+ //# debugId=2445D97C1319365564756E2164756E21