@sema-agent/client-core 0.100.0 → 0.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +452 -0
- package/README.md +172 -120
- package/dist/adapt/arms.js +51 -16
- package/dist/adapt/textStream.js +7 -4
- package/dist/adapt/toolCards.d.ts +2 -1
- package/dist/adapt/toolCards.js +28 -13
- package/dist/adapt.d.ts +1 -1
- package/dist/adapt.js +8 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +24 -2
- package/dist/adapter/activeRunSelfHeal.js +108 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +38 -79
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +60 -1
- package/dist/adapter/downstream/terminalToSdkResult.js +209 -39
- package/dist/adapter/downstream/wiringManifestView.d.ts +1 -0
- package/dist/adapter/downstream/wiringManifestView.js +138 -0
- package/dist/adapter/runStream.d.ts +4 -4
- package/dist/adapter/runStream.js +158 -43
- package/dist/agentsWireCaps.d.ts +2 -7
- package/dist/agentsWireCaps.js +1 -2
- package/dist/approvalDecidedByCapability.js +2 -2
- package/dist/approvalFrameFamilies.d.ts +33 -0
- package/dist/approvalFrameFamilies.js +120 -0
- package/dist/approvalsStreamLiveCapability.js +2 -2
- package/dist/attachmentsWireCaps.js +41 -13
- package/dist/callerCwdCapability.js +2 -2
- package/dist/centerWiringCapability.js +2 -2
- package/dist/clockReading.d.ts +2 -0
- package/dist/clockReading.js +4 -0
- package/dist/cloudConfigWireCaps.d.ts +19 -5
- package/dist/cloudConfigWireCaps.js +193 -56
- package/dist/compensations.js +1 -1
- package/dist/coreValuePorts.d.ts +12 -2
- package/dist/coreValuePorts.js +9 -0
- package/dist/decideFailureNote.js +5 -3
- package/dist/decideReceipt.js +2 -2
- package/dist/deviceExecutorManagementCapability.js +2 -2
- package/dist/deviceFlowPolling.js +1 -1
- package/dist/disableSkillsWire.d.ts +1 -1
- package/dist/disableSkillsWire.js +4 -3
- package/dist/displayUntrusted.d.ts +9 -4
- package/dist/displayUntrusted.js +834 -104
- package/dist/engineCapReader.js +1 -1
- package/dist/engineConfigDrift.js +1 -1
- package/dist/engineErrorCodes.d.ts +14 -5
- package/dist/engineErrorCodes.js +27 -6
- package/dist/engineGenerationConvergence.d.ts +39 -0
- package/dist/engineGenerationConvergence.js +95 -0
- package/dist/engineGenerationPort.d.ts +61 -0
- package/dist/engineGenerationPort.js +144 -0
- package/dist/engineHealthFacts.d.ts +23 -0
- package/dist/engineHealthFacts.js +92 -0
- package/dist/engineIdentity.d.ts +4 -0
- package/dist/engineIdentity.js +11 -0
- package/dist/engineNoticeCodes.d.ts +2 -5
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.js +2 -2
- package/dist/engineToolDirectory.js +2 -2
- package/dist/engineWireFor.d.ts +99 -0
- package/dist/engineWireFor.js +248 -6
- package/dist/engineWireTarget.d.ts +1 -0
- package/dist/engineWireTarget.js +8 -0
- package/dist/env/uiLanguage.js +1 -1
- package/dist/errorSupplementRoles.d.ts +3 -0
- package/dist/errorSupplementRoles.js +37 -0
- package/dist/executionLaneCapability.js +2 -2
- package/dist/fileHistoryCaptureCapability.js +3 -3
- package/dist/finalVerifyWire.d.ts +6 -3
- package/dist/finalVerifyWire.js +6 -23
- package/dist/flagInput.d.ts +4 -0
- package/dist/flagInput.js +24 -0
- package/dist/fleet/fleetLedger.js +5 -2
- package/dist/fleet/fleetProjection.d.ts +1 -0
- package/dist/fleet/fleetProjection.js +16 -3
- package/dist/gateVocabulary.js +3 -0
- package/dist/generated/engineFactTables.d.ts +7 -3
- package/dist/generated/engineFactTables.js +52 -0
- package/dist/generated/engineNoticeTables.js +12 -0
- package/dist/generated/settingsSchemaActiveTiers.d.ts +1 -0
- package/dist/generated/settingsSchemaActiveTiers.js +14 -0
- package/dist/generated/settingsSchemaCallerTextEcho.d.ts +1 -0
- package/dist/generated/settingsSchemaCallerTextEcho.js +8 -0
- package/dist/generated/settingsSchemaControlAndBidi.d.ts +1 -0
- package/dist/generated/settingsSchemaControlAndBidi.js +8 -0
- package/dist/generated/settingsSchemaDefaultModel.d.ts +11 -0
- package/dist/generated/settingsSchemaDefaultModel.js +25 -0
- package/dist/generated/settingsSchemaFns.d.ts +54 -0
- package/dist/generated/settingsSchemaFns.js +26 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -1
- package/dist/generated/settingsSchemaMcpRequestEntry.js +1 -7
- package/dist/generated/settingsSchemaSafetyMergeSpec.d.ts +1 -0
- package/dist/generated/settingsSchemaSafetyMergeSpec.js +95 -0
- package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -0
- package/dist/generated/settingsSchemaSettingsSources.js +58 -0
- package/dist/generated/settingsSchemaTables.d.ts +2 -0
- package/dist/generated/settingsSchemaTables.js +13 -0
- package/dist/generated/settingsSchemaUrlPattern.d.ts +1 -0
- package/dist/generated/settingsSchemaUrlPattern.js +183 -0
- package/dist/headlessPermissionModeWire.d.ts +18 -2
- package/dist/headlessPermissionModeWire.js +30 -19
- package/dist/hitl/allowRuleShadow.js +7 -5
- package/dist/hitl/approvalCardReading.d.ts +3 -0
- package/dist/hitl/approvalCardReading.js +17 -0
- package/dist/hitl/approvalCompleteParked.js +1 -1
- package/dist/hitl/approvalDelivery.d.ts +87 -0
- package/dist/hitl/approvalDelivery.js +193 -0
- package/dist/hitl/approvalResolution.d.ts +11 -0
- package/dist/hitl/approvalResolution.js +50 -11
- package/dist/hitl/askClassPair.d.ts +6 -0
- package/dist/hitl/askClassPair.js +30 -3
- package/dist/hitl/askParkAutoReopenBlock.d.ts +30 -0
- package/dist/hitl/askParkAutoReopenBlock.js +117 -0
- package/dist/hitl/askParkRowRouting.js +4 -1
- package/dist/hitl/attributionLadder.d.ts +42 -3
- package/dist/hitl/attributionLadder.js +79 -8
- package/dist/hitl/automaticAnswerVerdict.d.ts +6 -1
- package/dist/hitl/automaticAnswerVerdict.js +46 -11
- package/dist/hitl/crashConverged.js +2 -2
- package/dist/hitl/decisionConflict.d.ts +6 -2
- package/dist/hitl/decisionConflict.js +24 -9
- package/dist/hitl/decisionRefusal.d.ts +20 -10
- package/dist/hitl/decisionRefusal.js +99 -54
- package/dist/hitl/decisionSend.d.ts +3 -0
- package/dist/hitl/decisionSend.js +87 -103
- package/dist/hitl/frameRouter.d.ts +1 -0
- package/dist/hitl/frameRouter.js +9 -2
- package/dist/hitl/hitlBridge.d.ts +18 -6
- package/dist/hitl/hitlBridge.js +41 -37
- package/dist/hitl/livePendingAsk.js +4 -3
- package/dist/hitl/noAllowCause.js +1 -1
- package/dist/hitl/parkResolver.js +3 -2
- package/dist/hitl/persistedRulesWire.js +1 -0
- package/dist/hitl/planReviewWire.d.ts +4 -0
- package/dist/hitl/planReviewWire.js +59 -30
- package/dist/hitl/resumeRunningCard.d.ts +3 -2
- package/dist/hitl/resumeRunningCard.js +17 -11
- package/dist/hitl/sessionPolicyDeliverable.d.ts +5 -2
- package/dist/hitl/sessionPolicyDeliverable.js +62 -29
- package/dist/hitl/sessionPolicyWire.d.ts +13 -3
- package/dist/hitl/sessionPolicyWire.js +81 -16
- package/dist/hitl/standingRows.js +1 -1
- package/dist/hitl/toolApprovalWire.d.ts +9 -10
- package/dist/hitl/toolApprovalWire.js +72 -54
- package/dist/hookMatcherVerdict.d.ts +2 -0
- package/dist/hookMatcherVerdict.js +12 -0
- package/dist/hooksCompactTransition.d.ts +19 -0
- package/dist/hooksCompactTransition.js +41 -0
- package/dist/hooksWireCaps.d.ts +1 -1
- package/dist/hooksWireCaps.js +202 -203
- package/dist/host.d.ts +1 -14
- package/dist/host.js +0 -8
- package/dist/hostCallbackGuard.d.ts +1 -0
- package/dist/hostCallbackGuard.js +1 -1
- package/dist/hostSettingsSource.d.ts +172 -0
- package/dist/hostSettingsSource.js +675 -0
- package/dist/hostTurnSettings.d.ts +73 -17
- package/dist/hostTurnSettings.js +594 -97
- package/dist/httpHookPolicy.d.ts +37 -0
- package/dist/httpHookPolicy.js +176 -0
- package/dist/humanTurn.d.ts +2 -1
- package/dist/humanTurn.js +37 -7
- package/dist/humanTurnRead.js +4 -3
- package/dist/humanTurnSentences.d.ts +10 -0
- package/dist/humanTurnSentences.js +74 -0
- package/dist/i18n/messages.en.d.ts +222 -2
- package/dist/i18n/messages.en.js +225 -5
- package/dist/i18n/messages.zh.js +237 -5
- package/dist/i18n/translate.js +3 -3
- package/dist/index.d.ts +77 -15
- package/dist/index.js +50 -13
- package/dist/inheritEnvCapability.d.ts +3 -1
- package/dist/inheritEnvCapability.js +31 -17
- package/dist/inheritEnvWire.d.ts +2 -1
- package/dist/inheritEnvWire.js +11 -5
- package/dist/interactiveHalt.d.ts +3 -1
- package/dist/interactiveHalt.js +2 -0
- package/dist/interactiveInterrupt.d.ts +2 -0
- package/dist/interactiveInterrupt.js +15 -0
- package/dist/interactiveToolsWire.d.ts +4 -2
- package/dist/interactiveToolsWire.js +5 -5
- package/dist/jsonFaithful.d.ts +20 -0
- package/dist/jsonFaithful.js +152 -0
- package/dist/limitsWire.d.ts +7 -2
- package/dist/limitsWire.js +19 -13
- package/dist/liveInitToolFace.d.ts +6 -1
- package/dist/liveInitToolFace.js +5 -3
- package/dist/liveModelCatalog.d.ts +22 -0
- package/dist/liveModelCatalog.js +132 -18
- package/dist/mcpPanel.js +1 -1
- package/dist/mcpProbeCapability.js +2 -2
- package/dist/mcpStatusSupersetKeys.d.ts +24 -0
- package/dist/mcpStatusSupersetKeys.js +45 -0
- package/dist/mcpToolToggles.js +2 -1
- package/dist/mcpWireCaps.d.ts +39 -1
- package/dist/mcpWireCaps.js +254 -50
- package/dist/memoryComplianceCapability.js +2 -2
- package/dist/memoryOriginCapability.js +2 -2
- package/dist/model/catalogDefault.d.ts +24 -0
- package/dist/model/catalogDefault.js +4 -0
- package/dist/model/liveCatalogShape.js +5 -4
- package/dist/model/modelsPolicy.js +4 -3
- package/dist/model/onboardJudgement.d.ts +1 -0
- package/dist/model/onboardJudgement.js +1 -1
- package/dist/model/subagentModelWord.js +2 -2
- package/dist/modelCapabilityProbe.js +6 -6
- package/dist/modelIdentityResolvability.d.ts +10 -1
- package/dist/modelIdentityResolvability.js +62 -39
- package/dist/modsFace.d.ts +8 -0
- package/dist/modsFace.js +59 -0
- package/dist/modsKernelIdentity.d.ts +10 -0
- package/dist/modsKernelIdentity.js +103 -0
- package/dist/modsKernelTransit.d.ts +8 -0
- package/dist/modsKernelTransit.js +6 -0
- package/dist/notifications.d.ts +30 -12
- package/dist/notifications.js +241 -53
- package/dist/outputStyleSeatCapability.js +2 -2
- package/dist/ownKey.d.ts +12 -0
- package/dist/ownKey.js +179 -3
- package/dist/panelReduce.js +1 -1
- package/dist/peerFrames.d.ts +1 -1
- package/dist/peerFrames.js +6 -2
- package/dist/peerLaneCapability.js +2 -2
- package/dist/permissionModesCapability.js +4 -4
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.js +2 -2
- package/dist/permissionsAllowGrantCapability.js +2 -2
- package/dist/permissionsDeclaration.d.ts +43 -4
- package/dist/permissionsDeclaration.js +102 -35
- package/dist/pluginHooksWire.d.ts +20 -4
- package/dist/pluginHooksWire.js +92 -53
- package/dist/prepareRefusal.d.ts +3 -2
- package/dist/prepareRefusal.js +27 -9
- package/dist/printInitToolFace.js +2 -2
- package/dist/printModelStatus.js +1 -1
- package/dist/printToolResultFrame.js +1 -1
- package/dist/projectMemory.d.ts +32 -0
- package/dist/projectMemory.js +70 -0
- package/dist/promptBlockedCopy.d.ts +2 -1
- package/dist/promptBlockedCopy.js +2 -1
- package/dist/promptDelivery.d.ts +23 -3
- package/dist/promptDelivery.js +169 -30
- package/dist/providerRejection.d.ts +19 -1
- package/dist/providerRejection.js +75 -4
- package/dist/queuedDelivery.d.ts +48 -0
- package/dist/queuedDelivery.js +233 -0
- package/dist/reattachWindow.d.ts +94 -0
- package/dist/reattachWindow.js +127 -0
- package/dist/request/printNotification.d.ts +1 -1
- package/dist/request/printNotification.js +6 -2
- package/dist/request/submissionIdentity.d.ts +37 -0
- package/dist/request/submissionIdentity.js +65 -0
- package/dist/request/taskRequest.d.ts +33 -4
- package/dist/request/taskRequest.js +341 -156
- package/dist/resultFrameKeys.d.ts +1 -0
- package/dist/resultFrameKeys.js +4 -1
- package/dist/retryStatus.d.ts +8 -0
- package/dist/retryStatus.js +57 -9
- package/dist/rewindArchiveCapability.js +2 -2
- package/dist/rewindEngineAction.d.ts +2 -0
- package/dist/rewindEngineAction.js +23 -1
- package/dist/rowKind.d.ts +36 -0
- package/dist/rowKind.js +97 -0
- package/dist/ruleCompileVerdict.d.ts +18 -0
- package/dist/ruleCompileVerdict.js +67 -2
- package/dist/ruleReadings.d.ts +58 -0
- package/dist/ruleReadings.js +132 -0
- package/dist/ruleRefusalSentence.d.ts +4 -0
- package/dist/ruleRefusalSentence.js +9 -3
- package/dist/runCancelContext.d.ts +0 -1
- package/dist/runCancelContext.js +1 -2
- package/dist/runTerminal.d.ts +5 -0
- package/dist/runTerminal.js +52 -17
- package/dist/sandboxWire.d.ts +1 -1
- package/dist/sandboxWire.js +4 -6
- package/dist/scenarioRefusal.js +1 -1
- package/dist/scenarioSkills.d.ts +20 -0
- package/dist/scenarioSkills.js +72 -0
- package/dist/scenarioWire.d.ts +5 -2
- package/dist/scenarioWire.js +9 -9
- package/dist/sealedKeyCapability.js +2 -2
- package/dist/seam.d.ts +2 -0
- package/dist/seam.js +3 -3
- package/dist/seatContract.d.ts +68 -7
- package/dist/seatContract.js +84 -25
- package/dist/selfOrchestrationDenial.js +1 -1
- package/dist/sessionBackground.d.ts +165 -0
- package/dist/sessionBackground.js +781 -0
- package/dist/sessionBackgroundHandoff.d.ts +54 -0
- package/dist/sessionBackgroundHandoff.js +321 -0
- package/dist/sessionMap.js +4 -1
- package/dist/sessionPolicyCapability.js +2 -2
- package/dist/sessionRulesChildrenReadLive.d.ts +6 -0
- package/dist/sessionRulesChildrenReadLive.js +5 -0
- package/dist/sessionRulesNamespaceFormsCapability.d.ts +12 -0
- package/dist/sessionRulesNamespaceFormsCapability.js +29 -0
- package/dist/sessionSyncFileHistoryCapability.js +2 -2
- package/dist/settingsCredentialKeyPaths.js +55 -15
- package/dist/settingsHooksSalvage.d.ts +1 -0
- package/dist/settingsHooksSalvage.js +7 -1
- package/dist/settingsLayerAdmission.d.ts +4 -0
- package/dist/settingsLayerAdmission.js +16 -0
- package/dist/skillToolListsCapability.js +6 -5
- package/dist/skillsWireCaps.d.ts +14 -0
- package/dist/skillsWireCaps.js +47 -16
- package/dist/slashCommandGate.d.ts +24 -0
- package/dist/slashCommandGate.js +74 -0
- package/dist/slashCommandTable.d.ts +14 -0
- package/dist/slashCommandTable.js +99 -0
- package/dist/sqlEngineCapability.js +2 -2
- package/dist/steerPriorityCapability.js +2 -2
- package/dist/storePostureCapability.js +2 -2
- package/dist/subagent/agentStateDetail.js +1 -1
- package/dist/subagent/engineDelegatedPrompt.d.ts +9 -0
- package/dist/subagent/engineDelegatedPrompt.js +38 -7
- package/dist/subagent/engineRowStopGate.js +2 -2
- package/dist/subagent/engineSubagentResume.js +3 -3
- package/dist/subagent/engineTaskHandleWire.d.ts +1 -0
- package/dist/subagent/engineTaskHandleWire.js +10 -0
- package/dist/submitFailure.d.ts +8 -0
- package/dist/submitFailure.js +17 -0
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +7 -0
- package/dist/terminationIntent.d.ts +55 -0
- package/dist/terminationIntent.js +352 -0
- package/dist/thinkingLatch.d.ts +69 -0
- package/dist/thinkingLatch.js +255 -0
- package/dist/thinkingLatchWords.d.ts +7 -0
- package/dist/thinkingLatchWords.js +4 -0
- package/dist/toolHistoryMismatch.d.ts +8 -0
- package/dist/toolHistoryMismatch.js +37 -6
- package/dist/toolResult.d.ts +13 -3
- package/dist/toolResult.js +159 -32
- package/dist/toolResultContent.d.ts +13 -0
- package/dist/toolResultContent.js +82 -7
- package/dist/toolRoster.d.ts +18 -0
- package/dist/toolRoster.js +64 -0
- package/dist/turnFailurePresentation.js +27 -90
- package/dist/usageLimitAutoResume.d.ts +74 -0
- package/dist/usageLimitAutoResume.js +227 -0
- package/dist/userAttachmentEnvelope.js +1 -1
- package/dist/userAttachmentSeat.js +5 -5
- package/dist/userInvokedSkillsCapability.js +2 -2
- package/dist/webSearchBackendCapability.js +2 -2
- package/dist/wireErrorTriage.js +99 -50
- package/dist/wireFailureShape.d.ts +25 -1
- package/dist/wireFailureShape.js +92 -5
- package/dist/wireRefusalCopy.d.ts +24 -1
- package/dist/wireRefusalCopy.js +253 -32
- package/dist/wiringFleetDoctor.d.ts +3 -0
- package/dist/wiringFleetDoctor.js +21 -0
- package/dist/workflow.d.ts +2 -1
- package/dist/workflow.js +38 -1
- package/dist/workflowClient.d.ts +2 -7
- package/dist/workflowsJournalCapability.js +2 -2
- package/dist/writeProtectionCapability.js +2 -2
- package/docs/INTEGRATION-CLIENTS.md +907 -182
- package/package.json +14 -3
- package/dist/argvFlagValue.d.ts +0 -8
- package/dist/argvFlagValue.js +0 -37
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { encodeHumanTurn } from './humanTurn.js';
|
|
2
|
+
import { imageVisionOf } from './liveModelCatalog.js';
|
|
3
|
+
import { userPromptSubmitExecutorOf } from './pluginHooksWire.js';
|
|
4
|
+
import { observedUserAttachmentSeat } from './userAttachmentSeat.js';
|
|
5
|
+
import { guardedRead, readOwnDataValue } from './ownKey.js';
|
|
6
|
+
const own = (o, key) => guardedRead(() => readOwnDataValue(o, key));
|
|
7
|
+
const str = (o, key) => {
|
|
8
|
+
const v = own(o, key);
|
|
9
|
+
return typeof v === 'string' ? v : undefined;
|
|
10
|
+
};
|
|
11
|
+
const UNREADABLE = Symbol('unreadable');
|
|
12
|
+
function peek(o, key) {
|
|
13
|
+
if (typeof o !== 'object' || o === null)
|
|
14
|
+
return UNREADABLE;
|
|
15
|
+
try {
|
|
16
|
+
const d = Object.getOwnPropertyDescriptor(o, key);
|
|
17
|
+
if (d === undefined)
|
|
18
|
+
return undefined;
|
|
19
|
+
return Object.hasOwn(d, 'value') ? d.value : UNREADABLE;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return UNREADABLE;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function arrayFact(v) {
|
|
26
|
+
if (v === undefined)
|
|
27
|
+
return 'absent';
|
|
28
|
+
if (v === UNREADABLE)
|
|
29
|
+
return 'bad';
|
|
30
|
+
try {
|
|
31
|
+
if (!Array.isArray(v))
|
|
32
|
+
return 'bad';
|
|
33
|
+
return v.length > 0 ? 'some' : 'empty';
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return 'bad';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const nonEmptyArray = (v) => arrayFact(v) === 'some';
|
|
40
|
+
export function batchCompatible(head, follower, plan) {
|
|
41
|
+
try {
|
|
42
|
+
if (plan === undefined || plan === null)
|
|
43
|
+
return false;
|
|
44
|
+
if (typeof head !== 'object' || head === null || typeof follower !== 'object' || follower === null)
|
|
45
|
+
return false;
|
|
46
|
+
const executor = userPromptSubmitExecutorOf(plan);
|
|
47
|
+
if (executor === 'engine' || executor === 'unknown')
|
|
48
|
+
return false;
|
|
49
|
+
if (peek(follower, 'screening') !== undefined)
|
|
50
|
+
return false;
|
|
51
|
+
const item = peek(follower, 'item');
|
|
52
|
+
if (typeof item !== 'object' || item === null)
|
|
53
|
+
return false;
|
|
54
|
+
const mentions = arrayFact(peek(item, 'attachments'));
|
|
55
|
+
if (mentions !== 'absent' && mentions !== 'empty')
|
|
56
|
+
return false;
|
|
57
|
+
const he = peek(head, 'upsExecutor');
|
|
58
|
+
const fe = peek(follower, 'upsExecutor');
|
|
59
|
+
if (!upsExecutorWordOk(he) || !upsExecutorWordOk(fe))
|
|
60
|
+
return false;
|
|
61
|
+
if (he !== undefined && fe !== undefined && he !== fe)
|
|
62
|
+
return false;
|
|
63
|
+
const kind = str(head, 'kind');
|
|
64
|
+
if (kind === undefined || kind !== str(follower, 'kind'))
|
|
65
|
+
return false;
|
|
66
|
+
const sameOptStr = (key) => {
|
|
67
|
+
const a = peek(head, key);
|
|
68
|
+
const b = peek(follower, key);
|
|
69
|
+
if ((a !== undefined && typeof a !== 'string') || (b !== undefined && typeof b !== 'string'))
|
|
70
|
+
return false;
|
|
71
|
+
return a === b;
|
|
72
|
+
};
|
|
73
|
+
if (!sameOptStr('injection') || !sameOptStr('intentKey'))
|
|
74
|
+
return false;
|
|
75
|
+
const ha = peek(head, 'hidden');
|
|
76
|
+
const hb = peek(follower, 'hidden');
|
|
77
|
+
if ((ha !== undefined && typeof ha !== 'boolean') || (hb !== undefined && typeof hb !== 'boolean'))
|
|
78
|
+
return false;
|
|
79
|
+
if ((ha === true) !== (hb === true))
|
|
80
|
+
return false;
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function upsExecutorWordOk(v) {
|
|
88
|
+
return v === undefined || v === 'shell' || v === 'engine' || v === 'unknown' || v === 'none';
|
|
89
|
+
}
|
|
90
|
+
export function planQueuedDelivery(entries, run, caps, policy) {
|
|
91
|
+
const steerNow = [];
|
|
92
|
+
const held = [];
|
|
93
|
+
let list = [];
|
|
94
|
+
try {
|
|
95
|
+
list = Array.isArray(entries) ? [...entries] : [];
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
list = [];
|
|
99
|
+
}
|
|
100
|
+
const uuidOf = (e) => str(e, 'uuid') ?? '';
|
|
101
|
+
const live = own(run, 'live') === true && own(run, 'steerVerb') === true;
|
|
102
|
+
if (!live) {
|
|
103
|
+
for (const e of list)
|
|
104
|
+
held.push({ uuid: uuidOf(e), reason: 'no_run' });
|
|
105
|
+
return { steerNow, held, canSendNow: false };
|
|
106
|
+
}
|
|
107
|
+
const overtake = policy === undefined ? true : own(policy, 'overtakeBashHead') !== false;
|
|
108
|
+
let barrier = false;
|
|
109
|
+
let headSeen = false;
|
|
110
|
+
for (const e of list) {
|
|
111
|
+
const uuid = uuidOf(e);
|
|
112
|
+
const heldMark = peek(e, 'held');
|
|
113
|
+
if (heldMark === true) {
|
|
114
|
+
held.push({ uuid, reason: 'not_steerable' });
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const isHead = !headSeen;
|
|
118
|
+
headSeen = true;
|
|
119
|
+
if (barrier) {
|
|
120
|
+
held.push({ uuid, reason: 'barrier' });
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const state = peek(e, 'steerState');
|
|
124
|
+
const kind = peek(e, 'kind');
|
|
125
|
+
const shellBlock = peek(e, 'shellBlock');
|
|
126
|
+
const item = peek(e, 'item');
|
|
127
|
+
const stateKnown = state === undefined || state === 'none' || state === 'in_flight' || state === 'attempted';
|
|
128
|
+
if ((heldMark !== undefined && heldMark !== false) || !stateKnown || kind === UNREADABLE || shellBlock === UNREADABLE || item === UNREADABLE) {
|
|
129
|
+
held.push({ uuid, reason: 'not_steerable' });
|
|
130
|
+
barrier = true;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (state === 'in_flight' || state === 'attempted') {
|
|
134
|
+
held.push({ uuid, reason: state });
|
|
135
|
+
barrier = true;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (kind === 'bash' && isHead && overtake) {
|
|
139
|
+
held.push({ uuid, reason: 'not_steerable' });
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (kind !== 'prompt' || shellBlock !== undefined || typeof item !== 'object' || item === null) {
|
|
143
|
+
held.push({ uuid, reason: 'not_steerable' });
|
|
144
|
+
barrier = true;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const text = str(item, 'text');
|
|
148
|
+
if (text === undefined) {
|
|
149
|
+
held.push({ uuid, reason: 'not_steerable' });
|
|
150
|
+
barrier = true;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const mediaFacts = ['images', 'attachments', 'attachmentIds', 'missing', 'riders'].map((k) => arrayFact(peek(item, k)));
|
|
154
|
+
if (mediaFacts.includes('bad')) {
|
|
155
|
+
held.push({ uuid, reason: 'not_steerable' });
|
|
156
|
+
barrier = true;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const media = mediaFacts.includes('some');
|
|
160
|
+
if (text.trim() === '' && !media) {
|
|
161
|
+
held.push({ uuid, reason: 'not_steerable' });
|
|
162
|
+
barrier = true;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (nonEmptyArray(own(item, 'attachments'))) {
|
|
166
|
+
held.push({ uuid, reason: 'share_incomplete' });
|
|
167
|
+
barrier = true;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const enc = encodeHumanTurn({ items: [item], lane: 'steer', caps });
|
|
171
|
+
if (!enc.ok) {
|
|
172
|
+
held.push({ uuid, reason: enc.reason === 'steer_hold' && enc.why === 'no_text' && media ? 'share_incomplete' : 'not_steerable' });
|
|
173
|
+
barrier = true;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (enc.lane !== 'steer' || enc.shares.some((s) => s.level !== 'full')) {
|
|
177
|
+
held.push({ uuid, reason: 'share_incomplete' });
|
|
178
|
+
barrier = true;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
steerNow.push({ uuid, payload: enc });
|
|
182
|
+
}
|
|
183
|
+
return { steerNow, held, canSendNow: steerNow.length > 0 };
|
|
184
|
+
}
|
|
185
|
+
export function selfHealSteerEligible(items, caps) {
|
|
186
|
+
try {
|
|
187
|
+
if (!Array.isArray(items) || items.length !== 1)
|
|
188
|
+
return false;
|
|
189
|
+
if (nonEmptyArray(own(items[0], 'attachments')))
|
|
190
|
+
return false;
|
|
191
|
+
const enc = encodeHumanTurn({ items: [items[0]], lane: 'steer', caps });
|
|
192
|
+
return enc.ok === true && enc.lane === 'steer' && enc.shares.length === 1 && enc.shares.every((s) => s.level === 'full');
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
export function humanTurnCapsOf(facts) {
|
|
199
|
+
const model = facts === undefined ? undefined : str(facts, 'model');
|
|
200
|
+
const baseUrl = facts === undefined ? undefined : str(facts, 'baseUrl');
|
|
201
|
+
const catalog = facts === undefined ? undefined : own(facts, 'catalog');
|
|
202
|
+
let vision = 'unknown';
|
|
203
|
+
try {
|
|
204
|
+
vision = catalog === undefined ? imageVisionOf(model) : imageVisionOf(model, catalog);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
vision = 'unknown';
|
|
208
|
+
}
|
|
209
|
+
let userAttachments;
|
|
210
|
+
try {
|
|
211
|
+
userAttachments = baseUrl === undefined ? observedUserAttachmentSeat() : observedUserAttachmentSeat(baseUrl);
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
userAttachments = undefined;
|
|
215
|
+
}
|
|
216
|
+
return { vision, ...(userAttachments !== undefined ? { userAttachments } : {}) };
|
|
217
|
+
}
|
|
218
|
+
export function humanTextForKeywordScan(items) {
|
|
219
|
+
try {
|
|
220
|
+
if (!Array.isArray(items))
|
|
221
|
+
return '';
|
|
222
|
+
const parts = [];
|
|
223
|
+
for (const it of items) {
|
|
224
|
+
const t = str(it, 'text');
|
|
225
|
+
if (t !== undefined && t.trim() !== '')
|
|
226
|
+
parts.push(t);
|
|
227
|
+
}
|
|
228
|
+
return parts.join('\n');
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export declare const REATTACH_WINDOW_MS = 300000;
|
|
2
|
+
export declare const REATTACH_BACKOFF_START_MS = 1000;
|
|
3
|
+
export declare const REATTACH_BACKOFF_CAP_MS = 30000;
|
|
4
|
+
export declare const REATTACH_NOT_FOUND_CONFIRM = 3;
|
|
5
|
+
export declare const REATTACH_NOT_FOUND_MIN_ELAPSED_MS = 10000;
|
|
6
|
+
export interface ReattachWindowTuning {
|
|
7
|
+
readonly windowMs?: number;
|
|
8
|
+
readonly startMs?: number;
|
|
9
|
+
readonly capMs?: number;
|
|
10
|
+
readonly notFoundConfirm?: number;
|
|
11
|
+
readonly notFoundMinElapsedMs?: number;
|
|
12
|
+
}
|
|
13
|
+
interface Tuned {
|
|
14
|
+
readonly windowMs: number;
|
|
15
|
+
readonly startMs: number;
|
|
16
|
+
readonly capMs: number;
|
|
17
|
+
readonly notFoundConfirm: number;
|
|
18
|
+
readonly notFoundMinElapsedMs: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function reattachBackoffMs(attempt: number, tuning?: ReattachWindowTuning): number;
|
|
21
|
+
export interface ReattachWindowState {
|
|
22
|
+
readonly enteredAtMs: number;
|
|
23
|
+
readonly deadlineMs: number;
|
|
24
|
+
readonly attempt: number;
|
|
25
|
+
readonly consecutiveNotFound: number;
|
|
26
|
+
readonly notFoundConfirmed: boolean;
|
|
27
|
+
readonly tuning: Readonly<Tuned>;
|
|
28
|
+
}
|
|
29
|
+
export declare function reattachWindowOpen(nowMs: number, tuning?: ReattachWindowTuning): ReattachWindowState;
|
|
30
|
+
export type ReattachProbeResult = 'readable' | 'unreachable' | 'not-found';
|
|
31
|
+
export type ReattachWindowEvent = {
|
|
32
|
+
readonly type: 'attempt';
|
|
33
|
+
} | {
|
|
34
|
+
readonly type: 'probe';
|
|
35
|
+
readonly result: ReattachProbeResult;
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: 'tail-frame';
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: 'tail-refused-404';
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: 'backoff';
|
|
42
|
+
readonly serverRetryAfterMs?: number;
|
|
43
|
+
} | {
|
|
44
|
+
readonly type: 'new-segment';
|
|
45
|
+
};
|
|
46
|
+
export type ReattachWindowDecision = {
|
|
47
|
+
readonly action: 'continue';
|
|
48
|
+
readonly notFoundConfirmed: boolean;
|
|
49
|
+
} | {
|
|
50
|
+
readonly action: 'wait';
|
|
51
|
+
readonly afterMs: number;
|
|
52
|
+
} | {
|
|
53
|
+
readonly action: 'window-exhausted';
|
|
54
|
+
} | {
|
|
55
|
+
readonly action: 'run-unknown';
|
|
56
|
+
readonly confirmations: number;
|
|
57
|
+
};
|
|
58
|
+
export interface ReattachWindowStep {
|
|
59
|
+
readonly state: ReattachWindowState;
|
|
60
|
+
readonly decision: ReattachWindowDecision;
|
|
61
|
+
}
|
|
62
|
+
export declare function reattachWindowStep(state: ReattachWindowState, event: ReattachWindowEvent, nowMs: number): ReattachWindowStep;
|
|
63
|
+
export interface PoisonFrameState {
|
|
64
|
+
readonly lastGoodSeq: string | null;
|
|
65
|
+
readonly strikeAt: string | null | undefined;
|
|
66
|
+
}
|
|
67
|
+
export declare function poisonFrameInitial(): PoisonFrameState;
|
|
68
|
+
export type PoisonFrameEvent = {
|
|
69
|
+
readonly type: 'frame-ok';
|
|
70
|
+
readonly seq?: string;
|
|
71
|
+
} | {
|
|
72
|
+
readonly type: 'frame-bad';
|
|
73
|
+
readonly raw?: string;
|
|
74
|
+
};
|
|
75
|
+
export type PoisonFrameDecision = {
|
|
76
|
+
readonly action: 'continue';
|
|
77
|
+
} | {
|
|
78
|
+
readonly action: 'resume-from';
|
|
79
|
+
readonly seq: string | null;
|
|
80
|
+
} | {
|
|
81
|
+
readonly action: 'raise';
|
|
82
|
+
readonly afterSeq: string | null;
|
|
83
|
+
readonly raw?: string;
|
|
84
|
+
};
|
|
85
|
+
export interface PoisonFrameStep {
|
|
86
|
+
readonly state: PoisonFrameState;
|
|
87
|
+
readonly decision: PoisonFrameDecision;
|
|
88
|
+
}
|
|
89
|
+
export declare const POISON_FRAME_RAW_MAX = 2000;
|
|
90
|
+
export declare function poisonFrameStep(state: PoisonFrameState, event: PoisonFrameEvent): PoisonFrameStep;
|
|
91
|
+
export declare function malformedFrameErrorOf(err: {} | null | undefined): {
|
|
92
|
+
readonly detail: string;
|
|
93
|
+
} | null;
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { usableClockMs } from './clockReading.js';
|
|
2
|
+
import { readThrownSlot, THROWN_SLOT_UNREADABLE } from './wireFailureShape.js';
|
|
3
|
+
export const REATTACH_WINDOW_MS = 300_000;
|
|
4
|
+
export const REATTACH_BACKOFF_START_MS = 1_000;
|
|
5
|
+
export const REATTACH_BACKOFF_CAP_MS = 30_000;
|
|
6
|
+
export const REATTACH_NOT_FOUND_CONFIRM = 3;
|
|
7
|
+
export const REATTACH_NOT_FOUND_MIN_ELAPSED_MS = 10_000;
|
|
8
|
+
const pos = (v, d) => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : d);
|
|
9
|
+
const nonNeg = (v, d) => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : d);
|
|
10
|
+
const posInt = (v, d) => (typeof v === 'number' && Number.isSafeInteger(v) && v > 0 ? v : d);
|
|
11
|
+
function tuned(t) {
|
|
12
|
+
const startMs = pos(t?.startMs, REATTACH_BACKOFF_START_MS);
|
|
13
|
+
return {
|
|
14
|
+
windowMs: pos(t?.windowMs, REATTACH_WINDOW_MS),
|
|
15
|
+
startMs,
|
|
16
|
+
capMs: Math.max(startMs, pos(t?.capMs, REATTACH_BACKOFF_CAP_MS)),
|
|
17
|
+
notFoundConfirm: posInt(t?.notFoundConfirm, REATTACH_NOT_FOUND_CONFIRM),
|
|
18
|
+
notFoundMinElapsedMs: nonNeg(t?.notFoundMinElapsedMs, REATTACH_NOT_FOUND_MIN_ELAPSED_MS),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function reattachBackoffMs(attempt, tuning) {
|
|
22
|
+
const { startMs, capMs } = tuned(tuning);
|
|
23
|
+
if (typeof attempt !== 'number' || !(attempt > 1))
|
|
24
|
+
return startMs;
|
|
25
|
+
const raw = startMs * 2 ** (attempt - 1);
|
|
26
|
+
return Number.isFinite(raw) ? Math.min(raw, capMs) : capMs;
|
|
27
|
+
}
|
|
28
|
+
export function reattachWindowOpen(nowMs, tuning) {
|
|
29
|
+
const t = tuned(tuning);
|
|
30
|
+
const start = usableClockMs(nowMs) ?? Number.NaN;
|
|
31
|
+
return Object.freeze({ enteredAtMs: start, deadlineMs: start + t.windowMs, attempt: 0, consecutiveNotFound: 0, notFoundConfirmed: false, tuning: Object.freeze(t) });
|
|
32
|
+
}
|
|
33
|
+
const step = (state, decision) => Object.freeze({ state, decision });
|
|
34
|
+
const exhausted = (state) => step(state, Object.freeze({ action: 'window-exhausted' }));
|
|
35
|
+
const cont = (state, notFoundConfirmed = false) => step(state, Object.freeze({ action: 'continue', notFoundConfirmed }));
|
|
36
|
+
const next = (state, patch) => Object.freeze({ ...state, ...patch });
|
|
37
|
+
const isCount = (v) => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0;
|
|
38
|
+
function validState(s) {
|
|
39
|
+
if (typeof s !== 'object' || s === null)
|
|
40
|
+
return false;
|
|
41
|
+
const o = s;
|
|
42
|
+
return typeof o.enteredAtMs === 'number' && typeof o.deadlineMs === 'number' && isCount(o.attempt) && isCount(o.consecutiveNotFound) && typeof o.notFoundConfirmed === 'boolean' && typeof o.tuning === 'object' && o.tuning !== null;
|
|
43
|
+
}
|
|
44
|
+
export function reattachWindowStep(state, event, nowMs) {
|
|
45
|
+
try {
|
|
46
|
+
if (!validState(state))
|
|
47
|
+
return exhausted(reattachWindowOpen(Number.NaN));
|
|
48
|
+
if (typeof event !== 'object' || event === null)
|
|
49
|
+
return cont(state);
|
|
50
|
+
const type = event.type;
|
|
51
|
+
const result = event.result;
|
|
52
|
+
const serverRetryAfterMs = event.serverRetryAfterMs;
|
|
53
|
+
if (type === 'new-segment')
|
|
54
|
+
return cont(reattachWindowOpen(nowMs, state.tuning));
|
|
55
|
+
if (usableClockMs(nowMs) === null || !Number.isFinite(state.deadlineMs))
|
|
56
|
+
return exhausted(state);
|
|
57
|
+
switch (type) {
|
|
58
|
+
case 'attempt':
|
|
59
|
+
return nowMs < state.deadlineMs ? cont(next(state, { attempt: state.attempt + 1 })) : exhausted(state);
|
|
60
|
+
case 'probe': {
|
|
61
|
+
if (result === 'not-found') {
|
|
62
|
+
const count = state.consecutiveNotFound + 1;
|
|
63
|
+
const confirmed = count >= state.tuning.notFoundConfirm && nowMs - state.enteredAtMs >= state.tuning.notFoundMinElapsedMs;
|
|
64
|
+
return cont(next(state, { consecutiveNotFound: count, notFoundConfirmed: confirmed }), confirmed);
|
|
65
|
+
}
|
|
66
|
+
if (result === 'readable' || result === 'unreachable')
|
|
67
|
+
return cont(next(state, { consecutiveNotFound: 0, notFoundConfirmed: false }));
|
|
68
|
+
return cont(state);
|
|
69
|
+
}
|
|
70
|
+
case 'tail-frame':
|
|
71
|
+
return cont(next(state, { consecutiveNotFound: 0, notFoundConfirmed: false }));
|
|
72
|
+
case 'tail-refused-404':
|
|
73
|
+
return state.notFoundConfirmed ? step(state, Object.freeze({ action: 'run-unknown', confirmations: state.consecutiveNotFound })) : cont(state);
|
|
74
|
+
case 'backoff': {
|
|
75
|
+
const own = reattachBackoffMs(state.attempt, state.tuning);
|
|
76
|
+
const delay = typeof serverRetryAfterMs === 'number' && Number.isFinite(serverRetryAfterMs) && serverRetryAfterMs > 0 ? Math.max(own, serverRetryAfterMs) : own;
|
|
77
|
+
return nowMs + delay >= state.deadlineMs ? exhausted(state) : step(state, Object.freeze({ action: 'wait', afterMs: delay }));
|
|
78
|
+
}
|
|
79
|
+
default:
|
|
80
|
+
return cont(state);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return exhausted(reattachWindowOpen(Number.NaN));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function poisonFrameInitial() {
|
|
88
|
+
return Object.freeze({ lastGoodSeq: null, strikeAt: undefined });
|
|
89
|
+
}
|
|
90
|
+
export const POISON_FRAME_RAW_MAX = 2_000;
|
|
91
|
+
export function poisonFrameStep(state, event) {
|
|
92
|
+
const keep = (s) => Object.freeze({ state: s, decision: Object.freeze({ action: 'continue' }) });
|
|
93
|
+
try {
|
|
94
|
+
if (typeof state !== 'object' || state === null || typeof event !== 'object' || event === null)
|
|
95
|
+
return keep(typeof state === 'object' && state !== null ? state : poisonFrameInitial());
|
|
96
|
+
const goodSeq = state.lastGoodSeq;
|
|
97
|
+
const strikeAt = state.strikeAt;
|
|
98
|
+
const type = event.type;
|
|
99
|
+
const lastGoodSeq = typeof goodSeq === 'string' ? goodSeq : null;
|
|
100
|
+
if (type === 'frame-ok') {
|
|
101
|
+
const evSeq = event.seq;
|
|
102
|
+
const seq = typeof evSeq === 'string' && evSeq.length > 0 ? evSeq : lastGoodSeq;
|
|
103
|
+
return keep(Object.freeze({ lastGoodSeq: seq, strikeAt: undefined }));
|
|
104
|
+
}
|
|
105
|
+
if (type === 'frame-bad') {
|
|
106
|
+
const evRaw = event.raw;
|
|
107
|
+
const raw = typeof evRaw === 'string' ? evRaw.slice(0, POISON_FRAME_RAW_MAX) : undefined;
|
|
108
|
+
if (strikeAt !== undefined && strikeAt === lastGoodSeq) {
|
|
109
|
+
return Object.freeze({ state, decision: Object.freeze({ action: 'raise', afterSeq: lastGoodSeq, ...(raw !== undefined ? { raw } : {}) }) });
|
|
110
|
+
}
|
|
111
|
+
return Object.freeze({ state: Object.freeze({ lastGoodSeq, strikeAt: lastGoodSeq }), decision: Object.freeze({ action: 'resume-from', seq: lastGoodSeq }) });
|
|
112
|
+
}
|
|
113
|
+
return keep(state);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return keep(typeof state === 'object' && state !== null ? state : poisonFrameInitial());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const MALFORMED_FRAME_LEAD = /^SSE: malformed event data/;
|
|
120
|
+
export function malformedFrameErrorOf(err) {
|
|
121
|
+
if (typeof err !== 'object' || err === null)
|
|
122
|
+
return null;
|
|
123
|
+
const message = readThrownSlot(err, 'message');
|
|
124
|
+
if (message === THROWN_SLOT_UNREADABLE || typeof message !== 'string' || !MALFORMED_FRAME_LEAD.test(message))
|
|
125
|
+
return null;
|
|
126
|
+
return Object.freeze({ detail: message.replace(MALFORMED_FRAME_LEAD, '').replace(/^\s*\(contract breach\)\s*:?\s*/, '').trim().slice(0, 300) });
|
|
127
|
+
}
|
|
@@ -9,5 +9,5 @@ export interface PrintNotificationFieldSpec {
|
|
|
9
9
|
why: string;
|
|
10
10
|
}
|
|
11
11
|
export declare const PRINT_NOTIFICATION_FIELD_MATRIX: readonly PrintNotificationFieldSpec[];
|
|
12
|
-
export declare function taskNotificationToPrintFrame(
|
|
12
|
+
export declare function taskNotificationToPrintFrame(raw: Record<string, unknown>, identity?: PrintFrameIdentity): Record<string, unknown> | null;
|
|
13
13
|
export declare function unregisteredPrintNotificationKeys(frame: Record<string, unknown>): string[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeTaskNotification } from '../notifications.js';
|
|
2
|
+
import { ownSnapshotRecord } from '../ownKey.js';
|
|
2
3
|
export const PRINT_NOTIFICATION_FIELD_MATRIX = [
|
|
3
4
|
{ field: 'type', from: '—', cc: true, why: "CC system 帧信封:{type:'system'}" },
|
|
4
5
|
{ field: 'subtype', from: '—', cc: true, why: "CC 完成通知的 subtype:'task_notification'(187 print/SDK 出口形)" },
|
|
@@ -15,7 +16,7 @@ export const PRINT_NOTIFICATION_FIELD_MATRIX = [
|
|
|
15
16
|
{ field: '_sema_partial', from: 'partial', cc: false, why: 'server 1.258:被终止子代的残果(消费方须渲成不完整,不得当完整结果)' },
|
|
16
17
|
{ field: '_sema_exit_code', from: 'exitCode', cc: false, why: '后台 bash 退出码(137=OOM 这类归因只在这一位上)' },
|
|
17
18
|
{ field: '_sema_diagnostics', from: 'diagnostics', cc: false, why: '引擎侧诊断串(UNTRUSTED,service 已 redact)' },
|
|
18
|
-
{ field: '_sema_result', from: 'result', cc: false, why: '完成结果正文(
|
|
19
|
+
{ field: '_sema_result', from: 'result', cc: false, why: '完成结果正文(帧带 result 必入 XML,print 出口同理不得独漏)' },
|
|
19
20
|
{ field: '_sema_lines', from: 'lines', cc: false, why: '尾部输出行(UNTRUSTED);交互面折进 <output-lines>' },
|
|
20
21
|
{ field: '_sema_recent_steps', from: 'recentSteps', cc: false, why: '结构化残局步骤 {tool,target,outcome}[] —— **原样透传**,不降级成交互面那份显示串(SDK 消费方要结构)' },
|
|
21
22
|
{ field: '_sema_edited_files', from: 'editedFiles', cc: false, why: '结构化改档清单 {path,edits}[];同上原样透传' },
|
|
@@ -25,7 +26,10 @@ export const PRINT_NOTIFICATION_FIELD_MATRIX = [
|
|
|
25
26
|
{ field: '_sema_injected', from: 'injected', cc: false, why: '[1818]§四:本帧**不**证明 XML 已进模型上下文;消费方须按此位判,不得按帧到达判' },
|
|
26
27
|
];
|
|
27
28
|
const PRINT_FRAME_KEYS = new Set(PRINT_NOTIFICATION_FIELD_MATRIX.map(r => r.field));
|
|
28
|
-
export function taskNotificationToPrintFrame(
|
|
29
|
+
export function taskNotificationToPrintFrame(raw, identity = {}) {
|
|
30
|
+
const n = ownSnapshotRecord(raw);
|
|
31
|
+
if (n === undefined)
|
|
32
|
+
return null;
|
|
29
33
|
const f = normalizeTaskNotification(n);
|
|
30
34
|
if (f === null)
|
|
31
35
|
return null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RequestLane } from './taskRequest.js';
|
|
2
|
+
export type RejectedSubmissionOrigin = 'user' | 'injected';
|
|
3
|
+
export declare const SUBMISSION_SURFACES: readonly ["interactive", "print"];
|
|
4
|
+
export type SubmissionSurface = (typeof SUBMISSION_SURFACES)[number];
|
|
5
|
+
export declare const SUBMISSION_ORIGINS: readonly ["user", "injected", "shell"];
|
|
6
|
+
export type SubmissionOrigin = (typeof SUBMISSION_ORIGINS)[number];
|
|
7
|
+
export declare const SUBMISSION_TOOLS: readonly ["full", "none"];
|
|
8
|
+
export type SubmissionTools = (typeof SUBMISSION_TOOLS)[number];
|
|
9
|
+
export interface SubmissionIdentity {
|
|
10
|
+
readonly surface: SubmissionSurface;
|
|
11
|
+
readonly origin: SubmissionOrigin;
|
|
12
|
+
readonly tools: SubmissionTools;
|
|
13
|
+
}
|
|
14
|
+
export declare const SUBMISSION_KINDS: readonly ["keyboard", "wake", "schedule", "plan_review_outcome", "shell_side"];
|
|
15
|
+
export type SubmissionKind = (typeof SUBMISSION_KINDS)[number];
|
|
16
|
+
export interface SubmissionProvenance {
|
|
17
|
+
readonly kind: SubmissionKind;
|
|
18
|
+
readonly origin: SubmissionOrigin;
|
|
19
|
+
readonly authoredByUser: boolean;
|
|
20
|
+
readonly source?: 'objective' | 'resume_message';
|
|
21
|
+
readonly selfHealOrigin?: RejectedSubmissionOrigin;
|
|
22
|
+
}
|
|
23
|
+
export declare function submissionProvenanceOf(kind: SubmissionKind): SubmissionProvenance | undefined;
|
|
24
|
+
export interface SubmissionIdentityInput {
|
|
25
|
+
readonly surface: SubmissionSurface;
|
|
26
|
+
readonly kind: SubmissionKind;
|
|
27
|
+
readonly tools: SubmissionTools;
|
|
28
|
+
}
|
|
29
|
+
export declare function submissionIdentityOf(input: SubmissionIdentityInput): SubmissionIdentity | undefined;
|
|
30
|
+
export declare function requestLaneOf(identity: SubmissionIdentity): RequestLane | undefined;
|
|
31
|
+
export declare function submissionOriginOf(identity: SubmissionIdentity): SubmissionOrigin | undefined;
|
|
32
|
+
export declare function submissionSurfaceOf(identity: {} | null | undefined): SubmissionSurface | undefined;
|
|
33
|
+
export interface SubmissionAxes {
|
|
34
|
+
readonly lane: RequestLane;
|
|
35
|
+
readonly origin: SubmissionOrigin;
|
|
36
|
+
}
|
|
37
|
+
export declare function submissionAxesOf(x: object): SubmissionAxes | undefined;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { guardedRead, readOwnDataValue } from '../ownKey.js';
|
|
2
|
+
export const SUBMISSION_SURFACES = Object.freeze(['interactive', 'print']);
|
|
3
|
+
export const SUBMISSION_ORIGINS = Object.freeze(['user', 'injected', 'shell']);
|
|
4
|
+
export const SUBMISSION_TOOLS = Object.freeze(['full', 'none']);
|
|
5
|
+
export const SUBMISSION_KINDS = Object.freeze(['keyboard', 'wake', 'schedule', 'plan_review_outcome', 'shell_side']);
|
|
6
|
+
const PROVENANCE_ROWS = Object.freeze({
|
|
7
|
+
keyboard: { origin: 'user', source: 'objective', selfHealOrigin: 'user' },
|
|
8
|
+
wake: { origin: 'user', source: 'resume_message', selfHealOrigin: 'injected' },
|
|
9
|
+
schedule: { origin: 'user', source: 'resume_message', selfHealOrigin: 'injected' },
|
|
10
|
+
plan_review_outcome: { origin: 'injected', selfHealOrigin: 'injected' },
|
|
11
|
+
shell_side: { origin: 'shell' },
|
|
12
|
+
});
|
|
13
|
+
const PROVENANCE = Object.freeze(Object.fromEntries(SUBMISSION_KINDS.map((kind) => {
|
|
14
|
+
const row = PROVENANCE_ROWS[kind];
|
|
15
|
+
const p = Object.freeze({
|
|
16
|
+
kind,
|
|
17
|
+
origin: row.origin,
|
|
18
|
+
authoredByUser: row.origin === 'user',
|
|
19
|
+
...(row.source !== undefined ? { source: row.source } : {}),
|
|
20
|
+
...(row.selfHealOrigin !== undefined ? { selfHealOrigin: row.selfHealOrigin } : {}),
|
|
21
|
+
});
|
|
22
|
+
return [kind, p];
|
|
23
|
+
})));
|
|
24
|
+
const memberOf = (set, v) => typeof v === 'string' && set.includes(v);
|
|
25
|
+
const slotOf = (o, key) => guardedRead(() => readOwnDataValue(o, key));
|
|
26
|
+
const isCarrier = (x) => typeof x === 'object' && x !== null && guardedRead(() => !Array.isArray(x)) === true;
|
|
27
|
+
export function submissionProvenanceOf(kind) {
|
|
28
|
+
return typeof kind === 'string' && Object.hasOwn(PROVENANCE, kind) ? PROVENANCE[kind] : undefined;
|
|
29
|
+
}
|
|
30
|
+
export function submissionIdentityOf(input) {
|
|
31
|
+
if (!isCarrier(input))
|
|
32
|
+
return undefined;
|
|
33
|
+
const surface = slotOf(input, 'surface');
|
|
34
|
+
const kind = slotOf(input, 'kind');
|
|
35
|
+
const tools = slotOf(input, 'tools');
|
|
36
|
+
if (!memberOf(SUBMISSION_SURFACES, surface) || !memberOf(SUBMISSION_KINDS, kind) || !memberOf(SUBMISSION_TOOLS, tools))
|
|
37
|
+
return undefined;
|
|
38
|
+
const provenance = submissionProvenanceOf(kind);
|
|
39
|
+
return provenance === undefined ? undefined : Object.freeze({ surface, origin: provenance.origin, tools });
|
|
40
|
+
}
|
|
41
|
+
const identitySnapshotOf = (x) => {
|
|
42
|
+
if (!isCarrier(x))
|
|
43
|
+
return undefined;
|
|
44
|
+
const surface = slotOf(x, 'surface');
|
|
45
|
+
const origin = slotOf(x, 'origin');
|
|
46
|
+
const tools = slotOf(x, 'tools');
|
|
47
|
+
return memberOf(SUBMISSION_SURFACES, surface) && memberOf(SUBMISSION_ORIGINS, origin) && memberOf(SUBMISSION_TOOLS, tools)
|
|
48
|
+
? Object.freeze({ surface, origin, tools })
|
|
49
|
+
: undefined;
|
|
50
|
+
};
|
|
51
|
+
const laneOfIdentity = (id) => id.surface === 'print' ? 'print' : id.origin === 'shell' && id.tools === 'none' ? 'utility' : 'interactive';
|
|
52
|
+
export function requestLaneOf(identity) {
|
|
53
|
+
const id = identitySnapshotOf(identity);
|
|
54
|
+
return id === undefined ? undefined : laneOfIdentity(id);
|
|
55
|
+
}
|
|
56
|
+
export function submissionOriginOf(identity) {
|
|
57
|
+
return identitySnapshotOf(identity)?.origin;
|
|
58
|
+
}
|
|
59
|
+
export function submissionSurfaceOf(identity) {
|
|
60
|
+
return typeof identity === 'object' && identity !== null ? identitySnapshotOf(identity)?.surface : undefined;
|
|
61
|
+
}
|
|
62
|
+
export function submissionAxesOf(x) {
|
|
63
|
+
const id = identitySnapshotOf(x);
|
|
64
|
+
return id === undefined ? undefined : Object.freeze({ lane: laneOfIdentity(id), origin: id.origin });
|
|
65
|
+
}
|