@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
|
@@ -229,8 +229,40 @@ function dropTask(key) {
|
|
|
229
229
|
totalBytes -= s.bytes;
|
|
230
230
|
tasks.delete(key);
|
|
231
231
|
}
|
|
232
|
+
let subagentIdsReader;
|
|
233
|
+
export function bindSubagentIdentityReader(fn) {
|
|
234
|
+
subagentIdsReader = fn;
|
|
235
|
+
}
|
|
236
|
+
function sameSubagentIds(id) {
|
|
237
|
+
let ids;
|
|
238
|
+
try {
|
|
239
|
+
ids = subagentIdsReader?.(id);
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
ids = undefined;
|
|
243
|
+
}
|
|
244
|
+
if (ids === undefined)
|
|
245
|
+
return [id];
|
|
246
|
+
return ids.includes(id) ? ids : [...ids, id];
|
|
247
|
+
}
|
|
248
|
+
function homeKeyOf(key) {
|
|
249
|
+
return sameSubagentIds(key).find((id) => tasks.has(id)) ?? key;
|
|
250
|
+
}
|
|
251
|
+
function contentKeyOf(taskId) {
|
|
252
|
+
const ids = sameSubagentIds(taskId);
|
|
253
|
+
const direct = ids.find((id) => tasks.has(id));
|
|
254
|
+
if (direct !== undefined)
|
|
255
|
+
return direct;
|
|
256
|
+
for (const id of ids) {
|
|
257
|
+
const parked = taskToParent.get(id)?.card;
|
|
258
|
+
if (parked !== undefined && tasks.has(parked))
|
|
259
|
+
return parked;
|
|
260
|
+
}
|
|
261
|
+
return '';
|
|
262
|
+
}
|
|
232
263
|
const parentToTask = new Map();
|
|
233
264
|
const taskToParent = new Map();
|
|
265
|
+
let parentStampSeq = 0;
|
|
234
266
|
let notifyListener = null;
|
|
235
267
|
const pendingNotify = new Set();
|
|
236
268
|
let notifyTimer = null;
|
|
@@ -383,7 +415,8 @@ function aliasContentKey(parentToolCallId, taskId) {
|
|
|
383
415
|
export function registerSubagentAlias(parentToolCallId, taskId) {
|
|
384
416
|
if (!aliasContentKey(parentToolCallId, taskId))
|
|
385
417
|
return;
|
|
386
|
-
taskToParent.
|
|
418
|
+
if (taskToParent.get(taskId)?.card !== parentToolCallId)
|
|
419
|
+
taskToParent.set(taskId, { card: parentToolCallId, stamp: ++parentStampSeq });
|
|
387
420
|
}
|
|
388
421
|
function replaySeen(s, ev) {
|
|
389
422
|
const id = ev.eventId;
|
|
@@ -459,7 +492,7 @@ function canonicalKey(ev) {
|
|
|
459
492
|
return parentToTask.get(ev.parentToolCallId) ?? ev.parentToolCallId;
|
|
460
493
|
}
|
|
461
494
|
export function publishSubagentContentEvent(ev) {
|
|
462
|
-
const key = canonicalKey(ev);
|
|
495
|
+
const key = homeKeyOf(canonicalKey(ev));
|
|
463
496
|
const s = stateFor(key, ev.parentToolCallId);
|
|
464
497
|
switch (ev.type) {
|
|
465
498
|
case 'text_delta':
|
|
@@ -561,15 +594,17 @@ export function publishSubagentContentEvent(ev) {
|
|
|
561
594
|
scheduleNotify(key);
|
|
562
595
|
}
|
|
563
596
|
export function pushSubagentLocalEcho(taskId, text) {
|
|
564
|
-
const
|
|
597
|
+
const known = contentKeyOf(taskId);
|
|
598
|
+
const key = known !== '' ? known : taskId;
|
|
599
|
+
const s = stateFor(key, tasks.get(key)?.parentToolCallId ?? '');
|
|
565
600
|
flushBuffers(s);
|
|
566
601
|
pushItem(s, { kind: 'echo', text });
|
|
567
602
|
enforceTaskCap(s);
|
|
568
|
-
enforceTotalCap(
|
|
569
|
-
scheduleNotify(
|
|
603
|
+
enforceTotalCap(key);
|
|
604
|
+
scheduleNotify(key);
|
|
570
605
|
}
|
|
571
606
|
export function getSubagentContentSnapshot(taskId) {
|
|
572
|
-
const key =
|
|
607
|
+
const key = contentKeyOf(taskId);
|
|
573
608
|
const s = tasks.get(key);
|
|
574
609
|
if (!s)
|
|
575
610
|
return null;
|
|
@@ -615,17 +650,42 @@ export function planSubagentViewSlots(taskId) {
|
|
|
615
650
|
return out;
|
|
616
651
|
}
|
|
617
652
|
export function parentToolCallIdOf(taskId) {
|
|
618
|
-
|
|
653
|
+
const ids = sameSubagentIds(taskId);
|
|
654
|
+
let stated;
|
|
655
|
+
let statedStamp = -1;
|
|
656
|
+
for (const id of ids) {
|
|
657
|
+
const hit = taskToParent.get(id);
|
|
658
|
+
if (hit === undefined)
|
|
659
|
+
continue;
|
|
660
|
+
if (stated === undefined || hit.stamp > statedStamp) {
|
|
661
|
+
stated = hit.card;
|
|
662
|
+
statedStamp = hit.stamp;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
if (stated !== undefined)
|
|
666
|
+
return stated;
|
|
667
|
+
for (const id of ids) {
|
|
668
|
+
const fromContent = tasks.get(id)?.parentToolCallId;
|
|
669
|
+
if (fromContent !== undefined)
|
|
670
|
+
return fromContent;
|
|
671
|
+
}
|
|
672
|
+
return undefined;
|
|
619
673
|
}
|
|
620
674
|
export function settleSubagentContent(taskId) {
|
|
621
|
-
const
|
|
675
|
+
const key = contentKeyOf(taskId);
|
|
676
|
+
const s = tasks.get(key);
|
|
622
677
|
if (!s)
|
|
623
678
|
return;
|
|
624
679
|
flushBuffers(s);
|
|
625
|
-
scheduleNotify(
|
|
680
|
+
scheduleNotify(key);
|
|
626
681
|
}
|
|
627
682
|
export function clearSubagentContent(taskId) {
|
|
628
|
-
|
|
683
|
+
for (;;) {
|
|
684
|
+
const key = contentKeyOf(taskId);
|
|
685
|
+
if (key === '')
|
|
686
|
+
return;
|
|
687
|
+
dropTask(key);
|
|
688
|
+
}
|
|
629
689
|
}
|
|
630
690
|
const bgFacts = new Map();
|
|
631
691
|
export function recordBgTerminalFacts(taskId, facts) {
|
|
@@ -641,10 +701,12 @@ export function recordBgTerminalFacts(taskId, facts) {
|
|
|
641
701
|
scheduleNotify(taskId);
|
|
642
702
|
}
|
|
643
703
|
export function clearBgTerminalFacts(taskId) {
|
|
644
|
-
|
|
704
|
+
for (const id of sameSubagentIds(taskId))
|
|
705
|
+
bgFacts.delete(id);
|
|
645
706
|
}
|
|
646
707
|
export function getBgTerminalFacts(taskId) {
|
|
647
|
-
const
|
|
708
|
+
const ids = sameSubagentIds(taskId);
|
|
709
|
+
const key = ids.find((id) => bgFacts.has(id)) ?? ids.map((id) => taskToParent.get(id)?.card).find((c) => c !== undefined) ?? '';
|
|
648
710
|
touchLru(bgFacts, key);
|
|
649
711
|
return bgFacts.get(key);
|
|
650
712
|
}
|
|
@@ -665,15 +727,35 @@ export function recordBgParentRun(taskId, runId, sessionId, sessionKey) {
|
|
|
665
727
|
export function recordSubagentOwner(taskId, runId, sessionId, sessionKey) {
|
|
666
728
|
if (!taskId || typeof runId !== 'string' || runId === '' || taskId === runId)
|
|
667
729
|
return;
|
|
668
|
-
|
|
730
|
+
const ids = sameSubagentIds(taskId);
|
|
731
|
+
const heldKeys = ids.filter((k) => bgParentRun.has(k));
|
|
732
|
+
const heldRecs = [];
|
|
733
|
+
for (const k of heldKeys) {
|
|
734
|
+
const rec = bgParentRun.get(k);
|
|
735
|
+
if (rec !== undefined)
|
|
736
|
+
heldRecs.push(rec);
|
|
737
|
+
}
|
|
738
|
+
if (bgParentRun.size >= MAX_BG_PARENT_RUNS && heldKeys.length === 0) {
|
|
669
739
|
const oldest = bgParentRun.keys().next().value;
|
|
670
740
|
if (oldest !== undefined)
|
|
671
741
|
bgParentRun.delete(oldest);
|
|
672
742
|
}
|
|
673
|
-
const
|
|
674
|
-
if (
|
|
743
|
+
const quarantinedHere = ids.some((k) => conflictQuarantine.get(k) === runId);
|
|
744
|
+
if (quarantinedHere)
|
|
745
|
+
return;
|
|
746
|
+
const sameRunHeld = heldRecs.filter((r) => r.runId === runId);
|
|
747
|
+
const heldSlots = new Set(sameRunHeld.map((r) => r.sessionKey ?? DEFAULT_SESSION_KEY));
|
|
748
|
+
if (sameRunHeld.length > 1 && heldSlots.size > 1) {
|
|
749
|
+
ownerSessionConflictCount++;
|
|
750
|
+
const pairOf = (r) => ({
|
|
751
|
+
...(r.sessionId !== undefined ? { sessionId: r.sessionId } : {}),
|
|
752
|
+
...(r.sessionKey !== undefined ? { sessionKey: r.sessionKey } : {}),
|
|
753
|
+
});
|
|
754
|
+
lastOwnerSessionConflict = { taskId, runId, prior: pairOf(sameRunHeld[0]), next: pairOf(sameRunHeld[1]) };
|
|
755
|
+
quarantineRun(ids, runId);
|
|
675
756
|
return;
|
|
676
|
-
|
|
757
|
+
}
|
|
758
|
+
const prior = heldRecs.find((r) => r.runId === runId) ?? heldRecs[0];
|
|
677
759
|
const sameRun = prior?.runId === runId;
|
|
678
760
|
const incoming = typeof sessionId === 'string' && sessionId !== '' ? sessionId : undefined;
|
|
679
761
|
const incomingKey = typeof sessionKey === 'string' && sessionKey !== '' ? sessionKey : undefined;
|
|
@@ -707,16 +789,13 @@ export function recordSubagentOwner(taskId, runId, sessionId, sessionKey) {
|
|
|
707
789
|
const priorSlot = prior?.sessionKey ?? DEFAULT_SESSION_KEY;
|
|
708
790
|
const nextSlot = nextPair.sessionKey ?? DEFAULT_SESSION_KEY;
|
|
709
791
|
if (priorSlot !== nextSlot) {
|
|
710
|
-
|
|
711
|
-
if (conflictQuarantine.size >= MAX_BG_PARENT_RUNS && !conflictQuarantine.has(taskId)) {
|
|
712
|
-
const oldestQ = conflictQuarantine.keys().next().value;
|
|
713
|
-
if (oldestQ !== undefined)
|
|
714
|
-
conflictQuarantine.delete(oldestQ);
|
|
715
|
-
}
|
|
716
|
-
conflictQuarantine.set(taskId, runId);
|
|
792
|
+
quarantineRun(ids, runId);
|
|
717
793
|
return;
|
|
718
794
|
}
|
|
719
795
|
}
|
|
796
|
+
for (const k of ids)
|
|
797
|
+
if (k !== taskId)
|
|
798
|
+
bgParentRun.delete(k);
|
|
720
799
|
bgParentRun.delete(taskId);
|
|
721
800
|
bgParentRun.set(taskId, { runId, ...nextPair });
|
|
722
801
|
}
|
|
@@ -733,14 +812,43 @@ export function recordSubagentOwnerFromProgress(ev, ownerRunId, ownerSessionId,
|
|
|
733
812
|
recordSubagentOwner(o.taskId, ownerRunId, ownerSessionId, ownerSessionKey);
|
|
734
813
|
}
|
|
735
814
|
export function getBgParentRun(taskId) {
|
|
736
|
-
|
|
737
|
-
return bgParentRun.get(taskId)?.runId;
|
|
815
|
+
return getBgParentRunOwner(taskId)?.runId;
|
|
738
816
|
}
|
|
739
817
|
export function getBgParentRunOwner(taskId) {
|
|
740
818
|
if (typeof taskId !== 'string' || taskId === '')
|
|
741
819
|
return undefined;
|
|
742
|
-
|
|
743
|
-
|
|
820
|
+
const live = liveOwnerEntries(sameSubagentIds(taskId));
|
|
821
|
+
const first = live[0];
|
|
822
|
+
if (first === undefined)
|
|
823
|
+
return undefined;
|
|
824
|
+
if (!live.every(([, rec]) => sameOwnerRecord(rec, first[1])))
|
|
825
|
+
return undefined;
|
|
826
|
+
touchLru(bgParentRun, first[0]);
|
|
827
|
+
return first[1];
|
|
828
|
+
}
|
|
829
|
+
function liveOwnerEntries(ids) {
|
|
830
|
+
const out = [];
|
|
831
|
+
for (const k of ids) {
|
|
832
|
+
const rec = bgParentRun.get(k);
|
|
833
|
+
if (rec === undefined)
|
|
834
|
+
continue;
|
|
835
|
+
if (ids.some((q) => conflictQuarantine.get(q) === rec.runId))
|
|
836
|
+
continue;
|
|
837
|
+
out.push([k, rec]);
|
|
838
|
+
}
|
|
839
|
+
return out;
|
|
840
|
+
}
|
|
841
|
+
const sameOwnerRecord = (a, b) => a.runId === b.runId && a.sessionId === b.sessionId && a.sessionKey === b.sessionKey;
|
|
842
|
+
function quarantineRun(ids, runId) {
|
|
843
|
+
for (const k of ids) {
|
|
844
|
+
bgParentRun.delete(k);
|
|
845
|
+
if (conflictQuarantine.size >= MAX_BG_PARENT_RUNS && !conflictQuarantine.has(k)) {
|
|
846
|
+
const oldestQ = conflictQuarantine.keys().next().value;
|
|
847
|
+
if (oldestQ !== undefined)
|
|
848
|
+
conflictQuarantine.delete(oldestQ);
|
|
849
|
+
}
|
|
850
|
+
conflictQuarantine.set(k, runId);
|
|
851
|
+
}
|
|
744
852
|
}
|
|
745
853
|
export function __resetSubagentOwnerLedgerForTests() {
|
|
746
854
|
bgParentRun.clear();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SDKAssistantMessageError } from '@sema-agent/agent-types';
|
|
2
|
+
import type { SemaRowKind } from './rowKind.js';
|
|
3
|
+
export interface SubmitFailureClass {
|
|
4
|
+
readonly kind: Extract<SemaRowKind, 'api_error' | 'model_output_error'>;
|
|
5
|
+
readonly errorCode?: string;
|
|
6
|
+
readonly ccError?: SDKAssistantMessageError;
|
|
7
|
+
}
|
|
8
|
+
export declare function classifySubmitFailure(err: {} | null | undefined): SubmitFailureClass;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isModelOutputErrorText } from './adapter/runStream.js';
|
|
2
|
+
import { ccErrorOfProviderStatus } from './providerRejection.js';
|
|
3
|
+
import { classifyTurnWireError } from './wireErrorTriage.js';
|
|
4
|
+
export function classifySubmitFailure(err) {
|
|
5
|
+
const verdict = classifyTurnWireError(err);
|
|
6
|
+
const status = verdict.kind === 'http' ? verdict.status : undefined;
|
|
7
|
+
const errorCode = verdict.kind === 'http' && verdict.errorCode !== undefined && verdict.errorCode.length > 0 ? verdict.errorCode : undefined;
|
|
8
|
+
const text = verdict.kind === 'http' ? verdict.message : verdict.kind === 'transport' || verdict.kind === 'internal' ? verdict.detail : '';
|
|
9
|
+
const kind = isModelOutputErrorText(text) ? 'model_output_error' : 'api_error';
|
|
10
|
+
const mapped = status === undefined ? undefined : ccErrorOfProviderStatus(status);
|
|
11
|
+
const ccError = mapped === 'model_not_found' && errorCode !== undefined ? undefined : mapped;
|
|
12
|
+
return {
|
|
13
|
+
kind,
|
|
14
|
+
...(errorCode !== undefined ? { errorCode } : {}),
|
|
15
|
+
...(ccError !== undefined ? { ccError } : {}),
|
|
16
|
+
};
|
|
17
|
+
}
|
package/dist/supportFloor.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export type EngineVersionTier = 'engine' | 'legacy' | 'unknown';
|
|
|
10
10
|
export declare function engineVersionTier(version: unknown, floor?: string): EngineVersionTier;
|
|
11
11
|
export declare function engineSupportFloorEffective(floor?: string): string;
|
|
12
12
|
export declare function coreVersionTier(version: unknown, floor?: string): EngineVersionTier;
|
|
13
|
+
export declare function compareReleaseVersions(a: string, b: string): -1 | 0 | 1 | undefined;
|
package/dist/supportFloor.js
CHANGED
|
@@ -51,3 +51,10 @@ export function engineSupportFloorEffective(floor) {
|
|
|
51
51
|
export function coreVersionTier(version, floor) {
|
|
52
52
|
return judgeAgainst(version, SUPPORT_FLOOR.core, floor, 'coreVersionTier').tier;
|
|
53
53
|
}
|
|
54
|
+
export function compareReleaseVersions(a, b) {
|
|
55
|
+
const ta = releaseTriple(a);
|
|
56
|
+
const tb = releaseTriple(b);
|
|
57
|
+
if (ta === undefined || tb === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
return compareTriple(ta, tb);
|
|
60
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
2
|
+
export declare const TERMINATION_INTENT_TTL_MS = 60000;
|
|
3
|
+
export declare const TERMINATION_INTENT_WEAK_SOURCE = "esc-abort";
|
|
4
|
+
export declare const INTERRUPTED_SETTLE_BUDGET_MS = 10000;
|
|
5
|
+
export declare const INTERRUPTED_SETTLE_POLL_MS = 1000;
|
|
6
|
+
export type TerminationIntentSource = string;
|
|
7
|
+
export interface TerminationIntentSnapshot {
|
|
8
|
+
readonly source: TerminationIntentSource;
|
|
9
|
+
readonly at: number;
|
|
10
|
+
readonly abortAt: number | null;
|
|
11
|
+
}
|
|
12
|
+
export interface TerminationIntentLedgerOptions {
|
|
13
|
+
readonly now: () => number;
|
|
14
|
+
readonly ttlMs?: number;
|
|
15
|
+
readonly exemptAbortReasons?: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface TerminationIntentLedger {
|
|
18
|
+
record(taskId: string | null | undefined, source: TerminationIntentSource): number;
|
|
19
|
+
snapshot(taskId: string | null | undefined): TerminationIntentSnapshot | null;
|
|
20
|
+
restoreIf(taskId: string | null | undefined, version: number, snapshot: TerminationIntentSnapshot | null): boolean;
|
|
21
|
+
rollbackIf(taskId: string | null | undefined, version: number, prior: TerminationIntentSource | null): boolean;
|
|
22
|
+
rollback(taskId: string | null | undefined, prior: TerminationIntentSource | null): void;
|
|
23
|
+
wasRecentlyTerminatedByUs(taskId: string | null | undefined): boolean;
|
|
24
|
+
sourceOf(taskId: string | null | undefined): TerminationIntentSource | null;
|
|
25
|
+
armOnAbort(signal: AbortSignal | undefined, taskId: string): void;
|
|
26
|
+
forget(taskId: string | null | undefined): void;
|
|
27
|
+
size(): number;
|
|
28
|
+
}
|
|
29
|
+
export declare function createTerminationIntentLedger(options: TerminationIntentLedgerOptions): TerminationIntentLedger;
|
|
30
|
+
export type InterruptedRunSettleVerdict = {
|
|
31
|
+
readonly kind: 'settled';
|
|
32
|
+
readonly status: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: 'still-running';
|
|
35
|
+
readonly waitedMs: number;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'parked';
|
|
38
|
+
readonly status: string;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: 'unknown';
|
|
41
|
+
};
|
|
42
|
+
export interface InterruptedRunRow {
|
|
43
|
+
readonly status?: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface InterruptedRunSettleDeps {
|
|
46
|
+
readonly getRun?: (taskId: string, opts?: {
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}) => Promise<InterruptedRunRow | null>;
|
|
49
|
+
readonly signal?: AbortSignal;
|
|
50
|
+
readonly budgetMs?: number;
|
|
51
|
+
readonly intervalMs?: number;
|
|
52
|
+
readonly now?: () => number;
|
|
53
|
+
}
|
|
54
|
+
export declare function awaitInterruptedRunSettle(taskId: string, deps: InterruptedRunSettleDeps): Promise<InterruptedRunSettleVerdict>;
|
|
55
|
+
export declare function interruptedRunSettleRow(taskId: string, verdict: InterruptedRunSettleVerdict, lang?: UiLanguage): string | null;
|