@getpochi/cli 0.6.3 → 0.6.4
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/cli.js +276 -174
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -133488,13 +133488,13 @@ var init_Entity = __esm(() => {
|
|
|
133488
133488
|
get client() {
|
|
133489
133489
|
return shardingTag.pipe(flatMap15((sharding) => sharding.makeClient(this)));
|
|
133490
133490
|
},
|
|
133491
|
-
toLayer(
|
|
133492
|
-
return shardingTag.pipe(flatMap15((sharding) => sharding.registerEntity(this, isEffect2(
|
|
133491
|
+
toLayer(build4, options12) {
|
|
133492
|
+
return shardingTag.pipe(flatMap15((sharding) => sharding.registerEntity(this, isEffect2(build4) ? build4 : succeed11(build4), options12)), scopedDiscard2);
|
|
133493
133493
|
},
|
|
133494
133494
|
of: identity,
|
|
133495
|
-
toLayerMailbox(
|
|
133495
|
+
toLayerMailbox(build4, options12) {
|
|
133496
133496
|
const buildHandlers = gen4(this, function* () {
|
|
133497
|
-
const behaviour = isEffect2(
|
|
133497
|
+
const behaviour = isEffect2(build4) ? yield* build4 : build4;
|
|
133498
133498
|
const mailbox = yield* make80();
|
|
133499
133499
|
const handler2 = (envelope) => {
|
|
133500
133500
|
return async((resume2) => {
|
|
@@ -135063,14 +135063,14 @@ var init_Sharding = __esm(() => {
|
|
|
135063
135063
|
const context15 = yield* context3();
|
|
135064
135064
|
const reaper = yield* EntityReaper;
|
|
135065
135065
|
const entityManagerLatches = new Map;
|
|
135066
|
-
const registerEntity = fnUntraced2(function* (entity,
|
|
135066
|
+
const registerEntity = fnUntraced2(function* (entity, build4, options12) {
|
|
135067
135067
|
if (isNone2(config5.runnerAddress) || entityManagers.has(entity.type))
|
|
135068
135068
|
return;
|
|
135069
135069
|
const scope5 = yield* scope3;
|
|
135070
135070
|
yield* addFinalizer2(scope5, sync6(() => {
|
|
135071
135071
|
state2.status = "closed";
|
|
135072
135072
|
}));
|
|
135073
|
-
const manager = yield* make178(entity,
|
|
135073
|
+
const manager = yield* make178(entity, build4, {
|
|
135074
135074
|
...options12,
|
|
135075
135075
|
storage,
|
|
135076
135076
|
runnerAddress: config5.runnerAddress.value,
|
|
@@ -172750,7 +172750,7 @@ var require_main2 = __commonJS((exports, module) => {
|
|
|
172750
172750
|
__export3(node_exports, {
|
|
172751
172751
|
analyzeMetafile: () => analyzeMetafile,
|
|
172752
172752
|
analyzeMetafileSync: () => analyzeMetafileSync,
|
|
172753
|
-
build: () =>
|
|
172753
|
+
build: () => build4,
|
|
172754
172754
|
buildSync: () => buildSync,
|
|
172755
172755
|
context: () => context15,
|
|
172756
172756
|
default: () => node_default,
|
|
@@ -174725,7 +174725,7 @@ More information: The file containing the code for esbuild's JavaScript API (${_
|
|
|
174725
174725
|
}
|
|
174726
174726
|
};
|
|
174727
174727
|
var version4 = "0.25.9";
|
|
174728
|
-
var
|
|
174728
|
+
var build4 = (options14) => ensureServiceIsRunning().build(options14);
|
|
174729
174729
|
var context15 = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
|
174730
174730
|
var transform14 = (input, options14) => ensureServiceIsRunning().transform(input, options14);
|
|
174731
174731
|
var formatMessages2 = (messages, options14) => ensureServiceIsRunning().formatMessages(messages, options14);
|
|
@@ -175217,7 +175217,7 @@ function build$1(options14, isSynchronous) {
|
|
|
175217
175217
|
else
|
|
175218
175218
|
return isSynchronous ? defaultSync : defaultAsync;
|
|
175219
175219
|
}
|
|
175220
|
-
function
|
|
175220
|
+
function build4(isSynchronous) {
|
|
175221
175221
|
return isSynchronous ? walkSync : walkAsync;
|
|
175222
175222
|
}
|
|
175223
175223
|
function promise5(root2, options14) {
|
|
@@ -175411,7 +175411,7 @@ var __require3, SLASHES_REGEX, WINDOWS_ROOT_DIR_REGEX, pushDirectory = (director
|
|
|
175411
175411
|
this.getArray = build$4(options14);
|
|
175412
175412
|
this.groupFiles = build$3(options14);
|
|
175413
175413
|
this.resolveSymlink = build$2(options14, this.isSynchronous);
|
|
175414
|
-
this.walkDirectory =
|
|
175414
|
+
this.walkDirectory = build4(this.isSynchronous);
|
|
175415
175415
|
}
|
|
175416
175416
|
start() {
|
|
175417
175417
|
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
@@ -178023,7 +178023,7 @@ var require_main3 = __commonJS((exports, module) => {
|
|
|
178023
178023
|
__export3(node_exports, {
|
|
178024
178024
|
analyzeMetafile: () => analyzeMetafile,
|
|
178025
178025
|
analyzeMetafileSync: () => analyzeMetafileSync,
|
|
178026
|
-
build: () =>
|
|
178026
|
+
build: () => build5,
|
|
178027
178027
|
buildSync: () => buildSync,
|
|
178028
178028
|
context: () => context15,
|
|
178029
178029
|
default: () => node_default,
|
|
@@ -179998,7 +179998,7 @@ More information: The file containing the code for esbuild's JavaScript API (${_
|
|
|
179998
179998
|
}
|
|
179999
179999
|
};
|
|
180000
180000
|
var version4 = "0.25.1";
|
|
180001
|
-
var
|
|
180001
|
+
var build5 = (options14) => ensureServiceIsRunning().build(options14);
|
|
180002
180002
|
var context15 = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
|
180003
180003
|
var transform14 = (input, options14) => ensureServiceIsRunning().transform(input, options14);
|
|
180004
180004
|
var formatMessages2 = (messages, options14) => ensureServiceIsRunning().formatMessages(messages, options14);
|
|
@@ -186739,16 +186739,16 @@ var require_babel = __commonJS((exports, module) => {
|
|
|
186739
186739
|
if (maps[i8].sources.length > 1)
|
|
186740
186740
|
throw new Error(`Transformation map ${i8} must have exactly one source file.
|
|
186741
186741
|
Did you specify these with the most recent transformation maps first?`);
|
|
186742
|
-
let tree =
|
|
186742
|
+
let tree = build5(map52, loader, "", 0);
|
|
186743
186743
|
for (let i8 = maps.length - 1;i8 >= 0; i8--)
|
|
186744
186744
|
tree = MapSource(maps[i8], [tree]);
|
|
186745
186745
|
return tree;
|
|
186746
186746
|
}
|
|
186747
|
-
function
|
|
186747
|
+
function build5(map52, loader, importer, importerDepth) {
|
|
186748
186748
|
const { resolvedSources, sourcesContent, ignoreList } = map52, depth = importerDepth + 1;
|
|
186749
186749
|
return MapSource(map52, resolvedSources.map((sourceFile, i8) => {
|
|
186750
186750
|
const ctx = { importer, depth, source: sourceFile || "", content: undefined, ignore: undefined }, sourceMap = loader(ctx.source, ctx), { source, content: content3, ignore: ignore7 } = ctx;
|
|
186751
|
-
return sourceMap ?
|
|
186751
|
+
return sourceMap ? build5(new traceMapping.TraceMap(sourceMap, source), loader, source, depth) : OriginalSource(source, content3 !== undefined ? content3 : sourcesContent ? sourcesContent[i8] : null, ignore7 !== undefined ? ignore7 : !!ignoreList && ignoreList.includes(i8));
|
|
186752
186752
|
}));
|
|
186753
186753
|
}
|
|
186754
186754
|
|
|
@@ -191124,10 +191124,10 @@ See https://babeljs.io/docs/configuration#print-effective-configs for more info.
|
|
|
191124
191124
|
}
|
|
191125
191125
|
Object.defineProperty(exports2, "__esModule", { value: true }), exports2.default = function(allowlist, outputType = "global") {
|
|
191126
191126
|
let tree;
|
|
191127
|
-
const
|
|
191128
|
-
if (!
|
|
191127
|
+
const build5 = { global: buildGlobal, module: buildModule, umd: buildUmd, var: buildVar }[outputType];
|
|
191128
|
+
if (!build5)
|
|
191129
191129
|
throw new Error(`Unsupported output type ${outputType}`);
|
|
191130
|
-
tree =
|
|
191130
|
+
tree = build5(allowlist);
|
|
191131
191131
|
return (0, _generator().default)(tree).code;
|
|
191132
191132
|
};
|
|
191133
191133
|
const { arrayExpression: arrayExpression2, assignmentExpression: assignmentExpression2, binaryExpression: binaryExpression2, blockStatement: blockStatement2, callExpression: callExpression2, cloneNode, conditionalExpression: conditionalExpression2, exportNamedDeclaration: exportNamedDeclaration2, exportSpecifier: exportSpecifier2, expressionStatement: expressionStatement2, functionExpression: functionExpression2, identifier: identifier3, memberExpression: memberExpression2, objectExpression: objectExpression2, program: program4, stringLiteral, unaryExpression: unaryExpression2, variableDeclaration: variableDeclaration2, variableDeclarator: variableDeclarator2 } = _t(), buildUmdWrapper = (replacements2) => _template().default.statement`
|
|
@@ -362928,7 +362928,7 @@ function build$13(options14, isSynchronous) {
|
|
|
362928
362928
|
else
|
|
362929
362929
|
return isSynchronous ? defaultSync2 : defaultAsync2;
|
|
362930
362930
|
}
|
|
362931
|
-
function
|
|
362931
|
+
function build6(isSynchronous) {
|
|
362932
362932
|
return isSynchronous ? walkSync2 : walkAsync2;
|
|
362933
362933
|
}
|
|
362934
362934
|
function promise6(root3, options14) {
|
|
@@ -363122,7 +363122,7 @@ var __require5, SLASHES_REGEX2, WINDOWS_ROOT_DIR_REGEX2, pushDirectory2 = (direc
|
|
|
363122
363122
|
this.getArray = build$42(options14);
|
|
363123
363123
|
this.groupFiles = build$32(options14);
|
|
363124
363124
|
this.resolveSymlink = build$23(options14, this.isSynchronous);
|
|
363125
|
-
this.walkDirectory =
|
|
363125
|
+
this.walkDirectory = build6(this.isSynchronous);
|
|
363126
363126
|
}
|
|
363127
363127
|
start() {
|
|
363128
363128
|
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
@@ -441631,7 +441631,7 @@ var require_colors = __commonJS((exports, module) => {
|
|
|
441631
441631
|
}
|
|
441632
441632
|
return str.replace(matchOperatorsRe, "\\$&");
|
|
441633
441633
|
};
|
|
441634
|
-
function
|
|
441634
|
+
function build8(_styles) {
|
|
441635
441635
|
var builder = function builder() {
|
|
441636
441636
|
return applyStyle2.apply(builder, arguments);
|
|
441637
441637
|
};
|
|
@@ -441646,7 +441646,7 @@ var require_colors = __commonJS((exports, module) => {
|
|
|
441646
441646
|
ansiStyles2[key].closeRe = new RegExp(escapeStringRegexp3(ansiStyles2[key].close), "g");
|
|
441647
441647
|
ret[key] = {
|
|
441648
441648
|
get: function() {
|
|
441649
|
-
return
|
|
441649
|
+
return build8(this._styles.concat(key));
|
|
441650
441650
|
}
|
|
441651
441651
|
};
|
|
441652
441652
|
});
|
|
@@ -441705,7 +441705,7 @@ var require_colors = __commonJS((exports, module) => {
|
|
|
441705
441705
|
Object.keys(styles3).forEach(function(name17) {
|
|
441706
441706
|
ret[name17] = {
|
|
441707
441707
|
get: function() {
|
|
441708
|
-
return
|
|
441708
|
+
return build8([name17]);
|
|
441709
441709
|
}
|
|
441710
441710
|
};
|
|
441711
441711
|
});
|
|
@@ -447848,8 +447848,8 @@ var require_coerce = __commonJS((exports, module) => {
|
|
|
447848
447848
|
const minor = match33[3] || "0";
|
|
447849
447849
|
const patch25 = match33[4] || "0";
|
|
447850
447850
|
const prerelease = options14.includePrerelease && match33[5] ? `-${match33[5]}` : "";
|
|
447851
|
-
const
|
|
447852
|
-
return parse30(`${major}.${minor}.${patch25}${prerelease}${
|
|
447851
|
+
const build10 = options14.includePrerelease && match33[6] ? `+${match33[6]}` : "";
|
|
447852
|
+
return parse30(`${major}.${minor}.${patch25}${prerelease}${build10}`, options14);
|
|
447853
447853
|
};
|
|
447854
447854
|
module.exports = coerce3;
|
|
447855
447855
|
});
|
|
@@ -493638,7 +493638,7 @@ class BrowserSessionStore {
|
|
|
493638
493638
|
// package.json
|
|
493639
493639
|
var package_default = {
|
|
493640
493640
|
name: "@getpochi/cli",
|
|
493641
|
-
version: "0.6.
|
|
493641
|
+
version: "0.6.4",
|
|
493642
493642
|
devDependencies: {
|
|
493643
493643
|
"@commander-js/extra-typings": "^14.0.0",
|
|
493644
493644
|
"@getpochi/common": "workspace:*",
|
|
@@ -495979,7 +495979,11 @@ var materializers2 = exports_mod6.SQLite.materializers(events, {
|
|
|
495979
495979
|
data: message
|
|
495980
495980
|
}).where({ id: message.id })),
|
|
495981
495981
|
"v1.ForkTaskInited": ({ tasks, messages, files }) => [
|
|
495982
|
-
...tasks.map((task) => tables.tasks.insert({
|
|
495982
|
+
...tasks.map((task) => tables.tasks.insert({
|
|
495983
|
+
...task,
|
|
495984
|
+
shareId: task.parentId ? undefined : `p-${task.id.replaceAll("-", "")}`,
|
|
495985
|
+
updatedAt: task.createdAt
|
|
495986
|
+
})),
|
|
495983
495987
|
...messages.map((message) => tables.messages.insert(message)),
|
|
495984
495988
|
...files.map((file7) => tables.files.insert(file7))
|
|
495985
495989
|
]
|
|
@@ -497718,143 +497722,10 @@ end
|
|
|
497718
497722
|
complete -f -d 'pochi' -c pochi -a "(eval _pochi_completion)"
|
|
497719
497723
|
###-end-pochi-completion-###
|
|
497720
497724
|
`;
|
|
497721
|
-
// src/json-renderer.ts
|
|
497722
|
-
var runExclusive2 = __toESM(require_runExclusive(), 1);
|
|
497723
|
-
|
|
497724
|
-
class JsonRenderer {
|
|
497725
|
-
stream;
|
|
497726
|
-
store;
|
|
497727
|
-
blobStore;
|
|
497728
|
-
state;
|
|
497729
|
-
outputMessageIds = new Set;
|
|
497730
|
-
lastMessageCount = 0;
|
|
497731
|
-
mode;
|
|
497732
|
-
attemptCompletionSchemaOverride;
|
|
497733
|
-
constructor(stream15, store, blobStore, state2, options7 = { mode: "full" }) {
|
|
497734
|
-
this.stream = stream15;
|
|
497735
|
-
this.store = store;
|
|
497736
|
-
this.blobStore = blobStore;
|
|
497737
|
-
this.state = state2;
|
|
497738
|
-
this.mode = options7.mode;
|
|
497739
|
-
this.attemptCompletionSchemaOverride = !!options7.attemptCompletionSchemaOverride;
|
|
497740
|
-
if (this.mode === "full") {
|
|
497741
|
-
this.state.signal.messages.subscribe(runExclusive2.build(async (messages) => {
|
|
497742
|
-
if (messages.length > this.lastMessageCount) {
|
|
497743
|
-
await this.outputMessages(messages.slice(0, -1));
|
|
497744
|
-
this.lastMessageCount = messages.length;
|
|
497745
|
-
}
|
|
497746
|
-
}));
|
|
497747
|
-
}
|
|
497748
|
-
}
|
|
497749
|
-
async shutdown() {
|
|
497750
|
-
if (this.mode === "result-only") {
|
|
497751
|
-
this.outputResult();
|
|
497752
|
-
} else {
|
|
497753
|
-
await this.outputMessages(this.state.signal.messages.value);
|
|
497754
|
-
await this.outputFilesData();
|
|
497755
|
-
}
|
|
497756
|
-
}
|
|
497757
|
-
outputResult() {
|
|
497758
|
-
const messages = this.state.signal.messages.value;
|
|
497759
|
-
const lastMessage = messages.at(-1);
|
|
497760
|
-
if (lastMessage?.role === "assistant") {
|
|
497761
|
-
for (const part of lastMessage.parts || []) {
|
|
497762
|
-
if (isToolUIPart(part) && part.type === "tool-attemptCompletion") {
|
|
497763
|
-
if (part.input) {
|
|
497764
|
-
const input = part.input;
|
|
497765
|
-
if (this.attemptCompletionSchemaOverride) {
|
|
497766
|
-
this.stream.write(`${JSON.stringify(input.result, null, 2)}
|
|
497767
|
-
`);
|
|
497768
|
-
} else {
|
|
497769
|
-
this.stream.write(`${input.result}
|
|
497770
|
-
`);
|
|
497771
|
-
}
|
|
497772
|
-
}
|
|
497773
|
-
return;
|
|
497774
|
-
}
|
|
497775
|
-
}
|
|
497776
|
-
}
|
|
497777
|
-
}
|
|
497778
|
-
async outputMessages(messages) {
|
|
497779
|
-
for (const message of messages) {
|
|
497780
|
-
if (!this.outputMessageIds.has(message.id)) {
|
|
497781
|
-
let outputMessage = await inlineSubTask(this.store, message);
|
|
497782
|
-
outputMessage = await mapStoreBlob(this.blobStore, outputMessage);
|
|
497783
|
-
this.stream.write(`${JSON.stringify(outputMessage)}
|
|
497784
|
-
`);
|
|
497785
|
-
this.outputMessageIds.add(message.id);
|
|
497786
|
-
}
|
|
497787
|
-
}
|
|
497788
|
-
}
|
|
497789
|
-
async outputFilesData() {
|
|
497790
|
-
const files = this.store.query(defaultCatalog.queries.makeStoreFilesQuery());
|
|
497791
|
-
if (files.length > 0) {
|
|
497792
|
-
const data = {
|
|
497793
|
-
type: "files",
|
|
497794
|
-
files
|
|
497795
|
-
};
|
|
497796
|
-
this.stream.write(`${JSON.stringify(data)}
|
|
497797
|
-
`);
|
|
497798
|
-
}
|
|
497799
|
-
}
|
|
497800
|
-
}
|
|
497801
|
-
async function inlineSubTask(store, message) {
|
|
497802
|
-
const partsWithSubtasks = message.parts.map((part) => {
|
|
497803
|
-
if (part.type === "tool-newTask" && part.state !== "input-streaming") {
|
|
497804
|
-
const input = part.input;
|
|
497805
|
-
const subtaskId = input._meta?.uid;
|
|
497806
|
-
if (subtaskId) {
|
|
497807
|
-
const subtask = store.query(defaultCatalog.queries.makeTaskQuery(subtaskId));
|
|
497808
|
-
const subtaskMessages = store.query(defaultCatalog.queries.makeMessagesQuery(subtaskId));
|
|
497809
|
-
if (subtask) {
|
|
497810
|
-
return {
|
|
497811
|
-
...part,
|
|
497812
|
-
input: {
|
|
497813
|
-
...input,
|
|
497814
|
-
_transient: {
|
|
497815
|
-
task: {
|
|
497816
|
-
clientTaskId: subtaskId,
|
|
497817
|
-
messages: subtaskMessages.map((m) => m.data),
|
|
497818
|
-
todos: subtask.todos.map((t5) => ({ ...t5 }))
|
|
497819
|
-
}
|
|
497820
|
-
}
|
|
497821
|
-
}
|
|
497822
|
-
};
|
|
497823
|
-
}
|
|
497824
|
-
}
|
|
497825
|
-
}
|
|
497826
|
-
return part;
|
|
497827
|
-
});
|
|
497828
|
-
return {
|
|
497829
|
-
...message,
|
|
497830
|
-
parts: partsWithSubtasks
|
|
497831
|
-
};
|
|
497832
|
-
}
|
|
497833
|
-
async function mapStoreBlob(store, o6) {
|
|
497834
|
-
if (t3(o6) && o6.startsWith(store.protocol)) {
|
|
497835
|
-
const blob3 = await store.get(o6);
|
|
497836
|
-
if (!blob3)
|
|
497837
|
-
throw new Error(`Store blob not found at "${o6}"`);
|
|
497838
|
-
const base643 = Buffer.from(blob3.data).toString("base64");
|
|
497839
|
-
return `data:${blob3.mimeType};base64,${base643}`;
|
|
497840
|
-
}
|
|
497841
|
-
if (o5(o6)) {
|
|
497842
|
-
return Promise.all(o6.map((el) => mapStoreBlob(store, el)));
|
|
497843
|
-
}
|
|
497844
|
-
if (o4(o6)) {
|
|
497845
|
-
const entires = await Promise.all(t4(o6).map(async ([k2, v2]) => [
|
|
497846
|
-
k2,
|
|
497847
|
-
await mapStoreBlob(store, v2)
|
|
497848
|
-
]));
|
|
497849
|
-
return n2(entires);
|
|
497850
|
-
}
|
|
497851
|
-
return o6;
|
|
497852
|
-
}
|
|
497853
|
-
|
|
497854
497725
|
// src/lib/ffmpeg-mjpeg-to-mp4.ts
|
|
497855
497726
|
import { PassThrough } from "node:stream";
|
|
497856
497727
|
var import_fluent_ffmpeg = __toESM(require_fluent_ffmpeg(), 1);
|
|
497857
|
-
var
|
|
497728
|
+
var runExclusive2 = __toESM(require_runExclusive(), 1);
|
|
497858
497729
|
var logger15 = getLogger("MjpegToMp4");
|
|
497859
497730
|
function setFfmpegPath(path5) {
|
|
497860
497731
|
import_fluent_ffmpeg.default.setFfmpegPath(path5);
|
|
@@ -497920,7 +497791,7 @@ function startMjpegToMp4Converter(outputPath, opts = {}) {
|
|
|
497920
497791
|
command.on("error", (err) => logger15.debug("[ffmpeg] error:", err));
|
|
497921
497792
|
command.on("end", () => logger15.debug("[ffmpeg] end"));
|
|
497922
497793
|
command.run();
|
|
497923
|
-
const writeRepeatedFrames =
|
|
497794
|
+
const writeRepeatedFrames = runExclusive2.build(async (jpeg, repeat6) => {
|
|
497924
497795
|
for (let i6 = 0;i6 < repeat6; i6++) {
|
|
497925
497796
|
if (!mjpegStream.write(jpeg)) {
|
|
497926
497797
|
await new Promise((r6) => mjpegStream.once("drain", r6));
|
|
@@ -527152,6 +527023,189 @@ class NodeBlobStore {
|
|
|
527152
527023
|
}
|
|
527153
527024
|
}
|
|
527154
527025
|
|
|
527026
|
+
// src/renderers/experimental-trajectory-stream-renderer.ts
|
|
527027
|
+
var runExclusive3 = __toESM(require_runExclusive(), 1);
|
|
527028
|
+
|
|
527029
|
+
// src/renderers/utils.ts
|
|
527030
|
+
async function inlineSubTask(store, message) {
|
|
527031
|
+
const partsWithSubtasks = message.parts.map((part) => {
|
|
527032
|
+
if (part.type === "tool-newTask" && part.state !== "input-streaming") {
|
|
527033
|
+
const input = part.input;
|
|
527034
|
+
const subtaskId = input._meta?.uid;
|
|
527035
|
+
if (subtaskId) {
|
|
527036
|
+
const subtask = store.query(defaultCatalog.queries.makeTaskQuery(subtaskId));
|
|
527037
|
+
const subtaskMessages = store.query(defaultCatalog.queries.makeMessagesQuery(subtaskId));
|
|
527038
|
+
if (subtask) {
|
|
527039
|
+
return {
|
|
527040
|
+
...part,
|
|
527041
|
+
input: {
|
|
527042
|
+
...input,
|
|
527043
|
+
_transient: {
|
|
527044
|
+
task: {
|
|
527045
|
+
clientTaskId: subtaskId,
|
|
527046
|
+
messages: subtaskMessages.map((m6) => m6.data),
|
|
527047
|
+
todos: subtask.todos.map((t10) => ({ ...t10 }))
|
|
527048
|
+
}
|
|
527049
|
+
}
|
|
527050
|
+
}
|
|
527051
|
+
};
|
|
527052
|
+
}
|
|
527053
|
+
}
|
|
527054
|
+
}
|
|
527055
|
+
return part;
|
|
527056
|
+
});
|
|
527057
|
+
return {
|
|
527058
|
+
...message,
|
|
527059
|
+
parts: partsWithSubtasks
|
|
527060
|
+
};
|
|
527061
|
+
}
|
|
527062
|
+
async function mapStoreBlob(store, o14) {
|
|
527063
|
+
if (t3(o14) && o14.startsWith(store.protocol)) {
|
|
527064
|
+
const blob3 = await store.get(o14);
|
|
527065
|
+
if (!blob3)
|
|
527066
|
+
throw new Error(`Store blob not found at "${o14}"`);
|
|
527067
|
+
const base643 = Buffer.from(blob3.data).toString("base64");
|
|
527068
|
+
return `data:${blob3.mimeType};base64,${base643}`;
|
|
527069
|
+
}
|
|
527070
|
+
if (o5(o14)) {
|
|
527071
|
+
return Promise.all(o14.map((el) => mapStoreBlob(store, el)));
|
|
527072
|
+
}
|
|
527073
|
+
if (o4(o14)) {
|
|
527074
|
+
const entires = await Promise.all(t4(o14).map(async ([k6, v6]) => [
|
|
527075
|
+
k6,
|
|
527076
|
+
await mapStoreBlob(store, v6)
|
|
527077
|
+
]));
|
|
527078
|
+
return n2(entires);
|
|
527079
|
+
}
|
|
527080
|
+
return o14;
|
|
527081
|
+
}
|
|
527082
|
+
|
|
527083
|
+
// src/renderers/experimental-trajectory-stream-renderer.ts
|
|
527084
|
+
class ExperimentalTrajectoryStreamRenderer {
|
|
527085
|
+
stream;
|
|
527086
|
+
store;
|
|
527087
|
+
blobStore;
|
|
527088
|
+
state;
|
|
527089
|
+
emittedParts = new Map;
|
|
527090
|
+
emittedMetadata = new Set;
|
|
527091
|
+
unsubscribe;
|
|
527092
|
+
constructor(stream29, store, blobStore, state2) {
|
|
527093
|
+
this.stream = stream29;
|
|
527094
|
+
this.store = store;
|
|
527095
|
+
this.blobStore = blobStore;
|
|
527096
|
+
this.state = state2;
|
|
527097
|
+
this.unsubscribe = this.state.signal.messages.subscribe(runExclusive3.build(async (messages3) => {
|
|
527098
|
+
await this.outputTrajectory(messages3);
|
|
527099
|
+
}));
|
|
527100
|
+
}
|
|
527101
|
+
async outputTrajectory(messages3, isFinalFlush = false) {
|
|
527102
|
+
for (let msgIdx = 0;msgIdx < messages3.length; msgIdx++) {
|
|
527103
|
+
const message = messages3[msgIdx];
|
|
527104
|
+
const isFinalized = isFinalFlush || msgIdx < messages3.length - 1;
|
|
527105
|
+
const outputMessage = await inlineSubTask(this.store, message);
|
|
527106
|
+
for (let i10 = 0;i10 < outputMessage.parts.length; i10++) {
|
|
527107
|
+
const part = outputMessage.parts[i10];
|
|
527108
|
+
const partId = `${message.id}:${i10}`;
|
|
527109
|
+
const resolvedPart = await mapStoreBlob(this.blobStore, part);
|
|
527110
|
+
const cachedPart = this.emittedParts.get(partId);
|
|
527111
|
+
if (!k(cachedPart, resolvedPart)) {
|
|
527112
|
+
const outputData = {
|
|
527113
|
+
type: "message-part",
|
|
527114
|
+
messageId: message.id,
|
|
527115
|
+
role: message.role,
|
|
527116
|
+
index: i10,
|
|
527117
|
+
part: resolvedPart
|
|
527118
|
+
};
|
|
527119
|
+
this.stream.write(`${JSON.stringify(outputData)}
|
|
527120
|
+
`);
|
|
527121
|
+
this.emittedParts.set(partId, p2(resolvedPart));
|
|
527122
|
+
}
|
|
527123
|
+
}
|
|
527124
|
+
if (isFinalized && !this.emittedMetadata.has(message.id)) {
|
|
527125
|
+
if (outputMessage.metadata !== undefined) {
|
|
527126
|
+
const outputData = {
|
|
527127
|
+
type: "message-metadata",
|
|
527128
|
+
messageId: message.id,
|
|
527129
|
+
role: message.role,
|
|
527130
|
+
metadata: outputMessage.metadata
|
|
527131
|
+
};
|
|
527132
|
+
this.stream.write(`${JSON.stringify(outputData)}
|
|
527133
|
+
`);
|
|
527134
|
+
}
|
|
527135
|
+
this.emittedMetadata.add(message.id);
|
|
527136
|
+
}
|
|
527137
|
+
}
|
|
527138
|
+
}
|
|
527139
|
+
async shutdown() {
|
|
527140
|
+
if (this.unsubscribe) {
|
|
527141
|
+
this.unsubscribe();
|
|
527142
|
+
this.unsubscribe = undefined;
|
|
527143
|
+
}
|
|
527144
|
+
await runExclusive3.build(async () => {
|
|
527145
|
+
await this.outputTrajectory(this.state.signal.messages.value, true);
|
|
527146
|
+
await this.outputFilesData();
|
|
527147
|
+
})();
|
|
527148
|
+
}
|
|
527149
|
+
async outputFilesData() {
|
|
527150
|
+
const files = this.store.query(defaultCatalog.queries.makeStoreFilesQuery());
|
|
527151
|
+
if (files.length > 0) {
|
|
527152
|
+
const data = {
|
|
527153
|
+
type: "files",
|
|
527154
|
+
files
|
|
527155
|
+
};
|
|
527156
|
+
this.stream.write(`${JSON.stringify(data)}
|
|
527157
|
+
`);
|
|
527158
|
+
}
|
|
527159
|
+
}
|
|
527160
|
+
}
|
|
527161
|
+
// src/renderers/json-renderer.ts
|
|
527162
|
+
var runExclusive4 = __toESM(require_runExclusive(), 1);
|
|
527163
|
+
class JsonRenderer {
|
|
527164
|
+
stream;
|
|
527165
|
+
store;
|
|
527166
|
+
blobStore;
|
|
527167
|
+
state;
|
|
527168
|
+
outputMessageIds = new Set;
|
|
527169
|
+
lastMessageCount = 0;
|
|
527170
|
+
constructor(stream29, store, blobStore, state2) {
|
|
527171
|
+
this.stream = stream29;
|
|
527172
|
+
this.store = store;
|
|
527173
|
+
this.blobStore = blobStore;
|
|
527174
|
+
this.state = state2;
|
|
527175
|
+
this.state.signal.messages.subscribe(runExclusive4.build(async (messages3) => {
|
|
527176
|
+
if (messages3.length > this.lastMessageCount) {
|
|
527177
|
+
await this.outputMessages(messages3.slice(0, -1));
|
|
527178
|
+
this.lastMessageCount = messages3.length;
|
|
527179
|
+
}
|
|
527180
|
+
}));
|
|
527181
|
+
}
|
|
527182
|
+
async shutdown() {
|
|
527183
|
+
await this.outputMessages(this.state.signal.messages.value);
|
|
527184
|
+
await this.outputFilesData();
|
|
527185
|
+
}
|
|
527186
|
+
async outputMessages(messages3) {
|
|
527187
|
+
for (const message of messages3) {
|
|
527188
|
+
if (!this.outputMessageIds.has(message.id)) {
|
|
527189
|
+
let outputMessage = await inlineSubTask(this.store, message);
|
|
527190
|
+
outputMessage = await mapStoreBlob(this.blobStore, outputMessage);
|
|
527191
|
+
this.stream.write(`${JSON.stringify(outputMessage)}
|
|
527192
|
+
`);
|
|
527193
|
+
this.outputMessageIds.add(message.id);
|
|
527194
|
+
}
|
|
527195
|
+
}
|
|
527196
|
+
}
|
|
527197
|
+
async outputFilesData() {
|
|
527198
|
+
const files = this.store.query(defaultCatalog.queries.makeStoreFilesQuery());
|
|
527199
|
+
if (files.length > 0) {
|
|
527200
|
+
const data = {
|
|
527201
|
+
type: "files",
|
|
527202
|
+
files
|
|
527203
|
+
};
|
|
527204
|
+
this.stream.write(`${JSON.stringify(data)}
|
|
527205
|
+
`);
|
|
527206
|
+
}
|
|
527207
|
+
}
|
|
527208
|
+
}
|
|
527155
527209
|
// ../../node_modules/unist-util-find-after/lib/index.js
|
|
527156
527210
|
var findAfter = function(parent, index3, test3) {
|
|
527157
527211
|
const is6 = convert(test3);
|
|
@@ -537977,7 +538031,7 @@ function findTodos(message) {
|
|
|
537977
538031
|
}, []);
|
|
537978
538032
|
return todos;
|
|
537979
538033
|
}
|
|
537980
|
-
// src/output-renderer.ts
|
|
538034
|
+
// src/renderers/output-renderer.ts
|
|
537981
538035
|
init_source();
|
|
537982
538036
|
|
|
537983
538037
|
// ../../node_modules/eventemitter3/index.mjs
|
|
@@ -539883,7 +539937,7 @@ var Listr = class {
|
|
|
539883
539937
|
}
|
|
539884
539938
|
};
|
|
539885
539939
|
|
|
539886
|
-
// src/output-renderer.ts
|
|
539940
|
+
// src/renderers/output-renderer.ts
|
|
539887
539941
|
class OutputRenderer {
|
|
539888
539942
|
stream;
|
|
539889
539943
|
state;
|
|
@@ -540060,6 +540114,14 @@ ${optionsText}` : ""}`;
|
|
|
540060
540114
|
error: errorText
|
|
540061
540115
|
};
|
|
540062
540116
|
}
|
|
540117
|
+
if (part.type === "tool-useSkill") {
|
|
540118
|
+
const { skill = "unknown" } = part.input || {};
|
|
540119
|
+
return {
|
|
540120
|
+
text: `\uD83E\uDDE9 Using skill ${source_default.bold(skill)}`,
|
|
540121
|
+
stop: hasError ? "fail" : "succeed",
|
|
540122
|
+
error: errorText
|
|
540123
|
+
};
|
|
540124
|
+
}
|
|
540063
540125
|
if (part.type === "tool-todoWrite") {
|
|
540064
540126
|
const { todos = [] } = part.input || {};
|
|
540065
540127
|
return {
|
|
@@ -540254,7 +540316,38 @@ function renderSubtaskMessages(messages3) {
|
|
|
540254
540316
|
}
|
|
540255
540317
|
return output;
|
|
540256
540318
|
}
|
|
540257
|
-
|
|
540319
|
+
// src/renderers/result-renderer.ts
|
|
540320
|
+
class ResultRenderer {
|
|
540321
|
+
stream;
|
|
540322
|
+
state;
|
|
540323
|
+
attemptCompletionSchemaOverride;
|
|
540324
|
+
constructor(stream29, state2, options14 = {}) {
|
|
540325
|
+
this.stream = stream29;
|
|
540326
|
+
this.state = state2;
|
|
540327
|
+
this.attemptCompletionSchemaOverride = !!options14.attemptCompletionSchemaOverride;
|
|
540328
|
+
}
|
|
540329
|
+
async shutdown() {
|
|
540330
|
+
const messages3 = this.state.signal.messages.value;
|
|
540331
|
+
const lastMessage = messages3.at(-1);
|
|
540332
|
+
if (lastMessage?.role === "assistant") {
|
|
540333
|
+
for (const part of lastMessage.parts || []) {
|
|
540334
|
+
if (isToolUIPart(part) && part.type === "tool-attemptCompletion") {
|
|
540335
|
+
if (part.input) {
|
|
540336
|
+
const input = part.input;
|
|
540337
|
+
if (this.attemptCompletionSchemaOverride) {
|
|
540338
|
+
this.stream.write(`${JSON.stringify(input.result, null, 2)}
|
|
540339
|
+
`);
|
|
540340
|
+
} else {
|
|
540341
|
+
this.stream.write(`${input.result}
|
|
540342
|
+
`);
|
|
540343
|
+
}
|
|
540344
|
+
}
|
|
540345
|
+
return;
|
|
540346
|
+
}
|
|
540347
|
+
}
|
|
540348
|
+
}
|
|
540349
|
+
}
|
|
540350
|
+
}
|
|
540258
540351
|
// src/task-runner.ts
|
|
540259
540352
|
import { spawn as spawn6 } from "node:child_process";
|
|
540260
540353
|
|
|
@@ -546472,7 +546565,7 @@ var parseNonNegativeInt = (input) => {
|
|
|
546472
546565
|
}
|
|
546473
546566
|
return result2;
|
|
546474
546567
|
};
|
|
546475
|
-
var program7 = new Command().name("pochi").description(`${source_default.bold("Pochi")} v${package_default.version} - A powerful CLI tool for AI-driven development.`).optionsGroup("Prompt:").option("-p, --prompt <prompt>", "Create a new task with a given prompt. Input can also be piped. For example: `cat my-prompt.md | pochi`.").option("-a, --attach <path...>", "Attach one or more files to the prompt, e.g images").optionsGroup("Options:").option("--stream-json [filepath]", "Stream the output in JSON format. This is useful for parsing the output in scripts. If filepath is not specified, the output will be written to stdout, mixed with normal UI output. Cannot be used with --output-result.").option("-x, --output-result [filepath]", "Output the result from attemptCompletion. This is useful for scripts that need to capture the final result. If filepath is not specified, the output will be written to stdout, mixed with normal UI output. Cannot be used with --stream-json.").option("--max-steps <number>", "Set the maximum number of steps for a task. The task will stop if it exceeds this limit.", parsePositiveInt, 24).option("--max-retries <number>", "Set the maximum number of retries for a single step in a task.", parsePositiveInt, 3).option("--async-wait-timeout <ms>", "Wait for async subtasks and background jobs to complete before finalizing attemptCompletion. Set to 0 to disable waiting.", parseNonNegativeInt, 60000).option("--agent <name>", "Run the task as a sub-agent using the specified custom agent. This applies the agent's system prompt and tool restrictions, matching the behavior of sub-tasks created via the newTask tool.").addOption(new Option("--experimental-output-schema <schema>", "Specify a JSON schema for the output of the task. The task will be validated against this schema.").hideHelp()).addOption(new Option("--attempt-completion-schema <schema>", "Specify a JSON schema that attempt-completion will enforce.").hideHelp()).addOption(new Option("--attempt-completion-hook <command>", "Specify a command that attempt-completion will run").hideHelp()).addOption(new Option("--ffmpeg <path>", "Specify the path to the ffmpeg executable for browser session recording. Pochi will try to use the ffmpeg executable in the system path if this option is not specified. Browser session recording is disabled when no ffmpeg executable available.").hideHelp()).addOption(new Option("--blobs-dir <path>", "Specify the path to be used as a storage directory for blobs.").default(path40.join(os16.tmpdir(), "pochi", "blobs")).hideHelp()).optionsGroup("Model:").option("-m, --model <model>", "Specify the model to be used for the task.", "google/gemini-3-flash").optionsGroup("MCP:").option("--no-mcp", "Disable MCP (Model Context Protocol) integration completely.").action(async (options14) => {
|
|
546568
|
+
var program7 = new Command().name("pochi").description(`${source_default.bold("Pochi")} v${package_default.version} - A powerful CLI tool for AI-driven development.`).optionsGroup("Prompt:").option("-p, --prompt <prompt>", "Create a new task with a given prompt. Input can also be piped. For example: `cat my-prompt.md | pochi`.").option("-a, --attach <path...>", "Attach one or more files to the prompt, e.g images").optionsGroup("Options:").option("--stream-json [filepath]", "Stream the output in JSON format. This is useful for parsing the output in scripts. If filepath is not specified, the output will be written to stdout, mixed with normal UI output. Cannot be used with --output-result.").option("-x, --output-result [filepath]", "Output the result from attemptCompletion. This is useful for scripts that need to capture the final result. If filepath is not specified, the output will be written to stdout, mixed with normal UI output. Cannot be used with --stream-json.").option("--experimental-stream-trajectory [filepath]", "Stream message parts whenever signal.messages updates. Cannot be used with --stream-json or --output-result.").option("--max-steps <number>", "Set the maximum number of steps for a task. The task will stop if it exceeds this limit.", parsePositiveInt, 24).option("--max-retries <number>", "Set the maximum number of retries for a single step in a task.", parsePositiveInt, 3).option("--async-wait-timeout <ms>", "Wait for async subtasks and background jobs to complete before finalizing attemptCompletion. Set to 0 to disable waiting.", parseNonNegativeInt, 60000).option("--agent <name>", "Run the task as a sub-agent using the specified custom agent. This applies the agent's system prompt and tool restrictions, matching the behavior of sub-tasks created via the newTask tool.").addOption(new Option("--experimental-output-schema <schema>", "Specify a JSON schema for the output of the task. The task will be validated against this schema.").hideHelp()).addOption(new Option("--attempt-completion-schema <schema>", "Specify a JSON schema that attempt-completion will enforce.").hideHelp()).addOption(new Option("--attempt-completion-hook <command>", "Specify a command that attempt-completion will run").hideHelp()).addOption(new Option("--ffmpeg <path>", "Specify the path to the ffmpeg executable for browser session recording. Pochi will try to use the ffmpeg executable in the system path if this option is not specified. Browser session recording is disabled when no ffmpeg executable available.").hideHelp()).addOption(new Option("--blobs-dir <path>", "Specify the path to be used as a storage directory for blobs.").default(path40.join(os16.tmpdir(), "pochi", "blobs")).hideHelp()).optionsGroup("Model:").option("-m, --model <model>", "Specify the model to be used for the task.", "google/gemini-3-flash").optionsGroup("MCP:").option("--no-mcp", "Disable MCP (Model Context Protocol) integration completely.").action(async (options14) => {
|
|
546476
546569
|
const customAgents = await loadAgents(process.cwd());
|
|
546477
546570
|
const skills = await loadSkills(process.cwd());
|
|
546478
546571
|
let selectedAgent;
|
|
@@ -546515,8 +546608,8 @@ ${available2 || " (none)"}`);
|
|
|
546515
546608
|
setFfmpegPath(options14.ffmpeg);
|
|
546516
546609
|
}
|
|
546517
546610
|
let jsonOutputStream = undefined;
|
|
546518
|
-
if (options14.streamJson
|
|
546519
|
-
program7.error("Cannot use --stream-json
|
|
546611
|
+
if ((options14.streamJson ? 1 : 0) + (options14.outputResult ? 1 : 0) + (options14.experimentalStreamTrajectory ? 1 : 0) > 1) {
|
|
546612
|
+
program7.error("Cannot use more than one of --stream-json, --output-result, or --experimental-stream-trajectory at the same time.");
|
|
546520
546613
|
}
|
|
546521
546614
|
if (options14.streamJson === true) {
|
|
546522
546615
|
jsonOutputStream = process.stdout;
|
|
@@ -546526,6 +546619,10 @@ ${available2 || " (none)"}`);
|
|
|
546526
546619
|
jsonOutputStream = process.stdout;
|
|
546527
546620
|
} else if (typeof options14.outputResult === "string") {
|
|
546528
546621
|
jsonOutputStream = fs21.createWriteStream(options14.outputResult);
|
|
546622
|
+
} else if (options14.experimentalStreamTrajectory === true) {
|
|
546623
|
+
jsonOutputStream = process.stdout;
|
|
546624
|
+
} else if (typeof options14.experimentalStreamTrajectory === "string") {
|
|
546625
|
+
jsonOutputStream = fs21.createWriteStream(options14.experimentalStreamTrajectory);
|
|
546529
546626
|
}
|
|
546530
546627
|
const mcpHub = options14.mcp ? await initializeMcp(program7) : undefined;
|
|
546531
546628
|
const abortController = createAbortControllerWithGracefulShutdown();
|
|
@@ -546565,12 +546662,17 @@ ${available2 || " (none)"}`);
|
|
|
546565
546662
|
const outputRenderer = new OutputRenderer(process.stdout, runner.state, {
|
|
546566
546663
|
attemptCompletionSchemaOverride: !!options14.attemptCompletionSchema
|
|
546567
546664
|
});
|
|
546568
|
-
let
|
|
546665
|
+
let streamRenderer = undefined;
|
|
546569
546666
|
if (jsonOutputStream) {
|
|
546570
|
-
|
|
546571
|
-
|
|
546572
|
-
|
|
546573
|
-
|
|
546667
|
+
if (options14.experimentalStreamTrajectory) {
|
|
546668
|
+
streamRenderer = new ExperimentalTrajectoryStreamRenderer(jsonOutputStream, store, blobStore, runner.state);
|
|
546669
|
+
} else if (options14.outputResult) {
|
|
546670
|
+
streamRenderer = new ResultRenderer(jsonOutputStream, runner.state, {
|
|
546671
|
+
attemptCompletionSchemaOverride: !!options14.attemptCompletionSchema
|
|
546672
|
+
});
|
|
546673
|
+
} else {
|
|
546674
|
+
streamRenderer = new JsonRenderer(jsonOutputStream, store, blobStore, runner.state);
|
|
546675
|
+
}
|
|
546574
546676
|
}
|
|
546575
546677
|
let runtimeError = undefined;
|
|
546576
546678
|
try {
|
|
@@ -546579,7 +546681,7 @@ ${available2 || " (none)"}`);
|
|
|
546579
546681
|
runtimeError = error48 instanceof Error ? error48 : new Error(String(error48));
|
|
546580
546682
|
} finally {
|
|
546581
546683
|
outputRenderer.shutdown();
|
|
546582
|
-
await
|
|
546684
|
+
await streamRenderer?.shutdown();
|
|
546583
546685
|
if (jsonOutputStream && jsonOutputStream instanceof fs21.WriteStream) {
|
|
546584
546686
|
jsonOutputStream.end();
|
|
546585
546687
|
await finished(jsonOutputStream);
|