@sema-agent/client-core 0.105.0 → 0.107.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 +301 -0
- package/README.md +40 -21
- package/dist/adapt/arms.js +10 -1
- package/dist/adapter/activeRunSelfHeal.d.ts +21 -2
- package/dist/adapter/activeRunSelfHeal.js +129 -28
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +0 -5
- package/dist/adapter/downstream/eventToSdkMessage.js +20 -19
- package/dist/adapter/downstream/terminalToSdkResult.js +2 -3
- package/dist/adapter/downstream/wiringManifestView.d.ts +1 -3
- package/dist/adapter/downstream/wiringManifestView.js +0 -1
- package/dist/adapter/runStream.js +3 -4
- package/dist/approvalReachWire.d.ts +1 -0
- package/dist/approvalReachWire.js +4 -1
- package/dist/approvalSeat.d.ts +21 -0
- package/dist/approvalSeat.js +73 -0
- package/dist/assistantInbox.d.ts +2 -0
- package/dist/assistantInbox.js +3 -0
- package/dist/checkpointRowVerdict.d.ts +29 -0
- package/dist/checkpointRowVerdict.js +98 -0
- package/dist/coreValuePorts.d.ts +12 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/decideFailureNote.js +3 -1
- package/dist/decideReceipt.d.ts +9 -0
- package/dist/decideReceipt.js +29 -1
- package/dist/declared/supportFloorDeclared.js +2 -2
- package/dist/deviceRebind.d.ts +7 -0
- package/dist/deviceRebind.js +39 -5
- package/dist/displayUntrusted.d.ts +5 -3
- package/dist/displayUntrusted.js +50 -41
- package/dist/engineAddress.d.ts +3 -0
- package/dist/engineAddress.js +25 -0
- package/dist/engineDirectory.js +9 -17
- package/dist/engineErrorCodes.d.ts +8 -0
- package/dist/engineErrorCodes.js +8 -0
- package/dist/engineNoticeCodes.d.ts +38 -3
- package/dist/engineNoticeCodes.js +167 -11
- package/dist/engineRowRef.js +1 -1
- package/dist/errorSupplementRoles.js +4 -1
- package/dist/eventLeg.d.ts +2 -2
- package/dist/eventLeg.js +2 -1
- package/dist/executionLaneCapability.js +3 -2
- package/dist/executionLaneWords.d.ts +1 -0
- package/dist/executionLaneWords.js +3 -0
- package/dist/fleet/fleetProjection.js +26 -5
- package/dist/generated/engineFactTables.d.ts +2 -1
- package/dist/generated/engineFactTables.js +3 -1
- package/dist/generated/engineNoticeTables.js +28 -7
- package/dist/generated/sdkFactTables.d.ts +3 -0
- package/dist/generated/sdkFactTables.js +15 -0
- package/dist/generated/settingsSchemaFns.d.ts +11 -0
- package/dist/generated/settingsSchemaFns.js +2 -1
- package/dist/generated/settingsSchemaSafetyMergeSpec.js +1 -1
- package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -1
- package/dist/generated/settingsSchemaSettingsSources.js +22 -2
- package/dist/hitl/approvalLiveFace.d.ts +17 -0
- package/dist/hitl/approvalLiveFace.js +35 -0
- package/dist/hitl/approvalQueueRow.d.ts +21 -0
- package/dist/hitl/approvalQueueRow.js +69 -0
- package/dist/hitl/approvalResolution.d.ts +5 -1
- package/dist/hitl/approvalResolution.js +18 -1
- package/dist/hitl/approvalsFeed.d.ts +5 -4
- package/dist/hitl/approvalsFeed.js +39 -6
- package/dist/hitl/askParkRowRouting.d.ts +4 -3
- package/dist/hitl/askParkRowRouting.js +27 -3
- package/dist/hitl/automaticAnswerVerdict.js +13 -10
- package/dist/hitl/crashConverged.d.ts +5 -1
- package/dist/hitl/decisionConflict.js +2 -1
- package/dist/hitl/decisionRefusal.js +1 -1
- package/dist/hitl/decisionSend.d.ts +3 -0
- package/dist/hitl/decisionSend.js +32 -6
- package/dist/hitl/frameRouter.js +4 -5
- package/dist/hitl/hitlBridge.d.ts +6 -2
- package/dist/hitl/hitlBridge.js +53 -7
- package/dist/hitl/livePendingAsk.d.ts +5 -0
- package/dist/hitl/livePendingAsk.js +10 -3
- package/dist/hitl/parkOwnership.js +4 -5
- package/dist/hitl/parkResolver.js +9 -5
- package/dist/hitl/parkRowBirthWait.d.ts +7 -0
- package/dist/hitl/parkRowBirthWait.js +1 -1
- package/dist/hitl/parkRowDelegation.d.ts +6 -0
- package/dist/hitl/parkRowDelegation.js +33 -0
- package/dist/hitl/persistedRulesWire.d.ts +15 -3
- package/dist/hitl/persistedRulesWire.js +102 -20
- package/dist/hitl/planReviewCard.d.ts +2 -0
- package/dist/hitl/planReviewCard.js +21 -0
- package/dist/hitl/planReviewWire.d.ts +2 -2
- package/dist/hitl/planReviewWire.js +105 -38
- package/dist/hitl/sessionAllowRoute.d.ts +7 -0
- package/dist/hitl/sessionAllowRoute.js +49 -0
- package/dist/hitl/sessionPolicyWire.d.ts +1 -7
- package/dist/hitl/sessionPolicyWire.js +3 -43
- package/dist/hitl/standingRows.js +10 -10
- package/dist/hitl/subagentSource.d.ts +1 -0
- package/dist/hitl/subagentSource.js +13 -0
- package/dist/hitl/toolApprovalWire.d.ts +3 -2
- package/dist/hitl/toolApprovalWire.js +100 -44
- package/dist/hostSettingsSource.d.ts +4 -1
- package/dist/hostSettingsSource.js +11 -6
- package/dist/hostTurnSettings.d.ts +4 -5
- package/dist/hostTurnSettings.js +80 -19
- package/dist/i18n/messages.en.d.ts +41 -12
- package/dist/i18n/messages.en.js +42 -13
- package/dist/i18n/messages.zh.js +45 -13
- package/dist/index.d.ts +22 -2
- package/dist/index.js +12 -2
- package/dist/injectionLaneNotice.js +2 -1
- package/dist/liveInitToolFace.js +0 -1
- package/dist/liveModelCatalog.d.ts +15 -0
- package/dist/liveModelCatalog.js +40 -0
- package/dist/mcpWireCaps.js +1 -1
- package/dist/modelCapabilityProbe.js +66 -33
- package/dist/noticePresentation.js +2 -0
- package/dist/ownKey.d.ts +0 -1
- package/dist/ownKey.js +0 -2
- package/dist/permissionsDeclaration.d.ts +2 -2
- package/dist/permissionsDeclaration.js +12 -14
- package/dist/projectSeed.d.ts +39 -0
- package/dist/projectSeed.js +80 -0
- package/dist/promptDelivery.js +1 -1
- package/dist/replayBody.d.ts +7 -6
- package/dist/replayBody.js +62 -7
- package/dist/request/taskRequest.js +3 -4
- package/dist/ruleCompileVerdict.d.ts +0 -2
- package/dist/ruleCompileVerdict.js +0 -31
- package/dist/ruleRefusalSentence.js +0 -3
- package/dist/runReattachPolicy.d.ts +3 -0
- package/dist/runReattachPolicy.js +15 -2
- package/dist/runTerminal.js +30 -8
- package/dist/sandboxWire.d.ts +0 -3
- package/dist/sandboxWire.js +0 -9
- package/dist/sdkWireTransit.d.ts +1 -1
- package/dist/seam.d.ts +14 -7
- package/dist/seam.js +12 -0
- package/dist/seatContract.d.ts +58 -7
- package/dist/seatContract.js +135 -4
- package/dist/serverSupportRange.d.ts +18 -0
- package/dist/serverSupportRange.js +25 -0
- package/dist/sessionEngine.d.ts +156 -0
- package/dist/sessionEngine.js +464 -0
- package/dist/sessionMap.d.ts +11 -1
- package/dist/sessionMap.js +35 -9
- package/dist/sessionMemorySync.d.ts +31 -0
- package/dist/sessionMemorySync.js +95 -0
- package/dist/sessionRowTag.d.ts +4 -0
- package/dist/sessionRowTag.js +18 -0
- package/dist/settingsLayerAdmission.d.ts +1 -0
- package/dist/settingsLayerAdmission.js +4 -1
- package/dist/toolResult.js +1 -1
- package/dist/wireRefusalCopy.d.ts +6 -1
- package/dist/wireRefusalCopy.js +9 -7
- package/docs/INTEGRATION-CLIENTS.md +1393 -18
- package/package.json +5 -5
|
@@ -4,6 +4,7 @@ import { readApprovalCardWord, readRuleOffers } from './toolApprovalWire.js';
|
|
|
4
4
|
import { CORE_SKILL_TOOL_NAME } from '../generated/toolNameTables.js';
|
|
5
5
|
import { toolPermissionRequestIdDomain } from '../seatContract.js';
|
|
6
6
|
import { permissionsDeclarationReport } from '../permissionsDeclaration.js';
|
|
7
|
+
import { readCardUnreadableEvidence, sessionAllowCardReadable, sessionAllowEligible } from './sessionAllowRoute.js';
|
|
7
8
|
const UNREADABLE = Symbol('unreadable');
|
|
8
9
|
function ownData(v, key) {
|
|
9
10
|
try {
|
|
@@ -90,18 +91,17 @@ function enginePremiseOf(card) {
|
|
|
90
91
|
return 'card_unreadable';
|
|
91
92
|
if (refused.inCard)
|
|
92
93
|
return refused.value === true ? 'remember_refused' : 'remember_unreadable';
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
94
|
+
const list = readCardUnreadableEvidence(card);
|
|
95
|
+
if (list === 'unreadable')
|
|
95
96
|
return 'card_unreadable';
|
|
96
|
-
if (
|
|
97
|
+
if (list === 'absent')
|
|
97
98
|
return { evidenceUnreadable: false };
|
|
98
|
-
const list = ownData(card, 'unreadableEvidence');
|
|
99
|
-
if (!Array.isArray(list) || !list.every((k) => typeof k === 'string'))
|
|
100
|
-
return 'card_unreadable';
|
|
101
99
|
if (list.includes('rememberRefused'))
|
|
102
100
|
return 'remember_unreadable';
|
|
103
101
|
return { evidenceUnreadable: list.length > 0 };
|
|
104
102
|
}
|
|
103
|
+
const _sessionWhyPin = true;
|
|
104
|
+
void _sessionWhyPin;
|
|
105
105
|
export function standingRowsOf(card, host) {
|
|
106
106
|
if (typeof card !== 'object' || card === null)
|
|
107
107
|
return allClosed('card_unreadable');
|
|
@@ -110,11 +110,11 @@ export function standingRowsOf(card, host) {
|
|
|
110
110
|
if (typeof premise === 'string')
|
|
111
111
|
return allClosed(premise);
|
|
112
112
|
const evidenceUnreadable = premise.evidenceUnreadable;
|
|
113
|
-
const
|
|
114
|
-
const
|
|
113
|
+
const sessionWhy = sessionAllowEligible(card);
|
|
114
|
+
const sessionRow = sessionWhy === 'given';
|
|
115
115
|
let deploymentList;
|
|
116
116
|
if (!sessionRow) {
|
|
117
|
-
deploymentList =
|
|
117
|
+
deploymentList = sessionWhy;
|
|
118
118
|
}
|
|
119
119
|
else {
|
|
120
120
|
const pair = readAskClassPairState(card);
|
|
@@ -143,7 +143,7 @@ export function seatSessionRowOf(card, requestId) {
|
|
|
143
143
|
const domain = toolPermissionRequestIdDomain(requestId);
|
|
144
144
|
if (domain !== 'live:' && domain !== 'durable:')
|
|
145
145
|
return false;
|
|
146
|
-
return typeof enginePremiseOf(card) !== 'string';
|
|
146
|
+
return typeof enginePremiseOf(card) !== 'string' && sessionAllowCardReadable(card) === 'given';
|
|
147
147
|
}
|
|
148
148
|
catch {
|
|
149
149
|
return false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function subagentSourceSessionOf(carrier: object | null | undefined): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { slotReadOf } from '../wireFailureShape.js';
|
|
2
|
+
const nonEmpty = (v) => (typeof v === 'string' && v !== '' ? v : undefined);
|
|
3
|
+
export function subagentSourceSessionOf(carrier) {
|
|
4
|
+
if (typeof carrier !== 'object' || carrier === null)
|
|
5
|
+
return undefined;
|
|
6
|
+
const current = slotReadOf(carrier, 'sourceSessionId');
|
|
7
|
+
if (current.presence === 'present')
|
|
8
|
+
return nonEmpty(current.value);
|
|
9
|
+
if (current.presence !== 'absent')
|
|
10
|
+
return undefined;
|
|
11
|
+
const retired = slotReadOf(carrier, 'sourceTaskId');
|
|
12
|
+
return retired.presence === 'present' ? nonEmpty(retired.value) : undefined;
|
|
13
|
+
}
|
|
@@ -163,7 +163,7 @@ export declare function approvalCardPortFor(sessionKey: string): ApprovalCardPor
|
|
|
163
163
|
export declare function __resetSettledApprovalsForTests(): void;
|
|
164
164
|
export declare function _resetApprovalCardPortForTest(): void;
|
|
165
165
|
export declare function surfaceApprovalCard(req: ApprovalCardRequest): Promise<ApprovalCardDecision>;
|
|
166
|
-
declare const REMEMBER_REFUSAL_CODES: readonly ["remember_not_in_proof", "
|
|
166
|
+
declare const REMEMBER_REFUSAL_CODES: readonly ["remember_not_in_proof", "capability.store_required", "decide.workflow_remember_unsupported", "decide.parked_remember_unsupported"];
|
|
167
167
|
export type RememberRefusalCode = (typeof REMEMBER_REFUSAL_CODES)[number];
|
|
168
168
|
export declare function rememberRefusalOf(error: unknown): RememberRefusalCode | undefined;
|
|
169
169
|
export declare function surfaceFsApprovalAndDecide(deps: FsApprovalWireDeps, taskId: string, argsByCall: Map<string, unknown>, signal?: AbortSignal, parkGatedCallId?: string, parkToolName?: string): Promise<ApprovalResolution>;
|
|
@@ -179,7 +179,7 @@ export interface ReadRootCandidateView {
|
|
|
179
179
|
covers?: 'exact';
|
|
180
180
|
}
|
|
181
181
|
export type ToolApprovalDelegation = ApprovalCardDelegation;
|
|
182
|
-
export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "readRootCandidate", "mandated", "mandate", "origin", "approvalCard", "askClass", "classes", "inputHasBidi", "parked", "persistedRuleShadowed", "allowRuleShadowed", "probeCause", "probeReason", "rememberRefused", "boundGrantDigest", "boundGrantAbsence", "boundGrants", "classifierNoRuling", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome", "cause", "requestedBy"];
|
|
182
|
+
export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "sourceSessionId", "agentId", "askReasons", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "readRootCandidate", "mandated", "mandate", "origin", "approvalCard", "askClass", "classes", "inputHasBidi", "parked", "persistedRuleShadowed", "allowRuleShadowed", "probeCause", "probeReason", "rememberRefused", "boundGrantDigest", "boundGrantAbsence", "boundGrants", "classifierNoRuling", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome", "cause", "requestedBy"];
|
|
183
183
|
export interface ApprovalMandatedFacts {
|
|
184
184
|
readonly mandated?: true;
|
|
185
185
|
readonly ruleOffersAbsence?: string;
|
|
@@ -283,6 +283,7 @@ export interface ApprovalCardFrameFactsOptions {
|
|
|
283
283
|
readonly argsUnavailable?: true;
|
|
284
284
|
}
|
|
285
285
|
export declare function approvalCardFactsOfV1(card: object | null | undefined): Readonly<ApprovalCardV1Facts> | undefined;
|
|
286
|
+
export declare function approvalCardFactsOfV1Frame(frame: object | null | undefined): Readonly<ApprovalCardFacts> | undefined;
|
|
286
287
|
export declare function approvalCardFactsOfFrame(frame: object | null | undefined, opts?: ApprovalCardFrameFactsOptions | null): Readonly<ApprovalCardFacts> | undefined;
|
|
287
288
|
export declare function approvalCardFactsOfGeneric(card: object | null | undefined): Readonly<ApprovalCardFacts> | undefined;
|
|
288
289
|
export interface ToolApprovalFrameLaneOpts {
|
|
@@ -15,9 +15,10 @@ import { readEngineActiveBgTasks } from '../fleet/fleetLedger.js';
|
|
|
15
15
|
import { CORE_SKILL_TOOL_NAME } from '../generated/toolNameTables.js';
|
|
16
16
|
import { CORE_ALLOW_ENTRY_INERT_REASONS, CORE_PERSISTED_RULE_MATCHES } from '../generated/engineFactTables.js';
|
|
17
17
|
import { msg, renderMessage } from '../i18n/translate.js';
|
|
18
|
+
import { sessionAllowCarried, sessionAllowEligible } from './sessionAllowRoute.js';
|
|
18
19
|
import { INTERRUPT_DENY_REASON, observeCancelByDeny, surfaceApprovalParking, surfaceRememberNotApplied, surfaceEditNotForwarded, surfaceEditRefusedOnBlindAsk, surfaceRuleArmNotSent, surfaceRuleArmRejected } from './hitlHostSurface.js';
|
|
19
20
|
import { approvalCallKey, liveFrameCallKey } from './gateIdentity.js';
|
|
20
|
-
import { displayUntrusted } from '../displayUntrusted.js';
|
|
21
|
+
import { displayUntrusted, quoteUntrustedForSentence } from '../displayUntrusted.js';
|
|
21
22
|
import { frameBindingOf } from '../frameBinding.js';
|
|
22
23
|
import { carriesAttributionKey, deliverWithAttributionLadder } from './attributionLadder.js';
|
|
23
24
|
import { deliverApprovalDecision, newSendTally } from './approvalDelivery.js';
|
|
@@ -28,6 +29,8 @@ import { isApprovalMandateWord } from '../gateVocabulary.js';
|
|
|
28
29
|
import { approvalDecidedByAdmitted } from '../approvalDecidedByCapability.js';
|
|
29
30
|
import { decideFailureNote } from '../decideFailureNote.js';
|
|
30
31
|
import { slotPresenceOf, wireFailureTextsOf } from '../wireFailureShape.js';
|
|
32
|
+
import { APPROVAL_LIVE_FACE_KEYS, approvalLiveFaceOf, hasOwnStrictTrue } from './approvalLiveFace.js';
|
|
33
|
+
import { subagentSourceSessionOf } from './subagentSource.js';
|
|
31
34
|
import { isPlainRecord } from '../jsonFaithful.js';
|
|
32
35
|
import { DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED } from '../engineErrorCodes.js';
|
|
33
36
|
import { readDecideReceipt } from '../decideReceipt.js';
|
|
@@ -156,7 +159,6 @@ function cardPortMissReason() {
|
|
|
156
159
|
}
|
|
157
160
|
const REMEMBER_REFUSAL_CODES = Object.freeze([
|
|
158
161
|
'remember_not_in_proof',
|
|
159
|
-
'remember_requires_binding',
|
|
160
162
|
'capability.store_required',
|
|
161
163
|
DECIDE_WORKFLOW_REMEMBER_UNSUPPORTED,
|
|
162
164
|
'decide.parked_remember_unsupported',
|
|
@@ -447,7 +449,7 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
|
|
|
447
449
|
closeDurableRead(readMark);
|
|
448
450
|
}
|
|
449
451
|
if (!found.ok)
|
|
450
|
-
return { kind: 'not_sent', lane: 'decide', cause: found.code ?? 'fetch_failed', ...(found.reason !== '' ? { detail: found.reason } : {}) };
|
|
452
|
+
return { kind: 'not_sent', lane: 'decide', cause: found.code ?? 'fetch_failed', ...(found.reason !== '' ? { detail: found.reason } : {}), ...(found.rowVerdict !== undefined ? { rowVerdict: found.rowVerdict } : {}) };
|
|
451
453
|
if (held !== undefined)
|
|
452
454
|
return joinDurableDecision(held, deps, signal);
|
|
453
455
|
const rowIdentity = parkRowHolderIdentity(found.pending, found.gatedCallId);
|
|
@@ -498,7 +500,7 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
498
500
|
const durableRuleOffersAbsence = pending.ruleOffersAbsence;
|
|
499
501
|
hold.presented = true;
|
|
500
502
|
deps.onPresented?.();
|
|
501
|
-
const
|
|
503
|
+
const cardRequest = withUnreadableEvidence(pending, 'row', {
|
|
502
504
|
toolName,
|
|
503
505
|
args,
|
|
504
506
|
callKey,
|
|
@@ -512,9 +514,7 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
512
514
|
...(argsRewritten ? { argsRewritten: true, wireNote: ARGS_REWRITTEN_NOTE } : {}),
|
|
513
515
|
...(pending.governanceForced === true ? { governanceForced: true } : {}),
|
|
514
516
|
...(readRequiresRealApproval(pending) ? { requiresRealApproval: true } : {}),
|
|
515
|
-
...(
|
|
516
|
-
...((w) => (w !== undefined ? { mandate: w } : {}))(readApprovalMandate(pending)),
|
|
517
|
-
...((o) => (o !== undefined ? { origin: o } : {}))(readAskOrigin(pending)),
|
|
517
|
+
...approvalLiveFaceOf(pending).facts,
|
|
518
518
|
...((w) => (w !== undefined ? { approvalCard: w } : {}))(readApprovalCardWord(pending)),
|
|
519
519
|
...(readAskClassPair(pending) ?? {}),
|
|
520
520
|
...(pending.gateKind === 'irreversible_ask' ? { irreversibleParkGate: true } : {}),
|
|
@@ -533,7 +533,8 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
533
533
|
allowSessionCarried: true,
|
|
534
534
|
grantBinding: readApprovalGrantBinding(pending),
|
|
535
535
|
parkRow: parkRowOf(taskId, pending, gatedCallId),
|
|
536
|
-
})
|
|
536
|
+
});
|
|
537
|
+
const card = await surfaceCallTrackedCard(gatedCallId, undefined, ledgerSlot, cardRequest);
|
|
537
538
|
hold.phase = 'respond';
|
|
538
539
|
if (rowArgsGap !== undefined && card.kind === 'allow' && card.updatedInput !== undefined) {
|
|
539
540
|
hostLog('error', `liveToolApprovalWire: approval card for ${gatedCallId ?? `task ${taskId}`} returned an edited approval, but the tool input is ${rowArgsGap === 'truncated' ? 'a size marker on the pending row' : 'missing from both the stream and the pending row'} — nothing sent (the park stays pending)`);
|
|
@@ -560,10 +561,15 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
560
561
|
let rememberStop;
|
|
561
562
|
try {
|
|
562
563
|
let rememberRefused = false;
|
|
563
|
-
const
|
|
564
|
+
const sessionAllowWhy = sessionAllowEligible(cardRequest);
|
|
565
|
+
const sessionDowngraded = card.allowSession === true && sessionAllowWhy !== 'given';
|
|
566
|
+
if (sessionDowngraded)
|
|
567
|
+
hostLog('debug', `liveToolApprovalWire: ${gatedCallId ?? `task ${taskId}`} session-wide allow taken as allow-once — the card is not eligible (${sessionAllowWhy})`);
|
|
568
|
+
const answered = sessionDowngraded ? { ...card, allowSession: false } : card;
|
|
569
|
+
const approveBody = answerPayloadFor(answered, 'decide');
|
|
564
570
|
const { remember: _remember, ...plainApproveBody } = approveBody;
|
|
565
571
|
void _remember;
|
|
566
|
-
emitAnswerCommitted(callKey, 'decide',
|
|
572
|
+
emitAnswerCommitted(callKey, 'decide', answered, approveBody);
|
|
567
573
|
if (approveBody.remember === 'session') {
|
|
568
574
|
let sessionReceipt;
|
|
569
575
|
let sessionDecided = false;
|
|
@@ -591,7 +597,7 @@ async function presentFsApprovalAndDecide(deps, taskId, argsByCall, signal, foun
|
|
|
591
597
|
}
|
|
592
598
|
const raw = await bridge.decideTool(plainApproveBody, gatedCallId, decideOpts, pending);
|
|
593
599
|
const receipt = readDecideReceipt(raw);
|
|
594
|
-
if (rememberRefused)
|
|
600
|
+
if (rememberRefused || sessionDowngraded)
|
|
595
601
|
surfaceRememberNotApplied();
|
|
596
602
|
return { kind: 'decided', ...at, decision: 'allow', ...(receipt !== undefined ? { receipt } : {}) };
|
|
597
603
|
}
|
|
@@ -683,6 +689,9 @@ export const TOOL_APPROVAL_FRAME_KEYS_MIRROR = [
|
|
|
683
689
|
'toolCallId',
|
|
684
690
|
'toolName',
|
|
685
691
|
'sourceTaskId',
|
|
692
|
+
'sourceSessionId',
|
|
693
|
+
'agentId',
|
|
694
|
+
'askReasons',
|
|
686
695
|
'fromSubagent',
|
|
687
696
|
'sourceAgentName',
|
|
688
697
|
'message',
|
|
@@ -758,9 +767,6 @@ export function toolPermissionRequestAskBits(card, requestId) {
|
|
|
758
767
|
...(seatSessionRowOf(card, requestId) ? { sessionRow: true } : {}),
|
|
759
768
|
};
|
|
760
769
|
}
|
|
761
|
-
function hasOwnStrictTrue(v, key) {
|
|
762
|
-
return Object.hasOwn(v, key) && v[key] === true;
|
|
763
|
-
}
|
|
764
770
|
function isToolApprovalDelegation(v) {
|
|
765
771
|
if (v === null || typeof v !== 'object')
|
|
766
772
|
return false;
|
|
@@ -1283,6 +1289,30 @@ export function classifierNoRulingDetail(word, lang) {
|
|
|
1283
1289
|
return renderMessage(msg('approval.classifier.noRulingOther', { reason: displayUntrusted(word) }), lang);
|
|
1284
1290
|
return renderMessage(msg('approval.classifier.noRulingBare'), lang);
|
|
1285
1291
|
}
|
|
1292
|
+
const BOUND_GRANT_NAMES_SHOWN = 6;
|
|
1293
|
+
const BOUND_GRANT_NAME_MAX = 512;
|
|
1294
|
+
const BOUND_GRANT_NAME_INPUT_MAX = 8192;
|
|
1295
|
+
const BOUND_GRANT_NAMES_LOOKAHEAD = 32;
|
|
1296
|
+
function boundGrantNameList(rules, lang) {
|
|
1297
|
+
const shown = [];
|
|
1298
|
+
let looked = 0;
|
|
1299
|
+
for (const entry of rules) {
|
|
1300
|
+
if (shown.length >= BOUND_GRANT_NAMES_SHOWN || looked >= BOUND_GRANT_NAMES_LOOKAHEAD)
|
|
1301
|
+
break;
|
|
1302
|
+
looked += 1;
|
|
1303
|
+
if (entry.length > BOUND_GRANT_NAME_INPUT_MAX)
|
|
1304
|
+
continue;
|
|
1305
|
+
const quoted = quoteUntrustedForSentence(entry, BOUND_GRANT_NAME_MAX);
|
|
1306
|
+
if (quoted !== undefined)
|
|
1307
|
+
shown.push(quoted);
|
|
1308
|
+
}
|
|
1309
|
+
if (shown.length === 0)
|
|
1310
|
+
return undefined;
|
|
1311
|
+
const rest = rules.length - shown.length;
|
|
1312
|
+
if (rest > 0)
|
|
1313
|
+
shown.push(renderMessage(msg('approval.boundGrants.more', { count: rest }), lang));
|
|
1314
|
+
return shown.join(' · ');
|
|
1315
|
+
}
|
|
1286
1316
|
export function approvalBoundGrantsDetail(grants, lang) {
|
|
1287
1317
|
const g = readApprovalBoundGrants({ boundGrants: grants });
|
|
1288
1318
|
if (g === undefined)
|
|
@@ -1290,8 +1320,10 @@ export function approvalBoundGrantsDetail(grants, lang) {
|
|
|
1290
1320
|
if (g.skill === null)
|
|
1291
1321
|
return renderMessage(msg('approval.boundGrants.noSkill'), lang);
|
|
1292
1322
|
const isRule = (e) => readBoundGrantEntry(e)?.kind === 'rule';
|
|
1293
|
-
const
|
|
1294
|
-
const
|
|
1323
|
+
const allowRules = g.allowedTools.filter(isRule);
|
|
1324
|
+
const denyRules = g.disallowedTools.filter(isRule);
|
|
1325
|
+
const a = allowRules.length;
|
|
1326
|
+
const d = denyRules.length;
|
|
1295
1327
|
const allowNothing = g.allowedTools.length - a;
|
|
1296
1328
|
const denyNothing = g.disallowedTools.length - d;
|
|
1297
1329
|
if (denyNothing > 0) {
|
|
@@ -1302,8 +1334,14 @@ export function approvalBoundGrantsDetail(grants, lang) {
|
|
|
1302
1334
|
return renderMessage(allowNothing === 1 ? msg('approval.boundGrants.listsNoToolsWithNothing.one') : msg('approval.boundGrants.listsNoToolsWithNothing.other', { count: String(allowNothing) }), lang);
|
|
1303
1335
|
return renderMessage(msg('approval.boundGrants.listsNoTools'), lang);
|
|
1304
1336
|
}
|
|
1305
|
-
const
|
|
1306
|
-
const
|
|
1337
|
+
const allowNames = boundGrantNameList(allowRules, lang);
|
|
1338
|
+
const denyNames = boundGrantNameList(denyRules, lang);
|
|
1339
|
+
const allow = allowNames !== undefined
|
|
1340
|
+
? (a === 1 ? msg('approval.boundGrants.allowPart.named.one', { names: allowNames }) : msg('approval.boundGrants.allowPart.named.other', { count: a, names: allowNames }))
|
|
1341
|
+
: (a === 1 ? msg('approval.boundGrants.allowPart.one') : msg('approval.boundGrants.allowPart.other', { count: a }));
|
|
1342
|
+
const deny = denyNames !== undefined
|
|
1343
|
+
? (d === 1 ? msg('approval.boundGrants.denyPart.named.one', { names: denyNames }) : msg('approval.boundGrants.denyPart.named.other', { count: d, names: denyNames }))
|
|
1344
|
+
: (d === 1 ? msg('approval.boundGrants.denyPart.one') : msg('approval.boundGrants.denyPart.other', { count: d }));
|
|
1307
1345
|
if (allowNothing > 0) {
|
|
1308
1346
|
return renderMessage(allowNothing === 1 ? msg('approval.boundGrants.activatesWithNothing.one', { allow, deny }) : msg('approval.boundGrants.activatesWithNothing.other', { allow, deny, count: String(allowNothing) }), lang);
|
|
1309
1347
|
}
|
|
@@ -1320,7 +1358,8 @@ function askSigOf(classes, origin, mandate) {
|
|
|
1320
1358
|
}
|
|
1321
1359
|
function carrierAskSig(v, live) {
|
|
1322
1360
|
try {
|
|
1323
|
-
|
|
1361
|
+
const face = live === undefined ? undefined : approvalLiveFaceOf(live);
|
|
1362
|
+
return askSigOf(readAskClassPair(v)?.classes, face?.facts.origin, face?.facts.mandate);
|
|
1324
1363
|
}
|
|
1325
1364
|
catch {
|
|
1326
1365
|
return undefined;
|
|
@@ -1605,10 +1644,11 @@ export function readRuleOfferSupply(offers) {
|
|
|
1605
1644
|
}
|
|
1606
1645
|
function subagentBadgeFor(frame) {
|
|
1607
1646
|
let name = typeof frame.sourceAgentName === 'string' && frame.sourceAgentName.length > 0 ? frame.sourceAgentName : '';
|
|
1608
|
-
|
|
1609
|
-
|
|
1647
|
+
const source = subagentSourceSessionOf(frame);
|
|
1648
|
+
if (!name && source !== undefined) {
|
|
1649
|
+
name = source;
|
|
1610
1650
|
try {
|
|
1611
|
-
const row = readEngineActiveBgTasks().tasks.find(t => t.id ===
|
|
1651
|
+
const row = readEngineActiveBgTasks().tasks.find(t => t.id === source);
|
|
1612
1652
|
if (typeof row?.name === 'string' && row.name.length > 0)
|
|
1613
1653
|
name = row.name;
|
|
1614
1654
|
}
|
|
@@ -1631,10 +1671,11 @@ function v1Bit(stamp) {
|
|
|
1631
1671
|
const SUSPENDED_ASK_ARGS_NOTE = "this request's tool arguments are not available on this surface — it was raised while no client was connected, " +
|
|
1632
1672
|
'so you are deciding without seeing them; deny it if you are not sure what it will do. ' +
|
|
1633
1673
|
'Edits are not accepted on this card: there is no original input to edit';
|
|
1634
|
-
function cardFactsOf(carrier, leg, opts, liveFacts) {
|
|
1674
|
+
function cardFactsOf(carrier, leg, opts, liveFacts, approvalId) {
|
|
1635
1675
|
const c = carrier;
|
|
1636
1676
|
const full = leg !== 'generic';
|
|
1637
1677
|
const live = leg === 'frame' ? carrier : leg === 'v1' ? liveFacts : undefined;
|
|
1678
|
+
let face;
|
|
1638
1679
|
const asFrame = carrier;
|
|
1639
1680
|
const fromSubagent = full
|
|
1640
1681
|
? (() => {
|
|
@@ -1747,15 +1788,11 @@ function cardFactsOf(carrier, leg, opts, liveFacts) {
|
|
|
1747
1788
|
realApprovalUnreadable = true;
|
|
1748
1789
|
}
|
|
1749
1790
|
if (live !== undefined) {
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
const w = readApprovalMandate(live);
|
|
1756
|
-
if (w !== undefined)
|
|
1757
|
-
out.mandate = w;
|
|
1758
|
-
});
|
|
1791
|
+
face = approvalLiveFaceOf(live);
|
|
1792
|
+
if (face.facts.mandated === true)
|
|
1793
|
+
out.mandated = true;
|
|
1794
|
+
if (face.facts.mandate !== undefined)
|
|
1795
|
+
out.mandate = face.facts.mandate;
|
|
1759
1796
|
v1Bit(() => {
|
|
1760
1797
|
const rc = readReadRootCandidate(live.readRootCandidate);
|
|
1761
1798
|
if (rc !== undefined)
|
|
@@ -1777,13 +1814,8 @@ function cardFactsOf(carrier, leg, opts, liveFacts) {
|
|
|
1777
1814
|
if (dlf !== undefined)
|
|
1778
1815
|
out.denialLimitFallback = dlf;
|
|
1779
1816
|
});
|
|
1780
|
-
if (
|
|
1781
|
-
|
|
1782
|
-
const o = readAskOrigin(live);
|
|
1783
|
-
if (o !== undefined)
|
|
1784
|
-
out.origin = o;
|
|
1785
|
-
});
|
|
1786
|
-
}
|
|
1817
|
+
if (face !== undefined && face.facts.origin !== undefined)
|
|
1818
|
+
out.origin = face.facts.origin;
|
|
1787
1819
|
if (leg !== 'generic') {
|
|
1788
1820
|
v1Bit(() => {
|
|
1789
1821
|
const w = readApprovalCardWord(carrier);
|
|
@@ -1817,16 +1849,32 @@ function cardFactsOf(carrier, leg, opts, liveFacts) {
|
|
|
1817
1849
|
});
|
|
1818
1850
|
if (leg === 'generic')
|
|
1819
1851
|
out.cardPayloadUnreadable = true;
|
|
1820
|
-
if (leg
|
|
1852
|
+
if (sessionAllowCarried(leg, approvalId))
|
|
1821
1853
|
out.allowSessionCarried = true;
|
|
1822
1854
|
out.grantBinding = readApprovalGrantBinding(carrier);
|
|
1823
|
-
|
|
1855
|
+
const reported = realApprovalUnreadable ? ['requiresRealApproval'] : [];
|
|
1856
|
+
if (face?.layerUnknown === 'marked' || (leg === 'v1' && face?.layerUnknown === 'absent'))
|
|
1857
|
+
reported.push(...APPROVAL_LIVE_FACE_KEYS);
|
|
1858
|
+
return withUnreadableEvidence(carrier, leg, out, reported, live);
|
|
1824
1859
|
}
|
|
1825
1860
|
export function approvalCardFactsOfV1(card) {
|
|
1826
1861
|
if (typeof card !== 'object' || card === null)
|
|
1827
1862
|
return undefined;
|
|
1828
1863
|
return Object.freeze(cardFactsOf(card, 'v1'));
|
|
1829
1864
|
}
|
|
1865
|
+
export function approvalCardFactsOfV1Frame(frame) {
|
|
1866
|
+
if (typeof frame !== 'object' || frame === null)
|
|
1867
|
+
return undefined;
|
|
1868
|
+
try {
|
|
1869
|
+
const carriers = openingFrameCarriersOf(frame);
|
|
1870
|
+
if (carriers.leg !== 'v1')
|
|
1871
|
+
return undefined;
|
|
1872
|
+
return Object.freeze(cardFactsOf(carriers.body, 'v1', null, carriers.live, ownDataValue(frame, 'approvalId')));
|
|
1873
|
+
}
|
|
1874
|
+
catch {
|
|
1875
|
+
return undefined;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1830
1878
|
export function approvalCardFactsOfFrame(frame, opts) {
|
|
1831
1879
|
if (typeof frame !== 'object' || frame === null)
|
|
1832
1880
|
return undefined;
|
|
@@ -1888,7 +1936,7 @@ function liveCardIdentityOf(approvalId, frame, carriers, run) {
|
|
|
1888
1936
|
const fromSubagent = isFromSubagent(carriers.body);
|
|
1889
1937
|
const bound = fromSubagent ? undefined : frameBindingOf(frame);
|
|
1890
1938
|
const source = bound ?? run;
|
|
1891
|
-
const ownRun = fromSubagent ? body
|
|
1939
|
+
const ownRun = fromSubagent ? subagentSourceSessionOf(carriers.body) : source?.taskId;
|
|
1892
1940
|
const taskId = typeof ownRun === 'string' && ownRun !== '' ? ownRun : undefined;
|
|
1893
1941
|
const sessionId = !fromSubagent && typeof source?.sessionId === 'string' && source.sessionId !== '' ? source.sessionId : undefined;
|
|
1894
1942
|
const askSig = carrierAskSig(carriers.body, carriers.live);
|
|
@@ -1950,7 +1998,7 @@ async function presentToolApprovalFrameAndRespond(frame, carriers, approvalId, r
|
|
|
1950
1998
|
const bodyToolCallId = carriers.body.toolCallId;
|
|
1951
1999
|
const frameToolCallId = typeof bodyToolCallId === 'string' && bodyToolCallId !== '' ? bodyToolCallId : undefined;
|
|
1952
2000
|
const decidedByReading = decidedByReadingSnapshotOf(lane);
|
|
1953
|
-
const facts = cardFactsOf(carriers.body, carriers.leg, { streamArgs, ...(lane?.argsUnavailable === true ? { argsUnavailable: true } : {}) }, carriers.live);
|
|
2001
|
+
const facts = cardFactsOf(carriers.body, carriers.leg, { streamArgs, ...(lane?.argsUnavailable === true ? { argsUnavailable: true } : {}) }, carriers.live, approvalId);
|
|
1954
2002
|
const argsNotRealInput = facts.argsUnavailable === true;
|
|
1955
2003
|
const ruleOffers = facts.ruleOffers;
|
|
1956
2004
|
if (argsNotRealInput && lane?.argsUnavailable !== true && facts.wireNote !== undefined) {
|
|
@@ -1996,9 +2044,15 @@ async function presentToolApprovalFrameAndRespond(frame, carriers, approvalId, r
|
|
|
1996
2044
|
enterLiveRespondPhase(hold);
|
|
1997
2045
|
const noteCapable = lane?.approvalDecisionNoteCapable === true;
|
|
1998
2046
|
const denyReasonRead = card.kind === 'deny' ? ((r) => (typeof r === 'string' ? r : undefined))(card.reason) : undefined;
|
|
2047
|
+
const sessionAllowWhy = sessionAllowEligible(facts);
|
|
2048
|
+
const sessionDowngraded = card.kind === 'allow' && card.allowSession === true && sessionAllowWhy !== 'given';
|
|
2049
|
+
if (sessionDowngraded)
|
|
2050
|
+
hostLog('debug', `liveToolApprovalWire: ${approvalId} session-wide allow taken as allow-once — the card is not eligible (${sessionAllowWhy})`);
|
|
1999
2051
|
const answerSnapshot = card.kind === 'deny'
|
|
2000
2052
|
? ((by) => ({ kind: 'deny', ...(denyReasonRead !== undefined ? { reason: denyReasonRead } : {}), ...(by !== undefined ? { settledBy: by } : {}) }))(readApprovalDenySettledBy(card))
|
|
2001
|
-
: card
|
|
2053
|
+
: sessionDowngraded && card.kind === 'allow'
|
|
2054
|
+
? { ...card, allowSession: false }
|
|
2055
|
+
: card;
|
|
2002
2056
|
const basePayload = answerPayloadFor(answerSnapshot, 'respond', { approvalDecisionNoteCapable: noteCapable });
|
|
2003
2057
|
const decision = basePayload?.decision ?? 'deny';
|
|
2004
2058
|
if (card.kind === 'allow' && typeof card.note === 'string' && card.note.trim() !== '' && answerCarriage({ callKey: liveFrameCallKey(approvalId) }).allowNote === 'none') {
|
|
@@ -2231,6 +2285,8 @@ async function presentToolApprovalFrameAndRespond(frame, carriers, approvalId, r
|
|
|
2231
2285
|
logAfterDecided(`liveToolApprovalWire: ${approvalId} allow_session ack rememberApplied=false — grant not stored, surfacing honest notice`);
|
|
2232
2286
|
surfaceRememberNotApplied();
|
|
2233
2287
|
}
|
|
2288
|
+
if (replayed === undefined && sessionDowngraded)
|
|
2289
|
+
surfaceRememberNotApplied();
|
|
2234
2290
|
if (respondOpts.updatedInput !== undefined && applied?.updatedInputForwarded === false) {
|
|
2235
2291
|
logAfterDecided(`liveToolApprovalWire: ${approvalId} edited args were NOT forwarded (ack.updatedInputForwarded=false) — the tool runs on the ORIGINAL input`);
|
|
2236
2292
|
surfaceEditNotForwarded();
|
|
@@ -2,7 +2,7 @@ import { SETTINGS_WORKSPACE_TRUST_STATES } from './generated/settingsSchemaTable
|
|
|
2
2
|
import type { ManagedPolicyState, PluginHooksReading, SessionHooksReading, SettingsDocument } from './host.js';
|
|
3
3
|
import type { PluginHookReaderState } from './pluginHooksWire.js';
|
|
4
4
|
export type WorkspaceTrustState = (typeof SETTINGS_WORKSPACE_TRUST_STATES)[number];
|
|
5
|
-
export declare const HOST_SETTINGS_LAYERS: readonly ["policySettings", "userSettings", "projectSettings", "localSettings", "flagSettings"];
|
|
5
|
+
export declare const HOST_SETTINGS_LAYERS: readonly ["policySettings", "userSettings", "projectSettings", "localSettings", "flagSettings", "foreignProjectSettings"];
|
|
6
6
|
export type HostSettingsLayer = (typeof HOST_SETTINGS_LAYERS)[number];
|
|
7
7
|
export declare const MANAGED_POLICY_STATES: readonly ["absent", "in-effect", "in-effect-pieces", "unreadable-covered", "unreadable-uncovered", "remote-unknown"];
|
|
8
8
|
export declare const HOST_STARTUP_MODES: readonly ["safe", "bare", "none"];
|
|
@@ -71,6 +71,8 @@ export declare function sourceOfRead(read: HostSettingsRead): HostSettingsSource
|
|
|
71
71
|
export declare function settingsValueOf(read: HostSettingsRead, key: string): {} | null | undefined;
|
|
72
72
|
export declare function mergedBooleanOf(read: HostSettingsRead, key: string): boolean | undefined;
|
|
73
73
|
export declare const CC_MERGE_ORDER: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings"];
|
|
74
|
+
export type TightenOnlyHostSettingsLayer = Exclude<HostSettingsLayer, (typeof CC_MERGE_ORDER)[number]>;
|
|
75
|
+
export declare const TIGHTEN_ONLY_HOST_SETTINGS_LAYERS: readonly TightenOnlyHostSettingsLayer[];
|
|
74
76
|
export declare function nonManagedLayerDown(read: HostSettingsRead): boolean;
|
|
75
77
|
export declare const ADOPTED_LAYERS: readonly ["userSettings", "projectSettings", "localSettings", "flagSettings"];
|
|
76
78
|
export type AdoptedLayer = (typeof ADOPTED_LAYERS)[number];
|
|
@@ -102,6 +104,7 @@ export declare function hostSettingsSessionFollows(stored: HostSettingsSession |
|
|
|
102
104
|
export declare const FIRST_SESSION: HostSettingsSession;
|
|
103
105
|
export declare function sessionSnapshotOf(previous: {} | null | undefined): HostSettingsSession | undefined;
|
|
104
106
|
export declare function permissionRulesOf(doc: SettingsDocument | null, bucket: 'allow' | 'deny' | 'ask'): readonly string[];
|
|
107
|
+
export declare function permissionBucketOf(doc: SettingsDocument | null, bucket: 'allow' | 'deny' | 'ask'): readonly string[] | undefined;
|
|
105
108
|
export interface HostSettingsAdoption {
|
|
106
109
|
readonly read: HostSettingsRead;
|
|
107
110
|
readonly session: HostSettingsSession;
|
|
@@ -2,7 +2,7 @@ import { appendOwnElement } from './ownKey.js';
|
|
|
2
2
|
import { SETTINGS_WORKSPACE_TRUST_STATES } from './generated/settingsSchemaTables.js';
|
|
3
3
|
import { jsonFaithfulCost, materializeJsonFaithful } from './jsonFaithful.js';
|
|
4
4
|
import { faultText } from './hostCallbackGuard.js';
|
|
5
|
-
export const HOST_SETTINGS_LAYERS = Object.freeze(['policySettings', 'userSettings', 'projectSettings', 'localSettings', 'flagSettings']);
|
|
5
|
+
export const HOST_SETTINGS_LAYERS = Object.freeze(['policySettings', 'userSettings', 'projectSettings', 'localSettings', 'flagSettings', 'foreignProjectSettings']);
|
|
6
6
|
export const MANAGED_POLICY_STATES = Object.freeze(['absent', 'in-effect', 'in-effect-pieces', 'unreadable-covered', 'unreadable-uncovered', 'remote-unknown']);
|
|
7
7
|
export const HOST_STARTUP_MODES = Object.freeze(['safe', 'bare', 'none']);
|
|
8
8
|
export const HOST_SETTINGS_CARRIER_STATUSES = Object.freeze(['loaded', 'loaded-partial', 'empty', 'absent', 'unreadable', 'not-loaded']);
|
|
@@ -394,8 +394,9 @@ export function mergedBooleanOf(read, key) {
|
|
|
394
394
|
return out;
|
|
395
395
|
}
|
|
396
396
|
export const CC_MERGE_ORDER = Object.freeze(['userSettings', 'projectSettings', 'localSettings', 'flagSettings', 'policySettings']);
|
|
397
|
+
export const TIGHTEN_ONLY_HOST_SETTINGS_LAYERS = Object.freeze(HOST_SETTINGS_LAYERS.filter((l) => !CC_MERGE_ORDER.includes(l)));
|
|
397
398
|
export function nonManagedLayerDown(read) {
|
|
398
|
-
return
|
|
399
|
+
return CC_MERGE_ORDER.some((l) => {
|
|
399
400
|
if (l === 'policySettings')
|
|
400
401
|
return false;
|
|
401
402
|
const snap = read.layers[l];
|
|
@@ -403,6 +404,7 @@ export function nonManagedLayerDown(read) {
|
|
|
403
404
|
});
|
|
404
405
|
}
|
|
405
406
|
export const ADOPTED_LAYERS = Object.freeze(['userSettings', 'projectSettings', 'localSettings', 'flagSettings']);
|
|
407
|
+
const isAdoptedLayer = (l) => ADOPTED_LAYERS.includes(l);
|
|
406
408
|
const GENESIS_VERSION = '0';
|
|
407
409
|
export const parentVersionOf = (session) => (session.version === GENESIS_VERSION ? null : session.version);
|
|
408
410
|
function canonicalOf(v) {
|
|
@@ -512,13 +514,16 @@ export function sessionSnapshotOf(previous) {
|
|
|
512
514
|
}
|
|
513
515
|
const LOADED = new Set(['loaded', 'loaded-partial']);
|
|
514
516
|
export function permissionRulesOf(doc, bucket) {
|
|
517
|
+
return permissionBucketOf(doc, bucket) ?? [];
|
|
518
|
+
}
|
|
519
|
+
export function permissionBucketOf(doc, bucket) {
|
|
515
520
|
if (doc === null)
|
|
516
|
-
return
|
|
521
|
+
return undefined;
|
|
517
522
|
const p = ownData(doc, 'permissions');
|
|
518
523
|
if (!p.ok || !isRecord(p.value))
|
|
519
|
-
return
|
|
524
|
+
return undefined;
|
|
520
525
|
const b = ownData(p.value, bucket);
|
|
521
|
-
return b.ok && Array.isArray(b.value) ? b.value.filter((x) => typeof x === 'string') :
|
|
526
|
+
return b.ok && Array.isArray(b.value) ? b.value.filter((x) => typeof x === 'string') : undefined;
|
|
522
527
|
}
|
|
523
528
|
function overflowOf(read, session) {
|
|
524
529
|
return Object.freeze({ read, session: remintSameContent(session), trusted: false, clean: false, extraTighten: NO_EXTRA, allowByLayer: emptyByLayer(), overflow: true });
|
|
@@ -624,7 +629,7 @@ export function adoptHostSettingsRead(read, session, allowAdmitted = () => true,
|
|
|
624
629
|
const effectiveLayers = {};
|
|
625
630
|
for (const l of HOST_SETTINGS_LAYERS) {
|
|
626
631
|
const snap = read.layers[l];
|
|
627
|
-
effectiveLayers[l] = l
|
|
632
|
+
effectiveLayers[l] = isAdoptedLayer(l) ? Object.freeze({ ...snap, doc: base.docs[l] }) : snap;
|
|
628
633
|
}
|
|
629
634
|
const effective = Object.freeze({ ...read, layers: Object.freeze(effectiveLayers), current: read, debug: Object.freeze([]) });
|
|
630
635
|
const idOf = (layer, rule) => (layeredRules ? JSON.stringify([layer, rule]) : rule);
|
|
@@ -3,8 +3,8 @@ import type { WireHooksConfig } from './finalVerifyWire.js';
|
|
|
3
3
|
import type { memoryOffDeclared as MemoryOffDeclared } from './request/taskRequest.js';
|
|
4
4
|
import type { EnvLike } from './hostEnv.js';
|
|
5
5
|
import { type SettingsDocument } from './host.js';
|
|
6
|
-
import type {
|
|
7
|
-
import { type HostSettingsSession, type HostSettingsSource } from './hostSettingsSource.js';
|
|
6
|
+
import type { HooksWirePlan, HooksWirePlanOptions } from './pluginHooksWire.js';
|
|
7
|
+
import { type HostSettingsLayer, type HostSettingsSession, type HostSettingsSource } from './hostSettingsSource.js';
|
|
8
8
|
import { type SubmissionIdentity } from './request/submissionIdentity.js';
|
|
9
9
|
import { type WebSearchApiKeyFor } from './webSearchWireCaps.js';
|
|
10
10
|
import { type FileHistoryCaptureReading } from './fileHistoryCaptureCapability.js';
|
|
@@ -16,12 +16,12 @@ export type HostSettingCause = (typeof HOST_SETTING_CAUSES)[number];
|
|
|
16
16
|
export declare const HOST_SETTING_DISPOSITIONS: readonly ["carry", "carry_partial", "withhold_notice", "withhold_by_policy", "hold_for_consent", "refuse_turn", "unwired", "nothing_to_carry"];
|
|
17
17
|
export type HostSettingDisposition = (typeof HOST_SETTING_DISPOSITIONS)[number];
|
|
18
18
|
export type HostSettingPlane = 'turn' | 'session' | 'diagnostic';
|
|
19
|
-
export type HostSettingNoticeId = 'HS-UNWIRED' | 'HS-MANAGED-REJECTED' | 'HS-PROJECTION' | 'HS-SOURCE-UNREADABLE' | 'HS-WEBSEARCH-MALFORMED' | 'HS-SWITCH-MALFORMED' | 'HS-FILEHISTORY-UNJUDGED' | 'HS-FILEHISTORY-RESTORE' | 'HS-MANAGED-UNREADABLE' | 'HS-LAYER-NOT-LOADED' | 'HS-HELD-PREVIOUS' | 'HS-STYLE-MISSING' | 'HS-STYLE-SAFE';
|
|
19
|
+
export type HostSettingNoticeId = 'HS-UNWIRED' | 'HS-MANAGED-REJECTED' | 'HS-PROJECTION' | 'HS-SOURCE-UNREADABLE' | 'HS-WEBSEARCH-MALFORMED' | 'HS-SWITCH-MALFORMED' | 'HS-FILEHISTORY-UNJUDGED' | 'HS-FILEHISTORY-RESTORE' | 'HS-MANAGED-UNREADABLE' | 'HS-LAYER-NOT-LOADED' | 'HS-HELD-PREVIOUS' | 'HS-STYLE-MISSING' | 'HS-STYLE-SAFE' | 'HS-LAYER-PARTS-UNREAD';
|
|
20
20
|
export interface HostSettingRow {
|
|
21
21
|
readonly key: HostSuppliedKey;
|
|
22
22
|
readonly cause: HostSettingCause;
|
|
23
23
|
readonly disposition: HostSettingDisposition;
|
|
24
|
-
readonly layers?: readonly
|
|
24
|
+
readonly layers?: readonly HostSettingsLayer[];
|
|
25
25
|
}
|
|
26
26
|
export interface HostSettingNotice {
|
|
27
27
|
readonly id: HostSettingNoticeId;
|
|
@@ -123,7 +123,6 @@ export interface HostPermissionFacts {
|
|
|
123
123
|
readonly ask?: readonly string[];
|
|
124
124
|
};
|
|
125
125
|
readonly clientOwnedServers?: readonly string[];
|
|
126
|
-
readonly serverVersion?: string;
|
|
127
126
|
}
|
|
128
127
|
export declare function rethrowHostResolvedDeferred(product: HostTurnSettings): void;
|
|
129
128
|
export type HostResolvedMaterializer = (snapshot: SettingsDocument) => SettingsDocument;
|