zen-code 4.6.1 → 4.6.2
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/MultiLineTextInput-e7hD79Wp.mjs +24631 -0
- package/dist/app-Cynj004J.mjs +16204 -0
- package/dist/checkpoint-1sAx_j1E-DMtqyBT9.mjs +318 -0
- package/dist/checkpoint-DxiUsHMy-DqfBiLDW.mjs +394 -0
- package/dist/cli.mjs +17 -17
- package/dist/devtools-CzaVuYnh.mjs +2667 -0
- package/dist/graphBuilder-mpLrx9tk.mjs +49189 -0
- package/dist/{index-DEcMgCTj.mjs → index-B6kFMamn.mjs} +1 -1
- package/dist/index-BW3-KScB.mjs +463 -0
- package/dist/index-FHDPQ2Qk.mjs +211 -0
- package/dist/load-Cjl9cJ0o.mjs +105 -0
- package/dist/{memories-rSGKIPk5.mjs → memories-DirsFRdm.mjs} +1 -1
- package/dist/nonInteractive.mjs +6 -7
- package/dist/pg-adapter-BFtir1GE-BbUXBpaX.mjs +60 -0
- package/dist/queue-Cu_nO_wt-DVTcONlE.mjs +106 -0
- package/dist/remote-threads-CrG03ZS7-C9duTCnB.mjs +157 -0
- package/dist/shallow-BQy_8shO.mjs +331 -0
- package/dist/sqlite-adapter-BKOLSdoL-5XOA6_0i.mjs +71 -0
- package/dist/{subTasks-5KLIr9iy.mjs → subTasks-Bt97OwvY.mjs} +2 -2
- package/dist/zen-code.mjs +2 -8654
- package/dist/zen-keyboard.mjs +6 -7
- package/package.json +10 -7
- package/dist/MultiLineTextInput-B4NEXnFm.mjs +0 -23343
- package/dist/devtools-BHqoL8a6.mjs +0 -11653
- package/dist/graphBuilder-B3IJ7dB2.mjs +0 -2641
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { existsSync as S, readdirSync as _, lstatSync as L, statSync as v, readFileSync as I } from "node:fs";
|
|
2
|
+
import { resolve as m, join as d } from "node:path";
|
|
3
|
+
import { parse as b } from "yaml";
|
|
4
|
+
const A = 10 * 1024 * 1024, E = 64, f = 1024;
|
|
5
|
+
function g(t, o) {
|
|
6
|
+
try {
|
|
7
|
+
const n = m(t), s = m(o), e = n.substring(s.length);
|
|
8
|
+
return n === s || e.startsWith("/") || e === "";
|
|
9
|
+
} catch {
|
|
10
|
+
return !1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function N(t, o) {
|
|
14
|
+
return t ? t.length > E ? [!1, "name exceeds 64 characters"] : /^[a-z0-9]+(-[a-z0-9]+)*$/.test(t) ? t !== o ? [!1, `name '${t}' must match directory name '${o}'`] : [!0, ""] : [!1, "name must be lowercase alphanumeric with single hyphens only"] : [!1, "name is required"];
|
|
15
|
+
}
|
|
16
|
+
function x(t, o) {
|
|
17
|
+
try {
|
|
18
|
+
const n = v(t);
|
|
19
|
+
if (n.size > A)
|
|
20
|
+
return console.warn(`Skipping ${t}: file too large (${n.size} bytes)`), null;
|
|
21
|
+
const s = I(t, "utf-8"), e = /^---\s*\n(.*?)\n---\s*\n/s, c = s.match(e);
|
|
22
|
+
if (!c)
|
|
23
|
+
return console.warn(`Skipping ${t}: no valid YAML frontmatter found`), null;
|
|
24
|
+
const a = c[1];
|
|
25
|
+
let r;
|
|
26
|
+
try {
|
|
27
|
+
r = b(a);
|
|
28
|
+
} catch (w) {
|
|
29
|
+
return console.warn(`Invalid YAML in ${t}: ${w}`), null;
|
|
30
|
+
}
|
|
31
|
+
if (typeof r != "object" || r === null)
|
|
32
|
+
return console.warn(`Skipping ${t}: frontmatter is not a mapping`), null;
|
|
33
|
+
const i = r.name, l = r.description;
|
|
34
|
+
if (!i || !l)
|
|
35
|
+
return console.warn(`Skipping ${t}: missing required 'name' or 'description'`), null;
|
|
36
|
+
const p = t.split("/").slice(-2)[0], [$, h] = N(String(i), p);
|
|
37
|
+
$ || console.warn(`Skill '${i}' in ${t} does not follow Agent Skills spec: ${h}. Consider renaming to be spec-compliant.`);
|
|
38
|
+
let u = String(l);
|
|
39
|
+
return u.length > f && (console.warn(`Description exceeds ${f} chars in ${t}, truncating`), u = u.substring(0, f)), {
|
|
40
|
+
name: String(i),
|
|
41
|
+
description: u,
|
|
42
|
+
path: t,
|
|
43
|
+
source: o,
|
|
44
|
+
license: r.license,
|
|
45
|
+
compatibility: r.compatibility,
|
|
46
|
+
metadata: r.metadata,
|
|
47
|
+
allowed_tools: r["allowed-tools"]
|
|
48
|
+
};
|
|
49
|
+
} catch (n) {
|
|
50
|
+
return console.warn(`Error reading ${t}: ${n.message}`), null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function y(t, o) {
|
|
54
|
+
if (!S(t))
|
|
55
|
+
return [];
|
|
56
|
+
let n;
|
|
57
|
+
try {
|
|
58
|
+
n = m(t);
|
|
59
|
+
} catch {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
const s = [];
|
|
63
|
+
let e;
|
|
64
|
+
try {
|
|
65
|
+
e = _(t);
|
|
66
|
+
} catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
for (const c of e) {
|
|
70
|
+
const a = d(t, c);
|
|
71
|
+
if (!g(a, n))
|
|
72
|
+
continue;
|
|
73
|
+
let r;
|
|
74
|
+
try {
|
|
75
|
+
r = L(a);
|
|
76
|
+
} catch {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (!r.isDirectory())
|
|
80
|
+
continue;
|
|
81
|
+
const i = d(a, "SKILL.md");
|
|
82
|
+
if (!S(i) || !g(i, n))
|
|
83
|
+
continue;
|
|
84
|
+
const l = x(i, o);
|
|
85
|
+
l && s.push(l);
|
|
86
|
+
}
|
|
87
|
+
return s;
|
|
88
|
+
}
|
|
89
|
+
function k(t, o) {
|
|
90
|
+
const n = /* @__PURE__ */ new Map();
|
|
91
|
+
if (t) {
|
|
92
|
+
const s = y(t, "user");
|
|
93
|
+
for (const e of s)
|
|
94
|
+
n.set(e.name, e);
|
|
95
|
+
}
|
|
96
|
+
if (o) {
|
|
97
|
+
const s = y(o, "project");
|
|
98
|
+
for (const e of s)
|
|
99
|
+
n.set(e.name, e);
|
|
100
|
+
}
|
|
101
|
+
return Array.from(n.values());
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
k as l
|
|
105
|
+
};
|
package/dist/nonInteractive.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { HumanMessage as c } from "langchain";
|
|
2
|
-
import { i as d, j as m, k as l } from "./graphBuilder-
|
|
3
|
-
import "@langgraph
|
|
2
|
+
import { i as d, j as m, k as l } from "./graphBuilder-mpLrx9tk.mjs";
|
|
3
|
+
import "@langchain/langgraph";
|
|
4
|
+
import "zod";
|
|
5
|
+
import "@langchain/openai";
|
|
4
6
|
import "@langchain/anthropic";
|
|
5
7
|
import "@langchain/google-genai";
|
|
6
8
|
import "yaml";
|
|
7
|
-
import "@langchain/core/messages";
|
|
8
|
-
import "@langgraph-js/standard-agent";
|
|
9
|
-
import "@langgraph-js/auk";
|
|
10
9
|
async function p() {
|
|
11
10
|
return new Promise((t, n) => {
|
|
12
11
|
let r = "";
|
|
@@ -19,7 +18,7 @@ async function p() {
|
|
|
19
18
|
});
|
|
20
19
|
});
|
|
21
20
|
}
|
|
22
|
-
async function
|
|
21
|
+
async function y(t, n = !1) {
|
|
23
22
|
await d();
|
|
24
23
|
const r = await m();
|
|
25
24
|
let e = t || "";
|
|
@@ -48,5 +47,5 @@ async function b(t, n = !1) {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
export {
|
|
51
|
-
|
|
50
|
+
y as runNonInteractive
|
|
52
51
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Kysely as r, PostgresDialect as s, sql as e } from "kysely";
|
|
2
|
+
class i {
|
|
3
|
+
constructor(t) {
|
|
4
|
+
this.pool = t, this.db = new r({
|
|
5
|
+
dialect: new s({
|
|
6
|
+
pool: t
|
|
7
|
+
})
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
db;
|
|
11
|
+
dateToDb(t) {
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
dbToDate(t) {
|
|
15
|
+
return t instanceof Date ? t : new Date(t);
|
|
16
|
+
}
|
|
17
|
+
jsonToDb(t) {
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
dbToJson(t) {
|
|
21
|
+
return t;
|
|
22
|
+
}
|
|
23
|
+
buildJsonQuery(t, a, T, E) {
|
|
24
|
+
return e`${e.ref(a)}->>${e.lit(T)} = ${e.lit(JSON.stringify(E))}`;
|
|
25
|
+
}
|
|
26
|
+
now() {
|
|
27
|
+
return /* @__PURE__ */ new Date();
|
|
28
|
+
}
|
|
29
|
+
async createTables(t) {
|
|
30
|
+
await e`
|
|
31
|
+
CREATE TABLE IF NOT EXISTS threads (
|
|
32
|
+
thread_id TEXT PRIMARY KEY,
|
|
33
|
+
created_at TIMESTAMP NOT NULL,
|
|
34
|
+
updated_at TIMESTAMP NOT NULL,
|
|
35
|
+
metadata JSONB NOT NULL DEFAULT '{}',
|
|
36
|
+
status TEXT NOT NULL DEFAULT 'idle',
|
|
37
|
+
values JSONB,
|
|
38
|
+
interrupts JSONB NOT NULL DEFAULT '{}'
|
|
39
|
+
)
|
|
40
|
+
`.execute(t), await e`
|
|
41
|
+
CREATE TABLE IF NOT EXISTS runs (
|
|
42
|
+
run_id TEXT PRIMARY KEY,
|
|
43
|
+
thread_id TEXT NOT NULL,
|
|
44
|
+
assistant_id TEXT NOT NULL,
|
|
45
|
+
created_at TIMESTAMP NOT NULL,
|
|
46
|
+
updated_at TIMESTAMP NOT NULL,
|
|
47
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
48
|
+
metadata JSONB NOT NULL DEFAULT '{}',
|
|
49
|
+
multitask_strategy TEXT NOT NULL DEFAULT 'reject',
|
|
50
|
+
FOREIGN KEY (thread_id) REFERENCES threads(thread_id) ON DELETE CASCADE
|
|
51
|
+
)
|
|
52
|
+
`.execute(t);
|
|
53
|
+
}
|
|
54
|
+
async createIndexes(t) {
|
|
55
|
+
await e`CREATE INDEX IF NOT EXISTS idx_threads_status ON threads(status)`.execute(t), await e`CREATE INDEX IF NOT EXISTS idx_threads_created_at ON threads(created_at)`.execute(t), await e`CREATE INDEX IF NOT EXISTS idx_threads_updated_at ON threads(updated_at)`.execute(t), await e`CREATE INDEX IF NOT EXISTS idx_runs_thread_id ON runs(thread_id)`.execute(t), await e`CREATE INDEX IF NOT EXISTS idx_runs_status ON runs(status)`.execute(t);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
i as PostgresAdapter
|
|
60
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { a as h, C as d } from "./app-Cynj004J.mjs";
|
|
2
|
+
import { createClient as m } from "redis";
|
|
3
|
+
class o extends h {
|
|
4
|
+
// 轮询间隔(毫秒)
|
|
5
|
+
constructor(e, t = !0, s = 300) {
|
|
6
|
+
super(e, !0, s), this.id = e, this.compressMessages = t, this.ttl = s, this.streamKey = `stream:${this.id}`, this.listKey = `queue:${this.id}`, this.redis = m({
|
|
7
|
+
url: process.env.REDIS_URL
|
|
8
|
+
}), this.cancelSignal = new AbortController(), this.redis.isOpen || this.redis.connect(), this.isConnected = !0;
|
|
9
|
+
}
|
|
10
|
+
redis;
|
|
11
|
+
streamKey;
|
|
12
|
+
listKey;
|
|
13
|
+
isConnected = !1;
|
|
14
|
+
cancelSignal;
|
|
15
|
+
lastStreamId = "0";
|
|
16
|
+
// 最后读取的 Stream ID
|
|
17
|
+
pollInterval = 100;
|
|
18
|
+
/**
|
|
19
|
+
* 推送消息到 Redis Stream 和 List
|
|
20
|
+
* - Stream: 用于实时推送(集群友好)
|
|
21
|
+
* - List: 用于 getAll() 批量获取历史数据
|
|
22
|
+
*/
|
|
23
|
+
async push(e) {
|
|
24
|
+
const t = await this.encodeData(e), s = Buffer.from(t).toString("base64"), a = Buffer.from(t);
|
|
25
|
+
await this.redis.xAdd(this.streamKey, "*", { data: s }), await this.redis.expire(this.streamKey, this.ttl), await this.redis.rPush(this.listKey, a), await this.redis.expire(this.listKey, this.ttl), this.emit("dataChange", s);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 异步生成器:使用 Redis Streams XREAD 轮询消费队列数据
|
|
29
|
+
*/
|
|
30
|
+
async *onDataReceive() {
|
|
31
|
+
let e = !1;
|
|
32
|
+
if (this.cancelSignal.signal.aborted)
|
|
33
|
+
return;
|
|
34
|
+
const t = () => {
|
|
35
|
+
e = !0;
|
|
36
|
+
};
|
|
37
|
+
this.cancelSignal.signal.addEventListener("abort", t);
|
|
38
|
+
try {
|
|
39
|
+
for (; !e && !this.cancelSignal.signal.aborted; ) {
|
|
40
|
+
const s = await this.redis.xRead([{ key: this.streamKey, id: this.lastStreamId }], {
|
|
41
|
+
BLOCK: this.pollInterval,
|
|
42
|
+
COUNT: 10
|
|
43
|
+
});
|
|
44
|
+
if (s && s.length > 0)
|
|
45
|
+
for (const a of s) {
|
|
46
|
+
for (const r of a.messages) {
|
|
47
|
+
this.lastStreamId = r.id;
|
|
48
|
+
const n = r.message.data, l = Buffer.from(n, "base64"), i = await this.decodeData(l);
|
|
49
|
+
if ((i.event === "__stream_end__" || i.event === "__stream_error__" || i.event === "__stream_cancel__") && (await new Promise((c) => setTimeout(c, 300)), e = !0, i.event === "__stream_cancel__" && await this.cancel()), yield i, e)
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
if (e)
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
!e && !this.cancelSignal.signal.aborted && await new Promise((a) => setTimeout(a, this.pollInterval));
|
|
56
|
+
}
|
|
57
|
+
} finally {
|
|
58
|
+
this.cancelSignal.signal.removeEventListener("abort", t);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* 获取队列中的所有数据(从 List 获取历史数据)
|
|
63
|
+
*/
|
|
64
|
+
async getAll() {
|
|
65
|
+
const e = await this.redis.lRange(this.listKey, 0, -1);
|
|
66
|
+
return !e || e.length === 0 ? [] : this.compressMessages ? await Promise.all(
|
|
67
|
+
e.map((t) => {
|
|
68
|
+
const s = typeof t == "string" ? Buffer.from(t, "binary") : t;
|
|
69
|
+
return this.decodeData(s);
|
|
70
|
+
})
|
|
71
|
+
) : e.map((t) => JSON.parse(t));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 清空队列
|
|
75
|
+
*/
|
|
76
|
+
clear() {
|
|
77
|
+
this.isConnected && (this.redis.del(this.streamKey), this.redis.del(this.listKey));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 取消操作
|
|
81
|
+
*/
|
|
82
|
+
async cancel() {
|
|
83
|
+
this.cancelSignal.abort("user cancel this run"), await this.push(new d());
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 复制队列到另一个队列
|
|
87
|
+
*/
|
|
88
|
+
async copyToQueue(e, t) {
|
|
89
|
+
const s = new o(e, this.compressMessages, t ?? this.ttl);
|
|
90
|
+
await this.redis.copy(this.listKey, s.listKey), await this.redis.expire(s.listKey, t ?? this.ttl);
|
|
91
|
+
const a = await this.redis.xRange(this.streamKey, "-", "+");
|
|
92
|
+
if (a && a.length > 0) {
|
|
93
|
+
for (const r of a) {
|
|
94
|
+
const n = {};
|
|
95
|
+
for (const [l, i] of Object.entries(r.message))
|
|
96
|
+
n[l] = String(i);
|
|
97
|
+
await this.redis.xAdd(s.streamKey, "*", n);
|
|
98
|
+
}
|
|
99
|
+
await this.redis.expire(s.streamKey, t ?? this.ttl);
|
|
100
|
+
}
|
|
101
|
+
return s;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
o as RedisStreamQueue
|
|
106
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
var h = /* @__PURE__ */ ((a) => (a.NETWORK_ERROR = "NETWORK_ERROR", a.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", a.INTERNAL_ERROR = "INTERNAL_ERROR", a.THREAD_NOT_FOUND = "THREAD_NOT_FOUND", a.THREAD_BUSY = "THREAD_BUSY", a.RUN_NOT_FOUND = "RUN_NOT_FOUND", a.GRAPH_NOT_FOUND = "GRAPH_NOT_FOUND", a.INVALID_REQUEST = "INVALID_REQUEST", a))(h || {});
|
|
2
|
+
class d extends Error {
|
|
3
|
+
constructor(s, t, e) {
|
|
4
|
+
super(t), this.code = s, this.statusCode = e, this.name = "RemoteApiError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
async function c(a, s, t) {
|
|
8
|
+
try {
|
|
9
|
+
let e = a;
|
|
10
|
+
if (t?.query) {
|
|
11
|
+
const f = new URLSearchParams();
|
|
12
|
+
Object.entries(t.query).forEach(([v, N]) => {
|
|
13
|
+
f.append(v, String(N));
|
|
14
|
+
}), e += `?${f.toString()}`;
|
|
15
|
+
}
|
|
16
|
+
const i = await fetch(e, {
|
|
17
|
+
method: s,
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "application/json"
|
|
20
|
+
},
|
|
21
|
+
body: t?.body ? JSON.stringify(t.body) : void 0
|
|
22
|
+
}), n = await i.json();
|
|
23
|
+
if (!i.ok || !n.success)
|
|
24
|
+
throw new d(
|
|
25
|
+
n.error?.code || h.INTERNAL_ERROR,
|
|
26
|
+
n.error?.message || "Unknown error",
|
|
27
|
+
i.status
|
|
28
|
+
);
|
|
29
|
+
return n;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
throw e instanceof d ? e : new d(
|
|
32
|
+
h.NETWORK_ERROR,
|
|
33
|
+
`Network error: ${e instanceof Error ? e.message : "Unknown error"}`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function o(a, s) {
|
|
38
|
+
return c(a, "GET", { query: s });
|
|
39
|
+
}
|
|
40
|
+
async function r(a, s, t) {
|
|
41
|
+
return c(a, "POST", { body: s, query: t });
|
|
42
|
+
}
|
|
43
|
+
async function l(a, s, t) {
|
|
44
|
+
return c(a, "PUT", { body: s, query: t });
|
|
45
|
+
}
|
|
46
|
+
async function O(a, s) {
|
|
47
|
+
return c(a, "DELETE", { query: s });
|
|
48
|
+
}
|
|
49
|
+
class p {
|
|
50
|
+
constructor(s, t) {
|
|
51
|
+
this.serverUrl = s, this.httpClient = t, this.serverUrl = s.replace(/\/$/, ""), this.httpClient = t || fetch;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 初始化数据库
|
|
55
|
+
*/
|
|
56
|
+
async setup() {
|
|
57
|
+
await r(`${this.serverUrl}/setup`);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 创建线程
|
|
61
|
+
*/
|
|
62
|
+
async create(s) {
|
|
63
|
+
return (await r(`${this.serverUrl}/threads`, s)).data;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 搜索线程
|
|
67
|
+
*/
|
|
68
|
+
async search(s) {
|
|
69
|
+
const t = {};
|
|
70
|
+
return s?.ids !== void 0 && s.ids.length > 0 && (t.ids = JSON.stringify(s.ids)), s?.metadata !== void 0 && (t.metadata = JSON.stringify(s.metadata)), s?.limit !== void 0 && (t.limit = s.limit), s?.offset !== void 0 && (t.offset = s.offset), s?.status !== void 0 && (t.status = s.status), s?.sortBy !== void 0 && (t.sortBy = s.sortBy), s?.sortOrder !== void 0 && (t.sortOrder = s.sortOrder), s?.values !== void 0 && (t.values = JSON.stringify(s.values)), s?.select !== void 0 && (t.select = JSON.stringify(s.select)), s?.withoutDetails !== void 0 && (t.withoutDetails = s.withoutDetails), (await o(`${this.serverUrl}/threads`, t)).data;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 获取线程
|
|
74
|
+
*/
|
|
75
|
+
async get(s) {
|
|
76
|
+
return (await o(`${this.serverUrl}/threads/${s}`)).data;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 更新线程
|
|
80
|
+
*/
|
|
81
|
+
async set(s, t) {
|
|
82
|
+
await l(`${this.serverUrl}/threads/${s}`, t);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 删除线程
|
|
86
|
+
*/
|
|
87
|
+
async delete(s) {
|
|
88
|
+
await O(`${this.serverUrl}/threads/${s}`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 更新状态
|
|
92
|
+
*/
|
|
93
|
+
async updateState(s, t) {
|
|
94
|
+
return (await r(
|
|
95
|
+
`${this.serverUrl}/threads/${s}/state`,
|
|
96
|
+
t
|
|
97
|
+
)).data;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 创建运行
|
|
101
|
+
*/
|
|
102
|
+
async createRun(s, t, e) {
|
|
103
|
+
return (await r(`${this.serverUrl}/threads/${s}/runs`, e || {}, {
|
|
104
|
+
assistantId: t
|
|
105
|
+
})).data;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 列出运行
|
|
109
|
+
*/
|
|
110
|
+
async listRuns(s, t) {
|
|
111
|
+
const e = {};
|
|
112
|
+
return t?.limit !== void 0 && (e.limit = t.limit), t?.offset !== void 0 && (e.offset = t.offset), t?.status !== void 0 && (e.status = t.status), (await o(`${this.serverUrl}/threads/${s}/runs`, e)).data;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 更新运行
|
|
116
|
+
*/
|
|
117
|
+
async updateRun(s, t) {
|
|
118
|
+
await l(`${this.serverUrl}/runs/${s}`, t);
|
|
119
|
+
}
|
|
120
|
+
// New methods for Threads API
|
|
121
|
+
/**
|
|
122
|
+
* 计算线程数量
|
|
123
|
+
*/
|
|
124
|
+
async count(s) {
|
|
125
|
+
const t = {};
|
|
126
|
+
return s?.ids !== void 0 && s.ids.length > 0 && (t.ids = JSON.stringify(s.ids)), s?.metadata !== void 0 && (t.metadata = JSON.stringify(s.metadata)), s?.status !== void 0 && (t.status = s.status), s?.values !== void 0 && (t.values = JSON.stringify(s.values)), (await o(`${this.serverUrl}/threads/count`, t)).data;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* 更新线程元数据
|
|
130
|
+
*/
|
|
131
|
+
async patch(s, t) {
|
|
132
|
+
return (await r(`${this.serverUrl}/threads/${s}`, t)).data;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 获取线程状态
|
|
136
|
+
*/
|
|
137
|
+
async getState(s, t) {
|
|
138
|
+
const e = {};
|
|
139
|
+
return t?.subgraphs !== void 0 && (e.subgraphs = t.subgraphs), t?.checkpointId !== void 0 && (e.checkpointId = t.checkpointId), (await r(`${this.serverUrl}/threads/${s}/state`, e)).data;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 获取线程历史
|
|
143
|
+
*/
|
|
144
|
+
async getStateHistory(s, t) {
|
|
145
|
+
const e = {};
|
|
146
|
+
return t?.limit !== void 0 && (e.limit = t.limit), t?.before !== void 0 && (e.before = t.before), (await r(`${this.serverUrl}/threads/${s}/history`, e)).data;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* 复制线程
|
|
150
|
+
*/
|
|
151
|
+
async copy(s) {
|
|
152
|
+
return (await r(`${this.serverUrl}/threads/${s}/copy`)).data;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
p as RemoteKyselyThreadsManager
|
|
157
|
+
};
|