@duct-sdk/sdk 0.1.13 → 0.2.2
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 +36 -0
- package/README.md +33 -22
- package/dist/adapters/next/shell.d.ts +2 -3
- package/dist/adapters/next/shell.js +11 -4
- package/dist/adapters/react/shell.d.ts +2 -2
- package/dist/adapters/react/shell.js +2 -2
- package/dist/adapters/react/use-page-context.d.ts +1 -1
- package/dist/cli/detectors/topology.d.ts +20 -0
- package/dist/cli/detectors/topology.js +107 -0
- package/dist/cli/generators/config.js +4 -4
- package/dist/cli/generators/shell.js +6 -6
- package/dist/cli/index.js +141 -3
- package/dist/cli/init.js +2 -3
- package/dist/cli/prompts/review.d.ts +25 -0
- package/dist/cli/prompts/review.js +108 -2
- package/dist/cli/selectors/express.d.ts +12 -0
- package/dist/cli/selectors/express.js +117 -0
- package/dist/cli/selectors/fastapi.d.ts +12 -0
- package/dist/cli/selectors/fastapi.js +122 -0
- package/dist/cli/selectors/generic.d.ts +10 -0
- package/dist/cli/selectors/generic.js +74 -0
- package/dist/cli/selectors/index.d.ts +15 -0
- package/dist/cli/selectors/index.js +41 -0
- package/dist/cli/selectors/next.d.ts +12 -0
- package/dist/cli/selectors/next.js +130 -0
- package/dist/core/action.js +0 -2
- package/dist/core/config.d.ts +5 -5
- package/dist/core/config.js +2 -2
- package/dist/core/endpoints.js +2 -2
- package/dist/core/status.d.ts +2 -2
- package/dist/core/status.js +4 -2
- package/dist/core/types.d.ts +15 -11
- package/package.json +6 -3
- package/dist/assets/logo.d.ts +0 -1
- package/dist/assets/logo.js +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// @duct/sdk — Generic File Selector (fallback)
|
|
3
|
+
// Returns the top maxFiles .ts/.js/.py files sorted by file size
|
|
4
|
+
// (larger files are more likely to contain route definitions).
|
|
5
|
+
// ============================================================
|
|
6
|
+
import * as fs from "fs/promises";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import { glob } from "glob";
|
|
9
|
+
async function globFiles(root, pattern) {
|
|
10
|
+
try {
|
|
11
|
+
const matches = await glob(pattern, {
|
|
12
|
+
cwd: root,
|
|
13
|
+
ignore: [
|
|
14
|
+
"**/node_modules/**",
|
|
15
|
+
"**/.git/**",
|
|
16
|
+
"**/dist/**",
|
|
17
|
+
"**/build/**",
|
|
18
|
+
"**/out/**",
|
|
19
|
+
"**/.next/**",
|
|
20
|
+
"**/__pycache__/**",
|
|
21
|
+
"**/.venv/**",
|
|
22
|
+
"**/venv/**",
|
|
23
|
+
"**/*.test.{ts,js}",
|
|
24
|
+
"**/*.spec.{ts,js}",
|
|
25
|
+
"**/*.d.ts",
|
|
26
|
+
],
|
|
27
|
+
nodir: true,
|
|
28
|
+
absolute: false,
|
|
29
|
+
});
|
|
30
|
+
return matches;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function getFileSize(filePath) {
|
|
37
|
+
try {
|
|
38
|
+
const s = await fs.stat(filePath);
|
|
39
|
+
return s.size;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// ----------------------------------------------------------------
|
|
46
|
+
// Generic selector — main export
|
|
47
|
+
// ----------------------------------------------------------------
|
|
48
|
+
/**
|
|
49
|
+
* Generic fallback file selector.
|
|
50
|
+
*
|
|
51
|
+
* Returns the top `maxFiles` .ts/.js/.py files sorted by file size descending
|
|
52
|
+
* (larger files are more likely to contain route/handler definitions).
|
|
53
|
+
*
|
|
54
|
+
* @param projectRoot Absolute project root path
|
|
55
|
+
* @param maxFiles Maximum total files to return (default 30)
|
|
56
|
+
*/
|
|
57
|
+
export async function selectGenericFiles(projectRoot, maxFiles = 30) {
|
|
58
|
+
const allFiles = [];
|
|
59
|
+
const tsFiles = await globFiles(projectRoot, "**/*.{ts,tsx}");
|
|
60
|
+
const jsFiles = await globFiles(projectRoot, "**/*.{js,jsx,mjs}");
|
|
61
|
+
const pyFiles = await globFiles(projectRoot, "**/*.py");
|
|
62
|
+
allFiles.push(...tsFiles, ...jsFiles, ...pyFiles);
|
|
63
|
+
if (allFiles.length === 0)
|
|
64
|
+
return [];
|
|
65
|
+
// Deduplicate
|
|
66
|
+
const unique = [...new Set(allFiles)];
|
|
67
|
+
// Sort by file size descending — larger = more likely to contain route definitions
|
|
68
|
+
const sized = await Promise.all(unique.map(async (f) => ({
|
|
69
|
+
f,
|
|
70
|
+
size: await getFileSize(path.join(projectRoot, f)),
|
|
71
|
+
})));
|
|
72
|
+
sized.sort((a, b) => b.size - a.size);
|
|
73
|
+
return sized.slice(0, maxFiles).map((s) => s.f);
|
|
74
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { SandboxFS } from "../fs/sandbox.js";
|
|
2
2
|
import type { TopoResult } from "../detectors/topology.js";
|
|
3
|
+
export { selectNextFiles } from "./next.js";
|
|
4
|
+
export { selectExpressFiles } from "./express.js";
|
|
5
|
+
export { selectFastApiFiles } from "./fastapi.js";
|
|
6
|
+
export { selectGenericFiles } from "./generic.js";
|
|
3
7
|
/** Per-agent bounded file list, max MAX_FILES_PER_LIST entries each. */
|
|
4
8
|
export interface ReadList {
|
|
5
9
|
/** Files for the Route Agent — page files, layouts */
|
|
@@ -9,6 +13,17 @@ export interface ReadList {
|
|
|
9
13
|
/** Files for the Auth Agent — middleware, auth config, env examples */
|
|
10
14
|
authFiles: string[];
|
|
11
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Select the most relevant source files for a given project topology.
|
|
18
|
+
*
|
|
19
|
+
* Returns a flat, deduplicated list of relative file paths capped at
|
|
20
|
+
* `maxFiles`. Files are ordered by relevance: API routes first, then
|
|
21
|
+
* type definitions, then entry points / middleware.
|
|
22
|
+
*
|
|
23
|
+
* Delegates to framework-specific selectors (next, express, fastapi) or
|
|
24
|
+
* falls back to the generic size-ranked selector for unknown stacks.
|
|
25
|
+
*/
|
|
26
|
+
export declare function selectFilesForFramework(topo: TopoResult, maxFiles?: number): Promise<string[]>;
|
|
12
27
|
/**
|
|
13
28
|
* Build a bounded ReadList per agent from the project's topology.
|
|
14
29
|
*
|
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
// Builds a bounded ReadList per agent from a TopoResult.
|
|
4
4
|
// No LLM. Max MAX_FILES_PER_LIST files per agent list.
|
|
5
5
|
// ============================================================
|
|
6
|
+
import { selectNextFiles } from "./next.js";
|
|
7
|
+
import { selectExpressFiles } from "./express.js";
|
|
8
|
+
import { selectFastApiFiles } from "./fastapi.js";
|
|
9
|
+
import { selectGenericFiles } from "./generic.js";
|
|
10
|
+
export { selectNextFiles } from "./next.js";
|
|
11
|
+
export { selectExpressFiles } from "./express.js";
|
|
12
|
+
export { selectFastApiFiles } from "./fastapi.js";
|
|
13
|
+
export { selectGenericFiles } from "./generic.js";
|
|
6
14
|
const MAX_FILES_PER_LIST = 30;
|
|
7
15
|
// ----------------------------------------------------------------
|
|
8
16
|
// Ranking helpers
|
|
@@ -236,6 +244,39 @@ async function selectGenericFallback(sandboxFs, apiRoot) {
|
|
|
236
244
|
};
|
|
237
245
|
}
|
|
238
246
|
// ----------------------------------------------------------------
|
|
247
|
+
// selectFilesForFramework — flat file list for downstream consumers
|
|
248
|
+
// ----------------------------------------------------------------
|
|
249
|
+
/**
|
|
250
|
+
* Select the most relevant source files for a given project topology.
|
|
251
|
+
*
|
|
252
|
+
* Returns a flat, deduplicated list of relative file paths capped at
|
|
253
|
+
* `maxFiles`. Files are ordered by relevance: API routes first, then
|
|
254
|
+
* type definitions, then entry points / middleware.
|
|
255
|
+
*
|
|
256
|
+
* Delegates to framework-specific selectors (next, express, fastapi) or
|
|
257
|
+
* falls back to the generic size-ranked selector for unknown stacks.
|
|
258
|
+
*/
|
|
259
|
+
export async function selectFilesForFramework(topo, maxFiles = 30) {
|
|
260
|
+
const root = topo.projectRoot ?? process.cwd();
|
|
261
|
+
switch (topo.framework) {
|
|
262
|
+
case "next-app":
|
|
263
|
+
case "next-pages":
|
|
264
|
+
return selectNextFiles(root, maxFiles);
|
|
265
|
+
case "remix":
|
|
266
|
+
case "sveltekit":
|
|
267
|
+
case "nuxt":
|
|
268
|
+
case "vue3":
|
|
269
|
+
case "vite-react":
|
|
270
|
+
// These frameworks share the Express-like pattern for backend selection
|
|
271
|
+
return selectExpressFiles(root, maxFiles);
|
|
272
|
+
default:
|
|
273
|
+
if (topo.language === "python") {
|
|
274
|
+
return selectFastApiFiles(root, maxFiles);
|
|
275
|
+
}
|
|
276
|
+
return selectGenericFiles(root, maxFiles);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// ----------------------------------------------------------------
|
|
239
280
|
// buildReadList — main export
|
|
240
281
|
// ----------------------------------------------------------------
|
|
241
282
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Select files for Next.js projects (App Router + Pages Router).
|
|
3
|
+
*
|
|
4
|
+
* Priority:
|
|
5
|
+
* 1. API route files: app/api/.../route.ts, pages/api/...ts
|
|
6
|
+
* 2. Type files: types/...ts, lib/types.ts, src/types.ts
|
|
7
|
+
* 3. Auth middleware: middleware.ts, app/middleware.ts
|
|
8
|
+
*
|
|
9
|
+
* @param projectRoot Absolute project root path
|
|
10
|
+
* @param maxFiles Maximum total files to return (default 30)
|
|
11
|
+
*/
|
|
12
|
+
export declare function selectNextFiles(projectRoot: string, maxFiles?: number): Promise<string[]>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// @duct/sdk — Next.js File Selector
|
|
3
|
+
// Selects API routes, type files, and auth middleware for Next.js projects.
|
|
4
|
+
// ============================================================
|
|
5
|
+
import * as fs from "fs/promises";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
import { glob } from "glob";
|
|
8
|
+
const EXCLUDED_DIRS = new Set([
|
|
9
|
+
"node_modules",
|
|
10
|
+
".next",
|
|
11
|
+
"dist",
|
|
12
|
+
"build",
|
|
13
|
+
"out",
|
|
14
|
+
".turbo",
|
|
15
|
+
".vercel",
|
|
16
|
+
".cache",
|
|
17
|
+
"coverage",
|
|
18
|
+
]);
|
|
19
|
+
async function dirExists(dirPath) {
|
|
20
|
+
try {
|
|
21
|
+
const s = await fs.stat(dirPath);
|
|
22
|
+
return s.isDirectory();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function fileExists(filePath) {
|
|
29
|
+
try {
|
|
30
|
+
await fs.access(filePath);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Collect file paths matching a glob pattern under a project root.
|
|
39
|
+
* Filters out excluded directories and non-existent paths.
|
|
40
|
+
*/
|
|
41
|
+
async function globFiles(root, pattern) {
|
|
42
|
+
try {
|
|
43
|
+
const matches = await glob(pattern, {
|
|
44
|
+
cwd: root,
|
|
45
|
+
ignore: ["**/node_modules/**", "**/.next/**", "**/dist/**", "**/build/**", "**/out/**"],
|
|
46
|
+
nodir: true,
|
|
47
|
+
absolute: false,
|
|
48
|
+
});
|
|
49
|
+
return matches.sort();
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function getFileSize(filePath) {
|
|
56
|
+
try {
|
|
57
|
+
const s = await fs.stat(filePath);
|
|
58
|
+
return s.size;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Sort files by priority (ascending size = more focused), limit to maxFiles.
|
|
66
|
+
*/
|
|
67
|
+
async function limitFiles(root, files, maxFiles) {
|
|
68
|
+
if (files.length <= maxFiles)
|
|
69
|
+
return files;
|
|
70
|
+
const sized = await Promise.all(files.map(async (f) => ({ f, size: await getFileSize(path.join(root, f)) })));
|
|
71
|
+
sized.sort((a, b) => a.size - b.size);
|
|
72
|
+
return sized.slice(0, maxFiles).map((s) => s.f);
|
|
73
|
+
}
|
|
74
|
+
// ----------------------------------------------------------------
|
|
75
|
+
// Next.js selector — main export
|
|
76
|
+
// ----------------------------------------------------------------
|
|
77
|
+
/**
|
|
78
|
+
* Select files for Next.js projects (App Router + Pages Router).
|
|
79
|
+
*
|
|
80
|
+
* Priority:
|
|
81
|
+
* 1. API route files: app/api/.../route.ts, pages/api/...ts
|
|
82
|
+
* 2. Type files: types/...ts, lib/types.ts, src/types.ts
|
|
83
|
+
* 3. Auth middleware: middleware.ts, app/middleware.ts
|
|
84
|
+
*
|
|
85
|
+
* @param projectRoot Absolute project root path
|
|
86
|
+
* @param maxFiles Maximum total files to return (default 30)
|
|
87
|
+
*/
|
|
88
|
+
export async function selectNextFiles(projectRoot, maxFiles = 30) {
|
|
89
|
+
const priority1 = [];
|
|
90
|
+
const priority2 = [];
|
|
91
|
+
const priority3 = [];
|
|
92
|
+
// ── Priority 1: API route files ─────────────────────────────
|
|
93
|
+
const appDir = (await dirExists(path.join(projectRoot, "src/app"))) ? "src/app" : "app";
|
|
94
|
+
const pagesDir = (await dirExists(path.join(projectRoot, "src/pages"))) ? "src/pages" : "pages";
|
|
95
|
+
const appApiRoutes = await globFiles(projectRoot, `${appDir}/api/**/route.{ts,tsx,js}`);
|
|
96
|
+
const pagesApiRoutes = await globFiles(projectRoot, `${pagesDir}/api/**/*.{ts,js}`);
|
|
97
|
+
priority1.push(...appApiRoutes, ...pagesApiRoutes);
|
|
98
|
+
// ── Priority 2: Type definition files ───────────────────────
|
|
99
|
+
const typeFiles = await globFiles(projectRoot, "types/**/*.ts");
|
|
100
|
+
const libTypes = await globFiles(projectRoot, "lib/types*.ts");
|
|
101
|
+
const srcTypes = await globFiles(projectRoot, "src/types*.ts");
|
|
102
|
+
const appTypes = await globFiles(projectRoot, `${appDir}/**/types*.{ts,tsx}`);
|
|
103
|
+
priority2.push(...typeFiles, ...libTypes, ...srcTypes, ...appTypes);
|
|
104
|
+
// ── Priority 3: Auth middleware ──────────────────────────────
|
|
105
|
+
const authCandidates = [
|
|
106
|
+
"middleware.ts",
|
|
107
|
+
"middleware.js",
|
|
108
|
+
"src/middleware.ts",
|
|
109
|
+
"src/middleware.js",
|
|
110
|
+
`${appDir}/middleware.ts`,
|
|
111
|
+
"auth.ts",
|
|
112
|
+
"auth.config.ts",
|
|
113
|
+
];
|
|
114
|
+
for (const candidate of authCandidates) {
|
|
115
|
+
if (await fileExists(path.join(projectRoot, candidate))) {
|
|
116
|
+
priority3.push(candidate);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// ── Combine + deduplicate + limit ───────────────────────────
|
|
120
|
+
const seen = new Set();
|
|
121
|
+
const combined = [];
|
|
122
|
+
for (const f of [...priority1, ...priority2, ...priority3]) {
|
|
123
|
+
if (!seen.has(f)) {
|
|
124
|
+
seen.add(f);
|
|
125
|
+
combined.push(f);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return limitFiles(projectRoot, combined, maxFiles);
|
|
129
|
+
}
|
|
130
|
+
void EXCLUDED_DIRS; // referenced implicitly via glob ignore patterns
|
package/dist/core/action.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// ============================================================
|
|
2
2
|
// @duct/sdk — buildAction() factory
|
|
3
|
-
// Mirrors the buildTool() pattern from the miniclaude reference.
|
|
4
3
|
// Fail-closed defaults: denies agents when !agentAccessible,
|
|
5
4
|
// denies side-effects without user_consent_token, upgrades
|
|
6
5
|
// high/critical sensitivity to 'ask'.
|
|
7
|
-
// See duct-technical-spec.md §13.1
|
|
8
6
|
// ============================================================
|
|
9
7
|
// ----------------------------------------------------------------
|
|
10
8
|
// checkActionPermission — three-tier rule model
|
package/dist/core/config.d.ts
CHANGED
|
@@ -263,20 +263,20 @@ export declare const DuctConfigSchema: z.ZodObject<{
|
|
|
263
263
|
agentPermissions: z.ZodObject<{
|
|
264
264
|
defaultLevel: z.ZodEnum<["none", "read", "write", "admin"]>;
|
|
265
265
|
actionOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<["none", "read", "write", "admin"]>>>;
|
|
266
|
-
|
|
266
|
+
allowedCallers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
267
267
|
requireUserConsent: z.ZodBoolean;
|
|
268
268
|
allowedActions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
269
269
|
}, "strip", z.ZodTypeAny, {
|
|
270
270
|
defaultLevel: "none" | "read" | "write" | "admin";
|
|
271
271
|
requireUserConsent: boolean;
|
|
272
272
|
actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
|
|
273
|
-
|
|
273
|
+
allowedCallers?: string[] | undefined;
|
|
274
274
|
allowedActions?: string[] | undefined;
|
|
275
275
|
}, {
|
|
276
276
|
defaultLevel: "none" | "read" | "write" | "admin";
|
|
277
277
|
requireUserConsent: boolean;
|
|
278
278
|
actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
|
|
279
|
-
|
|
279
|
+
allowedCallers?: string[] | undefined;
|
|
280
280
|
allowedActions?: string[] | undefined;
|
|
281
281
|
}>;
|
|
282
282
|
widget: z.ZodOptional<z.ZodObject<{
|
|
@@ -381,7 +381,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
|
|
|
381
381
|
defaultLevel: "none" | "read" | "write" | "admin";
|
|
382
382
|
requireUserConsent: boolean;
|
|
383
383
|
actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
|
|
384
|
-
|
|
384
|
+
allowedCallers?: string[] | undefined;
|
|
385
385
|
allowedActions?: string[] | undefined;
|
|
386
386
|
};
|
|
387
387
|
widget?: {
|
|
@@ -414,7 +414,7 @@ export declare const DuctConfigSchema: z.ZodObject<{
|
|
|
414
414
|
defaultLevel: "none" | "read" | "write" | "admin";
|
|
415
415
|
requireUserConsent: boolean;
|
|
416
416
|
actionOverrides?: Record<string, "none" | "read" | "write" | "admin"> | undefined;
|
|
417
|
-
|
|
417
|
+
allowedCallers?: string[] | undefined;
|
|
418
418
|
allowedActions?: string[] | undefined;
|
|
419
419
|
};
|
|
420
420
|
routes?: {
|
package/dist/core/config.js
CHANGED
|
@@ -121,7 +121,7 @@ const AgentPermissionLevelSchema = z.enum([
|
|
|
121
121
|
const AgentPermissionsSchema = z.object({
|
|
122
122
|
defaultLevel: AgentPermissionLevelSchema,
|
|
123
123
|
actionOverrides: z.record(AgentPermissionLevelSchema).optional(),
|
|
124
|
-
|
|
124
|
+
allowedCallers: z.array(z.string()).optional(),
|
|
125
125
|
requireUserConsent: z.boolean(),
|
|
126
126
|
allowedActions: z.array(z.string()).optional(),
|
|
127
127
|
});
|
|
@@ -193,7 +193,7 @@ export function defineDuctConfig(config) {
|
|
|
193
193
|
const formatted = result.error.errors
|
|
194
194
|
.map((e) => ` • [${e.path.join(".")}] ${e.message}`)
|
|
195
195
|
.join("\n");
|
|
196
|
-
throw new Error(`Invalid Duct configuration:\n${formatted}\n\nSee
|
|
196
|
+
throw new Error(`Invalid Duct configuration:\n${formatted}\n\nSee your Duct docs /config reference for details.`);
|
|
197
197
|
}
|
|
198
198
|
// Cross-validate: deeplink target routes must exist in routes list
|
|
199
199
|
const routePaths = new Set(result.data.routes.map((r) => r.path));
|
package/dist/core/endpoints.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// Override any individual service URL explicitly if needed:
|
|
8
8
|
// DUCT_AUTH_URL — auth service (default: {base}/auth or :3001)
|
|
9
|
-
// DUCT_API_URL —
|
|
9
|
+
// DUCT_API_URL — Duct API (default: {base}/api or :3002)
|
|
10
10
|
// DUCT_SHELL_URL — shell runtime (default: {base}/shell or :3000)
|
|
11
11
|
// DUCT_REGISTRY_URL — shell registry (default: {base}/registry or :3003)
|
|
12
12
|
// DUCT_DASHBOARD_URL— dashboard (default: {base}/dash or :3004)
|
|
@@ -85,7 +85,7 @@ export function getActiveAuthBase(profile) {
|
|
|
85
85
|
return candidates[0] ?? "http://localhost:3001";
|
|
86
86
|
}
|
|
87
87
|
export function getManifestApiBase(profile) {
|
|
88
|
-
// Manifest
|
|
88
|
+
// Manifest is served from the Duct API base
|
|
89
89
|
const bases = getManifestApiBases(profile);
|
|
90
90
|
return bases[0] ?? "http://localhost:3002";
|
|
91
91
|
}
|
package/dist/core/status.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export interface ShellStatus {
|
|
|
15
15
|
}
|
|
16
16
|
export interface CheckShellStatusOptions {
|
|
17
17
|
/**
|
|
18
|
-
* Override the
|
|
19
|
-
* Defaults to
|
|
18
|
+
* Override the Duct API base URL.
|
|
19
|
+
* Defaults to DUCT_API_URL (or DUCT_AGENT_PROXY_URL) → http://localhost:3002
|
|
20
20
|
*/
|
|
21
21
|
agentProxyUrl?: string;
|
|
22
22
|
/** Fetch timeout in milliseconds. Defaults to 5000. */
|
package/dist/core/status.js
CHANGED
|
@@ -17,8 +17,10 @@
|
|
|
17
17
|
*/
|
|
18
18
|
export async function checkShellStatus(shellId, options = {}) {
|
|
19
19
|
const base = options.agentProxyUrl ??
|
|
20
|
-
(typeof process !== 'undefined'
|
|
21
|
-
|
|
20
|
+
(typeof process !== 'undefined'
|
|
21
|
+
? process.env?.['DUCT_API_URL'] ?? process.env?.['DUCT_AGENT_PROXY_URL']
|
|
22
|
+
: undefined) ??
|
|
23
|
+
'http://localhost:3002';
|
|
22
24
|
const url = `${base.replace(/\/$/, '')}/v1/shells/${shellId}/status`;
|
|
23
25
|
const controller = new AbortController();
|
|
24
26
|
const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? 5000);
|
package/dist/core/types.d.ts
CHANGED
|
@@ -34,12 +34,12 @@ export interface RouteManifest {
|
|
|
34
34
|
updatedAt?: string;
|
|
35
35
|
/** Agent detection confidence (0.0–1.0). */
|
|
36
36
|
confidence?: number;
|
|
37
|
-
/**
|
|
38
|
-
evidence?: string;
|
|
37
|
+
/** Files and signals that led to this route being detected (e.g. "app/api/orders/route.ts:12"). */
|
|
38
|
+
evidence?: string[];
|
|
39
39
|
/**
|
|
40
40
|
* Maps URL query params to an action for structured data access.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* When set, the shell invokes this action instead of firing a deeplink handoff
|
|
42
|
+
* for data_query intents on this route — keeping users in-shell with rich results.
|
|
43
43
|
*/
|
|
44
44
|
searchAction?: {
|
|
45
45
|
actionId: string;
|
|
@@ -90,8 +90,8 @@ export interface ActionManifest {
|
|
|
90
90
|
updatedAt?: string;
|
|
91
91
|
/** Agent detection confidence (0.0–1.0). */
|
|
92
92
|
confidence?: number;
|
|
93
|
-
/**
|
|
94
|
-
evidence?: string;
|
|
93
|
+
/** Files and signals that led to this action being detected (e.g. "routes/orders.ts:42"). */
|
|
94
|
+
evidence?: string[];
|
|
95
95
|
/**
|
|
96
96
|
* Declares that this action depends on results from other actions.
|
|
97
97
|
* Forms a DAG; shell runtime traverses it via topological sort.
|
|
@@ -124,6 +124,10 @@ export interface AuthSchema {
|
|
|
124
124
|
tokenEndpoint?: string;
|
|
125
125
|
/** Custom claims added to tokens */
|
|
126
126
|
customClaims?: Record<string, string>;
|
|
127
|
+
/** Agent detection confidence (0.0–1.0). */
|
|
128
|
+
confidence?: number;
|
|
129
|
+
/** Files and signals that led to this auth strategy being detected. */
|
|
130
|
+
evidence?: string[];
|
|
127
131
|
}
|
|
128
132
|
export interface StateField {
|
|
129
133
|
key: string;
|
|
@@ -182,7 +186,7 @@ export interface AgentPermissions {
|
|
|
182
186
|
/** Per-action overrides */
|
|
183
187
|
actionOverrides?: Record<string, AgentPermissionLevel>;
|
|
184
188
|
/** List of allowed agent/shell IDs */
|
|
185
|
-
|
|
189
|
+
allowedCallers?: string[];
|
|
186
190
|
/** Whether to require explicit user consent for agent actions */
|
|
187
191
|
requireUserConsent: boolean;
|
|
188
192
|
/** Allowed actions (action IDs) */
|
|
@@ -317,9 +321,9 @@ export interface DuctConfig {
|
|
|
317
321
|
/** Shell widget display config */
|
|
318
322
|
widget?: WidgetConfig;
|
|
319
323
|
/**
|
|
320
|
-
* Backend data entity declarations
|
|
321
|
-
*
|
|
322
|
-
*
|
|
324
|
+
* Backend data entity declarations — links entity types to discovery/fetch actions.
|
|
325
|
+
* Powers automatic entity resolution in multi-step agent loops.
|
|
326
|
+
* Declare your entities now; runtime enforcement is in active development.
|
|
323
327
|
*/
|
|
324
328
|
dataModel?: DataModel;
|
|
325
329
|
}
|
|
@@ -464,7 +468,7 @@ export interface ActionRuntimeFields {
|
|
|
464
468
|
}
|
|
465
469
|
/**
|
|
466
470
|
* ActionDef = manifest data + runtime callbacks.
|
|
467
|
-
* Produced by buildAction(). Used
|
|
471
|
+
* Produced by buildAction(). Used by the SDK and Duct platform at invoke time.
|
|
468
472
|
*
|
|
469
473
|
* Use BuiltActionDef when you know the value came from buildAction() and
|
|
470
474
|
* want the compiler to enforce that validateInput and checkPermissions are present.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duct-sdk/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
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",
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsc",
|
|
21
|
-
"dev": "tsc --watch"
|
|
21
|
+
"dev": "tsc --watch",
|
|
22
|
+
"verify:publish": "node scripts/verify-publish.mjs",
|
|
23
|
+
"prepublishOnly": "npm run build && npm run verify:publish"
|
|
22
24
|
},
|
|
23
25
|
"dependencies": {
|
|
24
26
|
"@anthropic-ai/sdk": "^0.24.0",
|
|
@@ -59,7 +61,8 @@
|
|
|
59
61
|
},
|
|
60
62
|
"files": [
|
|
61
63
|
"dist",
|
|
62
|
-
"README.md"
|
|
64
|
+
"README.md",
|
|
65
|
+
"CHANGELOG.md"
|
|
63
66
|
],
|
|
64
67
|
"keywords": [
|
|
65
68
|
"duct",
|