@sema-agent/client-core 0.100.0 → 0.102.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 +452 -0
- package/README.md +172 -120
- package/dist/adapt/arms.js +51 -16
- package/dist/adapt/textStream.js +7 -4
- package/dist/adapt/toolCards.d.ts +2 -1
- package/dist/adapt/toolCards.js +28 -13
- package/dist/adapt.d.ts +1 -1
- package/dist/adapt.js +8 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +24 -2
- package/dist/adapter/activeRunSelfHeal.js +108 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +38 -79
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
- package/dist/adapter/downstream/terminalToSdkResult.js +209 -39
- package/dist/adapter/downstream/wiringManifestView.d.ts +1 -0
- package/dist/adapter/downstream/wiringManifestView.js +138 -0
- package/dist/adapter/runStream.d.ts +4 -4
- package/dist/adapter/runStream.js +158 -43
- package/dist/agentsWireCaps.d.ts +2 -7
- package/dist/agentsWireCaps.js +1 -2
- 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 +19 -5
- package/dist/cloudConfigWireCaps.js +193 -56
- package/dist/compensations.js +1 -1
- package/dist/coreValuePorts.d.ts +12 -2
- package/dist/coreValuePorts.js +9 -0
- package/dist/decideFailureNote.js +5 -3
- 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 +9 -4
- package/dist/displayUntrusted.js +834 -104
- package/dist/engineCapReader.js +1 -1
- package/dist/engineConfigDrift.js +1 -1
- package/dist/engineErrorCodes.d.ts +14 -5
- package/dist/engineErrorCodes.js +27 -6
- 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.js +2 -2
- 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/executionLaneCapability.js +2 -2
- package/dist/fileHistoryCaptureCapability.js +3 -3
- 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 +16 -3
- package/dist/gateVocabulary.js +3 -0
- package/dist/generated/engineFactTables.d.ts +7 -3
- package/dist/generated/engineFactTables.js +52 -0
- package/dist/generated/engineNoticeTables.js +12 -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 +54 -0
- package/dist/generated/settingsSchemaFns.js +26 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.js +1 -7
- 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 +2 -0
- package/dist/generated/settingsSchemaTables.js +13 -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 +7 -5
- package/dist/hitl/approvalCardReading.d.ts +3 -0
- package/dist/hitl/approvalCardReading.js +17 -0
- 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/approvalResolution.d.ts +11 -0
- package/dist/hitl/approvalResolution.js +50 -11
- package/dist/hitl/askClassPair.d.ts +6 -0
- package/dist/hitl/askClassPair.js +30 -3
- 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 +42 -3
- package/dist/hitl/attributionLadder.js +79 -8
- 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/decisionRefusal.d.ts +20 -10
- package/dist/hitl/decisionRefusal.js +99 -54
- package/dist/hitl/decisionSend.d.ts +3 -0
- package/dist/hitl/decisionSend.js +87 -103
- 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 +41 -37
- 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 +59 -30
- 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 +62 -29
- 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 +72 -54
- 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 +73 -17
- package/dist/hostTurnSettings.js +594 -97
- package/dist/httpHookPolicy.d.ts +37 -0
- package/dist/httpHookPolicy.js +176 -0
- package/dist/humanTurn.d.ts +2 -1
- package/dist/humanTurn.js +37 -7
- 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 +222 -2
- package/dist/i18n/messages.en.js +225 -5
- package/dist/i18n/messages.zh.js +237 -5
- package/dist/i18n/translate.js +3 -3
- package/dist/index.d.ts +77 -15
- package/dist/index.js +50 -13
- package/dist/inheritEnvCapability.d.ts +3 -1
- package/dist/inheritEnvCapability.js +31 -17
- package/dist/inheritEnvWire.d.ts +2 -1
- package/dist/inheritEnvWire.js +11 -5
- package/dist/interactiveHalt.d.ts +3 -1
- package/dist/interactiveHalt.js +2 -0
- package/dist/interactiveInterrupt.d.ts +2 -0
- package/dist/interactiveInterrupt.js +15 -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 +1 -1
- package/dist/mcpProbeCapability.js +2 -2
- package/dist/mcpStatusSupersetKeys.d.ts +24 -0
- package/dist/mcpStatusSupersetKeys.js +45 -0
- package/dist/mcpToolToggles.js +2 -1
- package/dist/mcpWireCaps.d.ts +39 -1
- package/dist/mcpWireCaps.js +254 -50
- 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.js +6 -6
- package/dist/modelIdentityResolvability.d.ts +10 -1
- package/dist/modelIdentityResolvability.js +62 -39
- package/dist/modsFace.d.ts +8 -0
- package/dist/modsFace.js +59 -0
- 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 +12 -0
- package/dist/ownKey.js +179 -3
- package/dist/panelReduce.js +1 -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.js +2 -0
- 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 +92 -53
- package/dist/prepareRefusal.d.ts +3 -2
- package/dist/prepareRefusal.js +27 -9
- package/dist/printInitToolFace.js +2 -2
- package/dist/printModelStatus.js +1 -1
- package/dist/printToolResultFrame.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 +6 -2
- package/dist/request/submissionIdentity.d.ts +37 -0
- package/dist/request/submissionIdentity.js +65 -0
- package/dist/request/taskRequest.d.ts +33 -4
- package/dist/request/taskRequest.js +341 -156
- package/dist/resultFrameKeys.d.ts +1 -0
- package/dist/resultFrameKeys.js +4 -1
- package/dist/retryStatus.d.ts +8 -0
- package/dist/retryStatus.js +57 -9
- 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 +4 -0
- package/dist/ruleRefusalSentence.js +9 -3
- 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 +1 -1
- package/dist/sandboxWire.js +4 -6
- package/dist/scenarioRefusal.js +1 -1
- 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 +2 -0
- package/dist/seam.js +3 -3
- package/dist/seatContract.d.ts +68 -7
- package/dist/seatContract.js +84 -25
- package/dist/selfOrchestrationDenial.js +1 -1
- package/dist/sessionBackground.d.ts +165 -0
- package/dist/sessionBackground.js +781 -0
- package/dist/sessionBackgroundHandoff.d.ts +54 -0
- package/dist/sessionBackgroundHandoff.js +321 -0
- package/dist/sessionMap.js +4 -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.js +55 -15
- 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 -0
- package/dist/skillsWireCaps.js +47 -16
- 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/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/thinkingLatch.d.ts +69 -0
- package/dist/thinkingLatch.js +255 -0
- package/dist/thinkingLatchWords.d.ts +7 -0
- package/dist/thinkingLatchWords.js +4 -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 +159 -32
- 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/turnFailurePresentation.js +27 -90
- 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 +24 -1
- package/dist/wireRefusalCopy.js +253 -32
- 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 +907 -182
- package/package.json +14 -3
- package/dist/argvFlagValue.d.ts +0 -8
- package/dist/argvFlagValue.js +0 -37
|
@@ -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,6 +169,9 @@ 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 } : {}),
|
|
158
176
|
...(owner !== undefined ? { _sema_terminal_owner: owner } : {}),
|
|
159
177
|
});
|
|
@@ -161,11 +179,14 @@ function syntheticTerminalRow(ctx, identity, replayed, text, historyKey, resend,
|
|
|
161
179
|
function withTerminalOwner(frame, owner) {
|
|
162
180
|
return owner === undefined ? frame : { ...frame, _sema_terminal_owner: owner };
|
|
163
181
|
}
|
|
182
|
+
function withHistoryAccepted(frame, accepted) {
|
|
183
|
+
return accepted === undefined ? frame : { ...frame, [SEMA_TOOL_HISTORY_ACCEPTED_KEY]: true };
|
|
184
|
+
}
|
|
164
185
|
function terminalOwnerOfStream(ctx, busy, busyHandle, runId) {
|
|
165
186
|
const hostString = (k) => {
|
|
166
187
|
try {
|
|
167
188
|
const d = Object.getOwnPropertyDescriptor(ctx, k);
|
|
168
|
-
return d !== undefined && 'value'
|
|
189
|
+
return d !== undefined && Object.hasOwn(d, 'value') && typeof d.value === 'string' && d.value.length > 0 ? d.value : undefined;
|
|
169
190
|
}
|
|
170
191
|
catch {
|
|
171
192
|
return undefined;
|
|
@@ -192,7 +213,7 @@ function engineSessionIdOf(result) {
|
|
|
192
213
|
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
193
214
|
}
|
|
194
215
|
export function isOutcomeUnknownRowText(text) {
|
|
195
|
-
return text
|
|
216
|
+
return legacyRowKindOfText(text) === 'outcome_unknown';
|
|
196
217
|
}
|
|
197
218
|
export function isGovernanceTerminal(input) {
|
|
198
219
|
if (input.status === 'blocked')
|
|
@@ -291,8 +312,18 @@ function ownTerminalSnapshot(result) {
|
|
|
291
312
|
}
|
|
292
313
|
const ts = ownDataCopy(t, ['kind', 'code', 'message']);
|
|
293
314
|
const detail = plainObjectOf(ownDataBit(t, 'detail'));
|
|
294
|
-
if (detail !== undefined)
|
|
295
|
-
|
|
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
|
+
}
|
|
296
327
|
snap.terminal = ts;
|
|
297
328
|
return snap;
|
|
298
329
|
}
|
|
@@ -356,6 +387,7 @@ function apiErrorTerminalFromFacts(x, facts) {
|
|
|
356
387
|
return {
|
|
357
388
|
carrier: mintToolHistoryCarrier(nonEmptyStr(ownDataBit(read, 'code')), status, nonEmptyStr(ownDataBit(read, 'message'))),
|
|
358
389
|
detail: detail,
|
|
390
|
+
coded: runTerminalCodedDetail(read),
|
|
359
391
|
};
|
|
360
392
|
}
|
|
361
393
|
catch {
|
|
@@ -413,6 +445,15 @@ export function _resetDroppedFrameReportForTest() {
|
|
|
413
445
|
export function _droppedFrameMemoSizeForTest() {
|
|
414
446
|
return reportedDroppedTypes.size;
|
|
415
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
|
+
}
|
|
416
457
|
function withStringFailureFields(ev) {
|
|
417
458
|
if (ev.type !== 'failed')
|
|
418
459
|
return ev;
|
|
@@ -460,6 +501,73 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
460
501
|
let deniedCallsOverflowed = false;
|
|
461
502
|
let successfulToolEndObserved = false;
|
|
462
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
|
+
};
|
|
463
571
|
const sameArgs = (a, b) => {
|
|
464
572
|
if (a === b)
|
|
465
573
|
return true;
|
|
@@ -472,6 +580,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
472
580
|
};
|
|
473
581
|
for await (const rawEv of events) {
|
|
474
582
|
const ev = withStringFailureFields(rawEv);
|
|
583
|
+
const wireSubFlow = wireFrameIsSubFlow(ev);
|
|
475
584
|
if (ev.type === 'tool_end' && ev.isError !== true)
|
|
476
585
|
successfulToolEndObserved = true;
|
|
477
586
|
const seq = eventSeq(ev);
|
|
@@ -596,10 +705,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
596
705
|
reportDroppedFrame('turn_end_usage_absent', ev.type, ctx);
|
|
597
706
|
continue;
|
|
598
707
|
}
|
|
599
|
-
const
|
|
600
|
-
const isSubFlow = identityEnvelope.parentToolCallId !== undefined ||
|
|
601
|
-
identityEnvelope.sourceTaskId !== undefined ||
|
|
602
|
-
identityEnvelope.bgAgentId !== undefined;
|
|
708
|
+
const isSubFlow = wireSubFlow;
|
|
603
709
|
{
|
|
604
710
|
if (measured !== undefined) {
|
|
605
711
|
handle.latestUsage = usage;
|
|
@@ -664,6 +770,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
664
770
|
}
|
|
665
771
|
const outputTokens = engineUsage.outputTokens;
|
|
666
772
|
if (!isSubFlow) {
|
|
773
|
+
closeLiveMessage();
|
|
667
774
|
yield {
|
|
668
775
|
type: 'turn_usage',
|
|
669
776
|
...(usageMissing ? { _sema_usage_missing: true } : { _sema_last_assistant_usage: usage }),
|
|
@@ -682,7 +789,10 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
682
789
|
const terminalRunId = terminalRunIdOf(ev);
|
|
683
790
|
const replayed = isReplayedTerminal(ev);
|
|
684
791
|
const owner = terminalOwnerOfStream(ctx, rowFacts.busy.busy, rowFacts.busy.handle, terminalRunId);
|
|
792
|
+
let wayOutFacts;
|
|
793
|
+
let codedDetailJudged;
|
|
685
794
|
const errText = rowFacts.errText;
|
|
795
|
+
let historyAcceptedSinceMismatch;
|
|
686
796
|
if (errText) {
|
|
687
797
|
const busy = rowFacts.busy;
|
|
688
798
|
const maxTokHint = /max_tokens/i.test(errText)
|
|
@@ -691,9 +801,11 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
691
801
|
const busyHandle = busy.handle;
|
|
692
802
|
const arm = terminalRowArmOf(rowFacts);
|
|
693
803
|
const rowText = arm === 'busy'
|
|
694
|
-
?
|
|
804
|
+
? `${SESSION_BUSY_ROW_LEAD}${busyHandle ? ` (run ${busyHandle})` : ''} that ` +
|
|
695
805
|
`has not been released, so this message was NOT sent. Nothing releases it on its own — ` +
|
|
696
|
-
|
|
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.`)
|
|
697
809
|
: arm === 'governance'
|
|
698
810
|
?
|
|
699
811
|
`${isGovernanceStopRowText(errText) ? errText : `${RUN_STOPPED_MESSAGE_PREFIX}: ${errText}`}${maxTokHint}`
|
|
@@ -706,34 +818,40 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
706
818
|
: doneTerminal?.kind === 'failed' && isCorruptSessionCode(doneTerminal.code);
|
|
707
819
|
const abortNote = abortCauseNoteOf(ev);
|
|
708
820
|
const historyTerminal = apiErrorTerminalOfRowFrame(ev, rowFacts);
|
|
821
|
+
if (arm === 'apiError') {
|
|
822
|
+
wayOutFacts = wayOutFactsOfApiError(historyTerminal);
|
|
823
|
+
codedDetailJudged = { value: historyTerminal.coded };
|
|
824
|
+
}
|
|
709
825
|
const historyMismatch = classifyToolHistoryMismatch(historyTerminal.carrier);
|
|
710
826
|
const historyEchoedSid = ev.type === 'done' ? engineSessionIdOf(engineResultOf(ev.result)) : undefined;
|
|
711
|
-
const historyRepeat =
|
|
827
|
+
const historyRepeat = noteToolHistoryTerminalFacts({
|
|
712
828
|
sessionId: historyEchoedSid ?? ctx.sessionId,
|
|
713
829
|
sessionEchoed: historyEchoedSid !== undefined,
|
|
714
830
|
generation: historyGeneration,
|
|
715
831
|
runId: terminalRunId,
|
|
716
832
|
replay: replayed,
|
|
717
833
|
mismatch: historyMismatch,
|
|
718
|
-
|
|
834
|
+
accepted: false,
|
|
835
|
+
}).consecutive;
|
|
719
836
|
const rewindOffered = historyMismatch !== null && ctx.lane !== 'print' && ctx.lane !== 'utility' && toolHistoryRewindOffered(ctx.offersRewind);
|
|
720
837
|
const rewindLine = rewindOffered
|
|
721
838
|
? `\n${TOOL_HISTORY_REWIND_SENTENCE}${historyRepeat !== undefined && historyRepeat >= 2 ? ` ${toolHistoryRepeatSentence(historyRepeat)}` : ''}`
|
|
722
839
|
: '';
|
|
723
840
|
const resend = historyTerminal.detail !== undefined ? providerRejectionResend(historyTerminal.detail, historyTerminal.carrier) : undefined;
|
|
724
841
|
const resendLine = resend !== undefined ? `\n${resend.text}` : '';
|
|
725
|
-
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, owner);
|
|
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));
|
|
726
843
|
}
|
|
727
844
|
else {
|
|
728
845
|
const echoedSid = ev.type === 'done' ? engineSessionIdOf(engineResultOf(ev.result)) : undefined;
|
|
729
|
-
|
|
846
|
+
historyAcceptedSinceMismatch = noteToolHistoryTerminalFacts({
|
|
730
847
|
sessionId: echoedSid ?? ctx.sessionId,
|
|
731
848
|
sessionEchoed: echoedSid !== undefined,
|
|
732
849
|
generation: historyGeneration,
|
|
733
850
|
runId: terminalRunId,
|
|
734
851
|
replay: replayed,
|
|
735
852
|
mismatch: null,
|
|
736
|
-
|
|
853
|
+
accepted: ev.type === 'done' && (doneTerminal?.kind === 'completed' || doneTerminal?.kind === 'paused'),
|
|
854
|
+
}).acceptedSinceMismatch;
|
|
737
855
|
}
|
|
738
856
|
if (ev.type === 'done' && isReviewPark(doneTerminal) && ctx.emitChrome) {
|
|
739
857
|
try {
|
|
@@ -748,23 +866,20 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
748
866
|
emitChromeFireAndForget(ctx, { kind: 'run_cost_reconciled', laneProof: mainLane(), ...costFacts.reconcile });
|
|
749
867
|
}
|
|
750
868
|
}
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
streamSawRunOpen,
|
|
759
|
-
deniedToolNameByCallId,
|
|
760
|
-
deniedCallsOverflowed,
|
|
761
|
-
}), owner);
|
|
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());
|
|
762
876
|
const outcome = resultFrame.
|
|
763
877
|
_sema_outcome;
|
|
764
878
|
if (outcome === 'unknown') {
|
|
765
|
-
const errs = resultFrame.errors;
|
|
879
|
+
const errs = (resultFrame.errors ?? mintResultFrame(null).errors);
|
|
766
880
|
const sentence = Array.isArray(errs) && typeof errs[0] === 'string' ? errs[0] : 'the run ended without a terminal record this client can read';
|
|
767
|
-
yield syntheticTerminalRow(ctx, { runId: terminalRunId, label: 'outcome-unknown' }, replayed, `${OUTCOME_UNKNOWN_ROW_PREFIX}: ${sentence}`, undefined, undefined, undefined, owner);
|
|
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());
|
|
768
883
|
}
|
|
769
884
|
yield terminalFactOf(ev, doneTerminal);
|
|
770
885
|
yield resultFrame;
|
|
@@ -777,7 +892,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
777
892
|
}
|
|
778
893
|
const projection = eventToSdkMessage(ev, ctx);
|
|
779
894
|
if (projection.kind === 'message') {
|
|
780
|
-
yield projection.message;
|
|
895
|
+
yield noteRow(projection.message, wireSubFlow);
|
|
781
896
|
continue;
|
|
782
897
|
}
|
|
783
898
|
if (projection.kind === 'dropped')
|
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[];
|
package/dist/agentsWireCaps.js
CHANGED
|
@@ -224,9 +224,8 @@ export function projectAgentsForWire(defs, deps) {
|
|
|
224
224
|
whoMemo = `agent "${name}"${typeof source === 'string' && source.length > 0 ? ` (${capForDisplay(source, 120)})` : ''}`;
|
|
225
225
|
return whoMemo;
|
|
226
226
|
};
|
|
227
|
-
const rosterInHand = typeof rosterMountedNames(deps.toolRoster) === 'object';
|
|
228
227
|
const flaws = agentToolListFlaws([item], deps.toolRoster).map((f) => {
|
|
229
|
-
if (
|
|
228
|
+
if (f.list !== 'disallowedTools' || f.kind !== 'retired' || f.currentName === undefined || f.toolName !== undefined)
|
|
230
229
|
return f;
|
|
231
230
|
const to = f.currentName;
|
|
232
231
|
if (item.denyTools !== undefined)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader } from './engineCapReader.js';
|
|
3
3
|
import { ownDataField, readOwnDataValue } from './ownKey.js';
|
|
4
4
|
export function projectApprovalDecidedByCapability(caps) {
|
|
@@ -18,7 +18,7 @@ const reader = createEngineCapReader({
|
|
|
18
18
|
name: 'approvalDecidedBy',
|
|
19
19
|
project: projectApprovalDecidedByCapability,
|
|
20
20
|
});
|
|
21
|
-
export function observedApprovalDecidedBy(baseUrl =
|
|
21
|
+
export function observedApprovalDecidedBy(baseUrl = engineWireTargetBaseUrl()) {
|
|
22
22
|
return reader.observed(baseUrl);
|
|
23
23
|
}
|
|
24
24
|
export function approvalDecidedByAdmitted(reading) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type ApprovalFrameFamiliesReading = {
|
|
2
|
+
readonly kind: 'confirmed';
|
|
3
|
+
readonly families: readonly string[];
|
|
4
|
+
} | {
|
|
5
|
+
readonly kind: 'absent';
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'declined';
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'unreadable';
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'unobserved';
|
|
12
|
+
};
|
|
13
|
+
export declare function observedApprovalFrameFamilies(baseUrl?: string | undefined): ApprovalFrameFamiliesReading;
|
|
14
|
+
export type ApprovalFrameFamiliesWithheldCause = 'capability_absent' | 'capability_declined' | 'capability_unreadable' | 'reading_absent';
|
|
15
|
+
export interface ApprovalFrameFamiliesWithheld {
|
|
16
|
+
readonly cause: ApprovalFrameFamiliesWithheldCause;
|
|
17
|
+
}
|
|
18
|
+
export interface ApprovalFrameFamiliesDeclaration {
|
|
19
|
+
readonly field: {
|
|
20
|
+
readonly approvalFrameFamilies?: readonly string[];
|
|
21
|
+
};
|
|
22
|
+
readonly withheld?: ApprovalFrameFamiliesWithheld;
|
|
23
|
+
}
|
|
24
|
+
export declare function approvalFrameFamiliesDeclaration(reading: ApprovalFrameFamiliesReading): ApprovalFrameFamiliesDeclaration;
|
|
25
|
+
export declare function frameFamiliesJudgementOf(reading: ApprovalFrameFamiliesReading): FrameFamiliesJudgement;
|
|
26
|
+
export type FrameFamiliesJudgement = {
|
|
27
|
+
readonly ok: true;
|
|
28
|
+
readonly families: readonly string[];
|
|
29
|
+
} | {
|
|
30
|
+
readonly ok: false;
|
|
31
|
+
readonly cause: ApprovalFrameFamiliesWithheldCause;
|
|
32
|
+
};
|
|
33
|
+
export declare function intersectRenderedFamilies(presented: readonly string[], rendered: readonly string[]): readonly string[];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { engineCapNestedValue, engineCapValue } from './engineCapsCache.js';
|
|
2
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
3
|
+
import { appendOwnElement, guardedRead, readOwnDataValue } from './ownKey.js';
|
|
4
|
+
const PRESENTED_FAMILIES_KEY = 'approvalFrameFamilies';
|
|
5
|
+
const ACCEPTANCE_GROUP_KEY = 'taskSettings';
|
|
6
|
+
const ACCEPTANCE_KEY = 'approvalFrameFamilies';
|
|
7
|
+
const SERVER_FRAME_FAMILY_WORDS = Object.freeze(['tool_approval', 'approval_request']);
|
|
8
|
+
const RENDERED_FRAME_FAMILY_WORDS = Object.freeze(['tool_approval', 'approval_request']);
|
|
9
|
+
const MAX_PRESENTED_ENTRIES = 16;
|
|
10
|
+
const READ_ABSENT = Object.freeze({ kind: 'absent' });
|
|
11
|
+
const READ_DECLINED = Object.freeze({ kind: 'declined' });
|
|
12
|
+
const READ_UNREADABLE = Object.freeze({ kind: 'unreadable' });
|
|
13
|
+
const READ_UNOBSERVED = Object.freeze({ kind: 'unobserved' });
|
|
14
|
+
function presentedFamiliesOf(raw) {
|
|
15
|
+
try {
|
|
16
|
+
if (!Array.isArray(raw)) {
|
|
17
|
+
if (typeof raw === 'object' && raw !== null)
|
|
18
|
+
Object.getPrototypeOf(raw);
|
|
19
|
+
return 'declined';
|
|
20
|
+
}
|
|
21
|
+
const lenDesc = Object.getOwnPropertyDescriptor(raw, 'length');
|
|
22
|
+
const len = lenDesc !== undefined && Object.hasOwn(lenDesc, 'value') ? lenDesc.value : undefined;
|
|
23
|
+
if (typeof len !== 'number' || !Number.isInteger(len) || len < 0)
|
|
24
|
+
return 'unreadable';
|
|
25
|
+
if (len > MAX_PRESENTED_ENTRIES)
|
|
26
|
+
return 'declined';
|
|
27
|
+
const out = [];
|
|
28
|
+
for (let i = 0; i < len; i++) {
|
|
29
|
+
const d = Object.getOwnPropertyDescriptor(raw, String(i));
|
|
30
|
+
if (d === undefined)
|
|
31
|
+
return 'declined';
|
|
32
|
+
if (!Object.hasOwn(d, 'value'))
|
|
33
|
+
return 'unreadable';
|
|
34
|
+
const w = d.value;
|
|
35
|
+
if (typeof w !== 'string' || !SERVER_FRAME_FAMILY_WORDS.includes(w))
|
|
36
|
+
return 'declined';
|
|
37
|
+
if (!out.includes(w))
|
|
38
|
+
appendOwnElement(out, w);
|
|
39
|
+
}
|
|
40
|
+
return Object.freeze(out);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return 'unreadable';
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function observedApprovalFrameFamilies(baseUrl) {
|
|
47
|
+
try {
|
|
48
|
+
const picked = baseUrl === undefined ? engineWireTargetBaseUrl() : baseUrl;
|
|
49
|
+
const base = typeof picked === 'string' ? picked : undefined;
|
|
50
|
+
const accepted = engineCapNestedValue(base, ACCEPTANCE_GROUP_KEY, ACCEPTANCE_KEY);
|
|
51
|
+
switch (accepted.kind) {
|
|
52
|
+
case 'unobserved':
|
|
53
|
+
return READ_UNOBSERVED;
|
|
54
|
+
case 'not_reported':
|
|
55
|
+
return READ_ABSENT;
|
|
56
|
+
case 'unreadable':
|
|
57
|
+
return READ_UNREADABLE;
|
|
58
|
+
case 'null':
|
|
59
|
+
return READ_DECLINED;
|
|
60
|
+
case 'value':
|
|
61
|
+
if (accepted.value !== true)
|
|
62
|
+
return READ_DECLINED;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
const presented = engineCapValue(base, PRESENTED_FAMILIES_KEY);
|
|
66
|
+
switch (presented.kind) {
|
|
67
|
+
case 'unobserved':
|
|
68
|
+
return READ_UNOBSERVED;
|
|
69
|
+
case 'not_reported':
|
|
70
|
+
return READ_ABSENT;
|
|
71
|
+
case 'unreadable':
|
|
72
|
+
return READ_UNREADABLE;
|
|
73
|
+
case 'null':
|
|
74
|
+
return READ_DECLINED;
|
|
75
|
+
case 'value': {
|
|
76
|
+
const families = presentedFamiliesOf(presented.value);
|
|
77
|
+
if (families === 'declined')
|
|
78
|
+
return READ_DECLINED;
|
|
79
|
+
if (families === 'unreadable')
|
|
80
|
+
return READ_UNREADABLE;
|
|
81
|
+
return Object.freeze({ kind: 'confirmed', families });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return READ_UNOBSERVED;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const NO_FIELD = Object.freeze(Object.create(null));
|
|
90
|
+
function withheldOf(cause) {
|
|
91
|
+
return Object.freeze({ field: NO_FIELD, withheld: Object.freeze({ cause }) });
|
|
92
|
+
}
|
|
93
|
+
export function approvalFrameFamiliesDeclaration(reading) {
|
|
94
|
+
const j = judgeReading(reading);
|
|
95
|
+
return j.ok ? Object.freeze({ field: Object.freeze({ approvalFrameFamilies: j.families }) }) : withheldOf(j.cause);
|
|
96
|
+
}
|
|
97
|
+
export function frameFamiliesJudgementOf(reading) {
|
|
98
|
+
return judgeReading(reading);
|
|
99
|
+
}
|
|
100
|
+
function judgeReading(reading) {
|
|
101
|
+
const kind = guardedRead(() => (typeof reading === 'object' && reading !== null ? readOwnDataValue(reading, 'kind') : undefined));
|
|
102
|
+
if (kind === 'absent')
|
|
103
|
+
return { ok: false, cause: 'capability_absent' };
|
|
104
|
+
if (kind === 'declined')
|
|
105
|
+
return { ok: false, cause: 'capability_declined' };
|
|
106
|
+
if (kind !== 'confirmed')
|
|
107
|
+
return { ok: false, cause: 'capability_unreadable' };
|
|
108
|
+
const raw = guardedRead(() => readOwnDataValue(reading, 'families'));
|
|
109
|
+
const presented = presentedFamiliesOf(raw);
|
|
110
|
+
if (presented === 'declined' || presented === 'unreadable')
|
|
111
|
+
return { ok: false, cause: 'capability_unreadable' };
|
|
112
|
+
return { ok: true, families: intersectRenderedFamilies(presented, RENDERED_FRAME_FAMILY_WORDS) };
|
|
113
|
+
}
|
|
114
|
+
export function intersectRenderedFamilies(presented, rendered) {
|
|
115
|
+
const out = [];
|
|
116
|
+
for (const w of presented)
|
|
117
|
+
if (rendered.includes(w) && !out.includes(w))
|
|
118
|
+
appendOwnElement(out, w);
|
|
119
|
+
return Object.freeze(out);
|
|
120
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { engineWireTargetBaseUrl } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
3
3
|
import { ownDataField } from './ownKey.js';
|
|
4
4
|
export function projectApprovalsStreamLiveCapability(caps) {
|
|
@@ -22,7 +22,7 @@ const reader = createEngineCapReader({
|
|
|
22
22
|
name: 'approvalsStreamLive',
|
|
23
23
|
project: projectApprovalsStreamLiveCapability,
|
|
24
24
|
});
|
|
25
|
-
export function observedApprovalsStreamLive(baseUrl =
|
|
25
|
+
export function observedApprovalsStreamLive(baseUrl = engineWireTargetBaseUrl()) {
|
|
26
26
|
return reader.observed(baseUrl);
|
|
27
27
|
}
|
|
28
28
|
export function livePendingNeedsReconcile(reading) {
|