@duct-sdk/sdk 0.5.12 → 0.6.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 (159) hide show
  1. package/CHANGELOG.md +385 -336
  2. package/README.md +418 -264
  3. package/TOKEN_SPEC.md +243 -237
  4. package/dist/cli/add.d.ts +7 -0
  5. package/dist/cli/add.js +152 -0
  6. package/dist/cli/agent-prompt.d.ts +3 -0
  7. package/dist/cli/agent-prompt.js +39 -0
  8. package/dist/cli/api-sources.d.ts +26 -0
  9. package/dist/cli/api-sources.js +222 -0
  10. package/dist/cli/cloud.d.ts +133 -0
  11. package/dist/cli/cloud.js +298 -0
  12. package/dist/cli/config-loader.d.ts +14 -0
  13. package/dist/cli/config-loader.js +56 -7
  14. package/dist/cli/device-login.d.ts +17 -0
  15. package/dist/cli/device-login.js +75 -0
  16. package/dist/cli/drift.js +6 -6
  17. package/dist/cli/generators/any-stack.d.ts +3 -0
  18. package/dist/cli/generators/any-stack.js +97 -0
  19. package/dist/cli/generators/config.js +3 -2
  20. package/dist/cli/generators/receiver.js +7 -7
  21. package/dist/cli/generators/shell.js +12 -12
  22. package/dist/cli/generators/token-route.js +245 -245
  23. package/dist/cli/index.js +402 -611
  24. package/dist/cli/mcp-core.d.ts +42 -0
  25. package/dist/cli/mcp-core.js +161 -0
  26. package/dist/cli/mcp-setup.d.ts +4 -0
  27. package/dist/cli/mcp-setup.js +360 -0
  28. package/dist/cli/mcp.d.ts +2 -0
  29. package/dist/cli/mcp.js +457 -0
  30. package/dist/cli/migrate-intershell.js +5 -5
  31. package/dist/cli/policy-defaults.d.ts +37 -0
  32. package/dist/cli/policy-defaults.js +127 -0
  33. package/dist/cli/processors/integration-audit.js +2 -2
  34. package/dist/cli/processors/openapi-parser.d.ts +5 -0
  35. package/dist/cli/processors/openapi-parser.js +8 -3
  36. package/dist/cli/project-loader.d.ts +58 -0
  37. package/dist/cli/project-loader.js +198 -0
  38. package/dist/cli/project-writer.d.ts +23 -0
  39. package/dist/cli/project-writer.js +171 -0
  40. package/dist/cli/push.d.ts +43 -0
  41. package/dist/cli/push.js +276 -0
  42. package/dist/cli/safety-checks.d.ts +9 -0
  43. package/dist/cli/safety-checks.js +29 -0
  44. package/dist/cli/setup.d.ts +20 -0
  45. package/dist/cli/setup.js +349 -0
  46. package/dist/cli/shell-name.d.ts +8 -0
  47. package/dist/cli/shell-name.js +29 -0
  48. package/dist/cli/shells.d.ts +22 -0
  49. package/dist/cli/shells.js +122 -0
  50. package/dist/cli/split.d.ts +7 -0
  51. package/dist/cli/split.js +71 -0
  52. package/dist/cli/sync.d.ts +25 -0
  53. package/dist/cli/sync.js +120 -0
  54. package/dist/cli/test-runner.d.ts +21 -0
  55. package/dist/cli/test-runner.js +281 -0
  56. package/dist/core/compile.d.ts +43 -0
  57. package/dist/core/compile.js +510 -0
  58. package/dist/core/config.d.ts +533 -1
  59. package/dist/core/config.js +32 -12
  60. package/dist/core/hosted-upstream-check.d.ts +3 -0
  61. package/dist/core/hosted-upstream-check.js +35 -0
  62. package/dist/core/login-handoff.d.ts +1 -1
  63. package/dist/core/login-handoff.js +1 -1
  64. package/dist/core/project.d.ts +1798 -0
  65. package/dist/core/project.js +278 -0
  66. package/dist/core/readiness-checks.js +2 -2
  67. package/dist/core/types.d.ts +26 -1
  68. package/dist/index.d.ts +6 -0
  69. package/dist/index.js +16 -0
  70. package/dist/project.d.ts +4 -0
  71. package/dist/project.js +8 -0
  72. package/dist/server.d.ts +2 -0
  73. package/dist/server.js +1 -0
  74. package/fixtures/token-conformance-vectors.json +26 -0
  75. package/package.json +94 -94
  76. package/dist/adapters/react/page-context-guard.test.d.ts +0 -1
  77. package/dist/adapters/react/page-context-guard.test.js +0 -15
  78. package/dist/cli/agents/api-agent.d.ts +0 -22
  79. package/dist/cli/agents/api-agent.js +0 -761
  80. package/dist/cli/agents/auth-agent.d.ts +0 -7
  81. package/dist/cli/agents/auth-agent.js +0 -212
  82. package/dist/cli/agents/deeplink-agent.d.ts +0 -6
  83. package/dist/cli/agents/deeplink-agent.js +0 -285
  84. package/dist/cli/agents/llm.d.ts +0 -33
  85. package/dist/cli/agents/llm.js +0 -309
  86. package/dist/cli/agents/pipeline.d.ts +0 -72
  87. package/dist/cli/agents/pipeline.js +0 -421
  88. package/dist/cli/agents/reviewer-agent.d.ts +0 -13
  89. package/dist/cli/agents/reviewer-agent.js +0 -450
  90. package/dist/cli/agents/route-agent.d.ts +0 -17
  91. package/dist/cli/agents/route-agent.js +0 -383
  92. package/dist/cli/config-loader.test.d.ts +0 -1
  93. package/dist/cli/config-loader.test.js +0 -63
  94. package/dist/cli/detectors/topology.d.ts +0 -46
  95. package/dist/cli/detectors/topology.js +0 -417
  96. package/dist/cli/generators/config.test.d.ts +0 -1
  97. package/dist/cli/generators/config.test.js +0 -222
  98. package/dist/cli/generators/shell.test.d.ts +0 -1
  99. package/dist/cli/generators/shell.test.js +0 -73
  100. package/dist/cli/generators/token-route.test.d.ts +0 -1
  101. package/dist/cli/generators/token-route.test.js +0 -53
  102. package/dist/cli/generators/wiring-snippets.test.d.ts +0 -1
  103. package/dist/cli/generators/wiring-snippets.test.js +0 -80
  104. package/dist/cli/init.d.ts +0 -32
  105. package/dist/cli/init.js +0 -1336
  106. package/dist/cli/manifest-diff.test.d.ts +0 -1
  107. package/dist/cli/manifest-diff.test.js +0 -144
  108. package/dist/cli/processors/curl-parser.test.d.ts +0 -1
  109. package/dist/cli/processors/curl-parser.test.js +0 -24
  110. package/dist/cli/processors/integration-audit.test.d.ts +0 -1
  111. package/dist/cli/processors/integration-audit.test.js +0 -154
  112. package/dist/cli/processors/postprocess.d.ts +0 -22
  113. package/dist/cli/processors/postprocess.js +0 -107
  114. package/dist/cli/processors/prisma-parser.d.ts +0 -35
  115. package/dist/cli/processors/prisma-parser.js +0 -117
  116. package/dist/cli/processors/verify-discovery.d.ts +0 -33
  117. package/dist/cli/processors/verify-discovery.js +0 -193
  118. package/dist/cli/processors/verify-discovery.test.d.ts +0 -1
  119. package/dist/cli/processors/verify-discovery.test.js +0 -153
  120. package/dist/cli/processors/zod-extractor.d.ts +0 -27
  121. package/dist/cli/processors/zod-extractor.js +0 -153
  122. package/dist/cli/prompts/review.d.ts +0 -61
  123. package/dist/cli/prompts/review.js +0 -410
  124. package/dist/cli/selectors/express.d.ts +0 -12
  125. package/dist/cli/selectors/express.js +0 -117
  126. package/dist/cli/selectors/fastapi.d.ts +0 -12
  127. package/dist/cli/selectors/fastapi.js +0 -122
  128. package/dist/cli/selectors/generic.d.ts +0 -10
  129. package/dist/cli/selectors/generic.js +0 -74
  130. package/dist/cli/selectors/index.d.ts +0 -37
  131. package/dist/cli/selectors/index.js +0 -315
  132. package/dist/cli/selectors/next.d.ts +0 -12
  133. package/dist/cli/selectors/next.js +0 -130
  134. package/dist/core/config-policy.test.d.ts +0 -1
  135. package/dist/core/config-policy.test.js +0 -101
  136. package/dist/core/config-roundtrip.test.d.ts +0 -1
  137. package/dist/core/config-roundtrip.test.js +0 -180
  138. package/dist/core/endpoint-guard.test.d.ts +0 -1
  139. package/dist/core/endpoint-guard.test.js +0 -57
  140. package/dist/core/env-diagnostics.test.d.ts +0 -1
  141. package/dist/core/env-diagnostics.test.js +0 -31
  142. package/dist/core/evidence-bundle.conformance.test.d.ts +0 -1
  143. package/dist/core/evidence-bundle.conformance.test.js +0 -110
  144. package/dist/core/evidence-bundle.test.d.ts +0 -1
  145. package/dist/core/evidence-bundle.test.js +0 -58
  146. package/dist/core/invariants.test.d.ts +0 -1
  147. package/dist/core/invariants.test.js +0 -217
  148. package/dist/core/login-handoff.test.d.ts +0 -1
  149. package/dist/core/login-handoff.test.js +0 -31
  150. package/dist/core/profile.test.d.ts +0 -1
  151. package/dist/core/profile.test.js +0 -95
  152. package/dist/core/readiness-checks.test.d.ts +0 -1
  153. package/dist/core/readiness-checks.test.js +0 -106
  154. package/dist/core/receipt.test.d.ts +0 -1
  155. package/dist/core/receipt.test.js +0 -75
  156. package/dist/core/side-effects-review.test.d.ts +0 -1
  157. package/dist/core/side-effects-review.test.js +0 -28
  158. package/dist/core/token.test.d.ts +0 -1
  159. package/dist/core/token.test.js +0 -66
