@sema-agent/client-core 0.95.0 → 0.97.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 +269 -0
- package/README.md +61 -31
- package/dist/adapt/arms.js +7 -1
- package/dist/adapt/toolCards.d.ts +1 -0
- package/dist/adapt/toolCards.js +16 -3
- package/dist/adapt/wireShapes.js +2 -16
- package/dist/adapter/activeRunSelfHeal.d.ts +4 -2
- package/dist/adapter/activeRunSelfHeal.js +32 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +11 -3
- package/dist/adapter/downstream/terminalToSdkResult.js +14 -11
- package/dist/adapter/runStream.js +30 -47
- package/dist/agentSession/backgroundView.js +2 -15
- package/dist/agentSession/engineAgentRegistryRead.js +5 -4
- package/dist/agentSession/engineSessionBackgroundStop.js +22 -15
- package/dist/agentsWireCaps.d.ts +1 -1
- package/dist/agentsWireCaps.js +29 -12
- package/dist/approvalDecidedByCapability.d.ts +2 -0
- package/dist/approvalDecidedByCapability.js +0 -1
- package/dist/approvalsStreamLiveCapability.d.ts +2 -0
- package/dist/approvalsStreamLiveCapability.js +3 -2
- package/dist/attachmentSeatCapability.d.ts +2 -0
- package/dist/attachmentSeatCapability.js +0 -1
- package/dist/callerCwdCapability.d.ts +2 -4
- package/dist/callerCwdCapability.js +0 -7
- package/dist/centerWiringCapability.d.ts +2 -4
- package/dist/centerWiringCapability.js +4 -9
- package/dist/classifierVerdictWire.js +4 -16
- package/dist/clientSlice.js +1 -1
- package/dist/cloudConfigWireCaps.d.ts +4 -4
- package/dist/cloudConfigWireCaps.js +241 -85
- package/dist/coreValuePorts.d.ts +11 -7
- package/dist/coreValuePorts.js +5 -8
- package/dist/credentialProvenance.d.ts +28 -0
- package/dist/credentialProvenance.js +76 -0
- package/dist/decideFailureNote.js +3 -1
- package/dist/decideReceipt.js +7 -10
- package/dist/declared/supportFloorDeclared.js +3 -3
- package/dist/deviceExecutorManagementCapability.d.ts +2 -0
- package/dist/deviceExecutorManagementCapability.js +3 -2
- package/dist/displayUntrusted.d.ts +10 -3
- package/dist/displayUntrusted.js +371 -60
- package/dist/engineCapReader.d.ts +8 -2
- package/dist/engineCapReader.js +15 -7
- package/dist/engineCapsCache.d.ts +17 -3
- package/dist/engineCapsCache.js +268 -43
- package/dist/engineDirectory.d.ts +79 -0
- package/dist/engineDirectory.js +186 -0
- package/dist/engineErrorCodes.d.ts +17 -1
- package/dist/engineErrorCodes.js +46 -16
- package/dist/engineNoticeCodes.d.ts +17 -0
- package/dist/engineNoticeCodes.js +54 -1
- package/dist/executionLaneCapability.d.ts +2 -0
- package/dist/executionLaneCapability.js +3 -2
- package/dist/fileHistoryCaptureCapability.d.ts +16 -0
- package/dist/fileHistoryCaptureCapability.js +98 -2
- package/dist/fileHistoryLegNotice.js +4 -0
- package/dist/fleet/bgSubagentRow.d.ts +15 -0
- package/dist/fleet/bgSubagentRow.js +67 -0
- package/dist/fleet/fleetLedger.d.ts +1 -0
- package/dist/fleet/fleetLedger.js +164 -126
- package/dist/fleet/fleetProjection.d.ts +1 -0
- package/dist/fleet/fleetProjection.js +10 -3
- package/dist/fleetTaskDesc.js +4 -17
- package/dist/gateOutcome.d.ts +12 -1
- package/dist/gateOutcome.js +56 -1
- package/dist/gateVocabulary.d.ts +2 -2
- package/dist/gateVocabulary.js +4 -3
- package/dist/generated/engineAskFaceTables.js +1 -1
- package/dist/generated/engineFactTables.d.ts +5 -3
- package/dist/generated/engineFactTables.js +17 -4
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/sdkFactTables.d.ts +2 -0
- package/dist/generated/sdkFactTables.js +7 -0
- package/dist/generated/settingsSchemaFns.d.ts +3 -0
- package/dist/generated/settingsSchemaFns.js +53 -0
- package/dist/generated/toolNameTables.d.ts +1 -1
- package/dist/generated/toolNameTables.js +1 -42
- package/dist/hitl/approvalDecisionNoteAudit.js +2 -2
- package/dist/hitl/approvalEndingCause.d.ts +2 -0
- package/dist/hitl/approvalEndingCause.js +26 -21
- package/dist/hitl/approvalHolds.d.ts +16 -1
- package/dist/hitl/approvalHolds.js +52 -12
- package/dist/hitl/askGateWire.js +1 -0
- package/dist/hitl/askParkRowRouting.js +1 -1
- package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
- package/dist/hitl/automaticAnswerVerdict.js +13 -10
- package/dist/hitl/decisionConflict.js +4 -5
- package/dist/hitl/decisionRefusal.d.ts +8 -0
- package/dist/hitl/decisionRefusal.js +55 -14
- package/dist/hitl/frameRouter.d.ts +3 -1
- package/dist/hitl/frameRouter.js +58 -39
- package/dist/hitl/gateLedger.d.ts +0 -5
- package/dist/hitl/gateLedger.js +0 -21
- package/dist/hitl/hitlBridge.d.ts +6 -2
- package/dist/hitl/hitlBridge.js +46 -11
- package/dist/hitl/localAllowRule.d.ts +1 -0
- package/dist/hitl/localAllowRule.js +2 -2
- package/dist/hitl/noAllowCause.d.ts +2 -1
- package/dist/hitl/noAllowCause.js +3 -2
- package/dist/hitl/parkResolver.d.ts +1 -0
- package/dist/hitl/parkResolver.js +14 -56
- package/dist/hitl/parkRowBirthWait.d.ts +1 -0
- package/dist/hitl/parkRowBirthWait.js +2 -2
- package/dist/hitl/planReviewWire.d.ts +1 -0
- package/dist/hitl/planReviewWire.js +98 -20
- package/dist/hitl/replayedApproval.d.ts +3 -3
- package/dist/hitl/replayedApproval.js +21 -16
- package/dist/hitl/sessionPolicyDeliverable.d.ts +0 -1
- package/dist/hitl/sessionPolicyDeliverable.js +17 -17
- package/dist/hitl/sessionPolicyWire.d.ts +2 -0
- package/dist/hitl/sessionPolicyWire.js +15 -3
- package/dist/hitl/standingRows.d.ts +19 -0
- package/dist/hitl/standingRows.js +148 -0
- package/dist/hitl/suspendedReopen.js +2 -1
- package/dist/hitl/toolApprovalWire.d.ts +22 -10
- package/dist/hitl/toolApprovalWire.js +286 -47
- package/dist/hookMatcherVerdict.d.ts +1 -9
- package/dist/hookMatcherVerdict.js +21 -61
- package/dist/hooksWireCaps.js +2 -2
- package/dist/hostCallbackGuard.d.ts +1 -0
- package/dist/hostCallbackGuard.js +6 -0
- package/dist/index.d.ts +26 -12
- package/dist/index.js +20 -10
- package/dist/liveModelCatalog.d.ts +13 -0
- package/dist/liveModelCatalog.js +56 -0
- package/dist/mcpProbeCapability.d.ts +2 -4
- package/dist/mcpProbeCapability.js +3 -8
- package/dist/mcpWireCaps.d.ts +1 -0
- package/dist/mcpWireCaps.js +4 -1
- package/dist/memoryComplianceCapability.d.ts +2 -4
- package/dist/memoryComplianceCapability.js +3 -8
- package/dist/memoryOriginCapability.d.ts +2 -4
- package/dist/memoryOriginCapability.js +3 -8
- package/dist/memorySpecWire.js +2 -2
- package/dist/modelIdentityResolvability.d.ts +2 -2
- package/dist/modelIdentityResolvability.js +14 -5
- package/dist/noticePresentation.d.ts +68 -0
- package/dist/noticePresentation.js +247 -0
- package/dist/outputStyleSeatCapability.d.ts +2 -1
- package/dist/outputStyleSeatCapability.js +0 -4
- package/dist/ownKey.d.ts +2 -0
- package/dist/ownKey.js +18 -0
- package/dist/peerFrames.js +13 -9
- package/dist/peerLaneCapability.d.ts +2 -0
- package/dist/peerLaneCapability.js +3 -2
- package/dist/permissionModesCapability.d.ts +2 -4
- package/dist/permissionModesCapability.js +0 -7
- package/dist/permissionRuleIssue.js +0 -3
- package/dist/permissionRulesWriteCapability.d.ts +2 -0
- package/dist/permissionRulesWriteCapability.js +3 -2
- package/dist/permissionsAllowGrantCapability.d.ts +2 -0
- package/dist/permissionsAllowGrantCapability.js +4 -2
- package/dist/permissionsDeclaration.d.ts +2 -0
- package/dist/permissionsDeclaration.js +72 -59
- package/dist/printPermissionOutcome.d.ts +12 -0
- package/dist/printPermissionOutcome.js +50 -0
- package/dist/printToolResultFrame.d.ts +1 -0
- package/dist/printToolResultFrame.js +5 -9
- package/dist/promptBlockedCopy.d.ts +5 -0
- package/dist/promptBlockedCopy.js +35 -0
- package/dist/protocolSegment.d.ts +9 -6
- package/dist/protocolSegment.js +31 -21
- package/dist/providerRejection.d.ts +4 -0
- package/dist/providerRejection.js +75 -14
- package/dist/replayBody.d.ts +12 -0
- package/dist/replayBody.js +25 -0
- package/dist/request/taskRequest.d.ts +1 -4
- package/dist/request/taskRequest.js +74 -19
- package/dist/resumeRefusalCopy.js +9 -25
- package/dist/retryStatus.d.ts +9 -1
- package/dist/retryStatus.js +9 -2
- package/dist/rewindArchiveCapability.d.ts +3 -13
- package/dist/rewindArchiveCapability.js +12 -58
- package/dist/rewindArchiveReading.d.ts +17 -0
- package/dist/rewindArchiveReading.js +55 -0
- package/dist/ruleCompileVerdict.d.ts +9 -1
- package/dist/ruleCompileVerdict.js +29 -4
- package/dist/runTerminal.d.ts +48 -5
- package/dist/runTerminal.js +215 -12
- package/dist/sandboxWire.js +13 -0
- package/dist/sdkWireTransit.d.ts +2 -1
- package/dist/sdkWireTransit.js +1 -0
- package/dist/sealedKeyCapability.d.ts +2 -4
- package/dist/sealedKeyCapability.js +0 -7
- package/dist/seam.js +4 -2
- package/dist/seatContract.d.ts +76 -11
- package/dist/seatContract.js +222 -27
- package/dist/sessionPolicyCapability.d.ts +2 -0
- package/dist/sessionPolicyCapability.js +3 -2
- package/dist/sessionReadRedactionCapability.d.ts +2 -4
- package/dist/sessionReadRedactionCapability.js +0 -7
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +66 -0
- package/dist/sessionSyncFileHistoryCapability.d.ts +2 -1
- package/dist/sessionSyncFileHistoryCapability.js +3 -5
- package/dist/skillToolListsCapability.d.ts +2 -1
- package/dist/skillToolListsCapability.js +3 -5
- package/dist/sqlEngineCapability.d.ts +2 -0
- package/dist/sqlEngineCapability.js +4 -3
- package/dist/steerPriorityCapability.d.ts +2 -1
- package/dist/steerPriorityCapability.js +3 -5
- package/dist/storePostureCapability.d.ts +2 -4
- package/dist/storePostureCapability.js +4 -9
- package/dist/subagent/engineSubagentSteer.js +7 -5
- package/dist/subagentContentStore.js +4 -15
- package/dist/supportFloor.d.ts +1 -0
- package/dist/supportFloor.js +13 -9
- package/dist/systemReminderTag.d.ts +1 -0
- package/dist/systemReminderTag.js +8 -0
- package/dist/toolHistoryBadTurn.js +3 -2
- package/dist/toolHistoryMismatch.d.ts +0 -3
- package/dist/toolHistoryMismatch.js +3 -7
- package/dist/toolResult.d.ts +12 -1
- package/dist/toolResult.js +55 -1
- package/dist/toolResultContent.d.ts +2 -0
- package/dist/toolResultContent.js +63 -0
- package/dist/usageAnalytics.js +40 -16
- package/dist/userInvokedSkillsCapability.d.ts +2 -1
- package/dist/userInvokedSkillsCapability.js +3 -5
- package/dist/webSearchBackendCapability.d.ts +2 -0
- package/dist/webSearchBackendCapability.js +3 -2
- package/dist/wireErrorTriage.d.ts +2 -0
- package/dist/wireErrorTriage.js +91 -38
- package/dist/wireFailureShape.d.ts +20 -3
- package/dist/wireFailureShape.js +128 -72
- package/dist/workflowsJournalCapability.d.ts +2 -0
- package/dist/workflowsJournalCapability.js +3 -2
- package/dist/writeProtectionCapability.d.ts +2 -0
- package/dist/writeProtectionCapability.js +3 -2
- package/docs/INTEGRATION-CLIENTS.md +1784 -20
- package/package.json +5 -5
- package/dist/engineRefusedToolName.d.ts +0 -1
- package/dist/engineRefusedToolName.js +0 -8
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { CONFIG_LEGACY_TOOL_NAME, RULES_LEGACY_TOOL_NAME } from '../engineErrorCodes.js';
|
|
2
2
|
import { rosterMountedNames } from '../rosterMountedNames.js';
|
|
3
3
|
import { ruleCompileVerdict } from '../ruleCompileVerdict.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ruleToolNameVerdictOf } from '../protocolSegment.js';
|
|
5
5
|
import { PREFIXES_IN_PROSE, REFUSED_NAME_CLASSES, REFUSED_NAME_FIX, RULES_LEGACY_TOOL_NAME_WRITE_NOTE } from './refusedToolNameProse.js';
|
|
6
|
-
import { CORE_PROTOCOL_PREFIXES
|
|
7
|
-
import { isEngineRefusedToolName } from '../engineRefusedToolName.js';
|
|
6
|
+
import { CORE_PROTOCOL_PREFIXES } from '../generated/toolNameTables.js';
|
|
8
7
|
const COVERING_NAMESPACE_PREFIXES = CORE_PROTOCOL_PREFIXES;
|
|
9
|
-
const ENGINE_RETIRED_TOOL_NAMES = CORE_RETIRED_TOOL_CURRENT_NAMES;
|
|
10
8
|
const WITHHELD_NOTICE = {
|
|
11
9
|
ask_no_bucket: 'Not written to this session’s rule record: that record only holds rules that block outright, and this rule asks before running instead — recording it as a block would change what it means.',
|
|
12
10
|
qualified_deny: 'Not written to this session’s rule record: that record holds whole tool names and command names only, and this rule has a part in parentheses it cannot carry — recording just the name could block more than this rule does.',
|
|
@@ -37,11 +35,8 @@ function withheldWhyOf(rule) {
|
|
|
37
35
|
}
|
|
38
36
|
if (rule.trim() !== rule)
|
|
39
37
|
return 'not_a_tool_name';
|
|
40
|
-
if (isEngineRefusedToolName(rule))
|
|
41
|
-
return 'legacy_tool_name';
|
|
42
38
|
return undefined;
|
|
43
39
|
}
|
|
44
|
-
export { isEngineRefusedToolName } from '../engineRefusedToolName.js';
|
|
45
40
|
function suppliedRosterNames(opts) {
|
|
46
41
|
if (opts === undefined || opts === null)
|
|
47
42
|
return 'absent';
|
|
@@ -95,27 +90,32 @@ export function sessionPolicyDeliverable(behavior, rules, opts) {
|
|
|
95
90
|
continue;
|
|
96
91
|
}
|
|
97
92
|
let why = withheldWhyOf(r);
|
|
93
|
+
let currentName;
|
|
98
94
|
if (why === undefined) {
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
95
|
+
const verdict = ruleToolNameVerdictOf(r);
|
|
96
|
+
if (verdict.kind === 'unknown')
|
|
101
97
|
return unreadable();
|
|
102
|
-
if (
|
|
98
|
+
if (verdict.kind === 'retired' || verdict.kind === 'unprefixed_namespace') {
|
|
99
|
+
why = 'legacy_tool_name';
|
|
100
|
+
if (verdict.kind === 'retired')
|
|
101
|
+
currentName = verdict.currentName;
|
|
102
|
+
}
|
|
103
|
+
else if (verdict.kind === 'unmintable_segment')
|
|
103
104
|
why = 'not_a_tool_name';
|
|
104
105
|
}
|
|
105
|
-
if (why === undefined
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
why = 'not_a_tool_name';
|
|
109
|
-
else if (segment.kind === 'unknown')
|
|
106
|
+
if (why === undefined) {
|
|
107
|
+
const grammar = ruleCompileVerdict(r, 'deny').kind;
|
|
108
|
+
if (grammar === 'unknown')
|
|
110
109
|
return unreadable();
|
|
110
|
+
if (grammar === 'refused')
|
|
111
|
+
why = 'not_a_tool_name';
|
|
111
112
|
}
|
|
112
113
|
if (why === undefined && mounted !== undefined && !mounted.has(r))
|
|
113
114
|
why = 'not_in_roster';
|
|
114
115
|
if (why === undefined)
|
|
115
116
|
exact.push(r);
|
|
116
117
|
else {
|
|
117
|
-
|
|
118
|
-
withheld.push(typeof currentName === 'string' ? { rule: r, why, currentName } : { rule: r, why });
|
|
118
|
+
withheld.push(why === 'legacy_tool_name' && currentName !== undefined ? { rule: r, why, currentName } : { rule: r, why });
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
if (withheld.length > 0 || exact.length === 0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { wireFailureShapeOf } from '../wireFailureShape.js';
|
|
2
2
|
import { hostLog } from '../host.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ruleToolNameVerdictOf } from '../protocolSegment.js';
|
|
4
4
|
import { RULES_LEGACY_TOOL_NAME_WRITE_NOTE } from './refusedToolNameProse.js';
|
|
5
5
|
import { RULES_LEGACY_TOOL_NAME, isRulesRefusalCode } from '../engineErrorCodes.js';
|
|
6
6
|
import { rosterMountedNames } from '../rosterMountedNames.js';
|
|
@@ -434,7 +434,14 @@ function withoutRefusedEntries(prior, mounted) {
|
|
|
434
434
|
const kept = [];
|
|
435
435
|
const seen = new Set();
|
|
436
436
|
for (const x of list) {
|
|
437
|
-
if (
|
|
437
|
+
if (mounted.has(x)) {
|
|
438
|
+
kept.push(x);
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const kind = ruleToolNameVerdictOf(x).kind;
|
|
442
|
+
if (kind === 'unknown')
|
|
443
|
+
return 'judge_failed';
|
|
444
|
+
if (kind === 'current') {
|
|
438
445
|
kept.push(x);
|
|
439
446
|
continue;
|
|
440
447
|
}
|
|
@@ -479,7 +486,10 @@ async function attemptRemoval(facade, sessionId, mounted, opts) {
|
|
|
479
486
|
return { done: removalFailed(read.failure, 'read') };
|
|
480
487
|
if (read.kind === 'malformed')
|
|
481
488
|
return { done: { kind: 'read_failed', why: 'read_unreadable', message: read.detail } };
|
|
482
|
-
const
|
|
489
|
+
const judged = withoutRefusedEntries(read.rules, mounted);
|
|
490
|
+
if (judged === 'judge_failed')
|
|
491
|
+
return { done: { kind: 'judge_failed' } };
|
|
492
|
+
const { next, removed } = judged;
|
|
483
493
|
if (removed.length === 0)
|
|
484
494
|
return { done: { kind: 'nothing_to_remove', rev: read.rev } };
|
|
485
495
|
let receipt;
|
|
@@ -563,6 +573,8 @@ export function sessionPolicyRemovalNotice(outcome) {
|
|
|
563
573
|
}
|
|
564
574
|
case 'nothing_to_remove':
|
|
565
575
|
return 'This session’s rule record holds no entry naming a tool the engine refuses that the supplied roster does not mount, so nothing was changed. If runs still fail at startup over a refused tool name, that entry is set somewhere this record does not cover — the settings sent with the run, a parent session’s rule record, or the deployment’s own tool rules — or it is a name the engine refuses that this version does not yet recognise, or the failing run does not mount a tool the supplied roster has under that name.';
|
|
576
|
+
case 'judge_failed':
|
|
577
|
+
return 'Nothing was changed: this client could not check which entries in this session’s rule record name a tool the engine refuses (its copy of the engine’s tool-name check is unavailable or gave no clear answer), so it removed none rather than guess. Removing them needs that check available in this client.';
|
|
566
578
|
case 'loosen_forbidden':
|
|
567
579
|
return 'The engine refused to take these entries out of this session’s rule record: on this engine only an operator can remove entries from it, so the record is unchanged. Ask an operator to remove them, or continue in a new session.';
|
|
568
580
|
case 'conflict':
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type StandingRowWhy = 'given' | 'card_unreadable' | 'remember_refused' | 'remember_unreadable' | 'route_cannot_carry' | 'classes_unreadable' | 'not_deployment_list_question' | 'evidence_unreadable' | 'offers_unreadable' | 'engine_lane_closed' | 'args_unavailable' | 'grant_binding' | 'tool_name_unreadable' | 'rule_cannot_clear' | 'host_fact_missing' | 'face_not_generic' | 'rule_not_sent';
|
|
2
|
+
export type StandingPersistentRow = 'engine_offer' | 'local_whole_tool' | 'none';
|
|
3
|
+
export interface StandingRowsWhy {
|
|
4
|
+
readonly session: StandingRowWhy;
|
|
5
|
+
readonly persistent: StandingRowWhy;
|
|
6
|
+
readonly deploymentList: StandingRowWhy;
|
|
7
|
+
}
|
|
8
|
+
export interface StandingRows {
|
|
9
|
+
readonly sessionRow: boolean;
|
|
10
|
+
readonly persistentRow: StandingPersistentRow;
|
|
11
|
+
readonly deploymentListSessionRow: boolean;
|
|
12
|
+
readonly why: StandingRowsWhy;
|
|
13
|
+
}
|
|
14
|
+
export interface StandingRowsHostFacts {
|
|
15
|
+
readonly cardFace?: string;
|
|
16
|
+
readonly wholeToolRuleSent?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function standingRowsOf(card: object | null | undefined, host?: StandingRowsHostFacts | null): StandingRows;
|
|
19
|
+
export declare function seatSessionRowOf(card: object | null | undefined, requestId: string | undefined): boolean;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { readAskClassPairState } from './askClassPair.js';
|
|
2
|
+
import { automaticAnswerVerdict } from './automaticAnswerVerdict.js';
|
|
3
|
+
import { readRuleOffers } from './toolApprovalWire.js';
|
|
4
|
+
import { toolPermissionRequestIdDomain } from '../seatContract.js';
|
|
5
|
+
const DEPLOYMENT_LIST_ASK_CLASSES = Object.freeze(['ask_rule']);
|
|
6
|
+
const UNREADABLE = Symbol('unreadable');
|
|
7
|
+
function ownData(v, key) {
|
|
8
|
+
try {
|
|
9
|
+
const d = Object.getOwnPropertyDescriptor(v, key);
|
|
10
|
+
return d !== undefined && 'value' in d ? d.value : undefined;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function hasKey(v, key) {
|
|
17
|
+
try {
|
|
18
|
+
return { inCard: key in v };
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return UNREADABLE;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function present(v, key) {
|
|
25
|
+
try {
|
|
26
|
+
const inCard = key in v;
|
|
27
|
+
return { inCard, value: inCard ? v[key] : undefined };
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return UNREADABLE;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function freezeRows(sessionRow, persistentRow, deploymentListSessionRow, why) {
|
|
34
|
+
return Object.freeze({ sessionRow, persistentRow, deploymentListSessionRow, why: Object.freeze({ ...why }) });
|
|
35
|
+
}
|
|
36
|
+
function allClosed(why) {
|
|
37
|
+
return freezeRows(false, 'none', false, { session: why, persistent: why, deploymentList: why });
|
|
38
|
+
}
|
|
39
|
+
function persistentRowOf(card, host, evidenceUnreadable) {
|
|
40
|
+
if (evidenceUnreadable)
|
|
41
|
+
return { row: 'none', why: 'evidence_unreadable' };
|
|
42
|
+
for (const key of ['ruleOffers', 'ruleOffersReadOnly']) {
|
|
43
|
+
const p = hasKey(card, key);
|
|
44
|
+
if (p === UNREADABLE)
|
|
45
|
+
return UNREADABLE;
|
|
46
|
+
if (!p.inCard)
|
|
47
|
+
continue;
|
|
48
|
+
const offers = readRuleOffers(ownData(card, key));
|
|
49
|
+
if (offers === undefined || offers.length === 0)
|
|
50
|
+
return { row: 'none', why: 'offers_unreadable' };
|
|
51
|
+
return { row: 'engine_offer', why: 'given' };
|
|
52
|
+
}
|
|
53
|
+
const absence = present(card, 'ruleOffersAbsence');
|
|
54
|
+
if (absence === UNREADABLE)
|
|
55
|
+
return UNREADABLE;
|
|
56
|
+
if (absence.inCard)
|
|
57
|
+
return { row: 'none', why: 'engine_lane_closed' };
|
|
58
|
+
const blind = present(card, 'argsUnavailable');
|
|
59
|
+
if (blind === UNREADABLE)
|
|
60
|
+
return UNREADABLE;
|
|
61
|
+
if (blind.inCard)
|
|
62
|
+
return { row: 'none', why: 'args_unavailable' };
|
|
63
|
+
if (ownData(card, 'grantBinding') !== 'none')
|
|
64
|
+
return { row: 'none', why: 'grant_binding' };
|
|
65
|
+
const tool = ownData(card, 'toolName');
|
|
66
|
+
if (typeof tool !== 'string' || tool.length === 0)
|
|
67
|
+
return { row: 'none', why: 'tool_name_unreadable' };
|
|
68
|
+
if (automaticAnswerVerdict(card, 'standing_rule').kind !== 'may_answer')
|
|
69
|
+
return { row: 'none', why: 'rule_cannot_clear' };
|
|
70
|
+
if (typeof host !== 'object' || host === null)
|
|
71
|
+
return { row: 'none', why: 'host_fact_missing' };
|
|
72
|
+
const face = ownData(host, 'cardFace');
|
|
73
|
+
if (typeof face !== 'string')
|
|
74
|
+
return { row: 'none', why: 'host_fact_missing' };
|
|
75
|
+
if (face !== 'generic')
|
|
76
|
+
return { row: 'none', why: 'face_not_generic' };
|
|
77
|
+
const sent = ownData(host, 'wholeToolRuleSent');
|
|
78
|
+
if (typeof sent !== 'boolean')
|
|
79
|
+
return { row: 'none', why: 'host_fact_missing' };
|
|
80
|
+
if (!sent)
|
|
81
|
+
return { row: 'none', why: 'rule_not_sent' };
|
|
82
|
+
return { row: 'local_whole_tool', why: 'given' };
|
|
83
|
+
}
|
|
84
|
+
function enginePremiseOf(card) {
|
|
85
|
+
const refused = present(card, 'rememberRefused');
|
|
86
|
+
if (refused === UNREADABLE)
|
|
87
|
+
return 'card_unreadable';
|
|
88
|
+
if (refused.inCard)
|
|
89
|
+
return refused.value === true ? 'remember_refused' : 'remember_unreadable';
|
|
90
|
+
const evidence = present(card, 'unreadableEvidence');
|
|
91
|
+
if (evidence === UNREADABLE)
|
|
92
|
+
return 'card_unreadable';
|
|
93
|
+
if (!evidence.inCard)
|
|
94
|
+
return { evidenceUnreadable: false };
|
|
95
|
+
const list = ownData(card, 'unreadableEvidence');
|
|
96
|
+
if (!Array.isArray(list) || !list.every((k) => typeof k === 'string'))
|
|
97
|
+
return 'card_unreadable';
|
|
98
|
+
if (list.includes('rememberRefused'))
|
|
99
|
+
return 'remember_unreadable';
|
|
100
|
+
return { evidenceUnreadable: list.length > 0 };
|
|
101
|
+
}
|
|
102
|
+
export function standingRowsOf(card, host) {
|
|
103
|
+
if (typeof card !== 'object' || card === null)
|
|
104
|
+
return allClosed('card_unreadable');
|
|
105
|
+
try {
|
|
106
|
+
const premise = enginePremiseOf(card);
|
|
107
|
+
if (typeof premise === 'string')
|
|
108
|
+
return allClosed(premise);
|
|
109
|
+
const evidenceUnreadable = premise.evidenceUnreadable;
|
|
110
|
+
const sessionRow = ownData(card, 'allowSessionCarried') === true;
|
|
111
|
+
const sessionWhy = sessionRow ? 'given' : 'route_cannot_carry';
|
|
112
|
+
let deploymentList;
|
|
113
|
+
if (!sessionRow) {
|
|
114
|
+
deploymentList = 'route_cannot_carry';
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const pair = readAskClassPairState(card);
|
|
118
|
+
deploymentList =
|
|
119
|
+
pair.state !== 'pair'
|
|
120
|
+
? 'classes_unreadable'
|
|
121
|
+
: pair.classes.every((c) => DEPLOYMENT_LIST_ASK_CLASSES.includes(c))
|
|
122
|
+
? 'given'
|
|
123
|
+
: 'not_deployment_list_question';
|
|
124
|
+
}
|
|
125
|
+
const persistent = persistentRowOf(card, host, evidenceUnreadable);
|
|
126
|
+
if (persistent === UNREADABLE)
|
|
127
|
+
return allClosed('card_unreadable');
|
|
128
|
+
return freezeRows(sessionRow, persistent.row, deploymentList === 'given', { session: sessionWhy, persistent: persistent.why, deploymentList });
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return allClosed('card_unreadable');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export function seatSessionRowOf(card, requestId) {
|
|
135
|
+
if (typeof card !== 'object' || card === null)
|
|
136
|
+
return false;
|
|
137
|
+
try {
|
|
138
|
+
if (Object.hasOwn(card, 'requestId'))
|
|
139
|
+
return false;
|
|
140
|
+
const domain = toolPermissionRequestIdDomain(requestId);
|
|
141
|
+
if (domain !== 'live:' && domain !== 'durable:')
|
|
142
|
+
return false;
|
|
143
|
+
return typeof enginePremiseOf(card) !== 'string';
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RESUME_REOPEN_CODES, RESUME_ENV_FAILED, RESUME_TOOL_UNAVAILABLE, refusalSaysStillPending } from '../engineErrorCodes.js';
|
|
2
|
+
import { guardedRead, ownDataField } from '../ownKey.js';
|
|
2
3
|
const UNSTATED = Object.freeze({ kind: 'unstated' });
|
|
3
4
|
const NOT_REOPENED = Object.freeze({ kind: 'not_reopened' });
|
|
4
5
|
export function suspendedReopenOf(ev) {
|
|
@@ -22,7 +23,7 @@ export function suspendedReopenOf(ev) {
|
|
|
22
23
|
export function resumeReopenFromError(err) {
|
|
23
24
|
if (typeof err !== 'object' || err === null)
|
|
24
25
|
return null;
|
|
25
|
-
const code = err
|
|
26
|
+
const code = guardedRead(() => ownDataField(err, 'errorCode'));
|
|
26
27
|
if (typeof code !== 'string' || !RESUME_REOPEN_CODES.includes(code))
|
|
27
28
|
return null;
|
|
28
29
|
if (!refusalSaysStillPending(err))
|
|
@@ -6,11 +6,7 @@ import { type DenyAttributionRefusalDetail } from '../wireRefusalCopy.js';
|
|
|
6
6
|
import { type ApprovalDecidedByReading } from '../approvalDecidedByCapability.js';
|
|
7
7
|
import { type DecideReceiptView } from '../decideReceipt.js';
|
|
8
8
|
import { RULE_OFFER_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_UNCOVERED_REASONS, RULE_OFFERS_ABSENCE_REASONS } from '@sema-agent/sdk';
|
|
9
|
-
import type { ApprovalDecidedBy, ApprovalSettleCause, ToolApprovalRespondAck, PersistedRuleAnchor as SdkPersistedRuleAnchor, RuleOfferMatch as SdkRuleOfferMatch, RuleOfferBatchMember as SdkRuleOfferBatchMember, RuleOfferUncoveredDetail as SdkRuleOfferUncoveredDetail, RuleOfferUncoveredReason as SdkRuleOfferUncoveredReason, AskOrigin as SdkAskOrigin, RuleOffersAbsence as SdkRuleOffersAbsence, DenialLimitKind as SdkDenialLimitKind, DenialLimitFallback as SdkDenialLimitFallback } from '@sema-agent/sdk';
|
|
10
|
-
export declare function isFsApprovalGate(gate: {
|
|
11
|
-
kind?: unknown;
|
|
12
|
-
toolName?: unknown;
|
|
13
|
-
} | undefined | null): boolean;
|
|
9
|
+
import type { ApprovalDecidedBy, ApprovalSettleCause, ToolApprovalRespondAck, PersistedRuleAnchor as SdkPersistedRuleAnchor, RuleOfferMatch as SdkRuleOfferMatch, RuleOfferBatchMember as SdkRuleOfferBatchMember, RuleOfferUncoveredDetail as SdkRuleOfferUncoveredDetail, RuleOfferUncoveredReason as SdkRuleOfferUncoveredReason, AskOrigin as SdkAskOrigin, RuleOffersAbsence as SdkRuleOffersAbsence, DenialLimitKind as SdkDenialLimitKind, DenialLimitFallback as SdkDenialLimitFallback, ToolApprovalCardWord } from '@sema-agent/sdk';
|
|
14
10
|
export declare function toolNameIsFsWrite(name: string): boolean;
|
|
15
11
|
export declare function toolNameIsShellExec(name: string): boolean;
|
|
16
12
|
export declare function isToolApprovalGate(gate: {
|
|
@@ -40,8 +36,9 @@ export type FsApprovalOutcome = {
|
|
|
40
36
|
stage: HitlFailureStage;
|
|
41
37
|
gatedCallId?: string | undefined;
|
|
42
38
|
reason: string;
|
|
43
|
-
code?: 'no_pending' | undefined;
|
|
39
|
+
code?: 'no_pending' | 'wrong_gate' | undefined;
|
|
44
40
|
errorCode?: string | undefined;
|
|
41
|
+
blockedBy?: string | undefined;
|
|
45
42
|
retriable?: true;
|
|
46
43
|
safetyCode?: HitlSafetyCode | undefined;
|
|
47
44
|
retryExhausted?: true;
|
|
@@ -68,7 +65,6 @@ export type DenialLimitKind = SdkDenialLimitKind;
|
|
|
68
65
|
export type DenialLimitFallback = SdkDenialLimitFallback;
|
|
69
66
|
export { RULE_OFFERS_ABSENCE_REASONS };
|
|
70
67
|
export declare const ASK_ORIGIN_WORDS: readonly string[];
|
|
71
|
-
export declare const APPROVAL_MANDATE_WORDS: readonly ["operator_always", "tool_marks", "probe_mandate", "probe_unanswered", "write_protection", "write_protection_unresolved"];
|
|
72
68
|
export type WireRuleOffer = {
|
|
73
69
|
kind: 'single';
|
|
74
70
|
rule: string;
|
|
@@ -141,6 +137,7 @@ export interface ApprovalCardRequest {
|
|
|
141
137
|
probeCause?: unknown;
|
|
142
138
|
probeReason?: string;
|
|
143
139
|
rememberRefused?: true;
|
|
140
|
+
allowSessionCarried?: true;
|
|
144
141
|
ruleEvidence?: unknown;
|
|
145
142
|
requiresRealApproval?: true;
|
|
146
143
|
irreversibleParkGate?: true;
|
|
@@ -154,9 +151,12 @@ export interface ApprovalCardRequest {
|
|
|
154
151
|
mandate?: ApprovalMandateWord;
|
|
155
152
|
denialLimitFallback?: DenialLimitFallback;
|
|
156
153
|
origin?: string;
|
|
154
|
+
approvalCard?: ToolApprovalCardWord;
|
|
157
155
|
askClass?: string;
|
|
158
156
|
classes?: readonly string[];
|
|
159
157
|
boundGrants?: BoundSkillGrantsWire;
|
|
158
|
+
grantBinding?: ApprovalGrantBinding;
|
|
159
|
+
unreadableEvidence?: readonly string[];
|
|
160
160
|
classifierNoRuling?: string;
|
|
161
161
|
priorCardsForCall?: readonly ApprovalPriorCard[];
|
|
162
162
|
}
|
|
@@ -174,12 +174,13 @@ export declare function approvalCardPortMissesFor(sessionKey: string): number;
|
|
|
174
174
|
export declare function hasApprovalCardPort(): boolean;
|
|
175
175
|
export declare function hasApprovalCardPortFor(sessionKey: string): boolean;
|
|
176
176
|
export declare function approvalCardPortFor(sessionKey: string): ApprovalCardPort | null;
|
|
177
|
+
export declare function __resetSettledApprovalsForTests(): void;
|
|
177
178
|
export declare function _resetApprovalCardPortForTest(): void;
|
|
178
179
|
export declare function surfaceApprovalCard(req: ApprovalCardRequest): Promise<ApprovalCardDecision>;
|
|
179
180
|
declare const REMEMBER_REFUSAL_CODES: readonly ["remember_not_in_proof", "remember_requires_binding", "capability.store_required", "decide.workflow_remember_unsupported", "decide.parked_remember_unsupported"];
|
|
180
181
|
export type RememberRefusalCode = (typeof REMEMBER_REFUSAL_CODES)[number];
|
|
181
182
|
export declare function rememberRefusalOf(error: unknown): RememberRefusalCode | undefined;
|
|
182
|
-
export declare function surfaceFsApprovalAndDecide(deps: FsApprovalWireDeps, taskId: string, argsByCall: Map<string, unknown>, signal?: AbortSignal, parkGatedCallId?: string): Promise<FsApprovalOutcome>;
|
|
183
|
+
export declare function surfaceFsApprovalAndDecide(deps: FsApprovalWireDeps, taskId: string, argsByCall: Map<string, unknown>, signal?: AbortSignal, parkGatedCallId?: string, parkToolName?: string): Promise<FsApprovalOutcome>;
|
|
183
184
|
export interface BoundSkillGrantsWire {
|
|
184
185
|
readonly skill: string | null;
|
|
185
186
|
readonly allowedTools: readonly string[];
|
|
@@ -216,6 +217,7 @@ export interface ToolApprovalFrame {
|
|
|
216
217
|
mandated?: true;
|
|
217
218
|
mandate?: string;
|
|
218
219
|
origin?: string;
|
|
220
|
+
approvalCard?: string;
|
|
219
221
|
askClass?: string;
|
|
220
222
|
classes?: readonly string[];
|
|
221
223
|
inputHasBidi?: true;
|
|
@@ -235,7 +237,7 @@ export interface ToolApprovalDelegation {
|
|
|
235
237
|
depth: number;
|
|
236
238
|
agentName?: string;
|
|
237
239
|
}
|
|
238
|
-
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", "askClass", "classes", "inputHasBidi", "parked", "persistedRuleShadowed", "allowRuleShadowed", "probeCause", "probeReason", "rememberRefused", "boundGrantDigest", "boundGrants", "classifierNoRuling", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome", "cause"];
|
|
240
|
+
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", "boundGrants", "classifierNoRuling", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome", "cause"];
|
|
239
241
|
export interface ApprovalMandatedFacts {
|
|
240
242
|
readonly mandated?: true;
|
|
241
243
|
readonly ruleOffersAbsence?: string;
|
|
@@ -245,7 +247,8 @@ export declare function approvalIsMandated(v: ApprovalMandatedFacts | undefined
|
|
|
245
247
|
export declare function readApprovalMandate(v: {
|
|
246
248
|
readonly mandate?: string;
|
|
247
249
|
} | undefined | null): ApprovalMandateWord | undefined;
|
|
248
|
-
export declare function
|
|
250
|
+
export declare function readApprovalCardWord(carrier: unknown): ToolApprovalCardWord | undefined;
|
|
251
|
+
export declare function toolPermissionRequestAskBits(card: object | null | undefined, requestId?: string): Pick<ToolPermissionRequest, 'mandated' | 'mandate' | 'origin' | 'ruleOffersAbsence' | 'askClass' | 'classes' | 'sessionRow'>;
|
|
249
252
|
export declare function isFromSubagent(frame: ToolApprovalFrame): boolean;
|
|
250
253
|
export type ToolApprovalRespondDecision = 'allow' | 'allow_session' | 'deny';
|
|
251
254
|
export interface RespondToolApprovalOpts {
|
|
@@ -299,6 +302,12 @@ interface ToolApprovalRespondRefusalFields {
|
|
|
299
302
|
status?: number;
|
|
300
303
|
errorCode?: string;
|
|
301
304
|
message?: string;
|
|
305
|
+
retriable?: true;
|
|
306
|
+
extra?: {
|
|
307
|
+
readonly cause?: string;
|
|
308
|
+
readonly field?: string;
|
|
309
|
+
};
|
|
310
|
+
unreadable?: true;
|
|
302
311
|
}
|
|
303
312
|
export type ToolApprovalRespondRefusal = (ToolApprovalRespondRefusalFields & {
|
|
304
313
|
status: number;
|
|
@@ -312,6 +321,7 @@ export declare function isToolApprovalFrame(ev: unknown): ev is ToolApprovalFram
|
|
|
312
321
|
export declare function askProbeReasonDetail(card: Pick<ApprovalCardRequest, 'probeReason' | 'probeCause'> | null | undefined): string | undefined;
|
|
313
322
|
export declare function readApprovalRememberRefused(v: unknown): boolean;
|
|
314
323
|
export declare function readApprovalBoundGrants(v: unknown): BoundSkillGrantsWire | undefined;
|
|
324
|
+
export type ApprovalGrantBinding = 'bound' | 'none' | 'unreadable';
|
|
315
325
|
export declare function readApprovalClassifierNoRuling(v: unknown): string | undefined;
|
|
316
326
|
export declare function classifierNoRulingDetail(word: string | undefined): string;
|
|
317
327
|
export declare function approvalBoundGrantsDetail(grants: BoundSkillGrantsWire | null | undefined): string | undefined;
|
|
@@ -319,6 +329,8 @@ export declare function approvalPriorCardsDetail(card: Pick<ApprovalCardRequest,
|
|
|
319
329
|
export declare function readDenialLimitFallback(v: unknown): DenialLimitFallback | undefined;
|
|
320
330
|
export declare function readRuleOffers(v: unknown): RuleOffer[] | undefined;
|
|
321
331
|
export declare function readRuleOfferSupply(offers: unknown): RuleOffer[] | undefined;
|
|
332
|
+
export type ApprovalCardV1Facts = Pick<ApprovalCardRequest, 'toolName' | 'args'> & Pick<ApprovalCardRequest, 'toolCallId' | 'workerBadge' | 'wireNote' | 'argsUnavailable' | 'governanceForced' | 'delegation' | 'ruleOffersReadOnly' | 'inputHasBidi' | 'allowRuleShadow' | 'probeCause' | 'rememberRefused' | 'ruleEvidence' | 'requiresRealApproval' | 'ruleOffersAbsence' | 'denialLimitFallback' | 'askClass' | 'classes' | 'grantBinding' | 'unreadableEvidence'>;
|
|
333
|
+
export declare function approvalCardFactsOfV1(card: object | null | undefined): Readonly<ApprovalCardV1Facts> | undefined;
|
|
322
334
|
export interface ToolApprovalFrameLaneOpts {
|
|
323
335
|
approvalDecisionNoteCapable?: boolean;
|
|
324
336
|
respondFreeFormRulesCapable?: boolean;
|