@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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type AccountRowView } from './coreValuePorts.js';
|
|
2
|
+
export declare const SESSION_COST_BOUNDS: readonly ["known", "lower_bound", "unknown"];
|
|
3
|
+
export type SessionCostBound = (typeof SESSION_COST_BOUNDS)[number];
|
|
4
|
+
export declare const SESSION_COST_HISTORY_BASES: readonly ["complete", "partial", "unread"];
|
|
5
|
+
export type SessionCostHistoryBasis = (typeof SESSION_COST_HISTORY_BASES)[number];
|
|
6
|
+
export declare const SESSION_COST_LOWER_BOUND_CAUSES: readonly ["usage_missing", "history_partial", "history_unread"];
|
|
7
|
+
export type SessionCostLowerBoundCause = (typeof SESSION_COST_LOWER_BOUND_CAUSES)[number];
|
|
8
|
+
export declare const SESSION_COST_UNKNOWN_WHYS: readonly ["port_absent", "lines_malformed", "fold_unreadable", "line_cost_unknown", "zero_lower_bound", "pending_run_cost"];
|
|
9
|
+
export type SessionCostUnknownWhy = (typeof SESSION_COST_UNKNOWN_WHYS)[number];
|
|
10
|
+
export interface SessionCostKnownFigure {
|
|
11
|
+
readonly bound: 'known';
|
|
12
|
+
readonly micro: number;
|
|
13
|
+
readonly usd: number;
|
|
14
|
+
readonly mark: '';
|
|
15
|
+
}
|
|
16
|
+
export interface SessionCostLowerBoundFigure {
|
|
17
|
+
readonly bound: 'lower_bound';
|
|
18
|
+
readonly micro: number;
|
|
19
|
+
readonly usd: number;
|
|
20
|
+
readonly mark: '+';
|
|
21
|
+
readonly causes: readonly SessionCostLowerBoundCause[];
|
|
22
|
+
}
|
|
23
|
+
export interface SessionCostUnknownFigure {
|
|
24
|
+
readonly bound: 'unknown';
|
|
25
|
+
readonly why: SessionCostUnknownWhy;
|
|
26
|
+
readonly mark: '';
|
|
27
|
+
}
|
|
28
|
+
export type SessionCostFigure = SessionCostKnownFigure | SessionCostLowerBoundFigure | SessionCostUnknownFigure;
|
|
29
|
+
export interface SessionCostReading {
|
|
30
|
+
readonly frame: SessionCostFigure;
|
|
31
|
+
readonly cumulative: SessionCostFigure;
|
|
32
|
+
readonly sideQuery: SessionCostFigure;
|
|
33
|
+
}
|
|
34
|
+
export type SessionCostLine = AccountRowView | {
|
|
35
|
+
readonly account: AccountRowView;
|
|
36
|
+
};
|
|
37
|
+
export interface SessionCostInput {
|
|
38
|
+
readonly lines: Iterable<SessionCostLine>;
|
|
39
|
+
readonly history: SessionCostHistoryBasis;
|
|
40
|
+
readonly pendingTurns?: number;
|
|
41
|
+
}
|
|
42
|
+
export declare function sessionCostReadingOf(input: SessionCostInput): SessionCostReading;
|
|
43
|
+
export interface SessionCostForkSource {
|
|
44
|
+
readonly lines: Iterable<SessionCostLine>;
|
|
45
|
+
readonly history: SessionCostHistoryBasis;
|
|
46
|
+
}
|
|
47
|
+
export interface SessionCostSeed {
|
|
48
|
+
readonly lines: readonly AccountRowView[];
|
|
49
|
+
readonly history: 'partial' | 'unread';
|
|
50
|
+
readonly reading: SessionCostReading;
|
|
51
|
+
}
|
|
52
|
+
export declare function forkSeedCostOf(source: SessionCostForkSource): SessionCostSeed;
|
|
53
|
+
export declare const RUN_COST_SETTLEMENTS: readonly ["awaiting", "priced", "unpriced", "lost"];
|
|
54
|
+
export type RunCostSettlement = (typeof RUN_COST_SETTLEMENTS)[number];
|
|
55
|
+
export declare const TURN_COST_UNKNOWN_WHYS: readonly ["usage_missing", "unpriced", "absent", "malformed", "pending_terminal", "terminal_lost"];
|
|
56
|
+
export type TurnCostUnknownWhy = (typeof TURN_COST_UNKNOWN_WHYS)[number];
|
|
57
|
+
export interface TurnCostUsageView {
|
|
58
|
+
readonly costMicroUsd?: number;
|
|
59
|
+
readonly costUSD?: number;
|
|
60
|
+
readonly _sema_cost_absent?: true;
|
|
61
|
+
readonly usageMissing?: true;
|
|
62
|
+
}
|
|
63
|
+
export type TurnCostReading = {
|
|
64
|
+
readonly bound: 'known';
|
|
65
|
+
readonly usd: number;
|
|
66
|
+
} | {
|
|
67
|
+
readonly bound: 'unknown';
|
|
68
|
+
readonly why: TurnCostUnknownWhy;
|
|
69
|
+
};
|
|
70
|
+
export declare function turnCostReadingOf(usage: TurnCostUsageView, settlement: RunCostSettlement): TurnCostReading;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { foldAccount } from './coreValuePorts.js';
|
|
2
|
+
import { appendOwnElement, readOwnDataValue } from './ownKey.js';
|
|
3
|
+
export const SESSION_COST_BOUNDS = Object.freeze(['known', 'lower_bound', 'unknown']);
|
|
4
|
+
export const SESSION_COST_HISTORY_BASES = Object.freeze(['complete', 'partial', 'unread']);
|
|
5
|
+
export const SESSION_COST_LOWER_BOUND_CAUSES = Object.freeze(['usage_missing', 'history_partial', 'history_unread']);
|
|
6
|
+
export const SESSION_COST_UNKNOWN_WHYS = Object.freeze(['port_absent', 'lines_malformed', 'fold_unreadable', 'line_cost_unknown', 'zero_lower_bound', 'pending_run_cost']);
|
|
7
|
+
const MICRO_PER_USD = 1_000_000;
|
|
8
|
+
function unknownFigure(why) {
|
|
9
|
+
return { bound: 'unknown', why, mark: '' };
|
|
10
|
+
}
|
|
11
|
+
function allUnknown(why) {
|
|
12
|
+
return { frame: unknownFigure(why), cumulative: unknownFigure(why), sideQuery: unknownFigure(why) };
|
|
13
|
+
}
|
|
14
|
+
function unwrapLines(lines) {
|
|
15
|
+
if (typeof lines !== 'object' || lines === null || typeof lines[Symbol.iterator] !== 'function')
|
|
16
|
+
return undefined;
|
|
17
|
+
const rows = [];
|
|
18
|
+
for (const line of lines) {
|
|
19
|
+
if (typeof line !== 'object' || line === null)
|
|
20
|
+
return undefined;
|
|
21
|
+
const origin = readOwnDataValue(line, 'origin');
|
|
22
|
+
const account = readOwnDataValue(line, 'account');
|
|
23
|
+
if (origin !== undefined && account !== undefined)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (origin !== undefined) {
|
|
26
|
+
appendOwnElement(rows, line);
|
|
27
|
+
}
|
|
28
|
+
else if (typeof account === 'object' && account !== null) {
|
|
29
|
+
appendOwnElement(rows, account);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return rows;
|
|
36
|
+
}
|
|
37
|
+
function figureOf(total, history, pending) {
|
|
38
|
+
if (typeof total !== 'object' || total === null)
|
|
39
|
+
return unknownFigure('fold_unreadable');
|
|
40
|
+
const costSlot = Object.getOwnPropertyDescriptor(total, 'costMicroUsd');
|
|
41
|
+
if (costSlot === undefined)
|
|
42
|
+
return unknownFigure('line_cost_unknown');
|
|
43
|
+
const micro = Object.hasOwn(costSlot, 'value') ? costSlot.value : undefined;
|
|
44
|
+
if (typeof micro !== 'number' || !Number.isSafeInteger(micro) || micro < 0)
|
|
45
|
+
return unknownFigure('fold_unreadable');
|
|
46
|
+
const causes = [];
|
|
47
|
+
if (readOwnDataValue(total, 'usageMissing') === true)
|
|
48
|
+
appendOwnElement(causes, 'usage_missing');
|
|
49
|
+
if (history === 'partial')
|
|
50
|
+
appendOwnElement(causes, 'history_partial');
|
|
51
|
+
else if (history !== 'complete')
|
|
52
|
+
appendOwnElement(causes, 'history_unread');
|
|
53
|
+
if (causes.length > 0)
|
|
54
|
+
return micro === 0 ? unknownFigure('zero_lower_bound') : { bound: 'lower_bound', micro, usd: micro / MICRO_PER_USD, mark: '+', causes };
|
|
55
|
+
if (micro === 0 && pending > 0)
|
|
56
|
+
return unknownFigure('pending_run_cost');
|
|
57
|
+
return { bound: 'known', micro, usd: micro / MICRO_PER_USD, mark: '' };
|
|
58
|
+
}
|
|
59
|
+
export function sessionCostReadingOf(input) {
|
|
60
|
+
try {
|
|
61
|
+
let rows;
|
|
62
|
+
let account;
|
|
63
|
+
try {
|
|
64
|
+
rows = unwrapLines(readOwnDataValue(input, 'lines'));
|
|
65
|
+
if (rows === undefined)
|
|
66
|
+
return allUnknown('lines_malformed');
|
|
67
|
+
account = foldAccount(rows);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return allUnknown('lines_malformed');
|
|
71
|
+
}
|
|
72
|
+
if (account === undefined)
|
|
73
|
+
return allUnknown('port_absent');
|
|
74
|
+
const byOrigin = readOwnDataValue(account, 'byOrigin');
|
|
75
|
+
if (typeof byOrigin !== 'object' || byOrigin === null)
|
|
76
|
+
return allUnknown('fold_unreadable');
|
|
77
|
+
const history = readOwnDataValue(input, 'history');
|
|
78
|
+
const pendingRaw = readOwnDataValue(input, 'pendingTurns');
|
|
79
|
+
const pending = pendingRaw === undefined ? 0 : Number.isSafeInteger(pendingRaw) && pendingRaw >= 0 ? pendingRaw : Number.POSITIVE_INFINITY;
|
|
80
|
+
return {
|
|
81
|
+
frame: figureOf(readOwnDataValue(byOrigin, 'run'), history, pending),
|
|
82
|
+
cumulative: figureOf(account, history, pending),
|
|
83
|
+
sideQuery: figureOf(readOwnDataValue(byOrigin, 'side_query'), history, 0),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return allUnknown('fold_unreadable');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export function forkSeedCostOf(source) {
|
|
91
|
+
const empty = () => ({ lines: [], history: 'unread', reading: allUnknown('lines_malformed') });
|
|
92
|
+
try {
|
|
93
|
+
const rows = unwrapLines(readOwnDataValue(source, 'lines'));
|
|
94
|
+
if (rows === undefined)
|
|
95
|
+
return empty();
|
|
96
|
+
const sourceHistory = readOwnDataValue(source, 'history');
|
|
97
|
+
const history = sourceHistory === 'complete' || sourceHistory === 'partial' ? 'partial' : 'unread';
|
|
98
|
+
const reading = sessionCostReadingOf({ lines: rows, history });
|
|
99
|
+
if (reading.cumulative.bound === 'unknown' && reading.cumulative.why === 'lines_malformed')
|
|
100
|
+
return empty();
|
|
101
|
+
return { lines: rows, history, reading };
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return empty();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export const RUN_COST_SETTLEMENTS = Object.freeze(['awaiting', 'priced', 'unpriced', 'lost']);
|
|
108
|
+
export const TURN_COST_UNKNOWN_WHYS = Object.freeze(['usage_missing', 'unpriced', 'absent', 'malformed', 'pending_terminal', 'terminal_lost']);
|
|
109
|
+
function turnUnknown(why) {
|
|
110
|
+
return { bound: 'unknown', why };
|
|
111
|
+
}
|
|
112
|
+
export function turnCostReadingOf(usage, settlement) {
|
|
113
|
+
try {
|
|
114
|
+
if (typeof usage !== 'object' || usage === null)
|
|
115
|
+
return turnUnknown('malformed');
|
|
116
|
+
if (readOwnDataValue(usage, 'usageMissing') === true)
|
|
117
|
+
return turnUnknown('usage_missing');
|
|
118
|
+
const costAbsent = readOwnDataValue(usage, '_sema_cost_absent') === true;
|
|
119
|
+
const micro = readOwnDataValue(usage, 'costMicroUsd');
|
|
120
|
+
const microIsNumber = typeof micro === 'number';
|
|
121
|
+
if (costAbsent && !(microIsNumber && Number.isFinite(micro) && micro > 0))
|
|
122
|
+
return turnUnknown('unpriced');
|
|
123
|
+
let usd;
|
|
124
|
+
if (micro !== undefined) {
|
|
125
|
+
if (!microIsNumber || !Number.isFinite(micro) || micro < 0)
|
|
126
|
+
return turnUnknown('malformed');
|
|
127
|
+
usd = micro / MICRO_PER_USD;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const mirror = readOwnDataValue(usage, 'costUSD');
|
|
131
|
+
if (mirror === undefined)
|
|
132
|
+
return turnUnknown('absent');
|
|
133
|
+
if (typeof mirror !== 'number' || !Number.isFinite(mirror) || mirror < 0)
|
|
134
|
+
return turnUnknown('malformed');
|
|
135
|
+
usd = mirror;
|
|
136
|
+
}
|
|
137
|
+
if (usd > 0)
|
|
138
|
+
return { bound: 'known', usd };
|
|
139
|
+
if (settlement === 'priced')
|
|
140
|
+
return { bound: 'known', usd: 0 };
|
|
141
|
+
if (settlement === 'unpriced')
|
|
142
|
+
return turnUnknown('unpriced');
|
|
143
|
+
if (settlement === 'lost')
|
|
144
|
+
return turnUnknown('terminal_lost');
|
|
145
|
+
return turnUnknown('pending_terminal');
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
return turnUnknown('malformed');
|
|
149
|
+
}
|
|
150
|
+
}
|
package/dist/sessionEngine.d.ts
CHANGED
|
@@ -153,5 +153,7 @@ export declare function sessionEngineBindingFor(input: SessionEngineBindingInput
|
|
|
153
153
|
export declare function isSessionEngineView(v: {} | null | undefined): boolean;
|
|
154
154
|
export declare function readSessionEngine(record: SessionMapRecord | undefined): SessionEngineReading;
|
|
155
155
|
export declare function commitSessionEngine(store: SessionMapStorePort, session: SessionEngineSessionRef, request: SessionEngineCommitRequest): SessionEngineCommitResult;
|
|
156
|
+
export type SessionEngineRepointResult = 'moved' | 'unaffected' | 'conflict' | 'unreadable' | 'store-failed' | 'request-invalid';
|
|
157
|
+
export declare function repointSessionEngine(store: SessionMapStorePort, from: string, to: string): SessionEngineRepointResult;
|
|
156
158
|
export declare function sessionDispatchRefusedFor(refusal: SessionDispatchRefusal): SessionDispatchRefused;
|
|
157
159
|
export declare function sessionDispatchTarget(reading: SessionEngineReading, ctx: SessionEngineWiring): SessionDispatchDecision;
|
package/dist/sessionEngine.js
CHANGED
|
@@ -377,6 +377,117 @@ function methodOf(o, key) {
|
|
|
377
377
|
return undefined;
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
+
function addressBindingOf(raw) {
|
|
381
|
+
if (typeof raw !== 'string')
|
|
382
|
+
return undefined;
|
|
383
|
+
const b = addressBinding(raw);
|
|
384
|
+
return b.ok && b.identityKind === 'address' ? b : undefined;
|
|
385
|
+
}
|
|
386
|
+
function enginesTableOf(record) {
|
|
387
|
+
const slot = slotReadOf(record, 'engines');
|
|
388
|
+
if (slot.presence === 'absent' || (slot.presence === 'present' && slot.value === undefined))
|
|
389
|
+
return 'absent';
|
|
390
|
+
return slot.presence === 'present' && isObj(slot.value) ? slot.value : 'unreadable';
|
|
391
|
+
}
|
|
392
|
+
function movedEngines(table, dropKey, putKey, entry) {
|
|
393
|
+
const out = {};
|
|
394
|
+
for (const k of Object.keys(table)) {
|
|
395
|
+
if (k === dropKey)
|
|
396
|
+
continue;
|
|
397
|
+
const slot = slotReadOf(table, k);
|
|
398
|
+
if (slot.presence !== 'present')
|
|
399
|
+
return undefined;
|
|
400
|
+
Object.defineProperty(out, k, { value: slot.value, writable: true, enumerable: true, configurable: true });
|
|
401
|
+
}
|
|
402
|
+
Object.defineProperty(out, putKey, { value: entry, writable: true, enumerable: true, configurable: true });
|
|
403
|
+
return out;
|
|
404
|
+
}
|
|
405
|
+
function repointStep(prior, from, to, fromNs, toNs, now) {
|
|
406
|
+
try {
|
|
407
|
+
const reading = readSessionEngine(prior);
|
|
408
|
+
if (reading.kind === 'none')
|
|
409
|
+
return { result: 'unaffected' };
|
|
410
|
+
if (reading.kind === 'unresolved' || prior === undefined)
|
|
411
|
+
return { result: 'unreadable' };
|
|
412
|
+
const table = enginesTableOf(prior);
|
|
413
|
+
if (reading.kind === 'bound') {
|
|
414
|
+
const id = reading.binding.identity;
|
|
415
|
+
if (id.identityKind !== 'address' || id.key !== from.key)
|
|
416
|
+
return { result: 'unaffected' };
|
|
417
|
+
if (table === 'absent' || table === 'unreadable')
|
|
418
|
+
return { result: 'unreadable' };
|
|
419
|
+
if (Object.hasOwn(table, to.key))
|
|
420
|
+
return { result: 'conflict' };
|
|
421
|
+
const entry = slotReadOf(table, from.key);
|
|
422
|
+
if (entry.presence !== 'present' || !isObj(entry.value))
|
|
423
|
+
return { result: 'unreadable' };
|
|
424
|
+
const engines = movedEngines(table, from.key, to.key, entry.value);
|
|
425
|
+
if (engines === undefined)
|
|
426
|
+
return { result: 'unreadable' };
|
|
427
|
+
return {
|
|
428
|
+
result: 'moved',
|
|
429
|
+
next: { ...prior, boundEngine: snapshotOf({ kind: reading.binding.kind, identity: to }), engines, updatedAt: now },
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
if (table === 'absent')
|
|
433
|
+
return { result: 'unaffected' };
|
|
434
|
+
if (table === 'unreadable')
|
|
435
|
+
return { result: 'unreadable' };
|
|
436
|
+
if (!Object.hasOwn(table, fromNs))
|
|
437
|
+
return { result: 'unaffected' };
|
|
438
|
+
if (Object.hasOwn(table, toNs))
|
|
439
|
+
return { result: 'conflict' };
|
|
440
|
+
const entry = slotReadOf(table, fromNs);
|
|
441
|
+
if (entry.presence !== 'present' || !isObj(entry.value))
|
|
442
|
+
return { result: 'unreadable' };
|
|
443
|
+
const engines = movedEngines(table, fromNs, toNs, entry.value);
|
|
444
|
+
if (engines === undefined)
|
|
445
|
+
return { result: 'unreadable' };
|
|
446
|
+
return { result: 'moved', next: { ...prior, engines, updatedAt: now } };
|
|
447
|
+
}
|
|
448
|
+
catch {
|
|
449
|
+
return { result: 'unreadable' };
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
export function repointSessionEngine(store, from, to) {
|
|
453
|
+
let readMergeWrite;
|
|
454
|
+
let fromB;
|
|
455
|
+
let toB;
|
|
456
|
+
try {
|
|
457
|
+
if (!isObj(store))
|
|
458
|
+
return 'request-invalid';
|
|
459
|
+
const rmw = methodOf(store, 'readMergeWrite');
|
|
460
|
+
if (rmw === undefined)
|
|
461
|
+
return 'request-invalid';
|
|
462
|
+
readMergeWrite = (build) => rmw.call(store, build);
|
|
463
|
+
const f = addressBindingOf(from);
|
|
464
|
+
const t = addressBindingOf(to);
|
|
465
|
+
if (f === undefined || t === undefined || f.key === t.key)
|
|
466
|
+
return 'request-invalid';
|
|
467
|
+
fromB = f;
|
|
468
|
+
toB = t;
|
|
469
|
+
}
|
|
470
|
+
catch {
|
|
471
|
+
return 'request-invalid';
|
|
472
|
+
}
|
|
473
|
+
const fromNs = engineNamespaceKeyFor(from);
|
|
474
|
+
const toNs = engineNamespaceKeyFor(to);
|
|
475
|
+
let step;
|
|
476
|
+
try {
|
|
477
|
+
const returned = readMergeWrite((prior) => {
|
|
478
|
+
step = repointStep(prior, fromB, toB, fromNs, toNs, new Date().toISOString());
|
|
479
|
+
return Object.hasOwn(step, 'next') ? step.next : undefined;
|
|
480
|
+
});
|
|
481
|
+
if (step === undefined)
|
|
482
|
+
return 'store-failed';
|
|
483
|
+
if (Object.hasOwn(step, 'next') && !isObj(returned))
|
|
484
|
+
return 'store-failed';
|
|
485
|
+
return step.result;
|
|
486
|
+
}
|
|
487
|
+
catch {
|
|
488
|
+
return 'store-failed';
|
|
489
|
+
}
|
|
490
|
+
}
|
|
380
491
|
const REFUSAL_KEYS = {
|
|
381
492
|
'not-wired': 'session.engine.dispatch.notWired',
|
|
382
493
|
'scope-mismatch': 'session.engine.dispatch.scopeMismatch',
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type HooksWirePlan } from './pluginHooksWire.js';
|
|
2
|
+
import type { SessionHooksRoster } from './seatContract.js';
|
|
3
|
+
import type { DeviceUnreadable } from './deviceRebind.js';
|
|
4
|
+
export declare function sessionHooksRosterOf(plan: HooksWirePlan | null | undefined): SessionHooksRoster | DeviceUnreadable;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { HOOK_ENTRY_TYPE_WORDS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_EXCLUSION_REASONS, PLUGIN_HOOK_REASONS, SETTINGS_HOOK_DROP_REASONS, hooksWirePlanShapeOf, isEngineFiredHookEvent, } from './pluginHooksWire.js';
|
|
2
|
+
import { HTTP_POLICY_DROP_REASONS } from './httpHookPolicy.js';
|
|
3
|
+
import { HOOK_SETTINGS_SOURCE_TEXT } from './settingsHooksSalvage.js';
|
|
4
|
+
import { SETTINGS_HOOK_EVENTS, SETTINGS_HOOKS_DROPPED_PIECE_CODES, SETTINGS_HOOKS_REJECTION_CODES } from './generated/settingsSchemaFns.js';
|
|
5
|
+
import { appendOwnElement, ownDataField, readOwnDataValue } from './ownKey.js';
|
|
6
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
7
|
+
const inWords = (words, v) => typeof v === 'string' && words.includes(v);
|
|
8
|
+
const isSource = (v) => typeof v === 'string' && Object.hasOwn(HOOK_SETTINGS_SOURCE_TEXT, v);
|
|
9
|
+
const isIndex = (v) => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0;
|
|
10
|
+
const isObject = (v) => typeof v === 'object' && v !== null;
|
|
11
|
+
function ownRowsOf(plan, key) {
|
|
12
|
+
const v = readOwnDataValue(plan, key);
|
|
13
|
+
if (!Array.isArray(v))
|
|
14
|
+
return undefined;
|
|
15
|
+
const n = ownDataField(v, 'length');
|
|
16
|
+
const out = [];
|
|
17
|
+
if (typeof n !== 'number')
|
|
18
|
+
return out;
|
|
19
|
+
for (let i = 0; i < n; i += 1)
|
|
20
|
+
appendOwnElement(out, readOwnDataValue(v, String(i)));
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
const field = (row, key) => (isObject(row) ? readOwnDataValue(row, key) : undefined);
|
|
24
|
+
function coordOf(row) {
|
|
25
|
+
const source = field(row, 'source');
|
|
26
|
+
const event = field(row, 'event');
|
|
27
|
+
const groupIndex = field(row, 'groupIndex');
|
|
28
|
+
const hookIndex = field(row, 'hookIndex');
|
|
29
|
+
const type = field(row, 'type');
|
|
30
|
+
if (!isSource(source) || !inWords(SETTINGS_HOOK_EVENTS, event) || !isIndex(groupIndex) || !isIndex(hookIndex))
|
|
31
|
+
return undefined;
|
|
32
|
+
let typed = {};
|
|
33
|
+
if (type !== undefined) {
|
|
34
|
+
if (!inWords(HOOK_ENTRY_TYPE_WORDS, type))
|
|
35
|
+
return undefined;
|
|
36
|
+
typed = { type };
|
|
37
|
+
}
|
|
38
|
+
return { source, event, groupIndex, hookIndex, ...typed };
|
|
39
|
+
}
|
|
40
|
+
function droppedStatusOf(event, notRun) {
|
|
41
|
+
if (notRun)
|
|
42
|
+
return 'not_run';
|
|
43
|
+
return isEngineFiredHookEvent(event) ? 'shell' : undefined;
|
|
44
|
+
}
|
|
45
|
+
const rosterUnreadable = () => Object.freeze({ kind: 'unreadable', why: renderMessage(msg('config.hooks.roster.unreadable')) });
|
|
46
|
+
export function sessionHooksRosterOf(plan) {
|
|
47
|
+
try {
|
|
48
|
+
if (hooksWirePlanShapeOf(plan) !== 'plan' || !isObject(plan))
|
|
49
|
+
return rosterUnreadable();
|
|
50
|
+
let unlisted = 0;
|
|
51
|
+
const rows = [];
|
|
52
|
+
const addRow = (row) => {
|
|
53
|
+
if (row === undefined)
|
|
54
|
+
unlisted += 1;
|
|
55
|
+
else
|
|
56
|
+
appendOwnElement(rows, Object.freeze(row));
|
|
57
|
+
};
|
|
58
|
+
for (const r of ownRowsOf(plan, 'settingsVerdicts') ?? []) {
|
|
59
|
+
const at = coordOf(r);
|
|
60
|
+
const disposition = field(r, 'disposition');
|
|
61
|
+
const reason = field(r, 'reason');
|
|
62
|
+
addRow(at !== undefined && inWords(PLUGIN_HOOK_DISPOSITIONS, disposition) && inWords(PLUGIN_HOOK_REASONS, reason) ? { ...at, status: disposition, reason } : undefined);
|
|
63
|
+
}
|
|
64
|
+
for (const r of ownRowsOf(plan, 'settingsDropped') ?? []) {
|
|
65
|
+
const at = coordOf(r);
|
|
66
|
+
const reason = field(r, 'reason');
|
|
67
|
+
const notRun = field(r, 'notRun');
|
|
68
|
+
const status = at !== undefined && typeof notRun === 'boolean' ? droppedStatusOf(at.event, notRun) : undefined;
|
|
69
|
+
addRow(at !== undefined && status !== undefined && inWords(SETTINGS_HOOK_DROP_REASONS, reason) ? { ...at, status, reason } : undefined);
|
|
70
|
+
}
|
|
71
|
+
for (const r of ownRowsOf(plan, 'settingsExcluded') ?? []) {
|
|
72
|
+
const at = coordOf(r);
|
|
73
|
+
const reason = field(r, 'reason');
|
|
74
|
+
addRow(at !== undefined && inWords(PLUGIN_HOOK_EXCLUSION_REASONS, reason) ? { ...at, status: 'not_run', reason } : undefined);
|
|
75
|
+
}
|
|
76
|
+
const layers = [];
|
|
77
|
+
for (const r of ownRowsOf(plan, 'settingsSalvage') ?? []) {
|
|
78
|
+
const layer = salvageLayerOf(r);
|
|
79
|
+
if (layer === undefined)
|
|
80
|
+
unlisted += 1;
|
|
81
|
+
else
|
|
82
|
+
appendOwnElement(layers, layer);
|
|
83
|
+
}
|
|
84
|
+
for (const r of ownRowsOf(plan, 'settingsWithheld') ?? []) {
|
|
85
|
+
const source = field(r, 'source');
|
|
86
|
+
if (isSource(source) && field(r, 'cause') === 'trust_withheld')
|
|
87
|
+
appendOwnElement(layers, Object.freeze({ source, state: 'trust_withheld' }));
|
|
88
|
+
else
|
|
89
|
+
unlisted += 1;
|
|
90
|
+
}
|
|
91
|
+
const http = [];
|
|
92
|
+
for (const r of ownRowsOf(plan, 'httpPolicyDrops') ?? []) {
|
|
93
|
+
const source = field(r, 'layer');
|
|
94
|
+
const event = field(r, 'event');
|
|
95
|
+
const reason = field(r, 'reason');
|
|
96
|
+
if (isSource(source) && inWords(SETTINGS_HOOK_EVENTS, event) && inWords(HTTP_POLICY_DROP_REASONS, reason)) {
|
|
97
|
+
appendOwnElement(http, Object.freeze({ source, event, reason }));
|
|
98
|
+
}
|
|
99
|
+
else
|
|
100
|
+
unlisted += 1;
|
|
101
|
+
}
|
|
102
|
+
const closedByRaw = readOwnDataValue(plan, 'closedBy');
|
|
103
|
+
const closedBy = closedByRaw === 'workspace_untrusted' || closedByRaw === 'governance_unreadable' || closedByRaw === 'policy_disable_all' ? closedByRaw : null;
|
|
104
|
+
const sourcesRaw = ownRowsOf(plan, 'settingsSources');
|
|
105
|
+
let sources;
|
|
106
|
+
if (sourcesRaw !== undefined) {
|
|
107
|
+
sources = [];
|
|
108
|
+
for (const s of sourcesRaw) {
|
|
109
|
+
if (isSource(s))
|
|
110
|
+
appendOwnElement(sources, s);
|
|
111
|
+
else
|
|
112
|
+
unlisted += 1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return Object.freeze({
|
|
116
|
+
closedBy,
|
|
117
|
+
...(sources === undefined ? {} : { sources: Object.freeze(sources) }),
|
|
118
|
+
rows: Object.freeze(rows),
|
|
119
|
+
layers: Object.freeze(layers),
|
|
120
|
+
http: Object.freeze(http),
|
|
121
|
+
unlisted,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return rosterUnreadable();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function salvageLayerOf(r) {
|
|
129
|
+
const source = field(r, 'source');
|
|
130
|
+
const outcome = field(r, 'outcome');
|
|
131
|
+
if (!isSource(source))
|
|
132
|
+
return undefined;
|
|
133
|
+
if (outcome === 'loaded-partial') {
|
|
134
|
+
const codes = codesOf(r, 'dropped', SETTINGS_HOOKS_DROPPED_PIECE_CODES);
|
|
135
|
+
return codes === undefined ? undefined : Object.freeze({ source, state: 'loaded-partial', codes });
|
|
136
|
+
}
|
|
137
|
+
if (outcome === 'rejected') {
|
|
138
|
+
const codes = codesOf(r, 'rejections', SETTINGS_HOOKS_REJECTION_CODES);
|
|
139
|
+
return codes === undefined ? undefined : Object.freeze({ source, state: 'rejected', codes });
|
|
140
|
+
}
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
function codesOf(r, key, words) {
|
|
144
|
+
if (!isObject(r))
|
|
145
|
+
return undefined;
|
|
146
|
+
const pieces = ownRowsOf(r, key);
|
|
147
|
+
if (pieces === undefined || pieces.length === 0)
|
|
148
|
+
return undefined;
|
|
149
|
+
const out = [];
|
|
150
|
+
for (const p of pieces) {
|
|
151
|
+
const code = field(p, 'code');
|
|
152
|
+
if (!inWords(words, code))
|
|
153
|
+
return undefined;
|
|
154
|
+
if (!out.includes(code))
|
|
155
|
+
appendOwnElement(out, code);
|
|
156
|
+
}
|
|
157
|
+
return Object.freeze(out);
|
|
158
|
+
}
|
|
@@ -9,7 +9,8 @@ export interface MemoryStatusClientLike {
|
|
|
9
9
|
} & SessionMemoryStatus>;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
export type MemoryStatusFacts =
|
|
12
|
+
export type MemoryStatusFacts = SessionMemoryStatus & {
|
|
13
|
+
autoConsolidationArmed?: SessionMemoryStatusResponse['autoConsolidationArmed'];
|
|
13
14
|
readonly memorySync?: MemorySyncFacts;
|
|
14
15
|
};
|
|
15
16
|
export interface MemorySyncFacts {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isSessionIdPathSegment } from './sessionIdSegment.js';
|
|
2
2
|
import { readThrownSlot, THROWN_SLOT_UNREADABLE } from './wireFailureShape.js';
|
|
3
3
|
import { isUiLanguage } from './env/uiLanguage.js';
|
|
4
|
-
import { msg, renderMessage } from './i18n/translate.js';
|
|
4
|
+
import { msg, renderLanguageOf, renderMessage } from './i18n/translate.js';
|
|
5
5
|
export const MEMORY_SYNC_WAY_OUT_DELETE_CURSOR = 'delete_cursor';
|
|
6
6
|
const MEMORY_SYNC_PARKED_READ_MAX = 256;
|
|
7
7
|
export function classifyMemoryStatusFailure(e) {
|
|
@@ -182,7 +182,7 @@ export function memorySyncParkingNotice(reading, lang) {
|
|
|
182
182
|
return renderMessage(msg(count === 1 ? 'session.memorySync.parkedUnnamed.one' : 'session.memorySync.parkedUnnamed.other', { count, wayOut }), isUiLanguage(lang) ? lang : undefined);
|
|
183
183
|
if (count === 1)
|
|
184
184
|
return renderMessage(msg('session.memorySync.parked.one', { scope: scopes[0] ?? '', wayOut }), isUiLanguage(lang) ? lang : undefined);
|
|
185
|
-
return renderMessage(msg('session.memorySync.parked.other', { count, scopes: scopes.join(lang === 'zh' ? '、' : ', '), wayOut }), isUiLanguage(lang) ? lang : undefined);
|
|
185
|
+
return renderMessage(msg('session.memorySync.parked.other', { count, scopes: scopes.join(renderLanguageOf(lang) === 'zh' ? '、' : ', '), wayOut }), isUiLanguage(lang) ? lang : undefined);
|
|
186
186
|
}
|
|
187
187
|
catch {
|
|
188
188
|
return undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type SessionReadRedactionLeavesReading = {
|
|
2
|
+
readonly kind: 'redacted';
|
|
3
|
+
readonly leaves?: readonly string[];
|
|
4
|
+
} | {
|
|
5
|
+
readonly kind: 'unconfirmed';
|
|
6
|
+
};
|
|
7
|
+
export declare function sessionReadRedactionOf(caps: object | null | undefined): SessionReadRedactionLeavesReading;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { appendOwnElement, ownDataField } from './ownKey.js';
|
|
2
|
+
export function sessionReadRedactionOf(caps) {
|
|
3
|
+
try {
|
|
4
|
+
if (typeof caps !== 'object' || caps === null || Array.isArray(caps))
|
|
5
|
+
return Object.freeze({ kind: 'unconfirmed' });
|
|
6
|
+
const bit = ownDataField(caps, 'sessionReadRedaction');
|
|
7
|
+
if (bit === true)
|
|
8
|
+
return Object.freeze({ kind: 'redacted' });
|
|
9
|
+
if (!Array.isArray(bit))
|
|
10
|
+
return Object.freeze({ kind: 'unconfirmed' });
|
|
11
|
+
const length = ownDataField(bit, 'length');
|
|
12
|
+
if (typeof length !== 'number' || !Number.isSafeInteger(length) || length < 1)
|
|
13
|
+
return Object.freeze({ kind: 'unconfirmed' });
|
|
14
|
+
const leaves = [];
|
|
15
|
+
for (let i = 0; i < length; i++) {
|
|
16
|
+
const leaf = ownDataField(bit, String(i));
|
|
17
|
+
if (typeof leaf !== 'string' || leaf === '')
|
|
18
|
+
return Object.freeze({ kind: 'unconfirmed' });
|
|
19
|
+
appendOwnElement(leaves, leaf);
|
|
20
|
+
}
|
|
21
|
+
return Object.freeze({ kind: 'redacted', leaves: Object.freeze(leaves) });
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return Object.freeze({ kind: 'unconfirmed' });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import type { RowBitsOutcome } from '@sema-agent/sdk';
|
|
2
|
+
import { type UiLanguage } from './env/uiLanguage.js';
|
|
1
3
|
export declare const FILE_HISTORY_SKIPPED_NOTICE: string;
|
|
2
4
|
export declare function fileHistorySyncNotice(result: unknown): string | undefined;
|
|
3
5
|
export declare function fileHistorySyncNoticeIdentity(result: unknown): string | undefined;
|
|
4
6
|
export declare function isFileHistoryBlobMissing(err: unknown): boolean;
|
|
7
|
+
export type PushRowBitsWord = RowBitsOutcome | 'writer_side';
|
|
8
|
+
export declare function sessionPushRowBitsNotice(result: {} | null | undefined, lang?: UiLanguage | (string & {})): string | undefined;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NOT_FOUND_BLOB } from './engineErrorCodes.js';
|
|
2
2
|
import { effectiveWireErrorCode } from './wireErrorTriage.js';
|
|
3
3
|
import { readThrownSlot } from './wireFailureShape.js';
|
|
4
|
+
import { isUiLanguage } from './env/uiLanguage.js';
|
|
5
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
4
6
|
export const FILE_HISTORY_SKIPPED_NOTICE = 'File history was not copied: only the conversation was synced, because one of the two engines does not confirm that it can ' +
|
|
5
7
|
'transfer file history (the record /rewind uses to restore files). Syncing this session again will not add it until ' +
|
|
6
8
|
'the conversation has new turns and both engines can transfer file history.';
|
|
@@ -64,3 +66,28 @@ export function isFileHistoryBlobMissing(err) {
|
|
|
64
66
|
return false;
|
|
65
67
|
}
|
|
66
68
|
}
|
|
69
|
+
const PUSH_ROW_BITS_SPEAKS = Object.freeze({
|
|
70
|
+
mirrored: false,
|
|
71
|
+
unsupported: false,
|
|
72
|
+
absent: false,
|
|
73
|
+
writer_side: true,
|
|
74
|
+
});
|
|
75
|
+
function pushRowBitsSpeaks(word) {
|
|
76
|
+
return PUSH_ROW_BITS_SPEAKS[word];
|
|
77
|
+
}
|
|
78
|
+
function isPushRowBitsWord(v) {
|
|
79
|
+
return Object.hasOwn(PUSH_ROW_BITS_SPEAKS, v);
|
|
80
|
+
}
|
|
81
|
+
export function sessionPushRowBitsNotice(result, lang) {
|
|
82
|
+
if (result === null || typeof result !== 'object')
|
|
83
|
+
return undefined;
|
|
84
|
+
try {
|
|
85
|
+
const word = getOwn(result, 'rowBits');
|
|
86
|
+
if (typeof word !== 'string' || !isPushRowBitsWord(word) || !pushRowBitsSpeaks(word))
|
|
87
|
+
return undefined;
|
|
88
|
+
return renderMessage(msg('session.sync.pushRowBitsWriterSide'), isUiLanguage(lang) ? lang : undefined);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requestCoordinateText } from './requestCoordinate.js';
|
|
1
2
|
import { displayUntrusted } from './displayUntrusted.js';
|
|
2
3
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
3
4
|
import { appendOwnElement } from './ownKey.js';
|
|
@@ -162,7 +163,7 @@ export function hooksEntryUnreadKeys(event, entry, notRead) {
|
|
|
162
163
|
return unreadOf(raw, carried, own(carried, 'type') === 'command' ? READER_COMMAND_WIRE_KEYS : [], notRead);
|
|
163
164
|
}
|
|
164
165
|
export function hooksKeyCoordinateText(path) {
|
|
165
|
-
return
|
|
166
|
+
return requestCoordinateText('settings', path, (seg) => labelOf(seg));
|
|
166
167
|
}
|
|
167
168
|
export const HOOK_SETTINGS_SOURCE_TEXT = Object.freeze({
|
|
168
169
|
policySettings: 'Managed settings',
|