@sema-agent/client-core 0.97.1 → 0.99.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 +607 -0
- package/README.md +96 -46
- package/dist/adapt/arms.d.ts +1 -0
- package/dist/adapt/arms.js +188 -53
- package/dist/adapt/ids.d.ts +12 -1
- package/dist/adapt/ids.js +59 -8
- package/dist/adapt/instanceLedger.d.ts +50 -0
- package/dist/adapt/instanceLedger.js +147 -0
- package/dist/adapt/panelTasks.d.ts +1 -1
- package/dist/adapt/panelTasks.js +2 -2
- package/dist/adapt/textStream.d.ts +1 -0
- package/dist/adapt/textStream.js +24 -7
- package/dist/adapt/toolCards.d.ts +27 -5
- package/dist/adapt/toolCards.js +39 -6
- package/dist/adapt/wireShapes.js +6 -2
- package/dist/adapt.d.ts +2 -0
- package/dist/adapt.js +8 -3
- package/dist/adapter/activeRunSelfHeal.d.ts +9 -3
- package/dist/adapter/activeRunSelfHeal.js +205 -313
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
- package/dist/adapter/downstream/eventToSdkMessage.js +77 -36
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
- package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
- package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
- package/dist/adapter/runStream.js +79 -48
- package/dist/adapter/types.d.ts +4 -4
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/backgroundView.js +2 -1
- package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
- package/dist/agentSession/engineAgentRegistryRead.js +12 -13
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +8 -11
- package/dist/agentsWireCaps.js +196 -194
- package/dist/approvalDecidedByCapability.d.ts +0 -4
- package/dist/approvalDecidedByCapability.js +0 -6
- package/dist/approvalsStreamLiveCapability.d.ts +0 -4
- package/dist/approvalsStreamLiveCapability.js +0 -6
- package/dist/assistantInbox.d.ts +34 -0
- package/dist/assistantInbox.js +118 -0
- package/dist/centerWiringCapability.js +9 -1
- package/dist/clientSlice.d.ts +0 -9
- package/dist/clientSlice.js +0 -3
- package/dist/cloudConfigWireCaps.d.ts +5 -3
- package/dist/cloudConfigWireCaps.js +106 -64
- package/dist/compensations.js +1 -1
- package/dist/connectorStatus.d.ts +21 -0
- package/dist/connectorStatus.js +112 -0
- package/dist/controlRouter.d.ts +18 -3
- package/dist/controlRouter.js +106 -67
- package/dist/coreValuePorts.d.ts +29 -4
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/decideReceipt.d.ts +2 -2
- package/dist/decideReceipt.js +5 -2
- package/dist/declared/supportFloorDeclared.js +3 -3
- package/dist/detachWire.js +3 -2
- package/dist/deviceExecutorManagementCapability.d.ts +0 -4
- package/dist/deviceExecutorManagementCapability.js +0 -6
- package/dist/deviceRebind.d.ts +49 -1
- package/dist/deviceRebind.js +221 -3
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +2 -0
- package/dist/displayUntrusted.js +253 -76
- package/dist/engineAgentAbsence.d.ts +1 -1
- package/dist/engineAgentPanelStore.d.ts +12 -4
- package/dist/engineAgentPanelStore.js +16 -11
- package/dist/engineCapReader.d.ts +2 -5
- package/dist/engineCapReader.js +8 -10
- package/dist/engineCapsCache.d.ts +12 -0
- package/dist/engineCapsCache.js +76 -18
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineClosedSets.d.ts +1 -0
- package/dist/engineClosedSets.js +4 -1
- package/dist/engineErrorCodes.d.ts +11 -3
- package/dist/engineErrorCodes.js +11 -8
- package/dist/engineIdentity.d.ts +1 -0
- package/dist/engineIdentity.js +8 -0
- package/dist/engineRowRef.d.ts +28 -0
- package/dist/engineRowRef.js +114 -0
- package/dist/engineSessionMessages.d.ts +68 -0
- package/dist/engineSessionMessages.js +370 -0
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineToolDirectory.d.ts +0 -9
- package/dist/engineToolDirectory.js +1 -94
- package/dist/engineUrl.d.ts +18 -0
- package/dist/engineUrl.js +52 -0
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +11 -1
- package/dist/env/uiLanguage.js +38 -2
- package/dist/eventLeg.d.ts +100 -0
- package/dist/eventLeg.js +305 -0
- package/dist/executionLaneCapability.d.ts +0 -4
- package/dist/executionLaneCapability.js +3 -16
- package/dist/fileHistoryCaptureCapability.d.ts +2 -5
- package/dist/fileHistoryCaptureCapability.js +13 -21
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/fleet/fleetLedger.d.ts +0 -3
- package/dist/fleet/fleetLedger.js +21 -36
- package/dist/fleet/fleetProjection.d.ts +2 -2
- package/dist/fleet/fleetProjection.js +10 -8
- package/dist/frameBinding.d.ts +8 -0
- package/dist/frameBinding.js +35 -0
- package/dist/gateFailureCodes.d.ts +2 -0
- package/dist/gateFailureCodes.js +15 -0
- package/dist/gateOutcome.d.ts +3 -1
- package/dist/gateOutcome.js +41 -8
- package/dist/gateVocabulary.d.ts +10 -4
- package/dist/gateVocabulary.js +107 -47
- package/dist/generated/engineAskFaceTables.js +2 -2
- package/dist/generated/engineFactTables.d.ts +22 -3
- package/dist/generated/engineFactTables.js +51 -4
- package/dist/generated/engineNoticeTables.js +18 -3
- package/dist/generated/settingsSchemaFns.d.ts +6 -0
- package/dist/generated/settingsSchemaFns.js +57 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaTables.d.ts +1 -0
- package/dist/generated/settingsSchemaTables.js +4 -0
- package/dist/generated/settingsSchemaTypes.d.ts +105 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +8 -2
- package/dist/hitl/allowRuleShadow.js +36 -29
- package/dist/hitl/approvalCardReading.d.ts +15 -0
- package/dist/hitl/approvalCardReading.js +154 -0
- package/dist/hitl/approvalCardReasons.d.ts +14 -0
- package/dist/hitl/approvalCardReasons.js +119 -0
- package/dist/hitl/approvalHolds.d.ts +50 -15
- package/dist/hitl/approvalHolds.js +177 -27
- package/dist/hitl/approvalResolution.d.ts +51 -26
- package/dist/hitl/approvalResolution.js +86 -122
- package/dist/hitl/approvalsFeed.js +6 -18
- package/dist/hitl/askClassPair.d.ts +2 -0
- package/dist/hitl/askClassPair.js +17 -0
- package/dist/hitl/askGateWire.d.ts +20 -2
- package/dist/hitl/askGateWire.js +50 -1
- package/dist/hitl/askParkRowRouting.d.ts +5 -0
- package/dist/hitl/askParkRowRouting.js +32 -1
- package/dist/hitl/askSettlementLine.d.ts +28 -0
- package/dist/hitl/askSettlementLine.js +99 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +3 -2
- package/dist/hitl/automaticAnswerVerdict.js +29 -13
- package/dist/hitl/crashConverged.d.ts +11 -20
- package/dist/hitl/crashConverged.js +56 -0
- package/dist/hitl/crashConvergedNotice.d.ts +6 -3
- package/dist/hitl/crashConvergedNotice.js +48 -24
- package/dist/hitl/decisionConflict.js +3 -10
- package/dist/hitl/decisionRefusal.d.ts +40 -1
- package/dist/hitl/decisionRefusal.js +199 -42
- package/dist/hitl/frameRouter.d.ts +5 -2
- package/dist/hitl/frameRouter.js +27 -24
- package/dist/hitl/gateLedger.d.ts +2 -0
- package/dist/hitl/gateLedger.js +50 -13
- package/dist/hitl/hitlBridge.d.ts +2 -2
- package/dist/hitl/hitlBridge.js +13 -10
- package/dist/hitl/livePendingAsk.d.ts +3 -3
- package/dist/hitl/livePendingAsk.js +7 -18
- package/dist/hitl/parkResolver.d.ts +2 -24
- package/dist/hitl/parkResolver.js +61 -97
- package/dist/hitl/persistedRulesWire.d.ts +25 -0
- package/dist/hitl/persistedRulesWire.js +104 -2
- package/dist/hitl/planReviewWire.d.ts +31 -13
- package/dist/hitl/planReviewWire.js +120 -78
- package/dist/hitl/refusedToolNameProse.d.ts +0 -1
- package/dist/hitl/refusedToolNameProse.js +0 -3
- package/dist/hitl/replayedApproval.d.ts +4 -3
- package/dist/hitl/replayedApproval.js +7 -4
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +48 -7
- package/dist/hitl/sessionPolicyWire.d.ts +34 -21
- package/dist/hitl/sessionPolicyWire.js +179 -70
- package/dist/hitl/standingRows.d.ts +20 -2
- package/dist/hitl/standingRows.js +69 -8
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +103 -156
- package/dist/hitl/toolApprovalWire.js +661 -411
- package/dist/hookMatcherVerdict.d.ts +6 -1
- package/dist/hookMatcherVerdict.js +14 -7
- package/dist/hooksWireCaps.d.ts +2 -2
- package/dist/hooksWireCaps.js +174 -81
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +71 -0
- package/dist/hostTurnSettings.js +291 -0
- package/dist/humanTurn.d.ts +14 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +703 -0
- package/dist/i18n/messages.en.js +701 -0
- package/dist/i18n/messages.zh.d.ts +3 -0
- package/dist/i18n/messages.zh.js +837 -0
- package/dist/i18n/translate.d.ts +25 -0
- package/dist/i18n/translate.js +127 -0
- package/dist/index.d.ts +78 -29
- package/dist/index.js +54 -18
- package/dist/inheritEnvCapability.d.ts +32 -0
- package/dist/inheritEnvCapability.js +104 -0
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +12 -14
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +3 -3
- package/dist/liveModelCatalog.js +15 -13
- package/dist/liveQuestionStore.d.ts +2 -21
- package/dist/mcpLiveness.d.ts +2 -1
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +40 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +9 -2
- package/dist/mcpProbeWire.js +6 -1
- package/dist/mcpWireCaps.d.ts +47 -2
- package/dist/mcpWireCaps.js +164 -16
- package/dist/memoryEntriesWire.d.ts +4 -9
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/modelSupplyRules.d.ts +0 -2
- package/dist/model/modelSupplyRules.js +3 -12
- package/dist/model/modelsPolicy.d.ts +0 -5
- package/dist/model/modelsPolicy.js +6 -36
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/subagentModelWord.d.ts +31 -0
- package/dist/model/subagentModelWord.js +261 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +64 -0
- package/dist/modelCapabilityProbe.js +600 -0
- package/dist/modelIdentityResolvability.d.ts +3 -0
- package/dist/modelIdentityResolvability.js +26 -17
- package/dist/notifications.d.ts +6 -0
- package/dist/notifications.js +71 -23
- package/dist/outputStyleSeatCapability.d.ts +0 -3
- package/dist/outputStyleSeatCapability.js +0 -3
- package/dist/ownKey.d.ts +22 -0
- package/dist/ownKey.js +94 -3
- package/dist/panelReduce.d.ts +21 -10
- package/dist/panelReduce.js +728 -550
- package/dist/panelStateHolder.d.ts +3 -7
- package/dist/panelStateHolder.js +14 -130
- package/dist/peerLaneCapability.d.ts +0 -4
- package/dist/peerLaneCapability.js +0 -6
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.d.ts +2 -5
- package/dist/permissionRulesWriteCapability.js +8 -12
- package/dist/permissionWireCaps.d.ts +2 -2
- package/dist/permissionWireCaps.js +2 -0
- package/dist/permissionsAllowGrantCapability.d.ts +0 -4
- package/dist/permissionsAllowGrantCapability.js +0 -6
- package/dist/permissionsDeclaration.d.ts +0 -11
- package/dist/permissionsDeclaration.js +60 -53
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +219 -16
- package/dist/preemptWire.d.ts +44 -0
- package/dist/preemptWire.js +83 -0
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/printToolResultFrame.js +15 -4
- package/dist/replayBody.d.ts +3 -0
- package/dist/replayBody.js +14 -0
- package/dist/request/taskRequest.d.ts +11 -6
- package/dist/request/taskRequest.js +112 -19
- package/dist/resumeRefusalCopy.d.ts +13 -9
- package/dist/resumeRefusalCopy.js +81 -118
- package/dist/retryStatus.d.ts +45 -0
- package/dist/retryStatus.js +185 -1
- package/dist/rewindArchiveCapability.d.ts +0 -4
- package/dist/rewindArchiveCapability.js +2 -10
- package/dist/rewindArchiveReading.d.ts +0 -1
- package/dist/rewindArchiveReading.js +0 -3
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +4 -2
- package/dist/runReattachPolicy.d.ts +31 -0
- package/dist/runReattachPolicy.js +46 -0
- package/dist/runTerminal.d.ts +3 -6
- package/dist/runTerminal.js +8 -9
- package/dist/sandboxWire.d.ts +3 -1
- package/dist/sandboxWire.js +76 -27
- package/dist/scenarioRefusal.d.ts +9 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/scenarioWire.js +1 -1
- package/dist/seam.d.ts +48 -2
- package/dist/seam.js +25 -4
- package/dist/seatContract.d.ts +311 -18
- package/dist/seatContract.js +824 -100
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -5
- package/dist/sessionPolicyCapability.js +8 -12
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
- package/dist/sessionSyncFileHistoryCapability.js +0 -3
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -4
- package/dist/skillToolListsCapability.js +8 -9
- package/dist/sqlEngineCapability.d.ts +0 -4
- package/dist/sqlEngineCapability.js +0 -6
- package/dist/sseIdleTriage.js +3 -2
- package/dist/steerPriorityCapability.d.ts +0 -3
- package/dist/steerPriorityCapability.js +0 -3
- package/dist/streamDrainingLegs.d.ts +4 -0
- package/dist/streamDrainingLegs.js +6 -1
- package/dist/subagent/engineCompactWire.d.ts +0 -1
- package/dist/subagent/engineCompactWire.js +7 -5
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagent/engineTaskHandleWire.js +4 -7
- package/dist/subagentContentStore.d.ts +3 -0
- package/dist/subagentContentStore.js +22 -10
- package/dist/submitReopen.d.ts +24 -0
- package/dist/submitReopen.js +75 -0
- package/dist/terminalStatuses.d.ts +3 -0
- package/dist/terminalStatuses.js +10 -2
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolResult.d.ts +10 -1
- package/dist/toolResult.js +34 -6
- package/dist/toolRoster.d.ts +3 -4
- package/dist/toolRoster.js +21 -22
- package/dist/turnFailurePresentation.d.ts +39 -0
- package/dist/turnFailurePresentation.js +402 -0
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -4
- package/dist/userInvokedSkillsCapability.js +31 -10
- package/dist/webSearchBackendCapability.d.ts +0 -4
- package/dist/webSearchBackendCapability.js +0 -6
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +26 -23
- package/dist/wireFailureShape.d.ts +62 -5
- package/dist/wireFailureShape.js +106 -5
- package/dist/wireRefusalCopy.d.ts +25 -3
- package/dist/wireRefusalCopy.js +74 -80
- package/dist/workflowsJournalCapability.d.ts +2 -5
- package/dist/workflowsJournalCapability.js +8 -12
- package/dist/writeProtectionCapability.d.ts +0 -4
- package/dist/writeProtectionCapability.js +0 -6
- package/docs/INTEGRATION-CLIENTS.md +1775 -56
- package/package.json +6 -5
- package/dist/attachmentSeatCapability.d.ts +0 -12
- package/dist/attachmentSeatCapability.js +0 -23
- package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
- package/dist/hitl/approvalOutcomeNote.js +0 -29
- package/dist/sessionReadRedactionCapability.d.ts +0 -13
- package/dist/sessionReadRedactionCapability.js +0 -35
package/dist/eventLeg.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { approvalFrameContextOfFrame, frameBindingOf, registerApprovalFrameContext, registerFrameBinding } from './frameBinding.js';
|
|
2
|
+
import { bridgeAskUserQuestionGates } from './hitl/askGateWire.js';
|
|
3
|
+
import { diagnoseSseIdleTear } from './sseIdleTriage.js';
|
|
4
|
+
import { recordSubagentOwnerFromProgress } from './subagentContentStore.js';
|
|
5
|
+
import { activeRunBusySignal } from './adapter/runStream.js';
|
|
6
|
+
import { invokeHostCallbackIsolated } from './hostCallbackGuard.js';
|
|
7
|
+
import { hostLog } from './host.js';
|
|
8
|
+
import { guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
|
|
9
|
+
import { settleEngineClosedApproval } from './hitl/approvalHolds.js';
|
|
10
|
+
import { approvalCompleteParked } from './hitl/approvalCompleteParked.js';
|
|
11
|
+
export const EVENT_LEG_KINDS = Object.freeze(['live', 'durable', 'continuation']);
|
|
12
|
+
export const EVENT_LEG_TABLE = Object.freeze({
|
|
13
|
+
live: Object.freeze({ stages: Object.freeze(['bindRun', 'stampOwner', 'hitlFrames', 'askBridge', 'idleTriage']), windowIsCurrent: true }),
|
|
14
|
+
durable: Object.freeze({ stages: Object.freeze(['bindRun', 'stampOwner', 'hitlFrames', 'askBridge']), windowIsCurrent: false }),
|
|
15
|
+
continuation: Object.freeze({ stages: Object.freeze(['bindRun', 'stampOwner', 'hitlFrames']), windowIsCurrent: false }),
|
|
16
|
+
});
|
|
17
|
+
function makeFrameStageDomains(domains) {
|
|
18
|
+
return Object.freeze(domains);
|
|
19
|
+
}
|
|
20
|
+
const FRAME_STAGE_DOMAINS = makeFrameStageDomains({
|
|
21
|
+
bindRun: Object.freeze(['meta', 'done', 'failed']),
|
|
22
|
+
stampOwner: Object.freeze(['task_progress']),
|
|
23
|
+
hitlFrames: Object.freeze(['question', 'question_complete', 'elicitation', 'elicitation_complete', 'tool_approval', 'tool_approval_complete', 'approval_request', 'approval_revoke']),
|
|
24
|
+
});
|
|
25
|
+
const HITL_PORT_OF = Object.freeze({
|
|
26
|
+
question: 'question',
|
|
27
|
+
question_complete: 'question',
|
|
28
|
+
elicitation: 'elicitation',
|
|
29
|
+
elicitation_complete: 'elicitation',
|
|
30
|
+
tool_approval: 'toolApproval',
|
|
31
|
+
tool_approval_complete: 'toolApproval',
|
|
32
|
+
approval_request: 'register',
|
|
33
|
+
approval_revoke: 'register',
|
|
34
|
+
});
|
|
35
|
+
const inDomain = (stage, frameType) => FRAME_STAGE_DOMAINS[stage].includes(frameType);
|
|
36
|
+
export function approvalFrameContextOf(arm) {
|
|
37
|
+
const frame = guardedRead(() => readOwnDataValue(arm, 'frame'));
|
|
38
|
+
return typeof frame === 'object' && frame !== null ? approvalFrameContextOfFrame(frame) : undefined;
|
|
39
|
+
}
|
|
40
|
+
const HOST_PORT_MISSING = 'host_port_missing';
|
|
41
|
+
export function composeEventLeg(source, leg, ports) {
|
|
42
|
+
const kind = leg.kind;
|
|
43
|
+
if (!EVENT_LEG_KINDS.includes(kind))
|
|
44
|
+
throw new TypeError(`composeEventLeg: unknown leg kind ${JSON.stringify(kind)}`);
|
|
45
|
+
const legRunId = kind === 'live' ? undefined : leg.runId;
|
|
46
|
+
if (kind !== 'live' && (typeof legRunId !== 'string' || legRunId === ''))
|
|
47
|
+
throw new TypeError(`composeEventLeg: a ${kind} leg needs a non-empty runId`);
|
|
48
|
+
const row = EVENT_LEG_TABLE[kind];
|
|
49
|
+
const stageOn = (s) => row.stages.includes(s);
|
|
50
|
+
const hostBridge = stageOn('askBridge') && typeof ports.askBridge === 'object' && ports.askBridge !== null ? ports.askBridge : undefined;
|
|
51
|
+
const hitl = ports.hitl;
|
|
52
|
+
const required = [];
|
|
53
|
+
if (typeof hitl?.question !== 'function')
|
|
54
|
+
required.push('hitl.question');
|
|
55
|
+
if (typeof hitl?.elicitation !== 'function')
|
|
56
|
+
required.push('hitl.elicitation');
|
|
57
|
+
if (hostBridge === undefined && typeof hitl?.toolApproval !== 'function')
|
|
58
|
+
required.push('hitl.toolApproval');
|
|
59
|
+
if (hostBridge !== undefined && typeof hostBridge.respondToolApproval !== 'function')
|
|
60
|
+
required.push('askBridge.respondToolApproval');
|
|
61
|
+
if (required.length > 0) {
|
|
62
|
+
throw Object.assign(new Error(`composeEventLeg: host port missing — ${required.join(', ')}`), { code: HOST_PORT_MISSING, ports: Object.freeze([...required]) });
|
|
63
|
+
}
|
|
64
|
+
const runPorts = ports.run;
|
|
65
|
+
const missingPorts = [];
|
|
66
|
+
if (typeof runPorts?.onBound !== 'function')
|
|
67
|
+
missingPorts.push('run.onBound');
|
|
68
|
+
if (typeof runPorts?.onTerminal !== 'function')
|
|
69
|
+
missingPorts.push('run.onTerminal');
|
|
70
|
+
const portFaults = {};
|
|
71
|
+
let hitlUndelivered = 0;
|
|
72
|
+
const fault = (name, why) => {
|
|
73
|
+
portFaults[name] = (portFaults[name] ?? 0) + 1;
|
|
74
|
+
hostLog('debug', `eventLeg: host port ${name} faulted — ${why.slice(0, 160)}`);
|
|
75
|
+
};
|
|
76
|
+
const callPort = (name, call) => {
|
|
77
|
+
let threw = false;
|
|
78
|
+
invokeHostCallbackIsolated(`eventLeg: ${name}`, () => {
|
|
79
|
+
try {
|
|
80
|
+
return call();
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
threw = true;
|
|
84
|
+
portFaults[name] = (portFaults[name] ?? 0) + 1;
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return threw;
|
|
89
|
+
};
|
|
90
|
+
const isCurrentNow = () => {
|
|
91
|
+
if (runPorts === undefined)
|
|
92
|
+
return true;
|
|
93
|
+
try {
|
|
94
|
+
const port = runPorts.isCurrent;
|
|
95
|
+
if (port === undefined)
|
|
96
|
+
return true;
|
|
97
|
+
if (typeof port !== 'function') {
|
|
98
|
+
fault('run.isCurrent', `not a function (${typeof port})`);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return port.call(runPorts) === true;
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
fault('run.isCurrent', String(e));
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const readHeaderRunId = () => {
|
|
109
|
+
if (runPorts === undefined)
|
|
110
|
+
return undefined;
|
|
111
|
+
try {
|
|
112
|
+
const port = runPorts.headerRunId;
|
|
113
|
+
if (port === undefined)
|
|
114
|
+
return undefined;
|
|
115
|
+
if (typeof port !== 'function') {
|
|
116
|
+
fault('run.headerRunId', `not a function (${typeof port})`);
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const v = port.call(runPorts);
|
|
120
|
+
if (typeof v === 'string' && v !== '')
|
|
121
|
+
return v;
|
|
122
|
+
if (v !== undefined && v !== '')
|
|
123
|
+
fault('run.headerRunId', `returned ${typeof v}`);
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
fault('run.headerRunId', String(e));
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const sessionKey = typeof ports.owner?.sessionKey === 'string' && ports.owner.sessionKey !== '' ? ports.owner.sessionKey : undefined;
|
|
132
|
+
const taps = (ports.taps ?? []).filter((t) => typeof t === 'function');
|
|
133
|
+
const decorators = (ports.perStream ?? []).filter((d) => typeof d === 'function');
|
|
134
|
+
const info = Object.freeze({ leg: kind });
|
|
135
|
+
const runSessions = new Map();
|
|
136
|
+
let lastBound;
|
|
137
|
+
const noteBound = (binding) => {
|
|
138
|
+
if (lastBound !== undefined && lastBound.taskId === binding.taskId && lastBound.sessionId === binding.sessionId)
|
|
139
|
+
return;
|
|
140
|
+
const cause = lastBound === undefined ? 'open' : lastBound.taskId !== binding.taskId ? 'handoff' : 'frame';
|
|
141
|
+
lastBound = binding;
|
|
142
|
+
if (runPorts === undefined || typeof runPorts.onBound !== 'function' || !isCurrentNow())
|
|
143
|
+
return;
|
|
144
|
+
const boundInfo = Object.freeze({ cause, leg: kind });
|
|
145
|
+
callPort('run.onBound', () => runPorts.onBound?.(binding, boundInfo));
|
|
146
|
+
};
|
|
147
|
+
const deliverHitl = (ev, env, streamEnded) => {
|
|
148
|
+
if (!inDomain('hitlFrames', ev.type))
|
|
149
|
+
return false;
|
|
150
|
+
const port = HITL_PORT_OF[ev.type];
|
|
151
|
+
if (port === 'register') {
|
|
152
|
+
registerApprovalFrameContext(ev, Object.freeze({ leg: env.leg, windowIsCurrent: env.windowIsCurrent, receivedAtMs: Date.now(), streamEnded }));
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
if (port === 'toolApproval' && hostBridge !== undefined)
|
|
156
|
+
return false;
|
|
157
|
+
if (ev.type === 'tool_approval_complete')
|
|
158
|
+
settleEngineClosedApproval(ev, approvalCompleteParked(ev));
|
|
159
|
+
const threw = callPort(`hitl.${port}`, () => hitl?.[port]?.call(hitl, ev, env));
|
|
160
|
+
if (threw)
|
|
161
|
+
hitlUndelivered++;
|
|
162
|
+
return true;
|
|
163
|
+
};
|
|
164
|
+
async function* frameLevel(stream, streamKind, streamRunId) {
|
|
165
|
+
let taskId = streamRunId;
|
|
166
|
+
let sessionId = streamRunId !== undefined ? runSessions.get(streamRunId) : undefined;
|
|
167
|
+
let binding;
|
|
168
|
+
let runEvidence = false;
|
|
169
|
+
const env = Object.freeze({ windowIsCurrent: EVENT_LEG_TABLE[streamKind].windowIsCurrent, leg: streamKind });
|
|
170
|
+
const ended = new AbortController();
|
|
171
|
+
try {
|
|
172
|
+
for await (const ev of stream) {
|
|
173
|
+
if (taskId === undefined && streamKind === 'live')
|
|
174
|
+
taskId = readHeaderRunId();
|
|
175
|
+
const refusal = streamKind === 'live' && !runEvidence && inDomain('bindRun', ev.type) ? refusalOf(ev, taskId) : undefined;
|
|
176
|
+
if (!inDomain('bindRun', ev.type))
|
|
177
|
+
runEvidence = true;
|
|
178
|
+
if (refusal !== undefined) {
|
|
179
|
+
if (runPorts !== undefined && typeof runPorts.onRefused === 'function' && isCurrentNow())
|
|
180
|
+
callPort('run.onRefused', () => runPorts.onRefused?.(refusal, info));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
if (ev.type === 'meta' || ev.type === 'done') {
|
|
184
|
+
const carrier = ev.type === 'meta' ? ev : ev.result;
|
|
185
|
+
const tid = typeof carrier === 'object' && carrier !== null ? guardedRead(() => readOwnDataNonEmptyString(carrier, 'taskId')) : undefined;
|
|
186
|
+
const sid = typeof carrier === 'object' && carrier !== null ? guardedRead(() => readOwnDataNonEmptyString(carrier, 'sessionId')) : undefined;
|
|
187
|
+
const runId = ev.type === 'done' && tid !== undefined && tid === sid ? undefined : tid;
|
|
188
|
+
if (streamKind === 'live' && runId !== undefined && runId !== taskId) {
|
|
189
|
+
taskId = runId;
|
|
190
|
+
sessionId = sid;
|
|
191
|
+
}
|
|
192
|
+
else if (sid !== undefined && taskId !== undefined && (runId === undefined || runId === taskId)) {
|
|
193
|
+
sessionId = sid;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (taskId !== undefined) {
|
|
197
|
+
if (binding === undefined || binding.taskId !== taskId || binding.sessionId !== sessionId) {
|
|
198
|
+
binding = Object.freeze({ taskId, ...(sessionId !== undefined ? { sessionId } : {}) });
|
|
199
|
+
}
|
|
200
|
+
if (sessionId !== undefined)
|
|
201
|
+
runSessions.set(taskId, sessionId);
|
|
202
|
+
registerFrameBinding(ev, binding);
|
|
203
|
+
noteBound(binding);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (inDomain('stampOwner', ev.type)) {
|
|
207
|
+
const b = frameBindingOf(ev);
|
|
208
|
+
recordSubagentOwnerFromProgress(ev, b?.taskId, b?.sessionId, sessionKey);
|
|
209
|
+
}
|
|
210
|
+
if (deliverHitl(ev, env, ended.signal))
|
|
211
|
+
continue;
|
|
212
|
+
for (const tap of taps)
|
|
213
|
+
callPort('taps', () => tap(ev));
|
|
214
|
+
yield ev;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
ended.abort();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const streamOf = (raw, streamKind, streamRunId) => {
|
|
222
|
+
let s = generatorOf(raw);
|
|
223
|
+
const ctx = Object.freeze({ leg: streamKind, runId: streamRunId });
|
|
224
|
+
for (const d of decorators)
|
|
225
|
+
s = d(s, ctx);
|
|
226
|
+
return frameLevel(s, streamKind, streamRunId);
|
|
227
|
+
};
|
|
228
|
+
let inner = streamOf(source, kind, legRunId);
|
|
229
|
+
if (hostBridge !== undefined) {
|
|
230
|
+
let windowOpen = row.windowIsCurrent;
|
|
231
|
+
const runsEvents = (taskId, opts) => {
|
|
232
|
+
windowOpen = false;
|
|
233
|
+
return streamOf(hostBridge.runsEvents(taskId, opts), 'continuation', taskId);
|
|
234
|
+
};
|
|
235
|
+
const deps = hostView(hostBridge, {
|
|
236
|
+
runsEvents: () => runsEvents,
|
|
237
|
+
approvalLane: () => {
|
|
238
|
+
const lane = hostBridge.approvalLane;
|
|
239
|
+
return typeof lane === 'object' && lane !== null ? hostView(lane, { windowIsCurrent: () => windowOpen }) : Object.freeze({ windowIsCurrent: windowOpen });
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
inner = bridgeAskUserQuestionGates(inner, deps, { ...(ports.signal !== undefined ? { signal: ports.signal } : {}), ...(legRunId !== undefined ? { taskId: legRunId } : {}) });
|
|
243
|
+
}
|
|
244
|
+
const baseUrl = ports.idleTriage?.baseUrl;
|
|
245
|
+
if (stageOn('idleTriage') && typeof baseUrl === 'string' && baseUrl !== '')
|
|
246
|
+
inner = diagnoseSseIdleTear(inner, baseUrl, ports.signal);
|
|
247
|
+
async function* exit(stream) {
|
|
248
|
+
for await (const ev of stream) {
|
|
249
|
+
if ((ev.type === 'done' || ev.type === 'failed') && runPorts !== undefined && typeof runPorts.onTerminal === 'function' && isCurrentNow()) {
|
|
250
|
+
const binding = frameBindingOf(ev);
|
|
251
|
+
callPort('run.onTerminal', () => runPorts.onTerminal?.(ev, binding, info));
|
|
252
|
+
}
|
|
253
|
+
yield ev;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return Object.freeze({
|
|
257
|
+
events: exit(inner),
|
|
258
|
+
report: () => Object.freeze({ missingPorts: Object.freeze([...missingPorts]), portFaults: Object.freeze({ ...portFaults }), hitlUndelivered }),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function refusalOf(ev, candidateRunId) {
|
|
262
|
+
if (ev.type !== 'done' && ev.type !== 'failed')
|
|
263
|
+
return undefined;
|
|
264
|
+
const candidate = candidateRunId !== undefined ? { candidateRunId } : {};
|
|
265
|
+
const busy = activeRunBusySignal(ev);
|
|
266
|
+
if (busy !== null)
|
|
267
|
+
return Object.freeze({ kind: 'busy', ...candidate, busy });
|
|
268
|
+
if (ev.type !== 'done')
|
|
269
|
+
return undefined;
|
|
270
|
+
const r = guardedRead(() => readOwnDataValue(ev, 'result'));
|
|
271
|
+
if (typeof r !== 'object' || r === null || Array.isArray(r))
|
|
272
|
+
return undefined;
|
|
273
|
+
if (guardedRead(() => readOwnDataNonEmptyString(r, 'status')) !== 'failed')
|
|
274
|
+
return undefined;
|
|
275
|
+
for (const k of ['taskId', 'stats', 'terminal', 'activeTaskId'])
|
|
276
|
+
if (guardedRead(() => Object.hasOwn(r, k)) !== false)
|
|
277
|
+
return undefined;
|
|
278
|
+
const errorCode = guardedRead(() => readOwnDataNonEmptyString(r, 'errorCode'));
|
|
279
|
+
if (errorCode === undefined || guardedRead(() => readOwnDataNonEmptyString(r, 'errorMessage')) === undefined)
|
|
280
|
+
return undefined;
|
|
281
|
+
return Object.freeze({ kind: 'not_created', ...candidate, errorCode });
|
|
282
|
+
}
|
|
283
|
+
function hostView(host, overrides) {
|
|
284
|
+
const replaced = (k) => typeof k === 'string' && Object.hasOwn(overrides, k);
|
|
285
|
+
const valueOf = (k) => overrides[k]?.();
|
|
286
|
+
return new Proxy(Object.create(null), {
|
|
287
|
+
get(_t, k) {
|
|
288
|
+
if (replaced(k))
|
|
289
|
+
return valueOf(k);
|
|
290
|
+
const v = Reflect.get(host, k, host);
|
|
291
|
+
return typeof v === 'function' ? v.bind(host) : v;
|
|
292
|
+
},
|
|
293
|
+
has: (_t, k) => replaced(k) || Reflect.has(host, k),
|
|
294
|
+
getOwnPropertyDescriptor(_t, k) {
|
|
295
|
+
if (replaced(k))
|
|
296
|
+
return { value: valueOf(k), writable: false, enumerable: true, configurable: true };
|
|
297
|
+
const d = Reflect.getOwnPropertyDescriptor(host, k);
|
|
298
|
+
return d === undefined ? undefined : { ...d, configurable: true };
|
|
299
|
+
},
|
|
300
|
+
ownKeys: () => [...new Set([...Reflect.ownKeys(host), ...Object.keys(overrides)])],
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
async function* generatorOf(raw) {
|
|
304
|
+
yield* raw;
|
|
305
|
+
}
|
|
@@ -17,12 +17,8 @@ export type ExecutionLaneReading = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare function projectExecutionLaneCapability(caps: unknown): ExecutionLaneReading | undefined;
|
|
19
19
|
export declare function projectExecutionLaneWiring(wiring: unknown): ExecutionLaneReading | undefined;
|
|
20
|
-
export declare function noteEngineCapsForExecutionLane(baseUrl: string, caps: unknown, opts?: {
|
|
21
|
-
generation?: number;
|
|
22
|
-
}): void;
|
|
23
20
|
export declare function observedExecutionLane(baseUrl?: string | undefined): ExecutionLaneReading;
|
|
24
21
|
export declare function toolsRunHereFromExecutionLane(reading: ExecutionLaneReading): boolean;
|
|
25
22
|
export declare function noOsSandboxOnThisHost(reading: ExecutionLaneReading): 'yes' | 'no' | 'unknown';
|
|
26
23
|
export declare function noOsSandboxContent(): string;
|
|
27
24
|
export declare function executionLaneDoctorDetail(reading: ExecutionLaneReading): string;
|
|
28
|
-
export declare function __resetExecutionLaneReadingsForTests(): void;
|
|
@@ -26,17 +26,10 @@ function projectExecutionLaneObject(lane) {
|
|
|
26
26
|
return undefined;
|
|
27
27
|
if (typeof toolsOnThisHost !== 'boolean')
|
|
28
28
|
return undefined;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
isolated = ownDataField(lane, 'isolated');
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
isolatedThrew = true;
|
|
36
|
-
}
|
|
37
|
-
if (!isolatedThrew && typeof isolated === 'boolean')
|
|
29
|
+
const isolated = ownDataField(lane, 'isolated');
|
|
30
|
+
if (typeof isolated === 'boolean')
|
|
38
31
|
return { kind: 'present', view: { provider, toolsOnThisHost, isolated } };
|
|
39
|
-
const isolatedAbsent =
|
|
32
|
+
const isolatedAbsent = isolated !== undefined ? 'unreadable' : toolsOnThisHost ? 'unreadable' : 'no_hands';
|
|
40
33
|
return { kind: 'present', view: { provider, toolsOnThisHost, isolatedAbsent } };
|
|
41
34
|
}
|
|
42
35
|
export function projectExecutionLaneWiring(wiring) {
|
|
@@ -56,9 +49,6 @@ const reader = createEngineCapReader({
|
|
|
56
49
|
name: 'executionLane',
|
|
57
50
|
project: projectExecutionLaneCapability,
|
|
58
51
|
});
|
|
59
|
-
export function noteEngineCapsForExecutionLane(baseUrl, caps, opts) {
|
|
60
|
-
reader.note(baseUrl, caps, opts);
|
|
61
|
-
}
|
|
62
52
|
export function observedExecutionLane(baseUrl = engineWireTarget()?.baseUrl) {
|
|
63
53
|
return reader.observed(baseUrl);
|
|
64
54
|
}
|
|
@@ -117,6 +107,3 @@ export function executionLaneDoctorDetail(reading) {
|
|
|
117
107
|
}
|
|
118
108
|
}
|
|
119
109
|
}
|
|
120
|
-
export function __resetExecutionLaneReadingsForTests() {
|
|
121
|
-
reader.__resetForTests();
|
|
122
|
-
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
1
2
|
export type FileHistoryCaptureReading = {
|
|
2
3
|
kind: 'unobserved';
|
|
3
4
|
} | {
|
|
@@ -10,9 +11,6 @@ export type FileHistoryCaptureReading = {
|
|
|
10
11
|
};
|
|
11
12
|
export type FileHistoryCaptureMode = 'off' | 'on-optional' | 'unknown';
|
|
12
13
|
export declare function projectFileHistoryCaptureCapability(caps: unknown): FileHistoryCaptureReading | undefined;
|
|
13
|
-
export declare function noteEngineCapsForFileHistoryCapture(baseUrl: string, caps: unknown, opts?: {
|
|
14
|
-
generation?: number;
|
|
15
|
-
}): void;
|
|
16
14
|
export declare function observedFileHistoryCapture(baseUrl?: string | undefined): FileHistoryCaptureReading;
|
|
17
15
|
export declare function fileHistoryCaptureMode(reading: FileHistoryCaptureReading): FileHistoryCaptureMode;
|
|
18
16
|
export declare function fileHistoryDeclarationField(reading: FileHistoryCaptureReading, captureOff: boolean): {
|
|
@@ -21,7 +19,7 @@ export declare function fileHistoryDeclarationField(reading: FileHistoryCaptureR
|
|
|
21
19
|
export declare const FILE_HISTORY_TIGHTEN_VERDICTS: readonly ["not_requested", "declare", "already_off", "unjudged"];
|
|
22
20
|
export type FileHistoryTightenVerdict = (typeof FILE_HISTORY_TIGHTEN_VERDICTS)[number];
|
|
23
21
|
export declare function fileHistoryTightenVerdict(reading: FileHistoryCaptureReading, captureOffByUser: boolean): FileHistoryTightenVerdict;
|
|
24
|
-
export declare function fileHistoryUnjudgedRefusal(reading: FileHistoryCaptureReading, captureOffByUser: boolean): string | undefined;
|
|
22
|
+
export declare function fileHistoryUnjudgedRefusal(reading: FileHistoryCaptureReading, captureOffByUser: boolean, lang?: UiLanguage): string | undefined;
|
|
25
23
|
export interface FileHistoryTightenJudgement {
|
|
26
24
|
readonly verdict: FileHistoryTightenVerdict;
|
|
27
25
|
readonly reading: FileHistoryCaptureReading;
|
|
@@ -33,4 +31,3 @@ export declare function judgeFileHistoryTighten(captureOffByUser: boolean, opts?
|
|
|
33
31
|
withinMs?: number;
|
|
34
32
|
}): Promise<FileHistoryTightenJudgement>;
|
|
35
33
|
export declare function fileHistoryCaptureDoctorDetail(reading: FileHistoryCaptureReading): string;
|
|
36
|
-
export declare function __resetFileHistoryCaptureReadingsForTests(): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
1
2
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
2
3
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
3
4
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
@@ -23,9 +24,6 @@ const reader = createEngineCapReader({
|
|
|
23
24
|
name: 'fileHistoryCapture',
|
|
24
25
|
project: projectFileHistoryCaptureCapability,
|
|
25
26
|
});
|
|
26
|
-
export function noteEngineCapsForFileHistoryCapture(baseUrl, caps, opts) {
|
|
27
|
-
reader.note(baseUrl, caps, opts);
|
|
28
|
-
}
|
|
29
27
|
export function observedFileHistoryCapture(baseUrl = engineWireTarget()?.baseUrl) {
|
|
30
28
|
return reader.observed(baseUrl);
|
|
31
29
|
}
|
|
@@ -63,17 +61,11 @@ export function fileHistoryTightenVerdict(reading, captureOffByUser) {
|
|
|
63
61
|
return 'already_off';
|
|
64
62
|
return 'unjudged';
|
|
65
63
|
}
|
|
66
|
-
const FILE_HISTORY_REFUSAL_NOT_YET =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
'while this engine reports the same; to send and let file history be recorded this time, turn file checkpointing back on in your settings.';
|
|
72
|
-
const FILE_HISTORY_REFUSAL_UNREADABLE = "Nothing was sent: file checkpointing is turned off in your settings, but this engine's report on whether it can stop " +
|
|
73
|
-
'recording file history for a session could not be read by this client, so sending now could record it anyway. Trying ' +
|
|
74
|
-
'again will not change that while this engine reports the same; to send and let file history be recorded this time, ' +
|
|
75
|
-
'turn file checkpointing back on in your settings.';
|
|
76
|
-
function unjudgedRefusalOf(reading) {
|
|
64
|
+
const FILE_HISTORY_REFUSAL_NOT_YET = 'session.fileHistoryRefusal.notYet';
|
|
65
|
+
const FILE_HISTORY_REFUSAL_NOT_SAID = 'session.fileHistoryRefusal.notSaid';
|
|
66
|
+
const FILE_HISTORY_REFUSAL_UNRECOGNIZED = 'session.fileHistoryRefusal.unrecognized';
|
|
67
|
+
const FILE_HISTORY_REFUSAL_UNREADABLE = 'session.fileHistoryRefusal.unreadable';
|
|
68
|
+
function unjudgedRefusalKeyOf(reading) {
|
|
77
69
|
let kind;
|
|
78
70
|
let word;
|
|
79
71
|
try {
|
|
@@ -88,11 +80,14 @@ function unjudgedRefusalOf(reading) {
|
|
|
88
80
|
if (kind === 'not_reported')
|
|
89
81
|
return FILE_HISTORY_REFUSAL_NOT_SAID;
|
|
90
82
|
if (kind === 'present' && typeof word === 'string' && word.length > 0)
|
|
91
|
-
return
|
|
83
|
+
return FILE_HISTORY_REFUSAL_UNRECOGNIZED;
|
|
92
84
|
return FILE_HISTORY_REFUSAL_NOT_YET;
|
|
93
85
|
}
|
|
94
|
-
|
|
95
|
-
return
|
|
86
|
+
function unjudgedRefusalOf(reading, lang) {
|
|
87
|
+
return renderMessage(msg(unjudgedRefusalKeyOf(reading)), lang);
|
|
88
|
+
}
|
|
89
|
+
export function fileHistoryUnjudgedRefusal(reading, captureOffByUser, lang) {
|
|
90
|
+
return fileHistoryTightenVerdict(reading, captureOffByUser) === 'unjudged' ? unjudgedRefusalOf(reading, lang) : undefined;
|
|
96
91
|
}
|
|
97
92
|
const FILE_HISTORY_REFRESH_WITHIN_MS = 3000;
|
|
98
93
|
export async function judgeFileHistoryTighten(captureOffByUser, opts) {
|
|
@@ -100,7 +95,7 @@ export async function judgeFileHistoryTighten(captureOffByUser, opts) {
|
|
|
100
95
|
const failClosed = () => {
|
|
101
96
|
const reading = { kind: 'unobserved' };
|
|
102
97
|
return closed
|
|
103
|
-
? { verdict: 'unjudged', reading, refreshed: false, refusal: FILE_HISTORY_REFUSAL_NOT_YET }
|
|
98
|
+
? { verdict: 'unjudged', reading, refreshed: false, refusal: renderMessage(msg(FILE_HISTORY_REFUSAL_NOT_YET)) }
|
|
104
99
|
: { verdict: 'not_requested', reading, refreshed: false, refusal: undefined };
|
|
105
100
|
};
|
|
106
101
|
try {
|
|
@@ -179,6 +174,3 @@ export function fileHistoryCaptureDoctorDetail(reading) {
|
|
|
179
174
|
return unobserved;
|
|
180
175
|
}
|
|
181
176
|
}
|
|
182
|
-
export function __resetFileHistoryCaptureReadingsForTests() {
|
|
183
|
-
reader.__resetForTests();
|
|
184
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentEvent } from '@sema-agent/sdk';
|
|
2
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
2
3
|
import { type FileHistoryCaptureReading } from './fileHistoryCaptureCapability.js';
|
|
3
4
|
export type FileHistoryDeclarationFact = 'sent' | 'not_sent' | 'unknown';
|
|
4
5
|
export declare const FILE_HISTORY_LEG_VERDICTS: readonly ["not_honored", "honored", "not_declared", "unknown"];
|
|
@@ -10,7 +11,7 @@ export interface FileHistoryLegNoticeInput {
|
|
|
10
11
|
readonly legWord: string | undefined;
|
|
11
12
|
}
|
|
12
13
|
export declare function fileHistoryLegNoticeVerdict(input: FileHistoryLegNoticeInput): FileHistoryLegNoticeVerdict;
|
|
13
|
-
export declare function fileHistoryLegNoticeSentence(verdict: FileHistoryLegNoticeVerdict): string | null;
|
|
14
|
+
export declare function fileHistoryLegNoticeSentence(verdict: FileHistoryLegNoticeVerdict, lang?: UiLanguage): string | null;
|
|
14
15
|
export declare function fileHistoryDeclarationOfBody(body: object | null | undefined): FileHistoryDeclarationFact;
|
|
15
16
|
export type OutboundBodyField = {
|
|
16
17
|
kind: 'absent';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fileHistoryCaptureMode } from './fileHistoryCaptureCapability.js';
|
|
2
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
3
|
import { frameProvesDelivery } from './promptDelivery.js';
|
|
3
4
|
import { FILE_HISTORY_DISABLED } from './request/taskRequest.js';
|
|
4
5
|
export const FILE_HISTORY_LEG_VERDICTS = Object.freeze(['not_honored', 'honored', 'not_declared', 'unknown']);
|
|
@@ -35,10 +36,9 @@ export function fileHistoryLegNoticeVerdict(input) {
|
|
|
35
36
|
return 'not_declared';
|
|
36
37
|
return 'unknown';
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
export function fileHistoryLegNoticeSentence(verdict) {
|
|
39
|
+
export function fileHistoryLegNoticeSentence(verdict, lang) {
|
|
40
40
|
if (verdict === 'not_honored')
|
|
41
|
-
return
|
|
41
|
+
return renderMessage(msg('session.fileHistoryLeg.notHonored'), lang);
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
export function fileHistoryDeclarationOfBody(body) {
|
|
@@ -74,7 +74,6 @@ export interface CreateFleetLedgerOptions {
|
|
|
74
74
|
nowFn?: () => number;
|
|
75
75
|
}
|
|
76
76
|
export interface FleetLedgerStatus {
|
|
77
|
-
connected: boolean;
|
|
78
77
|
version: number | null;
|
|
79
78
|
scoped: boolean | null;
|
|
80
79
|
sessionScoped: boolean | undefined;
|
|
@@ -89,12 +88,10 @@ export interface FleetLedgerStatus {
|
|
|
89
88
|
droppedStaleIngress: number;
|
|
90
89
|
}
|
|
91
90
|
export interface FleetLedger {
|
|
92
|
-
applyFrame(frame: FleetFrame): void;
|
|
93
91
|
issueStream(): FleetIngress;
|
|
94
92
|
issueSnapshot(opts?: {
|
|
95
93
|
timeoutMs?: number;
|
|
96
94
|
}): FleetSnapshotIngress;
|
|
97
|
-
setConnected(v: boolean): void;
|
|
98
95
|
project(nowMs: number, opts: ProjectTasksOptions & {
|
|
99
96
|
viewingTaskId?: string | undefined;
|
|
100
97
|
}): {
|