@duct-sdk/sdk 0.5.9 → 0.5.10

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,18 @@
1
1
  # Changelog — @duct-sdk/sdk
2
2
 
3
+ ## [0.5.10] — 2026-07-19
4
+
5
+ ### Added
6
+ - **`duct verify-evidence`** — offline verification for `duct:audit-evidence:v1` bundles (receipt signatures, chain integrity, signed checkpoints); exported from `@duct-sdk/sdk` and `@duct-sdk/sdk/server`.
7
+ - **Intershell manifest validation** — `agentPermissions.allowedCallees` schema; `crossValidateDuctConfig` requires `webhooks.identityUrl` when `intershell_enabled` and protected actions coexist.
8
+
9
+ ### Improved
10
+ - **Readiness product URL probe** — `duct checkup` and shared readiness helpers now HTTP-probe `product.baseUrl` (with a Docker `host.docker.internal` fallback for loopback URLs) and optionally check the platform status page URL.
11
+
12
+ ### Changed
13
+ - **Shell panel defaults** — default `panelHeight` 640→680; preset heights +40px (`tall` 700, `square` 540, `large` 760) so trust footer does not shrink the chat area.
14
+ - **Launcher icon** — default closed-widget candidates prefer shell-origin Duct assets; removed host-relative `/duct-text-no-bg.png` first candidate that could show a host site's own file.
15
+
3
16
  ## [0.5.9] — 2026-07-18
4
17
 
5
18
  ### Added
@@ -89,7 +89,7 @@ export interface DuctShellProps {
89
89
  panelWidth?: number;
90
90
  /**
91
91
  * Panel height in pixels. Ignored when `preset` is set.
92
- * @default 640
92
+ * @default 680
93
93
  */
94
94
  panelHeight?: number;
95
95
  /** Override container styles (wrapper div). */
@@ -97,7 +97,7 @@ export interface DuctShellProps {
97
97
  className?: string;
98
98
  /**
99
99
  * Optional launcher icon source.
100
- * When omitted, the SDK tries the host app's /duct-text-no-bg.png, then the shell host URL, then /assets/logo.png.
100
+ * When omitted, the SDK tries the shell host `/duct-text-no-bg.png`, then `/assets/logo.png`.
101
101
  */
102
102
  launcherIconSrc?: string;
103
103
  /**
@@ -269,7 +269,7 @@ function cancelRafUpdate(rafRef, pendingRef, commit) {
269
269
  * />
270
270
  * ```
271
271
  */
272
- export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, onPageContext, open, onOpenChange, defaultOpen = false, shellHost = DUCT_SHELL_HOST_DEFAULT, position = "bottom-right", preset, theme = "system", draggable = true, panelWidth = 420, panelHeight = 640, style, className, launcherIconSrc, readyCheck = false, }) {
272
+ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, onPageContext, open, onOpenChange, defaultOpen = false, shellHost = DUCT_SHELL_HOST_DEFAULT, position = "bottom-right", preset, theme = "system", draggable = true, panelWidth = 420, panelHeight = 680, style, className, launcherIconSrc, readyCheck = false, }) {
273
273
  const iframeRef = useRef(null);
274
274
  const panelRef = useRef(null);
275
275
  const [isReady, setIsReady] = useState(false);
@@ -334,7 +334,6 @@ export function DuctShell({ shellId, userContext, onTokenRequest, onNavigate, on
334
334
  const iconCandidates = launcherIconSrc
335
335
  ? [launcherIconSrc]
336
336
  : [
337
- "/duct-text-no-bg.png",
338
337
  `${shellOrigin}/duct-text-no-bg.png`,
339
338
  DUCT_LAUNCHER_ICON_LOCAL_FALLBACK,
340
339
  ];
@@ -60,6 +60,9 @@ function sampleConfig(overrides = {}) {
60
60
  },
61
61
  intershell_enabled: true,
62
62
  registry_visibility: "public",
63
+ webhooks: {
64
+ identityUrl: "https://app.acme.com/duct/identity",
65
+ },
63
66
  ...overrides,
64
67
  };
65
68
  }
package/dist/cli/index.js CHANGED
@@ -1381,6 +1381,43 @@ migrateCmd
1381
1381
  }
1382
1382
  });
1383
1383
  // ----------------------------------------------------------------
1384
+ // duct verify-evidence — offline evidence bundle verification
1385
+ // ----------------------------------------------------------------
1386
+ program
1387
+ .command("verify-evidence")
1388
+ .description("Verify a duct:audit-evidence:v1 bundle offline")
1389
+ .requiredOption("--bundle <path>", "Path to evidence bundle JSON file")
1390
+ .option("--hmac-secret <secret>", "HMAC secret for legacy gate receipts")
1391
+ .action(async (opts) => {
1392
+ const { verifyEvidenceBundle } = await import("../core/evidence-bundle.js");
1393
+ const raw = await fs.readFile(path.resolve(opts.bundle), "utf-8");
1394
+ const bundle = JSON.parse(raw);
1395
+ const result = verifyEvidenceBundle(bundle, {
1396
+ hmacSecret: opts.hmacSecret ?? process.env.RECEIPT_SIGNING_KEY,
1397
+ });
1398
+ if (process.stdout.isTTY) {
1399
+ console.log(chalk.bold(result.valid ? "✓ Bundle verified" : "✗ Bundle failed verification"));
1400
+ console.log(chalk.dim(` Schema: ${result.schema}`));
1401
+ console.log(chalk.dim(` Completeness: ${result.completeness}`));
1402
+ console.log(chalk.dim(` Receipts verified: ${result.verified_receipts}`));
1403
+ if (result.warnings.length) {
1404
+ console.log(chalk.yellow("\nWarnings:"));
1405
+ for (const w of result.warnings)
1406
+ console.log(chalk.yellow(` • ${w}`));
1407
+ }
1408
+ if (result.failed_receipts.length) {
1409
+ console.log(chalk.red("\nFailed receipts:"));
1410
+ for (const f of result.failed_receipts) {
1411
+ console.log(chalk.red(` • ${f.receipt_id ?? "?"}: ${f.reason}`));
1412
+ }
1413
+ }
1414
+ }
1415
+ else {
1416
+ console.log(JSON.stringify(result, null, 2));
1417
+ }
1418
+ process.exit(result.valid ? 0 : 1);
1419
+ });
1420
+ // ----------------------------------------------------------------
1384
1421
  // Error handling
1385
1422
  // ----------------------------------------------------------------
1386
1423
  program.exitOverride();
@@ -40,6 +40,15 @@ function requiresPrompt(action) {
40
40
  const lowConfidence = (action.confidence ?? 0) < 0.85;
41
41
  return isSideEffect || lowConfidence;
42
42
  }
43
+ /**
44
+ * True when at least one agent-accessible action requires auth or has side effects —
45
+ * i.e. this shell needs `webhooks.identityUrl` configured before intershell callers
46
+ * can ever authorize it (see `crossValidateDuctConfig` in core/config.ts for the
47
+ * authoritative, enforced version of this check against the final assembled config).
48
+ */
49
+ function hasProtectedAgentAccessibleAction(actions) {
50
+ return actions.some((a) => a.agentAccessible && (a.requiresAuth || a.sideEffects));
51
+ }
43
52
  // ----------------------------------------------------------------
44
53
  // Single-action prompt (readline-based, not inquirer)
