@sema-agent/client-core 0.109.0 → 0.111.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 +342 -0
- package/README.md +88 -32
- package/dist/abortableSleep.d.ts +7 -0
- package/dist/abortableSleep.js +37 -0
- package/dist/adapt/arms.js +45 -11
- package/dist/adapt/toolCards.d.ts +3 -1
- package/dist/adapt/toolCards.js +4 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
- package/dist/adapter/activeRunSelfHeal.js +171 -3
- package/dist/adapter/downstream/eventToSdkMessage.js +20 -15
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
- package/dist/adapter/runStream.d.ts +5 -0
- package/dist/adapter/runStream.js +15 -3
- package/dist/attachmentRoute.d.ts +20 -0
- package/dist/attachmentRoute.js +39 -0
- package/dist/attachmentsWireCaps.js +1 -1
- package/dist/builtinOutputStyles.d.ts +12 -0
- package/dist/builtinOutputStyles.js +147 -0
- package/dist/compactionStatus.d.ts +9 -0
- package/dist/compactionStatus.js +29 -5
- package/dist/controlRouter.js +2 -1
- package/dist/coreValuePorts.d.ts +39 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +138 -14
- package/dist/engineErrorCodes.d.ts +3 -0
- package/dist/engineErrorCodes.js +3 -0
- package/dist/engineHealthFacts.d.ts +20 -0
- package/dist/engineHealthFacts.js +42 -1
- package/dist/engineHealthProbeVerdict.d.ts +23 -0
- package/dist/engineHealthProbeVerdict.js +115 -0
- package/dist/engineInlineTaskStats.d.ts +4 -3
- package/dist/engineInlineTaskStats.js +18 -2
- package/dist/engineNoticeCodes.d.ts +10 -0
- package/dist/engineNoticeCodes.js +36 -6
- package/dist/engineRepoint.d.ts +147 -0
- package/dist/engineRepoint.js +310 -0
- package/dist/engineRowRef.d.ts +3 -0
- package/dist/engineRowRef.js +13 -1
- package/dist/engineSessionMessages.d.ts +2 -1
- package/dist/engineSessionMessages.js +5 -0
- package/dist/engineSwapCrossing.d.ts +57 -0
- package/dist/engineSwapCrossing.js +297 -0
- package/dist/engineUnavailable.d.ts +44 -0
- package/dist/engineUnavailable.js +492 -0
- package/dist/errorSupplementRoles.js +2 -1
- package/dist/eventLeg.js +3 -3
- package/dist/fleet/fleetProjection.js +3 -2
- package/dist/generated/engineFactTables.d.ts +2 -0
- package/dist/generated/engineFactTables.js +12 -0
- package/dist/generated/sdkFactTables.d.ts +2 -1
- package/dist/generated/sdkFactTables.js +5 -0
- package/dist/generated/settingsSchemaTables.d.ts +4 -0
- package/dist/generated/settingsSchemaTables.js +1 -0
- package/dist/hitl/approvalAskers.d.ts +6 -0
- package/dist/hitl/approvalAskers.js +30 -0
- package/dist/hitl/approvalCardReasons.js +6 -3
- package/dist/hitl/approvalDelivery.d.ts +1 -0
- package/dist/hitl/approvalDelivery.js +1 -1
- package/dist/hitl/approvalRequestFrameReading.d.ts +7 -0
- package/dist/hitl/approvalRequestFrameReading.js +11 -0
- package/dist/hitl/approvalResolution.d.ts +9 -2
- package/dist/hitl/approvalResolution.js +6 -1
- package/dist/hitl/askGateWire.js +5 -8
- package/dist/hitl/automaticAnswerVerdict.js +2 -2
- package/dist/hitl/decisionConflict.js +6 -3
- package/dist/hitl/decisionRefusal.d.ts +2 -0
- package/dist/hitl/decisionRefusal.js +8 -8
- package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
- package/dist/hitl/decisionRefusalCarrier.js +348 -0
- package/dist/hitl/decisionSend.d.ts +10 -0
- package/dist/hitl/decisionSend.js +57 -17
- package/dist/hitl/editedApprovalAcceptance.d.ts +25 -0
- package/dist/hitl/editedApprovalAcceptance.js +26 -0
- package/dist/hitl/elicitationRefusal.d.ts +4 -0
- package/dist/hitl/elicitationRefusal.js +23 -0
- package/dist/hitl/frameRouter.d.ts +2 -2
- package/dist/hitl/frameRouter.js +12 -33
- package/dist/hitl/gateIdentity.d.ts +5 -0
- package/dist/hitl/gateIdentity.js +23 -0
- package/dist/hitl/gateLedger.d.ts +0 -4
- package/dist/hitl/gateLedger.js +0 -19
- package/dist/hitl/hitlBridge.d.ts +7 -0
- package/dist/hitl/hitlBridge.js +14 -8
- package/dist/hitl/hitlHostSurface.d.ts +3 -1
- package/dist/hitl/hitlHostSurface.js +14 -4
- package/dist/hitl/hostWithdrawal.d.ts +15 -0
- package/dist/hitl/hostWithdrawal.js +38 -0
- package/dist/hitl/localAllowRedemption.d.ts +67 -0
- package/dist/hitl/localAllowRedemption.js +256 -0
- package/dist/hitl/parkResolver.js +32 -13
- package/dist/hitl/persistedRulesWire.d.ts +16 -0
- package/dist/hitl/persistedRulesWire.js +72 -2
- package/dist/hitl/planReviewWire.d.ts +3 -0
- package/dist/hitl/planReviewWire.js +37 -10
- package/dist/hitl/policyDenyCause.d.ts +1 -1
- package/dist/hitl/policyDenyCause.js +1 -1
- package/dist/hitl/resumeRunningCard.d.ts +1 -0
- package/dist/hitl/resumeRunningCard.js +1 -0
- package/dist/hitl/screenCardCarriers.d.ts +15 -0
- package/dist/hitl/screenCardCarriers.js +41 -0
- package/dist/hitl/screenDecisionCards.d.ts +98 -0
- package/dist/hitl/screenDecisionCards.js +362 -0
- package/dist/hitl/sessionPolicyWire.js +6 -4
- package/dist/hitl/standingRows.d.ts +4 -1
- package/dist/hitl/standingRows.js +33 -1
- package/dist/hitl/toolApprovalWire.d.ts +64 -15
- package/dist/hitl/toolApprovalWire.js +470 -125
- package/dist/hooksWireCaps.js +31 -1
- package/dist/hostSettingNoticeArm.d.ts +3 -0
- package/dist/hostSettingNoticeArm.js +12 -0
- package/dist/hostTurnSettings.d.ts +13 -4
- package/dist/hostTurnSettings.js +150 -10
- package/dist/humanTurnRead.js +11 -1
- package/dist/i18n/messages.en.d.ts +212 -0
- package/dist/i18n/messages.en.js +217 -5
- package/dist/i18n/messages.zh.js +235 -5
- package/dist/i18n/translate.d.ts +3 -0
- package/dist/i18n/translate.js +78 -10
- package/dist/i18n/zh.d.ts +1 -0
- package/dist/i18n/zh.js +1 -0
- package/dist/index.d.ts +56 -16
- package/dist/index.js +40 -12
- package/dist/inheritEnvCapability.js +2 -0
- package/dist/inputAuthor.d.ts +16 -0
- package/dist/inputAuthor.js +44 -0
- package/dist/interactiveHalt.js +2 -1
- package/dist/interactiveInterrupt.js +20 -2
- package/dist/interruptRefusalNote.d.ts +2 -0
- package/dist/interruptRefusalNote.js +17 -0
- package/dist/liveModelCatalog.d.ts +2 -0
- package/dist/liveModelCatalog.js +23 -9
- package/dist/liveQuestionStore.d.ts +4 -1
- package/dist/liveQuestionStore.js +12 -3
- package/dist/localEngineSeatReading.d.ts +2 -2
- package/dist/localEngineSeatReading.js +5 -3
- package/dist/localEngineSpawn.d.ts +0 -7
- package/dist/localEngineSpawn.js +0 -92
- package/dist/localEngineStep.d.ts +2 -2
- package/dist/localEngineStep.js +2 -0
- package/dist/mcpEngineLeg.d.ts +3 -0
- package/dist/mcpEngineLeg.js +38 -1
- package/dist/mcpPanel.js +2 -0
- package/dist/mcpReconnect.d.ts +9 -1
- package/dist/mcpReconnect.js +124 -19
- package/dist/mcpWireCaps.js +1 -1
- package/dist/model/engineModelWords.d.ts +3 -0
- package/dist/model/engineModelWords.js +13 -0
- package/dist/model/subagentModelWord.d.ts +21 -2
- package/dist/model/subagentModelWord.js +100 -29
- package/dist/modelCapabilityProbe.js +7 -43
- package/dist/modsFace.d.ts +8 -1
- package/dist/modsFace.js +27 -0
- package/dist/notifications.d.ts +36 -6
- package/dist/notifications.js +170 -20
- package/dist/ownKey.d.ts +6 -5
- package/dist/ownKey.js +31 -7
- package/dist/peerFrames.d.ts +40 -2
- package/dist/peerFrames.js +158 -3
- package/dist/pendingUserRow.d.ts +4 -0
- package/dist/pendingUserRow.js +16 -0
- package/dist/permissionsDeclaration.d.ts +1 -0
- package/dist/permissionsDeclaration.js +11 -1
- package/dist/planReviewCardFacts.d.ts +3 -0
- package/dist/planReviewCardFacts.js +52 -2
- package/dist/pluginHooksWire.d.ts +10 -1
- package/dist/pluginHooksWire.js +96 -7
- package/dist/printToolResultFrame.js +4 -2
- package/dist/promptBlockedCopy.js +11 -6
- package/dist/promptSuggestionBatch.d.ts +7 -0
- package/dist/promptSuggestionBatch.js +9 -0
- package/dist/promptSuggestionsTail.d.ts +39 -0
- package/dist/promptSuggestionsTail.js +116 -0
- package/dist/replayBody.js +10 -2
- package/dist/request/taskRequest.d.ts +5 -0
- package/dist/request/taskRequest.js +142 -21
- package/dist/requestCoordinate.d.ts +1 -0
- package/dist/requestCoordinate.js +13 -0
- package/dist/resumeRefusalCopy.d.ts +1 -3
- package/dist/resumeRefusalCopy.js +2 -1
- package/dist/retryStatus.d.ts +2 -2
- package/dist/retryStatus.js +2 -0
- package/dist/rewindArchiveReading.js +4 -4
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +1 -0
- package/dist/runPermissionModeSwitch.js +2 -2
- package/dist/scenarioRefusal.js +11 -13
- package/dist/scenarioSkills.js +11 -6
- package/dist/seam.d.ts +27 -2
- package/dist/seam.js +17 -1
- package/dist/seatContract.d.ts +189 -12
- package/dist/seatContract.js +401 -9
- package/dist/sessionBackground.js +2 -1
- package/dist/sessionBackgroundHandoff.js +2 -1
- package/dist/sessionCostReading.d.ts +70 -0
- package/dist/sessionCostReading.js +150 -0
- package/dist/sessionEngine.d.ts +2 -0
- package/dist/sessionEngine.js +111 -0
- package/dist/sessionHooksRoster.d.ts +4 -0
- package/dist/sessionHooksRoster.js +158 -0
- package/dist/sessionMemoryStatus.d.ts +2 -1
- package/dist/sessionMemoryStatus.js +2 -2
- package/dist/sessionReadRedaction.d.ts +7 -0
- package/dist/sessionReadRedaction.js +26 -0
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +27 -0
- package/dist/settingsHooksSalvage.js +2 -1
- package/dist/sseIdleTriage.d.ts +13 -1
- package/dist/sseIdleTriage.js +25 -6
- package/dist/storeDurabilityWord.d.ts +15 -0
- package/dist/storeDurabilityWord.js +18 -0
- package/dist/storePostureCapability.d.ts +7 -3
- package/dist/storePostureCapability.js +69 -39
- package/dist/subagent/engineSubagentResume.js +2 -2
- package/dist/subagent/engineSubagentTail.js +8 -1
- package/dist/subagentContentStore.d.ts +11 -0
- package/dist/subagentContentStore.js +28 -2
- package/dist/terminalStatuses.d.ts +1 -0
- package/dist/terminalStatuses.js +4 -1
- package/dist/toolResult.d.ts +1 -0
- package/dist/toolResult.js +2 -0
- package/dist/turnFailurePresentation.js +9 -2
- package/dist/typePins.d.ts +11 -0
- package/dist/usageAnalytics.d.ts +17 -0
- package/dist/usageAnalytics.js +44 -2
- package/dist/userAttachmentEnvelope.d.ts +2 -1
- package/dist/userAttachmentEnvelope.js +10 -0
- package/dist/wireErrorTriage.js +2 -1
- package/dist/wireFailureShape.d.ts +6 -5
- package/dist/wireFailureShape.js +150 -38
- package/dist/wireRefusalCopy.d.ts +16 -5
- package/dist/wireRefusalCopy.js +119 -86
- package/docs/INTEGRATION-CLIENTS.md +4228 -21
- package/package.json +7 -3
|
@@ -67,6 +67,36 @@ export function approvalAskReasonsOf(carrier) {
|
|
|
67
67
|
return undefined;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
export function requestedByViewOf(v) {
|
|
71
|
+
try {
|
|
72
|
+
if (typeof v !== 'object' || v === null || Array.isArray(v))
|
|
73
|
+
return undefined;
|
|
74
|
+
const kind = slotReadOf(v, 'kind');
|
|
75
|
+
if (kind.presence !== 'present' || kind.value !== 'extension')
|
|
76
|
+
return undefined;
|
|
77
|
+
const name = ownNonEmptyText(v, 'name');
|
|
78
|
+
if (name === undefined)
|
|
79
|
+
return undefined;
|
|
80
|
+
return Object.freeze({ kind: 'extension', name });
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function approvalRequestedByOf(carrier) {
|
|
87
|
+
try {
|
|
88
|
+
if (typeof carrier !== 'object' || carrier === null)
|
|
89
|
+
return undefined;
|
|
90
|
+
const slot = slotReadOf(carrier, 'requestedBy');
|
|
91
|
+
if (slot.presence !== 'present')
|
|
92
|
+
return undefined;
|
|
93
|
+
const v = slot.value;
|
|
94
|
+
return typeof v === 'object' && v !== null ? requestedByViewOf(v) : undefined;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
70
100
|
export function approvalAgentIdOf(carrier) {
|
|
71
101
|
try {
|
|
72
102
|
if (typeof carrier !== 'object' || carrier === null)
|
|
@@ -4,7 +4,7 @@ import { approvalMandateDetail, askOriginNoteOf } from '../gateVocabulary.js';
|
|
|
4
4
|
import { readAskOrigin, readOwnDataValue, guardedRead } from '../ownKey.js';
|
|
5
5
|
import { elideMiddleForDisplay } from '../noticePresentation.js';
|
|
6
6
|
import { allowRuleShadowSentence } from './allowRuleShadow.js';
|
|
7
|
-
import {
|
|
7
|
+
import { cardPayloadReadingOf } from './approvalRequestFrameReading.js';
|
|
8
8
|
import { mandatedApprovalDetailOf } from './automaticAnswerVerdict.js';
|
|
9
9
|
import { approvalBoundGrantsDetail, approvalIsMandated, approvalPriorCardsDetail, askProbeReasonDetail, classifierNoRulingDetail, readApprovalBoundGrants, readApprovalClassifierNoRuling, readApprovalMandate, readDenialLimitFallback, } from './toolApprovalWire.js';
|
|
10
10
|
export const APPROVAL_CARD_REASON_SOURCES = Object.freeze([
|
|
@@ -31,7 +31,7 @@ function engineMessageLine(engineMessage) {
|
|
|
31
31
|
return settled.length <= MESSAGE_DISPLAY_MAX ? settled : displayUntrusted(engineMessage, { max: MESSAGE_DISPLAY_MAX });
|
|
32
32
|
}
|
|
33
33
|
function payloadUnreadableDetail(why, lang) {
|
|
34
|
-
switch (
|
|
34
|
+
switch (why) {
|
|
35
35
|
case 'version_unknown':
|
|
36
36
|
return renderMessage(msg('approval.card.payloadUnreadable.versionUnknown'), lang);
|
|
37
37
|
case 'kind_unknown':
|
|
@@ -82,7 +82,10 @@ export function approvalCardReasons(card, opts, lang) {
|
|
|
82
82
|
catch {
|
|
83
83
|
denialLimitReadable = false;
|
|
84
84
|
}
|
|
85
|
-
add('payload_unreadable', () =>
|
|
85
|
+
add('payload_unreadable', () => {
|
|
86
|
+
const reading = cardPayloadReadingOf(card);
|
|
87
|
+
return reading.payloadUnreadable ? payloadUnreadableDetail(reading.why, lang) : undefined;
|
|
88
|
+
});
|
|
86
89
|
add('prior_cards', () => approvalPriorCardsDetail(card, lang));
|
|
87
90
|
add('message', () => {
|
|
88
91
|
const engineMessage = ownData(card, 'message');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AnswerCapture, type TopCauseReading, type TopLocalCodeReading, type UnansweredCapture } from '../engineWireFor.js';
|
|
2
2
|
import { type AttributionLadderState, type AttributionLadderStep } from './attributionLadder.js';
|
|
3
3
|
import { type RefusalCarrier, type SafetyStopHead } from './hitlBridge.js';
|
|
4
|
+
export declare const RETRY_BUDGET_MS = 8000;
|
|
4
5
|
export declare const PARKING_WAIT_CAP_MS = 5000;
|
|
5
6
|
export interface DeliveryTiming {
|
|
6
7
|
readonly delays?: readonly number[];
|
|
@@ -5,7 +5,7 @@ import { isSlotCarrier, readThrownSlot, THROWN_SLOT_UNREADABLE } from '../wireFa
|
|
|
5
5
|
import { deliverWithAttributionLadder, localCodeReadOf, topCauseReadOf } from './attributionLadder.js';
|
|
6
6
|
import { GATE_FAILURE_CODES, refusalCarrierOf, safetyStopHeadOf } from './hitlBridge.js';
|
|
7
7
|
const RETRY_DELAYS_MS = Object.freeze([500, 1_000, 2_000]);
|
|
8
|
-
const RETRY_BUDGET_MS = 8_000;
|
|
8
|
+
export const RETRY_BUDGET_MS = 8_000;
|
|
9
9
|
export const PARKING_WAIT_CAP_MS = 5_000;
|
|
10
10
|
let timingOverride;
|
|
11
11
|
export function setDeliveryTimingForTests(t) {
|
|
@@ -11,4 +11,11 @@ export type ApprovalRequestFrameReading = {
|
|
|
11
11
|
export declare function approvalRequestFrameReadingThrowing(frame: object | null | undefined): ApprovalRequestFrameReading;
|
|
12
12
|
export declare function approvalRequestFrameReadingOf(frame: object | null | undefined): ApprovalRequestFrameReading;
|
|
13
13
|
export declare function approvalUnreadableWhyWordOf(v: string): ApprovalRequestFrameUnreadableWhy | undefined;
|
|
14
|
+
export type CardPayloadReading = {
|
|
15
|
+
readonly payloadUnreadable: false;
|
|
16
|
+
} | {
|
|
17
|
+
readonly payloadUnreadable: true;
|
|
18
|
+
readonly why?: ApprovalRequestFrameUnreadableWhy;
|
|
19
|
+
};
|
|
20
|
+
export declare function cardPayloadReadingOf(card: object | null | undefined): CardPayloadReading;
|
|
14
21
|
export declare function approvalFrameUnreadableWhyOf(reading: ApprovalRequestFrameReading | null | undefined): ApprovalRequestFrameUnreadableWhy | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isApprovalRequestFrameV1 } from '@sema-agent/sdk';
|
|
2
2
|
import { displayUntrusted } from '../displayUntrusted.js';
|
|
3
|
+
import { guardedRead, readOwnDataValue } from '../ownKey.js';
|
|
3
4
|
export const APPROVAL_REQUEST_FRAME_UNREADABLE_WHYS = Object.freeze(['version_unknown', 'kind_unknown', 'unreadable_fields']);
|
|
4
5
|
const KNOWN_FRAME_TYPE = 'approval_request';
|
|
5
6
|
const KNOWN_SCHEMA_VERSION = 1;
|
|
@@ -60,6 +61,16 @@ export function approvalRequestFrameReadingOf(frame) {
|
|
|
60
61
|
export function approvalUnreadableWhyWordOf(v) {
|
|
61
62
|
return APPROVAL_REQUEST_FRAME_UNREADABLE_WHYS.find((w) => w === v);
|
|
62
63
|
}
|
|
64
|
+
export function cardPayloadReadingOf(card) {
|
|
65
|
+
if (typeof card !== 'object' || card === null)
|
|
66
|
+
return Object.freeze({ payloadUnreadable: false });
|
|
67
|
+
const flag = guardedRead(() => readOwnDataValue(card, 'cardPayloadUnreadable'));
|
|
68
|
+
if (flag !== true)
|
|
69
|
+
return Object.freeze({ payloadUnreadable: false });
|
|
70
|
+
const word = guardedRead(() => readOwnDataValue(card, 'cardPayloadUnreadableWhy'));
|
|
71
|
+
const why = typeof word === 'string' ? approvalUnreadableWhyWordOf(word) : undefined;
|
|
72
|
+
return why === undefined ? Object.freeze({ payloadUnreadable: true }) : Object.freeze({ payloadUnreadable: true, why });
|
|
73
|
+
}
|
|
63
74
|
export function approvalFrameUnreadableWhyOf(reading) {
|
|
64
75
|
try {
|
|
65
76
|
if (typeof reading !== 'object' || reading === null)
|
|
@@ -8,7 +8,7 @@ import { type DeliveredReading, type LadderSafetyStop } from './attributionLadde
|
|
|
8
8
|
import { type CheckpointRowVerdictReading } from '../checkpointRowVerdict.js';
|
|
9
9
|
export declare const APPROVAL_RESOLUTION_LANES: readonly ["respond", "decide", "ask"];
|
|
10
10
|
export type ApprovalResolutionLane = (typeof APPROVAL_RESOLUTION_LANES)[number];
|
|
11
|
-
export declare const APPROVAL_NOT_SENT_CAUSES: readonly ["retracted", "edit_refused", "no_pending", "wrong_gate", "fetch_failed", "no_input", "card_unavailable", "safety_stop", "row_unresumable"];
|
|
11
|
+
export declare const APPROVAL_NOT_SENT_CAUSES: readonly ["retracted", "edit_refused", "no_pending", "wrong_gate", "fetch_failed", "no_input", "card_unavailable", "safety_stop", "row_unresumable", "withdrawn"];
|
|
12
12
|
export type ApprovalNotSentCause = (typeof APPROVAL_NOT_SENT_CAUSES)[number];
|
|
13
13
|
export declare const APPROVAL_UNSETTLED_CAUSES: readonly ["engine_refused", "engine_error", "no_answer", "transport_exhausted", "parking_in_progress", "interrupted", "orchestration", "unreadable"];
|
|
14
14
|
export type ApprovalUnsettledCause = (typeof APPROVAL_UNSETTLED_CAUSES)[number];
|
|
@@ -18,6 +18,11 @@ export interface ApprovalDenyFacts {
|
|
|
18
18
|
readonly policyCause?: PolicyDenyCause;
|
|
19
19
|
readonly attributionKey?: 'dropped' | 'renamed';
|
|
20
20
|
}
|
|
21
|
+
export interface ToolPermissionSettledElsewhere {
|
|
22
|
+
readonly firstDecision: 'allow' | 'deny';
|
|
23
|
+
readonly contrary: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function toolPermissionSettledElsewhereOf(first: 'allow' | 'deny', sent: ToolApprovalRespondDecision | 'approve'): ToolPermissionSettledElsewhere;
|
|
21
26
|
interface ApprovalResolutionBase {
|
|
22
27
|
readonly lane: ApprovalResolutionLane;
|
|
23
28
|
readonly gatedCallId?: string;
|
|
@@ -30,6 +35,7 @@ export interface ApprovalResolutionDecided extends ApprovalResolutionBase {
|
|
|
30
35
|
readonly receipt?: DecideReceiptView;
|
|
31
36
|
readonly ack?: ToolApprovalRespondAckView;
|
|
32
37
|
readonly answered?: AskAnsweredOutput;
|
|
38
|
+
readonly settledElsewhere?: ToolPermissionSettledElsewhere;
|
|
33
39
|
}
|
|
34
40
|
export interface ApprovalResolutionNotSent extends ApprovalResolutionBase {
|
|
35
41
|
readonly kind: 'not_sent';
|
|
@@ -38,6 +44,7 @@ export interface ApprovalResolutionNotSent extends ApprovalResolutionBase {
|
|
|
38
44
|
readonly rowVerdict?: Exclude<CheckpointRowVerdictReading, {
|
|
39
45
|
readonly kind: 'ok';
|
|
40
46
|
}>;
|
|
47
|
+
readonly toldBy?: 'host';
|
|
41
48
|
readonly detail?: string;
|
|
42
49
|
}
|
|
43
50
|
export interface ApprovalResolutionUnsettled extends ApprovalResolutionBase {
|
|
@@ -53,7 +60,7 @@ export declare function isApprovalDecided(r: ApprovalResolution): r is ApprovalR
|
|
|
53
60
|
export declare function approvalNotSentCause(r: ApprovalResolution): ApprovalNotSentCause | undefined;
|
|
54
61
|
export declare function approvalUnsettledCause(r: ApprovalResolution): ApprovalUnsettledCause | undefined;
|
|
55
62
|
export declare const APPROVAL_NOTE_RETRACTED_DETAIL = "the card was retracted (this host no longer has a decision port for it)";
|
|
56
|
-
export declare const APPROVAL_NOTE_EDIT_REFUSED_DETAIL
|
|
63
|
+
export declare const APPROVAL_NOTE_EDIT_REFUSED_DETAIL: string;
|
|
57
64
|
export declare function approvalResolutionDetail(r: ApprovalResolution): string | undefined;
|
|
58
65
|
export declare function approvalResolutionStatusTag(r: ApprovalResolution): string;
|
|
59
66
|
export declare function unsettledCauseOfReading(reading: DecisionRefusalReading): 'engine_refused' | 'engine_error' | 'no_answer';
|
|
@@ -5,6 +5,7 @@ import { carrierReadOf, isLocalSafetyStop, localCodeReadOf, topCauseReadOf } fro
|
|
|
5
5
|
import { directFailureReadingOf, transportReadingOf } from './approvalDelivery.js';
|
|
6
6
|
import { ownReadingSlot } from '../engineWireFor.js';
|
|
7
7
|
import { CHECKPOINT_ROW_BAR_SENTENCE, unboundWayOutContent } from '../checkpointRowVerdict.js';
|
|
8
|
+
import { msg, renderMessage } from '../i18n/translate.js';
|
|
8
9
|
export const APPROVAL_RESOLUTION_LANES = Object.freeze(['respond', 'decide', 'ask']);
|
|
9
10
|
export const APPROVAL_NOT_SENT_CAUSES = Object.freeze([
|
|
10
11
|
'retracted',
|
|
@@ -16,6 +17,7 @@ export const APPROVAL_NOT_SENT_CAUSES = Object.freeze([
|
|
|
16
17
|
'card_unavailable',
|
|
17
18
|
'safety_stop',
|
|
18
19
|
'row_unresumable',
|
|
20
|
+
'withdrawn',
|
|
19
21
|
]);
|
|
20
22
|
export const APPROVAL_UNSETTLED_CAUSES = Object.freeze([
|
|
21
23
|
'engine_refused',
|
|
@@ -27,6 +29,9 @@ export const APPROVAL_UNSETTLED_CAUSES = Object.freeze([
|
|
|
27
29
|
'orchestration',
|
|
28
30
|
'unreadable',
|
|
29
31
|
]);
|
|
32
|
+
export function toolPermissionSettledElsewhereOf(first, sent) {
|
|
33
|
+
return Object.freeze({ firstDecision: first, contrary: (first === 'deny') !== (sent === 'deny') });
|
|
34
|
+
}
|
|
30
35
|
export function isApprovalDecided(r) {
|
|
31
36
|
return typeof r === 'object' && r !== null && r.kind === 'decided';
|
|
32
37
|
}
|
|
@@ -41,7 +46,7 @@ export function approvalUnsettledCause(r) {
|
|
|
41
46
|
return r.cause;
|
|
42
47
|
}
|
|
43
48
|
export const APPROVAL_NOTE_RETRACTED_DETAIL = 'the card was retracted (this host no longer has a decision port for it)';
|
|
44
|
-
export const APPROVAL_NOTE_EDIT_REFUSED_DETAIL = '
|
|
49
|
+
export const APPROVAL_NOTE_EDIT_REFUSED_DETAIL = renderMessage(msg('approval.editRefusal.stem'));
|
|
45
50
|
const NOT_SENT_SENTENCES = Object.freeze({
|
|
46
51
|
retracted: APPROVAL_NOTE_RETRACTED_DETAIL,
|
|
47
52
|
edit_refused: APPROVAL_NOTE_EDIT_REFUSED_DETAIL,
|
package/dist/hitl/askGateWire.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createGateLedger } from './gateLedger.js';
|
|
2
|
-
import {
|
|
2
|
+
import { flushHeldWithInterruptRewrite, isHostProgressFrame, routeFrame, } from './frameRouter.js';
|
|
3
3
|
import { resolvePark, nextHopBudget, stalledTerminal, MAX_GATE_HOPS } from './parkResolver.js';
|
|
4
4
|
import { createStreamDrainingLegs } from '../streamDrainingLegs.js';
|
|
5
5
|
import { abortableSleep } from '../abortableSleep.js';
|
|
6
6
|
import { hostLog } from '../host.js';
|
|
7
|
+
import { sourceGenerationNow } from './screenCardCarriers.js';
|
|
7
8
|
import { invokeHostCallbackIsolated } from '../hostCallbackGuard.js';
|
|
8
9
|
import { decideAcceptedNotResolved, readDecideReceipt } from '../decideReceipt.js';
|
|
9
10
|
import { APPROVAL_EXPIRED } from '../engineErrorCodes.js';
|
|
@@ -28,6 +29,7 @@ export async function* bridgeAskUserQuestionGates(source, deps, opts) {
|
|
|
28
29
|
deps,
|
|
29
30
|
taskId,
|
|
30
31
|
...(opts?.signal ? { signal: opts.signal } : {}),
|
|
32
|
+
streamGeneration: sourceGenerationNow(deps),
|
|
31
33
|
};
|
|
32
34
|
let stream = source;
|
|
33
35
|
let budget;
|
|
@@ -81,17 +83,12 @@ export async function* bridgeAskUserQuestionGates(source, deps, opts) {
|
|
|
81
83
|
const drained = drains.legEnded('returned');
|
|
82
84
|
if (drained !== undefined) {
|
|
83
85
|
const reopenAfterMs = 'reconnectAfterMs' in drained ? drained.reconnectAfterMs : undefined;
|
|
84
|
-
if (taskId.current === undefined) {
|
|
85
|
-
const bound = bridgeRunHandleFallbackOf(deps);
|
|
86
|
-
if (bound !== undefined && reopenAfterMs !== undefined)
|
|
87
|
-
taskId.current = bound;
|
|
88
|
-
}
|
|
89
86
|
if (reopenAfterMs !== undefined && taskId.current !== undefined && !opts?.signal?.aborted) {
|
|
90
87
|
hostLog('debug', `liveHitlAskWire: runs.events(${taskId.current}) ended on the drain end frame — the engine is going down; reopening in ${reopenAfterMs}ms`);
|
|
91
88
|
await abortableSleep(reopenAfterMs, opts?.signal ?? new AbortController().signal);
|
|
92
89
|
if (!opts?.signal?.aborted) {
|
|
93
90
|
const seq = led.lastSeq();
|
|
94
|
-
|
|
91
|
+
ctx.streamGeneration = sourceGenerationNow(deps);
|
|
95
92
|
stream = deps.runsEvents(taskId.current, {
|
|
96
93
|
...(seq !== undefined ? { lastEventId: seq } : {}),
|
|
97
94
|
...(opts?.signal ? { signal: opts.signal } : {}),
|
|
@@ -170,7 +167,7 @@ export async function* bridgeAskUserQuestionGates(source, deps, opts) {
|
|
|
170
167
|
led.forgetRunScopedState();
|
|
171
168
|
}
|
|
172
169
|
const seq = handoff !== undefined ? undefined : led.lastSeq();
|
|
173
|
-
|
|
170
|
+
ctx.streamGeneration = sourceGenerationNow(deps);
|
|
174
171
|
stream = deps.runsEvents(taskId.current, {
|
|
175
172
|
...(seq !== undefined ? { lastEventId: seq } : {}),
|
|
176
173
|
...(opts?.signal ? { signal: opts.signal } : {}),
|
|
@@ -61,13 +61,13 @@ export function foldModeArbitrationRow(classes, askFace) {
|
|
|
61
61
|
return ORDINARY_ROW;
|
|
62
62
|
return Object.freeze({ bypassImmune, classifierEligible, sandboxAdmission, ruleMayClear, hookAskFloor });
|
|
63
63
|
}
|
|
64
|
-
const
|
|
64
|
+
const HOOK_BLOCKING_CLASSES = new Set([...CORE_REAL_APPROVAL_ASK_CLASSES, ORIGIN_IMPLIES_CLASS.content_question]);
|
|
65
65
|
function classBlocks(lane, c, face) {
|
|
66
66
|
if (lane === 'mode_posture')
|
|
67
67
|
return bypassImmuneOn(c, face);
|
|
68
68
|
if (lane === 'standing_rule')
|
|
69
69
|
return !TABLE[c].ruleMayClear;
|
|
70
|
-
return
|
|
70
|
+
return HOOK_BLOCKING_CLASSES.has(c);
|
|
71
71
|
}
|
|
72
72
|
function mustAsk(road, extra) {
|
|
73
73
|
return Object.freeze({ kind: 'must_ask', road, ...(extra?.askClass !== undefined ? { askClass: extra.askClass } : {}), ...(extra?.origin !== undefined ? { origin: extra.origin } : {}) });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APPROVAL_BINDING_MISMATCH, CHECKPOINT_UNSUPPORTED_VERSION, RESUME_OUTCOME_INVALID } from '../engineErrorCodes.js';
|
|
1
|
+
import { APPROVAL_BINDING_MISMATCH, CHECKPOINT_INVALID_OUTCOME, CHECKPOINT_UNSUPPORTED_VERSION, RESUME_OUTCOME_INVALID } from '../engineErrorCodes.js';
|
|
2
2
|
import { msg, renderMessage } from '../i18n/translate.js';
|
|
3
3
|
import { ownDataField } from '../ownKey.js';
|
|
4
4
|
import { SDK_DECIDE_BINDING_KEYS } from '../generated/sdkFactTables.js';
|
|
@@ -28,16 +28,19 @@ export function decisionConflictOf(err, captured, protocolNameRead) {
|
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
const protocolName = namedProtocolOf(protocolNameRead ?? protocolErrorNameReading(err
|
|
31
|
+
const protocolName = namedProtocolOf(protocolNameRead ?? protocolErrorNameReading(err));
|
|
32
32
|
if (code === CHECKPOINT_UNSUPPORTED_VERSION)
|
|
33
33
|
return 'format_version';
|
|
34
34
|
const bindingFamily = code === APPROVAL_BINDING_MISMATCH || (code === undefined && protocolName === PROTOCOL_ERROR_NAME.ApprovalBindingMismatchError);
|
|
35
|
-
|
|
35
|
+
const rowOwnFamily = code === CHECKPOINT_INVALID_OUTCOME || (code === undefined && protocolName === PROTOCOL_ERROR_NAME.CheckpointInvalidOutcomeError);
|
|
36
|
+
if (!bindingFamily && !rowOwnFamily && code !== RESUME_OUTCOME_INVALID)
|
|
36
37
|
return undefined;
|
|
37
38
|
const slots = readRefusalSlots(err, REFUSAL_WORD_KEYS, extra.bag);
|
|
38
39
|
const field = slots.field.word;
|
|
39
40
|
if (code === RESUME_OUTCOME_INVALID)
|
|
40
41
|
return field === ANSWER_FIELD ? 'answer_invalid' : field === GRANT_DIGEST_FIELD ? 'grant_changed' : undefined;
|
|
42
|
+
if (rowOwnFamily)
|
|
43
|
+
return field === undefined && !slots.field.present && slots.reason.word !== undefined ? 'row_integrity' : undefined;
|
|
41
44
|
if (field === undefined) {
|
|
42
45
|
if (slots.field.present)
|
|
43
46
|
return undefined;
|
|
@@ -19,6 +19,8 @@ export interface RefusalRouteContext {
|
|
|
19
19
|
readonly afterRetry?: true;
|
|
20
20
|
}
|
|
21
21
|
export declare function notPendingAfterRetry(status: number | undefined, retried: boolean): boolean;
|
|
22
|
+
type RefusalRoute = NonNullable<RefusalRouteContext['route']>;
|
|
23
|
+
export declare const REFUSAL_ROUTES: readonly RefusalRoute[];
|
|
22
24
|
export interface RefusalDelivery {
|
|
23
25
|
readonly delivery: 'refused' | 'ambiguous' | 'no_answer';
|
|
24
26
|
readonly status?: number;
|
|
@@ -7,7 +7,7 @@ import { isAlreadyResolvedGateReason, isCodeClassifiedGateFailure } from './park
|
|
|
7
7
|
import { decisionConflictOf } from './decisionConflict.js';
|
|
8
8
|
import { readLivePendingRows } from './livePendingAsk.js';
|
|
9
9
|
import { guardedRead, ownDataField, readOwnDataValue } from '../ownKey.js';
|
|
10
|
-
import { PROTOCOL_ERROR_NAME, THROWN_SLOT_UNREADABLE, isDisplayableWireCode, isSlotCarrier, ownFoldedCodeBitsOf, protocolErrorNameReading, readErrorPresent,
|
|
10
|
+
import { PROTOCOL_ERROR_NAME, THROWN_SLOT_UNREADABLE, isDisplayableWireCode, isSlotCarrier, ownFoldedCodeBitsOf, protocolErrorNameReading, readErrorPresent, readErrorString, readRefusalField, readThrownSlot } from '../wireFailureShape.js';
|
|
11
11
|
import { attributionRefusalOf, carrierReadOf } from './attributionLadder.js';
|
|
12
12
|
import { CODE_UNREADABLE, ownReadingSlot } from '../engineWireFor.js';
|
|
13
13
|
export const ASK_DECIDED_CODE = 'conflict.ask_decided';
|
|
@@ -29,7 +29,7 @@ export function notPendingAfterRetry(status, retried) {
|
|
|
29
29
|
return retried && (status === 404 || status === 410);
|
|
30
30
|
}
|
|
31
31
|
const ROUTE_WORDS = { approval_decide: true, live_respond: true, ask_decide: true, plan_review: true, compact: true };
|
|
32
|
-
const REFUSAL_ROUTES = Object.freeze(Object.keys(ROUTE_WORDS));
|
|
32
|
+
export const REFUSAL_ROUTES = Object.freeze(Object.keys(ROUTE_WORDS));
|
|
33
33
|
const PRIOR_REFUSAL_EVIDENCE = Object.freeze([
|
|
34
34
|
Object.freeze({
|
|
35
35
|
errorCode: 'corrupt',
|
|
@@ -74,12 +74,11 @@ const codeUnreadable = () => {
|
|
|
74
74
|
throw new TypeError('status or errorCode was unreadable when this failure was first read');
|
|
75
75
|
};
|
|
76
76
|
function preflightSettledBitsPresent(carrier) {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return nonEmpty(bit('settledBy')) || nonEmpty(bit('rowStatus'));
|
|
77
|
+
const nonEmpty = (k) => {
|
|
78
|
+
const v = guardedRead(() => readErrorString(carrier, k));
|
|
79
|
+
return typeof v === 'string' && v.length > 0;
|
|
80
|
+
};
|
|
81
|
+
return nonEmpty('settledBy') || nonEmpty('rowStatus');
|
|
83
82
|
}
|
|
84
83
|
const RESOLUTION_KINDS = Object.freeze(['decided', 'not_sent', 'unsettled']);
|
|
85
84
|
const ASK_READINGS = Object.freeze(['settled', 'not_settled', 'unreadable']);
|
|
@@ -226,6 +225,7 @@ export function mintDecisionRefusalReading(err, context, attributionCarried, del
|
|
|
226
225
|
const acceptableForm = errorCode === RESUME_CONSTRAINT_REJECTED && obj !== undefined ? isolated(() => readErrorPresent(obj, 'acceptableForm')) : undefined;
|
|
227
226
|
const transient = inRange &&
|
|
228
227
|
conflict !== 'grant_changed' &&
|
|
228
|
+
conflict !== 'row_integrity' &&
|
|
229
229
|
!unrecoverable &&
|
|
230
230
|
(TRANSIENT_STATUSES.has(status) || retriable || (status === 404 && obj !== undefined && isolated(() => notPendingCauseReading(obj)) === 'other_replica'));
|
|
231
231
|
return Object.freeze({
|