@algolia/wizard 0.5.0-rc.50.20 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +113 -143
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { render } from "ink";
|
|
5
5
|
|
|
6
6
|
// src/ui/App.tsx
|
|
7
|
-
import { Box as Box13, Text as Text13, useApp, useInput as useInput6, useWindowSize as
|
|
7
|
+
import { Box as Box13, Text as Text13, useApp, useInput as useInput6, useWindowSize as useWindowSize7 } from "ink";
|
|
8
8
|
|
|
9
9
|
// src/core/store.ts
|
|
10
10
|
import { create } from "zustand";
|
|
@@ -525,10 +525,20 @@ function NextAction({
|
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
// src/ui/SelectPrompt.tsx
|
|
528
|
-
import { Box as Box4, Text as Text4, useInput } from "ink";
|
|
529
|
-
import { useState as useState3 } from "react";
|
|
528
|
+
import { Box as Box4, Text as Text4, measureElement as measureElement2, useInput, useWindowSize as useWindowSize3 } from "ink";
|
|
529
|
+
import { useLayoutEffect, useRef as useRef2, useState as useState3 } from "react";
|
|
530
530
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
531
531
|
var CANCEL = "cancel";
|
|
532
|
+
var ARROW_WIDTH = 4;
|
|
533
|
+
var COLUMN_GAP = 2;
|
|
534
|
+
var BAR_PADDING = 2;
|
|
535
|
+
function fittedWidth(node, columns) {
|
|
536
|
+
let left = 0;
|
|
537
|
+
for (let n = node; n; n = n.parentNode) {
|
|
538
|
+
left += n.yogaNode?.getComputedLeft() ?? 0;
|
|
539
|
+
}
|
|
540
|
+
return Math.max(Math.min(measureElement2(node).width, columns - left), 0);
|
|
541
|
+
}
|
|
532
542
|
function SelectPrompt({
|
|
533
543
|
options,
|
|
534
544
|
onSelect,
|
|
@@ -553,12 +563,29 @@ function SelectPrompt({
|
|
|
553
563
|
if (rows.length > 1) hints.push({ key: "[\u2191] [\u2193]", label: "move" });
|
|
554
564
|
if (multi) hints.push({ key: "[space]", label: "select" });
|
|
555
565
|
hints.push({ key: "[enter]", label: "confirm" });
|
|
556
|
-
const
|
|
557
|
-
const
|
|
566
|
+
const containerRef = useRef2(null);
|
|
567
|
+
const { columns } = useWindowSize3();
|
|
568
|
+
const [width, setWidth] = useState3(columns);
|
|
569
|
+
useLayoutEffect(() => {
|
|
570
|
+
if (containerRef.current) {
|
|
571
|
+
setWidth(fittedWidth(containerRef.current, columns));
|
|
572
|
+
}
|
|
573
|
+
}, [columns]);
|
|
574
|
+
const inner = Math.max(width - BAR_PADDING, 0);
|
|
575
|
+
const labelWidth = Math.min(
|
|
576
|
+
ARROW_WIDTH + (multi ? 2 : 0) + Math.max(0, ...rows.map((opt) => opt.length)) + COLUMN_GAP,
|
|
577
|
+
inner
|
|
578
|
+
);
|
|
579
|
+
const badgeWidth = Math.max(
|
|
558
580
|
0,
|
|
559
|
-
...rows.map((_, i) =>
|
|
581
|
+
...rows.map((_, i) => {
|
|
582
|
+
const s = secondary?.[i];
|
|
583
|
+
return s?.kind === "badge" ? s.value.length : 0;
|
|
584
|
+
})
|
|
560
585
|
);
|
|
561
|
-
const
|
|
586
|
+
const barWidth = Math.min(labelWidth + badgeWidth + BAR_PADDING, width);
|
|
587
|
+
const barLabelWidth = Math.max(barWidth - BAR_PADDING - badgeWidth, 0);
|
|
588
|
+
const textWidth = inner - labelWidth;
|
|
562
589
|
useInput((input, key) => {
|
|
563
590
|
if (rows.length === 0) return;
|
|
564
591
|
if (key.upArrow || input === "k") {
|
|
@@ -582,7 +609,7 @@ function SelectPrompt({
|
|
|
582
609
|
}
|
|
583
610
|
}
|
|
584
611
|
});
|
|
585
|
-
return /* @__PURE__ */ jsxs3(Box4, { flexDirection: "column", gap: 1, children: [
|
|
612
|
+
return /* @__PURE__ */ jsx4(Box4, { ref: containerRef, flexGrow: 1, children: /* @__PURE__ */ jsxs3(Box4, { flexDirection: "column", gap: 1, width, children: [
|
|
586
613
|
error && /* @__PURE__ */ jsx4(Text4, { color: COLORS.danger, children: error }),
|
|
587
614
|
messages?.map((m, i) => /* @__PURE__ */ jsx4(Text4, { color: COLORS.muted, children: m }, `msg-${i}`)),
|
|
588
615
|
table && /* @__PURE__ */ jsx4(Table, { columns: table.columns, rows: table.rows }),
|
|
@@ -596,29 +623,36 @@ function SelectPrompt({
|
|
|
596
623
|
const bullet = multi && !isCancel ? checked.has(i) ? "\u25CF " : "\u25CB " : "";
|
|
597
624
|
const sec = isCancel ? void 0 : secondary?.[i];
|
|
598
625
|
const labelColor = highlighted ? COLORS.highlight.fg : void 0;
|
|
599
|
-
const label = /* @__PURE__ */ jsxs3(Text4, { color: labelColor, children: [
|
|
626
|
+
const label = /* @__PURE__ */ jsxs3(Text4, { color: labelColor, wrap: "truncate", children: [
|
|
600
627
|
highlighted ? "\u276F " : " ",
|
|
601
628
|
bullet,
|
|
602
629
|
option
|
|
603
630
|
] });
|
|
631
|
+
const isText = sec?.kind === "text";
|
|
604
632
|
return /* @__PURE__ */ jsxs3(
|
|
605
633
|
Box4,
|
|
606
634
|
{
|
|
607
|
-
width:
|
|
635
|
+
width: isText ? "100%" : barWidth,
|
|
608
636
|
paddingX: 1,
|
|
609
637
|
paddingY: 1,
|
|
610
638
|
backgroundColor: highlighted ? COLORS.highlight.bg : void 0,
|
|
611
639
|
children: [
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
640
|
+
/* @__PURE__ */ jsx4(Box4, { width: isText ? labelWidth : barLabelWidth, children: label }),
|
|
641
|
+
isText && textWidth > 0 && /* @__PURE__ */ jsx4(Box4, { width: textWidth, children: /* @__PURE__ */ jsx4(
|
|
642
|
+
Text4,
|
|
643
|
+
{
|
|
644
|
+
wrap: "truncate",
|
|
645
|
+
color: highlighted ? COLORS.primary : COLORS.muted,
|
|
646
|
+
children: sec.value
|
|
647
|
+
}
|
|
648
|
+
) }),
|
|
649
|
+
sec?.kind === "badge" && /* @__PURE__ */ jsx4(Box4, { width: badgeWidth, justifyContent: "flex-end", children: /* @__PURE__ */ jsx4(Text4, { color: COLORS.badge, wrap: "truncate", children: sec.value }) })
|
|
616
650
|
]
|
|
617
651
|
},
|
|
618
652
|
`row-${i}`
|
|
619
653
|
);
|
|
620
654
|
}) }),
|
|
621
|
-
/* @__PURE__ */ jsx4(
|
|
655
|
+
/* @__PURE__ */ jsx4(Text4, { children: hints.map(({ key, label }, i) => /* @__PURE__ */ jsxs3(Text4, { children: [
|
|
622
656
|
i > 0 ? " " : "",
|
|
623
657
|
/* @__PURE__ */ jsx4(Text4, { color: COLORS.primary, children: key }),
|
|
624
658
|
/* @__PURE__ */ jsxs3(Text4, { color: COLORS.dim, children: [
|
|
@@ -626,7 +660,7 @@ function SelectPrompt({
|
|
|
626
660
|
label
|
|
627
661
|
] })
|
|
628
662
|
] }, label)) })
|
|
629
|
-
] });
|
|
663
|
+
] }) });
|
|
630
664
|
}
|
|
631
665
|
|
|
632
666
|
// src/ui/PromptInput.tsx
|
|
@@ -749,7 +783,7 @@ function PromptInput() {
|
|
|
749
783
|
// src/ui/Welcome.tsx
|
|
750
784
|
import { dirname as dirname2, join as join3 } from "node:path";
|
|
751
785
|
import { fileURLToPath } from "node:url";
|
|
752
|
-
import { Box as Box6, Spacer, Text as Text6, useInput as useInput3, useWindowSize as
|
|
786
|
+
import { Box as Box6, Spacer, Text as Text6, useInput as useInput3, useWindowSize as useWindowSize4 } from "ink";
|
|
753
787
|
|
|
754
788
|
// src/ui/copy/welcome.ts
|
|
755
789
|
var sidebarItems = [
|
|
@@ -797,7 +831,7 @@ function SidebarItem({
|
|
|
797
831
|
function Welcome() {
|
|
798
832
|
const confirmStart = useWizard((s) => s.confirmStart);
|
|
799
833
|
const openLearnMore = useWizard((s) => s.openLearnMore);
|
|
800
|
-
const { rows } =
|
|
834
|
+
const { rows } = useWindowSize4();
|
|
801
835
|
useInput3((input) => {
|
|
802
836
|
if (input === " ") confirmStart();
|
|
803
837
|
else if (input === "i") openLearnMore();
|
|
@@ -865,7 +899,7 @@ function Welcome() {
|
|
|
865
899
|
|
|
866
900
|
// src/ui/LearnMore.tsx
|
|
867
901
|
import { Fragment as Fragment2 } from "react";
|
|
868
|
-
import { Box as Box7, Text as Text7, useInput as useInput4, useWindowSize as
|
|
902
|
+
import { Box as Box7, Text as Text7, useInput as useInput4, useWindowSize as useWindowSize5 } from "ink";
|
|
869
903
|
|
|
870
904
|
// src/ui/copy/learn-more.ts
|
|
871
905
|
var accessIntro = "Everything runs locally on your machine. Nothing is written or sent without an explicit yes from you.";
|
|
@@ -929,7 +963,7 @@ function NeverLine({
|
|
|
929
963
|
function LearnMore() {
|
|
930
964
|
const confirmStart = useWizard((s) => s.confirmStart);
|
|
931
965
|
const backToHome = useWizard((s) => s.backToHome);
|
|
932
|
-
const { columns } =
|
|
966
|
+
const { columns } = useWindowSize5();
|
|
933
967
|
const dividerWidth = Math.max(0, columns - PADDING_X * 2);
|
|
934
968
|
useInput4((input, key) => {
|
|
935
969
|
if (key.escape) backToHome();
|
|
@@ -1142,8 +1176,8 @@ function Ribbon() {
|
|
|
1142
1176
|
import { useState as useState6 } from "react";
|
|
1143
1177
|
|
|
1144
1178
|
// src/ui/Logs.tsx
|
|
1145
|
-
import { useLayoutEffect, useRef as
|
|
1146
|
-
import { Box as Box12, Text as Text12, measureElement as
|
|
1179
|
+
import { useLayoutEffect as useLayoutEffect2, useRef as useRef3, useState as useState5 } from "react";
|
|
1180
|
+
import { Box as Box12, Text as Text12, measureElement as measureElement3, useInput as useInput5, useWindowSize as useWindowSize6 } from "ink";
|
|
1147
1181
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1148
1182
|
var KIND_COLOR = {
|
|
1149
1183
|
tool: COLORS.primary,
|
|
@@ -1174,15 +1208,15 @@ function formatTimestamp(ms) {
|
|
|
1174
1208
|
}
|
|
1175
1209
|
function Logs() {
|
|
1176
1210
|
const logs = useWizard((s) => s.logs);
|
|
1177
|
-
const { rows, columns } =
|
|
1178
|
-
const viewportRef =
|
|
1211
|
+
const { rows, columns } = useWindowSize6();
|
|
1212
|
+
const viewportRef = useRef3(null);
|
|
1179
1213
|
const [viewportHeight, setViewportHeight] = useState5(0);
|
|
1180
1214
|
const [viewportWidth, setViewportWidth] = useState5(0);
|
|
1181
1215
|
const [scrollOffset, setScrollOffset] = useState5(0);
|
|
1182
|
-
const prevMaxOffsetRef =
|
|
1183
|
-
|
|
1216
|
+
const prevMaxOffsetRef = useRef3(0);
|
|
1217
|
+
useLayoutEffect2(() => {
|
|
1184
1218
|
if (!viewportRef.current) return;
|
|
1185
|
-
const { width, height } =
|
|
1219
|
+
const { width, height } = measureElement3(viewportRef.current);
|
|
1186
1220
|
setViewportHeight(height);
|
|
1187
1221
|
setViewportWidth(width);
|
|
1188
1222
|
}, [rows, columns, logs.length === 0]);
|
|
@@ -1197,7 +1231,7 @@ function Logs() {
|
|
|
1197
1231
|
}
|
|
1198
1232
|
const capacityAtBottom = logs.length > viewportHeight ? Math.max(viewportHeight - 1, 0) : viewportHeight;
|
|
1199
1233
|
const maxOffset = Math.max(logs.length - capacityAtBottom, 0);
|
|
1200
|
-
|
|
1234
|
+
useLayoutEffect2(() => {
|
|
1201
1235
|
const wasAtBottom = scrollOffset >= prevMaxOffsetRef.current;
|
|
1202
1236
|
prevMaxOffsetRef.current = maxOffset;
|
|
1203
1237
|
setScrollOffset((o) => wasAtBottom ? maxOffset : Math.min(o, maxOffset));
|
|
@@ -1270,7 +1304,7 @@ import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
|
1270
1304
|
function App() {
|
|
1271
1305
|
const { phase, error, homeScreen, currentStepIndex, steps, inputReq } = useWizard();
|
|
1272
1306
|
const { exit } = useApp();
|
|
1273
|
-
const { columns, rows } =
|
|
1307
|
+
const { columns, rows } = useWindowSize7();
|
|
1274
1308
|
const [showLogs, setShowLogs] = useState6(false);
|
|
1275
1309
|
const finished = phase === "done" || phase === "error";
|
|
1276
1310
|
const currentStep = steps[currentStepIndex];
|
|
@@ -1324,26 +1358,28 @@ function App() {
|
|
|
1324
1358
|
width: "100%",
|
|
1325
1359
|
justifyContent: "space-between",
|
|
1326
1360
|
children: [
|
|
1327
|
-
showLogs ? (
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1361
|
+
showLogs ? /* @__PURE__ */ jsx13(Logs, {}) : (
|
|
1362
|
+
/* Fill the width beside the sidebar; row layout only (would grow vertically when stacked). */
|
|
1363
|
+
/* @__PURE__ */ jsxs12(
|
|
1364
|
+
Box13,
|
|
1365
|
+
{
|
|
1366
|
+
flexDirection: "column",
|
|
1367
|
+
paddingX: 4,
|
|
1368
|
+
paddingY: 2,
|
|
1369
|
+
width: showSidebar ? 70 : "100%",
|
|
1370
|
+
flexGrow: showSidebar ? 1 : 0,
|
|
1371
|
+
children: [
|
|
1372
|
+
/* @__PURE__ */ jsx13(Notices, {}),
|
|
1373
|
+
/* @__PURE__ */ jsx13(PromptInput, {}),
|
|
1374
|
+
phase === "running" && showSidebar && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsx13(CurrentStep, {}) }),
|
|
1375
|
+
phase === "error" && error && /* @__PURE__ */ jsx13(Box13, { marginTop: 1, children: /* @__PURE__ */ jsxs12(Text13, { color: COLORS.status.error, children: [
|
|
1376
|
+
"\u2716 ",
|
|
1377
|
+
error
|
|
1378
|
+
] }) })
|
|
1379
|
+
]
|
|
1380
|
+
}
|
|
1381
|
+
)
|
|
1382
|
+
),
|
|
1347
1383
|
showSidebar ? /* @__PURE__ */ jsx13(Sidebar, {}) : /* @__PURE__ */ jsx13(Ribbon, {})
|
|
1348
1384
|
]
|
|
1349
1385
|
}
|
|
@@ -1864,12 +1900,7 @@ var selectIndexStep = async (ctx) => {
|
|
|
1864
1900
|
};
|
|
1865
1901
|
|
|
1866
1902
|
// src/lib/agent.ts
|
|
1867
|
-
import {
|
|
1868
|
-
ToolLoopAgent,
|
|
1869
|
-
hasToolCall,
|
|
1870
|
-
stepCountIs,
|
|
1871
|
-
Output as Output2
|
|
1872
|
-
} from "ai";
|
|
1903
|
+
import { ToolLoopAgent, hasToolCall, Output as Output2 } from "ai";
|
|
1873
1904
|
import { createAnthropic as createAnthropic2 } from "@ai-sdk/anthropic";
|
|
1874
1905
|
import "zod";
|
|
1875
1906
|
|
|
@@ -2462,41 +2493,9 @@ var MODEL_BY_SIZE = {
|
|
|
2462
2493
|
medium: "claude-sonnet-4-6",
|
|
2463
2494
|
large: "claude-opus-4-8"
|
|
2464
2495
|
};
|
|
2465
|
-
var STEP_TIMEOUT_MS = 15e4;
|
|
2466
|
-
var CHUNK_TIMEOUT_MS = 45e3;
|
|
2467
|
-
var MAX_STEPS = 100;
|
|
2468
|
-
function withRollingCacheBreakpoint(messages) {
|
|
2469
|
-
const last = messages.at(-1);
|
|
2470
|
-
if (!last) return messages;
|
|
2471
|
-
return [
|
|
2472
|
-
...messages.slice(0, -1),
|
|
2473
|
-
{
|
|
2474
|
-
...last,
|
|
2475
|
-
providerOptions: {
|
|
2476
|
-
...last.providerOptions,
|
|
2477
|
-
anthropic: {
|
|
2478
|
-
...last.providerOptions?.anthropic,
|
|
2479
|
-
cacheControl: { type: "ephemeral" }
|
|
2480
|
-
}
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
];
|
|
2484
|
-
}
|
|
2485
|
-
function asAgentError(name, err) {
|
|
2486
|
-
const aborted = err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
2487
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
2488
|
-
return new Error(
|
|
2489
|
-
aborted ? `${name} agent stalled \u2014 no response for ${STEP_TIMEOUT_MS / 1e3}s, or the stream died mid-response` : `${name} agent failed: ${message}`,
|
|
2490
|
-
{ cause: err }
|
|
2491
|
-
);
|
|
2492
|
-
}
|
|
2493
2496
|
async function runAgent(req) {
|
|
2494
2497
|
const start = Date.now();
|
|
2495
|
-
|
|
2496
|
-
logger.info(
|
|
2497
|
-
{ agent: name, startedAt: new Date(start).toISOString() },
|
|
2498
|
-
"runAgent started"
|
|
2499
|
-
);
|
|
2498
|
+
logger.info({ startedAt: new Date(start).toISOString() }, "runAgent started");
|
|
2500
2499
|
const token = getAuthToken();
|
|
2501
2500
|
if (!token) {
|
|
2502
2501
|
throw new Error("Not authenticated: no user token available");
|
|
@@ -2516,16 +2515,11 @@ async function runAgent(req) {
|
|
|
2516
2515
|
] : [],
|
|
2517
2516
|
"Call notifyUser whenever you start a new phase of work or your focus shifts (e.g. moving from reading code to writing files) \u2014 a short, plain-language, high-level update. Do not call it for every tool use."
|
|
2518
2517
|
];
|
|
2519
|
-
let streamError;
|
|
2520
|
-
const logStreamErrors = {
|
|
2521
|
-
onError: ({ error }) => logger.error({ agent: name, err: error }, "agent stream error")
|
|
2522
|
-
};
|
|
2523
2518
|
const agent = new ToolLoopAgent({
|
|
2524
|
-
...logStreamErrors,
|
|
2525
2519
|
model: anthropic2(MODEL_BY_SIZE[req.modelSize ?? "medium"]),
|
|
2526
|
-
// Cache the
|
|
2527
|
-
//
|
|
2528
|
-
//
|
|
2520
|
+
// Cache tools + system on the last system block. Tools render before
|
|
2521
|
+
// system, so one breakpoint here caches both, reused on every loop turn
|
|
2522
|
+
// after the first.
|
|
2529
2523
|
instructions: instructions.map((i, idx, arr) => {
|
|
2530
2524
|
return {
|
|
2531
2525
|
role: "system",
|
|
@@ -2543,70 +2537,51 @@ async function runAgent(req) {
|
|
|
2543
2537
|
tools: req.tools
|
|
2544
2538
|
}),
|
|
2545
2539
|
toolChoice: "required",
|
|
2546
|
-
stopWhen: [hasToolCall("reportStatus")
|
|
2547
|
-
prepareStep: ({ messages }) => ({
|
|
2548
|
-
messages: withRollingCacheBreakpoint(messages)
|
|
2549
|
-
})
|
|
2540
|
+
stopWhen: [hasToolCall("reportStatus")]
|
|
2550
2541
|
});
|
|
2551
2542
|
const stream = await agent.stream({
|
|
2552
|
-
prompt: "Follow system instructions"
|
|
2553
|
-
timeout: { stepMs: STEP_TIMEOUT_MS, chunkMs: CHUNK_TIMEOUT_MS }
|
|
2543
|
+
prompt: "Follow system instructions"
|
|
2554
2544
|
});
|
|
2555
2545
|
let chunks = [];
|
|
2556
2546
|
const chunkLimit = 5;
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
continue;
|
|
2562
|
-
}
|
|
2563
|
-
if (part.type !== "text-delta") continue;
|
|
2564
|
-
if (chunks.length < chunkLimit) {
|
|
2565
|
-
chunks.push(part.text);
|
|
2566
|
-
continue;
|
|
2567
|
-
}
|
|
2568
|
-
chunks.push(part.text);
|
|
2569
|
-
logger.debug(chunks.join(""));
|
|
2570
|
-
chunks = [];
|
|
2547
|
+
for await (const chunk of stream.textStream) {
|
|
2548
|
+
if (chunks.length < chunkLimit) {
|
|
2549
|
+
chunks.push(chunk);
|
|
2550
|
+
continue;
|
|
2571
2551
|
}
|
|
2572
|
-
|
|
2573
|
-
|
|
2552
|
+
chunks.push(chunk);
|
|
2553
|
+
logger.debug(chunks.join(""));
|
|
2554
|
+
chunks = [];
|
|
2574
2555
|
}
|
|
2575
2556
|
if (chunks.length) {
|
|
2576
2557
|
logger.debug(chunks.join(""));
|
|
2577
2558
|
}
|
|
2578
2559
|
const end = Date.now();
|
|
2579
|
-
|
|
2580
|
-
let toolResults;
|
|
2581
|
-
try {
|
|
2582
|
-
usage = await stream.totalUsage;
|
|
2583
|
-
toolResults = await stream.toolResults;
|
|
2584
|
-
} catch (err) {
|
|
2585
|
-
throw asAgentError(name, streamError ?? err);
|
|
2586
|
-
}
|
|
2560
|
+
const usage = await stream.totalUsage;
|
|
2587
2561
|
logger.info(
|
|
2588
2562
|
{
|
|
2589
|
-
agent: name,
|
|
2590
2563
|
finishedAt: new Date(end).toISOString(),
|
|
2591
2564
|
durationMs: end - start,
|
|
2565
|
+
// cachedInputTokens > 0 confirms prompt caching engaged. If it stays 0
|
|
2566
|
+
// across turns, the tools+system prefix is under the model's min
|
|
2567
|
+
// cacheable size (2048 tokens for sonnet-4-6) and caching is a no-op.
|
|
2592
2568
|
usage
|
|
2593
2569
|
},
|
|
2594
2570
|
"runAgent finished"
|
|
2595
2571
|
);
|
|
2596
2572
|
logger.info(
|
|
2597
|
-
{
|
|
2573
|
+
{ counts: toolContext.counts, limits: toolContext.limits },
|
|
2598
2574
|
"tool usage"
|
|
2599
2575
|
);
|
|
2576
|
+
const toolResults = await stream.toolResults;
|
|
2600
2577
|
const report = [...toolResults].reverse().find((r) => r.toolName === "reportStatus");
|
|
2601
2578
|
if (!report) {
|
|
2602
|
-
throw new Error(
|
|
2603
|
-
cause: streamError
|
|
2604
|
-
});
|
|
2579
|
+
throw new Error("Agent finished without calling reportStatus");
|
|
2605
2580
|
}
|
|
2606
2581
|
const result = report.output;
|
|
2607
2582
|
if (result.status !== "success") {
|
|
2608
2583
|
throw new Error(
|
|
2609
|
-
|
|
2584
|
+
`Agent reported failure: ${result.reason ?? "no reason given"}`
|
|
2610
2585
|
);
|
|
2611
2586
|
}
|
|
2612
2587
|
return result.output;
|
|
@@ -2630,8 +2605,7 @@ var detectLanguage = () => runAgent({
|
|
|
2630
2605
|
],
|
|
2631
2606
|
tools: ["listFiles", "changeDirectory", "readFile", "searchFiles"],
|
|
2632
2607
|
outputSchema: detectLanguageSchema,
|
|
2633
|
-
modelSize: "small"
|
|
2634
|
-
name: "detect-language"
|
|
2608
|
+
modelSize: "small"
|
|
2635
2609
|
});
|
|
2636
2610
|
|
|
2637
2611
|
// src/actions/analyzeCodebase.ts
|
|
@@ -2707,8 +2681,7 @@ function runMode(mode, extraInstructions = []) {
|
|
|
2707
2681
|
return runAgent({
|
|
2708
2682
|
instructions: [...instructions, ...extraInstructions],
|
|
2709
2683
|
tools: READONLY_TOOLS,
|
|
2710
|
-
outputSchema
|
|
2711
|
-
name: `analyze:${mode}`
|
|
2684
|
+
outputSchema
|
|
2712
2685
|
});
|
|
2713
2686
|
}
|
|
2714
2687
|
async function runAnalysis(mode, extraInstructions = []) {
|
|
@@ -2722,7 +2695,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
2722
2695
|
// package.json
|
|
2723
2696
|
var package_default = {
|
|
2724
2697
|
name: "@algolia/wizard",
|
|
2725
|
-
version: "0.5.0
|
|
2698
|
+
version: "0.5.0",
|
|
2726
2699
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2727
2700
|
type: "module",
|
|
2728
2701
|
engines: {
|
|
@@ -3117,8 +3090,7 @@ ${formatCompletedSteps(ctx.completedSteps)}`,
|
|
|
3117
3090
|
],
|
|
3118
3091
|
tools: [],
|
|
3119
3092
|
outputSchema: reviewSchema,
|
|
3120
|
-
modelSize: "small"
|
|
3121
|
-
name: "review"
|
|
3093
|
+
modelSize: "small"
|
|
3122
3094
|
});
|
|
3123
3095
|
ctx.notify({ messages: formatReviewSummary(result) });
|
|
3124
3096
|
return result;
|
|
@@ -3900,8 +3872,7 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES, existingWo
|
|
|
3900
3872
|
extraInstructions
|
|
3901
3873
|
),
|
|
3902
3874
|
tools: toolsForUseCase(currentUseCase, input.ingestionSource),
|
|
3903
|
-
outputSchema: implementationOutputSchema
|
|
3904
|
-
name: `implement:${currentUseCase}`
|
|
3875
|
+
outputSchema: implementationOutputSchema
|
|
3905
3876
|
});
|
|
3906
3877
|
ctx.notify({
|
|
3907
3878
|
messages: [`Installing dependencies for ${currentUseCase}\u2026`]
|
|
@@ -3926,8 +3897,7 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES, existingWo
|
|
|
3926
3897
|
return runAgent({
|
|
3927
3898
|
instructions: buildAgentInstructions("verification", input),
|
|
3928
3899
|
tools: toolsForUseCase("verification"),
|
|
3929
|
-
outputSchema: verificationOutputSchema
|
|
3930
|
-
name: "implement:verification"
|
|
3900
|
+
outputSchema: verificationOutputSchema
|
|
3931
3901
|
});
|
|
3932
3902
|
}
|
|
3933
3903
|
if (useCases.includes("ingestion")) {
|