45
54
  // ----------------------------------------------------------------
@@ -276,6 +285,11 @@ export async function runInteractiveReview(pipelineResult, opts = {}) {
276
285
  }
277
286
  }
278
287
  }
288
+ if (hasProtectedAgentAccessibleAction(approvedActions)) {
289
+ console.log(chalk.yellow("\n [DUCT] intershell_enabled shells with protected actions must configure webhooks.identityUrl\n" +
290
+ " Set webhooks.identityUrl (Dashboard → Shell → Settings → Webhooks) or cross-shell\n" +
291
+ " callers will never be able to authorize these actions.\n"));
292
+ }
279
293
  }
280
294
  rl.close();
281
295
  const agentAccessibleCount = approvedActions.filter((a) => a.agentAccessible).length;
@@ -129,4 +129,52 @@ describe("config field round-trip", () => {
129
129
  assert.equal(result.data.actions[0].sensitivityLevel, "none");
130
130
  }
131
131
  });
132
+ it("preserves allowedCallees and webhooks (intershell egress + identity config)", () => {
133
+ const config = minimalConfig({
134
+ intershell_enabled: true,
135
+ registry_visibility: "public",
136
+ agentPermissions: {
137
+ defaultLevel: "none",
138
+ requireUserConsent: true,
139
+ allowedCallees: ["shell_partner_prod", "*"],
140
+ },
141
+ webhooks: {
142
+ consentCallback: "https://app.acme.com/duct/consent-callback",
143
+ identityUrl: "https://app.acme.com/duct/identity",
144
+ secret: "whsec_test123",
145
+ },
146
+ });
147
+ const result = validateDuctConfigStrict(config);
148
+ assert.equal(result.ok, true);
149
+ if (!result.ok)
150
+ return;
151
+ assert.deepEqual(result.data.agentPermissions.allowedCallees, [
152
+ "shell_partner_prod",
153
+ "*",
154
+ ]);
155
+ assert.equal(result.data.webhooks?.identityUrl, "https://app.acme.com/duct/identity");
156
+ assert.equal(result.data.webhooks?.secret, "whsec_test123");
157
+ });
158
+ it("rejects a malformed allowedCallees entry", () => {
159
+ const config = minimalConfig({
160
+ agentPermissions: {
161
+ defaultLevel: "none",
162
+ requireUserConsent: true,
163
+ allowedCallees: ["not-a-valid-shell-id"],
164
+ },
165
+ });
166
+ const result = validateDuctConfigStrict(config);
167
+ assert.equal(result.ok, false);
168
+ });
169
+ it("flags intershell_enabled shells with a protected action but no webhooks.identityUrl", () => {
170
+ const config = minimalConfig({
171
+ intershell_enabled: true,
172
+ registry_visibility: "public",
173
+ });
174
+ const result = validateDuctConfigStrict(config);
175
+ assert.equal(result.ok, false);
176
+ if (result.ok)
177
+ return;
178
+ assert.ok(result.issues.some((issue) => issue.issue.includes("webhooks.identityUrl")));
179
+ });
132
180
  });
@@ -441,6 +441,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
441
441
  defaultLevel: z.ZodEnum<["none", "read", "write", "admin"]>;
442
442
  actionOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<["none", "read", "write", "admin"]>>>;
443
443
  allowedCallers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
444
+ allowedCallees: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
444
445
  requireUserConsent: z.ZodBoolean;
445
446
  allowedActions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
446
447
  validFrom: z.ZodOptional<z.ZodString>;
@@ -451,6 +452,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
451
452
  requireUserConsent: boolean;
452
453
  actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
453
454
  allowedCallers?: string[] | undefined;
455
+ allowedCallees?: string[] | undefined;
454
456
  allowedActions?: string[] | undefined;
455
457
  validFrom?: string | undefined;
456
458
  validUntil?: string | undefined;
@@ -460,6 +462,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
460
462
  requireUserConsent: boolean;
461
463
  actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
462
464
  allowedCallers?: string[] | undefined;
465
+ allowedCallees?: string[] | undefined;
463
466
  allowedActions?: string[] | undefined;
464
467
  validFrom?: string | undefined;
465
468
  validUntil?: string | undefined;
@@ -563,6 +566,19 @@ export declare const DuctConfigSchema: z.ZodObject<{
563
566
  }>>;
564
567
  registry_visibility: z.ZodDefault<z.ZodOptional<z.ZodEnum<["public", "private"]>>>;
565
568
  intershell_enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
