@sema-agent/client-core 0.98.0 → 0.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +376 -0
- package/README.md +61 -35
- package/dist/adapt/arms.js +120 -55
- package/dist/adapt/panelTasks.d.ts +3 -2
- package/dist/adapt/panelTasks.js +34 -11
- package/dist/adapt/textStream.d.ts +1 -1
- package/dist/adapt/textStream.js +51 -28
- package/dist/adapter/activeRunSelfHeal.d.ts +11 -3
- package/dist/adapter/activeRunSelfHeal.js +210 -294
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +176 -12
- package/dist/adapter/downstream/terminalToSdkResult.js +10 -0
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/adapter/runStream.js +82 -40
- package/dist/adapter/types.d.ts +2 -0
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +7 -3
- package/dist/agentsWireCaps.js +133 -39
- package/dist/cloudConfigWireCaps.d.ts +10 -1
- package/dist/cloudConfigWireCaps.js +181 -65
- package/dist/compactionStatus.d.ts +34 -0
- package/dist/compactionStatus.js +196 -0
- package/dist/controlRouter.d.ts +4 -2
- package/dist/controlRouter.js +39 -51
- package/dist/coreValuePorts.d.ts +26 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/decideFailureNote.js +3 -3
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/detachWire.js +3 -2
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +153 -5
- package/dist/engineAgentPanelStore.d.ts +14 -4
- package/dist/engineAgentPanelStore.js +14 -0
- package/dist/engineCapReader.d.ts +2 -1
- package/dist/engineCapReader.js +7 -5
- package/dist/engineCapsCache.d.ts +8 -0
- package/dist/engineCapsCache.js +59 -6
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineErrorCodes.d.ts +11 -2
- package/dist/engineErrorCodes.js +11 -12
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.d.ts +1 -0
- package/dist/engineSessionMessages.js +7 -1
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineToolDirectory.d.ts +3 -0
- package/dist/engineToolDirectory.js +4 -2
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +2 -1
- package/dist/env/uiLanguage.js +3 -2
- package/dist/eventLeg.d.ts +7 -5
- package/dist/eventLeg.js +68 -49
- package/dist/fileHistoryCaptureCapability.d.ts +2 -4
- package/dist/fileHistoryCaptureCapability.js +12 -22
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/frameBinding.d.ts +3 -0
- package/dist/frameBinding.js +12 -0
- package/dist/gateOutcome.js +16 -2
- package/dist/gateVocabulary.d.ts +8 -7
- package/dist/gateVocabulary.js +71 -73
- package/dist/generated/engineFactTables.d.ts +18 -1
- package/dist/generated/engineFactTables.js +56 -0
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/settingsSchemaFns.d.ts +18 -0
- package/dist/generated/settingsSchemaFns.js +70 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.js +162 -0
- package/dist/generated/settingsSchemaTables.d.ts +2 -0
- package/dist/generated/settingsSchemaTables.js +9 -0
- package/dist/generated/settingsSchemaTypes.d.ts +133 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +2 -1
- package/dist/hitl/allowRuleShadow.js +18 -15
- package/dist/hitl/approvalCardReasons.d.ts +3 -2
- package/dist/hitl/approvalCardReasons.js +29 -30
- package/dist/hitl/approvalHolds.d.ts +17 -0
- package/dist/hitl/approvalHolds.js +114 -29
- package/dist/hitl/askClassPair.d.ts +2 -2
- package/dist/hitl/askClassPair.js +16 -0
- package/dist/hitl/askGateWire.js +2 -1
- package/dist/hitl/askSettlementLine.d.ts +14 -4
- package/dist/hitl/askSettlementLine.js +67 -47
- package/dist/hitl/attributionLadder.d.ts +23 -0
- package/dist/hitl/attributionLadder.js +67 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +2 -1
- package/dist/hitl/automaticAnswerVerdict.js +8 -8
- package/dist/hitl/crashConvergedNotice.d.ts +5 -4
- package/dist/hitl/crashConvergedNotice.js +28 -41
- package/dist/hitl/decisionLedger.d.ts +55 -0
- package/dist/hitl/decisionLedger.js +156 -0
- package/dist/hitl/decisionRefusal.d.ts +1 -0
- package/dist/hitl/decisionRefusal.js +1 -1
- package/dist/hitl/decisionSend.d.ts +113 -0
- package/dist/hitl/decisionSend.js +579 -0
- package/dist/hitl/frameRouter.js +7 -8
- package/dist/hitl/hitlBridge.d.ts +1 -0
- package/dist/hitl/hitlBridge.js +21 -9
- package/dist/hitl/persistedRulesWire.d.ts +6 -5
- package/dist/hitl/persistedRulesWire.js +55 -73
- package/dist/hitl/planReviewWire.d.ts +5 -0
- package/dist/hitl/planReviewWire.js +53 -76
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +49 -9
- package/dist/hitl/sessionPolicyWire.d.ts +2 -1
- package/dist/hitl/sessionPolicyWire.js +23 -24
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +17 -5
- package/dist/hitl/toolApprovalWire.js +120 -147
- package/dist/hooksWireCaps.js +145 -56
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +110 -0
- package/dist/hostTurnSettings.js +692 -0
- package/dist/humanTurn.d.ts +15 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +713 -0
- package/dist/i18n/messages.en.js +713 -0
- package/dist/i18n/messages.zh.js +854 -1
- package/dist/index.d.ts +45 -13
- package/dist/index.js +27 -9
- package/dist/inheritEnvCapability.d.ts +4 -2
- package/dist/inheritEnvCapability.js +12 -5
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +14 -16
- package/dist/injectionLaneNotice.d.ts +5 -0
- package/dist/injectionLaneNotice.js +46 -0
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +2 -1
- package/dist/liveModelCatalog.js +14 -8
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +42 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +3 -1
- package/dist/mcpProbeWire.js +5 -0
- package/dist/mcpReconnect.js +2 -2
- package/dist/mcpToolToggles.d.ts +6 -0
- package/dist/mcpToolToggles.js +46 -0
- package/dist/mcpWireCaps.d.ts +43 -3
- package/dist/mcpWireCaps.js +194 -59
- package/dist/mcpWireTransport.d.ts +4 -0
- package/dist/mcpWireTransport.js +18 -0
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +65 -0
- package/dist/modelCapabilityProbe.js +601 -0
- package/dist/modelIdentityResolvability.d.ts +5 -0
- package/dist/modelIdentityResolvability.js +49 -22
- package/dist/ownKey.d.ts +33 -0
- package/dist/ownKey.js +109 -0
- package/dist/panelReduce.d.ts +11 -1
- package/dist/panelReduce.js +95 -16
- package/dist/panelStateHolder.d.ts +1 -0
- package/dist/panelStateHolder.js +10 -1
- package/dist/permissionRuleIssue.d.ts +2 -1
- package/dist/permissionRuleIssue.js +23 -20
- package/dist/permissionRulesWriteCapability.d.ts +2 -1
- package/dist/permissionRulesWriteCapability.js +8 -6
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +220 -12
- package/dist/prepareRefusal.d.ts +8 -0
- package/dist/prepareRefusal.js +72 -0
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/request/taskRequest.d.ts +16 -10
- package/dist/request/taskRequest.js +195 -58
- package/dist/resumeRefusalCopy.d.ts +14 -9
- package/dist/resumeRefusalCopy.js +89 -144
- package/dist/retryStatus.d.ts +55 -0
- package/dist/retryStatus.js +155 -19
- package/dist/ruleRefusalSentence.d.ts +4 -0
- package/dist/ruleRefusalSentence.js +58 -0
- package/dist/sandboxWire.d.ts +2 -1
- package/dist/sandboxWire.js +55 -21
- package/dist/scenarioRefusal.d.ts +10 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/seam.d.ts +48 -9
- package/dist/seam.js +54 -5
- package/dist/seatContract.d.ts +272 -14
- package/dist/seatContract.js +711 -23
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -1
- package/dist/sessionPolicyCapability.js +8 -6
- package/dist/settingsCredentialKeyPaths.d.ts +8 -0
- package/dist/settingsCredentialKeyPaths.js +219 -0
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -1
- package/dist/skillToolListsCapability.js +8 -6
- package/dist/skillsWireCaps.d.ts +0 -3
- package/dist/skillsWireCaps.js +1 -2
- package/dist/sseIdleTriage.js +3 -2
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagentContentStore.d.ts +4 -0
- package/dist/subagentContentStore.js +157 -27
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolRoster.d.ts +3 -2
- package/dist/toolRoster.js +21 -20
- package/dist/toolsFlagNames.d.ts +8 -0
- package/dist/toolsFlagNames.js +110 -0
- package/dist/turnFailurePresentation.d.ts +12 -1
- package/dist/turnFailurePresentation.js +220 -15
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -1
- package/dist/userInvokedSkillsCapability.js +31 -7
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +23 -1
- package/dist/wireFailureShape.js +2 -1
- package/dist/wireRefusalCopy.d.ts +62 -16
- package/dist/wireRefusalCopy.js +307 -148
- package/dist/workflowsJournalCapability.d.ts +2 -1
- package/dist/workflowsJournalCapability.js +8 -6
- package/docs/INTEGRATION-CLIENTS.md +951 -42
- package/package.json +5 -5
package/dist/adapt/arms.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../gateOutcome.js';
|
|
2
|
+
import { terminalOwnerOf } from '../seam.js';
|
|
2
3
|
import { isSubFlowSegmentEnd, SEGMENT_END_IDENTITY_KEYS, snapshotSegmentIdentity, snapshotIsSubFlow } from '../adapter/types.js';
|
|
3
4
|
import { classifyPeerNotification, renderPeerFrameTranscriptText } from '../peerFrames.js';
|
|
4
5
|
import { dropQueuedNotificationsForRun, isEngineWorkflowNotified, isWorkflowCompletionCardEnqueued, markEngineWorkflowNotified, noteOwnWorkflowRun, normalizeTaskNotification, noteWorkflowCompletionCardEnqueued, renderTaskNotificationXml, taskNotificationDedupKey } from '../notifications.js';
|
|
5
|
-
import {
|
|
6
|
+
import { retryStatusFromArm } from '../retryStatus.js';
|
|
6
7
|
import { steeringInjectedToAttachments } from '../steering.js';
|
|
7
8
|
import { projectDiagnosticsFrame } from '../diagnostics.js';
|
|
8
9
|
import { recordEngineToolLabel } from '../engineToolLabelStore.js';
|
|
@@ -12,9 +13,11 @@ import { recordWorkflowAgentTaskId } from '../workflow.js';
|
|
|
12
13
|
import { isCoreTaskNotificationTerminal, isCoreTaskNotificationTerminalNotSuccess, isCoreTaskProgressTerminal, isCoreTaskProgressTerminalNotSuccess } from '../terminalStatuses.js';
|
|
13
14
|
import { readToolHistoryMismatchKey } from '../toolHistoryMismatch.js';
|
|
14
15
|
import { readProviderRejectionResendKey } from '../providerRejection.js';
|
|
15
|
-
import { contextUsageReadingOf, guardedRead, readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
|
|
16
|
-
import {
|
|
16
|
+
import { contextUsageReadingOf, guardedRead, humanInputAttachmentsOf, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
|
|
17
|
+
import { CORE_USER_ATTACHMENT_LABEL_MAX } from '../generated/engineFactTables.js';
|
|
18
|
+
import { ESCAPE_FACE, paintAndCap, washCredentials } from '../displayUntrusted.js';
|
|
17
19
|
import { resolveEnginePanelTaskId } from '../engineAgentPanelStore.js';
|
|
20
|
+
import { cycleSeqValue } from '../cycleOrder.js';
|
|
18
21
|
import { fleetRowAgentType } from '../fleet/fleetRowAgentType.js';
|
|
19
22
|
import { chrome, mainLane, transcript, messageIdentityOf } from './ids.js';
|
|
20
23
|
import { engineRefOf } from '../engineRowRef.js';
|
|
@@ -22,27 +25,6 @@ import { isReplayMarked, RESULT_REPLAYED_TEXT } from '../replayBody.js';
|
|
|
22
25
|
import { wiringManifestViewOf } from '../adapter/downstream/wiringManifestView.js';
|
|
23
26
|
import { isUnsettledHeldToolEnd } from '../engineRowRef.js';
|
|
24
27
|
import { CANCEL_MESSAGE, decisionOf, flattenWireOutput, REJECT_MESSAGE, sanitizeToolUseBlock, shortTaskLabel, TASK_TOOL_NAMES, WORKFLOW_TOOL_NAMES, } from './wireShapes.js';
|
|
25
|
-
function hostOwnString(o, key) {
|
|
26
|
-
return readFrameStringKey(o, key);
|
|
27
|
-
}
|
|
28
|
-
function continuesParkDeclarationOf(ctx) {
|
|
29
|
-
const decl = guardedRead(() => ctx.continuesPark);
|
|
30
|
-
return typeof decl === 'object' && decl !== null ? decl : undefined;
|
|
31
|
-
}
|
|
32
|
-
function continuesParkWitness(ctx, row) {
|
|
33
|
-
const decl = continuesParkDeclarationOf(ctx);
|
|
34
|
-
if (decl === undefined)
|
|
35
|
-
return false;
|
|
36
|
-
if (hostOwnString(decl, 'toolCallId') !== row.toolCallId)
|
|
37
|
-
return false;
|
|
38
|
-
const cp = hostOwnString(decl, 'checkpointId');
|
|
39
|
-
if (cp !== undefined && row.checkpointId !== undefined && cp !== row.checkpointId)
|
|
40
|
-
return false;
|
|
41
|
-
const parkedTaskId = hostOwnString(decl, 'parkedTaskId');
|
|
42
|
-
if (parkedTaskId !== undefined && row.parkedRun !== undefined && parkedTaskId !== row.parkedRun)
|
|
43
|
-
return false;
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
28
|
function claimParkedCard(m, callId, toolName, deps) {
|
|
47
29
|
const { ctx, cards, inst, pass } = deps;
|
|
48
30
|
if (cards.has(callId))
|
|
@@ -56,12 +38,11 @@ function claimParkedCard(m, callId, toolName, deps) {
|
|
|
56
38
|
return undefined;
|
|
57
39
|
const frameRun = engineRefOf(m)?.taskId;
|
|
58
40
|
if (frameRun !== undefined) {
|
|
59
|
-
const
|
|
60
|
-
const allowed = [row.parkedRun, row.card.engineRef?.taskId, readFrameStringKey(decl, 'parkedTaskId'), readFrameStringKey(decl, 'continuationTaskId')].filter((x) => x !== undefined);
|
|
41
|
+
const allowed = [row.parkedRun, row.card.engineRef?.taskId].filter((x) => x !== undefined);
|
|
61
42
|
if (allowed.length > 0 && !allowed.includes(frameRun))
|
|
62
43
|
return undefined;
|
|
63
44
|
}
|
|
64
|
-
if (row.pass !== pass
|
|
45
|
+
if (row.pass !== pass)
|
|
65
46
|
return undefined;
|
|
66
47
|
inst.dropParkedToolRow(row.key);
|
|
67
48
|
return row.card;
|
|
@@ -69,6 +50,12 @@ function claimParkedCard(m, callId, toolName, deps) {
|
|
|
69
50
|
function laneOfCard(p) {
|
|
70
51
|
return p.parentToolCallId !== undefined && p.parentToolCallId !== '' ? { lane: 'subagent', parentToolCallId: p.parentToolCallId } : mainLane();
|
|
71
52
|
}
|
|
53
|
+
function terminalOwnerCarry(m) {
|
|
54
|
+
if (m._sema_api_error_message !== true)
|
|
55
|
+
return {};
|
|
56
|
+
const owner = terminalOwnerOf(m);
|
|
57
|
+
return owner === undefined ? {} : { _sema_terminal_owner: owner };
|
|
58
|
+
}
|
|
72
59
|
function toolHistoryKeyCarry(m) {
|
|
73
60
|
if (m._sema_api_error_message !== true)
|
|
74
61
|
return {};
|
|
@@ -188,7 +175,7 @@ const assistantArm = function* (m, deps) {
|
|
|
188
175
|
}
|
|
189
176
|
const textBlock = blocks.find(b => b?.type === 'text');
|
|
190
177
|
const thinkingBlock = blocks.find(b => b?.type === 'thinking');
|
|
191
|
-
if (
|
|
178
|
+
if (textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0)
|
|
192
179
|
text.anchorWindow(m);
|
|
193
180
|
if (textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0) {
|
|
194
181
|
const rowText = m._sema_api_error_message === true ? washCredentials(textBlock.text) : textBlock.text;
|
|
@@ -204,6 +191,7 @@ const assistantArm = function* (m, deps) {
|
|
|
204
191
|
...(m._sema_api_error_message === true ? { _sema_api_error_message: true } : {}),
|
|
205
192
|
...toolHistoryKeyCarry(m),
|
|
206
193
|
...providerResendKeyCarry(m),
|
|
194
|
+
...terminalOwnerCarry(m),
|
|
207
195
|
}, ctx.now());
|
|
208
196
|
text.markEmittedText(rowText);
|
|
209
197
|
}
|
|
@@ -310,8 +298,15 @@ const humanInputArm = function* (m) {
|
|
|
310
298
|
...(actor !== undefined && Object.keys(actor).length > 0 ? { actor } : {}),
|
|
311
299
|
...(str(m.entryId) !== undefined ? { entryId: str(m.entryId) } : {}),
|
|
312
300
|
...(str(m.eventId) !== undefined ? { eventId: str(m.eventId) } : {}),
|
|
301
|
+
...humanInputAttachmentsForChrome(m),
|
|
313
302
|
});
|
|
314
303
|
};
|
|
304
|
+
function humanInputAttachmentsForChrome(m) {
|
|
305
|
+
const rows = humanInputAttachmentsOf(m);
|
|
306
|
+
if (rows === undefined)
|
|
307
|
+
return {};
|
|
308
|
+
return { attachments: rows.map((r) => (r.label !== undefined ? { ...r, label: paintAndCap(r.label, ESCAPE_FACE, CORE_USER_ATTACHMENT_LABEL_MAX) } : r)) };
|
|
309
|
+
}
|
|
315
310
|
const messageCommittedArm = function* (m) {
|
|
316
311
|
if (typeof m.parentToolCallId === 'string')
|
|
317
312
|
return;
|
|
@@ -449,12 +444,86 @@ const compactionOutcomeArm = function* (m) {
|
|
|
449
444
|
const trigger = str(m.trigger);
|
|
450
445
|
const reason = str(m.reason);
|
|
451
446
|
const eventId = str(idSnap.eventId);
|
|
447
|
+
const pass = str(m.pass);
|
|
452
448
|
yield chrome({
|
|
453
449
|
kind: 'compaction_outcome',
|
|
454
450
|
laneProof,
|
|
455
451
|
outcome,
|
|
456
452
|
...(trigger !== undefined ? { trigger } : {}),
|
|
457
453
|
...(reason !== undefined ? { reason } : {}),
|
|
454
|
+
...(pass !== undefined ? { pass } : {}),
|
|
455
|
+
...(eventId !== undefined ? { eventId } : {}),
|
|
456
|
+
});
|
|
457
|
+
};
|
|
458
|
+
const compactionStartedArm = function* (m) {
|
|
459
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
460
|
+
const pass = str(m.pass);
|
|
461
|
+
const trigger = str(m.trigger);
|
|
462
|
+
if (pass === undefined || trigger === undefined)
|
|
463
|
+
return;
|
|
464
|
+
const idSnap = snapshotSegmentIdentity(m);
|
|
465
|
+
if (idSnap === null)
|
|
466
|
+
return;
|
|
467
|
+
let laneProof = mainLane();
|
|
468
|
+
if (snapshotIsSubFlow(idSnap)) {
|
|
469
|
+
const parent = str(idSnap.parentToolCallId);
|
|
470
|
+
if (parent === undefined)
|
|
471
|
+
return;
|
|
472
|
+
laneProof = { lane: 'subagent', parentToolCallId: parent };
|
|
473
|
+
}
|
|
474
|
+
const startedAt = typeof m.startedAt === 'number' && Number.isFinite(m.startedAt) ? m.startedAt : undefined;
|
|
475
|
+
const eventId = str(idSnap.eventId);
|
|
476
|
+
yield chrome({
|
|
477
|
+
kind: 'compaction_started',
|
|
478
|
+
laneProof,
|
|
479
|
+
pass,
|
|
480
|
+
trigger,
|
|
481
|
+
...(startedAt !== undefined ? { startedAt } : {}),
|
|
482
|
+
...(eventId !== undefined ? { eventId } : {}),
|
|
483
|
+
});
|
|
484
|
+
};
|
|
485
|
+
const taskStartedArm = function* (m) {
|
|
486
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
487
|
+
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
|
|
488
|
+
const taskId = str(m.taskId);
|
|
489
|
+
if (taskId === undefined)
|
|
490
|
+
return;
|
|
491
|
+
const idSnap = snapshotSegmentIdentity(m);
|
|
492
|
+
if (idSnap === null)
|
|
493
|
+
return;
|
|
494
|
+
const parent = str(idSnap.parentToolCallId);
|
|
495
|
+
const laneProof = parent !== undefined ? { lane: 'subagent', parentToolCallId: parent } : mainLane();
|
|
496
|
+
const sessionId = str(m.sessionId);
|
|
497
|
+
const model = str(m.model);
|
|
498
|
+
const taskType = str(m.taskType);
|
|
499
|
+
const seq = num(m.seq);
|
|
500
|
+
const workflowRunId = str(m.workflowRunId);
|
|
501
|
+
const workflowAgentLabel = str(m.workflowAgentLabel);
|
|
502
|
+
const parentTaskId = str(m.parentTaskId);
|
|
503
|
+
const parentSessionId = str(m.parentSessionId);
|
|
504
|
+
const rootSessionId = str(m.rootSessionId);
|
|
505
|
+
const name = str(m.name);
|
|
506
|
+
const spawnName = str(m.spawnName);
|
|
507
|
+
const agentType = str(m.agentType);
|
|
508
|
+
const startedAt = num(m.startedAt);
|
|
509
|
+
const eventId = str(idSnap.eventId);
|
|
510
|
+
yield chrome({
|
|
511
|
+
kind: 'subagent_started',
|
|
512
|
+
laneProof,
|
|
513
|
+
taskId,
|
|
514
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
515
|
+
...(model !== undefined ? { model } : {}),
|
|
516
|
+
...(taskType !== undefined ? { taskType } : {}),
|
|
517
|
+
...(seq !== undefined ? { seq } : {}),
|
|
518
|
+
...(workflowRunId !== undefined ? { workflowRunId } : {}),
|
|
519
|
+
...(workflowAgentLabel !== undefined ? { workflowAgentLabel } : {}),
|
|
520
|
+
...(parentTaskId !== undefined ? { parentTaskId } : {}),
|
|
521
|
+
...(parentSessionId !== undefined ? { parentSessionId } : {}),
|
|
522
|
+
...(rootSessionId !== undefined ? { rootSessionId } : {}),
|
|
523
|
+
...(name !== undefined ? { name } : {}),
|
|
524
|
+
...(spawnName !== undefined ? { spawnName } : {}),
|
|
525
|
+
...(agentType !== undefined ? { agentType } : {}),
|
|
526
|
+
...(startedAt !== undefined ? { startedAt } : {}),
|
|
458
527
|
...(eventId !== undefined ? { eventId } : {}),
|
|
459
528
|
});
|
|
460
529
|
};
|
|
@@ -480,14 +549,8 @@ const promptAssembledArm = function* (m) {
|
|
|
480
549
|
const chars = size(o.chars);
|
|
481
550
|
return id === undefined || chars === undefined ? undefined : { id, chars };
|
|
482
551
|
});
|
|
483
|
-
const sections = promptManifestRows(m.sections, (o) =>
|
|
484
|
-
|
|
485
|
-
const chars = size(o.chars);
|
|
486
|
-
if (id === undefined || chars === undefined)
|
|
487
|
-
return undefined;
|
|
488
|
-
const slot = str(o.slot);
|
|
489
|
-
return { id, chars, ...(slot !== undefined ? { slot } : {}) };
|
|
490
|
-
});
|
|
552
|
+
const sections = promptManifestRows(m.sections, (o) => promptManifestSectionViewOf(o));
|
|
553
|
+
const promptIdentity = promptManifestIdentityOfFrame(m);
|
|
491
554
|
const tools = promptManifestRows(m.tools, (o) => {
|
|
492
555
|
const wireName = str(o.wireName);
|
|
493
556
|
return wireName === undefined ? undefined : { wireName };
|
|
@@ -514,6 +577,7 @@ const promptAssembledArm = function* (m) {
|
|
|
514
577
|
...(blocks !== undefined ? { blocks } : {}),
|
|
515
578
|
...(sections !== undefined ? { sections } : {}),
|
|
516
579
|
...(tools !== undefined ? { tools } : {}),
|
|
580
|
+
...(promptIdentity !== undefined ? { identity: promptIdentity } : {}),
|
|
517
581
|
...(eventId !== undefined ? { eventId } : {}),
|
|
518
582
|
});
|
|
519
583
|
};
|
|
@@ -523,6 +587,7 @@ const textSegmentEndArm = function* (m, { text }) {
|
|
|
523
587
|
const content = typeof m.content === 'string' ? m.content : '';
|
|
524
588
|
if (content.length === 0)
|
|
525
589
|
return;
|
|
590
|
+
text.anchorWindow(m);
|
|
526
591
|
const r = text.replaceAnswerSegment(content, m);
|
|
527
592
|
yield* text.drainLive();
|
|
528
593
|
yield chrome({
|
|
@@ -538,7 +603,7 @@ const textSegmentEndArm = function* (m, { text }) {
|
|
|
538
603
|
...(r.committedRows !== undefined ? { committedRows: r.committedRows } : {}),
|
|
539
604
|
...(typeof m.eventId === 'string' && m.eventId.length > 0 ? { eventId: m.eventId } : {}),
|
|
540
605
|
});
|
|
541
|
-
text.
|
|
606
|
+
yield* text.endSegment();
|
|
542
607
|
};
|
|
543
608
|
const thinkingSegmentEndArm = function* (m, { text }) {
|
|
544
609
|
if (isSubFlowSegmentEnd(m))
|
|
@@ -720,6 +785,15 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
|
|
|
720
785
|
}
|
|
721
786
|
panel.noteResidency(taskId, identity.taskId);
|
|
722
787
|
panel.markLive(taskId);
|
|
788
|
+
const cycleSeq = cycleSeqValue(m.seq);
|
|
789
|
+
panel.noteCycle(taskId, cycleSeq);
|
|
790
|
+
const finalUsage = {};
|
|
791
|
+
if (isCoreTaskProgressTerminal(m.status)) {
|
|
792
|
+
if (typeof usage.totalTokens === 'number' && Number.isFinite(usage.totalTokens))
|
|
793
|
+
finalUsage.totalTokens = true;
|
|
794
|
+
if (typeof usage.toolUses === 'number' && Number.isFinite(usage.toolUses))
|
|
795
|
+
finalUsage.toolUses = true;
|
|
796
|
+
}
|
|
723
797
|
yield chrome({
|
|
724
798
|
kind: 'panel_task',
|
|
725
799
|
laneProof: panel.laneOf(taskId),
|
|
@@ -735,11 +809,13 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
|
|
|
735
809
|
...(panel.isLiveBound(taskId) ? { cardBound: true } : {}),
|
|
736
810
|
toolUses: typeof usage.toolUses === 'number' ? usage.toolUses : 0,
|
|
737
811
|
totalTokens: typeof usage.totalTokens === 'number' ? usage.totalTokens : 0,
|
|
812
|
+
...(cycleSeq !== undefined ? { cycleSeq } : {}),
|
|
813
|
+
...(finalUsage.totalTokens === true || finalUsage.toolUses === true ? { final: finalUsage } : {}),
|
|
738
814
|
},
|
|
739
815
|
});
|
|
740
816
|
if (isCoreTaskProgressTerminal(m.status) && !panel.isLiveBound(taskId)) {
|
|
741
817
|
ctx.probe?.('tick', JSON.stringify({ t: ctx.now(), taskId, lane: 'foreground', settle: m.status }));
|
|
742
|
-
yield* panel.settleFromTerminalTick(taskId, isCoreTaskProgressTerminalNotSuccess(m.status));
|
|
818
|
+
yield* panel.settleFromTerminalTick(taskId, isCoreTaskProgressTerminalNotSuccess(m.status), cycleSeq);
|
|
743
819
|
}
|
|
744
820
|
};
|
|
745
821
|
const streamEventArm = function* (m, { text }) {
|
|
@@ -876,7 +952,8 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
876
952
|
});
|
|
877
953
|
dropQueuedNotificationsForRun(taskId);
|
|
878
954
|
if (n.task_type !== 'background_bash' && n.task_type !== 'monitor') {
|
|
879
|
-
|
|
955
|
+
const bgSessionId = n.task_type === 'background_agent' && typeof n.sessionId === 'string' && n.sessionId.length > 0 ? n.sessionId : undefined;
|
|
956
|
+
yield* panel.settleFromNotification(taskId, isCoreTaskNotificationTerminalNotSuccess(rawStatus), bgSessionId);
|
|
880
957
|
}
|
|
881
958
|
}
|
|
882
959
|
const peerFrame = classifyPeerNotification(n);
|
|
@@ -919,23 +996,9 @@ const workflowCompleteArm = function* (m) {
|
|
|
919
996
|
});
|
|
920
997
|
};
|
|
921
998
|
const retryStatusArm = function* (m, { ctx, flags }) {
|
|
922
|
-
|
|
999
|
+
const status = retryStatusFromArm(m, ctx.now());
|
|
1000
|
+
if (status === undefined)
|
|
923
1001
|
return;
|
|
924
|
-
const status = mapBrainStatusToRetry({
|
|
925
|
-
phase: typeof m.phase === 'string' ? m.phase : '',
|
|
926
|
-
...(typeof m.detail === 'string' ? { detail: m.detail } : {}),
|
|
927
|
-
...(typeof m.retryInSec === 'number' ? { retryInSec: m.retryInSec } : {}),
|
|
928
|
-
...(typeof m.retryInMs === 'number' ? { retryInMs: m.retryInMs } : {}),
|
|
929
|
-
...(typeof m.attempt === 'number' ? { attempt: m.attempt } : {}),
|
|
930
|
-
...(typeof m.maxRetries === 'number' ? { maxRetries: m.maxRetries } : {}),
|
|
931
|
-
...(typeof m.errClass === 'string' ? { errClass: m.errClass } : {}),
|
|
932
|
-
...(typeof m.retryAtMs === 'number' ? { retryAtMs: m.retryAtMs } : {}),
|
|
933
|
-
...(typeof m.errorStatus === 'number' ? { errorStatus: m.errorStatus } : {}),
|
|
934
|
-
...(typeof m.elapsedMs === 'number' ? { elapsedMs: m.elapsedMs } : {}),
|
|
935
|
-
...(typeof m.timeoutMs === 'number' ? { timeoutMs: m.timeoutMs } : {}),
|
|
936
|
-
...(typeof m.providerCondition === 'string' && m.providerCondition.length > 0 ? { providerCondition: m.providerCondition } : {}),
|
|
937
|
-
...(typeof m.providerConditionSource === 'string' && m.providerConditionSource.length > 0 ? { providerConditionSource: m.providerConditionSource } : {}),
|
|
938
|
-
}, ctx.now());
|
|
939
1002
|
if (status === null) {
|
|
940
1003
|
if (flags.takeRetryOverlay())
|
|
941
1004
|
yield chrome({ kind: 'retry_status', laneProof: mainLane(), status: null });
|
|
@@ -968,6 +1031,7 @@ export const ARMS = new Map([
|
|
|
968
1031
|
['user', userArm],
|
|
969
1032
|
['tool_end_result', toolEndResultArm],
|
|
970
1033
|
['task_progress', taskProgressArm],
|
|
1034
|
+
['task_started', taskStartedArm],
|
|
971
1035
|
['stream_event', streamEventArm],
|
|
972
1036
|
['turn_usage', turnUsageArm],
|
|
973
1037
|
['result', resultArm],
|
|
@@ -987,6 +1051,7 @@ export const ARMS = new Map([
|
|
|
987
1051
|
['tool_roster_delta', toolRosterDeltaArm],
|
|
988
1052
|
['context_usage', contextUsageArm],
|
|
989
1053
|
['compaction_outcome', compactionOutcomeArm],
|
|
1054
|
+
['compaction_started', compactionStartedArm],
|
|
990
1055
|
['prompt_assembled', promptAssembledArm],
|
|
991
1056
|
['wiring_manifest', wiringManifestArm],
|
|
992
1057
|
['approval_request', approvalFrameArm('approval_request')],
|
|
@@ -7,10 +7,11 @@ export interface PanelTaskLedger {
|
|
|
7
7
|
isLiveBound(taskId: string): boolean;
|
|
8
8
|
isLive(taskId: string): boolean;
|
|
9
9
|
markLive(taskId: string): void;
|
|
10
|
+
noteCycle(taskId: string, cycleSeq: number | undefined): void;
|
|
10
11
|
noteResidency(taskId: string, residentKey?: string): void;
|
|
11
12
|
start(taskId: string, agentType?: string): Generator<AdapterOutput>;
|
|
12
13
|
settle(cardId: string | null, isError: boolean, report?: string): Generator<AdapterOutput>;
|
|
13
|
-
settleFromNotification(taskId: string, isError: boolean): Generator<AdapterOutput>;
|
|
14
|
-
settleFromTerminalTick(taskId: string, isError: boolean): Generator<AdapterOutput>;
|
|
14
|
+
settleFromNotification(taskId: string, isError: boolean, sessionId?: string): Generator<AdapterOutput>;
|
|
15
|
+
settleFromTerminalTick(taskId: string, isError: boolean, cycleSeq?: number): Generator<AdapterOutput>;
|
|
15
16
|
}
|
|
16
17
|
export declare function createPanelTaskLedger(ctx: AdapterContext, cards: OpenCardView, inst: AdapterInstanceLedger): PanelTaskLedger;
|
package/dist/adapt/panelTasks.js
CHANGED
|
@@ -5,7 +5,15 @@ import { SUBAGENT_TOOL_NAMES } from './wireShapes.js';
|
|
|
5
5
|
export function createPanelTaskLedger(ctx, cards, inst) {
|
|
6
6
|
const taskCardBinding = new Map();
|
|
7
7
|
const livePanelTasks = new Set();
|
|
8
|
-
const endedPanelTasks = new
|
|
8
|
+
const endedPanelTasks = new Map();
|
|
9
|
+
const seenCycle = new Map();
|
|
10
|
+
const currentGenerationEnded = (taskId) => {
|
|
11
|
+
if (!endedPanelTasks.has(taskId))
|
|
12
|
+
return false;
|
|
13
|
+
const prior = endedPanelTasks.get(taskId);
|
|
14
|
+
const seen = seenCycle.get(taskId);
|
|
15
|
+
return !(prior !== undefined && seen !== undefined && prior < seen);
|
|
16
|
+
};
|
|
9
17
|
const liveBoundPanelTasks = new Set();
|
|
10
18
|
const clearResidencyBothKeys = (taskId) => clearEnginePanelTaskResidentByWire(taskId);
|
|
11
19
|
const subagentTypeById = new Map();
|
|
@@ -42,6 +50,13 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
42
50
|
markLive: (taskId) => {
|
|
43
51
|
livePanelTasks.add(taskId);
|
|
44
52
|
},
|
|
53
|
+
noteCycle: (taskId, cycleSeq) => {
|
|
54
|
+
if (cycleSeq === undefined)
|
|
55
|
+
return;
|
|
56
|
+
const seen = seenCycle.get(taskId);
|
|
57
|
+
if (seen === undefined || cycleSeq > seen)
|
|
58
|
+
seenCycle.set(taskId, cycleSeq);
|
|
59
|
+
},
|
|
45
60
|
noteResidency: (taskId, residentKey = taskId) => {
|
|
46
61
|
if (liveBoundPanelTasks.has(taskId))
|
|
47
62
|
clearEnginePanelTaskResident(residentKey);
|
|
@@ -69,9 +84,9 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
69
84
|
continue;
|
|
70
85
|
if (cardId === null && !liveBoundPanelTasks.has(taskId))
|
|
71
86
|
continue;
|
|
72
|
-
if (
|
|
87
|
+
if (currentGenerationEnded(taskId))
|
|
73
88
|
continue;
|
|
74
|
-
endedPanelTasks.
|
|
89
|
+
endedPanelTasks.set(taskId, undefined);
|
|
75
90
|
const mintLane = laneMinterFor(taskId);
|
|
76
91
|
const agentType = subagentTypeById.get(taskId);
|
|
77
92
|
yield chrome({
|
|
@@ -88,15 +103,15 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
88
103
|
});
|
|
89
104
|
}
|
|
90
105
|
},
|
|
91
|
-
*settleFromNotification(taskId, isError) {
|
|
106
|
+
*settleFromNotification(taskId, isError, sessionId) {
|
|
92
107
|
clearResidencyBothKeys(taskId);
|
|
93
|
-
if (
|
|
108
|
+
if (currentGenerationEnded(taskId))
|
|
94
109
|
return;
|
|
95
|
-
endedPanelTasks.
|
|
110
|
+
endedPanelTasks.set(taskId, undefined);
|
|
96
111
|
yield chrome({
|
|
97
112
|
kind: 'panel_task',
|
|
98
113
|
laneProof: mainLane(),
|
|
99
|
-
event: panelEndFact(taskId, isError),
|
|
114
|
+
event: panelEndFact(taskId, isError, sessionId !== undefined ? { sessionId } : undefined),
|
|
100
115
|
});
|
|
101
116
|
if (inst.hasFiredSubagentStart(taskId)) {
|
|
102
117
|
yield chrome({
|
|
@@ -108,10 +123,18 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
108
123
|
});
|
|
109
124
|
}
|
|
110
125
|
},
|
|
111
|
-
*settleFromTerminalTick(taskId, isError) {
|
|
112
|
-
if (endedPanelTasks.has(taskId))
|
|
126
|
+
*settleFromTerminalTick(taskId, isError, cycleSeq) {
|
|
127
|
+
if (endedPanelTasks.has(taskId)) {
|
|
128
|
+
const prior = endedPanelTasks.get(taskId);
|
|
129
|
+
if (cycleSeq === undefined || prior === undefined || cycleSeq <= prior)
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const seen = seenCycle.get(taskId);
|
|
133
|
+
if (cycleSeq !== undefined && seen !== undefined && cycleSeq < seen) {
|
|
134
|
+
yield chrome({ kind: 'panel_task', laneProof: laneMinterFor(taskId)(), event: panelEndFact(taskId, isError, { cycleSeq }) });
|
|
113
135
|
return;
|
|
114
|
-
|
|
136
|
+
}
|
|
137
|
+
endedPanelTasks.set(taskId, cycleSeq);
|
|
115
138
|
clearResidencyBothKeys(taskId);
|
|
116
139
|
const mintLane = laneMinterFor(taskId);
|
|
117
140
|
const card = taskCardBinding.get(taskId);
|
|
@@ -138,7 +161,7 @@ export function createPanelTaskLedger(ctx, cards, inst) {
|
|
|
138
161
|
yield chrome({
|
|
139
162
|
kind: 'panel_task',
|
|
140
163
|
laneProof: mintLane(),
|
|
141
|
-
event: panelEndFact(taskId, isError),
|
|
164
|
+
event: panelEndFact(taskId, isError, cycleSeq !== undefined ? { cycleSeq } : undefined),
|
|
142
165
|
});
|
|
143
166
|
},
|
|
144
167
|
};
|
|
@@ -36,7 +36,7 @@ export interface TextStream {
|
|
|
36
36
|
replaceThinkingSegment(content: string, anchor?: Frame): ThinkingSegmentReplacement;
|
|
37
37
|
segmentId(): string;
|
|
38
38
|
anchorWindow(frame: Frame): void;
|
|
39
|
-
|
|
39
|
+
endSegment(): Generator<AdapterOutput>;
|
|
40
40
|
stampSegmentIdentity(out: AdapterOutput): AdapterOutput;
|
|
41
41
|
readonly answerLength: number;
|
|
42
42
|
}
|
package/dist/adapt/textStream.js
CHANGED
|
@@ -38,7 +38,6 @@ export function createTextStream(ctx, idOf) {
|
|
|
38
38
|
let segmentCommitted = '';
|
|
39
39
|
let previousSegmentCommitted = '';
|
|
40
40
|
let segmentWindowCloseArmed = false;
|
|
41
|
-
let segmentSealed = '';
|
|
42
41
|
const flushEveryMs = typeof ctx.coalesceIntervalMs === 'number' && ctx.coalesceIntervalMs >= 0
|
|
43
42
|
? ctx.coalesceIntervalMs
|
|
44
43
|
: FLUSH_INTERVAL_MS;
|
|
@@ -55,6 +54,25 @@ export function createTextStream(ctx, idOf) {
|
|
|
55
54
|
segmentIdCache = idOf(segmentWindowAnchor ?? {}, 'segment');
|
|
56
55
|
return segmentIdCache;
|
|
57
56
|
};
|
|
57
|
+
const openSegmentWindow = (frame) => {
|
|
58
|
+
if (segmentWindowAnchor !== null)
|
|
59
|
+
return;
|
|
60
|
+
segmentWindowAnchor = frame;
|
|
61
|
+
segmentIdCache = null;
|
|
62
|
+
};
|
|
63
|
+
const closeSegmentWindow = () => {
|
|
64
|
+
committedTextRows = [];
|
|
65
|
+
segmentWindowAnchor = null;
|
|
66
|
+
segmentIdCache = null;
|
|
67
|
+
};
|
|
68
|
+
const consumeArmedClose = () => {
|
|
69
|
+
if (!segmentWindowCloseArmed)
|
|
70
|
+
return;
|
|
71
|
+
segmentWindowCloseArmed = false;
|
|
72
|
+
previousSegmentCommitted = '';
|
|
73
|
+
segmentCommitted = '';
|
|
74
|
+
closeSegmentWindow();
|
|
75
|
+
};
|
|
58
76
|
function* takeThinking() {
|
|
59
77
|
if (thinking.length === 0)
|
|
60
78
|
return;
|
|
@@ -77,9 +95,11 @@ export function createTextStream(ctx, idOf) {
|
|
|
77
95
|
yield transcript(msg, ctx.now());
|
|
78
96
|
}
|
|
79
97
|
function* emitAnswerSegment() {
|
|
80
|
-
const body =
|
|
98
|
+
const body = answerSegment;
|
|
81
99
|
if (body.length === 0)
|
|
82
100
|
return;
|
|
101
|
+
if (segmentAnchor !== null)
|
|
102
|
+
openSegmentWindow(segmentAnchor);
|
|
83
103
|
const anchor = segmentAnchor ?? {};
|
|
84
104
|
const msg = {
|
|
85
105
|
type: 'assistant',
|
|
@@ -90,10 +110,8 @@ export function createTextStream(ctx, idOf) {
|
|
|
90
110
|
};
|
|
91
111
|
const committedTextBeforeRow = committedText;
|
|
92
112
|
committedText += body;
|
|
93
|
-
segmentCommitted +=
|
|
94
|
-
|
|
95
|
-
committedTextRows.push({ text: body, uuid: msg.uuid, sealedPrefix: segmentSealed, msgSerial: messageSerial, msgTextBefore: committedTextBeforeRow });
|
|
96
|
-
segmentSealed = '';
|
|
113
|
+
segmentCommitted += body;
|
|
114
|
+
committedTextRows.push({ text: body, uuid: msg.uuid, msgSerial: messageSerial, msgTextBefore: committedTextBeforeRow });
|
|
97
115
|
answerSegment = '';
|
|
98
116
|
segmentAnchor = null;
|
|
99
117
|
segmentLast = null;
|
|
@@ -108,7 +126,7 @@ export function createTextStream(ctx, idOf) {
|
|
|
108
126
|
segmentCommitted = '';
|
|
109
127
|
}
|
|
110
128
|
function* takeAnswerSegmentOnIdle() {
|
|
111
|
-
const body =
|
|
129
|
+
const body = answerSegment;
|
|
112
130
|
if (body.length === 0)
|
|
113
131
|
return;
|
|
114
132
|
if (idleFlushUsedInSegment)
|
|
@@ -149,28 +167,20 @@ export function createTextStream(ctx, idOf) {
|
|
|
149
167
|
}
|
|
150
168
|
return {
|
|
151
169
|
*feedText(delta, frame) {
|
|
152
|
-
|
|
153
|
-
segmentWindowCloseArmed = false;
|
|
154
|
-
previousSegmentCommitted = '';
|
|
155
|
-
segmentCommitted = '';
|
|
156
|
-
committedTextRows = [];
|
|
157
|
-
}
|
|
170
|
+
consumeArmedClose();
|
|
158
171
|
if (thinking.length > 0 || thinkingPending.length > 0) {
|
|
159
172
|
yield* drainLive();
|
|
160
173
|
yield* takeThinking();
|
|
161
174
|
}
|
|
162
|
-
if (answerSegment.length === 0
|
|
175
|
+
if (answerSegment.length === 0)
|
|
163
176
|
segmentAnchor = frame;
|
|
164
177
|
segmentLast = frame;
|
|
165
|
-
|
|
166
|
-
segmentWindowAnchor = frame;
|
|
178
|
+
openSegmentWindow(frame);
|
|
167
179
|
answer += delta;
|
|
168
180
|
answerSegment += delta;
|
|
169
181
|
textPending += delta;
|
|
170
182
|
},
|
|
171
183
|
*feedThinking(delta, frame) {
|
|
172
|
-
if (segmentWindowAnchor === null)
|
|
173
|
-
segmentWindowAnchor = frame;
|
|
174
184
|
if (thinkingSettled) {
|
|
175
185
|
if (thinking.length > 0) {
|
|
176
186
|
yield* drainLive();
|
|
@@ -212,7 +222,7 @@ export function createTextStream(ctx, idOf) {
|
|
|
212
222
|
const rows = uuidsUnique ? rowsAll : [];
|
|
213
223
|
const rowUuids = rows.map((r) => r.uuid);
|
|
214
224
|
const committedRowsOut = committedPrefixDiverged && rows.length > 0
|
|
215
|
-
? rows.map((r, i) => ({ uuid: r.uuid, text: i === 0 ?
|
|
225
|
+
? rows.map((r, i) => ({ uuid: r.uuid, text: i === 0 ? content : '' }))
|
|
216
226
|
: undefined;
|
|
217
227
|
const attribution = uuidsUnique
|
|
218
228
|
? {
|
|
@@ -287,11 +297,12 @@ export function createTextStream(ctx, idOf) {
|
|
|
287
297
|
}
|
|
288
298
|
}
|
|
289
299
|
else {
|
|
290
|
-
|
|
300
|
+
answerSegment = verdict.tail;
|
|
291
301
|
if (diverged && anchor !== undefined)
|
|
292
302
|
segmentLast = anchor;
|
|
293
303
|
}
|
|
294
|
-
|
|
304
|
+
if (committedPrefixDiverged)
|
|
305
|
+
answerSegment = '';
|
|
295
306
|
if (answer.endsWith(liveSegment)) {
|
|
296
307
|
answer = answer.slice(0, answer.length - liveSegment.length) + content;
|
|
297
308
|
}
|
|
@@ -305,7 +316,6 @@ export function createTextStream(ctx, idOf) {
|
|
|
305
316
|
return { diverged, committedPrefixLen, committedPrefixDiverged, ...attribution };
|
|
306
317
|
},
|
|
307
318
|
hasPendingContent: () => thinking.length > 0 ||
|
|
308
|
-
segmentSealed.length > 0 ||
|
|
309
319
|
answerSegment.length > 0 ||
|
|
310
320
|
thinkingPending.length > 0 ||
|
|
311
321
|
textPending.length > 0,
|
|
@@ -365,13 +375,21 @@ export function createTextStream(ctx, idOf) {
|
|
|
365
375
|
},
|
|
366
376
|
segmentId: segmentIdNow,
|
|
367
377
|
anchorWindow: (frame) => {
|
|
368
|
-
|
|
369
|
-
segmentWindowAnchor = frame;
|
|
378
|
+
openSegmentWindow(frame);
|
|
370
379
|
},
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
380
|
+
*endSegment() {
|
|
381
|
+
try {
|
|
382
|
+
yield* emitAnswerSegment();
|
|
383
|
+
}
|
|
384
|
+
finally {
|
|
385
|
+
segmentAnchor = null;
|
|
386
|
+
segmentLast = null;
|
|
387
|
+
segmentCommitted = '';
|
|
388
|
+
previousSegmentCommitted = '';
|
|
389
|
+
idleFlushUsedInSegment = false;
|
|
390
|
+
textBlockOpen = false;
|
|
391
|
+
closeSegmentWindow();
|
|
392
|
+
}
|
|
375
393
|
},
|
|
376
394
|
stampSegmentIdentity: (out) => {
|
|
377
395
|
if (out.plane !== 'transcript')
|
|
@@ -385,6 +403,11 @@ export function createTextStream(ctx, idOf) {
|
|
|
385
403
|
const last = blocks[blocks.length - 1];
|
|
386
404
|
if (last === undefined || last.type !== 'text' || typeof last.text !== 'string')
|
|
387
405
|
return out;
|
|
406
|
+
if (segmentWindowAnchor === null) {
|
|
407
|
+
const rowUuid = out.message.uuid;
|
|
408
|
+
openSegmentWindow(typeof rowUuid === 'string' ? { uuid: rowUuid } : {});
|
|
409
|
+
}
|
|
410
|
+
;
|
|
388
411
|
out.message[SEMA_SEGMENT_ID_KEY] = segmentIdNow();
|
|
389
412
|
return out;
|
|
390
413
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UiLanguage } from '../env/uiLanguage.js';
|
|
1
2
|
import type { ActiveRunBusySignal } from './runStream.js';
|
|
2
3
|
import type { PlanReviewReopenTrigger } from '../hitl/planReviewWire.js';
|
|
3
4
|
import { atMostOnceFailureClass } from '../atMostOnce.js';
|
|
@@ -39,11 +40,14 @@ export type ReopenCardVerdict = {
|
|
|
39
40
|
dismissedByUser?: true;
|
|
40
41
|
_sema_noPresentationSurface?: true;
|
|
41
42
|
_sema_errorCode?: string;
|
|
43
|
+
_sema_reopenRefusal?: PlanReviewReopenRefusal;
|
|
42
44
|
} | {
|
|
43
45
|
reopened: true;
|
|
44
46
|
firstSight: boolean;
|
|
45
47
|
presented?: boolean;
|
|
46
48
|
};
|
|
49
|
+
export declare const PLAN_REVIEW_REOPEN_REFUSALS: readonly ["invalid_call", "no_delivery_path", "not_presented", "gate_record_gone", "internal_error"];
|
|
50
|
+
export type PlanReviewReopenRefusal = (typeof PLAN_REVIEW_REOPEN_REFUSALS)[number];
|
|
47
51
|
export interface RunningChoiceRequest {
|
|
48
52
|
taskId: string;
|
|
49
53
|
status: string;
|
|
@@ -139,6 +143,8 @@ export type SelfHealOutcome = {
|
|
|
139
143
|
taskId: string;
|
|
140
144
|
detail: string;
|
|
141
145
|
delivery: 'rejected' | 'unknown';
|
|
146
|
+
errorCode?: string;
|
|
147
|
+
runStatus?: string;
|
|
142
148
|
} | {
|
|
143
149
|
kind: 'running-attach';
|
|
144
150
|
taskId: string;
|
|
@@ -228,9 +234,11 @@ export interface ActiveRunSelfHealCopy {
|
|
|
228
234
|
freshSession?: string;
|
|
229
235
|
keepSessionWayOut?: () => string | null;
|
|
230
236
|
engineDecidePath?: boolean;
|
|
237
|
+
endRun?: string;
|
|
238
|
+
wakeSession?: string | null;
|
|
231
239
|
rowFor?: (outcome: SelfHealOutcome, signal: ActiveRunBusySignal | null | undefined) => string | undefined;
|
|
232
240
|
headlessRowFor?: (signal: ActiveRunBusySignal) => string | undefined;
|
|
233
241
|
}
|
|
234
|
-
export declare const INTERACTIVE_WAY_OUT
|
|
235
|
-
export declare function activeRunSelfHealRow(outcome: SelfHealOutcome, signal?: ActiveRunBusySignal | null, copy?: ActiveRunSelfHealCopy, origin?: RejectedSubmissionOrigin, follow?: SelfHealFollowDeclaration): string;
|
|
236
|
-
export declare function activeRunBusyHeadlessRow(signal: ActiveRunBusySignal, copy?: ActiveRunSelfHealCopy): string;
|
|
242
|
+
export declare const INTERACTIVE_WAY_OUT: string;
|
|
243
|
+
export declare function activeRunSelfHealRow(outcome: SelfHealOutcome, signal?: ActiveRunBusySignal | null, copy?: ActiveRunSelfHealCopy, origin?: RejectedSubmissionOrigin, follow?: SelfHealFollowDeclaration, lang?: UiLanguage): string;
|
|
244
|
+
export declare function activeRunBusyHeadlessRow(signal: ActiveRunBusySignal, copy?: ActiveRunSelfHealCopy, lang?: UiLanguage): string;
|