@felspar/sdk 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/README.md +133 -2
- package/dist/chunks/chunk-6EZBI7O6.js +583 -0
- package/dist/chunks/chunk-C2VMKF3S.js +4922 -0
- package/dist/draft-action-gate-claude.js +50 -0
- package/dist/draft-action-gate-eve.js +53 -0
- package/dist/draft-action-gate-openai.js +60 -0
- package/dist/draft-action-gate.js +35 -0
- package/dist/draft-hosted-client.js +8 -0
- package/dist/types/draft-action-gate-claude.d.ts +27 -0
- package/dist/types/draft-action-gate-decisions.d.ts +36 -0
- package/dist/types/draft-action-gate-domains.d.ts +2 -0
- package/dist/types/draft-action-gate-eve.d.ts +42 -0
- package/dist/types/draft-action-gate-openai.d.ts +36 -0
- package/dist/types/draft-action-gate-outputs.d.ts +35 -0
- package/dist/types/draft-action-gate-verifier.d.ts +7 -0
- package/dist/types/draft-action-gate.d.ts +65 -0
- package/dist/types/draft-hosted-client.d.ts +3384 -0
- package/package.json +68 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
entityIdOf,
|
|
3
|
+
jobOf
|
|
4
|
+
} from "./chunks/chunk-6EZBI7O6.js";
|
|
5
|
+
import "./chunks/chunk-C2VMKF3S.js";
|
|
6
|
+
|
|
7
|
+
// src/draft-action-gate-claude.ts
|
|
8
|
+
function felsparPreToolUse(gate) {
|
|
9
|
+
return async (input) => {
|
|
10
|
+
const toolName = input.tool_name ?? "";
|
|
11
|
+
if (input.hook_event_name !== "PreToolUse" || !gate.isGated(toolName)) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
const verdict = await gate.check(input.session_id, toolName, input.tool_input);
|
|
15
|
+
if (verdict.allow) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
hookSpecificOutput: {
|
|
20
|
+
hookEventName: "PreToolUse",
|
|
21
|
+
permissionDecision: "deny",
|
|
22
|
+
permissionDecisionReason: `Felspar's gate: ${verdict.reason}`
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function felsparPostToolUse(gate) {
|
|
28
|
+
return async (input) => {
|
|
29
|
+
const job = jobOf(input.tool_input);
|
|
30
|
+
if (job !== void 0 && input.hook_event_name === "PostToolUse" && gate.isOutputCheckTool(input.tool_name ?? "")) {
|
|
31
|
+
gate.decisions.recordOutputCheck(input.session_id, job, input.tool_response);
|
|
32
|
+
}
|
|
33
|
+
const entity = entityIdOf(input.tool_input);
|
|
34
|
+
if (entity !== void 0 && input.hook_event_name === "PostToolUse" && gate.isDecisionTool(input.tool_name ?? "")) {
|
|
35
|
+
gate.decisions.record(input.session_id, entity, input.tool_response);
|
|
36
|
+
}
|
|
37
|
+
return {};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function felsparHooks(gate) {
|
|
41
|
+
return {
|
|
42
|
+
PreToolUse: [{ hooks: [felsparPreToolUse(gate)] }],
|
|
43
|
+
PostToolUse: [{ hooks: [felsparPostToolUse(gate)] }]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
felsparHooks,
|
|
48
|
+
felsparPostToolUse,
|
|
49
|
+
felsparPreToolUse
|
|
50
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
entityIdOf,
|
|
3
|
+
jobOf
|
|
4
|
+
} from "./chunks/chunk-6EZBI7O6.js";
|
|
5
|
+
import "./chunks/chunk-C2VMKF3S.js";
|
|
6
|
+
|
|
7
|
+
// src/draft-action-gate-eve.ts
|
|
8
|
+
function felsparGate(gate) {
|
|
9
|
+
return async (call) => {
|
|
10
|
+
if (!gate.isGated(call.toolName)) {
|
|
11
|
+
return "not-applicable";
|
|
12
|
+
}
|
|
13
|
+
const verdict = await gate.check(call.session.id, call.toolName, call.toolInput);
|
|
14
|
+
return { type: verdict.allow ? "approved" : "denied", reason: verdict.reason };
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function felsparDecisionEvents(gate) {
|
|
18
|
+
const checks = /* @__PURE__ */ new Map();
|
|
19
|
+
function requested(event) {
|
|
20
|
+
const { actions } = event.data;
|
|
21
|
+
if (actions === void 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
for (const action of actions) {
|
|
25
|
+
const entity = entityIdOf(action.input);
|
|
26
|
+
if (entity !== void 0 && gate.isDecisionTool(action.toolName ?? "")) {
|
|
27
|
+
gate.decisions.noteRequest(action.callId, entity);
|
|
28
|
+
}
|
|
29
|
+
const job = jobOf(action.input);
|
|
30
|
+
if (job !== void 0 && gate.isOutputCheckTool(action.toolName ?? "")) {
|
|
31
|
+
checks.set(action.callId, job);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function result(event, context) {
|
|
36
|
+
const action = event.data.result;
|
|
37
|
+
const job = action?.callId === void 0 ? void 0 : checks.get(action.callId);
|
|
38
|
+
if (job !== void 0 && action?.callId !== void 0) {
|
|
39
|
+
checks.delete(action.callId);
|
|
40
|
+
if (action.isError !== true) {
|
|
41
|
+
gate.decisions.recordOutputCheck(context.session.id, job, action.output);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (action?.callId !== void 0 && gate.isDecisionTool(action.toolName ?? "") && action.isError !== true) {
|
|
45
|
+
gate.decisions.noteResult(context.session.id, action.callId, action.output);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { "actions.requested": requested, "action.result": result };
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
felsparDecisionEvents,
|
|
52
|
+
felsparGate
|
|
53
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
entityIdOf,
|
|
3
|
+
jobOf
|
|
4
|
+
} from "./chunks/chunk-6EZBI7O6.js";
|
|
5
|
+
import "./chunks/chunk-C2VMKF3S.js";
|
|
6
|
+
|
|
7
|
+
// src/draft-action-gate-openai.ts
|
|
8
|
+
function argumentsOf(text) {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(text);
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function felsparToolInputGuardrail(gate, options) {
|
|
16
|
+
return {
|
|
17
|
+
type: "tool_input",
|
|
18
|
+
name: "felspar_action_gate",
|
|
19
|
+
async run(data) {
|
|
20
|
+
if (!gate.isGated(data.toolCall.name)) {
|
|
21
|
+
return { behavior: { type: "allow" } };
|
|
22
|
+
}
|
|
23
|
+
const input = argumentsOf(data.toolCall.arguments);
|
|
24
|
+
let verdict;
|
|
25
|
+
try {
|
|
26
|
+
verdict = await gate.check(options.sessionOf(data.context), data.toolCall.name, input);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
verdict = { allow: false, reason: `gate error: ${String(error)}` };
|
|
29
|
+
}
|
|
30
|
+
return verdict.allow ? { behavior: { type: "allow" }, outputInfo: { reason: verdict.reason } } : {
|
|
31
|
+
behavior: {
|
|
32
|
+
type: "rejectContent",
|
|
33
|
+
message: `Felspar's gate denied this call: ${verdict.reason}`
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function felsparDecisionOutputGuardrail(gate, options) {
|
|
40
|
+
return {
|
|
41
|
+
type: "tool_output",
|
|
42
|
+
name: "felspar_decisions",
|
|
43
|
+
async run(data) {
|
|
44
|
+
const input = argumentsOf(data.toolCall.arguments);
|
|
45
|
+
const job = jobOf(input);
|
|
46
|
+
if (job !== void 0 && gate.isOutputCheckTool(data.toolCall.name)) {
|
|
47
|
+
gate.decisions.recordOutputCheck(options.sessionOf(data.context), job, data.output);
|
|
48
|
+
}
|
|
49
|
+
const entity = entityIdOf(input);
|
|
50
|
+
if (entity !== void 0 && gate.isDecisionTool(data.toolCall.name)) {
|
|
51
|
+
gate.decisions.record(options.sessionOf(data.context), entity, data.output);
|
|
52
|
+
}
|
|
53
|
+
return { behavior: { type: "allow" } };
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
felsparDecisionOutputGuardrail,
|
|
59
|
+
felsparToolInputGuardrail
|
|
60
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkAction,
|
|
3
|
+
createActionGate,
|
|
4
|
+
createDecisionRecorder,
|
|
5
|
+
decisionFromResult,
|
|
6
|
+
emailRecipientFields,
|
|
7
|
+
emailSubjectFields,
|
|
8
|
+
entityIdOf,
|
|
9
|
+
felsparOutputCheckVerifier,
|
|
10
|
+
felsparVerifier,
|
|
11
|
+
gatedRule,
|
|
12
|
+
isCompanyDomain,
|
|
13
|
+
jobOf,
|
|
14
|
+
outputCheckFromResult,
|
|
15
|
+
outputTextDigest,
|
|
16
|
+
sharedDomains
|
|
17
|
+
} from "./chunks/chunk-6EZBI7O6.js";
|
|
18
|
+
import "./chunks/chunk-C2VMKF3S.js";
|
|
19
|
+
export {
|
|
20
|
+
checkAction,
|
|
21
|
+
createActionGate,
|
|
22
|
+
createDecisionRecorder,
|
|
23
|
+
decisionFromResult,
|
|
24
|
+
emailRecipientFields,
|
|
25
|
+
emailSubjectFields,
|
|
26
|
+
entityIdOf,
|
|
27
|
+
felsparOutputCheckVerifier,
|
|
28
|
+
felsparVerifier,
|
|
29
|
+
gatedRule,
|
|
30
|
+
isCompanyDomain,
|
|
31
|
+
jobOf,
|
|
32
|
+
outputCheckFromResult,
|
|
33
|
+
outputTextDigest,
|
|
34
|
+
sharedDomains
|
|
35
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ActionGate } from "./draft-action-gate.js";
|
|
2
|
+
interface HookInput {
|
|
3
|
+
hook_event_name: string;
|
|
4
|
+
session_id: string;
|
|
5
|
+
tool_name?: string;
|
|
6
|
+
tool_input?: unknown;
|
|
7
|
+
tool_response?: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface PreToolUseDecision {
|
|
10
|
+
hookSpecificOutput: {
|
|
11
|
+
hookEventName: "PreToolUse";
|
|
12
|
+
permissionDecision: "deny";
|
|
13
|
+
permissionDecisionReason: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
type NoDecision = Record<string, never>;
|
|
17
|
+
export declare function felsparPreToolUse(gate: ActionGate): (input: HookInput) => Promise<PreToolUseDecision | NoDecision>;
|
|
18
|
+
export declare function felsparPostToolUse(gate: ActionGate): (input: HookInput) => Promise<NoDecision>;
|
|
19
|
+
export declare function felsparHooks(gate: ActionGate): {
|
|
20
|
+
PreToolUse: {
|
|
21
|
+
hooks: ((input: HookInput) => Promise<PreToolUseDecision | NoDecision>)[];
|
|
22
|
+
}[];
|
|
23
|
+
PostToolUse: {
|
|
24
|
+
hooks: ((input: HookInput) => Promise<NoDecision>)[];
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FelsparOutputCheck } from "./draft-action-gate-outputs.js";
|
|
2
|
+
export interface FelsparDecision {
|
|
3
|
+
entity: string;
|
|
4
|
+
outcome: string;
|
|
5
|
+
executionObjectId: string;
|
|
6
|
+
receipt: {
|
|
7
|
+
receiptDigest: string;
|
|
8
|
+
} & Record<string, unknown>;
|
|
9
|
+
context: unknown;
|
|
10
|
+
evidenceFreshUntil?: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface VerifiedDecision {
|
|
13
|
+
jobId: string;
|
|
14
|
+
entityId: string;
|
|
15
|
+
releaseId?: string;
|
|
16
|
+
outcome: string | null;
|
|
17
|
+
}
|
|
18
|
+
export type ReceiptVerifier = (decision: FelsparDecision) => Promise<VerifiedDecision | null>;
|
|
19
|
+
export declare function jobOf(input: unknown): string | undefined;
|
|
20
|
+
export declare function entityIdOf(input: unknown): string | undefined;
|
|
21
|
+
export declare function decisionFromResult(entity: string, output: unknown): FelsparDecision | null;
|
|
22
|
+
export interface DecisionRecorder {
|
|
23
|
+
recordOutputCheck: (sessionId: string, jobId: string, output: unknown) => FelsparOutputCheck | null;
|
|
24
|
+
outputChecksIn: (sessionId: string) => readonly FelsparOutputCheck[];
|
|
25
|
+
record: (sessionId: string, entity: string, output: unknown) => FelsparDecision | null;
|
|
26
|
+
noteRequest: (callId: string, entity: string) => void;
|
|
27
|
+
noteResult: (sessionId: string, callId: string, output: unknown) => FelsparDecision | null;
|
|
28
|
+
decisionsIn: (sessionId: string) => readonly FelsparDecision[];
|
|
29
|
+
forget: (sessionId: string) => void;
|
|
30
|
+
}
|
|
31
|
+
export interface DecisionRecorderLimits {
|
|
32
|
+
sessions?: number;
|
|
33
|
+
decisionsPerSession?: number;
|
|
34
|
+
pendingRequests?: number;
|
|
35
|
+
}
|
|
36
|
+
export declare function createDecisionRecorder(limits?: DecisionRecorderLimits): DecisionRecorder;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ActionGate } from "./draft-action-gate.js";
|
|
2
|
+
export type EveApprovalStatus = "not-applicable" | {
|
|
3
|
+
readonly type: "approved" | "denied";
|
|
4
|
+
readonly reason: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function felsparGate(gate: ActionGate): (call: {
|
|
7
|
+
readonly session: {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
};
|
|
10
|
+
readonly toolName: string;
|
|
11
|
+
readonly toolInput?: unknown;
|
|
12
|
+
}) => Promise<EveApprovalStatus>;
|
|
13
|
+
interface EveActionRequest {
|
|
14
|
+
readonly callId: string;
|
|
15
|
+
readonly toolName?: string | undefined;
|
|
16
|
+
readonly input?: unknown;
|
|
17
|
+
}
|
|
18
|
+
interface EveActionResult {
|
|
19
|
+
readonly callId?: string | undefined;
|
|
20
|
+
readonly toolName?: string | undefined;
|
|
21
|
+
readonly output?: unknown;
|
|
22
|
+
readonly isError?: boolean | undefined;
|
|
23
|
+
}
|
|
24
|
+
interface RequestedEvent {
|
|
25
|
+
readonly data: {
|
|
26
|
+
readonly actions?: readonly EveActionRequest[] | undefined;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface ResultEvent {
|
|
30
|
+
readonly data: {
|
|
31
|
+
readonly result?: EveActionResult | undefined;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export declare function felsparDecisionEvents(gate: ActionGate): {
|
|
35
|
+
"actions.requested": (event: RequestedEvent) => void;
|
|
36
|
+
"action.result": (event: ResultEvent, context: {
|
|
37
|
+
readonly session: {
|
|
38
|
+
readonly id: string;
|
|
39
|
+
};
|
|
40
|
+
}) => void;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ActionGate } from "./draft-action-gate.js";
|
|
2
|
+
export type ToolGuardrailBehavior = {
|
|
3
|
+
type: "allow";
|
|
4
|
+
} | {
|
|
5
|
+
type: "rejectContent";
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
export interface ToolGuardrailOutput {
|
|
9
|
+
behavior: ToolGuardrailBehavior;
|
|
10
|
+
outputInfo?: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface GuardrailData {
|
|
13
|
+
context: {
|
|
14
|
+
context?: unknown;
|
|
15
|
+
};
|
|
16
|
+
toolCall: {
|
|
17
|
+
name: string;
|
|
18
|
+
arguments: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface OpenAIGuardrailOptions {
|
|
22
|
+
sessionOf: (context: GuardrailData["context"]) => string;
|
|
23
|
+
}
|
|
24
|
+
export declare function felsparToolInputGuardrail(gate: ActionGate, options: OpenAIGuardrailOptions): {
|
|
25
|
+
type: "tool_input";
|
|
26
|
+
name: string;
|
|
27
|
+
run(data: GuardrailData): Promise<ToolGuardrailOutput>;
|
|
28
|
+
};
|
|
29
|
+
export declare function felsparDecisionOutputGuardrail(gate: ActionGate, options: OpenAIGuardrailOptions): {
|
|
30
|
+
type: "tool_output";
|
|
31
|
+
name: string;
|
|
32
|
+
run(data: GuardrailData & {
|
|
33
|
+
output: unknown;
|
|
34
|
+
}): Promise<ToolGuardrailOutput>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface FelsparOutputCheck {
|
|
2
|
+
checkId: string;
|
|
3
|
+
jobId: string;
|
|
4
|
+
output: string;
|
|
5
|
+
status: string;
|
|
6
|
+
decisionReceiptDigest: string;
|
|
7
|
+
artifactDigest: string;
|
|
8
|
+
receiptDigest: string;
|
|
9
|
+
}
|
|
10
|
+
export type OutputCheckVerifier = (check: FelsparOutputCheck) => Promise<{
|
|
11
|
+
status: string;
|
|
12
|
+
receiptDigest: string | null;
|
|
13
|
+
artifactDigest: string | null;
|
|
14
|
+
decisionReceiptDigest: string;
|
|
15
|
+
} | null>;
|
|
16
|
+
export interface OutputCheckRule {
|
|
17
|
+
fields: readonly string[];
|
|
18
|
+
output?: string;
|
|
19
|
+
}
|
|
20
|
+
type JsonRecord = Record<string, unknown>;
|
|
21
|
+
export declare function outputCheckFromResult(jobId: string, output: unknown): FelsparOutputCheck | null;
|
|
22
|
+
export declare function outputTextDigest(value: string): Promise<string>;
|
|
23
|
+
export declare function outputCheckProblem(rule: OutputCheckRule, call: {
|
|
24
|
+
input: JsonRecord;
|
|
25
|
+
decisionReceiptDigest: string;
|
|
26
|
+
checks: readonly FelsparOutputCheck[];
|
|
27
|
+
verify: OutputCheckVerifier | undefined;
|
|
28
|
+
}): Promise<string | null>;
|
|
29
|
+
export declare function felsparOutputCheckVerifier(configuration: {
|
|
30
|
+
origin: string;
|
|
31
|
+
agentKey?: string;
|
|
32
|
+
session?: string;
|
|
33
|
+
fetcher?: typeof fetch;
|
|
34
|
+
}): OutputCheckVerifier;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { FelsparOutputCheck, OutputCheckRule, OutputCheckVerifier } from "./draft-action-gate-outputs.js";
|
|
2
|
+
import type { DecisionRecorder, FelsparDecision, ReceiptVerifier } from "./draft-action-gate-decisions.js";
|
|
3
|
+
export { createDecisionRecorder, decisionFromResult, entityIdOf, jobOf, } from "./draft-action-gate-decisions.js";
|
|
4
|
+
export type { DecisionRecorder, DecisionRecorderLimits, FelsparDecision, ReceiptVerifier, VerifiedDecision, } from "./draft-action-gate-decisions.js";
|
|
5
|
+
export { isCompanyDomain, sharedDomains } from "./draft-action-gate-domains.js";
|
|
6
|
+
export { felsparVerifier } from "./draft-action-gate-verifier.js";
|
|
7
|
+
export { felsparOutputCheckVerifier, outputCheckFromResult, outputTextDigest, } from "./draft-action-gate-outputs.js";
|
|
8
|
+
export type { FelsparOutputCheck, OutputCheckRule, OutputCheckVerifier, } from "./draft-action-gate-outputs.js";
|
|
9
|
+
export interface ActionRule {
|
|
10
|
+
outcomes: readonly string[];
|
|
11
|
+
fields: readonly string[];
|
|
12
|
+
recipientFields?: readonly string[];
|
|
13
|
+
subjectFields?: readonly string[];
|
|
14
|
+
outputCheck?: OutputCheckRule;
|
|
15
|
+
}
|
|
16
|
+
export interface ActionGateRules {
|
|
17
|
+
job: string;
|
|
18
|
+
tools: Readonly<Record<string, ActionRule>>;
|
|
19
|
+
testRecipients?: readonly string[];
|
|
20
|
+
refuse?: readonly string[];
|
|
21
|
+
recipientFields?: readonly string[];
|
|
22
|
+
subjectFields?: readonly string[];
|
|
23
|
+
sharedDomains?: readonly string[];
|
|
24
|
+
releases?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
export type ActionVerdict = {
|
|
27
|
+
allow: true;
|
|
28
|
+
reason: string;
|
|
29
|
+
decision: FelsparDecision;
|
|
30
|
+
} | {
|
|
31
|
+
allow: false;
|
|
32
|
+
reason: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const emailRecipientFields: readonly ["to", "cc", "bcc", "replyTo", "reply_to"];
|
|
35
|
+
export declare const emailSubjectFields: readonly ["subject"];
|
|
36
|
+
export declare function gatedRule(rules: ActionGateRules, toolName: string): ActionRule | undefined;
|
|
37
|
+
export interface CheckActionRequest {
|
|
38
|
+
rules: ActionGateRules;
|
|
39
|
+
toolName: string;
|
|
40
|
+
input: unknown;
|
|
41
|
+
decisions: readonly FelsparDecision[];
|
|
42
|
+
verify: ReceiptVerifier;
|
|
43
|
+
outputChecks?: readonly FelsparOutputCheck[];
|
|
44
|
+
verifyOutputCheck?: OutputCheckVerifier;
|
|
45
|
+
now?: () => number;
|
|
46
|
+
}
|
|
47
|
+
export declare function checkAction(request: CheckActionRequest): Promise<ActionVerdict>;
|
|
48
|
+
export interface ActionGateConfig extends ActionGateRules {
|
|
49
|
+
verify: ReceiptVerifier;
|
|
50
|
+
decisionTool: string;
|
|
51
|
+
outputCheckTool?: string;
|
|
52
|
+
verifyOutputCheck?: OutputCheckVerifier;
|
|
53
|
+
decisions?: DecisionRecorder;
|
|
54
|
+
now?: () => number;
|
|
55
|
+
onVerdict?: (toolName: string, verdict: ActionVerdict) => void;
|
|
56
|
+
}
|
|
57
|
+
export interface ActionGate {
|
|
58
|
+
rules: ActionGateRules;
|
|
59
|
+
decisions: DecisionRecorder;
|
|
60
|
+
isGated: (toolName: string) => boolean;
|
|
61
|
+
isDecisionTool: (toolName: string) => boolean;
|
|
62
|
+
isOutputCheckTool: (toolName: string) => boolean;
|
|
63
|
+
check: (sessionId: string, toolName: string, input: unknown) => Promise<ActionVerdict>;
|
|
64
|
+
}
|
|
65
|
+
export declare function createActionGate(config: ActionGateConfig): ActionGate;
|