@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,16 +1,17 @@
|
|
|
1
1
|
import { isCcToolDenialKind, isCcToolDenialKindADenial, isGateDeniedByWord } from '../../gateVocabulary.js';
|
|
2
2
|
import { stamp } from '../types.js';
|
|
3
|
-
import { putOwnKey, readFrameStringKey } from '../../ownKey.js';
|
|
3
|
+
import { guardedRead, putOwnKey, readFrameStringKey, readOwnDataFiniteNumber, readOwnDataNonEmptyString, readOwnDataValue } from '../../ownKey.js';
|
|
4
4
|
import { REDACTION_MARKER_PREFIX, washCredentials } from '../../displayUntrusted.js';
|
|
5
5
|
import { readEffectiveReasoning, readEffectiveMemoryScopes } from '../../effectiveFacts.js';
|
|
6
|
-
import { isReviewPark, readRunTerminal, runTerminalCode, runTerminalGateToolName, } from '../../runTerminal.js';
|
|
6
|
+
import { isReviewPark, readRunTerminal, runTerminalCode, runTerminalCodedDetail, runTerminalGateToolName, } from '../../runTerminal.js';
|
|
7
7
|
import { doneResultView, isReplayedTerminal } from '../../replayBody.js';
|
|
8
8
|
import { terminalRunIdOf, terminalUuidOf } from '../../engineRowRef.js';
|
|
9
9
|
import { toCcModelUsage } from './turnUsageToModelUsage.js';
|
|
10
|
-
import {
|
|
10
|
+
import { LIMITS_MAX_TOKENS_EXCEEDED, LIMITS_MAX_WALLTIME_EXCEEDED, isCorruptSessionCode, isLimitsExceededCode, RESULT_LIMIT_WORDS, resultLimitRowOfCode, idempotencyPayloadMismatchContent, isIdempotencyPayloadMismatchCode, isRewindFamilyCode, } from '../../engineErrorCodes.js';
|
|
11
11
|
import { corruptSessionContent } from '../../corruptSessionCopy.js';
|
|
12
12
|
import { runBlockedText } from '../../promptBlockedCopy.js';
|
|
13
13
|
import { abortCauseNoteOf, readAbortCause } from '../../runCancelContext.js';
|
|
14
|
+
import { wayOutOfApiErrorFacts } from '../../providerRejection.js';
|
|
14
15
|
function withTerminalNote(text, code, frame) {
|
|
15
16
|
const withCorrupt = isCorruptSessionCode(code)
|
|
16
17
|
? `${text}\n${corruptSessionContent()}`
|
|
@@ -296,6 +297,26 @@ function costFactParts(stats, observed) {
|
|
|
296
297
|
...(facts.nested !== undefined ? { _sema_nested_usage: facts.nested } : {}),
|
|
297
298
|
};
|
|
298
299
|
}
|
|
300
|
+
export function terminalPartsOfObserved(observed) {
|
|
301
|
+
let denials;
|
|
302
|
+
try {
|
|
303
|
+
denials = permissionDenialParts(undefined, observed);
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
denials = permissionDenialParts(undefined, undefined);
|
|
307
|
+
}
|
|
308
|
+
let lowerBound = false;
|
|
309
|
+
try {
|
|
310
|
+
lowerBound = usageLowerBoundOf(undefined, observed);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
lowerBound = false;
|
|
314
|
+
}
|
|
315
|
+
return Object.freeze({
|
|
316
|
+
...denials,
|
|
317
|
+
...(lowerBound ? { _sema_usage_lower_bound: true } : {}),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
299
320
|
export const SEMA_SUBAGENT_USAGE_PARTIAL_KEY = '_sema_subagent_usage_partial';
|
|
300
321
|
export function subagentUsageIsPartial(row, opts) {
|
|
301
322
|
if (opts?.tablePartial === true)
|
|
@@ -427,23 +448,10 @@ function degradedOf(r) {
|
|
|
427
448
|
const d = r.degraded;
|
|
428
449
|
return d !== undefined && d !== null && typeof d === 'object' ? d : undefined;
|
|
429
450
|
}
|
|
430
|
-
const COST_EXCEEDED_CODES = new Set([LIMITS_MAX_COST_EXCEEDED]);
|
|
431
|
-
const TURNS_EXCEEDED_CODES = new Set([LIMITS_MAX_TURNS_EXCEEDED]);
|
|
432
451
|
const CUTOFF_EXCEEDED_CODES = new Set([
|
|
433
452
|
LIMITS_MAX_TOKENS_EXCEEDED,
|
|
434
453
|
LIMITS_MAX_WALLTIME_EXCEEDED,
|
|
435
454
|
]);
|
|
436
|
-
function subtypeForErrorCode(code) {
|
|
437
|
-
if (code === undefined || code.length === 0)
|
|
438
|
-
return 'error_during_execution';
|
|
439
|
-
if (COST_EXCEEDED_CODES.has(code))
|
|
440
|
-
return 'error_max_budget_usd';
|
|
441
|
-
if (TURNS_EXCEEDED_CODES.has(code))
|
|
442
|
-
return 'error_max_turns';
|
|
443
|
-
if (code === OUTPUT_INVALID)
|
|
444
|
-
return 'error_max_structured_output_retries';
|
|
445
|
-
return 'error_during_execution';
|
|
446
|
-
}
|
|
447
455
|
function terminalReasonOf(subtype, isError) {
|
|
448
456
|
switch (subtype) {
|
|
449
457
|
case 'success':
|
|
@@ -476,6 +484,103 @@ export function terminalReasonForResult(msg) {
|
|
|
476
484
|
return undefined;
|
|
477
485
|
}
|
|
478
486
|
}
|
|
487
|
+
export function resultLimitOf(frame) {
|
|
488
|
+
const raw = guardedRead(() => readOwnDataNonEmptyString(frame, '_sema_limit'));
|
|
489
|
+
return raw !== undefined && RESULT_LIMIT_WORDS.includes(raw) ? raw : undefined;
|
|
490
|
+
}
|
|
491
|
+
const PRINT_ARM_KIND_TABLE = Object.freeze({ completed: true, failed: true, blocked: true, paused: true, unknown: true });
|
|
492
|
+
function printArmNonBlank(v) {
|
|
493
|
+
return typeof v === 'string' && v.trim().length > 0;
|
|
494
|
+
}
|
|
495
|
+
function printArmObjectLike(v) {
|
|
496
|
+
return typeof v === 'object' && v !== null;
|
|
497
|
+
}
|
|
498
|
+
function printArmRowText(row) {
|
|
499
|
+
const message = readOwnDataValue(row, 'message');
|
|
500
|
+
if (!printArmObjectLike(message) || Array.isArray(message))
|
|
501
|
+
return undefined;
|
|
502
|
+
const content = readOwnDataValue(message, 'content');
|
|
503
|
+
if (typeof content === 'string')
|
|
504
|
+
return printArmNonBlank(content) ? content : undefined;
|
|
505
|
+
if (!Array.isArray(content) || content.length === 0)
|
|
506
|
+
return undefined;
|
|
507
|
+
const last = readOwnDataValue(content, String(content.length - 1));
|
|
508
|
+
if (!printArmObjectLike(last) || Array.isArray(last))
|
|
509
|
+
return undefined;
|
|
510
|
+
const text = readOwnDataValue(last, 'text');
|
|
511
|
+
return readOwnDataValue(last, 'type') === 'text' && printArmNonBlank(text) ? text : undefined;
|
|
512
|
+
}
|
|
513
|
+
function printArmLastRowOriginOf(row) {
|
|
514
|
+
try {
|
|
515
|
+
if (!printArmObjectLike(row) || Array.isArray(row))
|
|
516
|
+
return { origin: 'other' };
|
|
517
|
+
const isAssistant = readOwnDataValue(row, 'type') === 'assistant';
|
|
518
|
+
if (isAssistant && readOwnDataValue(row, '_sema_api_error_message') === true) {
|
|
519
|
+
const text = printArmRowText(row);
|
|
520
|
+
return text !== undefined ? { origin: 'api_error', text } : { origin: 'api_error' };
|
|
521
|
+
}
|
|
522
|
+
const salvaged = readOwnDataValue(row, 'salvagedText');
|
|
523
|
+
if (printArmNonBlank(salvaged))
|
|
524
|
+
return { origin: 'model_text', text: salvaged };
|
|
525
|
+
if (!isAssistant)
|
|
526
|
+
return { origin: 'other' };
|
|
527
|
+
const text = printArmRowText(row);
|
|
528
|
+
return text !== undefined ? { origin: 'model_text', text } : { origin: 'other' };
|
|
529
|
+
}
|
|
530
|
+
catch {
|
|
531
|
+
return { origin: 'other' };
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function printArmStopReasonOf(row) {
|
|
535
|
+
try {
|
|
536
|
+
if (!printArmObjectLike(row) || Array.isArray(row))
|
|
537
|
+
return null;
|
|
538
|
+
const message = readOwnDataValue(row, 'message');
|
|
539
|
+
if (!printArmObjectLike(message) || Array.isArray(message))
|
|
540
|
+
return null;
|
|
541
|
+
return readOwnDataNonEmptyString(message, 'stop_reason') ?? null;
|
|
542
|
+
}
|
|
543
|
+
catch {
|
|
544
|
+
return null;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
const PRINT_ARM_UNKNOWN_OUTCOME = Object.freeze({ subtype: 'error_during_execution', is_error: true, stop_reason: null });
|
|
548
|
+
export function printResultArmOf(input) {
|
|
549
|
+
return printArmReadingOf(input).arm;
|
|
550
|
+
}
|
|
551
|
+
function printArmReadingOf(input) {
|
|
552
|
+
try {
|
|
553
|
+
if (!printArmObjectLike(input) || Array.isArray(input))
|
|
554
|
+
return PRINT_ARM_UNKNOWN_READING;
|
|
555
|
+
if (!Object.hasOwn(input, 'terminal'))
|
|
556
|
+
return PRINT_ARM_UNKNOWN_READING;
|
|
557
|
+
const terminal = readOwnDataValue(input, 'terminal');
|
|
558
|
+
if (terminal !== null && (!printArmObjectLike(terminal) || Array.isArray(terminal)))
|
|
559
|
+
return PRINT_ARM_UNKNOWN_READING;
|
|
560
|
+
const kind = terminal === null ? null : readOwnDataValue(terminal, 'kind');
|
|
561
|
+
if (terminal !== null && (typeof kind !== 'string' || !Object.hasOwn(PRINT_ARM_KIND_TABLE, kind)))
|
|
562
|
+
return PRINT_ARM_UNKNOWN_READING;
|
|
563
|
+
const lastRow = readOwnDataValue(input, 'lastRow');
|
|
564
|
+
const stop_reason = printArmStopReasonOf(lastRow);
|
|
565
|
+
if (kind === 'completed')
|
|
566
|
+
return { arm: Object.freeze({ subtype: 'success', is_error: false, stop_reason }) };
|
|
567
|
+
if (kind === 'failed') {
|
|
568
|
+
const code = readOwnDataValue(terminal, 'code');
|
|
569
|
+
const limit = typeof code === 'string' ? resultLimitRowOfCode(code) : undefined;
|
|
570
|
+
if (limit !== undefined)
|
|
571
|
+
return { arm: Object.freeze({ subtype: limit.subtype, is_error: true, stop_reason, limit: limit.word }) };
|
|
572
|
+
}
|
|
573
|
+
const row = printArmLastRowOriginOf(lastRow);
|
|
574
|
+
if (row.origin === 'api_error' || row.origin === 'model_text') {
|
|
575
|
+
return { arm: Object.freeze({ subtype: 'success', is_error: true, stop_reason }), ...(row.text !== undefined ? { text: row.text, errorRow: row.origin === 'api_error' } : {}) };
|
|
576
|
+
}
|
|
577
|
+
return { arm: Object.freeze({ subtype: 'error_during_execution', is_error: true, stop_reason }) };
|
|
578
|
+
}
|
|
579
|
+
catch {
|
|
580
|
+
return PRINT_ARM_UNKNOWN_READING;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
const PRINT_ARM_UNKNOWN_READING = Object.freeze({ arm: PRINT_ARM_UNKNOWN_OUTCOME });
|
|
479
584
|
function selectedModelParts(model) {
|
|
480
585
|
return typeof model === 'string' && model.length > 0 ? { _sema_selected_model: model } : {};
|
|
481
586
|
}
|
|
@@ -496,17 +601,28 @@ function cutoffParts(r, message, fallbackMessage, code) {
|
|
|
496
601
|
...(salvaged !== undefined ? { salvagedResult: salvaged } : {}),
|
|
497
602
|
};
|
|
498
603
|
}
|
|
604
|
+
function localWayOutFacts(r, rejection) {
|
|
605
|
+
const apiFailure = guardedRead(() => readOwnDataValue(r, 'apiFailure'));
|
|
606
|
+
const apiFailureStatus = typeof apiFailure === 'object' && apiFailure !== null && guardedRead(() => !Array.isArray(apiFailure) || undefined) === true
|
|
607
|
+
? guardedRead(() => readOwnDataFiniteNumber(apiFailure, 'status'))
|
|
608
|
+
: undefined;
|
|
609
|
+
const status = apiFailureStatus ?? rejection?.status;
|
|
610
|
+
return {
|
|
611
|
+
...(status !== undefined ? { status } : {}),
|
|
612
|
+
...(rejection?.providerCondition !== undefined ? { providerCondition: rejection.providerCondition } : {}),
|
|
613
|
+
...(rejection?.route !== undefined ? { credentialSource: rejection.route.credentialSource } : {}),
|
|
614
|
+
};
|
|
615
|
+
}
|
|
499
616
|
function errorResult(ctx, parts) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
subtype: parts.subtype,
|
|
617
|
+
const errors = parts.errors.map(washCredentials);
|
|
618
|
+
const arm = parts.arm;
|
|
619
|
+
const result = arm.subtype === 'success' ? (parts.lastRowText ?? errors.join('\n')) : undefined;
|
|
620
|
+
const head = {
|
|
505
621
|
duration_ms: parts.durationMs,
|
|
506
622
|
duration_api_ms: parts.durationMs,
|
|
507
|
-
is_error:
|
|
623
|
+
is_error: arm.is_error,
|
|
508
624
|
num_turns: parts.stats?.turns ?? 0,
|
|
509
|
-
stop_reason:
|
|
625
|
+
stop_reason: arm.stop_reason,
|
|
510
626
|
total_cost_usd: costOrNull(parts.stats),
|
|
511
627
|
usage: flattenUsage(parts.stats),
|
|
512
628
|
modelUsage: modelUsageFor(parts.stats, parts.model),
|
|
@@ -514,8 +630,9 @@ function errorResult(ctx, parts) {
|
|
|
514
630
|
...costFactParts(parts.stats, parts.observed),
|
|
515
631
|
...reemitEffectiveFacts(parts.facts),
|
|
516
632
|
...nestedUsageByTaskParts(parts.stats, parts.observed?.nestedUsageByTask),
|
|
517
|
-
|
|
518
|
-
|
|
633
|
+
};
|
|
634
|
+
const tail = {
|
|
635
|
+
...terminalReasonParts(arm.subtype, arm.is_error),
|
|
519
636
|
...(parts.errorCode !== undefined && parts.errorCode.length > 0 ? { _sema_error_code: parts.errorCode } : {}),
|
|
520
637
|
...(parts.degraded !== undefined ? { _sema_model_degraded: parts.degraded } : {}),
|
|
521
638
|
...selectedModelParts(parts.model),
|
|
@@ -523,8 +640,61 @@ function errorResult(ctx, parts) {
|
|
|
523
640
|
...(parts.outcomeUnknown === true ? { _sema_outcome: 'unknown' } : {}),
|
|
524
641
|
...(parts.parkFailedReason !== undefined ? { _sema_park_failed_reason: washCredentials(parts.parkFailedReason) } : {}),
|
|
525
642
|
...(parts.abortCause !== undefined ? { _sema_abort_cause: parts.abortCause } : {}),
|
|
643
|
+
...(parts.route !== undefined ? { _sema_route: routeOnFrame(parts.route) } : {}),
|
|
644
|
+
...('limit' in arm && arm.limit !== undefined ? { _sema_limit: arm.limit } : {}),
|
|
645
|
+
...(parts.wayOut !== undefined ? { _sema_wayOut: wayOutOnFrame(parts.wayOut) } : {}),
|
|
646
|
+
...(parts.codedDetail !== undefined ? { _sema_coded_detail: parts.codedDetail } : {}),
|
|
647
|
+
...(parts.errorCode !== undefined && parts.errorCode.length > 0 && errorsStateCode(errors[0], parts.errorCode) ? { _sema_error_code_in_text: true } : {}),
|
|
648
|
+
};
|
|
649
|
+
if (arm.subtype === 'success') {
|
|
650
|
+
return stamp(ctx, {
|
|
651
|
+
uuid: parts.uuid,
|
|
652
|
+
session_id: undefined,
|
|
653
|
+
type: 'result',
|
|
654
|
+
subtype: 'success',
|
|
655
|
+
...head,
|
|
656
|
+
result,
|
|
657
|
+
errors,
|
|
658
|
+
...tail,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
return stamp(ctx, {
|
|
662
|
+
uuid: parts.uuid,
|
|
663
|
+
session_id: undefined,
|
|
664
|
+
type: 'result',
|
|
665
|
+
subtype: arm.subtype,
|
|
666
|
+
...head,
|
|
667
|
+
errors,
|
|
668
|
+
...tail,
|
|
526
669
|
});
|
|
527
670
|
}
|
|
671
|
+
function errorsStateCode(first, code) {
|
|
672
|
+
return typeof first === 'string' && (first === code || first.startsWith(`${code}\n`) || first.includes(` (${code})`));
|
|
673
|
+
}
|
|
674
|
+
function wayOutOnFrame(wayOut) {
|
|
675
|
+
return { word: wayOut.word, ...(wayOut.keySource !== undefined ? { keySource: wayOut.keySource } : {}) };
|
|
676
|
+
}
|
|
677
|
+
function routeOnFrame(route) {
|
|
678
|
+
return {
|
|
679
|
+
credentialSource: route.credentialSource,
|
|
680
|
+
...(route.carrier !== undefined ? { carrier: route.carrier } : {}),
|
|
681
|
+
...(route.carrierBag !== undefined ? { carrierBag: route.carrierBag } : {}),
|
|
682
|
+
root: route.root,
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function lastRowOf(observed) {
|
|
686
|
+
if (observed === undefined || !Object.hasOwn(observed, 'lastRow'))
|
|
687
|
+
return null;
|
|
688
|
+
return observed.lastRow ?? null;
|
|
689
|
+
}
|
|
690
|
+
function lastRowTextOf(reading) {
|
|
691
|
+
if (reading.text === undefined)
|
|
692
|
+
return undefined;
|
|
693
|
+
return reading.errorRow === true ? washCredentials(reading.text) : reading.text;
|
|
694
|
+
}
|
|
695
|
+
function failedEventTerminal(code) {
|
|
696
|
+
return typeof code === 'string' && code.length > 0 ? { kind: 'failed', plane: 'flat', code } : { kind: 'failed', plane: 'flat' };
|
|
697
|
+
}
|
|
528
698
|
export function doneToSdkResult(ev, ctx, observed) {
|
|
529
699
|
const msg = doneToSdkResultBody(ev, ctx, observed);
|
|
530
700
|
return isReplayedTerminal(ev) ? Object.assign({}, msg, { _sema_replay: true }) : msg;
|
|
@@ -540,29 +710,41 @@ function doneToSdkResultBody(ev, ctx, observed) {
|
|
|
540
710
|
if (typeof echoedSid === 'string' && echoedSid.length > 0)
|
|
541
711
|
ctx.sessionId = echoedSid;
|
|
542
712
|
const terminal = readRunTerminal(ev.result);
|
|
713
|
+
const armReading = printArmReadingOf({ terminal: terminal ?? null, lastRow: lastRowOf(observed) });
|
|
714
|
+
const arm = armReading.arm;
|
|
543
715
|
const durationMs = elapsedMs(ctx);
|
|
544
716
|
const errorCode = runTerminalCode(terminal);
|
|
545
717
|
const degraded = degradedOf(r);
|
|
546
718
|
const parkFailedReason = readFrameStringKey(ev, '_sema_park_failed_reason');
|
|
547
719
|
const terminalRunId = terminalRunIdOf(ev);
|
|
548
720
|
const resultUuid = terminalRunId === undefined ? undefined : terminalUuidOf(terminalRunId, 'result');
|
|
549
|
-
const errorBase = { uuid: resultUuid, durationMs, stats, model: r.model, errorCode, degraded, observed, facts: effectiveFactParts(rec), parkFailedReason, abortCause: abortCauseWordOf(ev) };
|
|
721
|
+
const errorBase = { uuid: resultUuid, arm, lastRowText: lastRowTextOf(armReading), durationMs, stats, model: r.model, errorCode, degraded, observed, facts: effectiveFactParts(rec), parkFailedReason, abortCause: abortCauseWordOf(ev) };
|
|
550
722
|
if (terminal?.kind === 'failed') {
|
|
551
723
|
const failedCode = terminal.code;
|
|
552
724
|
const failedMessage = terminal.message;
|
|
553
|
-
const
|
|
725
|
+
const failedLimit = 'limit' in arm ? arm.limit : undefined;
|
|
726
|
+
const failedCoded = observed !== undefined && Object.hasOwn(observed, 'codedDetail') ? observed.codedDetail : runTerminalCodedDetail(terminal);
|
|
554
727
|
if (failedCode !== undefined && CUTOFF_EXCEEDED_CODES.has(failedCode)) {
|
|
555
728
|
return errorResult(ctx, {
|
|
556
729
|
...errorBase,
|
|
557
|
-
|
|
730
|
+
...(failedCoded !== undefined ? { codedDetail: failedCoded } : {}),
|
|
558
731
|
...cutoffParts(r, failedMessage, failedCode === LIMITS_MAX_TOKENS_EXCEEDED
|
|
559
732
|
? 'run exhausted its token budget'
|
|
560
733
|
: 'run hit its wall-clock limit', failedCode),
|
|
561
734
|
});
|
|
562
735
|
}
|
|
736
|
+
const rejection = terminal.detail?.kind === 'provider_rejected' ? terminal.detail : undefined;
|
|
737
|
+
const wayOutFacts = observed !== undefined && Object.hasOwn(observed, 'wayOutFacts')
|
|
738
|
+
? observed.wayOutFacts
|
|
739
|
+
: failedLimit !== undefined || isLimitsExceededCode(failedCode)
|
|
740
|
+
? undefined
|
|
741
|
+
: localWayOutFacts(r, rejection);
|
|
742
|
+
const failedWayOut = wayOutFacts === undefined || failedLimit !== undefined ? undefined : wayOutOfApiErrorFacts(wayOutFacts);
|
|
563
743
|
return errorResult(ctx, {
|
|
564
744
|
...errorBase,
|
|
565
|
-
|
|
745
|
+
...(failedWayOut !== undefined ? { wayOut: failedWayOut } : {}),
|
|
746
|
+
...(failedCoded !== undefined ? { codedDetail: failedCoded } : {}),
|
|
747
|
+
...(terminal.detail?.kind === 'provider_rejected' && terminal.detail.route !== undefined ? { route: terminal.detail.route } : {}),
|
|
566
748
|
errors: [
|
|
567
749
|
withTerminalNote(isRewindFamilyCode(failedCode) && failedMessage
|
|
568
750
|
? `${failedMessage} (${failedCode})`
|
|
@@ -573,7 +755,6 @@ function doneToSdkResultBody(ev, ctx, observed) {
|
|
|
573
755
|
if (terminal?.kind === 'blocked') {
|
|
574
756
|
return errorResult(ctx, {
|
|
575
757
|
...errorBase,
|
|
576
|
-
subtype: 'error_during_execution',
|
|
577
758
|
errors: [runBlockedText(terminal)],
|
|
578
759
|
});
|
|
579
760
|
}
|
|
@@ -589,7 +770,6 @@ function doneToSdkResultBody(ev, ctx, observed) {
|
|
|
589
770
|
: `Answer it in the interactive REPL${sid ? ` (sema --resume ${sid})` : ''}, or decide the pending approval via the engine approvals API${sid ? ` (POST /v1/approvals/${sid}/decide)` : ''}.`;
|
|
590
771
|
return errorResult(ctx, {
|
|
591
772
|
...errorBase,
|
|
592
|
-
subtype: 'error_during_execution',
|
|
593
773
|
errors: [
|
|
594
774
|
`Turn suspended awaiting ${awaiting} that no one can provide in -p (non-interactive) mode${runId ? ` (run ${runId})` : ''}. ${wayOut}`,
|
|
595
775
|
],
|
|
@@ -598,7 +778,6 @@ function doneToSdkResultBody(ev, ctx, observed) {
|
|
|
598
778
|
if (terminal === null || terminal === undefined) {
|
|
599
779
|
return errorResult(ctx, {
|
|
600
780
|
...errorBase,
|
|
601
|
-
subtype: 'error_during_execution',
|
|
602
781
|
outcomeUnknown: true,
|
|
603
782
|
errors: [
|
|
604
783
|
'run ended with no terminal record — outcome unknown, not a failure verdict (this client cannot tell whether the run succeeded; treat the result as unverified)',
|
|
@@ -608,7 +787,6 @@ function doneToSdkResultBody(ev, ctx, observed) {
|
|
|
608
787
|
if (terminal?.kind === 'unknown') {
|
|
609
788
|
return errorResult(ctx, {
|
|
610
789
|
...errorBase,
|
|
611
|
-
subtype: 'error_during_execution',
|
|
612
790
|
outcomeUnknown: true,
|
|
613
791
|
errors: [
|
|
614
792
|
terminal.message ??
|
|
@@ -619,24 +797,25 @@ function doneToSdkResultBody(ev, ctx, observed) {
|
|
|
619
797
|
],
|
|
620
798
|
});
|
|
621
799
|
}
|
|
800
|
+
const completedArm = arm;
|
|
622
801
|
return stamp(ctx, {
|
|
623
802
|
uuid: resultUuid,
|
|
624
803
|
session_id: undefined,
|
|
625
804
|
type: 'result',
|
|
626
|
-
subtype:
|
|
805
|
+
subtype: completedArm.subtype,
|
|
627
806
|
duration_ms: durationMs,
|
|
628
807
|
duration_api_ms: durationMs,
|
|
629
|
-
is_error:
|
|
808
|
+
is_error: completedArm.is_error,
|
|
630
809
|
num_turns: stats?.turns ?? 0,
|
|
631
810
|
result: r.result ?? '',
|
|
632
811
|
...structuredOutputParts(r),
|
|
633
812
|
...(degraded !== undefined ? { _sema_model_degraded: degraded } : {}),
|
|
634
|
-
stop_reason:
|
|
813
|
+
stop_reason: completedArm.stop_reason,
|
|
635
814
|
total_cost_usd: costOrNull(stats),
|
|
636
815
|
usage: flattenUsage(stats),
|
|
637
816
|
modelUsage: modelUsageFor(stats, r.model),
|
|
638
817
|
...permissionDenialParts(stats, observed),
|
|
639
|
-
...terminalReasonParts(
|
|
818
|
+
...terminalReasonParts(completedArm.subtype, completedArm.is_error),
|
|
640
819
|
...costFactParts(stats, observed),
|
|
641
820
|
...effectiveFactParts(rec),
|
|
642
821
|
...nestedUsageByTaskParts(stats, observed?.nestedUsageByTask),
|
|
@@ -644,9 +823,10 @@ function doneToSdkResultBody(ev, ctx, observed) {
|
|
|
644
823
|
});
|
|
645
824
|
}
|
|
646
825
|
export function failedToSdkResult(ev, ctx, observed) {
|
|
647
|
-
const
|
|
826
|
+
const armReading = printArmReadingOf({ terminal: failedEventTerminal(ev.errorCode), lastRow: lastRowOf(observed) });
|
|
648
827
|
return errorResult(ctx, {
|
|
649
|
-
|
|
828
|
+
arm: armReading.arm,
|
|
829
|
+
lastRowText: lastRowTextOf(armReading),
|
|
650
830
|
observed,
|
|
651
831
|
durationMs: elapsedMs(ctx),
|
|
652
832
|
errorCode: ev.errorCode,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WiringManifestModelGate, WiringManifestAutoMode, WiringManifestMcpEntryView, WiringManifestHookEntryView, WiringManifestLspSeamView, WiringManifestWriteProtectionView, WiringManifestAutoConsolidationView, WiringManifestReadDenyView } from './eventToSdkMessage.js';
|
|
1
|
+
import type { WiringManifestModelGate, WiringManifestAutoMode, WiringManifestMcpEntryView, WiringManifestHookEntryView, WiringManifestLspSeamView, WiringManifestWriteProtectionView, WiringManifestAutoConsolidationView, WiringManifestReadDenyView, WiringManifestModView } from './eventToSdkMessage.js';
|
|
2
2
|
import type { ToolRosterView, WiringManifestHandsView } from '../../toolRoster.js';
|
|
3
3
|
export type WiringManifestSections = {
|
|
4
4
|
_sema_modelGate?: WiringManifestModelGate;
|
|
@@ -16,6 +16,7 @@ export type WiringManifestSections = {
|
|
|
16
16
|
readonly selected: readonly string[];
|
|
17
17
|
};
|
|
18
18
|
_sema_fleet?: WiringManifestFleetView;
|
|
19
|
+
_sema_mods?: WiringManifestModView[];
|
|
19
20
|
eventId?: string;
|
|
20
21
|
};
|
|
21
22
|
export interface WiringManifestFleetView {
|
|
@@ -37,6 +38,7 @@ export interface WiringManifestView {
|
|
|
37
38
|
readonly selected: readonly string[];
|
|
38
39
|
};
|
|
39
40
|
fleet?: WiringManifestFleetView;
|
|
41
|
+
mods?: readonly WiringManifestModView[];
|
|
40
42
|
eventId?: string;
|
|
41
43
|
}
|
|
42
44
|
export declare function readInstructionsSegment(holder: object, key: 'instructions' | '_sema_instructions'): {
|
|
@@ -59,6 +59,7 @@ export function wiringManifestViewOf(s) {
|
|
|
59
59
|
...(typeof s._sema_fileHistory === 'string' && s._sema_fileHistory.length > 0 ? { fileHistory: s._sema_fileHistory } : {}),
|
|
60
60
|
...(instructions !== undefined ? { instructions } : {}),
|
|
61
61
|
...(fleet !== undefined ? { fleet } : {}),
|
|
62
|
+
...(Array.isArray(s._sema_mods) ? { mods: s._sema_mods } : {}),
|
|
62
63
|
};
|
|
63
64
|
if (Object.keys(view).length === 0)
|
|
64
65
|
return undefined;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { AgentEvent } from '@sema-agent/sdk';
|
|
2
2
|
import { type SDKMessage, type EmitContext, type ModelUsage } from './types.js';
|
|
3
3
|
import { type EngineTurnUsage } from './downstream/turnUsageToModelUsage.js';
|
|
4
|
+
import type { ObservedTerminalParts } from './downstream/terminalToSdkResult.js';
|
|
4
5
|
import { type ToolHistoryErrorCarrier } from '../toolHistoryMismatch.js';
|
|
6
|
+
import { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, RUN_STOPPED_MESSAGE_PREFIX } from '../rowKind.js';
|
|
7
|
+
export { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, RUN_STOPPED_MESSAGE_PREFIX };
|
|
5
8
|
export interface ActiveRunPendingGate {
|
|
6
9
|
readonly kind: string | null;
|
|
7
10
|
readonly decidePath: string | null;
|
|
@@ -16,13 +19,9 @@ export interface ActiveRunBusySignal {
|
|
|
16
19
|
readonly msSinceLastActivity?: number;
|
|
17
20
|
}
|
|
18
21
|
export declare function activeRunBusySignal(ev: unknown): ActiveRunBusySignal | null;
|
|
19
|
-
export declare const RUN_STOPPED_MESSAGE_PREFIX = "Run stopped";
|
|
20
|
-
export declare const RUN_BLOCKED_MESSAGE_PREFIX = "Run blocked";
|
|
21
22
|
export declare function isGovernanceStopRowText(text: string): boolean;
|
|
22
|
-
export declare const MODEL_OUTPUT_ERROR_PREFIX = "Model output error";
|
|
23
23
|
export declare function isModelOutputErrorText(text: string): boolean;
|
|
24
24
|
export declare function isModelOutputErrorRowText(text: string): boolean;
|
|
25
|
-
export declare const OUTCOME_UNKNOWN_ROW_PREFIX = "Outcome unknown";
|
|
26
25
|
export declare function isOutcomeUnknownRowText(text: string): boolean;
|
|
27
26
|
export declare function isGovernanceTerminal(input: {
|
|
28
27
|
status: string | undefined;
|
|
@@ -36,6 +35,7 @@ export interface RunStreamHandle {
|
|
|
36
35
|
latestUsage?: ModelUsage;
|
|
37
36
|
latestEngineUsage?: EngineTurnUsage | undefined;
|
|
38
37
|
latestUsageMissing?: true;
|
|
38
|
+
observedTerminalParts?: () => ObservedTerminalParts;
|
|
39
39
|
}
|
|
40
40
|
export declare function isRunStreamActive(): boolean;
|
|
41
41
|
export declare function runStream(events: AsyncIterable<AgentEvent>, ctx: EmitContext, handle?: RunStreamHandle): AsyncGenerator<SDKMessage>;
|