569
+ webhooks: z.ZodOptional<z.ZodObject<{
570
+ consentCallback: z.ZodOptional<z.ZodString>;
571
+ identityUrl: z.ZodOptional<z.ZodString>;
572
+ secret: z.ZodOptional<z.ZodString>;
573
+ }, "strip", z.ZodTypeAny, {
574
+ consentCallback?: string | undefined;
575
+ identityUrl?: string | undefined;
576
+ secret?: string | undefined;
577
+ }, {
578
+ consentCallback?: string | undefined;
579
+ identityUrl?: string | undefined;
580
+ secret?: string | undefined;
581
+ }>>;
566
582
  }, "strip", z.ZodTypeAny, {
567
583
  auth: {
568
584
  strategy: "none" | "nextauth" | "clerk" | "auth0" | "custom-jwt" | "session-cookie" | "unknown";
@@ -691,6 +707,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
691
707
  requireUserConsent: boolean;
692
708
  actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
693
709
  allowedCallers?: string[] | undefined;
710
+ allowedCallees?: string[] | undefined;
694
711
  allowedActions?: string[] | undefined;
695
712
  validFrom?: string | undefined;
696
713
  validUntil?: string | undefined;
@@ -726,6 +743,11 @@ export declare const DuctConfigSchema: z.ZodObject<{
726
743
  dimensions?: string[] | undefined;
727
744
  }[];
728
745
  } | undefined;
746
+ webhooks?: {
747
+ consentCallback?: string | undefined;
748
+ identityUrl?: string | undefined;
749
+ secret?: string | undefined;
750
+ } | undefined;
729
751
  }, {
730
752
  auth: {
731
753
  strategy: "none" | "nextauth" | "clerk" | "auth0" | "custom-jwt" | "session-cookie" | "unknown";
@@ -754,6 +776,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
754
776
  requireUserConsent: boolean;
755
777
  actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
756
778
  allowedCallers?: string[] | undefined;
779
+ allowedCallees?: string[] | undefined;
757
780
  allowedActions?: string[] | undefined;
758
781
  validFrom?: string | undefined;
759
782
  validUntil?: string | undefined;
@@ -889,6 +912,11 @@ export declare const DuctConfigSchema: z.ZodObject<{
889
912
  } | undefined;
890
913
  registry_visibility?: "public" | "private" | undefined;
891
914
  intershell_enabled?: boolean | undefined;
915
+ webhooks?: {
916
+ consentCallback?: string | undefined;
917
+ identityUrl?: string | undefined;
918
+ secret?: string | undefined;
919
+ } | undefined;
892
920
  }>;
893
921
  export type ValidatedDuctConfig = z.infer<typeof DuctConfigSchema>;
894
922
  export interface DuctConfigValidationIssue {
@@ -119,12 +119,20 @@ const AgentPermissionsSchema = z.object({
119
119
  defaultLevel: AgentPermissionLevelSchema,
120
120
  actionOverrides: z.record(AgentPermissionLevelSchema).optional(),
121
121
  allowedCallers: z.array(z.string()).optional(),
122
+ allowedCallees: z
123
+ .array(z.string().regex(/^(shell_[a-z0-9_]+|\*)$/, "allowedCallees entries must be a shell_ id or '*'"))
124
+ .optional(),
122
125
  requireUserConsent: z.boolean(),
123
126
  allowedActions: z.array(z.string()).optional(),
124
127
  validFrom: iso8601Schema.optional(),
125
128
  validUntil: iso8601Schema.optional(),
126
129
  consentActionScope: z.array(z.string().min(1)).optional(),
127
130
  });
131
+ const WebhooksConfigSchema = z.object({
132
+ consentCallback: z.string().url().optional(),
133
+ identityUrl: z.string().url().optional(),
134
+ secret: z.string().optional(),
135
+ });
128
136
  const WidgetConfigSchema = z.object({
129
137
  primaryColor: z.string().optional(),
130
138
  position: z
@@ -180,6 +188,7 @@ export const DuctConfigSchema = z.object({
180
188
  dataModel: DataModelSchema.optional(),
181
189
  registry_visibility: z.enum(['public', 'private']).optional().default('private'),
182
190
  intershell_enabled: z.boolean().optional().default(false),
191
+ webhooks: WebhooksConfigSchema.optional(),
183
192
  });
184
193
  function zodIssuesToValidationIssues(errors) {
185
194
  return errors.map((e) => ({
@@ -298,6 +307,17 @@ export function crossValidateDuctConfig(data) {
298
307
  }
299
308
  }
300
309
  }
310
+ if (data.intershell_enabled) {
311
+ const hasProtectedAction = data.actions.some((action) => action.requiresAuth || action.sideEffects);
312
+ if (hasProtectedAction && !data.webhooks?.identityUrl) {
313
+ issues.push({
314
+ severity: "error",
315
+ area: "webhooks",
316
+ issue: "intershell_enabled shells with protected actions must configure webhooks.identityUrl",
317
+ fix: "Set webhooks.identityUrl to the company's identity resolver route, or disable intershell_enabled",
318
+ });
319
+ }
320
+ }
301
321
  return issues;
302
322
  }
303
323
  /**
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,110 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { createHmac } from 'crypto';
4
+ import { verifyEvidenceBundle } from './evidence-bundle.js';
5
+ import { computeReceiptId } from './receipt.js';
6
+ import { canonicalizeJson } from './jcs.js';
7
+ const HMAC_SECRET = 'conformance-fixture-secret-32bytes!!';
8
+ function signReceipt(body) {
9
+ const receipt_id = computeReceiptId(body);
10
+ const signature = createHmac('sha256', HMAC_SECRET).update(canonicalizeJson(body)).digest('hex');
11
+ return { ...body, receipt_id, signature, kid: 'duct-gateway-hs256-v1' };
12
+ }
13
+ function goldenReadActionBundle() {
14
+ const gate = signReceipt({
15
+ claim_type: 'duct:action:v1',
16
+ issued_at: '2026-01-01T00:00:01.000Z',
17
+ shell_id: 'shell_fixture',
18
+ action_id: 'get_items',
19
+ caller_type: 'human',
20
+ decision: 'permit',
21
+ reason: 'Passes all permission checks',
22
+ permission_source: 'default',
23
+ capture_mode: 'gateway_observed',
24
+ scope_of_claim: {
25
+ asserts: ['gate'],
26
+ does_not_assert: ['upstream'],
27
+ },
28
+ });
29
+ const execution = signReceipt({
30
+ claim_type: 'duct:execution:v1',
31
+ issued_at: '2026-01-01T00:00:05.000Z',
32
+ shell_id: 'shell_fixture',
33
+ action_id: 'get_items',
34
+ caller_type: 'human',
35
+ decision: 'permit',
36
+ reason: 'upstream_observed',
37
+ permission_source: 'gateway',
38
+ capture_mode: 'gateway_observed',
39
+ scope_of_claim: {
40
+ asserts: ['dispatch'],
41
+ does_not_assert: ['business correctness'],
42
+ },
43
+ gate_receipt_ref: gate.receipt_id,
44
+ execution_id: 'EX123',
45
+ upstream_status_class: 'success',
46
+ });
47
+ return {
48
+ manifest: {
49
+ schema: 'duct:audit-evidence:v1',
50
+ bundle_id: 'fixture-read-action',
51
+ exported_at: '2026-01-01T00:10:00.000Z',
52
+ shell_id: 'shell_fixture',
53
+ company_id: 'co_fixture',
54
+ profile: 'standard',
55
+ completeness: 'complete',
56
+ complete: true,
57
+ non_claims: [
58
+ 'does_not_assert_llm_reasoning_correctness',
59
+ 'does_not_assert_upstream_business_data_correctness',
60
+ ],
61
+ },
62
+ conversation: [
63
+ {
64
+ turn_id: 't_fixture',
65
+ message_preview: 'show my items',
66
+ reply_preview: 'Here are your items.',
67
+ occurred_at: '2026-01-01T00:00:00.000Z',
68
+ },
69
+ ],
70
+ evidence_events: [
71
+ { stage: 'request_observed' },
72
+ { stage: 'action_selected' },
73
+ { stage: 'policy_decided' },
74
+ { stage: 'upstream_dispatched' },
75
+ { stage: 'upstream_completed' },
76
+ { stage: 'response_delivered' },
77
+ ],
78
+ receipts: [gate, execution],
79
+ redaction_ledger: [],
80
+ integrity: { valid: true, window_size: 1 },
81
+ replay_descriptor: {
82
+ executions: [
83
+ {
84
+ execution_id: 'EX123',
85
+ action_id: 'get_items',
86
+ request_hash: 'abc123',
87
+ result_hash: 'def456',
88
+ },
89
+ ],
90
+ sandbox_only: true,
91
+ requires_fresh_approval: true,
92
+ },
93
+ };
94
+ }
95
+ describe('evidence bundle conformance fixtures', () => {
96
+ it('verifies the golden read-action scenario', () => {
97
+ const bundle = goldenReadActionBundle();
98
+ const result = verifyEvidenceBundle(bundle, { hmacSecret: HMAC_SECRET });
99
+ assert.equal(result.valid, true);
100
+ assert.equal(result.verified_receipts, 2);
101
+ assert.equal(result.completeness, 'complete');
102
+ assert.deepEqual(result.missing_stages, []);
103
+ });
104
+ it('flags partial bundles with warnings', () => {
105
+ const bundle = goldenReadActionBundle();
106
+ bundle.manifest.completeness = 'partial';
107
+ const result = verifyEvidenceBundle(bundle, { hmacSecret: HMAC_SECRET });
108
+ assert.ok(result.warnings.some((w) => w.includes('partial')));
109
+ });
110
+ });
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Offline verification for duct:audit-evidence:v1 bundles.
3
+ */
4
+ import { type ReceiptJwks, type SignedDuctReceipt, type VerifyReceiptOptions } from "./receipt.js";
5
+ export interface EvidenceBundleManifest {
6
+ schema: string;
7
+ bundle_id: string;
8
+ exported_at: string;
9
+ shell_id: string;
10
+ company_id: string;
11
+ profile: string;
12
+ completeness: "legacy" | "partial" | "complete";
13
+ complete: boolean;
14
+ verification_keys?: ReceiptJwks;
15
+ non_claims?: string[];
16
+ }
17
+ export interface EvidenceBundleIntegrity {
18
+ valid: boolean;
19
+ window_size: number;
20
+ head_hash?: string | null;
21
+ signed_checkpoint?: {
22
+ shell_id: string;
23
+ head_hash: string;
24
+ row_count_at_checkpoint: number;
25
+ issued_at: string;
26
+ signature: string;
27
+ kid: string;
28
+ };
29
+ redacted_count?: number;
30
+ }
31
+ export interface EvidenceBundle {
32
+ manifest: EvidenceBundleManifest;
33
+ conversation: unknown[];
34
+ evidence_events: unknown[];
35
+ receipts: SignedDuctReceipt[];
36
+ integrity?: EvidenceBundleIntegrity;
37
+ redaction_ledger: unknown[];
38
+ replay_descriptor?: {
39
+ executions: unknown[];
40
+ sandbox_only: boolean;
41
+ requires_fresh_approval: boolean;
42
+ };
43
+ }
44
+ export interface VerifyEvidenceBundleResult {
45
+ valid: boolean;
46
+ schema: string;
47
+ completeness: string;
48
+ verified_receipts: number;
49
+ failed_receipts: Array<{
50
+ receipt_id?: string;
51
+ reason: string;
52
+ }>;
53
+ integrity_valid: boolean;
54
+ missing_stages: string[];
55
+ redacted_fields: string[];
56
+ non_claims: string[];
57
+ warnings: string[];
58
+ }
59
+ export declare function verifyEvidenceBundle(bundle: EvidenceBundle, options?: VerifyReceiptOptions): VerifyEvidenceBundleResult;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Offline verification for duct:audit-evidence:v1 bundles.
3
+ */
4
+ import { verifyReceipt } from "./receipt.js";
5
+ export function verifyEvidenceBundle(bundle, options = {}) {
6
+ const warnings = [];
7
+ const failedReceipts = [];
8
+ let verifiedReceipts = 0;
9
+ const jwks = bundle.manifest.verification_keys ?? options.jwks;
10
+ const verifyOpts = { ...options, jwks: jwks ?? options.jwks };
11
+ for (const raw of bundle.receipts) {
12
+ const result = verifyReceipt(raw, verifyOpts);
13
+ if (result.valid) {
14
+ verifiedReceipts += 1;
15
+ }
16
+ else {
17
+ failedReceipts.push({
18
+ receipt_id: raw.receipt_id,
19
+ reason: result.reason,
20
+ });
21
+ }
22
+ }
23
+ const stages = new Set(bundle.evidence_events.map((e) => e.stage).filter(Boolean));
24
+ const required = [
25
+ "request_observed",
26
+ "policy_decided",
27
+ "upstream_dispatched",
28
+ "upstream_completed",
29
+ "response_delivered",
30
+ ];
31
+ const missingStages = required.filter((s) => !stages.has(s));
32
+ const redactedFields = [];
33
+ for (const ev of bundle.evidence_events) {
34
+ const fields = ev.disclosed_fields;
35
+ if (!fields)
36
+ continue;
37
+ for (const f of fields) {
38
+ if (f.mode === "redacted" || f.mode === "masked") {
39
+ redactedFields.push(f.key);
40
+ }
41
+ }
42
+ }
43
+ if (bundle.manifest.completeness === "partial") {
44
+ warnings.push("Bundle completeness is partial — some evidence stages may be missing");
45
+ }
46
+ if (bundle.integrity && !bundle.integrity.valid) {
47
+ warnings.push("Hash chain integrity check failed for included window");
48
+ }
49
+ if (!bundle.manifest.complete) {
50
+ warnings.push("Bundle is paginated — additional pages may be required");
51
+ }
52
+ const integrityValid = bundle.integrity?.valid !== false;
53
+ const valid = failedReceipts.length === 0 &&
54
+ integrityValid &&
55
+ bundle.manifest.schema === "duct:audit-evidence:v1";
56
+ return {
57
+ valid,
58
+ schema: bundle.manifest.schema,
59
+ completeness: bundle.manifest.completeness,
60
+ verified_receipts: verifiedReceipts,
61
+ failed_receipts: failedReceipts,
62
+ integrity_valid: integrityValid,
63
+ missing_stages: missingStages,
64
+ redacted_fields: [...new Set(redactedFields)],
65
+ non_claims: bundle.manifest.non_claims ?? [],
66
+ warnings,
67
+ };
68
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import { createHmac } from 'crypto';
4
+ import { verifyEvidenceBundle } from './evidence-bundle.js';
5
+ import { computeReceiptId } from './receipt.js';
6
+ import { canonicalizeJson } from './jcs.js';
7
+ const HMAC_SECRET = 'x'.repeat(32);
8
+ function minimalReceipt() {
9
+ const body = {
10
+ claim_type: 'duct:action:v1',
11
+ issued_at: new Date().toISOString(),
12
+ shell_id: 'shell_test',
13
+ action_id: 'get_items',
14
+ caller_type: 'human',
15
+ decision: 'permit',
16
+ reason: 'Passes all permission checks',
17
+ permission_source: 'default',
18
+ capture_mode: 'gateway_observed',
19
+ scope_of_claim: {
20
+ asserts: ['test'],
21
+ does_not_assert: ['test'],
22
+ },
23
+ };
24
+ const receipt_id = computeReceiptId(body);
25
+ const canonical = canonicalizeJson(body);
26
+ const signature = createHmac('sha256', HMAC_SECRET).update(canonical).digest('hex');
27
+ return { ...body, receipt_id, signature, kid: 'duct-gateway-hs256-v1' };
28
+ }
29
+ describe('verifyEvidenceBundle', () => {
30
+ it('validates a minimal complete bundle', () => {
31
+ const receipt = minimalReceipt();
32
+ const result = verifyEvidenceBundle({
33
+ manifest: {
34
+ schema: 'duct:audit-evidence:v1',
35
+ bundle_id: 'b1',
36
+ exported_at: new Date().toISOString(),
37
+ shell_id: 'shell_test',
38
+ company_id: 'co_1',
39
+ profile: 'standard',
40
+ completeness: 'complete',
41
+ complete: true,
42
+ },
43
+ conversation: [],
44
+ evidence_events: [
45
+ { stage: 'request_observed' },
46
+ { stage: 'policy_decided' },
47
+ { stage: 'upstream_dispatched' },
48
+ { stage: 'upstream_completed' },
49
+ { stage: 'response_delivered' },
50
+ ],
51
+ receipts: [receipt],
52
+ redaction_ledger: [],
53
+ integrity: { valid: true, window_size: 1 },
54
+ }, { hmacSecret: HMAC_SECRET });
55
+ assert.equal(result.valid, true);
56
+ assert.equal(result.verified_receipts, 1);
57
+ });
58
+ });
@@ -23,6 +23,8 @@ export declare const ReadinessReportSchema: z.ZodObject<{
23
23
  ok: z.ZodBoolean;
24
24
  generatedAt: z.ZodString;
25
25
  docsUrl: z.ZodOptional<z.ZodString>;
26
+ /** Marketing site status page — used by dashboard shell readiness. */
27
+ statusUrl: z.ZodOptional<z.ZodString>;
26
28
  checks: z.ZodArray<z.ZodObject<{
27
29
  id: z.ZodString;
28
30
  label: z.ZodString;
@@ -53,6 +55,7 @@ export declare const ReadinessReportSchema: z.ZodObject<{
53
55
  url?: string | undefined;
54
56
  }[];
55
57
  docsUrl?: string | undefined;
58
+ statusUrl?: string | undefined;
56
59
  }, {
57
60
  ok: boolean;
58
61
  generatedAt: string;
@@ -64,6 +67,7 @@ export declare const ReadinessReportSchema: z.ZodObject<{
64
67
  url?: string | undefined;
65
68
  }[];
66
69
  docsUrl?: string | undefined;
70
+ statusUrl?: string | undefined;
67
71
  }>;
68
72
  export type ReadinessCheckStatus = z.infer<typeof ReadinessCheckStatusSchema>;
69
73
  export type ReadinessCheck = z.infer<typeof ReadinessCheckSchema>;
@@ -96,6 +100,24 @@ export interface CliReadinessOptions {
96
100
  probe?: (url: string) => Promise<HealthProbeResult>;
97
101
  }
98
102
  export declare function buildCliReadinessReport(options: CliReadinessOptions): Promise<ReadinessReport>;
103
+ export interface ReachabilityProbeResult {
104
+ /** True when any HTTP response was received (including 4xx/5xx). */
105
+ reachable: boolean;
106
+ status?: number;
107
+ error?: string;
108
+ }
109
+ /**
110
+ * Probe whether a URL accepts connections. Any HTTP response counts as reachable;
111
+ * only network errors / timeouts do not.
112
+ */
113
+ export declare function probeReachable(url: string, timeoutMs?: number, fetchFn?: typeof fetch): Promise<ReachabilityProbeResult>;
114
+ /** Rewrite loopback hosts so a Dockerized probe can reach the operator's machine. */
115
+ export declare function rewriteLoopbackForDocker(url: string): string | null;
116
+ /**
117
+ * Probe a product base URL, retrying once via host.docker.internal when the
118
+ * configured host is loopback.
119
+ */
120
+ export declare function probeProductBaseUrl(url: string, fetchFn?: typeof fetch): Promise<ReachabilityProbeResult>;
99
121
  export interface ShellReadinessInput {
100
122
  shellId: string;
101
123
  manifestPushed: boolean;
@@ -103,11 +125,7 @@ export interface ShellReadinessInput {
103
125
  actionCount: number;
104
126
  recentMessages: number;
105
127
  recentInvokeTurns: number;
106
- endpoints: {
107
- authHealthUrl: string;
108
- apiHealthUrl: string;
109
- docsUrl: string;
110
- };
111
- probe?: (url: string) => Promise<HealthProbeResult>;
128
+ statusUrl?: string;
129
+ probeProduct?: (url: string) => Promise<ReachabilityProbeResult>;
112
130
  }
113
131
  export declare function buildShellReadinessReport(input: ShellReadinessInput): Promise<ReadinessReport>;
@@ -11,6 +11,8 @@ export const ReadinessReportSchema = z.object({
11
11
  ok: z.boolean(),
12
12
  generatedAt: z.string(),
13
13
  docsUrl: z.string().optional(),
14
+ /** Marketing site status page — used by dashboard shell readiness. */
15
+ statusUrl: z.string().optional(),
14
16
  checks: z.array(ReadinessCheckSchema),
15
17
  });
16
18
  export function readinessReportOk(checks) {
@@ -69,42 +71,92 @@ export async function buildCliReadinessReport(options) {
69
71
  checks,
70
72
  };
71
73
  }
74
+ /**
75
+ * Probe whether a URL accepts connections. Any HTTP response counts as reachable;
76
+ * only network errors / timeouts do not.
77
+ */
78
+ export async function probeReachable(url, timeoutMs = 3000, fetchFn = fetch) {
79
+ const controller = new AbortController();
80
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
81
+ try {
82
+ const response = await fetchFn(url, {
83
+ signal: controller.signal,
84
+ redirect: 'follow',
85
+ method: 'GET',
86
+ });
87
+ return { reachable: true, status: response.status };
88
+ }
89
+ catch (err) {
90
+ return {
91
+ reachable: false,
92
+ error: err instanceof Error ? err.message : String(err),
93
+ };
94
+ }
95
+ finally {
96
+ clearTimeout(timer);
97
+ }
98
+ }
99
+ /** Rewrite loopback hosts so a Dockerized probe can reach the operator's machine. */
100
+ export function rewriteLoopbackForDocker(url) {
101
+ try {
102
+ const parsed = new URL(url);
103
+ if (parsed.hostname !== 'localhost' && parsed.hostname !== '127.0.0.1') {
104
+ return null;
105
+ }
106
+ parsed.hostname = 'host.docker.internal';
107
+ return parsed.toString();
108
+ }
109
+ catch {
110
+ return null;
111
+ }
112
+ }
113
+ /**
114
+ * Probe a product base URL, retrying once via host.docker.internal when the
115
+ * configured host is loopback.
116
+ */
117
+ export async function probeProductBaseUrl(url, fetchFn = fetch) {
118
+ const first = await probeReachable(url, 3000, fetchFn);
119
+ if (first.reachable)
120
+ return first;
121
+ const rewritten = rewriteLoopbackForDocker(url);
122
+ if (!rewritten || rewritten === url)
123
+ return first;
124
+ const second = await probeReachable(rewritten, 3000, fetchFn);
125
+ if (second.reachable)
126
+ return second;
127
+ return first;
128
+ }
72
129
  export async function buildShellReadinessReport(input) {
73
- const probe = input.probe ?? ((url) => probeHealth(url));
130
+ const probe = input.probeProduct ?? ((url) => probeProductBaseUrl(url));
74
131
  const checks = [];
75
132
  checks.push(makeCheck('manifest_pushed', 'Manifest pushed', input.manifestPushed ? 'pass' : 'fail', {
76
133
  message: input.manifestPushed
77
134
  ? 'Shell status is live'
78
135
  : 'Run npx duct push to publish your manifest',
79
- }), makeCheck('product_base_url', 'Product base URL', input.productBaseUrl ? 'pass' : 'warn', {
80
- message: input.productBaseUrl || 'Set product.baseUrl in duct.config.ts',
81
- }), makeCheck('actions_defined', 'Actions defined', input.actionCount > 0 ? 'pass' : 'fail', { message: `${input.actionCount} action(s) in manifest` }), makeCheck('recent_activity', 'Recent shell activity', input.recentMessages > 0 || input.recentInvokeTurns > 0 ? 'pass' : 'warn', {
82
- message: input.recentMessages > 0 || input.recentInvokeTurns > 0
83
- ? `${input.recentMessages} message(s), ${input.recentInvokeTurns} agent invoke(s) in the last 30 days`
84
- : 'No messages or agent invokes yet — try the playground',
85
136
  }));
86
- for (const { id, label, url } of [
87
- { id: 'auth_reachable', label: 'Auth service', url: input.endpoints.authHealthUrl },
88
- { id: 'api_reachable', label: 'Agent API', url: input.endpoints.apiHealthUrl },
89
- ]) {
90
- const result = await probe(url);
91
- checks.push(makeCheck(id, label, result.ok ? 'pass' : 'fail', {
92
- url,
93
- message: result.ok
94
- ? 'Reachable'
95
- : result.status !== undefined
96
- ? `HTTP ${result.status}`
97
- : result.error ?? 'unreachable',
137
+ if (!input.productBaseUrl) {
138
+ checks.push(makeCheck('product_base_url', 'Product base URL', 'warn', {
139
+ message: 'Set product.baseUrl in duct.config.ts',
98
140
  }));
99
141
  }
100
- checks.push(makeCheck('docs_url', 'Docs URL', 'pass', {
101
- url: input.endpoints.docsUrl,
102
- message: input.endpoints.docsUrl,
142
+ else {
143
+ const result = await probe(input.productBaseUrl);
144
+ checks.push(makeCheck('product_base_url', 'Product base URL', result.reachable ? 'pass' : 'fail', {
145
+ url: input.productBaseUrl,
146
+ message: result.reachable
147
+ ? input.productBaseUrl
148
+ : `${input.productBaseUrl} — ${result.error ?? 'unreachable'}`,
149
+ }));
150
+ }
151
+ checks.push(makeCheck('actions_defined', 'Actions defined', input.actionCount > 0 ? 'pass' : 'fail', { message: `${input.actionCount} action(s) in manifest` }), makeCheck('recent_activity', 'Recent shell activity', input.recentMessages > 0 || input.recentInvokeTurns > 0 ? 'pass' : 'warn', {
152
+ message: input.recentMessages > 0 || input.recentInvokeTurns > 0
153
+ ? `${input.recentMessages} message(s), ${input.recentInvokeTurns} agent invoke(s) in the last 30 days`
154
+ : 'No messages or agent invokes yet — try the playground',
103
155
  }));
104
156
  return {
105
157
  ok: readinessReportOk(checks),
106
158
  generatedAt: new Date().toISOString(),
107
- docsUrl: input.endpoints.docsUrl,
159
+ statusUrl: input.statusUrl,
108
160
  checks,
109
161
  };
110
162
  }
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
- import { ReadinessReportSchema, buildCliReadinessReport, readinessReportOk, } from './readiness-checks.js';
3
+ import { ReadinessReportSchema, buildCliReadinessReport, buildShellReadinessReport, probeProductBaseUrl, readinessReportOk, rewriteLoopbackForDocker, } from './readiness-checks.js';
4
4
  describe('readiness-checks', () => {
5
5
  it('buildCliReadinessReport emits schema-valid output', async () => {
6
6
  const report = await buildCliReadinessReport({
@@ -46,4 +46,61 @@ describe('readiness-checks', () => {
46
46
  const api = report.checks.find((c) => c.id === 'api_reachable');
47
47
  assert.equal(api?.status, 'fail');
48
48
  });
49
+ it('rewriteLoopbackForDocker rewrites localhost hosts', () => {
50
+ assert.equal(rewriteLoopbackForDocker('http://localhost:5173'), 'http://host.docker.internal:5173/');
51
+ assert.equal(rewriteLoopbackForDocker('https://app.example.com'), null);
52
+ });
53
+ it('probeProductBaseUrl retries via host.docker.internal', async () => {
54
+ const attempted = [];
55
+ const fetchFn = (async (input) => {
56
+ const url = String(input);
57
+ attempted.push(url);
58
+ if (url.includes('host.docker.internal')) {
59
+ return new Response('ok', { status: 200 });
60
+ }
61
+ throw new Error('fetch failed');
62
+ });
63
+ const result = await probeProductBaseUrl('http://localhost:5173', fetchFn);
64
+ assert.equal(result.reachable, true);
65
+ assert.deepEqual(attempted, [
66
+ 'http://localhost:5173',
67
+ 'http://host.docker.internal:5173/',
68
+ ]);
69
+ });
70
+ it('buildShellReadinessReport is shell-only and probes product URL', async () => {
71
+ const report = await buildShellReadinessReport({
72
+ shellId: 'shell_test',
73
+ manifestPushed: true,
74
+ productBaseUrl: 'http://localhost:5173',
75
+ actionCount: 2,
76
+ recentMessages: 1,
77
+ recentInvokeTurns: 0,
78
+ statusUrl: 'http://localhost:3005/status',
79
+ probeProduct: async () => ({ reachable: false, error: 'fetch failed' }),
80
+ });
81
+ assert.equal(ReadinessReportSchema.safeParse(report).success, true);
82
+ assert.equal(report.ok, false);
83
+ assert.equal(report.statusUrl, 'http://localhost:3005/status');
84
+ assert.equal(report.checks.length, 4);
85
+ assert.ok(!report.checks.some((c) => c.id === 'auth_reachable'));
86
+ assert.ok(!report.checks.some((c) => c.id === 'api_reachable'));
87
+ assert.ok(!report.checks.some((c) => c.id === 'docs_url'));
88
+ const product = report.checks.find((c) => c.id === 'product_base_url');
89
+ assert.equal(product?.status, 'fail');
90
+ assert.match(product?.message ?? '', /fetch failed/);
91
+ });
92
+ it('buildShellReadinessReport passes when product URL is reachable', async () => {
93
+ const report = await buildShellReadinessReport({
94
+ shellId: 'shell_test',
95
+ manifestPushed: true,
96
+ productBaseUrl: 'http://localhost:5173',
97
+ actionCount: 1,
98
+ recentMessages: 0,
99
+ recentInvokeTurns: 1,
100
+ probeProduct: async () => ({ reachable: true, status: 200 }),
101
+ });
102
+ assert.equal(report.ok, true);
103
+ const product = report.checks.find((c) => c.id === 'product_base_url');
104
+ assert.equal(product?.status, 'pass');
105
+ });
49
106
  });
@@ -1,4 +1,4 @@
1
- export type ReceiptClaimType = "duct:action:v1" | "duct:authority:v1" | "duct:intent:v1";
1
+ export type ReceiptClaimType = "duct:action:v1" | "duct:authority:v1" | "duct:intent:v1" | "duct:execution:v1";
2
2
  export type ReceiptDecision = "permit" | "deny" | "ask";
3
3
  export type ReceiptCaptureMode = "gateway_observed" | "self_attested";
4
4
  export type ReceiptRejectionReason = "WRONG_CLAIM" | "INVALID_SIGNATURE" | "RECEIPT_ID_MISMATCH" | "SIGNING_KEY_UNAVAILABLE";
@@ -23,6 +23,10 @@ export interface DuctReceiptBody {
23
23
  capture_mode: ReceiptCaptureMode;
24
24
  scope_of_claim: ScopeOfClaim;
25
25
  intent_ref?: string;
26
+ upstream_status_class?: string;
27
+ result_hash?: string;
28
+ execution_id?: string;
29
+ gate_receipt_ref?: string;
26
30
  }
27
31
  export interface SignedDuctReceipt extends DuctReceiptBody {
28
32
  receipt_id: string;
@@ -273,6 +273,13 @@ export interface AgentPermissions {
273
273
  * To close this shell to cross-shell calls entirely, set intershell_enabled: false.
274
274
  */
275
275
  allowedCallers?: string[];
276
+ /**
277
+ * Optional egress restriction: if set (non-empty), this shell may ONLY call the listed
278
+ * shell IDs cross-shell. Absent/empty = may call any shell that admits it (subject to
279
+ * the target's inbound gate). '*' = explicitly open egress.
280
+ * Cross-company calls additionally require the target to admit this shell AND be verified.
281
+ */
282
+ allowedCallees?: string[];
276
283
  /** Whether to require explicit user consent for agent actions */
277
284
  requireUserConsent: boolean;
278
285
  /** Allowed actions (action IDs) */
@@ -491,6 +498,22 @@ export interface DuctConfig {
491
498
  registry_visibility?: 'public' | 'private';
492
499
  /** Master switch: allow other shells to call this one. Default: false */
493
500
  intershell_enabled?: boolean;
501
+ /** Identity/consent webhook wiring — required for cross-shell protected actions. */
502
+ webhooks?: WebhooksConfig;
503
+ }
504
+ /**
505
+ * Identity/consent webhook wiring for this shell. Read dynamically from manifest JSON
506
+ * by the auth service (`consent-state.ts`); typed here so `duct` can validate that any
507
+ * shell with a requiresAuth/sideEffects action AND intershell_enabled also declares
508
+ * `identityUrl` — otherwise cross-shell protected actions can never be authorized.
509
+ */
510
+ export interface WebhooksConfig {
511
+ /** Duct redirects the browser here after consent approval to deliver the auth code. */
512
+ consentCallback?: string;
513
+ /** Company identity resolver: thin route wired to the company's existing login/session. */
514
+ identityUrl?: string;
515
+ /** Shared webhook signing secret (whsec_…) used to verify identity vouches + signed callbacks. */
516
+ secret?: string;
494
517
  }
495
518
  export interface ShellManifest {
496
519
  shellId: string;
@@ -4,9 +4,9 @@
4
4
  // ============================================================
5
5
  /** Pixel dimensions for each shell preset. Single source of truth. */
6
6
  export const SHELL_PRESET_DIMENSIONS = {
7
- tall: { width: 400, height: 660 },
8
- square: { width: 460, height: 500 },
9
- large: { width: 560, height: 720 },
7
+ tall: { width: 400, height: 700 },
8
+ square: { width: 460, height: 540 },
9
+ large: { width: 560, height: 760 },
10
10
  };
11
11
  export const DEFAULT_SHELL_PRESET = 'tall';
12
12
  /** Viewport margins applied to the opened shell panel (matches DuctShell CSS). */
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export type { ValidatedDuctConfig, ManifestAction, ErrorEnvelope, ConfirmationSt
3
3
  export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
4
4
  export type { GenerateTokenOptions, GenerateTokenResult, VerifyTokenOptions, VerifyTokenResult, GenerateDeeplinkTokenOptions, GenerateDeeplinkTokenResult, VerifyDeeplinkTokenOptions, VerifyDeeplinkResult, DeeplinkReplayStore, RedisSetClient, } from "./core/token.js";
5
5
  export { verifyReceipt, computeReceiptId } from "./core/receipt.js";
6
+ export { verifyEvidenceBundle } from "./core/evidence-bundle.js";
6
7
  export type { SignedDuctReceipt, DuctReceiptBody, ReceiptClaimType, ReceiptJwks, VerifyReceiptOptions, VerifyReceiptResult, ReceiptRejectionReason, } from "./core/receipt.js";
7
8
  export { buildAction, checkActionPermission, buildActionSearchIndex, shouldDeferActions, } from "./core/action.js";
8
9
  export type { ActionSearchEntry } from "./core/action.js";
@@ -15,4 +16,4 @@ export type { ShellPreset, ShellPanelViewportInsets } from "./core/types.js";
15
16
  export type { DuctPageContext } from "./core/types.js";
16
17
  export { useDuctPageContext } from "./adapters/react/use-page-context.js";
17
18
  export type { UseDuctPageContextOptions } from "./adapters/react/use-page-context.js";
18
- export type { RouteManifest, RouteParam, QueryParam, UIStateHint, ActionManifest, ActionParam, SensitivityLevel, ApprovalPredicate, ApprovalCompareOp, ApprovalLogicalOp, ActionLimitPolicy, ActionRuntimeFields, ActionDef, BuiltActionDef, ActionValidationResult, AuthSchema, AuthStrategy, DeeplinkDefinition, StateField, ReviewResult, ReviewIssue, ReviewIssueSeverity, DuctConfig, ProductConfig, AgentPermissions, AgentPermissionLevel, WidgetConfig, ShellManifest, ModalityDecision, ScoredModalityDecision, ShellSessionPhase, ShellSessionState, ShellSessionType, ShellCallChain, ActionPermissionContext, ActionPermissionResult, PermissionDecision, PermissionRuleSource, SessionContext, Message, DuctTokenPayload, DeeplinkTokenPayload, DuctAdapter, ReceiverOptions, ShellOptions, } from "./core/types.js";
19
+ export type { RouteManifest, RouteParam, QueryParam, UIStateHint, ActionManifest, ActionParam, SensitivityLevel, ApprovalPredicate, ApprovalCompareOp, ApprovalLogicalOp, ActionLimitPolicy, ActionRuntimeFields, ActionDef, BuiltActionDef, ActionValidationResult, AuthSchema, AuthStrategy, DeeplinkDefinition, StateField, ReviewResult, ReviewIssue, ReviewIssueSeverity, DuctConfig, ProductConfig, AgentPermissions, AgentPermissionLevel, WidgetConfig, WebhooksConfig, ShellManifest, ModalityDecision, ScoredModalityDecision, ShellSessionPhase, ShellSessionState, ShellSessionType, ShellCallChain, ActionPermissionContext, ActionPermissionResult, PermissionDecision, PermissionRuleSource, SessionContext, Message, DuctTokenPayload, DeeplinkTokenPayload, DuctAdapter, ReceiverOptions, ShellOptions, } from "./core/types.js";
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig, ManifestAc
11
11
  export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
12
12
  // Outcome receipt verification (crypto layer)
13
13
  export { verifyReceipt, computeReceiptId } from "./core/receipt.js";
14
+ export { verifyEvidenceBundle } from "./core/evidence-bundle.js";
14
15
  // Action factory
15
16
  export { buildAction, checkActionPermission, buildActionSearchIndex, shouldDeferActions, } from "./core/action.js";
16
17
  // Shell status (server-side)
package/dist/server.d.ts CHANGED
@@ -3,6 +3,7 @@ export type { ValidatedDuctConfig, ManifestAction, ErrorEnvelope, ConfirmationSt
3
3
  export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
4
4
  export type { GenerateTokenOptions, GenerateTokenResult, VerifyTokenOptions, VerifyTokenResult, GenerateDeeplinkTokenOptions, GenerateDeeplinkTokenResult, VerifyDeeplinkTokenOptions, VerifyDeeplinkResult, DeeplinkReplayStore, RedisSetClient, } from "./core/token.js";
5
5
  export { verifyReceipt, computeReceiptId } from "./core/receipt.js";
6
+ export { verifyEvidenceBundle } from "./core/evidence-bundle.js";
6
7
  export type { SignedDuctReceipt, DuctReceiptBody, ReceiptClaimType, ReceiptJwks, VerifyReceiptOptions, VerifyReceiptResult, ReceiptRejectionReason, } from "./core/receipt.js";
7
8
  export { createIntrospectHandler, createIntrospectPageHandler, createIntrospectExpressHandler, } from "./core/introspect.js";
8
9
  export type { IntrospectEntity, IntrospectResult, IntrospectContext, IntrospectResolver, IntrospectHandlerOptions, } from "./core/introspect.js";
package/dist/server.js CHANGED
@@ -15,6 +15,7 @@ export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig, ManifestAc
15
15
  export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
16
16
  // Outcome receipt verification (crypto layer)
17
17
  export { verifyReceipt, computeReceiptId } from "./core/receipt.js";
18
+ export { verifyEvidenceBundle } from "./core/evidence-bundle.js";
18
19
  // Introspect handler factories
19
20
  export { createIntrospectHandler, createIntrospectPageHandler, createIntrospectExpressHandler, } from "./core/introspect.js";
20
21
  // Page-resolve handler factories (agent deeplink resolution)
package/package.json CHANGED
@@ -1,94 +1,94 @@
1
- {
2
- "name": "@duct-sdk/sdk",
3
- "version": "0.5.9",
4
- "type": "module",
5
- "description": "Duct SDK — manifest, CLI, and embed components for permissioned human and agent access to your product APIs.",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "bin": {
9
- "duct": "dist/cli/index.js"
10
- },
11
- "exports": {
12
- ".": "./dist/index.js",
13
- "./server": "./dist/server.js",
14
- "./next": "./dist/adapters/next/index.js",
15
- "./remix": "./dist/adapters/remix/index.js",
16
- "./vite": "./dist/adapters/vite/index.js",
17
- "./sveltekit": "./dist/adapters/sveltekit/index.js",
18
- "./react": "./dist/adapters/react/index.js"
19
- },
20
- "scripts": {
21
- "build": "npm run build --prefix ../contracts && tsc",
22
- "dev": "tsc --watch",
23
- "test": "npm run build && node --test dist/core/*.test.js dist/adapters/react/*.test.js dist/cli/*.test.js dist/cli/generators/*.test.js dist/cli/processors/*.test.js",
24
- "verify:publish": "node scripts/verify-publish.mjs",
25
- "pack:release": "npm run build && npm run verify:publish && node scripts/pack-release.mjs",
26
- "prepublishOnly": "npm run build && npm run verify:publish"
27
- },
28
- "dependencies": {
29
- "@duct-sdk/contracts": "file:../contracts",
30
- "@anthropic-ai/sdk": "^0.24.0",
31
- "jose": "^5.0.0",
32
- "ignore": "^5.0.0",
33
- "commander": "^12.0.0",
34
- "chalk": "^5.0.0",
35
- "ora": "^8.0.0",
36
- "inquirer": "^9.0.0",
37
- "zod": "^3.0.0",
38
- "node-fetch": "^3.0.0",
39
- "glob": "^10.0.0",
40
- "yaml": "^2.0.0"
41
- },
42
- "devDependencies": {
43
- "typescript": "^5.0.0",
44
- "@types/node": "^20.0.0",
45
- "@types/inquirer": "^9.0.0",
46
- "@types/react": "^18.0.0",
47
- "next": "^14.0.0",
48
- "react": "^18.0.0",
49
- "react-dom": "^18.0.0"
50
- },
51
- "peerDependencies": {
52
- "react": "^18.0.0 || ^19.0.0",
53
- "react-dom": "^18.0.0 || ^19.0.0",
54
- "next": ">=14.0.0"
55
- },
56
- "peerDependenciesMeta": {
57
- "react": {
58
- "optional": true
59
- },
60
- "react-dom": {
61
- "optional": true
62
- },
63
- "next": {
64
- "optional": true
65
- }
66
- },
67
- "files": [
68
- "dist",
69
- "assets",
70
- "README.md",
71
- "CHANGELOG.md",
72
- "TOKEN_SPEC.md"
73
- ],
74
- "keywords": [
75
- "duct",
76
- "ai",
77
- "agent",
78
- "shell",
79
- "cli",
80
- "llm",
81
- "ai-agent",
82
- "deeplink",
83
- "next",
84
- "nextjs",
85
- "remix",
86
- "vite",
87
- "sveltekit",
88
- "sdk"
89
- ],
90
- "publishConfig": {
91
- "registry": "https://registry.npmjs.org",
92
- "access": "public"
93
- }
94
- }
1
+ {
2
+ "name": "@duct-sdk/sdk",
3
+ "version": "0.5.10",
4
+ "type": "module",
5
+ "description": "Duct SDK — manifest, CLI, and embed components for permissioned human and agent access to your product APIs.",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "duct": "dist/cli/index.js"
10
+ },
11
+ "exports": {
12
+ ".": "./dist/index.js",
13
+ "./server": "./dist/server.js",
14
+ "./next": "./dist/adapters/next/index.js",
15
+ "./remix": "./dist/adapters/remix/index.js",
16
+ "./vite": "./dist/adapters/vite/index.js",
17
+ "./sveltekit": "./dist/adapters/sveltekit/index.js",
18
+ "./react": "./dist/adapters/react/index.js"
19
+ },
20
+ "scripts": {
21
+ "build": "npm run build --prefix ../contracts && tsc",
22
+ "dev": "tsc --watch",
23
+ "test": "npm run build && node --test dist/core/*.test.js dist/adapters/react/*.test.js dist/cli/*.test.js dist/cli/generators/*.test.js dist/cli/processors/*.test.js",
24
+ "verify:publish": "node scripts/verify-publish.mjs",
25
+ "pack:release": "npm run build && npm run verify:publish && node scripts/pack-release.mjs",
26
+ "prepublishOnly": "npm run build && npm run verify:publish"
27
+ },
28
+ "dependencies": {
29
+ "@duct-sdk/contracts": "file:../contracts",
30
+ "@anthropic-ai/sdk": "^0.24.0",
31
+ "jose": "^5.0.0",
32
+ "ignore": "^5.0.0",
33
+ "commander": "^12.0.0",
34
+ "chalk": "^5.0.0",
35
+ "ora": "^8.0.0",
36
+ "inquirer": "^9.0.0",
37
+ "zod": "^3.0.0",
38
+ "node-fetch": "^3.0.0",
39
+ "glob": "^10.0.0",
40
+ "yaml": "^2.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "typescript": "^5.0.0",
44
+ "@types/node": "^20.0.0",
45
+ "@types/inquirer": "^9.0.0",
46
+ "@types/react": "^18.0.0",
47
+ "next": "^14.0.0",
48
+ "react": "^18.0.0",
49
+ "react-dom": "^18.0.0"
50
+ },
51
+ "peerDependencies": {
52
+ "react": "^18.0.0 || ^19.0.0",
53
+ "react-dom": "^18.0.0 || ^19.0.0",
54
+ "next": ">=14.0.0"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "react": {
58
+ "optional": true
59
+ },
60
+ "react-dom": {
61
+ "optional": true
62
+ },
63
+ "next": {
64
+ "optional": true
65
+ }
66
+ },
67
+ "files": [
68
+ "dist",
69
+ "assets",
70
+ "README.md",
71
+ "CHANGELOG.md",
72
+ "TOKEN_SPEC.md"
73
+ ],
74
+ "keywords": [
75
+ "duct",
76
+ "ai",
77
+ "agent",
78
+ "shell",
79
+ "cli",
80
+ "llm",
81
+ "ai-agent",
82
+ "deeplink",
83
+ "next",
84
+ "nextjs",
85
+ "remix",
86
+ "vite",
87
+ "sveltekit",
88
+ "sdk"
89
+ ],
90
+ "publishConfig": {
91
+ "registry": "https://registry.npmjs.org",
92
+ "access": "public"
93
+ }
94
+ }