@xfey/tutti 0.1.66 → 0.1.68
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/collaboration-state/index.d.ts +1 -1
- package/dist/collaboration-state/index.js +1 -1
- package/dist/collaboration-state/task-compile-context.d.ts +2 -1
- package/dist/collaboration-state/task-compile-context.js +8 -3
- package/dist/control-plane/index.d.ts +7 -0
- package/dist/control-plane/index.js +77 -3
- package/dist/control-plane/recent-references.d.ts +26 -0
- package/dist/control-plane/recent-references.js +94 -0
- package/dist/control-plane/reference-context-types.d.ts +12 -0
- package/dist/control-plane/reference-context-types.js +2 -0
- package/dist/control-plane/reference-summary-refresh.d.ts +5 -1
- package/dist/control-plane/reference-summary-refresh.js +181 -113
- package/dist/control-plane/run-start.js +12 -0
- package/dist/control-plane/task-compile-continuation.d.ts +2 -0
- package/dist/control-plane/task-compile-continuation.js +11 -0
- package/dist/control-plane/task-compile-start.d.ts +2 -0
- package/dist/control-plane/task-compile-start.js +113 -16
- package/dist/control-plane/types.d.ts +2 -0
- package/dist/control-plane/workflows/openai.js +7 -0
- package/dist/control-plane/workflows/types.d.ts +3 -0
- package/dist/run-pipeline/task-run-invocation.js +3 -0
- package/dist/workspace-ops/index.d.ts +1 -1
- package/dist/workspace-ops/index.js +1 -1
- package/dist/workspace-ops/reference-files.js +98 -34
- package/dist/workspace-ops/reference-summaries.d.ts +5 -0
- package/dist/workspace-ops/reference-summaries.js +6 -5
- package/package.json +2 -2
- package/prompts/README.md +1 -1
- package/prompts/procedures/README.md +1 -1
- package/prompts/procedures/task-compile.md +2 -1
- package/prompts/prompt-flow-map.md +9 -2
- package/prompts/runs/README.md +1 -1
- package/prompts/runs/task-continuation.md +3 -0
- package/prompts/runs/task-retry.md +3 -0
- package/prompts/runs/task-run.md +3 -0
- package/web/assets/{homepage-motion-scene-Doj_Soje.js → homepage-motion-scene-D2GZ8Nix.js} +1 -1
- package/web/assets/{index-DuT1ti0p.js → index-NsxRK6_d.js} +2 -2
- package/web/index.html +1 -1
|
@@ -3,7 +3,7 @@ export { createIdleExecutionStatusProjection } from "./execution-status.js";
|
|
|
3
3
|
export { createMainChatAgentMessage, createMainChatMessage, createMainChatSystemMessage, ensureInitialProjectWelcomeMessage, hasMainChatArtifactPreviewMessage, hasMainChatTaskResultMessage, hasMainChatWorklistCompileMessage, hasMainChatWorklistFeedbackMessage, readCompletedWorklistFeedbackTaskIds, readMessageProjectionById, readMainChatMessageWindow, readMainChatMessagesBeforeCursor, readMainChatMessagesForScratchpadCycle, } from "./messages.js";
|
|
4
4
|
export { createEmptyScratchpadProjection, readScratchpadReceiptSourceRefs, readScratchpadProjection, upsertScratchpadProjection, } from "./scratchpad.js";
|
|
5
5
|
export { markScratchpadRefreshFailed, markScratchpadRefreshStarted, markScratchpadRefreshSucceeded, markScratchpadSourceDirty, readScratchpadSourceState, } from "./scratchpad-source-state.js";
|
|
6
|
-
export { captureTaskCompileContext, completeTaskCompileContext, readActiveTaskCompileContext, rollbackTaskCompileContext, taskCompileContextSnapshot, } from "./task-compile-context.js";
|
|
6
|
+
export { captureTaskCompileContext, completeTaskCompileContext, readActiveTaskCompileContext, readCurrentScratchpadSourceRefs, rollbackTaskCompileContext, taskCompileContextSnapshot, } from "./task-compile-context.js";
|
|
7
7
|
export { deleteStaleClarificationSubmitReplayHints, readActiveClarificationProjection, readClarificationRoundProjection, readClarificationRoundsForThread, readClarificationThreadResponse, readSealedClarificationRoundsWithoutSuccessor, } from "./clarification-records.js";
|
|
8
8
|
export { createClarificationRoundAgentMessage, createClarificationRoundMessage, readClarificationRoundMessagesWindow, } from "./clarification-messages.js";
|
|
9
9
|
export { openNextTaskBoundClarificationRound, openNextTaskCompileClarificationRound, openTaskCompileClarificationRound, } from "./clarification-rounds.js";
|
|
@@ -3,7 +3,7 @@ export { createIdleExecutionStatusProjection } from "./execution-status.js";
|
|
|
3
3
|
export { createMainChatAgentMessage, createMainChatMessage, createMainChatSystemMessage, ensureInitialProjectWelcomeMessage, hasMainChatArtifactPreviewMessage, hasMainChatTaskResultMessage, hasMainChatWorklistCompileMessage, hasMainChatWorklistFeedbackMessage, readCompletedWorklistFeedbackTaskIds, readMessageProjectionById, readMainChatMessageWindow, readMainChatMessagesBeforeCursor, readMainChatMessagesForScratchpadCycle, } from "./messages.js";
|
|
4
4
|
export { createEmptyScratchpadProjection, readScratchpadReceiptSourceRefs, readScratchpadProjection, upsertScratchpadProjection, } from "./scratchpad.js";
|
|
5
5
|
export { markScratchpadRefreshFailed, markScratchpadRefreshStarted, markScratchpadRefreshSucceeded, markScratchpadSourceDirty, readScratchpadSourceState, } from "./scratchpad-source-state.js";
|
|
6
|
-
export { captureTaskCompileContext, completeTaskCompileContext, readActiveTaskCompileContext, rollbackTaskCompileContext, taskCompileContextSnapshot, } from "./task-compile-context.js";
|
|
6
|
+
export { captureTaskCompileContext, completeTaskCompileContext, readActiveTaskCompileContext, readCurrentScratchpadSourceRefs, rollbackTaskCompileContext, taskCompileContextSnapshot, } from "./task-compile-context.js";
|
|
7
7
|
export { deleteStaleClarificationSubmitReplayHints, readActiveClarificationProjection, readClarificationRoundProjection, readClarificationRoundsForThread, readClarificationThreadResponse, readSealedClarificationRoundsWithoutSuccessor, } from "./clarification-records.js";
|
|
8
8
|
export { createClarificationRoundAgentMessage, createClarificationRoundMessage, readClarificationRoundMessagesWindow, } from "./clarification-messages.js";
|
|
9
9
|
export { openNextTaskBoundClarificationRound, openNextTaskCompileClarificationRound, openTaskCompileClarificationRound, } from "./clarification-rounds.js";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { WorkflowInvocationRef } from "@tutti/shared/ids";
|
|
2
2
|
import { type SqliteDatabase } from "../store/index.js";
|
|
3
|
-
import type { CaptureTaskCompileContextInput, CompleteTaskCompileContextInput, RollbackTaskCompileContextInput, ScratchpadContentSnapshot, TaskCompileContextRecord } from "./types.js";
|
|
3
|
+
import type { CaptureTaskCompileContextInput, CompleteTaskCompileContextInput, RollbackTaskCompileContextInput, ScratchpadContentSnapshot, ScratchpadSourceRefInput, TaskCompileContextRecord } from "./types.js";
|
|
4
4
|
export declare function readActiveTaskCompileContext(db: SqliteDatabase, workflowRef?: WorkflowInvocationRef): TaskCompileContextRecord | null;
|
|
5
|
+
export declare function readCurrentScratchpadSourceRefs(db: SqliteDatabase): ScratchpadSourceRefInput[];
|
|
5
6
|
export declare function captureTaskCompileContext(db: SqliteDatabase, input: CaptureTaskCompileContextInput): TaskCompileContextRecord;
|
|
6
7
|
export declare function completeTaskCompileContext(db: SqliteDatabase, input: CompleteTaskCompileContextInput): {
|
|
7
8
|
updated_at?: string;
|
|
@@ -89,7 +89,7 @@ export function readActiveTaskCompileContext(db, workflowRef) {
|
|
|
89
89
|
}
|
|
90
90
|
return mapContextRow(row, readContextSources(db, row.workflow_ref));
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
export function readCurrentScratchpadSourceRefs(db) {
|
|
93
93
|
return db
|
|
94
94
|
.prepare(`
|
|
95
95
|
SELECT message_id, created_at
|
|
@@ -98,7 +98,12 @@ function currentScratchpadSources(db) {
|
|
|
98
98
|
AND source_scope = 'main_chat'
|
|
99
99
|
ORDER BY created_at ASC, message_id ASC
|
|
100
100
|
`)
|
|
101
|
-
.all()
|
|
101
|
+
.all()
|
|
102
|
+
.map((source) => ({
|
|
103
|
+
message_id: source.message_id,
|
|
104
|
+
source_scope: "main_chat",
|
|
105
|
+
created_at: source.created_at,
|
|
106
|
+
}));
|
|
102
107
|
}
|
|
103
108
|
export function captureTaskCompileContext(db, input) {
|
|
104
109
|
return withHostStoreTransaction(db, (tx) => {
|
|
@@ -114,7 +119,7 @@ export function captureTaskCompileContext(db, input) {
|
|
|
114
119
|
throw new Error("A ready Scratchpad is required to capture Task Compile Context");
|
|
115
120
|
}
|
|
116
121
|
const sourceState = readScratchpadSourceState(tx);
|
|
117
|
-
const sources =
|
|
122
|
+
const sources = readCurrentScratchpadSourceRefs(tx);
|
|
118
123
|
const lastSource = sources.at(-1);
|
|
119
124
|
const through = sourceState.refreshed_through_cursor ??
|
|
120
125
|
(lastSource === undefined
|
|
@@ -18,6 +18,10 @@ export declare class Phase5ControlPlane {
|
|
|
18
18
|
private readonly runLifecycle;
|
|
19
19
|
private readonly now;
|
|
20
20
|
private readonly scratchpadAutoRefreshScheduler;
|
|
21
|
+
private readonly pendingReferenceSummaryPaths;
|
|
22
|
+
private readonly referenceSummaryWaiters;
|
|
23
|
+
private pendingAllReferenceSummaries;
|
|
24
|
+
private referenceSummaryStartScheduled;
|
|
21
25
|
private lastRecoveryConclusion;
|
|
22
26
|
constructor(options: Phase5ControlPlaneOptions);
|
|
23
27
|
getExecutionStatus(): ExecutionStatusProjection;
|
|
@@ -36,9 +40,12 @@ export declare class Phase5ControlPlane {
|
|
|
36
40
|
startTaskCompile(payload: SubmitWorklistPayload): ControlPlaneCommandResult<SubmitWorklistDisposition, SubmitWorklistResult>;
|
|
37
41
|
startContextSyncAnalysis(trigger?: ContextSyncWorkflowTrigger): ControlPlaneCommandResult<ContextSyncDisposition, ContextSyncResult>;
|
|
38
42
|
startReferenceSummaryRefresh(payload?: RefreshReferenceSummariesPayload): ControlPlaneCommandResult<RefreshReferenceSummariesDisposition, RefreshReferenceSummariesResult>;
|
|
43
|
+
private tryStartPendingReferenceSummaryRefresh;
|
|
39
44
|
sendClarificationRoundMessage(roundId: ClarificationRoundRef, payload: SendClarificationRoundMessagePayload, author: TrustedHumanAuthor): ControlPlaneCommandResult<SendClarificationRoundMessageDisposition, SendClarificationRoundMessageResult>;
|
|
40
45
|
submitClarificationRound(roundId: ClarificationRoundRef, payload: SubmitClarificationRoundPayload, commandId: IdempotencyKey): ControlPlaneCommandResult<SubmitClarificationRoundDisposition, SubmitClarificationRoundResult>;
|
|
41
46
|
waitForIdle(): Promise<void>;
|
|
47
|
+
private hasPendingReferenceSummaryRefresh;
|
|
48
|
+
private schedulePendingReferenceSummaryRefresh;
|
|
42
49
|
private startRunForTask;
|
|
43
50
|
private readActiveRun;
|
|
44
51
|
private readActiveProcedures;
|
|
@@ -30,6 +30,10 @@ export class Phase5ControlPlane {
|
|
|
30
30
|
runLifecycle;
|
|
31
31
|
now;
|
|
32
32
|
scratchpadAutoRefreshScheduler;
|
|
33
|
+
pendingReferenceSummaryPaths = new Set();
|
|
34
|
+
referenceSummaryWaiters = new Map();
|
|
35
|
+
pendingAllReferenceSummaries = false;
|
|
36
|
+
referenceSummaryStartScheduled = false;
|
|
33
37
|
lastRecoveryConclusion = null;
|
|
34
38
|
constructor(options) {
|
|
35
39
|
this.store = options.store;
|
|
@@ -139,6 +143,11 @@ export class Phase5ControlPlane {
|
|
|
139
143
|
this.tryRunTaskArrivalScheduler();
|
|
140
144
|
}
|
|
141
145
|
},
|
|
146
|
+
registerReferenceSummaryWaiter: (activityRef, waiter) => {
|
|
147
|
+
const existing = this.referenceSummaryWaiters.get(activityRef) ?? [];
|
|
148
|
+
existing.push(waiter);
|
|
149
|
+
this.referenceSummaryWaiters.set(activityRef, existing);
|
|
150
|
+
},
|
|
142
151
|
onTasksAdded: () => {
|
|
143
152
|
tasksAdded = true;
|
|
144
153
|
},
|
|
@@ -159,11 +168,25 @@ export class Phase5ControlPlane {
|
|
|
159
168
|
});
|
|
160
169
|
}
|
|
161
170
|
startReferenceSummaryRefresh(payload = {}) {
|
|
162
|
-
|
|
171
|
+
if (payload.paths === undefined) {
|
|
172
|
+
this.pendingAllReferenceSummaries = true;
|
|
173
|
+
this.pendingReferenceSummaryPaths.clear();
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
for (const path of payload.paths) {
|
|
177
|
+
this.pendingReferenceSummaryPaths.add(path);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return this.tryStartPendingReferenceSummaryRefresh();
|
|
181
|
+
}
|
|
182
|
+
tryStartPendingReferenceSummaryRefresh() {
|
|
183
|
+
const refreshAll = this.pendingAllReferenceSummaries;
|
|
184
|
+
const paths = refreshAll ? undefined : [...this.pendingReferenceSummaryPaths];
|
|
185
|
+
const result = startReferenceSummaryRefreshProcedure({
|
|
163
186
|
engine: this.engine,
|
|
164
187
|
store: this.store,
|
|
165
188
|
events: this.events,
|
|
166
|
-
...(
|
|
189
|
+
...(paths === undefined ? {} : { paths }),
|
|
167
190
|
resolveWorkflowRunner: this.resolveWorkflowRunner,
|
|
168
191
|
readActiveActivity: () => this.readSchedulerBlocker(),
|
|
169
192
|
projectContext: this.projectContext,
|
|
@@ -171,6 +194,18 @@ export class Phase5ControlPlane {
|
|
|
171
194
|
now: this.now,
|
|
172
195
|
publishProcedureTransition: (state) => this.publishProcedureTransition(state),
|
|
173
196
|
});
|
|
197
|
+
if (result.disposition.kind !== "already_running") {
|
|
198
|
+
if (refreshAll) {
|
|
199
|
+
this.pendingAllReferenceSummaries = false;
|
|
200
|
+
this.pendingReferenceSummaryPaths.clear();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
for (const path of paths ?? []) {
|
|
204
|
+
this.pendingReferenceSummaryPaths.delete(path);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
174
209
|
}
|
|
175
210
|
sendClarificationRoundMessage(roundId, payload, author) {
|
|
176
211
|
return runSendClarificationRoundMessage({
|
|
@@ -198,10 +233,28 @@ export class Phase5ControlPlane {
|
|
|
198
233
|
while (true) {
|
|
199
234
|
await this.engine.waitForIdle();
|
|
200
235
|
await this.runEngine.waitForIdle();
|
|
201
|
-
|
|
236
|
+
await Promise.resolve();
|
|
237
|
+
if (this.readAnyActiveActivity() === null &&
|
|
238
|
+
!this.hasPendingReferenceSummaryRefresh()) {
|
|
202
239
|
return;
|
|
203
240
|
}
|
|
241
|
+
this.schedulePendingReferenceSummaryRefresh();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
hasPendingReferenceSummaryRefresh() {
|
|
245
|
+
return this.pendingAllReferenceSummaries || this.pendingReferenceSummaryPaths.size !== 0;
|
|
246
|
+
}
|
|
247
|
+
schedulePendingReferenceSummaryRefresh() {
|
|
248
|
+
if (!this.hasPendingReferenceSummaryRefresh() || this.referenceSummaryStartScheduled) {
|
|
249
|
+
return;
|
|
204
250
|
}
|
|
251
|
+
this.referenceSummaryStartScheduled = true;
|
|
252
|
+
queueMicrotask(() => {
|
|
253
|
+
this.referenceSummaryStartScheduled = false;
|
|
254
|
+
if (this.hasPendingReferenceSummaryRefresh()) {
|
|
255
|
+
void this.tryStartPendingReferenceSummaryRefresh();
|
|
256
|
+
}
|
|
257
|
+
});
|
|
205
258
|
}
|
|
206
259
|
startRunForTask(input) {
|
|
207
260
|
const result = startControlPlaneRunForTask({
|
|
@@ -304,6 +357,9 @@ export class Phase5ControlPlane {
|
|
|
304
357
|
onTerminal: (terminalState) => this.handleRunTerminalTransition(terminalState),
|
|
305
358
|
});
|
|
306
359
|
this.scratchpadAutoRefreshScheduler.notifyActivityChanged();
|
|
360
|
+
if (state.transition_kind === "terminal") {
|
|
361
|
+
this.schedulePendingReferenceSummaryRefresh();
|
|
362
|
+
}
|
|
307
363
|
}
|
|
308
364
|
handleRunTerminalTransition(state) {
|
|
309
365
|
if (state.activity.status === "finished") {
|
|
@@ -377,6 +433,7 @@ export class Phase5ControlPlane {
|
|
|
377
433
|
owner,
|
|
378
434
|
roundId,
|
|
379
435
|
resolveWorkflowRunner: this.resolveWorkflowRunner,
|
|
436
|
+
projectContext: this.projectContext,
|
|
380
437
|
logger: this.logger,
|
|
381
438
|
now: this.now,
|
|
382
439
|
publishProcedureTransition: (state) => {
|
|
@@ -421,6 +478,23 @@ export class Phase5ControlPlane {
|
|
|
421
478
|
getExecutionStatus: () => this.getExecutionStatus(),
|
|
422
479
|
});
|
|
423
480
|
this.scratchpadAutoRefreshScheduler.notifyActivityChanged();
|
|
481
|
+
if (state.transition_kind === "terminal") {
|
|
482
|
+
const activityRef = state.activity.activity_ref;
|
|
483
|
+
const waiters = this.referenceSummaryWaiters.get(activityRef) ?? [];
|
|
484
|
+
this.referenceSummaryWaiters.delete(activityRef);
|
|
485
|
+
for (const waiter of waiters) {
|
|
486
|
+
try {
|
|
487
|
+
waiter(state);
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
this.logger?.info({
|
|
491
|
+
activity_ref: activityRef,
|
|
492
|
+
error_name: error instanceof Error ? error.name : "UnknownError",
|
|
493
|
+
}, "Reference summary continuation failed");
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
this.schedulePendingReferenceSummaryRefresh();
|
|
497
|
+
}
|
|
424
498
|
}
|
|
425
499
|
logProcedureTransition(state) {
|
|
426
500
|
const activity = state.activity;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MessageId } from "@tutti/shared/ids";
|
|
2
|
+
import type { MessageReferenceFileRef } from "@tutti/shared/schemas/api";
|
|
3
|
+
import type { ScratchpadSourceRefInput } from "../collaboration-state/types.js";
|
|
4
|
+
import type { SqliteDatabase } from "../store/index.js";
|
|
5
|
+
import type { RecentReferenceContext } from "./reference-context-types.js";
|
|
6
|
+
export type RecentReferenceSource = MessageReferenceFileRef & {
|
|
7
|
+
message_id: MessageId;
|
|
8
|
+
};
|
|
9
|
+
export declare function readRecentReferenceSources(db: SqliteDatabase, sourceRefs: Array<Pick<ScratchpadSourceRefInput, "message_id">>): RecentReferenceSource[];
|
|
10
|
+
export declare function readPendingRecentReferenceSummaryPaths(options: {
|
|
11
|
+
workspaceRoot: string;
|
|
12
|
+
sources: RecentReferenceSource[];
|
|
13
|
+
now: () => Date;
|
|
14
|
+
}): string[];
|
|
15
|
+
export declare function materializeRecentReferences(options: {
|
|
16
|
+
workspaceRoot: string;
|
|
17
|
+
sources: RecentReferenceSource[];
|
|
18
|
+
now: () => Date;
|
|
19
|
+
}): RecentReferenceContext[];
|
|
20
|
+
export declare function materializeWorkflowRecentReferences(options: {
|
|
21
|
+
db: SqliteDatabase;
|
|
22
|
+
workspaceRoot: string;
|
|
23
|
+
workflowRef: string;
|
|
24
|
+
now: () => Date;
|
|
25
|
+
}): RecentReferenceContext[];
|
|
26
|
+
//# sourceMappingURL=recent-references.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { readMessageProjectionById, readScratchpadReceiptSourceRefs, } from "../collaboration-state/index.js";
|
|
2
|
+
import { readReferenceSummaryEntries } from "../workspace-ops/index.js";
|
|
3
|
+
export function readRecentReferenceSources(db, sourceRefs) {
|
|
4
|
+
const sources = [];
|
|
5
|
+
const seen = new Set();
|
|
6
|
+
for (const sourceRef of sourceRefs) {
|
|
7
|
+
const message = readMessageProjectionById(db, sourceRef.message_id);
|
|
8
|
+
const reference = message?.refs?.reference_file;
|
|
9
|
+
if (message?.author.kind !== "human" ||
|
|
10
|
+
reference === undefined ||
|
|
11
|
+
reference.source !== "human_upload") {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const identity = `${reference.path}\u0000${reference.blob_oid ?? ""}`;
|
|
15
|
+
if (seen.has(identity)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
seen.add(identity);
|
|
19
|
+
sources.push({ message_id: sourceRef.message_id, ...reference });
|
|
20
|
+
}
|
|
21
|
+
return sources;
|
|
22
|
+
}
|
|
23
|
+
export function readPendingRecentReferenceSummaryPaths(options) {
|
|
24
|
+
const paths = [...new Set(options.sources.map((source) => source.path))];
|
|
25
|
+
if (paths.length === 0) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const entries = new Map(readReferenceSummaryEntries({
|
|
29
|
+
workspaceRoot: options.workspaceRoot,
|
|
30
|
+
paths,
|
|
31
|
+
now: options.now,
|
|
32
|
+
}).map((entry) => [entry.path, entry]));
|
|
33
|
+
const pending = new Set();
|
|
34
|
+
for (const source of options.sources) {
|
|
35
|
+
const entry = entries.get(source.path);
|
|
36
|
+
if (source.blob_oid === undefined ||
|
|
37
|
+
entry === undefined ||
|
|
38
|
+
entry.blob_oid !== source.blob_oid) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (entry.summary.status === "missing" || entry.summary.status === "stale") {
|
|
42
|
+
pending.add(source.path);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return [...pending];
|
|
46
|
+
}
|
|
47
|
+
export function materializeRecentReferences(options) {
|
|
48
|
+
const paths = [...new Set(options.sources.map((source) => source.path))];
|
|
49
|
+
const entries = new Map(paths.length === 0
|
|
50
|
+
? []
|
|
51
|
+
: readReferenceSummaryEntries({
|
|
52
|
+
workspaceRoot: options.workspaceRoot,
|
|
53
|
+
paths,
|
|
54
|
+
now: options.now,
|
|
55
|
+
}).map((entry) => [entry.path, entry]));
|
|
56
|
+
return options.sources.map((source) => {
|
|
57
|
+
const entry = entries.get(source.path);
|
|
58
|
+
if (source.blob_oid === undefined) {
|
|
59
|
+
return unavailableRecentReference(source, "source_blob_unavailable");
|
|
60
|
+
}
|
|
61
|
+
if (entry === undefined) {
|
|
62
|
+
return unavailableRecentReference(source, "reference_unavailable");
|
|
63
|
+
}
|
|
64
|
+
if (entry.blob_oid !== source.blob_oid) {
|
|
65
|
+
return unavailableRecentReference(source, "reference_source_changed");
|
|
66
|
+
}
|
|
67
|
+
if (entry.summary.status === "available" && entry.summary.text !== undefined) {
|
|
68
|
+
return {
|
|
69
|
+
path: source.path,
|
|
70
|
+
name: source.name,
|
|
71
|
+
summary: { status: "available", text: entry.summary.text },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (entry.summary.status === "unavailable") {
|
|
75
|
+
return unavailableRecentReference(source, entry.summary.unavailable_reason ?? "summary_unavailable");
|
|
76
|
+
}
|
|
77
|
+
return unavailableRecentReference(source, "summary_not_ready");
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export function materializeWorkflowRecentReferences(options) {
|
|
81
|
+
return materializeRecentReferences({
|
|
82
|
+
workspaceRoot: options.workspaceRoot,
|
|
83
|
+
sources: readRecentReferenceSources(options.db, readScratchpadReceiptSourceRefs(options.db, options.workflowRef)),
|
|
84
|
+
now: options.now,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function unavailableRecentReference(source, reason) {
|
|
88
|
+
return {
|
|
89
|
+
path: source.path,
|
|
90
|
+
name: source.name,
|
|
91
|
+
summary: { status: "unavailable", reason },
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=recent-references.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActivityRef } from "@tutti/shared/ids";
|
|
1
|
+
import type { ActivityRef, WorkflowInvocationRef } from "@tutti/shared/ids";
|
|
2
2
|
import type { RefreshReferenceSummariesDisposition, RefreshReferenceSummariesResult } from "@tutti/shared/schemas/api";
|
|
3
3
|
import type { ProcedureEngine, ProcedureEngineState } from "../procedure-engine/index.js";
|
|
4
4
|
import type { WorkspaceEventBus } from "../server-shell/http/workspace-events.js";
|
|
@@ -17,6 +17,10 @@ export declare function startReferenceSummaryRefreshProcedure(input: {
|
|
|
17
17
|
projectContext: Phase5ControlPlaneOptions["projectContext"];
|
|
18
18
|
logger?: ControlPlaneLogger | undefined;
|
|
19
19
|
now: () => Date;
|
|
20
|
+
onExecuteStart?: (input: {
|
|
21
|
+
activityRef: ActivityRef;
|
|
22
|
+
workflowRef: WorkflowInvocationRef;
|
|
23
|
+
}) => void;
|
|
20
24
|
publishProcedureTransition: (state: ProcedureEngineState) => void;
|
|
21
25
|
}): ControlPlaneCommandResult<RefreshReferenceSummariesDisposition, RefreshReferenceSummariesResult>;
|
|
22
26
|
//# sourceMappingURL=reference-summary-refresh.d.ts.map
|