@sema-agent/client-core 0.77.0 → 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 +23 -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 +1 -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 +10 -496
- 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 +11 -65
- package/dist/subagent/engineTaskHandleWire.js +20 -131
- 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 +62 -1
- package/package.json +1 -1
package/dist/adapt/toolCards.js
CHANGED
|
@@ -5,35 +5,21 @@ import { flattenWireOutput } from './wireShapes.js';
|
|
|
5
5
|
export function createToolCardLedger(ctx, idOf) {
|
|
6
6
|
const pending = new Map();
|
|
7
7
|
let assistantResponseId = null;
|
|
8
|
-
/**
|
|
9
|
-
* TodoWrite 划删线 diff 的 `oldTodos`。
|
|
10
|
-
* 🔴 **turn 级**(cli 同:`let lastLiveTodos` 声明在 generator 体内,不是 module 级 ——
|
|
11
|
-
* cli 的注释写着「module-level, per-process」但代码不是,以**代码**为准,差分守卫认代码)。
|
|
12
|
-
*/
|
|
13
8
|
let lastLiveTodos = [];
|
|
14
|
-
/**
|
|
15
|
-
* 一张开卡的收口(cli `buildToolResult` + 它内联的 #117a 桥)。产出顺序与 cli 的
|
|
16
|
-
* 「副作用先于 yield」一致:先 chrome(bg shell 建行),再 transcript(tool_result 卡)。
|
|
17
|
-
*/
|
|
18
9
|
function* buildToolResult(p, end) {
|
|
19
10
|
const isError = end?.isError ?? false;
|
|
20
|
-
// D 层 / T7:wire 带正文 ⇒ 真身投影;没带 ⇒ **诚实缺席**(§8-4,不再 mock 反造)。
|
|
21
11
|
const body = end && end.output !== undefined
|
|
22
12
|
? wireOutputToBody(p.name, end.output, isError, end.truncated === true, flattenWireOutput, end.structured)
|
|
23
13
|
: degradedToolResultBody(isError);
|
|
24
|
-
// ── E 层 ③:#117a 模型发起的后台 Bash/Monitor 回执 → ctrl+B 面板行(判定在库、执行留宿主;
|
|
25
|
-
// #158:Monitor 此前被工具名门拒 ⇒ 面板盲区,现同臂分 source)。
|
|
26
14
|
if ((p.name === 'Bash' || p.name === 'Monitor') && !isError && end?.output !== undefined) {
|
|
27
15
|
const reg = detectEngineBgShellReceipt(p.name, p.rawInput, flattenWireOutput(end.output));
|
|
28
16
|
if (reg) {
|
|
29
17
|
yield chrome({ kind: 'bgshell_register', laneProof: mainLane(), taskId: reg.taskId, registration: reg });
|
|
30
18
|
}
|
|
31
19
|
}
|
|
32
|
-
// B 层:structured → 逐工具 typed toolUseResult(卡的 outputSchema safeParse 过才渲富卡)。
|
|
33
20
|
let rich = end?.structured !== undefined
|
|
34
21
|
? structuredToToolUseResult(end.structured, end.output !== undefined ? flattenWireOutput(end.output) : undefined)
|
|
35
22
|
: null;
|
|
36
|
-
// E 层 ④/⑤:两条按**工具名**的补位(引擎不发 type 判别位,B 层 switch 认领不了)。
|
|
37
23
|
if (rich === null && p.name === 'TodoWrite') {
|
|
38
24
|
const todo = todoWriteToolUseResult(p.rawInput, lastLiveTodos, isError);
|
|
39
25
|
if (todo !== null) {
|
|
@@ -59,25 +45,18 @@ export function createToolCardLedger(ctx, idOf) {
|
|
|
59
45
|
},
|
|
60
46
|
],
|
|
61
47
|
},
|
|
62
|
-
// DIVERGENCE-2:cli 在缺 eventId 时铸随机 v4,本包一律**稳定键派生**
|
|
63
|
-
// (`wtc_<toolUseId>` —— 一张卡一个结果,天然唯一;同流重放 ⇒ 同 id 序列,[1653])。
|
|
64
48
|
uuid: eventId ?? deriveTranscriptId({ toolCallId: p.id }, ctx),
|
|
65
49
|
session_id: ctx.sessionId,
|
|
66
50
|
...(parentToolCallId !== undefined ? { parent_tool_use_id: parentToolCallId } : {}),
|
|
67
|
-
// CC 结果卡读 sidecar 上的 typed 输出(不是 block content)。
|
|
68
51
|
toolUseResult: rich !== null ? rich.toolUseResult : (body.toolUseResult ?? body.content),
|
|
69
|
-
// T7:wire 没带正文的诚实标记 —— 在场 = 这张卡没有真实执行结果(UI 显示决策留端)。
|
|
70
52
|
...(body.degraded !== undefined ? { _sema_degraded: body.degraded } : {}),
|
|
71
53
|
}, ctx.now());
|
|
72
54
|
}
|
|
73
|
-
/** 关一张卡的**唯一**实现:出栈 + S1 复位 + 铸卡,前两步恒在第一个 yield 之前。 */
|
|
74
55
|
function* closeCard(p, end) {
|
|
75
56
|
pending.delete(p.id);
|
|
76
57
|
assistantResponseId = null;
|
|
77
58
|
yield* buildToolResult(p, end);
|
|
78
59
|
}
|
|
79
|
-
// 🔴 FIX-05 同族纪律:本模块**零 `this`** —— 全部走闭包变量与具名函数,
|
|
80
|
-
// 所以「同一个台账有两条访问路径」这件事在这里结构上不可能发生。
|
|
81
60
|
return {
|
|
82
61
|
has: (id) => pending.has(id),
|
|
83
62
|
peek: (id) => pending.get(id),
|
|
@@ -88,8 +67,6 @@ export function createToolCardLedger(ctx, idOf) {
|
|
|
88
67
|
close: closeCard,
|
|
89
68
|
*sweep() {
|
|
90
69
|
for (const [, p] of pending) {
|
|
91
|
-
// 走同一个 closeCard:出栈 + S1 复位 + 铸卡三步与显式关卡**逐字同一段代码**
|
|
92
|
-
// (拆分前这里把那三步又抄了一遍 —— 抄的那份就是「时序会漂」的第二个构造点)。
|
|
93
70
|
yield* closeCard(p);
|
|
94
71
|
}
|
|
95
72
|
},
|
|
@@ -1,65 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* adapt/turnFlags.ts — M6a **响应度量** + M6b **重试覆盖层**两个小状态机(A 族拆分;矩阵 §1.4)。
|
|
3
|
-
*
|
|
4
|
-
* 🔴 为什么这两件必须在**同一个文件**、而且必须**连驱动壳那一半一起搬**(矩阵 §3.3):
|
|
5
|
-
* 它们各自只有三行代码,但每一件的两半都分居在「驱动壳的帧前置」与「某一条臂」里:
|
|
6
|
-
* · `messageStartEmitted`:D4 的 TTFT 门写它,`turn_usage` 臂(A6)把它复位成 false
|
|
7
|
-
* (下一个 model round 重新压基线);
|
|
8
|
-
* · `endEmitted`:A6 置位,`result` 臂(A7)读它当「别重复发 end」的门;
|
|
9
|
-
* · `retryOverlayActive`:`retry_status` 臂(A15)挂旗,D4 的「恢复即清」判位清旗。
|
|
10
|
-
* 按「臂」切会切出**只有半个状态机**的边 —— 那正是 R1 五报里那条修最容易漂回去的地方。
|
|
11
|
-
* 所以本文件的对外面是**动作**(onFrameBeforeDispatch / noteRetryStatus / …),而不是三个布尔位。
|
|
12
|
-
*
|
|
13
|
-
* 判据留给下一个人:本文件之外的任何地方都不该出现 `messageStartEmitted` / `endEmitted` /
|
|
14
|
-
* `retryOverlayActive` 这三个名字**的代码引用**。grep 到了就是有人把状态机又劈开了。
|
|
15
|
-
* ⚠️ ADAPT-F5 判据纠偏(2026-08-02):原文没排除注释面,而它在落码当天就已被同批文件证伪 ——
|
|
16
|
-
* `arms.ts` 的帧序耦合注释(`⟨帧序耦合 7/7⟩` 那一处与臂序总表)按名字点这两个位是**有意的交叉
|
|
17
|
-
* 索引**,不是状态机被劈开。一条恒假阳性的判据等于没有判据([probe-must-prove-it-speaks] 同族),
|
|
18
|
-
* 所以判据锚在「代码引用」:grep 后先剔注释行,剩下的才算命中。
|
|
19
|
-
*/
|
|
20
1
|
import type { AdapterContext, AdapterOutput } from '../seam.js';
|
|
21
2
|
import { type Frame } from './ids.js';
|
|
22
3
|
export interface TurnFlags {
|
|
23
|
-
/**
|
|
24
|
-
* 每帧**分派之前**的两道前置(顺序与拆分前逐字一致:先恢复即清,再 TTFT 起拍):
|
|
25
|
-
* ① R1 重试覆盖层「恢复即清」;② 首个 `stream_event` 的 `response_metrics{phase:'start'}`。
|
|
26
|
-
*/
|
|
27
4
|
onFrameBeforeDispatch(m: Frame): Generator<AdapterOutput>;
|
|
28
|
-
/** A6 `turn_usage`:发 end 度量 + 压下一轮基线。 */
|
|
29
5
|
emitTurnUsageEnd(outputTokens: number): Generator<AdapterOutput>;
|
|
30
|
-
/**
|
|
31
|
-
* A6 `turn_usage` 的**无数字那一支**(0.68.0;异源对抗复审轮五实抓)——
|
|
32
|
-
* **只压下一轮基线,不发任何帧**。
|
|
33
|
-
*
|
|
34
|
-
* 🔴 为什么必须把它拆出来:`emitTurnUsageEnd` 一直在做**两件事** —— 发 end 度量 **与** 把
|
|
35
|
-
* `messageStartEmitted` 复位(下一个 model round 重新压 TTFT 基线)。而 #711 之后,一轮没量出账时
|
|
36
|
-
* 这一拍**没有数字可发**(占位零不许当读数,见 `adapter/runStream.ts` 的那条判据)⇒ 若整条跳过
|
|
37
|
-
* `emitTurnUsageEnd`,**连模型轮边界也一起跳过了**:下一轮不再发 `response_metrics{start}`,
|
|
38
|
-
* 它的用量于是按**上一轮**的基线对账(实测:首轮 400 字符缺账、次轮 4 字符 + 50 tokens,
|
|
39
|
-
* 计数从 150 掉到 101,且下一轮的 TTFT 记录一并丢失)。
|
|
40
|
-
* 🔴 判据分家:**「这一轮结束了」是一件事,「这一轮花了多少」是另一件事** —— 前者与有没有数字
|
|
41
|
-
* 无关,后者才受占位零那条判据管。合成一个动作,过滤数字就会顺手把边界也过滤掉。
|
|
42
|
-
*/
|
|
43
6
|
noteModelRoundBoundary(): void;
|
|
44
|
-
/** A7 `result`:只有还没发过 end 且这帧真带了 outputTokens 时才补发(`!endEmitted` 门)。 */
|
|
45
|
-
/** `readOutputTokens` 惰性:只在真的要发 end 度量时才读 usage(与拆分前「`!endEmitted`
|
|
46
|
-
* 门内才读 `m.usage`」逐字同语义 —— 对抗复审 #3 收货修)。 */
|
|
47
7
|
emitResultEndIfNeeded(readOutputTokens: () => number | undefined): Generator<AdapterOutput>;
|
|
48
|
-
/** A15 `retry_status`:挂旗(下一帧主 lane 内容到达即清)。 */
|
|
49
8
|
noteRetryOverlay(): void;
|
|
50
|
-
/**
|
|
51
|
-
* A15 `retry_status` 的反向动作(#3004 跟修批 2026-08-08):**引擎直报恢复**(`recovered` 相)那一拍
|
|
52
|
-
* 调它 —— 返回「本次是否**仍需**发清除」并同时落旗(**原子**:读+落一步完成)。
|
|
53
|
-
*
|
|
54
|
-
* 🔴 为什么必须是「take」而不是「clear」(对抗复审命中的双清):两条清除腿共用同一个布尔位,
|
|
55
|
-
* 而它们的触发顺序两个方向都真实存在 ——
|
|
56
|
-
* · `retrying → recovered`:直报腿先到,旗还在 ⇒ 本次要发清除,发完落旗;间接腿之后看不到旗。
|
|
57
|
-
* · `retrying → 主lane内容 → recovered`:**间接腿先到**(已发过一次 null 并落了旗),直报腿这一拍
|
|
58
|
-
* 就**不该再发第二发** —— 已安装 core 在内容流跑完的 finally 里发 `recovered`,所以这个顺序
|
|
59
|
-
* 才是常态路径。首版写成无条件发 + `clearRetryOverlay()`,于是这条常态路径上双清。
|
|
60
|
-
* 返回 false ⇒ 本臂这一拍不 yield(没有覆盖层可摘,沉默才是诚实的);状态机仍只有本文件一处
|
|
61
|
-
* 持有那个布尔位。
|
|
62
|
-
*/
|
|
63
9
|
takeRetryOverlay(): boolean;
|
|
64
10
|
}
|
|
65
11
|
export declare function createTurnFlags(ctx: AdapterContext, turnStartAt: number): TurnFlags;
|
package/dist/adapt/turnFlags.js
CHANGED
|
@@ -2,18 +2,6 @@ import { chrome, mainLane } from './ids.js';
|
|
|
2
2
|
export function createTurnFlags(ctx, turnStartAt) {
|
|
3
3
|
let messageStartEmitted = false;
|
|
4
4
|
let endEmitted = false;
|
|
5
|
-
/**
|
|
6
|
-
* R1(clay 五报 07-31):retry 覆盖层的四个清除点全在 turn 边界,缺「重试成功→清」的转移 ——
|
|
7
|
-
* 当时引擎重试成功那一刻什么都不发,所以恢复只能由「主 lane 又有内容在流」这个事实来证明。
|
|
8
|
-
* 挂旗后首个主 lane 内容帧即清,CC 同位 = 重试循环退出即 onRetryStatus(null)(pretty220 finally 清)。
|
|
9
|
-
*
|
|
10
|
-
* 🔴 现势更正(2026-08-08,#3004 跟修批):上面括号里原本写着「BrainStatusPhase 无恢复终态,候
|
|
11
|
-
* core [2163]」—— core 早已兑现,`BrainStatusPhase` 现有 `recovered` / `gave_up` 两个终态相。于是
|
|
12
|
-
* 本位这条**间接推断腿**不再是唯一证据:`retry_status` 臂拿到 `recovered` 时走 `takeRetryOverlay()`
|
|
13
|
-
* 直报清除。两条腿共用同一个布尔位、且都靠 take 的**原子读落**决定要不要发帧,所以无论到达顺序
|
|
14
|
-
* 如何(直报先 / 内容帧先),一次恢复合计**恰好一发** `status:null`(pure 门 R1b 段两个方向都钉)。
|
|
15
|
-
* 间接腿保留 —— 老引擎不发 `recovered`,它仍是那些部署上唯一的证据。
|
|
16
|
-
*/
|
|
17
5
|
let retryOverlayActive = false;
|
|
18
6
|
return {
|
|
19
7
|
*onFrameBeforeDispatch(m) {
|
|
@@ -23,11 +11,7 @@ export function createTurnFlags(ctx, turnStartAt) {
|
|
|
23
11
|
m.type === 'tool_end_result' ||
|
|
24
12
|
m.type === 'turn_usage') &&
|
|
25
13
|
typeof m.parentToolCallId !== 'string' &&
|
|
26
|
-
// stream_event 的子流标记在 event 里(thinking 臂同款判位),帧顶层没有。
|
|
27
14
|
typeof m.event?.parentToolCallId !== 'string') {
|
|
28
|
-
// 恢复即清:主 lane 内容帧到达 = 引擎那次重试已成功;子流帧(parentToolCallId)不算证据
|
|
29
|
-
// (主 brain 仍可能在退避等待,#47 矩阵 #5 同族判别)。落旗后 `takeRetryOverlay()` 会对随后
|
|
30
|
-
// 到达的 `recovered` 直报帧返回 false ⇒ 不补第二发(两条腿合计恰好一发)。
|
|
31
15
|
retryOverlayActive = false;
|
|
32
16
|
yield chrome({ kind: 'retry_status', laneProof: mainLane(), status: null });
|
|
33
17
|
}
|
|
@@ -44,7 +28,7 @@ export function createTurnFlags(ctx, turnStartAt) {
|
|
|
44
28
|
*emitTurnUsageEnd(outputTokens) {
|
|
45
29
|
yield chrome({ kind: 'response_metrics', laneProof: mainLane(), phase: 'end', outputTokens });
|
|
46
30
|
endEmitted = true;
|
|
47
|
-
messageStartEmitted = false;
|
|
31
|
+
messageStartEmitted = false;
|
|
48
32
|
},
|
|
49
33
|
noteModelRoundBoundary: () => {
|
|
50
34
|
messageStartEmitted = false;
|
|
@@ -1,104 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* adapt/wireShapes.ts — A 层的**帧形词表 + 纯投影助手**(A 族拆分 REF-CC-SPLIT-01)。
|
|
3
|
-
*
|
|
4
|
-
* 这里全是**纯函数与常量**:零可变量、零 module 台账、零 ctx 依赖。所以它既不出现在
|
|
5
|
-
* 读写矩阵(ADAPT-RW-MATRIX §1)的任何一行里,也不需要任何时序约束 —— 判据锚在
|
|
6
|
-
* 「本文件零 **module 级**可变绑定,也不 import 任何台账」,拆分后的状态归属讨论永远绕开它。
|
|
7
|
-
* ⚠️ ADAPT-F6 判据纠偏(2026-08-02):原文写的是「本文件没有 `let`」,而 `estimateCjkTokens` 的
|
|
8
|
-
* 累加器就是一个 `let t = 0`(函数体局部,进不了任何跨调用状态)。结论(零 turn 级状态)没错,
|
|
9
|
-
* 写下的判据是错的:照它 grep 当场红,而真要防的东西(module 级 `let`)它一个字没说。
|
|
10
|
-
*
|
|
11
|
-
* 🔴 公面纪律:下面标了「公面」的六件在 0.1.x 起就是 `@sema-agent/client-core` 的导出名,
|
|
12
|
-
* `adapt.ts` 用**具名再导出**把它们原样送出门(不是 `export *` —— 那会把 `TASK_TOOL_NAMES` /
|
|
13
|
-
* `decisionOf` 这两件内部件一起推上公面,public-export-baseline 双向门当场红)。
|
|
14
|
-
*/
|
|
15
1
|
import type { Frame } from './ids.js';
|
|
16
|
-
/**
|
|
17
|
-
* 活体增量攒批节拍的**默认值**(时钟从 ctx.now() 取;宿主可用 `ctx.coalesceIntervalMs` 覆盖)。
|
|
18
|
-
*
|
|
19
|
-
* 取值依据(两个都是实测,别把其中一个当"唯一真相"):
|
|
20
|
-
* · **100ms** = 我们对标的 CC 2.1.207 CLI 口径(187 时代是 16ms,207 提到 100ms 降重绘频率,
|
|
21
|
-
* 长回答滚动更稳)—— 壳是 207 fork,所以库的默认值取它,壳消费本包时行为零变化;
|
|
22
|
-
* · **16ms** = CC **桌面端**宿主 `makeStreamDeltaCoalescer` 的单帧攒批节拍(设计稿 R1 实测)。
|
|
23
|
-
* ⇒ 结论:**节拍是宿主渲染策略,不是 wire 语义** —— CC 自己两个端就是两个值。web/桌面宿主
|
|
24
|
-
* 想要 16ms 就传 `coalesceIntervalMs: 16`,合并**语义**(思考先于文本、段边界重开块、
|
|
25
|
-
* committed 恒随后)在库里,一份。
|
|
26
|
-
*
|
|
27
|
-
* 🔴 顺带钉一句反面事实(R1 证伪,别再写进任何注释/文档):**"UI 从不见裸 token" 是错的** ——
|
|
28
|
-
* CC 攒批后 flush 的载荷仍是 `stream_event` 增量 delta,CC 的 UI 照样消费增量;
|
|
29
|
-
* 完整 assistant 消息是 SDK 另发的一路。我们这里的 `stream_delta` chrome 臂同构。
|
|
30
|
-
*
|
|
31
|
-
* 公面。
|
|
32
|
-
*/
|
|
33
2
|
export declare const FLUSH_INTERVAL_MS = 100;
|
|
34
|
-
/**
|
|
35
|
-
* T40 IDLE-FLUSH 竞速窗(cli upstreamBridge `IDLE_FLUSH_MS` 逐字同值)。
|
|
36
|
-
*
|
|
37
|
-
* 病:模型转入长工具参数生成(大 Write 的 input_json 不经本桥)时 SSE 增量停摆,而 thinking/
|
|
38
|
-
* answerSegment 里**已经生成**的内容还押着陪等(pty 确证:11s 整屏 hash 恒定)。
|
|
39
|
-
* 修:增量停 ≥1.5s 且缓冲非空 ⇒ 先 drainLive()(活体预览语义不变),再提交思考+文本段
|
|
40
|
-
* (段序铁律不破:本来就该在下一张工具卡前 flush,这里只是提前)。
|
|
41
|
-
* 🔴 这是**过渡修**,正解在 core [817](wire 侧给事件);且**需要宿主定时器**:
|
|
42
|
-
* `ctx.setTimer` 缺席 ⇒ 整条竞速不启用(纯等下一帧),与 0.4.0 逐字同行为。
|
|
43
|
-
*
|
|
44
|
-
* 🔴 **适用域收紧**(#323 症状①,2026-08-25 clay 裁 (a)+(b) 合取):上面这条「缓冲非空就提交」
|
|
45
|
-
* 的原文**外溢**到了它没打算管的场景 —— 慢模型的正常吐字节奏本身就带 >1.5s 的卡顿,于是每卡一次
|
|
46
|
-
* 切一刀,一轮回复碎成 N 条 assistant 消息(屏上 N 个 ⏺;离线复现:1600ms 间隔 ⇒ 19 条)。
|
|
47
|
-
* 段提交因此改走 `textStream.takeAnswerSegmentOnIdle` 的**两条准入**:
|
|
48
|
-
* (a) 每个 answer segment 至多一刀(用掉之后要等一次正常边界重开新段);
|
|
49
|
-
* (b) 只在段尾是句末字符(`。!?…` / `.!?`)或换行时提交,否则跳过本拍等下一拍。
|
|
50
|
-
* 原意(大 Write 静默窗:开场白句末收尾 + 长静默 ⇒ 开场白先上屏)在两条准入下**原样成立**。
|
|
51
|
-
*
|
|
52
|
-
* 公面。
|
|
53
|
-
*/
|
|
54
3
|
export declare const IDLE_FLUSH_MS = 1500;
|
|
55
|
-
/** cli SUBAGENT_TOOL_NAMES / WORKFLOW_TOOL_NAMES 同源(判别资产,别各自重写)。公面。 */
|
|
56
4
|
export declare const SUBAGENT_TOOL_NAMES: ReadonlySet<string>;
|
|
57
5
|
export declare const WORKFLOW_TOOL_NAMES: ReadonlySet<string>;
|
|
58
|
-
/** 引擎 task 族工具(ctrl+t 面板台账同步的侧信道触发名;cli handleEngineTaskToolUse 受理的三名:
|
|
59
|
-
* TodoWrite 全量表 upsert + TaskCreate/TaskUpdate;其余工具该函数直接 return)。**内部件**。 */
|
|
60
6
|
export declare const TASK_TOOL_NAMES: ReadonlySet<string>;
|
|
61
|
-
/**
|
|
62
|
-
* CC 自己的 reject/cancel 哨兵串(**数据**,非 CC 逻辑;cli src/utils/messages.ts:210-212 逐字)。
|
|
63
|
-
* CC 的 UserToolResultMessage 按 content 串前缀路由到 reject/cancel 卡,不看 is_error 位。
|
|
64
|
-
*
|
|
65
|
-
* 公面。
|
|
66
|
-
*/
|
|
67
7
|
export declare const REJECT_MESSAGE = "The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the user to tell you how to proceed.";
|
|
68
8
|
export declare const CANCEL_MESSAGE = "The user doesn't want to take this action right now. STOP what you are doing and wait for the user to tell you how to proceed.";
|
|
69
|
-
/** CJK 加权 token 估算(cli estimateCjkTokens 逐字:CJK≈0.6,其余≈0.25 tok/char)。公面。 */
|
|
70
9
|
export declare function estimateCjkTokens(s: string): number;
|
|
71
|
-
/**
|
|
72
|
-
* T8 —— 压平 §E1 wire `output`(**非均匀**:`string` | `(TextContent|ImageContent)[]`,events.d.ts:78)
|
|
73
|
-
* 成一条纯文本(cli `flattenWireOutput` 逐字)。text 块贡献 `.text`,image 块贡献中性占位 `[image]`
|
|
74
|
-
* (转录卡是文本粒度),裸字符串直通。
|
|
75
|
-
* 🔴 载荷 UNTRUSTED + 仅供观测(events.d.ts:80-85):渲染可以,**绝不回喂模型**;`truncated` 的更不行。
|
|
76
|
-
* B4 把它从 B 层(`wireOutputToBody`)提到独立导出:A 层的 `settlePanelTasks(report)` 也要用它
|
|
77
|
-
* (关卡时把子代最终报告串到面板行 end 事件上),两处必须同一份实现。
|
|
78
|
-
*
|
|
79
|
-
* 🔴 **包内另有一份块数组展平**(0.30.0 发包扫描登记,2026-08-14):`subagentContentStore.ts` 的
|
|
80
|
-
* `coerceOutput`(子代查看态结果栏那一位)。它**不能** import 本文件 —— 那个 store 在 `runStream.ts`
|
|
81
|
-
* 内核可移植闭包(`MAX_CLOSURE_FILES`,只许降)之内且以 dep-free 立身。两份由 **pure 门 ⑨b 段的
|
|
82
|
-
* 等值断言**逐形对拍钉住(六形 + 逐字面值);改本函数的块数组语义 ⇒ 同批改那一份并看那条断言。
|
|
83
|
-
* ⚠️ 两者只在**块数组与裸串**这两形上等值:非串非数组时本函数按「转录卡是文本粒度」返回 `''`,
|
|
84
|
-
* 而 `coerceOutput` 走 `JSON.stringify`(它服务的是诚实缺席/原型不保的对象形),这一分叉是刻意的。
|
|
85
|
-
*
|
|
86
|
-
* 公面。
|
|
87
|
-
*/
|
|
88
10
|
export declare function flattenWireOutput(output: unknown): string;
|
|
89
|
-
/** 引擎 subagent 卡的短标签(cli shortTaskLabel 逐字)。公面。 */
|
|
90
11
|
export declare function shortTaskLabel(task: string): string;
|
|
91
|
-
/**
|
|
92
|
-
* tool_use 块的渲染面消毒(cli assistant 臂逐条搬运,**纯函数**,不改入参):
|
|
93
|
-
* ① 摘 §E2 wire 身份(eventId/parentToolCallId)并从渲染块剥掉;
|
|
94
|
-
* ② 剥所有 `_sema_*` 保留哨兵(CC 的 per-tool 渲染器 safeParse strictObject,多一个键就降级成通用卡);
|
|
95
|
-
* ③ 引擎 subagent 参数名 {agent,task,taskName} → CC 名 {subagent_type,description,prompt}
|
|
96
|
-
* (strict schema 拒绝多余键 ⇒ REPLACE 不 merge;taskName 缺席时从 task 派生短标签);
|
|
97
|
-
* ④ 件8 类型标签诚实化:引擎通道兑现不了的 subagent_type 值一律删(只留 fork/general-purpose/worker),
|
|
98
|
-
* 否则卡头会显示 `Plan(…)` 而实跑 general-purpose。
|
|
99
|
-
*
|
|
100
|
-
* 公面。
|
|
101
|
-
*/
|
|
102
12
|
export declare function sanitizeToolUseBlock(block: Record<string, unknown>): {
|
|
103
13
|
block: Record<string, unknown>;
|
|
104
14
|
rawInput: unknown;
|
|
@@ -106,6 +16,4 @@ export declare function sanitizeToolUseBlock(block: Record<string, unknown>): {
|
|
|
106
16
|
parentToolCallId?: string;
|
|
107
17
|
label?: string;
|
|
108
18
|
};
|
|
109
|
-
/** seam 的 reserved decision 哨兵(cli decisionOf 逐字)。**内部件**;入参用具名 `Frame` 而不是
|
|
110
|
-
* 再写一遍 `Record<string, unknown>`(同一个 unknown 边界只该有一个名字)。 */
|
|
111
19
|
export declare function decisionOf(block: Frame): 'reject' | 'cancel' | 'error' | undefined;
|
package/dist/adapt/wireShapes.js
CHANGED
|
@@ -1,57 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 活体增量攒批节拍的**默认值**(时钟从 ctx.now() 取;宿主可用 `ctx.coalesceIntervalMs` 覆盖)。
|
|
3
|
-
*
|
|
4
|
-
* 取值依据(两个都是实测,别把其中一个当"唯一真相"):
|
|
5
|
-
* · **100ms** = 我们对标的 CC 2.1.207 CLI 口径(187 时代是 16ms,207 提到 100ms 降重绘频率,
|
|
6
|
-
* 长回答滚动更稳)—— 壳是 207 fork,所以库的默认值取它,壳消费本包时行为零变化;
|
|
7
|
-
* · **16ms** = CC **桌面端**宿主 `makeStreamDeltaCoalescer` 的单帧攒批节拍(设计稿 R1 实测)。
|
|
8
|
-
* ⇒ 结论:**节拍是宿主渲染策略,不是 wire 语义** —— CC 自己两个端就是两个值。web/桌面宿主
|
|
9
|
-
* 想要 16ms 就传 `coalesceIntervalMs: 16`,合并**语义**(思考先于文本、段边界重开块、
|
|
10
|
-
* committed 恒随后)在库里,一份。
|
|
11
|
-
*
|
|
12
|
-
* 🔴 顺带钉一句反面事实(R1 证伪,别再写进任何注释/文档):**"UI 从不见裸 token" 是错的** ——
|
|
13
|
-
* CC 攒批后 flush 的载荷仍是 `stream_event` 增量 delta,CC 的 UI 照样消费增量;
|
|
14
|
-
* 完整 assistant 消息是 SDK 另发的一路。我们这里的 `stream_delta` chrome 臂同构。
|
|
15
|
-
*
|
|
16
|
-
* 公面。
|
|
17
|
-
*/
|
|
18
1
|
export const FLUSH_INTERVAL_MS = 100;
|
|
19
|
-
/**
|
|
20
|
-
* T40 IDLE-FLUSH 竞速窗(cli upstreamBridge `IDLE_FLUSH_MS` 逐字同值)。
|
|
21
|
-
*
|
|
22
|
-
* 病:模型转入长工具参数生成(大 Write 的 input_json 不经本桥)时 SSE 增量停摆,而 thinking/
|
|
23
|
-
* answerSegment 里**已经生成**的内容还押着陪等(pty 确证:11s 整屏 hash 恒定)。
|
|
24
|
-
* 修:增量停 ≥1.5s 且缓冲非空 ⇒ 先 drainLive()(活体预览语义不变),再提交思考+文本段
|
|
25
|
-
* (段序铁律不破:本来就该在下一张工具卡前 flush,这里只是提前)。
|
|
26
|
-
* 🔴 这是**过渡修**,正解在 core [817](wire 侧给事件);且**需要宿主定时器**:
|
|
27
|
-
* `ctx.setTimer` 缺席 ⇒ 整条竞速不启用(纯等下一帧),与 0.4.0 逐字同行为。
|
|
28
|
-
*
|
|
29
|
-
* 🔴 **适用域收紧**(#323 症状①,2026-08-25 clay 裁 (a)+(b) 合取):上面这条「缓冲非空就提交」
|
|
30
|
-
* 的原文**外溢**到了它没打算管的场景 —— 慢模型的正常吐字节奏本身就带 >1.5s 的卡顿,于是每卡一次
|
|
31
|
-
* 切一刀,一轮回复碎成 N 条 assistant 消息(屏上 N 个 ⏺;离线复现:1600ms 间隔 ⇒ 19 条)。
|
|
32
|
-
* 段提交因此改走 `textStream.takeAnswerSegmentOnIdle` 的**两条准入**:
|
|
33
|
-
* (a) 每个 answer segment 至多一刀(用掉之后要等一次正常边界重开新段);
|
|
34
|
-
* (b) 只在段尾是句末字符(`。!?…` / `.!?`)或换行时提交,否则跳过本拍等下一拍。
|
|
35
|
-
* 原意(大 Write 静默窗:开场白句末收尾 + 长静默 ⇒ 开场白先上屏)在两条准入下**原样成立**。
|
|
36
|
-
*
|
|
37
|
-
* 公面。
|
|
38
|
-
*/
|
|
39
2
|
export const IDLE_FLUSH_MS = 1500;
|
|
40
|
-
/** cli SUBAGENT_TOOL_NAMES / WORKFLOW_TOOL_NAMES 同源(判别资产,别各自重写)。公面。 */
|
|
41
3
|
export const SUBAGENT_TOOL_NAMES = new Set(['Task', 'Agent', 'Fork']);
|
|
42
4
|
export const WORKFLOW_TOOL_NAMES = new Set(['Workflow', 'RunWorkflow', 'run_workflow']);
|
|
43
|
-
/** 引擎 task 族工具(ctrl+t 面板台账同步的侧信道触发名;cli handleEngineTaskToolUse 受理的三名:
|
|
44
|
-
* TodoWrite 全量表 upsert + TaskCreate/TaskUpdate;其余工具该函数直接 return)。**内部件**。 */
|
|
45
5
|
export const TASK_TOOL_NAMES = new Set(['TodoWrite', 'TaskCreate', 'TaskUpdate']);
|
|
46
|
-
/**
|
|
47
|
-
* CC 自己的 reject/cancel 哨兵串(**数据**,非 CC 逻辑;cli src/utils/messages.ts:210-212 逐字)。
|
|
48
|
-
* CC 的 UserToolResultMessage 按 content 串前缀路由到 reject/cancel 卡,不看 is_error 位。
|
|
49
|
-
*
|
|
50
|
-
* 公面。
|
|
51
|
-
*/
|
|
52
6
|
export const REJECT_MESSAGE = "The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the user to tell you how to proceed.";
|
|
53
7
|
export const CANCEL_MESSAGE = "The user doesn't want to take this action right now. STOP what you are doing and wait for the user to tell you how to proceed.";
|
|
54
|
-
/** CJK 加权 token 估算(cli estimateCjkTokens 逐字:CJK≈0.6,其余≈0.25 tok/char)。公面。 */
|
|
55
8
|
export function estimateCjkTokens(s) {
|
|
56
9
|
let t = 0;
|
|
57
10
|
for (const c of s) {
|
|
@@ -68,23 +21,6 @@ export function estimateCjkTokens(s) {
|
|
|
68
21
|
}
|
|
69
22
|
return Math.round(t);
|
|
70
23
|
}
|
|
71
|
-
/**
|
|
72
|
-
* T8 —— 压平 §E1 wire `output`(**非均匀**:`string` | `(TextContent|ImageContent)[]`,events.d.ts:78)
|
|
73
|
-
* 成一条纯文本(cli `flattenWireOutput` 逐字)。text 块贡献 `.text`,image 块贡献中性占位 `[image]`
|
|
74
|
-
* (转录卡是文本粒度),裸字符串直通。
|
|
75
|
-
* 🔴 载荷 UNTRUSTED + 仅供观测(events.d.ts:80-85):渲染可以,**绝不回喂模型**;`truncated` 的更不行。
|
|
76
|
-
* B4 把它从 B 层(`wireOutputToBody`)提到独立导出:A 层的 `settlePanelTasks(report)` 也要用它
|
|
77
|
-
* (关卡时把子代最终报告串到面板行 end 事件上),两处必须同一份实现。
|
|
78
|
-
*
|
|
79
|
-
* 🔴 **包内另有一份块数组展平**(0.30.0 发包扫描登记,2026-08-14):`subagentContentStore.ts` 的
|
|
80
|
-
* `coerceOutput`(子代查看态结果栏那一位)。它**不能** import 本文件 —— 那个 store 在 `runStream.ts`
|
|
81
|
-
* 内核可移植闭包(`MAX_CLOSURE_FILES`,只许降)之内且以 dep-free 立身。两份由 **pure 门 ⑨b 段的
|
|
82
|
-
* 等值断言**逐形对拍钉住(六形 + 逐字面值);改本函数的块数组语义 ⇒ 同批改那一份并看那条断言。
|
|
83
|
-
* ⚠️ 两者只在**块数组与裸串**这两形上等值:非串非数组时本函数按「转录卡是文本粒度」返回 `''`,
|
|
84
|
-
* 而 `coerceOutput` 走 `JSON.stringify`(它服务的是诚实缺席/原型不保的对象形),这一分叉是刻意的。
|
|
85
|
-
*
|
|
86
|
-
* 公面。
|
|
87
|
-
*/
|
|
88
24
|
export function flattenWireOutput(output) {
|
|
89
25
|
if (typeof output === 'string')
|
|
90
26
|
return output;
|
|
@@ -103,34 +39,17 @@ export function flattenWireOutput(output) {
|
|
|
103
39
|
}
|
|
104
40
|
return '';
|
|
105
41
|
}
|
|
106
|
-
/** 引擎 subagent 卡的短标签(cli shortTaskLabel 逐字)。公面。 */
|
|
107
42
|
export function shortTaskLabel(task) {
|
|
108
43
|
const firstLine = (task.split('\n').find(l => l.trim()) ?? task).trim();
|
|
109
44
|
const words = firstLine.split(/\s+/).slice(0, 6).join(' ');
|
|
110
45
|
const label = words.length > 48 ? words.slice(0, 47) + '…' : words;
|
|
111
46
|
return label || 'subagent';
|
|
112
47
|
}
|
|
113
|
-
/**
|
|
114
|
-
* tool_use 块的渲染面消毒(cli assistant 臂逐条搬运,**纯函数**,不改入参):
|
|
115
|
-
* ① 摘 §E2 wire 身份(eventId/parentToolCallId)并从渲染块剥掉;
|
|
116
|
-
* ② 剥所有 `_sema_*` 保留哨兵(CC 的 per-tool 渲染器 safeParse strictObject,多一个键就降级成通用卡);
|
|
117
|
-
* ③ 引擎 subagent 参数名 {agent,task,taskName} → CC 名 {subagent_type,description,prompt}
|
|
118
|
-
* (strict schema 拒绝多余键 ⇒ REPLACE 不 merge;taskName 缺席时从 task 派生短标签);
|
|
119
|
-
* ④ 件8 类型标签诚实化:引擎通道兑现不了的 subagent_type 值一律删(只留 fork/general-purpose/worker),
|
|
120
|
-
* 否则卡头会显示 `Plan(…)` 而实跑 general-purpose。
|
|
121
|
-
*
|
|
122
|
-
* 公面。
|
|
123
|
-
*/
|
|
124
48
|
export function sanitizeToolUseBlock(block) {
|
|
125
49
|
const out = { ...block };
|
|
126
50
|
const rawInput = out.input;
|
|
127
51
|
const eventId = typeof out.eventId === 'string' ? out.eventId : undefined;
|
|
128
52
|
const parentToolCallId = typeof out.parentToolCallId === 'string' ? out.parentToolCallId : undefined;
|
|
129
|
-
// 🔴 B4 补漏(0.5.0 真缺口,差分守卫此前无 fixture 携 label ⇒ 漏得静默):core 的**展示名**
|
|
130
|
-
// `tool_start.label` 同样是侧信道,必须在渲染前摘掉 —— tool_use block 会进壳 transcript,
|
|
131
|
-
// /compact 时原样直发 provider,多一个键 = 400 invalid_request(cli 头注记的「件1 事故同款」)。
|
|
132
|
-
// 摘下来的值由调用方交给 engineToolLabelStore(纯函数不做副作用),unknown-tool 卡按
|
|
133
|
-
// toolCallId 查。今天唯一的真命中族 = MCP 远端工具(name=mcp__srv__tool / label=srv:tool)。
|
|
134
53
|
const label = typeof out.label === 'string' ? out.label : undefined;
|
|
135
54
|
delete out.label;
|
|
136
55
|
delete out.eventId;
|
|
@@ -173,8 +92,6 @@ export function sanitizeToolUseBlock(block) {
|
|
|
173
92
|
...(label !== undefined ? { label } : {}),
|
|
174
93
|
};
|
|
175
94
|
}
|
|
176
|
-
/** seam 的 reserved decision 哨兵(cli decisionOf 逐字)。**内部件**;入参用具名 `Frame` 而不是
|
|
177
|
-
* 再写一遍 `Record<string, unknown>`(同一个 unknown 边界只该有一个名字)。 */
|
|
178
95
|
export function decisionOf(block) {
|
|
179
96
|
const input = block.input;
|
|
180
97
|
const d = input?._sema_decision;
|
package/dist/adapt.d.ts
CHANGED
|
@@ -1,80 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* adapt.ts — L3 适配管线首批落码(#52a,2026-07-25)。
|
|
3
|
-
*
|
|
4
|
-
* 真源 = sema-cli `src/sema/upstreamBridge.ts` 的 `sdkMessagesToCcEvents`(~1500 行 generator,
|
|
5
|
-
* 几十批 bug 修的结晶)。本文件把其中**纯投影**的臂搬成与宿主无关的双平面产出:
|
|
6
|
-
* · transcript 平面 = 重启后还该看得见的(committed assistant 文本/思考、tool_use 卡、
|
|
7
|
-
* task-notification user turn、compact 分界),载体 = CC `SDKMessage` 词汇;
|
|
8
|
-
* · chrome 平面 = 纯瞬态 + 宿主副作用(活体增量、spinner 计量、attachment 行、面板/队列/hook
|
|
9
|
-
* 记账),载体 = `ChromeEvent`(每臂的宿主消费义务写在 seam.ts 臂注释里)。
|
|
10
|
-
* 判据成文见 seam.ts 头注([1652]);id 一律走 `deriveTranscriptId`([1653] 不变量:同流重放
|
|
11
|
-
* ⇒ 同 id 序列),**零 Math.random / 零 Date.now**——时钟与铸号全从 `AdapterContext` 注入。
|
|
12
|
-
*
|
|
13
|
-
* ⚠️ 本批**故意只做一半**(cli 迁移消费 = #52b)。未覆盖臂见 `ADAPTER_COVERAGE.todo`,差分守卫
|
|
14
|
-
* (scripts/run-client-core-diff-test.mjs)把「cli 有、adapt 无」的清单钉死,防止悄悄漏臂。
|
|
15
|
-
*
|
|
16
|
-
* ── A 族拆分后的地图(REF-CC-SPLIT-01~05 / FIX-05,2026-08-02;设计=docs/refactor/ADAPT-RW-MATRIX.md)
|
|
17
|
-
* `adapt()` 曾是 1139 行单方法(26 个 turn 级可变量 + 14 个闭包 + 15 个 case)。现在:
|
|
18
|
-
* 本文件 = 公面契约表 + 适配器实例(台账)+ **驱动壳**(迭代器竞速 / abort / finally / 收口三形)
|
|
19
|
-
* adapt/ids.ts 零状态共用件(双平面包装、Frame、主车道证明出厂口、id 派生工厂)
|
|
20
|
-
* adapt/wireShapes.ts 帧形词表 + 纯投影助手(公面十件由本文件具名再导出)
|
|
21
|
-
* adapt/textStream.ts M1 流合并器(矩阵 §1.1 十二行状态 + 竞速/节拍两处判据)
|
|
22
|
-
* adapt/toolCards.ts M2 工具卡台账(§1.2 三行;S1 复位收进 close() 第一个 yield 前)
|
|
23
|
-
* adapt/panelTasks.ts M3 面板行台账(§1.3 六行;通知臂那半场收成 settleFromNotification)
|
|
24
|
-
* adapt/turnFlags.ts M6a 响应度量 + M6b 重试覆盖层(两个小状态机,两半必须同文件)
|
|
25
|
-
* adapt/instanceLedger.ts 三个实例级 Set(FIX-05:消 self/this 双路径)
|
|
26
|
-
* adapt/arms.ts 15 条帧臂的注册表(Map,不是对象 —— `{type:'__proto__'}` 会污染原型)
|
|
27
|
-
* 🔴 最高不变量(拆分不许动):**段序铁律**(活体增量 → 思考 committed → 文本段 committed → 工具卡)
|
|
28
|
-
* 与**重放确定性**(同流同 id)。收口三形(result 臂 / abort 尾 / T60 尾)**次序不同**,
|
|
29
|
-
* 逐格差异见矩阵 §2.4,pure 门 SPLIT 段钉②/钉③ 把它们钉住了 —— 别归一。
|
|
30
|
-
*/
|
|
31
1
|
import type { AdapterContext, AdapterOutput, WireToCcAdapter } from './seam.js';
|
|
32
|
-
/**
|
|
33
|
-
* ── A 族拆分(REF-CC-SPLIT-01,2026-08-02)—— 帧形词表与双平面共用件已落 `src/adapt/` ─────────
|
|
34
|
-
* 本文件从此只留:公面契约表(coverage/divergences/ledger 形)+ 适配器实例(台账)+ **驱动壳**。
|
|
35
|
-
* 词表与纯助手在 `adapt/wireShapes.ts`,双平面包装与 id 派生在 `adapt/ids.ts`。
|
|
36
|
-
* 🔴 公面用**具名再导出**(不是 `export *`):`TASK_TOOL_NAMES` / `decisionOf` 是内部件,
|
|
37
|
-
* `export *` 会把它们推上 npm 公面,public-export-baseline 双向门当场红。
|
|
38
|
-
*/
|
|
39
2
|
export { CANCEL_MESSAGE, estimateCjkTokens, flattenWireOutput, FLUSH_INTERVAL_MS, IDLE_FLUSH_MS, REJECT_MESSAGE, sanitizeToolUseBlock, shortTaskLabel, SUBAGENT_TOOL_NAMES, WORKFLOW_TOOL_NAMES, } from './adapt/wireShapes.js';
|
|
40
|
-
/** 台账序列化形(#63 回植:重启恢复 = 台账加载 + 纯重放)。 */
|
|
41
3
|
export interface AdapterLedgerState {
|
|
42
4
|
version: 1;
|
|
43
|
-
/** 已渲染过的通知去重键(`[external:]taskId:status[:seq]`)。 */
|
|
44
5
|
renderedNotifications: string[];
|
|
45
|
-
/** 已「跨通道通知过」的 run(收到终态推送帧后,补发通道不得再注入模型一遍)。 */
|
|
46
6
|
notifiedRuns: string[];
|
|
47
|
-
/** 完成卡已入队的 run(probe 合成先发时,后到的推送帧只记账不再渲第二条)。 */
|
|
48
7
|
cardEnqueuedRuns: string[];
|
|
49
8
|
}
|
|
50
|
-
/** 本批覆盖清单——差分守卫按它区分「已覆盖臂必须逐字段等价」与「已声明未覆盖臂」。 */
|
|
51
9
|
export declare const ADAPTER_COVERAGE: {
|
|
52
|
-
/** 已落码的帧臂。 */
|
|
53
10
|
readonly frames: readonly ["assistant", "user", "stream_event", "turn_usage", "result", "system", "task_notification", "workflow_complete", "diagnostics", "steering_injected", "workspace_changed", "human_input", "message_committed", "engine_notice", "text_end", "prompt_suggestions", "retry_status", "task_progress", "tool_end_result(label 补位 + 关卡 settle + response-id 复位 + 开卡台账出栈 + 经 cards.close 铸 tool_result)"];
|
|
54
|
-
/** 已落码臂产出的 transcript 消息类目(差分守卫的比对域)。 */
|
|
55
11
|
readonly transcriptKinds: readonly ["assistant_text", "assistant_thinking", "assistant_tool_use", "user_tool_result_decision", "user_task_notification", "system_passthrough"];
|
|
56
|
-
/** B3(0.5.0)新落码的臂/半场 —— 从 todo 移过来的,别再在 todo 里留同名条目。 */
|
|
57
12
|
readonly b3: readonly ["T38 三清第三清 + T57 第五处断闸:prompt_suggestions(turn 开场作废 + 子流断闸)", "T40 IDLE-FLUSH 1.5s 竞速(需 ctx.setTimer;缺席=不启用)", "T58 手动 iterator 的 finally cleanup(early break/throw 都要关上游生成器)", "T59 abort 半场(ctx.signal;中断后不产终答)", "T60 无 result 收尾腿(泄尾增量 → 清 liveness → 尾思考 → 尾文本段)"];
|
|
58
|
-
/** B4(0.6.0)新落码的臂/半场 —— A 层收官批,同样别再在 todo 里留同名条目。 */
|
|
59
13
|
readonly b4: readonly ["A 层第 14 臂 task_progress:workflow lane 三级门 + 判据④ belt 回植 + C1 alias + bindTaskCard(显式父/FIFO/含糊即 unbound)+ inline stats + T50 双形读 + SubagentStart + #6 resident 台账 + 面板 tick", "settlePanelTasks 三处 sweep 全接线(tool_end 显式关卡带报告 / result 防御 sweep / turn 末 + abort sweep)", "P0-2 tool label 侧信道(sanitizeToolUseBlock 摘 label + engineToolLabelStore 登记;0.5.0 真缺口,label 会随 tool_use block 落转录 → /compact 直发 provider 400)", "task_notification 的两件宿主义务收回库内自持:dropQueuedNotificationsForRun + clearEnginePanelTaskResident;stop hook 的 if-started 门由库解", "T8 flattenWireOutput 提为独立导出(A 层 settle 报告与 B 层卡体同一份)"];
|
|
60
|
-
/** B5(0.7.0)新落码的臂/半场 —— B/D/E 层收批,同样别再在 todo 里留同名条目。 */
|
|
61
14
|
readonly b5: readonly ["B 层 structuredToToolUseResult 14 case(ask-user-question/bash/edit/create/update/text/grep/glob/notebook-edit/cron-create/cron-delete/cron-list/agent/task-output)+ workflow-run 登记副作用", "D 层 wireOutputToBody 3 臂(bash / taskoutput / 泛化);structured 白名单在场时 T11+T14 正则退位,缺席保回落", "E 层 4 臂:#117a bg Bash 回执 + #158 Monitor 回执(同臂按工具名分,registration.source 判别;判定在库→chrome bgshell_register)· TodoWrite oldTodos 富卡 · ReportFindings 按名认领 · Remember→memory_saved 系统消息", "tool_end_result → user tool_result 正常路径(卡本体);result 与 turn 末两处开卡兜底关闭(abort 不兜底,cli 同)", "task/task-list structured → chrome task_ledger_sync{source:\"structured\"}(判定归一在库、落盘留宿主)", "T7 诚实缺席(§8-4:不搬 mock 合成器,改 degraded 标记)· T20 diff hunks 进包(src/diff/patch.ts)"];
|
|
62
|
-
/** 如实留白——写不动/依赖未搬运资产的臂,#52b 起分批接。 */
|
|
63
15
|
readonly todo: readonly ["T13 的 **D 层** 半场(taskoutput block content)未随 structured 退位:退位会改 block content 形状(cli 那里是裸对象 = 件1 隐患),属行为面改动,无真实需求驱动 ⇒ 见 DIVERGENCE-8", "macrotask 让渡(cli 在提交前让出宏任务给 Ink;宿主渲染策略,不进库)"];
|
|
64
16
|
};
|
|
65
|
-
/** 本批**已知的、有意的**行为分歧(差分守卫显式登记,绝不当等价) */
|
|
66
17
|
export declare const ADAPTER_DIVERGENCES: readonly [string, string, string, string, string, string, string, string, string];
|
|
67
|
-
/** 有台账序列化位的适配器(seam 的 WireToCcAdapter 只定了 exportLedger——见 SEAM-GAP-1)。 */
|
|
68
18
|
export interface WireToCcAdapterWithLedger extends WireToCcAdapter {
|
|
69
19
|
exportLedger(): AdapterLedgerState & Record<string, unknown>;
|
|
70
|
-
/** 台账回植:返回真正吃进去的键数。 */
|
|
71
20
|
importLedger(state: Partial<AdapterLedgerState> | Record<string, unknown>): number;
|
|
72
|
-
/** #63 resume 回植:从落盘转录里的 `<task-notification>` 块重建终态去重键。 */
|
|
73
21
|
importLedgerFromTranscript(messages: ReadonlyArray<unknown>): number;
|
|
74
|
-
/** 宿主把「完成卡已入队」的事实喂回来(双通道反向去重;见 SEAM-GAP-3)。 */
|
|
75
22
|
noteCardEnqueued(runId: string): void;
|
|
76
23
|
}
|
|
77
|
-
/** 造一个带台账的适配器实例(**一个 session 一个**——跨 turn 去重靠实例存活,重启靠 import/export)。 */
|
|
78
24
|
export declare function createWireToCcAdapter(): WireToCcAdapterWithLedger;
|
|
79
|
-
/** 一次性(无跨 turn 台账)投影:`frames → AdapterOutput`。多 turn 请用 createWireToCcAdapter()。 */
|
|
80
25
|
export declare function adapt(frames: AsyncIterable<unknown>, ctx: AdapterContext): AsyncGenerator<AdapterOutput>;
|