@agent-native/core 0.131.6 → 0.131.7
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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +7 -0
- package/corpus/core/docs/content/deployment.mdx +12 -10
- package/corpus/core/docs/content/security.mdx +2 -2
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/invoke.ts +4 -2
- package/corpus/core/src/agent/action-continuation-guidance.ts +2 -1
- package/corpus/core/src/agent/engine/registry.ts +61 -9
- package/corpus/core/src/guards/no-env-credentials.ts +2 -0
- package/corpus/core/src/scripts/call-agent.ts +4 -2
- package/corpus/core/src/secrets/crypto.ts +44 -15
- package/corpus/core/src/secrets/storage.ts +6 -4
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +2 -0
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +14 -9
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +14 -9
- package/corpus/core/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -9
- package/corpus/templates/analytics/AGENTS.md +1 -0
- package/corpus/templates/analytics/changelog/2026-07-30-delegated-analytics-questions-now-return-a-useful-current-me.md +6 -0
- package/corpus/templates/analytics/server/lib/real-data-actions.ts +10 -0
- package/corpus/templates/plan/actions/get-visual-plan.ts +10 -6
- package/corpus/templates/plan/actions/patch-visual-plan-source.ts +117 -1
- package/corpus/templates/plan/actions/update-visual-plan.ts +56 -14
- package/corpus/templates/plan/app/pages/PlansPage.tsx +1 -1
- package/corpus/templates/plan/changelog/2026-07-30-plan-agents-recover-with-targeted-writes.md +6 -0
- package/corpus/templates/plan/shared/plan-content.ts +35 -0
- package/corpus/templates/slides/actions/create-deck.ts +1 -1
- package/corpus/templates/slides/changelog/2026-07-30-new-decks-now-start-with-an-empty-slide-list-when-no-slides-.md +6 -0
- package/dist/a2a/invoke.d.ts.map +1 -1
- package/dist/a2a/invoke.js +4 -2
- package/dist/a2a/invoke.js.map +1 -1
- package/dist/agent/action-continuation-guidance.d.ts.map +1 -1
- package/dist/agent/action-continuation-guidance.js +2 -1
- package/dist/agent/action-continuation-guidance.js.map +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +59 -12
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/guards/no-env-credentials.d.ts.map +1 -1
- package/dist/guards/no-env-credentials.js +2 -0
- package/dist/guards/no-env-credentials.js.map +1 -1
- package/dist/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -1
- package/dist/notifications/routes.d.ts +6 -6
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +4 -2
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/secrets/crypto.d.ts +14 -9
- package/dist/secrets/crypto.d.ts.map +1 -1
- package/dist/secrets/crypto.js +42 -16
- package/dist/secrets/crypto.js.map +1 -1
- package/dist/secrets/storage.d.ts +6 -4
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +6 -4
- package/dist/secrets/storage.js.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.js +2 -0
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -1
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +14 -9
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +14 -9
- package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -9
- package/docs/content/deployment.mdx +12 -10
- package/docs/content/security.mdx +2 -2
- package/package.json +3 -3
- package/src/a2a/invoke.ts +4 -2
- package/src/agent/action-continuation-guidance.ts +2 -1
- package/src/agent/engine/registry.ts +61 -9
- package/src/guards/no-env-credentials.ts +2 -0
- package/src/scripts/call-agent.ts +4 -2
- package/src/secrets/crypto.ts +44 -15
- package/src/secrets/storage.ts +6 -4
- package/src/server/agent-chat/action-filters-a2a.ts +2 -0
- package/src/templates/default/.agents/skills/secrets/SKILL.md +14 -9
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +14 -9
- package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +14 -9
|
@@ -28,6 +28,73 @@ import {
|
|
|
28
28
|
} from "../server/plans.js";
|
|
29
29
|
import type { PlanContent } from "../shared/plan-content.js";
|
|
30
30
|
|
|
31
|
+
const agentPlanMdxSourcePatchesSchema = z
|
|
32
|
+
.array(
|
|
33
|
+
z.discriminatedUnion("op", [
|
|
34
|
+
z.object({
|
|
35
|
+
op: z.literal("replace-markdown-block"),
|
|
36
|
+
blockId: z.string().min(1),
|
|
37
|
+
markdown: z.string().max(16_000),
|
|
38
|
+
title: z.string().optional(),
|
|
39
|
+
}),
|
|
40
|
+
z.object({
|
|
41
|
+
op: z.literal("update-component-prop"),
|
|
42
|
+
file: z.enum(["plan.mdx", "canvas.mdx", "prototype.mdx"]),
|
|
43
|
+
componentId: z.string().min(1),
|
|
44
|
+
prop: z.string().min(1),
|
|
45
|
+
value: z.unknown(),
|
|
46
|
+
}),
|
|
47
|
+
z.object({
|
|
48
|
+
op: z.literal("update-wireframe-node"),
|
|
49
|
+
nodeId: z.string().min(1),
|
|
50
|
+
patch: z.record(z.string(), z.unknown()),
|
|
51
|
+
}),
|
|
52
|
+
z.object({
|
|
53
|
+
op: z.literal("update-annotation"),
|
|
54
|
+
annotationId: z.string().min(1),
|
|
55
|
+
patch: z.object({
|
|
56
|
+
type: z.enum(["note", "text", "callout", "arrow"]).optional(),
|
|
57
|
+
title: z.string().optional(),
|
|
58
|
+
text: z.string().max(2_000).optional(),
|
|
59
|
+
points: z
|
|
60
|
+
.array(z.object({ x: z.number(), y: z.number() }))
|
|
61
|
+
.min(1)
|
|
62
|
+
.max(12)
|
|
63
|
+
.optional(),
|
|
64
|
+
style: z
|
|
65
|
+
.object({
|
|
66
|
+
tone: z
|
|
67
|
+
.enum(["default", "accent", "warn", "ok", "muted"])
|
|
68
|
+
.optional(),
|
|
69
|
+
stroke: z.enum(["solid", "dashed"]).optional(),
|
|
70
|
+
width: z.number().min(1).max(12).optional(),
|
|
71
|
+
})
|
|
72
|
+
.optional(),
|
|
73
|
+
targetId: z.string().optional(),
|
|
74
|
+
placement: z
|
|
75
|
+
.enum([
|
|
76
|
+
"top",
|
|
77
|
+
"right",
|
|
78
|
+
"bottom",
|
|
79
|
+
"left",
|
|
80
|
+
"top-left",
|
|
81
|
+
"top-right",
|
|
82
|
+
"bottom-left",
|
|
83
|
+
"bottom-right",
|
|
84
|
+
])
|
|
85
|
+
.optional(),
|
|
86
|
+
x: z.number().optional(),
|
|
87
|
+
y: z.number().optional(),
|
|
88
|
+
}),
|
|
89
|
+
}),
|
|
90
|
+
]),
|
|
91
|
+
)
|
|
92
|
+
.max(80)
|
|
93
|
+
.describe(
|
|
94
|
+
"Small exported-MDX patches only. Never send replace-file or replace-artboard " +
|
|
95
|
+
"from an agent; for a live plan use update-visual-plan contentPatches instead.",
|
|
96
|
+
);
|
|
97
|
+
|
|
31
98
|
type PlanSurfaceCounts = {
|
|
32
99
|
blocks: number;
|
|
33
100
|
canvasFrames: number;
|
|
@@ -42,6 +109,28 @@ function planSurfaceCounts(content: PlanContent | null | undefined) {
|
|
|
42
109
|
} satisfies PlanSurfaceCounts;
|
|
43
110
|
}
|
|
44
111
|
|
|
112
|
+
function compactAgentWriteResult(
|
|
113
|
+
bundle: Awaited<ReturnType<typeof loadPlanBundle>>,
|
|
114
|
+
changed: Record<string, unknown>,
|
|
115
|
+
) {
|
|
116
|
+
return {
|
|
117
|
+
planId: bundle.plan.id,
|
|
118
|
+
plan: {
|
|
119
|
+
id: bundle.plan.id,
|
|
120
|
+
title: bundle.plan.title,
|
|
121
|
+
brief: bundle.plan.brief,
|
|
122
|
+
kind: bundle.plan.kind,
|
|
123
|
+
status: bundle.plan.status,
|
|
124
|
+
currentFocus: bundle.plan.currentFocus,
|
|
125
|
+
updatedAt: bundle.plan.updatedAt,
|
|
126
|
+
surfaces: planSurfaceCounts(bundle.plan.content),
|
|
127
|
+
},
|
|
128
|
+
changed,
|
|
129
|
+
path: planPath(bundle.plan.id, bundle.plan.kind),
|
|
130
|
+
url: planPath(bundle.plan.id, bundle.plan.kind),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
45
134
|
function stableJson(value: unknown): string {
|
|
46
135
|
if (value === null) return "null";
|
|
47
136
|
if (value === undefined) return "undefined";
|
|
@@ -140,7 +229,7 @@ function assertNoUnexpectedSurfaceCollapse(
|
|
|
140
229
|
|
|
141
230
|
export default defineAction({
|
|
142
231
|
description:
|
|
143
|
-
"Patch the MDX source for an Agent-Native Plan by stable semantic IDs, then normalize it back into runtime JSON. Use ONLY when working with exported MDX source files (repo check-in workflows); for live plans prefer update-visual-plan with contentPatches.
|
|
232
|
+
"Patch the MDX source for an Agent-Native Plan by stable semantic IDs, then normalize it back into runtime JSON. Use ONLY when working with exported MDX source files (repo check-in workflows); for live plans prefer update-visual-plan with contentPatches. For agent calls, use only small semantic patches and never resend replace-file or replace-artboard payloads.",
|
|
144
233
|
schema: z.object({
|
|
145
234
|
planId: z.string().describe("Plan ID"),
|
|
146
235
|
expectedUpdatedAt: z
|
|
@@ -162,6 +251,21 @@ export default defineAction({
|
|
|
162
251
|
),
|
|
163
252
|
note: z.string().optional().describe("Short audit note for plan history."),
|
|
164
253
|
}),
|
|
254
|
+
agentInputSchema: z.object({
|
|
255
|
+
planId: z.string().describe("Plan ID"),
|
|
256
|
+
expectedUpdatedAt: z
|
|
257
|
+
.string()
|
|
258
|
+
.min(1)
|
|
259
|
+
.optional()
|
|
260
|
+
.describe("Revision from the latest plan read when required."),
|
|
261
|
+
allowDestructive: z
|
|
262
|
+
.boolean()
|
|
263
|
+
.optional()
|
|
264
|
+
.default(false)
|
|
265
|
+
.describe("Allow an intentional nonempty-to-empty collapse."),
|
|
266
|
+
patches: agentPlanMdxSourcePatchesSchema,
|
|
267
|
+
note: z.string().optional().describe("Short audit note for plan history."),
|
|
268
|
+
}),
|
|
165
269
|
publicAgent: {
|
|
166
270
|
expose: true,
|
|
167
271
|
readOnly: false,
|
|
@@ -321,6 +425,18 @@ export default defineAction({
|
|
|
321
425
|
),
|
|
322
426
|
})
|
|
323
427
|
: null;
|
|
428
|
+
if (isAgentCaller) {
|
|
429
|
+
return {
|
|
430
|
+
...compactAgentWriteResult(updated, {
|
|
431
|
+
patchOps: args.patches.map((patch) => patch.op),
|
|
432
|
+
counts: {
|
|
433
|
+
before: beforeCounts,
|
|
434
|
+
after: afterCounts,
|
|
435
|
+
},
|
|
436
|
+
}),
|
|
437
|
+
...(local?.written ? { localFiles: local } : {}),
|
|
438
|
+
};
|
|
439
|
+
}
|
|
324
440
|
return {
|
|
325
441
|
...updated,
|
|
326
442
|
planId: updated.plan.id,
|
|
@@ -49,8 +49,7 @@ import {
|
|
|
49
49
|
sectionInputSchema,
|
|
50
50
|
} from "../server/plans.js";
|
|
51
51
|
import {
|
|
52
|
-
|
|
53
|
-
agentPlanContentSchema,
|
|
52
|
+
agentPlanIncrementalContentPatchesSchema,
|
|
54
53
|
applyPlanContentPatches,
|
|
55
54
|
planContentPatchesSchema,
|
|
56
55
|
planContentSchema,
|
|
@@ -454,6 +453,32 @@ const CONTENT_DESCRIPTION =
|
|
|
454
453
|
const CONTENT_PATCHES_DESCRIPTION =
|
|
455
454
|
"Targeted structured content edits addressed by stable id. Prefer granular operations for live plans. The destructive replace-blocks operation requires expectedUpdatedAt from a fresh read. patch-visual-plan-source is only for exported MDX folders. Supported ops: set-metadata for title/brief; set-visual-render-mode to persist `design` (high fidelity, authored CSS, no rough.js for any viewer) or `wireframe` across canvas, linked blocks, and prototype screens; set-prototype / remove-prototype / update-prototype-screen / patch-prototype-html for live prototype surfaces; update-block / replace-block, update-rich-text, patch-wireframe-html, patch-diagram-html, update-wireframe-node, replace-wireframe-screen, update-canvas-frame, update-canvas-annotation / append-canvas-annotation, append-block / remove-block, update-custom-html. A fidelity upgrade must also replace or patch the existing screen HTML/CSS with deliberate branded design; changing render mode alone only removes the sketch treatment.";
|
|
456
455
|
|
|
456
|
+
function compactAgentWriteResult(
|
|
457
|
+
bundle: Awaited<ReturnType<typeof loadPlanBundle>>,
|
|
458
|
+
changed: Record<string, unknown>,
|
|
459
|
+
) {
|
|
460
|
+
return {
|
|
461
|
+
planId: bundle.plan.id,
|
|
462
|
+
plan: {
|
|
463
|
+
id: bundle.plan.id,
|
|
464
|
+
title: bundle.plan.title,
|
|
465
|
+
brief: bundle.plan.brief,
|
|
466
|
+
kind: bundle.plan.kind,
|
|
467
|
+
status: bundle.plan.status,
|
|
468
|
+
currentFocus: bundle.plan.currentFocus,
|
|
469
|
+
updatedAt: bundle.plan.updatedAt,
|
|
470
|
+
surfaces: {
|
|
471
|
+
blocks: bundle.plan.content?.blocks.length ?? 0,
|
|
472
|
+
canvasFrames: bundle.plan.content?.canvas?.frames.length ?? 0,
|
|
473
|
+
prototypeScreens: bundle.plan.content?.prototype?.screens.length ?? 0,
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
changed,
|
|
477
|
+
path: planPath(bundle.plan.id, bundle.plan.kind),
|
|
478
|
+
url: planPath(bundle.plan.id, bundle.plan.kind),
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
457
482
|
// Named so `agentInputSchema` below can `.extend()` it with compact
|
|
458
483
|
// `content`/`contentPatches` fields instead of duplicating every other key.
|
|
459
484
|
const updateVisualPlanSchema = z.object({
|
|
@@ -527,21 +552,26 @@ const updateVisualPlanSchema = z.object({
|
|
|
527
552
|
.describe("Short label saved as the version-history snapshot label."),
|
|
528
553
|
});
|
|
529
554
|
|
|
555
|
+
// ADVERTISED-ONLY: agent edits to an existing plan must stay incremental. The
|
|
556
|
+
// runtime schema above still accepts full replacements for the browser editor
|
|
557
|
+
// and explicit callers that have intentionally chosen that workflow.
|
|
558
|
+
const agentUpdateVisualPlanSchema = updateVisualPlanSchema
|
|
559
|
+
.omit({ content: true, html: true, markdown: true, sections: true })
|
|
560
|
+
.extend({
|
|
561
|
+
contentPatches: agentPlanIncrementalContentPatchesSchema
|
|
562
|
+
.optional()
|
|
563
|
+
.default([])
|
|
564
|
+
.describe(
|
|
565
|
+
"Small targeted edits only. Do not send full content or replace-blocks; " +
|
|
566
|
+
"append or patch one existing block at a time.",
|
|
567
|
+
),
|
|
568
|
+
});
|
|
569
|
+
|
|
530
570
|
export default defineAction({
|
|
531
571
|
description:
|
|
532
|
-
"Update an Agent-Native Plan's structured content blocks, prototype screens, visual fidelity, sections, comments, or status.
|
|
572
|
+
"Update an Agent-Native Plan's structured content blocks, prototype screens, visual fidelity, sections, comments, or status. For an existing plan, use small contentPatches such as append-block, update-rich-text, or a text patch; do not resend the full document for an incremental edit. When a user asks for higher fidelity on an existing plan, update that same plan in place: use set-visual-render-mode with design and provide polished screen HTML/CSS in the same call instead of creating a duplicate plan or only toggling the viewer-local clean style. Use a full replacement only for an explicit broad rebuild. Works on plans and recaps alike when you have editor access; with viewer access (common on PR recaps published by CI) only comment-only calls succeed - to change a recap you cannot edit, publish a replacement with create-visual-recap instead of retrying this call.",
|
|
533
573
|
schema: updateVisualPlanSchema,
|
|
534
|
-
|
|
535
|
-
// swap the deep per-block-type union for a compact `type`-enum stand-in.
|
|
536
|
-
// Runtime validation always runs the full schema above — see the `actions`
|
|
537
|
-
// skill.
|
|
538
|
-
agentInputSchema: updateVisualPlanSchema.extend({
|
|
539
|
-
content: agentPlanContentSchema.optional().describe(CONTENT_DESCRIPTION),
|
|
540
|
-
contentPatches: agentPlanContentPatchesSchema
|
|
541
|
-
.optional()
|
|
542
|
-
.default([])
|
|
543
|
-
.describe(CONTENT_PATCHES_DESCRIPTION),
|
|
544
|
-
}),
|
|
574
|
+
agentInputSchema: agentUpdateVisualPlanSchema,
|
|
545
575
|
publicAgent: {
|
|
546
576
|
expose: true,
|
|
547
577
|
readOnly: false,
|
|
@@ -1173,6 +1203,18 @@ export default defineAction({
|
|
|
1173
1203
|
),
|
|
1174
1204
|
})
|
|
1175
1205
|
: null;
|
|
1206
|
+
if (isAgentCaller) {
|
|
1207
|
+
return {
|
|
1208
|
+
...compactAgentWriteResult(bundle, {
|
|
1209
|
+
titleChanged: args.title !== undefined,
|
|
1210
|
+
briefChanged: args.brief !== undefined,
|
|
1211
|
+
statusChanged: args.status !== undefined,
|
|
1212
|
+
contentPatchOps: args.contentPatches.map((patch) => patch.op),
|
|
1213
|
+
commentCount: insertedCommentIds.length,
|
|
1214
|
+
}),
|
|
1215
|
+
...(local?.written ? { localFiles: local } : {}),
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1176
1218
|
return {
|
|
1177
1219
|
...bundle,
|
|
1178
1220
|
planId: bundle.plan.id,
|
|
@@ -1602,7 +1602,7 @@ export function buildPlanAgentContext(input: {
|
|
|
1602
1602
|
: [
|
|
1603
1603
|
"Fast iteration workflow:",
|
|
1604
1604
|
"1. Call get-visual-plan with this plan ID to read structured content, exported HTML, sections, comments, and activity.",
|
|
1605
|
-
'2. Prefer update-visual-plan contentPatches for
|
|
1605
|
+
'2. Prefer small update-visual-plan contentPatches for every edit to an existing plan. Examples: append-block for new tasks, update-rich-text for a bounded copy change, patch-prototype-html / update-prototype-screen for live prototype states, update-wireframe-node for one kit-tree node, update-canvas-frame for frame layout, append-canvas-annotation / update-canvas-annotation for canvas markup, or remove-block for one block. Never resend the full plan, use replace-blocks, or use patch-visual-plan-source replace-file for an incremental change - those payloads can be truncated before the tool receives them. When the user asks for higher fidelity, polished mockups, production-like UI, real design, or anything "not sketchy," update this same plan in place: rewrite the relevant screen HTML/CSS and include set-visual-render-mode with renderMode design. Do not create a second plan, put CSS in style tags, or treat the viewer-local Clean toggle as a fidelity upgrade. Use a full replacement only for an explicit broad rebuild. Use html only when preserving or importing a legacy standalone HTML artifact.',
|
|
1606
1606
|
"3. Preserve the user's existing annotation comments and intent unless the user asks to remove or resolve them.",
|
|
1607
1607
|
"4. Match the requested fidelity: ordinary UI planning can use sketch diagrams and wireframes; high-fidelity requests need the persisted Design surface with deliberate branded HTML/CSS and stable data-design-id targets.",
|
|
1608
1608
|
"5. After applying feedback, keep the plan scannable, editable, and serious instead of turning it into a marketing page.",
|
|
@@ -2944,6 +2944,41 @@ export const agentPlanContentPatchesSchema = z
|
|
|
2944
2944
|
"replace-block / replace-blocks / append-block.",
|
|
2945
2945
|
);
|
|
2946
2946
|
|
|
2947
|
+
/**
|
|
2948
|
+
* Model-facing patch vocabulary for edits to an existing hosted plan. Full
|
|
2949
|
+
* block/content replacement remains valid at runtime for the browser editor
|
|
2950
|
+
* and explicit callers, but advertising it to an agent makes it too easy to
|
|
2951
|
+
* resend the whole document and hit the provider's streamed-JSON limit.
|
|
2952
|
+
*/
|
|
2953
|
+
const AGENT_INCREMENTAL_PATCH_EXCLUDED_OPS = new Set([
|
|
2954
|
+
"set-prototype",
|
|
2955
|
+
"replace-block",
|
|
2956
|
+
"replace-blocks",
|
|
2957
|
+
"replace-wireframe-screen",
|
|
2958
|
+
]);
|
|
2959
|
+
|
|
2960
|
+
const agentIncrementalPlanContentPatchOptions =
|
|
2961
|
+
agentPlanContentPatchOptions.filter((option) => {
|
|
2962
|
+
const op = (option.shape as { op: { value: string } }).op.value;
|
|
2963
|
+
return !AGENT_INCREMENTAL_PATCH_EXCLUDED_OPS.has(op);
|
|
2964
|
+
});
|
|
2965
|
+
|
|
2966
|
+
export const agentPlanIncrementalContentPatchesSchema = z
|
|
2967
|
+
.array(
|
|
2968
|
+
z.discriminatedUnion(
|
|
2969
|
+
"op",
|
|
2970
|
+
agentIncrementalPlanContentPatchOptions as unknown as Parameters<
|
|
2971
|
+
typeof z.discriminatedUnion
|
|
2972
|
+
>[1],
|
|
2973
|
+
),
|
|
2974
|
+
)
|
|
2975
|
+
.max(80)
|
|
2976
|
+
.describe(
|
|
2977
|
+
"Small targeted edits to an existing plan. Prefer append-block, update-rich-text, " +
|
|
2978
|
+
"patch-wireframe-html, patch-prototype-html, or update-block. Do not " +
|
|
2979
|
+
"resend the full plan; use get-visual-plan for context and keep each call incremental.",
|
|
2980
|
+
);
|
|
2981
|
+
|
|
2947
2982
|
export function applyPlanContentPatches(
|
|
2948
2983
|
content: PlanContent,
|
|
2949
2984
|
patches: PlanContentPatch[],
|
|
@@ -75,7 +75,7 @@ const SlideSchema = z.object({
|
|
|
75
75
|
|
|
76
76
|
// Accept either a parsed array (HTTP/agent) or a JSON string (CLI)
|
|
77
77
|
const SlidesSchema = z.preprocess(
|
|
78
|
-
(v) => (typeof v === "string" ? JSON.parse(v) : v),
|
|
78
|
+
(v) => (v === undefined ? [] : typeof v === "string" ? JSON.parse(v) : v),
|
|
79
79
|
z.array(SlideSchema),
|
|
80
80
|
);
|
|
81
81
|
|
package/dist/a2a/invoke.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../src/a2a/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,IAAI,qBAAqB,EACvC,SAAS,IAAI,gBAAgB,EAC7B,KAAK,eAAe,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,UAAU,IAAI,iBAAiB,EAC/B,SAAS,IAAI,gBAAgB,EAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,wBAAwB,GAChC,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,WAAW,GACX,WAAW,CAAC;AAEhB,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,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AChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mCAAwC,GAChD,OAAO,CAAC,6BAA6B,CAAC,CAqDxC;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CAwChC;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,2BAA2B,CAAC,CAkCtC;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,MAAM,CASR;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAExD"}
|
package/dist/a2a/invoke.js
CHANGED
|
@@ -121,9 +121,11 @@ export async function invokeAgentAction(options) {
|
|
|
121
121
|
}
|
|
122
122
|
export function buildAgentInvocationPrompt(prompt, agentUrl) {
|
|
123
123
|
return (`${prompt}\n\n` +
|
|
124
|
-
|
|
124
|
+
`<a2a-caller-hint>\n` +
|
|
125
|
+
`This request comes from another app via A2A. The caller cannot see your local UI, resource list, or navigation - only the literal text you put in your reply. ` +
|
|
125
126
|
`If you create or reference a deck/document/design/dashboard/resource, include its FULLY-QUALIFIED URL (e.g. ${agentUrl.replace(/\/$/, "")}/<path>/<id>) in your reply, not a relative path. ` +
|
|
126
|
-
`Use only artifact IDs and URL paths returned by successful actions - never invent slugs, IDs, or hosts
|
|
127
|
+
`Use only artifact IDs and URL paths returned by successful actions - never invent slugs, IDs, or hosts.\n` +
|
|
128
|
+
`</a2a-caller-hint>`);
|
|
127
129
|
}
|
|
128
130
|
export function looksLikeAgentUrl(value) {
|
|
129
131
|
return /^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim());
|
package/dist/a2a/invoke.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.js","sourceRoot":"","sources":["../../src/a2a/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,IAAI,qBAAqB,EACvC,SAAS,IAAI,gBAAgB,GAE9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,UAAU,IAAI,iBAAiB,EAC/B,SAAS,IAAI,gBAAgB,GAC9B,MAAM,aAAa,CAAC;AAerB,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAA2B;IAC/B,MAAM,CAAU;IAChB,eAAe,CAAqB;IAE7C,YACE,IAA8B,EAC9B,OAAe,EACf,OAAkE;QAElE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;QAC9B,IAAI,CAAC,eAAe,GAAG,OAAO,EAAE,eAAe,CAAC;IAClD,CAAC;CACF;AAkED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,MAAc,EACd,OAAO,GAAwC,EAAE;IAEjD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,oBAAoB,CAC5B,gBAAgB,EAChB,iCAAiC,CAClC,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,SAAS,EAAE,CAAC;QACd,gBAAgB,CAAC,SAAS,EAAE,OAAO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C;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IACE,UAAU,KAAK,OAAO;QACtB,UAAU,KAAK,QAAQ;QACvB,UAAU,KAAK,OAAO,EACtB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,OAAO,0DAA0D,SAAS,iIAAiI,CAAC;AAC9M,CAAC","sourcesContent":["import {\n discoverAgents as defaultDiscoverAgents,\n findAgent as defaultFindAgent,\n type DiscoveredAgent,\n} from \"../server/agent-discovery.js\";\nimport {\n callAction as defaultCallAction,\n callAgent as defaultCallAgent,\n} from \"./client.js\";\nimport type {\n A2ACorrelationMetadata,\n A2AReadOnlyActionResult,\n} from \"./types.js\";\n\nexport type AgentInvocationErrorCode =\n | \"missing-target\"\n | \"missing-prompt\"\n | \"missing-action\"\n | \"invalid-input\"\n | \"invalid-url\"\n | \"self-call\"\n | \"not-found\";\n\nexport class AgentInvocationError extends Error {\n readonly code: AgentInvocationErrorCode;\n readonly target?: string;\n readonly availableAgents?: DiscoveredAgent[];\n\n constructor(\n code: AgentInvocationErrorCode,\n message: string,\n options?: { target?: string; availableAgents?: DiscoveredAgent[] },\n ) {\n super(message);\n this.name = \"AgentInvocationError\";\n this.code = code;\n this.target = options?.target;\n this.availableAgents = options?.availableAgents;\n }\n}\n\nexport interface ResolvedAgentInvocationTarget {\n kind: \"discovered\" | \"url\";\n id?: string;\n name: string;\n description?: string;\n url: string;\n color?: string;\n}\n\nexport interface AgentInvocationResult {\n target: ResolvedAgentInvocationTarget;\n prompt: string;\n responseText: string;\n}\n\nexport interface AgentActionInvocationResult {\n target: ResolvedAgentInvocationTarget;\n action: string;\n result: A2AReadOnlyActionResult;\n}\n\nexport interface AgentInvocationRuntime {\n findAgent: typeof defaultFindAgent;\n discoverAgents: typeof defaultDiscoverAgents;\n callAgent: typeof defaultCallAgent;\n callAction: typeof defaultCallAction;\n}\n\nexport interface ResolveAgentInvocationTargetOptions {\n selfAppId?: string;\n selfUrl?: string;\n runtime?: Partial<AgentInvocationRuntime>;\n}\n\nexport interface InvokeAgentOptions extends ResolveAgentInvocationTargetOptions {\n target: string;\n prompt: string;\n apiKey?: string;\n contextId?: string;\n userEmail?: string;\n orgDomain?: string;\n orgSecret?: string;\n async?: boolean;\n timeoutMs?: number;\n pollIntervalMs?: number;\n includeInvocationHint?: boolean;\n correlation?: A2ACorrelationMetadata;\n idempotencyKey?: string;\n runtime?: Partial<AgentInvocationRuntime>;\n}\n\nexport interface InvokeAgentActionOptions extends ResolveAgentInvocationTargetOptions {\n target: string;\n action: string;\n input?: Record<string, unknown>;\n apiKey?: string;\n userEmail?: string;\n orgDomain?: string;\n orgSecret?: string;\n requestTimeoutMs?: number;\n correlation?: A2ACorrelationMetadata;\n runtime?: Partial<AgentInvocationRuntime>;\n}\n\n/**\n * Resolve an A2A invocation target from a direct URL or from the connected app\n * registry. ID/name resolution deliberately uses the same discovery path as\n * the in-agent `call-agent` script.\n */\nexport async function resolveAgentInvocationTarget(\n target: string,\n options: ResolveAgentInvocationTargetOptions = {},\n): Promise<ResolvedAgentInvocationTarget> {\n const cleanTarget = target.trim();\n if (!cleanTarget) {\n throw new AgentInvocationError(\n \"missing-target\",\n \"Error: agent target is required\",\n );\n }\n\n const directUrl = parseAgentUrl(cleanTarget);\n if (directUrl) {\n assertNotSelfUrl(directUrl, options.selfUrl);\n return {\n kind: \"url\",\n name: directUrl,\n url: directUrl,\n };\n }\n\n if (\n options.selfAppId &&\n normalizeAgentHandle(cleanTarget) ===\n normalizeAgentHandle(options.selfAppId)\n ) {\n throw new AgentInvocationError(\n \"self-call\",\n formatSelfCallError(options.selfAppId),\n { target: cleanTarget },\n );\n }\n\n const findAgent = options.runtime?.findAgent ?? defaultFindAgent;\n const discoverAgents =\n options.runtime?.discoverAgents ?? defaultDiscoverAgents;\n const agent = await findAgent(cleanTarget, options.selfAppId);\n if (!agent) {\n const availableAgents = await discoverAgents(options.selfAppId);\n const available = availableAgents.map((a) => a.name).join(\", \");\n throw new AgentInvocationError(\n \"not-found\",\n `Error: Agent \"${cleanTarget}\" not found. Available agents: ${available || \"(none)\"}`,\n { target: cleanTarget, availableAgents },\n );\n }\n\n return {\n kind: \"discovered\",\n id: agent.id,\n name: agent.name,\n description: agent.description,\n url: agent.url,\n color: agent.color,\n };\n}\n\n/**\n * First-class headless A2A primitive: resolve an app/agent by id, name, or URL,\n * send a text prompt, and return the text response with target metadata.\n */\nexport async function invokeAgent(\n options: InvokeAgentOptions,\n): Promise<AgentInvocationResult> {\n const prompt = options.prompt;\n if (!prompt.trim()) {\n throw new AgentInvocationError(\n \"missing-prompt\",\n \"Error: prompt is required\",\n { target: options.target },\n );\n }\n\n const target = await resolveAgentInvocationTarget(options.target, {\n selfAppId: options.selfAppId,\n selfUrl: options.selfUrl,\n runtime: options.runtime,\n });\n\n const promptToSend =\n options.includeInvocationHint === false\n ? prompt\n : buildAgentInvocationPrompt(prompt, target.url);\n\n const callAgent = options.runtime?.callAgent ?? defaultCallAgent;\n const responseText = await callAgent(target.url, promptToSend, {\n apiKey: options.apiKey,\n contextId: options.contextId,\n userEmail: options.userEmail,\n orgDomain: options.orgDomain,\n orgSecret: options.orgSecret,\n async: options.async,\n timeoutMs: options.timeoutMs,\n pollIntervalMs: options.pollIntervalMs,\n correlation: options.correlation,\n idempotencyKey: options.idempotencyKey,\n });\n\n return {\n target,\n prompt: promptToSend,\n responseText,\n };\n}\n\n/**\n * Resolve another app and execute one explicitly exposed read-only action on\n * it. This is the fast A2A path for bounded data operations that do not need a\n * second model to plan or synthesize.\n */\nexport async function invokeAgentAction(\n options: InvokeAgentActionOptions,\n): Promise<AgentActionInvocationResult> {\n const action = options.action.trim();\n if (!action) {\n throw new AgentInvocationError(\n \"missing-action\",\n \"Error: action is required\",\n { target: options.target },\n );\n }\n const input = options.input ?? {};\n if (!input || typeof input !== \"object\" || Array.isArray(input)) {\n throw new AgentInvocationError(\n \"invalid-input\",\n \"Error: action input must be an object\",\n { target: options.target },\n );\n }\n\n const target = await resolveAgentInvocationTarget(options.target, {\n selfAppId: options.selfAppId,\n selfUrl: options.selfUrl,\n runtime: options.runtime,\n });\n const callAction = options.runtime?.callAction ?? defaultCallAction;\n const result = await callAction(target.url, action, input, {\n apiKey: options.apiKey,\n userEmail: options.userEmail,\n orgDomain: options.orgDomain,\n orgSecret: options.orgSecret,\n requestTimeoutMs: options.requestTimeoutMs,\n correlation: options.correlation,\n });\n\n return { target, action, result };\n}\n\nexport function buildAgentInvocationPrompt(\n prompt: string,\n agentUrl: string,\n): string {\n return (\n `${prompt}\\n\\n` +\n `[Note: this request comes from another app via A2A. The caller cannot see your local UI, resource list, or navigation - only the literal text you put in your reply. ` +\n `If you create or reference a deck/document/design/dashboard/resource, include its FULLY-QUALIFIED URL (e.g. ${agentUrl.replace(/\\/$/, \"\")}/<path>/<id>) in your reply, not a relative path. ` +\n `Use only artifact IDs and URL paths returned by successful actions - never invent slugs, IDs, or hosts.]`\n );\n}\n\nexport function looksLikeAgentUrl(value: string): boolean {\n return /^[a-z][a-z0-9+.-]*:\\/\\//i.test(value.trim());\n}\n\nfunction parseAgentUrl(value: string): string | null {\n const trimmed = value.trim();\n if (!looksLikeAgentUrl(trimmed)) return null;\n\n let parsed: URL;\n try {\n parsed = new URL(trimmed);\n } catch {\n throw new AgentInvocationError(\n \"invalid-url\",\n `Error: Invalid agent URL \"${trimmed}\"`,\n { target: trimmed },\n );\n }\n\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n throw new AgentInvocationError(\n \"invalid-url\",\n \"Error: Agent URL must use http or https\",\n { target: trimmed },\n );\n }\n\n parsed.hash = \"\";\n parsed.search = \"\";\n return parsed.toString().replace(/\\/$/, \"\");\n}\n\nfunction assertNotSelfUrl(targetUrl: string, selfUrl: string | undefined) {\n if (!selfUrl) return;\n const target = canonicalAgentBaseUrl(targetUrl);\n const self = canonicalAgentBaseUrl(selfUrl);\n if (!target || !self || target !== self) return;\n throw new AgentInvocationError(\n \"self-call\",\n \"Error: You cannot invoke this app via A2A from itself. Use the app's own registered actions/tools instead. A2A invocation is only for communicating with other separately-deployed apps.\",\n { target: targetUrl },\n );\n}\n\nfunction canonicalAgentBaseUrl(value: string): string | null {\n try {\n const parsed = new URL(value);\n parsed.hash = \"\";\n parsed.search = \"\";\n let pathname = parsed.pathname.replace(/\\/+$/, \"\");\n if (pathname.endsWith(\"/_agent-native/a2a\")) {\n pathname = pathname.slice(0, -\"/_agent-native/a2a\".length);\n } else if (pathname.endsWith(\"/a2a\")) {\n pathname = pathname.slice(0, -\"/a2a\".length);\n }\n parsed.pathname = pathname || \"/\";\n return parsed.toString().replace(/\\/$/, \"\");\n } catch {\n return null;\n }\n}\n\nfunction normalizeAgentHandle(value: string): string {\n const normalized = value.trim().toLowerCase();\n if (\n normalized === \"image\" ||\n normalized === \"images\" ||\n normalized === \"asset\"\n ) {\n return \"assets\";\n }\n return normalized;\n}\n\nfunction formatSelfCallError(selfAppId: string): string {\n return `Error: You cannot use A2A invocation to call yourself (${selfAppId}). Use your own registered actions/tools instead. A2A invocation is only for communicating with OTHER separately-deployed apps.`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"invoke.js","sourceRoot":"","sources":["../../src/a2a/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,IAAI,qBAAqB,EACvC,SAAS,IAAI,gBAAgB,GAE9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,UAAU,IAAI,iBAAiB,EAC/B,SAAS,IAAI,gBAAgB,GAC9B,MAAM,aAAa,CAAC;AAerB,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IACpC,IAAI,CAA2B;IAC/B,MAAM,CAAU;IAChB,eAAe,CAAqB;IAE7C,YACE,IAA8B,EAC9B,OAAe,EACf,OAAkE;QAEl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AG,EAAE,CAAC;QACnB,IAAI,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACnD,IAAI,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;YAC5C,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;QACD,MAAM,CAAC,QAAQ,GAAG,QAAQ,IAAI,GAAG,CAAC;QAClC,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,IACE,UAAU,KAAK,OAAO;QACtB,UAAU,KAAK,QAAQ;QACvB,UAAU,KAAK,OAAO,EACtB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,OAAO,0DAA0D,SAAS,iIAAiI,CAAC;AAC9M,CAAC","sourcesContent":["import {\n discoverAgents as defaultDiscoverAgents,\n findAgent as defaultFindAgent,\n type DiscoveredAgent,\n} from \"../server/agent-discovery.js\";\nimport {\n callAction as defaultCallAction,\n callAgent as defaultCallAgent,\n} from \"./client.js\";\nimport type {\n A2ACorrelationMetadata,\n A2AReadOnlyActionResult,\n} from \"./types.js\";\n\nexport type AgentInvocationErrorCode =\n | \"missing-target\"\n | \"missing-prompt\"\n | \"missing-action\"\n | \"invalid-input\"\n | \"invalid-url\"\n | \"self-call\"\n | \"not-found\";\n\nexport class AgentInvocationError extends Error {\n readonly code: AgentInvocationErrorCode;\n readonly target?: string;\n readonly availableAgents?: DiscoveredAgent[];\n\n constructor(\n code: AgentInvocationErrorCode,\n message: string,\n options?: { target?: string; availableAgents?: DiscoveredAgent[] },\n ) {\n super(message);\n this.name = \"AgentInvocationError\";\n this.code = code;\n this.target = options?.target;\n this.availableAgents = options?.availableAgents;\n }\n}\n\nexport interface ResolvedAgentInvocationTarget {\n kind: \"discovered\" | \"url\";\n id?: string;\n name: string;\n description?: string;\n url: string;\n color?: string;\n}\n\nexport interface AgentInvocationResult {\n target: ResolvedAgentInvocationTarget;\n prompt: string;\n responseText: string;\n}\n\nexport interface AgentActionInvocationResult {\n target: ResolvedAgentInvocationTarget;\n action: string;\n result: A2AReadOnlyActionResult;\n}\n\nexport interface AgentInvocationRuntime {\n findAgent: typeof defaultFindAgent;\n discoverAgents: typeof defaultDiscoverAgents;\n callAgent: typeof defaultCallAgent;\n callAction: typeof defaultCallAction;\n}\n\nexport interface ResolveAgentInvocationTargetOptions {\n selfAppId?: string;\n selfUrl?: string;\n runtime?: Partial<AgentInvocationRuntime>;\n}\n\nexport interface InvokeAgentOptions extends ResolveAgentInvocationTargetOptions {\n target: string;\n prompt: string;\n apiKey?: string;\n contextId?: string;\n userEmail?: string;\n orgDomain?: string;\n orgSecret?: string;\n async?: boolean;\n timeoutMs?: number;\n pollIntervalMs?: number;\n includeInvocationHint?: boolean;\n correlation?: A2ACorrelationMetadata;\n idempotencyKey?: string;\n runtime?: Partial<AgentInvocationRuntime>;\n}\n\nexport interface InvokeAgentActionOptions extends ResolveAgentInvocationTargetOptions {\n target: string;\n action: string;\n input?: Record<string, unknown>;\n apiKey?: string;\n userEmail?: string;\n orgDomain?: string;\n orgSecret?: string;\n requestTimeoutMs?: number;\n correlation?: A2ACorrelationMetadata;\n runtime?: Partial<AgentInvocationRuntime>;\n}\n\n/**\n * Resolve an A2A invocation target from a direct URL or from the connected app\n * registry. ID/name resolution deliberately uses the same discovery path as\n * the in-agent `call-agent` script.\n */\nexport async function resolveAgentInvocationTarget(\n target: string,\n options: ResolveAgentInvocationTargetOptions = {},\n): Promise<ResolvedAgentInvocationTarget> {\n const cleanTarget = target.trim();\n if (!cleanTarget) {\n throw new AgentInvocationError(\n \"missing-target\",\n \"Error: agent target is required\",\n );\n }\n\n const directUrl = parseAgentUrl(cleanTarget);\n if (directUrl) {\n assertNotSelfUrl(directUrl, options.selfUrl);\n return {\n kind: \"url\",\n name: directUrl,\n url: directUrl,\n };\n }\n\n if (\n options.selfAppId &&\n normalizeAgentHandle(cleanTarget) ===\n normalizeAgentHandle(options.selfAppId)\n ) {\n throw new AgentInvocationError(\n \"self-call\",\n formatSelfCallError(options.selfAppId),\n { target: cleanTarget },\n );\n }\n\n const findAgent = options.runtime?.findAgent ?? defaultFindAgent;\n const discoverAgents =\n options.runtime?.discoverAgents ?? defaultDiscoverAgents;\n const agent = await findAgent(cleanTarget, options.selfAppId);\n if (!agent) {\n const availableAgents = await discoverAgents(options.selfAppId);\n const available = availableAgents.map((a) => a.name).join(\", \");\n throw new AgentInvocationError(\n \"not-found\",\n `Error: Agent \"${cleanTarget}\" not found. Available agents: ${available || \"(none)\"}`,\n { target: cleanTarget, availableAgents },\n );\n }\n\n return {\n kind: \"discovered\",\n id: agent.id,\n name: agent.name,\n description: agent.description,\n url: agent.url,\n color: agent.color,\n };\n}\n\n/**\n * First-class headless A2A primitive: resolve an app/agent by id, name, or URL,\n * send a text prompt, and return the text response with target metadata.\n */\nexport async function invokeAgent(\n options: InvokeAgentOptions,\n): Promise<AgentInvocationResult> {\n const prompt = options.prompt;\n if (!prompt.trim()) {\n throw new AgentInvocationError(\n \"missing-prompt\",\n \"Error: prompt is required\",\n { target: options.target },\n );\n }\n\n const target = await resolveAgentInvocationTarget(options.target, {\n selfAppId: options.selfAppId,\n selfUrl: options.selfUrl,\n runtime: options.runtime,\n });\n\n const promptToSend =\n options.includeInvocationHint === false\n ? prompt\n : buildAgentInvocationPrompt(prompt, target.url);\n\n const callAgent = options.runtime?.callAgent ?? defaultCallAgent;\n const responseText = await callAgent(target.url, promptToSend, {\n apiKey: options.apiKey,\n contextId: options.contextId,\n userEmail: options.userEmail,\n orgDomain: options.orgDomain,\n orgSecret: options.orgSecret,\n async: options.async,\n timeoutMs: options.timeoutMs,\n pollIntervalMs: options.pollIntervalMs,\n correlation: options.correlation,\n idempotencyKey: options.idempotencyKey,\n });\n\n return {\n target,\n prompt: promptToSend,\n responseText,\n };\n}\n\n/**\n * Resolve another app and execute one explicitly exposed read-only action on\n * it. This is the fast A2A path for bounded data operations that do not need a\n * second model to plan or synthesize.\n */\nexport async function invokeAgentAction(\n options: InvokeAgentActionOptions,\n): Promise<AgentActionInvocationResult> {\n const action = options.action.trim();\n if (!action) {\n throw new AgentInvocationError(\n \"missing-action\",\n \"Error: action is required\",\n { target: options.target },\n );\n }\n const input = options.input ?? {};\n if (!input || typeof input !== \"object\" || Array.isArray(input)) {\n throw new AgentInvocationError(\n \"invalid-input\",\n \"Error: action input must be an object\",\n { target: options.target },\n );\n }\n\n const target = await resolveAgentInvocationTarget(options.target, {\n selfAppId: options.selfAppId,\n selfUrl: options.selfUrl,\n runtime: options.runtime,\n });\n const callAction = options.runtime?.callAction ?? defaultCallAction;\n const result = await callAction(target.url, action, input, {\n apiKey: options.apiKey,\n userEmail: options.userEmail,\n orgDomain: options.orgDomain,\n orgSecret: options.orgSecret,\n requestTimeoutMs: options.requestTimeoutMs,\n correlation: options.correlation,\n });\n\n return { target, action, result };\n}\n\nexport function buildAgentInvocationPrompt(\n prompt: string,\n agentUrl: string,\n): string {\n return (\n `${prompt}\\n\\n` +\n `<a2a-caller-hint>\\n` +\n `This request comes from another app via A2A. The caller cannot see your local UI, resource list, or navigation - only the literal text you put in your reply. ` +\n `If you create or reference a deck/document/design/dashboard/resource, include its FULLY-QUALIFIED URL (e.g. ${agentUrl.replace(/\\/$/, \"\")}/<path>/<id>) in your reply, not a relative path. ` +\n `Use only artifact IDs and URL paths returned by successful actions - never invent slugs, IDs, or hosts.\\n` +\n `</a2a-caller-hint>`\n );\n}\n\nexport function looksLikeAgentUrl(value: string): boolean {\n return /^[a-z][a-z0-9+.-]*:\\/\\//i.test(value.trim());\n}\n\nfunction parseAgentUrl(value: string): string | null {\n const trimmed = value.trim();\n if (!looksLikeAgentUrl(trimmed)) return null;\n\n let parsed: URL;\n try {\n parsed = new URL(trimmed);\n } catch {\n throw new AgentInvocationError(\n \"invalid-url\",\n `Error: Invalid agent URL \"${trimmed}\"`,\n { target: trimmed },\n );\n }\n\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n throw new AgentInvocationError(\n \"invalid-url\",\n \"Error: Agent URL must use http or https\",\n { target: trimmed },\n );\n }\n\n parsed.hash = \"\";\n parsed.search = \"\";\n return parsed.toString().replace(/\\/$/, \"\");\n}\n\nfunction assertNotSelfUrl(targetUrl: string, selfUrl: string | undefined) {\n if (!selfUrl) return;\n const target = canonicalAgentBaseUrl(targetUrl);\n const self = canonicalAgentBaseUrl(selfUrl);\n if (!target || !self || target !== self) return;\n throw new AgentInvocationError(\n \"self-call\",\n \"Error: You cannot invoke this app via A2A from itself. Use the app's own registered actions/tools instead. A2A invocation is only for communicating with other separately-deployed apps.\",\n { target: targetUrl },\n );\n}\n\nfunction canonicalAgentBaseUrl(value: string): string | null {\n try {\n const parsed = new URL(value);\n parsed.hash = \"\";\n parsed.search = \"\";\n let pathname = parsed.pathname.replace(/\\/+$/, \"\");\n if (pathname.endsWith(\"/_agent-native/a2a\")) {\n pathname = pathname.slice(0, -\"/_agent-native/a2a\".length);\n } else if (pathname.endsWith(\"/a2a\")) {\n pathname = pathname.slice(0, -\"/a2a\".length);\n }\n parsed.pathname = pathname || \"/\";\n return parsed.toString().replace(/\\/$/, \"\");\n } catch {\n return null;\n }\n}\n\nfunction normalizeAgentHandle(value: string): string {\n const normalized = value.trim().toLowerCase();\n if (\n normalized === \"image\" ||\n normalized === \"images\" ||\n normalized === \"asset\"\n ) {\n return \"assets\";\n }\n return normalized;\n}\n\nfunction formatSelfCallError(selfAppId: string): string {\n return `Error: You cannot use A2A invocation to call yourself (${selfAppId}). Use your own registered actions/tools instead. A2A invocation is only for communicating with OTHER separately-deployed apps.`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-continuation-guidance.d.ts","sourceRoot":"","sources":["../../src/agent/action-continuation-guidance.ts"],"names":[],"mappings":"AAKA,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"action-continuation-guidance.d.ts","sourceRoot":"","sources":["../../src/agent/action-continuation-guidance.ts"],"names":[],"mappings":"AAKA,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA0B1E;AAED,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKtE"}
|
|
@@ -21,8 +21,9 @@ export function incrementalActionGuidance(tool) {
|
|
|
21
21
|
case "create-prototype-plan":
|
|
22
22
|
return "create the plan with its core sections or first screen, then expand it with `update-visual-plan`/`patch-visual-plan-source` follow-up edits";
|
|
23
23
|
case "update-visual-plan":
|
|
24
|
+
return "apply one or a few small `update-visual-plan` `contentPatches` such as `append-block`, `update-rich-text`, or a text patch; do not resend the full plan or switch to a source-control workflow";
|
|
24
25
|
case "patch-visual-plan-source":
|
|
25
|
-
return "apply
|
|
26
|
+
return "apply small targeted `patch-visual-plan-source` MDX AST edits; do not use `replace-file`, and do not use this source action for a live plan edit";
|
|
26
27
|
case "update-dashboard":
|
|
27
28
|
return "save a small dashboard first, then add panels one at a time with `update-dashboard` incremental `ops` edits instead of authoring the whole config in one call";
|
|
28
29
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-continuation-guidance.js","sourceRoot":"","sources":["../../src/agent/action-continuation-guidance.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,+EAA+E;AAC/E,yBAAyB;AACzB,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,kBAAkB,CAAC;QACxB,KAAK,kBAAkB;YACrB,OAAO,gHAAgH,CAAC;QAC1H,KAAK,iBAAiB,CAAC;QACvB,KAAK,eAAe;YAClB,OAAO,6aAA6a,CAAC;QACvb,KAAK,aAAa;YAChB,OAAO,8jBAA8jB,CAAC;QACxkB,KAAK,yBAAyB;YAC5B,OAAO,ubAAub,CAAC;QACjc,KAAK,oBAAoB,CAAC;QAC1B,KAAK,gBAAgB,CAAC;QACtB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,uBAAuB;YAC1B,OAAO,6IAA6I,CAAC;QACvJ,KAAK,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"action-continuation-guidance.js","sourceRoot":"","sources":["../../src/agent/action-continuation-guidance.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,+EAA+E;AAC/E,yBAAyB;AACzB,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,kBAAkB,CAAC;QACxB,KAAK,kBAAkB;YACrB,OAAO,gHAAgH,CAAC;QAC1H,KAAK,iBAAiB,CAAC;QACvB,KAAK,eAAe;YAClB,OAAO,6aAA6a,CAAC;QACvb,KAAK,aAAa;YAChB,OAAO,8jBAA8jB,CAAC;QACxkB,KAAK,yBAAyB;YAC5B,OAAO,ubAAub,CAAC;QACjc,KAAK,oBAAoB,CAAC;QAC1B,KAAK,gBAAgB,CAAC;QACtB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,uBAAuB;YAC1B,OAAO,6IAA6I,CAAC;QACvJ,KAAK,oBAAoB;YACvB,OAAO,gMAAgM,CAAC;QAC1M,KAAK,0BAA0B;YAC7B,OAAO,kJAAkJ,CAAC;QAC5J,KAAK,kBAAkB;YACrB,OAAO,+JAA+J,CAAC;QACzK;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,IAAY;IAC5D,MAAM,QAAQ,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO,QAAQ;QACb,CAAC,CAAC,0DAA0D,IAAI,wHAAwH,QAAQ,GAAG;QACnM,CAAC,CAAC,0DAA0D,IAAI,yMAAyM,CAAC;AAC9Q,CAAC","sourcesContent":["// Concrete \"ship a compact first version, then refine incrementally\" guidance\n// keyed by the large-payload action the model was cut off while preparing.\n// A run cut off before the tool starts tends to reassemble the same oversized\n// payload on every continuation; pointing the model at the incremental path is\n// what breaks that loop.\nexport function incrementalActionGuidance(tool: string): string | undefined {\n switch (tool) {\n case \"create-extension\":\n case \"update-extension\":\n return \"create a compact working v1 with `create-extension`, then use focused `update-extension` edits for refinements\";\n case \"generate-design\":\n case \"update-design\":\n return 'if an existing design file or snapshot is already in history, especially after a Design variant pick, stop retrying `generate-design`: call `get-design-snapshot` for the selected file, then call `edit-design` once on that same `fileId` (`mode: \"replace-file\"` for a compact full-file replacement, or search/replace for smaller edits). Use `generate-design` only for a brand-new compact first file when no target file exists yet';\n case \"edit-design\":\n return 'retry with a smaller `edit-design` payload against the already-snapshotted file. If this is a selected Design variant expansion, reuse the existing `fileId` and snapshot in history; do not call `list-files`, `delete-file`, or `get-design-snapshot` again just to recover. Save one compact complete first version with `mode: \"replace-file\"` and `replacementContent`, or use a handful of exact search/replace edits when that is smaller. Avoid another huge full-file rewrite; upgrade the highest-value visible sections first, save once, and summarize any remaining refinements';\n case \"present-design-variants\":\n return 'call `present-design-variants` with concise labels, descriptions, accent colors, and feature bullets; omit large `content` HTML when needed so the action can render compact representative screens. After the user picks a direction, delete unchosen screens, snapshot the selected `fileId`, and refine that same file with `edit-design` (`mode: \"replace-file\"` for placeholder expansion). Do not call `generate-design` after the variant pick';\n case \"create-visual-plan\":\n case \"create-ui-plan\":\n case \"create-plan-design\":\n case \"create-prototype-plan\":\n return \"create the plan with its core sections or first screen, then expand it with `update-visual-plan`/`patch-visual-plan-source` follow-up edits\";\n case \"update-visual-plan\":\n return \"apply one or a few small `update-visual-plan` `contentPatches` such as `append-block`, `update-rich-text`, or a text patch; do not resend the full plan or switch to a source-control workflow\";\n case \"patch-visual-plan-source\":\n return \"apply small targeted `patch-visual-plan-source` MDX AST edits; do not use `replace-file`, and do not use this source action for a live plan edit\";\n case \"update-dashboard\":\n return \"save a small dashboard first, then add panels one at a time with `update-dashboard` incremental `ops` edits instead of authoring the whole config in one call\";\n default:\n return undefined;\n }\n}\n\nexport function actionPreparationContinuationNote(tool: string): string {\n const guidance = incrementalActionGuidance(tool);\n return guidance\n ? `\\n\\nThe previous run was cut off while preparing the \\`${tool}\\` action input before the action could finish. Avoid spending another whole run assembling one large tool payload - ${guidance}.`\n : `\\n\\nThe previous run was cut off while preparing the \\`${tool}\\` action input before the action could finish. Avoid re-assembling one large tool payload: produce a compact first result you can finish in a single run, then refine it with smaller follow-up edits.`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/agent/engine/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkBH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIlE,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;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C,EACT,MAAM,GACN,WAAW,GACX;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IACtD,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAsB,iCAAiC,CACrD,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA0B7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAoItB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,WAAW,GAAG,MAAM,EAC5B,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgC7B"}
|
|
@@ -459,6 +459,41 @@ async function resolveUsableProviderSecret(key) {
|
|
|
459
459
|
const authFailure = await getProviderCredentialAuthFailure({ key, value });
|
|
460
460
|
return authFailure ? null : value;
|
|
461
461
|
}
|
|
462
|
+
/**
|
|
463
|
+
* Return true only when the supplied key can be positively identified as a
|
|
464
|
+
* usable credential for a different registered provider.
|
|
465
|
+
*
|
|
466
|
+
* `ResolveEngineConfig.apiKey` is public and may be an opaque caller-provided
|
|
467
|
+
* key, so automatic selection must not silently replace it merely because a
|
|
468
|
+
* stored credential also exists. Delegated/internal callers, however,
|
|
469
|
+
* historically pass the current "active" provider key before the registry
|
|
470
|
+
* selects an app-default engine. Exact in-memory comparison lets us correct
|
|
471
|
+
* that proven mismatch without guessing from provider-specific key prefixes
|
|
472
|
+
* or exposing either value.
|
|
473
|
+
*/
|
|
474
|
+
async function apiKeyBelongsToDifferentProvider(apiKey, selectedEntry) {
|
|
475
|
+
const selectedEnvVars = new Set(selectedEntry.requiredEnvVars);
|
|
476
|
+
const checkedEnvVars = new Set();
|
|
477
|
+
for (const entry of _registry.values()) {
|
|
478
|
+
if (entry === selectedEntry || entry.name === "builder")
|
|
479
|
+
continue;
|
|
480
|
+
for (const key of entry.requiredEnvVars) {
|
|
481
|
+
if (selectedEnvVars.has(key) || checkedEnvVars.has(key))
|
|
482
|
+
continue;
|
|
483
|
+
checkedEnvVars.add(key);
|
|
484
|
+
try {
|
|
485
|
+
if ((await resolveUsableProviderSecret(key)) === apiKey)
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
// An unrelated provider store failure is not proof that the explicit
|
|
490
|
+
// key belongs elsewhere. Preserve the caller's key and let the
|
|
491
|
+
// selected provider's own preflight report any relevant failure.
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
462
497
|
async function engineCreateConfigForEntry(entry, apiKey, extra, preferResolvedCredential = false) {
|
|
463
498
|
const safeExtra = { ...(extra ?? {}) };
|
|
464
499
|
let matchingApiKey = apiKey;
|
|
@@ -466,27 +501,39 @@ async function engineCreateConfigForEntry(entry, apiKey, extra, preferResolvedCr
|
|
|
466
501
|
// Callers historically passed one untagged "active" key before the registry
|
|
467
502
|
// chose an engine, which could hand an Anthropic key to an app-default
|
|
468
503
|
// OpenAI engine (or vice versa). Explicit engineOption branches retain their
|
|
469
|
-
// paired key
|
|
504
|
+
// paired key. Automatic branches replace only a key proven to belong to a
|
|
505
|
+
// different configured provider; opaque caller-supplied keys keep the public
|
|
506
|
+
// `ResolveEngineConfig.apiKey` contract.
|
|
470
507
|
if (preferResolvedCredential &&
|
|
471
508
|
entry.name !== "builder" &&
|
|
472
509
|
entry.requiredEnvVars.length > 0) {
|
|
473
|
-
let
|
|
510
|
+
let resolvedMatchingCredential;
|
|
511
|
+
let matchingCredentialUsesDeployFallback = false;
|
|
474
512
|
for (const key of entry.requiredEnvVars) {
|
|
475
513
|
const resolved = (await resolveUsableProviderSecret(key)) ?? undefined;
|
|
476
514
|
if (!resolved)
|
|
477
515
|
continue;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
516
|
+
resolvedMatchingCredential = resolved;
|
|
517
|
+
matchingCredentialUsesDeployFallback =
|
|
518
|
+
canUseDeployCredentialFallbackForRequest(key) &&
|
|
519
|
+
readDeployCredentialEnv(key) === resolved;
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
const suppliedKeyMatchesSelected = matchingApiKey !== undefined &&
|
|
523
|
+
matchingApiKey === resolvedMatchingCredential;
|
|
524
|
+
const suppliedKeyBelongsElsewhere = matchingApiKey !== undefined &&
|
|
525
|
+
!suppliedKeyMatchesSelected &&
|
|
526
|
+
(await apiKeyBelongsToDifferentProvider(matchingApiKey, entry));
|
|
527
|
+
if (matchingApiKey === undefined || suppliedKeyBelongsElsewhere) {
|
|
481
528
|
// Keep deploy-only credentials implicit so provider SDKs retain their
|
|
482
529
|
// established env-fallback behavior. Scoped credentials must be passed
|
|
483
|
-
// explicitly
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
530
|
+
// explicitly. A proven different-provider key is replaced or cleared;
|
|
531
|
+
// an opaque caller-supplied key is preserved by the branch above.
|
|
532
|
+
matchingApiKey =
|
|
533
|
+
resolvedMatchingCredential && !matchingCredentialUsesDeployFallback
|
|
534
|
+
? resolvedMatchingCredential
|
|
535
|
+
: undefined;
|
|
487
536
|
}
|
|
488
|
-
if (!foundMatchingCredential)
|
|
489
|
-
matchingApiKey = undefined;
|
|
490
537
|
}
|
|
491
538
|
if (entry.name === "ai-sdk:openai") {
|
|
492
539
|
if (typeof safeExtra.baseURL === "string" && safeExtra.baseUrl == null) {
|
|
@@ -703,7 +750,7 @@ export async function resolveEngine(config) {
|
|
|
703
750
|
if (!anthropicEntry) {
|
|
704
751
|
throw new Error("[agent-engine] Default Anthropic engine is not registered. Did builtin.ts fail to load?");
|
|
705
752
|
}
|
|
706
|
-
return anthropicEntry.create(await engineCreateConfigForEntry(anthropicEntry, apiKey));
|
|
753
|
+
return anthropicEntry.create(await engineCreateConfigForEntry(anthropicEntry, apiKey, undefined, true));
|
|
707
754
|
}
|
|
708
755
|
/**
|
|
709
756
|
* Read the user-selected model for an engine from the `agent-engine` setting.
|