@duct-sdk/sdk 0.5.13 → 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 (160) hide show
  1. package/CHANGELOG.md +385 -344
  2. package/README.md +418 -264
  3. package/TOKEN_SPEC.md +243 -243
  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 +396 -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 +464 -1
  59. package/dist/core/config.js +14 -14
  60. package/dist/core/login-handoff.d.ts +1 -1
  61. package/dist/core/login-handoff.js +1 -1
  62. package/dist/core/project.d.ts +1798 -0
  63. package/dist/core/project.js +278 -0
  64. package/dist/core/readiness-checks.js +2 -2
  65. package/dist/core/types.d.ts +1 -1
  66. package/dist/index.d.ts +2 -0
  67. package/dist/index.js +1 -0
  68. package/dist/project.d.ts +4 -0
  69. package/dist/project.js +8 -0
  70. package/dist/server.d.ts +2 -0
  71. package/dist/server.js +1 -0
  72. package/package.json +94 -95
  73. package/dist/adapters/react/page-context-guard.test.d.ts +0 -1
  74. package/dist/adapters/react/page-context-guard.test.js +0 -15
  75. package/dist/cli/agents/api-agent.d.ts +0 -22
  76. package/dist/cli/agents/api-agent.js +0 -761
  77. package/dist/cli/agents/auth-agent.d.ts +0 -7
  78. package/dist/cli/agents/auth-agent.js +0 -212
  79. package/dist/cli/agents/deeplink-agent.d.ts +0 -6
  80. package/dist/cli/agents/deeplink-agent.js +0 -285
  81. package/dist/cli/agents/llm.d.ts +0 -33
  82. package/dist/cli/agents/llm.js +0 -309
  83. package/dist/cli/agents/pipeline.d.ts +0 -72
  84. package/dist/cli/agents/pipeline.js +0 -421
  85. package/dist/cli/agents/reviewer-agent.d.ts +0 -13
  86. package/dist/cli/agents/reviewer-agent.js +0 -450
  87. package/dist/cli/agents/route-agent.d.ts +0 -17
  88. package/dist/cli/agents/route-agent.js +0 -383
  89. package/dist/cli/config-loader.test.d.ts +0 -1
  90. package/dist/cli/config-loader.test.js +0 -63
  91. package/dist/cli/detectors/topology.d.ts +0 -46
  92. package/dist/cli/detectors/topology.js +0 -417
  93. package/dist/cli/generators/config.test.d.ts +0 -1
  94. package/dist/cli/generators/config.test.js +0 -222
  95. package/dist/cli/generators/shell.test.d.ts +0 -1
  96. package/dist/cli/generators/shell.test.js +0 -73
  97. package/dist/cli/generators/token-route.test.d.ts +0 -1
  98. package/dist/cli/generators/token-route.test.js +0 -53
  99. package/dist/cli/generators/wiring-snippets.test.d.ts +0 -1
  100. package/dist/cli/generators/wiring-snippets.test.js +0 -80
  101. package/dist/cli/init.d.ts +0 -32
  102. package/dist/cli/init.js +0 -1336
  103. package/dist/cli/manifest-diff.test.d.ts +0 -1
  104. package/dist/cli/manifest-diff.test.js +0 -144
  105. package/dist/cli/processors/curl-parser.test.d.ts +0 -1
  106. package/dist/cli/processors/curl-parser.test.js +0 -24
  107. package/dist/cli/processors/integration-audit.test.d.ts +0 -1
  108. package/dist/cli/processors/integration-audit.test.js +0 -154
  109. package/dist/cli/processors/postprocess.d.ts +0 -22
  110. package/dist/cli/processors/postprocess.js +0 -107
  111. package/dist/cli/processors/prisma-parser.d.ts +0 -35
  112. package/dist/cli/processors/prisma-parser.js +0 -117
  113. package/dist/cli/processors/verify-discovery.d.ts +0 -33
  114. package/dist/cli/processors/verify-discovery.js +0 -193
  115. package/dist/cli/processors/verify-discovery.test.d.ts +0 -1
  116. package/dist/cli/processors/verify-discovery.test.js +0 -153
  117. package/dist/cli/processors/zod-extractor.d.ts +0 -27
  118. package/dist/cli/processors/zod-extractor.js +0 -153
  119. package/dist/cli/prompts/review.d.ts +0 -61
  120. package/dist/cli/prompts/review.js +0 -410
  121. package/dist/cli/selectors/express.d.ts +0 -12
  122. package/dist/cli/selectors/express.js +0 -117
  123. package/dist/cli/selectors/fastapi.d.ts +0 -12
  124. package/dist/cli/selectors/fastapi.js +0 -122
  125. package/dist/cli/selectors/generic.d.ts +0 -10
  126. package/dist/cli/selectors/generic.js +0 -74
  127. package/dist/cli/selectors/index.d.ts +0 -37
  128. package/dist/cli/selectors/index.js +0 -315
  129. package/dist/cli/selectors/next.d.ts +0 -12
  130. package/dist/cli/selectors/next.js +0 -130
  131. package/dist/core/config-policy.test.d.ts +0 -1
  132. package/dist/core/config-policy.test.js +0 -101
  133. package/dist/core/config-roundtrip.test.d.ts +0 -1
  134. package/dist/core/config-roundtrip.test.js +0 -180
  135. package/dist/core/endpoint-guard.test.d.ts +0 -1
  136. package/dist/core/endpoint-guard.test.js +0 -57
  137. package/dist/core/env-diagnostics.test.d.ts +0 -1
  138. package/dist/core/env-diagnostics.test.js +0 -31
  139. package/dist/core/evidence-bundle.conformance.test.d.ts +0 -1
  140. package/dist/core/evidence-bundle.conformance.test.js +0 -110
  141. package/dist/core/evidence-bundle.test.d.ts +0 -1
  142. package/dist/core/evidence-bundle.test.js +0 -58
  143. package/dist/core/invariants.test.d.ts +0 -1
  144. package/dist/core/invariants.test.js +0 -217
  145. package/dist/core/login-handoff.test.d.ts +0 -1
  146. package/dist/core/login-handoff.test.js +0 -31
  147. package/dist/core/profile.test.d.ts +0 -1
  148. package/dist/core/profile.test.js +0 -95
  149. package/dist/core/readiness-checks.test.d.ts +0 -1
  150. package/dist/core/readiness-checks.test.js +0 -106
  151. package/dist/core/receipt.test.d.ts +0 -1
  152. package/dist/core/receipt.test.js +0 -75
  153. package/dist/core/sdk-entrypoint.test.d.ts +0 -1
  154. package/dist/core/sdk-entrypoint.test.js +0 -8
  155. package/dist/core/side-effects-review.test.d.ts +0 -1
  156. package/dist/core/side-effects-review.test.js +0 -28
  157. package/dist/core/token.conformance.test.d.ts +0 -1
  158. package/dist/core/token.conformance.test.js +0 -43
  159. package/dist/core/token.test.d.ts +0 -1
  160. package/dist/core/token.test.js +0 -66
