@duct-sdk/sdk 0.4.4 → 0.5.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +36 -1
  3. package/TOKEN_SPEC.md +237 -0
  4. package/dist/adapters/react/page-context-guard.d.ts +7 -0
  5. package/dist/adapters/react/page-context-guard.js +26 -0
  6. package/dist/adapters/react/page-context-guard.test.d.ts +1 -0
  7. package/dist/adapters/react/page-context-guard.test.js +15 -0
  8. package/dist/adapters/react/shell.js +110 -37
  9. package/dist/adapters/react/use-page-context.d.ts +1 -1
  10. package/dist/adapters/react/use-page-context.js +6 -16
  11. package/dist/cli/agents/reviewer-agent.d.ts +3 -1
  12. package/dist/cli/agents/reviewer-agent.js +29 -21
  13. package/dist/cli/config-loader.d.ts +15 -0
  14. package/dist/cli/config-loader.js +187 -0
  15. package/dist/cli/config-loader.test.d.ts +1 -0
  16. package/dist/cli/config-loader.test.js +63 -0
  17. package/dist/cli/detectors/framework.d.ts +1 -1
  18. package/dist/cli/detectors/framework.js +40 -0
  19. package/dist/cli/generators/receiver.js +206 -76
  20. package/dist/cli/generators/shell.js +50 -4
  21. package/dist/cli/generators/shell.test.d.ts +1 -0
  22. package/dist/cli/generators/shell.test.js +73 -0
  23. package/dist/cli/generators/token-route.d.ts +1 -0
  24. package/dist/cli/generators/token-route.js +108 -5
  25. package/dist/cli/generators/wiring-snippets.d.ts +14 -0
  26. package/dist/cli/generators/wiring-snippets.js +180 -16
  27. package/dist/cli/generators/wiring-snippets.test.js +15 -1
  28. package/dist/cli/index.js +108 -151
  29. package/dist/cli/init.js +110 -17
  30. package/dist/cli/manifest-diff.d.ts +21 -0
  31. package/dist/cli/manifest-diff.js +158 -0
  32. package/dist/cli/manifest-diff.test.d.ts +1 -0
  33. package/dist/cli/manifest-diff.test.js +104 -0
  34. package/dist/cli/output-paths.d.ts +2 -0
  35. package/dist/cli/output-paths.js +22 -4
  36. package/dist/cli/processors/integration-audit.js +1 -1
  37. package/dist/core/config-policy.test.d.ts +1 -0
  38. package/dist/core/config-policy.test.js +101 -0
  39. package/dist/core/config.d.ts +86 -1
  40. package/dist/core/config.js +120 -2
  41. package/dist/core/invariants.test.d.ts +1 -0
  42. package/dist/core/invariants.test.js +217 -0
  43. package/dist/core/jcs.d.ts +5 -0
  44. package/dist/core/jcs.js +21 -0
  45. package/dist/core/receipt.d.ts +70 -0
  46. package/dist/core/receipt.js +86 -0
  47. package/dist/core/receipt.test.d.ts +1 -0
  48. package/dist/core/receipt.test.js +75 -0
  49. package/dist/core/replay-store.d.ts +51 -0
  50. package/dist/core/replay-store.js +65 -0
  51. package/dist/core/token.d.ts +14 -0
  52. package/dist/core/token.js +50 -18
  53. package/dist/core/token.test.d.ts +1 -0
  54. package/dist/core/token.test.js +66 -0
  55. package/dist/core/types.d.ts +72 -0
  56. package/dist/index.d.ts +6 -4
  57. package/dist/index.js +4 -2
  58. package/dist/server.d.ts +6 -4
  59. package/dist/server.js +4 -2
  60. package/package.json +91 -90
