@opencorelabs/lucidity 0.6.0 → 0.8.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/README.md +18 -3
- package/dist/assets/speech/lucidity-speech +0 -0
- package/dist/automations/agent.d.ts.map +1 -1
- package/dist/automations/agent.js +2 -0
- package/dist/automations/designer.d.ts +1 -1
- package/dist/chat/server.d.ts +1 -0
- package/dist/chat/server.d.ts.map +1 -1
- package/dist/chat/server.js +6 -1
- package/dist/coding/conduct.d.ts +1 -22
- package/dist/coding/conduct.d.ts.map +1 -1
- package/dist/coding/conduct.js +9 -94
- package/dist/coding/runCodeTurn.d.ts +3 -16
- package/dist/coding/runCodeTurn.d.ts.map +1 -1
- package/dist/coding/runCodeTurn.js +157 -165
- package/dist/coding/workspaceRegistry.d.ts +24 -0
- package/dist/coding/workspaceRegistry.d.ts.map +1 -0
- package/dist/coding/workspaceRegistry.js +230 -0
- package/dist/coding/worktree.d.ts +11 -14
- package/dist/coding/worktree.d.ts.map +1 -1
- package/dist/coding/worktree.js +41 -21
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/daemonLease.d.ts +12 -0
- package/dist/daemonLease.d.ts.map +1 -0
- package/dist/daemonLease.js +32 -0
- package/dist/goals/assessment.d.ts +115 -0
- package/dist/goals/assessment.d.ts.map +1 -0
- package/dist/goals/assessment.js +67 -0
- package/dist/goals/notes.d.ts +18 -0
- package/dist/goals/notes.d.ts.map +1 -0
- package/dist/goals/notes.js +72 -0
- package/dist/index.js +63 -15
- package/dist/jobs/goals.d.ts +15 -0
- package/dist/jobs/goals.d.ts.map +1 -0
- package/dist/jobs/goals.js +286 -0
- package/dist/jobs/weeklyReview.d.ts.map +1 -1
- package/dist/jobs/weeklyReview.js +3 -2
- package/dist/queue.d.ts +1 -0
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +4 -0
- package/dist/room/client.d.ts +5 -0
- package/dist/room/client.d.ts.map +1 -1
- package/dist/room/client.js +124 -107
- package/dist/room/computer.d.ts.map +1 -1
- package/dist/room/computer.js +2 -0
- package/dist/room/durablePublish.d.ts +6 -0
- package/dist/room/durablePublish.d.ts.map +1 -0
- package/dist/room/durablePublish.js +19 -0
- package/dist/room/incidents.d.ts +1 -1
- package/dist/room/incidents.d.ts.map +1 -1
- package/dist/room/incidents.js +14 -7
- package/dist/room/turnQueue.d.ts.map +1 -1
- package/dist/room/turnQueue.js +27 -24
- package/dist/runtimeStore.d.ts +44 -0
- package/dist/runtimeStore.d.ts.map +1 -0
- package/dist/runtimeStore.js +188 -0
- package/dist/setup/server.js +1 -1
- package/dist/turnLog.d.ts +10 -40
- package/dist/turnLog.d.ts.map +1 -1
- package/dist/turnLog.js +33 -56
- package/package.json +4 -4
- package/src/automations/agent.ts +2 -0
- package/src/chat/server.ts +7 -1
- package/src/coding/conduct.ts +10 -147
- package/src/coding/runCodeTurn.ts +42 -61
- package/src/coding/workspaceRegistry.ts +210 -0
- package/src/coding/worktree.ts +44 -20
- package/src/config.ts +2 -0
- package/src/daemonLease.ts +33 -0
- package/src/goals/assessment.ts +106 -0
- package/src/goals/notes.ts +88 -0
- package/src/index.ts +63 -18
- package/src/jobs/goals.ts +384 -0
- package/src/jobs/weeklyReview.ts +4 -3
- package/src/queue.ts +4 -0
- package/src/room/client.ts +85 -80
- package/src/room/computer.ts +2 -0
- package/src/room/durablePublish.ts +25 -0
- package/src/room/incidents.ts +16 -8
- package/src/room/turnQueue.ts +26 -27
- package/src/runtimeStore.ts +190 -0
- package/src/setup/server.ts +1 -1
- package/src/turnLog.ts +32 -75
- package/vendor/decisions/dist/dayPlan.d.ts +9 -0
- package/vendor/decisions/dist/dayPlan.js +82 -0
- package/vendor/decisions/dist/index.d.ts +1 -0
- package/vendor/decisions/dist/index.js +1 -0
- package/vendor/decisions/dist/jev.js +3 -1
- package/vendor/decisions/src/dayPlan.ts +80 -0
- package/vendor/decisions/src/index.ts +1 -0
- package/vendor/decisions/src/jev.ts +3 -1
- package/vendor/mcp-server/dist/index.js +2 -0
- package/vendor/mcp-server/dist/tools/goals.d.ts +4 -0
- package/vendor/mcp-server/dist/tools/goals.d.ts.map +1 -0
- package/vendor/mcp-server/dist/tools/goals.js +38 -0
- package/vendor/mcp-server/package.json +1 -1
- package/vendor/mcp-server/src/index.ts +2 -0
- package/vendor/mcp-server/src/tools/goals.ts +62 -0
- package/vendor/runtime/README.md +2 -2
- package/vendor/runtime/dist/executor/asyncQueue.d.ts +1 -0
- package/vendor/runtime/dist/executor/asyncQueue.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/asyncQueue.js +3 -0
- package/vendor/runtime/dist/executor/claudeAgent.d.ts +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/claudeAgent.js +25 -10
- package/vendor/runtime/dist/executor/codex.d.ts +1 -0
- package/vendor/runtime/dist/executor/codex.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codex.js +69 -36
- package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts +4 -1
- package/vendor/runtime/dist/executor/codexProtocol/FunctionCallOutputContentItem.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts +3 -0
- package/vendor/runtime/dist/executor/codexProtocol/Personality.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/PlanType.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts +6 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/CyberAccessProgram.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts +5 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/GetAccountRateLimitsResponse.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts +8 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/Model.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts +11 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ModelAccessPrograms.js +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts +4 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/RateLimitSnapshot.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts +2 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/ReviewStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts +4 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadResumeParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts +3 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/ThreadStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts +7 -2
- package/vendor/runtime/dist/executor/codexProtocol/v2/TurnStartParams.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts +3 -0
- package/vendor/runtime/dist/executor/codexProtocol/v2/UserInput.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexRpc.d.ts +10 -3
- package/vendor/runtime/dist/executor/codexRpc.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/codexRpc.js +18 -3
- package/vendor/runtime/dist/executor/codexSessions.d.ts +30 -0
- package/vendor/runtime/dist/executor/codexSessions.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/codexSessions.js +88 -0
- package/vendor/runtime/dist/executor/health.d.ts +2 -1
- package/vendor/runtime/dist/executor/health.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/health.js +17 -5
- package/vendor/runtime/dist/executor/liveTurns.d.ts +2 -1
- package/vendor/runtime/dist/executor/liveTurns.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/liveTurns.js +12 -5
- package/vendor/runtime/dist/executor/ownership.d.ts +35 -0
- package/vendor/runtime/dist/executor/ownership.d.ts.map +1 -0
- package/vendor/runtime/dist/executor/ownership.js +99 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts +1 -0
- package/vendor/runtime/dist/executor/providerRouter.d.ts.map +1 -1
- package/vendor/runtime/dist/executor/providerRouter.js +5 -0
- package/vendor/runtime/dist/executor/types.d.ts +4 -0
- package/vendor/runtime/dist/executor/types.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.d.ts +1 -0
- package/vendor/runtime/dist/harness/index.d.ts.map +1 -1
- package/vendor/runtime/dist/harness/index.js +12 -1
- package/vendor/runtime/dist/harness/types.d.ts +2 -1
- package/vendor/runtime/dist/harness/types.d.ts.map +1 -1
- package/vendor/runtime/dist/index.d.ts +1 -0
- package/vendor/runtime/dist/index.d.ts.map +1 -1
- package/vendor/runtime/dist/index.js +1 -0
- package/vendor/runtime/dist/prompts/dayPlanning.d.ts +44 -0
- package/vendor/runtime/dist/prompts/dayPlanning.d.ts.map +1 -0
- package/vendor/runtime/dist/prompts/dayPlanning.js +42 -0
- package/vendor/runtime/src/executor/asyncQueue.ts +3 -0
- package/vendor/runtime/src/executor/claudeAgent.ts +20 -9
- package/vendor/runtime/src/executor/codex.ts +76 -44
- package/vendor/runtime/src/executor/codexProtocol/FunctionCallOutputContentItem.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/Personality.ts +3 -0
- package/vendor/runtime/src/executor/codexProtocol/PlanType.ts +1 -1
- package/vendor/runtime/src/executor/codexProtocol/README.md +2 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/CyberAccessProgram.ts +9 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/GetAccountRateLimitsResponse.ts +5 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/Model.ts +11 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/ModelAccessPrograms.ts +13 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/RateLimitSnapshot.ts +5 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ReviewStartParams.ts +2 -0
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadResumeParams.ts +5 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/ThreadStartParams.ts +4 -1
- package/vendor/runtime/src/executor/codexProtocol/v2/TurnStartParams.ts +7 -2
- package/vendor/runtime/src/executor/codexProtocol/v2/UserInput.ts +1 -1
- package/vendor/runtime/src/executor/codexRpc.ts +22 -4
- package/vendor/runtime/src/executor/codexSessions.ts +108 -0
- package/vendor/runtime/src/executor/health.ts +16 -6
- package/vendor/runtime/src/executor/liveTurns.ts +12 -5
- package/vendor/runtime/src/executor/ownership.ts +76 -0
- package/vendor/runtime/src/executor/providerRouter.ts +6 -0
- package/vendor/runtime/src/executor/types.ts +4 -0
- package/vendor/runtime/src/harness/index.ts +12 -1
- package/vendor/runtime/src/harness/types.ts +2 -1
- package/vendor/runtime/src/index.ts +1 -0
- package/vendor/runtime/src/prompts/dayPlanning.ts +46 -0
- package/vendor/shared/dist/agentCommands.d.ts +1 -0
- package/vendor/shared/dist/agentCommands.d.ts.map +1 -1
- package/vendor/shared/dist/cardStudio.d.ts +41 -0
- package/vendor/shared/dist/cardStudio.d.ts.map +1 -1
- package/vendor/shared/dist/cardStudio.js +13 -3
- package/vendor/shared/dist/commandLocal.d.ts.map +1 -1
- package/vendor/shared/dist/commandLocal.js +2 -0
- package/vendor/shared/dist/commands.d.ts +18 -0
- package/vendor/shared/dist/commands.d.ts.map +1 -1
- package/vendor/shared/dist/commands.js +2 -0
- package/vendor/shared/dist/computer.d.ts +7 -1
- package/vendor/shared/dist/computer.d.ts.map +1 -1
- package/vendor/shared/dist/computer.js +13 -2
- package/vendor/shared/dist/constants.d.ts +3 -3
- package/vendor/shared/dist/constants.d.ts.map +1 -1
- package/vendor/shared/dist/constants.js +5 -4
- package/vendor/shared/dist/dayPlan.d.ts +86 -0
- package/vendor/shared/dist/dayPlan.d.ts.map +1 -0
- package/vendor/shared/dist/dayPlan.js +46 -0
- package/vendor/shared/dist/dayPlanning.d.ts +139 -0
- package/vendor/shared/dist/dayPlanning.d.ts.map +1 -0
- package/vendor/shared/dist/dayPlanning.js +67 -0
- package/vendor/shared/dist/goalNotes.d.ts +4 -0
- package/vendor/shared/dist/goalNotes.d.ts.map +1 -0
- package/vendor/shared/dist/goalNotes.js +23 -0
- package/vendor/shared/dist/goals.d.ts +835 -0
- package/vendor/shared/dist/goals.d.ts.map +1 -0
- package/vendor/shared/dist/goals.js +198 -0
- package/vendor/shared/dist/index.d.ts +5 -0
- package/vendor/shared/dist/index.d.ts.map +1 -1
- package/vendor/shared/dist/index.js +5 -0
- package/vendor/shared/dist/schemas/harness.d.ts +155 -0
- package/vendor/shared/dist/schemas/harness.d.ts.map +1 -1
- package/vendor/shared/dist/schemas/harness.js +8 -0
- package/vendor/shared/dist/workspaces.d.ts +138 -0
- package/vendor/shared/dist/workspaces.d.ts.map +1 -0
- package/vendor/shared/dist/workspaces.js +40 -0
- package/vendor/shared/src/agentCommands.ts +1 -0
- package/vendor/shared/src/cardStudio.ts +13 -3
- package/vendor/shared/src/commandLocal.ts +2 -0
- package/vendor/shared/src/commands.ts +2 -0
- package/vendor/shared/src/computer.ts +18 -2
- package/vendor/shared/src/constants.ts +5 -4
- package/vendor/shared/src/dayPlan.ts +81 -0
- package/vendor/shared/src/dayPlanning.ts +77 -0
- package/vendor/shared/src/goalNotes.ts +23 -0
- package/vendor/shared/src/goals.ts +237 -0
- package/vendor/shared/src/index.ts +6 -0
- package/vendor/shared/src/schemas/harness.ts +8 -0
- package/vendor/shared/src/workspaces.ts +48 -0
- package/dist/coding/fleetIntegrate.d.ts +0 -37
- package/dist/coding/fleetIntegrate.d.ts.map +0 -1
- package/dist/coding/fleetIntegrate.js +0 -64
- package/dist/coding/openFleetPr.d.ts +0 -41
- package/dist/coding/openFleetPr.d.ts.map +0 -1
- package/dist/coding/openFleetPr.js +0 -121
- package/src/coding/fleetIntegrate.ts +0 -95
- package/src/coding/openFleetPr.ts +0 -148
package/dist/room/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { publishDurably } from './durablePublish.js';
|
|
1
2
|
import { computerId, computerRuntime } from './computer.js';
|
|
2
3
|
import { DurableTurnQueue } from './turnQueue.js';
|
|
3
4
|
import { WebSocket } from 'ws';
|
|
@@ -94,8 +95,17 @@ export async function dispatchRequest(raw, deps) {
|
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
96
97
|
const req = parsed.data;
|
|
97
|
-
const
|
|
98
|
-
|
|
98
|
+
const structured = req.kind === 'ask' && (req.dayPlan ? 'day-plan' : req.projectPlan ? 'project-plan' : undefined);
|
|
99
|
+
let deferTerminal = false;
|
|
100
|
+
let terminal;
|
|
101
|
+
const send = (frame) => {
|
|
102
|
+
const event = frame;
|
|
103
|
+
if (deferTerminal && event?.requestId === req.id && (['done', 'error', 'cancelled'].includes(String(event.type)) || ['ask', 'briefing', 'attention'].includes(String(event.kind)))) {
|
|
104
|
+
terminal ??= event;
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
sendFrame(structured ? { ...event, purpose: structured } : frame);
|
|
108
|
+
};
|
|
99
109
|
if (req.kind === 'voice-capture' || req.kind === 'voice-capture-status') {
|
|
100
110
|
try {
|
|
101
111
|
if (!deps.captures)
|
|
@@ -154,7 +164,7 @@ export async function dispatchRequest(raw, deps) {
|
|
|
154
164
|
!['pull', 'cancel', 'permission', 'steer'].includes(req.kind)) {
|
|
155
165
|
let provider;
|
|
156
166
|
try {
|
|
157
|
-
provider =
|
|
167
|
+
provider = req.kind === 'ask' && req.dayPlan ? deps.runtime().defaults.code :
|
|
158
168
|
'resume' in req && req.resume
|
|
159
169
|
? decodeSession(req.resume).provider
|
|
160
170
|
: 'provider' in req
|
|
@@ -169,7 +179,7 @@ export async function dispatchRequest(raw, deps) {
|
|
|
169
179
|
});
|
|
170
180
|
return;
|
|
171
181
|
}
|
|
172
|
-
const availability = computerAvailability({ type: 'presence', daemonConnected: true, runtime: deps.runtime() }, 'online', req.kind, provider);
|
|
182
|
+
const availability = computerAvailability({ type: 'presence', daemonConnected: true, runtime: deps.runtime() }, 'online', req.kind === 'ask' && req.dayPlan ? 'day-plan' : req.kind, provider);
|
|
173
183
|
if (!availability.canSend) {
|
|
174
184
|
send({
|
|
175
185
|
type: 'error',
|
|
@@ -273,13 +283,16 @@ export async function dispatchRequest(raw, deps) {
|
|
|
273
283
|
const controller = inFlight?.get(req.targetId);
|
|
274
284
|
if (controller) {
|
|
275
285
|
controller.abort();
|
|
276
|
-
//
|
|
277
|
-
// landing at maxSeq+1) — a later pull then sees a settled turn.
|
|
278
|
-
send({ type: 'cancelled', requestId: req.targetId });
|
|
286
|
+
// The owner publishes cancellation after the provider and workspace are released.
|
|
279
287
|
}
|
|
280
288
|
else {
|
|
281
|
-
// Conductor workers have provider-owned request IDs, separate from the parent lane.
|
|
282
289
|
await deps.controls?.interrupt(req.targetId);
|
|
290
|
+
// Completion can beat Stop while its terminal frame is lost in transit. Replay
|
|
291
|
+
// the actual outcome so the phone settles without rewriting finished work.
|
|
292
|
+
const state = deps.turnLogs.read(req.targetId);
|
|
293
|
+
if (state.terminated)
|
|
294
|
+
for (const frame of state.frames)
|
|
295
|
+
deps.sendRaw(frame);
|
|
283
296
|
}
|
|
284
297
|
return;
|
|
285
298
|
}
|
|
@@ -310,19 +323,6 @@ export async function dispatchRequest(raw, deps) {
|
|
|
310
323
|
// restores its controls instead of waiting forever for another model token.
|
|
311
324
|
if (!state.terminated && inFlight?.has(req.targetId))
|
|
312
325
|
deps.controls?.publishPending(req.targetId);
|
|
313
|
-
// Open log (no terminal) with no live run owning it → the subprocess died (the daemon
|
|
314
|
-
// restarted mid-turn). Settle it with a synthesized, persisted terminal so the phone
|
|
315
|
-
// stops waiting and a repeat pull is idempotent. If it's still in `inFlight`, live
|
|
316
|
-
// frames past maxSeq keep flowing on the current socket (deduped by seq) — leave it.
|
|
317
|
-
if (!state.terminated &&
|
|
318
|
-
!inFlight?.has(req.targetId) &&
|
|
319
|
-
!deps.turnQueue?.owns(req.targetId)) {
|
|
320
|
-
sendRaw(turnLogs.append(req.targetId, {
|
|
321
|
-
type: 'error',
|
|
322
|
-
requestId: req.targetId,
|
|
323
|
-
message: 'Lucid restarted before finishing this turn.',
|
|
324
|
-
}));
|
|
325
|
-
}
|
|
326
326
|
return;
|
|
327
327
|
}
|
|
328
328
|
if ((req.kind === 'ask' || req.kind === 'code') && req.queue) {
|
|
@@ -342,39 +342,26 @@ export async function dispatchRequest(raw, deps) {
|
|
|
342
342
|
}
|
|
343
343
|
if (deps.recordAcceptance &&
|
|
344
344
|
['ask', 'code', 'conduct', 'briefing', 'attention', 'clone'].includes(req.kind)) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
345
|
+
try {
|
|
346
|
+
deps.turnLogs.read(req.id); // Adopt legacy receipts before admission.
|
|
347
|
+
const receipt = deps.turnLogs.runtime.accept(req);
|
|
348
|
+
for (const frame of receipt.frames)
|
|
348
349
|
deps.sendRaw(frame);
|
|
349
|
-
|
|
350
|
+
if (receipt.duplicate || inFlight?.has(req.id))
|
|
351
|
+
return;
|
|
350
352
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
type: 'accepted',
|
|
355
|
-
requestId: req.id,
|
|
356
|
-
scope: {
|
|
357
|
-
kind: req.kind,
|
|
358
|
-
...('repoId' in req ? { repoId: req.repoId } : {}),
|
|
359
|
-
...('workerId' in req ? { workerId: req.workerId } : {}),
|
|
360
|
-
...('mode' in req ? { mode: req.mode } : {}),
|
|
361
|
-
},
|
|
362
|
-
});
|
|
363
|
-
if (!deps.turnLogs.read(req.id).exists) {
|
|
364
|
-
send({
|
|
365
|
-
type: 'error',
|
|
366
|
-
requestId: req.id,
|
|
367
|
-
message: 'Cannot save the request safely on this computer. Check available disk space and retry.',
|
|
368
|
-
});
|
|
353
|
+
catch (error) {
|
|
354
|
+
deps.sendRaw({ type: 'error', requestId: req.id,
|
|
355
|
+
message: `Cannot accept this request safely: ${error instanceof Error ? error.message : String(error)}` });
|
|
369
356
|
return;
|
|
370
357
|
}
|
|
371
|
-
deps.sendRaw(accepted);
|
|
372
358
|
}
|
|
373
359
|
// Own abort controller per request, combined with the daemon-shutdown signal, so a
|
|
374
360
|
// `cancel` message (stop button) can kill just this run without affecting others.
|
|
375
361
|
const ownController = new AbortController();
|
|
376
362
|
const signal = combineSignals(outerSignal, ownController.signal);
|
|
377
363
|
inFlight?.set(req.id, ownController);
|
|
364
|
+
deferTerminal = true;
|
|
378
365
|
// Wait for the lane INSIDE the try, and after `inFlight.set` above — a turn waiting its turn
|
|
379
366
|
// must still be cancellable, and the `signal?.aborted` checks below mean a cancel that lands
|
|
380
367
|
// while queued drops the run instead of starting it late.
|
|
@@ -387,12 +374,13 @@ export async function dispatchRequest(raw, deps) {
|
|
|
387
374
|
if (req.kind === 'ask') {
|
|
388
375
|
await onLane('room:ask', async () => {
|
|
389
376
|
const base = {
|
|
390
|
-
...(
|
|
391
|
-
prompt: req.handoff && !req.resume
|
|
377
|
+
...(structured ? { user: { name: '' } } : await askContext(req.prompt)),
|
|
378
|
+
prompt: req.handoff && !req.resume && !structured
|
|
392
379
|
? handoffPrompt(req.prompt, req.handoff, { coding: false })
|
|
393
380
|
: req.prompt,
|
|
394
381
|
provider: req.resume ? undefined : req.provider,
|
|
395
382
|
projectPlan: req.projectPlan,
|
|
383
|
+
dayPlan: req.dayPlan,
|
|
396
384
|
images: req.images,
|
|
397
385
|
requestId: req.id,
|
|
398
386
|
onApproval: deps.controls
|
|
@@ -411,7 +399,7 @@ export async function dispatchRequest(raw, deps) {
|
|
|
411
399
|
// attempt with a first-output deadline. Yields nothing in time → retry once
|
|
412
400
|
// fresh so the turn still lands and a new session id is captured. A user
|
|
413
401
|
// cancel (`signal.aborted`) must not retry. Mirrors runCodeTurn.
|
|
414
|
-
const resumed = req.resume && !
|
|
402
|
+
const resumed = req.resume && !structured
|
|
415
403
|
? await consumeResumed((sig) => harness.askStream({
|
|
416
404
|
...base,
|
|
417
405
|
resume: req.resume,
|
|
@@ -435,7 +423,7 @@ export async function dispatchRequest(raw, deps) {
|
|
|
435
423
|
}
|
|
436
424
|
}
|
|
437
425
|
else {
|
|
438
|
-
const reply = await harness.ask({ ...base, resume:
|
|
426
|
+
const reply = await harness.ask({ ...base, resume: structured ? undefined : req.resume });
|
|
439
427
|
send({
|
|
440
428
|
requestId: req.id,
|
|
441
429
|
kind: 'ask',
|
|
@@ -517,6 +505,11 @@ export async function dispatchRequest(raw, deps) {
|
|
|
517
505
|
nextBefore: result.nextBefore,
|
|
518
506
|
});
|
|
519
507
|
}
|
|
508
|
+
else if (req.kind === 'workspaces') {
|
|
509
|
+
if (!deps.workspaces)
|
|
510
|
+
throw new Error('Update Lucidity on the computer to use persistent workers.');
|
|
511
|
+
send({ requestId: req.id, kind: 'workspaces', snapshot: await deps.workspaces.command(req.command, req.id) });
|
|
512
|
+
}
|
|
520
513
|
else if (req.kind === 'repos') {
|
|
521
514
|
send({
|
|
522
515
|
requestId: req.id,
|
|
@@ -595,21 +588,11 @@ export async function dispatchRequest(raw, deps) {
|
|
|
595
588
|
}
|
|
596
589
|
else if (req.kind === 'conduct') {
|
|
597
590
|
if (deps.conductHandler) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
repoId: req.repoId,
|
|
604
|
-
phase: req.phase,
|
|
605
|
-
prompt: req.prompt,
|
|
606
|
-
images: req.images,
|
|
607
|
-
plan: req.plan,
|
|
608
|
-
resume: req.resume,
|
|
609
|
-
// Forward it or a quick spawn silently mints a parent task + subtask anyway: the
|
|
610
|
-
// phone sends `ephemeral`, conduct honours it, and this hop used to drop it.
|
|
611
|
-
ephemeral: req.ephemeral,
|
|
612
|
-
}, { send, signal }));
|
|
591
|
+
await deps.conductHandler({ id: req.id, repoId: req.repoId, phase: req.phase, prompt: req.prompt,
|
|
592
|
+
images: req.images, plan: req.plan, resume: req.resume, ephemeral: req.ephemeral }, {
|
|
593
|
+
send, signal,
|
|
594
|
+
runWorker: (worker, workerDeps) => dispatchRequest(JSON.stringify({ ...worker, kind: 'code', stream: true, mode: 'worktree' }), { ...deps, signal, send: workerDeps.send, recordAcceptance: true }),
|
|
595
|
+
});
|
|
613
596
|
}
|
|
614
597
|
else {
|
|
615
598
|
send({
|
|
@@ -651,8 +634,10 @@ export async function dispatchRequest(raw, deps) {
|
|
|
651
634
|
catch (err) {
|
|
652
635
|
// A deadline/cancel abort surfaces as an AbortError ("The operation was aborted").
|
|
653
636
|
// Never forward that literal text to the phone — end the turn quietly instead.
|
|
654
|
-
if (isAbortError(err))
|
|
637
|
+
if (isAbortError(err)) {
|
|
638
|
+
send({ type: 'cancelled', requestId: req.id });
|
|
655
639
|
return;
|
|
640
|
+
}
|
|
656
641
|
const message = err instanceof Error ? err.message : String(err);
|
|
657
642
|
deps.telemetry?.record('dispatch-error', message, req.id);
|
|
658
643
|
send({ type: 'error', requestId: req.id, message });
|
|
@@ -660,6 +645,11 @@ export async function dispatchRequest(raw, deps) {
|
|
|
660
645
|
finally {
|
|
661
646
|
deps.controls?.end(req.id);
|
|
662
647
|
inFlight?.delete(req.id);
|
|
648
|
+
deferTerminal = false;
|
|
649
|
+
if (signal?.aborted)
|
|
650
|
+
send({ type: 'cancelled', requestId: req.id });
|
|
651
|
+
else if (terminal)
|
|
652
|
+
send(terminal);
|
|
663
653
|
}
|
|
664
654
|
}
|
|
665
655
|
const MAX_BACKOFF_MS = 30_000;
|
|
@@ -774,11 +764,23 @@ export function startRoomClient(opts) {
|
|
|
774
764
|
if (typeof rec.type === 'string' &&
|
|
775
765
|
STREAM_EVENT_TYPES.has(rec.type) &&
|
|
776
766
|
typeof rec.requestId === 'string') {
|
|
777
|
-
|
|
767
|
+
publishDurably(turnLogs, { ...rec, requestId: rec.requestId }, inFlight, sendRaw);
|
|
778
768
|
durableQueue?.wake();
|
|
779
769
|
return;
|
|
780
770
|
}
|
|
781
771
|
}
|
|
772
|
+
const buffered = obj;
|
|
773
|
+
if (buffered && typeof buffered.requestId === 'string' && ['ask', 'briefing', 'attention'].includes(String(buffered.kind))) {
|
|
774
|
+
publishDurably(turnLogs, { ...buffered, type: 'done', requestId: buffered.requestId }, inFlight, (frame) => {
|
|
775
|
+
const saved = frame;
|
|
776
|
+
if (saved.type === 'error')
|
|
777
|
+
sendRaw(frame);
|
|
778
|
+
else
|
|
779
|
+
sendRaw({ ...buffered, seq: saved.seq });
|
|
780
|
+
});
|
|
781
|
+
durableQueue?.wake();
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
782
784
|
sendRaw(obj);
|
|
783
785
|
};
|
|
784
786
|
// The phone's repo list — recomputed live so a freshly-cloned repo appears with no restart, and
|
|
@@ -829,47 +831,55 @@ export function startRoomClient(opts) {
|
|
|
829
831
|
}, delay);
|
|
830
832
|
reconnectTimer.unref?.();
|
|
831
833
|
}
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
834
|
+
const pendingRequests = new Set();
|
|
835
|
+
const dispatch = (raw, overrides = {}) => {
|
|
836
|
+
if (stopped)
|
|
837
|
+
return Promise.resolve();
|
|
838
|
+
const pending = dispatchRequest(raw, {
|
|
839
|
+
harness,
|
|
840
|
+
recordAcceptance: true,
|
|
841
|
+
runtime: opts.providerHealth ? () => computerRuntime(opts) : undefined,
|
|
842
|
+
controls: opts.controls,
|
|
843
|
+
models: opts.models,
|
|
844
|
+
commands: opts.commands,
|
|
845
|
+
askContext,
|
|
846
|
+
briefingContext,
|
|
847
|
+
send: turnSend,
|
|
848
|
+
sendRaw,
|
|
849
|
+
turnLogs,
|
|
850
|
+
workspaces: opts.workspaces,
|
|
851
|
+
signal,
|
|
852
|
+
codeHandler,
|
|
853
|
+
conductHandler,
|
|
854
|
+
cloneHandler,
|
|
855
|
+
queue: executionLanes,
|
|
856
|
+
inFlight,
|
|
857
|
+
attention: opts.attention,
|
|
858
|
+
logger: log,
|
|
859
|
+
// Live allowlist (#78) + each row's live branch (#121); shared with pushRepos above.
|
|
860
|
+
listRepos,
|
|
861
|
+
listPrs: (repoId, mode) => resolvePrs(repoId, mode, config),
|
|
862
|
+
getConfig,
|
|
863
|
+
speech: opts.speech,
|
|
864
|
+
captures,
|
|
865
|
+
automations: opts.automations,
|
|
866
|
+
setConfig: setConfig
|
|
867
|
+
? (patch, restart) => {
|
|
868
|
+
const result = setConfig(patch, restart);
|
|
869
|
+
publishComputer();
|
|
870
|
+
return result;
|
|
871
|
+
}
|
|
872
|
+
: undefined,
|
|
873
|
+
requestRestart,
|
|
874
|
+
telemetry,
|
|
875
|
+
machine: config.machineName,
|
|
876
|
+
incidentsDir: opts.incidentsDir,
|
|
877
|
+
turnQueue: durableQueue,
|
|
878
|
+
...overrides,
|
|
879
|
+
}).finally(() => { pendingRequests.delete(pending); });
|
|
880
|
+
pendingRequests.add(pending);
|
|
881
|
+
return pending;
|
|
882
|
+
};
|
|
873
883
|
durableQueue = new DurableTurnQueue({
|
|
874
884
|
dir: turnLogs.queueDirectory(),
|
|
875
885
|
logs: turnLogs,
|
|
@@ -883,6 +893,7 @@ export function startRoomClient(opts) {
|
|
|
883
893
|
? (targetId, prompt) => opts.controls.steer(targetId, prompt)
|
|
884
894
|
: undefined,
|
|
885
895
|
});
|
|
896
|
+
turnLogs.reconcile((id) => durableQueue.owns(id));
|
|
886
897
|
durableQueue.wake();
|
|
887
898
|
if (opts.speech) {
|
|
888
899
|
// Never resume another account's queued commands after replacing credentials.
|
|
@@ -1012,6 +1023,8 @@ export function startRoomClient(opts) {
|
|
|
1012
1023
|
stopped = true;
|
|
1013
1024
|
captures?.stop();
|
|
1014
1025
|
durableQueue?.stop();
|
|
1026
|
+
for (const controller of inFlight.values())
|
|
1027
|
+
controller.abort();
|
|
1015
1028
|
clearInterval(redialWatchdog);
|
|
1016
1029
|
unsubscribeHealth?.();
|
|
1017
1030
|
if (reconnectTimer) {
|
|
@@ -1029,5 +1042,9 @@ export function startRoomClient(opts) {
|
|
|
1029
1042
|
}
|
|
1030
1043
|
if (!stopped)
|
|
1031
1044
|
connect();
|
|
1032
|
-
return { stop, push: sendRaw, pushRepos
|
|
1045
|
+
return { stop, push: sendRaw, pushRepos, async drain() {
|
|
1046
|
+
while (pendingRequests.size)
|
|
1047
|
+
await Promise.allSettled(pendingRequests);
|
|
1048
|
+
await executionLanes.drain();
|
|
1049
|
+
} };
|
|
1033
1050
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computer.d.ts","sourceRoot":"","sources":["../../src/room/computer.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,gGAAgG;AAChG,wBAAgB,UAAU,CACxB,IAAI,SAA8C,GACjD,MAAM,CAmBR;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"computer.d.ts","sourceRoot":"","sources":["../../src/room/computer.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,gGAAgG;AAChG,wBAAgB,UAAU,CACxB,IAAI,SAA8C,GACjD,MAAM,CAmBR;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,GAAG,eAAe,CA4CxE"}
|
package/dist/room/computer.js
CHANGED
|
@@ -36,6 +36,7 @@ export function computerRuntime(opts) {
|
|
|
36
36
|
features: [
|
|
37
37
|
'ask',
|
|
38
38
|
'project-plan',
|
|
39
|
+
'day-plan',
|
|
39
40
|
'briefing',
|
|
40
41
|
'journal',
|
|
41
42
|
'repos',
|
|
@@ -53,6 +54,7 @@ export function computerRuntime(opts) {
|
|
|
53
54
|
...(opts.commands ? ['commands'] : []),
|
|
54
55
|
...(opts.controls ? ['permission', 'steer'] : []),
|
|
55
56
|
...(opts.codeHandler ? ['code'] : []),
|
|
57
|
+
...(opts.workspaces ? ['workspaces', 'checkout-history'] : []),
|
|
56
58
|
...(opts.conductHandler ? ['conduct'] : []),
|
|
57
59
|
...(opts.cloneHandler ? ['clone'] : []),
|
|
58
60
|
...(opts.attention ? ['attention'] : []),
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TurnLogStore } from '../turnLog.js';
|
|
2
|
+
/** A durability failure stops owned work. Its uncertain outcome is reported only after release. */
|
|
3
|
+
export declare function publishDurably(logs: TurnLogStore, event: Record<string, unknown> & {
|
|
4
|
+
requestId: string;
|
|
5
|
+
}, inFlight: Map<string, AbortController>, send: (frame: unknown) => void): void;
|
|
6
|
+
//# sourceMappingURL=durablePublish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durablePublish.d.ts","sourceRoot":"","sources":["../../src/room/durablePublish.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,mGAAmG;AACnG,wBAAgB,cAAc,CAC5B,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EACtD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACtC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAC7B,IAAI,CAcN"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const terminalTypes = new Set(['done', 'error', 'cancelled']);
|
|
2
|
+
/** A durability failure stops owned work. Its uncertain outcome is reported only after release. */
|
|
3
|
+
export function publishDurably(logs, event, inFlight, send) {
|
|
4
|
+
let frame;
|
|
5
|
+
try {
|
|
6
|
+
frame = logs.append(event.requestId, event);
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
for (const controller of inFlight.values())
|
|
10
|
+
controller.abort();
|
|
11
|
+
if (terminalTypes.has(String(event.type)) && !inFlight.has(event.requestId)) {
|
|
12
|
+
send({ type: 'error', requestId: event.requestId, code: 'durability_fault',
|
|
13
|
+
message: "Computer storage failed. This turn's final outcome could not be saved. Free disk space and restart Lucidity, then inspect the workspace before retrying." });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
send(frame);
|
|
19
|
+
}
|
package/dist/room/incidents.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { type InvariantFinding } from './detectors.js';
|
|
|
17
17
|
* - session-reset — delivered and answered, but from a fresh memoryless session (`freshStart`):
|
|
18
18
|
* the turn succeeded yet lost its thread memory.
|
|
19
19
|
*/
|
|
20
|
-
export type IncidentClass = 'ok' | 'cancelled' | 'pending' | 'outbound-loss' | 'inbound-loss' | 'session-reset';
|
|
20
|
+
export type IncidentClass = 'ok' | 'execution-error' | 'history-unavailable' | 'cancelled' | 'pending' | 'outbound-loss' | 'inbound-loss' | 'session-reset';
|
|
21
21
|
/** The daemon's turn-log view of one turn, reduced to what the join needs. */
|
|
22
22
|
export interface DaemonTurnView {
|
|
23
23
|
exists: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incidents.d.ts","sourceRoot":"","sources":["../../src/room/incidents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,aAAa,GACrB,IAAI,GACJ,WAAW,GACX,SAAS,GACT,eAAe,GACf,cAAc,GACd,eAAe,CAAC;AAEpB,8EAA8E;AAC9E,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB;;;6FAGyF;IACzF,YAAY,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,IAAI,CAAC;IACpD,mGAAmG;IACnG,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,mFAAmF;AACnF,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;gFAEgF;AAChF,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAA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kFAAkF;IAClF,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,oEAAoE;IACpE,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAcD;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,cAAc,GACrB,aAAa,CA2Bf;AAsED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,EAAE;QAAE,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IACjD,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,IAAI,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,+FAA+F;AAC/F,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,oBAAoB,GACzB,cAAc,CAyHhB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,EACtB,GAAG,GAAE,MAAsB,EAC3B,GAAG,GAAE,MAAM,MAAiB,GAC3B,MAAM,GAAG,IAAI,CAUf"}
|
package/dist/room/incidents.js
CHANGED
|
@@ -31,7 +31,9 @@ function terminalTypeOf(frames) {
|
|
|
31
31
|
}
|
|
32
32
|
/** Severity for picking which turn a bundle headlines. Higher = worse. */
|
|
33
33
|
const SEVERITY = {
|
|
34
|
+
'execution-error': 4,
|
|
34
35
|
'outbound-loss': 4,
|
|
36
|
+
'history-unavailable': 1,
|
|
35
37
|
'session-reset': 3,
|
|
36
38
|
'inbound-loss': 2,
|
|
37
39
|
pending: 1,
|
|
@@ -49,7 +51,9 @@ export function classifyTurn(phone, daemon) {
|
|
|
49
51
|
return 'session-reset';
|
|
50
52
|
// The phone got a terminal: a real reply, or a daemon error that reached it. Either way the
|
|
51
53
|
// connection worked — an error the phone displayed is not a connection loss.
|
|
52
|
-
if (phone.state === '
|
|
54
|
+
if (phone.state === 'error')
|
|
55
|
+
return 'execution-error';
|
|
56
|
+
if (phone.state === 'done')
|
|
53
57
|
return 'ok';
|
|
54
58
|
if (phone.state === 'cancelled')
|
|
55
59
|
return 'cancelled';
|
|
@@ -63,14 +67,13 @@ export function classifyTurn(phone, daemon) {
|
|
|
63
67
|
return 'inbound-loss'; // Mac wrote frames the phone never saw
|
|
64
68
|
return 'pending'; // Mac still working, phone has caught up — no loss yet
|
|
65
69
|
}
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// is what turns "no record" into a real outbound loss.
|
|
70
|
+
// Missing legacy logs may have expired. Even a settled phone request is not proof
|
|
71
|
+
// that the daemon never accepted it.
|
|
69
72
|
const settled = phone.state === 'timeout' ||
|
|
70
73
|
phone.state === 'lost' ||
|
|
71
74
|
phone.endedAt != null;
|
|
72
75
|
if (phone.staleSend || phone.transport === 'outbox' || settled)
|
|
73
|
-
return '
|
|
76
|
+
return 'history-unavailable';
|
|
74
77
|
return 'pending';
|
|
75
78
|
}
|
|
76
79
|
/** A turn is truly recoverable only when the Mac finished it with a real reply (`done`). An
|
|
@@ -86,13 +89,17 @@ function noteFor(t) {
|
|
|
86
89
|
const id = requestId.slice(0, 8);
|
|
87
90
|
const missed = Math.max(0, daemon.maxSeq - (phone.seq ?? 0));
|
|
88
91
|
switch (t.class) {
|
|
92
|
+
case 'execution-error':
|
|
93
|
+
return `Turn ${id} delivered an execution error${daemon.terminalDetail ? `: ${daemon.terminalDetail}` : '.'} Inspect that failure before retrying; delivery and execution are separate outcomes.`;
|
|
94
|
+
case 'history-unavailable':
|
|
95
|
+
return `No retained receipt for turn ${id}. Its earlier history may have expired or it may never have been accepted. The outcome is unknown; do not rerun it automatically.`;
|
|
89
96
|
case 'outbound-loss':
|
|
90
97
|
return `Turn ${id} (${phone.kind}) left the phone ${phone.staleSend ? 'on a socket that only looked open' : 'via the outbox'} but the daemon's turn log has no record of it — the prompt never reached the Mac.`;
|
|
91
98
|
case 'inbound-loss':
|
|
92
99
|
// Terminal TYPE decides whether this is a waiting reply or a dead turn — the crux the old
|
|
93
100
|
// "recoverable via a pull" note got wrong (it called a restart-killed turn recoverable).
|
|
94
101
|
if (daemon.terminalType === 'error')
|
|
95
|
-
return `The Mac terminated turn ${id} with an error${daemon.terminalDetail ? ` ("${daemon.terminalDetail}")` : ''} at seq ${daemon.maxSeq}; the phone settled '${phone.state}' at seq ${phone.seq ?? 0}
|
|
102
|
+
return `The Mac terminated turn ${id} with an error${daemon.terminalDetail ? ` ("${daemon.terminalDetail}")` : ''} at seq ${daemon.maxSeq}; the phone settled '${phone.state}' at seq ${phone.seq ?? 0}. The recorded error is available by pull. Inspect workspace and provider state before choosing to retry.`;
|
|
96
103
|
if (daemon.terminalType === 'done')
|
|
97
104
|
return `The Mac ran turn ${id} to completion (done at seq ${daemon.maxSeq}) but the phone settled '${phone.state}' at seq ${phone.seq ?? 0} — it is missing ${missed} frame${missed === 1 ? '' : 's'} incl. the reply, which is on disk and recoverable via a pull.`;
|
|
98
105
|
return `The Mac produced ${daemon.maxSeq} frames for turn ${id} (not yet terminated) but the phone settled '${phone.state}' at seq ${phone.seq ?? 0} — it is ${missed} frame${missed === 1 ? '' : 's'} behind; a pull replays the gap.`;
|
|
@@ -110,7 +117,7 @@ function noteFor(t) {
|
|
|
110
117
|
function pickOffender(turns, focusRequestId) {
|
|
111
118
|
if (focusRequestId) {
|
|
112
119
|
const f = turns.find((t) => t.requestId === focusRequestId);
|
|
113
|
-
if (f
|
|
120
|
+
if (f)
|
|
114
121
|
return f;
|
|
115
122
|
}
|
|
116
123
|
const candidates = turns.filter((t) => SEVERITY[t.class] >= 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turnQueue.d.ts","sourceRoot":"","sources":["../../src/room/turnQueue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"turnQueue.d.ts","sourceRoot":"","sources":["../../src/room/turnQueue.ts"],"names":[],"mappings":"AAQA,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,KAAK,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAA;CAAE,CAAC,CAAC;AAQjE,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAI7C;AAED;uFACuF;AACvF,qBAAa,gBAAgB;IAMzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IALvB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;gBAEL,IAAI,EAAE;QACrB,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,YAAY,CAAC;QACnB,KAAK,EAAE,SAAS,CAAC;QACjB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QAClC,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC7D;IAuEH,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,IAAI;IAOZ,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIz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