@pugi/sdk 0.1.0-alpha.3

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.
@@ -0,0 +1,387 @@
1
+ import { z } from 'zod';
2
+ export declare const auditEventBaseSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ sessionId: z.ZodString;
5
+ timestamp: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ id: string;
8
+ sessionId: string;
9
+ timestamp: string;
10
+ }, {
11
+ id: string;
12
+ sessionId: string;
13
+ timestamp: string;
14
+ }>;
15
+ export declare const toolCallEventSchema: z.ZodObject<{
16
+ id: z.ZodString;
17
+ sessionId: z.ZodString;
18
+ timestamp: z.ZodString;
19
+ } & {
20
+ type: z.ZodLiteral<"tool_call">;
21
+ tool: z.ZodString;
22
+ inputSummary: z.ZodString;
23
+ permissionDecision: z.ZodOptional<z.ZodDiscriminatedUnion<"decision", [z.ZodObject<{
24
+ decision: z.ZodLiteral<"allow">;
25
+ reason: z.ZodString;
26
+ source: z.ZodString;
27
+ expiresAt: z.ZodOptional<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ reason: string;
30
+ decision: "allow";
31
+ source: string;
32
+ expiresAt?: string | undefined;
33
+ }, {
34
+ reason: string;
35
+ decision: "allow";
36
+ source: string;
37
+ expiresAt?: string | undefined;
38
+ }>, z.ZodObject<{
39
+ decision: z.ZodLiteral<"ask">;
40
+ reason: z.ZodString;
41
+ risk: z.ZodEnum<["low", "medium", "high"]>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ reason: string;
44
+ decision: "ask";
45
+ risk: "low" | "medium" | "high";
46
+ }, {
47
+ reason: string;
48
+ decision: "ask";
49
+ risk: "low" | "medium" | "high";
50
+ }>, z.ZodObject<{
51
+ decision: z.ZodLiteral<"deny">;
52
+ reason: z.ZodString;
53
+ source: z.ZodString;
54
+ }, "strip", z.ZodTypeAny, {
55
+ reason: string;
56
+ decision: "deny";
57
+ source: string;
58
+ }, {
59
+ reason: string;
60
+ decision: "deny";
61
+ source: string;
62
+ }>]>>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ type: "tool_call";
65
+ tool: string;
66
+ id: string;
67
+ sessionId: string;
68
+ timestamp: string;
69
+ inputSummary: string;
70
+ permissionDecision?: {
71
+ reason: string;
72
+ decision: "allow";
73
+ source: string;
74
+ expiresAt?: string | undefined;
75
+ } | {
76
+ reason: string;
77
+ decision: "ask";
78
+ risk: "low" | "medium" | "high";
79
+ } | {
80
+ reason: string;
81
+ decision: "deny";
82
+ source: string;
83
+ } | undefined;
84
+ }, {
85
+ type: "tool_call";
86
+ tool: string;
87
+ id: string;
88
+ sessionId: string;
89
+ timestamp: string;
90
+ inputSummary: string;
91
+ permissionDecision?: {
92
+ reason: string;
93
+ decision: "allow";
94
+ source: string;
95
+ expiresAt?: string | undefined;
96
+ } | {
97
+ reason: string;
98
+ decision: "ask";
99
+ risk: "low" | "medium" | "high";
100
+ } | {
101
+ reason: string;
102
+ decision: "deny";
103
+ source: string;
104
+ } | undefined;
105
+ }>;
106
+ export declare const toolResultEventSchema: z.ZodObject<{
107
+ id: z.ZodString;
108
+ sessionId: z.ZodString;
109
+ timestamp: z.ZodString;
110
+ } & {
111
+ type: z.ZodLiteral<"tool_result">;
112
+ toolCallId: z.ZodString;
113
+ status: z.ZodEnum<["success", "error", "cancelled"]>;
114
+ outputSummary: z.ZodString;
115
+ outputRef: z.ZodOptional<z.ZodString>;
116
+ }, "strip", z.ZodTypeAny, {
117
+ type: "tool_result";
118
+ status: "error" | "success" | "cancelled";
119
+ id: string;
120
+ toolCallId: string;
121
+ sessionId: string;
122
+ timestamp: string;
123
+ outputSummary: string;
124
+ outputRef?: string | undefined;
125
+ }, {
126
+ type: "tool_result";
127
+ status: "error" | "success" | "cancelled";
128
+ id: string;
129
+ toolCallId: string;
130
+ sessionId: string;
131
+ timestamp: string;
132
+ outputSummary: string;
133
+ outputRef?: string | undefined;
134
+ }>;
135
+ export declare const fileMutationEventSchema: z.ZodObject<{
136
+ id: z.ZodString;
137
+ sessionId: z.ZodString;
138
+ timestamp: z.ZodString;
139
+ } & {
140
+ type: z.ZodLiteral<"file_mutation">;
141
+ toolCallId: z.ZodString;
142
+ path: z.ZodString;
143
+ operation: z.ZodEnum<["create", "update", "delete", "move"]>;
144
+ beforeBlob: z.ZodOptional<z.ZodString>;
145
+ afterBlob: z.ZodOptional<z.ZodString>;
146
+ beforeHash: z.ZodOptional<z.ZodString>;
147
+ afterHash: z.ZodOptional<z.ZodString>;
148
+ diffRef: z.ZodOptional<z.ZodString>;
149
+ }, "strip", z.ZodTypeAny, {
150
+ path: string;
151
+ type: "file_mutation";
152
+ id: string;
153
+ toolCallId: string;
154
+ sessionId: string;
155
+ timestamp: string;
156
+ operation: "create" | "update" | "delete" | "move";
157
+ beforeBlob?: string | undefined;
158
+ afterBlob?: string | undefined;
159
+ beforeHash?: string | undefined;
160
+ afterHash?: string | undefined;
161
+ diffRef?: string | undefined;
162
+ }, {
163
+ path: string;
164
+ type: "file_mutation";
165
+ id: string;
166
+ toolCallId: string;
167
+ sessionId: string;
168
+ timestamp: string;
169
+ operation: "create" | "update" | "delete" | "move";
170
+ beforeBlob?: string | undefined;
171
+ afterBlob?: string | undefined;
172
+ beforeHash?: string | undefined;
173
+ afterHash?: string | undefined;
174
+ diffRef?: string | undefined;
175
+ }>;
176
+ export declare const sessionEventSchema: z.ZodObject<{
177
+ id: z.ZodString;
178
+ sessionId: z.ZodString;
179
+ timestamp: z.ZodString;
180
+ } & {
181
+ type: z.ZodLiteral<"session">;
182
+ name: z.ZodEnum<["created", "command_started", "command_completed"]>;
183
+ command: z.ZodOptional<z.ZodString>;
184
+ status: z.ZodOptional<z.ZodEnum<["success", "error"]>>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ type: "session";
187
+ id: string;
188
+ name: "created" | "command_started" | "command_completed";
189
+ sessionId: string;
190
+ timestamp: string;
191
+ status?: "error" | "success" | undefined;
192
+ command?: string | undefined;
193
+ }, {
194
+ type: "session";
195
+ id: string;
196
+ name: "created" | "command_started" | "command_completed";
197
+ sessionId: string;
198
+ timestamp: string;
199
+ status?: "error" | "success" | undefined;
200
+ command?: string | undefined;
201
+ }>;
202
+ export declare const auditEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
203
+ id: z.ZodString;
204
+ sessionId: z.ZodString;
205
+ timestamp: z.ZodString;
206
+ } & {
207
+ type: z.ZodLiteral<"session">;
208
+ name: z.ZodEnum<["created", "command_started", "command_completed"]>;
209
+ command: z.ZodOptional<z.ZodString>;
210
+ status: z.ZodOptional<z.ZodEnum<["success", "error"]>>;
211
+ }, "strip", z.ZodTypeAny, {
212
+ type: "session";
213
+ id: string;
214
+ name: "created" | "command_started" | "command_completed";
215
+ sessionId: string;
216
+ timestamp: string;
217
+ status?: "error" | "success" | undefined;
218
+ command?: string | undefined;
219
+ }, {
220
+ type: "session";
221
+ id: string;
222
+ name: "created" | "command_started" | "command_completed";
223
+ sessionId: string;
224
+ timestamp: string;
225
+ status?: "error" | "success" | undefined;
226
+ command?: string | undefined;
227
+ }>, z.ZodObject<{
228
+ id: z.ZodString;
229
+ sessionId: z.ZodString;
230
+ timestamp: z.ZodString;
231
+ } & {
232
+ type: z.ZodLiteral<"tool_call">;
233
+ tool: z.ZodString;
234
+ inputSummary: z.ZodString;
235
+ permissionDecision: z.ZodOptional<z.ZodDiscriminatedUnion<"decision", [z.ZodObject<{
236
+ decision: z.ZodLiteral<"allow">;
237
+ reason: z.ZodString;
238
+ source: z.ZodString;
239
+ expiresAt: z.ZodOptional<z.ZodString>;
240
+ }, "strip", z.ZodTypeAny, {
241
+ reason: string;
242
+ decision: "allow";
243
+ source: string;
244
+ expiresAt?: string | undefined;
245
+ }, {
246
+ reason: string;
247
+ decision: "allow";
248
+ source: string;
249
+ expiresAt?: string | undefined;
250
+ }>, z.ZodObject<{
251
+ decision: z.ZodLiteral<"ask">;
252
+ reason: z.ZodString;
253
+ risk: z.ZodEnum<["low", "medium", "high"]>;
254
+ }, "strip", z.ZodTypeAny, {
255
+ reason: string;
256
+ decision: "ask";
257
+ risk: "low" | "medium" | "high";
258
+ }, {
259
+ reason: string;
260
+ decision: "ask";
261
+ risk: "low" | "medium" | "high";
262
+ }>, z.ZodObject<{
263
+ decision: z.ZodLiteral<"deny">;
264
+ reason: z.ZodString;
265
+ source: z.ZodString;
266
+ }, "strip", z.ZodTypeAny, {
267
+ reason: string;
268
+ decision: "deny";
269
+ source: string;
270
+ }, {
271
+ reason: string;
272
+ decision: "deny";
273
+ source: string;
274
+ }>]>>;
275
+ }, "strip", z.ZodTypeAny, {
276
+ type: "tool_call";
277
+ tool: string;
278
+ id: string;
279
+ sessionId: string;
280
+ timestamp: string;
281
+ inputSummary: string;
282
+ permissionDecision?: {
283
+ reason: string;
284
+ decision: "allow";
285
+ source: string;
286
+ expiresAt?: string | undefined;
287
+ } | {
288
+ reason: string;
289
+ decision: "ask";
290
+ risk: "low" | "medium" | "high";
291
+ } | {
292
+ reason: string;
293
+ decision: "deny";
294
+ source: string;
295
+ } | undefined;
296
+ }, {
297
+ type: "tool_call";
298
+ tool: string;
299
+ id: string;
300
+ sessionId: string;
301
+ timestamp: string;
302
+ inputSummary: string;
303
+ permissionDecision?: {
304
+ reason: string;
305
+ decision: "allow";
306
+ source: string;
307
+ expiresAt?: string | undefined;
308
+ } | {
309
+ reason: string;
310
+ decision: "ask";
311
+ risk: "low" | "medium" | "high";
312
+ } | {
313
+ reason: string;
314
+ decision: "deny";
315
+ source: string;
316
+ } | undefined;
317
+ }>, z.ZodObject<{
318
+ id: z.ZodString;
319
+ sessionId: z.ZodString;
320
+ timestamp: z.ZodString;
321
+ } & {
322
+ type: z.ZodLiteral<"tool_result">;
323
+ toolCallId: z.ZodString;
324
+ status: z.ZodEnum<["success", "error", "cancelled"]>;
325
+ outputSummary: z.ZodString;
326
+ outputRef: z.ZodOptional<z.ZodString>;
327
+ }, "strip", z.ZodTypeAny, {
328
+ type: "tool_result";
329
+ status: "error" | "success" | "cancelled";
330
+ id: string;
331
+ toolCallId: string;
332
+ sessionId: string;
333
+ timestamp: string;
334
+ outputSummary: string;
335
+ outputRef?: string | undefined;
336
+ }, {
337
+ type: "tool_result";
338
+ status: "error" | "success" | "cancelled";
339
+ id: string;
340
+ toolCallId: string;
341
+ sessionId: string;
342
+ timestamp: string;
343
+ outputSummary: string;
344
+ outputRef?: string | undefined;
345
+ }>, z.ZodObject<{
346
+ id: z.ZodString;
347
+ sessionId: z.ZodString;
348
+ timestamp: z.ZodString;
349
+ } & {
350
+ type: z.ZodLiteral<"file_mutation">;
351
+ toolCallId: z.ZodString;
352
+ path: z.ZodString;
353
+ operation: z.ZodEnum<["create", "update", "delete", "move"]>;
354
+ beforeBlob: z.ZodOptional<z.ZodString>;
355
+ afterBlob: z.ZodOptional<z.ZodString>;
356
+ beforeHash: z.ZodOptional<z.ZodString>;
357
+ afterHash: z.ZodOptional<z.ZodString>;
358
+ diffRef: z.ZodOptional<z.ZodString>;
359
+ }, "strip", z.ZodTypeAny, {
360
+ path: string;
361
+ type: "file_mutation";
362
+ id: string;
363
+ toolCallId: string;
364
+ sessionId: string;
365
+ timestamp: string;
366
+ operation: "create" | "update" | "delete" | "move";
367
+ beforeBlob?: string | undefined;
368
+ afterBlob?: string | undefined;
369
+ beforeHash?: string | undefined;
370
+ afterHash?: string | undefined;
371
+ diffRef?: string | undefined;
372
+ }, {
373
+ path: string;
374
+ type: "file_mutation";
375
+ id: string;
376
+ toolCallId: string;
377
+ sessionId: string;
378
+ timestamp: string;
379
+ operation: "create" | "update" | "delete" | "move";
380
+ beforeBlob?: string | undefined;
381
+ afterBlob?: string | undefined;
382
+ beforeHash?: string | undefined;
383
+ afterHash?: string | undefined;
384
+ diffRef?: string | undefined;
385
+ }>]>;
386
+ export type AuditEvent = z.infer<typeof auditEventSchema>;
387
+ //# sourceMappingURL=audit-trace.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { z } from 'zod';
2
+ import { permissionDecisionSchema } from './permission-rules.js';
3
+ export const auditEventBaseSchema = z.object({
4
+ id: z.string().min(1),
5
+ sessionId: z.string().min(1),
6
+ timestamp: z.string().datetime(),
7
+ });
8
+ export const toolCallEventSchema = auditEventBaseSchema.extend({
9
+ type: z.literal('tool_call'),
10
+ tool: z.string().min(1),
11
+ inputSummary: z.string().min(1),
12
+ permissionDecision: permissionDecisionSchema.optional(),
13
+ });
14
+ export const toolResultEventSchema = auditEventBaseSchema.extend({
15
+ type: z.literal('tool_result'),
16
+ toolCallId: z.string().min(1),
17
+ status: z.enum(['success', 'error', 'cancelled']),
18
+ outputSummary: z.string().min(1),
19
+ outputRef: z.string().min(1).optional(),
20
+ });
21
+ export const fileMutationEventSchema = auditEventBaseSchema.extend({
22
+ type: z.literal('file_mutation'),
23
+ toolCallId: z.string().min(1),
24
+ path: z.string().min(1),
25
+ operation: z.enum(['create', 'update', 'delete', 'move']),
26
+ beforeBlob: z.string().min(1).optional(),
27
+ afterBlob: z.string().min(1).optional(),
28
+ beforeHash: z.string().min(1).optional(),
29
+ afterHash: z.string().min(1).optional(),
30
+ diffRef: z.string().min(1).optional(),
31
+ });
32
+ export const sessionEventSchema = auditEventBaseSchema.extend({
33
+ type: z.literal('session'),
34
+ name: z.enum(['created', 'command_started', 'command_completed']),
35
+ command: z.string().min(1).optional(),
36
+ status: z.enum(['success', 'error']).optional(),
37
+ });
38
+ export const auditEventSchema = z.discriminatedUnion('type', [
39
+ sessionEventSchema,
40
+ toolCallEventSchema,
41
+ toolResultEventSchema,
42
+ fileMutationEventSchema,
43
+ ]);
44
+ //# sourceMappingURL=audit-trace.js.map
@@ -0,0 +1,98 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * OAuth 2.0 Device Authorization Grant (RFC 8628) wire contracts.
4
+ *
5
+ * The CLI hits two endpoints:
6
+ * POST /api/auth/device/start
7
+ * POST /api/auth/device/poll
8
+ *
9
+ * The cabinet UI hits two more (JWT-authenticated):
10
+ * POST /api/auth/device/approve
11
+ * POST /api/auth/device/deny
12
+ *
13
+ * Field naming follows RFC 8628 (snake_case) on the wire, not the
14
+ * camelCase server type used by Prisma — Zod schemas below are the
15
+ * canonical wire shape. CLI consumers parse the response with these
16
+ * schemas to defeat a hostile or buggy runtime returning malformed
17
+ * fields.
18
+ */
19
+ export declare const pugiDeviceStartRequestSchema: z.ZodObject<{
20
+ clientId: z.ZodLiteral<"pugi-cli">;
21
+ }, "strip", z.ZodTypeAny, {
22
+ clientId: "pugi-cli";
23
+ }, {
24
+ clientId: "pugi-cli";
25
+ }>;
26
+ export type PugiDeviceStartRequest = z.infer<typeof pugiDeviceStartRequestSchema>;
27
+ export declare const pugiDeviceStartResponseSchema: z.ZodObject<{
28
+ device_code: z.ZodString;
29
+ user_code: z.ZodString;
30
+ verification_uri: z.ZodString;
31
+ verification_uri_complete: z.ZodString;
32
+ expires_in: z.ZodNumber;
33
+ interval: z.ZodNumber;
34
+ }, "strip", z.ZodTypeAny, {
35
+ device_code: string;
36
+ user_code: string;
37
+ verification_uri: string;
38
+ verification_uri_complete: string;
39
+ expires_in: number;
40
+ interval: number;
41
+ }, {
42
+ device_code: string;
43
+ user_code: string;
44
+ verification_uri: string;
45
+ verification_uri_complete: string;
46
+ expires_in: number;
47
+ interval: number;
48
+ }>;
49
+ export type PugiDeviceStartResponse = z.infer<typeof pugiDeviceStartResponseSchema>;
50
+ export declare const pugiDevicePollRequestSchema: z.ZodObject<{
51
+ deviceCode: z.ZodString;
52
+ }, "strip", z.ZodTypeAny, {
53
+ deviceCode: string;
54
+ }, {
55
+ deviceCode: string;
56
+ }>;
57
+ export type PugiDevicePollRequest = z.infer<typeof pugiDevicePollRequestSchema>;
58
+ export declare const pugiDevicePollStatusSchema: z.ZodEnum<["pending", "authorized", "denied", "expired", "redeemed"]>;
59
+ export type PugiDevicePollStatus = z.infer<typeof pugiDevicePollStatusSchema>;
60
+ export declare const pugiDevicePollResponseSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
61
+ status: z.ZodLiteral<"authorized">;
62
+ access_token: z.ZodString;
63
+ token_type: z.ZodLiteral<"Bearer">;
64
+ }, "strip", z.ZodTypeAny, {
65
+ status: "authorized";
66
+ access_token: string;
67
+ token_type: "Bearer";
68
+ }, {
69
+ status: "authorized";
70
+ access_token: string;
71
+ token_type: "Bearer";
72
+ }>, z.ZodObject<{
73
+ status: z.ZodLiteral<"pending">;
74
+ }, "strip", z.ZodTypeAny, {
75
+ status: "pending";
76
+ }, {
77
+ status: "pending";
78
+ }>, z.ZodObject<{
79
+ status: z.ZodLiteral<"denied">;
80
+ }, "strip", z.ZodTypeAny, {
81
+ status: "denied";
82
+ }, {
83
+ status: "denied";
84
+ }>, z.ZodObject<{
85
+ status: z.ZodLiteral<"expired">;
86
+ }, "strip", z.ZodTypeAny, {
87
+ status: "expired";
88
+ }, {
89
+ status: "expired";
90
+ }>, z.ZodObject<{
91
+ status: z.ZodLiteral<"redeemed">;
92
+ }, "strip", z.ZodTypeAny, {
93
+ status: "redeemed";
94
+ }, {
95
+ status: "redeemed";
96
+ }>]>;
97
+ export type PugiDevicePollResponse = z.infer<typeof pugiDevicePollResponseSchema>;
98
+ //# sourceMappingURL=device-flow.d.ts.map
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * OAuth 2.0 Device Authorization Grant (RFC 8628) wire contracts.
4
+ *
5
+ * The CLI hits two endpoints:
6
+ * POST /api/auth/device/start
7
+ * POST /api/auth/device/poll
8
+ *
9
+ * The cabinet UI hits two more (JWT-authenticated):
10
+ * POST /api/auth/device/approve
11
+ * POST /api/auth/device/deny
12
+ *
13
+ * Field naming follows RFC 8628 (snake_case) on the wire, not the
14
+ * camelCase server type used by Prisma — Zod schemas below are the
15
+ * canonical wire shape. CLI consumers parse the response with these
16
+ * schemas to defeat a hostile or buggy runtime returning malformed
17
+ * fields.
18
+ */
19
+ export const pugiDeviceStartRequestSchema = z.object({
20
+ clientId: z.literal('pugi-cli'),
21
+ });
22
+ export const pugiDeviceStartResponseSchema = z.object({
23
+ device_code: z.string().length(64),
24
+ user_code: z.string().min(8).max(16),
25
+ verification_uri: z.string().url(),
26
+ verification_uri_complete: z.string().url(),
27
+ // Cap `expires_in` at 1 hour so a hostile or misconfigured runtime
28
+ // cannot trap the CLI in a year-long poll loop by returning a huge
29
+ // expiration. The server today uses 10 min; this is just the upper
30
+ // bound the SDK trusts.
31
+ expires_in: z.number().int().positive().max(3600),
32
+ interval: z.number().int().min(1).max(60),
33
+ });
34
+ export const pugiDevicePollRequestSchema = z.object({
35
+ deviceCode: z.string().min(32).max(128),
36
+ });
37
+ export const pugiDevicePollStatusSchema = z.enum([
38
+ 'pending',
39
+ 'authorized',
40
+ 'denied',
41
+ 'expired',
42
+ 'redeemed',
43
+ ]);
44
+ export const pugiDevicePollResponseSchema = z.discriminatedUnion('status', [
45
+ z.object({
46
+ status: z.literal('authorized'),
47
+ access_token: z.string().min(1),
48
+ token_type: z.literal('Bearer'),
49
+ }),
50
+ z.object({ status: z.literal('pending') }),
51
+ z.object({ status: z.literal('denied') }),
52
+ z.object({ status: z.literal('expired') }),
53
+ z.object({ status: z.literal('redeemed') }),
54
+ ]);
55
+ //# sourceMappingURL=device-flow.js.map