@sema-agent/client-core 0.94.0 → 0.96.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 +521 -0
- package/README.md +104 -57
- package/dist/adapt/arms.js +12 -7
- package/dist/adapt/panelTasks.js +4 -10
- package/dist/adapt/toolCards.d.ts +1 -0
- package/dist/adapt/toolCards.js +18 -5
- package/dist/adapt/wireShapes.js +5 -24
- package/dist/adapter/activeRunSelfHeal.d.ts +12 -3
- package/dist/adapter/activeRunSelfHeal.js +50 -16
- package/dist/adapter/downstream/eventToSdkMessage.js +33 -18
- package/dist/adapter/downstream/terminalToSdkResult.js +19 -12
- package/dist/adapter/runStream.js +30 -46
- package/dist/adapter/types.d.ts +7 -0
- package/dist/adapter/types.js +15 -0
- package/dist/agentSession/backgroundView.js +5 -1
- package/dist/agentSession/engineAgentRegistryRead.js +7 -5
- package/dist/agentSession/engineSessionBackgroundStop.js +25 -17
- package/dist/agentsWireCaps.d.ts +2 -0
- package/dist/agentsWireCaps.js +13 -2
- package/dist/approvalDecidedByCapability.d.ts +0 -1
- package/dist/approvalDecidedByCapability.js +2 -7
- package/dist/approvalsStreamLiveCapability.d.ts +0 -1
- package/dist/approvalsStreamLiveCapability.js +2 -6
- package/dist/atMostOnce.d.ts +8 -0
- package/dist/atMostOnce.js +36 -0
- package/dist/attachmentSeatCapability.d.ts +0 -1
- package/dist/attachmentSeatCapability.js +0 -3
- package/dist/attachmentsWireCaps.js +11 -6
- package/dist/bashExitReading.d.ts +10 -0
- package/dist/bashExitReading.js +12 -0
- package/dist/callerCwdCapability.d.ts +0 -5
- package/dist/callerCwdCapability.js +2 -13
- package/dist/centerWiringCapability.d.ts +1 -7
- package/dist/centerWiringCapability.js +18 -27
- package/dist/classifierStatus.js +4 -4
- package/dist/classifierVerdictWire.js +4 -16
- package/dist/clientSlice.js +1 -1
- package/dist/cloudConfigWireCaps.d.ts +3 -3
- package/dist/cloudConfigWireCaps.js +85 -43
- package/dist/compensations.js +1 -1
- package/dist/coreValuePorts.d.ts +11 -7
- package/dist/coreValuePorts.js +5 -8
- package/dist/credentialProvenance.d.ts +28 -0
- package/dist/credentialProvenance.js +76 -0
- package/dist/cycleOrder.d.ts +15 -0
- package/dist/cycleOrder.js +45 -0
- package/dist/decideFailureNote.js +7 -2
- package/dist/decideReceipt.d.ts +2 -1
- package/dist/decideReceipt.js +39 -14
- package/dist/declared/supportFloorDeclared.d.ts +1 -0
- package/dist/declared/supportFloorDeclared.js +5 -0
- package/dist/deviceExecutorManagementCapability.d.ts +0 -1
- package/dist/deviceExecutorManagementCapability.js +7 -16
- package/dist/deviceRebind.d.ts +88 -0
- package/dist/deviceRebind.js +242 -0
- package/dist/displayUntrusted.d.ts +8 -3
- package/dist/displayUntrusted.js +661 -63
- package/dist/engineAgentAbsence.d.ts +2 -2
- package/dist/engineAgentPanelStore.d.ts +8 -18
- package/dist/engineAgentPanelStore.js +19 -537
- package/dist/engineCapReader.d.ts +6 -6
- package/dist/engineCapReader.js +30 -43
- package/dist/engineCapsCache.d.ts +13 -2
- package/dist/engineCapsCache.js +276 -44
- package/dist/engineCredentialRequirement.d.ts +9 -0
- package/dist/engineCredentialRequirement.js +23 -0
- package/dist/engineDirectory.d.ts +79 -0
- package/dist/engineDirectory.js +186 -0
- package/dist/engineEnvSourcing.d.ts +53 -0
- package/dist/engineEnvSourcing.js +81 -0
- package/dist/engineErrorCodes.d.ts +28 -4
- package/dist/engineErrorCodes.js +68 -25
- package/dist/engineIdentity.js +2 -0
- package/dist/engineNoticeCodes.d.ts +17 -0
- package/dist/engineNoticeCodes.js +57 -3
- package/dist/engineWireSdk.js +2 -2
- package/dist/engineWordRenames.d.ts +8 -0
- package/dist/engineWordRenames.js +13 -0
- package/dist/executionLaneCapability.d.ts +2 -3
- package/dist/executionLaneCapability.js +18 -23
- package/dist/fileHistoryCaptureCapability.d.ts +14 -1
- package/dist/fileHistoryCaptureCapability.js +72 -6
- package/dist/fileHistoryLegNotice.d.ts +3 -2
- package/dist/fileHistoryLegNotice.js +51 -2
- package/dist/fleet/bgSubagentRow.d.ts +15 -0
- package/dist/fleet/bgSubagentRow.js +67 -0
- package/dist/fleet/fleetLedger.d.ts +3 -0
- package/dist/fleet/fleetLedger.js +153 -122
- package/dist/fleet/fleetProjection.d.ts +1 -3
- package/dist/fleet/fleetProjection.js +19 -19
- package/dist/fleetAgentPanelProjection.d.ts +4 -17
- package/dist/fleetAgentPanelProjection.js +7 -197
- package/dist/fleetAgentRowLike.d.ts +16 -0
- package/dist/fleetAgentRowLike.js +1 -0
- package/dist/fleetTaskDesc.js +4 -17
- package/dist/gateOutcome.d.ts +12 -1
- package/dist/gateOutcome.js +87 -18
- package/dist/gateVocabulary.d.ts +7 -2
- package/dist/gateVocabulary.js +5 -1
- package/dist/generated/engineAskFaceTables.js +1 -1
- package/dist/generated/engineFactTables.d.ts +5 -3
- package/dist/generated/engineFactTables.js +17 -4
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/sdkFactTables.d.ts +2 -0
- package/dist/generated/sdkFactTables.js +17 -0
- package/dist/generated/settingsSchemaFns.d.ts +13 -0
- package/dist/generated/settingsSchemaFns.js +75 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/headlessPermissionModeWire.d.ts +1 -1
- package/dist/headlessPermissionModeWire.js +1 -1
- package/dist/headlessReconnectWire.js +49 -20
- package/dist/hitl/allowRuleShadow.d.ts +1 -1
- package/dist/hitl/allowRuleShadow.js +49 -8
- package/dist/hitl/approvalCompleteParked.d.ts +1 -0
- package/dist/hitl/approvalCompleteParked.js +14 -0
- package/dist/hitl/approvalEndingCause.d.ts +7 -0
- package/dist/hitl/approvalEndingCause.js +71 -0
- package/dist/hitl/approvalHolds.d.ts +12 -2
- package/dist/hitl/approvalHolds.js +53 -2
- package/dist/hitl/approvalsFeed.js +23 -11
- package/dist/hitl/askGateWire.d.ts +2 -1
- package/dist/hitl/askGateWire.js +26 -1
- package/dist/hitl/askParkRowRouting.js +1 -1
- package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
- package/dist/hitl/automaticAnswerVerdict.js +15 -10
- package/dist/hitl/crashConverged.js +2 -0
- package/dist/hitl/decisionConflict.d.ts +3 -0
- package/dist/hitl/decisionConflict.js +41 -0
- package/dist/hitl/decisionRefusal.d.ts +12 -0
- package/dist/hitl/decisionRefusal.js +63 -4
- package/dist/hitl/frameRouter.d.ts +0 -1
- package/dist/hitl/frameRouter.js +32 -57
- package/dist/hitl/gateLedger.d.ts +5 -0
- package/dist/hitl/gateLedger.js +21 -0
- package/dist/hitl/hitlBridge.d.ts +17 -2
- package/dist/hitl/hitlBridge.js +91 -55
- package/dist/hitl/hitlHostSurface.js +3 -11
- package/dist/hitl/livePendingAsk.d.ts +16 -6
- package/dist/hitl/livePendingAsk.js +36 -4
- package/dist/hitl/localAllowRule.d.ts +1 -0
- package/dist/hitl/localAllowRule.js +2 -2
- package/dist/hitl/noAllowCause.d.ts +2 -1
- package/dist/hitl/noAllowCause.js +3 -2
- package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
- package/dist/hitl/parkExpiryJudgements.js +46 -0
- package/dist/hitl/parkResolver.d.ts +4 -7
- package/dist/hitl/parkResolver.js +12 -34
- package/dist/hitl/parkRowBirthWait.d.ts +1 -0
- package/dist/hitl/parkRowBirthWait.js +2 -2
- package/dist/hitl/persistedRulesWire.js +5 -1
- package/dist/hitl/planReviewWire.d.ts +3 -2
- package/dist/hitl/planReviewWire.js +154 -50
- package/dist/hitl/replayedApproval.d.ts +9 -0
- package/dist/hitl/replayedApproval.js +139 -10
- package/dist/hitl/resumeRunningCard.d.ts +2 -0
- package/dist/hitl/resumeRunningCard.js +15 -4
- package/dist/hitl/sessionPolicyDeliverable.js +8 -6
- package/dist/hitl/standingRows.d.ts +18 -0
- package/dist/hitl/standingRows.js +127 -0
- package/dist/hitl/toolApprovalWire.d.ts +39 -7
- package/dist/hitl/toolApprovalWire.js +351 -61
- package/dist/hookMatcherVerdict.d.ts +1 -9
- package/dist/hookMatcherVerdict.js +21 -61
- package/dist/hooksWireCaps.js +40 -8
- package/dist/host.d.ts +5 -0
- package/dist/host.js +3 -1
- package/dist/hostCallbackGuard.d.ts +2 -0
- package/dist/hostCallbackGuard.js +31 -0
- package/dist/index.d.ts +48 -17
- package/dist/index.js +36 -15
- package/dist/interactiveInterrupt.d.ts +8 -0
- package/dist/interactiveInterrupt.js +54 -0
- package/dist/limitsWire.d.ts +5 -0
- package/dist/limitsWire.js +49 -3
- package/dist/liveModelCatalog.d.ts +95 -0
- package/dist/liveModelCatalog.js +297 -32
- package/dist/mcpEngineLeg.d.ts +25 -0
- package/dist/mcpEngineLeg.js +71 -15
- package/dist/mcpPanel.js +2 -1
- package/dist/mcpProbeCapability.d.ts +0 -5
- package/dist/mcpProbeCapability.js +2 -12
- package/dist/mcpReconnect.d.ts +1 -3
- package/dist/mcpReconnect.js +10 -5
- package/dist/memoryComplianceCapability.d.ts +0 -5
- package/dist/memoryComplianceCapability.js +2 -12
- package/dist/memoryOriginCapability.d.ts +0 -5
- package/dist/memoryOriginCapability.js +2 -12
- package/dist/memorySpecWire.js +2 -2
- package/dist/memoryVerbsWire.d.ts +1 -1
- package/dist/memoryVerbsWire.js +4 -0
- package/dist/model/liveCatalogShape.d.ts +14 -0
- package/dist/model/liveCatalogShape.js +71 -0
- package/dist/model/modelSupplyRules.d.ts +1 -0
- package/dist/model/modelSupplyRules.js +30 -9
- package/dist/model/modelsPolicy.d.ts +21 -0
- package/dist/model/modelsPolicy.js +90 -0
- package/dist/modelIdentityResolvability.d.ts +2 -2
- package/dist/modelIdentityResolvability.js +14 -12
- package/dist/modelSwitchFallback.d.ts +69 -0
- package/dist/modelSwitchFallback.js +206 -0
- package/dist/noticePresentation.d.ts +68 -0
- package/dist/noticePresentation.js +247 -0
- package/dist/notifications.js +12 -11
- package/dist/outputStyleSeatCapability.d.ts +0 -2
- package/dist/outputStyleSeatCapability.js +2 -10
- package/dist/ownKey.d.ts +8 -0
- package/dist/ownKey.js +66 -0
- package/dist/panelReduce.d.ts +114 -0
- package/dist/panelReduce.js +1135 -0
- package/dist/panelStateHolder.d.ts +17 -0
- package/dist/panelStateHolder.js +201 -0
- package/dist/peerFrames.js +13 -9
- package/dist/peerLaneCapability.d.ts +0 -1
- package/dist/peerLaneCapability.js +2 -6
- package/dist/permissionModesCapability.d.ts +0 -5
- package/dist/permissionModesCapability.js +5 -16
- package/dist/permissionRuleIssue.js +0 -3
- package/dist/permissionRulesWriteCapability.d.ts +0 -1
- package/dist/permissionRulesWriteCapability.js +2 -6
- package/dist/permissionsAllowGrantCapability.d.ts +0 -1
- package/dist/permissionsAllowGrantCapability.js +3 -9
- package/dist/permissionsDeclaration.d.ts +8 -0
- package/dist/permissionsDeclaration.js +101 -41
- package/dist/printPermissionOutcome.d.ts +12 -0
- package/dist/printPermissionOutcome.js +50 -0
- package/dist/printToolResultFrame.d.ts +1 -0
- package/dist/printToolResultFrame.js +5 -17
- package/dist/promptBlockedCopy.d.ts +5 -0
- package/dist/promptBlockedCopy.js +35 -0
- package/dist/promptDelivery.js +0 -8
- package/dist/protocolSegment.d.ts +9 -6
- package/dist/protocolSegment.js +31 -21
- package/dist/providerRejection.d.ts +4 -0
- package/dist/providerRejection.js +75 -14
- package/dist/replayBody.d.ts +12 -0
- package/dist/replayBody.js +25 -0
- package/dist/resumeRefusalCopy.d.ts +18 -1
- package/dist/resumeRefusalCopy.js +127 -32
- package/dist/retryStatus.d.ts +9 -1
- package/dist/retryStatus.js +9 -2
- package/dist/rewindArchiveCapability.d.ts +5 -14
- package/dist/rewindArchiveCapability.js +18 -61
- package/dist/rewindArchiveReading.d.ts +15 -0
- package/dist/rewindArchiveReading.js +56 -0
- package/dist/rewindEngineAction.d.ts +21 -0
- package/dist/rewindEngineAction.js +36 -0
- package/dist/rewindWireCaps.d.ts +2 -1
- package/dist/rewindWireCaps.js +1 -0
- package/dist/ruleCompileVerdict.d.ts +9 -1
- package/dist/ruleCompileVerdict.js +29 -4
- package/dist/runTerminal.d.ts +15 -12
- package/dist/runTerminal.js +60 -35
- package/dist/sandboxWire.js +13 -0
- package/dist/sdkRegistryTransit.d.ts +2 -1
- package/dist/sdkRegistryTransit.js +1 -0
- package/dist/sealedKeyCapability.d.ts +0 -5
- package/dist/sealedKeyCapability.js +3 -15
- package/dist/seam.js +4 -2
- package/dist/seatContract.d.ts +125 -34
- package/dist/seatContract.js +583 -179
- package/dist/sessionIdSegment.d.ts +1 -0
- package/dist/sessionIdSegment.js +11 -0
- package/dist/sessionMemoryErase.d.ts +1 -1
- package/dist/sessionMemoryErase.js +6 -1
- package/dist/sessionMemoryStatus.js +3 -2
- package/dist/sessionPolicyCapability.d.ts +0 -1
- package/dist/sessionPolicyCapability.js +2 -6
- package/dist/sessionReadRedactionCapability.d.ts +0 -5
- package/dist/sessionReadRedactionCapability.js +2 -13
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +66 -0
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -2
- package/dist/sessionSyncFileHistoryCapability.js +2 -9
- package/dist/skillToolListsCapability.d.ts +0 -2
- package/dist/skillToolListsCapability.js +2 -9
- package/dist/skillsWireCaps.d.ts +4 -0
- package/dist/skillsWireCaps.js +66 -1
- package/dist/sqlEngineCapability.d.ts +0 -1
- package/dist/sqlEngineCapability.js +9 -14
- package/dist/steerPriorityCapability.d.ts +0 -2
- package/dist/steerPriorityCapability.js +3 -12
- package/dist/storePostureCapability.d.ts +1 -5
- package/dist/storePostureCapability.js +16 -22
- package/dist/streamDrainingLegs.d.ts +6 -0
- package/dist/streamDrainingLegs.js +23 -0
- package/dist/subagent/engineCompactWire.js +13 -38
- package/dist/subagent/engineDelegatedPrompt.js +10 -6
- package/dist/subagent/engineSubagentOutput.d.ts +0 -1
- package/dist/subagent/engineSubagentOutput.js +5 -20
- package/dist/subagent/engineSubagentSteer.js +7 -5
- package/dist/subagent/engineSubagentTail.d.ts +0 -1
- package/dist/subagent/engineSubagentTail.js +7 -32
- package/dist/subagentContentStore.js +7 -18
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +15 -14
- package/dist/systemReminderTag.d.ts +1 -0
- package/dist/systemReminderTag.js +8 -0
- package/dist/terminalStatuses.d.ts +30 -0
- package/dist/terminalStatuses.js +67 -0
- package/dist/toolHistoryMismatch.d.ts +0 -3
- package/dist/toolHistoryMismatch.js +3 -7
- package/dist/toolResult.d.ts +6 -1
- package/dist/toolResult.js +90 -37
- package/dist/toolResultContent.d.ts +2 -0
- package/dist/toolResultContent.js +63 -0
- package/dist/types/engineState.d.ts +2 -1
- package/dist/usageAnalytics.d.ts +146 -0
- package/dist/usageAnalytics.js +335 -0
- package/dist/userInvokedSkillsCapability.d.ts +0 -2
- package/dist/userInvokedSkillsCapability.js +2 -9
- package/dist/webSearchBackendCapability.d.ts +0 -1
- package/dist/webSearchBackendCapability.js +3 -7
- package/dist/webSearchWireCaps.js +3 -11
- package/dist/wireErrorTriage.d.ts +2 -0
- package/dist/wireErrorTriage.js +34 -5
- package/dist/wireFailureShape.d.ts +23 -2
- package/dist/wireFailureShape.js +88 -43
- package/dist/wireRefusalCopy.js +2 -18
- package/dist/workflowClient.js +7 -11
- package/dist/workflowsJournalCapability.d.ts +0 -1
- package/dist/workflowsJournalCapability.js +2 -6
- package/dist/writeProtectionCapability.d.ts +0 -1
- package/dist/writeProtectionCapability.js +5 -10
- package/docs/INTEGRATION-CLIENTS.md +2279 -27
- package/package.json +5 -5
- package/dist/engineCapsGenerationGuard.d.ts +0 -4
- package/dist/engineCapsGenerationGuard.js +0 -19
- package/dist/panelRunningHistory.d.ts +0 -22
- package/dist/panelRunningHistory.js +0 -82
- package/dist/registryConflict.d.ts +0 -3
- package/dist/registryConflict.js +0 -44
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AUTO_MODE_UNAVAILABLE_CAUSES } from './autoModeUnavailable.js';
|
|
2
2
|
import { displayUntrusted } from './displayUntrusted.js';
|
|
3
|
+
import { currentEngineWord } from './engineWordRenames.js';
|
|
3
4
|
import { CORE_ENGINE_NOTICE_CODES, CORE_MCP_INJECTION_DROP_REASONS, CORE_NOTICE_AUDIENCE, CORE_USER_INPUT_UNDRAINED_FAMILIES, } from './generated/engineNoticeTables.js';
|
|
4
5
|
import { CORE_ASK_UNRESOLVABLE_CAUSES, CORE_DURABLE_MANDATE_SOURCES, CORE_PERMISSION_MODE_FOLD_REASONS, } from './generated/engineFactTables.js';
|
|
5
6
|
export const ENGINE_NOTICE_CODES = CORE_ENGINE_NOTICE_CODES;
|
|
@@ -8,13 +9,13 @@ function audienceRow(table, code) {
|
|
|
8
9
|
return Object.hasOwn(table, code) ? table[code] : undefined;
|
|
9
10
|
}
|
|
10
11
|
export function engineNoticeInCatalog(code) {
|
|
11
|
-
return typeof code === 'string' && CATALOG.has(code);
|
|
12
|
+
return typeof code === 'string' && (CATALOG.has(code) || CATALOG.has(currentEngineWord(code)));
|
|
12
13
|
}
|
|
13
14
|
export const ENGINE_NOTICE_AUDIENCE = CORE_NOTICE_AUDIENCE;
|
|
14
15
|
export function noticeAudienceOf(code) {
|
|
15
16
|
if (typeof code !== 'string')
|
|
16
17
|
return 'operator';
|
|
17
|
-
return audienceRow(ENGINE_NOTICE_AUDIENCE, code) ?? 'operator';
|
|
18
|
+
return audienceRow(ENGINE_NOTICE_AUDIENCE, code) ?? audienceRow(ENGINE_NOTICE_AUDIENCE, currentEngineWord(code)) ?? 'operator';
|
|
18
19
|
}
|
|
19
20
|
export const MCP_INJECTION_DROP_REASONS = CORE_MCP_INJECTION_DROP_REASONS;
|
|
20
21
|
const DROP_REASONS = new Set(MCP_INJECTION_DROP_REASONS);
|
|
@@ -602,12 +603,21 @@ function readToolTurnIncompleteOf(notice) {
|
|
|
602
603
|
const o = d;
|
|
603
604
|
const cause = nonEmpty(ownSeat(o, 'cause'));
|
|
604
605
|
const count = positiveInt(ownSeat(o, 'count'));
|
|
606
|
+
const outcome = optionalNonEmpty(o, 'outcome');
|
|
605
607
|
const toolCallIds = optionalNameList(o, 'toolCallIds');
|
|
606
608
|
const sessionId = nonEmpty(ownSeat(o, 'sessionId'));
|
|
607
609
|
const runId = nonEmpty(ownSeat(o, 'runId'));
|
|
608
610
|
if (cause === undefined || count === undefined || sessionId === undefined || runId === undefined)
|
|
609
611
|
return undefined;
|
|
610
|
-
return { cause, count, ...(toolCallIds !== undefined ? { toolCallIds } : {}), sessionId, runId };
|
|
612
|
+
return { cause, count, ...(outcome !== undefined ? { outcome } : {}), ...(toolCallIds !== undefined ? { toolCallIds } : {}), sessionId, runId };
|
|
613
|
+
}
|
|
614
|
+
function optionalNonEmpty(o, key) {
|
|
615
|
+
try {
|
|
616
|
+
return nonEmpty(ownSeat(o, key));
|
|
617
|
+
}
|
|
618
|
+
catch {
|
|
619
|
+
return undefined;
|
|
620
|
+
}
|
|
611
621
|
}
|
|
612
622
|
export function readUserInputUndrained(notice) {
|
|
613
623
|
return guardedRead(notice, readUserInputUndrainedOf);
|
|
@@ -779,6 +789,48 @@ export function steerCutVerdict(notice, messageId) {
|
|
|
779
789
|
return 'unattributed';
|
|
780
790
|
return facts.inputId === messageId ? 'this_input' : 'other_input';
|
|
781
791
|
}
|
|
792
|
+
export function readFinishReasonUnknown(notice) {
|
|
793
|
+
return guardedRead(notice, readFinishReasonUnknownOf);
|
|
794
|
+
}
|
|
795
|
+
function readFinishReasonUnknownOf(notice) {
|
|
796
|
+
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
797
|
+
return undefined;
|
|
798
|
+
const n = notice;
|
|
799
|
+
if (ownSeat(n, 'code') !== 'route.finish_reason_unknown')
|
|
800
|
+
return undefined;
|
|
801
|
+
const d = ownSeat(n, 'detail');
|
|
802
|
+
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
803
|
+
return undefined;
|
|
804
|
+
const o = d;
|
|
805
|
+
const finishReason = nonEmpty(ownSeat(o, 'finishReason'));
|
|
806
|
+
const sessionId = nonEmpty(ownSeat(o, 'sessionId'));
|
|
807
|
+
const runId = nonEmpty(ownSeat(o, 'runId'));
|
|
808
|
+
if (finishReason === undefined || sessionId === undefined || runId === undefined)
|
|
809
|
+
return undefined;
|
|
810
|
+
return { finishReason, sessionId, runId };
|
|
811
|
+
}
|
|
812
|
+
export function readStreamEndIgnored(notice) {
|
|
813
|
+
return guardedRead(notice, readStreamEndIgnoredOf);
|
|
814
|
+
}
|
|
815
|
+
function readStreamEndIgnoredOf(notice) {
|
|
816
|
+
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
817
|
+
return undefined;
|
|
818
|
+
const n = notice;
|
|
819
|
+
if (ownSeat(n, 'code') !== 'route.stream_end_ignored')
|
|
820
|
+
return undefined;
|
|
821
|
+
const d = ownSeat(n, 'detail');
|
|
822
|
+
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
823
|
+
return undefined;
|
|
824
|
+
const o = d;
|
|
825
|
+
const statement = nonEmpty(ownSeat(o, 'statement'));
|
|
826
|
+
const word = nonEmpty(ownSeat(o, 'word'));
|
|
827
|
+
const frames = positiveInt(ownSeat(o, 'frames'));
|
|
828
|
+
const sessionId = nonEmpty(ownSeat(o, 'sessionId'));
|
|
829
|
+
const runId = nonEmpty(ownSeat(o, 'runId'));
|
|
830
|
+
if (statement === undefined || word === undefined || frames === undefined || sessionId === undefined || runId === undefined)
|
|
831
|
+
return undefined;
|
|
832
|
+
return { statement, word, frames, sessionId, runId };
|
|
833
|
+
}
|
|
782
834
|
export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
|
|
783
835
|
'mcp.injection_dropped': readMcpInjectionDrop,
|
|
784
836
|
'delegation.ask_unresolvable': readAskUnresolvable,
|
|
@@ -801,6 +853,8 @@ export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
|
|
|
801
853
|
'task.user_steer_undrained': readUserInputUndrained,
|
|
802
854
|
'task.user_followup_undrained': readUserInputUndrained,
|
|
803
855
|
'task.turn_interrupted': readTurnInterrupted,
|
|
856
|
+
'route.finish_reason_unknown': readFinishReasonUnknown,
|
|
857
|
+
'route.stream_end_ignored': readStreamEndIgnored,
|
|
804
858
|
});
|
|
805
859
|
const _factReaderTablePin = true;
|
|
806
860
|
void _factReaderTablePin;
|
package/dist/engineWireSdk.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AgentClient } from '@sema-agent/sdk';
|
|
2
|
+
import { SETTINGS_IS_LOOPBACK_AUTH_HOST } from './generated/settingsSchemaFns.js';
|
|
2
3
|
import { normalizeWirePrincipal } from './principalWire.js';
|
|
3
4
|
export function isLoopbackWireUrl(url) {
|
|
4
5
|
try {
|
|
5
|
-
|
|
6
|
-
return h === '127.0.0.1' || h === 'localhost' || h === '::1' || h === '[::1]';
|
|
6
|
+
return SETTINGS_IS_LOOPBACK_AUTH_HOST(new URL(url).hostname);
|
|
7
7
|
}
|
|
8
8
|
catch {
|
|
9
9
|
return false;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PRIOR_ENGINE_WORD_RENAMES: Readonly<{
|
|
2
|
+
readonly write_protection_unresolved: "target_unresolved";
|
|
3
|
+
}>;
|
|
4
|
+
export declare const PRIOR_ENGINE_NOTICE_CODE_RENAMES: Readonly<{
|
|
5
|
+
readonly 'config.write_protection_unresolved': "config.path_view_unresolved";
|
|
6
|
+
}>;
|
|
7
|
+
export type PriorEngineWord = keyof typeof PRIOR_ENGINE_WORD_RENAMES;
|
|
8
|
+
export declare function currentEngineWord(word: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const PRIOR_ENGINE_WORD_RENAMES = Object.freeze({
|
|
2
|
+
write_protection_unresolved: 'target_unresolved',
|
|
3
|
+
});
|
|
4
|
+
export const PRIOR_ENGINE_NOTICE_CODE_RENAMES = Object.freeze({
|
|
5
|
+
'config.write_protection_unresolved': 'config.path_view_unresolved',
|
|
6
|
+
});
|
|
7
|
+
export function currentEngineWord(word) {
|
|
8
|
+
if (Object.hasOwn(PRIOR_ENGINE_WORD_RENAMES, word))
|
|
9
|
+
return PRIOR_ENGINE_WORD_RENAMES[word];
|
|
10
|
+
if (Object.hasOwn(PRIOR_ENGINE_NOTICE_CODE_RENAMES, word))
|
|
11
|
+
return PRIOR_ENGINE_NOTICE_CODE_RENAMES[word];
|
|
12
|
+
return word;
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ExecutionLaneIsolatedAbsence = 'no_hands' | '
|
|
1
|
+
export type ExecutionLaneIsolatedAbsence = 'no_hands' | 'unreadable';
|
|
2
2
|
export interface ExecutionLaneCapabilityView {
|
|
3
3
|
provider: string;
|
|
4
4
|
toolsOnThisHost: boolean;
|
|
@@ -19,9 +19,8 @@ export declare function noteEngineCapsForExecutionLane(baseUrl: string, caps: un
|
|
|
19
19
|
generation?: number;
|
|
20
20
|
}): void;
|
|
21
21
|
export declare function observedExecutionLane(baseUrl?: string | undefined): ExecutionLaneReading;
|
|
22
|
-
export declare function toolsRunHereFromExecutionLane(reading: ExecutionLaneReading
|
|
22
|
+
export declare function toolsRunHereFromExecutionLane(reading: ExecutionLaneReading): boolean;
|
|
23
23
|
export declare function noOsSandboxOnThisHost(reading: ExecutionLaneReading): 'yes' | 'no' | 'unknown';
|
|
24
24
|
export declare function noOsSandboxContent(): string;
|
|
25
25
|
export declare function executionLaneDoctorDetail(reading: ExecutionLaneReading): string;
|
|
26
|
-
export declare function forgetExecutionLaneReading(baseUrl: string | undefined): void;
|
|
27
26
|
export declare function __resetExecutionLaneReadingsForTests(): void;
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
2
2
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
3
|
-
import {
|
|
3
|
+
import { createEngineCapReader } from './engineCapReader.js';
|
|
4
|
+
import { ownDataField } from './ownKey.js';
|
|
4
5
|
export function projectExecutionLaneCapability(caps) {
|
|
5
6
|
try {
|
|
6
7
|
if (caps === null || typeof caps !== 'object')
|
|
7
8
|
return undefined;
|
|
8
9
|
if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
|
|
9
10
|
return undefined;
|
|
10
|
-
|
|
11
|
-
return { kind: 'not_reported' };
|
|
12
|
-
const lane = caps.executionLane;
|
|
11
|
+
const lane = ownDataField(caps, 'executionLane');
|
|
13
12
|
if (lane === undefined)
|
|
14
13
|
return { kind: 'not_reported' };
|
|
15
|
-
return projectExecutionLaneObject(lane
|
|
14
|
+
return projectExecutionLaneObject(lane);
|
|
16
15
|
}
|
|
17
16
|
catch {
|
|
18
17
|
return undefined;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
function projectExecutionLaneObject(lane
|
|
20
|
+
function projectExecutionLaneObject(lane) {
|
|
22
21
|
if (lane === null || typeof lane !== 'object' || Array.isArray(lane))
|
|
23
22
|
return undefined;
|
|
24
|
-
const provider = lane
|
|
25
|
-
const toolsOnThisHost = lane
|
|
23
|
+
const provider = ownDataField(lane, 'provider');
|
|
24
|
+
const toolsOnThisHost = ownDataField(lane, 'toolsOnThisHost');
|
|
26
25
|
if (typeof provider !== 'string' || provider === '')
|
|
27
26
|
return undefined;
|
|
28
27
|
if (typeof toolsOnThisHost !== 'boolean')
|
|
@@ -30,26 +29,24 @@ function projectExecutionLaneObject(lane, newGeneration) {
|
|
|
30
29
|
let isolated;
|
|
31
30
|
let isolatedThrew = false;
|
|
32
31
|
try {
|
|
33
|
-
isolated =
|
|
32
|
+
isolated = ownDataField(lane, 'isolated');
|
|
34
33
|
}
|
|
35
34
|
catch {
|
|
36
35
|
isolatedThrew = true;
|
|
37
36
|
}
|
|
38
37
|
if (!isolatedThrew && typeof isolated === 'boolean')
|
|
39
38
|
return { kind: 'present', view: { provider, toolsOnThisHost, isolated } };
|
|
40
|
-
const isolatedAbsent = isolatedThrew || isolated !== undefined ? 'unreadable' :
|
|
39
|
+
const isolatedAbsent = isolatedThrew || isolated !== undefined ? 'unreadable' : toolsOnThisHost ? 'unreadable' : 'no_hands';
|
|
41
40
|
return { kind: 'present', view: { provider, toolsOnThisHost, isolatedAbsent } };
|
|
42
41
|
}
|
|
43
42
|
export function projectExecutionLaneWiring(wiring) {
|
|
44
43
|
try {
|
|
45
44
|
if (wiring === null || typeof wiring !== 'object' || Array.isArray(wiring))
|
|
46
45
|
return undefined;
|
|
47
|
-
|
|
48
|
-
return { kind: 'not_reported' };
|
|
49
|
-
const lane = wiring.executionLane;
|
|
46
|
+
const lane = ownDataField(wiring, 'executionLane');
|
|
50
47
|
if (lane === undefined)
|
|
51
48
|
return { kind: 'not_reported' };
|
|
52
|
-
return projectExecutionLaneObject(lane
|
|
49
|
+
return projectExecutionLaneObject(lane);
|
|
53
50
|
}
|
|
54
51
|
catch {
|
|
55
52
|
return undefined;
|
|
@@ -66,12 +63,13 @@ export function noteEngineCapsForExecutionLane(baseUrl, caps, opts) {
|
|
|
66
63
|
export function observedExecutionLane(baseUrl = engineWireTarget()?.baseUrl) {
|
|
67
64
|
return reader.observed(baseUrl);
|
|
68
65
|
}
|
|
69
|
-
export function toolsRunHereFromExecutionLane(reading
|
|
70
|
-
|
|
71
|
-
return reading.view.toolsOnThisHost;
|
|
72
|
-
|
|
66
|
+
export function toolsRunHereFromExecutionLane(reading) {
|
|
67
|
+
try {
|
|
68
|
+
return reading.kind === 'present' && reading.view.toolsOnThisHost === true;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
73
71
|
return false;
|
|
74
|
-
|
|
72
|
+
}
|
|
75
73
|
}
|
|
76
74
|
export function noOsSandboxOnThisHost(reading) {
|
|
77
75
|
if (typeof reading !== 'object' || reading === null)
|
|
@@ -105,7 +103,7 @@ export function executionLaneDoctorDetail(reading) {
|
|
|
105
103
|
'this process has no usable capabilities reading cached for it (none received, the last one was unreadable, or the last one was discarded when the engine connection was reset; this process cannot tell which)');
|
|
106
104
|
case 'not_reported':
|
|
107
105
|
return ('execution lane not reported by this engine; ' +
|
|
108
|
-
'this does not say where tools run, so
|
|
106
|
+
'this does not say where tools run, so skill baseDir is not sent until the engine reports it');
|
|
109
107
|
case 'present': {
|
|
110
108
|
const lane = capForDisplay(reading.view.provider, LANE_DETAIL_MAX);
|
|
111
109
|
if (reading.view.toolsOnThisHost) {
|
|
@@ -118,9 +116,6 @@ export function executionLaneDoctorDetail(reading) {
|
|
|
118
116
|
}
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
|
-
export function forgetExecutionLaneReading(baseUrl) {
|
|
122
|
-
reader.forget(baseUrl);
|
|
123
|
-
}
|
|
124
119
|
export function __resetExecutionLaneReadingsForTests() {
|
|
125
120
|
reader.__resetForTests();
|
|
126
121
|
}
|
|
@@ -16,6 +16,19 @@ export declare function fileHistoryCaptureMode(reading: FileHistoryCaptureReadin
|
|
|
16
16
|
export declare function fileHistoryDeclarationField(reading: FileHistoryCaptureReading, captureOff: boolean): {
|
|
17
17
|
fileHistory: 'disabled';
|
|
18
18
|
} | Record<string, never>;
|
|
19
|
+
export declare const FILE_HISTORY_TIGHTEN_VERDICTS: readonly ["not_requested", "declare", "already_off", "unjudged"];
|
|
20
|
+
export type FileHistoryTightenVerdict = (typeof FILE_HISTORY_TIGHTEN_VERDICTS)[number];
|
|
21
|
+
export declare function fileHistoryTightenVerdict(reading: FileHistoryCaptureReading, captureOffByUser: boolean): FileHistoryTightenVerdict;
|
|
22
|
+
export declare function fileHistoryUnjudgedRefusal(reading: FileHistoryCaptureReading, captureOffByUser: boolean): string | undefined;
|
|
23
|
+
export interface FileHistoryTightenJudgement {
|
|
24
|
+
readonly verdict: FileHistoryTightenVerdict;
|
|
25
|
+
readonly reading: FileHistoryCaptureReading;
|
|
26
|
+
readonly refreshed: boolean;
|
|
27
|
+
readonly refusal: string | undefined;
|
|
28
|
+
}
|
|
29
|
+
export declare function judgeFileHistoryTighten(captureOffByUser: boolean, opts?: {
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
withinMs?: number;
|
|
32
|
+
}): Promise<FileHistoryTightenJudgement>;
|
|
19
33
|
export declare function fileHistoryCaptureDoctorDetail(reading: FileHistoryCaptureReading): string;
|
|
20
|
-
export declare function forgetFileHistoryCaptureReading(baseUrl: string | undefined): void;
|
|
21
34
|
export declare function __resetFileHistoryCaptureReadingsForTests(): void;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
2
2
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
3
3
|
import { createEngineCapReader } from './engineCapReader.js';
|
|
4
|
+
import { refreshEngineCapsOnce } from './engineCapsCache.js';
|
|
5
|
+
import { ownDataField } from './ownKey.js';
|
|
4
6
|
import { FILE_HISTORY_DISABLED } from './request/taskRequest.js';
|
|
5
7
|
export function projectFileHistoryCaptureCapability(caps) {
|
|
6
8
|
try {
|
|
7
9
|
if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
|
|
8
10
|
return undefined;
|
|
9
|
-
|
|
10
|
-
return { kind: 'not_reported' };
|
|
11
|
-
const v = caps.fileHistoryCapture;
|
|
11
|
+
const v = ownDataField(caps, 'fileHistoryCapture');
|
|
12
12
|
if (v === undefined)
|
|
13
13
|
return { kind: 'not_reported' };
|
|
14
14
|
if (typeof v !== 'string' || v.length === 0)
|
|
@@ -53,6 +53,75 @@ export function fileHistoryCaptureMode(reading) {
|
|
|
53
53
|
export function fileHistoryDeclarationField(reading, captureOff) {
|
|
54
54
|
return captureOff === true && fileHistoryCaptureMode(reading) === 'on-optional' ? { fileHistory: FILE_HISTORY_DISABLED } : {};
|
|
55
55
|
}
|
|
56
|
+
export const FILE_HISTORY_TIGHTEN_VERDICTS = Object.freeze(['not_requested', 'declare', 'already_off', 'unjudged']);
|
|
57
|
+
export function fileHistoryTightenVerdict(reading, captureOffByUser) {
|
|
58
|
+
if (captureOffByUser !== true)
|
|
59
|
+
return 'not_requested';
|
|
60
|
+
const mode = fileHistoryCaptureMode(reading);
|
|
61
|
+
if (mode === 'on-optional')
|
|
62
|
+
return 'declare';
|
|
63
|
+
if (mode === 'off')
|
|
64
|
+
return 'already_off';
|
|
65
|
+
return 'unjudged';
|
|
66
|
+
}
|
|
67
|
+
const FILE_HISTORY_UNJUDGED_REFUSAL = 'Nothing was sent: file checkpointing is turned off in your settings, but this engine did not report whether it can ' +
|
|
68
|
+
'stop recording file history for a session, so sending now could record it anyway. Try again in a moment; to send ' +
|
|
69
|
+
'regardless and let file history be recorded this time, turn file checkpointing back on in your settings.';
|
|
70
|
+
export function fileHistoryUnjudgedRefusal(reading, captureOffByUser) {
|
|
71
|
+
return fileHistoryTightenVerdict(reading, captureOffByUser) === 'unjudged' ? FILE_HISTORY_UNJUDGED_REFUSAL : undefined;
|
|
72
|
+
}
|
|
73
|
+
const FILE_HISTORY_REFRESH_WITHIN_MS = 3000;
|
|
74
|
+
export async function judgeFileHistoryTighten(captureOffByUser, opts) {
|
|
75
|
+
const closed = captureOffByUser === true;
|
|
76
|
+
const failClosed = () => {
|
|
77
|
+
const reading = { kind: 'unobserved' };
|
|
78
|
+
return closed
|
|
79
|
+
? { verdict: 'unjudged', reading, refreshed: false, refusal: FILE_HISTORY_UNJUDGED_REFUSAL }
|
|
80
|
+
: { verdict: 'not_requested', reading, refreshed: false, refusal: undefined };
|
|
81
|
+
};
|
|
82
|
+
try {
|
|
83
|
+
let explicitBase;
|
|
84
|
+
let withinMs = FILE_HISTORY_REFRESH_WITHIN_MS;
|
|
85
|
+
if (typeof opts === 'object' && opts !== null) {
|
|
86
|
+
try {
|
|
87
|
+
const b = opts.baseUrl;
|
|
88
|
+
if (b !== undefined) {
|
|
89
|
+
if (typeof b !== 'string' || b === '')
|
|
90
|
+
return failClosed();
|
|
91
|
+
explicitBase = b;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return failClosed();
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const w = opts.withinMs;
|
|
99
|
+
if (w !== undefined)
|
|
100
|
+
withinMs = typeof w === 'number' ? w : 0;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
withinMs = 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const baseUrl = explicitBase ?? engineWireTarget()?.baseUrl;
|
|
107
|
+
const first = observedFileHistoryCapture(baseUrl);
|
|
108
|
+
const v1 = fileHistoryTightenVerdict(first, captureOffByUser);
|
|
109
|
+
if (v1 !== 'unjudged')
|
|
110
|
+
return { verdict: v1, reading: first, refreshed: false, refusal: undefined };
|
|
111
|
+
const outcome = await refreshEngineCapsOnce(baseUrl, { withinMs });
|
|
112
|
+
const second = observedFileHistoryCapture(baseUrl);
|
|
113
|
+
const v2 = fileHistoryTightenVerdict(second, captureOffByUser);
|
|
114
|
+
return {
|
|
115
|
+
verdict: v2,
|
|
116
|
+
reading: second,
|
|
117
|
+
refreshed: outcome !== 'no_probe',
|
|
118
|
+
refusal: v2 === 'unjudged' ? FILE_HISTORY_UNJUDGED_REFUSAL : undefined,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return failClosed();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
56
125
|
const WORD_DETAIL_MAX = 40;
|
|
57
126
|
export function fileHistoryCaptureDoctorDetail(reading) {
|
|
58
127
|
const unobserved = 'file history capture not observed — the engine reports it on /v1/capabilities; this process has no usable capabilities reading cached for it, so whether this deployment captures file history is unknown';
|
|
@@ -84,9 +153,6 @@ export function fileHistoryCaptureDoctorDetail(reading) {
|
|
|
84
153
|
return unobserved;
|
|
85
154
|
}
|
|
86
155
|
}
|
|
87
|
-
export function forgetFileHistoryCaptureReading(baseUrl) {
|
|
88
|
-
reader.forget(baseUrl);
|
|
89
|
-
}
|
|
90
156
|
export function __resetFileHistoryCaptureReadingsForTests() {
|
|
91
157
|
reader.__resetForTests();
|
|
92
158
|
}
|
|
@@ -4,7 +4,7 @@ export type FileHistoryDeclarationFact = 'sent' | 'not_sent' | 'unknown';
|
|
|
4
4
|
export declare const FILE_HISTORY_LEG_VERDICTS: readonly ["not_honored", "honored", "not_declared", "unknown"];
|
|
5
5
|
export type FileHistoryLegNoticeVerdict = (typeof FILE_HISTORY_LEG_VERDICTS)[number];
|
|
6
6
|
export interface FileHistoryLegNoticeInput {
|
|
7
|
-
readonly
|
|
7
|
+
readonly assemblyCapability: FileHistoryCaptureReading;
|
|
8
8
|
readonly declaration: FileHistoryDeclarationFact;
|
|
9
9
|
readonly captureOffByUser: boolean;
|
|
10
10
|
readonly legWord: string | undefined;
|
|
@@ -22,10 +22,11 @@ export type OutboundBodyField = {
|
|
|
22
22
|
};
|
|
23
23
|
export declare function readOutboundBodyField(body: object | null | undefined, key: string): OutboundBodyField;
|
|
24
24
|
export interface FileHistoryDeclarationLedger {
|
|
25
|
-
declared(requestKey: string, fact: FileHistoryDeclarationFact): boolean;
|
|
25
|
+
declared(requestKey: string, fact: FileHistoryDeclarationFact, capabilityAtAssembly?: FileHistoryCaptureReading): boolean;
|
|
26
26
|
boundToRun(requestKey: string, runId: string, event: AgentEvent): boolean;
|
|
27
27
|
declarationOf(runId: string): FileHistoryDeclarationFact;
|
|
28
28
|
declaredLegCwd(requestKey: string, cwd: string | undefined): boolean;
|
|
29
29
|
legCwdOf(runId: string): string | undefined;
|
|
30
|
+
capabilityAtAssemblyOf(runId: string): FileHistoryCaptureReading;
|
|
30
31
|
}
|
|
31
32
|
export declare function createFileHistoryDeclarationLedger(): FileHistoryDeclarationLedger;
|
|
@@ -16,7 +16,7 @@ export function fileHistoryLegNoticeVerdict(input) {
|
|
|
16
16
|
let offByUser;
|
|
17
17
|
let legWord;
|
|
18
18
|
try {
|
|
19
|
-
capability = ownRead(input, '
|
|
19
|
+
capability = ownRead(input, 'assemblyCapability');
|
|
20
20
|
declaration = declarationOfInput(ownRead(input, 'declaration'));
|
|
21
21
|
offByUser = ownRead(input, 'captureOffByUser') === true;
|
|
22
22
|
legWord = ownRead(input, 'legWord');
|
|
@@ -82,10 +82,35 @@ export function readOutboundBodyField(body, key) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
const idOk = (v) => typeof v === 'string' && v.length > 0;
|
|
85
|
+
function canonReading(r) {
|
|
86
|
+
try {
|
|
87
|
+
if (typeof r !== 'object' || r === null)
|
|
88
|
+
return 'unobserved';
|
|
89
|
+
const kind = r.kind;
|
|
90
|
+
if (kind === 'not_reported')
|
|
91
|
+
return 'not_reported';
|
|
92
|
+
if (kind === 'present') {
|
|
93
|
+
const word = r.word;
|
|
94
|
+
return typeof word === 'string' && word.length > 0 ? `present:${word}` : 'unobserved';
|
|
95
|
+
}
|
|
96
|
+
return 'unobserved';
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return 'unobserved';
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function readingOfCanon(c) {
|
|
103
|
+
if (c === 'not_reported')
|
|
104
|
+
return { kind: 'not_reported' };
|
|
105
|
+
if (c.startsWith('present:'))
|
|
106
|
+
return { kind: 'present', word: c.slice('present:'.length) };
|
|
107
|
+
return { kind: 'unobserved' };
|
|
108
|
+
}
|
|
85
109
|
export function createFileHistoryDeclarationLedger() {
|
|
86
110
|
const factsByKey = new Map();
|
|
87
111
|
const cwdsByKey = new Map();
|
|
88
112
|
const keysByRun = new Map();
|
|
113
|
+
const readingsByKey = new Map();
|
|
89
114
|
return Object.freeze({
|
|
90
115
|
declaredLegCwd(requestKey, cwd) {
|
|
91
116
|
if (!idOk(requestKey) || !idOk(cwd))
|
|
@@ -114,15 +139,39 @@ export function createFileHistoryDeclarationLedger() {
|
|
|
114
139
|
}
|
|
115
140
|
return agreed;
|
|
116
141
|
},
|
|
117
|
-
declared(requestKey, fact) {
|
|
142
|
+
declared(requestKey, fact, capabilityAtAssembly) {
|
|
118
143
|
if (!idOk(requestKey) || (fact !== 'sent' && fact !== 'not_sent'))
|
|
119
144
|
return false;
|
|
120
145
|
let set = factsByKey.get(requestKey);
|
|
121
146
|
if (set === undefined)
|
|
122
147
|
factsByKey.set(requestKey, (set = new Set()));
|
|
123
148
|
set.add(fact);
|
|
149
|
+
if (capabilityAtAssembly !== undefined) {
|
|
150
|
+
let rs = readingsByKey.get(requestKey);
|
|
151
|
+
if (rs === undefined)
|
|
152
|
+
readingsByKey.set(requestKey, (rs = new Set()));
|
|
153
|
+
rs.add(canonReading(capabilityAtAssembly));
|
|
154
|
+
}
|
|
124
155
|
return true;
|
|
125
156
|
},
|
|
157
|
+
capabilityAtAssemblyOf(runId) {
|
|
158
|
+
if (!idOk(runId))
|
|
159
|
+
return { kind: 'unobserved' };
|
|
160
|
+
const keys = keysByRun.get(runId);
|
|
161
|
+
if (keys === undefined)
|
|
162
|
+
return { kind: 'unobserved' };
|
|
163
|
+
let agreed;
|
|
164
|
+
for (const k of keys) {
|
|
165
|
+
const rs = readingsByKey.get(k);
|
|
166
|
+
if (rs === undefined || rs.size !== 1)
|
|
167
|
+
return { kind: 'unobserved' };
|
|
168
|
+
const [only] = rs;
|
|
169
|
+
if (only === undefined || (agreed !== undefined && agreed !== only))
|
|
170
|
+
return { kind: 'unobserved' };
|
|
171
|
+
agreed = only;
|
|
172
|
+
}
|
|
173
|
+
return agreed === undefined ? { kind: 'unobserved' } : readingOfCanon(agreed);
|
|
174
|
+
},
|
|
126
175
|
boundToRun(requestKey, runId, event) {
|
|
127
176
|
if (!idOk(requestKey) || !idOk(runId) || !frameProvesDelivery(event))
|
|
128
177
|
return false;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FleetTaskRow } from '@sema-agent/sdk';
|
|
2
|
+
export declare const DURABLE_AGENT_HANDLE_RE: RegExp;
|
|
3
|
+
export declare function isAgentHandle(rowId: string): boolean;
|
|
4
|
+
export type NonAgentHandleKind = 'background_bash' | 'monitor';
|
|
5
|
+
export declare function nonAgentHandleKind(rowId: string): NonAgentHandleKind | null;
|
|
6
|
+
export type BgSubagentRowFacts = Pick<FleetTaskRow, 'id' | 'parentId' | 'sourceLane'>;
|
|
7
|
+
export declare function isBackgroundSubagentRow(row: BgSubagentRowFacts): boolean;
|
|
8
|
+
export declare function isBackgroundWorkRow(row: BgSubagentRowFacts): boolean;
|
|
9
|
+
export interface BgRowOwnership {
|
|
10
|
+
readonly scoped: boolean;
|
|
11
|
+
readonly isOwnRun: (taskIdTail: string) => boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function liveBgRowOwnership(): BgRowOwnership;
|
|
14
|
+
export declare function liveBgRowOwnershipFor(sessionKey: string): BgRowOwnership;
|
|
15
|
+
export declare function isOwnBackgroundSubagentRow(row: BgSubagentRowFacts, own: BgRowOwnership): boolean;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { CORE_DURABLE_AGENT_HANDLE_RE, CORE_TASK_HANDLE_PREFIXES } from '../generated/engineFactTables.js';
|
|
2
|
+
import { DEFAULT_SESSION_KEY } from '../sessionSlot.js';
|
|
3
|
+
import { isOwnEngineRun } from '../subagentContentStore.js';
|
|
4
|
+
import { isWorkflowAgentTaskId, rowIdTail } from '../workflow.js';
|
|
5
|
+
import { isFleetSessionScopedFor } from './fleetLedger.js';
|
|
6
|
+
import { wireParentId } from './fleetProjection.js';
|
|
7
|
+
const _taskTypePins = [true, true];
|
|
8
|
+
void _taskTypePins;
|
|
9
|
+
export const DURABLE_AGENT_HANDLE_RE = CORE_DURABLE_AGENT_HANDLE_RE;
|
|
10
|
+
export function isAgentHandle(rowId) {
|
|
11
|
+
if (typeof rowId !== 'string' || rowId.length === 0)
|
|
12
|
+
return false;
|
|
13
|
+
if (rowIdTail(rowId) !== rowId)
|
|
14
|
+
return false;
|
|
15
|
+
return DURABLE_AGENT_HANDLE_RE.test(rowId) || isWorkflowAgentTaskId(rowId);
|
|
16
|
+
}
|
|
17
|
+
const NON_AGENT_HANDLE_TYPES = ['background_bash', 'monitor'];
|
|
18
|
+
export function nonAgentHandleKind(rowId) {
|
|
19
|
+
if (typeof rowId !== 'string')
|
|
20
|
+
return null;
|
|
21
|
+
const prefix = /^([a-z])[0-9a-f]{16}$/.exec(rowIdTail(rowId))?.[1];
|
|
22
|
+
if (prefix === undefined)
|
|
23
|
+
return null;
|
|
24
|
+
for (const type of NON_AGENT_HANDLE_TYPES)
|
|
25
|
+
if (CORE_TASK_HANDLE_PREFIXES[type] === prefix)
|
|
26
|
+
return type;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const RUN_LEG_LANE = 'run-leg';
|
|
30
|
+
function isForegroundDelegationRow(row) {
|
|
31
|
+
return rowIdTail(row.id) !== row.id || row.sourceLane === RUN_LEG_LANE;
|
|
32
|
+
}
|
|
33
|
+
function hasRowId(row) {
|
|
34
|
+
return typeof row?.id === 'string' && row.id.length > 0;
|
|
35
|
+
}
|
|
36
|
+
export function isBackgroundSubagentRow(row) {
|
|
37
|
+
if (!hasRowId(row))
|
|
38
|
+
return false;
|
|
39
|
+
if (isForegroundDelegationRow(row))
|
|
40
|
+
return false;
|
|
41
|
+
if (nonAgentHandleKind(row.id) !== null)
|
|
42
|
+
return false;
|
|
43
|
+
if (wireParentId(row) !== undefined)
|
|
44
|
+
return true;
|
|
45
|
+
return isAgentHandle(row.id);
|
|
46
|
+
}
|
|
47
|
+
export function isBackgroundWorkRow(row) {
|
|
48
|
+
if (isBackgroundSubagentRow(row))
|
|
49
|
+
return true;
|
|
50
|
+
if (!hasRowId(row))
|
|
51
|
+
return false;
|
|
52
|
+
return !isForegroundDelegationRow(row) && nonAgentHandleKind(row.id) !== null;
|
|
53
|
+
}
|
|
54
|
+
export function liveBgRowOwnership() {
|
|
55
|
+
return liveBgRowOwnershipFor(DEFAULT_SESSION_KEY);
|
|
56
|
+
}
|
|
57
|
+
export function liveBgRowOwnershipFor(sessionKey) {
|
|
58
|
+
return { scoped: isFleetSessionScopedFor(sessionKey), isOwnRun: isOwnEngineRun };
|
|
59
|
+
}
|
|
60
|
+
export function isOwnBackgroundSubagentRow(row, own) {
|
|
61
|
+
if (!isBackgroundSubagentRow(row))
|
|
62
|
+
return false;
|
|
63
|
+
if (own.scoped)
|
|
64
|
+
return true;
|
|
65
|
+
const parentId = wireParentId(row);
|
|
66
|
+
return own.isOwnRun(rowIdTail(row.id)) || (parentId !== undefined && own.isOwnRun(rowIdTail(parentId)));
|
|
67
|
+
}
|
|
@@ -6,6 +6,7 @@ export interface EngineActiveBgTask {
|
|
|
6
6
|
name?: string;
|
|
7
7
|
status: string;
|
|
8
8
|
parentId?: string;
|
|
9
|
+
sourceLane?: string;
|
|
9
10
|
retiredByNotification?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export interface EngineActiveBgReading {
|
|
@@ -18,6 +19,8 @@ export declare function readEngineActiveBgTasks(): EngineActiveBgReading;
|
|
|
18
19
|
export declare function readEngineActiveBgTasksFor(sessionKey: string): EngineActiveBgReading;
|
|
19
20
|
export declare function clearAllRetainedFleetRows(): void;
|
|
20
21
|
export declare function clearAllRetainedFleetRowsFor(sessionKey: string): void;
|
|
22
|
+
export declare function forgetSettledTerminalRow(id: string): boolean;
|
|
23
|
+
export declare function forgetSettledTerminalRowFor(sessionKey: string, id: string): boolean;
|
|
21
24
|
export declare function __resetFleetLedgerRegistryForTests(): void;
|
|
22
25
|
export declare function fleetStreamOptions(): {
|
|
23
26
|
session?: string;
|