@sema-agent/client-core 0.97.1 → 0.99.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 +607 -0
- package/README.md +96 -46
- package/dist/adapt/arms.d.ts +1 -0
- package/dist/adapt/arms.js +188 -53
- package/dist/adapt/ids.d.ts +12 -1
- package/dist/adapt/ids.js +59 -8
- package/dist/adapt/instanceLedger.d.ts +50 -0
- package/dist/adapt/instanceLedger.js +147 -0
- package/dist/adapt/panelTasks.d.ts +1 -1
- package/dist/adapt/panelTasks.js +2 -2
- package/dist/adapt/textStream.d.ts +1 -0
- package/dist/adapt/textStream.js +24 -7
- package/dist/adapt/toolCards.d.ts +27 -5
- package/dist/adapt/toolCards.js +39 -6
- package/dist/adapt/wireShapes.js +6 -2
- package/dist/adapt.d.ts +2 -0
- package/dist/adapt.js +8 -3
- package/dist/adapter/activeRunSelfHeal.d.ts +9 -3
- package/dist/adapter/activeRunSelfHeal.js +205 -313
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
- package/dist/adapter/downstream/eventToSdkMessage.js +77 -36
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
- package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
- package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
- package/dist/adapter/runStream.js +79 -48
- package/dist/adapter/types.d.ts +4 -4
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/backgroundView.js +2 -1
- package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
- package/dist/agentSession/engineAgentRegistryRead.js +12 -13
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +8 -11
- package/dist/agentsWireCaps.js +196 -194
- package/dist/approvalDecidedByCapability.d.ts +0 -4
- package/dist/approvalDecidedByCapability.js +0 -6
- package/dist/approvalsStreamLiveCapability.d.ts +0 -4
- package/dist/approvalsStreamLiveCapability.js +0 -6
- package/dist/assistantInbox.d.ts +34 -0
- package/dist/assistantInbox.js +118 -0
- package/dist/centerWiringCapability.js +9 -1
- package/dist/clientSlice.d.ts +0 -9
- package/dist/clientSlice.js +0 -3
- package/dist/cloudConfigWireCaps.d.ts +5 -3
- package/dist/cloudConfigWireCaps.js +106 -64
- package/dist/compensations.js +1 -1
- package/dist/connectorStatus.d.ts +21 -0
- package/dist/connectorStatus.js +112 -0
- package/dist/controlRouter.d.ts +18 -3
- package/dist/controlRouter.js +106 -67
- package/dist/coreValuePorts.d.ts +29 -4
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/decideReceipt.d.ts +2 -2
- package/dist/decideReceipt.js +5 -2
- package/dist/declared/supportFloorDeclared.js +3 -3
- package/dist/detachWire.js +3 -2
- package/dist/deviceExecutorManagementCapability.d.ts +0 -4
- package/dist/deviceExecutorManagementCapability.js +0 -6
- package/dist/deviceRebind.d.ts +49 -1
- package/dist/deviceRebind.js +221 -3
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +2 -0
- package/dist/displayUntrusted.js +253 -76
- package/dist/engineAgentAbsence.d.ts +1 -1
- package/dist/engineAgentPanelStore.d.ts +12 -4
- package/dist/engineAgentPanelStore.js +16 -11
- package/dist/engineCapReader.d.ts +2 -5
- package/dist/engineCapReader.js +8 -10
- package/dist/engineCapsCache.d.ts +12 -0
- package/dist/engineCapsCache.js +76 -18
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineClosedSets.d.ts +1 -0
- package/dist/engineClosedSets.js +4 -1
- package/dist/engineErrorCodes.d.ts +11 -3
- package/dist/engineErrorCodes.js +11 -8
- package/dist/engineIdentity.d.ts +1 -0
- package/dist/engineIdentity.js +8 -0
- package/dist/engineRowRef.d.ts +28 -0
- package/dist/engineRowRef.js +114 -0
- package/dist/engineSessionMessages.d.ts +68 -0
- package/dist/engineSessionMessages.js +370 -0
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineToolDirectory.d.ts +0 -9
- package/dist/engineToolDirectory.js +1 -94
- package/dist/engineUrl.d.ts +18 -0
- package/dist/engineUrl.js +52 -0
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +11 -1
- package/dist/env/uiLanguage.js +38 -2
- package/dist/eventLeg.d.ts +100 -0
- package/dist/eventLeg.js +305 -0
- package/dist/executionLaneCapability.d.ts +0 -4
- package/dist/executionLaneCapability.js +3 -16
- package/dist/fileHistoryCaptureCapability.d.ts +2 -5
- package/dist/fileHistoryCaptureCapability.js +13 -21
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/fleet/fleetLedger.d.ts +0 -3
- package/dist/fleet/fleetLedger.js +21 -36
- package/dist/fleet/fleetProjection.d.ts +2 -2
- package/dist/fleet/fleetProjection.js +10 -8
- package/dist/frameBinding.d.ts +8 -0
- package/dist/frameBinding.js +35 -0
- package/dist/gateFailureCodes.d.ts +2 -0
- package/dist/gateFailureCodes.js +15 -0
- package/dist/gateOutcome.d.ts +3 -1
- package/dist/gateOutcome.js +41 -8
- package/dist/gateVocabulary.d.ts +10 -4
- package/dist/gateVocabulary.js +107 -47
- package/dist/generated/engineAskFaceTables.js +2 -2
- package/dist/generated/engineFactTables.d.ts +22 -3
- package/dist/generated/engineFactTables.js +51 -4
- package/dist/generated/engineNoticeTables.js +18 -3
- package/dist/generated/settingsSchemaFns.d.ts +6 -0
- package/dist/generated/settingsSchemaFns.js +57 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaTables.d.ts +1 -0
- package/dist/generated/settingsSchemaTables.js +4 -0
- package/dist/generated/settingsSchemaTypes.d.ts +105 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +8 -2
- package/dist/hitl/allowRuleShadow.js +36 -29
- package/dist/hitl/approvalCardReading.d.ts +15 -0
- package/dist/hitl/approvalCardReading.js +154 -0
- package/dist/hitl/approvalCardReasons.d.ts +14 -0
- package/dist/hitl/approvalCardReasons.js +119 -0
- package/dist/hitl/approvalHolds.d.ts +50 -15
- package/dist/hitl/approvalHolds.js +177 -27
- package/dist/hitl/approvalResolution.d.ts +51 -26
- package/dist/hitl/approvalResolution.js +86 -122
- package/dist/hitl/approvalsFeed.js +6 -18
- package/dist/hitl/askClassPair.d.ts +2 -0
- package/dist/hitl/askClassPair.js +17 -0
- package/dist/hitl/askGateWire.d.ts +20 -2
- package/dist/hitl/askGateWire.js +50 -1
- package/dist/hitl/askParkRowRouting.d.ts +5 -0
- package/dist/hitl/askParkRowRouting.js +32 -1
- package/dist/hitl/askSettlementLine.d.ts +28 -0
- package/dist/hitl/askSettlementLine.js +99 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +3 -2
- package/dist/hitl/automaticAnswerVerdict.js +29 -13
- package/dist/hitl/crashConverged.d.ts +11 -20
- package/dist/hitl/crashConverged.js +56 -0
- package/dist/hitl/crashConvergedNotice.d.ts +6 -3
- package/dist/hitl/crashConvergedNotice.js +48 -24
- package/dist/hitl/decisionConflict.js +3 -10
- package/dist/hitl/decisionRefusal.d.ts +40 -1
- package/dist/hitl/decisionRefusal.js +199 -42
- package/dist/hitl/frameRouter.d.ts +5 -2
- package/dist/hitl/frameRouter.js +27 -24
- package/dist/hitl/gateLedger.d.ts +2 -0
- package/dist/hitl/gateLedger.js +50 -13
- package/dist/hitl/hitlBridge.d.ts +2 -2
- package/dist/hitl/hitlBridge.js +13 -10
- package/dist/hitl/livePendingAsk.d.ts +3 -3
- package/dist/hitl/livePendingAsk.js +7 -18
- package/dist/hitl/parkResolver.d.ts +2 -24
- package/dist/hitl/parkResolver.js +61 -97
- package/dist/hitl/persistedRulesWire.d.ts +25 -0
- package/dist/hitl/persistedRulesWire.js +104 -2
- package/dist/hitl/planReviewWire.d.ts +31 -13
- package/dist/hitl/planReviewWire.js +120 -78
- package/dist/hitl/refusedToolNameProse.d.ts +0 -1
- package/dist/hitl/refusedToolNameProse.js +0 -3
- package/dist/hitl/replayedApproval.d.ts +4 -3
- package/dist/hitl/replayedApproval.js +7 -4
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +48 -7
- package/dist/hitl/sessionPolicyWire.d.ts +34 -21
- package/dist/hitl/sessionPolicyWire.js +179 -70
- package/dist/hitl/standingRows.d.ts +20 -2
- package/dist/hitl/standingRows.js +69 -8
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +103 -156
- package/dist/hitl/toolApprovalWire.js +661 -411
- package/dist/hookMatcherVerdict.d.ts +6 -1
- package/dist/hookMatcherVerdict.js +14 -7
- package/dist/hooksWireCaps.d.ts +2 -2
- package/dist/hooksWireCaps.js +174 -81
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +71 -0
- package/dist/hostTurnSettings.js +291 -0
- package/dist/humanTurn.d.ts +14 -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 +703 -0
- package/dist/i18n/messages.en.js +701 -0
- package/dist/i18n/messages.zh.d.ts +3 -0
- package/dist/i18n/messages.zh.js +837 -0
- package/dist/i18n/translate.d.ts +25 -0
- package/dist/i18n/translate.js +127 -0
- package/dist/index.d.ts +78 -29
- package/dist/index.js +54 -18
- package/dist/inheritEnvCapability.d.ts +32 -0
- package/dist/inheritEnvCapability.js +104 -0
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +12 -14
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +3 -3
- package/dist/liveModelCatalog.js +15 -13
- package/dist/liveQuestionStore.d.ts +2 -21
- package/dist/mcpLiveness.d.ts +2 -1
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +40 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +9 -2
- package/dist/mcpProbeWire.js +6 -1
- package/dist/mcpWireCaps.d.ts +47 -2
- package/dist/mcpWireCaps.js +164 -16
- package/dist/memoryEntriesWire.d.ts +4 -9
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/modelSupplyRules.d.ts +0 -2
- package/dist/model/modelSupplyRules.js +3 -12
- package/dist/model/modelsPolicy.d.ts +0 -5
- package/dist/model/modelsPolicy.js +6 -36
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/subagentModelWord.d.ts +31 -0
- package/dist/model/subagentModelWord.js +261 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +64 -0
- package/dist/modelCapabilityProbe.js +600 -0
- package/dist/modelIdentityResolvability.d.ts +3 -0
- package/dist/modelIdentityResolvability.js +26 -17
- package/dist/notifications.d.ts +6 -0
- package/dist/notifications.js +71 -23
- package/dist/outputStyleSeatCapability.d.ts +0 -3
- package/dist/outputStyleSeatCapability.js +0 -3
- package/dist/ownKey.d.ts +22 -0
- package/dist/ownKey.js +94 -3
- package/dist/panelReduce.d.ts +21 -10
- package/dist/panelReduce.js +728 -550
- package/dist/panelStateHolder.d.ts +3 -7
- package/dist/panelStateHolder.js +14 -130
- package/dist/peerLaneCapability.d.ts +0 -4
- package/dist/peerLaneCapability.js +0 -6
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.d.ts +2 -5
- package/dist/permissionRulesWriteCapability.js +8 -12
- package/dist/permissionWireCaps.d.ts +2 -2
- package/dist/permissionWireCaps.js +2 -0
- package/dist/permissionsAllowGrantCapability.d.ts +0 -4
- package/dist/permissionsAllowGrantCapability.js +0 -6
- package/dist/permissionsDeclaration.d.ts +0 -11
- package/dist/permissionsDeclaration.js +60 -53
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +219 -16
- package/dist/preemptWire.d.ts +44 -0
- package/dist/preemptWire.js +83 -0
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/printToolResultFrame.js +15 -4
- package/dist/replayBody.d.ts +3 -0
- package/dist/replayBody.js +14 -0
- package/dist/request/taskRequest.d.ts +11 -6
- package/dist/request/taskRequest.js +112 -19
- package/dist/resumeRefusalCopy.d.ts +13 -9
- package/dist/resumeRefusalCopy.js +81 -118
- package/dist/retryStatus.d.ts +45 -0
- package/dist/retryStatus.js +185 -1
- package/dist/rewindArchiveCapability.d.ts +0 -4
- package/dist/rewindArchiveCapability.js +2 -10
- package/dist/rewindArchiveReading.d.ts +0 -1
- package/dist/rewindArchiveReading.js +0 -3
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +4 -2
- package/dist/runReattachPolicy.d.ts +31 -0
- package/dist/runReattachPolicy.js +46 -0
- package/dist/runTerminal.d.ts +3 -6
- package/dist/runTerminal.js +8 -9
- package/dist/sandboxWire.d.ts +3 -1
- package/dist/sandboxWire.js +76 -27
- package/dist/scenarioRefusal.d.ts +9 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/scenarioWire.js +1 -1
- package/dist/seam.d.ts +48 -2
- package/dist/seam.js +25 -4
- package/dist/seatContract.d.ts +311 -18
- package/dist/seatContract.js +824 -100
- 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 -5
- package/dist/sessionPolicyCapability.js +8 -12
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
- package/dist/sessionSyncFileHistoryCapability.js +0 -3
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -4
- package/dist/skillToolListsCapability.js +8 -9
- package/dist/sqlEngineCapability.d.ts +0 -4
- package/dist/sqlEngineCapability.js +0 -6
- package/dist/sseIdleTriage.js +3 -2
- package/dist/steerPriorityCapability.d.ts +0 -3
- package/dist/steerPriorityCapability.js +0 -3
- package/dist/streamDrainingLegs.d.ts +4 -0
- package/dist/streamDrainingLegs.js +6 -1
- package/dist/subagent/engineCompactWire.d.ts +0 -1
- package/dist/subagent/engineCompactWire.js +7 -5
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagent/engineTaskHandleWire.js +4 -7
- package/dist/subagentContentStore.d.ts +3 -0
- package/dist/subagentContentStore.js +22 -10
- package/dist/submitReopen.d.ts +24 -0
- package/dist/submitReopen.js +75 -0
- package/dist/terminalStatuses.d.ts +3 -0
- package/dist/terminalStatuses.js +10 -2
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolResult.d.ts +10 -1
- package/dist/toolResult.js +34 -6
- package/dist/toolRoster.d.ts +3 -4
- package/dist/toolRoster.js +21 -22
- package/dist/turnFailurePresentation.d.ts +39 -0
- package/dist/turnFailurePresentation.js +402 -0
- 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 -4
- package/dist/userInvokedSkillsCapability.js +31 -10
- package/dist/webSearchBackendCapability.d.ts +0 -4
- package/dist/webSearchBackendCapability.js +0 -6
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +26 -23
- package/dist/wireFailureShape.d.ts +62 -5
- package/dist/wireFailureShape.js +106 -5
- package/dist/wireRefusalCopy.d.ts +25 -3
- package/dist/wireRefusalCopy.js +74 -80
- package/dist/workflowsJournalCapability.d.ts +2 -5
- package/dist/workflowsJournalCapability.js +8 -12
- package/dist/writeProtectionCapability.d.ts +0 -4
- package/dist/writeProtectionCapability.js +0 -6
- package/docs/INTEGRATION-CLIENTS.md +1775 -56
- package/package.json +6 -5
- package/dist/attachmentSeatCapability.d.ts +0 -12
- package/dist/attachmentSeatCapability.js +0 -23
- package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
- package/dist/hitl/approvalOutcomeNote.js +0 -29
- package/dist/sessionReadRedactionCapability.d.ts +0 -13
- package/dist/sessionReadRedactionCapability.js +0 -35
package/dist/adapt/arms.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface ArmDeps extends ProjectionArmDeps {
|
|
|
15
15
|
readonly panel: PanelTaskLedger;
|
|
16
16
|
readonly flags: TurnFlags;
|
|
17
17
|
readonly inst: AdapterInstanceLedger;
|
|
18
|
+
readonly pass: number;
|
|
18
19
|
}
|
|
19
20
|
export type ProjectionArmFn = (m: Frame, deps: ProjectionArmDeps) => Generator<AdapterOutput>;
|
|
20
21
|
type ArmFn = (m: Frame, deps: ArmDeps) => Generator<AdapterOutput>;
|
package/dist/adapt/arms.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ccToolDenialKindForToolEnd } from '../gateOutcome.js';
|
|
1
|
+
import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../gateOutcome.js';
|
|
2
2
|
import { isSubFlowSegmentEnd, SEGMENT_END_IDENTITY_KEYS, snapshotSegmentIdentity, snapshotIsSubFlow } from '../adapter/types.js';
|
|
3
3
|
import { classifyPeerNotification, renderPeerFrameTranscriptText } from '../peerFrames.js';
|
|
4
4
|
import { dropQueuedNotificationsForRun, isEngineWorkflowNotified, isWorkflowCompletionCardEnqueued, markEngineWorkflowNotified, noteOwnWorkflowRun, normalizeTaskNotification, noteWorkflowCompletionCardEnqueued, renderTaskNotificationXml, taskNotificationDedupKey } from '../notifications.js';
|
|
5
|
-
import {
|
|
5
|
+
import { retryStatusFromArm } from '../retryStatus.js';
|
|
6
6
|
import { steeringInjectedToAttachments } from '../steering.js';
|
|
7
7
|
import { projectDiagnosticsFrame } from '../diagnostics.js';
|
|
8
8
|
import { recordEngineToolLabel } from '../engineToolLabelStore.js';
|
|
@@ -12,13 +12,64 @@ import { recordWorkflowAgentTaskId } from '../workflow.js';
|
|
|
12
12
|
import { isCoreTaskNotificationTerminal, isCoreTaskNotificationTerminalNotSuccess, isCoreTaskProgressTerminal, isCoreTaskProgressTerminalNotSuccess } from '../terminalStatuses.js';
|
|
13
13
|
import { readToolHistoryMismatchKey } from '../toolHistoryMismatch.js';
|
|
14
14
|
import { readProviderRejectionResendKey } from '../providerRejection.js';
|
|
15
|
-
import { readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
|
|
16
|
-
import {
|
|
15
|
+
import { contextUsageReadingOf, guardedRead, humanInputAttachmentsOf, readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
|
|
16
|
+
import { CORE_USER_ATTACHMENT_LABEL_MAX } from '../generated/engineFactTables.js';
|
|
17
|
+
import { ESCAPE_FACE, paintAndCap, washCredentials } from '../displayUntrusted.js';
|
|
17
18
|
import { resolveEnginePanelTaskId } from '../engineAgentPanelStore.js';
|
|
18
19
|
import { fleetRowAgentType } from '../fleet/fleetRowAgentType.js';
|
|
19
20
|
import { chrome, mainLane, transcript, messageIdentityOf } from './ids.js';
|
|
21
|
+
import { engineRefOf } from '../engineRowRef.js';
|
|
22
|
+
import { isReplayMarked, RESULT_REPLAYED_TEXT } from '../replayBody.js';
|
|
20
23
|
import { wiringManifestViewOf } from '../adapter/downstream/wiringManifestView.js';
|
|
24
|
+
import { isUnsettledHeldToolEnd } from '../engineRowRef.js';
|
|
21
25
|
import { CANCEL_MESSAGE, decisionOf, flattenWireOutput, REJECT_MESSAGE, sanitizeToolUseBlock, shortTaskLabel, TASK_TOOL_NAMES, WORKFLOW_TOOL_NAMES, } from './wireShapes.js';
|
|
26
|
+
function hostOwnString(o, key) {
|
|
27
|
+
return readFrameStringKey(o, key);
|
|
28
|
+
}
|
|
29
|
+
function continuesParkDeclarationOf(ctx) {
|
|
30
|
+
const decl = guardedRead(() => ctx.continuesPark);
|
|
31
|
+
return typeof decl === 'object' && decl !== null ? decl : undefined;
|
|
32
|
+
}
|
|
33
|
+
function continuesParkWitness(ctx, row) {
|
|
34
|
+
const decl = continuesParkDeclarationOf(ctx);
|
|
35
|
+
if (decl === undefined)
|
|
36
|
+
return false;
|
|
37
|
+
if (hostOwnString(decl, 'toolCallId') !== row.toolCallId)
|
|
38
|
+
return false;
|
|
39
|
+
const cp = hostOwnString(decl, 'checkpointId');
|
|
40
|
+
if (cp !== undefined && row.checkpointId !== undefined && cp !== row.checkpointId)
|
|
41
|
+
return false;
|
|
42
|
+
const parkedTaskId = hostOwnString(decl, 'parkedTaskId');
|
|
43
|
+
if (parkedTaskId !== undefined && row.parkedRun !== undefined && parkedTaskId !== row.parkedRun)
|
|
44
|
+
return false;
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
function claimParkedCard(m, callId, toolName, deps) {
|
|
48
|
+
const { ctx, cards, inst, pass } = deps;
|
|
49
|
+
if (cards.has(callId))
|
|
50
|
+
return undefined;
|
|
51
|
+
const row = inst.parkedToolRowFor(ctx.sessionId, callId);
|
|
52
|
+
if (row === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
if (readFrameStringKey(m, 'parentToolCallId') !== row.card.parentToolCallId)
|
|
55
|
+
return undefined;
|
|
56
|
+
if (toolName !== undefined && toolName !== row.card.name)
|
|
57
|
+
return undefined;
|
|
58
|
+
const frameRun = engineRefOf(m)?.taskId;
|
|
59
|
+
if (frameRun !== undefined) {
|
|
60
|
+
const decl = continuesParkDeclarationOf(ctx);
|
|
61
|
+
const allowed = [row.parkedRun, row.card.engineRef?.taskId, readFrameStringKey(decl, 'parkedTaskId'), readFrameStringKey(decl, 'continuationTaskId')].filter((x) => x !== undefined);
|
|
62
|
+
if (allowed.length > 0 && !allowed.includes(frameRun))
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
if (row.pass !== pass && !continuesParkWitness(ctx, row))
|
|
66
|
+
return undefined;
|
|
67
|
+
inst.dropParkedToolRow(row.key);
|
|
68
|
+
return row.card;
|
|
69
|
+
}
|
|
70
|
+
function laneOfCard(p) {
|
|
71
|
+
return p.parentToolCallId !== undefined && p.parentToolCallId !== '' ? { lane: 'subagent', parentToolCallId: p.parentToolCallId } : mainLane();
|
|
72
|
+
}
|
|
22
73
|
function toolHistoryKeyCarry(m) {
|
|
23
74
|
if (m._sema_api_error_message !== true)
|
|
24
75
|
return {};
|
|
@@ -33,7 +84,8 @@ function providerResendKeyCarry(m) {
|
|
|
33
84
|
const key = readProviderRejectionResendKey(typeof raw === 'object' && raw !== null ? raw : undefined);
|
|
34
85
|
return key === undefined ? {} : { _sema_provider_rejection_resend: key };
|
|
35
86
|
}
|
|
36
|
-
const assistantArm = function* (m,
|
|
87
|
+
const assistantArm = function* (m, deps) {
|
|
88
|
+
const { ctx, idOf, text, cards, inst } = deps;
|
|
37
89
|
const message = m.message;
|
|
38
90
|
const blocks = Array.isArray(message?.content)
|
|
39
91
|
? message.content
|
|
@@ -61,21 +113,27 @@ const assistantArm = function* (m, { ctx, idOf, text, cards, inst }) {
|
|
|
61
113
|
}
|
|
62
114
|
yield* text.takeAnswerSegment();
|
|
63
115
|
yield* text.takeThinking();
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
116
|
+
const claimed = claimParkedCard(m, toolUseId, toolName, deps);
|
|
117
|
+
const startUuid = claimed !== undefined ? claimed.rowUuid : idOf(m);
|
|
118
|
+
if (claimed === undefined)
|
|
119
|
+
inst.noteStartRow(ctx.sessionId, toolUseId, startUuid);
|
|
120
|
+
if (claimed === undefined) {
|
|
121
|
+
text.beginAssistantMessage();
|
|
122
|
+
const cardIdentity = messageIdentityOf(m, ctx);
|
|
123
|
+
yield transcript({
|
|
124
|
+
type: 'assistant',
|
|
125
|
+
message: {
|
|
126
|
+
id: cards.mintResponseId(m),
|
|
127
|
+
role: 'assistant',
|
|
128
|
+
content: renderBlocks,
|
|
129
|
+
...(cardIdentity.model !== undefined ? { model: cardIdentity.model } : {}),
|
|
130
|
+
},
|
|
131
|
+
uuid: startUuid,
|
|
132
|
+
session_id: ctx.sessionId,
|
|
133
|
+
parent_tool_use_id: null,
|
|
134
|
+
...(readFrameTrueMark(m, '_sema_tool_recovered') ? { _sema_tool_recovered: true } : {}),
|
|
135
|
+
}, ctx.now());
|
|
136
|
+
}
|
|
79
137
|
if (decision === 'reject' || decision === 'cancel') {
|
|
80
138
|
cards.resetResponseId();
|
|
81
139
|
yield transcript({
|
|
@@ -116,18 +174,23 @@ const assistantArm = function* (m, { ctx, idOf, text, cards, inst }) {
|
|
|
116
174
|
}, ctx.now());
|
|
117
175
|
return;
|
|
118
176
|
}
|
|
119
|
-
cards.open({
|
|
177
|
+
cards.open(claimed !== undefined ? { ...claimed, rawInput: san.rawInput } : {
|
|
120
178
|
id: toolUseId,
|
|
121
179
|
name: toolName,
|
|
122
180
|
rawInput: san.rawInput,
|
|
123
181
|
...(san.eventId !== undefined ? { eventId: san.eventId } : {}),
|
|
124
182
|
...(san.parentToolCallId !== undefined ? { parentToolCallId: san.parentToolCallId } : {}),
|
|
183
|
+
engineRef: engineRefOf(m),
|
|
184
|
+
...(startUuid !== undefined ? { rowUuid: startUuid } : {}),
|
|
125
185
|
});
|
|
126
186
|
if (WORKFLOW_TOOL_NAMES.has(toolName))
|
|
127
187
|
inst.markWorkflowCard(toolUseId);
|
|
128
188
|
return;
|
|
129
189
|
}
|
|
130
190
|
const textBlock = blocks.find(b => b?.type === 'text');
|
|
191
|
+
const thinkingBlock = blocks.find(b => b?.type === 'thinking');
|
|
192
|
+
if ((textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0) || (thinkingBlock && typeof thinkingBlock.thinking === 'string'))
|
|
193
|
+
text.anchorWindow(m);
|
|
131
194
|
if (textBlock && typeof textBlock.text === 'string' && textBlock.text.length > 0) {
|
|
132
195
|
const rowText = m._sema_api_error_message === true ? washCredentials(textBlock.text) : textBlock.text;
|
|
133
196
|
text.appendAnswer(rowText);
|
|
@@ -145,7 +208,6 @@ const assistantArm = function* (m, { ctx, idOf, text, cards, inst }) {
|
|
|
145
208
|
}, ctx.now());
|
|
146
209
|
text.markEmittedText(rowText);
|
|
147
210
|
}
|
|
148
|
-
const thinkingBlock = blocks.find(b => b?.type === 'thinking');
|
|
149
211
|
if (thinkingBlock && typeof thinkingBlock.thinking === 'string') {
|
|
150
212
|
yield transcript({
|
|
151
213
|
type: 'assistant',
|
|
@@ -249,8 +311,15 @@ const humanInputArm = function* (m) {
|
|
|
249
311
|
...(actor !== undefined && Object.keys(actor).length > 0 ? { actor } : {}),
|
|
250
312
|
...(str(m.entryId) !== undefined ? { entryId: str(m.entryId) } : {}),
|
|
251
313
|
...(str(m.eventId) !== undefined ? { eventId: str(m.eventId) } : {}),
|
|
314
|
+
...humanInputAttachmentsForChrome(m),
|
|
252
315
|
});
|
|
253
316
|
};
|
|
317
|
+
function humanInputAttachmentsForChrome(m) {
|
|
318
|
+
const rows = humanInputAttachmentsOf(m);
|
|
319
|
+
if (rows === undefined)
|
|
320
|
+
return {};
|
|
321
|
+
return { attachments: rows.map((r) => (r.label !== undefined ? { ...r, label: paintAndCap(r.label, ESCAPE_FACE, CORE_USER_ATTACHMENT_LABEL_MAX) } : r)) };
|
|
322
|
+
}
|
|
254
323
|
const messageCommittedArm = function* (m) {
|
|
255
324
|
if (typeof m.parentToolCallId === 'string')
|
|
256
325
|
return;
|
|
@@ -360,20 +429,13 @@ const toolRosterDeltaArm = function* (m) {
|
|
|
360
429
|
const contextUsageArm = function* (m) {
|
|
361
430
|
if (isSubFlowSegmentEnd(m))
|
|
362
431
|
return;
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
const windowTokens = num(m.windowTokens);
|
|
366
|
-
const compactAtTokens = num(m.compactAtTokens);
|
|
367
|
-
const sections = Array.isArray(m.sections) ? m.sections : undefined;
|
|
368
|
-
if (usedTokens === undefined && windowTokens === undefined && compactAtTokens === undefined && sections === undefined)
|
|
432
|
+
const reading = contextUsageReadingOf(m);
|
|
433
|
+
if (reading === undefined)
|
|
369
434
|
return;
|
|
370
435
|
yield chrome({
|
|
371
436
|
kind: 'context_usage',
|
|
372
437
|
laneProof: mainLane(),
|
|
373
|
-
...
|
|
374
|
-
...(windowTokens !== undefined ? { windowTokens } : {}),
|
|
375
|
-
...(compactAtTokens !== undefined ? { compactAtTokens } : {}),
|
|
376
|
-
...(sections !== undefined ? { sections } : {}),
|
|
438
|
+
...reading,
|
|
377
439
|
...(typeof m.eventId === 'string' && m.eventId.length > 0 ? { eventId: m.eventId } : {}),
|
|
378
440
|
});
|
|
379
441
|
};
|
|
@@ -404,6 +466,51 @@ const compactionOutcomeArm = function* (m) {
|
|
|
404
466
|
...(eventId !== undefined ? { eventId } : {}),
|
|
405
467
|
});
|
|
406
468
|
};
|
|
469
|
+
const taskStartedArm = function* (m) {
|
|
470
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
471
|
+
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
|
|
472
|
+
const taskId = str(m.taskId);
|
|
473
|
+
if (taskId === undefined)
|
|
474
|
+
return;
|
|
475
|
+
const idSnap = snapshotSegmentIdentity(m);
|
|
476
|
+
if (idSnap === null)
|
|
477
|
+
return;
|
|
478
|
+
const parent = str(idSnap.parentToolCallId);
|
|
479
|
+
const laneProof = parent !== undefined ? { lane: 'subagent', parentToolCallId: parent } : mainLane();
|
|
480
|
+
const sessionId = str(m.sessionId);
|
|
481
|
+
const model = str(m.model);
|
|
482
|
+
const taskType = str(m.taskType);
|
|
483
|
+
const seq = num(m.seq);
|
|
484
|
+
const workflowRunId = str(m.workflowRunId);
|
|
485
|
+
const workflowAgentLabel = str(m.workflowAgentLabel);
|
|
486
|
+
const parentTaskId = str(m.parentTaskId);
|
|
487
|
+
const parentSessionId = str(m.parentSessionId);
|
|
488
|
+
const rootSessionId = str(m.rootSessionId);
|
|
489
|
+
const name = str(m.name);
|
|
490
|
+
const spawnName = str(m.spawnName);
|
|
491
|
+
const agentType = str(m.agentType);
|
|
492
|
+
const startedAt = num(m.startedAt);
|
|
493
|
+
const eventId = str(idSnap.eventId);
|
|
494
|
+
yield chrome({
|
|
495
|
+
kind: 'subagent_started',
|
|
496
|
+
laneProof,
|
|
497
|
+
taskId,
|
|
498
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
499
|
+
...(model !== undefined ? { model } : {}),
|
|
500
|
+
...(taskType !== undefined ? { taskType } : {}),
|
|
501
|
+
...(seq !== undefined ? { seq } : {}),
|
|
502
|
+
...(workflowRunId !== undefined ? { workflowRunId } : {}),
|
|
503
|
+
...(workflowAgentLabel !== undefined ? { workflowAgentLabel } : {}),
|
|
504
|
+
...(parentTaskId !== undefined ? { parentTaskId } : {}),
|
|
505
|
+
...(parentSessionId !== undefined ? { parentSessionId } : {}),
|
|
506
|
+
...(rootSessionId !== undefined ? { rootSessionId } : {}),
|
|
507
|
+
...(name !== undefined ? { name } : {}),
|
|
508
|
+
...(spawnName !== undefined ? { spawnName } : {}),
|
|
509
|
+
...(agentType !== undefined ? { agentType } : {}),
|
|
510
|
+
...(startedAt !== undefined ? { startedAt } : {}),
|
|
511
|
+
...(eventId !== undefined ? { eventId } : {}),
|
|
512
|
+
});
|
|
513
|
+
};
|
|
407
514
|
const promptManifestRows = (v, pick) => {
|
|
408
515
|
if (!Array.isArray(v))
|
|
409
516
|
return undefined;
|
|
@@ -516,7 +623,8 @@ const promptSuggestionsArm = function* (m) {
|
|
|
516
623
|
yield chrome({ kind: 'prompt_suggestions', laneProof: mainLane(), suggestions: list });
|
|
517
624
|
}
|
|
518
625
|
};
|
|
519
|
-
const toolEndResultArm = function* (m,
|
|
626
|
+
const toolEndResultArm = function* (m, deps) {
|
|
627
|
+
const { idOf, cards, panel, ctx, inst, pass } = deps;
|
|
520
628
|
const callId = typeof m.toolCallId === 'string' ? m.toolCallId : undefined;
|
|
521
629
|
recordEngineToolLabel(callId, m.label);
|
|
522
630
|
if (callId !== undefined) {
|
|
@@ -524,10 +632,25 @@ const toolEndResultArm = function* (m, { idOf, cards, panel }) {
|
|
|
524
632
|
if (launched !== null)
|
|
525
633
|
registerSubagentContentAlias(callId, launched.taskId);
|
|
526
634
|
}
|
|
635
|
+
if (callId !== undefined && isUnsettledHeldToolEnd(m)) {
|
|
636
|
+
const held = cards.detach(callId);
|
|
637
|
+
if (held !== undefined) {
|
|
638
|
+
inst.parkToolRow({ sessionId: ctx.sessionId, toolCallId: callId, card: held, pass });
|
|
639
|
+
yield chrome({ kind: 'tool_parked', laneProof: laneOfCard(held), toolUseId: callId, ...(held.rowUuid !== undefined ? { rowUuid: held.rowUuid } : {}) });
|
|
640
|
+
}
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
527
643
|
if (callId !== undefined) {
|
|
528
644
|
yield* panel.settle(callId, m.isError === true, m.output !== undefined ? flattenWireOutput(m.output) : undefined);
|
|
529
645
|
}
|
|
530
|
-
|
|
646
|
+
let p = callId !== undefined ? cards.peek(callId) : undefined;
|
|
647
|
+
if (p === undefined && callId !== undefined) {
|
|
648
|
+
const claimed = claimParkedCard(m, callId, readFrameStringKey(m, 'toolName'), deps);
|
|
649
|
+
if (claimed !== undefined) {
|
|
650
|
+
cards.open(claimed);
|
|
651
|
+
p = claimed;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
531
654
|
if (p === undefined || callId === undefined)
|
|
532
655
|
return;
|
|
533
656
|
const structured = m.structured;
|
|
@@ -537,6 +660,7 @@ const toolEndResultArm = function* (m, { idOf, cards, panel }) {
|
|
|
537
660
|
const closeParent = typeof closeParentRaw === 'string' ? closeParentRaw : undefined;
|
|
538
661
|
const stampedRaw = m._sema_denial_kind;
|
|
539
662
|
const closeDenialKindRaw = typeof stampedRaw === 'string' ? stampedRaw : ccToolDenialKindForToolEnd(m);
|
|
663
|
+
const closeGate = guardedRead(() => gateOutcomeOf(m));
|
|
540
664
|
yield* cards.close(p, {
|
|
541
665
|
output: m.output,
|
|
542
666
|
structured,
|
|
@@ -544,8 +668,10 @@ const toolEndResultArm = function* (m, { idOf, cards, panel }) {
|
|
|
544
668
|
isError: m.isError === true,
|
|
545
669
|
eventId: closeEventId,
|
|
546
670
|
parentToolCallId: closeParent,
|
|
671
|
+
engineRef: engineRefOf(m),
|
|
547
672
|
...(typeof closeDenialKindRaw === 'string' ? { denialKind: closeDenialKindRaw } : {}),
|
|
548
|
-
...(
|
|
673
|
+
...(closeGate !== undefined ? { gate: closeGate } : {}),
|
|
674
|
+
closeArm: m,
|
|
549
675
|
});
|
|
550
676
|
const s = structured !== undefined && structured !== null && typeof structured === 'object'
|
|
551
677
|
? structured
|
|
@@ -641,7 +767,7 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
|
|
|
641
767
|
: typeof input.task === 'string'
|
|
642
768
|
? input.task
|
|
643
769
|
: undefined;
|
|
644
|
-
const identity = resolveEnginePanelTaskId(taskId
|
|
770
|
+
const identity = resolveEnginePanelTaskId(taskId);
|
|
645
771
|
if (!panel.isLive(taskId)) {
|
|
646
772
|
yield* panel.start(taskId, fleetRowAgentType(identity.taskId));
|
|
647
773
|
}
|
|
@@ -761,6 +887,8 @@ const resultArm = function* (m, { ctx, idOf, text, cards, panel, flags }) {
|
|
|
761
887
|
resultLength: terminalText.length,
|
|
762
888
|
});
|
|
763
889
|
}
|
|
890
|
+
if (isReplayMarked(m))
|
|
891
|
+
yield chrome({ kind: 'result_replayed', laneProof: mainLane(), text: RESULT_REPLAYED_TEXT });
|
|
764
892
|
};
|
|
765
893
|
const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
766
894
|
const n = (m.notification ?? {});
|
|
@@ -801,7 +929,8 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
801
929
|
});
|
|
802
930
|
dropQueuedNotificationsForRun(taskId);
|
|
803
931
|
if (n.task_type !== 'background_bash' && n.task_type !== 'monitor') {
|
|
804
|
-
|
|
932
|
+
const bgSessionId = n.task_type === 'background_agent' && typeof n.sessionId === 'string' && n.sessionId.length > 0 ? n.sessionId : undefined;
|
|
933
|
+
yield* panel.settleFromNotification(taskId, isCoreTaskNotificationTerminalNotSuccess(rawStatus), bgSessionId);
|
|
805
934
|
}
|
|
806
935
|
}
|
|
807
936
|
const peerFrame = classifyPeerNotification(n);
|
|
@@ -844,23 +973,9 @@ const workflowCompleteArm = function* (m) {
|
|
|
844
973
|
});
|
|
845
974
|
};
|
|
846
975
|
const retryStatusArm = function* (m, { ctx, flags }) {
|
|
847
|
-
|
|
976
|
+
const status = retryStatusFromArm(m, ctx.now());
|
|
977
|
+
if (status === undefined)
|
|
848
978
|
return;
|
|
849
|
-
const status = mapBrainStatusToRetry({
|
|
850
|
-
phase: typeof m.phase === 'string' ? m.phase : '',
|
|
851
|
-
...(typeof m.detail === 'string' ? { detail: m.detail } : {}),
|
|
852
|
-
...(typeof m.retryInSec === 'number' ? { retryInSec: m.retryInSec } : {}),
|
|
853
|
-
...(typeof m.retryInMs === 'number' ? { retryInMs: m.retryInMs } : {}),
|
|
854
|
-
...(typeof m.attempt === 'number' ? { attempt: m.attempt } : {}),
|
|
855
|
-
...(typeof m.maxRetries === 'number' ? { maxRetries: m.maxRetries } : {}),
|
|
856
|
-
...(typeof m.errClass === 'string' ? { errClass: m.errClass } : {}),
|
|
857
|
-
...(typeof m.retryAtMs === 'number' ? { retryAtMs: m.retryAtMs } : {}),
|
|
858
|
-
...(typeof m.errorStatus === 'number' ? { errorStatus: m.errorStatus } : {}),
|
|
859
|
-
...(typeof m.elapsedMs === 'number' ? { elapsedMs: m.elapsedMs } : {}),
|
|
860
|
-
...(typeof m.timeoutMs === 'number' ? { timeoutMs: m.timeoutMs } : {}),
|
|
861
|
-
...(typeof m.providerCondition === 'string' && m.providerCondition.length > 0 ? { providerCondition: m.providerCondition } : {}),
|
|
862
|
-
...(typeof m.providerConditionSource === 'string' && m.providerConditionSource.length > 0 ? { providerConditionSource: m.providerConditionSource } : {}),
|
|
863
|
-
}, ctx.now());
|
|
864
979
|
if (status === null) {
|
|
865
980
|
if (flags.takeRetryOverlay())
|
|
866
981
|
yield chrome({ kind: 'retry_status', laneProof: mainLane(), status: null });
|
|
@@ -869,11 +984,31 @@ const retryStatusArm = function* (m, { ctx, flags }) {
|
|
|
869
984
|
yield chrome({ kind: 'retry_status', laneProof: mainLane(), status });
|
|
870
985
|
flags.noteRetryOverlay();
|
|
871
986
|
};
|
|
987
|
+
const terminalFactArm = function* (m, { ctx, inst, pass }) {
|
|
988
|
+
const taskId = readFrameStringKey(m, 'taskId');
|
|
989
|
+
const paused = guardedRead(() => {
|
|
990
|
+
const d = Object.getOwnPropertyDescriptor(m, 'paused');
|
|
991
|
+
return d !== undefined && Object.hasOwn(d, 'value') ? d.value : undefined;
|
|
992
|
+
});
|
|
993
|
+
if (typeof paused === 'object' && paused !== null) {
|
|
994
|
+
const heldCallId = readFrameStringKey(paused, 'heldCallId');
|
|
995
|
+
const checkpointId = readFrameStringKey(paused, 'checkpointId');
|
|
996
|
+
inst.noteParkedFact(ctx.sessionId, pass, {
|
|
997
|
+
...(heldCallId !== undefined ? { heldCallId } : {}),
|
|
998
|
+
...(checkpointId !== undefined ? { checkpointId } : {}),
|
|
999
|
+
...(taskId !== undefined ? { taskId } : {}),
|
|
1000
|
+
});
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
inst.retireParkedRowsOfRun(ctx.sessionId, pass, taskId);
|
|
1004
|
+
};
|
|
872
1005
|
export const ARMS = new Map([
|
|
873
1006
|
['assistant', assistantArm],
|
|
1007
|
+
['terminal_fact', terminalFactArm],
|
|
874
1008
|
['user', userArm],
|
|
875
1009
|
['tool_end_result', toolEndResultArm],
|
|
876
1010
|
['task_progress', taskProgressArm],
|
|
1011
|
+
['task_started', taskStartedArm],
|
|
877
1012
|
['stream_event', streamEventArm],
|
|
878
1013
|
['turn_usage', turnUsageArm],
|
|
879
1014
|
['result', resultArm],
|
package/dist/adapt/ids.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { AdapterContext, AdapterOutput, ChromeEvent, LaneProof } from '../seam.js';
|
|
2
|
+
import { type EngineRowRef } from '../engineRowRef.js';
|
|
2
3
|
export type Frame = Record<string, unknown>;
|
|
3
4
|
export declare const mainLane: () => LaneProof;
|
|
4
|
-
export
|
|
5
|
+
export interface RowSidecars {
|
|
6
|
+
readonly ref?: EngineRowRef;
|
|
7
|
+
readonly replay?: true;
|
|
8
|
+
}
|
|
9
|
+
export interface IdOf {
|
|
10
|
+
(frame: Frame, suffix?: string): string;
|
|
11
|
+
adopt(id: string, ref: EngineRowRef | undefined): string;
|
|
12
|
+
sidecarsOfId(id: string): RowSidecars | undefined;
|
|
13
|
+
}
|
|
5
14
|
export declare function messageIdentityOf(frame: Frame, ctx: {
|
|
6
15
|
model?: string;
|
|
7
16
|
}): {
|
|
@@ -11,3 +20,5 @@ export declare function messageIdentityOf(frame: Frame, ctx: {
|
|
|
11
20
|
export declare const chrome: (event: ChromeEvent) => AdapterOutput;
|
|
12
21
|
export declare const transcript: (message: Frame, nowMs: number) => AdapterOutput;
|
|
13
22
|
export declare function makeIdOf(ctx: AdapterContext): IdOf;
|
|
23
|
+
export declare function segmentRowId(idOf: IdOf, open: Frame, close: Frame | null, tag: 'text' | 'thinking'): string;
|
|
24
|
+
export declare function carryRowSidecars(out: AdapterOutput, idOf: IdOf): AdapterOutput;
|
package/dist/adapt/ids.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { deriveTranscriptId } from '../seam.js';
|
|
2
|
+
import { engineRefOf } from '../engineRowRef.js';
|
|
3
|
+
import { isReplayMarked } from '../replayBody.js';
|
|
2
4
|
export const mainLane = () => ({ lane: 'main' });
|
|
3
5
|
export function messageIdentityOf(frame, ctx) {
|
|
4
6
|
const msg = frame.message;
|
|
@@ -24,17 +26,66 @@ export const transcript = (message, nowMs) => {
|
|
|
24
26
|
: { ...message, timestamp: new Date(nowMs).toISOString() }),
|
|
25
27
|
};
|
|
26
28
|
};
|
|
29
|
+
function frameKeyOf(frame) {
|
|
30
|
+
if (frame === null)
|
|
31
|
+
return undefined;
|
|
32
|
+
return typeof frame.id === 'string' && frame.id.length > 0
|
|
33
|
+
? frame.id
|
|
34
|
+
: typeof frame.uuid === 'string' && frame.uuid.length > 0
|
|
35
|
+
? frame.uuid
|
|
36
|
+
: undefined;
|
|
37
|
+
}
|
|
27
38
|
export function makeIdOf(ctx) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
const ledger = new Map();
|
|
40
|
+
const note = (id, ref, replay) => {
|
|
41
|
+
if ((ref === undefined && !replay) || ledger.has(id))
|
|
42
|
+
return;
|
|
43
|
+
ledger.set(id, { ...(ref !== undefined ? { ref } : {}), ...(replay ? { replay: true } : {}) });
|
|
44
|
+
};
|
|
45
|
+
const idOf = (frame, suffix) => {
|
|
46
|
+
const base = frameKeyOf(frame);
|
|
47
|
+
const id = deriveTranscriptId({
|
|
35
48
|
...(base !== undefined ? { id: base } : {}),
|
|
36
|
-
...(typeof frame.seq === 'number' ? { seq: frame.seq } : {}),
|
|
37
49
|
...(typeof frame.toolCallId === 'string' ? { toolCallId: frame.toolCallId } : {}),
|
|
38
50
|
}, ctx, suffix);
|
|
51
|
+
note(id, engineRefOf(frame), isReplayMarked(frame));
|
|
52
|
+
return id;
|
|
53
|
+
};
|
|
54
|
+
return Object.assign(idOf, {
|
|
55
|
+
adopt: (id, ref) => {
|
|
56
|
+
note(id, ref, false);
|
|
57
|
+
return id;
|
|
58
|
+
},
|
|
59
|
+
sidecarsOfId: (id) => {
|
|
60
|
+
const row = ledger.get(id);
|
|
61
|
+
if (row === undefined)
|
|
62
|
+
return undefined;
|
|
63
|
+
return { ...(row.ref !== undefined ? { ref: { ...row.ref } } : {}), ...(row.replay === true ? { replay: true } : {}) };
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function segmentRowId(idOf, open, close, tag) {
|
|
68
|
+
const closeKey = frameKeyOf(close);
|
|
69
|
+
if (closeKey === undefined)
|
|
70
|
+
return idOf.adopt(idOf({}, tag), engineRefOf(open));
|
|
71
|
+
return idOf(open, `${tag}~${closeKey}`);
|
|
72
|
+
}
|
|
73
|
+
export function carryRowSidecars(out, idOf) {
|
|
74
|
+
if (out.plane !== 'transcript')
|
|
75
|
+
return out;
|
|
76
|
+
const row = out.message;
|
|
77
|
+
const uuid = row.uuid;
|
|
78
|
+
if (typeof uuid !== 'string')
|
|
79
|
+
return out;
|
|
80
|
+
const side = idOf.sidecarsOfId(uuid);
|
|
81
|
+
if (side === undefined)
|
|
82
|
+
return out;
|
|
83
|
+
const addRef = side.ref !== undefined && !Object.hasOwn(row, '_sema_engine_ref');
|
|
84
|
+
const addReplay = side.replay === true && !Object.hasOwn(row, '_sema_replay');
|
|
85
|
+
if (!addRef && !addReplay)
|
|
86
|
+
return out;
|
|
87
|
+
return {
|
|
88
|
+
plane: 'transcript',
|
|
89
|
+
message: Object.assign({}, out.message, addRef ? { _sema_engine_ref: side.ref } : {}, addReplay ? { _sema_replay: true } : {}),
|
|
39
90
|
};
|
|
40
91
|
}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
import type { PendingToolUse } from './toolCards.js';
|
|
2
|
+
import type { EngineRowRef } from '../engineRowRef.js';
|
|
3
|
+
export declare const PARKED_TOOL_ROWS_MAX = 64;
|
|
4
|
+
export declare const LATEST_START_ROWS_MAX = 1024;
|
|
5
|
+
export interface ParkedToolRow {
|
|
6
|
+
readonly key: string;
|
|
7
|
+
readonly sessionId: string;
|
|
8
|
+
readonly toolCallId: string;
|
|
9
|
+
readonly card: PendingToolUse;
|
|
10
|
+
readonly pass?: number;
|
|
11
|
+
readonly seq: number;
|
|
12
|
+
parkedRun?: string;
|
|
13
|
+
checkpointId?: string;
|
|
14
|
+
}
|
|
1
15
|
export interface AdapterInstanceLedger {
|
|
2
16
|
hasRenderedNotification(key: string): boolean;
|
|
3
17
|
addRenderedNotification(key: string): void;
|
|
@@ -7,5 +21,41 @@ export interface AdapterInstanceLedger {
|
|
|
7
21
|
markWorkflowCard(toolUseId: string): void;
|
|
8
22
|
hasFiredSubagentStart(taskId: string): boolean;
|
|
9
23
|
markFiredSubagentStart(taskId: string): void;
|
|
24
|
+
beginPass(): number;
|
|
25
|
+
parkToolRow(row: ParkToolRowInput): void;
|
|
26
|
+
parkedToolRowFor(sessionId: string, toolCallId: string): ParkedToolRow | undefined;
|
|
27
|
+
noteParkedFact(sessionId: string, pass: number, fact: ParkedTerminalFact): void;
|
|
28
|
+
retireParkedRowsOfRun(sessionId: string, pass: number, taskId: string | undefined): void;
|
|
29
|
+
dropParkedToolRow(key: string): void;
|
|
30
|
+
noteStartRow(sessionId: string, toolCallId: string, rowUuid: string | undefined): void;
|
|
31
|
+
listParkedToolRows(): ParkedToolRowSnapshot[];
|
|
32
|
+
takeParkedToolRows(rows: {} | null | undefined): number;
|
|
33
|
+
}
|
|
34
|
+
export interface ParkToolRowInput {
|
|
35
|
+
readonly sessionId: string;
|
|
36
|
+
readonly toolCallId: string;
|
|
37
|
+
readonly card: PendingToolUse;
|
|
38
|
+
readonly pass: number;
|
|
39
|
+
}
|
|
40
|
+
export interface ParkedTerminalFact {
|
|
41
|
+
readonly heldCallId?: string;
|
|
42
|
+
readonly checkpointId?: string;
|
|
43
|
+
readonly taskId?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ParkedToolCardSnapshot {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly rawInput: {} | null | undefined;
|
|
49
|
+
readonly eventId?: string;
|
|
50
|
+
readonly parentToolCallId?: string;
|
|
51
|
+
readonly rowUuid?: string;
|
|
52
|
+
readonly engineRef?: EngineRowRef;
|
|
53
|
+
}
|
|
54
|
+
export interface ParkedToolRowSnapshot {
|
|
55
|
+
readonly sessionId: string;
|
|
56
|
+
readonly toolCallId: string;
|
|
57
|
+
readonly parkedRun?: string;
|
|
58
|
+
readonly checkpointId?: string;
|
|
59
|
+
readonly card: ParkedToolCardSnapshot;
|
|
10
60
|
}
|
|
11
61
|
export declare function createAdapterInstanceLedger(): AdapterInstanceLedger;
|