@duct-sdk/sdk 0.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog — @duct-sdk/sdk
2
2
 
3
+ ## [0.7.1] — 2026-11-24
4
+
5
+ ### Fixed
6
+ - **`duct setup` uses your API's own description** (OpenAPI `info.description`, first paragraph that is not a heading, plain text, at most 300 characters) for `product.description`, instead of "<name> — connected to Duct". The assistant answers "what can you help me with?" from it.
7
+
8
+ ### Added
9
+ - **`upstreamProtection` in `duct/project.json`** (default on): learned per-endpoint timeouts, a duplicate request for slow read-only GETs, and a short pause when your API keeps failing. Set `false` for one request with a fixed 30 s timeout.
10
+
3
11
  ## [0.7.0] — 2026-11-23
4
12
 
5
13
  ### Added
@@ -9,6 +9,8 @@ export interface ApiSource {
9
9
  export interface LoadedApiSource {
10
10
  source: ApiSource;
11
11
  title?: string;
12
+ /** The API's own description (OpenAPI info.description), when it has one. */
13
+ description?: string;
12
14
  actions: CapabilitiesFile["actions"];
13
15
  skipped: number;
14
16
  }
@@ -214,7 +214,7 @@ export async function loadApiSource(root, source) {
214
214
  if (source.kind === "openapi") {
215
215
  const parsed = await parseOpenApiSpec(content, label);
216
216
  const { actions, skipped } = toCapabilities(parsed.actions);
217
- return { source, title: parsed.title, actions, skipped };
217
+ return { source, title: parsed.title, ...(parsed.description ? { description: parsed.description } : {}), actions, skipped };
218
218
  }
219
219
  const parsed = await parseCurlCollection(content, label);
220
220
  const { actions, skipped } = toCapabilities(parsed.actions);
@@ -8,6 +8,8 @@ export interface OpenApiParseResult {
8
8
  operationCount: number;
9
9
  /** Title from spec info block */
10
10
  title?: string;
11
+ /** Description from spec info block */
12
+ description?: string;
11
13
  }
12
14
  /**
13
15
  * Leading slash + OpenAPI `{param}` → `:param`. The Duct gateway interpolates
@@ -257,6 +257,7 @@ export async function parseOpenApiSpec(content, filePath = "openapi.json") {
257
257
  const spec = raw;
258
258
  const specVersion = spec.openapi ?? spec.swagger ?? "unknown";
259
259
  const title = spec.info?.title;
260
+ const description = typeof spec.info?.description === "string" ? spec.info.description.trim() : undefined;
260
261
  const actions = [];
261
262
  const routes = [];
262
263
  const seen = new Set(); // deduplicate by METHOD:path
@@ -354,5 +355,5 @@ export async function parseOpenApiSpec(content, filePath = "openapi.json") {
354
355
  }
355
356
  }
356
357
  }
357
- return { actions, routes, specVersion, operationCount, title };
358
+ return { actions, routes, specVersion, operationCount, title, ...(description ? { description } : {}) };
358
359
  }
@@ -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
  },
@@ -265,6 +265,7 @@ export function compileProject(input) {
265
265
  ...(shell?.widget ? { widget: shell.widget } : {}),
266
266
  ...(shell?.dataModel ? { dataModel: shell.dataModel } : {}),
267
267
  ...(project.webhooks ? { webhooks: project.webhooks } : {}),
268
+ ...(project.upstreamProtection === false ? { upstreamProtection: false } : {}),
268
269
  ...(project.network?.registry_visibility ? { registry_visibility: project.network.registry_visibility } : {}),
269
270
  ...(project.network?.intershell_enabled !== undefined
270
271
  ? { intershell_enabled: project.network.intershell_enabled }
@@ -1078,6 +1078,8 @@ export declare const DuctConfigSchema: z.ZodObject<{
1078
1078
  }>>;
1079
1079
  registry_visibility: z.ZodDefault<z.ZodOptional<z.ZodEnum<["public", "private"]>>>;
1080
1080
  intershell_enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1081
+ /** Company API protection; default on. */
1082
+ upstreamProtection: z.ZodOptional<z.ZodBoolean>;
1081
1083
  webhooks: z.ZodOptional<z.ZodObject<{
1082
1084
  consentCallback: z.ZodOptional<z.ZodString>;
1083
1085
  identityUrl: z.ZodOptional<z.ZodString>;
@@ -1304,6 +1306,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
1304
1306
  dimensions?: string[] | undefined;
1305
1307
  }[];
1306
1308
  } | undefined;
1309
+ upstreamProtection?: boolean | undefined;
1307
1310
  webhooks?: {
1308
1311
  consentCallback?: string | undefined;
1309
1312
  identityUrl?: string | undefined;
@@ -1492,6 +1495,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
1492
1495
  } | undefined;
1493
1496
  registry_visibility?: "public" | "private" | undefined;
1494
1497
  intershell_enabled?: boolean | undefined;
1498
+ upstreamProtection?: boolean | undefined;
1495
1499
  webhooks?: {
1496
1500
  consentCallback?: string | undefined;
1497
1501
  identityUrl?: string | undefined;
@@ -214,6 +214,8 @@ export const DuctConfigSchema = z.object({
214
214
  dataModel: DataModelSchema.optional(),
215
215
  registry_visibility: z.enum(['public', 'private']).optional().default('private'),
216
216
  intershell_enabled: z.boolean().optional().default(false),
217
+ /** Company API protection; default on. */
218
+ upstreamProtection: z.boolean().optional(),
217
219
  webhooks: WebhooksConfigSchema.optional(),
218
220
  approval: ApprovalConfigSchema.optional(),
219
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;
@@ -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
  // ----------------------------------------------------------------
@@ -531,6 +531,11 @@ export interface DuctConfig {
531
531
  registry_visibility?: 'public' | 'private';
532
532
  /** Master switch: allow other shells to call this one. Default: false */
533
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;
534
539
  /** Identity/consent webhook wiring — required for cross-shell protected actions. */
535
540
  webhooks?: WebhooksConfig;
536
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.7.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",