@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
|
@@ -5,7 +5,7 @@ import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../../gateOutcome.js'
|
|
|
5
5
|
import { projectToolRoster, projectToolRosterDelta } from '../../toolRoster.js';
|
|
6
6
|
import { projectHandsSection } from '../../handsSeam.js';
|
|
7
7
|
import { readMcpLiveness } from '../../mcpLiveness.js';
|
|
8
|
-
import { contextUsageReadingOf, humanInputAttachmentsOf, markMcpSectionDroppedNamedRows, readFrameTrueMark } from '../../ownKey.js';
|
|
8
|
+
import { contextUsageReadingOf, humanInputAttachmentsOf, guardedRead, markMcpSectionDroppedNamedRows, ownSnapshotTyped, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameTrueMark, readOwnDataNonEmptyString } from '../../ownKey.js';
|
|
9
9
|
import { SEGMENT_END_IDENTITY_KEYS, eventSeq, stripToolUseSideChannels } from '../types.js';
|
|
10
10
|
import { frozenSet } from '../../frozenSet.js';
|
|
11
11
|
import { isCoreWorkflowRunTerminal } from '../../terminalStatuses.js';
|
|
@@ -21,6 +21,7 @@ export const INTERNAL_SDK_ARM_TYPES = frozenSet([
|
|
|
21
21
|
'tool_roster_delta',
|
|
22
22
|
'context_usage',
|
|
23
23
|
'compaction_outcome',
|
|
24
|
+
'compaction_started',
|
|
24
25
|
'prompt_assembled',
|
|
25
26
|
'workflow_complete',
|
|
26
27
|
'tool_end_result',
|
|
@@ -69,15 +70,33 @@ function streamEventArm(ctx, event) {
|
|
|
69
70
|
const projected = (message) => ({ kind: 'message', message });
|
|
70
71
|
const nothing = (why) => ({ kind: 'none', why });
|
|
71
72
|
const dropped = (why, type) => ({ kind: 'dropped', why, type });
|
|
73
|
+
function isCompactionStartedFrame(ev) {
|
|
74
|
+
return ev.type === 'compaction_started';
|
|
75
|
+
}
|
|
72
76
|
function assertNeverArm(_ev) {
|
|
73
77
|
}
|
|
74
78
|
export function eventToSdkMessage(ev, ctx) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
const entry = sampleNotificationEntry(ev);
|
|
80
|
+
if (entry.dropped !== undefined)
|
|
81
|
+
return entry.dropped;
|
|
82
|
+
return withEngineIdentity(projectEvent(entry.frame, ctx), ev, ctx, entry.frame);
|
|
83
|
+
}
|
|
84
|
+
function sampleNotificationEntry(ev) {
|
|
85
|
+
const word = guardedRead(() => readOwnDataNonEmptyString(ev, 'type'));
|
|
86
|
+
if (word !== 'task_notification' && word !== 'workflow_complete')
|
|
87
|
+
return { frame: ev };
|
|
88
|
+
const sampled = ownSnapshotTyped(ev);
|
|
89
|
+
if (sampled === undefined)
|
|
90
|
+
return { dropped: dropped('malformed', word) };
|
|
91
|
+
return { frame: sampled };
|
|
92
|
+
}
|
|
93
|
+
function noticeSnapshotOf(ev) {
|
|
94
|
+
return ownSnapshotTyped(ev);
|
|
95
|
+
}
|
|
96
|
+
function withEngineIdentity(p, ev, ctx, identityFrame = ev) {
|
|
78
97
|
if (p.kind !== 'message')
|
|
79
98
|
return p;
|
|
80
|
-
const eventId = wireEventIdOf(
|
|
99
|
+
const eventId = wireEventIdOf(identityFrame);
|
|
81
100
|
if (eventId === undefined)
|
|
82
101
|
return p;
|
|
83
102
|
const env = p.message;
|
|
@@ -85,6 +104,8 @@ function withEngineIdentity(p, ev, ctx) {
|
|
|
85
104
|
return projected(Object.assign({}, env, { uuid: envelopeUuidOf(eventId, env.type), _sema_engine_ref: ref }));
|
|
86
105
|
}
|
|
87
106
|
function projectEvent(ev, ctx) {
|
|
107
|
+
if (isCompactionStartedFrame(ev))
|
|
108
|
+
return compactionStartedProjection(ev, ctx);
|
|
88
109
|
switch (ev.type) {
|
|
89
110
|
case 'task_started':
|
|
90
111
|
return taskStartedProjection(ev, ctx);
|
|
@@ -122,17 +143,20 @@ function projectEvent(ev, ctx) {
|
|
|
122
143
|
})));
|
|
123
144
|
}
|
|
124
145
|
case 'workflow_complete': {
|
|
125
|
-
|
|
146
|
+
const wf = noticeSnapshotOf(ev);
|
|
147
|
+
if (wf === undefined)
|
|
148
|
+
return dropped('malformed', 'workflow_complete');
|
|
149
|
+
if (typeof wf.runId !== 'string' || wf.runId.length === 0) {
|
|
126
150
|
return dropped('malformed', 'workflow_complete');
|
|
127
151
|
}
|
|
128
|
-
if (!isCoreWorkflowRunTerminal(
|
|
152
|
+
if (!isCoreWorkflowRunTerminal(wf.status)) {
|
|
129
153
|
return dropped('malformed', 'workflow_complete');
|
|
130
154
|
}
|
|
131
155
|
return projected(stamp(ctx, armBody({
|
|
132
156
|
type: 'workflow_complete',
|
|
133
|
-
runId:
|
|
134
|
-
status:
|
|
135
|
-
summary: typeof
|
|
157
|
+
runId: wf.runId,
|
|
158
|
+
status: wf.status,
|
|
159
|
+
summary: typeof wf.summary === 'string' ? wf.summary : '',
|
|
136
160
|
})));
|
|
137
161
|
}
|
|
138
162
|
case 'text':
|
|
@@ -164,6 +188,10 @@ function projectEvent(ev, ctx) {
|
|
|
164
188
|
}
|
|
165
189
|
case 'compacted': {
|
|
166
190
|
const raw = ev;
|
|
191
|
+
const pass = typeof raw.pass === 'string' && raw.pass.length > 0 ? raw.pass : undefined;
|
|
192
|
+
const tokenOf = (v) => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : undefined);
|
|
193
|
+
const tokensBefore = tokenOf(raw.triggerTokensBefore);
|
|
194
|
+
const tokensAfter = tokenOf(raw.tokensAfter);
|
|
167
195
|
const freedTokens = typeof raw.freedTokens === 'number' && Number.isFinite(raw.freedTokens) && raw.freedTokens >= 0 ? raw.freedTokens : undefined;
|
|
168
196
|
const attachedFiles = raw.attachedFiles;
|
|
169
197
|
const seg = raw.preserved_segment;
|
|
@@ -184,6 +212,10 @@ function projectEvent(ev, ctx) {
|
|
|
184
212
|
? { _sema_clamped_ratio: clampedRatio }
|
|
185
213
|
: {}),
|
|
186
214
|
...(freedTokens !== undefined ? { _sema_freed_tokens: freedTokens } : {}),
|
|
215
|
+
...(pass !== undefined ? { _sema_pass: pass } : {}),
|
|
216
|
+
...(tokensBefore !== undefined || tokensAfter !== undefined
|
|
217
|
+
? { _sema_compaction_tokens: { ...(tokensBefore !== undefined ? { before: tokensBefore } : {}), ...(tokensAfter !== undefined ? { after: tokensAfter } : {}) } }
|
|
218
|
+
: {}),
|
|
187
219
|
},
|
|
188
220
|
...(Array.isArray(attachedFiles) && attachedFiles.length > 0 ? { _sema_attached_files: attachedFiles } : {}),
|
|
189
221
|
})));
|
|
@@ -265,6 +297,7 @@ function projectEvent(ev, ctx) {
|
|
|
265
297
|
const workflowAgentLabel = ev.workflowAgentLabel;
|
|
266
298
|
const model = ev.model;
|
|
267
299
|
const status = ev.status;
|
|
300
|
+
const seq = typeof ev.seq === 'number' && Number.isFinite(ev.seq) ? ev.seq : undefined;
|
|
268
301
|
return projected(stamp(ctx, armBody({
|
|
269
302
|
type: 'task_progress',
|
|
270
303
|
taskId: ev.taskId,
|
|
@@ -284,6 +317,7 @@ function projectEvent(ev, ctx) {
|
|
|
284
317
|
...(ev.parentToolCallId !== undefined
|
|
285
318
|
? { parentToolCallId: ev.parentToolCallId }
|
|
286
319
|
: {}),
|
|
320
|
+
...(seq !== undefined ? { seq } : {}),
|
|
287
321
|
})));
|
|
288
322
|
}
|
|
289
323
|
case 'wiring_manifest': {
|
|
@@ -297,8 +331,11 @@ function projectEvent(ev, ctx) {
|
|
|
297
331
|
return projected(stamp(ctx, armBody({ type: 'wiring_manifest', ...body, ...identity })));
|
|
298
332
|
}
|
|
299
333
|
case 'task_notification': {
|
|
300
|
-
const
|
|
301
|
-
|
|
334
|
+
const notice = noticeSnapshotOf(ev);
|
|
335
|
+
if (notice === undefined)
|
|
336
|
+
return dropped('malformed', 'task_notification');
|
|
337
|
+
const nested = notice.notification;
|
|
338
|
+
const n = (nested ?? notice);
|
|
302
339
|
if (typeof n.task_id !== 'string')
|
|
303
340
|
return dropped('malformed', 'task_notification');
|
|
304
341
|
return projected(stamp(ctx, armBody({
|
|
@@ -582,7 +619,8 @@ function wiringManifestSupersetBody(ev) {
|
|
|
582
619
|
const fileHistory = projectFileHistorySection(ev);
|
|
583
620
|
const instructions = readInstructionsSegment(ev, 'instructions');
|
|
584
621
|
const fleet = readFleetSegment(ev, 'fleet');
|
|
585
|
-
|
|
622
|
+
const mods = projectModsSection(ev);
|
|
623
|
+
if (modelGate === undefined && autoMode === undefined && mcp === undefined && tools === undefined && hooks === undefined && lsp === undefined && writeProtection === undefined && autoConsolidation === undefined && readDeny === undefined && hands === undefined && fileHistory === undefined && instructions === undefined && fleet === undefined && mods === undefined)
|
|
586
624
|
return undefined;
|
|
587
625
|
return {
|
|
588
626
|
...(modelGate !== undefined ? { _sema_modelGate: modelGate } : {}),
|
|
@@ -598,6 +636,7 @@ function wiringManifestSupersetBody(ev) {
|
|
|
598
636
|
...(fileHistory !== undefined ? { _sema_fileHistory: fileHistory } : {}),
|
|
599
637
|
...(instructions !== undefined ? { _sema_instructions: instructions } : {}),
|
|
600
638
|
...(fleet !== undefined ? { _sema_fleet: fleet } : {}),
|
|
639
|
+
...(mods !== undefined ? { _sema_mods: mods } : {}),
|
|
601
640
|
};
|
|
602
641
|
}
|
|
603
642
|
function projectFileHistorySection(holder) {
|
|
@@ -636,6 +675,83 @@ function projectReadDenySection(raw) {
|
|
|
636
675
|
return undefined;
|
|
637
676
|
return { builtinTiers: [...tiers] };
|
|
638
677
|
}
|
|
678
|
+
const _modViewPins = [true, true, true, true, true, true];
|
|
679
|
+
void _modViewPins;
|
|
680
|
+
function projectModsSection(holder) {
|
|
681
|
+
try {
|
|
682
|
+
if (!Object.hasOwn(holder, 'mods'))
|
|
683
|
+
return undefined;
|
|
684
|
+
const raw = holder.mods;
|
|
685
|
+
if (!Array.isArray(raw))
|
|
686
|
+
return undefined;
|
|
687
|
+
const rows = [];
|
|
688
|
+
for (const r of raw) {
|
|
689
|
+
const row = modRowOf(r);
|
|
690
|
+
if (row !== undefined)
|
|
691
|
+
rows.push(row);
|
|
692
|
+
}
|
|
693
|
+
if (raw.length > 0 && rows.length === 0)
|
|
694
|
+
return undefined;
|
|
695
|
+
return rows;
|
|
696
|
+
}
|
|
697
|
+
catch {
|
|
698
|
+
return undefined;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function modRowOf(r) {
|
|
702
|
+
try {
|
|
703
|
+
if (typeof r !== 'object' || r === null || Array.isArray(r))
|
|
704
|
+
return undefined;
|
|
705
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
706
|
+
const strList = (v) => (Array.isArray(v) && v.every((x) => typeof x === 'string') ? [...v] : undefined);
|
|
707
|
+
const o = r;
|
|
708
|
+
const name = str(o.name);
|
|
709
|
+
const seat = str(o.seat);
|
|
710
|
+
const tier = str(o.tier);
|
|
711
|
+
if (name === undefined || seat === undefined || tier === undefined)
|
|
712
|
+
return undefined;
|
|
713
|
+
const eventsRaw = o.events;
|
|
714
|
+
const observeRaw = o.observe;
|
|
715
|
+
const skippedRaw = o.skipped;
|
|
716
|
+
const refusedByRaw = o.refusedBy;
|
|
717
|
+
const reasonRaw = o.reason;
|
|
718
|
+
const hasMountedKey = eventsRaw !== undefined || observeRaw !== undefined || skippedRaw !== undefined;
|
|
719
|
+
const hasRefusedKey = refusedByRaw !== undefined || reasonRaw !== undefined;
|
|
720
|
+
if (hasMountedKey && hasRefusedKey)
|
|
721
|
+
return undefined;
|
|
722
|
+
if (hasRefusedKey) {
|
|
723
|
+
const refusedBy = str(refusedByRaw);
|
|
724
|
+
const reason = str(reasonRaw);
|
|
725
|
+
return refusedBy === undefined || reason === undefined ? undefined : { name, seat, tier, refusedBy, reason };
|
|
726
|
+
}
|
|
727
|
+
const events = strList(eventsRaw);
|
|
728
|
+
if (events === undefined)
|
|
729
|
+
return undefined;
|
|
730
|
+
const observe = observeRaw === undefined ? undefined : strList(observeRaw);
|
|
731
|
+
const skipped = Array.isArray(skippedRaw)
|
|
732
|
+
? skippedRaw.flatMap((x) => {
|
|
733
|
+
if (typeof x !== 'object' || x === null || Array.isArray(x))
|
|
734
|
+
return [];
|
|
735
|
+
const k = x;
|
|
736
|
+
const registration = str(k.registration);
|
|
737
|
+
const cause = str(k.cause);
|
|
738
|
+
const why = str(k.reason);
|
|
739
|
+
return registration === undefined || cause === undefined || why === undefined ? [] : [{ registration, cause, reason: why }];
|
|
740
|
+
})
|
|
741
|
+
: undefined;
|
|
742
|
+
return {
|
|
743
|
+
name,
|
|
744
|
+
seat,
|
|
745
|
+
tier,
|
|
746
|
+
events,
|
|
747
|
+
...(observe !== undefined ? { observe } : {}),
|
|
748
|
+
...(skipped !== undefined && skipped.length > 0 ? { skipped } : {}),
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
catch {
|
|
752
|
+
return undefined;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
639
755
|
function projectHooksSection(raw) {
|
|
640
756
|
if (!Array.isArray(raw))
|
|
641
757
|
return undefined;
|
|
@@ -725,14 +841,37 @@ function compactionOutcomeProjection(frame, ctx) {
|
|
|
725
841
|
return dropped('malformed', 'compaction_outcome');
|
|
726
842
|
const trigger = str(ev.trigger);
|
|
727
843
|
const reason = str(ev.reason);
|
|
844
|
+
const pass = str(ev.pass);
|
|
728
845
|
return projected(internalArmExit(stamp(ctx, armBody({
|
|
729
846
|
type: 'compaction_outcome',
|
|
730
847
|
outcome,
|
|
731
848
|
...(trigger !== undefined ? { trigger } : {}),
|
|
732
849
|
...(reason !== undefined ? { reason } : {}),
|
|
850
|
+
...(pass !== undefined ? { pass } : {}),
|
|
733
851
|
...identity,
|
|
734
852
|
}))));
|
|
735
853
|
}
|
|
854
|
+
function compactionStartedProjection(frame, ctx) {
|
|
855
|
+
const ev = frame;
|
|
856
|
+
const { identity, bad } = identityOrMalformed(ev, 'compaction_started');
|
|
857
|
+
if (bad !== null)
|
|
858
|
+
return bad;
|
|
859
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
860
|
+
const pass = str(ev.pass);
|
|
861
|
+
const trigger = str(ev.trigger);
|
|
862
|
+
if (pass === undefined || trigger === undefined)
|
|
863
|
+
return dropped('malformed', 'compaction_started');
|
|
864
|
+
const startedAt = typeof ev.startedAt === 'number' && Number.isFinite(ev.startedAt) ? ev.startedAt : undefined;
|
|
865
|
+
return projected(internalArmExit(stamp(ctx, armBody({
|
|
866
|
+
type: 'compaction_started',
|
|
867
|
+
trigger,
|
|
868
|
+
pass,
|
|
869
|
+
...(startedAt !== undefined ? { startedAt } : {}),
|
|
870
|
+
...identity,
|
|
871
|
+
}))));
|
|
872
|
+
}
|
|
873
|
+
const _promptManifestPins = [true, true, true, true, true];
|
|
874
|
+
void _promptManifestPins;
|
|
736
875
|
function promptAssembledProjection(frame, ctx) {
|
|
737
876
|
const ev = frame;
|
|
738
877
|
const { identity, bad } = identityOrMalformed(ev, 'prompt_assembled');
|
|
@@ -748,16 +887,13 @@ function promptAssembledProjection(frame, ctx) {
|
|
|
748
887
|
for (const r of ev.sections) {
|
|
749
888
|
if (typeof r !== 'object' || r === null || Array.isArray(r))
|
|
750
889
|
continue;
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
if (id === undefined || chars === undefined)
|
|
755
|
-
continue;
|
|
756
|
-
const slot = str(o.slot);
|
|
757
|
-
rows.push({ id, chars, ...(slot !== undefined ? { slot } : {}) });
|
|
890
|
+
const row = promptManifestSectionViewOf(r);
|
|
891
|
+
if (row !== undefined)
|
|
892
|
+
rows.push(row);
|
|
758
893
|
}
|
|
759
894
|
return rows.length > 0 ? rows : undefined;
|
|
760
895
|
})();
|
|
896
|
+
const promptIdentity = promptManifestIdentityOfFrame(ev);
|
|
761
897
|
const blocks = (() => {
|
|
762
898
|
if (!Array.isArray(ev.blocks))
|
|
763
899
|
return undefined;
|
|
@@ -797,6 +933,7 @@ function promptAssembledProjection(frame, ctx) {
|
|
|
797
933
|
...(blocks !== undefined ? { blocks } : {}),
|
|
798
934
|
...(sections !== undefined ? { sections } : {}),
|
|
799
935
|
...(tools !== undefined ? { tools } : {}),
|
|
936
|
+
...(promptIdentity !== undefined ? { identity: promptIdentity } : {}),
|
|
800
937
|
...identity,
|
|
801
938
|
}))));
|
|
802
939
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { AgentEvent, TaskStats } from '@sema-agent/sdk';
|
|
2
2
|
import { type CcToolDenialKind, type GateDeniedByWord } from '../../gateVocabulary.js';
|
|
3
3
|
import { type SDKMessage, type EmitContext } from '../types.js';
|
|
4
|
-
import type { TerminalReason } from '@sema-agent/agent-types';
|
|
4
|
+
import type { SDKPermissionDenial, SDKResultError, SDKResultSuccess, TerminalReason } from '@sema-agent/agent-types';
|
|
5
|
+
import { type RunTerminalCodedDetail, type RunTerminalRead } from '../../runTerminal.js';
|
|
5
6
|
import { type SemaModelUsage } from './turnUsageToModelUsage.js';
|
|
7
|
+
import { type ResultLimitWord } from '../../engineErrorCodes.js';
|
|
8
|
+
import { type ResultWayOutFacts } from '../../providerRejection.js';
|
|
6
9
|
export interface SemaFlatUsage {
|
|
7
10
|
readonly inputTokens: number;
|
|
8
11
|
readonly outputTokens: number;
|
|
@@ -23,6 +26,9 @@ export interface TerminalStreamObserved {
|
|
|
23
26
|
readonly streamSawRunOpen?: boolean;
|
|
24
27
|
readonly deniedToolNameByCallId?: ReadonlyMap<string, string | undefined>;
|
|
25
28
|
readonly deniedCallsOverflowed?: boolean;
|
|
29
|
+
readonly wayOutFacts?: ResultWayOutFacts | undefined;
|
|
30
|
+
readonly codedDetail?: RunTerminalCodedDetail | undefined;
|
|
31
|
+
readonly lastRow?: PrintResultLastRow | null;
|
|
26
32
|
}
|
|
27
33
|
export declare const TOOL_INPUT_JOIN_MAX_CALLS = 4096;
|
|
28
34
|
export interface SemaPermissionDenial {
|
|
@@ -36,6 +42,22 @@ export interface SemaPermissionDenial {
|
|
|
36
42
|
readonly _sema_denied_by_source?: 'tool_end';
|
|
37
43
|
readonly toolDenialKind?: CcToolDenialKind;
|
|
38
44
|
}
|
|
45
|
+
export interface CcPermissionDenial {
|
|
46
|
+
readonly tool_name: string;
|
|
47
|
+
readonly tool_use_id: string;
|
|
48
|
+
readonly tool_input: SDKPermissionDenial['tool_input'];
|
|
49
|
+
readonly _sema_tool_arg?: string;
|
|
50
|
+
readonly _sema_tool_input_redacted?: true;
|
|
51
|
+
readonly deniedBy?: GateDeniedByWord;
|
|
52
|
+
readonly _sema_denied_by_source?: 'tool_end';
|
|
53
|
+
readonly toolDenialKind?: CcToolDenialKind;
|
|
54
|
+
}
|
|
55
|
+
export interface PermissionDenialParts {
|
|
56
|
+
readonly permission_denials: readonly CcPermissionDenial[];
|
|
57
|
+
readonly _sema_permission_denials?: readonly SemaPermissionDenial[];
|
|
58
|
+
readonly _sema_permission_denials_absent?: true;
|
|
59
|
+
readonly _sema_zero_output_denied?: true;
|
|
60
|
+
}
|
|
39
61
|
export interface SemaCostBreakdown {
|
|
40
62
|
readonly llmRootMicroUsd?: number;
|
|
41
63
|
readonly nestedSubagentMicroUsd?: number;
|
|
@@ -68,6 +90,10 @@ export interface RunCostFacts {
|
|
|
68
90
|
export declare function readRunCostFacts(stats: TaskStats | undefined, observed?: {
|
|
69
91
|
readonly usageMissingObserved?: boolean;
|
|
70
92
|
}): RunCostFacts | undefined;
|
|
93
|
+
export interface ObservedTerminalParts extends PermissionDenialParts {
|
|
94
|
+
readonly _sema_usage_lower_bound?: true;
|
|
95
|
+
}
|
|
96
|
+
export declare function terminalPartsOfObserved(observed: TerminalStreamObserved | undefined): ObservedTerminalParts;
|
|
71
97
|
export interface SemaSubagentUsageRow {
|
|
72
98
|
readonly turns: number;
|
|
73
99
|
readonly inputTokens: number;
|
|
@@ -98,6 +124,39 @@ export interface SemaTerminalModelUsage extends SemaModelUsage {
|
|
|
98
124
|
readonly _sema_cache_write_tokens_long?: number;
|
|
99
125
|
}
|
|
100
126
|
export declare function terminalReasonForResult(msg: SDKMessage): TerminalReason | undefined;
|
|
127
|
+
export type { ResultLimitWord };
|
|
128
|
+
export declare function resultLimitOf(frame: object | null | undefined): ResultLimitWord | undefined;
|
|
129
|
+
export interface PrintResultLastRowBlock {
|
|
130
|
+
readonly type?: string;
|
|
131
|
+
readonly text?: string;
|
|
132
|
+
}
|
|
133
|
+
export interface PrintResultLastRowMessage {
|
|
134
|
+
readonly content?: string | readonly PrintResultLastRowBlock[];
|
|
135
|
+
readonly stop_reason?: string | null;
|
|
136
|
+
}
|
|
137
|
+
export interface PrintResultLastRow {
|
|
138
|
+
readonly type?: string;
|
|
139
|
+
readonly _sema_api_error_message?: boolean;
|
|
140
|
+
readonly message?: PrintResultLastRowMessage;
|
|
141
|
+
readonly salvagedText?: string;
|
|
142
|
+
}
|
|
143
|
+
export interface PrintResultArmInput {
|
|
144
|
+
readonly terminal: RunTerminalRead | null;
|
|
145
|
+
readonly lastRow?: PrintResultLastRow | null;
|
|
146
|
+
}
|
|
147
|
+
export interface PrintResultSuccessArm {
|
|
148
|
+
readonly subtype: SDKResultSuccess['subtype'];
|
|
149
|
+
readonly is_error: boolean;
|
|
150
|
+
readonly stop_reason: SDKResultSuccess['stop_reason'];
|
|
151
|
+
}
|
|
152
|
+
export interface PrintResultErrorArm {
|
|
153
|
+
readonly subtype: SDKResultError['subtype'];
|
|
154
|
+
readonly is_error: true;
|
|
155
|
+
readonly stop_reason: SDKResultError['stop_reason'];
|
|
156
|
+
readonly limit?: ResultLimitWord;
|
|
157
|
+
}
|
|
158
|
+
export type PrintResultArm = PrintResultSuccessArm | PrintResultErrorArm;
|
|
159
|
+
export declare function printResultArmOf(input: PrintResultArmInput | null | undefined): PrintResultArm;
|
|
101
160
|
export declare function doneToSdkResult(ev: Extract<AgentEvent, {
|
|
102
161
|
type: 'done';
|
|
103
162
|
}>, ctx: EmitContext, observed?: TerminalStreamObserved): SDKMessage;
|