@@ -0,0 +1,158 @@
1
+ // ============================================================
2
+ // @duct-sdk/sdk — Manifest privilege diff (pure, testable)
3
+ // ============================================================
4
+ import { getManifestApiBases } from "../core/endpoints.js";
5
+ const SENSITIVITY_RANK = {
6
+ none: 0,
7
+ low: 1,
8
+ medium: 2,
9
+ high: 3,
10
+ critical: 4,
11
+ };
12
+ function actionMap(actions) {
13
+ return new Map(actions.map((a) => [a.id, a]));
14
+ }
15
+ function isAllowedCallersWidened(before, after) {
16
+ const beforeList = before ?? [];
17
+ const afterList = after ?? [];
18
+ if (beforeList.length > 0 && afterList.length === 0) {
19
+ return true;
20
+ }
21
+ if (beforeList.length === 0) {
22
+ return false;
23
+ }
24
+ const beforeSet = new Set(beforeList);
25
+ for (const id of afterList) {
26
+ if (!beforeSet.has(id))
27
+ return true;
28
+ }
29
+ return false;
30
+ }
31
+ /**
32
+ * Compare a candidate manifest against the live (or last-pushed) manifest and
33
+ * return privilege-increasing deltas operators must acknowledge before push.
34
+ */
35
+ export function computeManifestPrivilegeDiff(candidate, live) {
36
+ if (!live) {
37
+ return { isFirstPush: true, deltas: [], hasPrivilegeIncrease: false };
38
+ }
39
+ const deltas = [];
40
+ const liveActions = actionMap(live.actions ?? []);
41
+ const candidateActions = actionMap(candidate.actions ?? []);
42
+ for (const [id, after] of candidateActions) {
43
+ const before = liveActions.get(id);
44
+ if (!before) {
45
+ if (after.agentAccessible) {
46
+ deltas.push({
47
+ kind: "new_agent_accessible_action",
48
+ path: `actions.${id}`,
49
+ message: `New action "${id}" is agentAccessible: true`,
50
+ });
51
+ }
52
+ if (after.sideEffects) {
53
+ deltas.push({
54
+ kind: "side_effects_enabled",
55
+ path: `actions.${id}.sideEffects`,
56
+ message: `New action "${id}" has sideEffects: true`,
57
+ });
58
+ }
59
+ continue;
60
+ }
61
+ if (!before.agentAccessible && after.agentAccessible) {
62
+ deltas.push({
63
+ kind: "agent_accessible_enabled",
64
+ path: `actions.${id}.agentAccessible`,
65
+ message: `Action "${id}" is now agentAccessible (was false)`,
66
+ });
67
+ }
68
+ if (!before.sideEffects && after.sideEffects) {
69
+ deltas.push({
70
+ kind: "side_effects_enabled",
71
+ path: `actions.${id}.sideEffects`,
72
+ message: `Action "${id}" now has sideEffects: true`,
73
+ });
74
+ }
75
+ if (SENSITIVITY_RANK[after.sensitivityLevel] < SENSITIVITY_RANK[before.sensitivityLevel]) {
76
+ deltas.push({
77
+ kind: "sensitivity_downgrade",
78
+ path: `actions.${id}.sensitivityLevel`,
79
+ message: `Action "${id}" sensitivity lowered: ${before.sensitivityLevel} → ${after.sensitivityLevel}`,
80
+ });
81
+ }
82
+ }
83
+ const beforeBase = live.product?.baseUrl ?? "";
84
+ const afterBase = candidate.product?.baseUrl ?? "";
85
+ if (beforeBase && afterBase && beforeBase !== afterBase) {
86
+ deltas.push({
87
+ kind: "base_url_change",
88
+ path: "product.baseUrl",
89
+ message: `baseUrl changed: ${beforeBase} → ${afterBase}`,
90
+ });
91
+ }
92
+ const beforeCallers = live.agentPermissions?.allowedCallers;
93
+ const afterCallers = candidate.agentPermissions?.allowedCallers;
94
+ if (isAllowedCallersWidened(beforeCallers, afterCallers)) {
95
+ const beforeLabel = beforeCallers && beforeCallers.length > 0 ? beforeCallers.join(", ") : "(restricted list)";
96
+ const afterLabel = !afterCallers || afterCallers.length === 0
97
+ ? "(open to any public shell)"
98
+ : afterCallers.join(", ");
99
+ deltas.push({
100
+ kind: "allowed_callers_widened",
101
+ path: "agentPermissions.allowedCallers",
102
+ message: `allowedCallers widened: ${beforeLabel} → ${afterLabel}`,
103
+ });
104
+ }
105
+ if (!live.intershell_enabled && candidate.intershell_enabled) {
106
+ deltas.push({
107
+ kind: "intershell_enabled",
108
+ path: "intershell_enabled",
109
+ message: "intershell_enabled toggled false → true",
110
+ });
111
+ }
112
+ if (live.registry_visibility !== "public" && candidate.registry_visibility === "public") {
113
+ deltas.push({
114
+ kind: "registry_public",
115
+ path: "registry_visibility",
116
+ message: "registry_visibility changed to public",
117
+ });
118
+ }
119
+ return {
120
+ isFirstPush: false,
121
+ deltas,
122
+ hasPrivilegeIncrease: deltas.length > 0,
123
+ };
124
+ }
125
+ /** Fetch the live manifest config from Duct cloud (null when shell has no manifest yet). */
126
+ export async function fetchLiveManifestConfig(shellId, apiKey, profile) {
127
+ const bases = getManifestApiBases(profile);
128
+ for (const base of bases) {
129
+ const res = await fetch(`${base}/v1/shells/${shellId}/manifest`, {
130
+ method: "GET",
131
+ headers: { Authorization: `Bearer ${apiKey}` },
132
+ });
133
+ if (res.ok) {
134
+ const data = (await res.json());
135
+ return data.manifest ?? null;
136
+ }
137
+ if (res.status === 404)
138
+ continue;
139
+ break;
140
+ }
141
+ return null;
142
+ }
143
+ export function formatManifestPrivilegeDiff(diff) {
144
+ const lines = [];
145
+ if (diff.isFirstPush) {
146
+ lines.push("First push — no live manifest to diff against.");
147
+ return lines;
148
+ }
149
+ if (diff.deltas.length === 0) {
150
+ lines.push("No privilege-increasing changes detected vs live manifest.");
151
+ return lines;
152
+ }
153
+ lines.push("Privilege-increasing changes vs live manifest:");
154
+ for (const delta of diff.deltas) {
155
+ lines.push(` • [${delta.kind}] ${delta.message}`);
156
+ }
157
+ return lines;
158
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,104 @@
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { computeManifestPrivilegeDiff } from "./manifest-diff.js";
4
+ function baseConfig(overrides = {}) {
5
+ return {
6
+ shellId: "shell_acme_prod",
7
+ product: {
8
+ name: "Acme",
9
+ description: "Test",
10
+ baseUrl: "https://app.acme.com",
11
+ },
12
+ auth: {
13
+ strategy: "session-cookie",
14
+ sessionFields: ["id"],
15
+ guestAllowed: false,
16
+ tokenExpirySeconds: 60,
17
+ },
18
+ routes: [],
19
+ actions: [
20
+ {
21
+ id: "get_order",
22
+ name: "Get Order",
23
+ description: "Fetch order",
24
+ method: "GET",
25
+ path: "/api/orders",
26
+ agentAccessible: false,
27
+ sideEffects: false,
28
+ sensitivityLevel: "high",
29
+ params: [],
30
+ requiresAuth: true,
31
+ },
32
+ ],
33
+ deeplinks: [],
34
+ agentPermissions: {
35
+ defaultLevel: "none",
36
+ requireUserConsent: true,
37
+ allowedCallers: ["shell_partner_a"],
38
+ },
39
+ intershell_enabled: false,
40
+ registry_visibility: "private",
41
+ ...overrides,
42
+ };
43
+ }
44
+ describe("computeManifestPrivilegeDiff", () => {
45
+ it("treats missing live manifest as first push", () => {
46
+ const diff = computeManifestPrivilegeDiff(baseConfig(), null);
47
+ assert.equal(diff.isFirstPush, true);
48
+ assert.equal(diff.hasPrivilegeIncrease, false);
49
+ assert.equal(diff.deltas.length, 0);
50
+ });
51
+ it("detects agentAccessible flip as privilege increase", () => {
52
+ const live = baseConfig();
53
+ const candidate = baseConfig({
54
+ actions: [
55
+ {
56
+ ...live.actions[0],
57
+ agentAccessible: true,
58
+ },
59
+ ],
60
+ });
61
+ const diff = computeManifestPrivilegeDiff(candidate, live);
62
+ assert.equal(diff.hasPrivilegeIncrease, true);
63
+ assert.ok(diff.deltas.some((d) => d.kind === "agent_accessible_enabled"));
64
+ });
65
+ it("detects sensitivity downgrade", () => {
66
+ const live = baseConfig();
67
+ const candidate = baseConfig({
68
+ actions: [
69
+ {
70
+ ...live.actions[0],
71
+ sensitivityLevel: "low",
72
+ },
73
+ ],
74
+ });
75
+ const diff = computeManifestPrivilegeDiff(candidate, live);
76
+ assert.ok(diff.deltas.some((d) => d.kind === "sensitivity_downgrade"));
77
+ });
78
+ it("detects baseUrl change", () => {
79
+ const live = baseConfig();
80
+ const candidate = baseConfig({
81
+ product: { ...live.product, baseUrl: "https://new.acme.com" },
82
+ });
83
+ const diff = computeManifestPrivilegeDiff(candidate, live);
84
+ assert.ok(diff.deltas.some((d) => d.kind === "base_url_change"));
85
+ });
86
+ it("detects allowedCallers widening to open", () => {
87
+ const live = baseConfig({
88
+ agentPermissions: {
89
+ defaultLevel: "none",
90
+ requireUserConsent: true,
91
+ allowedCallers: ["shell_partner_a"],
92
+ },
93
+ });
94
+ const candidate = baseConfig({
95
+ agentPermissions: {
96
+ defaultLevel: "none",
97
+ requireUserConsent: true,
98
+ allowedCallers: [],
99
+ },
100
+ });
101
+ const diff = computeManifestPrivilegeDiff(candidate, live);
102
+ assert.ok(diff.deltas.some((d) => d.kind === "allowed_callers_widened"));
103
+ });
104
+ });
@@ -6,5 +6,7 @@ export interface GeneratedOutputPaths {
6
6
  shellComponentPath: string;
7
7
  envTemplatePath: string;
8
8
  }
9
+ /** Backend-only frameworks have no embeddable widget — init skips the shell component. */
10
+ export declare function frameworkHasShellComponent(framework: FrameworkInfo): boolean;
9
11
  export declare function getGeneratedOutputPaths(cwd: string, framework: FrameworkInfo): GeneratedOutputPaths;
10
12
  export declare function relativeOutputPaths(cwd: string, paths: GeneratedOutputPaths): GeneratedOutputPaths;
@@ -3,10 +3,15 @@
3
3
  // ============================================================
4
4
  import * as path from "path";
5
5
  function getEnvTemplateName(framework) {
6
- if (framework.name === "vite-react" || framework.name === "remix") {
7
- return ".env.example";
6
+ // Next.js conventionally uses .env.local for secrets; every other stack uses .env.
7
+ if (framework.name === "next-app" || framework.name === "next-pages") {
8
+ return ".env.local.example";
8
9
  }
9
- return ".env.local.example";
10
+ return ".env.example";
11
+ }
12
+ /** Backend-only frameworks have no embeddable widget — init skips the shell component. */
13
+ export function frameworkHasShellComponent(framework) {
14
+ return framework.name !== "express" && framework.name !== "fastapi";
10
15
  }
11
16
  export function getGeneratedOutputPaths(cwd, framework) {
12
17
  const isNextApp = framework.hasAppRouter || framework.name === "next-app";
@@ -30,7 +35,16 @@ export function getGeneratedOutputPaths(cwd, framework) {
30
35
  receiverPath = path.join(cwd, "src", "routes", "api", "duct", "receive", "+server.ts");
31
36
  tokenRoutePath = path.join(cwd, "src", "routes", "api", "duct", "token", "+server.ts");
32
37
  }
38
+ else if (framework.name === "nuxt") {
39
+ receiverPath = path.join(cwd, "server", "api", "duct", "receive.post.ts");
40
+ tokenRoutePath = path.join(cwd, "server", "api", "duct", "token.post.ts");
41
+ }
42
+ else if (framework.name === "fastapi") {
43
+ receiverPath = path.join(cwd, "duct_receive.py");
44
+ tokenRoutePath = path.join(cwd, "duct_token.py");
45
+ }
33
46
  else {
47
+ // vite-react, vue3, standalone express — Node/Express backend routes
34
48
  receiverPath = path.join(cwd, "server", "routes", "duct-receive.ts");
35
49
  tokenRoutePath = path.join(cwd, "server", "routes", "duct-token.ts");
36
50
  }
@@ -40,7 +54,11 @@ export function getGeneratedOutputPaths(cwd, framework) {
40
54
  ? path.join(cwd, "app", "components", "DuctShell.tsx")
41
55
  : framework.name === "sveltekit"
42
56
  ? path.join(cwd, "src", "lib", "components", "DuctShell.svelte")
43
- : path.join(cwd, "src", "components", "DuctShell.tsx");
57
+ : framework.name === "nuxt"
58
+ ? path.join(cwd, "components", "DuctShell.vue")
59
+ : framework.name === "vue3"
60
+ ? path.join(cwd, "src", "components", "DuctShell.vue")
61
+ : path.join(cwd, "src", "components", "DuctShell.tsx");
44
62
  return {
45
63
  configPath,
46
64
  receiverPath,
@@ -173,7 +173,7 @@ export async function runIntegrationAudit(sandboxFs, ctx) {
173
173
  severity: "info",
174
174
  area: "agents",
175
175
  issue: "Human shell works with duct_delegated only; partner agents need uct_ or OAuth",
176
- fix: "Re-run init and choose third-party agent support, or see DUCT_CONFIG_PROMPT.md Phase 4b",
176
+ fix: "Re-run init and choose third-party agent support, or see DUCT_CONFIG_PROMPT.md — Third-party agents and user identity",
177
177
  });
178
178
  }
179
179
  return issues;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,101 @@
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { validateDuctConfigStrict } from "./config.js";
4
+ function minimalConfig(overrides = {}) {
5
+ return {
6
+ shellId: "shell_acme_prod",
7
+ product: {
8
+ name: "Acme",
9
+ description: "Test",
10
+ baseUrl: "https://app.acme.com",
11
+ },
12
+ auth: {
13
+ strategy: "session-cookie",
14
+ sessionFields: ["id"],
15
+ guestAllowed: false,
16
+ tokenExpirySeconds: 60,
17
+ },
18
+ routes: [],
19
+ actions: [
20
+ {
21
+ id: "refund_order",
22
+ name: "Refund",
23
+ description: "Refund an order",
24
+ method: "POST",
25
+ path: "/api/refunds",
26
+ agentAccessible: true,
27
+ sideEffects: true,
28
+ sensitivityLevel: "high",
29
+ params: [{ name: "amount", type: "number", required: true }],
30
+ requiresAuth: true,
31
+ validFrom: "2026-07-01T00:00:00.000Z",
32
+ validUntil: "2026-12-31T23:59:59.000Z",
33
+ approveIf: { op: "gt", param: "amount", value: 100 },
34
+ actionLimit: { type: "rate", maxPerWindow: 5, windowSeconds: 86400 },
35
+ },
36
+ ],
37
+ deeplinks: [],
38
+ agentPermissions: {
39
+ defaultLevel: "none",
40
+ requireUserConsent: true,
41
+ consentActionScope: ["refund_order"],
42
+ },
43
+ ...overrides,
44
+ };
45
+ }
46
+ describe("policy schema validation", () => {
47
+ it("accepts time-bound grants, approveIf, actionLimit, and consentActionScope", () => {
48
+ const result = validateDuctConfigStrict(minimalConfig());
49
+ assert.equal(result.ok, true);
50
+ });
51
+ it("rejects wildcard in consentActionScope", () => {
52
+ const result = validateDuctConfigStrict(minimalConfig({
53
+ agentPermissions: {
54
+ defaultLevel: "none",
55
+ requireUserConsent: true,
56
+ consentActionScope: ["*"],
57
+ },
58
+ }));
59
+ assert.equal(result.ok, false);
60
+ if (!result.ok) {
61
+ assert.ok(result.issues.some((i) => i.area.includes("consentActionScope")));
62
+ }
63
+ });
64
+ it("rejects approveIf referencing unknown params", () => {
65
+ const result = validateDuctConfigStrict(minimalConfig({
66
+ actions: [
67
+ {
68
+ ...minimalConfig().actions[0],
69
+ approveIf: { op: "eq", param: "missing_param", value: 1 },
70
+ },
71
+ ],
72
+ }));
73
+ assert.equal(result.ok, false);
74
+ if (!result.ok) {
75
+ assert.ok(result.issues.some((i) => i.issue.includes("unknown param")));
76
+ }
77
+ });
78
+ it("rejects validFrom after validUntil on actions", () => {
79
+ const result = validateDuctConfigStrict(minimalConfig({
80
+ actions: [
81
+ {
82
+ ...minimalConfig().actions[0],
83
+ validFrom: "2026-12-31T23:59:59.000Z",
84
+ validUntil: "2026-07-01T00:00:00.000Z",
85
+ },
86
+ ],
87
+ }));
88
+ assert.equal(result.ok, false);
89
+ });
90
+ it("rejects invalid actionLimit discriminator", () => {
91
+ const parsed = validateDuctConfigStrict(minimalConfig({
92
+ actions: [
93
+ {
94
+ ...minimalConfig().actions[0],
95
+ actionLimit: { type: "count" },
96
+ },
97
+ ],
98
+ }));
99
+ assert.equal(parsed.ok, false);
100
+ });
101
+ });
@@ -172,6 +172,31 @@ export declare const DuctConfigSchema: z.ZodObject<{
172
172
  responseSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
173
173
  requiresAuth: z.ZodBoolean;
174
174
  rateLimit: z.ZodOptional<z.ZodNumber>;
175
+ validFrom: z.ZodOptional<z.ZodString>;
176
+ validUntil: z.ZodOptional<z.ZodString>;
177
+ approveIf: z.ZodOptional<z.ZodType<import("./types.js").ApprovalPredicate, z.ZodTypeDef, import("./types.js").ApprovalPredicate>>;
178
+ actionLimit: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
179
+ type: z.ZodLiteral<"rate">;
180
+ maxPerWindow: z.ZodNumber;
181
+ windowSeconds: z.ZodNumber;
182
+ }, "strip", z.ZodTypeAny, {
183
+ type: "rate";
184
+ maxPerWindow: number;
185
+ windowSeconds: number;
186
+ }, {
187
+ type: "rate";
188
+ maxPerWindow: number;
189
+ windowSeconds: number;
190
+ }>, z.ZodObject<{
191
+ type: z.ZodLiteral<"count">;
192
+ maxCount: z.ZodNumber;
193
+ }, "strip", z.ZodTypeAny, {
194
+ type: "count";
195
+ maxCount: number;
196
+ }, {
197
+ type: "count";
198
+ maxCount: number;
199
+ }>]>>;
175
200
  }, "strip", z.ZodTypeAny, {
176
201
  id: string;
177
202
  name: string;
@@ -191,6 +216,17 @@ export declare const DuctConfigSchema: z.ZodObject<{
191
216
  sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
192
217
  responseSchema?: Record<string, unknown> | undefined;
193
218
  rateLimit?: number | undefined;
219
+ validFrom?: string | undefined;
220
+ validUntil?: string | undefined;
221
+ approveIf?: import("./types.js").ApprovalPredicate | undefined;
222
+ actionLimit?: {
223
+ type: "rate";
224
+ maxPerWindow: number;
225
+ windowSeconds: number;
226
+ } | {
227
+ type: "count";
228
+ maxCount: number;
229
+ } | undefined;
194
230
  }, {
195
231
  id: string;
196
232
  name: string;
@@ -210,6 +246,17 @@ export declare const DuctConfigSchema: z.ZodObject<{
210
246
  }[] | undefined;
211
247
  responseSchema?: Record<string, unknown> | undefined;
212
248
  rateLimit?: number | undefined;
249
+ validFrom?: string | undefined;
250
+ validUntil?: string | undefined;
251
+ approveIf?: import("./types.js").ApprovalPredicate | undefined;
252
+ actionLimit?: {
253
+ type: "rate";
254
+ maxPerWindow: number;
255
+ windowSeconds: number;
256
+ } | {
257
+ type: "count";
258
+ maxCount: number;
259
+ } | undefined;
213
260
  }>, "many">>;
214
261
  deeplinks: z.ZodDefault<z.ZodArray<z.ZodObject<{
215
262
  id: z.ZodString;
@@ -304,18 +351,27 @@ export declare const DuctConfigSchema: z.ZodObject<{
304
351
  allowedCallers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
305
352
  requireUserConsent: z.ZodBoolean;
306
353
  allowedActions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
354
+ validFrom: z.ZodOptional<z.ZodString>;
355
+ validUntil: z.ZodOptional<z.ZodString>;
356
+ consentActionScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
307
357
  }, "strip", z.ZodTypeAny, {
308
358
  defaultLevel: "none" | "read" | "write" | "admin";
309
359
  requireUserConsent: boolean;
360
+ validFrom?: string | undefined;
361
+ validUntil?: string | undefined;
310
362
  actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
311
363
  allowedCallers?: string[] | undefined;
312
364
  allowedActions?: string[] | undefined;
365
+ consentActionScope?: string[] | undefined;
313
366
  }, {
314
367
  defaultLevel: "none" | "read" | "write" | "admin";
315
368
  requireUserConsent: boolean;
369
+ validFrom?: string | undefined;
370
+ validUntil?: string | undefined;
316
371
  actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
317
372
  allowedCallers?: string[] | undefined;
318
373
  allowedActions?: string[] | undefined;
374
+ consentActionScope?: string[] | undefined;
319
375
  }>;
320
376
  widget: z.ZodOptional<z.ZodObject<{
321
377
  primaryColor: z.ZodOptional<z.ZodString>;
@@ -421,6 +477,17 @@ export declare const DuctConfigSchema: z.ZodObject<{
421
477
  sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
422
478
  responseSchema?: Record<string, unknown> | undefined;
423
479
  rateLimit?: number | undefined;
480
+ validFrom?: string | undefined;
481
+ validUntil?: string | undefined;
482
+ approveIf?: import("./types.js").ApprovalPredicate | undefined;
483
+ actionLimit?: {
484
+ type: "rate";
485
+ maxPerWindow: number;
486
+ windowSeconds: number;
487
+ } | {
488
+ type: "count";
489
+ maxCount: number;
490
+ } | undefined;
424
491
  }[];
425
492
  deeplinks: {
426
493
  id: string;
@@ -448,9 +515,12 @@ export declare const DuctConfigSchema: z.ZodObject<{
448
515
  agentPermissions: {
449
516
  defaultLevel: "none" | "read" | "write" | "admin";
450
517
  requireUserConsent: boolean;
518
+ validFrom?: string | undefined;
519
+ validUntil?: string | undefined;
451
520
  actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
452
521
  allowedCallers?: string[] | undefined;
453
522
  allowedActions?: string[] | undefined;
523
+ consentActionScope?: string[] | undefined;
454
524
  };
455
525
  registry_visibility: "public" | "private";
456
526
  intershell_enabled: boolean;
@@ -492,9 +562,12 @@ export declare const DuctConfigSchema: z.ZodObject<{
492
562
  agentPermissions: {
493
563
  defaultLevel: "none" | "read" | "write" | "admin";
494
564
  requireUserConsent: boolean;
565
+ validFrom?: string | undefined;
566
+ validUntil?: string | undefined;
495
567
  actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
496
568
  allowedCallers?: string[] | undefined;
497
569
  allowedActions?: string[] | undefined;
570
+ consentActionScope?: string[] | undefined;
498
571
  };
499
572
  routes?: {
500
573
  name: string;
@@ -537,6 +610,17 @@ export declare const DuctConfigSchema: z.ZodObject<{
537
610
  }[] | undefined;
538
611
  responseSchema?: Record<string, unknown> | undefined;
539
612
  rateLimit?: number | undefined;
613
+ validFrom?: string | undefined;
614
+ validUntil?: string | undefined;
615
+ approveIf?: import("./types.js").ApprovalPredicate | undefined;
616
+ actionLimit?: {
617
+ type: "rate";
618
+ maxPerWindow: number;
619
+ windowSeconds: number;
620
+ } | {
621
+ type: "count";
622
+ maxCount: number;
623
+ } | undefined;
540
624
  }[] | undefined;
541
625
  deeplinks?: {
542
626
  id: string;
@@ -585,6 +669,7 @@ export interface DuctConfigValidationIssue {
585
669
  issue: string;
586
670
  fix: string;
587
671
  }
672
+ export declare function crossValidateDuctConfig(data: ValidatedDuctConfig): DuctConfigValidationIssue[];
588
673
  /**
589
674
  * Validate a Duct config without throwing — used by `duct init` before writing files.
590
675
  */
@@ -601,7 +686,7 @@ export declare function validateDuctConfigStrict(config: DuctConfig): {
601
686
  *
602
687
  * @example
603
688
  * ```ts
604
- * import { defineDuctConfig } from '@duct/sdk';
689
+ * import { defineDuctConfig } from '@duct-sdk/sdk';
605
690
  *
606
691
  * export default defineDuctConfig({
607
692
  * shellId: 'shell_acme_prod',