pi-agent-flow 1.8.1 → 1.8.3
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/README.md +4 -30
- package/agents/audit.md +1 -2
- package/agents/build.md +1 -0
- package/agents/craft.md +12 -8
- package/agents/debug.md +2 -2
- package/agents/ideas.md +1 -0
- package/agents/scout.md +1 -0
- package/dist/agents.d.ts +41 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +283 -0
- package/dist/agents.js.map +1 -0
- package/dist/batch/batch-bash.d.ts +87 -0
- package/dist/batch/batch-bash.d.ts.map +1 -0
- package/dist/batch/batch-bash.js +369 -0
- package/dist/batch/batch-bash.js.map +1 -0
- package/dist/batch/constants.d.ts +100 -0
- package/dist/batch/constants.d.ts.map +1 -0
- package/dist/batch/constants.js +15 -0
- package/dist/batch/constants.js.map +1 -0
- package/dist/batch/execute.d.ts +21 -0
- package/dist/batch/execute.d.ts.map +1 -0
- package/dist/batch/execute.js +440 -0
- package/dist/batch/execute.js.map +1 -0
- package/dist/batch/fuzzy-edit.d.ts +29 -0
- package/dist/batch/fuzzy-edit.d.ts.map +1 -0
- package/dist/batch/fuzzy-edit.js +257 -0
- package/dist/batch/fuzzy-edit.js.map +1 -0
- package/dist/batch/index.d.ts +85 -0
- package/dist/batch/index.d.ts.map +1 -0
- package/dist/batch/index.js +422 -0
- package/dist/batch/index.js.map +1 -0
- package/dist/batch/render.d.ts +14 -0
- package/dist/batch/render.d.ts.map +1 -0
- package/dist/batch/render.js +74 -0
- package/dist/batch/render.js.map +1 -0
- package/dist/batch/symbols.d.ts +9 -0
- package/dist/batch/symbols.d.ts.map +1 -0
- package/dist/batch/symbols.js +310 -0
- package/dist/batch/symbols.js.map +1 -0
- package/dist/batch.d.ts +12 -0
- package/dist/batch.d.ts.map +1 -0
- package/dist/batch.js +11 -0
- package/dist/batch.js.map +1 -0
- package/dist/cli-args.d.ts +27 -0
- package/dist/cli-args.d.ts.map +1 -0
- package/dist/cli-args.js +265 -0
- package/dist/cli-args.js.map +1 -0
- package/dist/config.d.ts +58 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +296 -0
- package/dist/config.js.map +1 -0
- package/dist/depth.d.ts +25 -0
- package/dist/depth.d.ts.map +1 -0
- package/dist/depth.js +160 -0
- package/dist/depth.js.map +1 -0
- package/dist/executor.d.ts +87 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +295 -0
- package/dist/executor.js.map +1 -0
- package/dist/flow-prompt.d.ts +23 -0
- package/dist/flow-prompt.d.ts.map +1 -0
- package/dist/flow-prompt.js +99 -0
- package/dist/flow-prompt.js.map +1 -0
- package/dist/flow.d.ts +76 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/flow.js +704 -0
- package/dist/flow.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +327 -0
- package/dist/index.js.map +1 -0
- package/dist/reasoning-strip.d.ts +26 -0
- package/dist/reasoning-strip.d.ts.map +1 -0
- package/dist/reasoning-strip.js +58 -0
- package/dist/reasoning-strip.js.map +1 -0
- package/dist/render-utils.d.ts +42 -0
- package/dist/render-utils.d.ts.map +1 -0
- package/dist/render-utils.js +182 -0
- package/dist/render-utils.js.map +1 -0
- package/dist/render.d.ts +24 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +409 -0
- package/dist/render.js.map +1 -0
- package/dist/runner-events.d.ts +59 -0
- package/dist/runner-events.d.ts.map +1 -0
- package/dist/runner-events.js +539 -0
- package/dist/runner-events.js.map +1 -0
- package/dist/session-mode.d.ts +10 -0
- package/dist/session-mode.d.ts.map +1 -0
- package/dist/session-mode.js +25 -0
- package/dist/session-mode.js.map +1 -0
- package/dist/settings-resolver.d.ts +28 -0
- package/dist/settings-resolver.d.ts.map +1 -0
- package/dist/settings-resolver.js +148 -0
- package/dist/settings-resolver.js.map +1 -0
- package/dist/sliding-prompt.d.ts +40 -0
- package/dist/sliding-prompt.d.ts.map +1 -0
- package/dist/sliding-prompt.js +121 -0
- package/dist/sliding-prompt.js.map +1 -0
- package/dist/snapshot.d.ts +29 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +199 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/structured-output.d.ts +36 -0
- package/dist/structured-output.d.ts.map +1 -0
- package/dist/structured-output.js +244 -0
- package/dist/structured-output.js.map +1 -0
- package/dist/timed-bash.d.ts +45 -0
- package/dist/timed-bash.d.ts.map +1 -0
- package/dist/timed-bash.js +219 -0
- package/dist/timed-bash.js.map +1 -0
- package/dist/tool-utils.d.ts +20 -0
- package/dist/tool-utils.d.ts.map +1 -0
- package/dist/tool-utils.js +38 -0
- package/dist/tool-utils.js.map +1 -0
- package/dist/transitions.d.ts +39 -0
- package/dist/transitions.d.ts.map +1 -0
- package/dist/transitions.js +59 -0
- package/dist/transitions.js.map +1 -0
- package/dist/types.d.ts +207 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +143 -0
- package/dist/types.js.map +1 -0
- package/dist/web-tool.d.ts +35 -0
- package/dist/web-tool.d.ts.map +1 -0
- package/dist/web-tool.js +545 -0
- package/dist/web-tool.js.map +1 -0
- package/package.json +7 -5
- package/src/agents.ts +0 -299
- package/src/ambient.d.ts +0 -107
- package/src/batch/batch-bash.ts +0 -443
- package/src/batch/constants.ts +0 -128
- package/src/batch/execute.ts +0 -551
- package/src/batch/fuzzy-edit.ts +0 -323
- package/src/batch/index.ts +0 -494
- package/src/batch/render.ts +0 -81
- package/src/batch/symbols.ts +0 -341
- package/src/batch.ts +0 -28
- package/src/cli-args.ts +0 -315
- package/src/config.ts +0 -391
- package/src/executor.ts +0 -445
- package/src/flow.ts +0 -834
- package/src/hooks.ts +0 -294
- package/src/index.ts +0 -1132
- package/src/render-utils.ts +0 -205
- package/src/render.ts +0 -524
- package/src/runner-events.ts +0 -692
- package/src/session-mode.ts +0 -33
- package/src/sliding-prompt.ts +0 -144
- package/src/structured-output.ts +0 -195
- package/src/timed-bash.ts +0 -270
- package/src/transitions.ts +0 -86
- package/src/types.ts +0 -386
- package/src/web-tool.ts +0 -663
package/dist/types.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for the flow-state delegation extension.
|
|
3
|
+
*/
|
|
4
|
+
import { getFlowFinalText } from "./runner-events.js";
|
|
5
|
+
/** Create an empty UsageStats object. */
|
|
6
|
+
export function emptyFlowUsage() {
|
|
7
|
+
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0, toolCalls: 0, smoothedTps: 0 };
|
|
8
|
+
}
|
|
9
|
+
/** Sum usage across multiple results. */
|
|
10
|
+
export function aggregateFlowUsage(results) {
|
|
11
|
+
const total = emptyFlowUsage();
|
|
12
|
+
for (const r of results) {
|
|
13
|
+
total.input += r.usage.input;
|
|
14
|
+
total.output += r.usage.output;
|
|
15
|
+
total.cacheRead += r.usage.cacheRead;
|
|
16
|
+
total.cacheWrite += r.usage.cacheWrite;
|
|
17
|
+
total.cost += r.usage.cost;
|
|
18
|
+
total.turns += r.usage.turns;
|
|
19
|
+
total.toolCalls += r.usage.toolCalls;
|
|
20
|
+
if ((r.usage.smoothedTps ?? 0) > (total.smoothedTps ?? 0)) {
|
|
21
|
+
total.smoothedTps = r.usage.smoothedTps;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return total;
|
|
25
|
+
}
|
|
26
|
+
/** Whether the child emitted a final assistant text response. */
|
|
27
|
+
export function hasFlowOutput(r) {
|
|
28
|
+
return getFlowFinalText(r.messages).trim().length > 0;
|
|
29
|
+
}
|
|
30
|
+
/** Whether the child semantically completed the run. */
|
|
31
|
+
export function isFlowComplete(r) {
|
|
32
|
+
return Boolean(r.sawAgentEnd) && hasFlowOutput(r);
|
|
33
|
+
}
|
|
34
|
+
/** Whether a result should be treated as successful by the wrapper/UI. */
|
|
35
|
+
export function isFlowSuccess(r) {
|
|
36
|
+
if (r.exitCode === -1)
|
|
37
|
+
return false;
|
|
38
|
+
if (isFlowComplete(r))
|
|
39
|
+
return true;
|
|
40
|
+
return r.exitCode === 0 && r.stopReason !== "error" && r.stopReason !== "aborted" && r.stopReason !== "timeout";
|
|
41
|
+
}
|
|
42
|
+
/** Whether a result represents an error. */
|
|
43
|
+
export function isFlowError(r) {
|
|
44
|
+
if (r.exitCode === -1)
|
|
45
|
+
return false;
|
|
46
|
+
return !isFlowSuccess(r);
|
|
47
|
+
}
|
|
48
|
+
/** Reconcile process exit status with semantic completion observed from Pi's event stream. */
|
|
49
|
+
export function normalizeFlowResult(result, wasAborted) {
|
|
50
|
+
const hasSemanticSuccess = isFlowComplete(result);
|
|
51
|
+
if (wasAborted) {
|
|
52
|
+
if (hasSemanticSuccess) {
|
|
53
|
+
result.exitCode = 0;
|
|
54
|
+
if (result.stopReason === "aborted")
|
|
55
|
+
result.stopReason = undefined;
|
|
56
|
+
if (result.errorMessage === "Flow was aborted.") {
|
|
57
|
+
result.errorMessage = undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
result.exitCode = 130;
|
|
62
|
+
result.stopReason = "aborted";
|
|
63
|
+
result.errorMessage = "Flow was aborted.";
|
|
64
|
+
if (!result.stderr.trim())
|
|
65
|
+
result.stderr = "Flow was aborted.";
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
if (result.exitCode > 0) {
|
|
70
|
+
if (hasSemanticSuccess) {
|
|
71
|
+
result.exitCode = 0;
|
|
72
|
+
if (result.stopReason === "error")
|
|
73
|
+
result.stopReason = undefined;
|
|
74
|
+
if (result.errorMessage === result.stderr.trim()) {
|
|
75
|
+
result.errorMessage = undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (!result.stopReason)
|
|
80
|
+
result.stopReason = "error";
|
|
81
|
+
if (!result.errorMessage && result.stderr.trim()) {
|
|
82
|
+
result.errorMessage = result.stderr.trim();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
/** Extract the last assistant text from a message history. */
|
|
89
|
+
export function getFlowOutput(messages) {
|
|
90
|
+
return getFlowFinalText(messages);
|
|
91
|
+
}
|
|
92
|
+
/** Extract all display-worthy items from a message history. */
|
|
93
|
+
export function getFlowDisplayItems(messages) {
|
|
94
|
+
const items = [];
|
|
95
|
+
for (const msg of messages) {
|
|
96
|
+
if (msg.role === "assistant") {
|
|
97
|
+
for (const part of msg.content) {
|
|
98
|
+
if (part.type === "text") {
|
|
99
|
+
items.push({ type: "text", text: part.text });
|
|
100
|
+
}
|
|
101
|
+
else if (part.type === "toolCall") {
|
|
102
|
+
const name = part.name ?? part.toolName ?? "unknown";
|
|
103
|
+
const args = (part.arguments ?? part.input ?? {});
|
|
104
|
+
items.push({ type: "toolCall", name, args });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return items;
|
|
110
|
+
}
|
|
111
|
+
/** Extract the last tool call from message history. */
|
|
112
|
+
export function getLastToolCall(messages) {
|
|
113
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
114
|
+
const msg = messages[i];
|
|
115
|
+
if (msg.role === "assistant") {
|
|
116
|
+
for (let j = msg.content.length - 1; j >= 0; j--) {
|
|
117
|
+
const part = msg.content[j];
|
|
118
|
+
if (part.type === "toolCall") {
|
|
119
|
+
const name = part.name ?? part.toolName ?? "unknown";
|
|
120
|
+
const args = (part.arguments ?? part.input ?? {});
|
|
121
|
+
return { type: "toolCall", name, args };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
/** Extract the last assistant text from message history. */
|
|
129
|
+
export function getLastAssistantText(messages) {
|
|
130
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
131
|
+
const msg = messages[i];
|
|
132
|
+
if (msg.role === "assistant") {
|
|
133
|
+
for (let j = msg.content.length - 1; j >= 0; j--) {
|
|
134
|
+
const part = msg.content[j];
|
|
135
|
+
if (part.type === "text" && part.text.trim()) {
|
|
136
|
+
return part.text.trim();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return "";
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA8ItD,yCAAyC;AACzC,MAAM,UAAU,cAAc;IAC7B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;AAChI,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,kBAAkB,CAAC,OAAuB;IACzD,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACzB,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7B,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;QAC/B,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;QACrC,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;QACvC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,IAA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AAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;oBAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACzB,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { type Static } from "@sinclair/typebox";
|
|
3
|
+
export declare const webSchema: any;
|
|
4
|
+
type WebParams = Static<typeof webSchema>;
|
|
5
|
+
export declare function createWebTool(): {
|
|
6
|
+
name: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description: string;
|
|
9
|
+
promptSnippet: string;
|
|
10
|
+
promptGuidelines: string[];
|
|
11
|
+
parameters: any;
|
|
12
|
+
execute(_toolCallId: string, params: WebParams, signal: AbortSignal | undefined, _onUpdate: unknown, ctx: ExtensionContext): Promise<{
|
|
13
|
+
content: {
|
|
14
|
+
type: "text";
|
|
15
|
+
text: string;
|
|
16
|
+
}[];
|
|
17
|
+
details: {
|
|
18
|
+
ops: Record<string, unknown>[];
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
export declare function setWebToolsActive(pi: ExtensionAPI, enabled: boolean): void;
|
|
23
|
+
export declare function extractSnippet(raw: string, title: string): string;
|
|
24
|
+
export declare function validateFetchUrl(url: string): void;
|
|
25
|
+
export declare function htmlToMarkdown(html: string, baseUrl: string): {
|
|
26
|
+
title: string;
|
|
27
|
+
markdown: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function trimLargeDocument(markdown: string, maxChars: number): string;
|
|
30
|
+
export declare function stripMarkdownFormatting(markdown: string): string;
|
|
31
|
+
export declare function urlToHash(url: string): string;
|
|
32
|
+
export declare function looksLikeUrlPrompt(prompt: string | undefined): boolean;
|
|
33
|
+
export declare function looksLikeWebSearchPrompt(prompt: string | undefined): boolean;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=web-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-tool.d.ts","sourceRoot":"","sources":["../src/web-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA4BtD,eAAO,MAAM,SAAS,KAKpB,CAAC;AAEH,KAAK,SAAS,GAAG,MAAM,CAAC,OAAO,SAAS,CAAC,CAAC;AA8B1C,wBAAgB,aAAa;;;;;;;yBAgBb,MAAM,UACX,SAAS,UACT,WAAW,GAAG,SAAS,aACpB,OAAO,OACb,gBAAgB;;;;;;;;;EAKvB;AAMD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,QAKnE;AA6XD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMjE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CA6BlD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAyCjG;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAY5E;AAOD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA4BhE;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAgBD,wBAAgB,kBAAkB,C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