@duct-sdk/sdk 0.1.6

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 (70) hide show
  1. package/README.md +92 -0
  2. package/dist/adapters/next/index.d.ts +4 -0
  3. package/dist/adapters/next/index.js +5 -0
  4. package/dist/adapters/next/receiver.d.ts +44 -0
  5. package/dist/adapters/next/receiver.js +162 -0
  6. package/dist/adapters/next/shell.d.ts +88 -0
  7. package/dist/adapters/next/shell.js +255 -0
  8. package/dist/adapters/react/index.d.ts +2 -0
  9. package/dist/adapters/react/index.js +4 -0
  10. package/dist/adapters/react/shell.d.ts +88 -0
  11. package/dist/adapters/react/shell.js +255 -0
  12. package/dist/adapters/remix/index.d.ts +2 -0
  13. package/dist/adapters/remix/index.js +4 -0
  14. package/dist/adapters/remix/receiver.d.ts +44 -0
  15. package/dist/adapters/remix/receiver.js +153 -0
  16. package/dist/adapters/sveltekit/index.d.ts +2 -0
  17. package/dist/adapters/sveltekit/index.js +4 -0
  18. package/dist/adapters/sveltekit/receiver.d.ts +56 -0
  19. package/dist/adapters/sveltekit/receiver.js +154 -0
  20. package/dist/adapters/vite/index.d.ts +2 -0
  21. package/dist/adapters/vite/index.js +4 -0
  22. package/dist/adapters/vite/receiver.d.ts +82 -0
  23. package/dist/adapters/vite/receiver.js +164 -0
  24. package/dist/assets/logo.d.ts +1 -0
  25. package/dist/assets/logo.js +1 -0
  26. package/dist/cli/agents/api-agent.d.ts +14 -0
  27. package/dist/cli/agents/api-agent.js +656 -0
  28. package/dist/cli/agents/auth-agent.d.ts +6 -0
  29. package/dist/cli/agents/auth-agent.js +198 -0
  30. package/dist/cli/agents/deeplink-agent.d.ts +6 -0
  31. package/dist/cli/agents/deeplink-agent.js +263 -0
  32. package/dist/cli/agents/llm.d.ts +33 -0
  33. package/dist/cli/agents/llm.js +276 -0
  34. package/dist/cli/agents/pipeline.d.ts +51 -0
  35. package/dist/cli/agents/pipeline.js +236 -0
  36. package/dist/cli/agents/reviewer-agent.d.ts +11 -0
  37. package/dist/cli/agents/reviewer-agent.js +442 -0
  38. package/dist/cli/agents/route-agent.d.ts +13 -0
  39. package/dist/cli/agents/route-agent.js +346 -0
  40. package/dist/cli/detectors/auth.d.ts +18 -0
  41. package/dist/cli/detectors/auth.js +273 -0
  42. package/dist/cli/detectors/framework.d.ts +22 -0
  43. package/dist/cli/detectors/framework.js +242 -0
  44. package/dist/cli/drift.d.ts +39 -0
  45. package/dist/cli/drift.js +247 -0
  46. package/dist/cli/fs/sandbox.d.ts +77 -0
  47. package/dist/cli/fs/sandbox.js +295 -0
  48. package/dist/cli/generators/config.d.ts +7 -0
  49. package/dist/cli/generators/config.js +255 -0
  50. package/dist/cli/generators/receiver.d.ts +12 -0
  51. package/dist/cli/generators/receiver.js +683 -0
  52. package/dist/cli/generators/shell.d.ts +18 -0
  53. package/dist/cli/generators/shell.js +672 -0
  54. package/dist/cli/index.d.ts +2 -0
  55. package/dist/cli/index.js +603 -0
  56. package/dist/cli/init.d.ts +26 -0
  57. package/dist/cli/init.js +835 -0
  58. package/dist/core/action.d.ts +37 -0
  59. package/dist/core/action.js +140 -0
  60. package/dist/core/config.d.ts +514 -0
  61. package/dist/core/config.js +221 -0
  62. package/dist/core/endpoints.d.ts +17 -0
  63. package/dist/core/endpoints.js +128 -0
  64. package/dist/core/token.d.ts +70 -0
  65. package/dist/core/token.js +174 -0
  66. package/dist/core/types.d.ts +450 -0
  67. package/dist/core/types.js +11 -0
  68. package/dist/index.d.ts +7 -0
  69. package/dist/index.js +9 -0
  70. package/package.json +84 -0
