@sema-agent/client-core 0.97.1 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +607 -0
- package/README.md +96 -46
- package/dist/adapt/arms.d.ts +1 -0
- package/dist/adapt/arms.js +188 -53
- package/dist/adapt/ids.d.ts +12 -1
- package/dist/adapt/ids.js +59 -8
- package/dist/adapt/instanceLedger.d.ts +50 -0
- package/dist/adapt/instanceLedger.js +147 -0
- package/dist/adapt/panelTasks.d.ts +1 -1
- package/dist/adapt/panelTasks.js +2 -2
- package/dist/adapt/textStream.d.ts +1 -0
- package/dist/adapt/textStream.js +24 -7
- package/dist/adapt/toolCards.d.ts +27 -5
- package/dist/adapt/toolCards.js +39 -6
- package/dist/adapt/wireShapes.js +6 -2
- package/dist/adapt.d.ts +2 -0
- package/dist/adapt.js +8 -3
- package/dist/adapter/activeRunSelfHeal.d.ts +9 -3
- package/dist/adapter/activeRunSelfHeal.js +205 -313
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
- package/dist/adapter/downstream/eventToSdkMessage.js +77 -36
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
- package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
- package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
- package/dist/adapter/runStream.js +79 -48
- package/dist/adapter/types.d.ts +4 -4
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/backgroundView.js +2 -1
- package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
- package/dist/agentSession/engineAgentRegistryRead.js +12 -13
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +8 -11
- package/dist/agentsWireCaps.js +196 -194
- package/dist/approvalDecidedByCapability.d.ts +0 -4
- package/dist/approvalDecidedByCapability.js +0 -6
- package/dist/approvalsStreamLiveCapability.d.ts +0 -4
- package/dist/approvalsStreamLiveCapability.js +0 -6
- package/dist/assistantInbox.d.ts +34 -0
- package/dist/assistantInbox.js +118 -0
- package/dist/centerWiringCapability.js +9 -1
- package/dist/clientSlice.d.ts +0 -9
- package/dist/clientSlice.js +0 -3
- package/dist/cloudConfigWireCaps.d.ts +5 -3
- package/dist/cloudConfigWireCaps.js +106 -64
- package/dist/compensations.js +1 -1
- package/dist/connectorStatus.d.ts +21 -0
- package/dist/connectorStatus.js +112 -0
- package/dist/controlRouter.d.ts +18 -3
- package/dist/controlRouter.js +106 -67
- package/dist/coreValuePorts.d.ts +29 -4
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/decideReceipt.d.ts +2 -2
- package/dist/decideReceipt.js +5 -2
- package/dist/declared/supportFloorDeclared.js +3 -3
- package/dist/detachWire.js +3 -2
- package/dist/deviceExecutorManagementCapability.d.ts +0 -4
- package/dist/deviceExecutorManagementCapability.js +0 -6
- package/dist/deviceRebind.d.ts +49 -1
- package/dist/deviceRebind.js +221 -3
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +2 -0
- package/dist/displayUntrusted.js +253 -76
- package/dist/engineAgentAbsence.d.ts +1 -1
- package/dist/engineAgentPanelStore.d.ts +12 -4
- package/dist/engineAgentPanelStore.js +16 -11
- package/dist/engineCapReader.d.ts +2 -5
- package/dist/engineCapReader.js +8 -10
- package/dist/engineCapsCache.d.ts +12 -0
- package/dist/engineCapsCache.js +76 -18
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineClosedSets.d.ts +1 -0
- package/dist/engineClosedSets.js +4 -1
- package/dist/engineErrorCodes.d.ts +11 -3
- package/dist/engineErrorCodes.js +11 -8
- package/dist/engineIdentity.d.ts +1 -0
- package/dist/engineIdentity.js +8 -0
- package/dist/engineRowRef.d.ts +28 -0
- package/dist/engineRowRef.js +114 -0
- package/dist/engineSessionMessages.d.ts +68 -0
- package/dist/engineSessionMessages.js +370 -0
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineToolDirectory.d.ts +0 -9
- package/dist/engineToolDirectory.js +1 -94
- package/dist/engineUrl.d.ts +18 -0
- package/dist/engineUrl.js +52 -0
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +11 -1
- package/dist/env/uiLanguage.js +38 -2
- package/dist/eventLeg.d.ts +100 -0
- package/dist/eventLeg.js +305 -0
- package/dist/executionLaneCapability.d.ts +0 -4
- package/dist/executionLaneCapability.js +3 -16
- package/dist/fileHistoryCaptureCapability.d.ts +2 -5
- package/dist/fileHistoryCaptureCapability.js +13 -21
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/fleet/fleetLedger.d.ts +0 -3
- package/dist/fleet/fleetLedger.js +21 -36
- package/dist/fleet/fleetProjection.d.ts +2 -2
- package/dist/fleet/fleetProjection.js +10 -8
- package/dist/frameBinding.d.ts +8 -0
- package/dist/frameBinding.js +35 -0
- package/dist/gateFailureCodes.d.ts +2 -0
- package/dist/gateFailureCodes.js +15 -0
- package/dist/gateOutcome.d.ts +3 -1
- package/dist/gateOutcome.js +41 -8
- package/dist/gateVocabulary.d.ts +10 -4
- package/dist/gateVocabulary.js +107 -47
- package/dist/generated/engineAskFaceTables.js +2 -2
- package/dist/generated/engineFactTables.d.ts +22 -3
- package/dist/generated/engineFactTables.js +51 -4
- package/dist/generated/engineNoticeTables.js +18 -3
- package/dist/generated/settingsSchemaFns.d.ts +6 -0
- package/dist/generated/settingsSchemaFns.js +57 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaTables.d.ts +1 -0
- package/dist/generated/settingsSchemaTables.js +4 -0
- package/dist/generated/settingsSchemaTypes.d.ts +105 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +8 -2
- package/dist/hitl/allowRuleShadow.js +36 -29
- package/dist/hitl/approvalCardReading.d.ts +15 -0
- package/dist/hitl/approvalCardReading.js +154 -0
- package/dist/hitl/approvalCardReasons.d.ts +14 -0
- package/dist/hitl/approvalCardReasons.js +119 -0
- package/dist/hitl/approvalHolds.d.ts +50 -15
- package/dist/hitl/approvalHolds.js +177 -27
- package/dist/hitl/approvalResolution.d.ts +51 -26
- package/dist/hitl/approvalResolution.js +86 -122
- package/dist/hitl/approvalsFeed.js +6 -18
- package/dist/hitl/askClassPair.d.ts +2 -0
- package/dist/hitl/askClassPair.js +17 -0
- package/dist/hitl/askGateWire.d.ts +20 -2
- package/dist/hitl/askGateWire.js +50 -1
- package/dist/hitl/askParkRowRouting.d.ts +5 -0
- package/dist/hitl/askParkRowRouting.js +32 -1
- package/dist/hitl/askSettlementLine.d.ts +28 -0
- package/dist/hitl/askSettlementLine.js +99 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +3 -2
- package/dist/hitl/automaticAnswerVerdict.js +29 -13
- package/dist/hitl/crashConverged.d.ts +11 -20
- package/dist/hitl/crashConverged.js +56 -0
- package/dist/hitl/crashConvergedNotice.d.ts +6 -3
- package/dist/hitl/crashConvergedNotice.js +48 -24
- package/dist/hitl/decisionConflict.js +3 -10
- package/dist/hitl/decisionRefusal.d.ts +40 -1
- package/dist/hitl/decisionRefusal.js +199 -42
- package/dist/hitl/frameRouter.d.ts +5 -2
- package/dist/hitl/frameRouter.js +27 -24
- package/dist/hitl/gateLedger.d.ts +2 -0
- package/dist/hitl/gateLedger.js +50 -13
- package/dist/hitl/hitlBridge.d.ts +2 -2
- package/dist/hitl/hitlBridge.js +13 -10
- package/dist/hitl/livePendingAsk.d.ts +3 -3
- package/dist/hitl/livePendingAsk.js +7 -18
- package/dist/hitl/parkResolver.d.ts +2 -24
- package/dist/hitl/parkResolver.js +61 -97
- package/dist/hitl/persistedRulesWire.d.ts +25 -0
- package/dist/hitl/persistedRulesWire.js +104 -2
- package/dist/hitl/planReviewWire.d.ts +31 -13
- package/dist/hitl/planReviewWire.js +120 -78
- package/dist/hitl/refusedToolNameProse.d.ts +0 -1
- package/dist/hitl/refusedToolNameProse.js +0 -3
- package/dist/hitl/replayedApproval.d.ts +4 -3
- package/dist/hitl/replayedApproval.js +7 -4
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +48 -7
- package/dist/hitl/sessionPolicyWire.d.ts +34 -21
- package/dist/hitl/sessionPolicyWire.js +179 -70
- package/dist/hitl/standingRows.d.ts +20 -2
- package/dist/hitl/standingRows.js +69 -8
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +103 -156
- package/dist/hitl/toolApprovalWire.js +661 -411
- package/dist/hookMatcherVerdict.d.ts +6 -1
- package/dist/hookMatcherVerdict.js +14 -7
- package/dist/hooksWireCaps.d.ts +2 -2
- package/dist/hooksWireCaps.js +174 -81
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +71 -0
- package/dist/hostTurnSettings.js +291 -0
- package/dist/humanTurn.d.ts +14 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +703 -0
- package/dist/i18n/messages.en.js +701 -0
- package/dist/i18n/messages.zh.d.ts +3 -0
- package/dist/i18n/messages.zh.js +837 -0
- package/dist/i18n/translate.d.ts +25 -0
- package/dist/i18n/translate.js +127 -0
- package/dist/index.d.ts +78 -29
- package/dist/index.js +54 -18
- package/dist/inheritEnvCapability.d.ts +32 -0
- package/dist/inheritEnvCapability.js +104 -0
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +12 -14
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +3 -3
- package/dist/liveModelCatalog.js +15 -13
- package/dist/liveQuestionStore.d.ts +2 -21
- package/dist/mcpLiveness.d.ts +2 -1
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +40 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +9 -2
- package/dist/mcpProbeWire.js +6 -1
- package/dist/mcpWireCaps.d.ts +47 -2
- package/dist/mcpWireCaps.js +164 -16
- package/dist/memoryEntriesWire.d.ts +4 -9
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/modelSupplyRules.d.ts +0 -2
- package/dist/model/modelSupplyRules.js +3 -12
- package/dist/model/modelsPolicy.d.ts +0 -5
- package/dist/model/modelsPolicy.js +6 -36
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/subagentModelWord.d.ts +31 -0
- package/dist/model/subagentModelWord.js +261 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +64 -0
- package/dist/modelCapabilityProbe.js +600 -0
- package/dist/modelIdentityResolvability.d.ts +3 -0
- package/dist/modelIdentityResolvability.js +26 -17
- package/dist/notifications.d.ts +6 -0
- package/dist/notifications.js +71 -23
- package/dist/outputStyleSeatCapability.d.ts +0 -3
- package/dist/outputStyleSeatCapability.js +0 -3
- package/dist/ownKey.d.ts +22 -0
- package/dist/ownKey.js +94 -3
- package/dist/panelReduce.d.ts +21 -10
- package/dist/panelReduce.js +728 -550
- package/dist/panelStateHolder.d.ts +3 -7
- package/dist/panelStateHolder.js +14 -130
- package/dist/peerLaneCapability.d.ts +0 -4
- package/dist/peerLaneCapability.js +0 -6
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.d.ts +2 -5
- package/dist/permissionRulesWriteCapability.js +8 -12
- package/dist/permissionWireCaps.d.ts +2 -2
- package/dist/permissionWireCaps.js +2 -0
- package/dist/permissionsAllowGrantCapability.d.ts +0 -4
- package/dist/permissionsAllowGrantCapability.js +0 -6
- package/dist/permissionsDeclaration.d.ts +0 -11
- package/dist/permissionsDeclaration.js +60 -53
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +219 -16
- package/dist/preemptWire.d.ts +44 -0
- package/dist/preemptWire.js +83 -0
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/printToolResultFrame.js +15 -4
- package/dist/replayBody.d.ts +3 -0
- package/dist/replayBody.js +14 -0
- package/dist/request/taskRequest.d.ts +11 -6
- package/dist/request/taskRequest.js +112 -19
- package/dist/resumeRefusalCopy.d.ts +13 -9
- package/dist/resumeRefusalCopy.js +81 -118
- package/dist/retryStatus.d.ts +45 -0
- package/dist/retryStatus.js +185 -1
- package/dist/rewindArchiveCapability.d.ts +0 -4
- package/dist/rewindArchiveCapability.js +2 -10
- package/dist/rewindArchiveReading.d.ts +0 -1
- package/dist/rewindArchiveReading.js +0 -3
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +4 -2
- package/dist/runReattachPolicy.d.ts +31 -0
- package/dist/runReattachPolicy.js +46 -0
- package/dist/runTerminal.d.ts +3 -6
- package/dist/runTerminal.js +8 -9
- package/dist/sandboxWire.d.ts +3 -1
- package/dist/sandboxWire.js +76 -27
- package/dist/scenarioRefusal.d.ts +9 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/scenarioWire.js +1 -1
- package/dist/seam.d.ts +48 -2
- package/dist/seam.js +25 -4
- package/dist/seatContract.d.ts +311 -18
- package/dist/seatContract.js +824 -100
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -5
- package/dist/sessionPolicyCapability.js +8 -12
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
- package/dist/sessionSyncFileHistoryCapability.js +0 -3
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -4
- package/dist/skillToolListsCapability.js +8 -9
- package/dist/sqlEngineCapability.d.ts +0 -4
- package/dist/sqlEngineCapability.js +0 -6
- package/dist/sseIdleTriage.js +3 -2
- package/dist/steerPriorityCapability.d.ts +0 -3
- package/dist/steerPriorityCapability.js +0 -3
- package/dist/streamDrainingLegs.d.ts +4 -0
- package/dist/streamDrainingLegs.js +6 -1
- package/dist/subagent/engineCompactWire.d.ts +0 -1
- package/dist/subagent/engineCompactWire.js +7 -5
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagent/engineTaskHandleWire.js +4 -7
- package/dist/subagentContentStore.d.ts +3 -0
- package/dist/subagentContentStore.js +22 -10
- package/dist/submitReopen.d.ts +24 -0
- package/dist/submitReopen.js +75 -0
- package/dist/terminalStatuses.d.ts +3 -0
- package/dist/terminalStatuses.js +10 -2
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolResult.d.ts +10 -1
- package/dist/toolResult.js +34 -6
- package/dist/toolRoster.d.ts +3 -4
- package/dist/toolRoster.js +21 -22
- package/dist/turnFailurePresentation.d.ts +39 -0
- package/dist/turnFailurePresentation.js +402 -0
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -4
- package/dist/userInvokedSkillsCapability.js +31 -10
- package/dist/webSearchBackendCapability.d.ts +0 -4
- package/dist/webSearchBackendCapability.js +0 -6
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +26 -23
- package/dist/wireFailureShape.d.ts +62 -5
- package/dist/wireFailureShape.js +106 -5
- package/dist/wireRefusalCopy.d.ts +25 -3
- package/dist/wireRefusalCopy.js +74 -80
- package/dist/workflowsJournalCapability.d.ts +2 -5
- package/dist/workflowsJournalCapability.js +8 -12
- package/dist/writeProtectionCapability.d.ts +0 -4
- package/dist/writeProtectionCapability.js +0 -6
- package/docs/INTEGRATION-CLIENTS.md +1775 -56
- package/package.json +6 -5
- package/dist/attachmentSeatCapability.d.ts +0 -12
- package/dist/attachmentSeatCapability.js +0 -23
- package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
- package/dist/hitl/approvalOutcomeNote.js +0 -29
- package/dist/sessionReadRedactionCapability.d.ts +0 -13
- package/dist/sessionReadRedactionCapability.js +0 -35
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { hostLog } from '../host.js';
|
|
2
|
-
import { resumeRetryLaterFromError } from '../wireErrorTriage.js';
|
|
2
|
+
import { isNotFoundFailure, resumeRetryLaterFromError } from '../wireErrorTriage.js';
|
|
3
|
+
import { readThrownSlot, THROWN_SLOT_UNREADABLE } from '../wireFailureShape.js';
|
|
3
4
|
import { RESUME_SESSION_NOT_FOUND } from '../engineErrorCodes.js';
|
|
4
5
|
import { displayUntrusted } from '../displayUntrusted.js';
|
|
5
6
|
import { engineCapTrue } from '../engineCapsCache.js';
|
|
@@ -25,15 +26,22 @@ const RETENTION_LAPSED_CODES = new Set([
|
|
|
25
26
|
RESUME_SESSION_NOT_FOUND,
|
|
26
27
|
]);
|
|
27
28
|
function shapeOf(e) {
|
|
28
|
-
const
|
|
29
|
+
const status = readThrownSlot(e ?? {}, 'status', 'data');
|
|
30
|
+
const errorCode = readThrownSlot(e ?? {}, 'errorCode', 'data');
|
|
31
|
+
const message = readThrownSlot(e ?? {}, 'message');
|
|
32
|
+
if (status === THROWN_SLOT_UNREADABLE || errorCode === THROWN_SLOT_UNREADABLE) {
|
|
33
|
+
return { message: typeof message === 'string' && message !== '' ? message : String(e), unreadable: true };
|
|
34
|
+
}
|
|
29
35
|
return {
|
|
30
|
-
...(typeof
|
|
31
|
-
...(typeof
|
|
32
|
-
message: typeof
|
|
36
|
+
...(typeof status === 'number' ? { status } : {}),
|
|
37
|
+
...(typeof errorCode === 'string' ? { errorCode } : {}),
|
|
38
|
+
message: typeof message === 'string' && message !== '' ? message : String(e),
|
|
33
39
|
};
|
|
34
40
|
}
|
|
35
41
|
export function classifySubagentResumeFailure(e) {
|
|
36
|
-
const { status, errorCode, message } = shapeOf(e);
|
|
42
|
+
const { status, errorCode, message, unreadable } = shapeOf(e);
|
|
43
|
+
if (unreadable === true)
|
|
44
|
+
return { reason: 'error', detail: message };
|
|
37
45
|
if (status === undefined && errorCode === undefined) {
|
|
38
46
|
const noAnswer = typeof e === 'object' ? noAnswerDetailFrom(e) : null;
|
|
39
47
|
if (noAnswer !== null)
|
|
@@ -63,12 +71,10 @@ export function classifySubagentResumeFailure(e) {
|
|
|
63
71
|
return { reason: 'row-contended', detail: message };
|
|
64
72
|
if (errorCode === 'resume.row_gone')
|
|
65
73
|
return { reason: 'row-gone', detail: message };
|
|
66
|
-
if (
|
|
74
|
+
if (isNotFoundFailure(e) !== false)
|
|
67
75
|
return { reason: 'not-found', detail: message };
|
|
68
76
|
if (errorCode === undefined && status === 400)
|
|
69
77
|
return { reason: 'bad-request', detail: message };
|
|
70
|
-
if (errorCode?.startsWith('not_found.') === true)
|
|
71
|
-
return { reason: 'not-found', detail: message };
|
|
72
78
|
return { reason: 'error', detail: message };
|
|
73
79
|
}
|
|
74
80
|
export function resolveOwnerRunId(childTaskId, activeRunId) {
|
|
@@ -2,7 +2,6 @@ import { TaskStopConflictError } from '@sema-agent/sdk';
|
|
|
2
2
|
import { hostLog } from '../host.js';
|
|
3
3
|
import { clientHasVerbs, engineWireFor, INJECTED_WIRE_SETTLE_MS, noAnswerDetailFrom, sendOnce, settleInjected } from '../engineWireFor.js';
|
|
4
4
|
import { engineWireDebugEnabled } from '../engineWireTarget.js';
|
|
5
|
-
import { engineCapTrue } from '../engineCapsCache.js';
|
|
6
5
|
import { engineSessionParamFor } from '../engineSessionParam.js';
|
|
7
6
|
import { resolveOwnerContext } from './engineSubagentResume.js';
|
|
8
7
|
import { engineTaskHandlesCapable } from './engineRowStopGate.js';
|
|
@@ -15,7 +14,7 @@ function usableTaskStopClient(client) {
|
|
|
15
14
|
}
|
|
16
15
|
const CAPS_KEY_REQUIRED_DETAIL = 'capability evidence for taskHandles is not available under the key the host named (capsBaseUrl) — nothing sent';
|
|
17
16
|
import { spoolMarkerOf } from '../toolResult.js';
|
|
18
|
-
import {
|
|
17
|
+
import { STOP_NOT_LANDED, STOP_NOT_LOCAL, STOP_PARKED, STOP_PARK_ARBITER_UNREACHABLE, STOP_PARK_RESUME_WON, } from '../engineErrorCodes.js';
|
|
19
18
|
function resolveHostRun(handle) {
|
|
20
19
|
const runId = resolveOwnerContext(handle).runId;
|
|
21
20
|
if (!runId) {
|
|
@@ -38,7 +37,7 @@ export async function fetchEngineTaskOutput(handle, opts) {
|
|
|
38
37
|
if (wire.kind === 'no-target' || wire.kind === 'injected-unusable')
|
|
39
38
|
return null;
|
|
40
39
|
if (wire.kind === 'injected') {
|
|
41
|
-
if (!
|
|
40
|
+
if (wire.capsBaseUrl === undefined || !engineTaskHandlesCapable(owner.key, wire.capsBaseUrl)) {
|
|
42
41
|
hostLog('debug', `[task-handle] output ${handle}: ${CAPS_KEY_REQUIRED_DETAIL}`);
|
|
43
42
|
return null;
|
|
44
43
|
}
|
|
@@ -115,9 +114,7 @@ function terminalOutputHint(output) {
|
|
|
115
114
|
export function classifyTaskStopConflict(e) {
|
|
116
115
|
const detail = e instanceof Error ? e.message : String(e);
|
|
117
116
|
const raw = e?.errorCode;
|
|
118
|
-
const code = typeof raw === 'string'
|
|
119
|
-
? raw
|
|
120
|
-
: (STOP_CONFLICT_CODES.find(c => detail.includes(c)) ?? '');
|
|
117
|
+
const code = typeof raw === 'string' ? raw : '';
|
|
121
118
|
switch (code) {
|
|
122
119
|
case STOP_NOT_LOCAL:
|
|
123
120
|
return { ok: false, reason: 'not_local', detail };
|
|
@@ -139,7 +136,7 @@ export async function stopEngineTask(handle, opts) {
|
|
|
139
136
|
if (wire.kind === 'no-target' || wire.kind === 'injected-unusable')
|
|
140
137
|
return { ok: false, reason: 'unavailable' };
|
|
141
138
|
if (wire.kind === 'injected') {
|
|
142
|
-
if (!
|
|
139
|
+
if (wire.capsBaseUrl === undefined || !engineTaskHandlesCapable(owner.key, wire.capsBaseUrl))
|
|
143
140
|
return { ok: false, reason: 'unavailable', detail: CAPS_KEY_REQUIRED_DETAIL };
|
|
144
141
|
}
|
|
145
142
|
else if (!engineTaskHandlesCapable(owner.key)) {
|
|
@@ -33,6 +33,9 @@ export interface SubagentContentEvent {
|
|
|
33
33
|
isError?: boolean | undefined;
|
|
34
34
|
}
|
|
35
35
|
export declare function coerceOutput(v: unknown): string | undefined;
|
|
36
|
+
export declare function subagentContentEventOf(ev: {
|
|
37
|
+
readonly type: string;
|
|
38
|
+
}): SubagentContentEvent | undefined;
|
|
36
39
|
export interface SubagentContentStoreConfig {
|
|
37
40
|
maxBytesPerTask: number;
|
|
38
41
|
maxBytesTotal: number;
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import { DEFAULT_SESSION_KEY } from './sessionSlot.js';
|
|
2
2
|
import { toolEndOutputText } from './toolResultContent.js';
|
|
3
3
|
export function coerceOutput(v) {
|
|
4
|
-
|
|
4
|
+
return toolEndOutputText(v);
|
|
5
|
+
}
|
|
6
|
+
export function subagentContentEventOf(ev) {
|
|
7
|
+
const t = ev.type;
|
|
8
|
+
if (t !== 'text_delta' && t !== 'reasoning_delta' && t !== 'text' && t !== 'reasoning' && t !== 'tool_start' && t !== 'tool_end')
|
|
5
9
|
return undefined;
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const sub = ev;
|
|
11
|
+
const parent = sub.parentToolCallId;
|
|
12
|
+
if (typeof parent !== 'string')
|
|
13
|
+
return undefined;
|
|
14
|
+
return {
|
|
15
|
+
type: sub.type,
|
|
16
|
+
taskId: sub.taskId ?? parent,
|
|
17
|
+
parentToolCallId: parent,
|
|
18
|
+
delta: sub.delta,
|
|
19
|
+
text: sub.text,
|
|
20
|
+
eventId: sub.eventId,
|
|
21
|
+
toolCallId: sub.toolCallId,
|
|
22
|
+
toolName: sub.toolName,
|
|
23
|
+
args: sub.args,
|
|
24
|
+
output: coerceOutput(sub.output),
|
|
25
|
+
isError: sub.isError,
|
|
26
|
+
};
|
|
15
27
|
}
|
|
16
28
|
const MAX_ITEMS_PER_TASK = 200;
|
|
17
29
|
const MAX_TASKS = 32;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type AgentClient, type AgentEvent, type TaskRequest } from '@sema-agent/sdk';
|
|
2
|
+
type TasksStreamOptions = Parameters<AgentClient['tasks']['stream']>[1];
|
|
3
|
+
export type SubmitStreamOptions = Omit<TasksStreamOptions, 'idempotencyKey'>;
|
|
4
|
+
export interface SubmitStreamReopenDeps {
|
|
5
|
+
readonly client: {
|
|
6
|
+
readonly tasks: {
|
|
7
|
+
stream(request: TaskRequest, options: TasksStreamOptions): AsyncGenerator<AgentEvent>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
readonly request: TaskRequest;
|
|
11
|
+
readonly options: SubmitStreamOptions;
|
|
12
|
+
}
|
|
13
|
+
export interface SubmitStreamReading {
|
|
14
|
+
readonly idempotencyKey: string;
|
|
15
|
+
readonly attempts: 0 | 1 | 2;
|
|
16
|
+
readonly reopened: boolean;
|
|
17
|
+
readonly replay: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface BoundedSubmitStream {
|
|
20
|
+
readonly frames: AsyncGenerator<AgentEvent>;
|
|
21
|
+
reading(): SubmitStreamReading;
|
|
22
|
+
}
|
|
23
|
+
export declare function submitStreamWithBoundedReopen(deps: SubmitStreamReopenDeps): BoundedSubmitStream;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { newIdempotencyKey } from '@sema-agent/sdk';
|
|
2
|
+
import { transportFailureScene } from './engineWireFor.js';
|
|
3
|
+
import { isReplayedTerminal } from './replayBody.js';
|
|
4
|
+
function boundByResponse(res) {
|
|
5
|
+
try {
|
|
6
|
+
const id = res.headers.get('x-task-id');
|
|
7
|
+
return typeof id === 'string' && id.length > 0;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function callerAborted(signal) {
|
|
14
|
+
try {
|
|
15
|
+
return signal !== null && signal !== undefined && signal.aborted === true;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function lostConnectionWithoutAnswer(error) {
|
|
22
|
+
const scene = transportFailureScene(error);
|
|
23
|
+
return scene.status === undefined && scene.end !== 'unreadable' && scene.noAnswer === 'connection-lost';
|
|
24
|
+
}
|
|
25
|
+
export function submitStreamWithBoundedReopen(deps) {
|
|
26
|
+
const idempotencyKey = newIdempotencyKey();
|
|
27
|
+
let attempts = 0;
|
|
28
|
+
let replay = false;
|
|
29
|
+
let consumerStopped = false;
|
|
30
|
+
async function* run() {
|
|
31
|
+
for (const attempt of [1, 2]) {
|
|
32
|
+
attempts = attempt;
|
|
33
|
+
let bound = false;
|
|
34
|
+
try {
|
|
35
|
+
const source = deps.client.tasks.stream(deps.request, {
|
|
36
|
+
...deps.options,
|
|
37
|
+
idempotencyKey,
|
|
38
|
+
onResponse: (res) => {
|
|
39
|
+
if (boundByResponse(res))
|
|
40
|
+
bound = true;
|
|
41
|
+
deps.options.onResponse?.(res);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
for await (const frame of source) {
|
|
45
|
+
bound = true;
|
|
46
|
+
if (isReplayedTerminal(frame))
|
|
47
|
+
replay = true;
|
|
48
|
+
yield frame;
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (attempt === 2 || bound || !lostConnectionWithoutAnswer(error))
|
|
54
|
+
throw error;
|
|
55
|
+
if (consumerStopped || callerAborted(deps.options.signal))
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const frames = run();
|
|
61
|
+
const innerReturn = frames.return.bind(frames);
|
|
62
|
+
const innerThrow = frames.throw.bind(frames);
|
|
63
|
+
frames.return = (value) => {
|
|
64
|
+
consumerStopped = true;
|
|
65
|
+
return innerReturn(value);
|
|
66
|
+
};
|
|
67
|
+
frames.throw = (error) => {
|
|
68
|
+
consumerStopped = true;
|
|
69
|
+
return innerThrow(error);
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
frames,
|
|
73
|
+
reading: () => Object.freeze({ idempotencyKey, attempts, reopened: attempts === 2, replay }),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -9,6 +9,9 @@ export declare function isSdkRunTerminal(status: unknown): status is SdkRunTermi
|
|
|
9
9
|
export declare function isSdkRunTerminalNotSuccess(status: unknown): status is Exclude<SdkRunTerminalStatus, 'completed'>;
|
|
10
10
|
export declare const SDK_PARKED_RUN_STATUSES: readonly ["suspended", "needs_review"];
|
|
11
11
|
export declare function isSdkRunParked(status: unknown): status is (typeof SDK_PARKED_RUN_STATUSES)[number];
|
|
12
|
+
export declare const SDK_RUN_LIVE_STATUSES: readonly ["running", "suspended", "needs_review"];
|
|
13
|
+
export type SdkRunLiveStatus = (typeof SDK_RUN_LIVE_STATUSES)[number];
|
|
14
|
+
export declare function isSdkRunLive(status: string): status is SdkRunLiveStatus;
|
|
12
15
|
export declare function isSdkRunFrameSynthesizable(status: unknown): boolean;
|
|
13
16
|
export declare const SDK_FLEET_TASK_TERMINAL_STATUSES: readonly ["completed", "failed", "killed"];
|
|
14
17
|
export type SdkFleetTaskTerminalStatus = (typeof SDK_FLEET_TASK_TERMINAL_STATUSES)[number];
|
package/dist/terminalStatuses.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CORE_TERMINAL_CAUSE_KINDS } from './generated/engineFactTables.js';
|
|
1
|
+
import { CORE_TERMINAL_CAUSE_KINDS, CORE_TASK_NOTIFICATION_TERMINAL_STATUSES as GENERATED_TASK_NOTIFICATION_TERMINAL_STATUSES } from './generated/engineFactTables.js';
|
|
2
2
|
function memberOf(table, word) {
|
|
3
3
|
return typeof word === 'string' && table.includes(word);
|
|
4
4
|
}
|
|
@@ -20,6 +20,14 @@ export const SDK_PARKED_RUN_STATUSES = Object.freeze(['suspended', 'needs_review
|
|
|
20
20
|
export function isSdkRunParked(status) {
|
|
21
21
|
return memberOf(SDK_PARKED_RUN_STATUSES, status);
|
|
22
22
|
}
|
|
23
|
+
export const SDK_RUN_LIVE_STATUSES = Object.freeze(['running', ...SDK_PARKED_RUN_STATUSES]);
|
|
24
|
+
const _runLiveCoversPartition = true;
|
|
25
|
+
const _partitionCoversRunLive = true;
|
|
26
|
+
void _runLiveCoversPartition;
|
|
27
|
+
void _partitionCoversRunLive;
|
|
28
|
+
export function isSdkRunLive(status) {
|
|
29
|
+
return memberOf(SDK_RUN_LIVE_STATUSES, status);
|
|
30
|
+
}
|
|
23
31
|
export function isSdkRunFrameSynthesizable(status) {
|
|
24
32
|
return isSdkRunTerminal(status) || isSdkRunParked(status);
|
|
25
33
|
}
|
|
@@ -30,7 +38,7 @@ export function isSdkFleetTaskTerminal(status) {
|
|
|
30
38
|
export function isSdkFleetTaskTerminalNotSuccess(status) {
|
|
31
39
|
return terminalNotSuccessOf(SDK_FLEET_TASK_TERMINAL_STATUSES, status);
|
|
32
40
|
}
|
|
33
|
-
export const CORE_TASK_NOTIFICATION_TERMINAL_STATUSES =
|
|
41
|
+
export const CORE_TASK_NOTIFICATION_TERMINAL_STATUSES = GENERATED_TASK_NOTIFICATION_TERMINAL_STATUSES;
|
|
34
42
|
export function isCoreTaskNotificationTerminal(status) {
|
|
35
43
|
return memberOf(CORE_TASK_NOTIFICATION_TERMINAL_STATUSES, status);
|
|
36
44
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { rewindArchiveReadingAt, rewindConversationAvailability } from './rewindArchiveReading.js';
|
|
2
|
+
import { ownDataField } from './ownKey.js';
|
|
2
3
|
export const TOOL_HISTORY_MISMATCH_KINDS = Object.freeze([
|
|
3
4
|
'tool_use_without_result',
|
|
4
5
|
'orphan_tool_result',
|
|
@@ -191,8 +192,8 @@ export function classifyToolHistoryMismatch(err) {
|
|
|
191
192
|
let status;
|
|
192
193
|
let rawMessage;
|
|
193
194
|
try {
|
|
194
|
-
code = err
|
|
195
|
-
status = err
|
|
195
|
+
code = ownDataField(err, 'code');
|
|
196
|
+
status = ownDataField(err, 'status');
|
|
196
197
|
rawMessage = err.message;
|
|
197
198
|
}
|
|
198
199
|
catch {
|
package/dist/toolResult.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TaskResult, TaskStats } from '@sema-agent/sdk';
|
|
2
2
|
import { type ModelFallbackReason } from './engineErrorCodes.js';
|
|
3
|
+
import type { toolKillCauseAcrossEngineIdentity } from './engineIdentity.js';
|
|
3
4
|
export declare const STRUCTURED_DETAIL_TYPES: ReadonlySet<string>;
|
|
4
5
|
export declare function structuredDetailType(structured: unknown): string | undefined;
|
|
5
6
|
export declare const PROTOCOL_MARKERS: {
|
|
@@ -103,7 +104,15 @@ export type ToolCardOutcomeReading = {
|
|
|
103
104
|
readonly kind: 'unreadable';
|
|
104
105
|
};
|
|
105
106
|
export declare function readToolCardOutcome(record: object | null | undefined): ToolCardOutcomeReading;
|
|
106
|
-
export
|
|
107
|
+
export interface ToolResultRowFlags {
|
|
108
|
+
readonly collateralAbort: boolean;
|
|
109
|
+
readonly interruptedNeverStarted: boolean;
|
|
110
|
+
readonly approvalWindowExpired: boolean;
|
|
111
|
+
readonly denialLimitWindowExpired: boolean;
|
|
112
|
+
}
|
|
113
|
+
export declare function toolResultRowFlagsOf(row: object | null | undefined): ToolResultRowFlags;
|
|
114
|
+
export type ToolKillCause = NonNullable<ReturnType<typeof toolKillCauseAcrossEngineIdentity>> | 'memory_pressure';
|
|
115
|
+
export declare function wireOutputToBody(toolName: string, output: unknown, isError: boolean, truncated: boolean, flatten: FlattenWireOutput, structured?: unknown, leaderLedger?: boolean, killCauseOf?: () => ToolKillCause | undefined): ToolResultBody;
|
|
107
116
|
export declare function structuredToToolUseResult(structured: unknown, modelText?: string, leaderLedger?: boolean): {
|
|
108
117
|
toolUseResult: unknown;
|
|
109
118
|
isError?: boolean;
|
package/dist/toolResult.js
CHANGED
|
@@ -4,7 +4,7 @@ import { parseWorkflowPollEnvelope, projectWorkflowTaskOutput } from './workflow
|
|
|
4
4
|
import { asModelFallbackReason } from './engineErrorCodes.js';
|
|
5
5
|
import { frozenSet } from './frozenSet.js';
|
|
6
6
|
import { bashExitOf, bashExitReadingFailed } from './bashExitReading.js';
|
|
7
|
-
import { readFrameTrueMark } from './ownKey.js';
|
|
7
|
+
import { readFrameTrueMark, readFrameTrueMarkReading } from './ownKey.js';
|
|
8
8
|
import { isCoreSemaTaskTerminal } from './terminalStatuses.js';
|
|
9
9
|
import { CORE_ENGINE_CARD_TYPES } from './generated/engineFactTables.js';
|
|
10
10
|
export const STRUCTURED_DETAIL_TYPES = frozenSet(CORE_ENGINE_CARD_TYPES);
|
|
@@ -314,7 +314,10 @@ export function readToolCardOutcome(record) {
|
|
|
314
314
|
const block = toolResultBlockOf(record);
|
|
315
315
|
if (block === undefined)
|
|
316
316
|
return { kind: 'unreadable' };
|
|
317
|
-
|
|
317
|
+
const notExecuted = readFrameTrueMarkReading(record, '_sema_not_executed');
|
|
318
|
+
if (notExecuted === 'unreadable')
|
|
319
|
+
return { kind: 'unreadable' };
|
|
320
|
+
if (notExecuted === 'marked')
|
|
318
321
|
return cardDegraded('not-executed');
|
|
319
322
|
const markerDesc = Object.getOwnPropertyDescriptor(record, '_sema_degraded');
|
|
320
323
|
if (markerDesc === undefined)
|
|
@@ -329,7 +332,31 @@ export function readToolCardOutcome(record) {
|
|
|
329
332
|
return { kind: 'unreadable' };
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
|
-
export function
|
|
335
|
+
export function toolResultRowFlagsOf(row) {
|
|
336
|
+
return Object.freeze({
|
|
337
|
+
collateralAbort: readFrameTrueMark(row, '_sema_collateral_abort'),
|
|
338
|
+
interruptedNeverStarted: readFrameTrueMark(row, '_sema_interrupted_never_started'),
|
|
339
|
+
approvalWindowExpired: readFrameTrueMark(row, '_sema_approval_window_expired'),
|
|
340
|
+
denialLimitWindowExpired: readFrameTrueMark(row, '_sema_denial_limit_window_expired'),
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
const TOOL_KILL_TEXT = {
|
|
344
|
+
engine_restarted: 'Command was killed when the engine restarted (exit 137)',
|
|
345
|
+
memory_pressure: 'Command was killed (exit 137 — the system ran out of memory; consider lowering build parallelism e.g. make -j2)',
|
|
346
|
+
unknown: 'Command was killed by signal 9 (exit 137)',
|
|
347
|
+
};
|
|
348
|
+
const isToolKillCause = (v) => v === 'engine_restarted' || v === 'memory_pressure';
|
|
349
|
+
const killedBySignalSentence = (killCauseOf) => {
|
|
350
|
+
let cause;
|
|
351
|
+
try {
|
|
352
|
+
cause = killCauseOf?.();
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
cause = undefined;
|
|
356
|
+
}
|
|
357
|
+
return TOOL_KILL_TEXT[isToolKillCause(cause) ? cause : 'unknown'];
|
|
358
|
+
};
|
|
359
|
+
export function wireOutputToBody(toolName, output, isError, truncated, flatten, structured, leaderLedger = true, killCauseOf) {
|
|
333
360
|
const text = flatten(output);
|
|
334
361
|
const name = (toolName || '').toLowerCase();
|
|
335
362
|
const sType = structuredDetailType(structured);
|
|
@@ -380,7 +407,7 @@ export function wireOutputToBody(toolName, output, isError, truncated, flatten,
|
|
|
380
407
|
const reason = slots.stderr.length > 0 ? slots.stderr : slots.stdout;
|
|
381
408
|
let body = slots.exitCode != null ? `Exit code ${slots.exitCode}\n${reason}` : reason;
|
|
382
409
|
if (slots.exitCode === 137) {
|
|
383
|
-
body += `\
|
|
410
|
+
body += `\n${killedBySignalSentence(killCauseOf)}`;
|
|
384
411
|
}
|
|
385
412
|
if (body.trim() === '' && text.trim() !== '')
|
|
386
413
|
body = text;
|
|
@@ -400,8 +427,9 @@ export function wireOutputToBody(toolName, output, isError, truncated, flatten,
|
|
|
400
427
|
};
|
|
401
428
|
}
|
|
402
429
|
const stdout = truncated ? `${text}\n…(truncated)` : text;
|
|
403
|
-
if (isError || bashExitReadingFailed(exit))
|
|
404
|
-
return { content: stdout, isError: true };
|
|
430
|
+
if (isError || bashExitReadingFailed(exit)) {
|
|
431
|
+
return { content: exit.exitCode === 137 ? `${stdout}\n${killedBySignalSentence(killCauseOf)}` : stdout, isError: true };
|
|
432
|
+
}
|
|
405
433
|
return { content: stdout, isError, toolUseResult: { stdout, stderr: '', interrupted: false } };
|
|
406
434
|
}
|
|
407
435
|
if (name === 'taskoutput' || name === 'task_output') {
|
package/dist/toolRoster.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
1
2
|
export interface ToolRosterPathTargetView {
|
|
2
3
|
param: string;
|
|
3
4
|
access: string;
|
|
@@ -12,7 +13,6 @@ export interface ToolRosterRenderHintsView {
|
|
|
12
13
|
activity?: string;
|
|
13
14
|
summaryParams?: readonly string[];
|
|
14
15
|
resultCards?: readonly string[];
|
|
15
|
-
approvalCard?: string;
|
|
16
16
|
}
|
|
17
17
|
export interface ToolRosterEntryView {
|
|
18
18
|
name: string;
|
|
@@ -78,8 +78,8 @@ export type HandsSeamReading = {
|
|
|
78
78
|
export declare function handsSeamReadingOf(view: {
|
|
79
79
|
readonly hands?: WiringManifestHandsView;
|
|
80
80
|
} | null | undefined): HandsSeamReading;
|
|
81
|
-
export declare function handsSeamDetail(reading: HandsSeamReading): string;
|
|
82
|
-
export declare function handsMountedDetail(reading: HandsMountedReading): string;
|
|
81
|
+
export declare function handsSeamDetail(reading: HandsSeamReading, lang?: UiLanguage): string;
|
|
82
|
+
export declare function handsMountedDetail(reading: HandsMountedReading, lang?: UiLanguage): string;
|
|
83
83
|
export declare function toolRosterNames(roster: ToolRosterView | undefined): readonly string[];
|
|
84
84
|
export interface ToolShim {
|
|
85
85
|
name: string;
|
|
@@ -87,7 +87,6 @@ export interface ToolShim {
|
|
|
87
87
|
family?: string;
|
|
88
88
|
userFacingName?: string;
|
|
89
89
|
activity?: string;
|
|
90
|
-
approvalCard?: string;
|
|
91
90
|
summaryParams?: readonly string[];
|
|
92
91
|
effect?: string;
|
|
93
92
|
egress?: boolean;
|
package/dist/toolRoster.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { displayUntrusted } from './displayUntrusted.js';
|
|
2
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
3
|
import { HANDS_REASON_NO_EXECUTION_ENV, projectHandsSection } from './handsSeam.js';
|
|
3
4
|
const str = (v) => typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
4
5
|
const strArr = (v) => Array.isArray(v) ? v.filter((x) => typeof x === 'string') : undefined;
|
|
@@ -77,7 +78,6 @@ function readEntry(raw) {
|
|
|
77
78
|
...(str(hintsRaw.activity) !== undefined ? { activity: str(hintsRaw.activity) } : {}),
|
|
78
79
|
...(strArr(hintsRaw.summaryParams) !== undefined ? { summaryParams: strArr(hintsRaw.summaryParams) } : {}),
|
|
79
80
|
...(strArr(hintsRaw.resultCards) !== undefined ? { resultCards: strArr(hintsRaw.resultCards) } : {}),
|
|
80
|
-
...(str(hintsRaw.approvalCard) !== undefined ? { approvalCard: str(hintsRaw.approvalCard) } : {}),
|
|
81
81
|
},
|
|
82
82
|
}
|
|
83
83
|
: {}),
|
|
@@ -145,55 +145,55 @@ export function handsSeamReadingOf(view) {
|
|
|
145
145
|
return { kind: 'mounted' };
|
|
146
146
|
return seam.reason !== undefined ? { kind: 'not_mounted', reason: seam.reason } : { kind: 'not_mounted' };
|
|
147
147
|
}
|
|
148
|
-
const HANDS_NONE_STEM = 'this leg of the run was assembled with NO built-in file-and-shell tools';
|
|
149
|
-
const HANDS_NONE_TAIL = "so on this leg the model had no tool of the engine's own for editing files or running commands (tools mounted by other conditions, such as external servers, and sub-runs delegated to other legs are not covered by this reading)";
|
|
150
148
|
const HANDS_REASON_DISPLAY_MAX = 64;
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
function handsNotReported(lang) {
|
|
150
|
+
return renderMessage(msg('notice.capability.hands.notReported'), lang);
|
|
151
|
+
}
|
|
152
|
+
export function handsSeamDetail(reading, lang) {
|
|
153
153
|
const kind = typeof reading === 'object' && reading !== null ? reading.kind : undefined;
|
|
154
154
|
switch (kind) {
|
|
155
155
|
case 'mounted':
|
|
156
|
-
return '
|
|
156
|
+
return renderMessage(msg('notice.capability.hands.seamMounted'), lang);
|
|
157
157
|
case 'not_mounted': {
|
|
158
158
|
const raw = reading.reason;
|
|
159
159
|
const reason = typeof raw === 'string' && raw.length > 0 ? raw : undefined;
|
|
160
160
|
const why = reason === undefined
|
|
161
|
-
? '
|
|
161
|
+
? msg('notice.capability.hands.whyNoReason')
|
|
162
162
|
: reason === HANDS_REASON_NO_EXECUTION_ENV
|
|
163
|
-
? '
|
|
164
|
-
:
|
|
165
|
-
return
|
|
163
|
+
? msg('notice.capability.hands.whyNoExecutionEnv')
|
|
164
|
+
: msg('notice.capability.hands.whyUnknownReason', { reason: displayUntrusted(reason, { max: HANDS_REASON_DISPLAY_MAX }) });
|
|
165
|
+
return renderMessage(msg('notice.capability.hands.noneLine', { stem: msg('notice.capability.hands.noneStem'), why, tail: msg('notice.capability.hands.noneTail') }), lang);
|
|
166
166
|
}
|
|
167
167
|
default:
|
|
168
|
-
return
|
|
168
|
+
return handsNotReported(lang);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
export function handsMountedDetail(reading) {
|
|
171
|
+
export function handsMountedDetail(reading, lang) {
|
|
172
172
|
const r = reading;
|
|
173
173
|
const kind = typeof r === 'object' && r !== null ? r.kind : undefined;
|
|
174
174
|
switch (kind) {
|
|
175
175
|
case 'mounted': {
|
|
176
176
|
const rows = r.rows;
|
|
177
177
|
if (typeof rows === 'number' && Number.isInteger(rows) && rows > 0)
|
|
178
|
-
return
|
|
179
|
-
return
|
|
178
|
+
return renderMessage(msg('notice.capability.hands.rosterMounted', { rows }), lang);
|
|
179
|
+
return handsNotReported(lang);
|
|
180
180
|
}
|
|
181
181
|
case 'not-mounted':
|
|
182
|
-
return
|
|
182
|
+
return renderMessage(msg('notice.capability.hands.rosterNotMounted', { stem: msg('notice.capability.hands.noneStem'), tail: msg('notice.capability.hands.noneTail') }), lang);
|
|
183
183
|
case 'unknown':
|
|
184
184
|
switch (r.why) {
|
|
185
185
|
case 'no-manifest':
|
|
186
|
-
return '
|
|
186
|
+
return renderMessage(msg('notice.capability.hands.unknownNoManifest'), lang);
|
|
187
187
|
case 'no-roster':
|
|
188
|
-
return '
|
|
188
|
+
return renderMessage(msg('notice.capability.hands.unknownNoRoster'), lang);
|
|
189
189
|
case 'roster-unreadable':
|
|
190
|
-
return '
|
|
190
|
+
return renderMessage(msg('notice.capability.hands.unknownRosterUnreadable'), lang);
|
|
191
191
|
case 'mount-condition-absent':
|
|
192
|
-
return '
|
|
192
|
+
return renderMessage(msg('notice.capability.hands.unknownMountConditionAbsent'), lang);
|
|
193
193
|
}
|
|
194
|
-
return
|
|
194
|
+
return handsNotReported(lang);
|
|
195
195
|
}
|
|
196
|
-
return
|
|
196
|
+
return handsNotReported(lang);
|
|
197
197
|
}
|
|
198
198
|
export function toolRosterNames(roster) {
|
|
199
199
|
return roster?.entries.map((e) => e.name) ?? [];
|
|
@@ -208,7 +208,6 @@ export function toolShimFromRoster(entry) {
|
|
|
208
208
|
...(e.family !== undefined ? { family: e.family } : {}),
|
|
209
209
|
...(e.renderHints?.userFacingName !== undefined ? { userFacingName: e.renderHints.userFacingName } : {}),
|
|
210
210
|
...(e.renderHints?.activity !== undefined ? { activity: e.renderHints.activity } : {}),
|
|
211
|
-
...(e.renderHints?.approvalCard !== undefined ? { approvalCard: e.renderHints.approvalCard } : {}),
|
|
212
211
|
...(e.renderHints?.summaryParams !== undefined ? { summaryParams: e.renderHints.summaryParams } : {}),
|
|
213
212
|
...(e.effect !== undefined ? { effect: e.effect } : {}),
|
|
214
213
|
...(e.egress !== undefined ? { egress: e.egress } : {}),
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
2
|
+
import { type TurnWireErrorVerdict } from './wireErrorTriage.js';
|
|
3
|
+
import { type LiveModelCatalog } from './liveModelCatalog.js';
|
|
4
|
+
import type { TaskRequestLike } from './request/taskRequest.js';
|
|
5
|
+
export type TurnFailureCategory = 'auth' | 'billing' | 'rate_limited' | 'invalid_request' | 'capability_unavailable' | 'timeout' | 'server_error' | 'connection_lost' | 'parked' | 'internal';
|
|
6
|
+
export declare const TURN_FAILURE_CATEGORIES: readonly TurnFailureCategory[];
|
|
7
|
+
export interface TurnFailureRetry {
|
|
8
|
+
readonly offer: boolean;
|
|
9
|
+
readonly basis: 'wire' | 'category';
|
|
10
|
+
}
|
|
11
|
+
export interface TurnFailurePresentation {
|
|
12
|
+
readonly category: TurnFailureCategory;
|
|
13
|
+
readonly kind: TurnWireErrorVerdict['kind'];
|
|
14
|
+
readonly status?: number;
|
|
15
|
+
readonly errorCode?: string;
|
|
16
|
+
readonly detail: string;
|
|
17
|
+
readonly headline?: string;
|
|
18
|
+
readonly name?: string;
|
|
19
|
+
readonly retry: TurnFailureRetry;
|
|
20
|
+
readonly waitSec?: number;
|
|
21
|
+
readonly notes: readonly string[];
|
|
22
|
+
readonly waitNote?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TurnFailureNotesContext {
|
|
25
|
+
readonly requestedScenario?: string;
|
|
26
|
+
readonly sentRequest?: TaskRequestLike;
|
|
27
|
+
readonly modelCatalog?: LiveModelCatalog | null;
|
|
28
|
+
readonly nowMs?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function turnFailurePresentation(err: {} | null | undefined, evidence?: {
|
|
31
|
+
readonly bound?: boolean;
|
|
32
|
+
readonly reopened?: boolean;
|
|
33
|
+
}, notesCtx?: TurnFailureNotesContext, lang?: UiLanguage): TurnFailurePresentation;
|
|
34
|
+
export type SeatTurnFailure = Pick<TurnFailurePresentation, 'category' | 'retry' | 'waitSec' | 'headline' | 'errorCode'>;
|
|
35
|
+
export declare function seatTurnFailureOf(err: {} | null | undefined, evidence?: {
|
|
36
|
+
readonly bound?: boolean;
|
|
37
|
+
readonly reopened?: boolean;
|
|
38
|
+
}): SeatTurnFailure;
|
|
39
|
+
export declare function readSeatTurnFailure(event: {} | null | undefined): SeatTurnFailure | undefined;
|