@duct-sdk/sdk 0.1.6

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.
Files changed (70) hide show
  1. package/README.md +92 -0
  2. package/dist/adapters/next/index.d.ts +4 -0
  3. package/dist/adapters/next/index.js +5 -0
  4. package/dist/adapters/next/receiver.d.ts +44 -0
  5. package/dist/adapters/next/receiver.js +162 -0
  6. package/dist/adapters/next/shell.d.ts +88 -0
  7. package/dist/adapters/next/shell.js +255 -0
  8. package/dist/adapters/react/index.d.ts +2 -0
  9. package/dist/adapters/react/index.js +4 -0
  10. package/dist/adapters/react/shell.d.ts +88 -0
  11. package/dist/adapters/react/shell.js +255 -0
  12. package/dist/adapters/remix/index.d.ts +2 -0
  13. package/dist/adapters/remix/index.js +4 -0
  14. package/dist/adapters/remix/receiver.d.ts +44 -0
  15. package/dist/adapters/remix/receiver.js +153 -0
  16. package/dist/adapters/sveltekit/index.d.ts +2 -0
  17. package/dist/adapters/sveltekit/index.js +4 -0
  18. package/dist/adapters/sveltekit/receiver.d.ts +56 -0
  19. package/dist/adapters/sveltekit/receiver.js +154 -0
  20. package/dist/adapters/vite/index.d.ts +2 -0
  21. package/dist/adapters/vite/index.js +4 -0
  22. package/dist/adapters/vite/receiver.d.ts +82 -0
  23. package/dist/adapters/vite/receiver.js +164 -0
  24. package/dist/assets/logo.d.ts +1 -0
  25. package/dist/assets/logo.js +1 -0
  26. package/dist/cli/agents/api-agent.d.ts +14 -0
  27. package/dist/cli/agents/api-agent.js +656 -0
  28. package/dist/cli/agents/auth-agent.d.ts +6 -0
  29. package/dist/cli/agents/auth-agent.js +198 -0
  30. package/dist/cli/agents/deeplink-agent.d.ts +6 -0
  31. package/dist/cli/agents/deeplink-agent.js +263 -0
  32. package/dist/cli/agents/llm.d.ts +33 -0
  33. package/dist/cli/agents/llm.js +276 -0
  34. package/dist/cli/agents/pipeline.d.ts +51 -0
  35. package/dist/cli/agents/pipeline.js +236 -0
  36. package/dist/cli/agents/reviewer-agent.d.ts +11 -0
  37. package/dist/cli/agents/reviewer-agent.js +442 -0
  38. package/dist/cli/agents/route-agent.d.ts +13 -0
  39. package/dist/cli/agents/route-agent.js +346 -0
  40. package/dist/cli/detectors/auth.d.ts +18 -0
  41. package/dist/cli/detectors/auth.js +273 -0
  42. package/dist/cli/detectors/framework.d.ts +22 -0
  43. package/dist/cli/detectors/framework.js +242 -0
  44. package/dist/cli/drift.d.ts +39 -0
  45. package/dist/cli/drift.js +247 -0
  46. package/dist/cli/fs/sandbox.d.ts +77 -0
  47. package/dist/cli/fs/sandbox.js +295 -0
  48. package/dist/cli/generators/config.d.ts +7 -0
  49. package/dist/cli/generators/config.js +255 -0
  50. package/dist/cli/generators/receiver.d.ts +12 -0
  51. package/dist/cli/generators/receiver.js +683 -0
  52. package/dist/cli/generators/shell.d.ts +18 -0
  53. package/dist/cli/generators/shell.js +672 -0
  54. package/dist/cli/index.d.ts +2 -0
  55. package/dist/cli/index.js +603 -0
  56. package/dist/cli/init.d.ts +26 -0
  57. package/dist/cli/init.js +835 -0
  58. package/dist/core/action.d.ts +37 -0
  59. package/dist/core/action.js +140 -0
  60. package/dist/core/config.d.ts +514 -0
  61. package/dist/core/config.js +221 -0
  62. package/dist/core/endpoints.d.ts +17 -0
  63. package/dist/core/endpoints.js +128 -0
  64. package/dist/core/token.d.ts +70 -0
  65. package/dist/core/token.js +174 -0
  66. package/dist/core/types.d.ts +450 -0
  67. package/dist/core/types.js +11 -0
  68. package/dist/index.d.ts +7 -0
  69. package/dist/index.js +9 -0
  70. package/package.json +84 -0