@@ -0,0 +1,442 @@
1
+ // ============================================================
2
+ // @duct/sdk — Reviewer Agent
3
+ // Validates and scores the pipeline output
4
+ // ============================================================
5
+ import { callDuctLLM } from "./llm.js";
6
+ import { buildAction } from "../../core/action.js";
7
+ // ----------------------------------------------------------------
8
+ // Output schema
9
+ // ----------------------------------------------------------------
10
+ const REVIEW_RESULT_SCHEMA = `
11
+ Single ReviewResult object:
12
+ {
13
+ "passed": true, // Overall pass/fail
14
+ "confidenceScore": 0.87, // 0-1 confidence in the pipeline output
15
+ "issues": [
16
+ {
17
+ "code": "ROUTE_MISSING_DESCRIPTION",
18
+ "severity": "warning", // "error"|"warning"|"info"
19
+ "message": "Route /dashboard has no description",
20
+ "path": "routes[0].description",
21
+ "suggestion": "Add a description explaining what the dashboard shows"
22
+ }
23
+ ],
24
+ "suggestions": [
25
+ "Consider adding a deeplink for the checkout page",
26
+ "Enable agentAccessible on get_orders for a better agent experience"
27
+ ],
28
+ "summary": "Config looks good overall. 2 warnings found."
29
+ }
30
+ `.trim();
31
+ // ----------------------------------------------------------------
32
+ // Rule-based pre-checks
33
+ // ----------------------------------------------------------------
34
+ async function runStaticChecks(input) {
35
+ const issues = [];
36
+ const { routes, actions, auth, deeplinks } = input;
37
+ const seenActionEndpoints = new Set();
38
+ // Routes checks
39
+ for (let i = 0; i < routes.length; i++) {
40
+ const route = routes[i];
41
+ if (!route.description || route.description.trim().length < 10) {
42
+ issues.push({
43
+ code: "ROUTE_SHORT_DESCRIPTION",
44
+ severity: "warning",
45
+ message: `Route "${route.path}" has a missing or very short description`,
46
+ path: `routes[${i}].description`,
47
+ suggestion: "Add a clear description of what this page does or shows",
48
+ });
49
+ }
50
+ if (route.params.length > 0) {
51
+ for (let j = 0; j < route.params.length; j++) {
52
+ if (!route.params[j].description) {
53
+ issues.push({
54
+ code: "PARAM_MISSING_DESCRIPTION",
55
+ severity: "info",
56
+ message: `Route "${route.path}" param "${route.params[j].name}" has no description`,
57
+ path: `routes[${i}].params[${j}].description`,
58
+ suggestion: `Describe what "${route.params[j].name}" represents`,
59
+ });
60
+ }
61
+ }
62
+ }
63
+ }
64
+ // Actions checks
65
+ for (let i = 0; i < actions.length; i++) {
66
+ const action = actions[i];
67
+ const endpointKey = `${action.method}:${action.path}`;
68
+ if (seenActionEndpoints.has(endpointKey)) {
69
+ issues.push({
70
+ code: "DUPLICATE_ACTION_ENDPOINT",
71
+ severity: "warning",
72
+ message: `Duplicate action endpoint detected for ${action.method} ${action.path}`,
73
+ path: `actions[${i}]`,
74
+ suggestion: "Keep only one action per method+path pair unless there is a clear reason to have aliases",
75
+ });
76
+ }
77
+ else {
78
+ seenActionEndpoints.add(endpointKey);
79
+ }
80
+ if (!action.path.startsWith("/api")) {
81
+ issues.push({
82
+ code: "ACTION_NON_API_PATH",
83
+ severity: "warning",
84
+ message: `Action "${action.id}" points to non-API path "${action.path}"`,
85
+ path: `actions[${i}].path`,
86
+ suggestion: "Use concrete backend API endpoints (typically /api/...) and avoid UI route paths in actions",
87
+ });
88
+ }
89
+ if (!action.description || action.description.trim().length < 10) {
90
+ issues.push({
91
+ code: "ACTION_SHORT_DESCRIPTION",
92
+ severity: "warning",
93
+ message: `Action "${action.id}" has a missing or very short description`,
94
+ path: `actions[${i}].description`,
95
+ suggestion: "Add a clear description of what this action does",
96
+ });
97
+ }
98
+ // Warn if high sensitivity actions are marked agent-accessible
99
+ if (action.agentAccessible &&
100
+ (action.sensitivityLevel === "high" || action.sensitivityLevel === "critical")) {
101
+ issues.push({
102
+ code: "HIGH_SENSITIVITY_AGENT_ACCESSIBLE",
103
+ severity: "error",
104
+ message: `Action "${action.id}" is agent-accessible but has sensitivity level "${action.sensitivityLevel}"`,
105
+ path: `actions[${i}].agentAccessible`,
106
+ suggestion: "Only mark agent-accessible for low/medium sensitivity actions, or require explicit user consent",
107
+ });
108
+ }
109
+ // Warn if side-effect actions are agent-accessible without rate limits
110
+ if (action.agentAccessible && action.sideEffects && !action.rateLimit) {
111
+ issues.push({
112
+ code: "AGENT_SIDE_EFFECT_NO_RATE_LIMIT",
113
+ severity: "warning",
114
+ message: `Agent-accessible action "${action.id}" has side effects but no rate limit`,
115
+ path: `actions[${i}].rateLimit`,
116
+ suggestion: "Add a rateLimit (requests/minute) to prevent agent abuse of side-effect actions",
117
+ });
118
+ }
119
+ }
120
+ // Auth checks
121
+ if (auth.strategy === "unknown") {
122
+ issues.push({
123
+ code: "UNKNOWN_AUTH_STRATEGY",
124
+ severity: "warning",
125
+ message: "Auth strategy could not be detected automatically",
126
+ path: "auth.strategy",
127
+ suggestion: "Set auth.strategy explicitly to one of: nextauth, clerk, auth0, custom-jwt, session-cookie, none",
128
+ });
129
+ }
130
+ if (auth.sessionFields.length === 0) {
131
+ issues.push({
132
+ code: "NO_SESSION_FIELDS",
133
+ severity: "error",
134
+ message: "No session fields defined",
135
+ path: "auth.sessionFields",
136
+ suggestion: 'Add at least ["id", "email"] to auth.sessionFields for Duct to identify users',
137
+ });
138
+ }
139
+ if (!auth.sessionFields.includes("id") && !auth.sessionFields.includes("sub") && !auth.sessionFields.includes("userId")) {
140
+ issues.push({
141
+ code: "NO_USER_ID_FIELD",
142
+ severity: "error",
143
+ message: "No user ID field found in session fields",
144
+ path: "auth.sessionFields",
145
+ suggestion: 'Add "id", "sub", or "userId" to auth.sessionFields — Duct needs a stable user identifier',
146
+ });
147
+ }
148
+ // ── agentAccessible coverage check ──────────────────────────
149
+ const agentAccessibleCount = actions.filter((a) => a.agentAccessible).length;
150
+ if (deeplinks.length > 0 && agentAccessibleCount === 0) {
151
+ issues.push({
152
+ code: "NO_AGENT_ACCESSIBLE_ACTIONS",
153
+ severity: "warning",
154
+ message: "Deeplinks are defined but no actions are agent-accessible. Deeplinks can only be auto-triggered by agent requests if at least one action is agentAccessible.",
155
+ path: "actions",
156
+ suggestion: "Mark at least one safe (read-only, low-sensitivity) action as agentAccessible: true",
157
+ });
158
+ }
159
+ // ── Auth consistency check ────────────────────────────────
160
+ const authRequiredActions = actions.filter((a) => a.requiresAuth);
161
+ if (auth.strategy === "none" && authRequiredActions.length > 0) {
162
+ for (let i = 0; i < actions.length; i++) {
163
+ if (actions[i].requiresAuth) {
164
+ issues.push({
165
+ code: "AUTH_STRATEGY_MISMATCH",
166
+ severity: "error",
167
+ message: `Action "${actions[i].id}" requires auth but auth.strategy is "none"`,
168
+ path: `actions[${i}].requiresAuth`,
169
+ suggestion: 'Set auth.strategy to the correct strategy (e.g., "nextauth", "clerk") or set requiresAuth: false',
170
+ });
171
+ }
172
+ }
173
+ }
174
+ // ── Sensitivity coverage check ────────────────────────────
175
+ for (let i = 0; i < actions.length; i++) {
176
+ const action = actions[i];
177
+ if (action.agentAccessible &&
178
+ (action.sensitivityLevel === "high" || action.sensitivityLevel === "critical")) {
179
+ // Already caught by HIGH_SENSITIVITY_AGENT_ACCESSIBLE above — add consent note
180
+ const alreadyFlagged = issues.some((iss) => iss.code === "HIGH_SENSITIVITY_AGENT_ACCESSIBLE" && iss.path === `actions[${i}].agentAccessible`);
181
+ if (!alreadyFlagged) {
182
+ issues.push({
183
+ code: "HIGH_SENSITIVITY_CONSENT_REQUIRED",
184
+ severity: "warning",
185
+ message: `Action "${action.id}" is agent-accessible with ${action.sensitivityLevel} sensitivity — ensure user_consent_token is enforced`,
186
+ path: `actions[${i}].sensitivityLevel`,
187
+ suggestion: "Verify that your auth service validates user_consent_token before executing this action",
188
+ });
189
+ }
190
+ }
191
+ }
192
+ // ── buildAction() validation ─────────────────────────────
193
+ // Call buildAction() on every generated action and verify defaults are sane.
194
+ for (let i = 0; i < actions.length; i++) {
195
+ const action = actions[i];
196
+ try {
197
+ const built = buildAction(action);
198
+ // Test checkPermissions with a default agent context
199
+ const agentCtx = {
200
+ actionId: action.id,
201
+ callerShellId: "shell_test_agent",
202
+ isAgent: true,
203
+ hasUserConsentToken: false,
204
+ callChainDepth: 0,
205
+ avoidInteractivePrompts: true,
206
+ };
207
+ // checkPermissions is always assigned by buildAction() — non-null assertion is safe here.
208
+ // Pass empty params ({}) because we're probing permission defaults, not a real invocation.
209
+ const agentResult = await built.checkPermissions({}, agentCtx);
210
+ // Warn if a non-agentAccessible action would silently allow agent calls
211
+ if (!action.agentAccessible && agentResult.decision === "allow") {
212
+ issues.push({
213
+ code: "BUILD_ACTION_UNEXPECTED_ALLOW",
214
+ severity: "warning",
215
+ message: `Action "${action.id}" is not agentAccessible but buildAction() checkPermissions returns allow for agent calls`,
216
+ path: `actions[${i}].agentAccessible`,
217
+ suggestion: "Review checkPermissions defaults — action may be inadvertently agent-accessible",
218
+ });
219
+ }
220
+ // Warn if an agentAccessible action would unexpectedly deny agent calls
221
+ if (action.agentAccessible && agentResult.decision === "deny") {
222
+ issues.push({
223
+ code: "BUILD_ACTION_UNEXPECTED_DENY",
224
+ severity: "warning",
225
+ message: `Action "${action.id}" is marked agentAccessible but buildAction() checkPermissions returns deny for a standard agent call`,
226
+ path: `actions[${i}].agentAccessible`,
227
+ suggestion: `Check sensitivityLevel (${action.sensitivityLevel}) and requiresAuth (${action.requiresAuth}) — one of these may be blocking agent access`,
228
+ });
229
+ }
230
+ }
231
+ catch (err) {
232
+ issues.push({
233
+ code: "BUILD_ACTION_FAILED",
234
+ severity: "error",
235
+ message: `buildAction() threw for action "${action.id}": ${err instanceof Error ? err.message : String(err)}`,
236
+ path: `actions[${i}]`,
237
+ suggestion: "Fix the action definition so buildAction() can process it without errors",
238
+ });
239
+ }
240
+ }
241
+ // ── Deeplink state populatability check ──────────────────
242
+ const actionResponseFields = new Set();
243
+ for (const action of actions) {
244
+ const schema = action.responseSchema;
245
+ if (schema?.properties && typeof schema.properties === "object") {
246
+ for (const key of Object.keys(schema.properties)) {
247
+ actionResponseFields.add(key);
248
+ }
249
+ }
250
+ }
251
+ // Deeplinks checks
252
+ const routePaths = new Set(routes.map((r) => r.path));
253
+ for (let i = 0; i < deeplinks.length; i++) {
254
+ const deeplink = deeplinks[i];
255
+ // Check target route exists
256
+ if (routes.length > 0 && !routePaths.has(deeplink.targetRoute)) {
257
+ issues.push({
258
+ code: "DEEPLINK_UNKNOWN_ROUTE",
259
+ severity: "error",
260
+ message: `Deeplink "${deeplink.id}" targets route "${deeplink.targetRoute}" which is not in routes[]`,
261
+ path: `deeplinks[${i}].targetRoute`,
262
+ suggestion: "Update targetRoute to match an existing route path",
263
+ });
264
+ }
265
+ if (deeplink.expirySeconds > 3600) {
266
+ issues.push({
267
+ code: "DEEPLINK_LONG_EXPIRY",
268
+ severity: "warning",
269
+ message: `Deeplink "${deeplink.id}" has expiry of ${deeplink.expirySeconds}s (>1 hour)`,
270
+ path: `deeplinks[${i}].expirySeconds`,
271
+ suggestion: "Consider reducing expiry to 300-600 seconds for security",
272
+ });
273
+ }
274
+ if (deeplink.stateFields.length === 0) {
275
+ issues.push({
276
+ code: "DEEPLINK_NO_STATE_FIELDS",
277
+ severity: "info",
278
+ message: `Deeplink "${deeplink.id}" has no state fields`,
279
+ path: `deeplinks[${i}].stateFields`,
280
+ suggestion: "Consider adding state fields to pre-populate the page when the user arrives",
281
+ });
282
+ }
283
+ // Check that required state fields have at least one source
284
+ for (let j = 0; j < deeplink.stateFields.length; j++) {
285
+ const field = deeplink.stateFields[j];
286
+ if (!field.required)
287
+ continue;
288
+ const hasSessionSource = !!field.sessionSource;
289
+ const hasActionSource = actionResponseFields.has(field.key);
290
+ const isCommonSessionField = ["userId", "id", "sub", "orgId", "email"].includes(field.key);
291
+ if (!hasSessionSource && !hasActionSource && !isCommonSessionField) {
292
+ issues.push({
293
+ code: "DEEPLINK_STATE_UNPOPULATABLE",
294
+ severity: "error",
295
+ message: `Deeplink "${deeplink.id}" required field "${field.key}" has no known source (no sessionSource, no action response match)`,
296
+ path: `deeplinks[${i}].stateFields[${j}]`,
297
+ suggestion: `Set sessionSource (e.g., "user.id") or ensure an action returns "${field.key}" in its responseSchema`,
298
+ });
299
+ }
300
+ }
301
+ }
302
+ return issues;
303
+ }
304
+ // ----------------------------------------------------------------
305
+ // runReviewerAgent
306
+ // ----------------------------------------------------------------
307
+ /**
308
+ * Run the Reviewer Agent to validate and score the pipeline output.
309
+ */
310
+ export async function runReviewerAgent(input) {
311
+ // Run static rule-based checks first
312
+ const staticIssues = await runStaticChecks(input);
313
+ // Build LLM review prompt
314
+ const prompt = `Review this Duct configuration for quality, completeness, and correctness.
315
+
316
+ ## Routes (${input.routes.length} total):
317
+ ${JSON.stringify(input.routes.slice(0, 15), null, 2)}
318
+
319
+ ## Actions (${input.actions.length} total):
320
+ ${JSON.stringify(input.actions.slice(0, 15), null, 2)}
321
+
322
+ ## Auth:
323
+ ${JSON.stringify(input.auth, null, 2)}
324
+
325
+ ## Deeplinks (${input.deeplinks.length} total):
326
+ ${JSON.stringify(input.deeplinks, null, 2)}
327
+
328
+ ## Static Issues Already Found:
329
+ ${staticIssues.map((i) => `- [${i.severity}] ${i.code}: ${i.message}`).join("\n") || "None"}
330
+
331
+ Please review for:
332
+ 1. Completeness — are important routes/actions likely missing?
333
+ 2. Consistency — do deeplinks target valid routes? Do action IDs make sense?
334
+ 3. Security — are any sensitive actions incorrectly marked agent-accessible?
335
+ 4. Quality — are descriptions informative enough for an AI to understand intent?
336
+ 5. Coverage — does the deeplink set cover the most important user journeys?
337
+
338
+ Combine the static issues above with any new issues you find.
339
+ Calculate a confidence score (0-1) based on how complete and correct this config appears.
340
+ Set passed: false if there are any "error" severity issues.`;
341
+ let llmResult;
342
+ try {
343
+ const result = await callDuctLLM({
344
+ agentName: "ReviewerAgent",
345
+ systemPrompt: "You are an expert at reviewing Duct configuration manifests. " +
346
+ "You ensure configurations are complete, secure, and well-documented. " +
347
+ "You combine static analysis with semantic understanding of the configuration.",
348
+ userPrompt: prompt,
349
+ outputSchema: REVIEW_RESULT_SCHEMA,
350
+ maxTokens: 3000,
351
+ });
352
+ const raw = result.parsed;
353
+ // Merge static issues with LLM issues
354
+ const allIssues = [
355
+ ...staticIssues,
356
+ ...(Array.isArray(raw.issues) ? raw.issues : []),
357
+ ];
358
+ // De-duplicate by code+path
359
+ const seen = new Set();
360
+ const dedupedIssues = allIssues.filter((issue) => {
361
+ const key = `${issue.code}:${issue.path ?? ""}`;
362
+ if (seen.has(key))
363
+ return false;
364
+ seen.add(key);
365
+ return true;
366
+ });
367
+ const hasErrors = dedupedIssues.some((i) => i.severity === "error");
368
+ llmResult = {
369
+ passed: raw.passed ?? !hasErrors,
370
+ confidenceScore: typeof raw.confidenceScore === "number"
371
+ ? Math.max(0, Math.min(1, raw.confidenceScore))
372
+ : computeConfidence(input, dedupedIssues),
373
+ issues: dedupedIssues,
374
+ suggestions: Array.isArray(raw.suggestions) ? raw.suggestions : [],
375
+ summary: raw.summary ?? buildSummary(dedupedIssues),
376
+ };
377
+ }
378
+ catch {
379
+ // If LLM fails, fall back to static analysis only
380
+ const hasErrors = staticIssues.some((i) => i.severity === "error");
381
+ llmResult = {
382
+ passed: !hasErrors,
383
+ confidenceScore: computeConfidence(input, staticIssues),
384
+ issues: staticIssues,
385
+ suggestions: generateDefaultSuggestions(input),
386
+ summary: buildSummary(staticIssues),
387
+ };
388
+ }
389
+ return llmResult;
390
+ }
391
+ // ----------------------------------------------------------------
392
+ // Helpers
393
+ // ----------------------------------------------------------------
394
+ function computeConfidence(input, issues) {
395
+ let score = 0.5;
396
+ // Reward completeness
397
+ if (input.routes.length > 0)
398
+ score += 0.1;
399
+ if (input.actions.length > 0)
400
+ score += 0.1;
401
+ if (input.deeplinks.length > 0)
402
+ score += 0.1;
403
+ if (input.auth.strategy !== "unknown")
404
+ score += 0.1;
405
+ if (input.auth.sessionFields.length >= 2)
406
+ score += 0.05;
407
+ // Penalize issues
408
+ const errorCount = issues.filter((i) => i.severity === "error").length;
409
+ const warningCount = issues.filter((i) => i.severity === "warning").length;
410
+ score -= errorCount * 0.1;
411
+ score -= warningCount * 0.03;
412
+ return Math.max(0, Math.min(1, score));
413
+ }
414
+ function buildSummary(issues) {
415
+ const errors = issues.filter((i) => i.severity === "error").length;
416
+ const warnings = issues.filter((i) => i.severity === "warning").length;
417
+ const infos = issues.filter((i) => i.severity === "info").length;
418
+ if (issues.length === 0) {
419
+ return "Config looks great! No issues found.";
420
+ }
421
+ const parts = [];
422
+ if (errors > 0)
423
+ parts.push(`${errors} error${errors !== 1 ? "s" : ""}`);
424
+ if (warnings > 0)
425
+ parts.push(`${warnings} warning${warnings !== 1 ? "s" : ""}`);
426
+ if (infos > 0)
427
+ parts.push(`${infos} suggestion${infos !== 1 ? "s" : ""}`);
428
+ return `Review complete. Found ${parts.join(", ")}.`;
429
+ }
430
+ function generateDefaultSuggestions(input) {
431
+ const suggestions = [];
432
+ if (input.actions.filter((a) => a.agentAccessible).length === 0) {
433
+ suggestions.push("Consider enabling agentAccessible: true on read-only actions to improve AI assistant capabilities");
434
+ }
435
+ if (input.deeplinks.length === 0) {
436
+ suggestions.push("Add at least one deeplink target to enable the AI to navigate users to specific pages");
437
+ }
438
+ if (input.routes.length > 10 && input.deeplinks.length < 3) {
439
+ suggestions.push("Your app has many routes — consider adding more deeplinks for common user journeys");
440
+ }
441
+ return suggestions;
442
+ }
@@ -0,0 +1,13 @@
1
+ import type { SandboxFS } from "../fs/sandbox.js";
2
+ import type { RouteManifest } from "../../core/types.js";
3
+ export interface RouteScannerStrategy {
4
+ readonly name: string;
5
+ /** Returns true if this strategy should handle the project. */
6
+ detect(sandboxFs: SandboxFS): Promise<boolean>;
7
+ /** Append framework-specific file listings and snippets to the prompt lines. */
8
+ appendPromptContext(sandboxFs: SandboxFS, lines: string[]): Promise<void>;
9
+ }
10
+ /**
11
+ * Run the Route Agent to produce a RouteManifest[] from the project structure.
12
+ */
13
+ export declare function runRouteAgent(sandboxFs: SandboxFS): Promise<RouteManifest[]>;