@getpochi/cli 0.5.66 → 0.5.68
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 +129 -95
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -104731,8 +104731,8 @@ var require_connection = __commonJS((exports, module) => {
|
|
|
104731
104731
|
return;
|
|
104732
104732
|
}
|
|
104733
104733
|
const secWSAccept = response.headersList.get("Sec-WebSocket-Accept");
|
|
104734
|
-
const
|
|
104735
|
-
if (secWSAccept !==
|
|
104734
|
+
const digest2 = crypto7.createHash("sha1").update(keyValue + uid).digest("base64");
|
|
104735
|
+
if (secWSAccept !== digest2) {
|
|
104736
104736
|
failWebsocketConnection(handler2, 1002, "Incorrect hash received in Sec-WebSocket-Accept header.");
|
|
104737
104737
|
return;
|
|
104738
104738
|
}
|
|
@@ -109298,8 +109298,8 @@ var require_websocket2 = __commonJS((exports, module) => {
|
|
|
109298
109298
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
109299
109299
|
return;
|
|
109300
109300
|
}
|
|
109301
|
-
const
|
|
109302
|
-
if (res.headers["sec-websocket-accept"] !==
|
|
109301
|
+
const digest2 = createHash5("sha1").update(key2 + GUID).digest("base64");
|
|
109302
|
+
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
109303
109303
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
109304
109304
|
return;
|
|
109305
109305
|
}
|
|
@@ -109879,12 +109879,12 @@ var require_websocket_server = __commonJS((exports, module) => {
|
|
|
109879
109879
|
}
|
|
109880
109880
|
if (this._state > RUNNING)
|
|
109881
109881
|
return abortHandshake(socket, 503);
|
|
109882
|
-
const
|
|
109882
|
+
const digest2 = createHash5("sha1").update(key2 + GUID).digest("base64");
|
|
109883
109883
|
const headers = [
|
|
109884
109884
|
"HTTP/1.1 101 Switching Protocols",
|
|
109885
109885
|
"Upgrade: websocket",
|
|
109886
109886
|
"Connection: Upgrade",
|
|
109887
|
-
`Sec-WebSocket-Accept: ${
|
|
109887
|
+
`Sec-WebSocket-Accept: ${digest2}`
|
|
109888
109888
|
];
|
|
109889
109889
|
const ws = new this.options.WebSocket(null, undefined, this.options);
|
|
109890
109890
|
if (protocols.size) {
|
|
@@ -113615,8 +113615,8 @@ var require_websocket3 = __commonJS((exports, module) => {
|
|
|
113615
113615
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
113616
113616
|
return;
|
|
113617
113617
|
}
|
|
113618
|
-
const
|
|
113619
|
-
if (res.headers["sec-websocket-accept"] !==
|
|
113618
|
+
const digest2 = createHash5("sha1").update(key2 + GUID).digest("base64");
|
|
113619
|
+
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
113620
113620
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
113621
113621
|
return;
|
|
113622
113622
|
}
|
|
@@ -114196,12 +114196,12 @@ var require_websocket_server2 = __commonJS((exports, module) => {
|
|
|
114196
114196
|
}
|
|
114197
114197
|
if (this._state > RUNNING)
|
|
114198
114198
|
return abortHandshake(socket, 503);
|
|
114199
|
-
const
|
|
114199
|
+
const digest2 = createHash5("sha1").update(key2 + GUID).digest("base64");
|
|
114200
114200
|
const headers = [
|
|
114201
114201
|
"HTTP/1.1 101 Switching Protocols",
|
|
114202
114202
|
"Upgrade: websocket",
|
|
114203
114203
|
"Connection: Upgrade",
|
|
114204
|
-
`Sec-WebSocket-Accept: ${
|
|
114204
|
+
`Sec-WebSocket-Accept: ${digest2}`
|
|
114205
114205
|
];
|
|
114206
114206
|
const ws = new this.options.WebSocket(null, undefined, this.options);
|
|
114207
114207
|
if (protocols.size) {
|
|
@@ -287061,7 +287061,7 @@ var require_previous_map = __commonJS((exports, module) => {
|
|
|
287061
287061
|
var { existsSync: existsSync4, readFileSync: readFileSync3 } = __require("fs");
|
|
287062
287062
|
var { dirname: dirname8, join: join18 } = __require("path");
|
|
287063
287063
|
var { SourceMapConsumer, SourceMapGenerator } = require_source_map();
|
|
287064
|
-
function
|
|
287064
|
+
function fromBase642(str) {
|
|
287065
287065
|
if (Buffer) {
|
|
287066
287066
|
return Buffer.from(str, "base64").toString();
|
|
287067
287067
|
} else {
|
|
@@ -287102,7 +287102,7 @@ var require_previous_map = __commonJS((exports, module) => {
|
|
|
287102
287102
|
}
|
|
287103
287103
|
let baseUriMatch = text19.match(baseCharsetUri) || text19.match(baseUri);
|
|
287104
287104
|
if (baseUriMatch) {
|
|
287105
|
-
return
|
|
287105
|
+
return fromBase642(text19.substr(baseUriMatch[0].length));
|
|
287106
287106
|
}
|
|
287107
287107
|
let encoding = text19.match(/data:application\/json;([^,]+),/)[1];
|
|
287108
287108
|
throw new Error("Unsupported source map encoding " + encoding);
|
|
@@ -321597,8 +321597,8 @@ Error: ${e$1.message}`);
|
|
|
321597
321597
|
abortHandshake$1(websocket, socket, "Invalid Upgrade header");
|
|
321598
321598
|
return;
|
|
321599
321599
|
}
|
|
321600
|
-
const
|
|
321601
|
-
if (res.headers["sec-websocket-accept"] !==
|
|
321600
|
+
const digest2 = createHash$1("sha1").update(key2 + GUID$1).digest("base64");
|
|
321601
|
+
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
321602
321602
|
abortHandshake$1(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
321603
321603
|
return;
|
|
321604
321604
|
}
|
|
@@ -375096,7 +375096,7 @@ var {
|
|
|
375096
375096
|
// package.json
|
|
375097
375097
|
var package_default = {
|
|
375098
375098
|
name: "@getpochi/cli",
|
|
375099
|
-
version: "0.5.
|
|
375099
|
+
version: "0.5.68",
|
|
375100
375100
|
type: "module",
|
|
375101
375101
|
bin: {
|
|
375102
375102
|
pochi: "src/cli.ts"
|
|
@@ -388882,6 +388882,92 @@ var makeBlobQuery = (checksum) => queryDb(() => tables.blobs.where("checksum", "
|
|
|
388882
388882
|
label: "blobs",
|
|
388883
388883
|
deps: [checksum]
|
|
388884
388884
|
});
|
|
388885
|
+
// ../livekit/src/store-blob.ts
|
|
388886
|
+
async function processContentOutput(store, output2, signal2) {
|
|
388887
|
+
const parsed = ContentOutput.safeParse(output2);
|
|
388888
|
+
if (parsed.success) {
|
|
388889
|
+
const content3 = parsed.data.content.map(async (item) => {
|
|
388890
|
+
if (item.type === "text") {
|
|
388891
|
+
return item;
|
|
388892
|
+
}
|
|
388893
|
+
if (item.type === "image") {
|
|
388894
|
+
return {
|
|
388895
|
+
type: "image",
|
|
388896
|
+
mimeType: item.mimeType,
|
|
388897
|
+
data: await findBlobUrl(store, item.mimeType, item.data, signal2)
|
|
388898
|
+
};
|
|
388899
|
+
}
|
|
388900
|
+
return item;
|
|
388901
|
+
});
|
|
388902
|
+
return {
|
|
388903
|
+
...parsed.data,
|
|
388904
|
+
content: await Promise.all(content3)
|
|
388905
|
+
};
|
|
388906
|
+
}
|
|
388907
|
+
return output2;
|
|
388908
|
+
}
|
|
388909
|
+
var ContentOutput = zod_default.object({
|
|
388910
|
+
content: zod_default.array(zod_default.discriminatedUnion("type", [
|
|
388911
|
+
zod_default.object({
|
|
388912
|
+
type: zod_default.literal("text"),
|
|
388913
|
+
text: zod_default.string()
|
|
388914
|
+
}),
|
|
388915
|
+
zod_default.object({
|
|
388916
|
+
type: zod_default.literal("image"),
|
|
388917
|
+
mimeType: zod_default.string(),
|
|
388918
|
+
data: zod_default.string()
|
|
388919
|
+
})
|
|
388920
|
+
]))
|
|
388921
|
+
});
|
|
388922
|
+
async function fileToUri(store, file5, signal2) {
|
|
388923
|
+
if ("POCHI_CORS_PROXY_PORT" in globalThis) {
|
|
388924
|
+
return fileToRemoteUri(file5, signal2);
|
|
388925
|
+
}
|
|
388926
|
+
const data = new Uint8Array(await file5.arrayBuffer());
|
|
388927
|
+
const checksum = await digest(data);
|
|
388928
|
+
const blob3 = store.query(makeBlobQuery(checksum));
|
|
388929
|
+
const url3 = `${StoreBlobProtocol}${checksum}`;
|
|
388930
|
+
if (blob3) {
|
|
388931
|
+
return url3;
|
|
388932
|
+
}
|
|
388933
|
+
store.commit(events.blobInserted({
|
|
388934
|
+
checksum,
|
|
388935
|
+
data,
|
|
388936
|
+
createdAt: new Date,
|
|
388937
|
+
mimeType: file5.type
|
|
388938
|
+
}));
|
|
388939
|
+
return url3;
|
|
388940
|
+
}
|
|
388941
|
+
async function findBlobUrl(store, mimeType, base643, signal2) {
|
|
388942
|
+
const file5 = new File([fromBase64(base643)], "file", {
|
|
388943
|
+
type: mimeType
|
|
388944
|
+
});
|
|
388945
|
+
return fileToUri(store, file5, signal2);
|
|
388946
|
+
}
|
|
388947
|
+
var fromBase64 = (base643) => Uint8Array.from(atob(base643), (v2) => v2.charCodeAt(0));
|
|
388948
|
+
async function digest(data) {
|
|
388949
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
388950
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
388951
|
+
return hashArray.map((b2) => b2.toString(16).padStart(2, "0")).join("");
|
|
388952
|
+
}
|
|
388953
|
+
async function fileToRemoteUri(file5, signal2) {
|
|
388954
|
+
const formData4 = new FormData;
|
|
388955
|
+
formData4.append("file", file5);
|
|
388956
|
+
const response = await fetch(`${getServerBaseUrl()}/api/upload`, {
|
|
388957
|
+
method: "POST",
|
|
388958
|
+
body: formData4,
|
|
388959
|
+
signal: signal2
|
|
388960
|
+
});
|
|
388961
|
+
if (!response.ok) {
|
|
388962
|
+
throw new Error(`Upload failed: ${response.statusText}`);
|
|
388963
|
+
}
|
|
388964
|
+
const data = await response.json();
|
|
388965
|
+
if (!data.url) {
|
|
388966
|
+
throw new Error("Failed to upload attachment");
|
|
388967
|
+
}
|
|
388968
|
+
return data.url;
|
|
388969
|
+
}
|
|
388970
|
+
|
|
388885
388971
|
// ../livekit/src/index.ts
|
|
388886
388972
|
var StoreBlobProtocol = "store-blob:";
|
|
388887
388973
|
|
|
@@ -414275,8 +414361,8 @@ function findTodos(message) {
|
|
|
414275
414361
|
return todos;
|
|
414276
414362
|
}
|
|
414277
414363
|
// ../../node_modules/eventemitter3/index.mjs
|
|
414278
|
-
var
|
|
414279
|
-
var eventemitter3_default =
|
|
414364
|
+
var import__6 = __toESM(require_eventemitter3(), 1);
|
|
414365
|
+
var eventemitter3_default = import__6.default;
|
|
414280
414366
|
|
|
414281
414367
|
// ../../node_modules/colorette/index.js
|
|
414282
414368
|
import * as tty3 from "tty";
|
|
@@ -416821,79 +416907,6 @@ async function process16({
|
|
|
416821
416907
|
}));
|
|
416822
416908
|
}
|
|
416823
416909
|
}
|
|
416824
|
-
// ../livekit/src/chat/chat-with-hook.ts
|
|
416825
|
-
function makeChatWithHookClass(store, chatClass) {
|
|
416826
|
-
const chatWithHook = class extends chatClass {
|
|
416827
|
-
constructor(...args2) {
|
|
416828
|
-
super(...args2);
|
|
416829
|
-
const addToolResult = this.addToolResult.bind(this);
|
|
416830
|
-
this.addToolResult = async (options6) => {
|
|
416831
|
-
const parsed = ContentOutput.safeParse(options6.output);
|
|
416832
|
-
if (parsed.success) {
|
|
416833
|
-
const content3 = parsed.data.content.map(async (item) => {
|
|
416834
|
-
if (item.type === "text") {
|
|
416835
|
-
return item;
|
|
416836
|
-
}
|
|
416837
|
-
if (item.type === "image") {
|
|
416838
|
-
return {
|
|
416839
|
-
type: "image",
|
|
416840
|
-
mimeType: item.mimeType,
|
|
416841
|
-
data: await findBlobUrl(store, item.mimeType, item.data)
|
|
416842
|
-
};
|
|
416843
|
-
}
|
|
416844
|
-
return item;
|
|
416845
|
-
});
|
|
416846
|
-
const output2 = {
|
|
416847
|
-
...options6.output,
|
|
416848
|
-
content: await Promise.all(content3)
|
|
416849
|
-
};
|
|
416850
|
-
return addToolResult({
|
|
416851
|
-
...options6,
|
|
416852
|
-
output: output2
|
|
416853
|
-
});
|
|
416854
|
-
}
|
|
416855
|
-
return addToolResult(options6);
|
|
416856
|
-
};
|
|
416857
|
-
}
|
|
416858
|
-
};
|
|
416859
|
-
return chatWithHook;
|
|
416860
|
-
}
|
|
416861
|
-
var ContentOutput = zod_default.object({
|
|
416862
|
-
content: zod_default.array(zod_default.discriminatedUnion("type", [
|
|
416863
|
-
zod_default.object({
|
|
416864
|
-
type: zod_default.literal("text"),
|
|
416865
|
-
text: zod_default.string()
|
|
416866
|
-
}),
|
|
416867
|
-
zod_default.object({
|
|
416868
|
-
type: zod_default.literal("image"),
|
|
416869
|
-
mimeType: zod_default.string(),
|
|
416870
|
-
data: zod_default.string()
|
|
416871
|
-
})
|
|
416872
|
-
]))
|
|
416873
|
-
});
|
|
416874
|
-
async function findBlobUrl(store, mimeType, base643) {
|
|
416875
|
-
const data = fromBase64(base643);
|
|
416876
|
-
const checksum = await digest(data);
|
|
416877
|
-
const blob3 = store.query(makeBlobQuery(checksum));
|
|
416878
|
-
const url3 = `${StoreBlobProtocol}${checksum}`;
|
|
416879
|
-
if (blob3) {
|
|
416880
|
-
return url3;
|
|
416881
|
-
}
|
|
416882
|
-
store.commit(events.blobInserted({
|
|
416883
|
-
checksum,
|
|
416884
|
-
data,
|
|
416885
|
-
createdAt: new Date,
|
|
416886
|
-
mimeType
|
|
416887
|
-
}));
|
|
416888
|
-
return url3;
|
|
416889
|
-
}
|
|
416890
|
-
var fromBase64 = (base643) => Uint8Array.from(atob(base643), (v11) => v11.charCodeAt(0));
|
|
416891
|
-
async function digest(data) {
|
|
416892
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
416893
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
416894
|
-
return hashArray.map((b11) => b11.toString(16).padStart(2, "0")).join("");
|
|
416895
|
-
}
|
|
416896
|
-
|
|
416897
416910
|
// ../livekit/src/chat/llm/repair-tool-call.ts
|
|
416898
416911
|
var makeRepairToolCall = (taskId, model2) => async ({ toolCall, inputSchema: inputSchema2, error: error46 }) => {
|
|
416899
416912
|
if (NoSuchToolError.isInstance(error46)) {
|
|
@@ -417029,7 +417042,7 @@ function parseMcpTool(store, _name, mcpTool) {
|
|
|
417029
417042
|
if (item.type === "text") {
|
|
417030
417043
|
return item;
|
|
417031
417044
|
}
|
|
417032
|
-
const blob3 = findBlob(store, new URL(item.data));
|
|
417045
|
+
const blob3 = findBlob(store, new URL(item.data), item.mimeType);
|
|
417033
417046
|
if (!blob3) {
|
|
417034
417047
|
return {
|
|
417035
417048
|
type: "text",
|
|
@@ -417054,7 +417067,7 @@ function toBase642(bytes) {
|
|
|
417054
417067
|
const base643 = btoa(binString);
|
|
417055
417068
|
return base643;
|
|
417056
417069
|
}
|
|
417057
|
-
function findBlob(store, url3) {
|
|
417070
|
+
function findBlob(store, url3, mediaType) {
|
|
417058
417071
|
if (url3.protocol === StoreBlobProtocol) {
|
|
417059
417072
|
const blob3 = store.query(makeBlobQuery(url3.pathname));
|
|
417060
417073
|
if (blob3) {
|
|
@@ -417063,6 +417076,11 @@ function findBlob(store, url3) {
|
|
|
417063
417076
|
mediaType: blob3.mimeType
|
|
417064
417077
|
};
|
|
417065
417078
|
}
|
|
417079
|
+
} else {
|
|
417080
|
+
return {
|
|
417081
|
+
data: fetch(url3).then((x11) => x11.blob()).then((blob3) => blob3.arrayBuffer()).then((data) => toBase642(new Uint8Array(data))),
|
|
417082
|
+
mediaType
|
|
417083
|
+
};
|
|
417066
417084
|
}
|
|
417067
417085
|
}
|
|
417068
417086
|
|
|
@@ -418086,12 +418104,13 @@ class FlexibleChatTransport {
|
|
|
418086
418104
|
return true;
|
|
418087
418105
|
});
|
|
418088
418106
|
const preparedMessages = await prepareMessages(messages2, environment2);
|
|
418107
|
+
const modelMessages = await resolvePromise(convertToModelMessages(formatters.llm(preparedMessages), { tools }));
|
|
418089
418108
|
const stream12 = streamText({
|
|
418090
418109
|
headers: {
|
|
418091
418110
|
[PochiTaskIdHeader]: chatId
|
|
418092
418111
|
},
|
|
418093
418112
|
system: prompts.system(environment2?.info?.customRules, this.customAgent, mcpInfo?.instructions),
|
|
418094
|
-
messages:
|
|
418113
|
+
messages: modelMessages,
|
|
418095
418114
|
model: wrapLanguageModel({
|
|
418096
418115
|
model: model2,
|
|
418097
418116
|
middleware: middlewares
|
|
@@ -418178,6 +418197,19 @@ function estimateTotalTokens(messages2) {
|
|
|
418178
418197
|
}
|
|
418179
418198
|
return Math.ceil(totalTextLength / 4);
|
|
418180
418199
|
}
|
|
418200
|
+
async function resolvePromise(o10) {
|
|
418201
|
+
const resolved = await o10;
|
|
418202
|
+
if (o5(resolved)) {
|
|
418203
|
+
return Promise.all(resolved.map((x11) => resolvePromise(x11)));
|
|
418204
|
+
}
|
|
418205
|
+
if (o4(resolved)) {
|
|
418206
|
+
return Object.fromEntries(await Promise.all(Object.entries(resolved).map(async ([k11, v11]) => [
|
|
418207
|
+
k11,
|
|
418208
|
+
await resolvePromise(v11)
|
|
418209
|
+
])));
|
|
418210
|
+
}
|
|
418211
|
+
return resolved;
|
|
418212
|
+
}
|
|
418181
418213
|
|
|
418182
418214
|
// ../livekit/src/chat/live-chat-kit.ts
|
|
418183
418215
|
var logger23 = getLogger("LiveChatKit");
|
|
@@ -418212,7 +418244,7 @@ class LiveChatKit {
|
|
|
418212
418244
|
customAgent,
|
|
418213
418245
|
outputSchema: outputSchema2
|
|
418214
418246
|
});
|
|
418215
|
-
this.chat = new
|
|
418247
|
+
this.chat = new chatClass({
|
|
418216
418248
|
...chatInit,
|
|
418217
418249
|
id: taskId,
|
|
418218
418250
|
messages: this.messages,
|
|
@@ -419014,6 +419046,7 @@ async function executeToolCall(tool2, options6, cwd2, abortSignal) {
|
|
|
419014
419046
|
var logger26 = getLogger("TaskRunner");
|
|
419015
419047
|
|
|
419016
419048
|
class TaskRunner {
|
|
419049
|
+
store;
|
|
419017
419050
|
cwd;
|
|
419018
419051
|
toolCallOptions;
|
|
419019
419052
|
stepCount;
|
|
@@ -419045,6 +419078,7 @@ class TaskRunner {
|
|
|
419045
419078
|
}
|
|
419046
419079
|
};
|
|
419047
419080
|
this.stepCount = new StepCount(options6.maxSteps, options6.maxRetries);
|
|
419081
|
+
this.store = options6.store;
|
|
419048
419082
|
this.chatKit = new LiveChatKit({
|
|
419049
419083
|
taskId: options6.uid,
|
|
419050
419084
|
store: options6.store,
|
|
@@ -419181,7 +419215,7 @@ class TaskRunner {
|
|
|
419181
419215
|
continue;
|
|
419182
419216
|
const toolName = getToolName(toolCall);
|
|
419183
419217
|
logger26.trace(`Found tool call: ${toolName} with args: ${JSON.stringify(toolCall.input)}`);
|
|
419184
|
-
const toolResult = await executeToolCall(toolCall, this.toolCallOptions, this.cwd);
|
|
419218
|
+
const toolResult = await processContentOutput(this.store, await executeToolCall(toolCall, this.toolCallOptions, this.cwd));
|
|
419185
419219
|
await this.chatKit.chat.addToolResult({
|
|
419186
419220
|
tool: toolName,
|
|
419187
419221
|
toolCallId: toolCall.toolCallId,
|