Skip to content

Commit b53f59b

Browse files
committed
fix(protocol): bound approval declaration exports
1 parent e08643e commit b53f59b

4 files changed

Lines changed: 29 additions & 24 deletions

File tree

packages/gateway-protocol/src/schema/approvals.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Gateway Protocol schema module defines durable cross-surface approval shapes.
22
import { Type } from "typebox";
3+
import type { Static } from "typebox";
34
import { NonEmptyString } from "./primitives.js";
45

56
const APPROVAL_ID_WELL_FORMED_UNICODE_PATTERN =
@@ -225,3 +226,25 @@ export const ApprovalResolveResultSchema = Type.Object(
225226
},
226227
{ additionalProperties: false },
227228
);
229+
230+
// These types are plugin-SDK-reachable through approval presentation. Export
231+
// them from the owner module so public declarations do not retain ProtocolSchemas.
232+
export type ApprovalKind = Static<typeof ApprovalKindSchema>;
233+
export type ApprovalDecision = Static<typeof ApprovalDecisionSchema>;
234+
export type ApprovalAllowDecision = Static<typeof ApprovalAllowDecisionSchema>;
235+
export type ApprovalTerminalReason = Static<typeof ApprovalTerminalReasonSchema>;
236+
export type PluginApprovalSeverity = Static<typeof PluginApprovalSeveritySchema>;
237+
export type ExecApprovalPresentation = Static<typeof ExecApprovalPresentationSchema>;
238+
export type PluginApprovalPresentation = Static<typeof PluginApprovalPresentationSchema>;
239+
export type ApprovalPresentation = Static<typeof ApprovalPresentationSchema>;
240+
export type PendingApprovalSnapshot = Static<typeof PendingApprovalSnapshotSchema>;
241+
export type AllowedApprovalSnapshot = Static<typeof AllowedApprovalSnapshotSchema>;
242+
export type DeniedApprovalSnapshot = Static<typeof DeniedApprovalSnapshotSchema>;
243+
export type ExpiredApprovalSnapshot = Static<typeof ExpiredApprovalSnapshotSchema>;
244+
export type CancelledApprovalSnapshot = Static<typeof CancelledApprovalSnapshotSchema>;
245+
export type ApprovalSnapshot = Static<typeof ApprovalSnapshotSchema>;
246+
export type TerminalApprovalSnapshot = Static<typeof TerminalApprovalSnapshotSchema>;
247+
export type ApprovalGetParams = Static<typeof ApprovalGetParamsSchema>;
248+
export type ApprovalGetResult = Static<typeof ApprovalGetResultSchema>;
249+
export type ApprovalResolveParams = Static<typeof ApprovalResolveParamsSchema>;
250+
export type ApprovalResolveResult = Static<typeof ApprovalResolveResultSchema>;

packages/gateway-protocol/src/schema/types.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -510,25 +510,6 @@ export type CronRunLogEntry = SchemaType<"CronRunLogEntry">;
510510
/** Logs and approval payloads for chat, exec commands, plugins, and devices. */
511511
export type LogsTailParams = SchemaType<"LogsTailParams">;
512512
export type LogsTailResult = SchemaType<"LogsTailResult">;
513-
export type ApprovalKind = SchemaType<"ApprovalKind">;
514-
export type ApprovalDecision = SchemaType<"ApprovalDecision">;
515-
export type ApprovalAllowDecision = SchemaType<"ApprovalAllowDecision">;
516-
export type ApprovalTerminalReason = SchemaType<"ApprovalTerminalReason">;
517-
export type PluginApprovalSeverity = SchemaType<"PluginApprovalSeverity">;
518-
export type ExecApprovalPresentation = SchemaType<"ExecApprovalPresentation">;
519-
export type PluginApprovalPresentation = SchemaType<"PluginApprovalPresentation">;
520-
export type ApprovalPresentation = SchemaType<"ApprovalPresentation">;
521-
export type PendingApprovalSnapshot = SchemaType<"PendingApprovalSnapshot">;
522-
export type AllowedApprovalSnapshot = SchemaType<"AllowedApprovalSnapshot">;
523-
export type DeniedApprovalSnapshot = SchemaType<"DeniedApprovalSnapshot">;
524-
export type ExpiredApprovalSnapshot = SchemaType<"ExpiredApprovalSnapshot">;
525-
export type CancelledApprovalSnapshot = SchemaType<"CancelledApprovalSnapshot">;
526-
export type ApprovalSnapshot = SchemaType<"ApprovalSnapshot">;
527-
export type TerminalApprovalSnapshot = SchemaType<"TerminalApprovalSnapshot">;
528-
export type ApprovalGetParams = SchemaType<"ApprovalGetParams">;
529-
export type ApprovalGetResult = SchemaType<"ApprovalGetResult">;
530-
export type ApprovalResolveParams = SchemaType<"ApprovalResolveParams">;
531-
export type ApprovalResolveResult = SchemaType<"ApprovalResolveResult">;
532513
export type ExecApprovalsGetParams = SchemaType<"ExecApprovalsGetParams">;
533514
export type ExecApprovalsSetParams = SchemaType<"ExecApprovalsSetParams">;
534515
export type ExecApprovalsNodeGetParams = SchemaType<"ExecApprovalsNodeGetParams">;

src/gateway/operator-approval-store.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// Persistent operator approval lifecycle and first-answer-wins transitions.
22
import type { Selectable } from "kysely";
3+
import { Value } from "typebox/value";
34
import {
5+
ApprovalPresentationSchema,
46
type ApprovalPresentation,
57
isWellFormedApprovalId,
6-
validateApprovalPresentation,
7-
} from "../../packages/gateway-protocol/src/index.js";
8+
} from "../../packages/gateway-protocol/src/schema/approvals.js";
89
import {
910
executeSqliteQuerySync,
1011
executeSqliteQueryTakeFirstSync,
@@ -168,7 +169,7 @@ const OPERATOR_APPROVAL_RESOLVER_KINDS = new Set<OperatorApprovalResolverKind>([
168169
function parseApprovalPresentation(raw: string): ApprovalPresentation | null {
169170
try {
170171
const value: unknown = JSON.parse(raw);
171-
return validateApprovalPresentation(value) ? value : null;
172+
return Value.Check(ApprovalPresentationSchema, value) ? value : null;
172173
} catch {
173174
return null;
174175
}
@@ -221,7 +222,7 @@ function normalizeStringArray(values: readonly string[] | undefined): string[] {
221222
}
222223

223224
function stringifyPresentation(presentation: ApprovalPresentation): string {
224-
if (!validateApprovalPresentation(presentation)) {
225+
if (!Value.Check(ApprovalPresentationSchema, presentation)) {
225226
throw new Error("operator approval presentation must match the safe protocol schema");
226227
}
227228
let raw: string;

src/infra/approval-presentation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type {
44
ApprovalDecision,
55
ApprovalKind,
66
ApprovalPresentation,
7-
} from "../../packages/gateway-protocol/src/index.js";
7+
} from "../../packages/gateway-protocol/src/schema/approvals.js";
88
import {
99
resolveExecApprovalCommandDisplay,
1010
sanitizeExecApprovalDisplayText,

0 commit comments

Comments
 (0)