@sema-agent/client-core 0.109.0 → 0.110.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 +173 -0
- package/README.md +46 -22
- package/dist/adapt/arms.js +20 -7
- package/dist/adapter/downstream/eventToSdkMessage.js +11 -6
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/displayUntrusted.js +132 -14
- package/dist/engineErrorCodes.d.ts +3 -0
- package/dist/engineErrorCodes.js +3 -0
- package/dist/engineHealthFacts.d.ts +9 -0
- package/dist/engineHealthFacts.js +21 -1
- package/dist/engineInlineTaskStats.d.ts +4 -3
- package/dist/engineInlineTaskStats.js +18 -2
- package/dist/engineNoticeCodes.d.ts +10 -0
- package/dist/engineNoticeCodes.js +33 -1
- package/dist/engineRepoint.d.ts +140 -0
- package/dist/engineRepoint.js +285 -0
- package/dist/engineRowRef.js +2 -0
- package/dist/engineSessionMessages.d.ts +2 -1
- package/dist/engineSessionMessages.js +5 -0
- package/dist/errorSupplementRoles.js +2 -1
- 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 +1 -0
- package/dist/generated/sdkFactTables.js +4 -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/approvalRequestFrameReading.d.ts +7 -0
- package/dist/hitl/approvalRequestFrameReading.js +11 -0
- package/dist/hitl/approvalResolution.d.ts +8 -1
- package/dist/hitl/approvalResolution.js +4 -0
- package/dist/hitl/askGateWire.js +0 -2
- package/dist/hitl/automaticAnswerVerdict.js +2 -2
- package/dist/hitl/decisionConflict.js +6 -3
- package/dist/hitl/decisionRefusal.js +1 -0
- package/dist/hitl/decisionSend.d.ts +3 -0
- package/dist/hitl/decisionSend.js +29 -11
- package/dist/hitl/editedApprovalAcceptance.d.ts +25 -0
- package/dist/hitl/editedApprovalAcceptance.js +26 -0
- package/dist/hitl/frameRouter.js +4 -18
- package/dist/hitl/gateLedger.d.ts +0 -4
- package/dist/hitl/gateLedger.js +0 -19
- package/dist/hitl/hitlBridge.d.ts +1 -0
- package/dist/hitl/hitlBridge.js +4 -4
- package/dist/hitl/hitlHostSurface.d.ts +1 -0
- package/dist/hitl/hitlHostSurface.js +7 -2
- package/dist/hitl/hostWithdrawal.d.ts +15 -0
- package/dist/hitl/hostWithdrawal.js +38 -0
- package/dist/hitl/parkResolver.js +25 -9
- package/dist/hitl/persistedRulesWire.js +2 -2
- package/dist/hitl/planReviewWire.js +14 -4
- package/dist/hitl/sessionPolicyWire.js +6 -4
- package/dist/hitl/standingRows.d.ts +1 -0
- package/dist/hitl/standingRows.js +15 -1
- package/dist/hitl/toolApprovalWire.d.ts +35 -8
- package/dist/hitl/toolApprovalWire.js +235 -33
- package/dist/hooksWireCaps.js +31 -1
- package/dist/hostTurnSettings.d.ts +10 -4
- package/dist/hostTurnSettings.js +112 -5
- package/dist/i18n/messages.en.d.ts +83 -0
- package/dist/i18n/messages.en.js +86 -2
- package/dist/i18n/messages.zh.js +96 -2
- package/dist/index.d.ts +21 -7
- package/dist/index.js +14 -4
- package/dist/inheritEnvCapability.js +2 -0
- package/dist/inputAuthor.d.ts +16 -0
- package/dist/inputAuthor.js +44 -0
- package/dist/interruptRefusalNote.d.ts +2 -0
- package/dist/interruptRefusalNote.js +17 -0
- package/dist/liveModelCatalog.d.ts +2 -0
- package/dist/liveModelCatalog.js +21 -7
- package/dist/liveQuestionStore.d.ts +4 -1
- package/dist/liveQuestionStore.js +12 -3
- 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 +121 -16
- package/dist/modelCapabilityProbe.js +4 -3
- package/dist/modsFace.d.ts +8 -1
- package/dist/modsFace.js +27 -0
- package/dist/notifications.d.ts +17 -6
- package/dist/notifications.js +67 -19
- package/dist/ownKey.d.ts +0 -5
- package/dist/ownKey.js +0 -7
- package/dist/peerFrames.d.ts +40 -2
- package/dist/peerFrames.js +158 -3
- package/dist/pluginHooksWire.d.ts +2 -1
- package/dist/pluginHooksWire.js +56 -1
- package/dist/replayBody.js +10 -2
- package/dist/request/taskRequest.d.ts +5 -0
- package/dist/request/taskRequest.js +138 -21
- 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/seam.d.ts +12 -1
- package/dist/seam.js +7 -1
- package/dist/seatContract.d.ts +86 -9
- package/dist/seatContract.js +196 -7
- package/dist/sessionBackground.js +2 -1
- package/dist/sessionBackgroundHandoff.js +2 -1
- package/dist/sessionEngine.d.ts +2 -0
- package/dist/sessionEngine.js +111 -0
- package/dist/sessionMemoryStatus.d.ts +2 -1
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +28 -0
- package/dist/sseIdleTriage.d.ts +13 -1
- package/dist/sseIdleTriage.js +24 -6
- package/dist/subagent/engineSubagentTail.js +6 -0
- package/dist/terminalStatuses.d.ts +1 -0
- package/dist/terminalStatuses.js +4 -1
- 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/wireFailureShape.d.ts +2 -5
- package/dist/wireFailureShape.js +10 -20
- package/dist/wireRefusalCopy.d.ts +10 -0
- package/dist/wireRefusalCopy.js +76 -0
- package/docs/INTEGRATION-CLIENTS.md +2126 -20
- package/package.json +3 -3
|
@@ -7,6 +7,7 @@ import { resolveOwnerContext } from './engineSubagentResume.js';
|
|
|
7
7
|
import { coerceOutput, parentToolCallIdOf, publishSubagentContentEvent, settleSubagentContent, } from '../subagentContentStore.js';
|
|
8
8
|
import { noteBgOwnerAbsence } from './subagentOwnerAbsence.js';
|
|
9
9
|
import { readFrameTrueMark } from '../ownKey.js';
|
|
10
|
+
import { publishEngineInlineTaskModel } from '../engineInlineTaskStats.js';
|
|
10
11
|
function usableTailClient(client) {
|
|
11
12
|
return clientHasVerbs(client, [['capabilities'], ['runs', 'subagentStream']]);
|
|
12
13
|
}
|
|
@@ -149,6 +150,11 @@ export function tailEngineSubagent(taskId, opts) {
|
|
|
149
150
|
hostLog('debug', `[subagent-tail] ${taskId} settled (${String(d.status)}${typeof d.seq === 'number' ? ` seq=${d.seq}` : ''}${typeof d.summary === 'string' ? ` summary=${d.summary.slice(0, 80)}` : ''}) — close`);
|
|
150
151
|
break;
|
|
151
152
|
}
|
|
153
|
+
else if (t === 'task_progress' || t === 'task_started') {
|
|
154
|
+
const card = parentToolCallIdOf(taskId);
|
|
155
|
+
if (card !== undefined && card !== taskId && typeof d.model === 'string')
|
|
156
|
+
publishEngineInlineTaskModel(card, d.model);
|
|
157
|
+
}
|
|
152
158
|
}
|
|
153
159
|
}
|
|
154
160
|
catch (e) {
|
|
@@ -26,6 +26,7 @@ export type CoreSemaTaskTerminalStatus = (typeof CORE_SEMA_TASK_TERMINAL_STATUSE
|
|
|
26
26
|
export declare function isCoreSemaTaskTerminal(status: unknown): status is CoreSemaTaskTerminalStatus;
|
|
27
27
|
export declare const CORE_WORKFLOW_RUN_TERMINAL_STATUSES: readonly ["completed", "failed"];
|
|
28
28
|
export declare function isCoreWorkflowRunTerminal(status: unknown): status is (typeof CORE_WORKFLOW_RUN_TERMINAL_STATUSES)[number];
|
|
29
|
+
export declare function isCoreWorkflowRunParkedEnd(status: unknown, errorCode: unknown): boolean;
|
|
29
30
|
export declare const CORE_TASK_PROGRESS_TERMINAL_STATUSES: readonly ["completed", "failed"];
|
|
30
31
|
export declare function isCoreTaskProgressTerminal(status: unknown): status is (typeof CORE_TASK_PROGRESS_TERMINAL_STATUSES)[number];
|
|
31
32
|
export declare function isCoreTaskProgressTerminalNotSuccess(status: unknown): status is 'failed';
|
package/dist/terminalStatuses.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CORE_TERMINAL_CAUSE_KINDS, CORE_TASK_NOTIFICATION_TERMINAL_STATUSES as GENERATED_TASK_NOTIFICATION_TERMINAL_STATUSES } from './generated/engineFactTables.js';
|
|
1
|
+
import { CORE_TERMINAL_CAUSE_KINDS, CORE_TASK_NOTIFICATION_TERMINAL_STATUSES as GENERATED_TASK_NOTIFICATION_TERMINAL_STATUSES, CORE_WORKFLOW_AGENT_PARKED_ERROR_CODE, } from './generated/engineFactTables.js';
|
|
2
2
|
function memberOf(table, word) {
|
|
3
3
|
return typeof word === 'string' && table.includes(word);
|
|
4
4
|
}
|
|
@@ -53,6 +53,9 @@ export const CORE_WORKFLOW_RUN_TERMINAL_STATUSES = Object.freeze(['completed', '
|
|
|
53
53
|
export function isCoreWorkflowRunTerminal(status) {
|
|
54
54
|
return memberOf(CORE_WORKFLOW_RUN_TERMINAL_STATUSES, status);
|
|
55
55
|
}
|
|
56
|
+
export function isCoreWorkflowRunParkedEnd(status, errorCode) {
|
|
57
|
+
return status === 'failed' && errorCode === CORE_WORKFLOW_AGENT_PARKED_ERROR_CODE;
|
|
58
|
+
}
|
|
56
59
|
export const CORE_TASK_PROGRESS_TERMINAL_STATUSES = Object.freeze(['completed', 'failed']);
|
|
57
60
|
export function isCoreTaskProgressTerminal(status) {
|
|
58
61
|
return memberOf(CORE_TASK_PROGRESS_TERMINAL_STATUSES, status);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
2
|
import { classifyTurnWireError, isPreStreamDrainingReject } from './wireErrorTriage.js';
|
|
3
|
-
import { isSseIdleError } from './sseIdleTriage.js';
|
|
3
|
+
import { isSseIdleError, streamEndedReasonOf } from './sseIdleTriage.js';
|
|
4
4
|
import { runNotFollowedOf } from './runFollow.js';
|
|
5
5
|
import { isCodeClassifiedGateFailure } from './gateFailureCodes.js';
|
|
6
6
|
import { CORRUPT_ROW_ERROR_CODE, CORRUPT_SESSION_ERROR_CODE, MEMORY_CONTROL_PLANE_CORRUPT, SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE } from './engineErrorCodes.js';
|
|
@@ -36,6 +36,13 @@ const TURN_FAILURE_HEADLINE_KEYS = Object.freeze({
|
|
|
36
36
|
internal: 'notice.failure.headline.internal',
|
|
37
37
|
cause_unreadable: 'notice.failure.headline.causeUnreadable',
|
|
38
38
|
});
|
|
39
|
+
const STREAM_ENDED_HEADLINE_KEYS = Object.freeze({
|
|
40
|
+
empty_legs: 'notice.streamEnded.emptyLegs.headline',
|
|
41
|
+
consecutive_failures: 'notice.streamEnded.consecutiveFailures.headline',
|
|
42
|
+
});
|
|
43
|
+
function parkedHeadlineKeyOf(reading) {
|
|
44
|
+
return reading.kind === 'read' ? STREAM_ENDED_HEADLINE_KEYS[reading.reason] : TURN_FAILURE_HEADLINE_KEYS.parked;
|
|
45
|
+
}
|
|
39
46
|
function waitSecOf(err) {
|
|
40
47
|
const ms = readThrownSlot(err, 'retryAfterMs', 'data');
|
|
41
48
|
if (typeof ms === 'number' && Number.isFinite(ms) && ms > 0)
|
|
@@ -128,7 +135,7 @@ export function turnFailurePresentation(err, evidence, notesCtx, lang) {
|
|
|
128
135
|
}
|
|
129
136
|
else if (verdict.kind === 'stream-ended-without-terminal') {
|
|
130
137
|
shape = { category: 'parked', offer: false };
|
|
131
|
-
headlineKey =
|
|
138
|
+
headlineKey = parkedHeadlineKeyOf(streamEndedReasonOf(err));
|
|
132
139
|
detail = wireFailureTextsOf(err).reason;
|
|
133
140
|
}
|
|
134
141
|
else if (verdict.kind === 'transport') {
|
package/dist/typePins.d.ts
CHANGED
|
@@ -8,4 +8,15 @@ type WritableKeys<T> = {
|
|
|
8
8
|
}, P, never>;
|
|
9
9
|
}[keyof T];
|
|
10
10
|
export type AllReadonly<T> = [WritableKeys<T>] extends [never] ? true : false;
|
|
11
|
+
export type Same<A, B> = [Exclude<A, B>, Exclude<B, A>] extends [never, never] ? true : false;
|
|
12
|
+
export type KeysEq<A, B> = Same<keyof A, keyof B>;
|
|
13
|
+
export type Fits<A, B> = [A] extends [B] ? true : false;
|
|
14
|
+
export type Present<T> = [T] extends [never] ? false : true;
|
|
15
|
+
export type RequiredKeys<T> = {
|
|
16
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
17
|
+
}[keyof T];
|
|
18
|
+
export type NeverValuedKeys<T> = {
|
|
19
|
+
[K in keyof T]-?: [Exclude<T[K], undefined>] extends [never] ? K : never;
|
|
20
|
+
}[keyof T];
|
|
21
|
+
export type NoNeverValues<T> = Same<NeverValuedKeys<T>, never>;
|
|
11
22
|
export {};
|
package/dist/usageAnalytics.d.ts
CHANGED
|
@@ -144,3 +144,20 @@ export declare function projectUsageAnalytics(inputs: UsageAnalyticsInputs, wind
|
|
|
144
144
|
export declare function readUsageAnalytics(client: UsageAnalyticsClientLike, window: UsageAnalyticsWindow, opts?: {
|
|
145
145
|
signal?: AbortSignal;
|
|
146
146
|
}): Promise<UsageAnalyticsView>;
|
|
147
|
+
export declare const CENTER_USAGE_COST_UNKNOWN_WHYS: readonly ["declared_unknown", "basis_unrecognized", "estimated_zero", "amount_absent"];
|
|
148
|
+
export type CenterUsageCostUnknownWhy = (typeof CENTER_USAGE_COST_UNKNOWN_WHYS)[number];
|
|
149
|
+
export interface CenterUsageCostAmount {
|
|
150
|
+
readonly value: number;
|
|
151
|
+
readonly bound: Extract<UsageBound, 'exact' | 'lower'>;
|
|
152
|
+
}
|
|
153
|
+
export interface CenterUsageCostAmountReading {
|
|
154
|
+
readonly state: 'amount';
|
|
155
|
+
readonly amount: CenterUsageCostAmount;
|
|
156
|
+
readonly unpriced: boolean;
|
|
157
|
+
}
|
|
158
|
+
export interface CenterUsageCostUnknownReading {
|
|
159
|
+
readonly state: 'unknown';
|
|
160
|
+
readonly why: CenterUsageCostUnknownWhy;
|
|
161
|
+
}
|
|
162
|
+
export type CenterUsageCostReading = CenterUsageCostAmountReading | CenterUsageCostUnknownReading;
|
|
163
|
+
export declare function centerUsageCostOf(body: object | null | undefined): CenterUsageCostReading;
|
package/dist/usageAnalytics.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readThrownSlot, THROWN_SLOT_UNREADABLE } from './wireFailureShape.js';
|
|
1
|
+
import { readThrownSlot, slotReadOf, THROWN_SLOT_UNREADABLE } from './wireFailureShape.js';
|
|
2
2
|
export const USAGE_SENTENCES = Object.freeze({
|
|
3
3
|
analyticsUnavailable: 'Usage analytics aren’t available on this backend.',
|
|
4
4
|
analyticsUnread: 'Usage analytics couldn’t be read just now.',
|
|
@@ -161,6 +161,9 @@ export function readUsageBreakdown(client, opts = {}) {
|
|
|
161
161
|
export function usageBoundPrefix(bound) {
|
|
162
162
|
return bound === 'lower' ? '≥' : bound === 'approximate' ? '≈' : '';
|
|
163
163
|
}
|
|
164
|
+
function costBoundOf(precision, truncated) {
|
|
165
|
+
return precision === 'exact' && !truncated ? 'exact' : 'lower';
|
|
166
|
+
}
|
|
164
167
|
const DAY_MS = 86_400_000;
|
|
165
168
|
export const USAGE_HEATMAP_MAX_DAYS = 70;
|
|
166
169
|
export function usageWindowOfRange(range, now) {
|
|
@@ -275,7 +278,7 @@ export function projectUsageAnalytics(inputs, window) {
|
|
|
275
278
|
readings.tokens = { value: sv.tokensIn + sv.tokensOut, bound: !exact ? 'approximate' : sv.truncated ? 'lower' : 'exact' };
|
|
276
279
|
}
|
|
277
280
|
if (sv.cost !== undefined)
|
|
278
|
-
readings.cost = { value: sv.cost, bound:
|
|
281
|
+
readings.cost = { value: sv.cost, bound: costBoundOf(sv.precision, sv.truncated) };
|
|
279
282
|
const day = inputs.daySeries;
|
|
280
283
|
if (day.kind === 'ok' && isWhole(day.value)) {
|
|
281
284
|
const dayValues = new Map();
|
|
@@ -328,3 +331,42 @@ export async function readUsageAnalytics(client, window, opts = {}) {
|
|
|
328
331
|
]);
|
|
329
332
|
return projectUsageAnalytics({ summary, daySeries, hourSeries, modelBreakdown }, window);
|
|
330
333
|
}
|
|
334
|
+
const CENTER_COST_BASIS_WORDS = ['exact', 'lowerBound', 'unknown'];
|
|
335
|
+
export const CENTER_USAGE_COST_UNKNOWN_WHYS = Object.freeze(['declared_unknown', 'basis_unrecognized', 'estimated_zero', 'amount_absent']);
|
|
336
|
+
const unknownCost = (why) => ({ state: 'unknown', why });
|
|
337
|
+
const amountCost = (value, bound, unpriced) => ({ state: 'amount', amount: { value, bound }, unpriced });
|
|
338
|
+
const flagNotRuledOut = (r) => r.value === true || r.presence === 'unreadable';
|
|
339
|
+
export function centerUsageCostOf(body) {
|
|
340
|
+
try {
|
|
341
|
+
if (!isRecord(body))
|
|
342
|
+
return unknownCost('amount_absent');
|
|
343
|
+
const basis = slotReadOf(body, 'costBasis');
|
|
344
|
+
let word;
|
|
345
|
+
if (basis.presence === 'present') {
|
|
346
|
+
word = CENTER_COST_BASIS_WORDS.find((w) => w === basis.value);
|
|
347
|
+
if (word === undefined)
|
|
348
|
+
return unknownCost('basis_unrecognized');
|
|
349
|
+
}
|
|
350
|
+
else if (basis.presence === 'unreadable') {
|
|
351
|
+
return unknownCost('basis_unrecognized');
|
|
352
|
+
}
|
|
353
|
+
if (word === 'unknown')
|
|
354
|
+
return unknownCost('declared_unknown');
|
|
355
|
+
const cost = slotReadOf(body, 'costUsd').value;
|
|
356
|
+
if (!nonNeg(cost))
|
|
357
|
+
return unknownCost('amount_absent');
|
|
358
|
+
const est = slotReadOf(body, 'estimated');
|
|
359
|
+
const trunc = slotReadOf(body, 'truncated');
|
|
360
|
+
const unpriced = est.value === true;
|
|
361
|
+
if (word === 'lowerBound')
|
|
362
|
+
return amountCost(cost, 'lower', unpriced);
|
|
363
|
+
if (word === 'exact')
|
|
364
|
+
return flagNotRuledOut(est) || flagNotRuledOut(trunc) ? amountCost(cost, 'lower', unpriced) : amountCost(cost, 'exact', false);
|
|
365
|
+
if (unpriced && cost === 0)
|
|
366
|
+
return unknownCost('estimated_zero');
|
|
367
|
+
return amountCost(cost, costBoundOf(precisionOf(est.value), flagNotRuledOut(trunc)), unpriced);
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
return unknownCost('amount_absent');
|
|
371
|
+
}
|
|
372
|
+
}
|
|
@@ -24,7 +24,6 @@ export type ThrownExtraReading = {
|
|
|
24
24
|
};
|
|
25
25
|
export declare function readThrownExtra(o: {} | null | undefined): ThrownExtraReading;
|
|
26
26
|
export interface ThrownExtraSnapshot {
|
|
27
|
-
readonly sdkInstance: boolean;
|
|
28
27
|
readonly bag: ThrownExtraReading;
|
|
29
28
|
}
|
|
30
29
|
export declare function readThrownExtraSnapshot(o: {} | null | undefined): ThrownExtraSnapshot;
|
|
@@ -32,6 +31,7 @@ export declare const PROTOCOL_ERROR_NAME: Readonly<{
|
|
|
32
31
|
readonly ApprovalBindingMismatchError: "ApprovalBindingMismatchError";
|
|
33
32
|
readonly ApprovalStaleError: "ApprovalStaleError";
|
|
34
33
|
readonly AskDecidedError: "AskDecidedError";
|
|
34
|
+
readonly CheckpointInvalidOutcomeError: "CheckpointInvalidOutcomeError";
|
|
35
35
|
readonly ConflictError: "ConflictError";
|
|
36
36
|
readonly NotFoundError: "NotFoundError";
|
|
37
37
|
readonly ParkedResumeStartupError: "ParkedResumeStartupError";
|
|
@@ -47,18 +47,15 @@ export declare const PROTOCOL_ERROR_NAME: Readonly<{
|
|
|
47
47
|
readonly UsageWindowExhaustedError: "UsageWindowExhaustedError";
|
|
48
48
|
}>;
|
|
49
49
|
export type ProtocolErrorName = (typeof PROTOCOL_ERROR_NAME)[keyof typeof PROTOCOL_ERROR_NAME];
|
|
50
|
-
export declare function isSdkErrorInstance(o: object): boolean;
|
|
51
50
|
export type ProtocolErrorNameReading = {
|
|
52
51
|
readonly state: 'named';
|
|
53
52
|
readonly name: ProtocolErrorName;
|
|
54
53
|
} | {
|
|
55
54
|
readonly state: 'absent';
|
|
56
|
-
} | {
|
|
57
|
-
readonly state: 'sdk-instance';
|
|
58
55
|
} | {
|
|
59
56
|
readonly state: 'unreadable';
|
|
60
57
|
};
|
|
61
|
-
export declare function protocolErrorNameReading(e: object
|
|
58
|
+
export declare function protocolErrorNameReading(e: object): ProtocolErrorNameReading;
|
|
62
59
|
export declare function protocolErrorNameOf(e: object): ProtocolErrorName | undefined;
|
|
63
60
|
export type ThrownStatusReading = number | undefined | typeof THROWN_SLOT_UNREADABLE;
|
|
64
61
|
export declare function readThrownStatusSlot(o: object, notePresence?: (presence: SlotPresence) => void): ThrownStatusReading;
|
package/dist/wireFailureShape.js
CHANGED
|
@@ -91,39 +91,39 @@ export function readThrownExtra(o) {
|
|
|
91
91
|
}
|
|
92
92
|
export function readThrownExtraSnapshot(o) {
|
|
93
93
|
if (o === null || o === undefined || (typeof o !== 'object' && typeof o !== 'function'))
|
|
94
|
-
return {
|
|
94
|
+
return { bag: { state: 'absent' } };
|
|
95
95
|
let at;
|
|
96
96
|
try {
|
|
97
97
|
at = extraSlotOf(o);
|
|
98
98
|
}
|
|
99
99
|
catch {
|
|
100
|
-
return {
|
|
100
|
+
return { bag: { state: 'unreadable' } };
|
|
101
101
|
}
|
|
102
|
-
const sdkInstance = at.kind === 'sdk-class';
|
|
103
102
|
if (at.kind === 'own-accessor')
|
|
104
|
-
return {
|
|
103
|
+
return { bag: { state: 'unreadable' } };
|
|
105
104
|
if (at.kind === 'none')
|
|
106
|
-
return {
|
|
105
|
+
return { bag: { state: 'absent' } };
|
|
107
106
|
let slot;
|
|
108
107
|
try {
|
|
109
108
|
slot = at.kind === 'own-data' ? at.value : Reflect.get(o, EXTRA_KEY);
|
|
110
109
|
}
|
|
111
110
|
catch {
|
|
112
|
-
return {
|
|
111
|
+
return { bag: { state: 'unreadable' } };
|
|
113
112
|
}
|
|
114
113
|
try {
|
|
115
114
|
if (typeof slot !== 'object' || slot === null || Array.isArray(slot))
|
|
116
|
-
return {
|
|
115
|
+
return { bag: { state: 'absent' } };
|
|
117
116
|
}
|
|
118
117
|
catch {
|
|
119
|
-
return {
|
|
118
|
+
return { bag: { state: 'unreadable' } };
|
|
120
119
|
}
|
|
121
|
-
return {
|
|
120
|
+
return { bag: { state: 'object', value: slot } };
|
|
122
121
|
}
|
|
123
122
|
export const PROTOCOL_ERROR_NAME = Object.freeze({
|
|
124
123
|
ApprovalBindingMismatchError: 'ApprovalBindingMismatchError',
|
|
125
124
|
ApprovalStaleError: 'ApprovalStaleError',
|
|
126
125
|
AskDecidedError: 'AskDecidedError',
|
|
126
|
+
CheckpointInvalidOutcomeError: 'CheckpointInvalidOutcomeError',
|
|
127
127
|
ConflictError: 'ConflictError',
|
|
128
128
|
NotFoundError: 'NotFoundError',
|
|
129
129
|
ParkedResumeStartupError: 'ParkedResumeStartupError',
|
|
@@ -139,20 +139,10 @@ export const PROTOCOL_ERROR_NAME = Object.freeze({
|
|
|
139
139
|
UsageWindowExhaustedError: 'UsageWindowExhaustedError',
|
|
140
140
|
});
|
|
141
141
|
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) {
|
|
142
|
+
export function protocolErrorNameReading(e) {
|
|
151
143
|
if (typeof e !== 'object' || e === null)
|
|
152
144
|
return { state: 'absent' };
|
|
153
145
|
try {
|
|
154
|
-
if (extra !== undefined ? extra.sdkInstance : isSdkErrorInstance(e))
|
|
155
|
-
return { state: 'sdk-instance' };
|
|
156
146
|
const name = ownDataField(e, 'name');
|
|
157
147
|
return typeof name === 'string' && PROTOCOL_ERROR_NAMES.has(name) ? { state: 'named', name: name } : { state: 'absent' };
|
|
158
148
|
}
|
|
@@ -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 {
|
|
@@ -158,6 +159,15 @@ export interface SessionIdRetiredDetail {
|
|
|
158
159
|
}
|
|
159
160
|
export declare function sessionIdRetiredFromError(err: {} | null | undefined): SessionIdRetiredDetail | null;
|
|
160
161
|
export declare function sessionIdRetiredContent(detail: Pick<SessionIdRetiredDetail, 'folded'>, lang?: UiLanguage): string;
|
|
162
|
+
export type UnreadRequestMembersFace = 'settings_hooks' | 'settings_env' | 'settings_other' | 'mcp_transport' | 'a2a_headers';
|
|
163
|
+
export interface UnreadRequestMembersDetail {
|
|
164
|
+
readonly code: typeof FIELD_INVALID;
|
|
165
|
+
readonly field: string;
|
|
166
|
+
readonly face: UnreadRequestMembersFace;
|
|
167
|
+
readonly folded?: true;
|
|
168
|
+
}
|
|
169
|
+
export declare function unreadRequestMembersFromError(err: {} | null | undefined): UnreadRequestMembersDetail | null;
|
|
170
|
+
export declare function unreadRequestMembersContent(detail: Pick<UnreadRequestMembersDetail, 'field' | 'face' | 'folded'>, lang?: UiLanguage): string;
|
|
161
171
|
export interface RunConcurrencyCapDetail {
|
|
162
172
|
readonly code: typeof LIMIT_RATE_EXCEEDED;
|
|
163
173
|
readonly reason: typeof RATE_EXCEEDED_RUN_CONCURRENCY_CAP;
|
package/dist/wireRefusalCopy.js
CHANGED
|
@@ -877,6 +877,74 @@ export function sessionIdRetiredFromError(err) {
|
|
|
877
877
|
export function sessionIdRetiredContent(detail, lang) {
|
|
878
878
|
return renderMessage(msg(detail.folded === true ? 'notice.wireRefusal.sessionIdRetired.folded' : 'notice.wireRefusal.sessionIdRetired'), lang);
|
|
879
879
|
}
|
|
880
|
+
function isIndexedMemberCoordinate(field, list, member) {
|
|
881
|
+
const head = `${list}[`;
|
|
882
|
+
if (!field.startsWith(head))
|
|
883
|
+
return false;
|
|
884
|
+
const close = field.indexOf(']', head.length);
|
|
885
|
+
if (close < 0 || !/^[0-9]+$/.test(field.slice(head.length, close)))
|
|
886
|
+
return false;
|
|
887
|
+
const rest = field.slice(close + 1);
|
|
888
|
+
return rest === `.${member}` || rest.startsWith(`.${member}.`);
|
|
889
|
+
}
|
|
890
|
+
function unreadMembersFaceOf(field) {
|
|
891
|
+
if (/^settings\.hooks(?:\.|$)/.test(field))
|
|
892
|
+
return 'settings_hooks';
|
|
893
|
+
if (/^settings\.env(?:\.|$)/.test(field))
|
|
894
|
+
return 'settings_env';
|
|
895
|
+
if (/^settings\.[^\s.[\]]/.test(field))
|
|
896
|
+
return 'settings_other';
|
|
897
|
+
if (isIndexedMemberCoordinate(field, 'mcpServers', 'transport'))
|
|
898
|
+
return 'mcp_transport';
|
|
899
|
+
if (isIndexedMemberCoordinate(field, 'a2aPeers', 'headers'))
|
|
900
|
+
return 'a2a_headers';
|
|
901
|
+
return undefined;
|
|
902
|
+
}
|
|
903
|
+
export function unreadRequestMembersFromError(err) {
|
|
904
|
+
try {
|
|
905
|
+
if (typeof err !== 'object' || err === null)
|
|
906
|
+
return null;
|
|
907
|
+
const effective = effectiveWireCodeReading(err);
|
|
908
|
+
if (effective.code !== FIELD_INVALID)
|
|
909
|
+
return null;
|
|
910
|
+
const slots = readRefusalSlots(err, ['field', 'reason', 'detail']);
|
|
911
|
+
if (slots.reason.present || slots.detail.present)
|
|
912
|
+
return null;
|
|
913
|
+
const field = slots.field.word;
|
|
914
|
+
if (field === undefined)
|
|
915
|
+
return null;
|
|
916
|
+
const face = unreadMembersFaceOf(field);
|
|
917
|
+
if (face === undefined)
|
|
918
|
+
return null;
|
|
919
|
+
return Object.freeze({ code: FIELD_INVALID, field, face, ...(effective.folded ? { folded: true } : {}) });
|
|
920
|
+
}
|
|
921
|
+
catch {
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
function unreadMembersPartKey(face) {
|
|
926
|
+
switch (face) {
|
|
927
|
+
case 'settings_hooks':
|
|
928
|
+
return 'notice.wireRefusal.unreadMembers.part.settingsHooks';
|
|
929
|
+
case 'settings_env':
|
|
930
|
+
return 'notice.wireRefusal.unreadMembers.part.settingsEnv';
|
|
931
|
+
case 'settings_other':
|
|
932
|
+
return 'notice.wireRefusal.unreadMembers.part.settingsOther';
|
|
933
|
+
case 'mcp_transport':
|
|
934
|
+
return 'notice.wireRefusal.unreadMembers.part.mcpTransport';
|
|
935
|
+
case 'a2a_headers':
|
|
936
|
+
return 'notice.wireRefusal.unreadMembers.part.a2aHeaders';
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
const UNREAD_MEMBERS_FIELD_SHOWN_MAX = 120;
|
|
940
|
+
export function unreadRequestMembersContent(detail, lang) {
|
|
941
|
+
const folded = detail.folded === true;
|
|
942
|
+
const part = renderMessage(msg(unreadMembersPartKey(detail.face)), lang);
|
|
943
|
+
const head = renderMessage(msg(folded ? 'notice.wireRefusal.unreadMembers.folded' : 'notice.wireRefusal.unreadMembers', { part }), lang);
|
|
944
|
+
const quoted = quoteUntrustedForSentence(detail.field, UNREAD_MEMBERS_FIELD_SHOWN_MAX);
|
|
945
|
+
const where = quoted !== undefined ? ` · ${renderMessage(msg('notice.wireRefusal.unreadMembers.where', { where: quoted }), lang)}` : '';
|
|
946
|
+
return `${head}${where} · ${renderMessage(msg(folded ? 'notice.wireRefusal.unreadMembers.folded.remedy' : 'notice.wireRefusal.unreadMembers.remedy'), lang)}`;
|
|
947
|
+
}
|
|
880
948
|
export function runConcurrencyCapFromError(err) {
|
|
881
949
|
try {
|
|
882
950
|
if (typeof err !== 'object' || err === null)
|
|
@@ -1069,3 +1137,11 @@ export function userAttachmentRefusalFromError(err) {
|
|
|
1069
1137
|
export function userInvokedSkillRefusalFromError(err) {
|
|
1070
1138
|
return effectiveWireErrorCode(err) === USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE ? { code: USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE, retryable: false } : null;
|
|
1071
1139
|
}
|
|
1140
|
+
const _pinRequestField = [true, true, true, true, true, true, true, true];
|
|
1141
|
+
void _pinRequestField;
|
|
1142
|
+
const _pinSettingsHooks = [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true];
|
|
1143
|
+
void _pinSettingsHooks;
|
|
1144
|
+
const _pinAttachment = [true, true, true];
|
|
1145
|
+
void _pinAttachment;
|
|
1146
|
+
const _pinWallSource = [true, true, true];
|
|
1147
|
+
void _pinWallSource;
|