@bastani/atomic 0.9.38 → 0.9.39-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/index.bundle.mjs +216 -2
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +16 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +14 -0
- package/dist/builtin/workflows/package.json +3 -3
- package/dist/builtin/workflows/src/durable/journal/resolution.d.ts +2 -15
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +593 -131
- package/dist/builtin/workflows/src/index.js +301 -27
- package/dist/cli.js +13 -6
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +4 -1
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +1 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +13 -10
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +2 -0
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +5 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +4 -0
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +1 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +3 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +1 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +6 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js +10 -0
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/sdk-types.d.ts +7 -1
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +12 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/storage/provider.d.ts +14 -0
- package/dist/core/storage/provider.d.ts.map +1 -1
- package/dist/core/storage/provider.js.map +1 -1
- package/dist/core/storage/session/legacy-session-store.d.ts +4 -1
- package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/legacy-session-store.js +42 -2
- package/dist/core/storage/session/legacy-session-store.js.map +1 -1
- package/dist/core/storage/session/legacy-session-summary.d.ts +8 -0
- package/dist/core/storage/session/legacy-session-summary.d.ts.map +1 -1
- package/dist/core/storage/session/legacy-session-summary.js +42 -2
- package/dist/core/storage/session/legacy-session-summary.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +0 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts +0 -1
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +8 -13
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/program-status-reporter.d.ts +0 -1
- package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -1
- package/dist/modes/interactive/program-status-reporter.js +0 -4
- package/dist/modes/interactive/program-status-reporter.js.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js +2 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/engine-heap.d.ts +24 -0
- package/dist/modes/interactive-engine/engine-heap.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-heap.js +88 -0
- package/dist/modes/interactive-engine/engine-heap.js.map +1 -0
- package/dist/modes/rpc/rpc-client-api.d.ts +1 -0
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +3 -0
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +7 -0
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +9 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/heap-relaunch.d.ts +14 -0
- package/dist/utils/heap-relaunch.d.ts.map +1 -0
- package/dist/utils/heap-relaunch.js +59 -0
- package/dist/utils/heap-relaunch.js.map +1 -0
- package/docs/environment-variables.md +2 -1
- package/docs/intercom/reference.md +1 -1
- package/docs/rpc/protocol.md +23 -0
- package/docs/sdk/web-server.md +1 -1
- package/docs/sdk.md +10 -1
- package/docs/session-format.md +1 -0
- package/docs/sessions.md +2 -0
- package/docs/settings.md +1 -1
- package/docs/workflows/api-reference.md +1 -1
- package/docs/workflows/operations.md +5 -1
- package/npm-shrinkwrap.json +32 -32
- package/package.json +4 -4
|
@@ -35557,6 +35557,72 @@ Defaulting to 2020, but this will stop working in the future.`)), t.ecmaVersion
|
|
|
35557
35557
|
})();
|
|
35558
35558
|
});
|
|
35559
35559
|
|
|
35560
|
+
// dist/builtin/workflows/builtin/index.ts
|
|
35561
|
+
var exports_builtin = {};
|
|
35562
|
+
__export(exports_builtin, {
|
|
35563
|
+
adversarialVerification: () => adversarial_verification_default,
|
|
35564
|
+
classifyAndAct: () => classify_and_act_default,
|
|
35565
|
+
fanOutAndSynthesize: () => fan_out_and_synthesize_default,
|
|
35566
|
+
generateAndFilter: () => generate_and_filter_default,
|
|
35567
|
+
goal: () => goal_default,
|
|
35568
|
+
loopUntilDone: () => loop_until_done_default,
|
|
35569
|
+
openClaudeDesign: () => open_claude_design_default,
|
|
35570
|
+
ralph: () => ralph_default,
|
|
35571
|
+
tournament: () => tournament_default
|
|
35572
|
+
});
|
|
35573
|
+
|
|
35574
|
+
// dist/builtin/workflows/builtin/steering-context.ts
|
|
35575
|
+
var exports_steering_context = {};
|
|
35576
|
+
__export(exports_steering_context, {
|
|
35577
|
+
withSteeringPropagationContext: () => withSteeringPropagationContext
|
|
35578
|
+
});
|
|
35579
|
+
|
|
35580
|
+
// dist/builtin/workflows/src/sdk-surface.ts
|
|
35581
|
+
var exports_sdk_surface = {};
|
|
35582
|
+
__export(exports_sdk_surface, {
|
|
35583
|
+
DEFAULT_WORKFLOW_HEARTBEAT_INTERVAL_MINUTES: () => DEFAULT_WORKFLOW_HEARTBEAT_INTERVAL_MINUTES,
|
|
35584
|
+
GraphFrontierTracker: () => GraphFrontierTracker,
|
|
35585
|
+
INTERACTIVE_WORKFLOW_POLICY: () => INTERACTIVE_WORKFLOW_POLICY,
|
|
35586
|
+
JOURNAL_COLUMNS: () => JOURNAL_COLUMNS,
|
|
35587
|
+
JOURNAL_LEASE: () => JOURNAL_LEASE,
|
|
35588
|
+
JOURNAL_PAYLOAD_ENCODING: () => JOURNAL_PAYLOAD_ENCODING,
|
|
35589
|
+
JOURNAL_SCHEMA_VERSION: () => JOURNAL_SCHEMA_VERSION,
|
|
35590
|
+
JOURNAL_TABLES: () => JOURNAL_TABLES,
|
|
35591
|
+
JournalCasConflictError: () => JournalCasConflictError,
|
|
35592
|
+
JournalClosedError: () => JournalClosedError,
|
|
35593
|
+
JournalCounterRangeError: () => JournalCounterRangeError,
|
|
35594
|
+
JournalError: () => JournalError,
|
|
35595
|
+
JournalInvalidTextError: () => JournalInvalidTextError,
|
|
35596
|
+
JournalMetaCorruptError: () => JournalMetaCorruptError,
|
|
35597
|
+
JournalSchemaVersionError: () => JournalSchemaVersionError,
|
|
35598
|
+
KEEP_CONTEXT_CLOSE_TAG: () => KEEP_CONTEXT_CLOSE_TAG,
|
|
35599
|
+
KEEP_CONTEXT_OPEN_TAG: () => KEEP_CONTEXT_OPEN_TAG,
|
|
35600
|
+
MemoryRunJournal: () => MemoryRunJournal,
|
|
35601
|
+
NON_INTERACTIVE_WORKFLOW_POLICY: () => NON_INTERACTIVE_WORKFLOW_POLICY,
|
|
35602
|
+
RUN_EVENT_TYPES: () => RUN_EVENT_TYPES,
|
|
35603
|
+
RunNotFoundError: () => RunNotFoundError,
|
|
35604
|
+
SqlRunJournal: () => SqlRunJournal,
|
|
35605
|
+
StaleLeaseError: () => StaleLeaseError,
|
|
35606
|
+
StorageUnavailableError: () => StorageUnavailableError,
|
|
35607
|
+
WORKFLOW_HEARTBEAT_CUSTOM_TYPE: () => WORKFLOW_HEARTBEAT_CUSTOM_TYPE,
|
|
35608
|
+
cancellationRegistry: () => cancellationRegistry,
|
|
35609
|
+
createAgentSessionAdapter: () => createAgentSessionAdapter,
|
|
35610
|
+
createCancellationRegistry: () => createCancellationRegistry,
|
|
35611
|
+
createRegistry: () => createRegistry,
|
|
35612
|
+
createStore: () => createStore,
|
|
35613
|
+
keepContext: () => keepContext,
|
|
35614
|
+
normalizeWorkflowName: () => normalizeWorkflowName,
|
|
35615
|
+
openSqlRunJournal: () => openSqlRunJournal,
|
|
35616
|
+
registerRunJournalConformance: () => registerRunJournalConformance,
|
|
35617
|
+
resolveInputs: () => resolveInputs,
|
|
35618
|
+
resolveRunJournal: () => resolveRunJournal,
|
|
35619
|
+
run: () => run2,
|
|
35620
|
+
setupGitWorktree: () => setupGitWorktree,
|
|
35621
|
+
store: () => store,
|
|
35622
|
+
workflow: () => workflow,
|
|
35623
|
+
workflowNamesEqual: () => workflowNamesEqual
|
|
35624
|
+
});
|
|
35625
|
+
|
|
35560
35626
|
// dist/builtin/workflows/src/extension/extension-factory.ts
|
|
35561
35627
|
import { registerExtensionContextRetirementEffect as registerExtensionContextRetirementEffect3 } from "@bastani/atomic";
|
|
35562
35628
|
|
|
@@ -41098,9 +41164,9 @@ function createStageControlRegistry() {
|
|
|
41098
41164
|
const _byRun = new Map;
|
|
41099
41165
|
const pendingDisposals = new Set;
|
|
41100
41166
|
const sessionStores = new Map;
|
|
41167
|
+
const releaseListeners = new Set;
|
|
41101
41168
|
let generation = 0;
|
|
41102
|
-
function rememberSessionStore(handle) {
|
|
41103
|
-
const store = handle.sessionStore;
|
|
41169
|
+
function rememberSessionStore(handle, store = handle.sessionStore) {
|
|
41104
41170
|
if (store === undefined)
|
|
41105
41171
|
return;
|
|
41106
41172
|
let stores = sessionStores.get(handle.runId);
|
|
@@ -41149,6 +41215,35 @@ function createStageControlRegistry() {
|
|
|
41149
41215
|
function disposeEntryInBackground(entry, message) {
|
|
41150
41216
|
disposeEntry(entry).catch((err) => console.warn(message, err));
|
|
41151
41217
|
}
|
|
41218
|
+
async function releaseIdleEntry(runId, stageId, entry) {
|
|
41219
|
+
const gate = entry.handle.releaseGate;
|
|
41220
|
+
if (gate === undefined || entry.disposal !== undefined)
|
|
41221
|
+
return;
|
|
41222
|
+
const epoch = entry.epoch;
|
|
41223
|
+
const savedIn = await gate.savedForReopen();
|
|
41224
|
+
if (savedIn === undefined)
|
|
41225
|
+
return;
|
|
41226
|
+
const runMap = _byRun.get(runId);
|
|
41227
|
+
if (runMap?.get(stageId) !== entry || entry.epoch !== epoch || entry.leases.size > 0)
|
|
41228
|
+
return;
|
|
41229
|
+
if (entry.disposal !== undefined || !gate.idle())
|
|
41230
|
+
return;
|
|
41231
|
+
const { stageName, sessionId } = entry.handle;
|
|
41232
|
+
rememberSessionStore(entry.handle, savedIn);
|
|
41233
|
+
runMap.delete(stageId);
|
|
41234
|
+
if (runMap.size === 0)
|
|
41235
|
+
_byRun.delete(runId);
|
|
41236
|
+
await disposeEntry(entry);
|
|
41237
|
+
if (sessionId === undefined)
|
|
41238
|
+
return;
|
|
41239
|
+
for (const listener of [...releaseListeners]) {
|
|
41240
|
+
try {
|
|
41241
|
+
listener({ runId, stageId, stageName, sessionId });
|
|
41242
|
+
} catch (error) {
|
|
41243
|
+
console.warn("atomic-workflows: released stage listener failed", error);
|
|
41244
|
+
}
|
|
41245
|
+
}
|
|
41246
|
+
}
|
|
41152
41247
|
function makeRunHandle(runId) {
|
|
41153
41248
|
return {
|
|
41154
41249
|
runId,
|
|
@@ -41208,7 +41303,8 @@ function createStageControlRegistry() {
|
|
|
41208
41303
|
handle,
|
|
41209
41304
|
controlsDependencies: true,
|
|
41210
41305
|
permanent: true,
|
|
41211
|
-
leases: new Set
|
|
41306
|
+
leases: new Set,
|
|
41307
|
+
epoch: 0
|
|
41212
41308
|
});
|
|
41213
41309
|
if (displaced !== undefined && displaced.handle !== handle && !displaced.permanent) {
|
|
41214
41310
|
disposeEntryInBackground(displaced, "atomic-workflows: displaced provisional stage handle dispose failed");
|
|
@@ -41230,6 +41326,7 @@ function createStageControlRegistry() {
|
|
|
41230
41326
|
const existing = runMap.get(stageId);
|
|
41231
41327
|
if (existing !== undefined && existing.handle.isDisposed !== true) {
|
|
41232
41328
|
existing.permanent = true;
|
|
41329
|
+
existing.epoch += 1;
|
|
41233
41330
|
return existing.handle;
|
|
41234
41331
|
}
|
|
41235
41332
|
if (existing !== undefined) {
|
|
@@ -41241,7 +41338,8 @@ function createStageControlRegistry() {
|
|
|
41241
41338
|
handle,
|
|
41242
41339
|
controlsDependencies: false,
|
|
41243
41340
|
permanent: true,
|
|
41244
|
-
leases: new Set
|
|
41341
|
+
leases: new Set,
|
|
41342
|
+
epoch: 0
|
|
41245
41343
|
});
|
|
41246
41344
|
return handle;
|
|
41247
41345
|
},
|
|
@@ -41258,11 +41356,13 @@ function createStageControlRegistry() {
|
|
|
41258
41356
|
handle: create(),
|
|
41259
41357
|
controlsDependencies: false,
|
|
41260
41358
|
permanent: false,
|
|
41261
|
-
leases: new Set
|
|
41359
|
+
leases: new Set,
|
|
41360
|
+
epoch: 0
|
|
41262
41361
|
};
|
|
41263
41362
|
runMap.set(stageId, entry);
|
|
41264
41363
|
}
|
|
41265
41364
|
const leasedEntry = entry;
|
|
41365
|
+
leasedEntry.epoch += 1;
|
|
41266
41366
|
const token = Symbol("detached-stage-handle-lease");
|
|
41267
41367
|
leasedEntry.leases.add(token);
|
|
41268
41368
|
let settled = false;
|
|
@@ -41315,8 +41415,10 @@ function createStageControlRegistry() {
|
|
|
41315
41415
|
},
|
|
41316
41416
|
claim(runId, stageId) {
|
|
41317
41417
|
const entry = _byRun.get(runId)?.get(stageId);
|
|
41318
|
-
if (entry !== undefined)
|
|
41418
|
+
if (entry !== undefined) {
|
|
41319
41419
|
entry.permanent = true;
|
|
41420
|
+
entry.epoch += 1;
|
|
41421
|
+
}
|
|
41320
41422
|
return entry?.handle;
|
|
41321
41423
|
},
|
|
41322
41424
|
get(runId, stageId) {
|
|
@@ -41366,6 +41468,21 @@ function createStageControlRegistry() {
|
|
|
41366
41468
|
_byRun.delete(runId);
|
|
41367
41469
|
}
|
|
41368
41470
|
await disposeEntries(entries);
|
|
41471
|
+
},
|
|
41472
|
+
async releaseIdle(runId) {
|
|
41473
|
+
for (const [stageId, entry] of [..._byRun.get(runId) ?? []]) {
|
|
41474
|
+
try {
|
|
41475
|
+
await releaseIdleEntry(runId, stageId, entry);
|
|
41476
|
+
} catch (error) {
|
|
41477
|
+
console.warn("atomic-workflows: completed stage session release failed", error);
|
|
41478
|
+
}
|
|
41479
|
+
}
|
|
41480
|
+
},
|
|
41481
|
+
onStageReleased(listener) {
|
|
41482
|
+
releaseListeners.add(listener);
|
|
41483
|
+
return () => {
|
|
41484
|
+
releaseListeners.delete(listener);
|
|
41485
|
+
};
|
|
41369
41486
|
}
|
|
41370
41487
|
};
|
|
41371
41488
|
}
|
|
@@ -45060,6 +45177,21 @@ function getDurableBackendProcessOwner() {
|
|
|
45060
45177
|
bag[DURABLE_BACKEND_PROCESS_OWNER_KEY] = created;
|
|
45061
45178
|
return created;
|
|
45062
45179
|
}
|
|
45180
|
+
async function releaseDurableBackendsHeldBy(holder) {
|
|
45181
|
+
const selected = getDurableBackendProcessOwner().selectedBackends;
|
|
45182
|
+
if (selected === undefined)
|
|
45183
|
+
return;
|
|
45184
|
+
const released = [];
|
|
45185
|
+
for (const [key, entry] of selected) {
|
|
45186
|
+
if (!entry.holders.delete(holder) || entry.holders.size > 0 || entry.pinned)
|
|
45187
|
+
continue;
|
|
45188
|
+
selected.delete(key);
|
|
45189
|
+
released.push(entry);
|
|
45190
|
+
}
|
|
45191
|
+
await Promise.all(released.map((entry) => entry.ready.then(() => entry.close?.(), () => {
|
|
45192
|
+
return;
|
|
45193
|
+
})));
|
|
45194
|
+
}
|
|
45063
45195
|
|
|
45064
45196
|
// dist/builtin/workflows/src/durable/journal/types.ts
|
|
45065
45197
|
import { StorageSchemaVersionError } from "@bastani/atomic/storage";
|
|
@@ -51294,27 +51426,66 @@ function enqueueTargetTurn(queues, key, deliver) {
|
|
|
51294
51426
|
return current;
|
|
51295
51427
|
}
|
|
51296
51428
|
async function deliverAsPostMortemTurn(event, resolveHandle, assertActive) {
|
|
51429
|
+
const handle = await reopenCompletedStage(event.workflowRunId, event.workflowStageId, resolveHandle, assertActive);
|
|
51430
|
+
for (const message of event.messages) {
|
|
51431
|
+
assertActive();
|
|
51432
|
+
if (handle.isStreaming)
|
|
51433
|
+
await handle.followUp(message.content);
|
|
51434
|
+
else
|
|
51435
|
+
await handle.prompt(message.content);
|
|
51436
|
+
}
|
|
51437
|
+
}
|
|
51438
|
+
async function reopenCompletedStage(runId, stageId, resolveHandle, assertActive) {
|
|
51297
51439
|
assertActive();
|
|
51298
|
-
const resolution = await resolveHandle(
|
|
51440
|
+
const resolution = await resolveHandle(runId, stageId);
|
|
51299
51441
|
assertActive();
|
|
51300
51442
|
if (resolution === undefined) {
|
|
51301
|
-
throw new Error(`Intercom ask target is unavailable: completed workflow stage ${
|
|
51443
|
+
throw new Error(`Intercom ask target is unavailable: completed workflow stage ${runId}/${stageId} was deleted or is no longer retained.`);
|
|
51302
51444
|
}
|
|
51303
51445
|
if (!resolution.ok) {
|
|
51304
|
-
throw new Error(unavailableReason(
|
|
51446
|
+
throw new Error(unavailableReason(runId, stageId, resolution.reason));
|
|
51305
51447
|
}
|
|
51306
51448
|
const handle = resolution.handle;
|
|
51307
51449
|
if (handle.status !== "completed" || handle.isDisposed === true) {
|
|
51308
|
-
throw new Error(`Intercom ask target is not resumable: workflow stage ${
|
|
51450
|
+
throw new Error(`Intercom ask target is not resumable: workflow stage ${runId}/${stageId} has no retained completed conversation.`);
|
|
51309
51451
|
}
|
|
51310
51452
|
await attachWithTimeout(handle);
|
|
51311
|
-
|
|
51312
|
-
|
|
51313
|
-
|
|
51314
|
-
|
|
51315
|
-
|
|
51316
|
-
|
|
51453
|
+
return handle;
|
|
51454
|
+
}
|
|
51455
|
+
function assistantMessageText(message) {
|
|
51456
|
+
if (message.role !== "assistant")
|
|
51457
|
+
return;
|
|
51458
|
+
let text = "";
|
|
51459
|
+
for (const block of message.content)
|
|
51460
|
+
if (block.type === "text")
|
|
51461
|
+
text += block.text;
|
|
51462
|
+
return text.trim().length > 0 ? text.trim() : undefined;
|
|
51463
|
+
}
|
|
51464
|
+
async function collectTurnReply(handle, content) {
|
|
51465
|
+
let reply;
|
|
51466
|
+
const unsubscribe = handle.subscribe((event) => {
|
|
51467
|
+
if (event.type !== "message_end")
|
|
51468
|
+
return;
|
|
51469
|
+
reply = assistantMessageText(event.message) ?? reply;
|
|
51470
|
+
});
|
|
51471
|
+
try {
|
|
51472
|
+
await handle.prompt(content);
|
|
51473
|
+
} finally {
|
|
51474
|
+
unsubscribe();
|
|
51317
51475
|
}
|
|
51476
|
+
return reply;
|
|
51477
|
+
}
|
|
51478
|
+
function createCompletedStageAnswerer(resolveHandle, assertActive = () => {}) {
|
|
51479
|
+
const queues = new Map;
|
|
51480
|
+
return (runId, stageId, content) => enqueueTargetTurn(queues, `${runId}:${stageId}`, async () => {
|
|
51481
|
+
const handle = await reopenCompletedStage(runId, stageId, resolveHandle, assertActive);
|
|
51482
|
+
if (handle.isStreaming) {
|
|
51483
|
+
throw new Error(`Completed workflow stage ${runId}/${stageId} is busy with another turn; ask again when it is idle.`);
|
|
51484
|
+
}
|
|
51485
|
+
const reply = await collectTurnReply(handle, content);
|
|
51486
|
+
assertActive();
|
|
51487
|
+
return reply ?? `Completed workflow stage ${runId}/${stageId} reopened but produced no text answer.`;
|
|
51488
|
+
});
|
|
51318
51489
|
}
|
|
51319
51490
|
async function attachWithTimeout(handle) {
|
|
51320
51491
|
let timeout;
|
|
@@ -58227,6 +58398,20 @@ class MemoryRunJournal {
|
|
|
58227
58398
|
|
|
58228
58399
|
// dist/builtin/workflows/src/durable/journal/journal-backend.ts
|
|
58229
58400
|
var PROCESS_HOLDER_ID = randomUUID4();
|
|
58401
|
+
var processExitCleanups = new Set;
|
|
58402
|
+
function runProcessExitCleanups() {
|
|
58403
|
+
for (const cleanup of processExitCleanups)
|
|
58404
|
+
cleanup();
|
|
58405
|
+
}
|
|
58406
|
+
function addProcessExitCleanup(cleanup) {
|
|
58407
|
+
if (processExitCleanups.size === 0)
|
|
58408
|
+
process.once("exit", runProcessExitCleanups);
|
|
58409
|
+
processExitCleanups.add(cleanup);
|
|
58410
|
+
}
|
|
58411
|
+
function removeProcessExitCleanup(cleanup) {
|
|
58412
|
+
if (processExitCleanups.delete(cleanup) && processExitCleanups.size === 0)
|
|
58413
|
+
process.off("exit", runProcessExitCleanups);
|
|
58414
|
+
}
|
|
58230
58415
|
function* invoke(action) {
|
|
58231
58416
|
try {
|
|
58232
58417
|
const result = action();
|
|
@@ -58853,7 +59038,7 @@ class JournalDurableBackend {
|
|
|
58853
59038
|
process.exitCode = 1;
|
|
58854
59039
|
});
|
|
58855
59040
|
};
|
|
58856
|
-
|
|
59041
|
+
addProcessExitCleanup(this.processExitCleanup);
|
|
58857
59042
|
}
|
|
58858
59043
|
async withWorkflowLease(runId, action) {
|
|
58859
59044
|
this.ensureOpen();
|
|
@@ -58921,7 +59106,7 @@ class JournalDurableBackend {
|
|
|
58921
59106
|
return this.closing;
|
|
58922
59107
|
this.state = "closing";
|
|
58923
59108
|
if (this.processExitCleanup !== undefined) {
|
|
58924
|
-
|
|
59109
|
+
removeProcessExitCleanup(this.processExitCleanup);
|
|
58925
59110
|
this.processExitCleanup = undefined;
|
|
58926
59111
|
}
|
|
58927
59112
|
if (this.timer !== undefined)
|
|
@@ -59462,28 +59647,33 @@ async function initializeDurableBackend(options = {}) {
|
|
|
59462
59647
|
projectTrusted: options.projectTrusted
|
|
59463
59648
|
}).getSettings() : undefined
|
|
59464
59649
|
});
|
|
59465
|
-
const
|
|
59650
|
+
const holder = options.holder;
|
|
59651
|
+
const key = "createRun" in selection ? selection : selection.kind === "memory" && choice !== undefined ? choice : selection.kind === "memory" && holder !== undefined ? holder : storageSelectionKey(selection, getAgentDir3());
|
|
59466
59652
|
const ownsJournal = choice === undefined || !("createRun" in choice);
|
|
59467
59653
|
owner.selectedBackends ??= new Map;
|
|
59468
59654
|
const selected = owner.selectedBackends;
|
|
59469
59655
|
const existing = selected.get(key);
|
|
59470
|
-
|
|
59471
|
-
|
|
59472
|
-
ready = existing.ready;
|
|
59473
|
-
} else {
|
|
59474
|
-
ready = openSelectedRunJournal(selection).then((journal) => JournalDurableBackend.open(journal, { ownsJournal })).then((opened) => {
|
|
59656
|
+
const entry = existing ?? {
|
|
59657
|
+
ready: openSelectedRunJournal(selection).then((journal) => JournalDurableBackend.open(journal, { ownsJournal })).then((opened) => {
|
|
59475
59658
|
if (ownsJournal)
|
|
59476
59659
|
opened.closeOnProcessExit();
|
|
59477
59660
|
entry.close = () => opened.close();
|
|
59478
59661
|
return opened;
|
|
59479
59662
|
}).catch((error) => {
|
|
59480
|
-
selected.
|
|
59663
|
+
if (selected.get(key) === entry)
|
|
59664
|
+
selected.delete(key);
|
|
59481
59665
|
throw error;
|
|
59482
|
-
})
|
|
59483
|
-
|
|
59666
|
+
}),
|
|
59667
|
+
holders: new Set,
|
|
59668
|
+
pinned: false
|
|
59669
|
+
};
|
|
59670
|
+
if (existing === undefined)
|
|
59484
59671
|
selected.set(key, entry);
|
|
59485
|
-
|
|
59486
|
-
|
|
59672
|
+
if (holder === undefined)
|
|
59673
|
+
entry.pinned = true;
|
|
59674
|
+
else
|
|
59675
|
+
entry.holders.add(holder);
|
|
59676
|
+
return withRunJournalConfigSource(selection, () => entry.ready);
|
|
59487
59677
|
}
|
|
59488
59678
|
|
|
59489
59679
|
// dist/builtin/workflows/src/shared/workflow-request-timeout.ts
|
|
@@ -60830,6 +61020,45 @@ function createDurableChildWorkflowPrimitive(input) {
|
|
|
60830
61020
|
};
|
|
60831
61021
|
}
|
|
60832
61022
|
|
|
61023
|
+
// dist/builtin/workflows/src/durable/run-result.ts
|
|
61024
|
+
var RUN_RESULT_CHECKPOINT_NAME = "workflow-run-result";
|
|
61025
|
+
var RUN_RESULT_CHECKPOINT_ID_PREFIX = "run-result:";
|
|
61026
|
+
function isOutputValues(value2) {
|
|
61027
|
+
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
61028
|
+
}
|
|
61029
|
+
function durableRunResult(backend, workflowId) {
|
|
61030
|
+
const output = backend.getToolOutput(workflowId, RUN_RESULT_CHECKPOINT_NAME);
|
|
61031
|
+
if (!isOutputValues(output))
|
|
61032
|
+
return;
|
|
61033
|
+
const result = output.result;
|
|
61034
|
+
return isOutputValues(result) ? result : undefined;
|
|
61035
|
+
}
|
|
61036
|
+
async function recordRunResultCheckpointAsync(backend, run) {
|
|
61037
|
+
const result = run.result;
|
|
61038
|
+
const hasResult = result !== undefined && Object.keys(result).length > 0;
|
|
61039
|
+
const recorded = backend.getToolCheckpoint(run.id, RUN_RESULT_CHECKPOINT_NAME);
|
|
61040
|
+
if (!hasResult && recorded === undefined)
|
|
61041
|
+
return false;
|
|
61042
|
+
if (backend.listCheckpoints(run.id).length === 0)
|
|
61043
|
+
return false;
|
|
61044
|
+
const output = hasResult ? { result } : {};
|
|
61045
|
+
if (recorded !== undefined && durableHash(recorded.output) === durableHash(output))
|
|
61046
|
+
return false;
|
|
61047
|
+
const previousSequence = Number(recorded?.checkpointId.slice(RUN_RESULT_CHECKPOINT_ID_PREFIX.length));
|
|
61048
|
+
const sequence = Number.isSafeInteger(previousSequence) ? previousSequence + 1 : 1;
|
|
61049
|
+
const completedAt = Math.max(Date.now(), recorded?.completedAt ?? 0);
|
|
61050
|
+
await backend.commitCheckpoint({
|
|
61051
|
+
kind: "tool",
|
|
61052
|
+
workflowId: run.id,
|
|
61053
|
+
checkpointId: `${RUN_RESULT_CHECKPOINT_ID_PREFIX}${sequence}`,
|
|
61054
|
+
name: RUN_RESULT_CHECKPOINT_NAME,
|
|
61055
|
+
argsHash: RUN_RESULT_CHECKPOINT_NAME,
|
|
61056
|
+
output,
|
|
61057
|
+
completedAt
|
|
61058
|
+
});
|
|
61059
|
+
return true;
|
|
61060
|
+
}
|
|
61061
|
+
|
|
60833
61062
|
// dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts
|
|
60834
61063
|
import { isAbsolute as isAbsolute9, join as join10, resolve as resolve10 } from "node:path";
|
|
60835
61064
|
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2 } from "@bastani/atomic";
|
|
@@ -66424,6 +66653,12 @@ async function finalizeDurableTerminalStatus(input) {
|
|
|
66424
66653
|
return;
|
|
66425
66654
|
const durableStatus = toDurableStatus(status);
|
|
66426
66655
|
if (durableStatus !== undefined) {
|
|
66656
|
+
try {
|
|
66657
|
+
await recordRunResultCheckpointAsync(input.durableBackend, input.runSnapshot);
|
|
66658
|
+
} catch (error) {
|
|
66659
|
+
if (input.runSnapshot.result !== undefined)
|
|
66660
|
+
throw error;
|
|
66661
|
+
}
|
|
66427
66662
|
if (durableStatus === "failed" || durableStatus === "blocked") {
|
|
66428
66663
|
await recordRunTimingCheckpointAsync(input.durableBackend, input.runSnapshot);
|
|
66429
66664
|
}
|
|
@@ -67646,6 +67881,7 @@ function createTrackedStageCaller(input) {
|
|
|
67646
67881
|
throw err;
|
|
67647
67882
|
}
|
|
67648
67883
|
const trackStageLifecycle = !runtime.state.stageFinalized;
|
|
67884
|
+
runtime.state.sessionCheckpointed = false;
|
|
67649
67885
|
let applyTerminalStageState;
|
|
67650
67886
|
let terminalStateIsSuccess = false;
|
|
67651
67887
|
let stageResultBeforeBudget;
|
|
@@ -67916,6 +68152,7 @@ function createTrackedStageCaller(input) {
|
|
|
67916
68152
|
} else if (runtime.state.stageClosedByWorkflowExit || runtime.exit.currentWorkflowExitAbortReason() !== undefined) {
|
|
67917
68153
|
await runtime.releaseLiveHandle().catch(() => {});
|
|
67918
68154
|
}
|
|
68155
|
+
runtime.state.sessionCheckpointed = finalizationError === undefined;
|
|
67919
68156
|
input.limiter.release();
|
|
67920
68157
|
if (finalizationError !== undefined)
|
|
67921
68158
|
throwFinalizationError(finalizationError.error);
|
|
@@ -68147,7 +68384,29 @@ function createStageControlHandle(runtime) {
|
|
|
68147
68384
|
toolExecutions.record(event);
|
|
68148
68385
|
queuedUserMessages.record(event);
|
|
68149
68386
|
});
|
|
68150
|
-
|
|
68387
|
+
let externalSubscribers = 0;
|
|
68388
|
+
const countSubscription = (unsubscribe) => {
|
|
68389
|
+
externalSubscribers += 1;
|
|
68390
|
+
let active = true;
|
|
68391
|
+
return () => {
|
|
68392
|
+
if (!active)
|
|
68393
|
+
return;
|
|
68394
|
+
active = false;
|
|
68395
|
+
externalSubscribers -= 1;
|
|
68396
|
+
unsubscribe();
|
|
68397
|
+
};
|
|
68398
|
+
};
|
|
68399
|
+
let activeOperations = 0;
|
|
68400
|
+
const tracked = async (operation) => {
|
|
68401
|
+
activeOperations += 1;
|
|
68402
|
+
try {
|
|
68403
|
+
return await operation();
|
|
68404
|
+
} finally {
|
|
68405
|
+
activeOperations -= 1;
|
|
68406
|
+
}
|
|
68407
|
+
};
|
|
68408
|
+
const sessionSaved = () => runtime.stageSnapshot.status === "completed" && runtime.state.stageFinalized && runtime.state.sessionCheckpointed && !runtime.state.liveHandleReleased && !runtime.state.stageClosedByWorkflowExit;
|
|
68409
|
+
const handle = {
|
|
68151
68410
|
runId: runtime.runId,
|
|
68152
68411
|
stageId: runtime.stageId,
|
|
68153
68412
|
stageName: runtime.name,
|
|
@@ -68318,18 +68577,41 @@ function createStageControlHandle(runtime) {
|
|
|
68318
68577
|
}
|
|
68319
68578
|
},
|
|
68320
68579
|
subscribe(listener) {
|
|
68321
|
-
return runtime.innerCtx.subscribe(listener);
|
|
68580
|
+
return countSubscription(runtime.innerCtx.subscribe(listener));
|
|
68322
68581
|
},
|
|
68323
68582
|
subscribeDeliveryActivity(listener) {
|
|
68324
|
-
return runtime.innerCtx.__subscribeDeliveryActivity(listener);
|
|
68583
|
+
return countSubscription(runtime.innerCtx.__subscribeDeliveryActivity(listener));
|
|
68325
68584
|
},
|
|
68326
68585
|
async dispose() {
|
|
68327
68586
|
unsubscribeStageEvents();
|
|
68328
68587
|
toolExecutions.clear();
|
|
68329
68588
|
queuedUserMessages.clear();
|
|
68330
68589
|
await runtime.releaseLiveHandle();
|
|
68590
|
+
},
|
|
68591
|
+
releaseGate: {
|
|
68592
|
+
async savedForReopen() {
|
|
68593
|
+
if (!sessionSaved())
|
|
68594
|
+
return;
|
|
68595
|
+
const store = runtime.innerCtx.__persistedSessionStore();
|
|
68596
|
+
const sessionId = runtime.innerCtx.__sessionMeta().sessionId ?? runtime.stageSnapshot.sessionId;
|
|
68597
|
+
if (store === undefined || sessionId === undefined)
|
|
68598
|
+
return;
|
|
68599
|
+
return await isReopenableSession(store, sessionId) ? store : undefined;
|
|
68600
|
+
},
|
|
68601
|
+
idle() {
|
|
68602
|
+
return sessionSaved() && externalSubscribers === 0 && activeOperations === 0 && stageQueuedUserMessageCount(queuedUserMessages.snapshot()) === 0 && !runtime.state.waitingForStageChatTurn && runtime.state.wakeWaitingForStageChatTurn === undefined && runtime.state.readinessController === undefined && runtime.state.resumeContinuationPending === false && runtime.innerCtx.__idleForRelease();
|
|
68603
|
+
}
|
|
68331
68604
|
}
|
|
68332
68605
|
};
|
|
68606
|
+
const { ensureAttached, sendUserMessage, prompt, steer, followUp, pause, resume } = handle;
|
|
68607
|
+
handle.ensureAttached = () => tracked(ensureAttached);
|
|
68608
|
+
handle.sendUserMessage = (text, options, beforeDelivery) => tracked(() => sendUserMessage(text, options, beforeDelivery));
|
|
68609
|
+
handle.prompt = (text) => tracked(() => prompt(text));
|
|
68610
|
+
handle.steer = (text) => tracked(() => steer(text));
|
|
68611
|
+
handle.followUp = (text) => tracked(() => followUp(text));
|
|
68612
|
+
handle.pause = () => tracked(pause);
|
|
68613
|
+
handle.resume = (message, beforeResume) => tracked(() => resume(message, beforeResume));
|
|
68614
|
+
return handle;
|
|
68333
68615
|
}
|
|
68334
68616
|
|
|
68335
68617
|
// dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts
|
|
@@ -68453,6 +68735,10 @@ function createReplayStageContext(input) {
|
|
|
68453
68735
|
return;
|
|
68454
68736
|
},
|
|
68455
68737
|
__pendingMessageCount: () => 0,
|
|
68738
|
+
__persistedSessionStore: () => {
|
|
68739
|
+
return;
|
|
68740
|
+
},
|
|
68741
|
+
__idleForRelease: () => false,
|
|
68456
68742
|
__modelFallbackMeta: () => ({
|
|
68457
68743
|
...replaySource.model !== undefined ? { model: replaySource.model } : {},
|
|
68458
68744
|
...replaySource.thinkingLevel !== undefined ? { thinkingLevel: replaySource.thinkingLevel } : {},
|
|
@@ -69107,6 +69393,9 @@ class StageMessageAdmission {
|
|
|
69107
69393
|
return this.runAdmitted(operation, admission);
|
|
69108
69394
|
return admission.then((release) => this.runAdmitted(operation, release));
|
|
69109
69395
|
}
|
|
69396
|
+
isBusy() {
|
|
69397
|
+
return this.tail !== undefined || this.starting !== undefined || this.owned !== undefined || this.startedGenerations.length > 0;
|
|
69398
|
+
}
|
|
69110
69399
|
isOwned(session) {
|
|
69111
69400
|
return this.session === session && this.owned?.state === "owned";
|
|
69112
69401
|
}
|
|
@@ -69766,6 +70055,10 @@ function asAgentSession(activeSession) {
|
|
|
69766
70055
|
}
|
|
69767
70056
|
return;
|
|
69768
70057
|
}
|
|
70058
|
+
function isStageSessionQuiescent(session) {
|
|
70059
|
+
const sdk = session;
|
|
70060
|
+
return !session.isStreaming && (session.pendingMessageCount ?? 0) === 0 && session.queuedMessagesPaused !== true && sdk.isCompacting !== true && sdk.isRetrying !== true && sdk.isBashRunning !== true && sdk.hasPendingBashMessages !== true;
|
|
70061
|
+
}
|
|
69769
70062
|
function normalizeSessionCreateResult(created) {
|
|
69770
70063
|
if ("session" in created)
|
|
69771
70064
|
return created;
|
|
@@ -70250,6 +70543,7 @@ class StageSessionController {
|
|
|
70250
70543
|
messageAdmission = new StageMessageAdmission;
|
|
70251
70544
|
deliveryActivity = new StageDeliveryActivity;
|
|
70252
70545
|
artifactCapture = new StageArtifactCapture;
|
|
70546
|
+
callerSessionManager;
|
|
70253
70547
|
beginOutputGeneration() {
|
|
70254
70548
|
this.artifactCapture.reset();
|
|
70255
70549
|
}
|
|
@@ -70705,6 +70999,25 @@ class StageSessionController {
|
|
|
70705
70999
|
pendingMessageCount() {
|
|
70706
71000
|
return typeof this.session?.pendingMessageCount === "number" ? this.session.pendingMessageCount : 0;
|
|
70707
71001
|
}
|
|
71002
|
+
persistedSessionStore() {
|
|
71003
|
+
return this.session === undefined ? undefined : this.callerSessionManager?.getSessionStore();
|
|
71004
|
+
}
|
|
71005
|
+
isIdleForRelease() {
|
|
71006
|
+
const session = this.session;
|
|
71007
|
+
if (session === undefined || this.disposed || this.pendingDisposal || this.disposalPromise !== undefined)
|
|
71008
|
+
return false;
|
|
71009
|
+
if (this.activeCreation !== undefined || this.ownedCreationPromise !== undefined)
|
|
71010
|
+
return false;
|
|
71011
|
+
if (this.sessionShutdownPromise !== undefined || this.replacement.retiringSession !== undefined)
|
|
71012
|
+
return false;
|
|
71013
|
+
if (this.pauseControl.isPaused())
|
|
71014
|
+
return false;
|
|
71015
|
+
if (this.thrownErrorRetryStates.size > 0)
|
|
71016
|
+
return false;
|
|
71017
|
+
if (this.messageAdmission.isBusy())
|
|
71018
|
+
return false;
|
|
71019
|
+
return isStageSessionQuiescent(session);
|
|
71020
|
+
}
|
|
70708
71021
|
bindAbortSignal() {
|
|
70709
71022
|
const { signal } = this.opts;
|
|
70710
71023
|
if (!signal)
|
|
@@ -71259,7 +71572,10 @@ class StageSessionController {
|
|
|
71259
71572
|
this.modelRoute?.assertCurrent();
|
|
71260
71573
|
if (this.modelRoute && candidate && (typeof candidate.value === "string" || !this.modelRoute.allowsModel(candidate.value, candidate.reasoningLevel)))
|
|
71261
71574
|
throw new Error("Workflow stage execution candidate is no longer eligible.");
|
|
71262
|
-
|
|
71575
|
+
const adapter = this.opts.adapters.agentSession ?? missingAdapter(consumer);
|
|
71576
|
+
const createOptions = await stripWorkflowOnlyOptions(stageOptions, this.opts.defaultSessionDir, this.meta, this.opts.pendingStageDelivery);
|
|
71577
|
+
this.callerSessionManager = createOptions.sessionManager;
|
|
71578
|
+
created = await adapter.create(createOptions, {
|
|
71263
71579
|
...this.meta,
|
|
71264
71580
|
startupSignal: this.startupWait.signal,
|
|
71265
71581
|
isFallbackAttempt: candidate !== undefined && candidate !== (await this.modelCandidates())[0],
|
|
@@ -71269,7 +71585,7 @@ class StageSessionController {
|
|
|
71269
71585
|
},
|
|
71270
71586
|
stageOptions,
|
|
71271
71587
|
...this.sharedOrchestrationContext !== undefined ? { orchestrationContext: this.sharedOrchestrationContext } : {}
|
|
71272
|
-
})
|
|
71588
|
+
});
|
|
71273
71589
|
} catch (error) {
|
|
71274
71590
|
if (error instanceof StageSessionBindingCleanupFailure) {
|
|
71275
71591
|
this.bindingCleanupFailure = error;
|
|
@@ -72079,6 +72395,12 @@ ${nextPrompt}`;
|
|
|
72079
72395
|
__pendingMessageCount() {
|
|
72080
72396
|
return controller.pendingMessageCount();
|
|
72081
72397
|
},
|
|
72398
|
+
__persistedSessionStore() {
|
|
72399
|
+
return controller.persistedSessionStore();
|
|
72400
|
+
},
|
|
72401
|
+
__idleForRelease() {
|
|
72402
|
+
return controller.isIdleForRelease();
|
|
72403
|
+
},
|
|
72082
72404
|
__modelFallbackMeta() {
|
|
72083
72405
|
return controller.currentModelFallbackMeta();
|
|
72084
72406
|
},
|
|
@@ -72250,6 +72572,7 @@ function createWorkflowStageFactory(input) {
|
|
|
72250
72572
|
liveHandleReleased: false,
|
|
72251
72573
|
stageClosedByWorkflowExit: false,
|
|
72252
72574
|
stageFinalized: false,
|
|
72575
|
+
sessionCheckpointed: false,
|
|
72253
72576
|
skippedForParallelFailFast: false,
|
|
72254
72577
|
stageControlDropped: false
|
|
72255
72578
|
};
|
|
@@ -72647,6 +72970,26 @@ class EngineRuntime {
|
|
|
72647
72970
|
}
|
|
72648
72971
|
}
|
|
72649
72972
|
|
|
72973
|
+
// dist/builtin/workflows/src/engine/session-closed-error.ts
|
|
72974
|
+
import { isStaleExtensionContextError as isStaleExtensionContextError5 } from "@bastani/atomic";
|
|
72975
|
+
var MAX_CAUSE_DEPTH = 8;
|
|
72976
|
+
function reportsClosedSession(error) {
|
|
72977
|
+
return "code" in error && error.code === "SessionClosed" || isStaleExtensionContextError5(error);
|
|
72978
|
+
}
|
|
72979
|
+
function isSessionClosedError(error) {
|
|
72980
|
+
let current = error;
|
|
72981
|
+
for (let depth = 0;depth < MAX_CAUSE_DEPTH && current !== undefined; depth++) {
|
|
72982
|
+
try {
|
|
72983
|
+
if (reportsClosedSession(current))
|
|
72984
|
+
return true;
|
|
72985
|
+
current = current.cause instanceof Error ? current.cause : undefined;
|
|
72986
|
+
} catch {
|
|
72987
|
+
return false;
|
|
72988
|
+
}
|
|
72989
|
+
}
|
|
72990
|
+
return false;
|
|
72991
|
+
}
|
|
72992
|
+
|
|
72650
72993
|
// dist/builtin/workflows/src/engine/workflow-activity.ts
|
|
72651
72994
|
import { runCallback as runCallback4 } from "@bastani/atomic";
|
|
72652
72995
|
function nextEventLoopTurn() {
|
|
@@ -73073,6 +73416,27 @@ async function executeRun(def, resolvedInputs, opts) {
|
|
|
73073
73416
|
toolNodes: [...runSnapshot.toolNodes]
|
|
73074
73417
|
};
|
|
73075
73418
|
};
|
|
73419
|
+
const suspendForClosedSession = async (reason) => {
|
|
73420
|
+
abandonInFlightAsCancelled(reason);
|
|
73421
|
+
const durable = durableBackend.getWorkflow(runId);
|
|
73422
|
+
let resumable;
|
|
73423
|
+
if (durable?.status === "running") {
|
|
73424
|
+
resumable = isDurableWorkflowResumable({ ...durable, status: "paused", resumable: true });
|
|
73425
|
+
await transitionDurableWorkflowStatus(durableBackend, runId, ["running"], "paused", undefined, resumable);
|
|
73426
|
+
await recordRunTimingCheckpointAsync(durableBackend, runSnapshot);
|
|
73427
|
+
}
|
|
73428
|
+
activeStore.recordRunPaused(runId, undefined, {
|
|
73429
|
+
exitReason: WORKFLOW_GRACEFUL_QUIT_EXIT_REASON,
|
|
73430
|
+
...resumable === undefined ? {} : { resumable }
|
|
73431
|
+
});
|
|
73432
|
+
return {
|
|
73433
|
+
runId,
|
|
73434
|
+
status: "paused",
|
|
73435
|
+
exitReason: WORKFLOW_GRACEFUL_QUIT_EXIT_REASON,
|
|
73436
|
+
stages: [...runSnapshot.stages],
|
|
73437
|
+
toolNodes: [...runSnapshot.toolNodes]
|
|
73438
|
+
};
|
|
73439
|
+
};
|
|
73076
73440
|
const resolvePromptNodeTopology = createDurableStageTopologyResolver(durableBackend, runId);
|
|
73077
73441
|
const priorPromptStageCheckpoints = durableBackend.listCheckpoints(runId).filter((checkpoint) => checkpoint.kind === "stage");
|
|
73078
73442
|
let promptNodeUi;
|
|
@@ -73435,8 +73799,10 @@ async function executeRun(def, resolvedInputs, opts) {
|
|
|
73435
73799
|
if (returned.status === "completed")
|
|
73436
73800
|
assertFrontierConsumed();
|
|
73437
73801
|
const recorded = activeStore.recordRunEnd(runId, returned.status, result, returned.error, returned.metadata);
|
|
73438
|
-
if (opts.parentRun === undefined)
|
|
73802
|
+
if (opts.parentRun === undefined) {
|
|
73439
73803
|
await recordRunTimingCheckpointAsync(durableBackend, runSnapshot);
|
|
73804
|
+
await recordRunResultCheckpointAsync(durableBackend, runSnapshot);
|
|
73805
|
+
}
|
|
73440
73806
|
await durableBackend.commitWorkflowStatus(runId, returned.status, undefined, returned.metadata?.resumable);
|
|
73441
73807
|
await appendRunEndWhenRecorded(opts.persistence, recorded, {
|
|
73442
73808
|
runId,
|
|
@@ -73464,8 +73830,14 @@ async function executeRun(def, resolvedInputs, opts) {
|
|
|
73464
73830
|
err = selectedTerminalEvent.error;
|
|
73465
73831
|
}
|
|
73466
73832
|
const gracefulQuit = observedQuitCancellation() ?? observedTaskTailQuit ?? findWorkflowGracefulQuit(err) ?? findWorkflowGracefulQuit(ownController.signal.reason);
|
|
73467
|
-
|
|
73833
|
+
const ownerClosing = opts.adapters?.ownerSessionClosing?.() === true;
|
|
73834
|
+
if (gracefulQuit !== undefined) {
|
|
73835
|
+
if (ownerClosing && gracefulQuit.runId !== runId)
|
|
73836
|
+
return await suspendForClosedSession(gracefulQuit);
|
|
73468
73837
|
return suspendForGracefulQuit(gracefulQuit);
|
|
73838
|
+
}
|
|
73839
|
+
if (ownerClosing && err instanceof Error && isSessionClosedError(err))
|
|
73840
|
+
return await suspendForClosedSession(err);
|
|
73469
73841
|
await admittedTools.closeAndDrain();
|
|
73470
73842
|
if (ownController.signal.aborted)
|
|
73471
73843
|
await Promise.allSettled([...pendingChildWorkflows]);
|
|
@@ -73569,6 +73941,8 @@ async function executeRun(def, resolvedInputs, opts) {
|
|
|
73569
73941
|
terminalEvents.dispose();
|
|
73570
73942
|
if (opts.stageControlRegistry === undefined && opts.executionMode !== "interactive" && isTerminalRunStatus(runSnapshot.status) && runSnapshot.resumable !== true) {
|
|
73571
73943
|
await stageRegistry.clear(runId);
|
|
73944
|
+
} else if (isTerminalRunStatus(runSnapshot.status)) {
|
|
73945
|
+
await stageRegistry.releaseIdle(runId);
|
|
73572
73946
|
}
|
|
73573
73947
|
}
|
|
73574
73948
|
}
|
|
@@ -74322,7 +74696,7 @@ async function prepareRuntimeDurableResumable(getBackend, workflowId) {
|
|
|
74322
74696
|
|
|
74323
74697
|
// dist/builtin/workflows/src/durable/completed-catalog.ts
|
|
74324
74698
|
function isReservedRunCheckpointHash(argsHash) {
|
|
74325
|
-
return [RUN_TIMING_CHECKPOINT_NAME, RUN_USAGE_CHECKPOINT_NAME].includes(argsHash) || argsHash === WORKFLOW_HEARTBEAT_ANCHOR_CHECKPOINT_NAME;
|
|
74699
|
+
return [RUN_TIMING_CHECKPOINT_NAME, RUN_USAGE_CHECKPOINT_NAME, RUN_RESULT_CHECKPOINT_NAME].includes(argsHash) || argsHash === WORKFLOW_HEARTBEAT_ANCHOR_CHECKPOINT_NAME;
|
|
74326
74700
|
}
|
|
74327
74701
|
function listCompletedFromBackend(backend) {
|
|
74328
74702
|
return backend.listCompletedWorkflows();
|
|
@@ -74386,6 +74760,7 @@ async function completedWorkflowRunSnapshots(backend, entry, sessionStore) {
|
|
|
74386
74760
|
...handle.failureRecoverability !== undefined ? { failureRecoverability: handle.failureRecoverability } : {},
|
|
74387
74761
|
...handle.failureDisposition !== undefined ? { failureDisposition: handle.failureDisposition } : {},
|
|
74388
74762
|
...handle.failedToolNodeId !== undefined ? { failedToolNodeId: handle.failedToolNodeId } : {},
|
|
74763
|
+
...runResultFields(backend, handle),
|
|
74389
74764
|
resumable: handle.resumable ?? false
|
|
74390
74765
|
};
|
|
74391
74766
|
return [root, ...runs.filter((_, index) => index !== rootIndex)];
|
|
@@ -74428,9 +74803,16 @@ function rootSnapshot(backend, handle, graph) {
|
|
|
74428
74803
|
...handle.failureRecoverability !== undefined ? { failureRecoverability: handle.failureRecoverability } : {},
|
|
74429
74804
|
...handle.failureDisposition !== undefined ? { failureDisposition: handle.failureDisposition } : {},
|
|
74430
74805
|
...handle.failedToolNodeId !== undefined ? { failedToolNodeId: handle.failedToolNodeId } : {},
|
|
74806
|
+
...runResultFields(backend, handle),
|
|
74431
74807
|
resumable: isDurableWorkflowResumable(handle)
|
|
74432
74808
|
};
|
|
74433
74809
|
}
|
|
74810
|
+
function runResultFields(backend, handle) {
|
|
74811
|
+
if (handle.status === "running" || handle.status === "paused")
|
|
74812
|
+
return {};
|
|
74813
|
+
const result = durableRunResult(backend, handle.workflowId);
|
|
74814
|
+
return result === undefined ? {} : { result };
|
|
74815
|
+
}
|
|
74434
74816
|
function durableNestedRunSnapshots(backend, rootWorkflowId) {
|
|
74435
74817
|
const handle = backend.getWorkflow(rootWorkflowId);
|
|
74436
74818
|
if (handle === undefined)
|
|
@@ -74879,6 +75261,7 @@ function createPostMortemStageHandle(runId, stage, sessionId, adapters, cwd, def
|
|
|
74879
75261
|
|
|
74880
75262
|
// dist/builtin/workflows/src/durable/completed-inspection.ts
|
|
74881
75263
|
var completedChatRegistrations = new WeakMap;
|
|
75264
|
+
var completedChatUnregisters = new WeakMap;
|
|
74882
75265
|
async function openCompletedDurableWorkflow(workflowId, deps, catalog) {
|
|
74883
75266
|
const selectedStore = await stageSessionStore({ sessionStore: deps.sessionStore ?? deps.adapters?.sessionStore, cwd: deps.cwd }, deps.defaultSessionDir);
|
|
74884
75267
|
const resolved = await resolveCompletedWorkflow(workflowId, deps.durableBackend, catalog, selectedStore);
|
|
@@ -74924,37 +75307,40 @@ function registerCompletedChatHandles(snapshot, deps, sessionStore) {
|
|
|
74924
75307
|
const registrations = completedChatRegistrations.get(registry) ?? new Map;
|
|
74925
75308
|
completedChatRegistrations.set(registry, registrations);
|
|
74926
75309
|
const desiredKeys = new Set(snapshot.stages.filter((stage) => stage.sessionId !== undefined).map((stage) => completedChatKey(snapshot.id, stage.id)));
|
|
74927
|
-
for (const
|
|
75310
|
+
for (const key of [...registrations.keys()]) {
|
|
74928
75311
|
if (!key.startsWith(`${snapshot.id}:`) || desiredKeys.has(key))
|
|
74929
75312
|
continue;
|
|
74930
|
-
removeCompletedChatRegistration(registrations, key
|
|
75313
|
+
removeCompletedChatRegistration(registrations, key);
|
|
74931
75314
|
}
|
|
74932
75315
|
for (const stage of snapshot.stages) {
|
|
74933
75316
|
if (stage.sessionId === undefined)
|
|
74934
75317
|
continue;
|
|
74935
75318
|
const key = completedChatKey(snapshot.id, stage.id);
|
|
74936
|
-
const registration = registrations.get(key);
|
|
75319
|
+
const registration = registrations.get(key)?.deref();
|
|
74937
75320
|
const existing = registry.claim(snapshot.id, stage.id);
|
|
74938
75321
|
if (existing?.sessionId === stage.sessionId && existing.sessionStore === sessionStore && !existing.isDisposed)
|
|
74939
75322
|
continue;
|
|
74940
75323
|
if (registration !== undefined) {
|
|
74941
|
-
removeCompletedChatRegistration(registrations, key
|
|
75324
|
+
removeCompletedChatRegistration(registrations, key);
|
|
74942
75325
|
} else if (existing !== undefined) {
|
|
74943
75326
|
disposeCompletedChatHandle(existing);
|
|
74944
75327
|
}
|
|
74945
75328
|
const handle = createPostMortemStageHandle(snapshot.id, stage, stage.sessionId, deps.adapters, deps.cwd, deps.defaultSessionDir, sessionStore);
|
|
74946
|
-
|
|
74947
|
-
registrations.set(key,
|
|
75329
|
+
completedChatUnregisters.set(handle, registry.register(handle));
|
|
75330
|
+
registrations.set(key, new WeakRef(handle));
|
|
74948
75331
|
registry.detachControl(snapshot.id, stage.id, handle);
|
|
74949
75332
|
}
|
|
74950
75333
|
}
|
|
74951
75334
|
function completedChatKey(runId, stageId) {
|
|
74952
75335
|
return `${runId}:${stageId}`;
|
|
74953
75336
|
}
|
|
74954
|
-
function removeCompletedChatRegistration(registrations, key
|
|
74955
|
-
|
|
75337
|
+
function removeCompletedChatRegistration(registrations, key) {
|
|
75338
|
+
const handle = registrations.get(key)?.deref();
|
|
74956
75339
|
registrations.delete(key);
|
|
74957
|
-
|
|
75340
|
+
if (handle === undefined)
|
|
75341
|
+
return;
|
|
75342
|
+
completedChatUnregisters.get(handle)?.();
|
|
75343
|
+
disposeCompletedChatHandle(handle);
|
|
74958
75344
|
}
|
|
74959
75345
|
function disposeCompletedChatHandle(handle) {
|
|
74960
75346
|
Promise.resolve(handle.dispose?.()).catch((error) => {
|
|
@@ -75818,6 +76204,7 @@ function registerWorkflowLifecycleHandlers(pi, deps) {
|
|
|
75818
76204
|
closeGeneration,
|
|
75819
76205
|
...lifetime.generations,
|
|
75820
76206
|
() => releasePausedRunsOfSession(sessionCaller, store),
|
|
76207
|
+
() => releaseDurableBackendsHeldBy(store),
|
|
75821
76208
|
() => {
|
|
75822
76209
|
lifetime.generations.clear();
|
|
75823
76210
|
}
|
|
@@ -75838,29 +76225,9 @@ import { registerExtensionContextRetirementEffect as registerExtensionContextRet
|
|
|
75838
76225
|
import { join as join30 } from "node:path";
|
|
75839
76226
|
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME3, getAgentDir as getAgentDir6 } from "@bastani/atomic";
|
|
75840
76227
|
|
|
75841
|
-
// dist/builtin/workflows/builtin/index.ts
|
|
75842
|
-
var exports_builtin = {};
|
|
75843
|
-
__export(exports_builtin, {
|
|
75844
|
-
adversarialVerification: () => adversarial_verification_default,
|
|
75845
|
-
classifyAndAct: () => classify_and_act_default,
|
|
75846
|
-
fanOutAndSynthesize: () => fan_out_and_synthesize_default,
|
|
75847
|
-
generateAndFilter: () => generate_and_filter_default,
|
|
75848
|
-
goal: () => goal_default,
|
|
75849
|
-
loopUntilDone: () => loop_until_done_default,
|
|
75850
|
-
openClaudeDesign: () => open_claude_design_default,
|
|
75851
|
-
ralph: () => ralph_default,
|
|
75852
|
-
tournament: () => tournament_default
|
|
75853
|
-
});
|
|
75854
|
-
|
|
75855
76228
|
// dist/builtin/workflows/builtin/adversarial-verification.ts
|
|
75856
76229
|
import { Type as Type5 } from "typebox";
|
|
75857
76230
|
|
|
75858
|
-
// dist/builtin/workflows/builtin/steering-context.ts
|
|
75859
|
-
var exports_steering_context = {};
|
|
75860
|
-
__export(exports_steering_context, {
|
|
75861
|
-
withSteeringPropagationContext: () => withSteeringPropagationContext
|
|
75862
|
-
});
|
|
75863
|
-
|
|
75864
76231
|
// dist/builtin/workflows/src/authoring/keep-context.ts
|
|
75865
76232
|
var KEEP_CONTEXT_OPEN_TAG = "<keepContext>";
|
|
75866
76233
|
var KEEP_CONTEXT_CLOSE_TAG = "</keepContext>";
|
|
@@ -81838,53 +82205,6 @@ function createJiti(id, opts = {}) {
|
|
|
81838
82205
|
import * as typeboxModule from "typebox";
|
|
81839
82206
|
import * as typeboxCompileModule from "typebox/compile";
|
|
81840
82207
|
import * as typeboxValueModule from "typebox/value";
|
|
81841
|
-
|
|
81842
|
-
// dist/builtin/workflows/src/sdk-surface.ts
|
|
81843
|
-
var exports_sdk_surface = {};
|
|
81844
|
-
__export(exports_sdk_surface, {
|
|
81845
|
-
DEFAULT_WORKFLOW_HEARTBEAT_INTERVAL_MINUTES: () => DEFAULT_WORKFLOW_HEARTBEAT_INTERVAL_MINUTES,
|
|
81846
|
-
GraphFrontierTracker: () => GraphFrontierTracker,
|
|
81847
|
-
INTERACTIVE_WORKFLOW_POLICY: () => INTERACTIVE_WORKFLOW_POLICY,
|
|
81848
|
-
JOURNAL_COLUMNS: () => JOURNAL_COLUMNS,
|
|
81849
|
-
JOURNAL_LEASE: () => JOURNAL_LEASE,
|
|
81850
|
-
JOURNAL_PAYLOAD_ENCODING: () => JOURNAL_PAYLOAD_ENCODING,
|
|
81851
|
-
JOURNAL_SCHEMA_VERSION: () => JOURNAL_SCHEMA_VERSION,
|
|
81852
|
-
JOURNAL_TABLES: () => JOURNAL_TABLES,
|
|
81853
|
-
JournalCasConflictError: () => JournalCasConflictError,
|
|
81854
|
-
JournalClosedError: () => JournalClosedError,
|
|
81855
|
-
JournalCounterRangeError: () => JournalCounterRangeError,
|
|
81856
|
-
JournalError: () => JournalError,
|
|
81857
|
-
JournalInvalidTextError: () => JournalInvalidTextError,
|
|
81858
|
-
JournalMetaCorruptError: () => JournalMetaCorruptError,
|
|
81859
|
-
JournalSchemaVersionError: () => JournalSchemaVersionError,
|
|
81860
|
-
KEEP_CONTEXT_CLOSE_TAG: () => KEEP_CONTEXT_CLOSE_TAG,
|
|
81861
|
-
KEEP_CONTEXT_OPEN_TAG: () => KEEP_CONTEXT_OPEN_TAG,
|
|
81862
|
-
MemoryRunJournal: () => MemoryRunJournal,
|
|
81863
|
-
NON_INTERACTIVE_WORKFLOW_POLICY: () => NON_INTERACTIVE_WORKFLOW_POLICY,
|
|
81864
|
-
RUN_EVENT_TYPES: () => RUN_EVENT_TYPES,
|
|
81865
|
-
RunNotFoundError: () => RunNotFoundError,
|
|
81866
|
-
SqlRunJournal: () => SqlRunJournal,
|
|
81867
|
-
StaleLeaseError: () => StaleLeaseError,
|
|
81868
|
-
StorageUnavailableError: () => StorageUnavailableError,
|
|
81869
|
-
WORKFLOW_HEARTBEAT_CUSTOM_TYPE: () => WORKFLOW_HEARTBEAT_CUSTOM_TYPE,
|
|
81870
|
-
cancellationRegistry: () => cancellationRegistry,
|
|
81871
|
-
createAgentSessionAdapter: () => createAgentSessionAdapter,
|
|
81872
|
-
createCancellationRegistry: () => createCancellationRegistry,
|
|
81873
|
-
createRegistry: () => createRegistry,
|
|
81874
|
-
createStore: () => createStore,
|
|
81875
|
-
keepContext: () => keepContext,
|
|
81876
|
-
normalizeWorkflowName: () => normalizeWorkflowName,
|
|
81877
|
-
openSqlRunJournal: () => openSqlRunJournal,
|
|
81878
|
-
registerRunJournalConformance: () => registerRunJournalConformance,
|
|
81879
|
-
resolveInputs: () => resolveInputs,
|
|
81880
|
-
resolveRunJournal: () => resolveRunJournal,
|
|
81881
|
-
run: () => run2,
|
|
81882
|
-
setupGitWorktree: () => setupGitWorktree,
|
|
81883
|
-
store: () => store,
|
|
81884
|
-
workflow: () => workflow,
|
|
81885
|
-
workflowNamesEqual: () => workflowNamesEqual
|
|
81886
|
-
});
|
|
81887
|
-
|
|
81888
82208
|
// dist/builtin/workflows/src/durable/journal/conformance.ts
|
|
81889
82209
|
import assert from "node:assert/strict";
|
|
81890
82210
|
function registerRunJournalConformance(runner, name, open, observeRead) {
|
|
@@ -82404,7 +82724,7 @@ async function openSqlRunJournal(source = workflowJournalPath(), options = {}) {
|
|
|
82404
82724
|
// dist/builtin/workflows/src/extension/wiring.ts
|
|
82405
82725
|
import { join as join28 } from "node:path";
|
|
82406
82726
|
import {
|
|
82407
|
-
isStaleExtensionContextError as
|
|
82727
|
+
isStaleExtensionContextError as isStaleExtensionContextError6,
|
|
82408
82728
|
ModelRuntime,
|
|
82409
82729
|
resolveRestoredModelReference
|
|
82410
82730
|
} from "@bastani/atomic";
|
|
@@ -82750,7 +83070,7 @@ function emitLateIntercomRoute(pi, meta, messages, options, batch) {
|
|
|
82750
83070
|
try {
|
|
82751
83071
|
pi.events.emit(LATE_STAGE_MESSAGE_EVENT2, event);
|
|
82752
83072
|
} catch (error) {
|
|
82753
|
-
if (!
|
|
83073
|
+
if (!isStaleExtensionContextError6(error))
|
|
82754
83074
|
throw error;
|
|
82755
83075
|
return Promise.reject(error);
|
|
82756
83076
|
}
|
|
@@ -82762,7 +83082,7 @@ function routeThroughStaleContextGuard(route) {
|
|
|
82762
83082
|
try {
|
|
82763
83083
|
return route();
|
|
82764
83084
|
} catch (error) {
|
|
82765
|
-
if (!
|
|
83085
|
+
if (!isStaleExtensionContextError6(error))
|
|
82766
83086
|
throw error;
|
|
82767
83087
|
return Promise.reject(error);
|
|
82768
83088
|
}
|
|
@@ -82980,6 +83300,7 @@ function buildRuntimeAdapters(builtWith, options = {}) {
|
|
|
82980
83300
|
}, options.sdk));
|
|
82981
83301
|
const broker = options.stageUiBroker ?? currentStageUiBroker();
|
|
82982
83302
|
const adapters = {
|
|
83303
|
+
...options.ownerSessionClosing === undefined ? {} : { ownerSessionClosing: options.ownerSessionClosing },
|
|
82983
83304
|
agentSession: {
|
|
82984
83305
|
async create(stageOptions, meta) {
|
|
82985
83306
|
const pi = resolveSurface();
|
|
@@ -84047,8 +84368,10 @@ function createExtensionRuntime(opts = {}) {
|
|
|
84047
84368
|
let ready;
|
|
84048
84369
|
const ensureReady = () => ready ??= (presetBackend === undefined ? initializeDurableBackend({
|
|
84049
84370
|
cwd: runtimeCwd,
|
|
84050
|
-
journal: opts.journal,
|
|
84051
|
-
|
|
84371
|
+
journal: opts.journal ?? opts.resolveJournal?.(),
|
|
84372
|
+
settings: opts.resolveJournalSettings?.(),
|
|
84373
|
+
projectTrusted: opts.isProjectTrusted?.(),
|
|
84374
|
+
holder: activeStore
|
|
84052
84375
|
}) : Promise.resolve(presetBackend)).then((backend) => {
|
|
84053
84376
|
backendRef.current = backend;
|
|
84054
84377
|
bindStoreDurableBackend(activeStore, backend);
|
|
@@ -85057,10 +85380,10 @@ function workflowModelCatalogFromContext(ctx, resolveLiveContext) {
|
|
|
85057
85380
|
}
|
|
85058
85381
|
|
|
85059
85382
|
// dist/builtin/workflows/src/extension/workflow-ports.ts
|
|
85060
|
-
import { isStaleExtensionContextError as
|
|
85383
|
+
import { isStaleExtensionContextError as isStaleExtensionContextError8 } from "@bastani/atomic";
|
|
85061
85384
|
|
|
85062
85385
|
// dist/builtin/workflows/src/extension/mcp.ts
|
|
85063
|
-
import { isStaleExtensionContextError as
|
|
85386
|
+
import { isStaleExtensionContextError as isStaleExtensionContextError7 } from "@bastani/atomic";
|
|
85064
85387
|
function setMcpScope(pi, opts) {
|
|
85065
85388
|
if (!pi.events)
|
|
85066
85389
|
return;
|
|
@@ -85072,7 +85395,7 @@ function setMcpScope(pi, opts) {
|
|
|
85072
85395
|
try {
|
|
85073
85396
|
pi.events.emit("mcp.scope.set", payload);
|
|
85074
85397
|
} catch (error) {
|
|
85075
|
-
if (!
|
|
85398
|
+
if (!isStaleExtensionContextError7(error))
|
|
85076
85399
|
throw error;
|
|
85077
85400
|
}
|
|
85078
85401
|
}
|
|
@@ -85087,7 +85410,7 @@ function clearMcpScope(pi, stageId) {
|
|
|
85087
85410
|
try {
|
|
85088
85411
|
pi.events.emit("mcp.scope.set", payload);
|
|
85089
85412
|
} catch (error) {
|
|
85090
|
-
if (!
|
|
85413
|
+
if (!isStaleExtensionContextError7(error))
|
|
85091
85414
|
throw error;
|
|
85092
85415
|
}
|
|
85093
85416
|
}
|
|
@@ -85097,7 +85420,7 @@ async function unlessStale(append) {
|
|
|
85097
85420
|
try {
|
|
85098
85421
|
return await append();
|
|
85099
85422
|
} catch (error) {
|
|
85100
|
-
if (
|
|
85423
|
+
if (isStaleExtensionContextError8(error))
|
|
85101
85424
|
return;
|
|
85102
85425
|
throw error;
|
|
85103
85426
|
}
|
|
@@ -85248,7 +85571,9 @@ function createWorkflowExtensionRuntimeState(pi, adapters, options = {}) {
|
|
|
85248
85571
|
stageControlRegistry,
|
|
85249
85572
|
toolControlRegistry,
|
|
85250
85573
|
stageUiBroker,
|
|
85251
|
-
isProjectTrusted: () => projectTrusted ?? pi.getResourceLoaderInheritanceSnapshot?.()?.projectTrusted ?? true
|
|
85574
|
+
isProjectTrusted: () => projectTrusted ?? pi.getResourceLoaderInheritanceSnapshot?.()?.projectTrusted ?? true,
|
|
85575
|
+
resolveJournal: () => pi.getWorkflowJournal?.(),
|
|
85576
|
+
resolveJournalSettings: () => pi.getSettings?.()
|
|
85252
85577
|
};
|
|
85253
85578
|
let contextCwd;
|
|
85254
85579
|
const resolveCwd = () => resolveHostCwd?.() ?? contextCwd ?? pi.sessionManager?.getCwd?.() ?? process.cwd();
|
|
@@ -85874,7 +86199,7 @@ function registerPendingStageIntercomBridge(pi, activeStore) {
|
|
|
85874
86199
|
if (!ownedRunIds.has(runId))
|
|
85875
86200
|
routeCompletions.delete(runId);
|
|
85876
86201
|
}
|
|
85877
|
-
sweepPromise = sweepPromise.then(() => settleUndeliverablePendingStageMessages(activeStore, notifyUndeliverable)).then(() => {
|
|
86202
|
+
sweepPromise = sweepPromise.then(() => outsideWorkflowExecutions(() => settleUndeliverablePendingStageMessages(activeStore, notifyUndeliverable))).then(() => {
|
|
85878
86203
|
return;
|
|
85879
86204
|
}).catch((error) => reportWarning(`atomic-workflows: pending stage delivery sweep failed: ${error.message}`));
|
|
85880
86205
|
};
|
|
@@ -86443,6 +86768,48 @@ function createPostMortemHandleResolver(deps) {
|
|
|
86443
86768
|
};
|
|
86444
86769
|
}
|
|
86445
86770
|
|
|
86771
|
+
// dist/builtin/workflows/src/extension/released-stage-intercom-route.ts
|
|
86772
|
+
var RELEASED_STAGE_EVENT = "atomic:workflow-released-stage";
|
|
86773
|
+
function announcementFor(store, released, answer) {
|
|
86774
|
+
const runs = store.runs();
|
|
86775
|
+
const run = runs.find((candidate) => candidate.id === released.runId);
|
|
86776
|
+
const stage = run?.stages.find((candidate) => candidate.id === released.stageId);
|
|
86777
|
+
if (run === undefined || stage?.pendingStageDeliveryAvailable !== true)
|
|
86778
|
+
return;
|
|
86779
|
+
const rootRunId = durableRootRunIdForRun(runs, run.id);
|
|
86780
|
+
if (rootRunId === undefined)
|
|
86781
|
+
return;
|
|
86782
|
+
const stageKeys = [released.stageId, released.stageName].filter((key) => !key.includes("/") && !key.includes("*"));
|
|
86783
|
+
return {
|
|
86784
|
+
runId: released.runId,
|
|
86785
|
+
stageId: released.stageId,
|
|
86786
|
+
stageName: released.stageName,
|
|
86787
|
+
sessionId: released.sessionId,
|
|
86788
|
+
group: stage.intercomGroup ?? workflowInvocationIntercomGroup(rootRunId),
|
|
86789
|
+
...stage.model === undefined ? {} : { model: stage.model },
|
|
86790
|
+
...stageKeys.length === 0 ? {} : { liveRoute: { stageKeys, capability: workflowPendingStageRouteCapability(store, run.id) } },
|
|
86791
|
+
answer
|
|
86792
|
+
};
|
|
86793
|
+
}
|
|
86794
|
+
function registerReleasedStageIntercomRoutes(pi, registry, store, resolveHandle) {
|
|
86795
|
+
let disposed = false;
|
|
86796
|
+
const answerAsCompletedStage = createCompletedStageAnswerer(resolveHandle, () => {
|
|
86797
|
+
if (disposed)
|
|
86798
|
+
throw new Error("Intercom ask target is unavailable: its owning session has closed.");
|
|
86799
|
+
});
|
|
86800
|
+
const unsubscribe = registry.onStageReleased((released) => {
|
|
86801
|
+
if (disposed)
|
|
86802
|
+
return;
|
|
86803
|
+
const announcement = announcementFor(store, released, (content) => answerAsCompletedStage(released.runId, released.stageId, content));
|
|
86804
|
+
if (announcement !== undefined)
|
|
86805
|
+
pi.events?.emit?.(RELEASED_STAGE_EVENT, announcement);
|
|
86806
|
+
});
|
|
86807
|
+
return () => {
|
|
86808
|
+
disposed = true;
|
|
86809
|
+
unsubscribe();
|
|
86810
|
+
};
|
|
86811
|
+
}
|
|
86812
|
+
|
|
86446
86813
|
// dist/builtin/workflows/src/extension/render-component.ts
|
|
86447
86814
|
function dynamicTextRenderComponent(renderText) {
|
|
86448
86815
|
return {
|
|
@@ -88323,6 +88690,60 @@ function createSessionRunControl(host) {
|
|
|
88323
88690
|
// dist/builtin/workflows/src/extension/workflow-tool.ts
|
|
88324
88691
|
import { getSupportedThinkingLevels } from "@bastani/pi-ai/compat";
|
|
88325
88692
|
|
|
88693
|
+
// dist/builtin/workflows/src/extension/workflow-status-digest.ts
|
|
88694
|
+
function promptMessage(prompt, request) {
|
|
88695
|
+
return prompt === undefined ? request?.questions[0]?.question : prompt.message;
|
|
88696
|
+
}
|
|
88697
|
+
function blockers(detail) {
|
|
88698
|
+
if (["completed", "skipped", "cancelled", "killed"].includes(detail.status))
|
|
88699
|
+
return [];
|
|
88700
|
+
const entries = [];
|
|
88701
|
+
for (const stage of detail.stages) {
|
|
88702
|
+
const awaitingInput = stage.status === "awaiting_input" || stage.pendingPrompt !== undefined || stage.inputRequest !== undefined;
|
|
88703
|
+
if (!awaitingInput && stage.status !== "failed" && stage.status !== "blocked")
|
|
88704
|
+
continue;
|
|
88705
|
+
const message = awaitingInput ? promptMessage(stage.pendingPrompt, stage.inputRequest) : stage.error;
|
|
88706
|
+
const promptId = stage.pendingPrompt?.id ?? stage.inputRequest?.id;
|
|
88707
|
+
entries.push({
|
|
88708
|
+
kind: awaitingInput ? "awaiting_input" : stage.status === "failed" ? "failed" : "blocked",
|
|
88709
|
+
node: "stage",
|
|
88710
|
+
id: stage.id,
|
|
88711
|
+
name: stage.name,
|
|
88712
|
+
...promptId === undefined ? {} : { promptId },
|
|
88713
|
+
...message === undefined ? {} : { message }
|
|
88714
|
+
});
|
|
88715
|
+
}
|
|
88716
|
+
for (const tool of detail.tools) {
|
|
88717
|
+
if (tool.status !== "failed")
|
|
88718
|
+
continue;
|
|
88719
|
+
entries.push({
|
|
88720
|
+
kind: "failed",
|
|
88721
|
+
node: "tool",
|
|
88722
|
+
id: tool.id,
|
|
88723
|
+
name: tool.name,
|
|
88724
|
+
...tool.error === undefined ? {} : { message: tool.error }
|
|
88725
|
+
});
|
|
88726
|
+
}
|
|
88727
|
+
return entries;
|
|
88728
|
+
}
|
|
88729
|
+
function buildWorkflowRunStatusDigest(detail) {
|
|
88730
|
+
return {
|
|
88731
|
+
runId: detail.runId,
|
|
88732
|
+
name: detail.name,
|
|
88733
|
+
status: detail.status,
|
|
88734
|
+
startedAt: detail.startedAt,
|
|
88735
|
+
...detail.endedAt === undefined ? {} : { endedAt: detail.endedAt },
|
|
88736
|
+
...detail.durationMs === undefined ? {} : { durationMs: detail.durationMs },
|
|
88737
|
+
...detail.result === undefined ? {} : { result: detail.result },
|
|
88738
|
+
...detail.error === undefined ? {} : { error: detail.error },
|
|
88739
|
+
...detail.exitReason === undefined ? {} : { exitReason: detail.exitReason },
|
|
88740
|
+
...detail.resumable === undefined ? {} : { resumable: detail.resumable },
|
|
88741
|
+
...detail.resumeGuidance === undefined ? {} : { resumeGuidance: detail.resumeGuidance },
|
|
88742
|
+
...detail.ownerActiveElsewhere === true ? { ownerActiveElsewhere: true } : {},
|
|
88743
|
+
blockers: blockers(detail)
|
|
88744
|
+
};
|
|
88745
|
+
}
|
|
88746
|
+
|
|
88326
88747
|
// dist/builtin/workflows/src/extension/workflow-status-summary.ts
|
|
88327
88748
|
var workflowStatusRenderRuns = new WeakMap;
|
|
88328
88749
|
function setWorkflowStatusRenderRuns(result, runs) {
|
|
@@ -88337,7 +88758,7 @@ function stageIsActive(stage) {
|
|
|
88337
88758
|
function stageAwaitingInput(stage) {
|
|
88338
88759
|
return stage.status === "awaiting_input" || stage.awaitingInputSince !== undefined || stage.pendingPrompt !== undefined || stage.inputRequest !== undefined;
|
|
88339
88760
|
}
|
|
88340
|
-
function
|
|
88761
|
+
function promptMessage2(prompt, request) {
|
|
88341
88762
|
if (prompt !== undefined)
|
|
88342
88763
|
return prompt.message;
|
|
88343
88764
|
return request?.questions[0]?.question;
|
|
@@ -88359,7 +88780,7 @@ function awaitingInputEntries(run) {
|
|
|
88359
88780
|
stageName: stage.name,
|
|
88360
88781
|
promptId: stage.pendingPrompt?.id ?? stage.inputRequest?.id,
|
|
88361
88782
|
promptKind: stage.pendingPrompt?.kind ?? stage.inputRequest?.kind,
|
|
88362
|
-
message:
|
|
88783
|
+
message: promptMessage2(stage.pendingPrompt, stage.inputRequest)
|
|
88363
88784
|
};
|
|
88364
88785
|
entries.push(entry);
|
|
88365
88786
|
}
|
|
@@ -88871,6 +89292,7 @@ function renderWorkflowToolContent(result, args) {
|
|
|
88871
89292
|
return renderStatusToolContent(result);
|
|
88872
89293
|
case "list":
|
|
88873
89294
|
case "statusDetail":
|
|
89295
|
+
case "statusSummary":
|
|
88874
89296
|
case "inputs":
|
|
88875
89297
|
case "get":
|
|
88876
89298
|
case "run":
|
|
@@ -89928,7 +90350,13 @@ function makeExecuteWorkflowTool(runtime, reloadWorkflowResources, ensureWorkflo
|
|
|
89928
90350
|
const durable = await awaitRequest(getRuntime().inspectDurableWorkflow(target));
|
|
89929
90351
|
if (durable.kind === "found")
|
|
89930
90352
|
await authorize(durable.detail.runId);
|
|
89931
|
-
|
|
90353
|
+
if (durable.kind !== "found")
|
|
90354
|
+
return { action: "statusDetail", runId: target, error: durable.message };
|
|
90355
|
+
return args.summary === true ? {
|
|
90356
|
+
action: "statusSummary",
|
|
90357
|
+
runId: durable.detail.runId,
|
|
90358
|
+
summary: buildWorkflowRunStatusDigest(durable.detail)
|
|
90359
|
+
} : { action: "statusDetail", runId: durable.detail.runId, detail: durable.detail };
|
|
89932
90360
|
}
|
|
89933
90361
|
if (!isResolvedRunId(resolved)) {
|
|
89934
90362
|
return { action: "statusDetail", runId: target, error: `run not found: ${target}` };
|
|
@@ -89938,6 +90366,13 @@ function makeExecuteWorkflowTool(runtime, reloadWorkflowResources, ensureWorkflo
|
|
|
89938
90366
|
if (!inspected.ok) {
|
|
89939
90367
|
return { action: "statusDetail", runId: target, error: `run not found: ${target}` };
|
|
89940
90368
|
}
|
|
90369
|
+
if (args.summary === true) {
|
|
90370
|
+
return {
|
|
90371
|
+
action: "statusSummary",
|
|
90372
|
+
runId: inspected.runId,
|
|
90373
|
+
summary: buildWorkflowRunStatusDigest(inspected.detail)
|
|
90374
|
+
};
|
|
90375
|
+
}
|
|
89941
90376
|
const detailResult = {
|
|
89942
90377
|
action: "statusDetail",
|
|
89943
90378
|
runId: inspected.runId,
|
|
@@ -90102,6 +90537,18 @@ function renderNotice(title, message, opts, themed) {
|
|
|
90102
90537
|
width
|
|
90103
90538
|
});
|
|
90104
90539
|
}
|
|
90540
|
+
function statusDigestNoticeText(digest) {
|
|
90541
|
+
const lines = [`${digest.name} ${digest.runId}: ${digest.status}`];
|
|
90542
|
+
if (digest.error !== undefined)
|
|
90543
|
+
lines.push(`error: ${digest.error}`);
|
|
90544
|
+
if (digest.result !== undefined)
|
|
90545
|
+
lines.push(`result: ${JSON.stringify(digest.result)}`);
|
|
90546
|
+
for (const blocker of digest.blockers) {
|
|
90547
|
+
lines.push(`${blocker.kind}: ${blocker.name}${blocker.message === undefined ? "" : ` — ${blocker.message}`}`);
|
|
90548
|
+
}
|
|
90549
|
+
return lines.join(`
|
|
90550
|
+
`);
|
|
90551
|
+
}
|
|
90105
90552
|
var TRANSCRIPT_NOTICE_ENTRY_LIMIT = 5;
|
|
90106
90553
|
var TRANSCRIPT_NOTICE_CHAR_LIMIT = 240;
|
|
90107
90554
|
function transcriptEntriesNoticeText(entries) {
|
|
@@ -90159,6 +90606,10 @@ function renderResultBody(result, opts) {
|
|
|
90159
90606
|
resolveBoundarySegments: (runId) => workflowBoundarySegments(allRuns, runId)
|
|
90160
90607
|
});
|
|
90161
90608
|
}
|
|
90609
|
+
case "statusSummary": {
|
|
90610
|
+
const { summary } = result;
|
|
90611
|
+
return renderNotice("WORKFLOW STATUS", statusDigestNoticeText(summary), opts, themed);
|
|
90612
|
+
}
|
|
90162
90613
|
case "statusDetail": {
|
|
90163
90614
|
if ("error" in result) {
|
|
90164
90615
|
const r = result;
|
|
@@ -90294,7 +90745,7 @@ function renderResultBody(result, opts) {
|
|
|
90294
90745
|
|
|
90295
90746
|
// dist/builtin/workflows/src/extension/workflow-prompts.ts
|
|
90296
90747
|
var WORKFLOW_SELECTION_GUIDANCE = "Unless the user explicitly chooses inline execution for this task, treat workflows as the default execution path for non-trivial tasks and requests with structure and a verifiable objective. Decide yourself whether a workflow fits the request. Use one for well-defined, authorized work that benefits from durable stages, checkpoints, dependencies, recovery, review loops or deliberate approval gates. Work inline for brainstorming, discussion, unclear goals, tiny deterministic low-risk answers or edits where tracking costs more than it adds, or when the user asks to work inline, directly, quickly or without a workflow. Judge the task's shape first, then refine the call with execution history and the user's stated or recorded preferences; missing, sparse, or mostly inline workflow history is not by itself a reason to work inline. Honor an explicit user request for a named workflow. To launch, inspect candidates with list/get/inputs, then call workflow run with the registered workflow name and inputs matching its input contract. Ask only for genuinely missing information.";
|
|
90297
|
-
var WORKFLOW_TOOL_DESCRIPTION = WORKFLOW_SELECTION_GUIDANCE + " " + "Run starts the named workflow and returns its runId; invalid inputs fail without launching. User /workflow commands launch directly and authored ctx.workflow(...) remains internal composition. " + "When workflow execution fits but another shape would better achieve the task, author a custom TypeScript workflow({...}) inline with normal coding tools, reload it, and run it; after successfully creating and reloading a newly authored custom workflow, report the folder containing its generated code as 'Custom workflow created. You can inspect its code at: <workflow-folder-path>'; do this only for newly created custom workflows, never builtin or pre-existing workflows; " + "discover with list/get/inputs/models, list session runs with status (no runId; statusFilter narrows the list), inspect status/stages/stage details, " + "answer pending prompts only while the root workflow is nonterminal, pause/resume/quit runs, and reload workflow resources. " + "When steering or communication is useful, use Intercom. Before steering a stage, join its invocation group. Use the Intercom `groups` action to discover it. Workflow invocation groups are named `workflow:<rootRunId>`. Then address the stage as `workflow:<rootRunId>/<segment>[/<segment>...]`; each segment may be a stage name, run id, or glob (`*` matches one segment and `**` any depth). Use `intercom list` inside the invocation group to see live, pending, and possible future targets. Live delivery is immediate; a known stage that has not started is queued and receives the message before its first model turn. Name and pattern sends remain sticky for every future matching stage until the root run terminates. When shared scope or acceptance criteria change, broadcast one authoritative update to `workflow:<rootRunId>/**` (or a narrower path pattern) rather than enumerating stages. A syntactically valid target outside the known set queues with a `notInKnownSet` warning and settles undeliverable at terminal only if never delivered. Use `ask` only for a reply-capable live session. " + "Treat a blocked run as continuable by default unless the user requests inline/no-workflow execution: then safely hold/stop it, reconcile completed work and in-flight side effects, and continue inline without duplication. Otherwise resume resumable blocks, answer pending prompts, steer past the obstacle, or start a follow-up workflow past a terminal block; resolve material ambiguity from user intent and repository evidence without bypassing safety or authorization. " + "For action 'run' and 'resume', budget accepts per-field duration, token, cost, and warning overrides; fields resolve over the workflow declaration and config, and 0 disables a field. Pass budget only for a user-specified limit; otherwise omit it and inherit. An estimate is not a budget. " + "For primitive prompt answers, use booleans or the documented confirm labels, exact case-insensitive select labels or 1-based indexes, and text strings for input/editor; an invalid answer remains pending and returns guidance instead of choosing a default. " + "For large stage handoffs, write context to files/artifacts, pass paths via reads, and prompt downstream agents to 'Read the file at <path>...' instead of injecting large previous text. " + "Wrap critical parts of run inputs and steering messages in <keepContext>...</keepContext> so compaction preserves them verbatim in the stages that inherit them; tag role constraints, prohibitions, must-hold criteria, and identifiers, not background or bulk reference material. " + "For transcripts, prefer status/stages/stage to get sessionFile/transcriptPath, " + "quote the exact path without rewriting separators (Windows backslashes are valid), " + "then search it with rg/grep and read small ranges; transcript is path-only by default when sessionFile/transcriptPath exists, explicit tail/limit returns bounded previews, and missing transcript paths fall back to a small preview. " + "Use action 'models' to inspect models in the configured catalog; the result is a configured-auth snapshot showing what's present in the registry with configured authentication, not proof of credentials, entitlements, OAuth freshness, or live provider access. " + "When a user delegates best-stage-model selection for a custom workflow, author model:'auto'; runtime selects from the actual interpolated stage prompt and supplied context. Preserve explicit user concrete model/effort and constraints.";
|
|
90748
|
+
var WORKFLOW_TOOL_DESCRIPTION = WORKFLOW_SELECTION_GUIDANCE + " " + "Run starts the named workflow and returns its runId; invalid inputs fail without launching. User /workflow commands launch directly and authored ctx.workflow(...) remains internal composition. " + "When workflow execution fits but another shape would better achieve the task, author a custom TypeScript workflow({...}) inline with normal coding tools, reload it, and run it; after successfully creating and reloading a newly authored custom workflow, report the folder containing its generated code as 'Custom workflow created. You can inspect its code at: <workflow-folder-path>'; do this only for newly created custom workflows, never builtin or pre-existing workflows; " + "discover with list/get/inputs/models, list session runs with status (no runId; statusFilter narrows the list), inspect status/stages/stage details (status with runId includes the final result; add summary:true for just status, result and blockers), " + "answer pending prompts only while the root workflow is nonterminal, pause/resume/quit runs, and reload workflow resources. " + "When steering or communication is useful, use Intercom. Before steering a stage, join its invocation group. Use the Intercom `groups` action to discover it. Workflow invocation groups are named `workflow:<rootRunId>`. Then address the stage as `workflow:<rootRunId>/<segment>[/<segment>...]`; each segment may be a stage name, run id, or glob (`*` matches one segment and `**` any depth). Use `intercom list` inside the invocation group to see live, pending, and possible future targets. Live delivery is immediate; a known stage that has not started is queued and receives the message before its first model turn. Name and pattern sends remain sticky for every future matching stage until the root run terminates. When shared scope or acceptance criteria change, broadcast one authoritative update to `workflow:<rootRunId>/**` (or a narrower path pattern) rather than enumerating stages. A syntactically valid target outside the known set queues with a `notInKnownSet` warning and settles undeliverable at terminal only if never delivered. Use `ask` only for a reply-capable live session. " + "Treat a blocked run as continuable by default unless the user requests inline/no-workflow execution: then safely hold/stop it, reconcile completed work and in-flight side effects, and continue inline without duplication. Otherwise resume resumable blocks, answer pending prompts, steer past the obstacle, or start a follow-up workflow past a terminal block; resolve material ambiguity from user intent and repository evidence without bypassing safety or authorization. " + "For action 'run' and 'resume', budget accepts per-field duration, token, cost, and warning overrides; fields resolve over the workflow declaration and config, and 0 disables a field. Pass budget only for a user-specified limit; otherwise omit it and inherit. An estimate is not a budget. " + "For primitive prompt answers, use booleans or the documented confirm labels, exact case-insensitive select labels or 1-based indexes, and text strings for input/editor; an invalid answer remains pending and returns guidance instead of choosing a default. " + "For large stage handoffs, write context to files/artifacts, pass paths via reads, and prompt downstream agents to 'Read the file at <path>...' instead of injecting large previous text. " + "Wrap critical parts of run inputs and steering messages in <keepContext>...</keepContext> so compaction preserves them verbatim in the stages that inherit them; tag role constraints, prohibitions, must-hold criteria, and identifiers, not background or bulk reference material. " + "For transcripts, prefer status/stages/stage to get sessionFile/transcriptPath, " + "quote the exact path without rewriting separators (Windows backslashes are valid), " + "then search it with rg/grep and read small ranges; transcript is path-only by default when sessionFile/transcriptPath exists, explicit tail/limit returns bounded previews, and missing transcript paths fall back to a small preview. " + "Use action 'models' to inspect models in the configured catalog; the result is a configured-auth snapshot showing what's present in the registry with configured authentication, not proof of credentials, entitlements, OAuth freshness, or live provider access. " + "When a user delegates best-stage-model selection for a custom workflow, author model:'auto'; runtime selects from the actual interpolated stage prompt and supplied context. Preserve explicit user concrete model/effort and constraints.";
|
|
90298
90749
|
var DEFAULT_PROMPT_GUIDANCE = [
|
|
90299
90750
|
WORKFLOW_SELECTION_GUIDANCE,
|
|
90300
90751
|
`**Workflow fit**:
|
|
@@ -90401,7 +90852,7 @@ var WorkflowParametersSchema = Type25.Object({
|
|
|
90401
90852
|
Type25.Literal("resume"),
|
|
90402
90853
|
Type25.Literal("reload")
|
|
90403
90854
|
], {
|
|
90404
|
-
description: "Workflow action: run/list/get/inputs/models/status, inspect stage metadata, answer pending prompts, pause/resume/quit runs, inspect the configured model catalog, or reload workflow resources. 'status' without runId lists every workflow run in the current session with concise per-run summaries (status, timing, active stages, awaiting-input prompts); filter the listing with statusFilter. 'status' with runId returns one run's full detail. For transcript inspection, prefer status/stages/stage first to get sessionFile/transcriptPath, quote the exact path without rewriting separators (Windows backslashes are valid), then search it with rg/grep and read small ranges; transcript is path-only by default when sessionFile/transcriptPath exists, explicit tail/limit returns bounded previews, and missing transcript paths fall back to a small preview."
|
|
90855
|
+
description: "Workflow action: run/list/get/inputs/models/status, inspect stage metadata, answer pending prompts, pause/resume/quit runs, inspect the configured model catalog, or reload workflow resources. 'status' without runId lists every workflow run in the current session with concise per-run summaries (status, timing, active stages, awaiting-input prompts); filter the listing with statusFilter. 'status' with runId returns one run's full detail, including its final outputs (result); add summary:true for a compact form without the stage history. For transcript inspection, prefer status/stages/stage first to get sessionFile/transcriptPath, quote the exact path without rewriting separators (Windows backslashes are valid), then search it with rg/grep and read small ranges; transcript is path-only by default when sessionFile/transcriptPath exists, explicit tail/limit returns bounded previews, and missing transcript paths fall back to a small preview."
|
|
90405
90856
|
})),
|
|
90406
90857
|
runId: Type25.Optional(Type25.String({
|
|
90407
90858
|
description: "Full 36-character run UUID or unique 8-character hexadecimal UUID prefix for status/stages/stage/transcript/answer/pause/resume/quit. Other truncated forms are rejected; ambiguous prefixes require the full UUID. Omit runId with action 'status' to list all session runs and their statuses. Use '--all' or all:true for supported bulk run-control actions."
|
|
@@ -90430,6 +90881,9 @@ var WorkflowParametersSchema = Type25.Object({
|
|
|
90430
90881
|
], {
|
|
90431
90882
|
description: "Filter stages (stages action) or listed runs (status action without runId) by status; 'all' (default) includes everything. For the status listing, run statuses match directly, 'awaiting_input' selects runs with at least one stage awaiting input or pending human prompt, and in-flight runs are listed first."
|
|
90432
90883
|
})),
|
|
90884
|
+
summary: Type25.Optional(Type25.Boolean({
|
|
90885
|
+
description: "Status with runId only: return the run's status, final outputs (result), error and blockers (failed, blocked or awaiting-input stages and tools) without the full stage and tool history. Use it to read what a finished run produced, including a run started by another session."
|
|
90886
|
+
})),
|
|
90433
90887
|
format: Type25.Optional(Type25.Union([Type25.Literal("text"), Type25.Literal("json")], {
|
|
90434
90888
|
description: "Agent-visible output format for data-bearing inspection actions (models, status, stages, stage, transcript); 'json' returns the full structured result."
|
|
90435
90889
|
})),
|
|
@@ -90607,9 +91061,15 @@ function factory(pi) {
|
|
|
90607
91061
|
};
|
|
90608
91062
|
}
|
|
90609
91063
|
const liveGeneration = trackLiveHostGeneration(pi);
|
|
91064
|
+
let hostSessionContext;
|
|
91065
|
+
pi.on?.("session_start", (_event, ctx) => {
|
|
91066
|
+
hostSessionContext = ctx;
|
|
91067
|
+
});
|
|
91068
|
+
const ownerSessionClosing = () => (hostSessionContext?.getCurrentSessionSignal?.() ?? hostSessionContext?.sessionSignal)?.aborted === true;
|
|
90610
91069
|
const adapters = buildRuntimeAdapters(pi, {
|
|
90611
91070
|
resolveSurface: () => liveGeneration()?.pi ?? pi,
|
|
90612
|
-
stageUiBroker: runState.stageUiBroker
|
|
91071
|
+
stageUiBroker: runState.stageUiBroker,
|
|
91072
|
+
ownerSessionClosing
|
|
90613
91073
|
});
|
|
90614
91074
|
const runtimeState = createWorkflowExtensionRuntimeState(pi, adapters, {
|
|
90615
91075
|
resolveLiveModelContext: () => liveGeneration()?.modelContext,
|
|
@@ -90624,11 +91084,13 @@ function factory(pi) {
|
|
|
90624
91084
|
const postMortemHandleResolver = createPostMortemHandleResolver(postMortemResolverDeps);
|
|
90625
91085
|
const disposeCompletedRoutes = registerCompletedStageIntercomAskRouter(pi, postMortemHandleResolver);
|
|
90626
91086
|
const disposePendingRoutes = registerPendingStageIntercomBridge(pi, store);
|
|
91087
|
+
const disposeReleasedRoutes = registerReleasedStageIntercomRoutes(pi, runState.stageControlRegistry, store, postMortemHandleResolver);
|
|
90627
91088
|
pi.on?.("session_start", (_event, ctx) => {
|
|
90628
91089
|
if (!ctx)
|
|
90629
91090
|
return;
|
|
90630
91091
|
registerExtensionContextRetirementEffect3(ctx, disposeCompletedRoutes);
|
|
90631
91092
|
registerExtensionContextRetirementEffect3(ctx, disposePendingRoutes);
|
|
91093
|
+
registerExtensionContextRetirementEffect3(ctx, disposeReleasedRoutes);
|
|
90632
91094
|
});
|
|
90633
91095
|
const overlay = buildWorkflowOverlay(pi, owner, postMortemHandleResolver, () => adapters.sessionStore);
|
|
90634
91096
|
const workflowCommands = new Map;
|