@@ -2,7 +2,7 @@
2
2
  // @duct/sdk — Config Definition and Validation
3
3
  // ============================================================
4
4
  import { z } from "zod";
5
- import { ActionManifestSchema, iso8601Schema, } from "@duct-sdk/contracts";
5
+ import { ActionManifestSchema, iso8601Schema, SensitivityLevelSchema, } from "@duct-sdk/contracts";
6
6
  export { ActionManifestSchema, ManifestActionSchema, SensitivityLevelSchema, ErrorEnvelopeSchema, ConfirmationStateSchema, } from "@duct-sdk/contracts";
7
7
  // ----------------------------------------------------------------
8
8
  // Zod Schemas
@@ -35,7 +35,7 @@ const QueryParamSchema = z.object({
35
35
  description: z.string().optional(),
36
36
  defaultValue: z.union([z.string(), z.number(), z.boolean()]).optional(),
37
37
  });
38
- const RouteManifestSchema = z.object({
38
+ export const RouteManifestSchema = z.object({
39
39
  path: z.string().min(1).startsWith("/"),
40
40
  name: z.string().min(1),
41
41
  description: z.string().min(1),
@@ -55,7 +55,7 @@ const RouteManifestSchema = z.object({
55
55
  })
56
56
  .optional(),
57
57
  });
58
- const AuthStrategySchema = z.enum([
58
+ export const AuthStrategySchema = z.enum([
59
59
  "nextauth",
60
60
  "clerk",
61
61
  "auth0",
@@ -64,7 +64,7 @@ const AuthStrategySchema = z.enum([
64
64
  "none",
65
65
  "unknown",
66
66
  ]);
67
- const AuthSchemaSchema = z.object({
67
+ export const AuthSchemaSchema = z.object({
68
68
  strategy: AuthStrategySchema,
69
69
  sessionFields: z.array(z.string()).default([]),
70
70
  guestAllowed: z.boolean(),
@@ -91,7 +91,7 @@ const PageResolverSchema = z.union([
91
91
  z.object({ actionId: z.string().min(1) }),
92
92
  z.object({ endpoint: z.string().min(1).startsWith("/") }),
93
93
  ]);
94
- const DeeplinkDefinitionSchema = z.object({
94
+ export const DeeplinkDefinitionSchema = z.object({
95
95
  id: z
96
96
  .string()
97
97
  .min(1)
@@ -109,13 +109,13 @@ const DeeplinkDefinitionSchema = z.object({
109
109
  contentSelector: z.string().optional(),
110
110
  updatedAt: z.string().optional(),
111
111
  });
112
- const AgentPermissionLevelSchema = z.enum([
112
+ export const AgentPermissionLevelSchema = z.enum([
113
113
  "none",
114
114
  "read",
115
115
  "write",
116
116
  "admin",
117
117
  ]);
118
- const AgentPermissionsSchema = z.object({
118
+ export const AgentPermissionsSchema = z.object({
119
119
  defaultLevel: AgentPermissionLevelSchema,
120
120
  actionOverrides: z.record(AgentPermissionLevelSchema).optional(),
121
121
  allowedCallers: z.array(z.string()).optional(),
@@ -128,12 +128,30 @@ const AgentPermissionsSchema = z.object({
128
128
  validUntil: iso8601Schema.optional(),
129
129
  consentActionScope: z.array(z.string().min(1)).optional(),
130
130
  });
131
- const WebhooksConfigSchema = z.object({
131
+ export const WebhooksConfigSchema = z.object({
132
132
  consentCallback: z.string().url().optional(),
133
133
  identityUrl: z.string().url().optional(),
134
134
  secret: z.string().optional(),
135
+ deeplinkCallback: z.string().url().optional(),
136
+ eventStream: z.string().url().optional(),
135
137
  });
136
- const WidgetConfigSchema = z.object({
138
+ export const ApprovalStepUpConfigSchema = z.object({
139
+ minSensitivity: SensitivityLevelSchema.optional().default('high'),
140
+ requireForSideEffects: z.boolean().optional().default(true),
141
+ sideEffectsMinSensitivity: SensitivityLevelSchema.optional().default('medium'),
142
+ });
143
+ export const ApprovalConfigSchema = z.object({
144
+ stepUp: ApprovalStepUpConfigSchema.optional().default({
145
+ minSensitivity: 'high',
146
+ requireForSideEffects: true,
147
+ sideEffectsMinSensitivity: 'medium',
148
+ }),
149
+ });
150
+ export const OperatorNotificationsConfigSchema = z.object({
151
+ approverEmails: z.array(z.string().email()).optional().default([]),
152
+ confirmationReminderLeadMinutes: z.number().int().positive().nullable().optional(),
153
+ });
154
+ export const WidgetConfigSchema = z.object({
137
155
  primaryColor: z.string().optional(),
138
156
  position: z
139
157
  .enum(["bottom-right", "bottom-left", "top-right", "top-left"])
@@ -161,10 +179,10 @@ const DataModelEntitySchema = z.object({
161
179
  labelKey: z.string().min(1),
162
180
  dimensions: z.array(z.string()).optional(),
163
181
  });
164
- const DataModelSchema = z.object({
182
+ export const DataModelSchema = z.object({
165
183
  entities: z.array(DataModelEntitySchema),
166
184
  });
167
- const ProductConfigSchema = z.object({
185
+ export const ProductConfigSchema = z.object({
168
186
  name: z.string().min(1),
169
187
  description: z.string().min(1),
170
188
  baseUrl: z.string().url(),
@@ -189,6 +207,8 @@ export const DuctConfigSchema = z.object({
189
207
  registry_visibility: z.enum(['public', 'private']).optional().default('private'),
190
208
  intershell_enabled: z.boolean().optional().default(false),
191
209
  webhooks: WebhooksConfigSchema.optional(),
210
+ approval: ApprovalConfigSchema.optional(),
211
+ operatorNotifications: OperatorNotificationsConfigSchema.optional(),
192
212
  });
193
213
  function zodIssuesToValidationIssues(errors) {
194
214
  return errors.map((e) => ({
@@ -321,7 +341,7 @@ export function crossValidateDuctConfig(data) {
321
341
  return issues;
322
342
  }
323
343
  /**
324
- * Validate a Duct config without throwing — used by `duct init` before writing files.
344
+ * Validate a Duct config without throwing — used by the CLI before writing files.
325
345
  */
326
346
  export function validateDuctConfigStrict(config) {
327
347
  const result = DuctConfigSchema.safeParse(config);
@@ -0,0 +1,3 @@
1
+ export declare function isPrivateOrLocalProductUrl(url: string): boolean;
2
+ export declare function hostedPrivateUpstreamMessage(apiUrl: string): string;
3
+ export declare function shouldWarnHostedPrivateUpstream(apiUrl: string): boolean;
@@ -0,0 +1,35 @@
1
+ import { isLocalDuctProfile, isLocalhostUrl } from './endpoint-guard.js';
2
+ const PRIVATE_HOST_PATTERNS = [
3
+ /^10\./,
4
+ /^192\.168\./,
5
+ /^172\.(1[6-9]|2\d|3[0-1])\./,
6
+ /^127\./,
7
+ /^0\./,
8
+ /^169\.254\./,
9
+ ];
10
+ export function isPrivateOrLocalProductUrl(url) {
11
+ if (!url.trim())
12
+ return false;
13
+ if (isLocalhostUrl(url))
14
+ return true;
15
+ try {
16
+ const host = new URL(url).hostname.toLowerCase();
17
+ return PRIVATE_HOST_PATTERNS.some((re) => re.test(host));
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
23
+ export function hostedPrivateUpstreamMessage(apiUrl) {
24
+ return (`Product API URL ${apiUrl} points at a private or local address while using hosted Duct. ` +
25
+ 'Hosted Duct cannot reach your machine directly. Expose your dev API with an HTTP tunnel, ' +
26
+ 'set product.apiBaseUrl to the public tunnel URL, and run checkup again. ' +
27
+ 'See /docs/local-development-hosted');
28
+ }
29
+ export function shouldWarnHostedPrivateUpstream(apiUrl) {
30
+ if (isLocalDuctProfile())
31
+ return false;
32
+ if ((process.env.DUCT_ALLOW_LOCALHOST ?? '').trim().toLowerCase() === 'true')
33
+ return false;
34
+ return isPrivateOrLocalProductUrl(apiUrl);
35
+ }
@@ -27,7 +27,7 @@ export declare const DEFAULT_LOGIN_HANDOFF_MESSAGE = "You'll need to sign in fir
27
27
  export declare function normalizeRoutePathForLogin(path: string): string;
28
28
  /**
29
29
  * Pick the best login route path from a manifest route inventory.
30
- * Used by `duct init` to populate `auth.loginRoutePath`.
30
+ * Used by `duct add identity` to populate `auth.loginRoutePath`.
31
31
  */
32
32
  export declare function detectLoginRoutePath(routes: LoginRouteLike[]): string | undefined;
33
33
  /**
@@ -37,7 +37,7 @@ function buildHandoffUrl(baseUrl, path) {
37
37
  }
38
38
  /**
39
39
  * Pick the best login route path from a manifest route inventory.
40
- * Used by `duct init` to populate `auth.loginRoutePath`.
40
+ * Used by `duct add identity` to populate `auth.loginRoutePath`.
41
41
  */
42
42
  export function detectLoginRoutePath(routes) {
43
43
  for (const route of routes) {