@duct-sdk/sdk 0.3.11 → 0.4.0

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 (63) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/adapters/next/receiver.d.ts +2 -6
  3. package/dist/adapters/next/receiver.js +20 -66
  4. package/dist/adapters/remix/receiver.d.ts +2 -6
  5. package/dist/adapters/remix/receiver.js +16 -33
  6. package/dist/adapters/sveltekit/receiver.d.ts +2 -6
  7. package/dist/adapters/sveltekit/receiver.js +13 -40
  8. package/dist/adapters/vite/receiver.d.ts +2 -4
  9. package/dist/adapters/vite/receiver.js +13 -30
  10. package/dist/cli/agents/api-agent.d.ts +3 -1
  11. package/dist/cli/agents/api-agent.js +22 -11
  12. package/dist/cli/agents/auth-agent.js +4 -4
  13. package/dist/cli/agents/pipeline.js +63 -7
  14. package/dist/cli/agents/route-agent.d.ts +3 -1
  15. package/dist/cli/agents/route-agent.js +17 -6
  16. package/dist/cli/detectors/topology.d.ts +1 -1
  17. package/dist/cli/detectors/topology.js +1 -1
  18. package/dist/cli/generators/config.js +71 -44
  19. package/dist/cli/generators/config.test.d.ts +1 -0
  20. package/dist/cli/generators/config.test.js +219 -0
  21. package/dist/cli/generators/normalize.d.ts +10 -0
  22. package/dist/cli/generators/normalize.js +49 -0
  23. package/dist/cli/generators/receiver.d.ts +2 -1
  24. package/dist/cli/generators/receiver.js +20 -201
  25. package/dist/cli/generators/token-route.d.ts +8 -0
  26. package/dist/cli/generators/token-route.js +235 -0
  27. package/dist/cli/generators/token-route.test.d.ts +1 -0
  28. package/dist/cli/generators/token-route.test.js +53 -0
  29. package/dist/cli/generators/wiring-snippets.d.ts +23 -0
  30. package/dist/cli/generators/wiring-snippets.js +233 -0
  31. package/dist/cli/generators/wiring-snippets.test.d.ts +1 -0
  32. package/dist/cli/generators/wiring-snippets.test.js +66 -0
  33. package/dist/cli/index.js +41 -1
  34. package/dist/cli/init.d.ts +1 -7
  35. package/dist/cli/init.js +100 -53
  36. package/dist/cli/output-paths.d.ts +10 -0
  37. package/dist/cli/output-paths.js +60 -0
  38. package/dist/cli/processors/curl-parser.test.d.ts +1 -0
  39. package/dist/cli/processors/curl-parser.test.js +24 -0
  40. package/dist/cli/processors/integration-audit.d.ts +23 -0
  41. package/dist/cli/processors/integration-audit.js +208 -0
  42. package/dist/cli/processors/integration-audit.test.d.ts +1 -0
  43. package/dist/cli/processors/integration-audit.test.js +154 -0
  44. package/dist/cli/processors/prisma-parser.js +1 -1
  45. package/dist/cli/processors/verify-discovery.d.ts +33 -0
  46. package/dist/cli/processors/verify-discovery.js +193 -0
  47. package/dist/cli/processors/verify-discovery.test.d.ts +1 -0
  48. package/dist/cli/processors/verify-discovery.test.js +153 -0
  49. package/dist/cli/processors/zod-extractor.js +1 -1
  50. package/dist/core/config.d.ts +59 -0
  51. package/dist/core/config.js +66 -28
  52. package/dist/core/endpoints.d.ts +2 -0
  53. package/dist/core/endpoints.js +10 -0
  54. package/dist/core/limits.d.ts +1 -1
  55. package/dist/core/limits.js +1 -1
  56. package/dist/core/page-resolve.d.ts +49 -0
  57. package/dist/core/page-resolve.js +87 -0
  58. package/dist/core/receiver.d.ts +33 -0
  59. package/dist/core/receiver.js +77 -0
  60. package/dist/core/types.d.ts +16 -0
  61. package/dist/server.d.ts +4 -0
  62. package/dist/server.js +4 -0
  63. package/package.json +2 -1
@@ -99,6 +99,10 @@ const StateFieldSchema = z.object({
99
99
  description: z.string().optional(),
100
100
  sessionSource: z.string().optional(),
101
101
  });
