@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DescriptorView } from './humanTurnRead.js';
|
|
2
2
|
export type UserAttachmentSource = 'at-mention' | 'compact-restore';
|
|
3
|
-
export type UserAttachmentNotIncludedReason = 'too-large' | 'unreadable' | 'read-denied' | 'approval-required' | 'server-not-connected' | 'resource-not-listed' | 'read-failed';
|
|
3
|
+
export type UserAttachmentNotIncludedReason = 'too-large' | 'unreadable' | 'read-denied' | 'approval-required' | 'server-not-connected' | 'resource-not-listed' | 'read-failed' | 'tools-elsewhere' | 'tools-location-unconfirmed';
|
|
4
4
|
export type UserAttachmentMcpResourcePart = {
|
|
5
5
|
readonly kind: 'text';
|
|
6
6
|
readonly text: string;
|
|
@@ -77,6 +77,7 @@ export type UserAttachmentDescriptor = {
|
|
|
77
77
|
readonly truncated: boolean;
|
|
78
78
|
};
|
|
79
79
|
export declare function showAttachmentName(s: string): string;
|
|
80
|
+
export declare function showAttachmentNameCc(s: string): string;
|
|
80
81
|
export declare function mintEnvelopeOf(d: DescriptorView, imageDelivery: 'attached' | 'not-attached'): string;
|
|
81
82
|
export declare function seatTextOf(d: DescriptorView): string | undefined;
|
|
82
83
|
export declare function mintReferenceOf(d: DescriptorView): string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readDescriptor } from './humanTurnRead.js';
|
|
2
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
3
|
const TILDE_CLASS_RUN = /[~\u02DC\u2053\u223C\u301C\uFF5E]+/g;
|
|
3
4
|
function envelopeFence(text) {
|
|
4
5
|
let longest = 0;
|
|
@@ -29,6 +30,13 @@ export function showAttachmentName(s) {
|
|
|
29
30
|
return cp > 0xffff ? `\\u{${cp.toString(16)}}` : `\\u${hex4(cp)}`;
|
|
30
31
|
});
|
|
31
32
|
}
|
|
33
|
+
const CC_CONTROL_UNITS = /[\p{Cc}\u2028\u2029]/gu;
|
|
34
|
+
export function showAttachmentNameCc(s) {
|
|
35
|
+
return String(s ?? '')
|
|
36
|
+
.replaceAll('<', '<')
|
|
37
|
+
.replaceAll('>', '>')
|
|
38
|
+
.replace(CC_CONTROL_UNITS, (c) => `&#${c.charCodeAt(0)};`);
|
|
39
|
+
}
|
|
32
40
|
const ESCAPE_NOTE = 'Some lines contain line-break control characters inside the line; they are shown as escape sequences (such as \\r or \\u2028), so those lines are not byte-for-byte the same as the file.';
|
|
33
41
|
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
34
42
|
function firstLine(source, what, name) {
|
|
@@ -169,6 +177,8 @@ const NOT_INCLUDED_REASON = Object.freeze({
|
|
|
169
177
|
'server-not-connected': 'the MCP server it comes from is not connected',
|
|
170
178
|
'resource-not-listed': 'the MCP server does not list that resource',
|
|
171
179
|
'read-failed': 'reading it from the MCP server failed',
|
|
180
|
+
'tools-elsewhere': renderMessage(msg('attachments.withheld.toolsElsewhere.model')),
|
|
181
|
+
'tools-location-unconfirmed': renderMessage(msg('attachments.withheld.toolsLocationUnconfirmed.model')),
|
|
172
182
|
});
|
|
173
183
|
function targetWhat(target) {
|
|
174
184
|
return target === 'directory' ? 'a directory' : target === 'file' ? 'a file' : 'a file or directory';
|
package/dist/wireErrorTriage.js
CHANGED
|
@@ -2,6 +2,7 @@ import { PROTOCOL_ERROR_NAME, effectiveWireCodeReading, isSlotCarrier, protocolE
|
|
|
2
2
|
import { capForDisplay, escapeDisplayControlChars } from './fleetTaskDesc.js';
|
|
3
3
|
import { readOwnDataValue } from './ownKey.js';
|
|
4
4
|
import { fleetLeaseUnavailableFromError } from './wireRefusalCopy.js';
|
|
5
|
+
import { isStreamEndedWithoutTerminalError } from './sseIdleTriage.js';
|
|
5
6
|
import { answerReadingOf, captureAnswer, captureUnanswered, causeSlotReadOf, effectiveCodeOf, noteTriageReading, ownReadingSlot } from './engineWireFor.js';
|
|
6
7
|
import { CORRUPT_ROW_ERROR_CODE, DRAINING_ERROR_CODE, FLEET_LEASE_UNAVAILABLE, isCorruptSessionCode, RESUME_AT_ERROR_CODE_PREFIX, RESUME_RETRY_LATER_CODES, RESUME_USAGE_WINDOW_EXHAUSTED, SCENARIO_NOT_ALLOWED_ERROR_CODE, } from './engineErrorCodes.js';
|
|
7
8
|
export const WIRE_NETWORK_ERROR_PATTERN = /fetch failed|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|EHOSTUNREACH|ENETUNREACH|EPIPE|socket hang up|UND_ERR|\bterminated\b|\bother side closed\b/i;
|
|
@@ -105,7 +106,7 @@ export function classifyTurnWireError(err) {
|
|
|
105
106
|
if (captured !== undefined && captured.layer === err)
|
|
106
107
|
return httpVerdictOf(captured, () => renderedText(err), undefined, topCauseRecordOf(err, topCauseRead));
|
|
107
108
|
const slots = readTurnErrorSlots(err, topStatusOf(err, ans), topCauseRead);
|
|
108
|
-
if (slots.status !== THROWN_SLOT_UNREADABLE &&
|
|
109
|
+
if (slots.status !== THROWN_SLOT_UNREADABLE && isStreamEndedWithoutTerminalError(err)) {
|
|
109
110
|
return noted({ kind: 'stream-ended-without-terminal' }, ans, captured, transportShapeOf(slots, err, ans), err, slots.errorCode, topCauseRead);
|
|
110
111
|
}
|
|
111
112
|
if (captured !== undefined) {
|
|
@@ -13,6 +13,8 @@ interface WireFailureShape {
|
|
|
13
13
|
export declare const THROWN_SLOT_UNREADABLE: unique symbol;
|
|
14
14
|
export declare function isSlotCarrier(x: {} | null | undefined): x is object;
|
|
15
15
|
export declare function readThrownSlot(o: unknown, key: string, own?: boolean | 'data'): unknown;
|
|
16
|
+
export declare function errnoCode(e: {} | null | undefined): string | undefined;
|
|
17
|
+
export declare function thrownSlotOf(err: {} | null | undefined, name: string, kind?: boolean | 'data'): {} | null | undefined;
|
|
16
18
|
export declare function thrownIsInstanceOf<C extends abstract new (...args: never[]) => unknown>(e: unknown, cls: C): e is InstanceType<C>;
|
|
17
19
|
export type ThrownExtraReading = {
|
|
18
20
|
readonly state: 'object';
|
|
@@ -24,14 +26,16 @@ export type ThrownExtraReading = {
|
|
|
24
26
|
};
|
|
25
27
|
export declare function readThrownExtra(o: {} | null | undefined): ThrownExtraReading;
|
|
26
28
|
export interface ThrownExtraSnapshot {
|
|
27
|
-
readonly sdkInstance: boolean;
|
|
28
29
|
readonly bag: ThrownExtraReading;
|
|
29
30
|
}
|
|
30
31
|
export declare function readThrownExtraSnapshot(o: {} | null | undefined): ThrownExtraSnapshot;
|
|
32
|
+
export declare function liftLegacyRefusalFacts(code: {} | null | undefined, bag: object): object;
|
|
33
|
+
export declare function placeThrownExtraOnCopy<V>(thrown: object, copy: object, copyBag: (bag: object) => V | undefined): 'placed' | 'not_placed' | 'place_failed';
|
|
31
34
|
export declare const PROTOCOL_ERROR_NAME: Readonly<{
|
|
32
35
|
readonly ApprovalBindingMismatchError: "ApprovalBindingMismatchError";
|
|
33
36
|
readonly ApprovalStaleError: "ApprovalStaleError";
|
|
34
37
|
readonly AskDecidedError: "AskDecidedError";
|
|
38
|
+
readonly CheckpointInvalidOutcomeError: "CheckpointInvalidOutcomeError";
|
|
35
39
|
readonly ConflictError: "ConflictError";
|
|
36
40
|
readonly NotFoundError: "NotFoundError";
|
|
37
41
|
readonly ParkedResumeStartupError: "ParkedResumeStartupError";
|
|
@@ -47,18 +51,15 @@ export declare const PROTOCOL_ERROR_NAME: Readonly<{
|
|
|
47
51
|
readonly UsageWindowExhaustedError: "UsageWindowExhaustedError";
|
|
48
52
|
}>;
|
|
49
53
|
export type ProtocolErrorName = (typeof PROTOCOL_ERROR_NAME)[keyof typeof PROTOCOL_ERROR_NAME];
|
|
50
|
-
export declare function isSdkErrorInstance(o: object): boolean;
|
|
51
54
|
export type ProtocolErrorNameReading = {
|
|
52
55
|
readonly state: 'named';
|
|
53
56
|
readonly name: ProtocolErrorName;
|
|
54
57
|
} | {
|
|
55
58
|
readonly state: 'absent';
|
|
56
|
-
} | {
|
|
57
|
-
readonly state: 'sdk-instance';
|
|
58
59
|
} | {
|
|
59
60
|
readonly state: 'unreadable';
|
|
60
61
|
};
|
|
61
|
-
export declare function protocolErrorNameReading(e: object
|
|
62
|
+
export declare function protocolErrorNameReading(e: object): ProtocolErrorNameReading;
|
|
62
63
|
export declare function protocolErrorNameOf(e: object): ProtocolErrorName | undefined;
|
|
63
64
|
export type ThrownStatusReading = number | undefined | typeof THROWN_SLOT_UNREADABLE;
|
|
64
65
|
export declare function readThrownStatusSlot(o: object, notePresence?: (presence: SlotPresence) => void): ThrownStatusReading;
|
package/dist/wireFailureShape.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
|
-
import { guardedRead, ownDataField, readOwnDataValue } from './ownKey.js';
|
|
3
|
-
import { RESUME_POLICY_FOLD_CODE } from './engineErrorCodes.js';
|
|
2
|
+
import { guardedRead, ownDataField, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
|
|
3
|
+
import { CONFIG_AGENT_UNKNOWN_TOOL, CONFIG_TOOL_FACE_CONTROL, REQUEST_FIELD_CONFLICT, RESUME_POLICY_FOLD_CODE, SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE, USER_ATTACHMENT_INVALID_ERROR_CODE } from './engineErrorCodes.js';
|
|
4
|
+
import { requestCoordinateText } from './requestCoordinate.js';
|
|
4
5
|
export const THROWN_SLOT_UNREADABLE = Symbol('thrown-slot-unreadable');
|
|
5
6
|
export function isSlotCarrier(x) {
|
|
6
7
|
return (typeof x === 'object' && x !== null) || typeof x === 'function';
|
|
@@ -20,6 +21,13 @@ export function readThrownSlot(o, key, own = false) {
|
|
|
20
21
|
return THROWN_SLOT_UNREADABLE;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
24
|
+
export function errnoCode(e) {
|
|
25
|
+
return guardedRead(() => readOwnDataNonEmptyString(e, 'code'));
|
|
26
|
+
}
|
|
27
|
+
export function thrownSlotOf(err, name, kind = false) {
|
|
28
|
+
const v = readThrownSlot(err, name, kind);
|
|
29
|
+
return v === THROWN_SLOT_UNREADABLE ? undefined : v;
|
|
30
|
+
}
|
|
23
31
|
function readGuarded(o, key) {
|
|
24
32
|
const v = readThrownSlot(o, key);
|
|
25
33
|
return v === THROWN_SLOT_UNREADABLE ? undefined : v;
|
|
@@ -91,39 +99,157 @@ export function readThrownExtra(o) {
|
|
|
91
99
|
}
|
|
92
100
|
export function readThrownExtraSnapshot(o) {
|
|
93
101
|
if (o === null || o === undefined || (typeof o !== 'object' && typeof o !== 'function'))
|
|
94
|
-
return {
|
|
102
|
+
return { bag: { state: 'absent' } };
|
|
95
103
|
let at;
|
|
96
104
|
try {
|
|
97
105
|
at = extraSlotOf(o);
|
|
98
106
|
}
|
|
99
107
|
catch {
|
|
100
|
-
return {
|
|
108
|
+
return { bag: { state: 'unreadable' } };
|
|
101
109
|
}
|
|
102
|
-
const sdkInstance = at.kind === 'sdk-class';
|
|
103
110
|
if (at.kind === 'own-accessor')
|
|
104
|
-
return {
|
|
111
|
+
return { bag: { state: 'unreadable' } };
|
|
105
112
|
if (at.kind === 'none')
|
|
106
|
-
return {
|
|
113
|
+
return { bag: { state: 'absent' } };
|
|
107
114
|
let slot;
|
|
108
115
|
try {
|
|
109
116
|
slot = at.kind === 'own-data' ? at.value : Reflect.get(o, EXTRA_KEY);
|
|
110
117
|
}
|
|
111
118
|
catch {
|
|
112
|
-
return {
|
|
119
|
+
return { bag: { state: 'unreadable' } };
|
|
113
120
|
}
|
|
114
121
|
try {
|
|
115
122
|
if (typeof slot !== 'object' || slot === null || Array.isArray(slot))
|
|
116
|
-
return {
|
|
123
|
+
return { bag: { state: 'absent' } };
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
return { bag: { state: 'unreadable' } };
|
|
127
|
+
}
|
|
128
|
+
return { bag: { state: 'object', value: liftLegacyRefusalFacts(readThrownSlot(o, 'errorCode', 'data'), slot) } };
|
|
129
|
+
}
|
|
130
|
+
export function liftLegacyRefusalFacts(code, bag) {
|
|
131
|
+
try {
|
|
132
|
+
if (typeof code !== 'string')
|
|
133
|
+
return bag;
|
|
134
|
+
const dd = Object.getOwnPropertyDescriptor(bag, 'detail');
|
|
135
|
+
if (dd === undefined || !Object.hasOwn(dd, 'value'))
|
|
136
|
+
return bag;
|
|
137
|
+
const detail = dd.value;
|
|
138
|
+
if (typeof detail !== 'object' || detail === null || Array.isArray(detail))
|
|
139
|
+
return bag;
|
|
140
|
+
const moves = legacyRefusalMovesOf(code, bag, detail);
|
|
141
|
+
if (moves === undefined)
|
|
142
|
+
return bag;
|
|
143
|
+
const out = Object.create(null);
|
|
144
|
+
for (const key of Reflect.ownKeys(bag)) {
|
|
145
|
+
if (key === 'detail')
|
|
146
|
+
continue;
|
|
147
|
+
const d = Object.getOwnPropertyDescriptor(bag, key);
|
|
148
|
+
if (d !== undefined)
|
|
149
|
+
Object.defineProperty(out, key, { ...d, configurable: true });
|
|
150
|
+
}
|
|
151
|
+
for (const [key, value, override] of moves) {
|
|
152
|
+
if (!override && Object.getOwnPropertyDescriptor(out, key) !== undefined)
|
|
153
|
+
continue;
|
|
154
|
+
Object.defineProperty(out, key, { value, enumerable: true, writable: false, configurable: true });
|
|
155
|
+
}
|
|
156
|
+
return Object.freeze(out);
|
|
117
157
|
}
|
|
118
158
|
catch {
|
|
119
|
-
return
|
|
159
|
+
return bag;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const LEGACY_PROBLEMS_CODES = Object.freeze(['request.field_invalid', CONFIG_AGENT_UNKNOWN_TOOL, CONFIG_TOOL_FACE_CONTROL, 'request.unprocessable', RESUME_POLICY_FOLD_CODE]);
|
|
163
|
+
const LEGACY_HOOKS_KEYS = Object.freeze(['reason', 'event', 'alias', 'canonical', 'groupIndex', 'budgetMs', 'totalMs', 'type', 'key', 'count', 'cap']);
|
|
164
|
+
function legacyRefusalMovesOf(code, bag, detail) {
|
|
165
|
+
const moves = [];
|
|
166
|
+
const take = (from, to = from, override = false) => {
|
|
167
|
+
const v = guardedRead(() => readOwnDataValue(detail, from));
|
|
168
|
+
if (v !== undefined)
|
|
169
|
+
moves.push([to, v, override]);
|
|
170
|
+
};
|
|
171
|
+
const rootField = guardedRead(() => readOwnDataValue(bag, 'field'));
|
|
172
|
+
if (code === 'request.field_invalid' && rootField === 'settings.hooks') {
|
|
173
|
+
for (const k of LEGACY_HOOKS_KEYS)
|
|
174
|
+
take(k);
|
|
175
|
+
const path = legacyHooksPathOf(detail);
|
|
176
|
+
if (path !== undefined)
|
|
177
|
+
moves.push(['field', requestCoordinateText(path[0] === 'hooks' ? 'settings' : 'settings.hooks', path), true]);
|
|
178
|
+
for (const k of ['problems', 'total', 'callerTrust'])
|
|
179
|
+
take(k);
|
|
180
|
+
return moves;
|
|
181
|
+
}
|
|
182
|
+
if (code === REQUEST_FIELD_CONFLICT) {
|
|
183
|
+
take('kind', 'reason');
|
|
184
|
+
for (const k of ['fields', 'count', 'cap'])
|
|
185
|
+
take(k);
|
|
186
|
+
return moves;
|
|
187
|
+
}
|
|
188
|
+
if (LEGACY_PROBLEMS_CODES.includes(code)) {
|
|
189
|
+
for (const k of ['problems', 'total', 'callerTrust'])
|
|
190
|
+
take(k);
|
|
191
|
+
return moves;
|
|
192
|
+
}
|
|
193
|
+
if (code === 'conflict.session_placed')
|
|
194
|
+
take('placement_kind');
|
|
195
|
+
else if (code === SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE)
|
|
196
|
+
for (const k of ['scenario', 'source'])
|
|
197
|
+
take(k);
|
|
198
|
+
else if (code === 'steering.duplicate_input_id')
|
|
199
|
+
take('differs');
|
|
200
|
+
else if (code === USER_ATTACHMENT_INVALID_ERROR_CODE) {
|
|
201
|
+
const path = guardedRead(() => readOwnDataValue(detail, 'path'));
|
|
202
|
+
if (typeof path === 'string' && path.length > 0)
|
|
203
|
+
moves.push(['field', path, false]);
|
|
204
|
+
const index = guardedRead(() => readOwnDataValue(detail, 'index'));
|
|
205
|
+
if (typeof index === 'number' && Number.isSafeInteger(index) && index >= 0)
|
|
206
|
+
moves.push(['index', index, false]);
|
|
207
|
+
}
|
|
208
|
+
else
|
|
209
|
+
return undefined;
|
|
210
|
+
return moves;
|
|
211
|
+
}
|
|
212
|
+
function legacyHooksPathOf(detail) {
|
|
213
|
+
try {
|
|
214
|
+
const raw = readOwnDataValue(detail, 'path');
|
|
215
|
+
if (!Array.isArray(raw) || raw.length === 0)
|
|
216
|
+
return undefined;
|
|
217
|
+
const out = [];
|
|
218
|
+
for (let i = 0; i < raw.length; i++) {
|
|
219
|
+
if (!Object.hasOwn(raw, i))
|
|
220
|
+
return undefined;
|
|
221
|
+
const v = raw[i];
|
|
222
|
+
if (typeof v === 'string' || (typeof v === 'number' && Number.isSafeInteger(v) && v >= 0))
|
|
223
|
+
out.push(v);
|
|
224
|
+
else
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
export function placeThrownExtraOnCopy(thrown, copy, copyBag) {
|
|
234
|
+
try {
|
|
235
|
+
const bag = readThrownExtraSnapshot(thrown).bag;
|
|
236
|
+
if (bag.state !== 'object')
|
|
237
|
+
return 'not_placed';
|
|
238
|
+
const value = copyBag(bag.value);
|
|
239
|
+
if (value === undefined)
|
|
240
|
+
return 'not_placed';
|
|
241
|
+
Object.defineProperty(copy, EXTRA_KEY, { value, writable: true, enumerable: true, configurable: true });
|
|
242
|
+
return 'placed';
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
return 'place_failed';
|
|
120
246
|
}
|
|
121
|
-
return { sdkInstance, bag: { state: 'object', value: slot } };
|
|
122
247
|
}
|
|
123
248
|
export const PROTOCOL_ERROR_NAME = Object.freeze({
|
|
124
249
|
ApprovalBindingMismatchError: 'ApprovalBindingMismatchError',
|
|
125
250
|
ApprovalStaleError: 'ApprovalStaleError',
|
|
126
251
|
AskDecidedError: 'AskDecidedError',
|
|
252
|
+
CheckpointInvalidOutcomeError: 'CheckpointInvalidOutcomeError',
|
|
127
253
|
ConflictError: 'ConflictError',
|
|
128
254
|
NotFoundError: 'NotFoundError',
|
|
129
255
|
ParkedResumeStartupError: 'ParkedResumeStartupError',
|
|
@@ -139,20 +265,10 @@ export const PROTOCOL_ERROR_NAME = Object.freeze({
|
|
|
139
265
|
UsageWindowExhaustedError: 'UsageWindowExhaustedError',
|
|
140
266
|
});
|
|
141
267
|
const PROTOCOL_ERROR_NAMES = new Set(Object.values(PROTOCOL_ERROR_NAME));
|
|
142
|
-
export function
|
|
143
|
-
try {
|
|
144
|
-
return extraSlotOf(o).kind === 'sdk-class';
|
|
145
|
-
}
|
|
146
|
-
catch {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
export function protocolErrorNameReading(e, extra) {
|
|
268
|
+
export function protocolErrorNameReading(e) {
|
|
151
269
|
if (typeof e !== 'object' || e === null)
|
|
152
270
|
return { state: 'absent' };
|
|
153
271
|
try {
|
|
154
|
-
if (extra !== undefined ? extra.sdkInstance : isSdkErrorInstance(e))
|
|
155
|
-
return { state: 'sdk-instance' };
|
|
156
272
|
const name = ownDataField(e, 'name');
|
|
157
273
|
return typeof name === 'string' && PROTOCOL_ERROR_NAMES.has(name) ? { state: 'named', name: name } : { state: 'absent' };
|
|
158
274
|
}
|
|
@@ -482,24 +598,20 @@ export function readRefusalNamedFields(o) {
|
|
|
482
598
|
out.push(v);
|
|
483
599
|
};
|
|
484
600
|
add(guardedRead(() => readRefusalField(o)));
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
if (typeof item !== 'object' || item === null)
|
|
496
|
-
continue;
|
|
497
|
-
add(guardedRead(() => readOwnDataValue(item, 'field')));
|
|
498
|
-
}
|
|
601
|
+
try {
|
|
602
|
+
const list = readErrorPresent(o, 'problems');
|
|
603
|
+
if (Array.isArray(list)) {
|
|
604
|
+
const n = list.length;
|
|
605
|
+
const len = typeof n === 'number' && Number.isSafeInteger(n) && n > 0 ? Math.min(n, REFUSAL_PROBLEMS_READ_MAX) : 0;
|
|
606
|
+
for (let i = 0; i < len; i += 1) {
|
|
607
|
+
const item = guardedRead(() => readOwnDataValue(list, String(i)));
|
|
608
|
+
if (typeof item !== 'object' || item === null)
|
|
609
|
+
continue;
|
|
610
|
+
add(guardedRead(() => readOwnDataValue(item, 'field')));
|
|
499
611
|
}
|
|
500
612
|
}
|
|
501
|
-
|
|
502
|
-
|
|
613
|
+
}
|
|
614
|
+
catch {
|
|
503
615
|
}
|
|
504
616
|
return Object.freeze(out);
|
|
505
617
|
}
|
|
@@ -53,6 +53,7 @@ export interface SessionDeleteConflictDetail {
|
|
|
53
53
|
}
|
|
54
54
|
export declare function sessionDeleteConflictFromError(err: unknown): SessionDeleteConflictDetail | null;
|
|
55
55
|
export declare function sessionDeleteConflictContent(detail: Pick<SessionDeleteConflictDetail, 'kind' | 'remaining' | 'activeTaskId'>, lang?: UiLanguage): string;
|
|
56
|
+
declare const FIELD_INVALID = "request.field_invalid";
|
|
56
57
|
export type SettingsPermissionBucket = 'allow' | 'deny' | 'ask';
|
|
57
58
|
export type SettingsPermissionBucketRefusalReason = 'over_cap' | 'bad_entry';
|
|
58
59
|
export interface SettingsPermissionBucketRefusalDetail {
|
|
@@ -107,28 +108,29 @@ export type HookMatcherRefusal = {
|
|
|
107
108
|
readonly event: string;
|
|
108
109
|
readonly alias: string;
|
|
109
110
|
readonly canonical: string;
|
|
110
|
-
readonly
|
|
111
|
+
readonly groupIndex?: number;
|
|
112
|
+
readonly field?: string;
|
|
111
113
|
} | {
|
|
112
114
|
readonly reason: 'invalid_regex';
|
|
113
115
|
readonly event: string;
|
|
114
116
|
readonly groupIndex: number;
|
|
115
|
-
readonly
|
|
117
|
+
readonly field?: string;
|
|
116
118
|
} | {
|
|
117
119
|
readonly reason: 'over_budget';
|
|
118
120
|
readonly event: string;
|
|
119
121
|
readonly groupIndex: number;
|
|
120
122
|
readonly budgetMs?: number;
|
|
121
|
-
readonly
|
|
123
|
+
readonly field?: string;
|
|
122
124
|
} | {
|
|
123
125
|
readonly reason: 'budget_exceeded';
|
|
124
126
|
readonly event: string;
|
|
125
127
|
readonly groupIndex: number;
|
|
126
128
|
readonly totalMs?: number;
|
|
127
|
-
readonly
|
|
129
|
+
readonly field?: string;
|
|
128
130
|
};
|
|
129
131
|
export interface SettingsHooksRefusal {
|
|
130
132
|
readonly reason: string;
|
|
131
|
-
readonly
|
|
133
|
+
readonly field: string;
|
|
132
134
|
readonly matcher?: HookMatcherRefusal;
|
|
133
135
|
readonly count?: number;
|
|
134
136
|
readonly cap?: number;
|
|
@@ -158,6 +160,15 @@ export interface SessionIdRetiredDetail {
|
|
|
158
160
|
}
|
|
159
161
|
export declare function sessionIdRetiredFromError(err: {} | null | undefined): SessionIdRetiredDetail | null;
|
|
160
162
|
export declare function sessionIdRetiredContent(detail: Pick<SessionIdRetiredDetail, 'folded'>, lang?: UiLanguage): string;
|
|
163
|
+
export type UnreadRequestMembersFace = 'settings_hooks' | 'settings_env' | 'settings_other' | 'mcp_transport' | 'a2a_headers';
|
|
164
|
+
export interface UnreadRequestMembersDetail {
|
|
165
|
+
readonly code: typeof FIELD_INVALID;
|
|
166
|
+
readonly field: string;
|
|
167
|
+
readonly face: UnreadRequestMembersFace;
|
|
168
|
+
readonly folded?: true;
|
|
169
|
+
}
|
|
170
|
+
export declare function unreadRequestMembersFromError(err: {} | null | undefined): UnreadRequestMembersDetail | null;
|
|
171
|
+
export declare function unreadRequestMembersContent(detail: Pick<UnreadRequestMembersDetail, 'field' | 'face' | 'folded'>, lang?: UiLanguage): string;
|
|
161
172
|
export interface RunConcurrencyCapDetail {
|
|
162
173
|
readonly code: typeof LIMIT_RATE_EXCEEDED;
|
|
163
174
|
readonly reason: typeof RATE_EXCEEDED_RUN_CONCURRENCY_CAP;
|