@sema-agent/client-core 0.110.0 → 0.112.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 +244 -0
- package/README.md +59 -18
- package/dist/abortableSleep.d.ts +7 -0
- package/dist/abortableSleep.js +37 -0
- package/dist/adapt/arms.js +25 -4
- 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 +10 -10
- 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/agentSession/engineSessionBackgroundStop.js +2 -2
- 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/checkpointRowVerdict.d.ts +3 -0
- package/dist/checkpointRowVerdict.js +14 -1
- package/dist/compactionStatus.d.ts +9 -0
- package/dist/compactionStatus.js +29 -5
- package/dist/consoleCaPin.d.ts +136 -0
- package/dist/consoleCaPin.js +827 -0
- package/dist/controlRouter.js +2 -1
- package/dist/coreValuePorts.d.ts +39 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/decideReceipt.d.ts +2 -1
- package/dist/deviceRebind.js +3 -3
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +6 -0
- package/dist/effectiveFacts.d.ts +9 -0
- package/dist/effectiveFacts.js +33 -0
- package/dist/engineAddress.d.ts +1 -0
- package/dist/engineAddress.js +4 -1
- package/dist/engineCredentialRelease.d.ts +54 -0
- package/dist/engineCredentialRelease.js +146 -0
- package/dist/engineErrorCodes.d.ts +1 -0
- package/dist/engineErrorCodes.js +1 -0
- package/dist/engineHealthProbeVerdict.d.ts +24 -0
- package/dist/engineHealthProbeVerdict.js +123 -0
- package/dist/engineNoticeCodes.js +5 -7
- package/dist/engineRepoint.d.ts +12 -5
- package/dist/engineRepoint.js +44 -19
- package/dist/engineRowRef.d.ts +3 -0
- package/dist/engineRowRef.js +11 -1
- package/dist/engineSwapCrossing.d.ts +57 -0
- package/dist/engineSwapCrossing.js +297 -0
- package/dist/engineUnavailable.d.ts +45 -0
- package/dist/engineUnavailable.js +496 -0
- package/dist/engineUrl.js +4 -2
- package/dist/eventLeg.js +3 -3
- package/dist/gateFailureCodes.js +2 -2
- package/dist/generated/sdkFactTables.d.ts +2 -1
- package/dist/generated/sdkFactTables.js +14 -0
- package/dist/generated/settingsSchemaFns.d.ts +1 -0
- package/dist/generated/settingsSchemaFns.js +3 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +38 -9
- package/dist/generated/settingsSchemaTables.d.ts +56 -0
- package/dist/generated/settingsSchemaTables.js +19 -0
- package/dist/generated/settingsSchemaTypes.d.ts +23 -13
- package/dist/generated/settingsSchemaUrlShape.d.ts +1 -0
- package/dist/generated/settingsSchemaUrlShape.js +17 -0
- package/dist/hitl/approvalDelivery.d.ts +1 -0
- package/dist/hitl/approvalDelivery.js +1 -1
- package/dist/hitl/approvalResolution.d.ts +1 -1
- package/dist/hitl/approvalResolution.js +2 -1
- package/dist/hitl/askGateWire.js +5 -6
- package/dist/hitl/decisionRefusal.d.ts +6 -0
- package/dist/hitl/decisionRefusal.js +19 -10
- package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
- package/dist/hitl/decisionRefusalCarrier.js +348 -0
- package/dist/hitl/decisionSend.d.ts +7 -0
- package/dist/hitl/decisionSend.js +34 -12
- package/dist/hitl/editedApprovalAcceptance.js +1 -1
- 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 +8 -15
- package/dist/hitl/gateIdentity.d.ts +5 -0
- package/dist/hitl/gateIdentity.js +23 -0
- package/dist/hitl/hitlBridge.d.ts +6 -0
- package/dist/hitl/hitlBridge.js +10 -4
- package/dist/hitl/hitlHostSurface.d.ts +2 -1
- package/dist/hitl/hitlHostSurface.js +7 -2
- package/dist/hitl/localAllowRedemption.d.ts +70 -0
- package/dist/hitl/localAllowRedemption.js +276 -0
- package/dist/hitl/parkOwnership.js +2 -1
- package/dist/hitl/parkResolver.js +14 -4
- package/dist/hitl/persistedRulesWire.d.ts +16 -0
- package/dist/hitl/persistedRulesWire.js +70 -0
- package/dist/hitl/planReviewWire.d.ts +3 -0
- package/dist/hitl/planReviewWire.js +23 -6
- 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 +363 -0
- package/dist/hitl/sessionPolicyWire.js +2 -2
- package/dist/hitl/standingRows.d.ts +6 -2
- package/dist/hitl/standingRows.js +27 -2
- package/dist/hitl/toolApprovalWire.d.ts +30 -8
- package/dist/hitl/toolApprovalWire.js +264 -121
- package/dist/hooksReaderGenerations.js +1 -1
- package/dist/hooksWireCaps.js +3 -3
- package/dist/hostSettingNoticeArm.d.ts +3 -0
- package/dist/hostSettingNoticeArm.js +12 -0
- package/dist/hostTurnSettings.d.ts +3 -0
- package/dist/hostTurnSettings.js +38 -5
- package/dist/humanTurnRead.js +11 -1
- package/dist/i18n/messages.en.d.ts +292 -0
- package/dist/i18n/messages.en.js +298 -7
- package/dist/i18n/messages.zh.js +316 -6
- 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 +71 -20
- package/dist/index.js +44 -13
- package/dist/interactiveHalt.js +2 -1
- package/dist/interactiveInterrupt.js +20 -2
- package/dist/liveModelCatalog.d.ts +4 -0
- package/dist/liveModelCatalog.js +12 -3
- package/dist/localConfig/documents.d.ts +61 -0
- package/dist/localConfig/documents.js +51 -0
- package/dist/localConfig/kernel.d.ts +149 -0
- package/dist/localConfig/kernel.js +597 -0
- package/dist/localConfig/mcp/edit.d.ts +161 -0
- package/dist/localConfig/mcp/edit.js +846 -0
- package/dist/localConfig/mcp/servers.d.ts +165 -0
- package/dist/localConfig/mcp/servers.js +776 -0
- package/dist/localConfig/mcp/views.d.ts +170 -0
- package/dist/localConfig/mcp/views.js +429 -0
- package/dist/localConfig/modelPool.d.ts +262 -0
- package/dist/localConfig/modelPool.js +1489 -0
- package/dist/localConfig/modelPoolWords.d.ts +13 -0
- package/dist/localConfig/modelPoolWords.js +20 -0
- package/dist/localConfig/receiptShape.d.ts +7 -0
- package/dist/localConfig/receiptShape.js +135 -0
- package/dist/localConfig/settingsWrite.d.ts +127 -0
- package/dist/localConfig/settingsWrite.js +237 -0
- package/dist/localConfig/skills.d.ts +124 -0
- package/dist/localConfig/skills.js +397 -0
- package/dist/localConfig/skillsWords.d.ts +10 -0
- package/dist/localConfig/skillsWords.js +5 -0
- 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/mcpProbeWire.js +2 -1
- package/dist/mcpReconnect.js +3 -3
- package/dist/mcpWireCaps.js +1 -1
- package/dist/memoryVerbsWire.js +3 -2
- package/dist/model/engineModelWords.d.ts +3 -0
- package/dist/model/engineModelWords.js +13 -0
- package/dist/model/onboardJudgement.d.ts +14 -4
- package/dist/model/onboardJudgement.js +91 -139
- package/dist/model/subagentModelWord.d.ts +21 -2
- package/dist/model/subagentModelWord.js +100 -29
- package/dist/modelCapabilityProbe.js +3 -40
- package/dist/modelConfigGapNotice.d.ts +20 -0
- package/dist/modelConfigGapNotice.js +102 -0
- package/dist/modsKernelIdentity.js +2 -47
- package/dist/notifications.d.ts +19 -0
- package/dist/notifications.js +114 -12
- package/dist/ownKey.d.ts +7 -0
- package/dist/ownKey.js +71 -8
- package/dist/pendingUserRow.d.ts +4 -0
- package/dist/pendingUserRow.js +16 -0
- package/dist/permissionsDeclaration.d.ts +3 -1
- package/dist/permissionsDeclaration.js +33 -9
- package/dist/planReviewCardFacts.d.ts +3 -0
- package/dist/planReviewCardFacts.js +52 -2
- package/dist/pluginHooksWire.d.ts +9 -1
- package/dist/pluginHooksWire.js +40 -6
- package/dist/printToolResultFrame.js +4 -2
- package/dist/promptBlockedCopy.js +12 -7
- 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/request/taskRequest.js +10 -6
- package/dist/requestCoordinate.d.ts +1 -0
- package/dist/requestCoordinate.js +13 -0
- package/dist/resumeRefusalCopy.d.ts +3 -1
- package/dist/resumeRefusalCopy.js +12 -4
- package/dist/rewindArchiveReading.js +4 -4
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +1 -0
- package/dist/runLedgerSnapshot.js +3 -3
- package/dist/runPermissionModeSwitch.js +3 -4
- package/dist/scenarioRefusal.js +11 -13
- package/dist/scenarioSkills.js +11 -6
- package/dist/seam.d.ts +16 -2
- package/dist/seam.js +10 -0
- package/dist/seatContract.d.ts +259 -9
- package/dist/seatContract.js +444 -15
- package/dist/sessionCostReading.d.ts +70 -0
- package/dist/sessionCostReading.js +150 -0
- package/dist/sessionHooksRoster.d.ts +4 -0
- package/dist/sessionHooksRoster.js +158 -0
- package/dist/sessionIdSegment.d.ts +1 -0
- package/dist/sessionIdSegment.js +4 -1
- package/dist/sessionMemoryErase.js +2 -1
- package/dist/sessionMemoryStatus.js +2 -2
- package/dist/sessionReadRedaction.d.ts +7 -0
- package/dist/sessionReadRedaction.js +26 -0
- package/dist/sessionSyncFileHistory.js +8 -9
- package/dist/settingsHooksSalvage.js +2 -1
- package/dist/sha256Bytes.d.ts +1 -0
- package/dist/sha256Bytes.js +46 -0
- package/dist/skillOverrideChain.d.ts +83 -0
- package/dist/skillOverrideChain.js +378 -0
- package/dist/skillsWireCaps.d.ts +3 -0
- package/dist/skillsWireCaps.js +16 -1
- package/dist/sseIdleTriage.js +2 -1
- 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 +2 -1
- package/dist/subagentContentStore.d.ts +11 -0
- package/dist/subagentContentStore.js +28 -2
- package/dist/toolResult.d.ts +1 -0
- package/dist/toolResult.js +2 -0
- package/dist/turnFailurePresentation.js +4 -10
- package/dist/userAttachmentEnvelope.d.ts +2 -1
- package/dist/userAttachmentEnvelope.js +10 -0
- package/dist/wireErrorTriage.js +2 -1
- package/dist/wireFailureShape.d.ts +4 -0
- package/dist/wireFailureShape.js +141 -19
- package/dist/wireRefusalCopy.d.ts +6 -5
- package/dist/wireRefusalCopy.js +49 -92
- package/docs/INTEGRATION-CLIENTS.md +2718 -17
- 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
|
+
}
|
|
@@ -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
|
+
}
|
package/dist/sessionIdSegment.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export function isDotSegment(seg) {
|
|
2
|
+
return seg === '.' || seg === '..';
|
|
3
|
+
}
|
|
1
4
|
export function isSessionIdPathSegment(id) {
|
|
2
|
-
if (typeof id !== 'string' || id === '' || id
|
|
5
|
+
if (typeof id !== 'string' || id === '' || isDotSegment(id))
|
|
3
6
|
return false;
|
|
4
7
|
try {
|
|
5
8
|
encodeURIComponent(id);
|
|
@@ -2,6 +2,7 @@ import { isLoopbackWireUrl, resolveWireAuth } from './engineWireSdk.js';
|
|
|
2
2
|
import { INJECTED_WIRE_SETTLE_MS, connectionLostDetail, noAnswerDetailFrom, noAnswerKindOf, provablyNotSent, settleInjected } from './engineWireFor.js';
|
|
3
3
|
import { memoryEraseReplayPosture, readMemoryEraseReceipt } from './memoryEntriesWire.js';
|
|
4
4
|
import { normalizeWirePrincipal } from './principalWire.js';
|
|
5
|
+
import { MEMORY_CONTROL_PLANE_CORRUPT } from './engineErrorCodes.js';
|
|
5
6
|
import { isSessionIdPathSegment } from './sessionIdSegment.js';
|
|
6
7
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
7
8
|
const PRINCIPAL_HEADER = 'x-agent-principal';
|
|
@@ -359,7 +360,7 @@ function bandOfCode(code) {
|
|
|
359
360
|
return { unconfirmed: 'store_link_outside' };
|
|
360
361
|
case 'memory.scope_home_not_directory':
|
|
361
362
|
return { unconfirmed: 'store_home_not_directory' };
|
|
362
|
-
case
|
|
363
|
+
case MEMORY_CONTROL_PLANE_CORRUPT:
|
|
363
364
|
return { unconfirmed: 'control_plane_corrupt' };
|
|
364
365
|
case 'internal.error':
|
|
365
366
|
return { unconfirmed: 'engine_fault' };
|
|
@@ -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
|
+
}
|
|
@@ -66,18 +66,17 @@ export function isFileHistoryBlobMissing(err) {
|
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
const PUSH_ROW_BITS_SPEAKS = Object.freeze({
|
|
70
|
+
mirrored: false,
|
|
71
|
+
unsupported: false,
|
|
72
|
+
absent: false,
|
|
73
|
+
writer_side: true,
|
|
74
|
+
});
|
|
69
75
|
function pushRowBitsSpeaks(word) {
|
|
70
|
-
|
|
71
|
-
case 'writer_side':
|
|
72
|
-
return true;
|
|
73
|
-
case 'mirrored':
|
|
74
|
-
case 'unsupported':
|
|
75
|
-
case 'absent':
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
76
|
+
return PUSH_ROW_BITS_SPEAKS[word];
|
|
78
77
|
}
|
|
79
78
|
function isPushRowBitsWord(v) {
|
|
80
|
-
return
|
|
79
|
+
return Object.hasOwn(PUSH_ROW_BITS_SPEAKS, v);
|
|
81
80
|
}
|
|
82
81
|
export function sessionPushRowBitsNotice(result, lang) {
|
|
83
82
|
if (result === null || typeof result !== 'object')
|
|
@@ -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',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sha256BytesHex(msg: Uint8Array): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function sha256BytesHex(msg) {
|
|
2
|
+
const k = [
|
|
3
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
4
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
5
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
6
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
7
|
+
];
|
|
8
|
+
const h = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];
|
|
9
|
+
const len = msg.length;
|
|
10
|
+
const padded = new Uint8Array(((len + 8) >>> 6) * 64 + 64);
|
|
11
|
+
padded.set(msg);
|
|
12
|
+
padded[len] = 0x80;
|
|
13
|
+
const view = new DataView(padded.buffer);
|
|
14
|
+
view.setUint32(padded.length - 8, Math.floor(len / 0x20000000));
|
|
15
|
+
view.setUint32(padded.length - 4, (len << 3) >>> 0);
|
|
16
|
+
const w = new Array(64).fill(0);
|
|
17
|
+
const rotr = (x, n) => (x >>> n) | (x << (32 - n));
|
|
18
|
+
for (let off = 0; off < padded.length; off += 64) {
|
|
19
|
+
for (let t = 0; t < 16; t++)
|
|
20
|
+
w[t] = view.getUint32(off + t * 4);
|
|
21
|
+
for (let t = 16; t < 64; t++) {
|
|
22
|
+
const x = w[t - 15] ?? 0;
|
|
23
|
+
const y = w[t - 2] ?? 0;
|
|
24
|
+
const s0 = rotr(x, 7) ^ rotr(x, 18) ^ (x >>> 3);
|
|
25
|
+
const s1 = rotr(y, 17) ^ rotr(y, 19) ^ (y >>> 10);
|
|
26
|
+
w[t] = ((w[t - 16] ?? 0) + s0 + (w[t - 7] ?? 0) + s1) | 0;
|
|
27
|
+
}
|
|
28
|
+
let [a, b, c, d, e, f, g, hh] = h;
|
|
29
|
+
for (let t = 0; t < 64; t++) {
|
|
30
|
+
const t1 = (hh + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + ((e & f) ^ (~e & g)) + (k[t] ?? 0) + (w[t] ?? 0)) | 0;
|
|
31
|
+
const t2 = ((rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) | 0;
|
|
32
|
+
hh = g;
|
|
33
|
+
g = f;
|
|
34
|
+
f = e;
|
|
35
|
+
e = (d + t1) | 0;
|
|
36
|
+
d = c;
|
|
37
|
+
c = b;
|
|
38
|
+
b = a;
|
|
39
|
+
a = (t1 + t2) | 0;
|
|
40
|
+
}
|
|
41
|
+
const next = [a, b, c, d, e, f, g, hh];
|
|
42
|
+
for (let i = 0; i < 8; i++)
|
|
43
|
+
h[i] = ((h[i] ?? 0) + (next[i] ?? 0)) | 0;
|
|
44
|
+
}
|
|
45
|
+
return h.map((x) => (x >>> 0).toString(16).padStart(8, '0')).join('');
|
|
46
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { SettingsDocument } from './host.js';
|
|
2
|
+
export declare const SKILL_OVERRIDE_STATES: readonly ["on", "name-only", "user-invocable-only", "off"];
|
|
3
|
+
export type SkillOverrideState = (typeof SKILL_OVERRIDE_STATES)[number];
|
|
4
|
+
export declare const SKILL_ORIGINS: readonly ["skills", "synced", "commands", "mcp", "plugin", "builtin", "bundled"];
|
|
5
|
+
export type SkillOrigin = (typeof SKILL_ORIGINS)[number];
|
|
6
|
+
export declare const SKILL_OVERRIDE_LAYERS: readonly ["policySettings", "flagSettings", "localSettings", "projectSettings", "userSettings"];
|
|
7
|
+
export type SkillOverrideLayer = (typeof SKILL_OVERRIDE_LAYERS)[number];
|
|
8
|
+
type PlainLayer = 'localSettings' | 'projectSettings' | 'userSettings';
|
|
9
|
+
export declare const SKILL_OVERRIDE_DECIDERS: readonly ["policySettings", "flagSettings", "localSettings", "projectSettings", "userSettings", "session", "default", "plugin", "builtin_clamp", "hidden_behind_plugin"];
|
|
10
|
+
export type SkillOverrideDecider = (typeof SKILL_OVERRIDE_DECIDERS)[number];
|
|
11
|
+
export declare const SKILL_OVERRIDE_LOCK_SOURCES: readonly ["policy", "flag", "plugin", "skill-author", "reserved-name"];
|
|
12
|
+
export type SkillOverrideLockSource = (typeof SKILL_OVERRIDE_LOCK_SOURCES)[number];
|
|
13
|
+
export interface SkillSyncedName {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly bare: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SkillOverrideSubject {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly origin: SkillOrigin;
|
|
20
|
+
readonly unqualifiedName?: string;
|
|
21
|
+
readonly bareNameReserved?: boolean;
|
|
22
|
+
readonly aliases?: readonly string[];
|
|
23
|
+
readonly mcpLabels?: readonly string[];
|
|
24
|
+
readonly reservedLabels?: readonly string[];
|
|
25
|
+
readonly syncedNames?: readonly SkillSyncedName[];
|
|
26
|
+
readonly followsSyncedSkillState?: boolean;
|
|
27
|
+
readonly disableModelInvocation?: boolean;
|
|
28
|
+
readonly hiddenBehindPlugin?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface SkillOverrideLayers {
|
|
31
|
+
readonly policySettings?: SettingsDocument | null;
|
|
32
|
+
readonly flagSettings?: SettingsDocument | null;
|
|
33
|
+
readonly localSettings?: SettingsDocument | null;
|
|
34
|
+
readonly projectSettings?: SettingsDocument | null;
|
|
35
|
+
readonly userSettings?: SettingsDocument | null;
|
|
36
|
+
readonly session?: {
|
|
37
|
+
readonly [name: string]: string;
|
|
38
|
+
} | null;
|
|
39
|
+
readonly disabledSources?: readonly PlainLayer[];
|
|
40
|
+
readonly bundledSkillsDisabledByEnv?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface SkillOverrideEffective {
|
|
43
|
+
readonly value: SkillOverrideState;
|
|
44
|
+
readonly decidedBy: SkillOverrideDecider;
|
|
45
|
+
}
|
|
46
|
+
export interface SkillOverrideLock {
|
|
47
|
+
readonly source: SkillOverrideLockSource;
|
|
48
|
+
readonly value: SkillOverrideState;
|
|
49
|
+
}
|
|
50
|
+
export interface ShapedSkillSubject {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly origin: SkillOrigin;
|
|
53
|
+
readonly unqualifiedName: string | undefined;
|
|
54
|
+
readonly bareNameReserved: boolean;
|
|
55
|
+
readonly aliases: readonly string[];
|
|
56
|
+
readonly mcpLabels: readonly string[];
|
|
57
|
+
readonly reservedLabels: readonly string[];
|
|
58
|
+
readonly syncedNames: readonly SkillSyncedName[];
|
|
59
|
+
readonly followsSyncedSkillState: boolean;
|
|
60
|
+
readonly disableModelInvocation: boolean;
|
|
61
|
+
readonly hiddenBehindPlugin: boolean;
|
|
62
|
+
}
|
|
63
|
+
export declare function shapeSkillSubject(v: SkillOverrideSubject | null | undefined): ShapedSkillSubject | undefined;
|
|
64
|
+
export interface ShapedSkillLayers {
|
|
65
|
+
readonly docs: {
|
|
66
|
+
readonly [L in SkillOverrideLayer]: object | undefined;
|
|
67
|
+
};
|
|
68
|
+
readonly session: object | undefined;
|
|
69
|
+
readonly enabled: (layer: SkillOverrideLayer) => boolean;
|
|
70
|
+
readonly bundledDisabled: boolean;
|
|
71
|
+
}
|
|
72
|
+
export declare function shapeSkillLayers(v: SkillOverrideLayers | null | undefined): ShapedSkillLayers;
|
|
73
|
+
export declare function bareNameOf(s: ShapedSkillSubject): string | undefined;
|
|
74
|
+
export declare function secondaryNamesOf(s: ShapedSkillSubject): string[];
|
|
75
|
+
export declare function effectiveOfShaped(L: ShapedSkillLayers, s: ShapedSkillSubject): SkillOverrideEffective;
|
|
76
|
+
export declare function lockOfShaped(L: ShapedSkillLayers, s: ShapedSkillSubject): SkillOverrideLock | undefined;
|
|
77
|
+
export declare function skillOverrideEffectiveOf(layers: SkillOverrideLayers, skill: SkillOverrideSubject): SkillOverrideEffective | undefined;
|
|
78
|
+
export declare function skillOverrideLockOf(layers: SkillOverrideLayers, skill: SkillOverrideSubject): SkillOverrideLock | undefined;
|
|
79
|
+
export declare function ownValueIn(ov: object | undefined, s: ShapedSkillSubject): SkillOverrideState | undefined;
|
|
80
|
+
export declare function stateAt(ov: object | undefined, key: string | undefined): SkillOverrideState | undefined;
|
|
81
|
+
export declare function lowerTierOf(L: ShapedSkillLayers, s: ShapedSkillSubject, target: 'localSettings' | 'userSettings', skipTargetBare: boolean): SkillOverrideState | undefined;
|
|
82
|
+
export declare function withLayerDoc(L: ShapedSkillLayers, layer: SkillOverrideLayer, doc: SettingsDocument): ShapedSkillLayers;
|
|
83
|
+
export {};
|