@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.
- package/CHANGELOG.md +385 -336
- package/README.md +418 -264
- package/TOKEN_SPEC.md +243 -237
- package/dist/cli/add.d.ts +7 -0
- package/dist/cli/add.js +152 -0
- package/dist/cli/agent-prompt.d.ts +3 -0
- package/dist/cli/agent-prompt.js +39 -0
- package/dist/cli/api-sources.d.ts +26 -0
- package/dist/cli/api-sources.js +222 -0
- package/dist/cli/cloud.d.ts +133 -0
- package/dist/cli/cloud.js +298 -0
- package/dist/cli/config-loader.d.ts +14 -0
- package/dist/cli/config-loader.js +56 -7
- package/dist/cli/device-login.d.ts +17 -0
- package/dist/cli/device-login.js +75 -0
- package/dist/cli/drift.js +6 -6
- package/dist/cli/generators/any-stack.d.ts +3 -0
- package/dist/cli/generators/any-stack.js +97 -0
- package/dist/cli/generators/config.js +3 -2
- package/dist/cli/generators/receiver.js +7 -7
- package/dist/cli/generators/shell.js +12 -12
- package/dist/cli/generators/token-route.js +245 -245
- package/dist/cli/index.js +402 -611
- package/dist/cli/mcp-core.d.ts +42 -0
- package/dist/cli/mcp-core.js +161 -0
- package/dist/cli/mcp-setup.d.ts +4 -0
- package/dist/cli/mcp-setup.js +360 -0
- package/dist/cli/mcp.d.ts +2 -0
- package/dist/cli/mcp.js +457 -0
- package/dist/cli/migrate-intershell.js +5 -5
- package/dist/cli/policy-defaults.d.ts +37 -0
- package/dist/cli/policy-defaults.js +127 -0
- package/dist/cli/processors/integration-audit.js +2 -2
- package/dist/cli/processors/openapi-parser.d.ts +5 -0
- package/dist/cli/processors/openapi-parser.js +8 -3
- package/dist/cli/project-loader.d.ts +58 -0
- package/dist/cli/project-loader.js +198 -0
- package/dist/cli/project-writer.d.ts +23 -0
- package/dist/cli/project-writer.js +171 -0
- package/dist/cli/push.d.ts +43 -0
- package/dist/cli/push.js +276 -0
- package/dist/cli/safety-checks.d.ts +9 -0
- package/dist/cli/safety-checks.js +29 -0
- package/dist/cli/setup.d.ts +20 -0
- package/dist/cli/setup.js +349 -0
- package/dist/cli/shell-name.d.ts +8 -0
- package/dist/cli/shell-name.js +29 -0
- package/dist/cli/shells.d.ts +22 -0
- package/dist/cli/shells.js +122 -0
- package/dist/cli/split.d.ts +7 -0
- package/dist/cli/split.js +71 -0
- package/dist/cli/sync.d.ts +25 -0
- package/dist/cli/sync.js +120 -0
- package/dist/cli/test-runner.d.ts +21 -0
- package/dist/cli/test-runner.js +281 -0
- package/dist/core/compile.d.ts +43 -0
- package/dist/core/compile.js +510 -0
- package/dist/core/config.d.ts +533 -1
- package/dist/core/config.js +32 -12
- package/dist/core/hosted-upstream-check.d.ts +3 -0
- package/dist/core/hosted-upstream-check.js +35 -0
- package/dist/core/login-handoff.d.ts +1 -1
- package/dist/core/login-handoff.js +1 -1
- package/dist/core/project.d.ts +1798 -0
- package/dist/core/project.js +278 -0
- package/dist/core/readiness-checks.js +2 -2
- package/dist/core/types.d.ts +26 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +16 -0
- package/dist/project.d.ts +4 -0
- package/dist/project.js +8 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +1 -0
- package/fixtures/token-conformance-vectors.json +26 -0
- package/package.json +94 -94
- package/dist/adapters/react/page-context-guard.test.d.ts +0 -1
- package/dist/adapters/react/page-context-guard.test.js +0 -15
- package/dist/cli/agents/api-agent.d.ts +0 -22
- package/dist/cli/agents/api-agent.js +0 -761
- package/dist/cli/agents/auth-agent.d.ts +0 -7
- package/dist/cli/agents/auth-agent.js +0 -212
- package/dist/cli/agents/deeplink-agent.d.ts +0 -6
- package/dist/cli/agents/deeplink-agent.js +0 -285
- package/dist/cli/agents/llm.d.ts +0 -33
- package/dist/cli/agents/llm.js +0 -309
- package/dist/cli/agents/pipeline.d.ts +0 -72
- package/dist/cli/agents/pipeline.js +0 -421
- package/dist/cli/agents/reviewer-agent.d.ts +0 -13
- package/dist/cli/agents/reviewer-agent.js +0 -450
- package/dist/cli/agents/route-agent.d.ts +0 -17
- package/dist/cli/agents/route-agent.js +0 -383
- package/dist/cli/config-loader.test.d.ts +0 -1
- package/dist/cli/config-loader.test.js +0 -63
- package/dist/cli/detectors/topology.d.ts +0 -46
- package/dist/cli/detectors/topology.js +0 -417
- package/dist/cli/generators/config.test.d.ts +0 -1
- package/dist/cli/generators/config.test.js +0 -222
- package/dist/cli/generators/shell.test.d.ts +0 -1
- package/dist/cli/generators/shell.test.js +0 -73
- package/dist/cli/generators/token-route.test.d.ts +0 -1
- package/dist/cli/generators/token-route.test.js +0 -53
- package/dist/cli/generators/wiring-snippets.test.d.ts +0 -1
- package/dist/cli/generators/wiring-snippets.test.js +0 -80
- package/dist/cli/init.d.ts +0 -32
- package/dist/cli/init.js +0 -1336
- package/dist/cli/manifest-diff.test.d.ts +0 -1
- package/dist/cli/manifest-diff.test.js +0 -144
- package/dist/cli/processors/curl-parser.test.d.ts +0 -1
- package/dist/cli/processors/curl-parser.test.js +0 -24
- package/dist/cli/processors/integration-audit.test.d.ts +0 -1
- package/dist/cli/processors/integration-audit.test.js +0 -154
- package/dist/cli/processors/postprocess.d.ts +0 -22
- package/dist/cli/processors/postprocess.js +0 -107
- package/dist/cli/processors/prisma-parser.d.ts +0 -35
- package/dist/cli/processors/prisma-parser.js +0 -117
- package/dist/cli/processors/verify-discovery.d.ts +0 -33
- package/dist/cli/processors/verify-discovery.js +0 -193
- package/dist/cli/processors/verify-discovery.test.d.ts +0 -1
- package/dist/cli/processors/verify-discovery.test.js +0 -153
- package/dist/cli/processors/zod-extractor.d.ts +0 -27
- package/dist/cli/processors/zod-extractor.js +0 -153
- package/dist/cli/prompts/review.d.ts +0 -61
- package/dist/cli/prompts/review.js +0 -410
- package/dist/cli/selectors/express.d.ts +0 -12
- package/dist/cli/selectors/express.js +0 -117
- package/dist/cli/selectors/fastapi.d.ts +0 -12
- package/dist/cli/selectors/fastapi.js +0 -122
- package/dist/cli/selectors/generic.d.ts +0 -10
- package/dist/cli/selectors/generic.js +0 -74
- package/dist/cli/selectors/index.d.ts +0 -37
- package/dist/cli/selectors/index.js +0 -315
- package/dist/cli/selectors/next.d.ts +0 -12
- package/dist/cli/selectors/next.js +0 -130
- package/dist/core/config-policy.test.d.ts +0 -1
- package/dist/core/config-policy.test.js +0 -101
- package/dist/core/config-roundtrip.test.d.ts +0 -1
- package/dist/core/config-roundtrip.test.js +0 -180
- package/dist/core/endpoint-guard.test.d.ts +0 -1
- package/dist/core/endpoint-guard.test.js +0 -57
- package/dist/core/env-diagnostics.test.d.ts +0 -1
- package/dist/core/env-diagnostics.test.js +0 -31
- package/dist/core/evidence-bundle.conformance.test.d.ts +0 -1
- package/dist/core/evidence-bundle.conformance.test.js +0 -110
- package/dist/core/evidence-bundle.test.d.ts +0 -1
- package/dist/core/evidence-bundle.test.js +0 -58
- package/dist/core/invariants.test.d.ts +0 -1
- package/dist/core/invariants.test.js +0 -217
- package/dist/core/login-handoff.test.d.ts +0 -1
- package/dist/core/login-handoff.test.js +0 -31
- package/dist/core/profile.test.d.ts +0 -1
- package/dist/core/profile.test.js +0 -95
- package/dist/core/readiness-checks.test.d.ts +0 -1
- package/dist/core/readiness-checks.test.js +0 -106
- package/dist/core/receipt.test.d.ts +0 -1
- package/dist/core/receipt.test.js +0 -75
- package/dist/core/side-effects-review.test.d.ts +0 -1
- package/dist/core/side-effects-review.test.js +0 -28
- package/dist/core/token.test.d.ts +0 -1
- package/dist/core/token.test.js +0 -66
package/dist/core/config.js
CHANGED
|
@@ -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
|
|
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
|
|
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,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
|
|
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
|
|
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) {
|