@duct-sdk/sdk 0.5.4 → 0.5.9
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 +29 -0
- package/README.md +10 -10
- package/dist/cli/index.js +179 -36
- package/dist/core/config-roundtrip.test.d.ts +1 -0
- package/dist/core/config-roundtrip.test.js +132 -0
- package/dist/core/config.d.ts +253 -25
- package/dist/core/config.js +31 -67
- package/dist/core/endpoint-guard.d.ts +27 -0
- package/dist/core/endpoint-guard.js +71 -0
- package/dist/core/endpoint-guard.test.d.ts +1 -0
- package/dist/core/endpoint-guard.test.js +57 -0
- package/dist/core/env-diagnostics.d.ts +13 -0
- package/dist/core/env-diagnostics.js +63 -0
- package/dist/core/env-diagnostics.test.d.ts +1 -0
- package/dist/core/env-diagnostics.test.js +31 -0
- package/dist/core/profile.d.ts +44 -0
- package/dist/core/profile.js +128 -0
- package/dist/core/profile.test.d.ts +1 -0
- package/dist/core/profile.test.js +95 -0
- package/dist/core/readiness-checks.d.ts +113 -0
- package/dist/core/readiness-checks.js +110 -0
- package/dist/core/readiness-checks.test.d.ts +1 -0
- package/dist/core/readiness-checks.test.js +49 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, it, beforeEach, afterEach } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { applyActiveProfileEnvSync, applyProfileUrlsToEnv, listProfileNames, readProfileFileSync, resolveActiveProfileName, resolveProfileUrls, setActiveProfileSync, writeProfileFileSync, } from "./profile.js";
|
|
7
|
+
const ORIGINAL_ENV = { ...process.env };
|
|
8
|
+
function restoreEnv() {
|
|
9
|
+
for (const key of Object.keys(process.env)) {
|
|
10
|
+
if (!(key in ORIGINAL_ENV))
|
|
11
|
+
delete process.env[key];
|
|
12
|
+
}
|
|
13
|
+
for (const [key, value] of Object.entries(ORIGINAL_ENV)) {
|
|
14
|
+
if (value === undefined)
|
|
15
|
+
delete process.env[key];
|
|
16
|
+
else
|
|
17
|
+
process.env[key] = value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
describe("profile discovery", () => {
|
|
21
|
+
let tempDir;
|
|
22
|
+
let profilePath;
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
tempDir = mkdtempSync(path.join(tmpdir(), "duct-profile-"));
|
|
25
|
+
profilePath = path.join(tempDir, "profile.json");
|
|
26
|
+
delete process.env.DUCT_PROFILE;
|
|
27
|
+
delete process.env.DUCT_URL;
|
|
28
|
+
delete process.env.DUCT_API_URL;
|
|
29
|
+
delete process.env.DUCT_AUTH_URL;
|
|
30
|
+
delete process.env.DUCT_SHELL_URL;
|
|
31
|
+
delete process.env.DUCT_DASHBOARD_URL;
|
|
32
|
+
delete process.env.DUCT_REGISTRY_URL;
|
|
33
|
+
delete process.env.DUCT_DOCS_URL;
|
|
34
|
+
});
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
restoreEnv();
|
|
37
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
38
|
+
});
|
|
39
|
+
it("defaults to hosted when no file or env", () => {
|
|
40
|
+
assert.equal(resolveActiveProfileName(null), "hosted");
|
|
41
|
+
});
|
|
42
|
+
it("reads active profile from file", () => {
|
|
43
|
+
writeProfileFileSync({ active: "local" }, profilePath);
|
|
44
|
+
const file = readProfileFileSync(profilePath);
|
|
45
|
+
assert.equal(resolveActiveProfileName(file), "local");
|
|
46
|
+
});
|
|
47
|
+
it("prefers DUCT_PROFILE env over file", () => {
|
|
48
|
+
process.env.DUCT_PROFILE = "staging";
|
|
49
|
+
writeProfileFileSync({ active: "local" }, profilePath);
|
|
50
|
+
const file = readProfileFileSync(profilePath);
|
|
51
|
+
assert.equal(resolveActiveProfileName(file), "staging");
|
|
52
|
+
});
|
|
53
|
+
it("applies local builtin URLs when profile is local", () => {
|
|
54
|
+
applyProfileUrlsToEnv("local");
|
|
55
|
+
assert.equal(process.env.DUCT_API_URL, "http://localhost:3002");
|
|
56
|
+
assert.equal(process.env.DUCT_AUTH_URL, "http://localhost:3001");
|
|
57
|
+
assert.equal(process.env.DUCT_PROFILE, "local");
|
|
58
|
+
});
|
|
59
|
+
it("merges custom profile URLs from file", () => {
|
|
60
|
+
writeProfileFileSync({
|
|
61
|
+
active: "staging",
|
|
62
|
+
profiles: {
|
|
63
|
+
staging: { ductUrl: "https://staging.acme.dev" },
|
|
64
|
+
},
|
|
65
|
+
}, profilePath);
|
|
66
|
+
const file = readProfileFileSync(profilePath);
|
|
67
|
+
const urls = resolveProfileUrls("staging", file);
|
|
68
|
+
assert.equal(urls.ductUrl, "https://staging.acme.dev");
|
|
69
|
+
});
|
|
70
|
+
it("does not override shell-protected env keys", () => {
|
|
71
|
+
process.env.DUCT_API_URL = "https://api.custom.test";
|
|
72
|
+
const protectedKeys = new Set(["DUCT_API_URL"]);
|
|
73
|
+
applyProfileUrlsToEnv("local", { protectedKeys });
|
|
74
|
+
assert.equal(process.env.DUCT_API_URL, "https://api.custom.test");
|
|
75
|
+
assert.equal(process.env.DUCT_AUTH_URL, "http://localhost:3001");
|
|
76
|
+
});
|
|
77
|
+
it("applyActiveProfileEnvSync loads file and applies URLs", () => {
|
|
78
|
+
writeProfileFileSync({ active: "local" }, profilePath);
|
|
79
|
+
const name = applyActiveProfileEnvSync({ profilePath });
|
|
80
|
+
assert.equal(name, "local");
|
|
81
|
+
assert.equal(process.env.DUCT_SHELL_URL, "http://localhost:3000");
|
|
82
|
+
});
|
|
83
|
+
it("lists builtin and custom profile names", () => {
|
|
84
|
+
writeProfileFileSync({ active: "local", profiles: { staging: { ductUrl: "https://x.test" } } }, profilePath);
|
|
85
|
+
const names = listProfileNames(readProfileFileSync(profilePath));
|
|
86
|
+
assert.ok(names.includes("local"));
|
|
87
|
+
assert.ok(names.includes("hosted"));
|
|
88
|
+
assert.ok(names.includes("staging"));
|
|
89
|
+
});
|
|
90
|
+
it("setActiveProfileSync updates active field", () => {
|
|
91
|
+
setActiveProfileSync("local", { profilePath });
|
|
92
|
+
const file = readProfileFileSync(profilePath);
|
|
93
|
+
assert.equal(file?.active, "local");
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ReadinessCheckStatusSchema: z.ZodEnum<["pass", "fail", "warn", "skip"]>;
|
|
3
|
+
export declare const ReadinessCheckSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
label: z.ZodString;
|
|
6
|
+
status: z.ZodEnum<["pass", "fail", "warn", "skip"]>;
|
|
7
|
+
message: z.ZodOptional<z.ZodString>;
|
|
8
|
+
url: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
status: "fail" | "pass" | "warn" | "skip";
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
message?: string | undefined;
|
|
14
|
+
url?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
status: "fail" | "pass" | "warn" | "skip";
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
message?: string | undefined;
|
|
20
|
+
url?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const ReadinessReportSchema: z.ZodObject<{
|
|
23
|
+
ok: z.ZodBoolean;
|
|
24
|
+
generatedAt: z.ZodString;
|
|
25
|
+
docsUrl: z.ZodOptional<z.ZodString>;
|
|
26
|
+
checks: z.ZodArray<z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
label: z.ZodString;
|
|
29
|
+
status: z.ZodEnum<["pass", "fail", "warn", "skip"]>;
|
|
30
|
+
message: z.ZodOptional<z.ZodString>;
|
|
31
|
+
url: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
status: "fail" | "pass" | "warn" | "skip";
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
message?: string | undefined;
|
|
37
|
+
url?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
status: "fail" | "pass" | "warn" | "skip";
|
|
40
|
+
id: string;
|
|
41
|
+
label: string;
|
|
42
|
+
message?: string | undefined;
|
|
43
|
+
url?: string | undefined;
|
|
44
|
+
}>, "many">;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
ok: boolean;
|
|
47
|
+
generatedAt: string;
|
|
48
|
+
checks: {
|
|
49
|
+
status: "fail" | "pass" | "warn" | "skip";
|
|
50
|
+
id: string;
|
|
51
|
+
label: string;
|
|
52
|
+
message?: string | undefined;
|
|
53
|
+
url?: string | undefined;
|
|
54
|
+
}[];
|
|
55
|
+
docsUrl?: string | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
ok: boolean;
|
|
58
|
+
generatedAt: string;
|
|
59
|
+
checks: {
|
|
60
|
+
status: "fail" | "pass" | "warn" | "skip";
|
|
61
|
+
id: string;
|
|
62
|
+
label: string;
|
|
63
|
+
message?: string | undefined;
|
|
64
|
+
url?: string | undefined;
|
|
65
|
+
}[];
|
|
66
|
+
docsUrl?: string | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
export type ReadinessCheckStatus = z.infer<typeof ReadinessCheckStatusSchema>;
|
|
69
|
+
export type ReadinessCheck = z.infer<typeof ReadinessCheckSchema>;
|
|
70
|
+
export type ReadinessReport = z.infer<typeof ReadinessReportSchema>;
|
|
71
|
+
export declare function readinessReportOk(checks: ReadinessCheck[]): boolean;
|
|
72
|
+
export interface HealthProbeResult {
|
|
73
|
+
ok: boolean;
|
|
74
|
+
status?: number;
|
|
75
|
+
error?: string;
|
|
76
|
+
}
|
|
77
|
+
export declare function probeHealth(url: string, timeoutMs?: number, fetchFn?: typeof fetch): Promise<HealthProbeResult>;
|
|
78
|
+
export declare function makeCheck(id: string, label: string, status: ReadinessCheckStatus, extras?: Pick<ReadinessCheck, 'message' | 'url'>): ReadinessCheck;
|
|
79
|
+
export interface CliReadinessEnv {
|
|
80
|
+
ductUrl?: string;
|
|
81
|
+
shellId?: string;
|
|
82
|
+
secretKey?: string;
|
|
83
|
+
authEmail?: string;
|
|
84
|
+
authSlug?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface CliReadinessEndpoints {
|
|
87
|
+
authHealthUrl: string;
|
|
88
|
+
apiHealthUrl: string;
|
|
89
|
+
shellHealthUrl: string;
|
|
90
|
+
dashboardHealthUrl: string;
|
|
91
|
+
docsUrl: string;
|
|
92
|
+
}
|
|
93
|
+
export interface CliReadinessOptions {
|
|
94
|
+
env: CliReadinessEnv;
|
|
95
|
+
endpoints: CliReadinessEndpoints;
|
|
96
|
+
probe?: (url: string) => Promise<HealthProbeResult>;
|
|
97
|
+
}
|
|
98
|
+
export declare function buildCliReadinessReport(options: CliReadinessOptions): Promise<ReadinessReport>;
|
|
99
|
+
export interface ShellReadinessInput {
|
|
100
|
+
shellId: string;
|
|
101
|
+
manifestPushed: boolean;
|
|
102
|
+
productBaseUrl?: string;
|
|
103
|
+
actionCount: number;
|
|
104
|
+
recentMessages: number;
|
|
105
|
+
recentInvokeTurns: number;
|
|
106
|
+
endpoints: {
|
|
107
|
+
authHealthUrl: string;
|
|
108
|
+
apiHealthUrl: string;
|
|
109
|
+
docsUrl: string;
|
|
110
|
+
};
|
|
111
|
+
probe?: (url: string) => Promise<HealthProbeResult>;
|
|
112
|
+
}
|
|
113
|
+
export declare function buildShellReadinessReport(input: ShellReadinessInput): Promise<ReadinessReport>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ReadinessCheckStatusSchema = z.enum(['pass', 'fail', 'warn', 'skip']);
|
|
3
|
+
export const ReadinessCheckSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
label: z.string(),
|
|
6
|
+
status: ReadinessCheckStatusSchema,
|
|
7
|
+
message: z.string().optional(),
|
|
8
|
+
url: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
export const ReadinessReportSchema = z.object({
|
|
11
|
+
ok: z.boolean(),
|
|
12
|
+
generatedAt: z.string(),
|
|
13
|
+
docsUrl: z.string().optional(),
|
|
14
|
+
checks: z.array(ReadinessCheckSchema),
|
|
15
|
+
});
|
|
16
|
+
export function readinessReportOk(checks) {
|
|
17
|
+
return !checks.some((check) => check.status === 'fail');
|
|
18
|
+
}
|
|
19
|
+
export async function probeHealth(url, timeoutMs = 3000, fetchFn = fetch) {
|
|
20
|
+
try {
|
|
21
|
+
const controller = new AbortController();
|
|
22
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
23
|
+
const res = await fetchFn(url, { signal: controller.signal });
|
|
24
|
+
clearTimeout(timer);
|
|
25
|
+
return { ok: res.ok, status: res.status };
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
29
|
+
return { ok: false, error: message };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function makeCheck(id, label, status, extras) {
|
|
33
|
+
return { id, label, status, ...extras };
|
|
34
|
+
}
|
|
35
|
+
export async function buildCliReadinessReport(options) {
|
|
36
|
+
const probe = options.probe ?? ((url) => probeHealth(url));
|
|
37
|
+
const { env, endpoints } = options;
|
|
38
|
+
const checks = [];
|
|
39
|
+
checks.push(makeCheck('env_duct_url', 'DUCT_URL', env.ductUrl ? 'pass' : 'warn', { message: env.ductUrl || 'Not set — using localhost defaults' }), makeCheck('env_shell_id', 'DUCT_SHELL_ID', env.shellId ? 'pass' : 'warn', { message: env.shellId || 'Not set' }), makeCheck('env_secret_key', 'DUCT_SECRET_KEY', env.secretKey ? 'pass' : 'warn', { message: env.secretKey ? `sk_...${env.secretKey.slice(-4)}` : 'Not set' }), makeCheck('auth_logged_in', 'CLI auth profile', env.authEmail ? 'pass' : 'warn', {
|
|
40
|
+
message: env.authEmail
|
|
41
|
+
? `${env.authEmail} (${env.authSlug ?? 'unknown slug'})`
|
|
42
|
+
: 'Not logged in — run: npx duct login',
|
|
43
|
+
}));
|
|
44
|
+
const serviceChecks = [
|
|
45
|
+
{ id: 'auth_reachable', label: 'Auth service', url: endpoints.authHealthUrl },
|
|
46
|
+
{ id: 'api_reachable', label: 'Agent API', url: endpoints.apiHealthUrl },
|
|
47
|
+
{ id: 'shell_reachable', label: 'Shell runtime', url: endpoints.shellHealthUrl },
|
|
48
|
+
{ id: 'dashboard_reachable', label: 'Dashboard', url: endpoints.dashboardHealthUrl },
|
|
49
|
+
];
|
|
50
|
+
for (const { id, label, url } of serviceChecks) {
|
|
51
|
+
const result = await probe(url);
|
|
52
|
+
checks.push(makeCheck(id, label, result.ok ? 'pass' : 'fail', {
|
|
53
|
+
url,
|
|
54
|
+
message: result.ok
|
|
55
|
+
? 'Reachable'
|
|
56
|
+
: result.status !== undefined
|
|
57
|
+
? `HTTP ${result.status}`
|
|
58
|
+
: result.error ?? 'unreachable',
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
checks.push(makeCheck('docs_url', 'Docs URL', 'pass', {
|
|
62
|
+
url: endpoints.docsUrl,
|
|
63
|
+
message: endpoints.docsUrl,
|
|
64
|
+
}));
|
|
65
|
+
return {
|
|
66
|
+
ok: readinessReportOk(checks),
|
|
67
|
+
generatedAt: new Date().toISOString(),
|
|
68
|
+
docsUrl: endpoints.docsUrl,
|
|
69
|
+
checks,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export async function buildShellReadinessReport(input) {
|
|
73
|
+
const probe = input.probe ?? ((url) => probeHealth(url));
|
|
74
|
+
const checks = [];
|
|
75
|
+
checks.push(makeCheck('manifest_pushed', 'Manifest pushed', input.manifestPushed ? 'pass' : 'fail', {
|
|
76
|
+
message: input.manifestPushed
|
|
77
|
+
? 'Shell status is live'
|
|
78
|
+
: '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
|
+
}));
|
|
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',
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
checks.push(makeCheck('docs_url', 'Docs URL', 'pass', {
|
|
101
|
+
url: input.endpoints.docsUrl,
|
|
102
|
+
message: input.endpoints.docsUrl,
|
|
103
|
+
}));
|
|
104
|
+
return {
|
|
105
|
+
ok: readinessReportOk(checks),
|
|
106
|
+
generatedAt: new Date().toISOString(),
|
|
107
|
+
docsUrl: input.endpoints.docsUrl,
|
|
108
|
+
checks,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { ReadinessReportSchema, buildCliReadinessReport, readinessReportOk, } from './readiness-checks.js';
|
|
4
|
+
describe('readiness-checks', () => {
|
|
5
|
+
it('buildCliReadinessReport emits schema-valid output', async () => {
|
|
6
|
+
const report = await buildCliReadinessReport({
|
|
7
|
+
env: {
|
|
8
|
+
ductUrl: 'http://localhost:3005',
|
|
9
|
+
shellId: 'shell_test',
|
|
10
|
+
secretKey: 'sk_test1234',
|
|
11
|
+
authEmail: 'dev@example.com',
|
|
12
|
+
authSlug: 'acme',
|
|
13
|
+
},
|
|
14
|
+
endpoints: {
|
|
15
|
+
authHealthUrl: 'http://localhost:3001/health',
|
|
16
|
+
apiHealthUrl: 'http://localhost:3002/health',
|
|
17
|
+
shellHealthUrl: 'http://localhost:3000/api/health',
|
|
18
|
+
dashboardHealthUrl: 'http://localhost:3004/api/health',
|
|
19
|
+
docsUrl: 'http://localhost:3005/docs',
|
|
20
|
+
},
|
|
21
|
+
probe: async (url) => ({ ok: url.includes('/health'), status: 200 }),
|
|
22
|
+
});
|
|
23
|
+
assert.equal(ReadinessReportSchema.safeParse(report).success, true);
|
|
24
|
+
assert.equal(report.ok, true);
|
|
25
|
+
assert.equal(report.docsUrl, 'http://localhost:3005/docs');
|
|
26
|
+
assert.ok(report.checks.some((c) => c.id === 'api_reachable' && c.status === 'pass'));
|
|
27
|
+
assert.ok(report.checks.some((c) => c.id === 'docs_url'));
|
|
28
|
+
});
|
|
29
|
+
it('marks report not ok when a required service probe fails', async () => {
|
|
30
|
+
const report = await buildCliReadinessReport({
|
|
31
|
+
env: {},
|
|
32
|
+
endpoints: {
|
|
33
|
+
authHealthUrl: 'http://localhost:3001/health',
|
|
34
|
+
apiHealthUrl: 'http://localhost:3002/health',
|
|
35
|
+
shellHealthUrl: 'http://localhost:3000/api/health',
|
|
36
|
+
dashboardHealthUrl: 'http://localhost:3004/api/health',
|
|
37
|
+
docsUrl: 'http://localhost:3005/docs',
|
|
38
|
+
},
|
|
39
|
+
probe: async (url) => ({
|
|
40
|
+
ok: !url.includes(':3002'),
|
|
41
|
+
status: url.includes(':3002') ? 503 : 200,
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
assert.equal(readinessReportOk(report.checks), false);
|
|
45
|
+
assert.equal(report.ok, false);
|
|
46
|
+
const api = report.checks.find((c) => c.id === 'api_reachable');
|
|
47
|
+
assert.equal(api?.status, 'fail');
|
|
48
|
+
});
|
|
49
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig } from "./core/config.js";
|
|
2
|
-
export type { ValidatedDuctConfig } from "./core/config.js";
|
|
1
|
+
export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig, ManifestActionSchema, ActionManifestSchema, SensitivityLevelSchema, ErrorEnvelopeSchema, ConfirmationStateSchema, } from "./core/config.js";
|
|
2
|
+
export type { ValidatedDuctConfig, ManifestAction, ErrorEnvelope, ConfirmationState } from "./core/config.js";
|
|
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";
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// runtimes where React is not installed (e.g. plain Express).
|
|
7
7
|
// ============================================================
|
|
8
8
|
// Core config
|
|
9
|
-
export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig } from "./core/config.js";
|
|
9
|
+
export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig, ManifestActionSchema, ActionManifestSchema, SensitivityLevelSchema, ErrorEnvelopeSchema, ConfirmationStateSchema, } from "./core/config.js";
|
|
10
10
|
// Token utilities
|
|
11
11
|
export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
|
|
12
12
|
// Outcome receipt verification (crypto layer)
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig } from "./core/config.js";
|
|
2
|
-
export type { ValidatedDuctConfig } from "./core/config.js";
|
|
1
|
+
export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig, ManifestActionSchema, ActionManifestSchema, SensitivityLevelSchema, ErrorEnvelopeSchema, ConfirmationStateSchema, } from "./core/config.js";
|
|
2
|
+
export type { ValidatedDuctConfig, ManifestAction, ErrorEnvelope, ConfirmationState } from "./core/config.js";
|
|
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";
|
package/dist/server.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// is not installed.
|
|
11
11
|
// ============================================================
|
|
12
12
|
// Config
|
|
13
|
-
export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig } from "./core/config.js";
|
|
13
|
+
export { defineDuctConfig, DuctConfigSchema, crossValidateDuctConfig, ManifestActionSchema, ActionManifestSchema, SensitivityLevelSchema, ErrorEnvelopeSchema, ConfirmationStateSchema, } from "./core/config.js";
|
|
14
14
|
// Token utilities — mint delegated JWTs, verify them, handle deeplinks
|
|
15
15
|
export { generateDuctToken, verifyDuctToken, generateDeeplinkToken, verifyDeeplinkToken, createDevReplayStore, InMemoryReplayStore, RedisReplayStore, } from "./core/token.js";
|
|
16
16
|
// Outcome receipt verification (crypto layer)
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duct-sdk/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Duct SDK — manifest, CLI, and embed components for permissioned human and agent access to your product APIs.",
|
|
6
|
-
"homepage": "https://ductai.vercel.app/docs",
|
|
7
6
|
"main": "dist/index.js",
|
|
8
7
|
"types": "dist/index.d.ts",
|
|
9
8
|
"bin": {
|
|
@@ -19,13 +18,15 @@
|
|
|
19
18
|
"./react": "./dist/adapters/react/index.js"
|
|
20
19
|
},
|
|
21
20
|
"scripts": {
|
|
22
|
-
"build": "tsc",
|
|
21
|
+
"build": "npm run build --prefix ../contracts && tsc",
|
|
23
22
|
"dev": "tsc --watch",
|
|
24
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",
|
|
25
24
|
"verify:publish": "node scripts/verify-publish.mjs",
|
|
25
|
+
"pack:release": "npm run build && npm run verify:publish && node scripts/pack-release.mjs",
|
|
26
26
|
"prepublishOnly": "npm run build && npm run verify:publish"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@duct-sdk/contracts": "file:../contracts",
|
|
29
30
|
"@anthropic-ai/sdk": "^0.24.0",
|
|
30
31
|
"jose": "^5.0.0",
|
|
31
32
|
"ignore": "^5.0.0",
|