@@ -0,0 +1,37 @@
1
+ import type { ActionManifest, BuiltActionDef, ActionPermissionContext, ActionPermissionResult } from "./types.js";
2
+ /**
3
+ * Walk permission rules in source-priority order:
4
+ * policy > manifest > session > default
5
+ *
6
+ * Returns the first decisive (allow/deny/ask) result.
7
+ */
8
+ export declare function checkActionPermission(action: ActionManifest, ctx: ActionPermissionContext): ActionPermissionResult;
9
+ /**
10
+ * Wraps a raw ActionManifest with runtime callbacks.
11
+ * Produces an ActionDef with fail-closed defaults for all guards.
12
+ *
13
+ * Usage:
14
+ * const def = buildAction(manifest.actions.find(a => a.id === 'create_order'));
15
+ * const perm = await def.checkPermissions({}, ctx);
16
+ * const val = def.validateInput(params);
17
+ */
18
+ export declare function buildAction(action: ActionManifest): BuiltActionDef;
19
+ export interface ActionSearchEntry {
20
+ id: string;
21
+ searchHint: string;
22
+ sideEffects: boolean;
23
+ sensitivityLevel: ActionManifest["sensitivityLevel"];
24
+ agentAccessible: boolean;
25
+ alwaysInclude: boolean;
26
+ }
27
+ /**
28
+ * Build a lightweight search index from a manifest's actions.
29
+ * When action count > 20, the router receives only this index for non-pinned actions.
30
+ * A second pass fetches full schemas for the top-N matched actions.
31
+ */
32
+ export declare function buildActionSearchIndex(actions: ActionManifest[]): ActionSearchEntry[];
33
+ /**
34
+ * Returns true when a manifest should use deferred action loading.
35
+ * Threshold: > 20 agent-accessible actions.
36
+ */
37
+ export declare function shouldDeferActions(actions: ActionManifest[]): boolean;
@@ -0,0 +1,140 @@
1
+ // ============================================================
2
+ // @duct/sdk — buildAction() factory
3
+ // Mirrors the buildTool() pattern from the miniclaude reference.
4
+ // Fail-closed defaults: denies agents when !agentAccessible,
5
+ // denies side-effects without user_consent_token, upgrades
6
+ // high/critical sensitivity to 'ask'.
7
+ // See duct-technical-spec.md §13.1
8
+ // ============================================================
9
+ // ----------------------------------------------------------------
10
+ // checkActionPermission — three-tier rule model
11
+ // ----------------------------------------------------------------
12
+ /**
13
+ * Walk permission rules in source-priority order:
14
+ * policy > manifest > session > default
15
+ *
16
+ * Returns the first decisive (allow/deny/ask) result.
17
+ */
18
+ export function checkActionPermission(action, ctx) {
19
+ // --- Policy tier (hard overrides, checked first) ---
20
+ // Side-effect actions without consent are always denied for agents
21
+ if (ctx.isAgent && action.sideEffects && !ctx.hasUserConsentToken) {
22
+ return deny("policy", "Side-effect actions require a user_consent_token for agent callers");
23
+ }
24
+ // Agents cannot call actions not marked agentAccessible
25
+ if (ctx.isAgent && !action.agentAccessible) {
26
+ return deny("policy", `Action '${action.id}' is not agent-accessible`);
27
+ }
28
+ // High/critical sensitivity → ask (unless agent cannot show UI)
29
+ if ((action.sensitivityLevel === "high" || action.sensitivityLevel === "critical") &&
30
+ !ctx.hasUserConsentToken) {
31
+ if (ctx.avoidInteractivePrompts) {
32
+ return deny("policy", `Action '${action.id}' has ${action.sensitivityLevel} sensitivity and requires user consent`);
33
+ }
34
+ return ask("policy", `Action '${action.id}' has ${action.sensitivityLevel} sensitivity — confirm with user`);
35
+ }
36
+ // --- Manifest tier ---
37
+ // Require auth: must have consent token
38
+ if (action.requiresAuth && !ctx.hasUserConsentToken) {
39
+ if (ctx.isAgent) {
40
+ return deny("manifest", `Action '${action.id}' requires auth — provide user_consent_token`);
41
+ }
42
+ return ask("manifest", `Action '${action.id}' requires authentication`);
43
+ }
44
+ // --- Default tier --- allow everything else
45
+ return allow("default", "Passes all permission checks");
46
+ }
47
+ // ----------------------------------------------------------------
48
+ // buildAction() factory
49
+ // ----------------------------------------------------------------
50
+ /**
51
+ * Wraps a raw ActionManifest with runtime callbacks.
52
+ * Produces an ActionDef with fail-closed defaults for all guards.
53
+ *
54
+ * Usage:
55
+ * const def = buildAction(manifest.actions.find(a => a.id === 'create_order'));
56
+ * const perm = await def.checkPermissions({}, ctx);
57
+ * const val = def.validateInput(params);
58
+ */
59
+ export function buildAction(action) {
60
+ const searchHint = action.searchHint ?? `${action.method} ${action.path}`;
61
+ const interruptBehavior = action.interruptBehavior ?? (action.sideEffects ? "block" : "cancel");
62
+ const validateInput = (params) => {
63
+ if (!action.inputSchema)
64
+ return { valid: true };
65
+ const schema = action.inputSchema;
66
+ const required = (schema.required ?? []);
67
+ const properties = (schema.properties ?? {});
68
+ for (const field of required) {
69
+ if (params[field] === undefined || params[field] === null) {
70
+ return {
71
+ valid: false,
72
+ message: `Missing required field: '${field}'`,
73
+ code: 4001,
74
+ };
75
+ }
76
+ }
77
+ for (const [field, fieldSchema] of Object.entries(properties)) {
78
+ const value = params[field];
79
+ if (value === undefined)
80
+ continue;
81
+ const expectedType = fieldSchema.type;
82
+ if (expectedType) {
83
+ const actualType = Array.isArray(value) ? "array" : typeof value;
84
+ if (actualType !== expectedType && !(expectedType === "integer" && Number.isInteger(value))) {
85
+ return {
86
+ valid: false,
87
+ message: `Field '${field}': expected ${expectedType}, got ${actualType}`,
88
+ code: 4002,
89
+ };
90
+ }
91
+ }
92
+ }
93
+ return { valid: true };
94
+ };
95
+ const checkPermissions = async (_params, ctx) => {
96
+ return checkActionPermission(action, ctx);
97
+ };
98
+ return {
99
+ ...action,
100
+ searchHint,
101
+ alwaysInclude: action.alwaysInclude ?? false,
102
+ interruptBehavior,
103
+ validateInput,
104
+ checkPermissions,
105
+ };
106
+ }
107
+ /**
108
+ * Build a lightweight search index from a manifest's actions.
109
+ * When action count > 20, the router receives only this index for non-pinned actions.
110
+ * A second pass fetches full schemas for the top-N matched actions.
111
+ */
112
+ export function buildActionSearchIndex(actions) {
113
+ return actions.map((a) => ({
114
+ id: a.id,
115
+ searchHint: a.searchHint ?? `${a.method} ${a.path}: ${a.description}`,
116
+ sideEffects: a.sideEffects,
117
+ sensitivityLevel: a.sensitivityLevel,
118
+ agentAccessible: a.agentAccessible,
119
+ alwaysInclude: a.alwaysInclude ?? false,
120
+ }));
121
+ }
122
+ /**
123
+ * Returns true when a manifest should use deferred action loading.
124
+ * Threshold: > 20 agent-accessible actions.
125
+ */
126
+ export function shouldDeferActions(actions) {
127
+ return actions.filter((a) => a.agentAccessible).length > 20;
128
+ }
129
+ // ----------------------------------------------------------------
130
+ // Helpers
131
+ // ----------------------------------------------------------------
132
+ function allow(source, reason) {
133
+ return { decision: "allow", reason, source };
134
+ }
135
+ function deny(source, reason) {
136
+ return { decision: "deny", reason, source };
137
+ }
138
+ function ask(source, reason) {
139
+ return { decision: "ask", reason, source };
140
+ }
@@ -0,0 +1,514 @@
1
+ import { z } from "zod";
2
+ import type { DuctConfig } from "./types.js";
3
+ export declare const DuctConfigSchema: z.ZodObject<{
4
+ shellId: z.ZodString;
5
+ product: z.ZodObject<{
6
+ name: z.ZodString;
7
+ description: z.ZodString;
8
+ baseUrl: z.ZodString;
9
+ locale: z.ZodOptional<z.ZodString>;
10
+ industry: z.ZodOptional<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ name: string;
13
+ description: string;
14
+ baseUrl: string;
15
+ locale?: string | undefined;
16
+ industry?: string | undefined;
17
+ }, {
18
+ name: string;
19
+ description: string;
20
+ baseUrl: string;
21
+ locale?: string | undefined;
22
+ industry?: string | undefined;
23
+ }>;
24
+ auth: z.ZodObject<{
25
+ strategy: z.ZodEnum<["nextauth", "clerk", "auth0", "custom-jwt", "session-cookie", "none", "unknown"]>;
26
+ sessionFields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
27
+ guestAllowed: z.ZodBoolean;
28
+ tokenExpirySeconds: z.ZodDefault<z.ZodNumber>;
29
+ tokenEndpoint: z.ZodOptional<z.ZodString>;
30
+ customClaims: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ strategy: "none" | "nextauth" | "clerk" | "auth0" | "custom-jwt" | "session-cookie" | "unknown";
33
+ sessionFields: string[];
34
+ guestAllowed: boolean;
35
+ tokenExpirySeconds: number;
36
+ tokenEndpoint?: string | undefined;
37
+ customClaims?: Record<string, string> | undefined;
38
+ }, {
39
+ strategy: "none" | "nextauth" | "clerk" | "auth0" | "custom-jwt" | "session-cookie" | "unknown";
40
+ guestAllowed: boolean;
41
+ sessionFields?: string[] | undefined;
42
+ tokenExpirySeconds?: number | undefined;
43
+ tokenEndpoint?: string | undefined;
44
+ customClaims?: Record<string, string> | undefined;
45
+ }>;
46
+ routes: z.ZodDefault<z.ZodArray<z.ZodObject<{
47
+ path: z.ZodString;
48
+ name: z.ZodString;
49
+ description: z.ZodString;
50
+ params: z.ZodDefault<z.ZodArray<z.ZodObject<{
51
+ name: z.ZodString;
52
+ type: z.ZodEnum<["string", "number", "uuid", "slug"]>;
53
+ required: z.ZodBoolean;
54
+ description: z.ZodOptional<z.ZodString>;
55
+ }, "strip", z.ZodTypeAny, {
56
+ name: string;
57
+ type: "string" | "number" | "uuid" | "slug";
58
+ required: boolean;
59
+ description?: string | undefined;
60
+ }, {
61
+ name: string;
62
+ type: "string" | "number" | "uuid" | "slug";
63
+ required: boolean;
64
+ description?: string | undefined;
65
+ }>, "many">>;
66
+ queryParams: z.ZodDefault<z.ZodArray<z.ZodObject<{
67
+ name: z.ZodString;
68
+ type: z.ZodEnum<["string", "number", "boolean", "string[]"]>;
69
+ required: z.ZodBoolean;
70
+ description: z.ZodOptional<z.ZodString>;
71
+ defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ name: string;
74
+ type: "string" | "number" | "boolean" | "string[]";
75
+ required: boolean;
76
+ description?: string | undefined;
77
+ defaultValue?: string | number | boolean | undefined;
78
+ }, {
79
+ name: string;
80
+ type: "string" | "number" | "boolean" | "string[]";
81
+ required: boolean;
82
+ description?: string | undefined;
83
+ defaultValue?: string | number | boolean | undefined;
84
+ }>, "many">>;
85
+ uiStateHint: z.ZodEnum<["form", "list", "detail", "dashboard", "modal", "wizard", "empty", "error", "auth", "checkout", "profile", "settings", "search"]>;
86
+ requiresAuth: z.ZodBoolean;
87
+ deeplinkable: z.ZodBoolean;
88
+ methods: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ name: string;
91
+ params: {
92
+ name: string;
93
+ type: "string" | "number" | "uuid" | "slug";
94
+ required: boolean;
95
+ description?: string | undefined;
96
+ }[];
97
+ path: string;
98
+ description: string;
99
+ queryParams: {
100
+ name: string;
101
+ type: "string" | "number" | "boolean" | "string[]";
102
+ required: boolean;
103
+ description?: string | undefined;
104
+ defaultValue?: string | number | boolean | undefined;
105
+ }[];
106
+ uiStateHint: "form" | "list" | "detail" | "dashboard" | "modal" | "wizard" | "empty" | "error" | "auth" | "checkout" | "profile" | "settings" | "search";
107
+ requiresAuth: boolean;
108
+ deeplinkable: boolean;
109
+ methods?: string[] | undefined;
110
+ }, {
111
+ name: string;
112
+ path: string;
113
+ description: string;
114
+ uiStateHint: "form" | "list" | "detail" | "dashboard" | "modal" | "wizard" | "empty" | "error" | "auth" | "checkout" | "profile" | "settings" | "search";
115
+ requiresAuth: boolean;
116
+ deeplinkable: boolean;
117
+ params?: {
118
+ name: string;
119
+ type: "string" | "number" | "uuid" | "slug";
120
+ required: boolean;
121
+ description?: string | undefined;
122
+ }[] | undefined;
123
+ queryParams?: {
124
+ name: string;
125
+ type: "string" | "number" | "boolean" | "string[]";
126
+ required: boolean;
127
+ description?: string | undefined;
128
+ defaultValue?: string | number | boolean | undefined;
129
+ }[] | undefined;
130
+ methods?: string[] | undefined;
131
+ }>, "many">>;
132
+ actions: z.ZodDefault<z.ZodArray<z.ZodObject<{
133
+ id: z.ZodString;
134
+ name: z.ZodString;
135
+ description: z.ZodString;
136
+ method: z.ZodEnum<["GET", "POST", "PUT", "PATCH", "DELETE"]>;
137
+ path: z.ZodString;
138
+ agentAccessible: z.ZodBoolean;
139
+ sideEffects: z.ZodBoolean;
140
+ sensitivityLevel: z.ZodEnum<["none", "low", "medium", "high", "critical"]>;
141
+ params: z.ZodDefault<z.ZodArray<z.ZodObject<{
142
+ name: z.ZodString;
143
+ type: z.ZodEnum<["string", "number", "boolean", "object", "array"]>;
144
+ required: z.ZodBoolean;
145
+ description: z.ZodOptional<z.ZodString>;
146
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
147
+ }, "strip", z.ZodTypeAny, {
148
+ name: string;
149
+ type: "string" | "number" | "boolean" | "object" | "array";
150
+ required: boolean;
151
+ description?: string | undefined;
152
+ schema?: Record<string, unknown> | undefined;
153
+ }, {
154
+ name: string;
155
+ type: "string" | "number" | "boolean" | "object" | "array";
156
+ required: boolean;
157
+ description?: string | undefined;
158
+ schema?: Record<string, unknown> | undefined;
159
+ }>, "many">>;
160
+ responseSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
161
+ requiresAuth: z.ZodBoolean;
162
+ rateLimit: z.ZodOptional<z.ZodNumber>;
163
+ }, "strip", z.ZodTypeAny, {
164
+ id: string;
165
+ name: string;
166
+ params: {
167
+ name: string;
168
+ type: "string" | "number" | "boolean" | "object" | "array";
169
+ required: boolean;
170
+ description?: string | undefined;
171
+ schema?: Record<string, unknown> | undefined;
172
+ }[];
173
+ path: string;
174
+ description: string;
175
+ requiresAuth: boolean;
176
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
177
+ agentAccessible: boolean;
178
+ sideEffects: boolean;
179
+ sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
180
+ responseSchema?: Record<string, unknown> | undefined;
181
+ rateLimit?: number | undefined;
182
+ }, {
183
+ id: string;
184
+ name: string;
185
+ path: string;
186
+ description: string;
187
+ requiresAuth: boolean;
188
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
189
+ agentAccessible: boolean;
190
+ sideEffects: boolean;
191
+ sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
192
+ params?: {
193
+ name: string;
194
+ type: "string" | "number" | "boolean" | "object" | "array";
195
+ required: boolean;
196
+ description?: string | undefined;
197
+ schema?: Record<string, unknown> | undefined;
198
+ }[] | undefined;
199
+ responseSchema?: Record<string, unknown> | undefined;
200
+ rateLimit?: number | undefined;
201
+ }>, "many">>;
202
+ deeplinks: z.ZodDefault<z.ZodArray<z.ZodObject<{
203
+ id: z.ZodString;
204
+ name: z.ZodString;
205
+ description: z.ZodString;
206
+ targetRoute: z.ZodString;
207
+ stateFields: z.ZodDefault<z.ZodArray<z.ZodObject<{
208
+ key: z.ZodString;
209
+ type: z.ZodEnum<["string", "number", "boolean", "object"]>;
210
+ required: z.ZodBoolean;
211
+ description: z.ZodOptional<z.ZodString>;
212
+ sessionSource: z.ZodOptional<z.ZodString>;
213
+ }, "strip", z.ZodTypeAny, {
214
+ type: "string" | "number" | "boolean" | "object";
215
+ required: boolean;
216
+ key: string;
217
+ description?: string | undefined;
218
+ sessionSource?: string | undefined;
219
+ }, {
220
+ type: "string" | "number" | "boolean" | "object";
221
+ required: boolean;
222
+ key: string;
223
+ description?: string | undefined;
224
+ sessionSource?: string | undefined;
225
+ }>, "many">>;
226
+ expirySeconds: z.ZodDefault<z.ZodNumber>;
227
+ requiresAuth: z.ZodBoolean;
228
+ intent: z.ZodOptional<z.ZodString>;
229
+ }, "strip", z.ZodTypeAny, {
230
+ id: string;
231
+ name: string;
232
+ description: string;
233
+ requiresAuth: boolean;
234
+ targetRoute: string;
235
+ stateFields: {
236
+ type: "string" | "number" | "boolean" | "object";
237
+ required: boolean;
238
+ key: string;
239
+ description?: string | undefined;
240
+ sessionSource?: string | undefined;
241
+ }[];
242
+ expirySeconds: number;
243
+ intent?: string | undefined;
244
+ }, {
245
+ id: string;
246
+ name: string;
247
+ description: string;
248
+ requiresAuth: boolean;
249
+ targetRoute: string;
250
+ stateFields?: {
251
+ type: "string" | "number" | "boolean" | "object";
252
+ required: boolean;
253
+ key: string;
254
+ description?: string | undefined;
255
+ sessionSource?: string | undefined;
256
+ }[] | undefined;
257
+ expirySeconds?: number | undefined;
258
+ intent?: string | undefined;
259
+ }>, "many">>;
260
+ agentPermissions: z.ZodObject<{
261
+ defaultLevel: z.ZodEnum<["none", "read", "write", "admin"]>;
262
+ actionOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<["none", "read", "write", "admin"]>>>;
263
+ allowedAgents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
264
+ requireUserConsent: z.ZodBoolean;
265
+ allowedActions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
266
+ }, "strip", z.ZodTypeAny, {
267
+ defaultLevel: "none" | "read" | "write" | "admin";
268
+ requireUserConsent: boolean;
269
+ actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
270
+ allowedAgents?: string[] | undefined;
271
+ allowedActions?: string[] | undefined;
272
+ }, {
273
+ defaultLevel: "none" | "read" | "write" | "admin";
274
+ requireUserConsent: boolean;
275
+ actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
276
+ allowedAgents?: string[] | undefined;
277
+ allowedActions?: string[] | undefined;
278
+ }>;
279
+ widget: z.ZodOptional<z.ZodObject<{
280
+ primaryColor: z.ZodOptional<z.ZodString>;
281
+ position: z.ZodOptional<z.ZodEnum<["bottom-right", "bottom-left", "top-right", "top-left"]>>;
282
+ defaultOpen: z.ZodOptional<z.ZodBoolean>;
283
+ launcherText: z.ZodOptional<z.ZodString>;
284
+ welcomeMessage: z.ZodOptional<z.ZodString>;
285
+ hideLauncher: z.ZodOptional<z.ZodBoolean>;
286
+ }, "strip", z.ZodTypeAny, {
287
+ primaryColor?: string | undefined;
288
+ position?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined;
289
+ defaultOpen?: boolean | undefined;
290
+ launcherText?: string | undefined;
291
+ welcomeMessage?: string | undefined;
292
+ hideLauncher?: boolean | undefined;
293
+ }, {
294
+ primaryColor?: string | undefined;
295
+ position?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined;
296
+ defaultOpen?: boolean | undefined;
297
+ launcherText?: string | undefined;
298
+ welcomeMessage?: string | undefined;
299
+ hideLauncher?: boolean | undefined;
300
+ }>>;
301
+ }, "strip", z.ZodTypeAny, {
302
+ auth: {
303
+ strategy: "none" | "nextauth" | "clerk" | "auth0" | "custom-jwt" | "session-cookie" | "unknown";
304
+ sessionFields: string[];
305
+ guestAllowed: boolean;
306
+ tokenExpirySeconds: number;
307
+ tokenEndpoint?: string | undefined;
308
+ customClaims?: Record<string, string> | undefined;
309
+ };
310
+ shellId: string;
311
+ product: {
312
+ name: string;
313
+ description: string;
314
+ baseUrl: string;
315
+ locale?: string | undefined;
316
+ industry?: string | undefined;
317
+ };
318
+ routes: {
319
+ name: string;
320
+ params: {
321
+ name: string;
322
+ type: "string" | "number" | "uuid" | "slug";
323
+ required: boolean;
324
+ description?: string | undefined;
325
+ }[];
326
+ path: string;
327
+ description: string;
328
+ queryParams: {
329
+ name: string;
330
+ type: "string" | "number" | "boolean" | "string[]";
331
+ required: boolean;
332
+ description?: string | undefined;
333
+ defaultValue?: string | number | boolean | undefined;
334
+ }[];
335
+ uiStateHint: "form" | "list" | "detail" | "dashboard" | "modal" | "wizard" | "empty" | "error" | "auth" | "checkout" | "profile" | "settings" | "search";
336
+ requiresAuth: boolean;
337
+ deeplinkable: boolean;
338
+ methods?: string[] | undefined;
339
+ }[];
340
+ actions: {
341
+ id: string;
342
+ name: string;
343
+ params: {
344
+ name: string;
345
+ type: "string" | "number" | "boolean" | "object" | "array";
346
+ required: boolean;
347
+ description?: string | undefined;
348
+ schema?: Record<string, unknown> | undefined;
349
+ }[];
350
+ path: string;
351
+ description: string;
352
+ requiresAuth: boolean;
353
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
354
+ agentAccessible: boolean;
355
+ sideEffects: boolean;
356
+ sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
357
+ responseSchema?: Record<string, unknown> | undefined;
358
+ rateLimit?: number | undefined;
359
+ }[];
360
+ deeplinks: {
361
+ id: string;
362
+ name: string;
363
+ description: string;
364
+ requiresAuth: boolean;
365
+ targetRoute: string;
366
+ stateFields: {
367
+ type: "string" | "number" | "boolean" | "object";
368
+ required: boolean;
369
+ key: string;
370
+ description?: string | undefined;
371
+ sessionSource?: string | undefined;
372
+ }[];
373
+ expirySeconds: number;
374
+ intent?: string | undefined;
375
+ }[];
376
+ agentPermissions: {
377
+ defaultLevel: "none" | "read" | "write" | "admin";
378
+ requireUserConsent: boolean;
379
+ actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
380
+ allowedAgents?: string[] | undefined;
381
+ allowedActions?: string[] | undefined;
382
+ };
383
+ widget?: {
384
+ primaryColor?: string | undefined;
385
+ position?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined;
386
+ defaultOpen?: boolean | undefined;
387
+ launcherText?: string | undefined;
388
+ welcomeMessage?: string | undefined;
389
+ hideLauncher?: boolean | undefined;
390
+ } | undefined;
391
+ }, {
392
+ auth: {
393
+ strategy: "none" | "nextauth" | "clerk" | "auth0" | "custom-jwt" | "session-cookie" | "unknown";
394
+ guestAllowed: boolean;
395
+ sessionFields?: string[] | undefined;
396
+ tokenExpirySeconds?: number | undefined;
397
+ tokenEndpoint?: string | undefined;
398
+ customClaims?: Record<string, string> | undefined;
399
+ };
400
+ shellId: string;
401
+ product: {
402
+ name: string;
403
+ description: string;
404
+ baseUrl: string;
405
+ locale?: string | undefined;
406
+ industry?: string | undefined;
407
+ };
408
+ agentPermissions: {
409
+ defaultLevel: "none" | "read" | "write" | "admin";
410
+ requireUserConsent: boolean;
411
+ actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
412
+ allowedAgents?: string[] | undefined;
413
+ allowedActions?: string[] | undefined;
414
+ };
415
+ routes?: {
416
+ name: string;
417
+ path: string;
418
+ description: string;
419
+ uiStateHint: "form" | "list" | "detail" | "dashboard" | "modal" | "wizard" | "empty" | "error" | "auth" | "checkout" | "profile" | "settings" | "search";
420
+ requiresAuth: boolean;
421
+ deeplinkable: boolean;
422
+ params?: {
423
+ name: string;
424
+ type: "string" | "number" | "uuid" | "slug";
425
+ required: boolean;
426
+ description?: string | undefined;
427
+ }[] | undefined;
428
+ queryParams?: {
429
+ name: string;
430
+ type: "string" | "number" | "boolean" | "string[]";
431
+ required: boolean;
432
+ description?: string | undefined;
433
+ defaultValue?: string | number | boolean | undefined;
434
+ }[] | undefined;
435
+ methods?: string[] | undefined;
436
+ }[] | undefined;
437
+ actions?: {
438
+ id: string;
439
+ name: string;
440
+ path: string;
441
+ description: string;
442
+ requiresAuth: boolean;
443
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
444
+ agentAccessible: boolean;
445
+ sideEffects: boolean;
446
+ sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
447
+ params?: {
448
+ name: string;
449
+ type: "string" | "number" | "boolean" | "object" | "array";
450
+ required: boolean;
451
+ description?: string | undefined;
452
+ schema?: Record<string, unknown> | undefined;
453
+ }[] | undefined;
454
+ responseSchema?: Record<string, unknown> | undefined;
455
+ rateLimit?: number | undefined;
456
+ }[] | undefined;
457
+ deeplinks?: {
458
+ id: string;
459
+ name: string;
460
+ description: string;
461
+ requiresAuth: boolean;
462
+ targetRoute: string;
463
+ stateFields?: {
464
+ type: "string" | "number" | "boolean" | "object";
465
+ required: boolean;
466
+ key: string;
467
+ description?: string | undefined;
468
+ sessionSource?: string | undefined;
469
+ }[] | undefined;
470
+ expirySeconds?: number | undefined;
471
+ intent?: string | undefined;
472
+ }[] | undefined;
473
+ widget?: {
474
+ primaryColor?: string | undefined;
475
+ position?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined;
476
+ defaultOpen?: boolean | undefined;
477
+ launcherText?: string | undefined;
478
+ welcomeMessage?: string | undefined;
479
+ hideLauncher?: boolean | undefined;
480
+ } | undefined;
481
+ }>;
482
+ export type ValidatedDuctConfig = z.infer<typeof DuctConfigSchema>;
483
+ /**
484
+ * Define and validate a Duct configuration.
485
+ * This is the primary entrypoint for companies configuring their Duct shell.
486
+ *
487
+ * @example
488
+ * ```ts
489
+ * import { defineDuctConfig } from '@duct/sdk';
490
+ *
491
+ * export default defineDuctConfig({
492
+ * shellId: 'shell_acme_prod',
493
+ * product: {
494
+ * name: 'Acme Corp',
495
+ * description: 'B2B SaaS for widget management',
496
+ * baseUrl: 'https://app.acme.com',
497
+ * },
498
+ * auth: {
499
+ * strategy: 'nextauth',
500
+ * sessionFields: ['id', 'email', 'orgId'],
501
+ * guestAllowed: false,
502
+ * tokenExpirySeconds: 300,
503
+ * },
504
+ * routes: [...],
505
+ * actions: [...],
506
+ * deeplinks: [...],
507
+ * agentPermissions: {
508
+ * defaultLevel: 'none',
509
+ * requireUserConsent: true,
510
+ * },
511
+ * });
512
+ * ```
513
+ */
514
+ export declare function defineDuctConfig(config: DuctConfig): ValidatedDuctConfig;