@sema-agent/client-core 0.98.0 → 0.99.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 +199 -0
- package/README.md +35 -22
- package/dist/adapt/arms.js +61 -20
- package/dist/adapt/panelTasks.d.ts +1 -1
- package/dist/adapt/panelTasks.js +2 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +4 -3
- package/dist/adapter/activeRunSelfHeal.js +162 -293
- package/dist/adapter/downstream/eventToSdkMessage.js +52 -4
- package/dist/adapter/runStream.js +52 -37
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +0 -3
- package/dist/agentsWireCaps.js +33 -24
- package/dist/cloudConfigWireCaps.d.ts +1 -1
- package/dist/cloudConfigWireCaps.js +26 -4
- package/dist/controlRouter.d.ts +4 -2
- package/dist/controlRouter.js +39 -51
- package/dist/coreValuePorts.d.ts +26 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/detachWire.js +3 -2
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +3 -0
- package/dist/engineAgentPanelStore.d.ts +7 -0
- package/dist/engineAgentPanelStore.js +14 -0
- package/dist/engineCapReader.d.ts +2 -1
- package/dist/engineCapReader.js +7 -5
- package/dist/engineCapsCache.d.ts +8 -0
- package/dist/engineCapsCache.js +59 -6
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineErrorCodes.d.ts +2 -1
- package/dist/engineErrorCodes.js +2 -7
- package/dist/engineRowRef.js +3 -0
- package/dist/engineSessionMessages.d.ts +1 -0
- package/dist/engineSessionMessages.js +7 -1
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +2 -1
- package/dist/env/uiLanguage.js +3 -2
- package/dist/eventLeg.d.ts +8 -0
- package/dist/eventLeg.js +61 -41
- package/dist/fileHistoryCaptureCapability.d.ts +2 -1
- package/dist/fileHistoryCaptureCapability.js +12 -18
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/frameBinding.d.ts +3 -0
- package/dist/frameBinding.js +12 -0
- package/dist/gateOutcome.js +16 -2
- package/dist/gateVocabulary.d.ts +8 -7
- package/dist/gateVocabulary.js +71 -73
- package/dist/generated/engineFactTables.d.ts +17 -1
- package/dist/generated/engineFactTables.js +29 -0
- package/dist/generated/engineNoticeTables.js +9 -3
- package/dist/generated/settingsSchemaFns.d.ts +6 -0
- package/dist/generated/settingsSchemaFns.js +57 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaTables.d.ts +1 -0
- package/dist/generated/settingsSchemaTables.js +4 -0
- package/dist/generated/settingsSchemaTypes.d.ts +105 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +2 -1
- package/dist/hitl/allowRuleShadow.js +17 -14
- package/dist/hitl/approvalCardReasons.d.ts +3 -2
- package/dist/hitl/approvalCardReasons.js +27 -28
- package/dist/hitl/approvalHolds.d.ts +3 -0
- package/dist/hitl/approvalHolds.js +73 -29
- package/dist/hitl/askClassPair.d.ts +1 -1
- package/dist/hitl/askClassPair.js +16 -0
- package/dist/hitl/askGateWire.js +2 -1
- package/dist/hitl/askSettlementLine.d.ts +14 -4
- package/dist/hitl/askSettlementLine.js +67 -47
- package/dist/hitl/automaticAnswerVerdict.d.ts +2 -1
- package/dist/hitl/automaticAnswerVerdict.js +8 -8
- package/dist/hitl/crashConvergedNotice.d.ts +5 -4
- package/dist/hitl/crashConvergedNotice.js +28 -41
- package/dist/hitl/frameRouter.js +7 -8
- package/dist/hitl/hitlBridge.d.ts +1 -0
- package/dist/hitl/hitlBridge.js +3 -3
- package/dist/hitl/persistedRulesWire.d.ts +6 -5
- package/dist/hitl/persistedRulesWire.js +55 -73
- package/dist/hitl/planReviewWire.d.ts +5 -0
- package/dist/hitl/planReviewWire.js +8 -0
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +46 -3
- package/dist/hitl/sessionPolicyWire.d.ts +2 -1
- package/dist/hitl/sessionPolicyWire.js +23 -24
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +17 -5
- package/dist/hitl/toolApprovalWire.js +79 -40
- package/dist/hooksWireCaps.js +145 -56
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +71 -0
- package/dist/hostTurnSettings.js +291 -0
- package/dist/humanTurn.d.ts +14 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +582 -0
- package/dist/i18n/messages.en.js +582 -0
- package/dist/i18n/messages.zh.js +718 -1
- package/dist/index.d.ts +29 -13
- package/dist/index.js +18 -9
- package/dist/inheritEnvCapability.d.ts +3 -2
- package/dist/inheritEnvCapability.js +3 -3
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +12 -14
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +2 -1
- package/dist/liveModelCatalog.js +14 -8
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +40 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +3 -1
- package/dist/mcpProbeWire.js +5 -0
- package/dist/mcpWireCaps.d.ts +34 -0
- package/dist/mcpWireCaps.js +117 -17
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +64 -0
- package/dist/modelCapabilityProbe.js +600 -0
- package/dist/modelIdentityResolvability.d.ts +3 -0
- package/dist/modelIdentityResolvability.js +26 -17
- package/dist/ownKey.d.ts +7 -0
- package/dist/ownKey.js +34 -0
- package/dist/panelReduce.d.ts +6 -1
- package/dist/panelReduce.js +50 -3
- package/dist/permissionRuleIssue.js +2 -0
- package/dist/permissionRulesWriteCapability.d.ts +2 -1
- package/dist/permissionRulesWriteCapability.js +8 -6
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +217 -11
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/request/taskRequest.d.ts +11 -5
- package/dist/request/taskRequest.js +112 -16
- package/dist/resumeRefusalCopy.d.ts +12 -9
- package/dist/resumeRefusalCopy.js +70 -143
- package/dist/retryStatus.d.ts +37 -0
- package/dist/retryStatus.js +79 -0
- package/dist/scenarioRefusal.d.ts +9 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/seam.d.ts +25 -1
- package/dist/seam.js +10 -1
- package/dist/seatContract.d.ts +260 -10
- package/dist/seatContract.js +692 -19
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -1
- package/dist/sessionPolicyCapability.js +8 -6
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -1
- package/dist/skillToolListsCapability.js +8 -6
- package/dist/sseIdleTriage.js +3 -2
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagentContentStore.d.ts +3 -0
- package/dist/subagentContentStore.js +22 -0
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolRoster.d.ts +3 -2
- package/dist/toolRoster.js +21 -20
- package/dist/turnFailurePresentation.d.ts +12 -1
- package/dist/turnFailurePresentation.js +212 -15
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -1
- package/dist/userInvokedSkillsCapability.js +31 -7
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +23 -1
- package/dist/wireFailureShape.js +2 -1
- package/dist/wireRefusalCopy.d.ts +13 -1
- package/dist/wireRefusalCopy.js +24 -28
- package/dist/workflowsJournalCapability.d.ts +2 -1
- package/dist/workflowsJournalCapability.js +8 -6
- package/docs/INTEGRATION-CLIENTS.md +542 -30
- package/package.json +5 -5
package/dist/ownKey.d.ts
CHANGED
|
@@ -24,5 +24,12 @@ export interface ContextUsageReading {
|
|
|
24
24
|
sections?: readonly ContextUsageSectionRow[];
|
|
25
25
|
}
|
|
26
26
|
export declare function contextUsageReadingOf(payload: {} | null | undefined): ContextUsageReading | undefined;
|
|
27
|
+
export interface HumanInputAttachmentView {
|
|
28
|
+
ordinal: number;
|
|
29
|
+
kind?: string;
|
|
30
|
+
outcome: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function humanInputAttachmentsOf(frame: {} | null | undefined): HumanInputAttachmentView[] | undefined;
|
|
27
34
|
export declare function markMcpSectionDroppedNamedRows(rows: object, dropped: ReadonlyMap<string, number>): void;
|
|
28
35
|
export declare function mcpSectionDroppedNamedRowsOf(rows: object | null | undefined, name: string): number;
|
package/dist/ownKey.js
CHANGED
|
@@ -131,6 +131,40 @@ export function contextUsageReadingOf(payload) {
|
|
|
131
131
|
return undefined;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
const HUMAN_INPUT_ATTACHMENT_ROWS_MAX = 256;
|
|
135
|
+
export function humanInputAttachmentsOf(frame) {
|
|
136
|
+
try {
|
|
137
|
+
if (typeof frame !== 'object' || frame === null || Array.isArray(frame))
|
|
138
|
+
return undefined;
|
|
139
|
+
const raw = guardedRead(() => readOwnDataValue(frame, 'attachments'));
|
|
140
|
+
if (!Array.isArray(raw))
|
|
141
|
+
return undefined;
|
|
142
|
+
const n = guardedRead(() => readOwnDataFiniteNumber(raw, 'length'));
|
|
143
|
+
if (n === undefined)
|
|
144
|
+
return undefined;
|
|
145
|
+
const rows = [];
|
|
146
|
+
for (let i = 0; i < Math.min(n, HUMAN_INPUT_ATTACHMENT_ROWS_MAX); i++) {
|
|
147
|
+
const row = guardedRead(() => {
|
|
148
|
+
const r = readOwnDataValue(raw, String(i));
|
|
149
|
+
if (typeof r !== 'object' || r === null || Array.isArray(r))
|
|
150
|
+
return undefined;
|
|
151
|
+
const ordinal = readOwnDataValue(r, 'ordinal');
|
|
152
|
+
const outcome = readOwnDataNonEmptyString(r, 'outcome');
|
|
153
|
+
if (typeof ordinal !== 'number' || !Number.isSafeInteger(ordinal) || ordinal < 1 || outcome === undefined)
|
|
154
|
+
return undefined;
|
|
155
|
+
const kind = readOwnDataNonEmptyString(r, 'kind');
|
|
156
|
+
const label = readOwnDataNonEmptyString(r, 'label');
|
|
157
|
+
return { ordinal, ...(kind !== undefined ? { kind } : {}), outcome, ...(label !== undefined ? { label } : {}) };
|
|
158
|
+
});
|
|
159
|
+
if (row !== undefined)
|
|
160
|
+
rows.push(row);
|
|
161
|
+
}
|
|
162
|
+
return rows.length > 0 ? rows : undefined;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
134
168
|
const DROPPED_NAMED_ROWS = Symbol.for('@sema-agent/client-core/mcpSectionDroppedNamedRows');
|
|
135
169
|
export function markMcpSectionDroppedNamedRows(rows, dropped) {
|
|
136
170
|
if (dropped.size === 0)
|
package/dist/panelReduce.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ export type PanelFrame = EngineAgentPanelEvent | {
|
|
|
31
31
|
kind: 'anchor';
|
|
32
32
|
taskId: string;
|
|
33
33
|
transcriptId: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'start';
|
|
36
|
+
taskId: string;
|
|
37
|
+
startedAt?: number;
|
|
38
|
+
workflowRunId?: string;
|
|
34
39
|
};
|
|
35
40
|
export interface PanelRowFields {
|
|
36
41
|
name?: string;
|
|
@@ -97,7 +102,7 @@ export interface PanelStep {
|
|
|
97
102
|
readonly deltas: PanelDelta[];
|
|
98
103
|
readonly facts: PanelFact[];
|
|
99
104
|
}
|
|
100
|
-
export declare function panelEndFact(taskId: string, isError: boolean, extra?: Pick<EndArm, 'report' | 'cycleSeq' | 'startedAt'>): EndArm;
|
|
105
|
+
export declare function panelEndFact(taskId: string, isError: boolean, extra?: Pick<EndArm, 'report' | 'cycleSeq' | 'startedAt' | 'sessionId'>): EndArm;
|
|
101
106
|
export interface EnginePanelTaskIdentity {
|
|
102
107
|
readonly taskId: string;
|
|
103
108
|
readonly origin: 'fleet-row' | 'wire';
|
package/dist/panelReduce.js
CHANGED
|
@@ -394,6 +394,7 @@ function merge(d, a, b) {
|
|
|
394
394
|
held: rs.held ?? rl.held,
|
|
395
395
|
resident: rs.resident ?? rl.resident,
|
|
396
396
|
anchor: rs.anchor ?? rl.anchor,
|
|
397
|
+
startedAt: rs.startedAt ?? rl.startedAt,
|
|
397
398
|
row: merged.row,
|
|
398
399
|
});
|
|
399
400
|
for (const id of idsOf(rl))
|
|
@@ -423,6 +424,7 @@ function merge(d, a, b) {
|
|
|
423
424
|
mintTerminal(d, key, merged.row.isError === true, merged.row.report, 'end');
|
|
424
425
|
}
|
|
425
426
|
}
|
|
427
|
+
fillStartedAt(d, s);
|
|
426
428
|
return s;
|
|
427
429
|
}
|
|
428
430
|
function genOf(r) {
|
|
@@ -513,6 +515,7 @@ export function panelEndFact(taskId, isError, extra) {
|
|
|
513
515
|
...(extra?.cycleSeq !== undefined ? { cycleSeq: extra.cycleSeq } : {}),
|
|
514
516
|
...(extra?.startedAt !== undefined ? { startedAt: extra.startedAt } : {}),
|
|
515
517
|
...(extra?.report !== undefined ? { report: extra.report } : {}),
|
|
518
|
+
...(typeof extra?.sessionId === 'string' && extra.sessionId.length > 0 ? { sessionId: extra.sessionId } : {}),
|
|
516
519
|
};
|
|
517
520
|
}
|
|
518
521
|
function terminalDelta(key, isError, report, cause) {
|
|
@@ -625,9 +628,10 @@ function announce(d, rid) {
|
|
|
625
628
|
if (r === undefined || row === undefined || row.announced)
|
|
626
629
|
return;
|
|
627
630
|
const key = keyOf(r);
|
|
628
|
-
|
|
631
|
+
const fields = row.fields.startedAt === undefined && r.startedAt !== undefined ? { ...row.fields, startedAt: r.startedAt } : row.fields;
|
|
632
|
+
d.put(rid, { consumerKey: key, announceSeq: d.counts.nextAnnounce, row: { ...row, fields, announced: true } });
|
|
629
633
|
d.counts.nextAnnounce++;
|
|
630
|
-
d.deltas.push({ op: 'upsert', canonicalId: key, created: true, fields: { ...
|
|
634
|
+
d.deltas.push({ op: 'upsert', canonicalId: key, created: true, fields: { ...fields } });
|
|
631
635
|
const u = fullUsage(key, row);
|
|
632
636
|
if (u !== undefined)
|
|
633
637
|
d.deltas.push(u);
|
|
@@ -861,7 +865,8 @@ function publishFleetRow(d, ev) {
|
|
|
861
865
|
const stale = order === 'after';
|
|
862
866
|
let newGen = false;
|
|
863
867
|
if (!stale) {
|
|
864
|
-
const
|
|
868
|
+
const endedHere = r.ended !== undefined && (r.cycle === undefined || cycleOrder(r.ended, r.cycle) === 'same') ? r.ended : undefined;
|
|
869
|
+
const endGen = r.row?.phase === 'ended' ? (r.row.endCycle ?? endedHere) : undefined;
|
|
865
870
|
newGen = order === 'before' || (endGen !== undefined && cycleOrder(endGen, rowCycle) === 'before');
|
|
866
871
|
if (!newGen && transcript !== undefined && !hasCycleSeq(r.cycle) && !hasCycleSeq(rowCycle) && r.currentRun !== undefined && r.currentRun !== transcript) {
|
|
867
872
|
newGen = true;
|
|
@@ -901,6 +906,36 @@ function publishTick(d, ev) {
|
|
|
901
906
|
}
|
|
902
907
|
d.pending.set(ev.taskId, { ev, beats: 0 });
|
|
903
908
|
}
|
|
909
|
+
function publishStart(d, ev) {
|
|
910
|
+
if (typeof ev.workflowRunId === 'string' && ev.workflowRunId.length > 0)
|
|
911
|
+
return;
|
|
912
|
+
if (typeof ev.taskId !== 'string' || ev.taskId.length === 0)
|
|
913
|
+
return;
|
|
914
|
+
const startedAt = typeof ev.startedAt === 'number' && Number.isFinite(ev.startedAt) ? ev.startedAt : undefined;
|
|
915
|
+
if (startedAt === undefined)
|
|
916
|
+
return;
|
|
917
|
+
const found = d.find(ev.taskId);
|
|
918
|
+
const former = found !== undefined ? d.rec(found) : undefined;
|
|
919
|
+
if (former !== undefined && formerGeneration(former, ev.taskId))
|
|
920
|
+
return;
|
|
921
|
+
if (found === undefined && d.records.size >= MAX_RECORDS)
|
|
922
|
+
return;
|
|
923
|
+
const rid = found ?? d.create({ id: ev.taskId });
|
|
924
|
+
const r = d.rec(rid);
|
|
925
|
+
if (r === undefined)
|
|
926
|
+
return;
|
|
927
|
+
if (r.startedAt === undefined)
|
|
928
|
+
d.put(rid, { startedAt });
|
|
929
|
+
fillStartedAt(d, rid);
|
|
930
|
+
}
|
|
931
|
+
function fillStartedAt(d, rid) {
|
|
932
|
+
const r = d.rec(rid);
|
|
933
|
+
const row = r?.row;
|
|
934
|
+
if (r === undefined || r.startedAt === undefined || row === undefined || !row.announced || row.phase !== 'running' || row.fields.startedAt !== undefined)
|
|
935
|
+
return;
|
|
936
|
+
d.deltas.push({ op: 'upsert', canonicalId: keyOf(r), fields: { startedAt: r.startedAt } });
|
|
937
|
+
d.put(rid, { row: { ...row, fields: { ...row.fields, startedAt: r.startedAt } } });
|
|
938
|
+
}
|
|
904
939
|
function releaseHeld(d, rid, endCycle) {
|
|
905
940
|
const held = d.rec(rid)?.held;
|
|
906
941
|
if (held === undefined)
|
|
@@ -921,6 +956,15 @@ function settle(d, rid, cycle) {
|
|
|
921
956
|
d.put(rid, { running: undefined, ended: older ? r.ended : mergeCycle(cycleOf(cycle), r.ended) });
|
|
922
957
|
}
|
|
923
958
|
function publishEnd(d, ev) {
|
|
959
|
+
const sessionId = typeof ev.sessionId === 'string' && ev.sessionId.length > 0 && ev.sessionId !== ev.taskId ? ev.sessionId : undefined;
|
|
960
|
+
if (sessionId !== undefined) {
|
|
961
|
+
const at = d.find(ev.taskId);
|
|
962
|
+
const ra = at !== undefined ? d.rec(at) : undefined;
|
|
963
|
+
const evCycle = frameCycleOn(ra, ev.taskId, ev);
|
|
964
|
+
const provablyOld = ra !== undefined && (isStaleEngineAgentPanelEnd(evCycle, ra.cycle) || isStaleEngineAgentPanelEnd(evCycle, ra.ended));
|
|
965
|
+
if (!provablyOld)
|
|
966
|
+
bind(d, ev.taskId, 'tail', sessionId, cycleOf(ev));
|
|
967
|
+
}
|
|
924
968
|
const pre = d.find(ev.taskId);
|
|
925
969
|
const pr = pre !== undefined ? d.rec(pre) : undefined;
|
|
926
970
|
if (pre !== undefined && pr !== undefined)
|
|
@@ -1187,6 +1231,9 @@ export function stepPanelFrame(state, frame) {
|
|
|
1187
1231
|
case 'resident-clear-wire':
|
|
1188
1232
|
clearResidentByWire(d, frame.taskId, frame.cycle);
|
|
1189
1233
|
break;
|
|
1234
|
+
case 'start':
|
|
1235
|
+
publishStart(d, frame);
|
|
1236
|
+
break;
|
|
1190
1237
|
case 'anchor':
|
|
1191
1238
|
if (frame.taskId && frame.transcriptId)
|
|
1192
1239
|
d.put(bind(d, frame.taskId, 'unknown', frame.transcriptId, undefined), { anchor: frame.transcriptId });
|
|
@@ -2,6 +2,7 @@ import { capForDisplay, escapeDisplayControlChars } from './fleetTaskDesc.js';
|
|
|
2
2
|
export const PERMISSION_RULE_ISSUE_CODES = Object.freeze([
|
|
3
3
|
'invalid.empty_tool',
|
|
4
4
|
'invalid.paren',
|
|
5
|
+
'invalid.tool_name',
|
|
5
6
|
'invalid.param_split',
|
|
6
7
|
'invalid.primary_field',
|
|
7
8
|
'invalid.cap_exceeded',
|
|
@@ -21,6 +22,7 @@ const ISSUE_MESSAGE_MAX = 200;
|
|
|
21
22
|
const ISSUE_SENTENCES = Object.freeze({
|
|
22
23
|
'invalid.empty_tool': 'this rule is invalid: it names no tool',
|
|
23
24
|
'invalid.paren': 'this rule is invalid: its parentheses do not parse (escape a literal one as \\( or \\))',
|
|
25
|
+
'invalid.tool_name': "this rule is invalid: its tool name is not spelled as a tool name (blanks around the rule, an invisible or disallowed character in the name or before the parenthesis, a leading '-', or the wildcard '*', which names no tool), so it would reach no tool or the wrong one",
|
|
24
26
|
'invalid.param_split': 'this rule is invalid: its parentheses do not hold a parameter rule written name:pattern',
|
|
25
27
|
'invalid.primary_field': "this rule is invalid: it patterns the tool's primary field, which matches the whole trimmed string rather than a prefix",
|
|
26
28
|
'invalid.cap_exceeded': 'this rule set is invalid: it is over one of the deployment caps (rule count, rule length, pattern length, or star count); this client cannot tell which from the code alone',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
1
2
|
export type PermissionRulesWriteReading = {
|
|
2
3
|
kind: 'unobserved';
|
|
3
4
|
} | {
|
|
@@ -12,4 +13,4 @@ export type PermissionRulesWriteReading = {
|
|
|
12
13
|
export declare function projectPermissionRulesWriteCapability(caps: unknown): PermissionRulesWriteReading | undefined;
|
|
13
14
|
export declare function observedPermissionRulesWrite(baseUrl?: string | undefined): PermissionRulesWriteReading;
|
|
14
15
|
export declare function permissionRulesWriteAvailable(reading: PermissionRulesWriteReading): boolean;
|
|
15
|
-
export declare function permissionRulesWriteDoctorDetail(reading: PermissionRulesWriteReading): string;
|
|
16
|
+
export declare function permissionRulesWriteDoctorDetail(reading: PermissionRulesWriteReading, lang?: UiLanguage): string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader, unreadableReadingDetail } from './engineCapReader.js';
|
|
3
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
3
4
|
import { ownDataField } from './ownKey.js';
|
|
4
5
|
export function projectPermissionRulesWriteCapability(caps) {
|
|
5
6
|
try {
|
|
@@ -28,17 +29,18 @@ export function observedPermissionRulesWrite(baseUrl = engineWireTarget()?.baseU
|
|
|
28
29
|
export function permissionRulesWriteAvailable(reading) {
|
|
29
30
|
return reading.kind === 'present';
|
|
30
31
|
}
|
|
31
|
-
export function permissionRulesWriteDoctorDetail(reading) {
|
|
32
|
+
export function permissionRulesWriteDoctorDetail(reading, lang) {
|
|
33
|
+
const subject = msg('notice.capability.subject.permissionRulesWrite');
|
|
32
34
|
switch (reading.kind) {
|
|
33
35
|
case 'unreadable':
|
|
34
|
-
return unreadableReadingDetail(
|
|
36
|
+
return unreadableReadingDetail(renderMessage(subject, lang), lang);
|
|
35
37
|
case 'unobserved':
|
|
36
|
-
return
|
|
38
|
+
return renderMessage(msg('notice.capability.unobserved', { subject, key: 'permissionRulesWrite' }), lang);
|
|
37
39
|
case 'not_reported':
|
|
38
|
-
return '
|
|
40
|
+
return renderMessage(msg('notice.capability.permissionRulesWrite.notReported'), lang);
|
|
39
41
|
case 'absent':
|
|
40
|
-
return '
|
|
42
|
+
return renderMessage(msg('notice.capability.permissionRulesWrite.absent'), lang);
|
|
41
43
|
case 'present':
|
|
42
|
-
return '
|
|
44
|
+
return renderMessage(msg('notice.capability.permissionRulesWrite.present'), lang);
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { WireHooksConfig } from './finalVerifyWire.js';
|
|
2
|
-
import type { PluginHookSource } from './host.js';
|
|
2
|
+
import type { PluginHookSource, SessionHookOrigin, SessionHookSource } from './host.js';
|
|
3
|
+
import { type HooksSalvageDrop, type HooksSalvageMask, type HooksSalvageRejection } from './settingsHooksSalvage.js';
|
|
3
4
|
export declare const ENGINE_FIRED_HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "PreCompact", "PostCompact", "Stop", "StopFailure", "UserPromptSubmit"];
|
|
4
5
|
export type EngineFiredHookEvent = (typeof ENGINE_FIRED_HOOK_EVENTS)[number];
|
|
5
6
|
export declare const PLUGIN_HOOK_DISPOSITIONS: readonly ["engine", "shell", "not_run"];
|
|
6
7
|
export type PluginHookDisposition = (typeof PLUGIN_HOOK_DISPOSITIONS)[number];
|
|
7
|
-
export declare const PLUGIN_HOOK_REASONS: readonly ["projected", "shell_event", "no_executor", "engine_not_local", "engine_locality_unknown", "engine_capability_absent", "engine_capability_unknown", "not_command", "sensitive_options", "engine_limit", "shell_form_user_config", "user_config_unset", "malformed_entry", "engine_hooks_off", "engine_hooks_unknown", "engine_type_skipped", "engine_llm_limit", "engine_unconfirmed", "engine_elsewhere"];
|
|
8
|
+
export declare const PLUGIN_HOOK_REASONS: readonly ["projected", "shell_event", "no_executor", "engine_not_local", "engine_locality_unknown", "engine_capability_absent", "engine_capability_unknown", "not_command", "sensitive_options", "engine_limit", "shell_form_user_config", "user_config_unset", "malformed_entry", "engine_hooks_off", "engine_hooks_unknown", "engine_type_skipped", "engine_llm_limit", "engine_unconfirmed", "engine_elsewhere", "hooks_module", "scope_unsupported", "source_incomplete"];
|
|
8
9
|
export type PluginHookReason = (typeof PLUGIN_HOOK_REASONS)[number];
|
|
9
10
|
export declare const PLUGIN_HOOK_EXCLUSION_REASONS: readonly ["workspace_untrusted", "governance_unreadable", "policy_disable_all", "startup_mode", "managed_plugins_only", "prompt_not_user_authored"];
|
|
10
11
|
export type PluginHookExclusionReason = (typeof PLUGIN_HOOK_EXCLUSION_REASONS)[number];
|
|
@@ -48,6 +49,28 @@ export interface SettingsHookExclusion {
|
|
|
48
49
|
readonly hookIndex: number;
|
|
49
50
|
readonly reason: PluginHookExclusionReason;
|
|
50
51
|
}
|
|
52
|
+
export interface SettingsHooksSalvageRow {
|
|
53
|
+
readonly source: HookSettingsSource;
|
|
54
|
+
readonly outcome: 'loaded-partial' | 'rejected';
|
|
55
|
+
readonly dropped: readonly HooksSalvageDrop[];
|
|
56
|
+
readonly rejections: readonly HooksSalvageRejection[];
|
|
57
|
+
readonly notice: string;
|
|
58
|
+
}
|
|
59
|
+
export interface PluginHookModuleVerdict {
|
|
60
|
+
readonly pluginId: string;
|
|
61
|
+
readonly pluginName: string;
|
|
62
|
+
readonly disposition: PluginHookDisposition;
|
|
63
|
+
readonly reason: PluginHookReason;
|
|
64
|
+
}
|
|
65
|
+
export interface SessionHookVerdict {
|
|
66
|
+
readonly origin: SessionHookOrigin;
|
|
67
|
+
readonly name: string;
|
|
68
|
+
readonly event: string;
|
|
69
|
+
readonly groupIndex: number;
|
|
70
|
+
readonly hookIndex: number;
|
|
71
|
+
readonly disposition: PluginHookDisposition;
|
|
72
|
+
readonly reason: PluginHookReason;
|
|
73
|
+
}
|
|
51
74
|
export interface HooksWireEngineFacts {
|
|
52
75
|
readonly ownedByThisShell: boolean | null;
|
|
53
76
|
readonly pluginHooksCapable: boolean | null;
|
|
@@ -62,6 +85,11 @@ export interface HooksWirePlan {
|
|
|
62
85
|
readonly settingsDropped: readonly SettingsHookDrop[];
|
|
63
86
|
readonly settingsVerdicts: readonly SettingsHookVerdict[];
|
|
64
87
|
readonly settingsExcluded: readonly SettingsHookExclusion[];
|
|
88
|
+
readonly settingsSalvage: readonly SettingsHooksSalvageRow[];
|
|
89
|
+
readonly moduleVerdicts: readonly PluginHookModuleVerdict[];
|
|
90
|
+
readonly sessionVerdicts: readonly SessionHookVerdict[];
|
|
91
|
+
readonly sessionReader: PluginHookReaderState;
|
|
92
|
+
readonly closedBy: Extract<PluginHookExclusionReason, 'workspace_untrusted' | 'governance_unreadable' | 'policy_disable_all'> | null;
|
|
65
93
|
readonly wire: WireHooksConfig | undefined;
|
|
66
94
|
}
|
|
67
95
|
export interface HooksWirePlanOptions {
|
|
@@ -70,7 +98,9 @@ export interface HooksWirePlanOptions {
|
|
|
70
98
|
readonly shellHookEvents?: readonly string[];
|
|
71
99
|
readonly shellHookTypesByEvent?: Readonly<Record<string, readonly string[]>>;
|
|
72
100
|
readonly promptAuthoredByUser?: boolean;
|
|
101
|
+
readonly suppressedLocally?: readonly string[];
|
|
73
102
|
}
|
|
103
|
+
export declare function hooksWirePlanShapeOf(v: unknown): 'plan' | 'not' | 'threw';
|
|
74
104
|
export declare const ENGINE_HOOK_LIMITS: {
|
|
75
105
|
readonly maxGroupsPerEvent: 16;
|
|
76
106
|
readonly maxEntriesPerEvent: 32;
|
|
@@ -102,15 +132,27 @@ export interface PluginHookDecisionInput {
|
|
|
102
132
|
readonly shellRuns: ShellRunsHook;
|
|
103
133
|
readonly promptAuthoredByUser: boolean;
|
|
104
134
|
readonly occupied: ReadonlyMap<string, EventOccupancy>;
|
|
135
|
+
readonly suppressedLocally?: ReadonlySet<string>;
|
|
105
136
|
}
|
|
106
137
|
export interface PluginHookDecision {
|
|
107
138
|
readonly verdicts: readonly PluginHookVerdict[];
|
|
139
|
+
readonly modules: readonly PluginHookModuleVerdict[];
|
|
108
140
|
readonly excluded: readonly PluginHookExclusion[];
|
|
109
141
|
readonly projected: ReadonlyMap<string, readonly WireHookGroup[]>;
|
|
110
142
|
readonly unreadable: number;
|
|
111
143
|
}
|
|
112
144
|
export declare function decidePluginHooks(input: PluginHookDecisionInput): PluginHookDecision;
|
|
113
|
-
export
|
|
145
|
+
export interface SessionHookDecisionInput {
|
|
146
|
+
readonly sources: readonly SessionHookSource[];
|
|
147
|
+
readonly engine: HooksWireEngineFacts;
|
|
148
|
+
readonly shellRuns: ShellRunsHook;
|
|
149
|
+
readonly promptAuthoredByUser: boolean;
|
|
150
|
+
}
|
|
151
|
+
export declare function decideSessionHooks(input: SessionHookDecisionInput): {
|
|
152
|
+
readonly verdicts: readonly SessionHookVerdict[];
|
|
153
|
+
readonly unreadable: number;
|
|
154
|
+
};
|
|
155
|
+
export declare function filterSettingsHookGroups(source: HookSettingsSource, event: string, groups: readonly WireHookGroup[], execFormCapable: boolean, shellRunsType: (type: string | undefined) => boolean, judge: SettingsHookJudge, mask?: HooksSalvageMask): SettingsHookFilterResult;
|
|
114
156
|
export interface SettingsHookFilterResult {
|
|
115
157
|
readonly groups: WireHookGroup[];
|
|
116
158
|
readonly drops: SettingsHookDrop[];
|
|
@@ -140,4 +182,5 @@ export declare function pluginHookReasonText(reason: PluginHookReason): string;
|
|
|
140
182
|
export declare function settingsHookDropText(reason: SettingsHookDropReason): string;
|
|
141
183
|
export declare function pluginHookExecutorLabel(v: PluginHookVerdict): string;
|
|
142
184
|
export declare function hooksNotRunNotice(plan: HooksWirePlan): readonly string[];
|
|
185
|
+
export declare function userPromptSubmitExecutorOf(plan: HooksWirePlan): 'shell' | 'engine' | 'unknown' | 'none';
|
|
143
186
|
export {};
|