@sema-agent/client-core 0.77.1 → 0.77.2
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 +13 -1
- package/README.md +5 -4
- package/dist/abortableSleep.d.ts +0 -28
- package/dist/abortableSleep.js +0 -28
- package/dist/adapt/arms.d.ts +0 -46
- package/dist/adapt/arms.js +9 -544
- package/dist/adapt/ids.d.ts +0 -58
- package/dist/adapt/ids.js +0 -63
- package/dist/adapt/instanceLedger.d.ts +0 -25
- package/dist/adapt/instanceLedger.js +0 -20
- package/dist/adapt/panelTasks.d.ts +0 -69
- package/dist/adapt/panelTasks.js +0 -95
- package/dist/adapt/textSegmentAuthority.d.ts +1 -137
- package/dist/adapt/textSegmentAuthority.js +0 -54
- package/dist/adapt/textStream.d.ts +0 -252
- package/dist/adapt/textStream.js +2 -281
- package/dist/adapt/toolCards.d.ts +0 -46
- package/dist/adapt/toolCards.js +0 -23
- package/dist/adapt/turnFlags.d.ts +0 -54
- package/dist/adapt/turnFlags.js +1 -17
- package/dist/adapt/wireShapes.d.ts +0 -92
- package/dist/adapt/wireShapes.js +0 -83
- package/dist/adapt.d.ts +0 -55
- package/dist/adapt.js +1 -120
- package/dist/adapter/activeRunSelfHeal.d.ts +22 -515
- package/dist/adapter/activeRunSelfHeal.js +10 -625
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -305
- package/dist/adapter/downstream/eventToSdkMessage.js +2 -867
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -314
- package/dist/adapter/downstream/terminalToSdkResult.js +13 -560
- package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +0 -95
- package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -31
- package/dist/adapter/runStream.d.ts +0 -206
- package/dist/adapter/runStream.js +6 -596
- package/dist/adapter/types.d.ts +0 -111
- package/dist/adapter/types.js +0 -29
- package/dist/agentSession/backgroundView.d.ts +0 -106
- package/dist/agentSession/backgroundView.js +3 -49
- package/dist/agentSession/contract.d.ts +0 -98
- package/dist/agentSession/contract.js +0 -12
- package/dist/agentsWireCaps.d.ts +0 -72
- package/dist/agentsWireCaps.js +4 -72
- package/dist/approvalsStreamLiveCapability.d.ts +0 -25
- package/dist/approvalsStreamLiveCapability.js +0 -31
- package/dist/argvFlagValue.d.ts +0 -33
- package/dist/argvFlagValue.js +3 -35
- package/dist/attachmentsWireCaps.d.ts +0 -127
- package/dist/attachmentsWireCaps.js +0 -144
- package/dist/autoModeUnavailable.d.ts +0 -120
- package/dist/autoModeUnavailable.js +0 -144
- package/dist/classifierStatus.d.ts +0 -72
- package/dist/classifierStatus.js +0 -167
- package/dist/classifierVerdictWire.d.ts +0 -54
- package/dist/classifierVerdictWire.js +0 -133
- package/dist/clientContextWireCaps.d.ts +0 -37
- package/dist/clientContextWireCaps.js +0 -36
- package/dist/clientSlice.d.ts +0 -63
- package/dist/clientSlice.js +0 -45
- package/dist/cloudConfigWireCaps.d.ts +0 -86
- package/dist/cloudConfigWireCaps.js +2 -65
- package/dist/compensations.d.ts +0 -52
- package/dist/compensations.js +2 -63
- package/dist/controlRouter.d.ts +2 -208
- package/dist/controlRouter.js +1 -129
- package/dist/coreValuePorts.d.ts +0 -84
- package/dist/coreValuePorts.js +0 -29
- package/dist/decideReceipt.d.ts +0 -110
- package/dist/decideReceipt.js +0 -84
- package/dist/detachWire.d.ts +0 -130
- package/dist/detachWire.js +1 -130
- package/dist/deviceExecutorManagementCapability.d.ts +2 -35
- package/dist/deviceExecutorManagementCapability.js +1 -37
- package/dist/diagnostics.d.ts +0 -8
- package/dist/diagnostics.js +0 -8
- package/dist/diff/patch.d.ts +0 -17
- package/dist/diff/patch.js +0 -19
- package/dist/effectiveFacts.d.ts +0 -40
- package/dist/effectiveFacts.js +0 -22
- package/dist/effortWire.d.ts +0 -11
- package/dist/effortWire.js +0 -12
- package/dist/engineAgentPanelStore.d.ts +0 -169
- package/dist/engineAgentPanelStore.js +13 -293
- package/dist/engineCapReader.d.ts +0 -62
- package/dist/engineCapReader.js +1 -43
- package/dist/engineCapsCache.d.ts +0 -177
- package/dist/engineCapsCache.js +0 -199
- package/dist/engineCapsGenerationGuard.d.ts +0 -2
- package/dist/engineCapsGenerationGuard.js +0 -11
- package/dist/engineErrorCodes.d.ts +1 -316
- package/dist/engineErrorCodes.js +0 -427
- package/dist/engineHttpTools.d.ts +0 -29
- package/dist/engineHttpTools.js +0 -29
- package/dist/engineIdentity.d.ts +0 -83
- package/dist/engineIdentity.js +0 -88
- package/dist/engineInlineTaskStats.d.ts +0 -57
- package/dist/engineInlineTaskStats.js +1 -42
- package/dist/engineNoticeCodes.d.ts +0 -190
- package/dist/engineNoticeCodes.js +0 -182
- package/dist/engineSessionParam.d.ts +0 -30
- package/dist/engineSessionParam.js +0 -52
- package/dist/engineToolLabelStore.d.ts +0 -29
- package/dist/engineToolLabelStore.js +0 -31
- package/dist/engineWireSdk.d.ts +0 -90
- package/dist/engineWireSdk.js +0 -74
- package/dist/engineWireTarget.d.ts +0 -14
- package/dist/engineWireTarget.js +0 -39
- package/dist/env/localeGeo.d.ts +0 -12
- package/dist/env/localeGeo.js +2 -77
- package/dist/env/localeTag.d.ts +0 -34
- package/dist/env/localeTag.js +0 -32
- package/dist/env/uiLanguage.d.ts +0 -13
- package/dist/env/uiLanguage.js +0 -25
- package/dist/envFlag.d.ts +0 -37
- package/dist/envFlag.js +0 -40
- package/dist/executionLaneCapability.d.ts +0 -48
- package/dist/executionLaneCapability.js +0 -54
- package/dist/finalVerifyWire.d.ts +0 -67
- package/dist/finalVerifyWire.js +3 -43
- package/dist/fleet/fleetLedger.d.ts +0 -308
- package/dist/fleet/fleetLedger.js +10 -429
- package/dist/fleet/fleetProjection.d.ts +0 -240
- package/dist/fleet/fleetProjection.js +0 -189
- package/dist/fleet/fleetRowAgentType.d.ts +0 -6
- package/dist/fleet/fleetRowAgentType.js +1 -32
- package/dist/fleet/workflowSizeWarning.d.ts +0 -47
- package/dist/fleet/workflowSizeWarning.js +1 -46
- package/dist/fleetAgentPanelProjection.d.ts +0 -48
- package/dist/fleetAgentPanelProjection.js +8 -173
- package/dist/fleetTaskDesc.d.ts +0 -39
- package/dist/fleetTaskDesc.js +0 -69
- package/dist/forkWireCaps.d.ts +0 -23
- package/dist/forkWireCaps.js +1 -24
- package/dist/gateOutcome.d.ts +0 -140
- package/dist/gateOutcome.js +0 -85
- package/dist/gateVocabulary.d.ts +0 -114
- package/dist/gateVocabulary.js +1 -161
- package/dist/goalStopHook.d.ts +0 -127
- package/dist/goalStopHook.js +0 -178
- package/dist/headlessPermissionModeWire.d.ts +0 -76
- package/dist/headlessPermissionModeWire.js +1 -155
- package/dist/headlessReconnectWire.d.ts +0 -84
- package/dist/headlessReconnectWire.js +13 -67
- package/dist/hitl/approvalDecisionNoteAudit.d.ts +0 -49
- package/dist/hitl/approvalDecisionNoteAudit.js +0 -56
- package/dist/hitl/approvalOutcomeNote.d.ts +0 -2
- package/dist/hitl/approvalOutcomeNote.js +0 -20
- package/dist/hitl/approvalResolution.d.ts +0 -113
- package/dist/hitl/approvalResolution.js +0 -66
- package/dist/hitl/approvalsFeed.d.ts +0 -183
- package/dist/hitl/approvalsFeed.js +12 -243
- package/dist/hitl/armedGateRegistry.d.ts +0 -55
- package/dist/hitl/armedGateRegistry.js +0 -146
- package/dist/hitl/askGateWire.d.ts +0 -86
- package/dist/hitl/askGateWire.js +1 -95
- package/dist/hitl/askParkRowRouting.d.ts +0 -123
- package/dist/hitl/askParkRowRouting.js +1 -89
- package/dist/hitl/crashConverged.d.ts +0 -148
- package/dist/hitl/crashConverged.js +0 -214
- package/dist/hitl/editedRuleTextPrecheck.d.ts +0 -109
- package/dist/hitl/editedRuleTextPrecheck.js +0 -71
- package/dist/hitl/frameRouter.d.ts +0 -134
- package/dist/hitl/frameRouter.js +6 -378
- package/dist/hitl/gateIdentity.d.ts +0 -39
- package/dist/hitl/gateIdentity.js +0 -41
- package/dist/hitl/gateLedger.d.ts +0 -267
- package/dist/hitl/gateLedger.js +0 -121
- package/dist/hitl/hitlBridge.d.ts +7 -431
- package/dist/hitl/hitlBridge.js +7 -476
- package/dist/hitl/hitlHostSurface.d.ts +0 -150
- package/dist/hitl/hitlHostSurface.js +0 -169
- package/dist/hitl/livePendingAsk.d.ts +0 -91
- package/dist/hitl/livePendingAsk.js +0 -74
- package/dist/hitl/localAllowRule.d.ts +0 -62
- package/dist/hitl/localAllowRule.js +1 -33
- package/dist/hitl/parkOwnership.d.ts +0 -56
- package/dist/hitl/parkOwnership.js +0 -22
- package/dist/hitl/parkResolver.d.ts +3 -88
- package/dist/hitl/parkResolver.js +8 -349
- package/dist/hitl/parkRowBirthWait.d.ts +2 -26
- package/dist/hitl/parkRowBirthWait.js +3 -93
- package/dist/hitl/persistedRulesWire.d.ts +13 -358
- package/dist/hitl/persistedRulesWire.js +0 -310
- package/dist/hitl/planReviewWire.d.ts +4 -176
- package/dist/hitl/planReviewWire.js +9 -312
- package/dist/hitl/resumeRunningCard.d.ts +0 -105
- package/dist/hitl/resumeRunningCard.js +0 -105
- package/dist/hitl/sessionPolicyWire.d.ts +11 -191
- package/dist/hitl/sessionPolicyWire.js +0 -149
- package/dist/hitl/suspendedReopen.d.ts +3 -24
- package/dist/hitl/suspendedReopen.js +0 -14
- package/dist/hitl/toolApprovalWire.d.ts +5 -1308
- package/dist/hitl/toolApprovalWire.js +5 -945
- package/dist/hooksWireCaps.d.ts +0 -38
- package/dist/hooksWireCaps.js +0 -190
- package/dist/host.d.ts +0 -105
- package/dist/host.js +0 -33
- package/dist/hostEnv.d.ts +0 -14
- package/dist/hostEnv.js +0 -13
- package/dist/imagesWireCaps.d.ts +0 -21
- package/dist/imagesWireCaps.js +0 -22
- package/dist/index.d.ts +0 -134
- package/dist/index.js +0 -476
- package/dist/interactiveHalt.d.ts +5 -153
- package/dist/interactiveHalt.js +0 -111
- package/dist/interactiveToolsWire.d.ts +0 -62
- package/dist/interactiveToolsWire.js +1 -67
- package/dist/leaderConflict.d.ts +0 -59
- package/dist/leaderConflict.js +0 -48
- package/dist/limitsWire.d.ts +0 -125
- package/dist/limitsWire.js +2 -120
- package/dist/liveInitToolFace.d.ts +0 -77
- package/dist/liveInitToolFace.js +1 -109
- package/dist/liveModelCatalog.d.ts +0 -52
- package/dist/liveModelCatalog.js +0 -48
- package/dist/liveQuestionStore.d.ts +0 -87
- package/dist/liveQuestionStore.js +1 -56
- package/dist/mcpLiveness.d.ts +0 -151
- package/dist/mcpLiveness.js +0 -122
- package/dist/mcpPanel.d.ts +0 -104
- package/dist/mcpPanel.js +0 -49
- package/dist/mcpReconnect.d.ts +0 -58
- package/dist/mcpReconnect.js +0 -69
- package/dist/mcpWireCaps.d.ts +0 -55
- package/dist/mcpWireCaps.js +1 -13
- package/dist/memoryComplianceCapability.d.ts +3 -57
- package/dist/memoryComplianceCapability.js +0 -57
- package/dist/memoryEntriesWire.d.ts +6 -198
- package/dist/memoryEntriesWire.js +0 -144
- package/dist/memoryOriginCapability.d.ts +3 -53
- package/dist/memoryOriginCapability.js +0 -50
- package/dist/memorySpecWire.d.ts +0 -116
- package/dist/memorySpecWire.js +0 -150
- package/dist/model/catalog.d.ts +0 -111
- package/dist/model/catalog.js +0 -87
- package/dist/model/catalogLoader.d.ts +0 -114
- package/dist/model/catalogLoader.js +2 -139
- package/dist/model/modelSupplyRules.d.ts +1 -55
- package/dist/model/modelSupplyRules.js +0 -62
- package/dist/model/providerAuth.d.ts +0 -103
- package/dist/model/providerAuth.js +2 -38
- package/dist/model/providerCatalog.d.ts +0 -45
- package/dist/model/providerCatalog.js +0 -37
- package/dist/model/providerPresets.d.ts +0 -33
- package/dist/model/providerPresets.js +2 -91
- package/dist/model/tierVocabulary.d.ts +0 -31
- package/dist/model/tierVocabulary.js +0 -27
- package/dist/modelBudgetRule.d.ts +0 -39
- package/dist/modelBudgetRule.js +0 -39
- package/dist/modelCapabilityProbe.d.ts +0 -175
- package/dist/modelCapabilityProbe.js +0 -147
- package/dist/modelWireCaps.d.ts +0 -13
- package/dist/modelWireCaps.js +0 -13
- package/dist/notifications.d.ts +0 -233
- package/dist/notifications.js +14 -492
- package/dist/oneShotWireCaps.d.ts +0 -34
- package/dist/oneShotWireCaps.js +0 -35
- package/dist/ownKey.d.ts +0 -33
- package/dist/ownKey.js +0 -33
- package/dist/panelRunningHistory.d.ts +0 -28
- package/dist/panelRunningHistory.js +0 -43
- package/dist/peerFrames.d.ts +0 -71
- package/dist/peerFrames.js +0 -168
- package/dist/peerLaneCapability.d.ts +0 -44
- package/dist/peerLaneCapability.js +0 -52
- package/dist/permissionRuleIssue.d.ts +0 -30
- package/dist/permissionRuleIssue.js +0 -78
- package/dist/permissionRulesWriteCapability.d.ts +0 -46
- package/dist/permissionRulesWriteCapability.js +0 -54
- package/dist/permissionWireCaps.d.ts +0 -37
- package/dist/permissionWireCaps.js +0 -37
- package/dist/postureKnob.d.ts +0 -71
- package/dist/postureKnob.js +0 -86
- package/dist/principalWire.d.ts +0 -17
- package/dist/principalWire.js +0 -17
- package/dist/printToolResultFrame.d.ts +0 -100
- package/dist/printToolResultFrame.js +0 -33
- package/dist/promptProfileWireCaps.d.ts +0 -13
- package/dist/promptProfileWireCaps.js +0 -13
- package/dist/readFacePosture.d.ts +0 -43
- package/dist/readFacePosture.js +0 -46
- package/dist/request/printNotification.d.ts +0 -20
- package/dist/request/printNotification.js +0 -55
- package/dist/request/taskRequest.d.ts +0 -249
- package/dist/request/taskRequest.js +6 -498
- package/dist/resumeRefusalCopy.d.ts +0 -136
- package/dist/resumeRefusalCopy.js +1 -117
- package/dist/retainBackgroundWireCaps.d.ts +0 -48
- package/dist/retainBackgroundWireCaps.js +0 -48
- package/dist/retryStatus.d.ts +2 -221
- package/dist/retryStatus.js +0 -107
- package/dist/rewindWireCaps.d.ts +0 -27
- package/dist/rewindWireCaps.js +0 -24
- package/dist/runCancelContext.d.ts +1 -20
- package/dist/runCancelContext.js +0 -34
- package/dist/runTerminal.d.ts +0 -273
- package/dist/runTerminal.js +0 -177
- package/dist/sandboxWire.d.ts +0 -38
- package/dist/sandboxWire.js +0 -82
- package/dist/scenarioWire.d.ts +0 -60
- package/dist/scenarioWire.js +0 -68
- package/dist/scratchpadWireCaps.d.ts +0 -11
- package/dist/scratchpadWireCaps.js +0 -32
- package/dist/sdkWireTransit.d.ts +0 -38
- package/dist/sdkWireTransit.js +0 -30
- package/dist/seam.d.ts +18 -853
- package/dist/seam.js +0 -52
- package/dist/seatContract.d.ts +0 -555
- package/dist/seatContract.js +5 -304
- package/dist/selfOrchestrationDenial.d.ts +0 -189
- package/dist/selfOrchestrationDenial.js +0 -162
- package/dist/selfOrchestrationWireCaps.d.ts +0 -38
- package/dist/selfOrchestrationWireCaps.js +0 -38
- package/dist/sessionMap.d.ts +0 -60
- package/dist/sessionMap.js +0 -37
- package/dist/sessionMemoryStatus.d.ts +11 -114
- package/dist/sessionMemoryStatus.js +0 -112
- package/dist/sessionModelLatch.d.ts +0 -29
- package/dist/sessionModelLatch.js +0 -40
- package/dist/sessionPolicyCapability.d.ts +3 -53
- package/dist/sessionPolicyCapability.js +0 -52
- package/dist/sessionSlot.d.ts +0 -26
- package/dist/sessionSlot.js +0 -17
- package/dist/skillsWireCaps.d.ts +0 -87
- package/dist/skillsWireCaps.js +0 -38
- package/dist/sqlEngineCapability.d.ts +0 -118
- package/dist/sqlEngineCapability.js +0 -134
- package/dist/sseIdleTriage.d.ts +0 -79
- package/dist/sseIdleTriage.js +1 -80
- package/dist/steering.d.ts +0 -54
- package/dist/steering.js +0 -63
- package/dist/subagent/engineCompactWire.d.ts +0 -34
- package/dist/subagent/engineCompactWire.js +4 -134
- package/dist/subagent/engineDelegatedPrompt.d.ts +0 -31
- package/dist/subagent/engineDelegatedPrompt.js +1 -103
- package/dist/subagent/engineRowStopGate.d.ts +0 -20
- package/dist/subagent/engineRowStopGate.js +0 -49
- package/dist/subagent/engineSubagentOutput.d.ts +0 -7
- package/dist/subagent/engineSubagentOutput.js +1 -51
- package/dist/subagent/engineSubagentResume.d.ts +2 -279
- package/dist/subagent/engineSubagentResume.js +2 -129
- package/dist/subagent/engineSubagentSteer.d.ts +0 -26
- package/dist/subagent/engineSubagentSteer.js +0 -63
- package/dist/subagent/engineSubagentTail.d.ts +0 -38
- package/dist/subagent/engineSubagentTail.js +2 -110
- package/dist/subagent/engineTaskHandleWire.d.ts +6 -67
- package/dist/subagent/engineTaskHandleWire.js +0 -126
- package/dist/subagent/subagentOwnerAbsence.d.ts +0 -2
- package/dist/subagent/subagentOwnerAbsence.js +0 -25
- package/dist/subagentContentStore.d.ts +3 -260
- package/dist/subagentContentStore.js +7 -540
- package/dist/systemReminderTag.d.ts +0 -49
- package/dist/systemReminderTag.js +0 -61
- package/dist/toolResult.d.ts +1 -211
- package/dist/toolResult.js +1 -358
- package/dist/toolRoster.d.ts +0 -140
- package/dist/toolRoster.js +0 -66
- package/dist/typePins.d.ts +0 -46
- package/dist/types/engineState.d.ts +0 -71
- package/dist/types/engineState.js +0 -16
- package/dist/ultracodeWireCaps.d.ts +0 -75
- package/dist/ultracodeWireCaps.js +0 -92
- package/dist/unrefTimer.d.ts +0 -27
- package/dist/webSearchBackendCapability.d.ts +0 -72
- package/dist/webSearchBackendCapability.js +0 -79
- package/dist/webSearchWireCaps.d.ts +0 -37
- package/dist/webSearchWireCaps.js +0 -34
- package/dist/websearch/searchProviderPresets.d.ts +0 -81
- package/dist/websearch/searchProviderPresets.js +0 -27
- package/dist/wireErrorTriage.d.ts +4 -160
- package/dist/wireErrorTriage.js +0 -171
- package/dist/wireRefusalCopy.d.ts +0 -28
- package/dist/wireRefusalCopy.js +0 -28
- package/dist/workflow.d.ts +0 -40
- package/dist/workflow.js +0 -52
- package/dist/workflowClient.d.ts +0 -122
- package/dist/workflowClient.js +8 -360
- package/dist/workflowMonitor.d.ts +2 -72
- package/dist/workflowMonitor.js +0 -26
- package/dist/writeProtectionCapability.d.ts +0 -112
- package/dist/writeProtectionCapability.js +0 -109
- package/docs/INTEGRATION-CLIENTS.md +30 -1
- package/package.json +1 -1
package/dist/detachWire.d.ts
CHANGED
|
@@ -1,108 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ⇄ B6 批搬迁(2026-07-27,设计稿 §3 B6):cli `src/sema/detachWire.ts` **拆**搬 —— 判定半场 +
|
|
3
|
-
* cancel-arm 台账进包,**信号路径的裸 fetch 发射留宿主**(设计稿 §3 表 `S/detachWire.ts` 那条
|
|
4
|
-
* 脚注:`:221` 裸 cancel = TUI 留,宪法例外 census C1-4)。
|
|
5
|
-
*
|
|
6
|
-
* 🔴 **拆缝画在哪、为什么**:`fireBestEffortDetachCancel` 是**信号处理器**里同步 DISPATCH 的
|
|
7
|
-
* fire-and-forget —— 它成立的前提是「进程正在被 SIGINT/SIGTERM 拆掉,不能 await、不能构造重对象」。
|
|
8
|
-
* 这套前提是 **Node 进程模型**的,浏览器/桌面渲染进程根本没有信号;而且它有意**绕开 SDK verb**
|
|
9
|
-
* (`AgentClient.runs.cancel` 是 await 型,包一层 void+catch 反而把纪律面弄模糊)——那是壳的
|
|
10
|
-
* 宪法例外,不该被搬成「库里有一处裸 fetch」。⇒ 发射留宿主,库出**台账 + 读口**。
|
|
11
|
-
*
|
|
12
|
-
* 🔴 **模块级状态与读写口同包**([multiclient-migration-batch-discipline]):`cancelArm` 一份,
|
|
13
|
-
* 写口 `armDetachCancel`(seamQueryEngine.ask 在头真拼上请求时调)、读口 `isDetachArmed`
|
|
14
|
-
* (`detachDurableOffHint` 的第一道门)/ `detachedTaskId`(分诊文案)/ `detachCancelArm`
|
|
15
|
-
* (**宿主发射腿**唯一取件口)全在本文件。壳侧 shim 的 `fireBestEffortDetachCancel` 从
|
|
16
|
-
* `detachCancelArm()` 取件 ⇒ 仍然只有一份台账;壳若自己再存一份 = 头发了但 hint 判不出、
|
|
17
|
-
* Ctrl+C 取消不掉(两个静默失效各一半)。
|
|
18
|
-
*
|
|
19
|
-
* 🔴 env 读取走 `hostEnv()`(本包零 `process`,portability 门盯着);Node 下同一对象 ⇒ 壳侧
|
|
20
|
-
* 「不传 env 参数」的调用点行为一字节不变。
|
|
21
|
-
*
|
|
22
|
-
* ── 以下为原文件的领域说明(逐字保留)────────────────────────────────────────────────────────
|
|
23
|
-
*
|
|
24
|
-
* detachWire — headless `-p` detach-on-disconnect wire (重连腿 M1 壳半场, 2026-07-15,
|
|
25
|
-
* design/HEADLESS-RECONNECT-DESIGN.md §6 M1; mirrors finalVerifyWire/limitsWire in shape).
|
|
26
|
-
*
|
|
27
|
-
* WHY: the `/v1/tasks/stream` lane ABORTS the run on client disconnect by design (anti token-burn —
|
|
28
|
-
* this is also the interactive cancel mechanism). server ≥1.196 accepts an opt-in escape hatch: the
|
|
29
|
-
* `x-detach-on-disconnect: true` REQUEST HEADER makes a disconnect DETACH the run instead — it keeps
|
|
30
|
-
* running to its terminal and lands in the durable run ledger (`GET /v1/runs/:id`; a deployment with
|
|
31
|
-
* no durable ledger 400s fail-loud — the shell's self-spawned engine always sets DB_BACKEND=local,
|
|
32
|
-
* so the ledger is always there on that lane). M1 = header + cancel fallback ONLY; reconnect/resume
|
|
33
|
-
* (R1 runs.events lane-switch / R2 idempotent re-POST) is M2/M3 — NOT here.
|
|
34
|
-
*
|
|
35
|
-
* 铁律 1 (design §2.1): the header is stamped ONLY on the headless `-p` lane (seamQueryEngine.ask),
|
|
36
|
-
* live-gated on SEMA_LIVE_BASEURL exactly like finalVerifyWire — the interactive REPL lane
|
|
37
|
-
* (seamQuery.ts) never imports this module, so Esc/interrupt keeps its disconnect==cancel semantics
|
|
38
|
-
* verbatim, and the mock/pty lanes never see the header (offline projection byte-identical).
|
|
39
|
-
*
|
|
40
|
-
* 铁律 2 (design §2.2): once detach is on, a USER abort must carry an explicit best-effort cancel —
|
|
41
|
-
* a detached run would otherwise burn tokens to completion in the background after Ctrl+C. The
|
|
42
|
-
* cancel-arm half of this module (armDetachCancel / the host's fireBestEffortDetachCancel) is
|
|
43
|
-
* consumed by the `-p` SIGINT handler and the SIGTERM/SIGHUP tail-frame handler (cli/print.ts):
|
|
44
|
-
* fire-and-forget `POST /v1/runs/:id/cancel` (the SDK RunsResource.cancel verb, runs.js — verified:
|
|
45
|
-
* no body), never awaited on the signal path. taskId not yet captured (pre X-Task-Id window) ⇒
|
|
46
|
-
* ACCEPTED uncancellable window — detach's inherent cost, no waiting introduced (design §2.2 记账).
|
|
47
|
-
*
|
|
48
|
-
* PRECEDENCE (off wins; otherwise DEFAULT ON):
|
|
49
|
-
* a) `SEMA_HEADLESS_DETACH` env = an {@link envFlagOff} spelling (REF-CC-141 dup-02 单源;settings
|
|
50
|
-
* env lane, fail-soft — any OTHER value including typos stays default-on, finalVerifyWire
|
|
51
|
-
* discipline) → off.
|
|
52
|
-
* b) VERSION GATE: SEMA_ENGINE_URL in play (user-supplied external engine) and `/health` CONFIRMS
|
|
53
|
-
* version <1.196.0 (or no version field = pre-1.96) → off + SEMA_DEBUG log.
|
|
54
|
-
* Unlike limitsWire (warn-and-send: an old server drops an unknown BODY field server-side), here
|
|
55
|
-
* we GATE: an old server silently ignores the unknown HEADER, so a disconnect still kills the
|
|
56
|
-
* run — sending it would only manufacture a false "detached" belief downstream (判死文案 would
|
|
57
|
-
* lie). Probe unreachable / unparsable response ⇒ fail-soft SEND (can't confirm staleness; the
|
|
58
|
-
* stream POST itself fails loudly if the engine is truly down).
|
|
59
|
-
* c) self-spawn lane (no SEMA_ENGINE_URL): release-pinned ≥1.197.0 — trusted, no probe, header on.
|
|
60
|
-
*/
|
|
61
1
|
import { type EnvLike } from './hostEnv.js';
|
|
62
|
-
/** The server ≥1.196 opt-in header: disconnect ⇒ detach (run continues to durable terminal). */
|
|
63
2
|
export declare const DETACH_HEADER = "x-detach-on-disconnect";
|
|
64
|
-
/** Settings-lane env knob(settings.json `env` 块 → 1a-envseed → process.env)。'false'/'0' = off。 */
|
|
65
3
|
export declare const HEADLESS_DETACH_ENV = "SEMA_HEADLESS_DETACH";
|
|
66
|
-
/**
|
|
67
|
-
* First server version that honors the detach header — 1.196.0, the SAME floor as the limits wire
|
|
68
|
-
* (both landed in the [857] batch), so the version predicate is limitsWire.versionSupportsLimits
|
|
69
|
-
* re-exported under the detach name (one comparator, two wires — 抽共用 per design).
|
|
70
|
-
*/
|
|
71
4
|
export declare const DETACH_WIRE_MIN_ENGINE: readonly [number, number, number];
|
|
72
|
-
/** True when the engine version string satisfies the detach-wire minimum (≥1.196.0). Unparsable ⇒ false. */
|
|
73
5
|
export declare const versionSupportsDetach: (v: string | undefined) => boolean;
|
|
74
|
-
/**
|
|
75
|
-
* The settings-lane off-switch: `SEMA_HEADLESS_DETACH` set to an {@link envFlagOff} spelling
|
|
76
|
-
* (REF-CC-141 dup-02 单源:`0`/`false`/`no`/`off`/`none`,大小写不敏感)disables the header. Any other
|
|
77
|
-
* value (empty/'true'/typo) = default ON — fail-soft, a settings typo never flips the lane silently
|
|
78
|
-
* to the strict-alignment (disconnect-kills-run) mode (finalVerifyWire 纪律).
|
|
79
|
-
*
|
|
80
|
-
* 🔴 [2393] sweep-F12(2026-08-03 全窗复审)**承诺范围如实**:上面那句话是在 off 集只有
|
|
81
|
-
* `{false,0}` 的时代写的,当时它覆盖 `no`/`off`/`none` 三个拼写(它们落进「任何其它值 ⇒ 默认 ON」)。
|
|
82
|
-
* REF-CC-141 把 off 集扩到五词之后,**这三个拼写现在会**把车道翻成 disconnect-kills-run。
|
|
83
|
-
* 扩集本身是既定方向(用户写 `no`/`off`/`none` 时意图确实是「关」),这里只把范围说清楚:
|
|
84
|
-
* 「typo 绝不静默翻车道」现在指的是 `{false,0,no,off,none}` **之外**的拼写。
|
|
85
|
-
*/
|
|
86
6
|
export declare function headlessDetachDisabledByEnv(env?: EnvLike): boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Version-gate probe: GET `${baseUrl}/health`, read `version`. Returns FALSE only when the engine is
|
|
89
|
-
* CONFIRMED older than 1.196.0 (parsable old version, or a healthy response with no version field =
|
|
90
|
-
* pre-1.96). Unreachable / timeout / non-2xx / unparsable JSON ⇒ TRUE (fail-soft: can't confirm
|
|
91
|
-
* staleness — the header is harmless on the wire, and the stream POST fails loudly on a dead engine).
|
|
92
|
-
* Same probe shape as limitsWire.engineLimitsSupportWarning (1.5s budget, never throws).
|
|
93
|
-
*/
|
|
94
|
-
/** 0.72.13 CC-53:版本闸探测的**三态**读数。`unknown` = /health 答得奇怪(非 2xx / 坏 JSON)或整个不可达 —— 不能证明陈旧,也没证明支持。 */
|
|
95
7
|
export type EngineDetachSupport = 'supported' | 'unsupported' | 'unknown';
|
|
96
|
-
/**
|
|
97
|
-
* 三态读口(0.72.13 CC-53;test 证据帖「异常被吞成健康值」一类):此前只有布尔口,「不可达」与「确认支持」同返 `true`。
|
|
98
|
-
* fail-soft 的**行为**不变(`unknown` 照发 detach 头:头在 wire 上无害,死引擎由随后的流 POST 响亮失败),变的是
|
|
99
|
-
* 调用方现在**分得清**并能把这件事说出来({@link detachSupportDisclosure})。1.5s 预算,永不抛。
|
|
100
|
-
*/
|
|
101
8
|
export declare function probeEngineDetachSupport(baseUrl: string, opts?: {
|
|
102
9
|
fetchImpl?: typeof fetch;
|
|
103
10
|
timeoutMs?: number;
|
|
104
11
|
}): Promise<EngineDetachSupport>;
|
|
105
|
-
/** `unknown` 时给用户 / 日志的一句披露(单源);另两态 ⇒ `undefined`(没什么要披露的)。 */
|
|
106
12
|
export declare function detachSupportDisclosure(support: EngineDetachSupport): string | undefined;
|
|
107
13
|
export declare function engineSupportsDetach(baseUrl: string, opts?: {
|
|
108
14
|
fetchImpl?: typeof fetch;
|
|
@@ -115,58 +21,22 @@ export type DetachResolution = {
|
|
|
115
21
|
on: false;
|
|
116
22
|
reason: 'env-off' | 'old-engine';
|
|
117
23
|
};
|
|
118
|
-
/**
|
|
119
|
-
* Resolve the detach header for a headless `-p` submit. DEFAULT ON; `SEMA_HEADLESS_DETACH`=false|0
|
|
120
|
-
* ⇒ off (env-off); SEMA_ENGINE_URL external engine confirmed <1.196.0 ⇒ off (old-engine — the caller
|
|
121
|
-
* SEMA_DEBUG-logs it). Self-spawn lane (no SEMA_ENGINE_URL) never probes (pin ≥1.197 trusted).
|
|
122
|
-
* The caller MUST live-gate on SEMA_LIVE_BASEURL (finalVerifyWire 同款) — mock/pty lanes never
|
|
123
|
-
* reach this resolver, so they never see the header.
|
|
124
|
-
*/
|
|
125
24
|
export declare function resolveHeadlessDetach(baseUrl: string, env?: EnvLike, opts?: {
|
|
126
25
|
fetchImpl?: typeof fetch;
|
|
127
26
|
timeoutMs?: number;
|
|
128
27
|
}): Promise<DetachResolution>;
|
|
129
|
-
/**
|
|
130
|
-
* 🟢 B8 ALLOW 清单登记(REF-CC-域词表-05,属主=client-core 规范重构轮,到期复议=server 契约文案
|
|
131
|
-
* 变更时或 2026-Q4 复审以先到者为准):文本匹配 + 非文本结构性合取前置(`isDetachArmed()` +
|
|
132
|
-
* `status===400`),不是散点裸字面量。同批同表的另两处:`classifierVerdictWire.ts`
|
|
133
|
-
* `CLASSIFIER_DENY_SIGNATURE`(core lockstep 机器签名)、`subagent/engineTaskHandleWire.ts`
|
|
134
|
-
* `STOP_CONFLICT_CODES`(SDK typed 缺席时的 code-in-text 回落)——三处互指,理由逐条写在各自
|
|
135
|
-
* 站点,不共享一份文案(判错方向、前置合取各不相同)。
|
|
136
|
-
*/
|
|
137
|
-
/** server 400 body 判别锚(server.ts sendJson 原文:"x-detach-on-disconnect requires a durable run
|
|
138
|
-
* (a run store + sessionId) — without one the detached result would be unqueryable")。 */
|
|
139
28
|
export declare const DETACH_DURABLE_OFF_400_ANCHOR = "x-detach-on-disconnect requires a durable run";
|
|
140
|
-
/**
|
|
141
|
-
* detach 头引发的 durable-off 400 → 人话提示行;其它错误(非 400 / 非该 body / 头没发过)恒 null
|
|
142
|
-
* (绝不误伤其它 400 —— sandboxImageProfile 400 等各有自己的 hint)。判别三重:头确已发出
|
|
143
|
-
* (isDetachArmed —— armDetachCancel 只在头拼上请求时调)+ SDK APIError.status===400 + message 含
|
|
144
|
-
* server 原文锚(sdk errors.js toApiError: msg = body.error 原文)。
|
|
145
|
-
*/
|
|
146
29
|
export declare function detachDurableOffHint(err: unknown): string | null;
|
|
147
30
|
export interface DetachCancelArm {
|
|
148
31
|
baseUrl: string;
|
|
149
|
-
/** 真 token 串,或 loopback 显式免鉴权(#118:cancel 兜底同样零 Authorization 头,绝不伪造 'anon')。 */
|
|
150
32
|
authToken: string | {
|
|
151
33
|
mode: 'loopback-unauthed';
|
|
152
34
|
};
|
|
153
|
-
/** SDK Principal。缺席(undefined)=消费方不发 x-agent-principal 头(owner-null 单机形)——
|
|
154
|
-
* 与 SDK 6.11 Transport 的值检查删头语义一致;绝不在此铸哨兵值。 */
|
|
155
35
|
principal: string | undefined;
|
|
156
|
-
/** Reads the durable taskId early-captured off the X-Task-Id response header; null before capture. */
|
|
157
36
|
getTaskId: () => string | null;
|
|
158
37
|
}
|
|
159
|
-
/** Arm the signal-path cancel fallback (called by ask when the detach header is actually sent). */
|
|
160
38
|
export declare function armDetachCancel(arm: DetachCancelArm): void;
|
|
161
|
-
/** Whether this process sent the detach header on its `-p` stream (the 判死文案 upgrade gate). */
|
|
162
39
|
export declare function isDetachArmed(): boolean;
|
|
163
|
-
/** The detached run's durable taskId, when already captured (X-Task-Id) — for the triage copy. */
|
|
164
40
|
export declare function detachedTaskId(): string | null;
|
|
165
|
-
/**
|
|
166
|
-
* 🔴 **宿主发射腿的唯一取件口**(拆缝的库这一侧)。宿主的 `fireBestEffortDetachCancel` 必须从这里
|
|
167
|
-
* 取 arm,**不许自己再存一份** —— 台账两份 = 头发了但 hint 判不出 / Ctrl+C 取消不掉。
|
|
168
|
-
* null = 没 arm 过(detach 关 / 版本门挡下 / mock 车道)⇒ 宿主零动作、零行为变化。
|
|
169
|
-
*/
|
|
170
41
|
export declare function detachCancelArm(): DetachCancelArm | null;
|
|
171
|
-
/** Test-only reset (module state is process-lifetime; `-p` is a one-shot). */
|
|
172
42
|
export declare function _resetDetachWireForTest(): void;
|
package/dist/detachWire.js
CHANGED
|
@@ -1,98 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ⇄ B6 批搬迁(2026-07-27,设计稿 §3 B6):cli `src/sema/detachWire.ts` **拆**搬 —— 判定半场 +
|
|
3
|
-
* cancel-arm 台账进包,**信号路径的裸 fetch 发射留宿主**(设计稿 §3 表 `S/detachWire.ts` 那条
|
|
4
|
-
* 脚注:`:221` 裸 cancel = TUI 留,宪法例外 census C1-4)。
|
|
5
|
-
*
|
|
6
|
-
* 🔴 **拆缝画在哪、为什么**:`fireBestEffortDetachCancel` 是**信号处理器**里同步 DISPATCH 的
|
|
7
|
-
* fire-and-forget —— 它成立的前提是「进程正在被 SIGINT/SIGTERM 拆掉,不能 await、不能构造重对象」。
|
|
8
|
-
* 这套前提是 **Node 进程模型**的,浏览器/桌面渲染进程根本没有信号;而且它有意**绕开 SDK verb**
|
|
9
|
-
* (`AgentClient.runs.cancel` 是 await 型,包一层 void+catch 反而把纪律面弄模糊)——那是壳的
|
|
10
|
-
* 宪法例外,不该被搬成「库里有一处裸 fetch」。⇒ 发射留宿主,库出**台账 + 读口**。
|
|
11
|
-
*
|
|
12
|
-
* 🔴 **模块级状态与读写口同包**([multiclient-migration-batch-discipline]):`cancelArm` 一份,
|
|
13
|
-
* 写口 `armDetachCancel`(seamQueryEngine.ask 在头真拼上请求时调)、读口 `isDetachArmed`
|
|
14
|
-
* (`detachDurableOffHint` 的第一道门)/ `detachedTaskId`(分诊文案)/ `detachCancelArm`
|
|
15
|
-
* (**宿主发射腿**唯一取件口)全在本文件。壳侧 shim 的 `fireBestEffortDetachCancel` 从
|
|
16
|
-
* `detachCancelArm()` 取件 ⇒ 仍然只有一份台账;壳若自己再存一份 = 头发了但 hint 判不出、
|
|
17
|
-
* Ctrl+C 取消不掉(两个静默失效各一半)。
|
|
18
|
-
*
|
|
19
|
-
* 🔴 env 读取走 `hostEnv()`(本包零 `process`,portability 门盯着);Node 下同一对象 ⇒ 壳侧
|
|
20
|
-
* 「不传 env 参数」的调用点行为一字节不变。
|
|
21
|
-
*
|
|
22
|
-
* ── 以下为原文件的领域说明(逐字保留)────────────────────────────────────────────────────────
|
|
23
|
-
*
|
|
24
|
-
* detachWire — headless `-p` detach-on-disconnect wire (重连腿 M1 壳半场, 2026-07-15,
|
|
25
|
-
* design/HEADLESS-RECONNECT-DESIGN.md §6 M1; mirrors finalVerifyWire/limitsWire in shape).
|
|
26
|
-
*
|
|
27
|
-
* WHY: the `/v1/tasks/stream` lane ABORTS the run on client disconnect by design (anti token-burn —
|
|
28
|
-
* this is also the interactive cancel mechanism). server ≥1.196 accepts an opt-in escape hatch: the
|
|
29
|
-
* `x-detach-on-disconnect: true` REQUEST HEADER makes a disconnect DETACH the run instead — it keeps
|
|
30
|
-
* running to its terminal and lands in the durable run ledger (`GET /v1/runs/:id`; a deployment with
|
|
31
|
-
* no durable ledger 400s fail-loud — the shell's self-spawned engine always sets DB_BACKEND=local,
|
|
32
|
-
* so the ledger is always there on that lane). M1 = header + cancel fallback ONLY; reconnect/resume
|
|
33
|
-
* (R1 runs.events lane-switch / R2 idempotent re-POST) is M2/M3 — NOT here.
|
|
34
|
-
*
|
|
35
|
-
* 铁律 1 (design §2.1): the header is stamped ONLY on the headless `-p` lane (seamQueryEngine.ask),
|
|
36
|
-
* live-gated on SEMA_LIVE_BASEURL exactly like finalVerifyWire — the interactive REPL lane
|
|
37
|
-
* (seamQuery.ts) never imports this module, so Esc/interrupt keeps its disconnect==cancel semantics
|
|
38
|
-
* verbatim, and the mock/pty lanes never see the header (offline projection byte-identical).
|
|
39
|
-
*
|
|
40
|
-
* 铁律 2 (design §2.2): once detach is on, a USER abort must carry an explicit best-effort cancel —
|
|
41
|
-
* a detached run would otherwise burn tokens to completion in the background after Ctrl+C. The
|
|
42
|
-
* cancel-arm half of this module (armDetachCancel / the host's fireBestEffortDetachCancel) is
|
|
43
|
-
* consumed by the `-p` SIGINT handler and the SIGTERM/SIGHUP tail-frame handler (cli/print.ts):
|
|
44
|
-
* fire-and-forget `POST /v1/runs/:id/cancel` (the SDK RunsResource.cancel verb, runs.js — verified:
|
|
45
|
-
* no body), never awaited on the signal path. taskId not yet captured (pre X-Task-Id window) ⇒
|
|
46
|
-
* ACCEPTED uncancellable window — detach's inherent cost, no waiting introduced (design §2.2 记账).
|
|
47
|
-
*
|
|
48
|
-
* PRECEDENCE (off wins; otherwise DEFAULT ON):
|
|
49
|
-
* a) `SEMA_HEADLESS_DETACH` env = an {@link envFlagOff} spelling (REF-CC-141 dup-02 单源;settings
|
|
50
|
-
* env lane, fail-soft — any OTHER value including typos stays default-on, finalVerifyWire
|
|
51
|
-
* discipline) → off.
|
|
52
|
-
* b) VERSION GATE: SEMA_ENGINE_URL in play (user-supplied external engine) and `/health` CONFIRMS
|
|
53
|
-
* version <1.196.0 (or no version field = pre-1.96) → off + SEMA_DEBUG log.
|
|
54
|
-
* Unlike limitsWire (warn-and-send: an old server drops an unknown BODY field server-side), here
|
|
55
|
-
* we GATE: an old server silently ignores the unknown HEADER, so a disconnect still kills the
|
|
56
|
-
* run — sending it would only manufacture a false "detached" belief downstream (判死文案 would
|
|
57
|
-
* lie). Probe unreachable / unparsable response ⇒ fail-soft SEND (can't confirm staleness; the
|
|
58
|
-
* stream POST itself fails loudly if the engine is truly down).
|
|
59
|
-
* c) self-spawn lane (no SEMA_ENGINE_URL): release-pinned ≥1.197.0 — trusted, no probe, header on.
|
|
60
|
-
*/
|
|
61
1
|
import { hostEnv } from './hostEnv.js';
|
|
62
2
|
import { envFlagOff } from './envFlag.js';
|
|
63
3
|
import { versionSupportsLimits } from './limitsWire.js';
|
|
64
|
-
/** The server ≥1.196 opt-in header: disconnect ⇒ detach (run continues to durable terminal). */
|
|
65
4
|
export const DETACH_HEADER = 'x-detach-on-disconnect';
|
|
66
|
-
/** Settings-lane env knob(settings.json `env` 块 → 1a-envseed → process.env)。'false'/'0' = off。 */
|
|
67
5
|
export const HEADLESS_DETACH_ENV = 'SEMA_HEADLESS_DETACH';
|
|
68
|
-
/**
|
|
69
|
-
* First server version that honors the detach header — 1.196.0, the SAME floor as the limits wire
|
|
70
|
-
* (both landed in the [857] batch), so the version predicate is limitsWire.versionSupportsLimits
|
|
71
|
-
* re-exported under the detach name (one comparator, two wires — 抽共用 per design).
|
|
72
|
-
*/
|
|
73
6
|
export const DETACH_WIRE_MIN_ENGINE = [1, 196, 0];
|
|
74
|
-
/** True when the engine version string satisfies the detach-wire minimum (≥1.196.0). Unparsable ⇒ false. */
|
|
75
7
|
export const versionSupportsDetach = versionSupportsLimits;
|
|
76
|
-
/**
|
|
77
|
-
* The settings-lane off-switch: `SEMA_HEADLESS_DETACH` set to an {@link envFlagOff} spelling
|
|
78
|
-
* (REF-CC-141 dup-02 单源:`0`/`false`/`no`/`off`/`none`,大小写不敏感)disables the header. Any other
|
|
79
|
-
* value (empty/'true'/typo) = default ON — fail-soft, a settings typo never flips the lane silently
|
|
80
|
-
* to the strict-alignment (disconnect-kills-run) mode (finalVerifyWire 纪律).
|
|
81
|
-
*
|
|
82
|
-
* 🔴 [2393] sweep-F12(2026-08-03 全窗复审)**承诺范围如实**:上面那句话是在 off 集只有
|
|
83
|
-
* `{false,0}` 的时代写的,当时它覆盖 `no`/`off`/`none` 三个拼写(它们落进「任何其它值 ⇒ 默认 ON」)。
|
|
84
|
-
* REF-CC-141 把 off 集扩到五词之后,**这三个拼写现在会**把车道翻成 disconnect-kills-run。
|
|
85
|
-
* 扩集本身是既定方向(用户写 `no`/`off`/`none` 时意图确实是「关」),这里只把范围说清楚:
|
|
86
|
-
* 「typo 绝不静默翻车道」现在指的是 `{false,0,no,off,none}` **之外**的拼写。
|
|
87
|
-
*/
|
|
88
8
|
export function headlessDetachDisabledByEnv(env = hostEnv()) {
|
|
89
9
|
return envFlagOff(env[HEADLESS_DETACH_ENV]);
|
|
90
10
|
}
|
|
91
|
-
/**
|
|
92
|
-
* 三态读口(0.72.13 CC-53;test 证据帖「异常被吞成健康值」一类):此前只有布尔口,「不可达」与「确认支持」同返 `true`。
|
|
93
|
-
* fail-soft 的**行为**不变(`unknown` 照发 detach 头:头在 wire 上无害,死引擎由随后的流 POST 响亮失败),变的是
|
|
94
|
-
* 调用方现在**分得清**并能把这件事说出来({@link detachSupportDisclosure})。1.5s 预算,永不抛。
|
|
95
|
-
*/
|
|
96
11
|
export async function probeEngineDetachSupport(baseUrl, opts) {
|
|
97
12
|
const fetchImpl = opts?.fetchImpl ?? fetch;
|
|
98
13
|
const controller = new AbortController();
|
|
@@ -105,13 +20,11 @@ export async function probeEngineDetachSupport(baseUrl, opts) {
|
|
|
105
20
|
if (!res.ok)
|
|
106
21
|
return 'unknown';
|
|
107
22
|
const body = await res.json();
|
|
108
|
-
// 回体必须是对象:null / 数组 / 标量 = 答得奇怪 ⇒ unknown(异源对抗复审:此前折成 unsupported,消费者据此关掉 detach)。
|
|
109
23
|
if (body === null || typeof body !== 'object' || Array.isArray(body))
|
|
110
24
|
return 'unknown';
|
|
111
25
|
if (!('version' in body))
|
|
112
|
-
return 'unsupported';
|
|
26
|
+
return 'unsupported';
|
|
113
27
|
const version = body.version;
|
|
114
|
-
// version 在场但不是可解析的 x.y.z 串 ⇒ unknown(不拿读不懂的值当「陈旧」证据)
|
|
115
28
|
if (typeof version !== 'string' || !/^\d+\.\d+\.\d+/.test(version))
|
|
116
29
|
return 'unknown';
|
|
117
30
|
if (versionSupportsDetach(version))
|
|
@@ -125,58 +38,25 @@ export async function probeEngineDetachSupport(baseUrl, opts) {
|
|
|
125
38
|
clearTimeout(timer);
|
|
126
39
|
}
|
|
127
40
|
}
|
|
128
|
-
/** `unknown` 时给用户 / 日志的一句披露(单源);另两态 ⇒ `undefined`(没什么要披露的)。 */
|
|
129
41
|
export function detachSupportDisclosure(support) {
|
|
130
42
|
if (support !== 'unknown')
|
|
131
43
|
return undefined;
|
|
132
44
|
return 'could not confirm whether this engine supports detach (its /health did not answer usably); sending the detach header anyway — it is harmless on the wire, and a dead engine fails the request loudly';
|
|
133
45
|
}
|
|
134
46
|
export async function engineSupportsDetach(baseUrl, opts) {
|
|
135
|
-
// 布尔口 = 三态口的薄封装(保留给既有调用方):只有**确证陈旧**才不发;`unknown` 仍 fail-soft 发。
|
|
136
47
|
return (await probeEngineDetachSupport(baseUrl, opts)) !== 'unsupported';
|
|
137
48
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Resolve the detach header for a headless `-p` submit. DEFAULT ON; `SEMA_HEADLESS_DETACH`=false|0
|
|
140
|
-
* ⇒ off (env-off); SEMA_ENGINE_URL external engine confirmed <1.196.0 ⇒ off (old-engine — the caller
|
|
141
|
-
* SEMA_DEBUG-logs it). Self-spawn lane (no SEMA_ENGINE_URL) never probes (pin ≥1.197 trusted).
|
|
142
|
-
* The caller MUST live-gate on SEMA_LIVE_BASEURL (finalVerifyWire 同款) — mock/pty lanes never
|
|
143
|
-
* reach this resolver, so they never see the header.
|
|
144
|
-
*/
|
|
145
49
|
export async function resolveHeadlessDetach(baseUrl, env = hostEnv(), opts) {
|
|
146
50
|
if (headlessDetachDisabledByEnv(env))
|
|
147
51
|
return { on: false, reason: 'env-off' };
|
|
148
52
|
if (env.SEMA_ENGINE_URL) {
|
|
149
|
-
// user-supplied external engine — the only lane where an old server is possible
|
|
150
53
|
const ok = await engineSupportsDetach(baseUrl, opts);
|
|
151
54
|
if (!ok)
|
|
152
55
|
return { on: false, reason: 'old-engine' };
|
|
153
56
|
}
|
|
154
57
|
return { on: true, reason: 'default-on' };
|
|
155
58
|
}
|
|
156
|
-
// ── durable-off 400 的人话分诊([862]④,1.0.5 小件5) ─────────────────────────────────────────────────
|
|
157
|
-
//
|
|
158
|
-
// server ≥1.196 对带 detach 头但无 durable 账本(无 runStore / 无 sessionId)的 submit 判 400 fail-loud
|
|
159
|
-
// (server http/server.ts [854]①b:静默忽略 = 断连仍杀 run,与 caller 声明语义相反;detach 成功了结果
|
|
160
|
-
// 也无处可查)。壳自 spawn 引擎恒 DB_BACKEND=local 永不命中;命中面 = SEMA_ENGINE_URL 外接引擎显式关
|
|
161
|
-
// durable。裸 `sema: API Error: 400 · x-detach-on-disconnect requires a durable run …` 是 server 视角
|
|
162
|
-
// 的契约话,用户不知道下一步 —— 追加一行人话(supplement, never mask:API Error 行字面保留)。
|
|
163
|
-
/**
|
|
164
|
-
* 🟢 B8 ALLOW 清单登记(REF-CC-域词表-05,属主=client-core 规范重构轮,到期复议=server 契约文案
|
|
165
|
-
* 变更时或 2026-Q4 复审以先到者为准):文本匹配 + 非文本结构性合取前置(`isDetachArmed()` +
|
|
166
|
-
* `status===400`),不是散点裸字面量。同批同表的另两处:`classifierVerdictWire.ts`
|
|
167
|
-
* `CLASSIFIER_DENY_SIGNATURE`(core lockstep 机器签名)、`subagent/engineTaskHandleWire.ts`
|
|
168
|
-
* `STOP_CONFLICT_CODES`(SDK typed 缺席时的 code-in-text 回落)——三处互指,理由逐条写在各自
|
|
169
|
-
* 站点,不共享一份文案(判错方向、前置合取各不相同)。
|
|
170
|
-
*/
|
|
171
|
-
/** server 400 body 判别锚(server.ts sendJson 原文:"x-detach-on-disconnect requires a durable run
|
|
172
|
-
* (a run store + sessionId) — without one the detached result would be unqueryable")。 */
|
|
173
59
|
export const DETACH_DURABLE_OFF_400_ANCHOR = 'x-detach-on-disconnect requires a durable run';
|
|
174
|
-
/**
|
|
175
|
-
* detach 头引发的 durable-off 400 → 人话提示行;其它错误(非 400 / 非该 body / 头没发过)恒 null
|
|
176
|
-
* (绝不误伤其它 400 —— sandboxImageProfile 400 等各有自己的 hint)。判别三重:头确已发出
|
|
177
|
-
* (isDetachArmed —— armDetachCancel 只在头拼上请求时调)+ SDK APIError.status===400 + message 含
|
|
178
|
-
* server 原文锚(sdk errors.js toApiError: msg = body.error 原文)。
|
|
179
|
-
*/
|
|
180
60
|
export function detachDurableOffHint(err) {
|
|
181
61
|
if (!isDetachArmed())
|
|
182
62
|
return null;
|
|
@@ -189,27 +69,18 @@ export function detachDurableOffHint(err) {
|
|
|
189
69
|
return 'engine has durable runs disabled — detach-on-disconnect unavailable; interrupted turns will abort (SEMA_HEADLESS_DETACH=false to silence)';
|
|
190
70
|
}
|
|
191
71
|
let cancelArm = null;
|
|
192
|
-
/** Arm the signal-path cancel fallback (called by ask when the detach header is actually sent). */
|
|
193
72
|
export function armDetachCancel(arm) {
|
|
194
73
|
cancelArm = arm;
|
|
195
74
|
}
|
|
196
|
-
/** Whether this process sent the detach header on its `-p` stream (the 判死文案 upgrade gate). */
|
|
197
75
|
export function isDetachArmed() {
|
|
198
76
|
return cancelArm !== null;
|
|
199
77
|
}
|
|
200
|
-
/** The detached run's durable taskId, when already captured (X-Task-Id) — for the triage copy. */
|
|
201
78
|
export function detachedTaskId() {
|
|
202
79
|
return cancelArm?.getTaskId() ?? null;
|
|
203
80
|
}
|
|
204
|
-
/**
|
|
205
|
-
* 🔴 **宿主发射腿的唯一取件口**(拆缝的库这一侧)。宿主的 `fireBestEffortDetachCancel` 必须从这里
|
|
206
|
-
* 取 arm,**不许自己再存一份** —— 台账两份 = 头发了但 hint 判不出 / Ctrl+C 取消不掉。
|
|
207
|
-
* null = 没 arm 过(detach 关 / 版本门挡下 / mock 车道)⇒ 宿主零动作、零行为变化。
|
|
208
|
-
*/
|
|
209
81
|
export function detachCancelArm() {
|
|
210
82
|
return cancelArm;
|
|
211
83
|
}
|
|
212
|
-
/** Test-only reset (module state is process-lifetime; `-p` is a one-shot). */
|
|
213
84
|
export function _resetDetachWireForTest() {
|
|
214
85
|
cancelArm = null;
|
|
215
86
|
}
|
|
@@ -1,53 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* deviceExecutorManagementCapability — `GET /v1/capabilities.deviceExecutor.management`(server ≥7.88.0;契约附录 B.1
|
|
3
|
-
* `deviceExecutor` 行 + §14)的三端共用读面(0.74.2;与 sql / writeProtection / webSearch.backend / executionLane /
|
|
4
|
-
* approvalsStreamLive 五只兄弟同一套四态词汇)。sdk 9.7.1 对该位无型 ⇒ 按契约结构读;9.8.x 起声明 `management?: boolean`(0.75.0 CC-81 对表:读器不改,门钉声明形)。
|
|
5
|
-
*
|
|
6
|
-
* ── 这一位答的是哪一个问题 ────────────────────────────────────────────────────────────────
|
|
7
|
-
* 「`/v1/devices/*` 的管理动词在这台 server 上在不在」(present-iff:与该族 501 判据逐字同源)。它挂在 `deviceExecutor`
|
|
8
|
-
* 对象里:`deviceExecutor === false` = 本部署**没有 device 车道**(管理面无从谈起,六动词一律 501 `capability.device_lane_required`);
|
|
9
|
-
* 对象在场但 `management` 键缺席 = 7.88.0 之前的 server,**判不出**,只能按 501 试探。
|
|
10
|
-
*
|
|
11
|
-
* ── 🔴 读法 ─────────────────────────────────────────────────────────────────────────────────
|
|
12
|
-
* ① `management` **键缺席 ≠ false**(真字节:7.87.3 车道真开而无此键)⇒ `not_reported`;`deviceExecutor` 键整个不存在
|
|
13
|
-
* (更老 server)同样 `not_reported`(判别子 `why` 分开记,后者只有夹具、无真版本见证)。
|
|
14
|
-
* ② `deviceExecutor: false` 是**键在、值为布尔 false**(不是键被省掉)⇒ `lane_absent`;判在场用 `hasOwn`,不用 `in` 判真值。
|
|
15
|
-
* ③ `management` 严格布尔;`null` / 串 / 数 / 数组 / 对象 ⇒ 畸形(删格 ⇒ `unobserved`);`deviceExecutor` 非 false 非对象同畸形。
|
|
16
|
-
* ④ 「管理动词能不能用」的判据归包:{@link deviceManagementVerbsAvailable} —— 只有 present ∧ true 才 `'yes'`;
|
|
17
|
-
* present ∧ false 与 `lane_absent` ⇒ `'no'`(明确的否);其余 ⇒ `'unknown'`(别当 no,也别当 yes)。
|
|
18
|
-
*/
|
|
19
|
-
/** 四态读数。`unobserved` 由读口在这一格空缺时铸,不由投影铸。 */
|
|
20
1
|
export type DeviceExecutorManagementReading = {
|
|
21
2
|
kind: 'unobserved';
|
|
22
|
-
}
|
|
23
|
-
/** `why`:`capability_absent` = `deviceExecutor` 键整个不存在(更老 server);`management_absent` = 车道对象在场、位缺席(7.88.0 之前)。 */
|
|
24
|
-
| {
|
|
3
|
+
} | {
|
|
25
4
|
kind: 'not_reported';
|
|
26
5
|
why: 'capability_absent' | 'management_absent';
|
|
27
|
-
}
|
|
28
|
-
/** `deviceExecutor === false`:本部署没有 device 车道。 */
|
|
29
|
-
| {
|
|
6
|
+
} | {
|
|
30
7
|
kind: 'lane_absent';
|
|
31
8
|
} | {
|
|
32
9
|
kind: 'present';
|
|
33
10
|
management: boolean;
|
|
34
11
|
};
|
|
35
|
-
/** caps 回体 → 本格读数;畸形一律 `undefined`(= 这一格不写 ⇒ 读口答 `unobserved`)。 */
|
|
36
12
|
export declare function projectDeviceExecutorManagementCapability(caps: unknown): DeviceExecutorManagementReading | undefined;
|
|
37
|
-
/** 宿主 caps probe 的读面 tee 落点(与五只兄弟并列)。绝不 throw;畸形 ⇒ 删格;`opts.generation` 关掉旧探测覆盖新读数的竞态。 */
|
|
38
13
|
export declare function noteEngineCapsForDeviceExecutorManagement(baseUrl: string, caps: unknown, opts?: {
|
|
39
14
|
generation?: number;
|
|
40
15
|
}): void;
|
|
41
|
-
/** 本进程观测到的读数;这一格空缺 ⇒ `{kind:'unobserved'}`。 */
|
|
42
16
|
export declare function observedDeviceExecutorManagement(baseUrl?: string | undefined): DeviceExecutorManagementReading;
|
|
43
|
-
/**
|
|
44
|
-
* 「`/v1/devices/*` 管理动词能不能用」的判据单源(三态):只有引擎明说在场(present ∧ true)才 `'yes'`;
|
|
45
|
-
* 明说不在(present ∧ false)或没有 device 车道 ⇒ `'no'`;老 server / 从没观测 ⇒ `'unknown'`(端按 501 试探,不预判)。
|
|
46
|
-
*/
|
|
47
17
|
export declare function deviceManagementVerbsAvailable(reading: DeviceExecutorManagementReading): 'yes' | 'no' | 'unknown';
|
|
48
|
-
/** doctor 那一行的 detail 串,唯一措辞真源。🔴 `not_reported` 句不许暗示「没有管理面」。 */
|
|
49
18
|
export declare function deviceExecutorManagementDoctorDetail(reading: DeviceExecutorManagementReading): string;
|
|
50
|
-
/** 换代失效口(引擎温切成功后调):清成未观测。空串 ⇒ no-op;绝不 throw。 */
|
|
51
19
|
export declare function forgetDeviceExecutorManagementReading(baseUrl: string | undefined): void;
|
|
52
|
-
/** 测试钩子。 */
|
|
53
20
|
export declare function __resetDeviceExecutorManagementReadingsForTests(): void;
|
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* deviceExecutorManagementCapability — `GET /v1/capabilities.deviceExecutor.management`(server ≥7.88.0;契约附录 B.1
|
|
3
|
-
* `deviceExecutor` 行 + §14)的三端共用读面(0.74.2;与 sql / writeProtection / webSearch.backend / executionLane /
|
|
4
|
-
* approvalsStreamLive 五只兄弟同一套四态词汇)。sdk 9.7.1 对该位无型 ⇒ 按契约结构读;9.8.x 起声明 `management?: boolean`(0.75.0 CC-81 对表:读器不改,门钉声明形)。
|
|
5
|
-
*
|
|
6
|
-
* ── 这一位答的是哪一个问题 ────────────────────────────────────────────────────────────────
|
|
7
|
-
* 「`/v1/devices/*` 的管理动词在这台 server 上在不在」(present-iff:与该族 501 判据逐字同源)。它挂在 `deviceExecutor`
|
|
8
|
-
* 对象里:`deviceExecutor === false` = 本部署**没有 device 车道**(管理面无从谈起,六动词一律 501 `capability.device_lane_required`);
|
|
9
|
-
* 对象在场但 `management` 键缺席 = 7.88.0 之前的 server,**判不出**,只能按 501 试探。
|
|
10
|
-
*
|
|
11
|
-
* ── 🔴 读法 ─────────────────────────────────────────────────────────────────────────────────
|
|
12
|
-
* ① `management` **键缺席 ≠ false**(真字节:7.87.3 车道真开而无此键)⇒ `not_reported`;`deviceExecutor` 键整个不存在
|
|
13
|
-
* (更老 server)同样 `not_reported`(判别子 `why` 分开记,后者只有夹具、无真版本见证)。
|
|
14
|
-
* ② `deviceExecutor: false` 是**键在、值为布尔 false**(不是键被省掉)⇒ `lane_absent`;判在场用 `hasOwn`,不用 `in` 判真值。
|
|
15
|
-
* ③ `management` 严格布尔;`null` / 串 / 数 / 数组 / 对象 ⇒ 畸形(删格 ⇒ `unobserved`);`deviceExecutor` 非 false 非对象同畸形。
|
|
16
|
-
* ④ 「管理动词能不能用」的判据归包:{@link deviceManagementVerbsAvailable} —— 只有 present ∧ true 才 `'yes'`;
|
|
17
|
-
* present ∧ false 与 `lane_absent` ⇒ `'no'`(明确的否);其余 ⇒ `'unknown'`(别当 no,也别当 yes)。
|
|
18
|
-
*/
|
|
19
1
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
20
2
|
import { createEngineCapReader } from './engineCapReader.js';
|
|
21
|
-
/** caps 回体 → 本格读数;畸形一律 `undefined`(= 这一格不写 ⇒ 读口答 `unobserved`)。 */
|
|
22
3
|
export function projectDeviceExecutorManagementCapability(caps) {
|
|
23
4
|
if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
|
|
24
|
-
return undefined;
|
|
5
|
+
return undefined;
|
|
25
6
|
const c = caps;
|
|
26
7
|
if (!Object.hasOwn(c, 'deviceExecutor'))
|
|
27
8
|
return { kind: 'not_reported', why: 'capability_absent' };
|
|
28
|
-
// 🔴 外层也只读一次(0.74.2 补审 [medium]):hasOwn 之后 `deviceExecutor` 读进局部量,undefined / false / 对象三判都对同一次读;
|
|
29
|
-
// 此前 undefined 判与取值各读一次,变化的 getter 会把第一次观测到的「车道缺席」丢掉。
|
|
30
9
|
const d = c.deviceExecutor;
|
|
31
10
|
if (d === undefined)
|
|
32
11
|
return { kind: 'not_reported', why: 'capability_absent' };
|
|
@@ -37,7 +16,6 @@ export function projectDeviceExecutorManagementCapability(caps) {
|
|
|
37
16
|
const o = d;
|
|
38
17
|
if (!Object.hasOwn(o, 'management'))
|
|
39
18
|
return { kind: 'not_reported', why: 'management_absent' };
|
|
40
|
-
// 🔴 只读一次(异源对抗复审 R1):校验与返回若各读一次,变化的 getter 会让校验读到布尔、返回读到串。
|
|
41
19
|
const mgmt = o.management;
|
|
42
20
|
if (mgmt === undefined)
|
|
43
21
|
return { kind: 'not_reported', why: 'management_absent' };
|
|
@@ -45,28 +23,17 @@ export function projectDeviceExecutorManagementCapability(caps) {
|
|
|
45
23
|
return undefined;
|
|
46
24
|
return { kind: 'present', management: mgmt };
|
|
47
25
|
}
|
|
48
|
-
/**
|
|
49
|
-
* 本格的 per-baseUrl 读账 + tee / 读口 / 失效口 / 测试钩四口 —— 各只能力位读器**共用同一份实现**
|
|
50
|
-
* ({@link createEngineCapReader});本文件只留这一格真正不同的部分:投影函数 {@link projectDeviceExecutorManagementCapability}、doctor 措辞表,以及本位自己的判据助手(如有)。
|
|
51
|
-
* 🔴 Map 在工厂闭包里,**一只读器一张**:收到读不懂的回体只删自己这一格,绝不连坐别的能力面。
|
|
52
|
-
*/
|
|
53
26
|
const reader = createEngineCapReader({
|
|
54
27
|
name: 'deviceExecutor.management',
|
|
55
28
|
project: projectDeviceExecutorManagementCapability,
|
|
56
29
|
makeUnobserved: () => ({ kind: 'unobserved' }),
|
|
57
30
|
});
|
|
58
|
-
/** 宿主 caps probe 的读面 tee 落点(与五只兄弟并列)。绝不 throw;畸形 ⇒ 删格;`opts.generation` 关掉旧探测覆盖新读数的竞态。 */
|
|
59
31
|
export function noteEngineCapsForDeviceExecutorManagement(baseUrl, caps, opts) {
|
|
60
32
|
reader.note(baseUrl, caps, opts);
|
|
61
33
|
}
|
|
62
|
-
/** 本进程观测到的读数;这一格空缺 ⇒ `{kind:'unobserved'}`。 */
|
|
63
34
|
export function observedDeviceExecutorManagement(baseUrl = engineWireTarget()?.baseUrl) {
|
|
64
35
|
return reader.observed(baseUrl);
|
|
65
36
|
}
|
|
66
|
-
/**
|
|
67
|
-
* 「`/v1/devices/*` 管理动词能不能用」的判据单源(三态):只有引擎明说在场(present ∧ true)才 `'yes'`;
|
|
68
|
-
* 明说不在(present ∧ false)或没有 device 车道 ⇒ `'no'`;老 server / 从没观测 ⇒ `'unknown'`(端按 501 试探,不预判)。
|
|
69
|
-
*/
|
|
70
37
|
export function deviceManagementVerbsAvailable(reading) {
|
|
71
38
|
if (reading.kind === 'present')
|
|
72
39
|
return reading.management ? 'yes' : 'no';
|
|
@@ -74,7 +41,6 @@ export function deviceManagementVerbsAvailable(reading) {
|
|
|
74
41
|
return 'no';
|
|
75
42
|
return 'unknown';
|
|
76
43
|
}
|
|
77
|
-
/** doctor 那一行的 detail 串,唯一措辞真源。🔴 `not_reported` 句不许暗示「没有管理面」。 */
|
|
78
44
|
export function deviceExecutorManagementDoctorDetail(reading) {
|
|
79
45
|
switch (reading.kind) {
|
|
80
46
|
case 'unobserved':
|
|
@@ -91,11 +57,9 @@ export function deviceExecutorManagementDoctorDetail(reading) {
|
|
|
91
57
|
: 'device lane on but the /v1/devices management verbs are off on this deployment';
|
|
92
58
|
}
|
|
93
59
|
}
|
|
94
|
-
/** 换代失效口(引擎温切成功后调):清成未观测。空串 ⇒ no-op;绝不 throw。 */
|
|
95
60
|
export function forgetDeviceExecutorManagementReading(baseUrl) {
|
|
96
61
|
reader.forget(baseUrl);
|
|
97
62
|
}
|
|
98
|
-
/** 测试钩子。 */
|
|
99
63
|
export function __resetDeviceExecutorManagementReadingsForTests() {
|
|
100
64
|
reader.__resetForTests();
|
|
101
65
|
}
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* diagnostics.ts — 引擎 LSP `diagnostics` 帧 → CC `diagnostics` attachment 载荷(PURE)。
|
|
3
|
-
* cli upstreamBridge case 'diagnostics' 的等价搬运(design/121):
|
|
4
|
-
* · wire severity 是 LSP 数字(1=Error 2=Warning 3=Info 4=Hint)→ CC 字符串枚举;
|
|
5
|
-
* 缺席/越界 → 'Error'(可见胜过隐身);
|
|
6
|
-
* · range 缺席 → 零 range 占位(渲染器必读字段);source/code 存在才铸(且一律 String 化);
|
|
7
|
-
* · 只留 `file://` 前缀且有诊断项的文件;全滤光 ⇒ 返回 null(宿主不渲空行)。
|
|
8
|
-
*/
|
|
9
1
|
declare const SEV: readonly ["Error", "Warning", "Info", "Hint"];
|
|
10
2
|
export interface DiagnosticsAttachment {
|
|
11
3
|
type: 'diagnostics';
|
package/dist/diagnostics.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* diagnostics.ts — 引擎 LSP `diagnostics` 帧 → CC `diagnostics` attachment 载荷(PURE)。
|
|
3
|
-
* cli upstreamBridge case 'diagnostics' 的等价搬运(design/121):
|
|
4
|
-
* · wire severity 是 LSP 数字(1=Error 2=Warning 3=Info 4=Hint)→ CC 字符串枚举;
|
|
5
|
-
* 缺席/越界 → 'Error'(可见胜过隐身);
|
|
6
|
-
* · range 缺席 → 零 range 占位(渲染器必读字段);source/code 存在才铸(且一律 String 化);
|
|
7
|
-
* · 只留 `file://` 前缀且有诊断项的文件;全滤光 ⇒ 返回 null(宿主不渲空行)。
|
|
8
|
-
*/
|
|
9
1
|
const SEV = ['Error', 'Warning', 'Info', 'Hint'];
|
|
10
2
|
export function projectDiagnosticsFrame(frame) {
|
|
11
3
|
const zeroRange = { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } };
|
package/dist/diff/patch.d.ts
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/diff/patch.ts — T20:**diff hunks 在客户端算**(core 已裁定归客户端,零上游依赖)。
|
|
3
|
-
*
|
|
4
|
-
* 为什么必须进本包:core 明确「引擎发 originalFile(客户端永远重建不出来的那一半),hunks 由客户端
|
|
5
|
-
* 算」—— 那么每个端(TUI/web/桌面)各算一遍就是三份实现三种 hunk;进包之后是**一份**。
|
|
6
|
-
* 搬自 cli `src/utils/diff.ts:81 getPatchFromContents` + `src/utils/file.ts:137
|
|
7
|
-
* convertLeadingTabsToSpaces`,**逐字**(含 & / $ 转义 token 与 CONTEXT_LINES/TIMEOUT 常量),
|
|
8
|
-
* 只丢掉宿主侧的 analytics / LOC 计数副作用(那两条在 cli 里也不在本函数内)。
|
|
9
|
-
*
|
|
10
|
-
* 🔴 唯一的运行时依赖 `diff`(jsdiff 9,零传递依赖、纯 JS、浏览器可用)—— 本包第一个 runtime dep。
|
|
11
|
-
* 判据:它不是「顺手拉进来的 hub」,而是 T20 这条能力**本身**;不引它就只能把能力退回各端。
|
|
12
|
-
* portability 门的 ALLOWED_PACKAGES 因此显式登记 `diff` 一条(登记 = 可审计,不是放行一切)。
|
|
13
|
-
*/
|
|
14
1
|
import { type StructuredPatchHunk } from 'diff';
|
|
15
2
|
export declare const CONTEXT_LINES = 3;
|
|
16
3
|
export declare const DIFF_TIMEOUT_MS = 5000;
|
|
17
|
-
/**
|
|
18
|
-
* 渲染前把**行首** tab 折成两空格 —— CC 自己的 Edit 卡在 structuredPatch 之前做同一件事
|
|
19
|
-
* (FileEditTool/utils.ts),不做的话 tab 缩进文件两边算出来的 hunk 对不上。
|
|
20
|
-
*/
|
|
21
4
|
export declare function convertLeadingTabsToSpaces(content: string): string;
|
|
22
5
|
export declare function getPatchFromContents({ filePath, oldContent, newContent, ignoreWhitespace, singleHunk, }: {
|
|
23
6
|
filePath: string;
|
package/dist/diff/patch.js
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/diff/patch.ts — T20:**diff hunks 在客户端算**(core 已裁定归客户端,零上游依赖)。
|
|
3
|
-
*
|
|
4
|
-
* 为什么必须进本包:core 明确「引擎发 originalFile(客户端永远重建不出来的那一半),hunks 由客户端
|
|
5
|
-
* 算」—— 那么每个端(TUI/web/桌面)各算一遍就是三份实现三种 hunk;进包之后是**一份**。
|
|
6
|
-
* 搬自 cli `src/utils/diff.ts:81 getPatchFromContents` + `src/utils/file.ts:137
|
|
7
|
-
* convertLeadingTabsToSpaces`,**逐字**(含 & / $ 转义 token 与 CONTEXT_LINES/TIMEOUT 常量),
|
|
8
|
-
* 只丢掉宿主侧的 analytics / LOC 计数副作用(那两条在 cli 里也不在本函数内)。
|
|
9
|
-
*
|
|
10
|
-
* 🔴 唯一的运行时依赖 `diff`(jsdiff 9,零传递依赖、纯 JS、浏览器可用)—— 本包第一个 runtime dep。
|
|
11
|
-
* 判据:它不是「顺手拉进来的 hub」,而是 T20 这条能力**本身**;不引它就只能把能力退回各端。
|
|
12
|
-
* portability 门的 ALLOWED_PACKAGES 因此显式登记 `diff` 一条(登记 = 可审计,不是放行一切)。
|
|
13
|
-
*/
|
|
14
1
|
import { structuredPatch } from 'diff';
|
|
15
2
|
export const CONTEXT_LINES = 3;
|
|
16
3
|
export const DIFF_TIMEOUT_MS = 5_000;
|
|
17
|
-
// cli 原注:`&` 会让 diff 库犯迷糊,先换成 token、算完再换回来。`$` 同理(替换模式转义位)。
|
|
18
4
|
const AMPERSAND_TOKEN = '<<:AMPERSAND_TOKEN:>>';
|
|
19
5
|
const DOLLAR_TOKEN = '<<:DOLLAR_TOKEN:>>';
|
|
20
6
|
function escapeForDiff(s) {
|
|
@@ -23,12 +9,7 @@ function escapeForDiff(s) {
|
|
|
23
9
|
function unescapeFromDiff(s) {
|
|
24
10
|
return s.replaceAll(AMPERSAND_TOKEN, '&').replaceAll(DOLLAR_TOKEN, '$');
|
|
25
11
|
}
|
|
26
|
-
/**
|
|
27
|
-
* 渲染前把**行首** tab 折成两空格 —— CC 自己的 Edit 卡在 structuredPatch 之前做同一件事
|
|
28
|
-
* (FileEditTool/utils.ts),不做的话 tab 缩进文件两边算出来的 hunk 对不上。
|
|
29
|
-
*/
|
|
30
12
|
export function convertLeadingTabsToSpaces(content) {
|
|
31
|
-
// 无 tab 的常见情形直接短路(/gm 正则会逐行扫)。
|
|
32
13
|
if (!content.includes('\t'))
|
|
33
14
|
return content;
|
|
34
15
|
return content.replace(/^\t+/gm, _ => ' '.repeat(_.length));
|