102
+ const PageResolverSchema = z.union([
103
+ z.object({ actionId: z.string().min(1) }),
104
+ z.object({ endpoint: z.string().min(1).startsWith("/") }),
105
+ ]);
102
106
  const DeeplinkDefinitionSchema = z.object({
103
107
  id: z
104
108
  .string()
@@ -111,6 +115,9 @@ const DeeplinkDefinitionSchema = z.object({
111
115
  expirySeconds: z.number().positive().default(300),
112
116
  requiresAuth: z.boolean(),
113
117
  intent: z.string().optional(),
118
+ pageResolver: PageResolverSchema.optional(),
119
+ allowFetch: z.boolean().optional(),
120
+ contentSelector: z.string().optional(),
114
121
  });
115
122
  const AgentPermissionLevelSchema = z.enum([
116
123
  "none",
@@ -165,6 +172,60 @@ export const DuctConfigSchema = z.object({
165
172
  registry_visibility: z.enum(['public', 'private']).optional().default('private'),
166
173
  intershell_enabled: z.boolean().optional().default(false),
167
174
  });
175
+ function zodIssuesToValidationIssues(errors) {
176
+ return errors.map((e) => ({
177
+ severity: "error",
178
+ area: e.path.length > 0 ? e.path.join(".") : "config",
179
+ issue: e.message,
180
+ fix: e.path.join(".") === "auth.tokenEndpoint"
181
+ ? "Set auth.tokenEndpoint to a full URL (e.g. https://app.example.com/api/duct/token) or omit the field"
182
+ : "Correct the field per the Duct config reference",
183
+ }));
184
+ }
185
+ function crossValidateDuctConfig(data) {
186
+ const issues = [];
187
+ const routePaths = new Set(data.routes.map((r) => r.path));
188
+ for (const deeplink of data.deeplinks) {
189
+ const normalizedTarget = deeplink.targetRoute.replace(/\[([^\]]+)\]/g, ":$1");
190
+ const normalizedRoutes = Array.from(routePaths).map((p) => p.replace(/\[([^\]]+)\]/g, ":$1"));
191
+ if (!normalizedRoutes.some((r) => r === normalizedTarget || routePaths.has(deeplink.targetRoute))) {
192
+ issues.push({
193
+ severity: "error",
194
+ area: "deeplinks",
195
+ issue: `Deeplink "${deeplink.id}" targets route "${deeplink.targetRoute}" which is not defined in routes[]`,
196
+ fix: `Add a matching route to routes[] or update deeplink "${deeplink.id}".targetRoute`,
197
+ });
198
+ }
199
+ }
200
+ const actionIds = new Set(data.actions.map((a) => a.id));
201
+ if (data.agentPermissions.actionOverrides) {
202
+ for (const actionId of Object.keys(data.agentPermissions.actionOverrides)) {
203
+ if (!actionIds.has(actionId)) {
204
+ issues.push({
205
+ severity: "error",
206
+ area: "agentPermissions",
207
+ issue: `actionOverrides references unknown action ID "${actionId}"`,
208
+ fix: `Remove the override or add action "${actionId}" to actions[]`,
209
+ });
210
+ }
211
+ }
212
+ }
213
+ return issues;
214
+ }
215
+ /**
216
+ * Validate a Duct config without throwing — used by `duct init` before writing files.
217
+ */
218
+ export function validateDuctConfigStrict(config) {
219
+ const result = DuctConfigSchema.safeParse(config);
220
+ if (!result.success) {
221
+ return { ok: false, issues: zodIssuesToValidationIssues(result.error.errors) };
222
+ }
223
+ const crossIssues = crossValidateDuctConfig(result.data);
224
+ if (crossIssues.length > 0) {
225
+ return { ok: false, issues: crossIssues };
226
+ }
227
+ return { ok: true, data: result.data };
228
+ }
168
229
  /**
169
230
  * Define and validate a Duct configuration.
170
231
  * This is the primary entrypoint for companies configuring their Duct shell.
@@ -197,35 +258,12 @@ export const DuctConfigSchema = z.object({
197
258
  * ```
198
259
  */
199
260
  export function defineDuctConfig(config) {
200
- const result = DuctConfigSchema.safeParse(config);
201
- if (!result.success) {
202
- const formatted = result.error.errors
203
- .map((e) => ` • [${e.path.join(".")}] ${e.message}`)
261
+ const validation = validateDuctConfigStrict(config);
262
+ if (!validation.ok) {
263
+ const formatted = validation.issues
264
+ .map((i) => ` • [${i.area}] ${i.issue}`)
204
265
  .join("\n");
205
266
  throw new Error(`Invalid Duct configuration:\n${formatted}\n\nSee your Duct docs /config reference for details.`);
206
267
  }
207
- // Cross-validate: deeplink target routes must exist in routes list
208
- const routePaths = new Set(result.data.routes.map((r) => r.path));
209
- const deeplinkErrors = [];
210
- for (const deeplink of result.data.deeplinks) {
211
- // Normalize dynamic segments for comparison
212
- const normalizedTarget = deeplink.targetRoute.replace(/\[([^\]]+)\]/g, ":$1");
213
- const normalizedRoutes = Array.from(routePaths).map((p) => p.replace(/\[([^\]]+)\]/g, ":$1"));
214
- if (!normalizedRoutes.some((r) => r === normalizedTarget || routePaths.has(deeplink.targetRoute))) {
215
- deeplinkErrors.push(`Deeplink "${deeplink.id}" targets route "${deeplink.targetRoute}" which is not defined in routes[]`);
216
- }
217
- }
218
- if (deeplinkErrors.length > 0) {
219
- throw new Error(`Duct configuration validation errors:\n${deeplinkErrors.map((e) => ` • ${e}`).join("\n")}`);
220
- }
221
- // Cross-validate: agent permission actionOverrides must reference valid action IDs
222
- const actionIds = new Set(result.data.actions.map((a) => a.id));
223
- if (result.data.agentPermissions.actionOverrides) {
224
- for (const actionId of Object.keys(result.data.agentPermissions.actionOverrides)) {
225
- if (!actionIds.has(actionId)) {
226
- throw new Error(`agentPermissions.actionOverrides references unknown action ID: "${actionId}"`);
227
- }
228
- }
229
- }
230
- return result.data;
268
+ return validation.data;
231
269
  }
@@ -9,6 +9,8 @@ export declare function getManifestApiBase(profile?: EndpointProfile | null): st
9
9
  export declare function getShellRuntimeUrl(): string;
10
10
  export declare function getRegistryUrl(): string;
11
11
  export declare function getConfiguredDashboard(profile?: EndpointProfile | null): string;
12
+ /** Public docs base URL for generated file headers and CLI hints. */
13
+ export declare function getDocsUrl(): string;
12
14
  export declare function getManifestApiBases(profile?: EndpointProfile | null): string[];
13
15
  export declare function getCandidateApiBases(profile?: EndpointProfile | null): string[];
14
16
  export declare function getCandidateAuthBases(profile?: EndpointProfile | null): string[];
@@ -100,6 +100,16 @@ export function getConfiguredDashboard(profile) {
100
100
  stripTrailingSlash(profile?.dashboardUrl ?? "") ||
101
101
  deriveSubdomain(getDuctBaseUrl(), "dash", 3004));
102
102
  }
