@poncho-ai/cli 0.13.0 → 0.14.1
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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +42 -0
- package/dist/{chunk-CUCEDHME.js → chunk-AIEVSNGF.js} +1994 -467
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{run-interactive-ink-VZBOYJYS.js → run-interactive-ink-7ULE5JJI.js} +151 -118
- package/package.json +4 -4
- package/src/api-docs.ts +674 -0
- package/src/index.ts +632 -229
- package/src/init-onboarding.ts +14 -1
- package/src/run-interactive-ink.ts +171 -147
- package/src/web-ui.ts +760 -244
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
consumeFirstRunIntro,
|
|
3
3
|
inferConversationTitle,
|
|
4
4
|
resolveHarnessEnvironment
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AIEVSNGF.js";
|
|
6
6
|
|
|
7
7
|
// src/run-interactive-ink.ts
|
|
8
8
|
import * as readline from "readline";
|
|
@@ -1717,8 +1717,7 @@ var runInteractiveInk = async ({
|
|
|
1717
1717
|
params,
|
|
1718
1718
|
workingDir,
|
|
1719
1719
|
config,
|
|
1720
|
-
conversationStore
|
|
1721
|
-
onSetApprovalCallback
|
|
1720
|
+
conversationStore
|
|
1722
1721
|
}) => {
|
|
1723
1722
|
const metadata = await loadMetadata(workingDir);
|
|
1724
1723
|
const rl = readline.createInterface({
|
|
@@ -1726,24 +1725,6 @@ var runInteractiveInk = async ({
|
|
|
1726
1725
|
output: process.stdout,
|
|
1727
1726
|
terminal: true
|
|
1728
1727
|
});
|
|
1729
|
-
if (onSetApprovalCallback) {
|
|
1730
|
-
onSetApprovalCallback((req) => {
|
|
1731
|
-
process.stdout.write("\n");
|
|
1732
|
-
const preview = compactPreview(req.input, 100);
|
|
1733
|
-
rl.question(
|
|
1734
|
-
`${C.yellow}${C.bold}Tool "${req.tool}" requires approval${C.reset}
|
|
1735
|
-
${C.gray}input: ${preview}${C.reset}
|
|
1736
|
-
${C.yellow}approve? (y/n): ${C.reset}`,
|
|
1737
|
-
(answer) => {
|
|
1738
|
-
const approved = answer.trim().toLowerCase() === "y";
|
|
1739
|
-
console.log(
|
|
1740
|
-
approved ? green(` approved ${req.tool}`) : magenta(` denied ${req.tool}`)
|
|
1741
|
-
);
|
|
1742
|
-
req.resolve(approved);
|
|
1743
|
-
}
|
|
1744
|
-
);
|
|
1745
|
-
});
|
|
1746
|
-
}
|
|
1747
1728
|
console.log("");
|
|
1748
1729
|
for (const line of getMascotLines()) {
|
|
1749
1730
|
console.log(line);
|
|
@@ -1858,114 +1839,166 @@ ${C.yellow}approve? (y/n): ${C.reset}`,
|
|
|
1858
1839
|
console.log(gray(` sending ${turnFiles.length} file(s)`));
|
|
1859
1840
|
pendingFiles = [];
|
|
1860
1841
|
}
|
|
1842
|
+
let eventSource = harness.run({
|
|
1843
|
+
task: trimmed,
|
|
1844
|
+
parameters: params,
|
|
1845
|
+
messages,
|
|
1846
|
+
files: turnFiles.length > 0 ? turnFiles : void 0,
|
|
1847
|
+
abortSignal: activeRunAbortController.signal
|
|
1848
|
+
});
|
|
1861
1849
|
try {
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
abortSignal: activeRunAbortController.signal
|
|
1868
|
-
})) {
|
|
1869
|
-
if (event.type === "run:started") {
|
|
1870
|
-
latestRunId = event.runId;
|
|
1871
|
-
}
|
|
1872
|
-
if (event.type === "model:chunk") {
|
|
1873
|
-
sawChunk = true;
|
|
1874
|
-
if (currentTools.length > 0) {
|
|
1875
|
-
sections.push({ type: "tools", content: currentTools });
|
|
1876
|
-
currentTools = [];
|
|
1850
|
+
while (true) {
|
|
1851
|
+
let checkpointEvent = null;
|
|
1852
|
+
for await (const event of eventSource) {
|
|
1853
|
+
if (event.type === "run:started") {
|
|
1854
|
+
latestRunId = event.runId;
|
|
1877
1855
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1856
|
+
if (event.type === "model:chunk") {
|
|
1857
|
+
sawChunk = true;
|
|
1858
|
+
if (currentTools.length > 0) {
|
|
1859
|
+
sections.push({ type: "tools", content: currentTools });
|
|
1860
|
+
currentTools = [];
|
|
1861
|
+
}
|
|
1862
|
+
responseText += event.content;
|
|
1863
|
+
streamedText += event.content;
|
|
1864
|
+
currentText += event.content;
|
|
1865
|
+
if (!thinkingCleared) {
|
|
1866
|
+
clearThinking();
|
|
1867
|
+
process.stdout.write(`${C.green}assistant> ${C.reset}`);
|
|
1868
|
+
}
|
|
1869
|
+
process.stdout.write(event.content);
|
|
1870
|
+
} else if (event.type === "tool:started" || event.type === "tool:completed" || event.type === "tool:error" || event.type === "tool:approval:required") {
|
|
1871
|
+
if (streamedText.length > 0) {
|
|
1872
|
+
committedText = true;
|
|
1873
|
+
streamedText = "";
|
|
1874
|
+
process.stdout.write("\n");
|
|
1875
|
+
}
|
|
1882
1876
|
clearThinking();
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
if (
|
|
1895
|
-
|
|
1896
|
-
|
|
1877
|
+
if (event.type === "tool:started") {
|
|
1878
|
+
if (currentText.length > 0) {
|
|
1879
|
+
sections.push({ type: "text", content: currentText });
|
|
1880
|
+
currentText = "";
|
|
1881
|
+
}
|
|
1882
|
+
const preview2 = showToolPayloads ? compactPreview(event.input, 400) : compactPreview(event.input, 100);
|
|
1883
|
+
console.log(yellow(`tools> start ${event.tool} input=${preview2}`));
|
|
1884
|
+
const toolText = `- start \`${event.tool}\``;
|
|
1885
|
+
toolTimeline.push(toolText);
|
|
1886
|
+
currentTools.push(toolText);
|
|
1887
|
+
toolEvents += 1;
|
|
1888
|
+
} else if (event.type === "tool:completed") {
|
|
1889
|
+
const preview2 = showToolPayloads ? compactPreview(event.output, 400) : compactPreview(event.output, 100);
|
|
1890
|
+
console.log(
|
|
1891
|
+
yellow(
|
|
1892
|
+
`tools> done ${event.tool} in ${formatDuration(event.duration)}`
|
|
1893
|
+
)
|
|
1894
|
+
);
|
|
1895
|
+
if (showToolPayloads) {
|
|
1896
|
+
console.log(yellow(`tools> output ${preview2}`));
|
|
1897
|
+
}
|
|
1898
|
+
const toolText = `- done \`${event.tool}\` in ${formatDuration(event.duration)}`;
|
|
1899
|
+
toolTimeline.push(toolText);
|
|
1900
|
+
currentTools.push(toolText);
|
|
1901
|
+
} else if (event.type === "tool:error") {
|
|
1902
|
+
console.log(
|
|
1903
|
+
red(`tools> error ${event.tool}: ${event.error}`)
|
|
1904
|
+
);
|
|
1905
|
+
const toolText = `- error \`${event.tool}\`: ${event.error}`;
|
|
1906
|
+
toolTimeline.push(toolText);
|
|
1907
|
+
currentTools.push(toolText);
|
|
1908
|
+
} else if (event.type === "tool:approval:required") {
|
|
1909
|
+
console.log(
|
|
1910
|
+
magenta(`tools> approval required for ${event.tool}`)
|
|
1911
|
+
);
|
|
1912
|
+
const toolText = `- approval required \`${event.tool}\``;
|
|
1913
|
+
toolTimeline.push(toolText);
|
|
1914
|
+
currentTools.push(toolText);
|
|
1897
1915
|
}
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
} else if (event.type === "
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
);
|
|
1911
|
-
|
|
1912
|
-
|
|
1916
|
+
} else if (event.type === "tool:approval:checkpoint") {
|
|
1917
|
+
checkpointEvent = event;
|
|
1918
|
+
} else if (event.type === "run:error") {
|
|
1919
|
+
clearThinking();
|
|
1920
|
+
runFailed = true;
|
|
1921
|
+
console.log(red(`error> ${event.error.message}`));
|
|
1922
|
+
} else if (event.type === "run:cancelled") {
|
|
1923
|
+
clearThinking();
|
|
1924
|
+
runCancelled = true;
|
|
1925
|
+
} else if (event.type === "model:response") {
|
|
1926
|
+
usage = event.usage;
|
|
1927
|
+
} else if (event.type === "run:completed" && !sawChunk) {
|
|
1928
|
+
clearThinking();
|
|
1929
|
+
responseText = event.result.response ?? "";
|
|
1930
|
+
if (responseText.length > 0) {
|
|
1931
|
+
process.stdout.write(
|
|
1932
|
+
`${C.green}assistant> ${C.reset}${responseText}
|
|
1933
|
+
`
|
|
1934
|
+
);
|
|
1913
1935
|
}
|
|
1914
|
-
const toolText = `- done \`${event.tool}\` in ${formatDuration(event.duration)}`;
|
|
1915
|
-
toolTimeline.push(toolText);
|
|
1916
|
-
currentTools.push(toolText);
|
|
1917
|
-
} else if (event.type === "tool:error") {
|
|
1918
|
-
console.log(
|
|
1919
|
-
red(`tools> error ${event.tool}: ${event.error}`)
|
|
1920
|
-
);
|
|
1921
|
-
const toolText = `- error \`${event.tool}\`: ${event.error}`;
|
|
1922
|
-
toolTimeline.push(toolText);
|
|
1923
|
-
currentTools.push(toolText);
|
|
1924
|
-
} else if (event.type === "tool:approval:required") {
|
|
1925
|
-
console.log(
|
|
1926
|
-
magenta(`tools> approval required for ${event.tool}`)
|
|
1927
|
-
);
|
|
1928
|
-
const toolText = `- approval required \`${event.tool}\``;
|
|
1929
|
-
toolTimeline.push(toolText);
|
|
1930
|
-
currentTools.push(toolText);
|
|
1931
|
-
} else if (event.type === "tool:approval:granted") {
|
|
1932
|
-
console.log(
|
|
1933
|
-
gray(`tools> approval granted (${event.approvalId})`)
|
|
1934
|
-
);
|
|
1935
|
-
const toolText = `- approval granted (${event.approvalId})`;
|
|
1936
|
-
toolTimeline.push(toolText);
|
|
1937
|
-
currentTools.push(toolText);
|
|
1938
|
-
} else if (event.type === "tool:approval:denied") {
|
|
1939
|
-
console.log(
|
|
1940
|
-
magenta(`tools> approval denied (${event.approvalId})`)
|
|
1941
|
-
);
|
|
1942
|
-
const toolText = `- approval denied (${event.approvalId})`;
|
|
1943
|
-
toolTimeline.push(toolText);
|
|
1944
|
-
currentTools.push(toolText);
|
|
1945
1936
|
}
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1937
|
+
}
|
|
1938
|
+
if (!checkpointEvent) break;
|
|
1939
|
+
if (streamedText.length > 0) {
|
|
1940
|
+
process.stdout.write("\n");
|
|
1941
|
+
streamedText = "";
|
|
1942
|
+
}
|
|
1943
|
+
clearThinking();
|
|
1944
|
+
const preview = compactPreview(checkpointEvent.input, 100);
|
|
1945
|
+
const answer = await ask(
|
|
1946
|
+
rl,
|
|
1947
|
+
`${C.yellow}${C.bold}Tool "${checkpointEvent.tool}" requires approval${C.reset}
|
|
1948
|
+
${C.gray}input: ${preview}${C.reset}
|
|
1949
|
+
${C.yellow}approve? (y/n): ${C.reset}`
|
|
1950
|
+
);
|
|
1951
|
+
const approved = answer.trim().toLowerCase() === "y";
|
|
1952
|
+
console.log(
|
|
1953
|
+
approved ? green(` approved ${checkpointEvent.tool}`) : magenta(` denied ${checkpointEvent.tool}`)
|
|
1954
|
+
);
|
|
1955
|
+
const approvalText = approved ? `- approval granted (${checkpointEvent.approvalId})` : `- approval denied (${checkpointEvent.approvalId})`;
|
|
1956
|
+
toolTimeline.push(approvalText);
|
|
1957
|
+
currentTools.push(approvalText);
|
|
1958
|
+
let toolResults;
|
|
1959
|
+
if (approved) {
|
|
1960
|
+
const execResults = await harness.executeTools(
|
|
1961
|
+
[{ id: checkpointEvent.toolCallId, name: checkpointEvent.tool, input: checkpointEvent.input }],
|
|
1962
|
+
{ runId: latestRunId, agentId: "interactive", step: 0, workingDir, parameters: params }
|
|
1963
|
+
);
|
|
1964
|
+
toolResults = execResults.map((r) => ({
|
|
1965
|
+
callId: r.callId,
|
|
1966
|
+
toolName: r.tool,
|
|
1967
|
+
result: r.output,
|
|
1968
|
+
error: r.error
|
|
1969
|
+
}));
|
|
1970
|
+
for (const r of execResults) {
|
|
1971
|
+
if (r.error) {
|
|
1972
|
+
console.log(red(`tools> error ${r.tool}: ${r.error}`));
|
|
1973
|
+
const toolText = `- error \`${r.tool}\`: ${r.error}`;
|
|
1974
|
+
toolTimeline.push(toolText);
|
|
1975
|
+
currentTools.push(toolText);
|
|
1976
|
+
} else {
|
|
1977
|
+
console.log(yellow(`tools> done ${r.tool}`));
|
|
1978
|
+
const toolText = `- done \`${r.tool}\``;
|
|
1979
|
+
toolTimeline.push(toolText);
|
|
1980
|
+
currentTools.push(toolText);
|
|
1981
|
+
}
|
|
1963
1982
|
}
|
|
1983
|
+
} else {
|
|
1984
|
+
toolResults = [{
|
|
1985
|
+
callId: checkpointEvent.toolCallId,
|
|
1986
|
+
toolName: checkpointEvent.tool,
|
|
1987
|
+
error: "Tool execution denied by user"
|
|
1988
|
+
}];
|
|
1964
1989
|
}
|
|
1990
|
+
const fullMessages = [...messages, ...checkpointEvent.checkpointMessages];
|
|
1991
|
+
eventSource = harness.continueFromToolResult({
|
|
1992
|
+
messages: fullMessages,
|
|
1993
|
+
toolResults,
|
|
1994
|
+
abortSignal: activeRunAbortController.signal
|
|
1995
|
+
});
|
|
1996
|
+
process.stdout.write(gray("thinking..."));
|
|
1997
|
+
thinkingCleared = false;
|
|
1965
1998
|
}
|
|
1966
1999
|
} catch (error) {
|
|
1967
2000
|
clearThinking();
|
|
1968
|
-
if (activeRunAbortController
|
|
2001
|
+
if (activeRunAbortController?.signal.aborted) {
|
|
1969
2002
|
runCancelled = true;
|
|
1970
2003
|
} else {
|
|
1971
2004
|
runFailed = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poncho-ai/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "CLI for building and deploying AI agents",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"react": "^19.2.4",
|
|
28
28
|
"react-devtools-core": "^6.1.5",
|
|
29
29
|
"yaml": "^2.8.1",
|
|
30
|
-
"@poncho-ai/
|
|
31
|
-
"@poncho-ai/
|
|
32
|
-
"@poncho-ai/sdk": "1.0.
|
|
30
|
+
"@poncho-ai/harness": "0.14.1",
|
|
31
|
+
"@poncho-ai/messaging": "0.2.1",
|
|
32
|
+
"@poncho-ai/sdk": "1.0.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/busboy": "^1.5.4",
|