@@ -1,309 +0,0 @@
1
- // ============================================================
2
- // @duct/sdk — LLM Helper
3
- // Supports Anthropic, OpenAI, Gemini, Groq, Grok (xAI),
4
- // OpenRouter, and the Duct hosted endpoint.
5
- //
6
- // Provider is auto-detected from available env vars, or set
7
- // explicitly via LLM_PROVIDER. Model name is never hardcoded —
8
- // always set LLM_MODEL in your environment.
9
- //
10
- // Note: "grok" is xAI's Grok (api.x.ai) — distinct from "groq"
11
- // (api.groq.com). The xAI key follows xAI's official console
12
- // naming convention: XAI_API_KEY.
13
- // ============================================================
14
- import Anthropic from "@anthropic-ai/sdk";
15
- import { getActiveApiBase, getConfiguredDashboard, } from "../../core/endpoints.js";
16
- // ----------------------------------------------------------------
17
- // Provider resolution
18
- // ----------------------------------------------------------------
19
- function resolveProvider() {
20
- const explicitProvider = process.env["LLM_PROVIDER"]?.toLowerCase();
21
- const model = process.env["LLM_MODEL"];
22
- const keys = {
23
- anthropic: process.env["ANTHROPIC_API_KEY"],
24
- openai: process.env["OPENAI_API_KEY"],
25
- gemini: process.env["GEMINI_API_KEY"],
26
- groq: process.env["GROQ_API_KEY"],
27
- grok: process.env["XAI_API_KEY"],
28
- openrouter: process.env["OPENROUTER_API_KEY"],
29
- duct: process.env["DUCT_API_KEY"],
30
- };
31
- // Explicit provider wins
32
- if (explicitProvider) {
33
- const key = keys[explicitProvider];
34
- if (!key) {
35
- throw new Error(`LLM_PROVIDER is set to "${explicitProvider}" but the corresponding API key is missing.\n\n` +
36
- providerKeyHint(explicitProvider));
37
- }
38
- if (!model && explicitProvider !== "duct") {
39
- throw new Error(`LLM_MODEL is not set.\n\nSet LLM_MODEL to the model name you want to use with ${explicitProvider}.\n` +
40
- `Example: LLM_MODEL=your-preferred-model`);
41
- }
42
- return { provider: explicitProvider, apiKey: key, model: model ?? "" };
43
- }
44
- // Auto-detect: first key that's set wins (duct → anthropic → openai → gemini → groq → grok → openrouter)
45
- const autoOrder = ["duct", "anthropic", "openai", "gemini", "groq", "grok", "openrouter"];
46
- for (const p of autoOrder) {
47
- const key = keys[p];
48
- if (key) {
49
- if (!model && p !== "duct") {
50
- throw new Error(`LLM_MODEL is not set.\n\nAuto-detected provider "${p}" from your environment, but LLM_MODEL is required.\n` +
51
- `Set LLM_MODEL to the model name you want to use.\nExample: LLM_MODEL=your-preferred-model`);
52
- }
53
- return { provider: p, apiKey: key, model: model ?? "" };
54
- }
55
- }
56
- const dashboardUrl = getConfiguredDashboard();
57
- throw new Error(`No API key configured for the Duct agent pipeline.\n\n` +
58
- `Set one of the following environment variables:\n` +
59
- ` ANTHROPIC_API_KEY — Anthropic Claude\n` +
60
- ` OPENAI_API_KEY — OpenAI\n` +
61
- ` GEMINI_API_KEY — Google Gemini\n` +
62
- ` GROQ_API_KEY — Groq (api.groq.com)\n` +
63
- ` XAI_API_KEY — Grok / xAI (api.x.ai)\n` +
64
- ` OPENROUTER_API_KEY — OpenRouter\n` +
65
- ` DUCT_API_KEY — Duct hosted AI endpoint (requires Duct hosted LLM API)\n\n` +
66
- `Also set LLM_MODEL to the model you want to use (e.g. LLM_MODEL=your-preferred-model).\n` +
67
- `For local development, prefer ANTHROPIC_API_KEY/OPENAI_API_KEY/etc.\n` +
68
- `Dashboard: ${dashboardUrl}`);
69
- }
70
- function providerKeyHint(provider) {
71
- const hints = {
72
- anthropic: "Set ANTHROPIC_API_KEY",
73
- openai: "Set OPENAI_API_KEY",
74
- gemini: "Set GEMINI_API_KEY",
75
- groq: "Set GROQ_API_KEY",
76
- grok: "Set XAI_API_KEY (Grok uses xAI's official key naming)",
77
- openrouter: "Set OPENROUTER_API_KEY",
78
- duct: "Set DUCT_API_KEY",
79
- };
80
- return hints[provider] ?? "";
81
- }
82
- // ----------------------------------------------------------------
83
- // callDuctLLM — public entry point
84
- // ----------------------------------------------------------------
85
- /**
86
- * Call an LLM for the Duct agent pipeline.
87
- *
88
- * Provider is resolved in this order:
89
- * 1. LLM_PROVIDER env var (explicit)
90
- * 2. First available API key: DUCT_API_KEY → ANTHROPIC_API_KEY → OPENAI_API_KEY
91
- * → GEMINI_API_KEY → GROQ_API_KEY → XAI_API_KEY (Grok) → OPENROUTER_API_KEY
92
- *
93
- * Model name is always taken from LLM_MODEL — never hardcoded.
94
- *
95
- * @throws {Error} If no API key or LLM_MODEL is configured
96
- */
97
- export async function callDuctLLM(options) {
98
- const { agentName, systemPrompt, userPrompt, outputSchema, maxTokens = 4096, maxRetries = 3, } = options;
99
- const { provider, apiKey, model } = resolveProvider();
100
- const fullSystemPrompt = `${systemPrompt}
101
-
102
- You are the ${agentName} agent in the Duct SDK pipeline. Your job is to analyze a codebase and produce structured output.
103
-
104
- IMPORTANT OUTPUT RULES:
105
- 1. Respond with ONLY valid JSON — no markdown, no prose, no code fences
106
- 2. Your output must exactly match this schema:
107
- ${outputSchema}
108
- 3. Be thorough but concise. Prefer accuracy over completeness.
109
- 4. If you're uncertain about a value, use a sensible default rather than omitting it.`;
110
- let lastError = null;
111
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
112
- try {
113
- switch (provider) {
114
- case "anthropic":
115
- return await callAnthropic({ apiKey, model, systemPrompt: fullSystemPrompt, userPrompt, maxTokens });
116
- case "openai":
117
- return await callOpenAICompatible({ apiKey, model, systemPrompt: fullSystemPrompt, userPrompt, maxTokens, baseUrl: "https://api.openai.com/v1" });
118
- case "gemini":
119
- return await callGemini({ apiKey, model, systemPrompt: fullSystemPrompt, userPrompt, maxTokens });
120
- case "groq":
121
- return await callOpenAICompatible({ apiKey, model, systemPrompt: fullSystemPrompt, userPrompt, maxTokens, baseUrl: "https://api.groq.com/openai/v1" });
122
- case "grok":
123
- return await callOpenAICompatible({ apiKey, model, systemPrompt: fullSystemPrompt, userPrompt, maxTokens, baseUrl: "https://api.x.ai/v1" });
124
- case "openrouter":
125
- return await callOpenAICompatible({ apiKey, model, systemPrompt: fullSystemPrompt, userPrompt, maxTokens, baseUrl: process.env["OPENROUTER_BASE_URL"] ?? "https://openrouter.ai/api/v1" });
126
- case "duct":
127
- return await callDuctEndpoint({ apiKey, agentName, systemPrompt: fullSystemPrompt, userPrompt, maxTokens });
128
- }
129
- }
130
- catch (err) {
131
- lastError = err instanceof Error ? err : new Error(String(err));
132
- // Fail fast on non-transient errors (auth failures, bad requests, JSON parse errors)
133
- if (!isRetryableError(lastError)) {
134
- throw lastError;
135
- }
136
- if (attempt < maxRetries) {
137
- await sleep(Math.pow(2, attempt - 1) * 1000);
138
- continue;
139
- }
140
- }
141
- }
142
- throw new Error(`${agentName} failed after ${maxRetries} attempts: ${lastError?.message ?? "Unknown error"}`);
143
- }
144
- // ----------------------------------------------------------------
145
- // Anthropic
146
- // ----------------------------------------------------------------
147
- async function callAnthropic(options) {
148
- const client = new Anthropic({ apiKey: options.apiKey });
149
- const message = await client.messages.create({
150
- model: options.model,
151
- max_tokens: options.maxTokens,
152
- system: options.systemPrompt,
153
- messages: [{ role: "user", content: options.userPrompt }],
154
- });
155
- const textBlock = message.content.find((b) => b.type === "text");
156
- if (!textBlock || textBlock.type !== "text") {
157
- throw new Error("Anthropic returned no text content");
158
- }
159
- return {
160
- text: textBlock.text.trim(),
161
- parsed: parseJSONResponse(textBlock.text.trim()),
162
- inputTokens: message.usage.input_tokens,
163
- outputTokens: message.usage.output_tokens,
164
- };
165
- }
166
- // ----------------------------------------------------------------
167
- // OpenAI-compatible (OpenAI, Groq, OpenRouter)
168
- // ----------------------------------------------------------------
169
- async function callOpenAICompatible(options) {
170
- const response = await fetch(`${options.baseUrl}/chat/completions`, {
171
- method: "POST",
172
- headers: {
173
- "Content-Type": "application/json",
174
- "Authorization": `Bearer ${options.apiKey}`,
175
- },
176
- body: JSON.stringify({
177
- model: options.model,
178
- max_tokens: options.maxTokens,
179
- messages: [
180
- { role: "system", content: options.systemPrompt },
181
- { role: "user", content: options.userPrompt },
182
- ],
183
- response_format: { type: "json_object" },
184
- }),
185
- });
186
- if (!response.ok) {
187
- const body = await response.text();
188
- throw new Error(`OpenAI-compatible API error (${response.status}): ${body}`);
189
- }
190
- const data = await response.json();
191
- const text = (data.choices[0]?.message?.content ?? "").trim();
192
- return {
193
- text,
194
- parsed: parseJSONResponse(text),
195
- inputTokens: data.usage?.prompt_tokens ?? 0,
196
- outputTokens: data.usage?.completion_tokens ?? 0,
197
- };
198
- }
199
- // ----------------------------------------------------------------
200
- // Gemini
201
- // ----------------------------------------------------------------
202
- async function callGemini(options) {
203
- const url = `https://generativelanguage.googleapis.com/v1beta/models/${options.model}:generateContent?key=${options.apiKey}`;
204
- const response = await fetch(url, {
205
- method: "POST",
206
- headers: { "Content-Type": "application/json" },
207
- body: JSON.stringify({
208
- system_instruction: { parts: [{ text: options.systemPrompt }] },
209
- contents: [{ parts: [{ text: options.userPrompt }] }],
210
- generationConfig: {
211
- maxOutputTokens: options.maxTokens,
212
- responseMimeType: "application/json",
213
- },
214
- }),
215
- });
216
- if (!response.ok) {
217
- const body = await response.text();
218
- throw new Error(`Gemini API error (${response.status}): ${body}`);
219
- }
220
- const data = await response.json();
221
- const text = (data.candidates[0]?.content?.parts[0]?.text ?? "").trim();
222
- return {
223
- text,
224
- parsed: parseJSONResponse(text),
225
- inputTokens: data.usageMetadata?.promptTokenCount ?? 0,
226
- outputTokens: data.usageMetadata?.candidatesTokenCount ?? 0,
227
- };
228
- }
229
- // ----------------------------------------------------------------
230
- // Duct hosted endpoint
231
- // ----------------------------------------------------------------
232
- async function callDuctEndpoint(options) {
233
- const ductApiBase = getActiveApiBase();
234
- const response = await fetch(`${ductApiBase}/v1/agent/complete`, {
235
- method: "POST",
236
- headers: {
237
- "Content-Type": "application/json",
238
- "Authorization": `Bearer ${options.apiKey}`,
239
- "X-Duct-Agent": options.agentName,
240
- },
241
- body: JSON.stringify({
242
- system: options.systemPrompt,
243
- user: options.userPrompt,
244
- max_tokens: options.maxTokens,
245
- }),
246
- });
247
- if (!response.ok) {
248
- const body = await response.text();
249
- throw new Error(`Duct API error (${response.status}): ${body}`);
250
- }
251
- const data = await response.json();
252
- const text = (data.text ?? data.content ?? "").trim();
253
- return {
254
- text,
255
- parsed: parseJSONResponse(text),
256
- inputTokens: data.usage?.input_tokens ?? 0,
257
- outputTokens: data.usage?.output_tokens ?? 0,
258
- };
259
- }
260
- // ----------------------------------------------------------------
261
- // Helpers
262
- // ----------------------------------------------------------------
263
- function parseJSONResponse(text) {
264
- let cleaned = text.trim();
265
- if (cleaned.startsWith("```")) {
266
- cleaned = cleaned
267
- .replace(/^```(?:json)?\s*/i, "")
268
- .replace(/\s*```\s*$/, "")
269
- .trim();
270
- }
271
- try {
272
- return JSON.parse(cleaned);
273
- }
274
- catch {
275
- const jsonMatch = cleaned.match(/\{[\s\S]*\}|\[[\s\S]*\]/);
276
- if (jsonMatch) {
277
- try {
278
- return JSON.parse(jsonMatch[0]);
279
- }
280
- catch {
281
- // Fall through
282
- }
283
- }
284
- throw new Error(`LLM returned invalid JSON. First 500 chars: ${cleaned.slice(0, 500)}`);
285
- }
286
- }
287
- function sleep(ms) {
288
- return new Promise((resolve) => setTimeout(resolve, ms));
289
- }
290
- /**
291
- * Returns true for transient errors that are safe to retry.
292
- * Auth errors (401/403) and bad-request (400) should fail immediately.
293
- */
294
- function isRetryableError(err) {
295
- const msg = err.message.toLowerCase();
296
- return (msg.includes("429") ||
297
- msg.includes("502") ||
298
- msg.includes("503") ||
299
- msg.includes("504") ||
300
- msg.includes("rate limit") ||
301
- msg.includes("too many requests") ||
302
- msg.includes("overloaded") ||
303
- msg.includes("service unavailable") ||
304
- msg.includes("timeout") ||
305
- msg.includes("econnreset") ||
306
- msg.includes("enotfound") ||
307
- msg.includes("network") ||
308
- msg.includes("socket"));
309
- }
@@ -1,72 +0,0 @@
1
- import { EventEmitter } from "events";
2
- import type { SandboxFS } from "../fs/sandbox.js";
3
- import type { PostProcessOptions } from "../processors/postprocess.js";
4
- import type { ReadList } from "../selectors/index.js";
5
- import type { RouteManifest, ActionManifest, AuthSchema, DeeplinkDefinition, ReviewResult } from "../../core/types.js";
6
- export interface PipelineOptions {
7
- /** Override specific agents */
8
- skipAgents?: Array<"routes" | "actions" | "auth" | "deeplinks" | "review">;
9
- /** Custom event emitter for progress events */
10
- emitter?: PipelineEmitter;
11
- /** Timeout in ms per agent (default: 120_000) */
12
- agentTimeout?: number;
13
- /**
14
- * Bounded file list from the file selector — when provided, agents
15
- * prioritize these files over their own broad scans.
16
- */
17
- readList?: ReadList;
18
- /**
19
- * Raw content of an OpenAPI/Swagger spec file (from --api-spec flag).
20
- * When provided, skips Route + API agents and parses the spec directly.
21
- */
22
- apiSpecContent?: string;
23
- /** Path label for the spec file (used in prompt context). */
24
- apiSpecPath?: string;
25
- /**
26
- * Raw content of a cURL script or Postman collection (from --curl-collection flag).
27
- */
28
- curlCollectionContent?: string;
29
- curlCollectionPath?: string;
30
- /** Options passed to the deterministic post-processing step. */
31
- postProcess?: PostProcessOptions;
32
- }
33
- export interface PipelineResult {
34
- routes: RouteManifest[];
35
- actions: ActionManifest[];
36
- auth: AuthSchema;
37
- deeplinks: DeeplinkDefinition[];
38
- review: ReviewResult;
39
- confidenceScore: number;
40
- /** Duration in ms */
41
- durationMs: number;
42
- }
43
- export type PipelineEventType = "start" | "agent:start" | "agent:complete" | "agent:error" | "complete" | "error";
44
- export interface PipelineEvent {
45
- type: PipelineEventType;
46
- agent?: string;
47
- message?: string;
48
- result?: unknown;
49
- error?: Error;
50
- progress?: number;
51
- }
52
- export type PipelineEventHandler = (event: PipelineEvent) => void;
53
- export interface PipelineEmitter {
54
- emitEvent(event: PipelineEvent): void;
55
- }
56
- export declare class DuctPipelineEmitter extends EventEmitter {
57
- emitEvent(event: PipelineEvent): void;
58
- on(eventName: string | symbol, listener: (...args: any[]) => void): this;
59
- }
60
- /**
61
- * Run the full 5-agent pipeline to analyze a project and produce a DuctConfig.
62
- *
63
- * Pipeline stages:
64
- * 1. Routes + API + Auth agents run in parallel
65
- * 2. Deeplink agent runs with routes + actions results
66
- * 3. Reviewer agent runs with all results
67
- *
68
- * @param sandboxFs - Sandboxed filesystem for the project
69
- * @param opts - Pipeline options
70
- * @returns PipelineResult with all agent outputs
71
- */
72
- export declare function runAgentPipeline(sandboxFs: SandboxFS, opts?: PipelineOptions): Promise<PipelineResult>;