@sema-agent/client-core 0.90.0 → 0.92.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 +365 -0
- package/README.md +48 -32
- package/dist/adapt/arms.js +13 -12
- package/dist/adapt/panelTasks.d.ts +0 -2
- package/dist/adapt/panelTasks.js +6 -26
- package/dist/adapt.js +2 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +0 -2
- package/dist/adapter/activeRunSelfHeal.js +5 -27
- package/dist/adapter/downstream/eventToSdkMessage.js +4 -2
- package/dist/adapter/downstream/terminalToSdkResult.js +16 -7
- package/dist/adapter/downstream/wiringManifestView.d.ts +6 -0
- package/dist/adapter/downstream/wiringManifestView.js +16 -0
- package/dist/adapter/runStream.js +39 -20
- package/dist/askSurvivesStandingAnswer.d.ts +13 -0
- package/dist/askSurvivesStandingAnswer.js +53 -0
- package/dist/attachmentSeatCapability.d.ts +11 -0
- package/dist/attachmentSeatCapability.js +27 -0
- package/dist/attachmentsWireCaps.d.ts +9 -0
- package/dist/attachmentsWireCaps.js +74 -21
- package/dist/autoModeUnavailable.js +3 -2
- package/dist/cloudConfigWireCaps.js +5 -4
- package/dist/compensations.js +13 -17
- package/dist/controlRouter.d.ts +32 -25
- package/dist/controlRouter.js +166 -63
- package/dist/coreValuePorts.d.ts +4 -2
- package/dist/coreValuePorts.js +5 -0
- package/dist/decideFailureNote.js +7 -3
- package/dist/decideReceipt.d.ts +9 -0
- package/dist/decideReceipt.js +62 -1
- package/dist/disableSkillsWire.d.ts +1 -0
- package/dist/disableSkillsWire.js +8 -1
- package/dist/displayUntrusted.js +155 -5
- package/dist/effectiveFacts.d.ts +14 -4
- package/dist/effectiveFacts.js +45 -5
- package/dist/engineAgentAbsence.js +2 -1
- package/dist/engineCapReader.js +16 -10
- package/dist/engineCapsCache.d.ts +5 -1
- package/dist/engineCapsCache.js +69 -8
- package/dist/engineClosedSets.d.ts +2 -0
- package/dist/engineClosedSets.js +3 -0
- package/dist/engineErrorCodes.d.ts +17 -0
- package/dist/engineErrorCodes.js +47 -0
- package/dist/engineNoticeCodes.d.ts +14 -0
- package/dist/engineNoticeCodes.js +71 -0
- package/dist/executionLaneCapability.js +2 -0
- package/dist/gateOutcome.js +2 -17
- package/dist/gateVocabulary.d.ts +2 -4
- package/dist/gateVocabulary.js +3 -11
- package/dist/generated/engineFactTables.d.ts +27 -0
- package/dist/generated/engineFactTables.js +128 -0
- package/dist/generated/engineNoticeTables.js +3 -0
- package/dist/generated/settingsSchemaTables.d.ts +8 -0
- package/dist/generated/settingsSchemaTables.js +40 -0
- package/dist/hitl/allowRuleShadow.d.ts +21 -0
- package/dist/hitl/allowRuleShadow.js +167 -0
- package/dist/hitl/askClassPair.d.ts +14 -0
- package/dist/hitl/askClassPair.js +42 -0
- package/dist/hitl/askGateWire.d.ts +1 -1
- package/dist/hitl/askGateWire.js +2 -1
- package/dist/hitl/askSurvivesPosture.d.ts +5 -0
- package/dist/hitl/askSurvivesPosture.js +17 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +21 -0
- package/dist/hitl/automaticAnswerVerdict.js +143 -0
- package/dist/hitl/crashConverged.d.ts +8 -0
- package/dist/hitl/crashConverged.js +58 -1
- package/dist/hitl/crashConvergedNotice.d.ts +4 -0
- package/dist/hitl/crashConvergedNotice.js +57 -0
- package/dist/hitl/frameRouter.d.ts +2 -0
- package/dist/hitl/frameRouter.js +66 -14
- package/dist/hitl/gateLedger.d.ts +6 -0
- package/dist/hitl/gateLedger.js +34 -5
- package/dist/hitl/hitlBridge.d.ts +7 -4
- package/dist/hitl/hitlHostSurface.d.ts +2 -0
- package/dist/hitl/hitlHostSurface.js +7 -0
- package/dist/hitl/livePendingAsk.js +24 -5
- package/dist/hitl/parkResolver.d.ts +7 -2
- package/dist/hitl/parkResolver.js +21 -7
- package/dist/hitl/persistedRulesWire.d.ts +4 -1
- package/dist/hitl/persistedRulesWire.js +9 -2
- package/dist/hitl/planReviewWire.d.ts +1 -1
- package/dist/hitl/planReviewWire.js +19 -5
- package/dist/hitl/replayedApproval.d.ts +21 -0
- package/dist/hitl/replayedApproval.js +89 -0
- package/dist/hitl/sessionPolicyDeliverable.js +20 -2
- package/dist/hitl/sessionPolicyWire.d.ts +13 -0
- package/dist/hitl/sessionPolicyWire.js +75 -2
- package/dist/hitl/suspendedReopen.js +2 -2
- package/dist/hitl/toolApprovalWire.d.ts +9 -1
- package/dist/hitl/toolApprovalWire.js +40 -40
- package/dist/hookMatcherVerdict.d.ts +29 -0
- package/dist/hookMatcherVerdict.js +266 -0
- package/dist/humanTurn.d.ts +91 -0
- package/dist/humanTurn.js +252 -0
- package/dist/humanTurnRead.d.ts +105 -0
- package/dist/humanTurnRead.js +331 -0
- package/dist/index.d.ts +38 -11
- package/dist/index.js +27 -8
- package/dist/inheritEnvWire.js +4 -5
- package/dist/liveModelCatalog.d.ts +2 -0
- package/dist/liveModelCatalog.js +51 -3
- package/dist/mcpLiveness.js +2 -1
- package/dist/memoryVerbsWire.d.ts +1 -1
- package/dist/memoryVerbsWire.js +3 -0
- package/dist/model/catalog.js +2 -1
- package/dist/model/providerPresets.d.ts +3 -1
- package/dist/model/tierVocabulary.d.ts +2 -1
- package/dist/model/tierVocabulary.js +3 -8
- package/dist/peerFrames.js +2 -2
- package/dist/permissionRuleIssue.d.ts +1 -1
- package/dist/permissionRuleIssue.js +31 -9
- package/dist/permissionsAllowGrantCapability.d.ts +2 -1
- package/dist/permissionsAllowGrantCapability.js +11 -2
- package/dist/permissionsDeclaration.d.ts +29 -0
- package/dist/permissionsDeclaration.js +155 -66
- package/dist/pluginHooksWire.js +2 -11
- package/dist/promptDelivery.d.ts +11 -3
- package/dist/promptDelivery.js +164 -29
- package/dist/promptProfileWireCaps.d.ts +2 -1
- package/dist/protocolSegment.d.ts +9 -0
- package/dist/protocolSegment.js +28 -0
- package/dist/providerRejection.d.ts +1 -0
- package/dist/providerRejection.js +20 -0
- package/dist/readDenyTiers.d.ts +10 -0
- package/dist/readDenyTiers.js +29 -0
- package/dist/request/taskRequest.js +3 -17
- package/dist/resumeRefusalCopy.d.ts +11 -0
- package/dist/resumeRefusalCopy.js +61 -4
- package/dist/rewindArchiveCapability.js +4 -4
- package/dist/rewindWireCaps.d.ts +2 -1
- package/dist/rewindWireCaps.js +19 -2
- package/dist/ruleCompileVerdict.d.ts +2 -0
- package/dist/ruleCompileVerdict.js +13 -0
- package/dist/ruleRemovalConsequence.d.ts +2 -1
- package/dist/runCancelContext.d.ts +12 -0
- package/dist/runCancelContext.js +83 -1
- package/dist/seam.d.ts +2 -0
- package/dist/seam.js +1 -1
- package/dist/seatContract.d.ts +2 -1
- package/dist/sessionMemoryStatus.d.ts +2 -4
- package/dist/sessionSyncFileHistoryCapability.d.ts +18 -0
- package/dist/sessionSyncFileHistoryCapability.js +50 -0
- package/dist/skillToolListsCapability.d.ts +18 -0
- package/dist/skillToolListsCapability.js +50 -0
- package/dist/sqlEngineCapability.js +1 -8
- package/dist/steerPriorityCapability.d.ts +18 -0
- package/dist/steerPriorityCapability.js +80 -0
- package/dist/steerReceipt.d.ts +9 -0
- package/dist/steerReceipt.js +25 -0
- package/dist/subagent/engineSubagentSteer.js +2 -9
- package/dist/supportFloor.js +2 -2
- package/dist/taskRequestWords.d.ts +7 -1
- package/dist/taskRequestWords.js +18 -8
- package/dist/toolHistoryBadTurn.d.ts +1 -0
- package/dist/toolHistoryBadTurn.js +89 -0
- package/dist/toolHistoryMismatch.d.ts +2 -1
- package/dist/toolHistoryMismatch.js +19 -6
- package/dist/toolResult.d.ts +8 -0
- package/dist/toolResult.js +47 -3
- package/dist/types/engineState.d.ts +2 -12
- package/dist/userAttachmentEnvelope.d.ts +61 -0
- package/dist/userAttachmentEnvelope.js +204 -0
- package/dist/userInvokedSkillsCapability.d.ts +18 -0
- package/dist/userInvokedSkillsCapability.js +50 -0
- package/dist/wireFailureShape.d.ts +3 -0
- package/dist/wireFailureShape.js +8 -0
- package/dist/wireRefusalCopy.d.ts +6 -0
- package/dist/wireRefusalCopy.js +26 -3
- package/dist/workflowsJournalCapability.d.ts +18 -0
- package/dist/workflowsJournalCapability.js +50 -0
- package/dist/writeProtectionCapability.d.ts +2 -4
- package/docs/INTEGRATION-CLIENTS.md +1489 -16
- package/package.json +3 -3
|
@@ -643,6 +643,76 @@ export function userInputUndrainedNotice(facts) {
|
|
|
643
643
|
}
|
|
644
644
|
return unrecognizedUndrainedSentence(n, kind);
|
|
645
645
|
}
|
|
646
|
+
export function readTurnInterrupted(notice) {
|
|
647
|
+
return guardedRead(notice, readTurnInterruptedOf);
|
|
648
|
+
}
|
|
649
|
+
function readTurnInterruptedOf(notice) {
|
|
650
|
+
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
651
|
+
return undefined;
|
|
652
|
+
const n = notice;
|
|
653
|
+
if (ownSeat(n, 'code') !== 'task.turn_interrupted')
|
|
654
|
+
return undefined;
|
|
655
|
+
const d = ownSeat(n, 'detail');
|
|
656
|
+
if (typeof d !== 'object' || d === null || Array.isArray(d))
|
|
657
|
+
return undefined;
|
|
658
|
+
const o = d;
|
|
659
|
+
const causeRaw = ownSeat(o, 'cause');
|
|
660
|
+
const cause = nonEmpty(causeRaw);
|
|
661
|
+
const inputId = nonEmpty(ownSeat(o, 'inputId'));
|
|
662
|
+
const lane = causeRaw === undefined && inputId !== undefined ? 'input_now' : cause === 'user_halt' ? 'user_halt' : 'unrecognized';
|
|
663
|
+
const sessionId = nonEmpty(optionalOwnSeat(o, 'sessionId'));
|
|
664
|
+
const runId = nonEmpty(optionalOwnSeat(o, 'runId'));
|
|
665
|
+
const taskId = nonEmpty(optionalOwnSeat(o, 'taskId'));
|
|
666
|
+
const actorId = nonEmpty(optionalOwnSeat(o, 'actorId'));
|
|
667
|
+
return {
|
|
668
|
+
lane,
|
|
669
|
+
...(lane === 'input_now' && inputId !== undefined ? { inputId } : {}),
|
|
670
|
+
...(cause !== undefined ? { cause } : {}),
|
|
671
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
672
|
+
...(runId !== undefined ? { runId } : {}),
|
|
673
|
+
...(taskId !== undefined ? { taskId } : {}),
|
|
674
|
+
...(actorId !== undefined ? { actorId } : {}),
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const TURN_INTERRUPTED_SENTENCE = Object.freeze({
|
|
678
|
+
input_now: 'Your message interrupted the running turn — tool calls that had already finished keep their results, and the run continues with your message first.',
|
|
679
|
+
user_halt: 'You stopped the run — the running turn was cut, and tool calls that had already finished keep their results.',
|
|
680
|
+
unrecognized: 'A running turn was cut for a reason this version does not recognise — tool calls that had already finished keep their results.',
|
|
681
|
+
});
|
|
682
|
+
export function turnInterruptedNotice(facts) {
|
|
683
|
+
try {
|
|
684
|
+
if (facts === null || typeof facts !== 'object' || Array.isArray(facts) || !Object.hasOwn(facts, 'lane'))
|
|
685
|
+
return undefined;
|
|
686
|
+
const lane = facts.lane;
|
|
687
|
+
return typeof lane === 'string' && Object.hasOwn(TURN_INTERRUPTED_SENTENCE, lane)
|
|
688
|
+
? TURN_INTERRUPTED_SENTENCE[lane]
|
|
689
|
+
: undefined;
|
|
690
|
+
}
|
|
691
|
+
catch {
|
|
692
|
+
return undefined;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
export function steerCutVerdict(notice, messageId) {
|
|
696
|
+
let code;
|
|
697
|
+
try {
|
|
698
|
+
if (typeof notice !== 'object' || notice === null || Array.isArray(notice))
|
|
699
|
+
return 'not_a_cut';
|
|
700
|
+
code = ownSeat(notice, 'code');
|
|
701
|
+
}
|
|
702
|
+
catch {
|
|
703
|
+
return 'not_a_cut';
|
|
704
|
+
}
|
|
705
|
+
if (code !== 'task.turn_interrupted')
|
|
706
|
+
return 'not_a_cut';
|
|
707
|
+
const facts = readTurnInterrupted(notice);
|
|
708
|
+
if (facts === undefined || facts.lane === 'unrecognized')
|
|
709
|
+
return 'unattributed';
|
|
710
|
+
if (facts.lane === 'user_halt')
|
|
711
|
+
return 'user_halt';
|
|
712
|
+
if (typeof messageId !== 'string' || messageId.length === 0 || facts.inputId === undefined)
|
|
713
|
+
return 'unattributed';
|
|
714
|
+
return facts.inputId === messageId ? 'this_input' : 'other_input';
|
|
715
|
+
}
|
|
646
716
|
export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
|
|
647
717
|
'mcp.injection_dropped': readMcpInjectionDrop,
|
|
648
718
|
'delegation.ask_unresolvable': readAskUnresolvable,
|
|
@@ -663,6 +733,7 @@ export const ENGINE_NOTICE_FACT_READERS = Object.freeze({
|
|
|
663
733
|
'task.tool_turn_incomplete': readToolTurnIncomplete,
|
|
664
734
|
'task.user_steer_undrained': readUserInputUndrained,
|
|
665
735
|
'task.user_followup_undrained': readUserInputUndrained,
|
|
736
|
+
'task.turn_interrupted': readTurnInterrupted,
|
|
666
737
|
});
|
|
667
738
|
const _factReaderTablePin = true;
|
|
668
739
|
void _factReaderTablePin;
|
|
@@ -64,6 +64,8 @@ export function observedExecutionLane(baseUrl = engineWireTarget()?.baseUrl) {
|
|
|
64
64
|
export function toolsRunHereFromExecutionLane(reading, legacyInference) {
|
|
65
65
|
if (reading.kind === 'present')
|
|
66
66
|
return reading.view.toolsOnThisHost;
|
|
67
|
+
if (reading.kind === 'not_reported')
|
|
68
|
+
return false;
|
|
67
69
|
return legacyInference;
|
|
68
70
|
}
|
|
69
71
|
export function noOsSandboxOnThisHost(reading) {
|
package/dist/gateOutcome.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ccToolDenialKindForSettledBy, isCcToolDenialKind, isGateDeniedByWord } from './gateVocabulary.js';
|
|
2
2
|
import { GATE_PARKED_ERROR_CODE } from './engineErrorCodes.js';
|
|
3
|
-
import { CORE_MODE_RELEASE_REASONS } from './generated/engineFactTables.js';
|
|
3
|
+
import { CORE_MODE_RELEASE_REASONS, CORE_SETTLEMENT_KINDS } from './generated/engineFactTables.js';
|
|
4
4
|
function str(v) {
|
|
5
5
|
return typeof v === 'string' && v.length > 0 ? v : undefined;
|
|
6
6
|
}
|
|
@@ -8,22 +8,7 @@ export const GATE_MODE_RELEASE_REASON_WORDS = CORE_MODE_RELEASE_REASONS;
|
|
|
8
8
|
export function isGateModeReleaseReasonWord(v) {
|
|
9
9
|
return typeof v === 'string' && CORE_MODE_RELEASE_REASONS.includes(v);
|
|
10
10
|
}
|
|
11
|
-
export const SETTLEMENT_KIND_WORDS =
|
|
12
|
-
'human_allowed',
|
|
13
|
-
'human_refused',
|
|
14
|
-
'approval_window_expired',
|
|
15
|
-
'denial_limit_window_expired',
|
|
16
|
-
'park_sla_expired',
|
|
17
|
-
'no_approver',
|
|
18
|
-
'approver_unavailable',
|
|
19
|
-
'approver_error',
|
|
20
|
-
'approver_contract',
|
|
21
|
-
'presentation_failed',
|
|
22
|
-
'blanket_allow_refused',
|
|
23
|
-
'policy_allowed',
|
|
24
|
-
'policy_refused',
|
|
25
|
-
'task_aborted',
|
|
26
|
-
]);
|
|
11
|
+
export const SETTLEMENT_KIND_WORDS = CORE_SETTLEMENT_KINDS;
|
|
27
12
|
function readWho(v) {
|
|
28
13
|
if (typeof v !== 'object' || v === null || Array.isArray(v))
|
|
29
14
|
return undefined;
|
package/dist/gateVocabulary.d.ts
CHANGED
|
@@ -5,12 +5,11 @@ export type CcToolDenialKind = (typeof CC_TOOL_DENIAL_KINDS)[number];
|
|
|
5
5
|
export declare function isCcToolDenialKind(v: unknown): v is CcToolDenialKind;
|
|
6
6
|
export declare function isCcToolDenialKindADenial(v: unknown): boolean;
|
|
7
7
|
export declare function ccToolDenialKindForSettledBy(settledBy: unknown): CcToolDenialKind | undefined;
|
|
8
|
-
|
|
9
|
-
export type GateDeniedByWord = (typeof CORE_DENIED_BY_VALUES)[number] | (typeof RETIRED_DENIED_BY_WORDS)[number];
|
|
8
|
+
export type GateDeniedByWord = (typeof CORE_DENIED_BY_VALUES)[number];
|
|
10
9
|
export declare const GATE_DENIED_BY_WORDS: readonly GateDeniedByWord[];
|
|
11
10
|
export declare function isGateDeniedByWord(v: unknown): v is GateDeniedByWord;
|
|
12
11
|
export declare function gateDeniedByDetail(deniedBy: unknown): string;
|
|
13
|
-
export declare function askOriginDetail(origin: unknown,
|
|
12
|
+
export declare function askOriginDetail(origin: unknown, _message?: unknown): string;
|
|
14
13
|
export declare const RULE_STORE_UNREADABLE_KINDS: readonly ["store", "call"];
|
|
15
14
|
export type RuleStoreUnreadableKind = (typeof RULE_STORE_UNREADABLE_KINDS)[number];
|
|
16
15
|
export declare function isRuleStoreUnreadableKind(v: unknown): v is RuleStoreUnreadableKind;
|
|
@@ -19,4 +18,3 @@ export declare function mandatedApprovalDetail(): string;
|
|
|
19
18
|
export type ApprovalMandateWord = (typeof APPROVAL_MANDATE_WORDS)[number];
|
|
20
19
|
export declare function isApprovalMandateWord(v: unknown): v is ApprovalMandateWord;
|
|
21
20
|
export declare function approvalMandateDetail(word: ApprovalMandateWord): string;
|
|
22
|
-
export {};
|
package/dist/gateVocabulary.js
CHANGED
|
@@ -21,8 +21,7 @@ export function ccToolDenialKindForSettledBy(settledBy) {
|
|
|
21
21
|
return 'permission-rule';
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
export const GATE_DENIED_BY_WORDS = Object.freeze([...CORE_DENIED_BY_VALUES, ...RETIRED_DENIED_BY_WORDS]);
|
|
24
|
+
export const GATE_DENIED_BY_WORDS = Object.freeze([...CORE_DENIED_BY_VALUES]);
|
|
26
25
|
const _deniedByWordsPin = true;
|
|
27
26
|
void _deniedByWordsPin;
|
|
28
27
|
const DENIED_BY_SENTENCES = Object.freeze({
|
|
@@ -31,7 +30,6 @@ const DENIED_BY_SENTENCES = Object.freeze({
|
|
|
31
30
|
org: 'denied by an organization rule',
|
|
32
31
|
persisted_rule: 'denied by a persisted rule',
|
|
33
32
|
classifier: 'denied by the auto-mode classifier',
|
|
34
|
-
plan_mode: 'denied because plan mode only allows reads',
|
|
35
33
|
compliance: 'denied by a compliance lock',
|
|
36
34
|
write_protection: 'denied because the write landed on a write-protected path',
|
|
37
35
|
ask_resolution: 'denied when the approval was resolved',
|
|
@@ -46,7 +44,7 @@ export function gateDeniedByDetail(deniedBy) {
|
|
|
46
44
|
return DENIED_BY_SENTENCES[deniedBy];
|
|
47
45
|
}
|
|
48
46
|
const word = typeof deniedBy === 'string' && deniedBy.length > 0 ? deniedBy : '(none)';
|
|
49
|
-
return `denied by a layer this build does not know (${word}) — this build does not know this layer name
|
|
47
|
+
return `denied by a layer this build does not know (${word}) — this build does not know this layer name, so it cannot say which layer refused this call or why`;
|
|
50
48
|
}
|
|
51
49
|
const ASK_ORIGIN_SENTENCES = Object.freeze({
|
|
52
50
|
content_question: 'the tool itself asked you a question',
|
|
@@ -61,16 +59,10 @@ const ASK_ORIGIN_SENTENCES = Object.freeze({
|
|
|
61
59
|
safety_tighten: 'the gate tightened on this call’s own facts (network egress, irreversibility, or a protected write)',
|
|
62
60
|
policy: 'this deployment’s permission policy asks about this call',
|
|
63
61
|
});
|
|
64
|
-
|
|
65
|
-
export function askOriginDetail(origin, message) {
|
|
62
|
+
export function askOriginDetail(origin, _message) {
|
|
66
63
|
const known = typeof origin === 'string' && Object.hasOwn(ASK_ORIGIN_SENTENCES, origin)
|
|
67
64
|
? ASK_ORIGIN_SENTENCES[origin]
|
|
68
65
|
: undefined;
|
|
69
|
-
if (typeof origin === 'string' && ORIGIN_PREFERS_ENGINE_MESSAGE.has(origin)) {
|
|
70
|
-
const spoken = typeof message === 'string' ? message.trim() : '';
|
|
71
|
-
if (spoken.length > 0)
|
|
72
|
-
return spoken;
|
|
73
|
-
}
|
|
74
66
|
if (known !== undefined)
|
|
75
67
|
return known;
|
|
76
68
|
const word = typeof origin === 'string' && origin.length > 0 ? origin : '(none)';
|
|
@@ -10,3 +10,30 @@ export declare const CORE_ENGINE_CARD_TYPES: readonly string[];
|
|
|
10
10
|
export declare const CORE_TOOL_DECLARATION_CODES: readonly string[];
|
|
11
11
|
export declare const CORE_MODE_RELEASE_REASONS: readonly ["rule_unreadable"];
|
|
12
12
|
export declare const CORE_HOOK_TOOL_ALIASES: Readonly<Record<string, string>>;
|
|
13
|
+
export declare const CORE_ASK_EVIDENCE_ABSENCE_VALUES: readonly ["not_wired", "not_adjudicated", "unavailable", "no_match", "not_reported"];
|
|
14
|
+
export declare const CORE_SYSTEM_INJECTION_PRIORITIES: readonly ["now", "next", "later"];
|
|
15
|
+
export declare const CORE_READ_DENY_BUILTIN_TIERS: readonly ["credentials", "shell-history", "browser", "wallet", "agent-config"];
|
|
16
|
+
export declare const CORE_READ_DENY_DEFAULT_TIERS: readonly ["credentials", "agent-config"];
|
|
17
|
+
export interface CoreModeArbitrationRow {
|
|
18
|
+
readonly bypassImmune: boolean;
|
|
19
|
+
readonly classifierEligible: boolean;
|
|
20
|
+
readonly sandboxAdmission: boolean;
|
|
21
|
+
readonly ruleMayClear: boolean;
|
|
22
|
+
readonly hookAskFloor: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const CORE_MODE_ARBITRATION: Readonly<Record<"content_question" | "hook" | "ancestor" | "unverifiable_delete" | "transcript_write" | "org_rule" | "governance_unavailable" | "rule_unreadable" | "ask_rule" | "denial_limit_fallback" | "requires_user_interaction" | "operator_forced" | "shell_floor" | "write_protection_unresolved" | "probe" | "write_protection" | "tool_marks_mcp" | "tool_marks_a2a" | "policy_rra" | "artifact_shared_read" | "mode" | "unstated" | "ordinary", CoreModeArbitrationRow>>;
|
|
25
|
+
export declare const CORE_SKILL_GRANT_ORIGINS: readonly ["model", "user", "inherited"];
|
|
26
|
+
export declare const CORE_ALLOW_ENTRY_INERT_REASONS: readonly ["wildcard_all", "namespace_wildcard", "path_pattern", "domain", "content_unsupported", "grammar"];
|
|
27
|
+
export declare const CORE_ALLOW_RULE_MEMBERS: readonly ["hook", "deployment", "persisted", "skill", "request"];
|
|
28
|
+
export declare const CORE_RULE_TOOL_NAME_VERDICTS: readonly ["current", "retired", "unprefixed_namespace"];
|
|
29
|
+
export declare const CORE_SETTLEMENT_KINDS: readonly ["human_allowed", "human_refused", "approval_window_expired", "denial_limit_window_expired", "park_sla_expired", "no_approver", "approver_unavailable", "approver_error", "approver_contract", "presentation_failed", "blanket_allow_refused", "policy_allowed", "policy_refused", "task_aborted"];
|
|
30
|
+
export declare const CORE_CLASSIFIER_DENY_CAUSES: readonly ["unavailable", "parse_error"];
|
|
31
|
+
export declare const CORE_AUTO_MODE_UNAVAILABLE_CAUSES: readonly ["error", "timeout"];
|
|
32
|
+
export declare const CORE_DEFAULT_TIER_ORDER: readonly ["ultra", "max", "pro", "flash", "lite"];
|
|
33
|
+
export declare const CORE_CC_MODEL_TIER_ALIASES: Readonly<Record<"fable" | "mythos" | "opus" | "sonnet" | "haiku", (typeof CORE_DEFAULT_TIER_ORDER)[number]>>;
|
|
34
|
+
export declare const CORE_DURABLE_AGENT_HANDLE_RE: RegExp;
|
|
35
|
+
export declare const CORE_PERMISSION_MODE_CLASSES: readonly ["bypass", "prompting"];
|
|
36
|
+
export declare const CORE_MCP_LIVENESS_STATES: readonly ["reachable", "unreachable", "unknown"];
|
|
37
|
+
export declare const CORE_RULE_BEHAVIORS: readonly ["deny", "ask", "allow"];
|
|
38
|
+
export declare const CORE_MCP_IMAGE_MAX_BASE64: number;
|
|
39
|
+
export declare const CORE_MAX_PENDING_STEER_CHARS: number;
|
|
@@ -117,3 +117,131 @@ export const CORE_MODE_RELEASE_REASONS = Object.freeze([
|
|
|
117
117
|
export const CORE_HOOK_TOOL_ALIASES = Object.freeze(Object.assign(Object.create(null), Object.fromEntries([
|
|
118
118
|
["ListPeers", "ListAgents"],
|
|
119
119
|
])));
|
|
120
|
+
export const CORE_ASK_EVIDENCE_ABSENCE_VALUES = Object.freeze([
|
|
121
|
+
"not_wired",
|
|
122
|
+
"not_adjudicated",
|
|
123
|
+
"unavailable",
|
|
124
|
+
"no_match",
|
|
125
|
+
"not_reported",
|
|
126
|
+
]);
|
|
127
|
+
export const CORE_SYSTEM_INJECTION_PRIORITIES = Object.freeze([
|
|
128
|
+
"now",
|
|
129
|
+
"next",
|
|
130
|
+
"later",
|
|
131
|
+
]);
|
|
132
|
+
export const CORE_READ_DENY_BUILTIN_TIERS = Object.freeze([
|
|
133
|
+
"credentials",
|
|
134
|
+
"shell-history",
|
|
135
|
+
"browser",
|
|
136
|
+
"wallet",
|
|
137
|
+
"agent-config",
|
|
138
|
+
]);
|
|
139
|
+
export const CORE_READ_DENY_DEFAULT_TIERS = Object.freeze([
|
|
140
|
+
"credentials",
|
|
141
|
+
"agent-config",
|
|
142
|
+
]);
|
|
143
|
+
export const CORE_MODE_ARBITRATION = Object.freeze({
|
|
144
|
+
"content_question": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: true }),
|
|
145
|
+
"hook": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
146
|
+
"ancestor": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
147
|
+
"unverifiable_delete": Object.freeze({ bypassImmune: true, classifierEligible: true, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: true }),
|
|
148
|
+
"transcript_write": Object.freeze({ bypassImmune: false, classifierEligible: true, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: true }),
|
|
149
|
+
"org_rule": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
150
|
+
"governance_unavailable": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
151
|
+
"rule_unreadable": Object.freeze({ bypassImmune: false, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
152
|
+
"ask_rule": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: true }),
|
|
153
|
+
"denial_limit_fallback": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
154
|
+
"requires_user_interaction": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: true }),
|
|
155
|
+
"operator_forced": Object.freeze({ bypassImmune: true, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false }),
|
|
156
|
+
"shell_floor": Object.freeze({ bypassImmune: true, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false }),
|
|
157
|
+
"write_protection_unresolved": Object.freeze({ bypassImmune: true, classifierEligible: false, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: true }),
|
|
158
|
+
"probe": Object.freeze({ bypassImmune: false, classifierEligible: true, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
159
|
+
"write_protection": Object.freeze({ bypassImmune: false, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: true }),
|
|
160
|
+
"tool_marks_mcp": Object.freeze({ bypassImmune: false, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false }),
|
|
161
|
+
"tool_marks_a2a": Object.freeze({ bypassImmune: false, classifierEligible: true, sandboxAdmission: true, ruleMayClear: false, hookAskFloor: false }),
|
|
162
|
+
"policy_rra": Object.freeze({ bypassImmune: true, classifierEligible: true, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
163
|
+
"artifact_shared_read": Object.freeze({ bypassImmune: false, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: true }),
|
|
164
|
+
"mode": Object.freeze({ bypassImmune: false, classifierEligible: false, sandboxAdmission: false, ruleMayClear: false, hookAskFloor: false }),
|
|
165
|
+
"unstated": Object.freeze({ bypassImmune: false, classifierEligible: true, sandboxAdmission: false, ruleMayClear: true, hookAskFloor: false }),
|
|
166
|
+
"ordinary": Object.freeze({ bypassImmune: false, classifierEligible: true, sandboxAdmission: true, ruleMayClear: true, hookAskFloor: false }),
|
|
167
|
+
});
|
|
168
|
+
export const CORE_SKILL_GRANT_ORIGINS = Object.freeze([
|
|
169
|
+
"model",
|
|
170
|
+
"user",
|
|
171
|
+
"inherited",
|
|
172
|
+
]);
|
|
173
|
+
export const CORE_ALLOW_ENTRY_INERT_REASONS = Object.freeze([
|
|
174
|
+
"wildcard_all",
|
|
175
|
+
"namespace_wildcard",
|
|
176
|
+
"path_pattern",
|
|
177
|
+
"domain",
|
|
178
|
+
"content_unsupported",
|
|
179
|
+
"grammar",
|
|
180
|
+
]);
|
|
181
|
+
export const CORE_ALLOW_RULE_MEMBERS = Object.freeze([
|
|
182
|
+
"hook",
|
|
183
|
+
"deployment",
|
|
184
|
+
"persisted",
|
|
185
|
+
"skill",
|
|
186
|
+
"request",
|
|
187
|
+
]);
|
|
188
|
+
export const CORE_RULE_TOOL_NAME_VERDICTS = Object.freeze([
|
|
189
|
+
"current",
|
|
190
|
+
"retired",
|
|
191
|
+
"unprefixed_namespace",
|
|
192
|
+
]);
|
|
193
|
+
export const CORE_SETTLEMENT_KINDS = Object.freeze([
|
|
194
|
+
"human_allowed",
|
|
195
|
+
"human_refused",
|
|
196
|
+
"approval_window_expired",
|
|
197
|
+
"denial_limit_window_expired",
|
|
198
|
+
"park_sla_expired",
|
|
199
|
+
"no_approver",
|
|
200
|
+
"approver_unavailable",
|
|
201
|
+
"approver_error",
|
|
202
|
+
"approver_contract",
|
|
203
|
+
"presentation_failed",
|
|
204
|
+
"blanket_allow_refused",
|
|
205
|
+
"policy_allowed",
|
|
206
|
+
"policy_refused",
|
|
207
|
+
"task_aborted",
|
|
208
|
+
]);
|
|
209
|
+
export const CORE_CLASSIFIER_DENY_CAUSES = Object.freeze([
|
|
210
|
+
"unavailable",
|
|
211
|
+
"parse_error",
|
|
212
|
+
]);
|
|
213
|
+
export const CORE_AUTO_MODE_UNAVAILABLE_CAUSES = Object.freeze([
|
|
214
|
+
"error",
|
|
215
|
+
"timeout",
|
|
216
|
+
]);
|
|
217
|
+
export const CORE_DEFAULT_TIER_ORDER = Object.freeze([
|
|
218
|
+
"ultra",
|
|
219
|
+
"max",
|
|
220
|
+
"pro",
|
|
221
|
+
"flash",
|
|
222
|
+
"lite",
|
|
223
|
+
]);
|
|
224
|
+
export const CORE_CC_MODEL_TIER_ALIASES = Object.freeze({
|
|
225
|
+
"fable": "max",
|
|
226
|
+
"mythos": "max",
|
|
227
|
+
"opus": "pro",
|
|
228
|
+
"sonnet": "flash",
|
|
229
|
+
"haiku": "lite",
|
|
230
|
+
});
|
|
231
|
+
export const CORE_DURABLE_AGENT_HANDLE_RE = Object.freeze(/^a[0-9a-f]{6,32}$/);
|
|
232
|
+
export const CORE_PERMISSION_MODE_CLASSES = Object.freeze([
|
|
233
|
+
"bypass",
|
|
234
|
+
"prompting",
|
|
235
|
+
]);
|
|
236
|
+
export const CORE_MCP_LIVENESS_STATES = Object.freeze([
|
|
237
|
+
"reachable",
|
|
238
|
+
"unreachable",
|
|
239
|
+
"unknown",
|
|
240
|
+
]);
|
|
241
|
+
export const CORE_RULE_BEHAVIORS = Object.freeze([
|
|
242
|
+
"deny",
|
|
243
|
+
"ask",
|
|
244
|
+
"allow",
|
|
245
|
+
]);
|
|
246
|
+
export const CORE_MCP_IMAGE_MAX_BASE64 = 5242880;
|
|
247
|
+
export const CORE_MAX_PENDING_STEER_CHARS = 16000;
|
|
@@ -28,6 +28,7 @@ export const CORE_ENGINE_NOTICE_CODES = Object.freeze([
|
|
|
28
28
|
"permission.ask_released_by_mode",
|
|
29
29
|
"permission.read_deny_unapplied",
|
|
30
30
|
"permission.rule_store_unavailable",
|
|
31
|
+
"permission.allowed_tool_not_granted",
|
|
31
32
|
"peer.inbound_disposition",
|
|
32
33
|
"peer.held_settled",
|
|
33
34
|
"peer.idle_subscription",
|
|
@@ -115,6 +116,7 @@ export const CORE_NOTICE_AUDIENCE = Object.freeze({
|
|
|
115
116
|
"permission.ask_released_by_mode": "user",
|
|
116
117
|
"permission.read_deny_unapplied": "user",
|
|
117
118
|
"permission.rule_store_unavailable": "user",
|
|
119
|
+
"permission.allowed_tool_not_granted": "user",
|
|
118
120
|
"peer.inbound_disposition": "user",
|
|
119
121
|
"peer.held_settled": "user",
|
|
120
122
|
"peer.idle_subscription": "user",
|
|
@@ -208,6 +210,7 @@ export const CORE_NOTICE_MINTER = Object.freeze({
|
|
|
208
210
|
"permission.ask_released_by_mode": "engine",
|
|
209
211
|
"permission.read_deny_unapplied": "engine",
|
|
210
212
|
"permission.rule_store_unavailable": "engine",
|
|
213
|
+
"permission.allowed_tool_not_granted": "engine",
|
|
211
214
|
"peer.inbound_disposition": "engine",
|
|
212
215
|
"peer.held_settled": "engine",
|
|
213
216
|
"peer.idle_subscription": "engine",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const SETTINGS_ENGINE_OWNED_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "PreCompact", "PostCompact", "Stop", "StopFailure", "UserPromptSubmit"];
|
|
2
|
+
export declare const SETTINGS_SECRET_LITERAL_RE: RegExp;
|
|
3
|
+
export declare const SETTINGS_TIER_GROUP_NAME_RE: RegExp;
|
|
4
|
+
export declare const SETTINGS_BUDGET_NUMBER_KEYS: readonly ["maxBudgetUsd", "tpmLimit", "rpmLimit", "maxParallelRequests", "maxRunCostUsd", "maxIterations"];
|
|
5
|
+
export declare const SETTINGS_BUDGET_STRING_KEYS: readonly ["mode", "budgetDuration", "enforcement"];
|
|
6
|
+
export declare const SETTINGS_BUDGET_PER_MODEL_NUMBER_KEYS: readonly ["maxBudgetUsd", "tpmLimit", "rpmLimit"];
|
|
7
|
+
export declare const SETTINGS_MODEL_API_WORDS: readonly ["openai-completions", "anthropic-messages"];
|
|
8
|
+
export declare const SETTINGS_TOOL_NAME_MATCHER_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure"];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const SETTINGS_ENGINE_OWNED_HOOK_EVENTS = Object.freeze([
|
|
2
|
+
"PreToolUse",
|
|
3
|
+
"PostToolUse",
|
|
4
|
+
"PostToolUseFailure",
|
|
5
|
+
"PostToolBatch",
|
|
6
|
+
"PreCompact",
|
|
7
|
+
"PostCompact",
|
|
8
|
+
"Stop",
|
|
9
|
+
"StopFailure",
|
|
10
|
+
"UserPromptSubmit",
|
|
11
|
+
]);
|
|
12
|
+
export const SETTINGS_SECRET_LITERAL_RE = Object.freeze(/^(sk-|gh[opus]_|github_pat_|xox[baprse]-|xapp-|bearer\s|basic\s|eyJ[A-Za-z0-9_-]{10,}\.|AKIA[0-9A-Z]{12,}|AIza[0-9A-Za-z_-]{20,}|-----BEGIN[A-Z0-9 ]*PRIVATE KEY)/i);
|
|
13
|
+
export const SETTINGS_TIER_GROUP_NAME_RE = Object.freeze(/^[a-z0-9][a-z0-9._-]*$/i);
|
|
14
|
+
export const SETTINGS_BUDGET_NUMBER_KEYS = Object.freeze([
|
|
15
|
+
"maxBudgetUsd",
|
|
16
|
+
"tpmLimit",
|
|
17
|
+
"rpmLimit",
|
|
18
|
+
"maxParallelRequests",
|
|
19
|
+
"maxRunCostUsd",
|
|
20
|
+
"maxIterations",
|
|
21
|
+
]);
|
|
22
|
+
export const SETTINGS_BUDGET_STRING_KEYS = Object.freeze([
|
|
23
|
+
"mode",
|
|
24
|
+
"budgetDuration",
|
|
25
|
+
"enforcement",
|
|
26
|
+
]);
|
|
27
|
+
export const SETTINGS_BUDGET_PER_MODEL_NUMBER_KEYS = Object.freeze([
|
|
28
|
+
"maxBudgetUsd",
|
|
29
|
+
"tpmLimit",
|
|
30
|
+
"rpmLimit",
|
|
31
|
+
]);
|
|
32
|
+
export const SETTINGS_MODEL_API_WORDS = Object.freeze([
|
|
33
|
+
"openai-completions",
|
|
34
|
+
"anthropic-messages",
|
|
35
|
+
]);
|
|
36
|
+
export const SETTINGS_TOOL_NAME_MATCHER_EVENTS = Object.freeze([
|
|
37
|
+
"PreToolUse",
|
|
38
|
+
"PostToolUse",
|
|
39
|
+
"PostToolUseFailure",
|
|
40
|
+
]);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface ApprovalAllowRuleShadowMember {
|
|
2
|
+
readonly member?: string;
|
|
3
|
+
readonly known: boolean;
|
|
4
|
+
readonly entries?: readonly string[];
|
|
5
|
+
readonly omitted?: number;
|
|
6
|
+
readonly malformed?: true;
|
|
7
|
+
}
|
|
8
|
+
export interface AllowRuleShadowedWireMember {
|
|
9
|
+
readonly member: string;
|
|
10
|
+
readonly entries: readonly string[];
|
|
11
|
+
readonly omitted?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ApprovalAllowRuleShadow {
|
|
14
|
+
readonly source: 'allow_rule_shadowed' | 'legacy_shadowed_rule';
|
|
15
|
+
readonly members: readonly ApprovalAllowRuleShadowMember[];
|
|
16
|
+
readonly unreadable?: true;
|
|
17
|
+
}
|
|
18
|
+
export declare function readAllowRuleShadowFromWire(carrier: object | null | undefined, leg: 'frame' | 'row'): ApprovalAllowRuleShadow | undefined;
|
|
19
|
+
export declare function readApprovalAllowRuleShadow(card: object | null | undefined): ApprovalAllowRuleShadow | undefined;
|
|
20
|
+
export declare function approvalAllowRuleShadowed(card: object | null | undefined): boolean;
|
|
21
|
+
export declare function legacyShadowedRuleTextOf(r: ApprovalAllowRuleShadow | undefined): string | undefined;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { CORE_ALLOW_RULE_MEMBERS } from '../generated/engineFactTables.js';
|
|
2
|
+
const KNOWN_MEMBERS = new Set(CORE_ALLOW_RULE_MEMBERS);
|
|
3
|
+
function freezeMember(m) {
|
|
4
|
+
return Object.freeze({ ...m });
|
|
5
|
+
}
|
|
6
|
+
function unreadable() {
|
|
7
|
+
return Object.freeze({ source: 'allow_rule_shadowed', members: Object.freeze([]), unreadable: true });
|
|
8
|
+
}
|
|
9
|
+
function readMemberRecord(r) {
|
|
10
|
+
if (typeof r !== 'object' || r === null || Array.isArray(r))
|
|
11
|
+
return freezeMember({ known: false, malformed: true });
|
|
12
|
+
let malformed = false;
|
|
13
|
+
const rawMember = Object.hasOwn(r, 'member') ? r.member : undefined;
|
|
14
|
+
const member = typeof rawMember === 'string' && rawMember !== '' ? rawMember : undefined;
|
|
15
|
+
if (member === undefined)
|
|
16
|
+
malformed = true;
|
|
17
|
+
let entries;
|
|
18
|
+
const rawEntries = Object.hasOwn(r, 'entries') ? r.entries : undefined;
|
|
19
|
+
if (Array.isArray(rawEntries)) {
|
|
20
|
+
const length = rawEntries.length;
|
|
21
|
+
if (typeof length === 'number' && Number.isSafeInteger(length) && length >= 0) {
|
|
22
|
+
const out = [];
|
|
23
|
+
let ok = true;
|
|
24
|
+
for (let i = 0; i < length; i++) {
|
|
25
|
+
const d = Object.getOwnPropertyDescriptor(rawEntries, i);
|
|
26
|
+
if (d === undefined || !('value' in d)) {
|
|
27
|
+
ok = false;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
const e = d.value;
|
|
31
|
+
if (typeof e !== 'string') {
|
|
32
|
+
ok = false;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
out.push(e);
|
|
36
|
+
}
|
|
37
|
+
if (ok && rawEntries.length === length)
|
|
38
|
+
entries = Object.freeze(out);
|
|
39
|
+
else
|
|
40
|
+
malformed = true;
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
malformed = true;
|
|
44
|
+
}
|
|
45
|
+
else
|
|
46
|
+
malformed = true;
|
|
47
|
+
let omitted;
|
|
48
|
+
if (Object.hasOwn(r, 'omitted')) {
|
|
49
|
+
const o = r.omitted;
|
|
50
|
+
if (typeof o === 'number' && Number.isSafeInteger(o) && o > 0)
|
|
51
|
+
omitted = o;
|
|
52
|
+
else if (o !== undefined)
|
|
53
|
+
malformed = true;
|
|
54
|
+
}
|
|
55
|
+
return freezeMember({
|
|
56
|
+
...(member !== undefined ? { member } : {}),
|
|
57
|
+
known: member !== undefined && KNOWN_MEMBERS.has(member),
|
|
58
|
+
...(entries !== undefined ? { entries } : {}),
|
|
59
|
+
...(omitted !== undefined ? { omitted } : {}),
|
|
60
|
+
...(malformed ? { malformed: true } : {}),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function readNewKeyValue(raw) {
|
|
64
|
+
if (raw === undefined)
|
|
65
|
+
return undefined;
|
|
66
|
+
if (!Array.isArray(raw))
|
|
67
|
+
return unreadable();
|
|
68
|
+
const length = raw.length;
|
|
69
|
+
if (typeof length !== 'number' || !Number.isSafeInteger(length) || length <= 0)
|
|
70
|
+
return unreadable();
|
|
71
|
+
const members = [];
|
|
72
|
+
for (let i = 0; i < length; i++)
|
|
73
|
+
members.push(readMemberAt(raw, i));
|
|
74
|
+
if (raw.length !== length)
|
|
75
|
+
return unreadable();
|
|
76
|
+
return Object.freeze({ source: 'allow_rule_shadowed', members: Object.freeze(members) });
|
|
77
|
+
}
|
|
78
|
+
function readLegacyValue(raw) {
|
|
79
|
+
if (typeof raw !== 'string' || raw.trim() === '')
|
|
80
|
+
return undefined;
|
|
81
|
+
return Object.freeze({
|
|
82
|
+
source: 'legacy_shadowed_rule',
|
|
83
|
+
members: Object.freeze([freezeMember({ member: 'persisted', known: true, entries: Object.freeze([raw]) })]),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function ownValue(v, key) {
|
|
87
|
+
return Object.hasOwn(v, key) ? v[key] : undefined;
|
|
88
|
+
}
|
|
89
|
+
function keyValue(v, key) {
|
|
90
|
+
return v[key];
|
|
91
|
+
}
|
|
92
|
+
function readMemberAt(arr, i) {
|
|
93
|
+
const d = Object.getOwnPropertyDescriptor(arr, i);
|
|
94
|
+
return d !== undefined && 'value' in d ? readMemberRecord(d.value) : freezeMember({ known: false, malformed: true });
|
|
95
|
+
}
|
|
96
|
+
export function readAllowRuleShadowFromWire(carrier, leg) {
|
|
97
|
+
try {
|
|
98
|
+
if (typeof carrier !== 'object' || carrier === null)
|
|
99
|
+
return undefined;
|
|
100
|
+
let host = carrier;
|
|
101
|
+
if (leg === 'row') {
|
|
102
|
+
const rd = keyValue(carrier, 'riskDescriptor');
|
|
103
|
+
host = typeof rd === 'object' && rd !== null ? rd : undefined;
|
|
104
|
+
}
|
|
105
|
+
if (host === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
const fresh = readNewKeyValue(keyValue(host, 'allowRuleShadowed'));
|
|
108
|
+
if (fresh !== undefined)
|
|
109
|
+
return fresh;
|
|
110
|
+
return readLegacyValue(keyValue(host, leg === 'row' ? 'shadowedRule' : 'persistedRuleShadowed'));
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return unreadable();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function readStampedValue(raw) {
|
|
117
|
+
if (typeof raw !== 'object' || raw === null)
|
|
118
|
+
return unreadable();
|
|
119
|
+
const source = ownValue(raw, 'source');
|
|
120
|
+
const members = ownValue(raw, 'members');
|
|
121
|
+
if ((source !== 'allow_rule_shadowed' && source !== 'legacy_shadowed_rule') || !Array.isArray(members))
|
|
122
|
+
return unreadable();
|
|
123
|
+
const length = members.length;
|
|
124
|
+
if (typeof length !== 'number' || !Number.isSafeInteger(length))
|
|
125
|
+
return unreadable();
|
|
126
|
+
const out = [];
|
|
127
|
+
for (let i = 0; i < length; i++) {
|
|
128
|
+
const r = readMemberAt(members, i);
|
|
129
|
+
const d = Object.getOwnPropertyDescriptor(members, i);
|
|
130
|
+
const was = d !== undefined && 'value' in d && typeof d.value === 'object' && d.value !== null && d.value.malformed === true;
|
|
131
|
+
out.push(was && r.malformed !== true ? freezeMember({ ...r, malformed: true }) : r);
|
|
132
|
+
}
|
|
133
|
+
if (members.length !== length)
|
|
134
|
+
return unreadable();
|
|
135
|
+
return Object.freeze({
|
|
136
|
+
source,
|
|
137
|
+
members: Object.freeze(out),
|
|
138
|
+
...(ownValue(raw, 'unreadable') === true || out.length === 0 ? { unreadable: true } : {}),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export function readApprovalAllowRuleShadow(card) {
|
|
142
|
+
try {
|
|
143
|
+
if (typeof card !== 'object' || card === null)
|
|
144
|
+
return undefined;
|
|
145
|
+
const stamped = keyValue(card, 'allowRuleShadow');
|
|
146
|
+
if (stamped !== undefined)
|
|
147
|
+
return readStampedValue(stamped);
|
|
148
|
+
return readAllowRuleShadowFromWire(card, 'frame');
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return unreadable();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
export function approvalAllowRuleShadowed(card) {
|
|
155
|
+
return readApprovalAllowRuleShadow(card) !== undefined;
|
|
156
|
+
}
|
|
157
|
+
export function legacyShadowedRuleTextOf(r) {
|
|
158
|
+
if (r === undefined)
|
|
159
|
+
return undefined;
|
|
160
|
+
for (const m of r.members) {
|
|
161
|
+
if (m.member !== 'persisted' || m.entries === undefined)
|
|
162
|
+
continue;
|
|
163
|
+
const first = m.entries[0];
|
|
164
|
+
return typeof first === 'string' && first.trim() !== '' ? first : undefined;
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type AskClassPairReading = {
|
|
2
|
+
readonly state: 'pair';
|
|
3
|
+
readonly askClass: string;
|
|
4
|
+
readonly classes: readonly string[];
|
|
5
|
+
} | {
|
|
6
|
+
readonly state: 'absent';
|
|
7
|
+
} | {
|
|
8
|
+
readonly state: 'malformed';
|
|
9
|
+
};
|
|
10
|
+
export declare function readAskClassPairState(v: object | null | undefined): AskClassPairReading;
|
|
11
|
+
export declare function readAskClassPair(v: object | null | undefined): {
|
|
12
|
+
askClass: string;
|
|
13
|
+
classes: readonly string[];
|
|
14
|
+
} | undefined;
|