@sema-agent/client-core 0.83.1 → 0.83.2

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.
@@ -1,5 +1,6 @@
1
1
  import { type GateCurrentPending, type HitlFailureStage, type HitlSafetyCode, type HitlClientLike, type DecideOperationObserver } from './hitlBridge.js';
2
2
  import { type RuleStoreUnreadableKind } from '../gateVocabulary.js';
3
+ import { type ApprovalMandateWord } from '../gateVocabulary.js';
3
4
  import { type DenyAttributionRefusalDetail } from '../wireRefusalCopy.js';
4
5
  import { type DecideReceiptView } from '../decideReceipt.js';
5
6
  import { RULE_OFFER_MATCHES, RULE_OFFER_BATCH_MEMBER_KINDS, RULE_OFFER_UNCOVERED_REASONS, RULE_OFFERS_ABSENCE_REASONS, DENIAL_LIMIT_KINDS } from '@sema-agent/sdk';
@@ -137,6 +138,7 @@ export interface ApprovalCardRequest {
137
138
  receivedAtMs?: number;
138
139
  ruleOffersAbsence?: string;
139
140
  mandated?: true;
141
+ mandate?: ApprovalMandateWord;
140
142
  denialLimitFallback?: DenialLimitFallback;
141
143
  origin?: string;
142
144
  ruleStoreUnreadable?: RuleStoreUnreadableKind;
@@ -176,6 +178,7 @@ export interface ToolApprovalFrame {
176
178
  ruleEvidence?: unknown;
177
179
  requiresRealApproval?: true;
178
180
  mandated?: true;
181
+ mandate?: string;
179
182
  origin?: string;
180
183
  inputHasBidi?: true;
181
184
  parked?: true;
@@ -194,11 +197,16 @@ export interface ToolApprovalDelegation {
194
197
  depth: number;
195
198
  agentName?: string;
196
199
  }
197
- export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleSuggestions", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "ruleStoreUnreadable", "readRootCandidate", "mandated", "origin", "inputHasBidi", "parked", "persistedRuleShadowed", "probeCause", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome"];
198
- export declare function approvalIsMandated(v: {
199
- mandated?: true;
200
- ruleOffersAbsence?: string;
201
- } | undefined | null): boolean;
200
+ export declare const TOOL_APPROVAL_FRAME_KEYS_MIRROR: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceTaskId", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "ruleSuggestions", "ruleOffers", "ruleOffersAbsence", "denialLimitFallback", "ruleStoreUnreadable", "readRootCandidate", "mandated", "mandate", "origin", "inputHasBidi", "parked", "persistedRuleShadowed", "probeCause", "ruleEvidence", "requiresRealApproval", "expiresInMs", "expiresAtMs", "serverNowMs", "delegation", "outcome"];
201
+ export interface ApprovalMandatedFacts {
202
+ readonly mandated?: true;
203
+ readonly ruleOffersAbsence?: string;
204
+ readonly mandate?: string;
205
+ }
206
+ export declare function approvalIsMandated(v: ApprovalMandatedFacts | undefined | null): boolean;
207
+ export declare function readApprovalMandate(v: {
208
+ readonly mandate?: string;
209
+ } | undefined | null): ApprovalMandateWord | undefined;
202
210
  export declare function isFromSubagent(frame: ToolApprovalFrame): boolean;
203
211
  export type ToolApprovalRespondDecision = 'allow' | 'allow_session' | 'deny';
204
212
  export interface RespondToolApprovalOpts {
@@ -1,11 +1,13 @@
1
1
  import { DEFAULT_DENY_REASON, DecideTransportRetryExhaustedError, HitlBridge, HitlSafetyError, denyReasonForWire, findPendingForTask, readDecideCurrentPending, readWireErrorCode, } from './hitlBridge.js';
2
2
  import { askParkRowArm } from './askParkRowRouting.js';
3
3
  import { hostLog } from '../host.js';
4
+ import { readOwnNonEmptyString } from '../ownKey.js';
4
5
  import { createSessionSlot, DEFAULT_SESSION_KEY } from '../sessionSlot.js';
5
6
  import { readEngineActiveBgTasks } from '../fleet/fleetLedger.js';
6
7
  import { observeCancelByDeny, surfaceRememberNotApplied, surfaceEditNotForwarded, surfaceEditRefusedOnBlindAsk, surfaceRuleArmNotSent, surfaceRuleArmRejected } from './hitlHostSurface.js';
7
8
  import { approvalCallKey, liveFrameCallKey } from './gateIdentity.js';
8
9
  import { isRuleStoreUnreadableKind } from '../gateVocabulary.js';
10
+ import { isApprovalMandateWord } from '../gateVocabulary.js';
9
11
  import { denyAttributionRefusalFromError } from '../wireRefusalCopy.js';
10
12
  import { decideFailureNote } from '../decideFailureNote.js';
11
13
  import { readDecideReceipt } from '../decideReceipt.js';
@@ -205,6 +207,8 @@ export async function surfaceFsApprovalAndDecide(deps, taskId, argsByCall, signa
205
207
  ...(pending.governanceForced === true ? { governanceForced: true } : {}),
206
208
  ...(pending.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
207
209
  ...(pending.mandated === true ? { mandated: true } : {}),
210
+ ...((w) => (w !== undefined ? { mandate: w } : {}))(readApprovalMandate(pending)),
211
+ ...((o) => (o !== undefined ? { origin: o } : {}))(readOwnNonEmptyString(pending, 'origin')),
208
212
  ...(pending.gateKind === 'irreversible_ask' ? { irreversibleParkGate: true } : {}),
209
213
  ...(pending.hasBidiControls === true ? { hasBidiControls: true } : {}),
210
214
  ...(ruleOffersReadOnly !== undefined ? { ruleOffersReadOnly } : {}),
@@ -379,6 +383,7 @@ export const TOOL_APPROVAL_FRAME_KEYS_MIRROR = [
379
383
  'ruleStoreUnreadable',
380
384
  'readRootCandidate',
381
385
  'mandated',
386
+ 'mandate',
382
387
  'origin',
383
388
  'inputHasBidi',
384
389
  'parked',
@@ -400,7 +405,15 @@ export function approvalIsMandated(v) {
400
405
  return false;
401
406
  if (v.mandated === true)
402
407
  return true;
403
- return v.ruleOffersAbsence === MANDATED_ABSENCE_WORD;
408
+ if (v.ruleOffersAbsence === MANDATED_ABSENCE_WORD)
409
+ return true;
410
+ return readApprovalMandate(v) !== undefined;
411
+ }
412
+ export function readApprovalMandate(v) {
413
+ if (typeof v !== 'object' || v === null || !Object.hasOwn(v, 'mandate'))
414
+ return undefined;
415
+ const raw = v.mandate;
416
+ return isApprovalMandateWord(raw) ? raw : undefined;
404
417
  }
405
418
  function isToolApprovalDelegation(v) {
406
419
  if (v === null || typeof v !== 'object')
@@ -828,6 +841,7 @@ export async function surfaceToolApprovalFrameAndRespond(frame, respond, streamA
828
841
  ...(isWireRecordCarrier(frame.ruleEvidence) ? { ruleEvidence: frame.ruleEvidence } : {}),
829
842
  ...(frame.requiresRealApproval === true ? { requiresRealApproval: true } : {}),
830
843
  ...(frame.mandated === true ? { mandated: true } : {}),
844
+ ...((w) => (w !== undefined ? { mandate: w } : {}))(readApprovalMandate(frame)),
831
845
  ...(() => { const rc = readReadRootCandidate(frame.readRootCandidate); return rc !== undefined ? { readRootCandidate: rc } : {}; })(),
832
846
  ...(frame.inputHasBidi === true ? { inputHasBidi: true } : {}),
833
847
  ...(typeof frame.ruleOffersAbsence === 'string' && frame.ruleOffersAbsence !== ''
@@ -835,7 +849,7 @@ export async function surfaceToolApprovalFrameAndRespond(frame, respond, streamA
835
849
  : {}),
836
850
  ...(denialLimitFallback !== undefined ? { denialLimitFallback } : {}),
837
851
  ...((k) => (k !== undefined ? { ruleStoreUnreadable: k } : {}))(readRuleStoreUnreadable(frame.ruleStoreUnreadable)),
838
- ...(typeof frame.origin === 'string' && frame.origin !== '' ? { origin: frame.origin } : {}),
852
+ ...((o) => (o !== undefined ? { origin: o } : {}))(readOwnNonEmptyString(frame, 'origin')),
839
853
  });
840
854
  if (argsNotRealInput && card.kind === 'allow' && card.updatedInput !== undefined) {
841
855
  hostLog('error', `liveToolApprovalWire: ${approvalId} card returned an edited approval on a card whose arguments are not the tool's real input (${lane?.argsUnavailable === true ? 'args-unavailable ask' : 'arguments omitted or absent on the frame'}) — nothing sent (the ask stays pending)`);
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from './sdkWireTransit.js';
14
14
  export { SEMA_SEGMENT_ID_KEY } from './adapt/textStream.js';
15
15
  export * from './subagentContentStore.js';
16
16
  export * from './engineAgentPanelStore.js';
17
+ export * from './engineAgentAbsence.js';
17
18
  export * from './fleetAgentPanelProjection.js';
18
19
  export * from './liveQuestionStore.js';
19
20
  export * from './engineInlineTaskStats.js';
@@ -166,6 +167,7 @@ export * from './hitl/sessionPolicyWire.js';
166
167
  export * from './hitl/sessionPolicyDeliverable.js';
167
168
  export * from './hitl/approvalsFeed.js';
168
169
  export * from './hitl/livePendingAsk.js';
170
+ export * from './hitl/askSurvivesPosture.js';
169
171
  export * from './hitl/crashConverged.js';
170
172
  export * from './interactiveHalt.js';
171
173
  export * from './compensations.js';
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ export * from './sdkWireTransit.js';
14
14
  export { SEMA_SEGMENT_ID_KEY } from './adapt/textStream.js';
15
15
  export * from './subagentContentStore.js';
16
16
  export * from './engineAgentPanelStore.js';
17
+ export * from './engineAgentAbsence.js';
17
18
  export * from './fleetAgentPanelProjection.js';
18
19
  export * from './liveQuestionStore.js';
19
20
  export * from './engineInlineTaskStats.js';
@@ -163,6 +164,7 @@ export * from './hitl/sessionPolicyWire.js';
163
164
  export * from './hitl/sessionPolicyDeliverable.js';
164
165
  export * from './hitl/approvalsFeed.js';
165
166
  export * from './hitl/livePendingAsk.js';
167
+ export * from './hitl/askSurvivesPosture.js';
166
168
  export * from './hitl/crashConverged.js';
167
169
  export * from './interactiveHalt.js';
168
170
  export * from './compensations.js';
package/dist/ownKey.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export declare function putOwnKey<T>(table: Record<string, T>, key: string, value: T): void;
2
+ export declare function readOwnNonEmptyString(v: object | null | undefined, key: string): string | undefined;
package/dist/ownKey.js CHANGED
@@ -1,3 +1,9 @@
1
1
  export function putOwnKey(table, key, value) {
2
2
  Object.defineProperty(table, key, { value, enumerable: true, writable: true, configurable: true });
3
3
  }
4
+ export function readOwnNonEmptyString(v, key) {
5
+ if (typeof v !== 'object' || v === null || !Object.hasOwn(v, key))
6
+ return undefined;
7
+ const raw = v[key];
8
+ return typeof raw === 'string' && raw !== '' ? raw : undefined;
9
+ }