103
+ /** Public docs base URL for generated file headers and CLI hints. */
104
+ export function getDocsUrl() {
105
+ const explicit = env("DUCT_DOCS_URL");
106
+ if (explicit)
107
+ return explicit;
108
+ const website = env("DUCT_WEBSITE_URL");
109
+ if (website)
110
+ return `${website}/docs`;
111
+ return "http://localhost:3005/docs";
112
+ }
103
113
  // ── Backward-compat helpers (used internally) ────────────────────
104
114
  export function getManifestApiBases(profile) {
105
115
  const configured = [
@@ -1,5 +1,5 @@
1
1
  /** Default agent loop ceilings used in widget manifest defaults. */
2
- export declare const DEFAULT_MAX_TOOL_ITERATIONS = 12;
2
+ export declare const DEFAULT_MAX_TOOL_ITERATIONS = 4;
3
3
  export declare const DEFAULT_MAX_PLAN_STEPS = 8;
4
4
  export declare const HARD_CEILING_TOOL_ITERATIONS = 25;
5
5
  export declare const HARD_CEILING_PLAN_STEPS = 12;
@@ -1,5 +1,5 @@
1
1
  /** Default agent loop ceilings used in widget manifest defaults. */
2
- export const DEFAULT_MAX_TOOL_ITERATIONS = 12;
2
+ export const DEFAULT_MAX_TOOL_ITERATIONS = 4;
3
3
  export const DEFAULT_MAX_PLAN_STEPS = 8;
4
4
  export const HARD_CEILING_TOOL_ITERATIONS = 25;
5
5
  export const HARD_CEILING_PLAN_STEPS = 12;
@@ -0,0 +1,49 @@
1
+ export interface DuctPageContext {
2
+ /** Human-readable page title */
3
+ title?: string;
4
+ /** Route or screen identifier in the host app */
5
+ route?: string;
6
+ /** Key fields visible on the page (entity snapshots, form values, etc.) */
7
+ fields?: Record<string, unknown>;
8
+ /** Optional structured sections (tables, lists) */
9
+ sections?: Array<{
10
+ id: string;
11
+ label?: string;
12
+ items?: unknown[];
13
+ }>;
14
+ [key: string]: unknown;
15
+ }
16
+ export interface PageResolveResult {
17
+ page_context: DuctPageContext;
18
+ data?: unknown;
19
+ }
20
+ export interface PageResolveContext {
21
+ deeplinkId: string;
22
+ state: Record<string, string>;
23
+ headers: Record<string, string | string[] | undefined>;
24
+ searchParams: Record<string, string>;
25
+ }
26
+ export type PageResolveResolver = (ctx: PageResolveContext) => Promise<PageResolveResult>;
27
+ export interface PageResolveHandlerOptions {
28
+ cacheTtlSeconds?: number;
29
+ noCache?: boolean;
30
+ }
31
+ export declare function createPageResolveHandler(resolver: PageResolveResolver, options?: PageResolveHandlerOptions): (req: Request) => Promise<Response>;
32
+ export declare function createPageResolvePageHandler(resolver: PageResolveResolver, options?: PageResolveHandlerOptions): (req: {
33
+ headers: Record<string, string | string[]>;
34
+ query: Record<string, string | string[]>;
35
+ }, res: {
36
+ status: (code: number) => {
37
+ json: (body: unknown) => void;
38
+ };
39
+ setHeader: (name: string, value: string) => void;
40
+ }) => Promise<void>;
41
+ export declare function createPageResolveExpressHandler(resolver: PageResolveResolver, options?: PageResolveHandlerOptions): (req: {
42
+ headers: Record<string, string | string[] | undefined>;
43
+ query: Record<string, string | string[]>;
44
+ }, res: {
45
+ status: (code: number) => {
46
+ json: (body: unknown) => void;
47
+ };
48
+ setHeader: (name: string, value: string) => void;
49
+ }) => Promise<void>;
@@ -0,0 +1,87 @@
1
+ // ============================================================
2
+ // @duct/sdk — /duct/page-resolve handler factory
3
+ // Companies implement structured page context for agent deeplink
4
+ // resolution (parallel to /duct/introspect).
5
+ //
6
+ // Contract:
7
+ // GET /duct/page-resolve?deeplink_id=...&<state fields>
8
+ // → { page_context: { ... }, data?: unknown }
9
+ // ============================================================
10
+ async function runPageResolveResolver(resolver, ctx, options) {
11
+ const ttl = options.cacheTtlSeconds ?? 60;
12
+ const cacheControl = options.noCache
13
+ ? 'no-store'
14
+ : `private, max-age=${ttl}, stale-while-revalidate=30`;
15
+ try {
16
+ const result = await resolver(ctx);
17
+ return {
18
+ body: result,
19
+ headers: { 'Cache-Control': cacheControl, 'Content-Type': 'application/json' },
20
+ status: 200,
21
+ };
22
+ }
23
+ catch {
24
+ return {
25
+ body: { page_context: {} },
26
+ headers: { 'Cache-Control': 'no-store', 'Content-Type': 'application/json' },
27
+ status: 500,
28
+ };
29
+ }
30
+ }
31
+ function headersToRecord(headers) {
32
+ const out = {};
33
+ headers.forEach((value, key) => { out[key] = value; });
34
+ return out;
35
+ }
36
+ function extractPageResolveContext(req, searchParamsFromUrl) {
37
+ const searchParams = {};
38
+ if (searchParamsFromUrl) {
39
+ searchParamsFromUrl.forEach((v, k) => { searchParams[k] = v; });
40
+ }
41
+ else if (req.query) {
42
+ for (const [k, v] of Object.entries(req.query)) {
43
+ searchParams[k] = Array.isArray(v) ? v[0] ?? '' : v;
44
+ }
45
+ }
46
+ const deeplinkId = searchParams.deeplink_id ?? searchParams.deeplinkId ?? '';
47
+ const state = {};
48
+ for (const [k, v] of Object.entries(searchParams)) {
49
+ if (k === 'deeplink_id' || k === 'deeplinkId')
50
+ continue;
51
+ state[k] = v;
52
+ }
53
+ return {
54
+ deeplinkId,
55
+ state,
56
+ headers: req.headers,
57
+ searchParams,
58
+ };
59
+ }
60
+ export function createPageResolveHandler(resolver, options = {}) {
61
+ return async (req) => {
62
+ const url = new URL(req.url);
63
+ const ctx = extractPageResolveContext({ headers: headersToRecord(req.headers) }, url.searchParams);
64
+ const { body, headers, status } = await runPageResolveResolver(resolver, ctx, options);
65
+ return new Response(JSON.stringify(body), { status, headers });
66
+ };
67
+ }
68
+ export function createPageResolvePageHandler(resolver, options = {}) {
69
+ return async (req, res) => {
70
+ const ctx = extractPageResolveContext({ headers: req.headers, query: req.query });
71
+ const { body, headers, status } = await runPageResolveResolver(resolver, ctx, options);
72
+ for (const [key, value] of Object.entries(headers)) {
73
+ res.setHeader(key, value);
74
+ }
75
+ res.status(status).json(body);
76
+ };
77
+ }
78
+ export function createPageResolveExpressHandler(resolver, options = {}) {
79
+ return async (req, res) => {
80
+ const ctx = extractPageResolveContext({ headers: req.headers, query: req.query });
81
+ const { body, headers, status } = await runPageResolveResolver(resolver, ctx, options);
82
+ for (const [key, value] of Object.entries(headers)) {
83
+ res.setHeader(key, value);
84
+ }
85
+ res.status(status).json(body);
86
+ };
87
+ }
@@ -0,0 +1,33 @@
1
+ import type { DeeplinkTokenPayload, SessionContext } from "./types.js";
2
+ /** Unified onReceive result shape across all framework adapters. */
3
+ export interface DeeplinkReceiverResult {
4
+ /** Override the redirect URL (default: derived from config) */
5
+ redirectUrl?: string;
6
+ /** Additional data to include in JSON responses (Next adapter) */
7
+ data?: Record<string, unknown>;
8
+ /** Additional headers to set on the response */
9
+ headers?: Record<string, string>;
10
+ }
11
+ /**
12
+ * Build a redirect URL from a deeplink target route and token state.
13
+ * Replaces `[param]` segments and appends remaining state as query params.
14
+ */
15
+ export declare function buildDeeplinkRedirectUrl(targetRoute: string, state: Record<string, unknown>, baseUrl: string): string;
16
+ /** Build a minimal session context for a deeplink handoff. */
17
+ export declare function buildDeeplinkSession(sub: string, shellId: string): SessionContext;
18
+ /**
19
+ * Validate required JWT claims after verifyDeeplinkToken succeeds.
20
+ * Returns an error message when a required claim is missing, else null.
21
+ */
22
+ export declare function validateDeeplinkClaims(payload: DeeplinkTokenPayload): string | null;
23
+ /**
24
+ * Fire-and-forget callback to Duct confirming deeplink receipt.
25
+ * No-op when DUCT_API_KEY is unset.
26
+ */
27
+ export declare function confirmDeeplinkReceipt(options: {
28
+ deeplinkId: string;
29
+ shellId: string;
30
+ userId: string;
31
+ redirectUrl: string;
32
+ apiKey?: string;
33
+ }): void;
@@ -0,0 +1,77 @@
1
+ // ============================================================
2
+ // @duct/sdk — Shared deeplink receiver helpers
3
+ // Used by Next, Remix, Vite, and SvelteKit adapters.
4
+ // ============================================================
5
+ import { getActiveApiBase } from "./endpoints.js";
6
+ /**
7
+ * Build a redirect URL from a deeplink target route and token state.
8
+ * Replaces `[param]` segments and appends remaining state as query params.
9
+ */
10
+ export function buildDeeplinkRedirectUrl(targetRoute, state, baseUrl) {
11
+ let path = targetRoute;
12
+ const usedKeys = new Set();
13
+ for (const match of [...targetRoute.matchAll(/\[([^\]]+)\]/g)]) {
14
+ const paramName = match[1];
15
+ const value = state[paramName] ??
16
+ state[`${paramName}Id`] ??
17
+ state[`${paramName}_id`];
18
+ if (value !== undefined) {
19
+ path = path.replace(match[0], String(value));
20
+ usedKeys.add(paramName);
21
+ }
22
+ }
23
+ const queryEntries = Object.entries(state).filter(([key]) => !usedKeys.has(key) && state[key] !== undefined && state[key] !== null);
24
+ if (queryEntries.length > 0) {
25
+ const qs = new URLSearchParams(queryEntries.map(([k, v]) => [k, String(v)])).toString();
26
+ path += `?${qs}`;
27
+ }
28
+ const base = baseUrl.replace(/\/$/, "");
29
+ return `${base}${path}`;
30
+ }
31
+ /** Build a minimal session context for a deeplink handoff. */
32
+ export function buildDeeplinkSession(sub, shellId) {
33
+ return {
34
+ sessionId: `dl_${Date.now()}_${Math.random().toString(36).slice(2)}`,
35
+ shellId,
36
+ user: { id: sub },
37
+ isAgent: false,
38
+ messages: [],
39
+ createdAt: new Date().toISOString(),
40
+ updatedAt: new Date().toISOString(),
41
+ };
42
+ }
43
+ /**
44
+ * Validate required JWT claims after verifyDeeplinkToken succeeds.
45
+ * Returns an error message when a required claim is missing, else null.
46
+ */
47
+ export function validateDeeplinkClaims(payload) {
48
+ if (!payload.iss)
49
+ return "Token missing iss claim";
50
+ if (!payload.sub)
51
+ return "Token missing sub claim";
52
+ return null;
53
+ }
54
+ /**
55
+ * Fire-and-forget callback to Duct confirming deeplink receipt.
56
+ * No-op when DUCT_API_KEY is unset.
57
+ */
58
+ export function confirmDeeplinkReceipt(options) {
59
+ const ductApiKey = options.apiKey ?? process.env["DUCT_API_KEY"];
60
+ if (!ductApiKey)
61
+ return;
62
+ const ductApiBase = getActiveApiBase();
63
+ fetch(`${ductApiBase}/v1/deeplinks/${options.deeplinkId}/confirm`, {
64
+ method: "POST",
65
+ headers: {
66
+ "Content-Type": "application/json",
67
+ Authorization: `Bearer ${ductApiKey}`,
68
+ },
69
+ body: JSON.stringify({
70
+ shellId: options.shellId,
71
+ userId: options.userId,
72
+ redirectUrl: options.redirectUrl,
73
+ }),
74
+ }).catch((err) => {
75
+ console.warn("[Duct] Could not confirm receipt:", err.message);
76
+ });
77
+ }
@@ -158,6 +158,22 @@ export interface DeeplinkDefinition {
158
158
  openInNewTab?: boolean;
159
159
  /** Human-readable intent description (for agent use) */
160
160
  intent?: string;
161
+ /**
162
+ * Agent page resolution — invoke an action or company endpoint to return
163
+ * structured page context instead of a bare handoff URL.
164
+ */
165
+ pageResolver?: {
166
+ actionId: string;
167
+ } | {
168
+ endpoint: string;
169
+ };
170
+ /**
171
+ * When true (and pageResolver absent or insufficient), platform may fetch
172
+ * rendered HTML from the deeplink URL. Off by default — explicit opt-in.
173
+ */
174
+ allowFetch?: boolean;
175
+ /** CSS selector hints for generic HTML extraction when allowFetch is true */
176
+ contentSelector?: string;
161
177
  /** ISO 8601 timestamp of last update (set by duct push) */
162
178
  updatedAt?: string;
163
179
  }
package/dist/server.d.ts CHANGED
@@ -4,12 +4,16 @@ export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeepli
4
4
  export type { GenerateTokenOptions, GenerateTokenResult, VerifyTokenOptions, VerifyTokenResult, GenerateDeeplinkTokenOptions, GenerateDeeplinkTokenResult, VerifyDeeplinkTokenOptions, VerifyDeeplinkResult, } from "./core/token.js";
5
5
  export { createIntrospectHandler, createIntrospectPageHandler, createIntrospectExpressHandler, } from "./core/introspect.js";
6
6
  export type { IntrospectEntity, IntrospectResult, IntrospectContext, IntrospectResolver, IntrospectHandlerOptions, } from "./core/introspect.js";
7
+ export { createPageResolveHandler, createPageResolvePageHandler, createPageResolveExpressHandler, } from "./core/page-resolve.js";
8
+ export type { DuctPageContext, PageResolveResult, PageResolveContext, PageResolveResolver, PageResolveHandlerOptions, } from "./core/page-resolve.js";
7
9
  export { buildAction, checkActionPermission, buildActionSearchIndex, shouldDeferActions, } from "./core/action.js";
8
10
  export type { ActionSearchEntry } from "./core/action.js";
9
11
  export { sendIntershellAction, sendIntershellQuery } from "./core/intershell.js";
10
12
  export type { IntershellClientOptions, IntershellMessage, IntershellActionResult, } from "./core/intershell.js";
11
13
  export { checkShellStatus } from "./core/status.js";
12
14
  export type { ShellStatus, ShellStatusWidget, CheckShellStatusOptions } from "./core/status.js";
15
+ export { buildDeeplinkRedirectUrl, buildDeeplinkSession, validateDeeplinkClaims, confirmDeeplinkReceipt, } from "./core/receiver.js";
16
+ export type { DeeplinkReceiverResult } from "./core/receiver.js";
13
17
  export { SHELL_PRESET_DIMENSIONS, DEFAULT_SHELL_PRESET, SHELL_PANEL_VIEWPORT_INSETS, resolveShellDimensions, fitShellPanelDimensions, } from "./core/types.js";
14
18
  export type { ShellPreset, ShellPanelViewportInsets } from "./core/types.js";
15
19
  export type { DuctConfig, DuctTokenPayload, DeeplinkTokenPayload, ActionManifest, ActionParam, RouteManifest, RouteParam, QueryParam, AuthSchema, AuthStrategy, DeeplinkDefinition, StateField, ShellManifest, ProductConfig, AgentPermissions, AgentPermissionLevel, WidgetConfig, SensitivityLevel, SessionContext, DuctAdapter, ReceiverOptions, } from "./core/types.js";
package/dist/server.js CHANGED
@@ -15,11 +15,15 @@ export { defineDuctConfig, DuctConfigSchema } from "./core/config.js";
15
15
  export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, } from "./core/token.js";
