arco-workbench 0.1.5 → 0.1.6

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 (154) hide show
  1. package/CONTRIBUTING.md +9 -0
  2. package/README.md +11 -4
  3. package/client/dist/assets/{PhosphorBackdrop-D6cbmLNY.js → PhosphorBackdrop-BR-TgB5x.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-2dyerOi4.js → ThemedBackgroundShaderImpl-DgcFj6JN.js} +1 -1
  5. package/client/dist/assets/{XtermView-AIwo7O3D.js → XtermView-CflVBQgC.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-DXAuxS8D.js → galleryEditor-BB-emfmi.js} +1 -1
  7. package/client/dist/assets/{index-8j6p-pmQ.js → index-B_EqHDz3.js} +242 -240
  8. package/client/dist/index.html +1 -1
  9. package/client/src/alerts/desktopAlerts.ts +13 -0
  10. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +28 -5
  11. package/client/src/components/ClusterRightPanel/MemberRow.tsx +1 -1
  12. package/client/src/components/ClusterTaskBoardTab.tsx +54 -3
  13. package/client/src/components/ContextMeter.tsx +7 -0
  14. package/client/src/components/Home/HomeView.tsx +1 -1
  15. package/client/src/components/NeedsYouBadge.tsx +31 -16
  16. package/client/src/components/OperatorQuestionNotice.tsx +10 -1
  17. package/client/src/components/ProvidersPopover.tsx +23 -12
  18. package/client/src/components/TabBar.tsx +11 -8
  19. package/client/src/components/TabStatusChip.tsx +8 -7
  20. package/client/src/components/clusterNeedsYou.ts +27 -8
  21. package/client/src/help/content/cluster.tsx +34 -22
  22. package/client/src/help/content/composer.tsx +8 -1
  23. package/client/src/help/content/header.tsx +22 -13
  24. package/client/src/help/content/misc.tsx +8 -0
  25. package/client/src/help/content/tabbar.tsx +2 -1
  26. package/client/src/help/manualSections/clusters.tsx +61 -18
  27. package/client/src/help/manualSections/gettingStarted.tsx +10 -0
  28. package/client/src/help/manualSections/maintenance.tsx +38 -8
  29. package/client/src/help/manualSections/providers.tsx +10 -3
  30. package/client/src/help/manualSections/reference.tsx +1 -1
  31. package/client/src/help/manualSections/workflows.tsx +13 -0
  32. package/client/src/help/manualSections/workspace.tsx +7 -1
  33. package/client/src/questions/waitingQuestion.ts +3 -2
  34. package/client/src/stores/appStore.ts +1 -1
  35. package/client/src/stores/appStore.types.ts +1 -0
  36. package/client/src/stores/notificationStore.ts +2 -0
  37. package/client/src/utils/activityPresentation.ts +1 -1
  38. package/client/src/utils/tabStatus.ts +8 -0
  39. package/client/src/voice/commands.ts +4 -3
  40. package/client/src/voice/executor.ts +3 -3
  41. package/client/src/ws/handleServerMessage.ts +22 -2
  42. package/client/src/ws/operatorQuestions.ts +2 -0
  43. package/docs/CLIENT.md +3 -3
  44. package/docs/FEATURES.md +1 -1
  45. package/docs/GETTING_STARTED.md +11 -5
  46. package/docs/GLOSSARY.md +6 -2
  47. package/docs/GOTCHAS.md +17 -5
  48. package/docs/OPERATIONS.md +184 -5
  49. package/docs/PERSISTENCE.md +4 -0
  50. package/docs/PRIMITIVES.md +1 -1
  51. package/docs/PROTOCOL.md +1 -1
  52. package/docs/PROTOCOL_CLUSTER.md +9 -5
  53. package/docs/PROVIDERS.md +10 -5
  54. package/docs/SETTINGS.md +4 -2
  55. package/docs/TASK_LEDGER.md +6 -0
  56. package/docs/VOICE.md +2 -0
  57. package/native/win32-arm64/manifest.json +1 -1
  58. package/node_modules/@arco/shared/dist/clusterRolePresets.d.ts +1 -1
  59. package/node_modules/@arco/shared/dist/clusterRolePresets.js +10 -0
  60. package/node_modules/@arco/shared/dist/protocol/autoPickup.js +9 -1
  61. package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +2 -2
  62. package/node_modules/@arco/shared/dist/protocol/models.d.ts +6 -0
  63. package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +4 -0
  64. package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +12 -0
  65. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +9 -3
  66. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
  67. package/node_modules/@arco/shared/package.json +1 -1
  68. package/package.json +2 -2
  69. package/scripts/packaging/arco.mjs +1 -0
  70. package/server/dist/attention.d.ts +1 -1
  71. package/server/dist/attention.js +6 -4
  72. package/server/dist/capabilities.d.ts +9 -8
  73. package/server/dist/capabilities.js +71 -102
  74. package/server/dist/cliUpdateDecision.d.ts +34 -0
  75. package/server/dist/cliUpdateDecision.js +152 -0
  76. package/server/dist/clusterDirector.js +1 -0
  77. package/server/dist/clusterPeerOps.js +2 -2
  78. package/server/dist/defaults/models.md +1 -1
  79. package/server/dist/fileAccessPolicy.js +7 -5
  80. package/server/dist/http/workflowDataRoutes.js +1 -1
  81. package/server/dist/index.js +5 -1
  82. package/server/dist/primitives/seedWorker.d.ts +1 -0
  83. package/server/dist/primitives/seedWorker.js +2 -1
  84. package/server/dist/providerConversation.d.ts +9 -0
  85. package/server/dist/providerConversation.js +80 -0
  86. package/server/dist/providers/claude-native/retainedContext.d.ts +4 -0
  87. package/server/dist/providers/claude-native/retainedContext.js +20 -0
  88. package/server/dist/providers/claude-native/worker.d.ts +1 -0
  89. package/server/dist/providers/claude-native/worker.js +34 -6
  90. package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -0
  91. package/server/dist/providers/codex-appserver/operatorQuestions.js +30 -0
  92. package/server/dist/providers/codex-appserver/worker.js +9 -4
  93. package/server/dist/providers/ollama.js +2 -3
  94. package/server/dist/server/broadcast.d.ts +1 -1
  95. package/server/dist/smartPickupAdapters.d.ts +1 -0
  96. package/server/dist/smartPickupAdapters.js +18 -5
  97. package/server/dist/smartPickupObserver.js +45 -8
  98. package/server/dist/workers/WorkerManager.d.ts +1 -0
  99. package/server/dist/workers/WorkerManager.js +1 -0
  100. package/server/dist/workers/limits.js +6 -2
  101. package/server/dist/workflowMeta.d.ts +11 -1
  102. package/server/dist/workflowMeta.js +132 -6
  103. package/server/dist/workflows/types.d.ts +1 -0
  104. package/server/dist/ws/compactHandlers.d.ts +1 -1
  105. package/server/dist/ws/compactHandlers.js +11 -4
  106. package/server/dist/ws/handoffHandlers.js +16 -6
  107. package/server/dist/ws/operatorQuestionHandlers.d.ts +2 -1
  108. package/server/dist/ws/operatorQuestionHandlers.js +9 -1
  109. package/server/dist/ws/turnEngine.d.ts +2 -4
  110. package/server/dist/ws/turnEngine.js +88 -129
  111. package/server/package.json +1 -1
  112. package/server/src/attention.ts +5 -4
  113. package/server/src/capabilities.ts +70 -111
  114. package/server/src/cliUpdateDecision.ts +159 -0
  115. package/server/src/clusterDirector.ts +1 -0
  116. package/server/src/clusterPeerOps.ts +2 -2
  117. package/server/src/defaults/models.md +1 -1
  118. package/server/src/fileAccessPolicy.ts +7 -5
  119. package/server/src/http/workflowDataRoutes.ts +1 -1
  120. package/server/src/index.ts +5 -1
  121. package/server/src/primitives/seedWorker.ts +3 -1
  122. package/server/src/providerConversation.ts +71 -0
  123. package/server/src/providers/claude-native/retainedContext.ts +22 -0
  124. package/server/src/providers/claude-native/worker.ts +33 -5
  125. package/server/src/providers/codex-appserver/operatorQuestions.ts +24 -0
  126. package/server/src/providers/codex-appserver/worker.ts +8 -4
  127. package/server/src/providers/ollama.ts +2 -3
  128. package/server/src/smartPickupAdapters.ts +19 -5
  129. package/server/src/smartPickupObserver.ts +31 -6
  130. package/server/src/workers/WorkerManager.ts +2 -0
  131. package/server/src/workers/limits.ts +7 -2
  132. package/server/src/workflowMeta.ts +139 -5
  133. package/server/src/workflows/types.ts +1 -0
  134. package/server/src/ws/compactHandlers.ts +9 -3
  135. package/server/src/ws/handoffHandlers.ts +13 -6
  136. package/server/src/ws/operatorQuestionHandlers.ts +10 -2
  137. package/server/src/ws/turnEngine.ts +80 -135
  138. package/shared/dist/clusterRolePresets.d.ts +1 -1
  139. package/shared/dist/clusterRolePresets.js +10 -0
  140. package/shared/dist/protocol/autoPickup.js +9 -1
  141. package/shared/dist/protocol/clientMessages.d.ts +2 -2
  142. package/shared/dist/protocol/models.d.ts +6 -0
  143. package/shared/dist/protocol/notifications.d.ts +4 -0
  144. package/shared/dist/protocol/operatorQuestions.d.ts +12 -0
  145. package/shared/dist/protocol/serverMessages.d.ts +9 -3
  146. package/shared/dist/protocol/workflows.d.ts +1 -0
  147. package/shared/src/clusterRolePresets.ts +11 -1
  148. package/shared/src/protocol/autoPickup.ts +9 -1
  149. package/shared/src/protocol/clientMessages.ts +2 -1
  150. package/shared/src/protocol/models.ts +5 -2
  151. package/shared/src/protocol/notifications.ts +5 -0
  152. package/shared/src/protocol/operatorQuestions.ts +13 -0
  153. package/shared/src/protocol/serverMessages.ts +12 -2
  154. package/shared/src/protocol/workflows.ts +4 -0
