@bastani/atomic 0.9.59-alpha.1 → 0.9.60-alpha.1
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 +14 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +10 -0
- package/dist/builtin/subagents/README.md +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +53 -27
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +10 -2
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +17 -6
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/resource-admission-scope.d.ts +5 -0
- package/dist/core/resource-admission-scope.d.ts.map +1 -1
- package/dist/core/resource-admission-scope.js +7 -0
- package/dist/core/resource-admission-scope.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +5 -4
- package/dist/utils/clipboard.js.map +1 -1
- package/docs/getting-started/installation.md +1 -1
- package/docs/keybindings.md +1 -1
- package/docs/sdk.md +2 -0
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.9.60-alpha.1] - 2026-11-01
|
|
6
|
+
|
|
7
|
+
Chats that keep working after a workflow wakes them, steadier subagent model choices, and copying that works inside Rex.
|
|
8
|
+
|
|
9
|
+
- **Chats stay responsive after a workflow wakes them:** a completion notice or stage message no longer leaves the chat's own `bash` and other commands waiting on that workflow's resource admission, so they start at once even on a busy host ([#4154](https://github.com/bastani-inc/atomic/pull/4154))
|
|
10
|
+
- **Subagents keep the model you asked for:** an unknown effort word such as `openai/gpt-5.5:extreme` now runs the requested model at its default level instead of silently switching to the default model, and fails with a clear error if the model is unavailable ([#4154](https://github.com/bastani-inc/atomic/pull/4154))
|
|
11
|
+
- **Copying works inside Rex terminals:** copies now reach the Rex client's clipboard through OSC 52 instead of landing only on the server machine ([#4156](https://github.com/bastani-inc/atomic/pull/4156))
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- A chat that a running workflow woke, for example with its completion notice or a message from one of its stages' subagents, no longer has its own `bash` and other commands wait for good on that workflow's resource admission (such as `admission.host.minFreeMemoryBytes` on a busy host), even after the run finished. A turn a delivered message starts now runs under the receiving session's own admission, or none, so the chat's commands start at once; a workflow stage's commands still use its run's admission. SDK hosts: a turn started by `sendCustomMessage`, `sendCustomMessages` or `sendUserMessage` no longer inherits the sender's `withResourceAdmission` scope ([#4154](https://github.com/bastani-inc/atomic/pull/4154))
|
|
16
|
+
- A subagent launched with an effort word that is not a level, such as `model: "openai/gpt-5.5:extreme"`, now runs that model at its default level, as for an effort the model does not support, instead of silently running on the default model; a `fallbackModels` entry with such a word runs its model at that model's default level too. If the model itself is not available either, the launch fails with `Unknown model "<model>": "<word>" is not an effort level (...)` instead of running another model ([#4154](https://github.com/bastani-inc/atomic/pull/4154))
|
|
17
|
+
- Copying from Atomic inside a [Rex](https://www.superlogical.com/rex/) terminal now reaches the Rex client's clipboard. Rex servers start shells without SSH variables, so Atomic treated them as local and wrote only to the server machine's clipboard (or, on FreeBSD, nowhere). Rex terminals now also send the copy through OSC 52, as SSH sessions do ([#4156](https://github.com/bastani-inc/atomic/pull/4156))
|
|
18
|
+
|
|
5
19
|
## [0.9.59] - 2026-11-01
|
|
6
20
|
|
|
7
21
|
GitHub Copilot tokens that work from `/login`, and intercom that recovers on Windows.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/intercom",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.60-alpha.1",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
|
|
6
6
|
"contributors": [
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.9.60-alpha.1] - 2026-11-01
|
|
6
|
+
|
|
7
|
+
Subagents keep the model you asked for.
|
|
8
|
+
|
|
9
|
+
- **Unknown effort words no longer swap models:** a launch such as `openai/gpt-5.5:extreme` now runs the requested model at its default level instead of silently running on the default model, and fails with a clear error if the model is unavailable ([#4154](https://github.com/bastani-inc/atomic/pull/4154))
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- A subagent launched with an effort word that is not a level, such as `model: "openai/gpt-5.5:extreme"`, now runs that model at its default level, as for an effort the model does not support, instead of silently running on the default model; a `fallbackModels` entry with such a word runs its model at that model's default level too. If the model itself is not available either, the launch fails with `Unknown model "<model>": "<word>" is not an effort level (...)` instead of running another model ([#4154](https://github.com/bastani-inc/atomic/pull/4154))
|
|
14
|
+
|
|
5
15
|
## [0.9.58] - 2026-11-01
|
|
6
16
|
|
|
7
17
|
### Added
|
|
@@ -816,7 +816,7 @@ The main runtime files are:
|
|
|
816
816
|
|
|
817
817
|
### Suffix-first reasoning levels
|
|
818
818
|
|
|
819
|
-
Reasoning levels are configured suffix-first using the `model_name:thinking_effort` syntax on `model` and each `fallbackModels` entry: `model: claude-sonnet-4:high` and `fallbackModels: claude-sonnet-4:medium, gpt-5:low, claude-haiku-4:off`. Canonical efforts are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. A child runs at exactly the effort it was launched with on a model that supports it; a model that does not support it, `xhigh` or `max` on many models, runs at its own default level instead (its `modelThinkingLevels` setting, else `defaultThinkingLevel`). Fallback models follow the same rule, using their own suffix or, without one, the launch's effort. The older `thinking` field is deprecated; it remains supported as a legacy default only when a model candidate has no suffix, and a suffix always wins.
|
|
819
|
+
Reasoning levels are configured suffix-first using the `model_name:thinking_effort` syntax on `model` and each `fallbackModels` entry: `model: claude-sonnet-4:high` and `fallbackModels: claude-sonnet-4:medium, gpt-5:low, claude-haiku-4:off`. Canonical efforts are `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. A child runs at exactly the effort it was launched with on a model that supports it; a model that does not support it, `xhigh` or `max` on many models, runs at its own default level instead (its `modelThinkingLevels` setting, else `defaultThinkingLevel`). A suffix that is not one of these efforts, such as `openai/gpt-5.5:extreme`, is treated the same way: the child runs that model at its default level. If the model before such a suffix is not available either, the launch fails with `Unknown model "<model>"` instead of running another model. Fallback models follow the same rule, using their own suffix or, without one, the launch's effort. The older `thinking` field is deprecated; it remains supported as a legacy default only when a model candidate has no suffix, and a suffix always wins.
|
|
820
820
|
|
|
821
821
|
Migrate legacy `thinking` frontmatter by folding the effort into `model` and `fallbackModels`:
|
|
822
822
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/subagents",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.60-alpha.1",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension for delegating tasks to subagents with parallel execution. Fork of: https://github.com/nicobailon/pi-subagents",
|
|
6
6
|
"contributors": [
|
|
@@ -7785,6 +7785,15 @@ function splitKnownThinkingSuffix(model) {
|
|
|
7785
7785
|
thinkingSuffix: `:${suffix}`
|
|
7786
7786
|
};
|
|
7787
7787
|
}
|
|
7788
|
+
function splitUnknownThinkingSuffix(model) {
|
|
7789
|
+
const colonIdx = model.lastIndexOf(":");
|
|
7790
|
+
if (colonIdx <= 0)
|
|
7791
|
+
return;
|
|
7792
|
+
const effort = model.substring(colonIdx + 1);
|
|
7793
|
+
if (!/^[a-z]+$/i.test(effort) || THINKING_LEVELS.some((level) => level === effort))
|
|
7794
|
+
return;
|
|
7795
|
+
return { baseModel: model.substring(0, colonIdx), effort };
|
|
7796
|
+
}
|
|
7788
7797
|
function taskRecordModel(model) {
|
|
7789
7798
|
return model === undefined ? undefined : splitKnownThinkingSuffix(model).baseModel;
|
|
7790
7799
|
}
|
|
@@ -10095,26 +10104,29 @@ function thinkingLevelFromSuffix(suffix) {
|
|
|
10095
10104
|
const level = suffix.slice(1);
|
|
10096
10105
|
return THINKING_LEVELS.find((known) => known === level);
|
|
10097
10106
|
}
|
|
10107
|
+
function findCandidateModel(baseModel, lookup, preferredProvider) {
|
|
10108
|
+
const slash = baseModel.indexOf("/");
|
|
10109
|
+
if (slash < 0) {
|
|
10110
|
+
const available = lookup.getAvailable().filter((entry) => entry.id === baseModel);
|
|
10111
|
+
return available.find((entry) => entry.provider === preferredProvider) ?? (available.length === 1 ? available[0] : undefined);
|
|
10112
|
+
}
|
|
10113
|
+
const model = lookup.find(baseModel.slice(0, slash), baseModel.slice(slash + 1));
|
|
10114
|
+
return model && lookup.hasConfiguredAuth(model) ? model : undefined;
|
|
10115
|
+
}
|
|
10098
10116
|
function resolveCandidateModel(candidateId, lookup, preferredProvider) {
|
|
10099
10117
|
const trimmed = candidateId.trim();
|
|
10100
10118
|
if (!trimmed)
|
|
10101
10119
|
return;
|
|
10102
10120
|
const { baseModel, thinkingSuffix } = splitKnownThinkingSuffix(trimmed);
|
|
10103
10121
|
const thinkingLevel = thinkingLevelFromSuffix(thinkingSuffix);
|
|
10104
|
-
const
|
|
10105
|
-
if (
|
|
10106
|
-
const available = lookup.getAvailable().filter((entry) => entry.id === baseModel);
|
|
10107
|
-
const model = available.find((entry) => entry.provider === preferredProvider) ?? (available.length === 1 ? available[0] : undefined);
|
|
10108
|
-
if (!model)
|
|
10109
|
-
return;
|
|
10122
|
+
const model = findCandidateModel(baseModel, lookup, preferredProvider);
|
|
10123
|
+
if (model)
|
|
10110
10124
|
return thinkingLevel === undefined ? { model } : { model, thinkingLevel };
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
const modelId = baseModel.slice(slash + 1);
|
|
10114
|
-
const model = lookup.find(provider, modelId);
|
|
10115
|
-
if (!model || !lookup.hasConfiguredAuth(model))
|
|
10125
|
+
const unknown = thinkingSuffix ? undefined : splitUnknownThinkingSuffix(trimmed);
|
|
10126
|
+
if (!unknown)
|
|
10116
10127
|
return;
|
|
10117
|
-
|
|
10128
|
+
const base = findCandidateModel(unknown.baseModel, lookup, preferredProvider);
|
|
10129
|
+
return base ? { model: base, unknownEffort: unknown.effort } : undefined;
|
|
10118
10130
|
}
|
|
10119
10131
|
function createCandidateModelResolver(lookup, preferredProvider) {
|
|
10120
10132
|
return (candidateId) => resolveCandidateModel(candidateId, lookup, preferredProvider);
|
|
@@ -12582,16 +12594,21 @@ function formatStartTimeout(ms) {
|
|
|
12582
12594
|
}
|
|
12583
12595
|
var DEFAULT_THINKING_LEVEL = "medium";
|
|
12584
12596
|
function explicitEffortFor(model, requested, settings) {
|
|
12585
|
-
|
|
12586
|
-
|
|
12597
|
+
const supported = getSupportedThinkingLevels(model).find((level) => level === requested);
|
|
12598
|
+
if (supported)
|
|
12599
|
+
return supported;
|
|
12587
12600
|
return clampThinkingLevel(model, settings.getModelThinkingLevel(model.provider, model.id) ?? settings.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL);
|
|
12588
12601
|
}
|
|
12589
12602
|
function pinFallbackEffort(entry, requested, settings, resolve) {
|
|
12590
12603
|
const resolved = resolve?.(entry);
|
|
12591
12604
|
if (!resolved)
|
|
12592
12605
|
return entry;
|
|
12593
|
-
const
|
|
12594
|
-
|
|
12606
|
+
const effort = requested === undefined ? resolved.unknownEffort : resolved.thinkingLevel ?? resolved.unknownEffort ?? requested;
|
|
12607
|
+
if (effort === undefined)
|
|
12608
|
+
return entry;
|
|
12609
|
+
const text = entry.trim();
|
|
12610
|
+
const { baseModel } = resolved.unknownEffort === undefined ? splitKnownThinkingSuffix(text) : splitUnknownThinkingSuffix(text) ?? { baseModel: text };
|
|
12611
|
+
return `${baseModel}:${explicitEffortFor(resolved.model, effort, settings)}`;
|
|
12595
12612
|
}
|
|
12596
12613
|
function modelIdForCandidate(candidate, fallbackModel) {
|
|
12597
12614
|
return candidate.modelId ?? (candidate.model ? `${candidate.model.provider}/${candidate.model.id}` : undefined) ?? (fallbackModel ? `${fallbackModel.provider}/${fallbackModel.id}` : undefined);
|
|
@@ -13289,9 +13306,12 @@ class SubagentControlRuntime {
|
|
|
13289
13306
|
const requested = admitted.spec.requestedThinking;
|
|
13290
13307
|
const startSuffix = splitKnownThinkingSuffix(candidate.modelId ?? "").thinkingSuffix.slice(1);
|
|
13291
13308
|
const startEffort = THINKING_LEVELS.find((level) => level === startSuffix) ?? requested;
|
|
13292
|
-
const
|
|
13293
|
-
|
|
13294
|
-
|
|
13309
|
+
const explicit = requested !== undefined && startEffort !== undefined;
|
|
13310
|
+
const fallbackEntries = inherited.fallbackModels ?? settingsManager.getFallbackModels() ?? [];
|
|
13311
|
+
const pinnedFallbacks = fallbackEntries.map((entry) => pinFallbackEffort(entry, requested, settingsManager, admitted.spec.resolveCandidateModel));
|
|
13312
|
+
const explicitEffort = {
|
|
13313
|
+
...explicit && inherited.model ? { thinkingLevel: explicitEffortFor(inherited.model, startEffort, settingsManager) } : {},
|
|
13314
|
+
...explicit || pinnedFallbacks.some((entry, index) => entry !== fallbackEntries[index]) ? { fallbackModels: pinnedFallbacks } : {}
|
|
13295
13315
|
};
|
|
13296
13316
|
const resourceLoader = new DefaultResourceLoader(inProcessChildResourceLoaderOptions({
|
|
13297
13317
|
cwd: admitted.policy.cwd,
|
|
@@ -14085,6 +14105,9 @@ function noSpawnableCandidatesResult(agent, task, skippedAttempts) {
|
|
|
14085
14105
|
const reason = "No spawnable subagent model candidates after pre-spawn filtering.";
|
|
14086
14106
|
return { ...refusedResult(agent, task, reason), modelAttempts: skippedAttempts };
|
|
14087
14107
|
}
|
|
14108
|
+
function unknownModelResult(agent, task, candidate, effort, baseModel) {
|
|
14109
|
+
return refusedResult(agent, task, `Unknown model "${candidate}": "${effort}" is not an effort level (${THINKING_LEVELS.join(", ")}), and no available model is "${baseModel}".`);
|
|
14110
|
+
}
|
|
14088
14111
|
async function runSingleInProcess(runtimeCwd, agent, task, options) {
|
|
14089
14112
|
const cwd = options.cwd ?? runtimeCwd;
|
|
14090
14113
|
if (!existsSync14(cwd))
|
|
@@ -14112,14 +14135,19 @@ async function runSingleInProcess(runtimeCwd, agent, task, options) {
|
|
|
14112
14135
|
});
|
|
14113
14136
|
if (rawCandidates.length > 0 && filteredCandidates.candidates.length === 0)
|
|
14114
14137
|
return noSpawnableCandidatesResult(agent, task, filteredCandidates.skippedAttempts);
|
|
14115
|
-
const
|
|
14138
|
+
const listedCandidate = filteredCandidates.candidates[0];
|
|
14116
14139
|
const fallbackCandidates = filteredCandidates.candidates.slice(1);
|
|
14117
14140
|
const inheritsDispatchConfig = agent.model === undefined && (agent.fallbackModels === undefined || agent.fallbackModels.length === 0) && options.modelOverride === undefined;
|
|
14118
|
-
const resolvedCandidate =
|
|
14141
|
+
const resolvedCandidate = listedCandidate ? options.resolveCandidateModel?.(listedCandidate) : undefined;
|
|
14119
14142
|
if (options.modelRoute && !resolvedCandidate)
|
|
14120
14143
|
throw new Error("Subagent auto-selected model could not be resolved before execution. Retry explicitly with the current catalog.");
|
|
14121
|
-
const
|
|
14122
|
-
|
|
14144
|
+
const unknownEffort = listedCandidate ? splitUnknownThinkingSuffix(listedCandidate) : undefined;
|
|
14145
|
+
if (listedCandidate && unknownEffort && options.resolveCandidateModel && !resolvedCandidate)
|
|
14146
|
+
return unknownModelResult(agent, task, listedCandidate, unknownEffort.effort, unknownEffort.baseModel);
|
|
14147
|
+
const candidate = resolvedCandidate?.unknownEffort !== undefined && unknownEffort ? unknownEffort.baseModel : listedCandidate;
|
|
14148
|
+
const launchModel = options.modelOverride ?? agent.model ?? "";
|
|
14149
|
+
const requestedSuffix = splitKnownThinkingSuffix(launchModel).thinkingSuffix.slice(1);
|
|
14150
|
+
const requestedThinking = options.modelRoute ? undefined : THINKING_LEVELS.find((level) => level === requestedSuffix) ?? (launchModel ? options.resolveCandidateModel?.(launchModel)?.unknownEffort : undefined);
|
|
14123
14151
|
const orchestrationContext = workflowOrchestrationContext(options);
|
|
14124
14152
|
const outputSnapshot = captureSingleOutputSnapshot(options.outputPath);
|
|
14125
14153
|
const parent = {
|
|
@@ -14161,10 +14189,8 @@ ${task}`);
|
|
|
14161
14189
|
...options.progressArtifactPath ? { progressArtifactPath: options.progressArtifactPath } : options.progressPath && artifactsDir ? { progressArtifactPath: options.progressPath } : {},
|
|
14162
14190
|
...artifactPaths?.outputPath ? { outputArtifactPath: artifactPaths.outputPath } : {},
|
|
14163
14191
|
...options.sessionStartTimeoutMs === undefined ? {} : { sessionStartTimeoutMs: options.sessionStartTimeoutMs },
|
|
14164
|
-
...requestedThinking === undefined ? {} : {
|
|
14165
|
-
|
|
14166
|
-
...options.resolveCandidateModel ? { resolveCandidateModel: options.resolveCandidateModel } : {}
|
|
14167
|
-
},
|
|
14192
|
+
...requestedThinking === undefined ? {} : { requestedThinking },
|
|
14193
|
+
...options.resolveCandidateModel ? { resolveCandidateModel: options.resolveCandidateModel } : {},
|
|
14168
14194
|
tools: agent.tools,
|
|
14169
14195
|
mcpDirectTools: agent.mcpDirectTools,
|
|
14170
14196
|
skills: options.skills ?? agent.skills,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/web-access",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.60-alpha.1",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
|
|
6
6
|
"contributors": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-message-queue.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mapp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AAY,GAAG,SAAS,MAAM,EAAE,CAEzE;AAMD,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAGvF;AAED;;;GAGG;AAEH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAGvF;AAKD,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B3C,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { waitForCustomMessagePreparation } from "./agent-session-prompt.js";
|
|
|
5
5
|
import { abort, pauseQueuedMessages, resumeQueuedMessages } from "./agent-session-queue-pause.js";
|
|
6
6
|
import { transferWorkflowStageDeliveriesTo } from "./agent-session-transfer.js";
|
|
7
7
|
import { customMessageExcludesContext, drainAgentMessageQueue, normalizeInterruptAbortMessage, priorityHoldCounts, } from "./agent-session-types.js";
|
|
8
|
+
import { withOwnResourceAdmission } from "./resource-admission-scope.js";
|
|
8
9
|
import { assertSessionOpen, sessionLifetime, trackSessionWork } from "./session-lifecycle-work.js";
|
|
9
10
|
import { settingsWriteOwner } from "./settings-write-ownership.js";
|
|
10
11
|
export { transferWorkflowStageDeliveriesTo };
|
|
@@ -82,7 +83,14 @@ export async function sendCustomMessage(message, options) {
|
|
|
82
83
|
if (currentOwner !== this)
|
|
83
84
|
return currentOwner.sendCustomMessage(message, options);
|
|
84
85
|
assertSessionOpen(this);
|
|
85
|
-
return
|
|
86
|
+
return deliveredMessageTurn(this, () => admittedCustomMessage.call(this, message, options));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A delivered message starts this session's turn, so the turn runs under this session's own resource admission, or
|
|
90
|
+
* none: never under the scope its sender runs in, such as the workflow run whose notice or stage message it is.
|
|
91
|
+
*/
|
|
92
|
+
function deliveredMessageTurn(session, deliver) {
|
|
93
|
+
return withOwnResourceAdmission(session._resourceAdmission, () => trackSessionWork(session, deliver));
|
|
86
94
|
}
|
|
87
95
|
async function admittedCustomMessage(message, options) {
|
|
88
96
|
const lifetime = sessionLifetime(this);
|
|
@@ -125,7 +133,7 @@ export async function sendCustomMessages(messages, options) {
|
|
|
125
133
|
if (currentOwner !== this)
|
|
126
134
|
return currentOwner.sendCustomMessages(messages, options);
|
|
127
135
|
assertSessionOpen(this);
|
|
128
|
-
return
|
|
136
|
+
return deliveredMessageTurn(this, () => admittedCustomMessages.call(this, messages, options));
|
|
129
137
|
}
|
|
130
138
|
async function admittedCustomMessages(messages, options) {
|
|
131
139
|
const lifetime = sessionLifetime(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-message-queue.js","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAC;AAErH,OAAO,EACN,iCAAiC,EACjC,uCAAuC,GACvC,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAGN,4BAA4B,EAE5B,sBAAsB,EAEtB,8BAA8B,EAC9B,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,iCAAiC,EAAE,CAAC;AAE7C,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAA+B,CAAC;AAE3E,SAAS,0BAA0B,CAA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iB,CAAC;AAC/B,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,mBAAmB;IAClC,OAAO,IAAI,CAAC,iBAAiB,CAAC;AAC/B,CAAC;AAED,4EAA4E;AAC5E,mBAAmB;AACnB,4EAA4E;AAE5E,MAAM,UAAU,eAAe,CAAqB,IAA6B;IAChF,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC/B,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC;AAED;;;GAGG;AAEH,MAAM,UAAU,eAAe,CAAqB,IAA6B;IAChF,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC/B,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,4EAA4E;AAC5E,8BAA8B;AAC9B,4EAA4E;AAC5E,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,WAAW;IACX,cAAc;IACd,wBAAwB;IACxB,iCAAiC;IACjC,2BAA2B;IAC3B,iBAAiB;IACjB,kBAAkB;IAClB,4BAA4B;IAC5B,oBAAoB;IACpB,2BAA2B;IAC3B,8BAA8B;IAC9B,8BAA8B;IAC9B,+BAA+B;IAC/B,wCAAwC;IACxC,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;IAClB,yBAAyB;IACzB,2BAA2B;IAC3B,UAAU;IACV,mBAAmB;IACnB,mBAAmB;IACnB,KAAK;IACL,eAAe;IACf,eAAe;CACf,CAAC","sourcesContent":["import type { ImageContent, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport { commitAdmittedCustomMessage, commitAdmittedCustomMessages } from \"./agent-session-custom-message-commit.ts\";\nimport { forwardedMessageOptions, resolveWorkflowStageDeliveryTarget } from \"./agent-session-delivery-forwarding.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport {\n\tisProtectedStreamingCustomMessage,\n\trestoreProtectedStreamingCustomMessages,\n} from \"./agent-session-persistent-custom-messages.ts\";\nimport { waitForCustomMessagePreparation } from \"./agent-session-prompt.ts\";\nimport { abort, pauseQueuedMessages, resumeQueuedMessages } from \"./agent-session-queue-pause.ts\";\nimport { transferWorkflowStageDeliveriesTo } from \"./agent-session-transfer.ts\";\nimport {\n\ttype AgentQueueAccess,\n\ttype ClearQueueOptions,\n\tcustomMessageExcludesContext,\n\ttype DrainedAgentQueues,\n\tdrainAgentMessageQueue,\n\ttype InterruptQueueHold,\n\tnormalizeInterruptAbortMessage,\n\tpriorityHoldCounts,\n} from \"./agent-session-types.js\";\nimport type { SendMessageOptions, SendMessagesOptions } from \"./extensions/index.js\";\nimport type { CustomMessage, StageAdmittedCustomMessage } from \"./messages.ts\";\nimport { assertSessionOpen, sessionLifetime, trackSessionWork } from \"./session-lifecycle-work.ts\";\nimport { settingsWriteOwner } from \"./settings-write-ownership.ts\";\n\nexport { transferWorkflowStageDeliveriesTo };\n\nconst interruptMutationQueues = new WeakMap<AgentSession, Promise<void>>();\n\nfunction serializeInterruptMutation(owner: AgentSession, operation: () => Promise<void>): Promise<void> {\n\tconst previous = interruptMutationQueues.get(owner) ?? Promise.resolve();\n\tconst delivery = previous.then(operation);\n\tinterruptMutationQueues.set(\n\t\towner,\n\t\tdelivery.catch(() => undefined),\n\t);\n\treturn delivery;\n}\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tassertSessionOpen(this);\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._queueSteer(text, images);\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tassertSessionOpen(this);\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._queueFollowUp(text, images);\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(\n\tthis: AgentSession,\n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst currentOwner = resolveWorkflowStageDeliveryTarget(this);\n\tif (currentOwner !== this) return currentOwner.sendCustomMessage(message, options);\n\tassertSessionOpen(this);\n\treturn trackSessionWork(this, () => admittedCustomMessage.call(this, message, options));\n}\n\nasync function admittedCustomMessage<T>(\n\tthis: AgentSession,\n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst lifetime = sessionLifetime(this);\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content ?? [],\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t\t...(options?.stageAdmissionKey === undefined ? {} : { stageAdmissionKey: options.stageAdmissionKey }),\n\t} satisfies CustomMessage<T> & { stageAdmissionKey?: string };\n\tconst boundary = this._subagentMessageAdmission ?? this._workflowStageAdmission;\n\tconst commit = async (): Promise<void> => {\n\t\tif (boundary && options?.stageAdmissionBarrier) await options.stageAdmissionBarrier();\n\t\tassertSessionOpen(this);\n\t\tif (lifetime.aborted) throw Object.assign(new Error(\"Session is closed\"), { code: \"SessionClosed\" });\n\t\tawait commitAdmittedCustomMessage(this, appMessage, options);\n\t};\n\t// Event hooks may await non-triggering writes while protected input awaits the\n\t// event writer. Those local writes must not queue behind that external input.\n\tconst deliver = () =>\n\t\tboundary && options?.triggerTurn === true ? boundary.serializeMessageDelivery(commit) : commit();\n\tif (boundary === undefined) return deliver();\n\tawait boundary.admit(options?.stageAdmissionKey, deliver, () => {\n\t\tif (this._subagentMessageAdmission) throw new Error(\"Subagent execution is terminal and cannot accept messages\");\n\t\tconst router = this._orchestrationContext?.lateMessageRouter;\n\t\tif (router === undefined) throw new Error(\"Workflow stage closed without a late-message router\");\n\t\treturn router.routeMessage(message, options);\n\t}).completion;\n}\n\n/** Atomically admits a custom-message batch in array order. */\nexport async function sendCustomMessages<T = unknown>(\n\tthis: AgentSession,\n\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\toptions?: SendMessagesOptions,\n): Promise<void> {\n\tconst currentOwner = resolveWorkflowStageDeliveryTarget(this);\n\tif (currentOwner !== this) return currentOwner.sendCustomMessages(messages, options);\n\tassertSessionOpen(this);\n\treturn trackSessionWork(this, () => admittedCustomMessages.call(this, messages, options));\n}\n\nasync function admittedCustomMessages<T>(\n\tthis: AgentSession,\n\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\toptions?: SendMessagesOptions,\n): Promise<void> {\n\tconst lifetime = sessionLifetime(this);\n\tconst timestamp = Date.now();\n\tconst appMessages = messages.map(\n\t\t(message) =>\n\t\t\t({\n\t\t\t\trole: \"custom\" as const,\n\t\t\t\tcustomType: message.customType,\n\t\t\t\tcontent: message.content ?? [],\n\t\t\t\tdisplay: message.display,\n\t\t\t\tdetails: message.details,\n\t\t\t\ttimestamp,\n\t\t\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t\t\t\t...(options?.stageAdmissionKey === undefined ? {} : { stageAdmissionKey: options.stageAdmissionKey }),\n\t\t\t}) satisfies CustomMessage<T> & { stageAdmissionKey?: string },\n\t);\n\tif (appMessages.length === 0) return;\n\tconst boundary = this._subagentMessageAdmission ?? this._workflowStageAdmission;\n\tconst commit = async (): Promise<void> => {\n\t\tif (boundary && options?.stageAdmissionBarrier) await options.stageAdmissionBarrier();\n\t\tassertSessionOpen(this);\n\t\tif (lifetime.aborted) throw Object.assign(new Error(\"Session is closed\"), { code: \"SessionClosed\" });\n\t\tawait commitAdmittedCustomMessages(this, appMessages, options);\n\t};\n\tconst deliver = () =>\n\t\tboundary && options?.triggerTurn === true ? boundary.serializeMessageDelivery(commit) : commit();\n\tif (boundary === undefined) return deliver();\n\tawait boundary.admit(options?.stageAdmissionKey, deliver, () => {\n\t\tif (this._subagentMessageAdmission) throw new Error(\"Subagent execution is terminal and cannot accept messages\");\n\t\tconst router = this._orchestrationContext?.lateMessageRouter;\n\t\tif (router === undefined) throw new Error(\"Workflow stage closed without a late-message router\");\n\t\treturn router.routeMessages(messages, options);\n\t}).completion;\n}\n\nexport function sealWorkflowStageGeneration(this: AgentSession): void {\n\tthis._workflowStageAdmission?.seal();\n}\n\nexport async function closeWorkflowStageGeneration(this: AgentSession): Promise<void> {\n\tawait this._workflowStageAdmission?.close();\n\tawait this.agent?.waitForIdle?.();\n\tawait this._agentEventQueue;\n}\n\nexport async function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) {\n\t\tawait owner._appendCustomMessage(message);\n\t\treturn;\n\t}\n\tconst stageAdmissionMessage = message as StageAdmittedCustomMessage;\n\tconst entryId = await this.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t\tundefined,\n\t\tstageAdmissionMessage.stageAdmissionKey,\n\t);\n\tthis._entryIdsByMessage.set(message, entryId);\n\tthis._refreshFinalizedContext();\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\nconst pendingCustomMessageDrains = new WeakMap<AgentSession, Promise<void>>();\n\n/** Append context-only custom messages once the current turn's tool results are in history. */\nexport function _flushPendingCustomMessages(this: AgentSession): Promise<void> {\n\tconst pending = pendingCustomMessageDrains.get(this);\n\tif (pending) return pending;\n\tif (this._pendingCustomMessages.length === 0) return Promise.resolve();\n\n\tconst drain = (async () => {\n\t\twhile (this._pendingCustomMessages.length > 0) {\n\t\t\tawait this._appendCustomMessage(this._pendingCustomMessages[0]);\n\t\t\tthis._pendingCustomMessages.shift();\n\t\t}\n\t})();\n\tpendingCustomMessageDrains.set(this, drain);\n\tvoid drain.then(\n\t\t() => pendingCustomMessageDrains.delete(this),\n\t\t() => pendingCustomMessageDrains.delete(this),\n\t);\n\treturn drain;\n}\nexport function _enqueueInterruptCustomMessage<T>(\n\tthis: AgentSession,\n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._enqueueInterruptCustomMessage(message, forwardedMessageOptions(options));\n\tassertSessionOpen(this);\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = trackSessionWork(this, () =>\n\t\tthis._interruptDeliveryQueue.then(async () => {\n\t\t\ttry {\n\t\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t\t} finally {\n\t\t\t\t// Retirement moves the pending count and hold synchronously. Settle the\n\t\t\t\t// same live owner so its queue cannot remain stranded on the replacement.\n\t\t\t\tconst liveOwner = resolveWorkflowStageDeliveryTarget(this);\n\t\t\t\tliveOwner._pendingInterruptDeliveries -= 1;\n\t\t\t\tif (liveOwner._pendingInterruptDeliveries === 0) {\n\t\t\t\t\tliveOwner._restoreAndClearActiveInterruptQueueHold();\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\nasync function sendInterruptCustomMessageUnlocked<T>(\n\tsession: AgentSession,\n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tassertSessionOpen(session);\n\tconst lifetime = sessionLifetime(session);\n\tsession.abortRetry();\n\tsession._ensureActiveInterruptQueueHold();\n\tawait waitForCustomMessagePreparation(session);\n\tif (session.isStreaming || session._isPreparingRun) {\n\t\tconst previousAbortMessage = session._activeInterruptAbortMessage;\n\t\tsession._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tsession.agent.abort();\n\t\t\tawait session.agent.waitForIdle();\n\t\t\tawait session._agentEventQueue;\n\t\t} finally {\n\t\t\tsession._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tconst owner = resolveWorkflowStageDeliveryTarget(session);\n\tif (owner !== session) return owner._sendInterruptCustomMessageNow(message, forwardedMessageOptions(options));\n\tassertSessionOpen(session);\n\tif (lifetime.aborted) throw Object.assign(new Error(\"Session is closed\"), { code: \"SessionClosed\" });\n\tif (session._queuedMessagesPaused) {\n\t\tsession._queueAgentMessage(message, \"steer\");\n\t\treturn;\n\t}\n\tawait session.agent.prompt(message);\n}\n\nexport function _sendInterruptCustomMessageNow<T>(\n\tthis: AgentSession,\n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._sendInterruptCustomMessageNow(message, forwardedMessageOptions(options));\n\treturn serializeInterruptMutation(this, () => sendInterruptCustomMessageUnlocked(this, message, options));\n}\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._ensureActiveInterruptQueueHold();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) {\n\t\towner._restoreAndClearActiveInterruptQueueHold();\n\t\treturn;\n\t}\n\tif (this._queuedMessagesPaused) return;\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) return;\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\nexport function _queueAgentMessage(\n\tthis: AgentSession,\n\tmessage: AgentMessage,\n\tdelivery: \"steer\" | \"followUp\" | \"interrupt\",\n): void {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) {\n\t\towner._queueAgentMessage(message, delivery);\n\t\treturn;\n\t}\n\tconst hold = delivery === \"interrupt\" ? this._ensureActiveInterruptQueueHold() : this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else if (delivery === \"interrupt\") {\n\t\t\tconst index = priorityHoldCounts.get(hold) ?? 0;\n\t\t\thold.steering.splice(index, 0, message);\n\t\t\tpriorityHoldCounts.set(hold, index + 1);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t} else if (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n\tconst yieldReason = message.role === \"user\" ? \"input-needed\" : \"intercom-coordination\";\n\tthis._agentTaskHost?.yieldTaskWaits(yieldReason);\n\tthis._childTaskWaits.yieldAll(yieldReason);\n}\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupt and pause holds prevent an aborting run from consuming queued raw\n\t// messages while preserving every entry for the existing resume boundary.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n/**\n * Clear queued text for editor restoration while retaining optional raw custom entries.\n */\nexport function clearQueue(\n\tthis: AgentSession,\n\toptions?: ClearQueueOptions,\n): { steering: string[]; followUp: string[] } {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner.clearQueue(options);\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tconst removed = this._drainQueuedAgentMessages();\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tremoved.steering.push(...hold.steering.splice(0));\n\t\tremoved.followUp.push(...hold.followUp.splice(0));\n\t\tpriorityHoldCounts.delete(hold);\n\t}\n\trestoreProtectedStreamingCustomMessages(this, removed);\n\tif (options?.preserveUnprotectedCustomMessages && hold !== undefined) {\n\t\tconst restoreUnprotectedCustomMessages = (\n\t\t\tremovedMessages: AgentMessage[],\n\t\t\theldMessages: AgentMessage[],\n\t\t): void => {\n\t\t\tconst currentlyHeld = [...heldMessages];\n\t\t\tconst preserved = removedMessages.filter(\n\t\t\t\t(message): message is Extract<AgentMessage, { role: \"custom\" }> =>\n\t\t\t\t\tmessage.role === \"custom\" && !isProtectedStreamingCustomMessage(this, message),\n\t\t\t);\n\t\t\tif (preserved.length === 0) return;\n\t\t\tconst preservedReferences = new Set<AgentMessage>(preserved);\n\t\t\tconst restoredProtected = new Set(currentlyHeld);\n\t\t\tconst ordered = removedMessages.filter(\n\t\t\t\t(message) => preservedReferences.has(message) || restoredProtected.has(message),\n\t\t\t);\n\t\t\tconst unmatched = currentlyHeld.filter((message) => !ordered.includes(message));\n\t\t\theldMessages.splice(0, heldMessages.length, ...ordered, ...unmatched);\n\t\t};\n\t\trestoreUnprotectedCustomMessages(removed.steering, hold.steering);\n\t\trestoreUnprotectedCustomMessages(removed.followUp, hold.followUp);\n\t}\n\tif (\n\t\t!this._queuedMessagesPaused &&\n\t\tthis._pendingInterruptDeliveries === 0 &&\n\t\thold !== undefined &&\n\t\thold.steering.length === 0 &&\n\t\thold.followUp.length === 0\n\t) {\n\t\tthis._activeInterruptQueueHold = undefined;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tsettingsWriteOwner.run(this, () => this.settingsManager.setSteeringMode(mode));\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tsettingsWriteOwner.run(this, () => this.settingsManager.setFollowUpMode(mode));\n}\n\n// =========================================================================\n// Queue and delivery settings\n// =========================================================================\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\ttransferWorkflowStageDeliveriesTo,\n\tsealWorkflowStageGeneration,\n\tsendCustomMessage,\n\tsendCustomMessages,\n\tcloseWorkflowStageGeneration,\n\t_appendCustomMessage,\n\t_flushPendingCustomMessages,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\tpauseQueuedMessages,\n\tresumeQueuedMessages,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"agent-session-message-queue.js","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACrH,OAAO,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,MAAM,wCAAwC,CAAC;AAErH,OAAO,EACN,iCAAiC,EACjC,uCAAuC,GACvC,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAClG,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAGN,4BAA4B,EAE5B,sBAAsB,EAEtB,8BAA8B,EAC9B,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,iCAAiC,EAAE,CAAC;AAE7C,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAA+B,CAAC;AAE3E,SAAS,0BAA0B,CAAC,KAAmB,EAAE,SAA8B;IACtF,MAAM,QAAQ,GAAG,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,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gentMessage } from \"@earendil-works/pi-agent-core\";\nimport { commitAdmittedCustomMessage, commitAdmittedCustomMessages } from \"./agent-session-custom-message-commit.ts\";\nimport { forwardedMessageOptions, resolveWorkflowStageDeliveryTarget } from \"./agent-session-delivery-forwarding.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport {\n\tisProtectedStreamingCustomMessage,\n\trestoreProtectedStreamingCustomMessages,\n} from \"./agent-session-persistent-custom-messages.ts\";\nimport { waitForCustomMessagePreparation } from \"./agent-session-prompt.ts\";\nimport { abort, pauseQueuedMessages, resumeQueuedMessages } from \"./agent-session-queue-pause.ts\";\nimport { transferWorkflowStageDeliveriesTo } from \"./agent-session-transfer.ts\";\nimport {\n\ttype AgentQueueAccess,\n\ttype ClearQueueOptions,\n\tcustomMessageExcludesContext,\n\ttype DrainedAgentQueues,\n\tdrainAgentMessageQueue,\n\ttype InterruptQueueHold,\n\tnormalizeInterruptAbortMessage,\n\tpriorityHoldCounts,\n} from \"./agent-session-types.js\";\nimport type { SendMessageOptions, SendMessagesOptions } from \"./extensions/index.js\";\nimport type { CustomMessage, StageAdmittedCustomMessage } from \"./messages.ts\";\nimport { withOwnResourceAdmission } from \"./resource-admission-scope.ts\";\nimport { assertSessionOpen, sessionLifetime, trackSessionWork } from \"./session-lifecycle-work.ts\";\nimport { settingsWriteOwner } from \"./settings-write-ownership.ts\";\n\nexport { transferWorkflowStageDeliveriesTo };\n\nconst interruptMutationQueues = new WeakMap<AgentSession, Promise<void>>();\n\nfunction serializeInterruptMutation(owner: AgentSession, operation: () => Promise<void>): Promise<void> {\n\tconst previous = interruptMutationQueues.get(owner) ?? Promise.resolve();\n\tconst delivery = previous.then(operation);\n\tinterruptMutationQueues.set(\n\t\towner,\n\t\tdelivery.catch(() => undefined),\n\t);\n\treturn delivery;\n}\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tassertSessionOpen(this);\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._queueSteer(text, images);\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tassertSessionOpen(this);\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._queueFollowUp(text, images);\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(\n\tthis: AgentSession,\n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst currentOwner = resolveWorkflowStageDeliveryTarget(this);\n\tif (currentOwner !== this) return currentOwner.sendCustomMessage(message, options);\n\tassertSessionOpen(this);\n\treturn deliveredMessageTurn(this, () => admittedCustomMessage.call(this, message, options));\n}\n\n/**\n * A delivered message starts this session's turn, so the turn runs under this session's own resource admission, or\n * none: never under the scope its sender runs in, such as the workflow run whose notice or stage message it is.\n */\nfunction deliveredMessageTurn<T>(session: AgentSession, deliver: () => Promise<T>): Promise<T> {\n\treturn withOwnResourceAdmission(session._resourceAdmission, () => trackSessionWork(session, deliver));\n}\n\nasync function admittedCustomMessage<T>(\n\tthis: AgentSession,\n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst lifetime = sessionLifetime(this);\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content ?? [],\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t\t...(options?.stageAdmissionKey === undefined ? {} : { stageAdmissionKey: options.stageAdmissionKey }),\n\t} satisfies CustomMessage<T> & { stageAdmissionKey?: string };\n\tconst boundary = this._subagentMessageAdmission ?? this._workflowStageAdmission;\n\tconst commit = async (): Promise<void> => {\n\t\tif (boundary && options?.stageAdmissionBarrier) await options.stageAdmissionBarrier();\n\t\tassertSessionOpen(this);\n\t\tif (lifetime.aborted) throw Object.assign(new Error(\"Session is closed\"), { code: \"SessionClosed\" });\n\t\tawait commitAdmittedCustomMessage(this, appMessage, options);\n\t};\n\t// Event hooks may await non-triggering writes while protected input awaits the\n\t// event writer. Those local writes must not queue behind that external input.\n\tconst deliver = () =>\n\t\tboundary && options?.triggerTurn === true ? boundary.serializeMessageDelivery(commit) : commit();\n\tif (boundary === undefined) return deliver();\n\tawait boundary.admit(options?.stageAdmissionKey, deliver, () => {\n\t\tif (this._subagentMessageAdmission) throw new Error(\"Subagent execution is terminal and cannot accept messages\");\n\t\tconst router = this._orchestrationContext?.lateMessageRouter;\n\t\tif (router === undefined) throw new Error(\"Workflow stage closed without a late-message router\");\n\t\treturn router.routeMessage(message, options);\n\t}).completion;\n}\n\n/** Atomically admits a custom-message batch in array order. */\nexport async function sendCustomMessages<T = unknown>(\n\tthis: AgentSession,\n\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\toptions?: SendMessagesOptions,\n): Promise<void> {\n\tconst currentOwner = resolveWorkflowStageDeliveryTarget(this);\n\tif (currentOwner !== this) return currentOwner.sendCustomMessages(messages, options);\n\tassertSessionOpen(this);\n\treturn deliveredMessageTurn(this, () => admittedCustomMessages.call(this, messages, options));\n}\n\nasync function admittedCustomMessages<T>(\n\tthis: AgentSession,\n\tmessages: Array<Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">>,\n\toptions?: SendMessagesOptions,\n): Promise<void> {\n\tconst lifetime = sessionLifetime(this);\n\tconst timestamp = Date.now();\n\tconst appMessages = messages.map(\n\t\t(message) =>\n\t\t\t({\n\t\t\t\trole: \"custom\" as const,\n\t\t\t\tcustomType: message.customType,\n\t\t\t\tcontent: message.content ?? [],\n\t\t\t\tdisplay: message.display,\n\t\t\t\tdetails: message.details,\n\t\t\t\ttimestamp,\n\t\t\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t\t\t\t...(options?.stageAdmissionKey === undefined ? {} : { stageAdmissionKey: options.stageAdmissionKey }),\n\t\t\t}) satisfies CustomMessage<T> & { stageAdmissionKey?: string },\n\t);\n\tif (appMessages.length === 0) return;\n\tconst boundary = this._subagentMessageAdmission ?? this._workflowStageAdmission;\n\tconst commit = async (): Promise<void> => {\n\t\tif (boundary && options?.stageAdmissionBarrier) await options.stageAdmissionBarrier();\n\t\tassertSessionOpen(this);\n\t\tif (lifetime.aborted) throw Object.assign(new Error(\"Session is closed\"), { code: \"SessionClosed\" });\n\t\tawait commitAdmittedCustomMessages(this, appMessages, options);\n\t};\n\tconst deliver = () =>\n\t\tboundary && options?.triggerTurn === true ? boundary.serializeMessageDelivery(commit) : commit();\n\tif (boundary === undefined) return deliver();\n\tawait boundary.admit(options?.stageAdmissionKey, deliver, () => {\n\t\tif (this._subagentMessageAdmission) throw new Error(\"Subagent execution is terminal and cannot accept messages\");\n\t\tconst router = this._orchestrationContext?.lateMessageRouter;\n\t\tif (router === undefined) throw new Error(\"Workflow stage closed without a late-message router\");\n\t\treturn router.routeMessages(messages, options);\n\t}).completion;\n}\n\nexport function sealWorkflowStageGeneration(this: AgentSession): void {\n\tthis._workflowStageAdmission?.seal();\n}\n\nexport async function closeWorkflowStageGeneration(this: AgentSession): Promise<void> {\n\tawait this._workflowStageAdmission?.close();\n\tawait this.agent?.waitForIdle?.();\n\tawait this._agentEventQueue;\n}\n\nexport async function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) {\n\t\tawait owner._appendCustomMessage(message);\n\t\treturn;\n\t}\n\tconst stageAdmissionMessage = message as StageAdmittedCustomMessage;\n\tconst entryId = await this.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t\tundefined,\n\t\tstageAdmissionMessage.stageAdmissionKey,\n\t);\n\tthis._entryIdsByMessage.set(message, entryId);\n\tthis._refreshFinalizedContext();\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\nconst pendingCustomMessageDrains = new WeakMap<AgentSession, Promise<void>>();\n\n/** Append context-only custom messages once the current turn's tool results are in history. */\nexport function _flushPendingCustomMessages(this: AgentSession): Promise<void> {\n\tconst pending = pendingCustomMessageDrains.get(this);\n\tif (pending) return pending;\n\tif (this._pendingCustomMessages.length === 0) return Promise.resolve();\n\n\tconst drain = (async () => {\n\t\twhile (this._pendingCustomMessages.length > 0) {\n\t\t\tawait this._appendCustomMessage(this._pendingCustomMessages[0]);\n\t\t\tthis._pendingCustomMessages.shift();\n\t\t}\n\t})();\n\tpendingCustomMessageDrains.set(this, drain);\n\tvoid drain.then(\n\t\t() => pendingCustomMessageDrains.delete(this),\n\t\t() => pendingCustomMessageDrains.delete(this),\n\t);\n\treturn drain;\n}\nexport function _enqueueInterruptCustomMessage<T>(\n\tthis: AgentSession,\n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._enqueueInterruptCustomMessage(message, forwardedMessageOptions(options));\n\tassertSessionOpen(this);\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = trackSessionWork(this, () =>\n\t\tthis._interruptDeliveryQueue.then(async () => {\n\t\t\ttry {\n\t\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t\t} finally {\n\t\t\t\t// Retirement moves the pending count and hold synchronously. Settle the\n\t\t\t\t// same live owner so its queue cannot remain stranded on the replacement.\n\t\t\t\tconst liveOwner = resolveWorkflowStageDeliveryTarget(this);\n\t\t\t\tliveOwner._pendingInterruptDeliveries -= 1;\n\t\t\t\tif (liveOwner._pendingInterruptDeliveries === 0) {\n\t\t\t\t\tliveOwner._restoreAndClearActiveInterruptQueueHold();\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t);\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\nasync function sendInterruptCustomMessageUnlocked<T>(\n\tsession: AgentSession,\n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tassertSessionOpen(session);\n\tconst lifetime = sessionLifetime(session);\n\tsession.abortRetry();\n\tsession._ensureActiveInterruptQueueHold();\n\tawait waitForCustomMessagePreparation(session);\n\tif (session.isStreaming || session._isPreparingRun) {\n\t\tconst previousAbortMessage = session._activeInterruptAbortMessage;\n\t\tsession._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tsession.agent.abort();\n\t\t\tawait session.agent.waitForIdle();\n\t\t\tawait session._agentEventQueue;\n\t\t} finally {\n\t\t\tsession._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tconst owner = resolveWorkflowStageDeliveryTarget(session);\n\tif (owner !== session) return owner._sendInterruptCustomMessageNow(message, forwardedMessageOptions(options));\n\tassertSessionOpen(session);\n\tif (lifetime.aborted) throw Object.assign(new Error(\"Session is closed\"), { code: \"SessionClosed\" });\n\tif (session._queuedMessagesPaused) {\n\t\tsession._queueAgentMessage(message, \"steer\");\n\t\treturn;\n\t}\n\tawait session.agent.prompt(message);\n}\n\nexport function _sendInterruptCustomMessageNow<T>(\n\tthis: AgentSession,\n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._sendInterruptCustomMessageNow(message, forwardedMessageOptions(options));\n\treturn serializeInterruptMutation(this, () => sendInterruptCustomMessageUnlocked(this, message, options));\n}\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner._ensureActiveInterruptQueueHold();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) {\n\t\towner._restoreAndClearActiveInterruptQueueHold();\n\t\treturn;\n\t}\n\tif (this._queuedMessagesPaused) return;\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) return;\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\nexport function _queueAgentMessage(\n\tthis: AgentSession,\n\tmessage: AgentMessage,\n\tdelivery: \"steer\" | \"followUp\" | \"interrupt\",\n): void {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) {\n\t\towner._queueAgentMessage(message, delivery);\n\t\treturn;\n\t}\n\tconst hold = delivery === \"interrupt\" ? this._ensureActiveInterruptQueueHold() : this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else if (delivery === \"interrupt\") {\n\t\t\tconst index = priorityHoldCounts.get(hold) ?? 0;\n\t\t\thold.steering.splice(index, 0, message);\n\t\t\tpriorityHoldCounts.set(hold, index + 1);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t} else if (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n\tconst yieldReason = message.role === \"user\" ? \"input-needed\" : \"intercom-coordination\";\n\tthis._agentTaskHost?.yieldTaskWaits(yieldReason);\n\tthis._childTaskWaits.yieldAll(yieldReason);\n}\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupt and pause holds prevent an aborting run from consuming queued raw\n\t// messages while preserving every entry for the existing resume boundary.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n/**\n * Clear queued text for editor restoration while retaining optional raw custom entries.\n */\nexport function clearQueue(\n\tthis: AgentSession,\n\toptions?: ClearQueueOptions,\n): { steering: string[]; followUp: string[] } {\n\tconst owner = resolveWorkflowStageDeliveryTarget(this);\n\tif (owner !== this) return owner.clearQueue(options);\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tconst removed = this._drainQueuedAgentMessages();\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tremoved.steering.push(...hold.steering.splice(0));\n\t\tremoved.followUp.push(...hold.followUp.splice(0));\n\t\tpriorityHoldCounts.delete(hold);\n\t}\n\trestoreProtectedStreamingCustomMessages(this, removed);\n\tif (options?.preserveUnprotectedCustomMessages && hold !== undefined) {\n\t\tconst restoreUnprotectedCustomMessages = (\n\t\t\tremovedMessages: AgentMessage[],\n\t\t\theldMessages: AgentMessage[],\n\t\t): void => {\n\t\t\tconst currentlyHeld = [...heldMessages];\n\t\t\tconst preserved = removedMessages.filter(\n\t\t\t\t(message): message is Extract<AgentMessage, { role: \"custom\" }> =>\n\t\t\t\t\tmessage.role === \"custom\" && !isProtectedStreamingCustomMessage(this, message),\n\t\t\t);\n\t\t\tif (preserved.length === 0) return;\n\t\t\tconst preservedReferences = new Set<AgentMessage>(preserved);\n\t\t\tconst restoredProtected = new Set(currentlyHeld);\n\t\t\tconst ordered = removedMessages.filter(\n\t\t\t\t(message) => preservedReferences.has(message) || restoredProtected.has(message),\n\t\t\t);\n\t\t\tconst unmatched = currentlyHeld.filter((message) => !ordered.includes(message));\n\t\t\theldMessages.splice(0, heldMessages.length, ...ordered, ...unmatched);\n\t\t};\n\t\trestoreUnprotectedCustomMessages(removed.steering, hold.steering);\n\t\trestoreUnprotectedCustomMessages(removed.followUp, hold.followUp);\n\t}\n\tif (\n\t\t!this._queuedMessagesPaused &&\n\t\tthis._pendingInterruptDeliveries === 0 &&\n\t\thold !== undefined &&\n\t\thold.steering.length === 0 &&\n\t\thold.followUp.length === 0\n\t) {\n\t\tthis._activeInterruptQueueHold = undefined;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tsettingsWriteOwner.run(this, () => this.settingsManager.setSteeringMode(mode));\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tsettingsWriteOwner.run(this, () => this.settingsManager.setFollowUpMode(mode));\n}\n\n// =========================================================================\n// Queue and delivery settings\n// =========================================================================\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\ttransferWorkflowStageDeliveriesTo,\n\tsealWorkflowStageGeneration,\n\tsendCustomMessage,\n\tsendCustomMessages,\n\tcloseWorkflowStageGeneration,\n\t_appendCustomMessage,\n\t_flushPendingCustomMessages,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\tpauseQueuedMessages,\n\tresumeQueuedMessages,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-session-prompt.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-prompt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIlE,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAOzG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-session-prompt.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-prompt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,O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,EAAE,EAChD,OAAO,CAAC,EAAE;IACT,SAAS,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IACjC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,kBAAkB,CAAC,EAAE,iCAAiC,CAAC,oBAAoB,CAAC,CAAC;CAC7E,GACC,OAAO,CAAC,IAAI,CAAC,CAoCf;AAED;;;;GAIG;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;CAUrC,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage, formatUnresol
|
|
|
6
6
|
import { runCallback } from "./callback-activity.js";
|
|
7
7
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
8
8
|
import { reserveQueuedInputAdmission, runInputHook, UNORDERED_ADMISSION, } from "./queued-input-admission.js";
|
|
9
|
+
import { currentResourceAdmission, withOwnResourceAdmission } from "./resource-admission-scope.js";
|
|
9
10
|
import { assertSessionOpen, sessionGenerationClosing, sessionLifetime, sessionQuitSignal, trackSessionWork, } from "./session-lifecycle-work.js";
|
|
10
11
|
import { getSkillCatalog } from "./skill-catalog.js";
|
|
11
12
|
const customPreparations = new WeakMap();
|
|
@@ -67,11 +68,19 @@ export async function prompt(text, options) {
|
|
|
67
68
|
return owner.prompt(text, options);
|
|
68
69
|
if (this._isEmittingAgentSettled && !queuesDuringAgentSettled(this, options)) {
|
|
69
70
|
// A run started by an agent_settled handler waits until every settled handler completes.
|
|
70
|
-
this
|
|
71
|
+
deferSettledAction(this, async () => await this.prompt(text, options));
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
return trackSessionWork(this, () => admittedPrompt.call(this, text, options));
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Defer `action` until the settling run has settled. It runs under the resource admission its requester ran under,
|
|
78
|
+
* not the settling run's: a turn a delivered message requests keeps the receiving session's own admission.
|
|
79
|
+
*/
|
|
80
|
+
function deferSettledAction(session, action) {
|
|
81
|
+
const admission = currentResourceAdmission();
|
|
82
|
+
session._deferredSettledActions.push(() => withOwnResourceAdmission(admission, action));
|
|
83
|
+
}
|
|
75
84
|
function queuesDuringAgentSettled(session, options) {
|
|
76
85
|
return session._isEmittingAgentSettled && options?.streamingBehavior !== undefined && options.source !== "extension";
|
|
77
86
|
}
|
|
@@ -353,7 +362,7 @@ export async function _runAgentPrompt(messages, promptStarted, reportDispatch, p
|
|
|
353
362
|
return owner._runAgentPrompt(messages, promptStarted, reportDispatch, prepared, customStarter);
|
|
354
363
|
}
|
|
355
364
|
if (this._isEmittingAgentSettled) {
|
|
356
|
-
this
|
|
365
|
+
deferSettledAction(this, () => this._runAgentPrompt(messages, promptStarted, reportDispatch, prepared, customStarter));
|
|
357
366
|
return;
|
|
358
367
|
}
|
|
359
368
|
// Any run that starts ends the gap before a fresh stage's first prompt (#3919).
|
|
@@ -852,7 +861,7 @@ export function deliverQueuedInputIfIdle(session, options) {
|
|
|
852
861
|
await runQueuedInput(session).catch(() => { });
|
|
853
862
|
};
|
|
854
863
|
if (session._isEmittingAgentSettled || openRuns.has(session))
|
|
855
|
-
session
|
|
864
|
+
deferSettledAction(session, deliver);
|
|
856
865
|
else if (session._activePromptCount === 0)
|
|
857
866
|
void deliver();
|
|
858
867
|
}
|
|
@@ -917,14 +926,16 @@ export async function sendUserMessage(content, options) {
|
|
|
917
926
|
// prompt() owns command dispatch and template expansion; the default (false)
|
|
918
927
|
// keeps every pre-existing caller sending literally. The private delivery hook
|
|
919
928
|
// lets workflow routing report and gate the branch selected after asynchronous
|
|
920
|
-
// input/compaction extension preflight.
|
|
921
|
-
|
|
929
|
+
// input/compaction extension preflight. A delivered message starts this session's
|
|
930
|
+
// turn, so the turn runs under this session's own resource admission, never under
|
|
931
|
+
// the scope its sender runs in, such as a workflow run's.
|
|
932
|
+
await withOwnResourceAdmission(this._resourceAdmission, () => this.prompt(text, {
|
|
922
933
|
expandPromptTemplates: options?.expandPromptTemplates ?? false,
|
|
923
934
|
streamingBehavior: options?.deliverAs,
|
|
924
935
|
images,
|
|
925
936
|
source: "extension",
|
|
926
937
|
__workflowDelivery: options?.__workflowDelivery,
|
|
927
|
-
});
|
|
938
|
+
}));
|
|
928
939
|
}
|
|
929
940
|
/**
|
|
930
941
|
* Clear all queued messages and return them.
|