@agent-native/core 0.58.3 → 0.58.5
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/dist/agent/production-agent.d.ts +9 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +80 -4
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/plan-local.d.ts +34 -0
- package/dist/cli/plan-local.d.ts.map +1 -1
- package/dist/cli/plan-local.js +205 -1
- package/dist/cli/plan-local.js.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.js +1 -1
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/cli/recap.d.ts +5 -0
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +19 -2
- package/dist/cli/recap.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +3 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +6 -3
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +5 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +141 -39
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +44 -31
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/blocks/library/diagram.d.ts.map +1 -1
- package/dist/client/blocks/library/diagram.js +85 -20
- package/dist/client/blocks/library/diagram.js.map +1 -1
- package/dist/client/blocks/library/tabs.d.ts.map +1 -1
- package/dist/client/blocks/library/tabs.js +5 -5
- package/dist/client/blocks/library/tabs.js.map +1 -1
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +13 -10
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/run-recovery.d.ts.map +1 -1
- package/dist/client/chat/run-recovery.js +3 -3
- package/dist/client/chat/run-recovery.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +0 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +5 -2
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat/widgets/DataChartRenderer.d.ts.map +1 -1
- package/dist/client/chat/widgets/DataChartRenderer.js +98 -21
- package/dist/client/chat/widgets/DataChartRenderer.js.map +1 -1
- package/dist/client/chat/widgets/builtin-tool-renderers.d.ts +4 -1
- package/dist/client/chat/widgets/builtin-tool-renderers.d.ts.map +1 -1
- package/dist/client/chat/widgets/builtin-tool-renderers.js +30 -4
- package/dist/client/chat/widgets/builtin-tool-renderers.js.map +1 -1
- package/dist/client/composer/AgentComposerFrame.js +1 -1
- package/dist/client/composer/AgentComposerFrame.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +17 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +6 -2
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +13 -0
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.js +25 -11
- package/dist/sharing/actions/set-resource-visibility.js.map +1 -1
- package/dist/styles/agent-native.css +115 -2
- package/dist/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +100 -0
- package/docs/content/pr-visual-recap.md +2 -2
- package/package.json +1 -1
- package/src/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +100 -0
package/dist/cli/plan-local.d.ts
CHANGED
|
@@ -49,6 +49,34 @@ type LocalPlanBridgeMdxFolder = {
|
|
|
49
49
|
".plan-state.json"?: string;
|
|
50
50
|
"assets/"?: Record<string, string>;
|
|
51
51
|
};
|
|
52
|
+
type VisualAnswerSourcePayload = {
|
|
53
|
+
question?: string;
|
|
54
|
+
title?: string;
|
|
55
|
+
brief?: string;
|
|
56
|
+
repoPath?: string;
|
|
57
|
+
sourceUrl?: string;
|
|
58
|
+
sourceType?: string;
|
|
59
|
+
mdx: {
|
|
60
|
+
"plan.mdx": string;
|
|
61
|
+
"canvas.mdx"?: string;
|
|
62
|
+
"prototype.mdx"?: string;
|
|
63
|
+
"assets/"?: Record<string, string>;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export type PublishVisualAnswerInput = {
|
|
67
|
+
appUrl: string;
|
|
68
|
+
token: string;
|
|
69
|
+
question?: string;
|
|
70
|
+
sourcePath?: string;
|
|
71
|
+
out?: string;
|
|
72
|
+
prevPlanId?: string;
|
|
73
|
+
repo?: string;
|
|
74
|
+
sourceUrl?: string;
|
|
75
|
+
sourceType?: string;
|
|
76
|
+
visibility?: "private" | "org" | "public";
|
|
77
|
+
fetchFn?: typeof fetch;
|
|
78
|
+
cwd?: string;
|
|
79
|
+
};
|
|
52
80
|
export type LocalPlanBridgePayload = {
|
|
53
81
|
ok: true;
|
|
54
82
|
version: 1;
|
|
@@ -154,6 +182,12 @@ export declare function verifyLocalPlanBridge(input: {
|
|
|
154
182
|
urlFile?: string | false;
|
|
155
183
|
fetchFn?: typeof fetch;
|
|
156
184
|
}): Promise<LocalPlanVerifyResult>;
|
|
185
|
+
export declare function readVisualAnswerSourcePayload(sourcePath: string): VisualAnswerSourcePayload;
|
|
186
|
+
export declare function publishVisualAnswerSource(input: PublishVisualAnswerInput): Promise<{
|
|
187
|
+
ok: true;
|
|
188
|
+
url: string;
|
|
189
|
+
out: string;
|
|
190
|
+
}>;
|
|
157
191
|
export declare function runPlan(argv: string[]): Promise<void>;
|
|
158
192
|
export {};
|
|
159
193
|
//# sourceMappingURL=plan-local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-local.d.ts","sourceRoot":"","sources":["../../src/cli/pl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MAAM,GACjB,yBAAyB,CA0B3B;AAED,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAyEjD;AAkQD,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuE3D"}
|
package/dist/cli/plan-local.js
CHANGED
|
@@ -14,10 +14,13 @@ import http from "node:http";
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
import { spawnSync } from "node:child_process";
|
|
16
16
|
import { pathToFileURL } from "node:url";
|
|
17
|
-
import { DEFAULT_PLAN_APP_URL, defaultPlanBlocksOut, fetchPlanBlockCatalog, normalizePlanBlockFormat, } from "./plan-blocks.js";
|
|
17
|
+
import { DEFAULT_PLAN_APP_URL, defaultPlanBlocksOut, fetchPlanBlockCatalog, normalizePlanBlockFormat, planActionEndpoint, } from "./plan-blocks.js";
|
|
18
18
|
const LOCAL_PLAN_ASSET_MAX_SINGLE_BYTES = 2 * 1024 * 1024;
|
|
19
19
|
const LOCAL_PLAN_ASSET_MAX_TOTAL_BYTES = 10 * 1024 * 1024;
|
|
20
20
|
const AGENT_NATIVE_MANIFEST_FILE = "agent-native.json";
|
|
21
|
+
const VISUAL_ANSWER_SOURCE_FILENAME = "visual-answer-source.json";
|
|
22
|
+
const VISUAL_ANSWER_URL_FILENAME = "visual-answer-url.txt";
|
|
23
|
+
const PLAN_ACTION_HTTP_TIMEOUT_MS = 45_000;
|
|
21
24
|
const LOCAL_PLAN_ASSET_EXTENSIONS = new Set([
|
|
22
25
|
"png",
|
|
23
26
|
"jpg",
|
|
@@ -57,6 +60,69 @@ function optionalArg(args, key) {
|
|
|
57
60
|
function boolArg(args, key) {
|
|
58
61
|
return args[key] === true;
|
|
59
62
|
}
|
|
63
|
+
function sanitizeHttpDetail(value, maxLength) {
|
|
64
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
65
|
+
if (normalized.length <= maxLength)
|
|
66
|
+
return normalized;
|
|
67
|
+
return `${normalized.slice(0, maxLength - 3)}...`;
|
|
68
|
+
}
|
|
69
|
+
function normalizeVisibility(value) {
|
|
70
|
+
if (!value)
|
|
71
|
+
return undefined;
|
|
72
|
+
if (value === "private" || value === "org" || value === "public") {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
throw new Error(`Invalid --visibility "${value}" (expected private, org, or public)`);
|
|
76
|
+
}
|
|
77
|
+
function normalizeVisualAnswerSourceType(value) {
|
|
78
|
+
if (!value)
|
|
79
|
+
return "code";
|
|
80
|
+
if ([
|
|
81
|
+
"code",
|
|
82
|
+
"pull-request",
|
|
83
|
+
"commit",
|
|
84
|
+
"branch",
|
|
85
|
+
"diff",
|
|
86
|
+
"issue",
|
|
87
|
+
"page",
|
|
88
|
+
].includes(value)) {
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`Invalid --source-type "${value}" (expected code, pull-request, commit, branch, diff, issue, or page)`);
|
|
92
|
+
}
|
|
93
|
+
function visualAnswerUrlFromPublishResult(result, appUrl) {
|
|
94
|
+
const base = appUrl.replace(/\/$/, "");
|
|
95
|
+
if (!result || typeof result !== "object")
|
|
96
|
+
return null;
|
|
97
|
+
const record = result;
|
|
98
|
+
const rawUrl = typeof record.url === "string"
|
|
99
|
+
? record.url
|
|
100
|
+
: record.path && typeof record.path === "string"
|
|
101
|
+
? record.path
|
|
102
|
+
: null;
|
|
103
|
+
if (rawUrl) {
|
|
104
|
+
try {
|
|
105
|
+
return new URL(rawUrl, `${base}/`).toString();
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const planId = typeof record.planId === "string"
|
|
112
|
+
? record.planId
|
|
113
|
+
: record.plan &&
|
|
114
|
+
typeof record.plan === "object" &&
|
|
115
|
+
typeof record.plan.id === "string"
|
|
116
|
+
? record.plan.id
|
|
117
|
+
: null;
|
|
118
|
+
return planId ? `${base}/plans/${encodeURIComponent(planId)}` : null;
|
|
119
|
+
}
|
|
120
|
+
async function fetchActionWithTimeout(url, init, fetchFn) {
|
|
121
|
+
return await fetchFn(url, {
|
|
122
|
+
...init,
|
|
123
|
+
signal: init.signal ?? AbortSignal.timeout(PLAN_ACTION_HTTP_TIMEOUT_MS),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
60
126
|
export function localPlanFolderName(title) {
|
|
61
127
|
const slug = title
|
|
62
128
|
.normalize("NFKD")
|
|
@@ -1510,6 +1576,132 @@ function runCheck(args) {
|
|
|
1510
1576
|
};
|
|
1511
1577
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
1512
1578
|
}
|
|
1579
|
+
export function readVisualAnswerSourcePayload(sourcePath) {
|
|
1580
|
+
let parsed;
|
|
1581
|
+
try {
|
|
1582
|
+
parsed = JSON.parse(fs.readFileSync(sourcePath, "utf-8"));
|
|
1583
|
+
}
|
|
1584
|
+
catch (error) {
|
|
1585
|
+
throw new Error(`Could not read ${sourcePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
1586
|
+
}
|
|
1587
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1588
|
+
throw new Error(`${sourcePath} must contain a JSON object.`);
|
|
1589
|
+
}
|
|
1590
|
+
const source = parsed;
|
|
1591
|
+
const mdx = source.mdx;
|
|
1592
|
+
if (!mdx || typeof mdx !== "object" || Array.isArray(mdx)) {
|
|
1593
|
+
throw new Error(`${sourcePath} must contain an mdx object.`);
|
|
1594
|
+
}
|
|
1595
|
+
const planMdx = mdx["plan.mdx"];
|
|
1596
|
+
if (typeof planMdx !== "string" || planMdx.trim().length === 0) {
|
|
1597
|
+
throw new Error(`${sourcePath} mdx["plan.mdx"] must be a non-empty string.`);
|
|
1598
|
+
}
|
|
1599
|
+
return source;
|
|
1600
|
+
}
|
|
1601
|
+
export async function publishVisualAnswerSource(input) {
|
|
1602
|
+
const cwd = input.cwd ?? process.cwd();
|
|
1603
|
+
const sourcePath = input.sourcePath ?? path.join(cwd, VISUAL_ANSWER_SOURCE_FILENAME);
|
|
1604
|
+
const out = input.out ?? path.join(cwd, VISUAL_ANSWER_URL_FILENAME);
|
|
1605
|
+
const token = input.token.trim();
|
|
1606
|
+
if (!token)
|
|
1607
|
+
throw new Error("Plan publish token is empty.");
|
|
1608
|
+
const source = readVisualAnswerSourcePayload(sourcePath);
|
|
1609
|
+
const question = input.question ?? source.question;
|
|
1610
|
+
if (!question?.trim()) {
|
|
1611
|
+
throw new Error(`Missing visual answer question. Pass --question or set question in ${sourcePath}.`);
|
|
1612
|
+
}
|
|
1613
|
+
const body = {
|
|
1614
|
+
question,
|
|
1615
|
+
...(input.prevPlanId ? { planId: input.prevPlanId } : {}),
|
|
1616
|
+
...(source.title ? { title: source.title } : {}),
|
|
1617
|
+
...(source.brief ? { brief: source.brief } : {}),
|
|
1618
|
+
visibility: input.visibility ?? "org",
|
|
1619
|
+
source: "imported",
|
|
1620
|
+
...((input.repo ?? source.repoPath)
|
|
1621
|
+
? { repoPath: input.repo ?? source.repoPath }
|
|
1622
|
+
: {}),
|
|
1623
|
+
...((input.sourceUrl ?? source.sourceUrl)
|
|
1624
|
+
? { sourceUrl: input.sourceUrl ?? source.sourceUrl }
|
|
1625
|
+
: {}),
|
|
1626
|
+
sourceType: normalizeVisualAnswerSourceType(input.sourceType ?? source.sourceType),
|
|
1627
|
+
currentFocus: `visual answer: ${question.trim().slice(0, 120)}`,
|
|
1628
|
+
status: "review",
|
|
1629
|
+
mdx: source.mdx,
|
|
1630
|
+
};
|
|
1631
|
+
const endpoint = planActionEndpoint(input.appUrl, "visual-answer");
|
|
1632
|
+
const fetchFn = input.fetchFn ?? fetch;
|
|
1633
|
+
const response = await fetchActionWithTimeout(endpoint, {
|
|
1634
|
+
method: "POST",
|
|
1635
|
+
headers: {
|
|
1636
|
+
accept: "application/json",
|
|
1637
|
+
"content-type": "application/json",
|
|
1638
|
+
authorization: `Bearer ${token}`,
|
|
1639
|
+
},
|
|
1640
|
+
body: JSON.stringify(body),
|
|
1641
|
+
}, fetchFn);
|
|
1642
|
+
const text = await response.text().catch((error) => String(error));
|
|
1643
|
+
if (!response.ok) {
|
|
1644
|
+
throw new Error(`visual-answer failed ${response.status} ${response.statusText}: ${sanitizeHttpDetail(text, 800)}`);
|
|
1645
|
+
}
|
|
1646
|
+
let result = null;
|
|
1647
|
+
try {
|
|
1648
|
+
result = text ? JSON.parse(text) : null;
|
|
1649
|
+
}
|
|
1650
|
+
catch {
|
|
1651
|
+
throw new Error("visual-answer returned non-JSON output.");
|
|
1652
|
+
}
|
|
1653
|
+
const url = visualAnswerUrlFromPublishResult(result, input.appUrl);
|
|
1654
|
+
if (!url) {
|
|
1655
|
+
throw new Error("visual-answer succeeded but did not return a usable /plans/<id> URL or plan id.");
|
|
1656
|
+
}
|
|
1657
|
+
fs.writeFileSync(path.resolve(out), `${url}\n`, "utf-8");
|
|
1658
|
+
return { ok: true, url, out };
|
|
1659
|
+
}
|
|
1660
|
+
async function runVisualAnswer(subcommand, args) {
|
|
1661
|
+
if (subcommand === undefined ||
|
|
1662
|
+
subcommand === "help" ||
|
|
1663
|
+
subcommand === "--help" ||
|
|
1664
|
+
subcommand === "-h" ||
|
|
1665
|
+
args.help === true ||
|
|
1666
|
+
args.h === true) {
|
|
1667
|
+
process.stdout.write(HELP);
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1670
|
+
if (subcommand !== "publish") {
|
|
1671
|
+
process.stderr.write(`Unknown plan visual-answer subcommand: ${subcommand}\n${HELP}`);
|
|
1672
|
+
process.exit(1);
|
|
1673
|
+
}
|
|
1674
|
+
const appUrl = optionalArg(args, "app-url") ||
|
|
1675
|
+
process.env.PLAN_VISUAL_ANSWER_APP_URL ||
|
|
1676
|
+
process.env.PLAN_RECAP_APP_URL ||
|
|
1677
|
+
DEFAULT_PLAN_APP_URL;
|
|
1678
|
+
const token = optionalArg(args, "token") ||
|
|
1679
|
+
process.env.PLAN_VISUAL_ANSWER_TOKEN ||
|
|
1680
|
+
process.env.PLAN_RECAP_TOKEN ||
|
|
1681
|
+
"";
|
|
1682
|
+
try {
|
|
1683
|
+
const result = await publishVisualAnswerSource({
|
|
1684
|
+
appUrl,
|
|
1685
|
+
token,
|
|
1686
|
+
question: optionalArg(args, "question"),
|
|
1687
|
+
sourcePath: optionalArg(args, "source") ?? VISUAL_ANSWER_SOURCE_FILENAME,
|
|
1688
|
+
out: optionalArg(args, "out") ?? VISUAL_ANSWER_URL_FILENAME,
|
|
1689
|
+
prevPlanId: optionalArg(args, "prev-plan-id"),
|
|
1690
|
+
repo: optionalArg(args, "repo"),
|
|
1691
|
+
sourceUrl: optionalArg(args, "source-url"),
|
|
1692
|
+
sourceType: optionalArg(args, "source-type"),
|
|
1693
|
+
visibility: normalizeVisibility(optionalArg(args, "visibility")),
|
|
1694
|
+
});
|
|
1695
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
1696
|
+
}
|
|
1697
|
+
catch (error) {
|
|
1698
|
+
process.stdout.write(`${JSON.stringify({
|
|
1699
|
+
ok: false,
|
|
1700
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
1701
|
+
}, null, 2)}\n`);
|
|
1702
|
+
process.exit(1);
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1513
1705
|
function runPreview(args) {
|
|
1514
1706
|
const result = writeLocalPlanPreview({
|
|
1515
1707
|
dir: stringArg(args, "dir"),
|
|
@@ -1646,6 +1838,7 @@ const HELP = `agent-native plan — local Agent-Native Plan helpers
|
|
|
1646
1838
|
|
|
1647
1839
|
Usage:
|
|
1648
1840
|
agent-native plan blocks [--format reference|schema] [--app-url <url>] [--out <file>] [--json]
|
|
1841
|
+
agent-native plan visual-answer publish --question <text> [--source visual-answer-source.json] [--out visual-answer-url.txt] [--repo owner/name] [--source-url <url>] [--app-url <url>] [--token <planToken>]
|
|
1649
1842
|
agent-native plan serve --dir <folder> [--app-url <url>] [--kind plan|recap] [--open] [--port <port>] [--url-file <file>]
|
|
1650
1843
|
agent-native plan local init --title <title> [--brief <text>] [--kind plan|recap] [--dir <folder>] [--force]
|
|
1651
1844
|
agent-native plan local check --dir <folder>
|
|
@@ -1659,6 +1852,13 @@ plan content and is safe for local-files authoring before writing MDX. It uses a
|
|
|
1659
1852
|
clack UI in interactive terminals and prints JSON for non-interactive shells or
|
|
1660
1853
|
when --json is passed.
|
|
1661
1854
|
|
|
1855
|
+
The visual-answer publish command sends a coding-agent-authored
|
|
1856
|
+
visual-answer-source.json file to the Plan app's visual-answer action and writes
|
|
1857
|
+
visual-answer-url.txt. The source file should contain a question, optional
|
|
1858
|
+
title/brief/repoPath/sourceUrl, and MDX files under mdx. It is the terminal
|
|
1859
|
+
handoff for /visual-answer workflows after a coding agent has inspected code via
|
|
1860
|
+
the local repo, the Plan bridge, or GitHub and authored structured Plan blocks.
|
|
1861
|
+
|
|
1662
1862
|
The local subcommands are the privacy-focused no-DB path. They only read and
|
|
1663
1863
|
write local files: plan.mdx, optional canvas.mdx, optional prototype.mdx, and
|
|
1664
1864
|
optional .plan-state.json. They do not call the Plan MCP server, the Plan app
|
|
@@ -1695,6 +1895,10 @@ export async function runPlan(argv) {
|
|
|
1695
1895
|
await runServe(args);
|
|
1696
1896
|
return;
|
|
1697
1897
|
}
|
|
1898
|
+
if (area === "visual-answer") {
|
|
1899
|
+
await runVisualAnswer(sub, parseArgs(rest));
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1698
1902
|
if (area !== "local") {
|
|
1699
1903
|
// Bare `agent-native plan` / `plan help` / `plan --help` → show help on
|
|
1700
1904
|
// stdout and exit 0 (informational, not an error).
|