@@ -9,7 +9,7 @@
9
9
  // decision per unchanged mail fingerprint per session; an evaluator slot is
10
10
  // reserved before any request and always counts. A result is discarded when
11
11
  // the session or mode changed while it was running.
12
- import { isSmartPickupMode, presetForText, sanitizeSmartPickupLimits, } from '@arco/shared';
12
+ import { isSmartPickupMode, isAutoPickupAcknowledgement, presetForText, sanitizeSmartPickupLimits, } from '@arco/shared';
13
13
  import * as clusterStore from './clusterStore.js';
14
14
  import * as clusterMailbox from './clusterMailbox.js';
15
15
  import * as taskLedger from './project/taskLedger.js';
@@ -153,8 +153,10 @@ export async function evaluateOnce(clusterId, workflowId) {
153
153
  if (prior && prior.sessionId === arm.sessionId && prior.fingerprint === snapshot.fingerprint) {
154
154
  // An admitted-in-principle wake that was blocked by a passing condition
155
155
  // (busy, cooldown) is retried without asking the evaluator again.
156
- if (prior.wakeOwed && arm.mode === 'smart-auto')
157
- return gateAndRecord({ ...base, action: 'wake', reason: 'retry', outcome: 'pending' }, arm);
156
+ if (prior.wakeOwed && arm.mode === 'smart-auto') {
157
+ const fallback = prior.action === null;
158
+ return gateAndRecord({ ...base, action: fallback ? null : 'wake', reason: fallback ? prior.reason : 'retry', outcome: 'pending' }, arm);
159
+ }
158
160
  // A defer lapses after deferMs so unchanged mail is looked at again; an
159
161
  // evaluation refused by a passing limit is attempted again.
160
162
  const deferLapsed = prior.action === 'defer' && prior.deferUntil !== undefined && deps.now() >= prior.deferUntil;
@@ -211,21 +213,32 @@ export async function evaluateOnce(clusterId, workflowId) {
211
213
  }
212
214
  if (failure !== null) {
213
215
  const d = { ...base, action: null, reason: `evaluator_error:${failure}`.slice(0, 64), outcome: 'none' };
214
- // A failure before the evaluator session was ready (a cold agent start)
215
- // says nothing about this mail: evaluate the same mail once more, with a
216
- // new reservation counted against the limits. Any other failure, or a
217
- // second start-up failure, stands until the mail changes.
216
+ // Preserve the established one retry for a failure before the evaluator
217
+ // session was ready: the model has not seen this mail yet. The retry
218
+ // spends its own reservation. A second startup failure or any other
219
+ // failure then takes the guarded fallback path without another request.
218
220
  const sameMail = prior?.fingerprint === snapshot.fingerprint && prior.sessionId === arm.sessionId;
219
221
  if (isStartupFailure(failure) && !(sameMail && prior?.startupRetried)) {
220
222
  await record(d, { retryEvaluation: true, startupRetried: true });
221
223
  return d;
222
224
  }
225
+ if (failure === 'cancelled') {
226
+ d.outcome = 'discarded';
227
+ await record(d);
228
+ return d;
229
+ }
230
+ if (still.mode === 'smart-auto')
231
+ return gateAndRecord(d, still);
232
+ d.outcome = 'fallback_observed';
223
233
  await record(d);
224
234
  return d;
225
235
  }
226
236
  const parsed = parseEvaluatorAnswer(raw);
227
237
  if (!parsed.ok) {
228
238
  const d = { ...base, action: null, reason: `invalid_answer:${parsed.problem}`, outcome: 'none' };
239
+ if (still.mode === 'smart-auto')
240
+ return gateAndRecord(d, still);
241
+ d.outcome = 'fallback_observed';
229
242
  await record(d);
230
243
  return d;
231
244
  }
@@ -245,7 +258,10 @@ export async function evaluateOnce(clusterId, workflowId) {
245
258
  const TRANSIENT = new Set(['busy', 'cooldown', 'rate_capped', 'limit_wakes_member_hour']);
246
259
  async function gateAndRecord(proposal, arm) {
247
260
  const result = await gateWake(proposal, arm);
248
- const d = { ...proposal, outcome: result.outcome, ...(result.reason ? { reason: proposal.reason === 'retry' ? result.reason : `${proposal.reason}:${result.reason}` } : {}) };
261
+ const fallback = proposal.action === null;
262
+ const d = fallback
263
+ ? { ...proposal, outcome: `fallback_${result.outcome}${result.reason ? `:${result.reason}` : ''}` }
264
+ : { ...proposal, outcome: result.outcome, ...(result.reason ? { reason: proposal.reason === 'retry' ? result.reason : `${proposal.reason}:${result.reason}` } : {}) };
249
265
  const owed = result.outcome !== 'woke' && result.reason !== undefined && TRANSIENT.has(result.reason);
250
266
  await record(d, owed ? { wakeOwed: true } : {});
251
267
  return d;
@@ -297,6 +313,27 @@ async function gateWake(p, arm) {
297
313
  refusal = 'mail_changed';
298
314
  return false;
299
315
  }
316
+ if (p.action === null) {
317
+ // Ordinary pickup ignores bare acknowledgements. Re-read the same
318
+ // exact mailbox under its lock; unreadable or empty mail cannot
319
+ // authorise fallback, and attachments retain their normal exception.
320
+ let pending;
321
+ try {
322
+ pending = await clusterMailbox.peek(wfid);
323
+ }
324
+ catch {
325
+ refusal = 'unverifiable';
326
+ return false;
327
+ }
328
+ if (ids.length === 0 || pending.length !== ids.length || pending.some((m) => !ids.includes(m.msgId))) {
329
+ refusal = 'unverifiable';
330
+ return false;
331
+ }
332
+ if (pending.every((m) => !m.artifacts?.length && isAutoPickupAcknowledgement(m.content))) {
333
+ refusal = 'ack_only';
334
+ return false;
335
+ }
336
+ }
300
337
  if (await smartPickupHoldActive(clusterId, wfid, ids, deps.now()).catch(() => true)) {
301
338
  refusal = 'stop_hold';
302
339
  return false;
@@ -53,6 +53,7 @@ export declare class WorkerManager {
53
53
  sessionId?: string;
54
54
  }) => void;
55
55
  drainSteer?: WorkerConfig['drainSteer'];
56
+ peekSteer?: WorkerConfig['peekSteer'];
56
57
  requeueSteer?: WorkerConfig['requeueSteer'];
57
58
  onSteerDelivered?: WorkerConfig['onSteerDelivered'];
58
59
  codexTransport?: WorkerConfig['codexTransport'];
@@ -64,6 +64,7 @@ export class WorkerManager {
64
64
  voiceOperator: options?.voiceOperator,
65
65
  incognito: options?.incognito,
66
66
  drainSteer: options?.drainSteer,
67
+ peekSteer: options?.peekSteer,
67
68
  requeueSteer: options?.requeueSteer,
68
69
  onSteerDelivered: options?.onSteerDelivered,
69
70
  // Phase 6 — workflowId is required for per-workflow-lifetime providers
@@ -19,7 +19,7 @@ function formatCapMb(bytes) {
19
19
  }
20
20
  export const OUTPUT_TRUNCATION_NOTICE = `\n\n[OUTPUT TRUNCATED — Arco enforced ${formatCapMb(MAX_WORKER_OUTPUT_BYTES)} worker-output cap. ` +
21
21
  'For reports larger than this, instruct the worker to write the full ' +
22
- 'output to a markdown file in the workflow artifacts directory and return only a brief summary + path.]';
22
+ 'output to a markdown file in the workflow artifacts directory and return only a brief summary + path, unless the operator wants it kept in the project.]';
23
23
  function parseRssEnv() {
24
24
  const raw = process.env.ARCO_RSS_KILL_BYTES;
25
25
  if (!raw)
@@ -61,6 +61,10 @@ export function buildWorkerSafetyFooter(cwd, wfid) {
61
61
  const bigOutputLine = dir
62
62
  ? `- For report-shaped outputs (deep dives, inventories, audits, multi-section findings), write a markdown file into \`${dir}/\` (this directory already exists) and return a brief summary that names the file in backticks (for example \`audit-spawns.md\`) so it is clickable in chat. Do NOT write report files at the project root — Arco tracks artifacts per-workflow and surfaces them inline in chat. For ordinary prose responses — even detailed ones — return the full text inline; the operator reads it in chat.`
63
63
  : `- For report-shaped outputs (deep dives, inventories, audits, multi-section findings), write a markdown file in the cwd and return a brief summary + absolute path. For ordinary prose responses — even detailed ones — return the full text inline; the operator reads it in chat.`;
64
+ const projectStateLine = `Never commit, force-add or add an ignore exception for \`.arco/\`, which is local state, except a skill shared through SHARE WITH REPOSITORY.`;
65
+ const projectFilesLine = dir
66
+ ? `\n- Put files the operator wants kept in the project (documentation, a README or notes to commit) in the project tree, for example \`docs/\`, not in artifacts. ${projectStateLine}`
67
+ : `\n- ${projectStateLine}`;
64
68
  const scratchLine = dir
65
69
  ? `\n- Put large intermediate files (builds, disk images, downloads, datasets) in \`${path.join(path.dirname(dir), 'scratch')}/\` (create it if missing), not in artifacts. Keep only finished deliverables in artifacts. The operator empties scratch with EMPTY SCRATCH; nothing there is deleted automatically.`
66
70
  : '';
@@ -72,7 +76,7 @@ export function buildWorkerSafetyFooter(cwd, wfid) {
72
76
  - No \`find /\` / \`du -sh /\` without \`-maxdepth\` and exclusions for \`/proc /sys /dev /run\`. Skip \`~/.cache\`, \`node_modules\`, \`.git/objects\`, \`/var/cache\`, \`/snap\`.
73
77
  - No reads of \`/proc/kcore\`, \`/proc/*/mem\`, \`/dev/{kmem,mem,zero,urandom}\` past first KB. No unbounded \`journalctl\` or \`while true\` loops.
74
78
  - No \`cat\` of files >10MB; use \`head -c 100K\` instead. \`xargs\` always with explicit limits.
75
- ${bigOutputLine}${scratchLine}
79
+ ${bigOutputLine}${projectFilesLine}${scratchLine}
76
80
  - Arco will hard-kill your process tree at 32GB RSS or ${formatCapMb(MAX_WORKER_OUTPUT_BYTES)} returned output. These are the floor, not the budget.
77
81
  `;
78
82
  }
@@ -1,3 +1,4 @@
1
+ import type { PrimaryConfig } from './primitives/seedWorker.js';
1
2
  import type { ProviderName, ModelName, EffortLevel, WorkflowMetaSummary, SessionHistoryEntry, PreviewHistoryEntry, SessionInfo, McpWorkflowAllow, GenesisSeed, WorkflowConfig, ArcoSkillRef, AutoHandoffConfig } from '@arco/shared';
2
3
  declare const WFID_PATTERN: RegExp;
3
4
  export declare function workflowDir(cwd: string, wfid: string): string;
@@ -23,6 +24,7 @@ export interface WorkflowMeta {
23
24
  providerAccountRef?: string;
24
25
  schemaVersion?: number;
25
26
  cliSessions: WorkflowCliSession[];
27
+ providerConversationPendingReading?: boolean;
26
28
  history?: SessionHistoryEntry[];
27
29
  handoffHistory?: import('./handoffHistory.js').HandoffHistorySource[];
28
30
  operator: string;
@@ -119,7 +121,7 @@ export declare function ensureMeta(cwd: string, seed: WorkflowMeta): Promise<Wor
119
121
  export declare function setResolvedModelId(cwd: string, wfid: string, resolvedModelId: string): Promise<void>;
120
122
  export declare function touchLastActive(cwd: string, wfid: string): Promise<void>;
121
123
  export declare function appendCliSession(cwd: string, wfid: string, session: WorkflowCliSession): Promise<void>;
122
- export declare function reconcileLatestCliSession(cwd: string, wfid: string, provider: ProviderName, liveSessionId: string, providerAccountRef?: string): Promise<void>;
124
+ export declare function reconcileLatestCliSession(cwd: string, wfid: string, provider: ProviderName, liveSessionId: string, providerAccountRef?: string, seed?: WorkflowMeta): Promise<void>;
123
125
  export declare function latestCliSessionFor(meta: WorkflowMeta, provider: ProviderName): WorkflowCliSession | null;
124
126
  export declare function arcoInternalSessionInfoForMeta(meta: WorkflowMeta): SessionInfo | null;
125
127
  export declare function appendHistoryEntry(cwd: string, wfid: string, entry: SessionHistoryEntry): Promise<void>;
@@ -127,3 +129,11 @@ export declare function clearProviderCliSessions(cwd: string, wfid: string, prov
127
129
  export declare function setMcpAllow(cwd: string, wfid: string, entry: McpWorkflowAllow): Promise<McpWorkflowAllow[] | null>;
128
130
  export declare function setMcpProbedTools(cwd: string, wfid: string, serverId: string, tools: McpWorkflowAllow['tools']): Promise<void>;
129
131
  export declare function listWorkflowMetas(cwd: string): Promise<WorkflowMetaSummary[]>;
132
+ export declare function workflowMetaSeed(cwd: string, workflowId: string, config: WorkflowConfig, primary: Pick<PrimaryConfig, 'provider' | 'model' | 'effort'>, opts?: {
133
+ parentWorkflowId?: string;
134
+ }): WorkflowMeta;
135
+ export declare function persistInitialMeta(cwd: string, workflowId: string, config: WorkflowConfig, primary: Pick<PrimaryConfig, 'provider' | 'model' | 'effort'>, opts?: {
136
+ parentWorkflowId?: string;
137
+ sessionId?: string;
138
+ pendingReading?: boolean;
139
+ }): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import { beginConversationWrite } from './conversationActivity.js';
2
2
  import { ensureProjectStateIgnore } from './projectStateIgnore.js';
3
- import { normalizeAutoHandoff, normalizeOutputStyle, retiredProviderReason, resolveAutoCompactionPolicy } from '@arco/shared';
3
+ import { isAutoCompactionPolicy, storedOutputStyle, normalizeAutoHandoff, normalizeOutputStyle, retiredProviderReason, resolveAutoCompactionPolicy } from '@arco/shared';
4
4
  // Slot 9 — per-workflow identity + session ledger (meta.json).
5
5
  //
6
6
  // Lives at <cwd>/.arco/workflows/<wfid>/meta.json alongside Slot 5's
@@ -226,8 +226,8 @@ export async function updateMeta(cwd, wfid, mutate) {
226
226
  });
227
227
  }
228
228
  // Ensure a meta.json exists — write one from `seed` if missing. Used by the
229
- // rehydrate path so pre-Slot-9 workflows (no meta.json on disk) get one
230
- // lazily the next time their client reconnects.
229
+ // creation, reconnect and turn paths. Existing metadata is preserved, including
230
+ // updates that land while the caller is constructing its authoritative seed.
231
231
  export async function ensureMeta(cwd, seed) {
232
232
  if (!cwd)
233
233
  return seed;
@@ -270,11 +270,16 @@ export async function appendCliSession(cwd, wfid, session) {
270
270
  // with Arco's placeholder id. Update that provider's latest entry in place
271
271
  // rather than appending a second row; when the ids already match, only refresh
272
272
  // lastActiveAt. This keeps resume lookup aligned with the live CLI session
273
- // after initial binding or session rotation.
274
- export async function reconcileLatestCliSession(cwd, wfid, provider, liveSessionId, providerAccountRef) {
273
+ // after initial binding or session rotation. An authoritative seed repairs a
274
+ // missing file inside the same lock; generic updateMeta remains update-only.
275
+ export async function reconcileLatestCliSession(cwd, wfid, provider, liveSessionId, providerAccountRef, seed) {
275
276
  if (!cwd || !liveSessionId)
276
277
  return;
277
- await updateMeta(cwd, wfid, (meta) => {
278
+ validateWfid(wfid);
279
+ await withFileLock(metaPath(cwd, wfid), async () => {
280
+ const meta = await readMeta(cwd, wfid) ?? seed;
281
+ if (!meta)
282
+ throw new Error('Workflow metadata is missing; the provider conversation was not saved.');
278
283
  // Find the latest entry for this provider (not strictly the last overall —
279
284
  // a cross-provider workflow might have interleaved entries).
280
285
  let latestIdx = -1;
@@ -295,6 +300,13 @@ export async function reconcileLatestCliSession(cwd, wfid, provider, liveSession
295
300
  meta.cliSessions[latestIdx].providerAccountRef = providerAccountRef;
296
301
  }
297
302
  meta.lastActiveAt = now;
303
+ if (seed) {
304
+ if (seed.providerConversationPendingReading)
305
+ meta.providerConversationPendingReading = true;
306
+ else
307
+ delete meta.providerConversationPendingReading;
308
+ }
309
+ await writeMeta(cwd, meta);
298
310
  });
299
311
  }
300
312
  // Most recent CLI session for the given provider, or null if the workflow
@@ -421,4 +433,118 @@ export async function listWorkflowMetas(cwd) {
421
433
  out.sort((a, b) => b.lastActiveAt - a.lastActiveAt);
422
434
  return out;
423
435
  }
436
+ export function workflowMetaSeed(cwd, workflowId, config, primary, opts) {
437
+ const now = Date.now();
438
+ return {
439
+ workflowId,
440
+ name: config.name,
441
+ cwd,
442
+ ...(config.kind === 'chat' ? { kind: 'chat' } : {}),
443
+ ...(config.kind === 'chat' && config.voiceOperator === true ? { voiceOperator: true } : {}),
444
+ createdAt: now,
445
+ lastActiveAt: now,
446
+ primaryProvider: primary.provider,
447
+ primaryModel: primary.model,
448
+ primaryEffort: primary.effort,
449
+ ...(config.providerAccountRef ? { providerAccountRef: config.providerAccountRef } : {}),
450
+ cliSessions: [],
451
+ operator: 'local',
452
+ lastEventSeq: null,
453
+ lastTranscriptSeq: null,
454
+ compactedAt: null,
455
+ ...(config.pinnedSkills?.length
456
+ ? { pinnedSkills: config.pinnedSkills.map((s) => ({ scope: s.scope, slug: s.slug })) }
457
+ : {}),
458
+ ...(opts?.parentWorkflowId ? { parentWorkflowId: opts.parentWorkflowId } : {}),
459
+ // docs/PROVIDERS.md / docs/PROVIDERS.md - when the New-tab
460
+ // picker (or Spawn-from-here parent inheritance) provided a non-default
461
+ // value, persist it to disk on the very first meta write so a server
462
+ // restart before the operator's first turn doesn't lose the pick.
463
+ // Sanitized one more time at write-site against unknown values reaching
464
+ // disk via a hand-edited cascade default.
465
+ ...(config.efficiencyToolFilter === 'off' || config.efficiencyToolFilter === 'conservative' || config.efficiencyToolFilter === 'aggressive'
466
+ ? { efficiencyToolFilter: config.efficiencyToolFilter }
467
+ : {}),
468
+ // docs/PROVIDERS.md - persist the stamped new-tab default or
469
+ // an explicit operator choice on the first meta write.
470
+ ...(config.efficiencyFactForce === 'on' || config.efficiencyFactForce === 'off'
471
+ ? { efficiencyFactForce: config.efficiencyFactForce }
472
+ : {}),
473
+ // Persist an explicit config-protection choice to disk on first meta-write
474
+ // so an operator opt-out survives a restart. Absent ⇒ gate ON by default.
475
+ ...(config.efficiencyConfigProtection === 'on' || config.efficiencyConfigProtection === 'off'
476
+ ? { efficiencyConfigProtection: config.efficiencyConfigProtection }
477
+ : {}),
478
+ ...(typeof config.claudeNativeCompact === 'boolean'
479
+ ? {
480
+ claudeNativeCompact: config.claudeNativeCompact,
481
+ ...(config.claudeNativeCompact === true ? { claudeNativeCompactUserSetAt: now } : {}),
482
+ }
483
+ : {}),
484
+ ...(typeof config.claudeNativeForceInterleavedThinkingBeta === 'boolean'
485
+ ? { claudeNativeForceInterleavedThinkingBeta: config.claudeNativeForceInterleavedThinkingBeta }
486
+ : {}),
487
+ nativeSubagents: config.nativeSubagents,
488
+ claudeNativeTaskDisabled: config.claudeNativeTaskDisabled,
489
+ ...(config.claudeNativeThinkingDisplay === 'omitted' || config.claudeNativeThinkingDisplay === 'summarized' || config.claudeNativeThinkingDisplay === 'updates'
490
+ ? { claudeNativeThinkingDisplay: config.claudeNativeThinkingDisplay }
491
+ : {}),
492
+ ...(config.codexTransport === 'exec' || config.codexTransport === 'appserver'
493
+ ? { codexTransport: config.codexTransport }
494
+ : {}),
495
+ ...(config.codexContextPolicy === 'max' || config.codexContextPolicy === 'standard'
496
+ ? { codexContextPolicy: config.codexContextPolicy }
497
+ : {}),
498
+ ...(config.claudeTransport === 'cli' || config.claudeTransport === 'native'
499
+ ? { claudeTransport: config.claudeTransport }
500
+ : {}),
501
+ // Persist the seeded auto-handoff default on the first meta-write so a
502
+ // server restart before the operator's first turn keeps the global
503
+ // default (handleCreateWorkflow bakes it into config for new tabs). The
504
+ // savedMeta restore in handleCreateWorkflow reads this back.
505
+ ...(isAutoCompactionPolicy(config.autoCompaction) ? { autoCompaction: { ...config.autoCompaction } } : {}),
506
+ ...(config.autoHandoff ? { autoHandoff: { ...config.autoHandoff } } : {}),
507
+ // docs/PROVIDERS.md - persist the sandbox toggle on the
508
+ // first meta-write when the cascade default supplied a non-undefined
509
+ // value. Default is 'off'; only the explicit on/off pair lands here so
510
+ // a stale cascade doesn't accidentally turn the sandbox on for tabs
511
+ // that were never asked.
512
+ ...(config.efficiencySandbox === 'on' || config.efficiencySandbox === 'off'
513
+ ? { efficiencySandbox: config.efficiencySandbox }
514
+ : {}),
515
+ // docs/PROVIDERS.md - persist the review-gate toggle on the first meta-write
516
+ // when the cascade default supplied an explicit value, so an operator opt-in
517
+ // survives a restart before the first turn. Default 'off'.
518
+ ...(config.reviewSafeMode === 'on' || config.reviewSafeMode === 'off'
519
+ ? { reviewSafeMode: config.reviewSafeMode }
520
+ : {}),
521
+ // Only a style other than the default is written; unset means
522
+ // DEFAULT_OUTPUT_STYLE. Legacy `lite` / `caveman` from a stale client are
523
+ // written as `plain` / `terse` (plain being the default, it stays unset).
524
+ ...(storedOutputStyle(config.outputStyle) ? { outputStyle: storedOutputStyle(config.outputStyle) } : {}),
525
+ // docs/GOTCHAS.md - persist a north-star seeded before the first turn
526
+ // (e.g. a Spawn-from-here that inherited the parent's) so it survives a
527
+ // restart even if the operator never re-sets it. Blank ⇒ omitted.
528
+ ...(config.goal && config.goal.trim() ? { goal: config.goal } : {}),
529
+ // docs/PROVIDERS.md - persist sticky ultracode on the first meta-write so a
530
+ // tab left in ultracode survives a restart (the rehydrate read in
531
+ // workflowHandlers.ts expects saved.ultracode). Without this the flag lives
532
+ // only in-memory and the tab silently drops out of ultracode on restart.
533
+ ...(config.ultracode === true ? { ultracode: true } : {}),
534
+ ...(typeof config.webSearchMaxUses === 'number' ? { webSearchMaxUses: config.webSearchMaxUses } : {}),
535
+ ...(config.managedWorktreeSourceCwd
536
+ ? { managedWorktreeSourceCwd: config.managedWorktreeSourceCwd }
537
+ : {}),
538
+ };
539
+ }
540
+ export async function persistInitialMeta(cwd, workflowId, config, primary, opts) {
541
+ if (config.incognito)
542
+ return;
543
+ const seed = workflowMetaSeed(cwd, workflowId, config, primary, opts);
544
+ if (opts?.pendingReading)
545
+ seed.providerConversationPendingReading = true;
546
+ if (opts?.sessionId)
547
+ seed.cliSessions.push({ provider: primary.provider, sessionId: opts.sessionId, createdAt: Date.now(), providerAccountRef: config.providerAccountRef });
548
+ await ensureMeta(cwd, seed);
549
+ }
424
550
  //# sourceMappingURL=workflowMeta.js.map
@@ -19,6 +19,7 @@ export interface WorkflowState {
19
19
  manager: WorkerManager;
20
20
  primary: PrimaryConfig;
21
21
  primarySessionId?: string;
22
+ providerConversation?: 'unavailable' | 'awaiting-reading';
22
23
  primaryTurn?: {
23
24
  token: number;
24
25
  workerId?: string;
@@ -1,5 +1,5 @@
1
1
  import { WebSocket } from 'ws';
2
2
  import type { CompactWorkflowMessage, FoldWorkflowMessage } from '@arco/shared';
3
3
  import type { Session } from '../workflows/types.js';
4
- export declare function handleCompactWorkflow(ws: WebSocket, session: Session, msg: CompactWorkflowMessage, claimGuard?: (claim: () => number) => Promise<number | false>, autoDetail?: string): Promise<void>;
4
+ export declare function handleCompactWorkflow(ws: WebSocket, session: Session, msg: CompactWorkflowMessage, claimGuard?: (claim: () => number) => Promise<number | false>, autoDetail?: string, onSuccess?: () => void): Promise<void>;
5
5
  export declare function handleFoldWorkflow(ws: WebSocket, _session: Session, msg: FoldWorkflowMessage): Promise<void>;
@@ -1,7 +1,8 @@
1
+ import { hasConversationHistory } from '../providerConversation.js';
1
2
  import { supportsManualCompact } from '../manualCompactCapability.js';
2
3
  import { publishActivity } from '../voice/activityBus.js';
3
4
  import { resolveOutputStyle } from '@arco/shared';
4
- import { claimBusy, ownsBusy, drainQueueIfIdle, maybeAutoContinueAfterCompact, releaseBusy, resetCodexContextAfterCompact, } from './turnEngine.js';
5
+ import { claimBusy, ownsBusy, drainQueueIfIdle, maybeAutoContinueAfterCompact, releaseBusy, resetCodexContextAfterCompact, resetAutoCompactionCycle, } from './turnEngine.js';
5
6
  import { send, broadcastWorkflow, broadcastTransient, notifyClusterStateForWorkflow } from '../server/broadcast.js';
6
7
  import { workflows, workflowCwds } from '../server/state.js';
7
8
  import { compactCodexAppServerThread } from '../providers/codex-appserver/index.js';
@@ -12,7 +13,7 @@ import { armOllamaForceCompact } from '../providers/ollamaForceCompact.js';
12
13
  import { resolveProviderAccount } from '../providerAccounts.js';
13
14
  import { readSettings } from '../settings.js';
14
15
  import * as clusterStore from '../clusterStore.js';
15
- export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDetail) {
16
+ export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDetail, onSuccess) {
16
17
  const workflowId = msg.workflowId;
17
18
  const wf = workflows.get(workflowId);
18
19
  if (!wf) {
@@ -121,7 +122,7 @@ export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDe
121
122
  result = { ok: false, error: 'Compact needs the Codex app-server transport (CONFIG → TRANSPORT). On Codex exec, use Handoff.' };
122
123
  }
123
124
  else if (!wf.primarySessionId) {
124
- result = { ok: false, error: 'no saved Codex thread for this workflow — run a turn first' };
125
+ result = { ok: false, error: await hasConversationHistory(cwd, workflowId) ? 'The previous Codex conversation cannot be resumed because its saved thread id is unavailable. The next message starts a new conversation; earlier messages remain in this tab.' : 'no saved Codex thread for this workflow — run a turn first' };
125
126
  }
126
127
  else {
127
128
  const account = await resolveProviderAccount('codex', wf.config.providerAccountRef, cwd).catch(() => null);
@@ -155,7 +156,7 @@ export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDe
155
156
  else if (provider === 'cursor') {
156
157
  compactedVia = 'cursor-acp';
157
158
  if (!wf.primarySessionId) {
158
- result = { ok: false, error: 'no saved Cursor session for this workflow — run a turn first' };
159
+ result = { ok: false, error: await hasConversationHistory(cwd, workflowId) ? 'The previous Cursor conversation cannot be resumed because its saved session id is unavailable. The next message starts a new conversation; earlier messages remain in this tab.' : 'no saved Cursor session for this workflow — run a turn first' };
159
160
  }
160
161
  else {
161
162
  const turnClusterId = clusterStore.getClusterIdForWorkflow(workflowId);
@@ -213,6 +214,12 @@ export async function handleCompactWorkflow(ws, session, msg, claimGuard, autoDe
213
214
  // False when STOP revoked the claim mid-compact (and a newer turn may hold
214
215
  // busy now) — report the outcome but leave busy + the queue alone.
215
216
  const owned = releaseBusy(wf, busyToken, 'interrupted', false);
217
+ if (result.ok && owned) {
218
+ if (autoDetail)
219
+ onSuccess?.();
220
+ else
221
+ resetAutoCompactionCycle(wf);
222
+ }
216
223
  if (result.ok && owned && autoDetail) {
217
224
  if (provider === 'codex')
218
225
  resetCodexContextAfterCompact(workflowId, wf);
@@ -1,3 +1,4 @@
1
+ import { ensureWorkflowMetadata, providerConversationState, saveProviderSession } from '../providerConversation.js';
1
2
  import { isClaudeNativeTaskActive } from '../providers/claude-native/index.js';
2
3
  import { appendHandoffNotice } from '../handoffHistoryTool.js';
3
4
  import { unsettledTaskStatuses } from './taskLifecycle.js';
@@ -35,7 +36,7 @@ import { acquirePlansWatcher, broadcastCluster, broadcastHandoffLockSnapshot, br
35
36
  import { buildLocalClusterSystemPrompt, LLAMACPP_PRIMARY_SYSTEM_PROMPT, OLLAMA_PRIMARY_SYSTEM_PROMPT, withPreviewNudge, } from '../server/prompts.js';
36
37
  import { cwdHandoffChain, workflowCwds, workflows, } from '../server/state.js';
37
38
  import { acquireProjectSettingsWatcher, readSettings, } from '../settings.js';
38
- import { appendHistoryEntry, readMeta, workflowConfigFromMeta, reconcileLatestCliSession, writeMeta, } from '../workflowMeta.js';
39
+ import { appendHistoryEntry, readMeta, workflowConfigFromMeta, writeMeta, } from '../workflowMeta.js';
39
40
  import { getHeadSeq as getWorkflowHeadSeq, initWorkflowStore, readFirstSeq as readWorkflowFirstSeq, replayEvents as replayWorkflowEvents, replayTailEvents, scanEventsOfTypes, } from '../workflowStore.js';
40
41
  import { ptyManager } from '../terminal/ptyManager.js';
41
42
  import { sendTaskLedgerSnapshot } from './taskLedgerHandlers.js';
@@ -416,6 +417,7 @@ export async function handleHandoffRequest(ws, session, msg) {
416
417
  if (!handoffOwned())
417
418
  return;
418
419
  wf.primarySessionId = undefined;
420
+ wf.providerConversation = undefined;
419
421
  // Retire every cached transport before the new seed, so Codex app-server
420
422
  // and Cursor ACP bootstrap their MCP children with the new history grant.
421
423
  // Await local teardown too, then recheck ownership before touching the seed.
@@ -598,7 +600,7 @@ export async function handleHandoffRequest(ws, session, msg) {
598
600
  // extras filter excludes non-streaming assistants when sessionChat is
599
601
  // non-empty from the pre-handoff session). No-op for non-Claude.
600
602
  startSessionWatcher(msg.workflowId, wf, cwd, ws);
601
- reconcileLatestCliSession(cwd, msg.workflowId, 'claude', primaryTurn.initialSessionId).catch((err) => {
603
+ saveProviderSession(cwd, msg.workflowId, wf, 'claude', primaryTurn.initialSessionId).catch((err) => {
602
604
  console.error(`[arco] handoff ${handle.handoffId} meta reconcile failed:`, err);
603
605
  });
604
606
  }
@@ -612,7 +614,7 @@ export async function handleHandoffRequest(ws, session, msg) {
612
614
  // practice; startSessionWatcher is a no-op on other providers.
613
615
  startSessionWatcher(msg.workflowId, wf, cwd, ws);
614
616
  }
615
- reconcileLatestCliSession(cwd, msg.workflowId, wf.primary.provider, sid, handoffAccount?.profile.id).catch((err) => {
617
+ saveProviderSession(cwd, msg.workflowId, wf, wf.primary.provider, sid, handoffAccount?.profile.id).catch((err) => {
616
618
  console.error(`[arco] handoff ${handle.handoffId} meta reconcile (${wf.primary.provider}) failed:`, err);
617
619
  });
618
620
  });
@@ -1251,7 +1253,7 @@ export async function handleSpawnFromHere(ws, session, msg) {
1251
1253
  // the usual watcher-start call never runs. Start it here once the new
1252
1254
  // session's id is known — same reasoning as the handoff fix above.
1253
1255
  startSessionWatcher(newWorkflowId, spawnedWf, newCwd, ws);
1254
- reconcileLatestCliSession(newCwd, newWorkflowId, 'claude', primaryTurn.initialSessionId).catch((err) => {
1256
+ saveProviderSession(newCwd, newWorkflowId, spawnedWf, 'claude', primaryTurn.initialSessionId).catch((err) => {
1255
1257
  console.error(`[arco] spawn meta reconcile failed:`, err);
1256
1258
  });
1257
1259
  }
@@ -1263,7 +1265,9 @@ export async function handleSpawnFromHere(ws, session, msg) {
1263
1265
  wf.primarySessionId = sid;
1264
1266
  startSessionWatcher(newWorkflowId, wf, newCwd, ws);
1265
1267
  }
1266
- reconcileLatestCliSession(newCwd, newWorkflowId, newPrimary.provider, sid, spawnAccount?.profile.id).catch((err) => {
1268
+ if (!wf)
1269
+ return;
1270
+ saveProviderSession(newCwd, newWorkflowId, wf, newPrimary.provider, sid, spawnAccount?.profile.id).catch((err) => {
1267
1271
  console.error(`[arco] spawn meta reconcile (${newPrimary.provider}) failed:`, err);
1268
1272
  });
1269
1273
  });
@@ -1411,6 +1415,7 @@ export async function handleRehydrateWorkflows(ws, session, entries) {
1411
1415
  // Read meta.json to restore primarySessionId so the next user_message
1412
1416
  // continues the prior CLI session instead of starting a fresh one.
1413
1417
  try {
1418
+ await ensureWorkflowMetadata(cwd, entry.workflowId, wf);
1414
1419
  const meta = await readMeta(cwd, entry.workflowId);
1415
1420
  if (meta) {
1416
1421
  const latestForProvider = [...meta.cliSessions].reverse().find((s) => s.provider === wf.primary.provider);
@@ -1679,6 +1684,8 @@ const TASK_SCAN_TYPES = [...TASK_LIFECYCLE_TYPES, 'primary_turn_ended'];
1679
1684
  const REPLAY_BATCH_THRESHOLD = 200;
1680
1685
  export async function rehydrateOneWorkflow(ws, workflowId, wf, clientLastSeq, opts = {}) {
1681
1686
  const cwd = wf.config.incognito ? '' : wf.config.workingDirectory;
1687
+ if (cwd)
1688
+ await ensureWorkflowMetadata(cwd, workflowId, wf);
1682
1689
  let latestNativeLastPromptTokens;
1683
1690
  const captureReplayTokens = (events) => {
1684
1691
  for (const event of events) {
@@ -1819,9 +1826,12 @@ export async function rehydrateOneWorkflow(ws, workflowId, wf, clientLastSeq, op
1819
1826
  : null;
1820
1827
  const codexSnapshotWindow = codexSnapshot?.modelContextWindow;
1821
1828
  const computerState = isComputer(wf) ? await computerContextState(workflowId, wf) : undefined;
1829
+ const conversationState = cwd ? await providerConversationState(cwd, workflowId, wf) : undefined;
1830
+ wf.providerConversation = conversationState;
1822
1831
  const msg = {
1823
1832
  type: 'workflow_state_snapshot',
1824
1833
  workflowId,
1834
+ ...(conversationState ? { providerConversation: conversationState } : {}),
1825
1835
  workers: {},
1826
1836
  busy: wf.busy,
1827
1837
  ...(wf.busy && Number.isFinite(wf.turnStartedAt) ? { turnStartedAt: wf.turnStartedAt } : {}),
@@ -1862,7 +1872,7 @@ export async function rehydrateOneWorkflow(ws, workflowId, wf, clientLastSeq, op
1862
1872
  startSessionWatcher(workflowId, wf, cwd, ws);
1863
1873
  // Phase 2 — emit a context estimate immediately so the client has a fill
1864
1874
  // reading as soon as the snapshot arrives (not only after the next turn).
1865
- if (cwd && wf.primary.provider === 'claude' && typeof latestNativeLastPromptTokens === 'number' && latestNativeLastPromptTokens > 0) {
1875
+ if (cwd && !conversationState && wf.primary.provider === 'claude' && typeof latestNativeLastPromptTokens === 'number' && latestNativeLastPromptTokens > 0) {
1866
1876
  const estimate = nativeContextEstimate(wf.primary.model, latestNativeLastPromptTokens);
1867
1877
  if (estimate && ws.readyState === WebSocket.OPEN) {
1868
1878
  const usage = { type: 'context_usage', workflowId, ...estimate };
@@ -1,4 +1,5 @@
1
1
  import { WebSocket } from 'ws';
2
- import type { OperatorQuestionReplyMessage } from '@arco/shared';
2
+ import type { OperatorQuestionReplyMessage, OperatorQuestionDismissMessage } from '@arco/shared';
3
3
  import type { Session } from '../workflows/types.js';
4
4
  export declare function handleOperatorQuestionReply(ws: WebSocket, session: Session, msg: OperatorQuestionReplyMessage): Promise<void>;
5
+ export declare function handleOperatorQuestionDismiss(ws: WebSocket, session: Session, msg: OperatorQuestionDismissMessage): void;
@@ -1,6 +1,6 @@
1
1
  import { WebSocket } from 'ws';
2
2
  import { workflows } from '../server/state.js';
3
- import { replyToOperatorQuestion } from '../providers/codex-appserver/operatorQuestions.js';
3
+ import { replyToOperatorQuestion, dismissOperatorQuestion } from '../providers/codex-appserver/operatorQuestions.js';
4
4
  import { handleUserMessage } from './turnEngine.js';
5
5
  import { broadcastWorkflow } from '../server/broadcast.js';
6
6
  export async function handleOperatorQuestionReply(ws, session, msg) {
@@ -25,4 +25,12 @@ export async function handleOperatorQuestionReply(ws, session, msg) {
25
25
  if (ws.readyState === WebSocket.OPEN)
26
26
  ws.send(JSON.stringify({ type: 'operator_question_reply_result', workflowId: msg.workflowId, requestId: msg.requestId, ...result }));
27
27
  }
28
+ export function handleOperatorQuestionDismiss(ws, session, msg) {
29
+ const wf = workflows.get(msg.workflowId);
30
+ const result = !wf || !wf.observers.has(ws) || !session.workflowIds.has(msg.workflowId)
31
+ ? { ok: false, error: 'Subscribe to this workflow before dismissing.' }
32
+ : dismissOperatorQuestion(msg.workflowId, msg.requestId);
33
+ if (ws.readyState === WebSocket.OPEN)
34
+ ws.send(JSON.stringify({ type: 'operator_question_dismiss_result', workflowId: msg.workflowId, requestId: msg.requestId, ...result }));
35
+ }
28
36
  //# sourceMappingURL=operatorQuestionHandlers.js.map
@@ -16,7 +16,7 @@ export interface TurnEngineDeps {
16
16
  handleHandoffRequest: (ws: WebSocket, session: Session, msg: import('@arco/shared').HandoffRequestMessage) => Promise<{
17
17
  artifactName: string;
18
18
  } | void>;
19
- handleCompactWorkflow?: (ws: WebSocket, session: Session, msg: import('@arco/shared').CompactWorkflowMessage, guard?: (claim: () => number) => Promise<number | false>, autoDetail?: string) => Promise<void>;
19
+ handleCompactWorkflow?: (ws: WebSocket, session: Session, msg: import('@arco/shared').CompactWorkflowMessage, guard?: (claim: () => number) => Promise<number | false>, autoDetail?: string, onSuccess?: () => void) => Promise<void>;
20
20
  }
21
21
  export declare function initTurnEngine(d: TurnEngineDeps): void;
22
22
  export declare function extractFilePath(tool: string, input: unknown): string | undefined;
@@ -82,9 +82,7 @@ export declare function projectQueue(items: QueueItem[]): Array<{
82
82
  export declare function broadcastQueueUpdate(workflowId: string): void;
83
83
  export declare function drainSteerForWorker(workflowId: string, ws: WebSocket, deliveryProvider?: WorkflowConfig['primaryProvider']): SteerItem[];
84
84
  export declare function requeueSteerForWorker(workflowId: string, ws: WebSocket, items: SteerItem[], bucket: 'steer' | 'follow-up'): void;
85
- export declare function persistInitialMeta(cwd: string, workflowId: string, config: WorkflowConfig, primary: PrimaryConfig, opts?: {
86
- parentWorkflowId?: string;
87
- }): Promise<void>;
85
+ export { persistInitialMeta } from '../workflowMeta.js';
88
86
  export declare function writeCalibrationToMeta(cwd: string, workflowId: string, ratio: number, overhead: number, lastGroundTruth: number): Promise<void>;
89
87
  export declare function enqueueBusyReminder(workflowId: string, content: string, allow?: () => boolean): Promise<boolean>;
90
88
  export declare function handleUserMessage(ws: WebSocket, session: Session, workflowId: string, content: string, clientMessageId: string | undefined, attachments: string[] | undefined, interjection: boolean, kind: 'steer' | 'follow-up' | 'interrupt' | undefined, primitive: 'docs' | 'git' | 'plan-review' | undefined, pickedSkills?: Array<{