16
16
  // Introspect handler factories
17
17
  export { createIntrospectHandler, createIntrospectPageHandler, createIntrospectExpressHandler, } from "./core/introspect.js";
18
+ // Page-resolve handler factories (agent deeplink resolution)
19
+ export { createPageResolveHandler, createPageResolvePageHandler, createPageResolveExpressHandler, } from "./core/page-resolve.js";
18
20
  // Action utilities (permission checking, search index)
19
21
  export { buildAction, checkActionPermission, buildActionSearchIndex, shouldDeferActions, } from "./core/action.js";
20
22
  // Cross-shell client (IS-29)
21
23
  export { sendIntershellAction, sendIntershellQuery } from "./core/intershell.js";
22
24
  // Shell status check (server-side polling)
23
25
  export { checkShellStatus } from "./core/status.js";
26
+ // Shared deeplink receiver helpers (used by framework adapters)
27
+ export { buildDeeplinkRedirectUrl, buildDeeplinkSession, validateDeeplinkClaims, confirmDeeplinkReceipt, } from "./core/receiver.js";
24
28
  // Shell embed layout (presets + viewport fitting)
25
29
  export { SHELL_PRESET_DIMENSIONS, DEFAULT_SHELL_PRESET, SHELL_PANEL_VIEWPORT_INSETS, resolveShellDimensions, fitShellPanelDimensions, } from "./core/types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duct-sdk/sdk",
3
- "version": "0.3.11",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Duct SDK — A shell (like terminal) that knows when to talk, when to show, and when to hand off.",
6
6
  "main": "dist/index.js",
@@ -20,6 +20,7 @@
20
20
  "scripts": {
21
21
  "build": "tsc",
22
22
  "dev": "tsc --watch",
23
+ "test": "npm run build && node --test dist/cli/generators/config.test.js dist/cli/generators/token-route.test.js dist/cli/generators/wiring-snippets.test.js dist/cli/processors/curl-parser.test.js dist/cli/processors/integration-audit.test.js dist/cli/processors/verify-discovery.test.js",
23
24
  "verify:publish": "node scripts/verify-publish.mjs",
24
25
  "prepublishOnly": "npm run build && npm run verify:publish"
25
26
  },