@theokit/sdk 3.2.2 → 3.3.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 +15 -0
- package/dist/a2a/index.cjs +56 -12
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +56 -12
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-DuhVPer6.d.ts → cron-BxoLC-XX.d.cts} +15 -1
- package/dist/{cron-4u1UdmgC.d.cts → cron-DFta_5kE.d.ts} +15 -1
- package/dist/cron.cjs +56 -12
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +56 -12
- package/dist/cron.js.map +1 -1
- package/dist/{errors-_fPS0X80.d.ts → errors-CFEt27lI.d.ts} +1 -1
- package/dist/{errors-jxK4yfp5.d.cts → errors-CIDoPGa7.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +56 -12
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +56 -12
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +64 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -93
- package/dist/index.d.ts +7 -93
- package/dist/index.js +64 -16
- package/dist/index.js.map +1 -1
- package/dist/internal/persistence/pagination.d.cts +14 -1
- package/dist/internal/persistence/pagination.d.ts +14 -1
- package/dist/internal/plugins/types.d.cts +7 -0
- package/dist/internal/plugins/types.d.ts +7 -0
- package/dist/permission-engine.d.ts +4 -3
- package/dist/{run-CrHz9BAP.d.cts → run-CL5Rw6a5.d.cts} +98 -1
- package/dist/{run-CrHz9BAP.d.ts → run-CL5Rw6a5.d.ts} +98 -1
- package/dist/types/agent.d.ts +7 -0
- package/dist/types/run.d.ts +10 -0
- package/package.json +1 -1
|
@@ -5,4 +5,17 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Apply an optional `{ offset, limit }` window to an ordered list.
|
|
10
|
+
* `undefined` opts returns the list unchanged; undefined offset ⇒ 0; undefined
|
|
11
|
+
* limit ⇒ to the end. An out-of-range (but valid) offset yields an empty slice.
|
|
12
|
+
*
|
|
13
|
+
* Invalid input FAILS FAST (error-handling.md): `offset`/`limit` must be a
|
|
14
|
+
* non-negative integer — a `NaN`, negative, fractional, or non-finite value is a
|
|
15
|
+
* caller mistake and throws `ConfigurationError` rather than being silently
|
|
16
|
+
* coerced (a `NaN` offset previously returned the whole list).
|
|
17
|
+
*/
|
|
18
|
+
export declare function paginate<T>(items: readonly T[], opts?: {
|
|
19
|
+
offset?: number;
|
|
20
|
+
limit?: number;
|
|
21
|
+
}): readonly T[];
|
|
@@ -5,4 +5,17 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Apply an optional `{ offset, limit }` window to an ordered list.
|
|
10
|
+
* `undefined` opts returns the list unchanged; undefined offset ⇒ 0; undefined
|
|
11
|
+
* limit ⇒ to the end. An out-of-range (but valid) offset yields an empty slice.
|
|
12
|
+
*
|
|
13
|
+
* Invalid input FAILS FAST (error-handling.md): `offset`/`limit` must be a
|
|
14
|
+
* non-negative integer — a `NaN`, negative, fractional, or non-finite value is a
|
|
15
|
+
* caller mistake and throws `ConfigurationError` rather than being silently
|
|
16
|
+
* coerced (a `NaN` offset previously returned the whole list).
|
|
17
|
+
*/
|
|
18
|
+
export declare function paginate<T>(items: readonly T[], opts?: {
|
|
19
|
+
offset?: number;
|
|
20
|
+
limit?: number;
|
|
21
|
+
}): readonly T[];
|
|
@@ -20,6 +20,13 @@ export interface PreToolCallContext {
|
|
|
20
20
|
args: Record<string, unknown>;
|
|
21
21
|
agentId: string;
|
|
22
22
|
runId: string;
|
|
23
|
+
/**
|
|
24
|
+
* SE1 — the run's resolved `PermissionMode` (from `SendOptions.permissionMode`
|
|
25
|
+
* ?? `AgentOptions.permissionMode`), threaded so a permission-style plugin can
|
|
26
|
+
* gate per-run rather than at construction time. Absent ⇒ the plugin's own
|
|
27
|
+
* default applies. Ignored by non-permission plugins.
|
|
28
|
+
*/
|
|
29
|
+
permissionMode?: import("../../permission-engine.js").PermissionMode;
|
|
23
30
|
}
|
|
24
31
|
export interface PreToolCallDecision {
|
|
25
32
|
block: true;
|
|
@@ -20,6 +20,13 @@ export interface PreToolCallContext {
|
|
|
20
20
|
args: Record<string, unknown>;
|
|
21
21
|
agentId: string;
|
|
22
22
|
runId: string;
|
|
23
|
+
/**
|
|
24
|
+
* SE1 — the run's resolved `PermissionMode` (from `SendOptions.permissionMode`
|
|
25
|
+
* ?? `AgentOptions.permissionMode`), threaded so a permission-style plugin can
|
|
26
|
+
* gate per-run rather than at construction time. Absent ⇒ the plugin's own
|
|
27
|
+
* default applies. Ignored by non-permission plugins.
|
|
28
|
+
*/
|
|
29
|
+
permissionMode?: import("../../permission-engine.js").PermissionMode;
|
|
23
30
|
}
|
|
24
31
|
export interface PreToolCallDecision {
|
|
25
32
|
block: true;
|
|
@@ -23,10 +23,11 @@ export type PermissionAction = "allow" | "deny" | "ask";
|
|
|
23
23
|
* for full read-only behavior.
|
|
24
24
|
* - `acceptEdits` — auto-approve the UNMATCHED verdict, but STILL honor an explicit
|
|
25
25
|
* `ask` rule (a caller gates a risky tool with an ask rule). Codex `UnlessTrusted`.
|
|
26
|
-
* - `bypass`
|
|
27
|
-
*
|
|
26
|
+
* - `bypass` (alias `bypassPermissions`, the Anthropic-exact name) — everything ⇒
|
|
27
|
+
* `allow` EXCEPT an explicit `deny` rule. Never asks. OpenCode
|
|
28
|
+
* `dangerously-skip-permissions` / Codex `Never` / Anthropic `bypassPermissions`.
|
|
28
29
|
*/
|
|
29
|
-
export type PermissionMode = "default" | "plan" | "acceptEdits" | "bypass";
|
|
30
|
+
export type PermissionMode = "default" | "plan" | "acceptEdits" | "bypass" | "bypassPermissions";
|
|
30
31
|
/**
|
|
31
32
|
* SE1 — apply a {@link PermissionMode} to a rule-engine verdict. Pure.
|
|
32
33
|
*
|
|
@@ -69,6 +69,93 @@ interface ToolResultGuardOptions {
|
|
|
69
69
|
redactPii?: boolean;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* `PermissionEngine` — first-match permission rules for tool invocations.
|
|
74
|
+
*
|
|
75
|
+
* Evaluates a tool name (and optional arguments, #55) against an ordered list
|
|
76
|
+
* of rules. First matching rule wins; when no rule matches the `defaultAction`
|
|
77
|
+
* is returned. #55 — the default is now `"ask"` (FAIL-CLOSED): a permission
|
|
78
|
+
* engine that cannot positively allow must not silently allow. Opt back into
|
|
79
|
+
* the previous fail-open behavior with `{ defaultAction: "allow" }`.
|
|
80
|
+
*/
|
|
81
|
+
type PermissionAction = "allow" | "deny" | "ask";
|
|
82
|
+
/**
|
|
83
|
+
* SE1 — a per-run permission MODE that adjusts the rule-engine verdict globally.
|
|
84
|
+
* A PURE post-processor of the verdict (no tool-safety metadata needed, so it fits
|
|
85
|
+
* a bring-your-own-tools runtime). Grounded in OpenCode (plan agent = deny-all,
|
|
86
|
+
* `dangerously-skip-permissions`) + Codex (`AskForApproval`: `OnRequest` default,
|
|
87
|
+
* `Never`, `UnlessTrusted`). See {@link applyMode} for the exact table.
|
|
88
|
+
*
|
|
89
|
+
* - `default` — verdict as-is (rules decide; unmatched ⇒ `ask`, fail-closed).
|
|
90
|
+
* - `plan` — read-only: `allow` rules pass, everything else ⇒ `deny` (mutations blocked).
|
|
91
|
+
* NOTE: `plan` gates on the resolved verdict, so an engine configured with
|
|
92
|
+
* `{ defaultAction: "allow" }` still yields `allow` for UNMATCHED calls under
|
|
93
|
+
* `plan` — pair `plan` with the default fail-closed engine (`defaultAction: "ask"`)
|
|
94
|
+
* for full read-only behavior.
|
|
95
|
+
* - `acceptEdits` — auto-approve the UNMATCHED verdict, but STILL honor an explicit
|
|
96
|
+
* `ask` rule (a caller gates a risky tool with an ask rule). Codex `UnlessTrusted`.
|
|
97
|
+
* - `bypass` (alias `bypassPermissions`, the Anthropic-exact name) — everything ⇒
|
|
98
|
+
* `allow` EXCEPT an explicit `deny` rule. Never asks. OpenCode
|
|
99
|
+
* `dangerously-skip-permissions` / Codex `Never` / Anthropic `bypassPermissions`.
|
|
100
|
+
*/
|
|
101
|
+
type PermissionMode = "default" | "plan" | "acceptEdits" | "bypass" | "bypassPermissions";
|
|
102
|
+
/**
|
|
103
|
+
* SE1 — apply a {@link PermissionMode} to a rule-engine verdict. Pure.
|
|
104
|
+
*
|
|
105
|
+
* `explicit` is `true` when the verdict came from a rule that matched by name (and
|
|
106
|
+
* args), `false` when it is the fail-closed default for an unmatched call. The flag
|
|
107
|
+
* is load-bearing for `acceptEdits`, which auto-approves the unmatched default but
|
|
108
|
+
* keeps honoring an explicit `ask` rule (unlike `bypass`, which allows even that).
|
|
109
|
+
*
|
|
110
|
+
* INVARIANT (both OpenCode + Codex): an explicit `deny` is immune to EVERY
|
|
111
|
+
* auto-approve mode — `bypass`/`acceptEdits` never un-deny.
|
|
112
|
+
*/
|
|
113
|
+
declare function applyMode(verdict: PermissionAction, mode: PermissionMode, explicit: boolean): PermissionAction;
|
|
114
|
+
/**
|
|
115
|
+
* #55 — an argument matcher. A rule with `args` gates on the tool's argument
|
|
116
|
+
* VALUES, not just its name: an exact string, a RegExp (tested against the
|
|
117
|
+
* stringified value), or a predicate. Every declared arg must match for the
|
|
118
|
+
* rule to apply — so `{ tool: "shell", args: { command: /rm\s+-rf/ } }` denies
|
|
119
|
+
* a destructive shell call while leaving `ls` to fall through.
|
|
120
|
+
*/
|
|
121
|
+
type ArgMatcher = string | RegExp | ((value: unknown) => boolean);
|
|
122
|
+
interface PermissionRule {
|
|
123
|
+
/** Tool name (exact string) or pattern (RegExp). */
|
|
124
|
+
tool: string | RegExp;
|
|
125
|
+
/**
|
|
126
|
+
* #55 — optional per-argument matchers. When present, the rule matches only
|
|
127
|
+
* if the tool name matches AND every declared arg predicate matches the
|
|
128
|
+
* corresponding call argument. A missing/undefined arg fails its predicate
|
|
129
|
+
* (the rule does not match) — never throws.
|
|
130
|
+
*/
|
|
131
|
+
args?: Record<string, ArgMatcher>;
|
|
132
|
+
/** Action to take when rule matches. */
|
|
133
|
+
action: PermissionAction;
|
|
134
|
+
}
|
|
135
|
+
/** Options for {@link PermissionEngine}. */
|
|
136
|
+
interface PermissionEngineOptions {
|
|
137
|
+
/**
|
|
138
|
+
* Action when no rule matches. #55 — default is now `"ask"` (fail-closed): a
|
|
139
|
+
* permission engine that cannot positively allow must not silently allow.
|
|
140
|
+
* Pass `"allow"` to restore the previous fail-open behavior.
|
|
141
|
+
*/
|
|
142
|
+
readonly defaultAction?: PermissionAction;
|
|
143
|
+
}
|
|
144
|
+
declare class PermissionEngine {
|
|
145
|
+
#private;
|
|
146
|
+
private readonly rules;
|
|
147
|
+
private readonly defaultAction;
|
|
148
|
+
constructor(rules: PermissionRule[], options?: PermissionEngineOptions);
|
|
149
|
+
/**
|
|
150
|
+
* Evaluate a tool name (and optional arguments) against the rules. First
|
|
151
|
+
* match wins; falls back to the configured `defaultAction` (default `"ask"`,
|
|
152
|
+
* fail-closed) when no rule matches. #55 — a rule with `args` gates on the
|
|
153
|
+
* argument values, so the same tool name can resolve to different actions
|
|
154
|
+
* depending on what it is asked to do.
|
|
155
|
+
*/
|
|
156
|
+
evaluate(toolName: string, args?: Record<string, unknown>, mode?: PermissionMode): PermissionAction;
|
|
157
|
+
}
|
|
158
|
+
|
|
72
159
|
/**
|
|
73
160
|
* SE2 — typed runtime EVENT stream, ADDITIVE to the `SDKMessage` content stream.
|
|
74
161
|
*
|
|
@@ -1251,6 +1338,16 @@ interface SendOptions {
|
|
|
1251
1338
|
* snapshot is untouched). Matching is glob-based (`**`, `*`, `?`).
|
|
1252
1339
|
*/
|
|
1253
1340
|
contextPaths?: readonly string[];
|
|
1341
|
+
/**
|
|
1342
|
+
* SE1 — the permission mode for THIS run, threaded to a registered
|
|
1343
|
+
* `PermissionPlugin`'s pre-tool gate. Precedence: this per-send value wins over
|
|
1344
|
+
* `AgentOptions.permissionMode` (creation-time default). Modes: `default` (rules
|
|
1345
|
+
* decide; unmatched ⇒ fail-closed ask), `plan` (read-only — allow rules pass,
|
|
1346
|
+
* everything else denied), `acceptEdits` (auto-approve unmatched, honor explicit
|
|
1347
|
+
* ask rules), `bypass` / `bypassPermissions` (allow all except an explicit deny).
|
|
1348
|
+
* Absent ⇒ the plugin's own construction-time mode applies. Local runtime.
|
|
1349
|
+
*/
|
|
1350
|
+
permissionMode?: PermissionMode;
|
|
1254
1351
|
onStep?: (args: {
|
|
1255
1352
|
step: ConversationStep;
|
|
1256
1353
|
}) => void | Promise<void>;
|
|
@@ -1475,4 +1572,4 @@ interface GenerateRunResult<O> {
|
|
|
1475
1572
|
};
|
|
1476
1573
|
}
|
|
1477
1574
|
|
|
1478
|
-
export { type
|
|
1575
|
+
export { type RunToCompletionResult as $, type AgentConversationTurn as A, type ProcessorTripwire as B, type CustomTool as C, type DoomLoopThresholds as D, type ProcessorViolation as E, type RunCompactBoundaryEvent as F, type GenerateOptions as G, type RunCompletionCheckEvent as H, type ImageBlock as I, type RunErrorDetail as J, type RunEvent as K, type RunEventSink as L, type ModelSelection as M, type RunGitInfo as N, type OutputProcessorContext as O, type Processor as P, type RunOperation as Q, type RunResult as R, type SDKMessage as S, type ToolResultContentBlock as T, type RunPermissionDeniedEvent as U, type RunRateLimitEvent as V, type RunStatus as W, type RunTaskCompletedEvent as X, type RunTaskStartedEvent as Y, type RunTaskUpdatedEvent as Z, type RunToCompletionOptions as _, type McpServerConfig as a, type RunToolProgressEvent as a0, type RunTripwireEvent as a1, type SDKAssistantMessage as a2, type SDKImage as a3, type SDKImageDimension as a4, type SDKObjectDelta as a5, type SDKRequestMessage as a6, type SDKStatusMessage as a7, type SDKSystemMessage as a8, type SDKTaskMessage as a9, type ToolResult as aA, type ToolResultGuardOptions as aB, type ToolUseBlock as aC, type TurnEndedUpdate as aD, type UserMessage as aE, type UserMessageAppendedUpdate as aF, applyMode as aG, emitRunEvent as aH, type SDKThinkingMessage as aa, type SDKToolUseMessage as ab, type SDKUserMessage as ac, type SDKUserMessageEvent as ad, type SendOptions as ae, type ShellCommand as af, type ShellConversationTurn as ag, type ShellOutput as ah, type ShellOutputDeltaUpdate as ai, type StepCompletedUpdate as aj, type StepStartedUpdate as ak, type StreamToCompletionResult as al, type SummaryCompletedUpdate as am, type SummaryStartedUpdate as an, type SummaryUpdate as ao, type TextBlock as ap, type TextDeltaUpdate as aq, type ThinkingCompletedUpdate as ar, type ThinkingDeltaUpdate as as, type ThinkingMessage as at, type TokenDeltaUpdate as au, type TokenUsage as av, type ToolCall as aw, type ToolCallCompletedUpdate as ax, type ToolCallStartedUpdate as ay, type ToolContextMessage as az, type Run as b, type PermissionMode as c, PermissionEngine as d, type AssistantMessage as e, type CompletionCheck as f, type CompletionCheckResult as g, type ConversationStep as h, type ConversationTurn as i, type CostBreakdown as j, type CostSource as k, type CostStatus as l, type GenerateRunResult as m, type InputProcessorContext as n, type InteractionUpdate as o, type McpAuthConfig as p, type McpHttpServerConfig as q, type McpOAuthConfig as r, type McpStdioServerConfig as s, type MessageOrigin as t, type ModelParameterValue as u, type PartialToolCallUpdate as v, type PermissionAction as w, type PermissionEngineOptions as x, type PermissionRule as y, type ProcessorControls as z };
|
|
@@ -69,6 +69,93 @@ interface ToolResultGuardOptions {
|
|
|
69
69
|
redactPii?: boolean;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* `PermissionEngine` — first-match permission rules for tool invocations.
|
|
74
|
+
*
|
|
75
|
+
* Evaluates a tool name (and optional arguments, #55) against an ordered list
|
|
76
|
+
* of rules. First matching rule wins; when no rule matches the `defaultAction`
|
|
77
|
+
* is returned. #55 — the default is now `"ask"` (FAIL-CLOSED): a permission
|
|
78
|
+
* engine that cannot positively allow must not silently allow. Opt back into
|
|
79
|
+
* the previous fail-open behavior with `{ defaultAction: "allow" }`.
|
|
80
|
+
*/
|
|
81
|
+
type PermissionAction = "allow" | "deny" | "ask";
|
|
82
|
+
/**
|
|
83
|
+
* SE1 — a per-run permission MODE that adjusts the rule-engine verdict globally.
|
|
84
|
+
* A PURE post-processor of the verdict (no tool-safety metadata needed, so it fits
|
|
85
|
+
* a bring-your-own-tools runtime). Grounded in OpenCode (plan agent = deny-all,
|
|
86
|
+
* `dangerously-skip-permissions`) + Codex (`AskForApproval`: `OnRequest` default,
|
|
87
|
+
* `Never`, `UnlessTrusted`). See {@link applyMode} for the exact table.
|
|
88
|
+
*
|
|
89
|
+
* - `default` — verdict as-is (rules decide; unmatched ⇒ `ask`, fail-closed).
|
|
90
|
+
* - `plan` — read-only: `allow` rules pass, everything else ⇒ `deny` (mutations blocked).
|
|
91
|
+
* NOTE: `plan` gates on the resolved verdict, so an engine configured with
|
|
92
|
+
* `{ defaultAction: "allow" }` still yields `allow` for UNMATCHED calls under
|
|
93
|
+
* `plan` — pair `plan` with the default fail-closed engine (`defaultAction: "ask"`)
|
|
94
|
+
* for full read-only behavior.
|
|
95
|
+
* - `acceptEdits` — auto-approve the UNMATCHED verdict, but STILL honor an explicit
|
|
96
|
+
* `ask` rule (a caller gates a risky tool with an ask rule). Codex `UnlessTrusted`.
|
|
97
|
+
* - `bypass` (alias `bypassPermissions`, the Anthropic-exact name) — everything ⇒
|
|
98
|
+
* `allow` EXCEPT an explicit `deny` rule. Never asks. OpenCode
|
|
99
|
+
* `dangerously-skip-permissions` / Codex `Never` / Anthropic `bypassPermissions`.
|
|
100
|
+
*/
|
|
101
|
+
type PermissionMode = "default" | "plan" | "acceptEdits" | "bypass" | "bypassPermissions";
|
|
102
|
+
/**
|
|
103
|
+
* SE1 — apply a {@link PermissionMode} to a rule-engine verdict. Pure.
|
|
104
|
+
*
|
|
105
|
+
* `explicit` is `true` when the verdict came from a rule that matched by name (and
|
|
106
|
+
* args), `false` when it is the fail-closed default for an unmatched call. The flag
|
|
107
|
+
* is load-bearing for `acceptEdits`, which auto-approves the unmatched default but
|
|
108
|
+
* keeps honoring an explicit `ask` rule (unlike `bypass`, which allows even that).
|
|
109
|
+
*
|
|
110
|
+
* INVARIANT (both OpenCode + Codex): an explicit `deny` is immune to EVERY
|
|
111
|
+
* auto-approve mode — `bypass`/`acceptEdits` never un-deny.
|
|
112
|
+
*/
|
|
113
|
+
declare function applyMode(verdict: PermissionAction, mode: PermissionMode, explicit: boolean): PermissionAction;
|
|
114
|
+
/**
|
|
115
|
+
* #55 — an argument matcher. A rule with `args` gates on the tool's argument
|
|
116
|
+
* VALUES, not just its name: an exact string, a RegExp (tested against the
|
|
117
|
+
* stringified value), or a predicate. Every declared arg must match for the
|
|
118
|
+
* rule to apply — so `{ tool: "shell", args: { command: /rm\s+-rf/ } }` denies
|
|
119
|
+
* a destructive shell call while leaving `ls` to fall through.
|
|
120
|
+
*/
|
|
121
|
+
type ArgMatcher = string | RegExp | ((value: unknown) => boolean);
|
|
122
|
+
interface PermissionRule {
|
|
123
|
+
/** Tool name (exact string) or pattern (RegExp). */
|
|
124
|
+
tool: string | RegExp;
|
|
125
|
+
/**
|
|
126
|
+
* #55 — optional per-argument matchers. When present, the rule matches only
|
|
127
|
+
* if the tool name matches AND every declared arg predicate matches the
|
|
128
|
+
* corresponding call argument. A missing/undefined arg fails its predicate
|
|
129
|
+
* (the rule does not match) — never throws.
|
|
130
|
+
*/
|
|
131
|
+
args?: Record<string, ArgMatcher>;
|
|
132
|
+
/** Action to take when rule matches. */
|
|
133
|
+
action: PermissionAction;
|
|
134
|
+
}
|
|
135
|
+
/** Options for {@link PermissionEngine}. */
|
|
136
|
+
interface PermissionEngineOptions {
|
|
137
|
+
/**
|
|
138
|
+
* Action when no rule matches. #55 — default is now `"ask"` (fail-closed): a
|
|
139
|
+
* permission engine that cannot positively allow must not silently allow.
|
|
140
|
+
* Pass `"allow"` to restore the previous fail-open behavior.
|
|
141
|
+
*/
|
|
142
|
+
readonly defaultAction?: PermissionAction;
|
|
143
|
+
}
|
|
144
|
+
declare class PermissionEngine {
|
|
145
|
+
#private;
|
|
146
|
+
private readonly rules;
|
|
147
|
+
private readonly defaultAction;
|
|
148
|
+
constructor(rules: PermissionRule[], options?: PermissionEngineOptions);
|
|
149
|
+
/**
|
|
150
|
+
* Evaluate a tool name (and optional arguments) against the rules. First
|
|
151
|
+
* match wins; falls back to the configured `defaultAction` (default `"ask"`,
|
|
152
|
+
* fail-closed) when no rule matches. #55 — a rule with `args` gates on the
|
|
153
|
+
* argument values, so the same tool name can resolve to different actions
|
|
154
|
+
* depending on what it is asked to do.
|
|
155
|
+
*/
|
|
156
|
+
evaluate(toolName: string, args?: Record<string, unknown>, mode?: PermissionMode): PermissionAction;
|
|
157
|
+
}
|
|
158
|
+
|
|
72
159
|
/**
|
|
73
160
|
* SE2 — typed runtime EVENT stream, ADDITIVE to the `SDKMessage` content stream.
|
|
74
161
|
*
|
|
@@ -1251,6 +1338,16 @@ interface SendOptions {
|
|
|
1251
1338
|
* snapshot is untouched). Matching is glob-based (`**`, `*`, `?`).
|
|
1252
1339
|
*/
|
|
1253
1340
|
contextPaths?: readonly string[];
|
|
1341
|
+
/**
|
|
1342
|
+
* SE1 — the permission mode for THIS run, threaded to a registered
|
|
1343
|
+
* `PermissionPlugin`'s pre-tool gate. Precedence: this per-send value wins over
|
|
1344
|
+
* `AgentOptions.permissionMode` (creation-time default). Modes: `default` (rules
|
|
1345
|
+
* decide; unmatched ⇒ fail-closed ask), `plan` (read-only — allow rules pass,
|
|
1346
|
+
* everything else denied), `acceptEdits` (auto-approve unmatched, honor explicit
|
|
1347
|
+
* ask rules), `bypass` / `bypassPermissions` (allow all except an explicit deny).
|
|
1348
|
+
* Absent ⇒ the plugin's own construction-time mode applies. Local runtime.
|
|
1349
|
+
*/
|
|
1350
|
+
permissionMode?: PermissionMode;
|
|
1254
1351
|
onStep?: (args: {
|
|
1255
1352
|
step: ConversationStep;
|
|
1256
1353
|
}) => void | Promise<void>;
|
|
@@ -1475,4 +1572,4 @@ interface GenerateRunResult<O> {
|
|
|
1475
1572
|
};
|
|
1476
1573
|
}
|
|
1477
1574
|
|
|
1478
|
-
export { type
|
|
1575
|
+
export { type RunToCompletionResult as $, type AgentConversationTurn as A, type ProcessorTripwire as B, type CustomTool as C, type DoomLoopThresholds as D, type ProcessorViolation as E, type RunCompactBoundaryEvent as F, type GenerateOptions as G, type RunCompletionCheckEvent as H, type ImageBlock as I, type RunErrorDetail as J, type RunEvent as K, type RunEventSink as L, type ModelSelection as M, type RunGitInfo as N, type OutputProcessorContext as O, type Processor as P, type RunOperation as Q, type RunResult as R, type SDKMessage as S, type ToolResultContentBlock as T, type RunPermissionDeniedEvent as U, type RunRateLimitEvent as V, type RunStatus as W, type RunTaskCompletedEvent as X, type RunTaskStartedEvent as Y, type RunTaskUpdatedEvent as Z, type RunToCompletionOptions as _, type McpServerConfig as a, type RunToolProgressEvent as a0, type RunTripwireEvent as a1, type SDKAssistantMessage as a2, type SDKImage as a3, type SDKImageDimension as a4, type SDKObjectDelta as a5, type SDKRequestMessage as a6, type SDKStatusMessage as a7, type SDKSystemMessage as a8, type SDKTaskMessage as a9, type ToolResult as aA, type ToolResultGuardOptions as aB, type ToolUseBlock as aC, type TurnEndedUpdate as aD, type UserMessage as aE, type UserMessageAppendedUpdate as aF, applyMode as aG, emitRunEvent as aH, type SDKThinkingMessage as aa, type SDKToolUseMessage as ab, type SDKUserMessage as ac, type SDKUserMessageEvent as ad, type SendOptions as ae, type ShellCommand as af, type ShellConversationTurn as ag, type ShellOutput as ah, type ShellOutputDeltaUpdate as ai, type StepCompletedUpdate as aj, type StepStartedUpdate as ak, type StreamToCompletionResult as al, type SummaryCompletedUpdate as am, type SummaryStartedUpdate as an, type SummaryUpdate as ao, type TextBlock as ap, type TextDeltaUpdate as aq, type ThinkingCompletedUpdate as ar, type ThinkingDeltaUpdate as as, type ThinkingMessage as at, type TokenDeltaUpdate as au, type TokenUsage as av, type ToolCall as aw, type ToolCallCompletedUpdate as ax, type ToolCallStartedUpdate as ay, type ToolContextMessage as az, type Run as b, type PermissionMode as c, PermissionEngine as d, type AssistantMessage as e, type CompletionCheck as f, type CompletionCheckResult as g, type ConversationStep as h, type ConversationTurn as i, type CostBreakdown as j, type CostSource as k, type CostStatus as l, type GenerateRunResult as m, type InputProcessorContext as n, type InteractionUpdate as o, type McpAuthConfig as p, type McpHttpServerConfig as q, type McpOAuthConfig as r, type McpStdioServerConfig as s, type MessageOrigin as t, type ModelParameterValue as u, type PartialToolCallUpdate as v, type PermissionAction as w, type PermissionEngineOptions as x, type PermissionRule as y, type ProcessorControls as z };
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -384,6 +384,13 @@ export interface AgentOptions {
|
|
|
384
384
|
* The two forms are mutually exclusive — pass one or the other.
|
|
385
385
|
*/
|
|
386
386
|
plugins?: PluginsSettings | readonly Plugin[];
|
|
387
|
+
/**
|
|
388
|
+
* SE1 — the default permission mode for this agent's runs, threaded to a
|
|
389
|
+
* registered `PermissionPlugin`'s pre-tool gate. A per-send
|
|
390
|
+
* `SendOptions.permissionMode` overrides it. Absent ⇒ the plugin's own
|
|
391
|
+
* construction-time mode applies. Local runtime.
|
|
392
|
+
*/
|
|
393
|
+
permissionMode?: import("../permission-engine.js").PermissionMode;
|
|
387
394
|
/**
|
|
388
395
|
* Skills configuration. Either a static {@link SkillsSettings} object or —
|
|
389
396
|
* SE22 — a {@link SkillsResolver} evaluated per `send()` to pick skills from
|
package/dist/types/run.d.ts
CHANGED
|
@@ -343,6 +343,16 @@ export interface SendOptions {
|
|
|
343
343
|
* snapshot is untouched). Matching is glob-based (`**`, `*`, `?`).
|
|
344
344
|
*/
|
|
345
345
|
contextPaths?: readonly string[];
|
|
346
|
+
/**
|
|
347
|
+
* SE1 — the permission mode for THIS run, threaded to a registered
|
|
348
|
+
* `PermissionPlugin`'s pre-tool gate. Precedence: this per-send value wins over
|
|
349
|
+
* `AgentOptions.permissionMode` (creation-time default). Modes: `default` (rules
|
|
350
|
+
* decide; unmatched ⇒ fail-closed ask), `plan` (read-only — allow rules pass,
|
|
351
|
+
* everything else denied), `acceptEdits` (auto-approve unmatched, honor explicit
|
|
352
|
+
* ask rules), `bypass` / `bypassPermissions` (allow all except an explicit deny).
|
|
353
|
+
* Absent ⇒ the plugin's own construction-time mode applies. Local runtime.
|
|
354
|
+
*/
|
|
355
|
+
permissionMode?: import("../permission-engine.js").PermissionMode;
|
|
346
356
|
onStep?: (args: {
|
|
347
357
|
step: ConversationStep;
|
|
348
358
|
}) => void | Promise<void>;
|
package/package.json
CHANGED