@sema-agent/client-core 0.99.0 → 0.101.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 +572 -0
- package/README.md +174 -114
- package/dist/adapt/arms.js +109 -50
- package/dist/adapt/panelTasks.d.ts +2 -1
- package/dist/adapt/panelTasks.js +32 -9
- package/dist/adapt/textStream.d.ts +1 -1
- package/dist/adapt/textStream.js +58 -32
- package/dist/adapt/toolCards.js +9 -8
- package/dist/adapt.js +7 -1
- package/dist/adapter/activeRunSelfHeal.d.ts +31 -2
- package/dist/adapter/activeRunSelfHeal.js +162 -13
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +157 -20
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
- package/dist/adapter/downstream/terminalToSdkResult.js +219 -39
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/adapter/runStream.d.ts +4 -4
- package/dist/adapter/runStream.js +184 -42
- package/dist/adapter/types.d.ts +2 -0
- package/dist/agentsWireCaps.d.ts +9 -7
- package/dist/agentsWireCaps.js +101 -17
- package/dist/approvalDecidedByCapability.js +2 -2
- package/dist/approvalFrameFamilies.d.ts +33 -0
- package/dist/approvalFrameFamilies.js +120 -0
- package/dist/approvalsStreamLiveCapability.js +2 -2
- package/dist/attachmentsWireCaps.js +41 -13
- package/dist/callerCwdCapability.js +2 -2
- package/dist/centerWiringCapability.js +2 -2
- package/dist/clockReading.d.ts +2 -0
- package/dist/clockReading.js +4 -0
- package/dist/cloudConfigWireCaps.d.ts +28 -5
- package/dist/cloudConfigWireCaps.js +334 -103
- package/dist/compactionStatus.d.ts +34 -0
- package/dist/compactionStatus.js +196 -0
- package/dist/coreValuePorts.d.ts +12 -2
- package/dist/coreValuePorts.js +9 -0
- package/dist/decideFailureNote.js +8 -6
- package/dist/decideReceipt.js +2 -2
- package/dist/deviceExecutorManagementCapability.js +2 -2
- package/dist/deviceFlowPolling.js +1 -1
- package/dist/disableSkillsWire.d.ts +1 -1
- package/dist/disableSkillsWire.js +4 -3
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +215 -13
- package/dist/engineAgentPanelStore.d.ts +7 -4
- package/dist/engineCapReader.js +1 -1
- package/dist/engineConfigDrift.js +1 -1
- package/dist/engineErrorCodes.d.ts +23 -6
- package/dist/engineErrorCodes.js +36 -11
- package/dist/engineGenerationConvergence.d.ts +39 -0
- package/dist/engineGenerationConvergence.js +95 -0
- package/dist/engineGenerationPort.d.ts +61 -0
- package/dist/engineGenerationPort.js +144 -0
- package/dist/engineHealthFacts.d.ts +23 -0
- package/dist/engineHealthFacts.js +92 -0
- package/dist/engineIdentity.d.ts +4 -0
- package/dist/engineIdentity.js +11 -0
- package/dist/engineNoticeCodes.d.ts +2 -5
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.js +2 -2
- package/dist/engineToolDirectory.d.ts +3 -0
- package/dist/engineToolDirectory.js +6 -4
- package/dist/engineWireFor.d.ts +99 -0
- package/dist/engineWireFor.js +248 -6
- package/dist/engineWireTarget.d.ts +1 -0
- package/dist/engineWireTarget.js +8 -0
- package/dist/env/uiLanguage.js +1 -1
- package/dist/errorSupplementRoles.d.ts +3 -0
- package/dist/errorSupplementRoles.js +37 -0
- package/dist/eventLeg.d.ts +1 -7
- package/dist/eventLeg.js +7 -8
- package/dist/executionLaneCapability.js +2 -2
- package/dist/fileHistoryCaptureCapability.d.ts +0 -3
- package/dist/fileHistoryCaptureCapability.js +3 -7
- package/dist/finalVerifyWire.d.ts +6 -3
- package/dist/finalVerifyWire.js +6 -23
- package/dist/flagInput.d.ts +4 -0
- package/dist/flagInput.js +24 -0
- package/dist/fleet/fleetLedger.js +5 -2
- package/dist/fleet/fleetProjection.d.ts +1 -0
- package/dist/fleet/fleetProjection.js +15 -2
- package/dist/gateVocabulary.js +3 -0
- package/dist/generated/engineFactTables.d.ts +7 -2
- package/dist/generated/engineFactTables.js +79 -0
- package/dist/generated/engineNoticeTables.js +15 -0
- package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
- package/dist/generated/settingsSchemaActiveTiers.js +14 -0
- package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
- package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
- package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
- package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
- package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
- package/dist/generated/settingsSchemaDefaultModel.js +25 -0
- package/dist/generated/settingsSchemaFns.d.ts +66 -0
- package/dist/generated/settingsSchemaFns.js +38 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.js +156 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
- package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
- package/dist/generated/settingsSchemaSettingsSources.js +58 -0
- package/dist/generated/settingsSchemaTables.d.ts +3 -0
- package/dist/generated/settingsSchemaTables.js +18 -0
- package/dist/generated/settingsSchemaTypes.d.ts +28 -0
- package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
- package/dist/generated/settingsSchemaUrlPattern.js +183 -0
- package/dist/headlessPermissionModeWire.d.ts +18 -2
- package/dist/headlessPermissionModeWire.js +30 -19
- package/dist/hitl/allowRuleShadow.js +9 -7
- package/dist/hitl/approvalCardReading.d.ts +3 -0
- package/dist/hitl/approvalCardReading.js +17 -0
- package/dist/hitl/approvalCardReasons.js +2 -2
- package/dist/hitl/approvalCompleteParked.js +1 -1
- package/dist/hitl/approvalDelivery.d.ts +87 -0
- package/dist/hitl/approvalDelivery.js +193 -0
- package/dist/hitl/approvalHolds.d.ts +14 -0
- package/dist/hitl/approvalHolds.js +41 -0
- package/dist/hitl/approvalResolution.d.ts +11 -0
- package/dist/hitl/approvalResolution.js +50 -11
- package/dist/hitl/askClassPair.d.ts +8 -2
- package/dist/hitl/askClassPair.js +31 -4
- package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
- package/dist/hitl/askParkAutoReopenBlock.js +117 -0
- package/dist/hitl/askParkRowRouting.js +4 -1
- package/dist/hitl/attributionLadder.d.ts +62 -0
- package/dist/hitl/attributionLadder.js +138 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
- package/dist/hitl/automaticAnswerVerdict.js +46 -11
- package/dist/hitl/crashConverged.js +2 -2
- package/dist/hitl/decisionConflict.d.ts +6 -2
- package/dist/hitl/decisionConflict.js +24 -9
- package/dist/hitl/decisionLedger.d.ts +55 -0
- package/dist/hitl/decisionLedger.js +156 -0
- package/dist/hitl/decisionRefusal.d.ts +21 -10
- package/dist/hitl/decisionRefusal.js +100 -55
- package/dist/hitl/decisionSend.d.ts +116 -0
- package/dist/hitl/decisionSend.js +563 -0
- package/dist/hitl/frameRouter.d.ts +1 -0
- package/dist/hitl/frameRouter.js +9 -2
- package/dist/hitl/hitlBridge.d.ts +18 -6
- package/dist/hitl/hitlBridge.js +59 -43
- package/dist/hitl/livePendingAsk.js +4 -3
- package/dist/hitl/noAllowCause.js +1 -1
- package/dist/hitl/parkResolver.js +3 -2
- package/dist/hitl/persistedRulesWire.js +1 -0
- package/dist/hitl/planReviewWire.d.ts +4 -0
- package/dist/hitl/planReviewWire.js +104 -106
- package/dist/hitl/resumeRunningCard.d.ts +3 -2
- package/dist/hitl/resumeRunningCard.js +17 -11
- package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
- package/dist/hitl/sessionPolicyDeliverable.js +65 -35
- package/dist/hitl/sessionPolicyWire.d.ts +13 -3
- package/dist/hitl/sessionPolicyWire.js +81 -16
- package/dist/hitl/standingRows.js +1 -1
- package/dist/hitl/toolApprovalWire.d.ts +9 -10
- package/dist/hitl/toolApprovalWire.js +103 -151
- package/dist/hookMatcherVerdict.d.ts +2 -0
- package/dist/hookMatcherVerdict.js +12 -0
- package/dist/hooksCompactTransition.d.ts +19 -0
- package/dist/hooksCompactTransition.js +41 -0
- package/dist/hooksWireCaps.d.ts +1 -1
- package/dist/hooksWireCaps.js +202 -203
- package/dist/host.d.ts +1 -14
- package/dist/host.js +0 -8
- package/dist/hostCallbackGuard.d.ts +1 -0
- package/dist/hostCallbackGuard.js +1 -1
- package/dist/hostSettingsSource.d.ts +172 -0
- package/dist/hostSettingsSource.js +675 -0
- package/dist/hostTurnSettings.d.ts +114 -19
- package/dist/hostTurnSettings.js +966 -68
- package/dist/httpHookPolicy.d.ts +37 -0
- package/dist/httpHookPolicy.js +176 -0
- package/dist/humanTurn.d.ts +4 -2
- package/dist/humanTurn.js +40 -10
- package/dist/humanTurnRead.js +4 -3
- package/dist/humanTurnSentences.d.ts +10 -0
- package/dist/humanTurnSentences.js +74 -0
- package/dist/i18n/messages.en.d.ts +313 -0
- package/dist/i18n/messages.en.js +326 -13
- package/dist/i18n/messages.zh.js +341 -13
- package/dist/i18n/translate.js +3 -3
- package/dist/index.d.ts +85 -15
- package/dist/index.js +53 -12
- package/dist/inheritEnvCapability.d.ts +4 -1
- package/dist/inheritEnvCapability.js +38 -17
- package/dist/inheritEnvWire.d.ts +2 -1
- package/dist/inheritEnvWire.js +11 -5
- package/dist/injectionLaneNotice.d.ts +5 -0
- package/dist/injectionLaneNotice.js +46 -0
- package/dist/interactiveToolsWire.d.ts +4 -2
- package/dist/interactiveToolsWire.js +5 -5
- package/dist/jsonFaithful.d.ts +20 -0
- package/dist/jsonFaithful.js +152 -0
- package/dist/limitsWire.d.ts +7 -2
- package/dist/limitsWire.js +19 -13
- package/dist/liveInitToolFace.d.ts +6 -1
- package/dist/liveInitToolFace.js +5 -3
- package/dist/liveModelCatalog.d.ts +22 -0
- package/dist/liveModelCatalog.js +132 -18
- package/dist/mcpPanel.js +3 -1
- package/dist/mcpProbeCapability.js +2 -2
- package/dist/mcpReconnect.js +2 -2
- package/dist/mcpStatusSupersetKeys.d.ts +24 -0
- package/dist/mcpStatusSupersetKeys.js +45 -0
- package/dist/mcpToolToggles.d.ts +6 -0
- package/dist/mcpToolToggles.js +47 -0
- package/dist/mcpWireCaps.d.ts +48 -4
- package/dist/mcpWireCaps.js +338 -99
- package/dist/mcpWireTransport.d.ts +4 -0
- package/dist/mcpWireTransport.js +18 -0
- package/dist/memoryComplianceCapability.js +2 -2
- package/dist/memoryOriginCapability.js +2 -2
- package/dist/model/catalogDefault.d.ts +24 -0
- package/dist/model/catalogDefault.js +4 -0
- package/dist/model/liveCatalogShape.js +5 -4
- package/dist/model/modelsPolicy.js +4 -3
- package/dist/model/onboardJudgement.d.ts +1 -0
- package/dist/model/onboardJudgement.js +1 -1
- package/dist/model/subagentModelWord.js +2 -2
- package/dist/modelCapabilityProbe.d.ts +2 -1
- package/dist/modelCapabilityProbe.js +16 -15
- package/dist/modelIdentityResolvability.d.ts +12 -1
- package/dist/modelIdentityResolvability.js +69 -28
- package/dist/modsKernelIdentity.d.ts +10 -0
- package/dist/modsKernelIdentity.js +103 -0
- package/dist/modsKernelTransit.d.ts +8 -0
- package/dist/modsKernelTransit.js +6 -0
- package/dist/notifications.d.ts +30 -12
- package/dist/notifications.js +241 -53
- package/dist/outputStyleSeatCapability.js +2 -2
- package/dist/ownKey.d.ts +37 -0
- package/dist/ownKey.js +238 -2
- package/dist/panelReduce.d.ts +5 -0
- package/dist/panelReduce.js +45 -13
- package/dist/panelStateHolder.d.ts +1 -0
- package/dist/panelStateHolder.js +10 -1
- package/dist/peerFrames.d.ts +1 -1
- package/dist/peerFrames.js +6 -2
- package/dist/peerLaneCapability.js +2 -2
- package/dist/permissionModesCapability.js +4 -4
- package/dist/permissionRuleIssue.d.ts +2 -1
- package/dist/permissionRuleIssue.js +24 -21
- package/dist/permissionRulesWriteCapability.js +2 -2
- package/dist/permissionsAllowGrantCapability.js +2 -2
- package/dist/permissionsDeclaration.d.ts +43 -4
- package/dist/permissionsDeclaration.js +102 -35
- package/dist/pluginHooksWire.d.ts +20 -4
- package/dist/pluginHooksWire.js +101 -60
- package/dist/prepareRefusal.d.ts +9 -0
- package/dist/prepareRefusal.js +90 -0
- package/dist/printInitToolFace.js +2 -2
- package/dist/printModelStatus.js +1 -1
- package/dist/projectMemory.d.ts +32 -0
- package/dist/projectMemory.js +70 -0
- package/dist/promptBlockedCopy.d.ts +2 -1
- package/dist/promptBlockedCopy.js +2 -1
- package/dist/promptDelivery.d.ts +23 -3
- package/dist/promptDelivery.js +169 -30
- package/dist/providerRejection.d.ts +19 -1
- package/dist/providerRejection.js +75 -4
- package/dist/queuedDelivery.d.ts +48 -0
- package/dist/queuedDelivery.js +233 -0
- package/dist/reattachWindow.d.ts +94 -0
- package/dist/reattachWindow.js +127 -0
- package/dist/request/printNotification.d.ts +1 -1
- package/dist/request/printNotification.js +5 -1
- package/dist/request/submissionIdentity.d.ts +37 -0
- package/dist/request/submissionIdentity.js +65 -0
- package/dist/request/taskRequest.d.ts +22 -14
- package/dist/request/taskRequest.js +312 -202
- package/dist/resultFrameKeys.d.ts +1 -0
- package/dist/resultFrameKeys.js +4 -1
- package/dist/resumeRefusalCopy.d.ts +3 -1
- package/dist/resumeRefusalCopy.js +22 -4
- package/dist/retryStatus.d.ts +26 -0
- package/dist/retryStatus.js +133 -28
- package/dist/rewindArchiveCapability.js +2 -2
- package/dist/rewindEngineAction.d.ts +2 -0
- package/dist/rewindEngineAction.js +23 -1
- package/dist/rowKind.d.ts +36 -0
- package/dist/rowKind.js +97 -0
- package/dist/ruleCompileVerdict.d.ts +18 -0
- package/dist/ruleCompileVerdict.js +67 -2
- package/dist/ruleReadings.d.ts +58 -0
- package/dist/ruleReadings.js +132 -0
- package/dist/ruleRefusalSentence.d.ts +8 -0
- package/dist/ruleRefusalSentence.js +64 -0
- package/dist/runCancelContext.d.ts +0 -1
- package/dist/runCancelContext.js +1 -2
- package/dist/runTerminal.d.ts +5 -0
- package/dist/runTerminal.js +52 -17
- package/dist/sandboxWire.d.ts +3 -2
- package/dist/sandboxWire.js +59 -27
- package/dist/scenarioRefusal.d.ts +2 -1
- package/dist/scenarioRefusal.js +6 -6
- package/dist/scenarioSkills.d.ts +20 -0
- package/dist/scenarioSkills.js +72 -0
- package/dist/scenarioWire.d.ts +5 -2
- package/dist/scenarioWire.js +9 -9
- package/dist/sealedKeyCapability.js +2 -2
- package/dist/seam.d.ts +26 -9
- package/dist/seam.js +44 -4
- package/dist/seatContract.d.ts +62 -9
- package/dist/seatContract.js +70 -25
- package/dist/selfOrchestrationDenial.js +1 -1
- package/dist/sessionPolicyCapability.js +2 -2
- package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
- package/dist/sessionRulesChildrenReadLive.js +5 -0
- package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
- package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
- package/dist/sessionSyncFileHistoryCapability.js +2 -2
- package/dist/settingsCredentialKeyPaths.d.ts +8 -0
- package/dist/settingsCredentialKeyPaths.js +274 -0
- package/dist/settingsHooksSalvage.d.ts +1 -0
- package/dist/settingsHooksSalvage.js +7 -1
- package/dist/settingsLayerAdmission.d.ts +4 -0
- package/dist/settingsLayerAdmission.js +16 -0
- package/dist/skillToolListsCapability.js +6 -5
- package/dist/skillsWireCaps.d.ts +14 -3
- package/dist/skillsWireCaps.js +48 -18
- package/dist/slashCommandGate.d.ts +24 -0
- package/dist/slashCommandGate.js +74 -0
- package/dist/slashCommandTable.d.ts +14 -0
- package/dist/slashCommandTable.js +99 -0
- package/dist/sqlEngineCapability.js +2 -2
- package/dist/steerPriorityCapability.js +2 -2
- package/dist/storePostureCapability.js +2 -2
- package/dist/subagent/agentStateDetail.js +1 -1
- package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
- package/dist/subagent/engineDelegatedPrompt.js +38 -7
- package/dist/subagent/engineRowStopGate.js +2 -2
- package/dist/subagent/engineSubagentResume.js +3 -3
- package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
- package/dist/subagent/engineTaskHandleWire.js +10 -0
- package/dist/subagentContentStore.d.ts +1 -0
- package/dist/subagentContentStore.js +135 -27
- package/dist/submitFailure.d.ts +8 -0
- package/dist/submitFailure.js +17 -0
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +7 -0
- package/dist/terminationIntent.d.ts +55 -0
- package/dist/terminationIntent.js +352 -0
- package/dist/toolHistoryMismatch.d.ts +8 -0
- package/dist/toolHistoryMismatch.js +37 -6
- package/dist/toolResult.d.ts +13 -3
- package/dist/toolResult.js +158 -9
- package/dist/toolResultContent.d.ts +13 -0
- package/dist/toolResultContent.js +82 -7
- package/dist/toolRoster.d.ts +18 -0
- package/dist/toolRoster.js +64 -0
- package/dist/toolsFlagNames.d.ts +8 -0
- package/dist/toolsFlagNames.js +110 -0
- package/dist/turnFailurePresentation.js +41 -96
- package/dist/usageLimitAutoResume.d.ts +74 -0
- package/dist/usageLimitAutoResume.js +227 -0
- package/dist/userAttachmentEnvelope.js +1 -1
- package/dist/userAttachmentSeat.js +5 -5
- package/dist/userInvokedSkillsCapability.js +2 -2
- package/dist/webSearchBackendCapability.js +2 -2
- package/dist/wireErrorTriage.js +99 -50
- package/dist/wireFailureShape.d.ts +25 -1
- package/dist/wireFailureShape.js +92 -5
- package/dist/wireRefusalCopy.d.ts +75 -18
- package/dist/wireRefusalCopy.js +532 -148
- package/dist/wiringFleetDoctor.d.ts +3 -0
- package/dist/wiringFleetDoctor.js +21 -0
- package/dist/workflow.d.ts +2 -1
- package/dist/workflow.js +38 -1
- package/dist/workflowClient.d.ts +2 -7
- package/dist/workflowsJournalCapability.js +2 -2
- package/dist/writeProtectionCapability.js +2 -2
- package/docs/INTEGRATION-CLIENTS.md +1013 -190
- package/package.json +15 -4
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import { eventSeq, stamp, } from './types.js';
|
|
1
|
+
import { eventSeq, isSubFlowSegmentEnd, SEGMENT_END_IDENTITY_KEYS, snapshotIsSubFlow, stamp, } from './types.js';
|
|
2
2
|
import { eventToSdkMessage, turnEndUsage } from './downstream/eventToSdkMessage.js';
|
|
3
3
|
import { turnUsageToModelUsage } from './downstream/turnUsageToModelUsage.js';
|
|
4
|
-
import { readRunCostFacts, terminalToSdkResult, TOOL_INPUT_JOIN_MAX_CALLS } from './downstream/terminalToSdkResult.js';
|
|
4
|
+
import { terminalPartsOfObserved, readRunCostFacts, terminalToSdkResult, TOOL_INPUT_JOIN_MAX_CALLS } from './downstream/terminalToSdkResult.js';
|
|
5
5
|
import { terminalRunIdOf, terminalUuidOf } from '../engineRowRef.js';
|
|
6
6
|
import { publishSubagentContentEvent, subagentContentEventOf } from '../subagentContentStore.js';
|
|
7
7
|
import { OUTPUT_INVALID, activeRunBusyCarrierOf, classifyActiveRunBusy, isCorruptSessionCode, isLimitsExceededCode } from '../engineErrorCodes.js';
|
|
8
8
|
import { doneResultView, isReplayedTerminal } from '../replayBody.js';
|
|
9
|
-
import { readFrameStringKey } from '../ownKey.js';
|
|
9
|
+
import { carriesAnswerText, guardedRead, readFrameStringKey } from '../ownKey.js';
|
|
10
|
+
import { ccErrorOfProviderStatus } from '../providerRejection.js';
|
|
10
11
|
import { corruptSessionContent } from '../corruptSessionCopy.js';
|
|
11
12
|
import { abortCauseNoteOf } from '../runCancelContext.js';
|
|
12
|
-
import { classifyToolHistoryMismatch,
|
|
13
|
-
import { isReviewPark, readRunTerminal, runTerminalCode } from '../runTerminal.js';
|
|
13
|
+
import { classifyToolHistoryMismatch, noteToolHistoryTerminalFacts, SEMA_TOOL_HISTORY_ACCEPTED_KEY, openToolHistoryGeneration, TOOL_HISTORY_REWIND_SENTENCE, toolHistoryMismatchRowKey, toolHistoryRepeatSentence, toolHistoryRewindOffered, } from '../toolHistoryMismatch.js';
|
|
14
|
+
import { isReviewPark, readRunTerminal, runTerminalCode, runTerminalCodedDetail } from '../runTerminal.js';
|
|
14
15
|
import { parkHeldCallIdOf } from '../engineRowRef.js';
|
|
15
16
|
import { providerRejectionResend } from '../providerRejection.js';
|
|
16
17
|
import { displayUntrusted, washCredentials } from '../displayUntrusted.js';
|
|
17
|
-
import {
|
|
18
|
+
import { runBlockedText } from '../promptBlockedCopy.js';
|
|
19
|
+
import { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, RUN_STOPPED_MESSAGE_PREFIX, SESSION_BUSY_ROW_LEAD, legacyRowKindOfText, } from '../rowKind.js';
|
|
20
|
+
export { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, RUN_STOPPED_MESSAGE_PREFIX };
|
|
18
21
|
import { ccToolDenialKindForToolEnd, gateDeniedBy, gateOutcomeOf } from '../gateOutcome.js';
|
|
19
22
|
import { resumeReopenContent, resumeReopenFromError, suspendedReopenOf } from '../hitl/suspendedReopen.js';
|
|
20
23
|
import { isCcToolDenialKind, isCcToolDenialKindADenial, isGateDeniedByWord } from '../gateVocabulary.js';
|
|
@@ -109,22 +112,17 @@ function busyReadOfFrame(ev, doneTerminal, preReadActiveTaskId) {
|
|
|
109
112
|
const cls = classifyActiveRunBusy({ errorCode: (isDone ? runTerminalCode(terminal) : undefined) ?? flatCode, activeTaskId });
|
|
110
113
|
return { carrier, cls };
|
|
111
114
|
}
|
|
112
|
-
export const RUN_STOPPED_MESSAGE_PREFIX = 'Run stopped';
|
|
113
|
-
export const RUN_BLOCKED_MESSAGE_PREFIX = 'Run blocked';
|
|
114
115
|
export function isGovernanceStopRowText(text) {
|
|
115
|
-
|
|
116
|
-
return t.startsWith(`${RUN_STOPPED_MESSAGE_PREFIX}:`) || t.startsWith(`${RUN_BLOCKED_MESSAGE_PREFIX}`) || t.startsWith(PROMPT_BLOCKED_BY_HOOK_ROW_LEAD);
|
|
116
|
+
return legacyRowKindOfText(text) === 'governance_stop';
|
|
117
117
|
}
|
|
118
|
-
export const MODEL_OUTPUT_ERROR_PREFIX = 'Model output error';
|
|
119
118
|
export function isModelOutputErrorText(text) {
|
|
120
119
|
const anchors = ['tool call argument(s) not valid JSON', 'tool call(s) arrived with no tool name and cannot be executed'];
|
|
121
120
|
const t = text.trimStart();
|
|
122
121
|
return anchors.some((a) => t.startsWith(a));
|
|
123
122
|
}
|
|
124
123
|
export function isModelOutputErrorRowText(text) {
|
|
125
|
-
return text
|
|
124
|
+
return legacyRowKindOfText(text) === 'model_output_error';
|
|
126
125
|
}
|
|
127
|
-
export const OUTCOME_UNKNOWN_ROW_PREFIX = 'Outcome unknown';
|
|
128
126
|
function apiErrorRowBitsOf(read) {
|
|
129
127
|
try {
|
|
130
128
|
const status = read.carrier.status;
|
|
@@ -134,6 +132,7 @@ function apiErrorRowBitsOf(read) {
|
|
|
134
132
|
...(typeof status === 'number' && Number.isInteger(status) && status >= 100 && status <= 999 ? { status } : {}),
|
|
135
133
|
...(providerCondition !== undefined ? { providerCondition } : {}),
|
|
136
134
|
...(errorCode !== undefined ? { errorCode } : {}),
|
|
135
|
+
...(read.coded !== undefined ? { codedDetail: read.coded } : {}),
|
|
137
136
|
};
|
|
138
137
|
return Object.keys(bits).length > 0 ? bits : undefined;
|
|
139
138
|
}
|
|
@@ -141,7 +140,23 @@ function apiErrorRowBitsOf(read) {
|
|
|
141
140
|
return undefined;
|
|
142
141
|
}
|
|
143
142
|
}
|
|
144
|
-
function
|
|
143
|
+
function wayOutFactsOfApiError(read) {
|
|
144
|
+
try {
|
|
145
|
+
const bits = apiErrorRowBitsOf(read);
|
|
146
|
+
const route = read.detail !== undefined && ownDataBit(read.detail, 'kind') === PROVIDER_REJECTED_DETAIL ? plainObjectOf(ownDataBit(read.detail, 'route')) : undefined;
|
|
147
|
+
const credentialSource = route === undefined ? undefined : nonEmptyStr(ownDataBit(route, 'credentialSource'));
|
|
148
|
+
return {
|
|
149
|
+
...(bits?.status !== undefined ? { status: bits.status } : {}),
|
|
150
|
+
...(bits?.providerCondition !== undefined ? { providerCondition: bits.providerCondition } : {}),
|
|
151
|
+
...(credentialSource !== undefined ? { credentialSource } : {}),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return {};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function syntheticTerminalRow(ctx, identity, replayed, kind, text, historyKey, resend, apiError, owner) {
|
|
159
|
+
const ccError = kind === 'api_error' && apiError?.status !== undefined ? ccErrorOfProviderStatus(apiError.status) : undefined;
|
|
145
160
|
return stamp(ctx, {
|
|
146
161
|
uuid: identity.runId === undefined ? undefined : terminalUuidOf(identity.runId, identity.label),
|
|
147
162
|
session_id: undefined,
|
|
@@ -154,9 +169,41 @@ function syntheticTerminalRow(ctx, identity, replayed, text, historyKey, resend,
|
|
|
154
169
|
...(apiError?.status !== undefined ? { _sema_api_error_status: apiError.status } : {}),
|
|
155
170
|
...(apiError?.providerCondition !== undefined ? { _sema_provider_condition: apiError.providerCondition } : {}),
|
|
156
171
|
...(apiError?.errorCode !== undefined ? { _sema_api_error_code: apiError.errorCode } : {}),
|
|
172
|
+
...(apiError?.codedDetail !== undefined ? { _sema_coded_detail: apiError.codedDetail } : {}),
|
|
173
|
+
_sema_row_kind: kind,
|
|
174
|
+
...(ccError !== undefined ? { error: ccError } : {}),
|
|
157
175
|
...(replayed ? { _sema_replay: true } : {}),
|
|
176
|
+
...(owner !== undefined ? { _sema_terminal_owner: owner } : {}),
|
|
158
177
|
});
|
|
159
178
|
}
|
|
179
|
+
function withTerminalOwner(frame, owner) {
|
|
180
|
+
return owner === undefined ? frame : { ...frame, _sema_terminal_owner: owner };
|
|
181
|
+
}
|
|
182
|
+
function withHistoryAccepted(frame, accepted) {
|
|
183
|
+
return accepted === undefined ? frame : { ...frame, [SEMA_TOOL_HISTORY_ACCEPTED_KEY]: true };
|
|
184
|
+
}
|
|
185
|
+
function terminalOwnerOfStream(ctx, busy, busyHandle, runId) {
|
|
186
|
+
const hostString = (k) => {
|
|
187
|
+
try {
|
|
188
|
+
const d = Object.getOwnPropertyDescriptor(ctx, k);
|
|
189
|
+
return d !== undefined && Object.hasOwn(d, 'value') && typeof d.value === 'string' && d.value.length > 0 ? d.value : undefined;
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const followed = hostString('followedRun');
|
|
196
|
+
if (followed !== undefined)
|
|
197
|
+
return { kind: 'followed-run', taskId: followed, ...(runId !== undefined ? { runId } : {}) };
|
|
198
|
+
if (!busy)
|
|
199
|
+
return undefined;
|
|
200
|
+
const requestId = hostString('requestId');
|
|
201
|
+
return {
|
|
202
|
+
kind: 'request-not-sent',
|
|
203
|
+
...(requestId !== undefined ? { requestId } : {}),
|
|
204
|
+
...(typeof busyHandle === 'string' && busyHandle.length > 0 ? { heldBy: busyHandle } : {}),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
160
207
|
function engineResultOf(result) {
|
|
161
208
|
const v = doneResultView(result);
|
|
162
209
|
return v.replay ? (v.engine ?? result) : result;
|
|
@@ -166,7 +213,7 @@ function engineSessionIdOf(result) {
|
|
|
166
213
|
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
167
214
|
}
|
|
168
215
|
export function isOutcomeUnknownRowText(text) {
|
|
169
|
-
return text
|
|
216
|
+
return legacyRowKindOfText(text) === 'outcome_unknown';
|
|
170
217
|
}
|
|
171
218
|
export function isGovernanceTerminal(input) {
|
|
172
219
|
if (input.status === 'blocked')
|
|
@@ -265,8 +312,18 @@ function ownTerminalSnapshot(result) {
|
|
|
265
312
|
}
|
|
266
313
|
const ts = ownDataCopy(t, ['kind', 'code', 'message']);
|
|
267
314
|
const detail = plainObjectOf(ownDataBit(t, 'detail'));
|
|
268
|
-
if (detail !== undefined)
|
|
269
|
-
|
|
315
|
+
if (detail !== undefined) {
|
|
316
|
+
const detailCopy = ownDataCopy(detail, ['kind', 'status', 'code', 'providerCondition']);
|
|
317
|
+
const route = plainObjectOf(ownDataBit(detail, 'route'));
|
|
318
|
+
if (route !== undefined)
|
|
319
|
+
detailCopy.route = ownDataCopy(route, ['credentialSource', 'root']);
|
|
320
|
+
if (detailCopy.kind === 'coded') {
|
|
321
|
+
const body = ownDataBit(detail, 'detail');
|
|
322
|
+
if (body !== undefined)
|
|
323
|
+
detailCopy.detail = body;
|
|
324
|
+
}
|
|
325
|
+
ts.detail = detailCopy;
|
|
326
|
+
}
|
|
270
327
|
snap.terminal = ts;
|
|
271
328
|
return snap;
|
|
272
329
|
}
|
|
@@ -330,6 +387,7 @@ function apiErrorTerminalFromFacts(x, facts) {
|
|
|
330
387
|
return {
|
|
331
388
|
carrier: mintToolHistoryCarrier(nonEmptyStr(ownDataBit(read, 'code')), status, nonEmptyStr(ownDataBit(read, 'message'))),
|
|
332
389
|
detail: detail,
|
|
390
|
+
coded: runTerminalCodedDetail(read),
|
|
333
391
|
};
|
|
334
392
|
}
|
|
335
393
|
catch {
|
|
@@ -387,6 +445,15 @@ export function _resetDroppedFrameReportForTest() {
|
|
|
387
445
|
export function _droppedFrameMemoSizeForTest() {
|
|
388
446
|
return reportedDroppedTypes.size;
|
|
389
447
|
}
|
|
448
|
+
function wireFrameIsSubFlow(ev) {
|
|
449
|
+
const snap = guardedRead(() => {
|
|
450
|
+
const s = {};
|
|
451
|
+
for (const k of SEGMENT_END_IDENTITY_KEYS)
|
|
452
|
+
s[k] = ev[k];
|
|
453
|
+
return s;
|
|
454
|
+
});
|
|
455
|
+
return snap === undefined || snapshotIsSubFlow(snap);
|
|
456
|
+
}
|
|
390
457
|
function withStringFailureFields(ev) {
|
|
391
458
|
if (ev.type !== 'failed')
|
|
392
459
|
return ev;
|
|
@@ -434,6 +501,73 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
434
501
|
let deniedCallsOverflowed = false;
|
|
435
502
|
let successfulToolEndObserved = false;
|
|
436
503
|
let streamSawRunOpen = false;
|
|
504
|
+
const observedSnapshot = () => ({
|
|
505
|
+
usageMissingObserved,
|
|
506
|
+
nestedUsageByTask,
|
|
507
|
+
toolInputByCallId,
|
|
508
|
+
gateDeniedByByCallId,
|
|
509
|
+
denialKindByCallId,
|
|
510
|
+
successfulToolEndObserved,
|
|
511
|
+
streamSawRunOpen,
|
|
512
|
+
deniedToolNameByCallId,
|
|
513
|
+
deniedCallsOverflowed,
|
|
514
|
+
});
|
|
515
|
+
handle.observedTerminalParts = () => terminalPartsOfObserved(observedSnapshot());
|
|
516
|
+
let lastTranscriptRow = null;
|
|
517
|
+
let liveTailDone = '';
|
|
518
|
+
let liveTailOpen = '';
|
|
519
|
+
let liveTailPrev = '';
|
|
520
|
+
let lateEndDone = '';
|
|
521
|
+
let lateEndOpen = '';
|
|
522
|
+
const closeLiveMessage = () => {
|
|
523
|
+
const t = liveTailDone + liveTailOpen;
|
|
524
|
+
if (carriesAnswerText(t)) {
|
|
525
|
+
liveTailPrev = t;
|
|
526
|
+
lateEndDone = liveTailDone;
|
|
527
|
+
lateEndOpen = liveTailOpen;
|
|
528
|
+
}
|
|
529
|
+
liveTailDone = '';
|
|
530
|
+
liveTailOpen = '';
|
|
531
|
+
};
|
|
532
|
+
const noteRow = (m, wireSubFlow) => {
|
|
533
|
+
const r = m;
|
|
534
|
+
if (r.parent_tool_use_id !== null && r.parent_tool_use_id !== undefined)
|
|
535
|
+
return m;
|
|
536
|
+
if (isSubFlowSegmentEnd(m))
|
|
537
|
+
return m;
|
|
538
|
+
if (wireSubFlow === true)
|
|
539
|
+
return m;
|
|
540
|
+
if (r.type === 'assistant' || r.type === 'user') {
|
|
541
|
+
lastTranscriptRow = m;
|
|
542
|
+
liveTailDone = '';
|
|
543
|
+
liveTailOpen = '';
|
|
544
|
+
liveTailPrev = '';
|
|
545
|
+
lateEndDone = '';
|
|
546
|
+
lateEndOpen = '';
|
|
547
|
+
}
|
|
548
|
+
else if (r.type === 'stream_event' && r.event?.type === 'text_delta' && typeof r.event.delta === 'string') {
|
|
549
|
+
liveTailOpen += r.event.delta;
|
|
550
|
+
if (r.event.delta.length > 0)
|
|
551
|
+
lateEndOpen = '';
|
|
552
|
+
}
|
|
553
|
+
else if (r.type === 'text_end' && typeof r.content === 'string') {
|
|
554
|
+
if (liveTailDone === '' && liveTailOpen === '' && lateEndOpen !== '') {
|
|
555
|
+
lateEndDone += r.content;
|
|
556
|
+
lateEndOpen = '';
|
|
557
|
+
liveTailPrev = lateEndDone;
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
liveTailDone += r.content;
|
|
561
|
+
liveTailOpen = '';
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return m;
|
|
565
|
+
};
|
|
566
|
+
const lastRowForResult = () => {
|
|
567
|
+
const open = liveTailDone + liveTailOpen;
|
|
568
|
+
const tail = carriesAnswerText(open) ? open : liveTailPrev;
|
|
569
|
+
return carriesAnswerText(tail) ? { type: 'assistant', message: { content: [{ type: 'text', text: tail }] } } : lastTranscriptRow;
|
|
570
|
+
};
|
|
437
571
|
const sameArgs = (a, b) => {
|
|
438
572
|
if (a === b)
|
|
439
573
|
return true;
|
|
@@ -446,6 +580,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
446
580
|
};
|
|
447
581
|
for await (const rawEv of events) {
|
|
448
582
|
const ev = withStringFailureFields(rawEv);
|
|
583
|
+
const wireSubFlow = wireFrameIsSubFlow(ev);
|
|
449
584
|
if (ev.type === 'tool_end' && ev.isError !== true)
|
|
450
585
|
successfulToolEndObserved = true;
|
|
451
586
|
const seq = eventSeq(ev);
|
|
@@ -570,10 +705,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
570
705
|
reportDroppedFrame('turn_end_usage_absent', ev.type, ctx);
|
|
571
706
|
continue;
|
|
572
707
|
}
|
|
573
|
-
const
|
|
574
|
-
const isSubFlow = identityEnvelope.parentToolCallId !== undefined ||
|
|
575
|
-
identityEnvelope.sourceTaskId !== undefined ||
|
|
576
|
-
identityEnvelope.bgAgentId !== undefined;
|
|
708
|
+
const isSubFlow = wireSubFlow;
|
|
577
709
|
{
|
|
578
710
|
if (measured !== undefined) {
|
|
579
711
|
handle.latestUsage = usage;
|
|
@@ -638,6 +770,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
638
770
|
}
|
|
639
771
|
const outputTokens = engineUsage.outputTokens;
|
|
640
772
|
if (!isSubFlow) {
|
|
773
|
+
closeLiveMessage();
|
|
641
774
|
yield {
|
|
642
775
|
type: 'turn_usage',
|
|
643
776
|
...(usageMissing ? { _sema_usage_missing: true } : { _sema_last_assistant_usage: usage }),
|
|
@@ -655,7 +788,11 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
655
788
|
const doneTerminal = rowFacts.doneTerminal;
|
|
656
789
|
const terminalRunId = terminalRunIdOf(ev);
|
|
657
790
|
const replayed = isReplayedTerminal(ev);
|
|
791
|
+
const owner = terminalOwnerOfStream(ctx, rowFacts.busy.busy, rowFacts.busy.handle, terminalRunId);
|
|
792
|
+
let wayOutFacts;
|
|
793
|
+
let codedDetailJudged;
|
|
658
794
|
const errText = rowFacts.errText;
|
|
795
|
+
let historyAcceptedSinceMismatch;
|
|
659
796
|
if (errText) {
|
|
660
797
|
const busy = rowFacts.busy;
|
|
661
798
|
const maxTokHint = /max_tokens/i.test(errText)
|
|
@@ -664,9 +801,11 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
664
801
|
const busyHandle = busy.handle;
|
|
665
802
|
const arm = terminalRowArmOf(rowFacts);
|
|
666
803
|
const rowText = arm === 'busy'
|
|
667
|
-
?
|
|
804
|
+
? `${SESSION_BUSY_ROW_LEAD}${busyHandle ? ` (run ${busyHandle})` : ''} that ` +
|
|
668
805
|
`has not been released, so this message was NOT sent. Nothing releases it on its own — ` +
|
|
669
|
-
|
|
806
|
+
(ctx.lane === 'print' || ctx.lane === 'utility'
|
|
807
|
+
? `cancel that run (POST /v1/runs/${busyHandle ?? '<id>'}/cancel), or start a new session.`
|
|
808
|
+
: `end ${busyHandle ? `run ${busyHandle}` : 'that run'} on the engine, or start a new session.`)
|
|
670
809
|
: arm === 'governance'
|
|
671
810
|
?
|
|
672
811
|
`${isGovernanceStopRowText(errText) ? errText : `${RUN_STOPPED_MESSAGE_PREFIX}: ${errText}`}${maxTokHint}`
|
|
@@ -679,34 +818,40 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
679
818
|
: doneTerminal?.kind === 'failed' && isCorruptSessionCode(doneTerminal.code);
|
|
680
819
|
const abortNote = abortCauseNoteOf(ev);
|
|
681
820
|
const historyTerminal = apiErrorTerminalOfRowFrame(ev, rowFacts);
|
|
821
|
+
if (arm === 'apiError') {
|
|
822
|
+
wayOutFacts = wayOutFactsOfApiError(historyTerminal);
|
|
823
|
+
codedDetailJudged = { value: historyTerminal.coded };
|
|
824
|
+
}
|
|
682
825
|
const historyMismatch = classifyToolHistoryMismatch(historyTerminal.carrier);
|
|
683
826
|
const historyEchoedSid = ev.type === 'done' ? engineSessionIdOf(engineResultOf(ev.result)) : undefined;
|
|
684
|
-
const historyRepeat =
|
|
827
|
+
const historyRepeat = noteToolHistoryTerminalFacts({
|
|
685
828
|
sessionId: historyEchoedSid ?? ctx.sessionId,
|
|
686
829
|
sessionEchoed: historyEchoedSid !== undefined,
|
|
687
830
|
generation: historyGeneration,
|
|
688
831
|
runId: terminalRunId,
|
|
689
832
|
replay: replayed,
|
|
690
833
|
mismatch: historyMismatch,
|
|
691
|
-
|
|
834
|
+
accepted: false,
|
|
835
|
+
}).consecutive;
|
|
692
836
|
const rewindOffered = historyMismatch !== null && ctx.lane !== 'print' && ctx.lane !== 'utility' && toolHistoryRewindOffered(ctx.offersRewind);
|
|
693
837
|
const rewindLine = rewindOffered
|
|
694
838
|
? `\n${TOOL_HISTORY_REWIND_SENTENCE}${historyRepeat !== undefined && historyRepeat >= 2 ? ` ${toolHistoryRepeatSentence(historyRepeat)}` : ''}`
|
|
695
839
|
: '';
|
|
696
840
|
const resend = historyTerminal.detail !== undefined ? providerRejectionResend(historyTerminal.detail, historyTerminal.carrier) : undefined;
|
|
697
841
|
const resendLine = resend !== undefined ? `\n${resend.text}` : '';
|
|
698
|
-
yield syntheticTerminalRow(ctx, { runId: terminalRunId, label: 'terminal-row' }, replayed, `${sessionUnreadable ? `${rowText}\n${corruptSessionContent()}` : rowText}${abortNote !== undefined ? `\n${abortNote}` : ''}${rewindLine}${resendLine}`, historyMismatch === null ? undefined : toolHistoryMismatchRowKey(historyMismatch, historyRepeat, rewindOffered), resend, arm === 'apiError' ? apiErrorRowBitsOf(historyTerminal) : undefined);
|
|
842
|
+
yield noteRow(syntheticTerminalRow(ctx, { runId: terminalRunId, label: 'terminal-row' }, replayed, arm === 'busy' ? 'session_busy' : arm === 'governance' ? 'governance_stop' : arm === 'modelOutput' ? 'model_output_error' : 'api_error', `${sessionUnreadable ? `${rowText}\n${corruptSessionContent()}` : rowText}${abortNote !== undefined ? `\n${abortNote}` : ''}${rewindLine}${resendLine}`, historyMismatch === null ? undefined : toolHistoryMismatchRowKey(historyMismatch, historyRepeat, rewindOffered), resend, arm === 'apiError' ? apiErrorRowBitsOf(historyTerminal) : undefined, owner));
|
|
699
843
|
}
|
|
700
844
|
else {
|
|
701
845
|
const echoedSid = ev.type === 'done' ? engineSessionIdOf(engineResultOf(ev.result)) : undefined;
|
|
702
|
-
|
|
846
|
+
historyAcceptedSinceMismatch = noteToolHistoryTerminalFacts({
|
|
703
847
|
sessionId: echoedSid ?? ctx.sessionId,
|
|
704
848
|
sessionEchoed: echoedSid !== undefined,
|
|
705
849
|
generation: historyGeneration,
|
|
706
850
|
runId: terminalRunId,
|
|
707
851
|
replay: replayed,
|
|
708
852
|
mismatch: null,
|
|
709
|
-
|
|
853
|
+
accepted: ev.type === 'done' && (doneTerminal?.kind === 'completed' || doneTerminal?.kind === 'paused'),
|
|
854
|
+
}).acceptedSinceMismatch;
|
|
710
855
|
}
|
|
711
856
|
if (ev.type === 'done' && isReviewPark(doneTerminal) && ctx.emitChrome) {
|
|
712
857
|
try {
|
|
@@ -721,23 +866,20 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
721
866
|
emitChromeFireAndForget(ctx, { kind: 'run_cost_reconciled', laneProof: mainLane(), ...costFacts.reconcile });
|
|
722
867
|
}
|
|
723
868
|
}
|
|
724
|
-
const
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
streamSawRunOpen,
|
|
732
|
-
deniedToolNameByCallId,
|
|
733
|
-
deniedCallsOverflowed,
|
|
734
|
-
});
|
|
869
|
+
const mintResultFrame = (lastRow) => withHistoryAccepted(withTerminalOwner(terminalToSdkResult(ev, ctx, {
|
|
870
|
+
...observedSnapshot(),
|
|
871
|
+
wayOutFacts,
|
|
872
|
+
...(codedDetailJudged !== undefined ? { codedDetail: codedDetailJudged.value } : {}),
|
|
873
|
+
lastRow: lastRow,
|
|
874
|
+
}), owner), historyAcceptedSinceMismatch);
|
|
875
|
+
let resultFrame = mintResultFrame(lastRowForResult());
|
|
735
876
|
const outcome = resultFrame.
|
|
736
877
|
_sema_outcome;
|
|
737
878
|
if (outcome === 'unknown') {
|
|
738
|
-
const errs = resultFrame.errors;
|
|
879
|
+
const errs = (resultFrame.errors ?? mintResultFrame(null).errors);
|
|
739
880
|
const sentence = Array.isArray(errs) && typeof errs[0] === 'string' ? errs[0] : 'the run ended without a terminal record this client can read';
|
|
740
|
-
yield syntheticTerminalRow(ctx, { runId: terminalRunId, label: 'outcome-unknown' }, replayed, `${OUTCOME_UNKNOWN_ROW_PREFIX}: ${sentence}
|
|
881
|
+
yield noteRow(syntheticTerminalRow(ctx, { runId: terminalRunId, label: 'outcome-unknown' }, replayed, 'outcome_unknown', `${OUTCOME_UNKNOWN_ROW_PREFIX}: ${sentence}`, undefined, undefined, undefined, owner));
|
|
882
|
+
resultFrame = mintResultFrame(lastRowForResult());
|
|
741
883
|
}
|
|
742
884
|
yield terminalFactOf(ev, doneTerminal);
|
|
743
885
|
yield resultFrame;
|
|
@@ -750,7 +892,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
750
892
|
}
|
|
751
893
|
const projection = eventToSdkMessage(ev, ctx);
|
|
752
894
|
if (projection.kind === 'message') {
|
|
753
|
-
yield projection.message;
|
|
895
|
+
yield noteRow(projection.message, wireSubFlow);
|
|
754
896
|
continue;
|
|
755
897
|
}
|
|
756
898
|
if (projection.kind === 'dropped')
|
package/dist/adapter/types.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface EmitContext {
|
|
|
23
23
|
emitChrome?(event: ChromeEvent): void | Promise<void>;
|
|
24
24
|
onDroppedFrame?(info: DroppedFrameInfo): void;
|
|
25
25
|
boundRun?(frame: AgentEvent): EngineBoundRun | undefined;
|
|
26
|
+
requestId?: string;
|
|
27
|
+
followedRun?: string;
|
|
26
28
|
}
|
|
27
29
|
export declare function stamp<T extends {
|
|
28
30
|
uuid?: string | undefined;
|
package/dist/agentsWireCaps.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { type EngineProbeOpts, type WireAuthTokenSource } from './engineWireSdk.js';
|
|
2
2
|
import type { ReasoningEffort } from './effortWire.js';
|
|
3
|
+
import type { SkillSpec } from '@sema-agent/sdk';
|
|
3
4
|
import type { ToolRosterView } from './toolRoster.js';
|
|
4
5
|
import { type AssemblyRefusal } from './wireFailureShape.js';
|
|
5
6
|
export declare const MAX_TASK_AGENTS = 32;
|
|
6
7
|
export declare const TASK_AGENT_WIRE_FIELDS: readonly ["name", "whenToUse", "whenToUseLean", "allowTools", "denyTools", "skills", "background", "isolation", "model", "thinking", "systemPrompt", "maxTurns", "memory", "observer", "observerMessage"];
|
|
7
8
|
export type WireThinkingLevel = ReasoningEffort;
|
|
8
|
-
export type TaskAgentWireSkill =
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
content: string;
|
|
12
|
-
allowedTools?: string[];
|
|
13
|
-
disallowedTools?: string[];
|
|
14
|
-
};
|
|
9
|
+
export type TaskAgentWireSkill = SkillSpec;
|
|
15
10
|
export declare const AGENT_MEMORY_WORDS: ReadonlySet<string>;
|
|
16
11
|
export type TaskAgentWireMemory = {
|
|
17
12
|
scopes: string[];
|
|
@@ -46,6 +41,12 @@ export type AgentDefLike = {
|
|
|
46
41
|
source: string;
|
|
47
42
|
getSystemPrompt?: (arg?: unknown) => string;
|
|
48
43
|
};
|
|
44
|
+
export declare const REFUSED_PROJECT_SERVER_CAUSES: readonly ["rejected", "not_approved", "disabled", "policy_blocked", "plugin_only", "malformed_config"];
|
|
45
|
+
export type RefusedProjectServerCause = (typeof REFUSED_PROJECT_SERVER_CAUSES)[number];
|
|
46
|
+
export interface RefusedProjectServer {
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly cause: RefusedProjectServerCause;
|
|
49
|
+
}
|
|
49
50
|
export type ProjectAgentsDeps = {
|
|
50
51
|
resolveModel: (frontmatterModel: string | undefined) => {
|
|
51
52
|
model: string;
|
|
@@ -55,6 +56,7 @@ export type ProjectAgentsDeps = {
|
|
|
55
56
|
skillSpecs?: TaskAgentWireSkill[];
|
|
56
57
|
toolRoster?: ToolRosterView | null;
|
|
57
58
|
agentSourceLabel?: (agentName: string) => string | undefined;
|
|
59
|
+
refusedProjectServers?: readonly RefusedProjectServer[];
|
|
58
60
|
};
|
|
59
61
|
export type ProjectAgentsResult = {
|
|
60
62
|
agents: TaskAgentWireItem[] | undefined;
|