@duct-sdk/sdk 0.6.0 → 0.7.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.
package/dist/cli/push.js CHANGED
@@ -16,7 +16,9 @@ import { formatSideEffectMismatchLines, findSideEffectReviewMismatches, resolveS
16
16
  import { generateConfigFile } from "./generators/config.js";
17
17
  import { computeManifestPrivilegeDiff, detectDashboardNetworkReverts, fetchLiveManifestConfig, formatManifestPrivilegeDiff, } from "./manifest-diff.js";
18
18
  import { resolveProjectConfig } from "./project-loader.js";
19
- import { CloudError, pushManifest, readAuth, resolveApiKey } from "./cloud.js";
19
+ import { CloudError, checkActionConfusion, checkPolicyReplay, pushManifest, readAuth, resolveApiKey } from "./cloud.js";
20
+ import { formatActionConfusion } from "./action-confusion-format.js";
21
+ import { formatPolicyReplay } from "./policy-replay-format.js";
20
22
  export class PushAbortedError extends Error {
21
23
  details;
22
24
  constructor(message, details = []) {
@@ -211,6 +213,36 @@ export async function runPush(opts) {
211
213
  if (privilegeDiff.hasPrivilegeIncrease && !opts.yes) {
212
214
  throw new PushAbortedError("Push blocked — this push gives agents more power. Review the diff above, then re-run with --yes.");
213
215
  }
216
+ // What this version would have done to the shell's recent real calls (needs a live shell).
217
+ if (apiKey && liveConfig) {
218
+ const replaySpinner = ora("Replaying recent calls against this version…").start();
219
+ const replay = await checkPolicyReplay(authProfile, apiKey, shellId, config).catch(() => null);
220
+ replaySpinner.stop();
221
+ if (replay) {
222
+ const { lines, breaksCalls } = formatPolicyReplay(replay);
223
+ console.log(chalk.bold(" Effect on recent calls:\n"));
224
+ for (const line of lines)
225
+ console.log((breaksCalls ? chalk.red : chalk.gray)(` ${line}`));
226
+ console.log();
227
+ if (breaksCalls && !opts.yes) {
228
+ throw new PushAbortedError("Push blocked — this version would stop calls that work today. Review the list above, then re-run with --yes.");
229
+ }
230
+ }
231
+ else {
232
+ console.log(chalk.gray(" Could not replay recent calls; continuing.\n"));
233
+ }
234
+ }
235
+ // Actions that read alike get routed to each other; say so before they go live (never blocks).
236
+ if (apiKey) {
237
+ const confusion = await checkActionConfusion(authProfile, apiKey, shellId, config).catch(() => null);
238
+ const lines = confusion ? formatActionConfusion(confusion) : [];
239
+ if (lines.length > 0) {
240
+ console.log(chalk.yellow(" Actions that may be confused:\n"));
241
+ for (const line of lines)
242
+ console.log(chalk.yellow(` ${line}`));
243
+ console.log();
244
+ }
245
+ }
214
246
  const networkReverts = detectDashboardNetworkReverts(liveConfig, validated);
215
247
  if (networkReverts.length > 0) {
216
248
  console.log(chalk.yellow("\n ! Network settings you changed in the dashboard would be reverted by this push:\n"));
@@ -17,4 +17,9 @@ export declare class SetupError extends Error {
17
17
  readonly hint?: string | undefined;
18
18
  constructor(message: string, hint?: string | undefined);
19
19
  }
20
+ /**
21
+ * What the product does, in its own words: the API's description (first paragraph, plain text,
22
+ * at most 300 characters), else a neutral line. Never a sentence about Duct.
23
+ */
24
+ export declare function productDescription(apiDescription: string | undefined, productName: string): string;
20
25
  export declare function runSetup(opts: SetupOptions): Promise<boolean>;
package/dist/cli/setup.js CHANGED
@@ -57,6 +57,22 @@ function validUrl(value) {
57
57
  return "Enter a URL like https://api.example.com";
58
58
  }
59
59
  }
60
+ /**
61
+ * What the product does, in its own words: the API's description (first paragraph, plain text,
62
+ * at most 300 characters), else a neutral line. Never a sentence about Duct.
63
+ */
64
+ export function productDescription(apiDescription, productName) {
65
+ const paragraph = (apiDescription ?? "")
66
+ .split(/\n\s*\n/)
67
+ .find((p) => p.trim() && !p.trim().startsWith("#")) ?? "";
68
+ const first = paragraph
69
+ .replace(/[#*_`>]/g, "")
70
+ .replace(/\s+/g, " ")
71
+ .trim();
72
+ if (first.length >= 12)
73
+ return first.length > 300 ? `${first.slice(0, 297).trimEnd()}…` : first;
74
+ return `${productName} product API`;
75
+ }
60
76
  async function readPackageName(root) {
61
77
  try {
62
78
  const pkg = JSON.parse(await fs.readFile(path.join(root, "package.json"), "utf-8"));
@@ -263,7 +279,9 @@ export async function runSetup(opts) {
263
279
  shellId: shell.id,
264
280
  product: {
265
281
  name: productName,
266
- description: `${productName} — connected to Duct`,
282
+ // The API's own description says what the product does; the assistant answers "what can
283
+ // you help me with?" from it. Edit it in duct/project.json to say it better.
284
+ description: productDescription(loaded?.description, productName),
267
285
  baseUrl,
268
286
  ...(apiBase && apiBase !== baseUrl ? { apiBaseUrl: apiBase } : {}),
269
287
  },
@@ -247,6 +247,7 @@ export function compileProject(input) {
247
247
  requireUserConsent: policy.agents.userConsent,
248
248
  ...(Object.keys(actionOverrides).length > 0 ? { actionOverrides } : {}),
249
249
  ...(policy.agents.consentScope ? { consentActionScope: policy.agents.consentScope } : {}),
250
+ ...(policy.agents.consentHours ? { consentGrantHours: policy.agents.consentHours } : {}),
250
251
  ...(policy.agents.validFrom ? { validFrom: policy.agents.validFrom } : {}),
251
252
  ...(policy.agents.validUntil ? { validUntil: policy.agents.validUntil } : {}),
252
253
  ...(project.network?.allowedCallers ? { allowedCallers: project.network.allowedCallers } : {}),
@@ -264,6 +265,7 @@ export function compileProject(input) {
264
265
  ...(shell?.widget ? { widget: shell.widget } : {}),
265
266
  ...(shell?.dataModel ? { dataModel: shell.dataModel } : {}),
266
267
  ...(project.webhooks ? { webhooks: project.webhooks } : {}),
268
+ ...(project.upstreamProtection === false ? { upstreamProtection: false } : {}),
267
269
  ...(project.network?.registry_visibility ? { registry_visibility: project.network.registry_visibility } : {}),
268
270
  ...(project.network?.intershell_enabled !== undefined
269
271
  ? { intershell_enabled: project.network.intershell_enabled }
@@ -361,6 +363,7 @@ export function enforcementDiff(before, after) {
361
363
  const shellChecks = [
362
364
  ["requireUserConsent", pa.requireUserConsent, pb.requireUserConsent],
363
365
  ["consentActionScope", pa.consentActionScope ?? null, pb.consentActionScope ?? null],
366
+ ["consentGrantHours", pa.consentGrantHours ?? null, pb.consentGrantHours ?? null],
364
367
  ["validFrom", pa.validFrom ?? null, pb.validFrom ?? null],
365
368
  ["validUntil", pa.validUntil ?? null, pb.validUntil ?? null],
366
369
  ["allowedCallers", pa.allowedCallers ?? null, pb.allowedCallers ?? null],
@@ -254,6 +254,19 @@ export declare const AgentPermissionsSchema: z.ZodObject<{
254
254
  validFrom: z.ZodOptional<z.ZodString>;
255
255
  validUntil: z.ZodOptional<z.ZodString>;
256
256
  consentActionScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
257
+ consentGrantHours: z.ZodOptional<z.ZodObject<{
258
+ low: z.ZodOptional<z.ZodNumber>;
259
+ medium: z.ZodOptional<z.ZodNumber>;
260
+ high: z.ZodOptional<z.ZodNumber>;
261
+ }, "strict", z.ZodTypeAny, {
262
+ low?: number | undefined;
263
+ medium?: number | undefined;
264
+ high?: number | undefined;
265
+ }, {
266
+ low?: number | undefined;
267
+ medium?: number | undefined;
268
+ high?: number | undefined;
269
+ }>>;
257
270
  }, "strip", z.ZodTypeAny, {
258
271
  defaultLevel: "none" | "read" | "write" | "admin";
259
272
  requireUserConsent: boolean;
@@ -264,6 +277,11 @@ export declare const AgentPermissionsSchema: z.ZodObject<{
264
277
  validFrom?: string | undefined;
265
278
  validUntil?: string | undefined;
266
279
  consentActionScope?: string[] | undefined;
280
+ consentGrantHours?: {
281
+ low?: number | undefined;
282
+ medium?: number | undefined;
283
+ high?: number | undefined;
284
+ } | undefined;
267
285
  }, {
268
286
  defaultLevel: "none" | "read" | "write" | "admin";
269
287
  requireUserConsent: boolean;
@@ -274,6 +292,11 @@ export declare const AgentPermissionsSchema: z.ZodObject<{
274
292
  validFrom?: string | undefined;
275
293
  validUntil?: string | undefined;
276
294
  consentActionScope?: string[] | undefined;
295
+ consentGrantHours?: {
296
+ low?: number | undefined;
297
+ medium?: number | undefined;
298
+ high?: number | undefined;
299
+ } | undefined;
277
300
  }>;
278
301
  export declare const WebhooksConfigSchema: z.ZodObject<{
279
302
  consentCallback: z.ZodOptional<z.ZodString>;
@@ -718,6 +741,11 @@ export declare const DuctConfigSchema: z.ZodObject<{
718
741
  paramMappings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
719
742
  navigatesTo: z.ZodOptional<z.ZodString>;
720
743
  }, "strip", z.ZodTypeAny, {
744
+ method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
745
+ path: string;
746
+ sideEffects: boolean;
747
+ sensitivityLevel: "low" | "none" | "medium" | "high" | "critical";
748
+ id: string;
721
749
  params: {
722
750
  type: "string" | "number" | "boolean" | "object" | "array";
723
751
  name: string;
@@ -725,14 +753,9 @@ export declare const DuctConfigSchema: z.ZodObject<{
725
753
  description?: string | undefined;
726
754
  schema?: Record<string, unknown> | undefined;
727
755
  }[];
728
- path: string;
729
756
  name: string;
730
757
  description: string;
731
- id: string;
732
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
733
758
  agentAccessible: boolean;
734
- sideEffects: boolean;
735
- sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
736
759
  requiresAuth: boolean;
737
760
  sideEffectsReviewAck?: string | undefined;
738
761
  responseSchema?: Record<string, unknown> | undefined;
@@ -764,14 +787,14 @@ export declare const DuctConfigSchema: z.ZodObject<{
764
787
  paramMappings?: Record<string, string> | undefined;
765
788
  navigatesTo?: string | undefined;
766
789
  }, {
790
+ method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
767
791
  path: string;
792
+ sideEffects: boolean;
793
+ sensitivityLevel: "low" | "none" | "medium" | "high" | "critical";
794
+ id: string;
768
795
  name: string;
769
796
  description: string;
770
- id: string;
771
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
772
797
  agentAccessible: boolean;
773
- sideEffects: boolean;
774
- sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
775
798
  requiresAuth: boolean;
776
799
  params?: {
777
800
  type: "string" | "number" | "boolean" | "object" | "array";
@@ -913,6 +936,19 @@ export declare const DuctConfigSchema: z.ZodObject<{
913
936
  validFrom: z.ZodOptional<z.ZodString>;
914
937
  validUntil: z.ZodOptional<z.ZodString>;
915
938
  consentActionScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
939
+ consentGrantHours: z.ZodOptional<z.ZodObject<{
940
+ low: z.ZodOptional<z.ZodNumber>;
941
+ medium: z.ZodOptional<z.ZodNumber>;
942
+ high: z.ZodOptional<z.ZodNumber>;
943
+ }, "strict", z.ZodTypeAny, {
944
+ low?: number | undefined;
945
+ medium?: number | undefined;
946
+ high?: number | undefined;
947
+ }, {
948
+ low?: number | undefined;
949
+ medium?: number | undefined;
950
+ high?: number | undefined;
951
+ }>>;
916
952
  }, "strip", z.ZodTypeAny, {
917
953
  defaultLevel: "none" | "read" | "write" | "admin";
918
954
  requireUserConsent: boolean;
@@ -923,6 +959,11 @@ export declare const DuctConfigSchema: z.ZodObject<{
923
959
  validFrom?: string | undefined;
924
960
  validUntil?: string | undefined;
925
961
  consentActionScope?: string[] | undefined;
962
+ consentGrantHours?: {
963
+ low?: number | undefined;
964
+ medium?: number | undefined;
965
+ high?: number | undefined;
966
+ } | undefined;
926
967
  }, {
927
968
  defaultLevel: "none" | "read" | "write" | "admin";
928
969
  requireUserConsent: boolean;
@@ -933,6 +974,11 @@ export declare const DuctConfigSchema: z.ZodObject<{
933
974
  validFrom?: string | undefined;
934
975
  validUntil?: string | undefined;
935
976
  consentActionScope?: string[] | undefined;
977
+ consentGrantHours?: {
978
+ low?: number | undefined;
979
+ medium?: number | undefined;
980
+ high?: number | undefined;
981
+ } | undefined;
936
982
  }>;
937
983
  widget: z.ZodOptional<z.ZodObject<{
938
984
  primaryColor: z.ZodOptional<z.ZodString>;
@@ -1032,6 +1078,8 @@ export declare const DuctConfigSchema: z.ZodObject<{
1032
1078
  }>>;
1033
1079
  registry_visibility: z.ZodDefault<z.ZodOptional<z.ZodEnum<["public", "private"]>>>;
1034
1080
  intershell_enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1081
+ /** Company API protection; default on. */
1082
+ upstreamProtection: z.ZodOptional<z.ZodBoolean>;
1035
1083
  webhooks: z.ZodOptional<z.ZodObject<{
1036
1084
  consentCallback: z.ZodOptional<z.ZodString>;
1037
1085
  identityUrl: z.ZodOptional<z.ZodString>;
@@ -1141,6 +1189,11 @@ export declare const DuctConfigSchema: z.ZodObject<{
1141
1189
  } | undefined;
1142
1190
  }[];
1143
1191
  actions: {
1192
+ method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
1193
+ path: string;
1194
+ sideEffects: boolean;
1195
+ sensitivityLevel: "low" | "none" | "medium" | "high" | "critical";
1196
+ id: string;
1144
1197
  params: {
1145
1198
  type: "string" | "number" | "boolean" | "object" | "array";
1146
1199
  name: string;
@@ -1148,14 +1201,9 @@ export declare const DuctConfigSchema: z.ZodObject<{
1148
1201
  description?: string | undefined;
1149
1202
  schema?: Record<string, unknown> | undefined;
1150
1203
  }[];
1151
- path: string;
1152
1204
  name: string;
1153
1205
  description: string;
1154
- id: string;
1155
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1156
1206
  agentAccessible: boolean;
1157
- sideEffects: boolean;
1158
- sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
1159
1207
  requiresAuth: boolean;
1160
1208
  sideEffectsReviewAck?: string | undefined;
1161
1209
  responseSchema?: Record<string, unknown> | undefined;
@@ -1222,6 +1270,11 @@ export declare const DuctConfigSchema: z.ZodObject<{
1222
1270
  validFrom?: string | undefined;
1223
1271
  validUntil?: string | undefined;
1224
1272
  consentActionScope?: string[] | undefined;
1273
+ consentGrantHours?: {
1274
+ low?: number | undefined;
1275
+ medium?: number | undefined;
1276
+ high?: number | undefined;
1277
+ } | undefined;
1225
1278
  };
1226
1279
  registry_visibility: "public" | "private";
1227
1280
  intershell_enabled: boolean;
@@ -1253,6 +1306,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
1253
1306
  dimensions?: string[] | undefined;
1254
1307
  }[];
1255
1308
  } | undefined;
1309
+ upstreamProtection?: boolean | undefined;
1256
1310
  webhooks?: {
1257
1311
  consentCallback?: string | undefined;
1258
1312
  identityUrl?: string | undefined;
@@ -1304,6 +1358,11 @@ export declare const DuctConfigSchema: z.ZodObject<{
1304
1358
  validFrom?: string | undefined;
1305
1359
  validUntil?: string | undefined;
1306
1360
  consentActionScope?: string[] | undefined;
1361
+ consentGrantHours?: {
1362
+ low?: number | undefined;
1363
+ medium?: number | undefined;
1364
+ high?: number | undefined;
1365
+ } | undefined;
1307
1366
  };
1308
1367
  routes?: {
1309
1368
  name: string;
@@ -1335,14 +1394,14 @@ export declare const DuctConfigSchema: z.ZodObject<{
1335
1394
  } | undefined;
1336
1395
  }[] | undefined;
1337
1396
  actions?: {
1397
+ method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
1338
1398
  path: string;
1399
+ sideEffects: boolean;
1400
+ sensitivityLevel: "low" | "none" | "medium" | "high" | "critical";
1401
+ id: string;
1339
1402
  name: string;
1340
1403
  description: string;
1341
- id: string;
1342
- method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1343
1404
  agentAccessible: boolean;
1344
- sideEffects: boolean;
1345
- sensitivityLevel: "none" | "low" | "medium" | "high" | "critical";
1346
1405
  requiresAuth: boolean;
1347
1406
  params?: {
1348
1407
  type: "string" | "number" | "boolean" | "object" | "array";
@@ -1436,6 +1495,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
1436
1495
  } | undefined;
1437
1496
  registry_visibility?: "public" | "private" | undefined;
1438
1497
  intershell_enabled?: boolean | undefined;
1498
+ upstreamProtection?: boolean | undefined;
1439
1499
  webhooks?: {
1440
1500
  consentCallback?: string | undefined;
1441
1501
  identityUrl?: string | undefined;
@@ -127,6 +127,14 @@ export const AgentPermissionsSchema = z.object({
127
127
  validFrom: iso8601Schema.optional(),
128
128
  validUntil: iso8601Schema.optional(),
129
129
  consentActionScope: z.array(z.string().min(1)).optional(),
130
+ consentGrantHours: z
131
+ .object({
132
+ low: z.number().positive().max(168).optional(),
133
+ medium: z.number().positive().max(168).optional(),
134
+ high: z.number().positive().max(168).optional(),
135
+ })
136
+ .strict()
137
+ .optional(),
130
138
  });
131
139
  export const WebhooksConfigSchema = z.object({
132
140
  consentCallback: z.string().url().optional(),
@@ -206,6 +214,8 @@ export const DuctConfigSchema = z.object({
206
214
  dataModel: DataModelSchema.optional(),
207
215
  registry_visibility: z.enum(['public', 'private']).optional().default('private'),
208
216
  intershell_enabled: z.boolean().optional().default(false),
217
+ /** Company API protection; default on. */
218
+ upstreamProtection: z.boolean().optional(),
209
219
  webhooks: WebhooksConfigSchema.optional(),
210
220
  approval: ApprovalConfigSchema.optional(),
211
221
  operatorNotifications: OperatorNotificationsConfigSchema.optional(),
@@ -130,6 +130,12 @@ export declare const ProjectFileSchema: z.ZodObject<{
130
130
  registry_visibility?: "public" | "private" | undefined;
131
131
  intershell_enabled?: boolean | undefined;
132
132
  }>>;
133
+ /**
134
+ * Protect calls to your API (default on): timeouts learned from each endpoint's own speed
135
+ * (never below 10 s), one duplicate request for slow read-only GETs, and a short pause when
136
+ * your API keeps failing. Set false to keep one request with a fixed 30 s timeout.
137
+ */
138
+ upstreamProtection: z.ZodOptional<z.ZodBoolean>;
133
139
  }, "strict", z.ZodTypeAny, {
134
140
  shellId: string;
135
141
  product: {
@@ -153,6 +159,7 @@ export declare const ProjectFileSchema: z.ZodObject<{
153
159
  loginDeeplinkId?: string | undefined;
154
160
  loginRoutePath?: string | undefined;
155
161
  } | undefined;
162
+ upstreamProtection?: boolean | undefined;
156
163
  webhooks?: {
157
164
  consentCallback?: string | undefined;
158
165
  identityUrl?: string | undefined;
@@ -189,6 +196,7 @@ export declare const ProjectFileSchema: z.ZodObject<{
189
196
  loginDeeplinkId?: string | undefined;
190
197
  loginRoutePath?: string | undefined;
191
198
  } | undefined;
199
+ upstreamProtection?: boolean | undefined;
192
200
  webhooks?: {
193
201
  consentCallback?: string | undefined;
194
202
  identityUrl?: string | undefined;
@@ -737,6 +745,24 @@ export declare const PolicyAgentsSchema: z.ZodObject<{
737
745
  userConsent: z.ZodDefault<z.ZodBoolean>;
738
746
  /** Limit which actions a user's consent can cover (exact action ids). */
739
747
  consentScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
748
+ /**
749
+ * How many hours a person's approval of an agent lasts, by the most sensitive action it
750
+ * covers. Defaults: low 24, medium 8, high 1 (high includes critical). At most 168.
751
+ * Side-effect actions still need a human approval on every call.
752
+ */
753
+ consentHours: z.ZodOptional<z.ZodObject<{
754
+ low: z.ZodOptional<z.ZodNumber>;
755
+ medium: z.ZodOptional<z.ZodNumber>;
756
+ high: z.ZodOptional<z.ZodNumber>;
757
+ }, "strict", z.ZodTypeAny, {
758
+ low?: number | undefined;
759
+ medium?: number | undefined;
760
+ high?: number | undefined;
761
+ }, {
762
+ low?: number | undefined;
763
+ medium?: number | undefined;
764
+ high?: number | undefined;
765
+ }>>;
740
766
  validFrom: z.ZodOptional<z.ZodString>;
741
767
  validUntil: z.ZodOptional<z.ZodString>;
742
768
  }, "strict", z.ZodTypeAny, {
@@ -748,6 +774,11 @@ export declare const PolicyAgentsSchema: z.ZodObject<{
748
774
  validUntil?: string | undefined;
749
775
  levels?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
750
776
  consentScope?: string[] | undefined;
777
+ consentHours?: {
778
+ low?: number | undefined;
779
+ medium?: number | undefined;
780
+ high?: number | undefined;
781
+ } | undefined;
751
782
  }, {
752
783
  allow?: string[] | undefined;
753
784
  deny?: string[] | undefined;
@@ -757,6 +788,11 @@ export declare const PolicyAgentsSchema: z.ZodObject<{
757
788
  levels?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
758
789
  userConsent?: boolean | undefined;
759
790
  consentScope?: string[] | undefined;
791
+ consentHours?: {
792
+ low?: number | undefined;
793
+ medium?: number | undefined;
794
+ high?: number | undefined;
795
+ } | undefined;
760
796
  }>;
761
797
  export declare const PolicyApproversSchema: z.ZodObject<{
762
798
  /** Who gets notified when an agent request is waiting for approval. */
@@ -807,6 +843,24 @@ export declare const PolicyFileSchema: z.ZodObject<{
807
843
  userConsent: z.ZodDefault<z.ZodBoolean>;
808
844
  /** Limit which actions a user's consent can cover (exact action ids). */
809
845
  consentScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
846
+ /**
847
+ * How many hours a person's approval of an agent lasts, by the most sensitive action it
848
+ * covers. Defaults: low 24, medium 8, high 1 (high includes critical). At most 168.
849
+ * Side-effect actions still need a human approval on every call.
850
+ */
851
+ consentHours: z.ZodOptional<z.ZodObject<{
852
+ low: z.ZodOptional<z.ZodNumber>;
853
+ medium: z.ZodOptional<z.ZodNumber>;
854
+ high: z.ZodOptional<z.ZodNumber>;
855
+ }, "strict", z.ZodTypeAny, {
856
+ low?: number | undefined;
857
+ medium?: number | undefined;
858
+ high?: number | undefined;
859
+ }, {
860
+ low?: number | undefined;
861
+ medium?: number | undefined;
862
+ high?: number | undefined;
863
+ }>>;
810
864
  validFrom: z.ZodOptional<z.ZodString>;
811
865
  validUntil: z.ZodOptional<z.ZodString>;
812
866
  }, "strict", z.ZodTypeAny, {
@@ -818,6 +872,11 @@ export declare const PolicyFileSchema: z.ZodObject<{
818
872
  validUntil?: string | undefined;
819
873
  levels?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
820
874
  consentScope?: string[] | undefined;
875
+ consentHours?: {
876
+ low?: number | undefined;
877
+ medium?: number | undefined;
878
+ high?: number | undefined;
879
+ } | undefined;
821
880
  }, {
822
881
  allow?: string[] | undefined;
823
882
  deny?: string[] | undefined;
@@ -827,6 +886,11 @@ export declare const PolicyFileSchema: z.ZodObject<{
827
886
  levels?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
828
887
  userConsent?: boolean | undefined;
829
888
  consentScope?: string[] | undefined;
889
+ consentHours?: {
890
+ low?: number | undefined;
891
+ medium?: number | undefined;
892
+ high?: number | undefined;
893
+ } | undefined;
830
894
  }>>;
831
895
  /** Require human approval when a call matches the condition. Later entries win. */
832
896
  approveWhen: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<Condition, z.ZodTypeDef, Condition>>>;
@@ -944,6 +1008,11 @@ export declare const PolicyFileSchema: z.ZodObject<{
944
1008
  validUntil?: string | undefined;
945
1009
  levels?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
946
1010
  consentScope?: string[] | undefined;
1011
+ consentHours?: {
1012
+ low?: number | undefined;
1013
+ medium?: number | undefined;
1014
+ high?: number | undefined;
1015
+ } | undefined;
947
1016
  };
948
1017
  approveWhen?: Record<string, Condition> | undefined;
949
1018
  limits?: Record<string, {
@@ -980,6 +1049,11 @@ export declare const PolicyFileSchema: z.ZodObject<{
980
1049
  levels?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
981
1050
  userConsent?: boolean | undefined;
982
1051
  consentScope?: string[] | undefined;
1052
+ consentHours?: {
1053
+ low?: number | undefined;
1054
+ medium?: number | undefined;
1055
+ high?: number | undefined;
1056
+ } | undefined;
983
1057
  } | undefined;
984
1058
  approveWhen?: Record<string, Condition> | undefined;
985
1059
  limits?: Record<string, {
@@ -65,6 +65,12 @@ export const ProjectFileSchema = z
65
65
  webhooks: WebhooksConfigSchema.optional(),
66
66
  /** Cross-shell settings (early access, off by default). */
67
67
  network: ProjectNetworkSchema.optional(),
68
+ /**
69
+ * Protect calls to your API (default on): timeouts learned from each endpoint's own speed
70
+ * (never below 10 s), one duplicate request for slow read-only GETs, and a short pause when
71
+ * your API keeps failing. Set false to keep one request with a fixed 30 s timeout.
72
+ */
73
+ upstreamProtection: z.boolean().optional(),
68
74
  })
69
75
  .strict();
70
76
  // ----------------------------------------------------------------
@@ -191,6 +197,19 @@ export const PolicyAgentsSchema = z
191
197
  userConsent: z.boolean().default(true),
192
198
  /** Limit which actions a user's consent can cover (exact action ids). */
193
199
  consentScope: z.array(z.string().regex(ACTION_ID_RE)).optional(),
200
+ /**
201
+ * How many hours a person's approval of an agent lasts, by the most sensitive action it
202
+ * covers. Defaults: low 24, medium 8, high 1 (high includes critical). At most 168.
203
+ * Side-effect actions still need a human approval on every call.
204
+ */
205
+ consentHours: z
206
+ .object({
207
+ low: z.number().positive().max(168).optional(),
208
+ medium: z.number().positive().max(168).optional(),
209
+ high: z.number().positive().max(168).optional(),
210
+ })
211
+ .strict()
212
+ .optional(),
194
213
  validFrom: iso8601Schema.optional(),
195
214
  validUntil: iso8601Schema.optional(),
196
215
  })
@@ -305,6 +305,15 @@ export interface AgentPermissions {
305
305
  * issuance (auth service) and the Duct gateway on invoke.
306
306
  */
307
307
  consentActionScope?: string[];
308
+ /**
309
+ * Hours a person's approval of an agent lasts, by the most sensitive action it covers
310
+ * (Duct defaults: low 24, medium 8, high 1; at most 168). From policy.agents.consentHours.
311
+ */
312
+ consentGrantHours?: {
313
+ low?: number;
314
+ medium?: number;
315
+ high?: number;
316
+ };
308
317
  }
309
318
  /**
310
319
  * Shell panel size/shape presets.
@@ -522,6 +531,11 @@ export interface DuctConfig {
522
531
  registry_visibility?: 'public' | 'private';
523
532
  /** Master switch: allow other shells to call this one. Default: false */
524
533
  intershell_enabled?: boolean;
534
+ /**
535
+ * Protect calls to your API: learned per-endpoint timeouts (never below 10 s), one duplicate
536
+ * request for slow read-only GETs, and a short pause when your API keeps failing. Default on.
537
+ */
538
+ upstreamProtection?: boolean;
525
539
  /** Identity/consent webhook wiring — required for cross-shell protected actions. */
526
540
  webhooks?: WebhooksConfig;
527
541
  /** Gateway approval policy (step-up thresholds). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duct-sdk/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "description": "Duct SDK — CLI, project files, and embed components for policy-enforced agent access to your product APIs.",
6
6
  "main": "dist/index.js",