anycodex 0.0.24 → 0.0.26
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/bin.js +289 -171
- package/dist/{chunk-ILSZBQFJ.js → chunk-2X6YJUFL.js} +5 -5
- package/dist/{chunk-TYWHGJLT.js → chunk-4SPBQLA5.js} +23 -6
- package/dist/{registry-4Z4O3ZD2-QFDRMPNT.js → registry-N6XVTLPC-H2PNFK4G.js} +2 -2
- package/dist/{session-CD67J7DC-TOJQJOSR.js → session-3H7MDN6G-ILPE3VAH.js} +1 -1
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Skill,
|
|
8
8
|
Tool,
|
|
9
9
|
ToolRegistry
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2X6YJUFL.js";
|
|
11
11
|
import {
|
|
12
12
|
AISDKError,
|
|
13
13
|
APICallError,
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
ProviderID,
|
|
27
27
|
Session,
|
|
28
28
|
SessionService,
|
|
29
|
-
Token,
|
|
30
29
|
TooManyEmbeddingValuesForCallError,
|
|
31
30
|
TypeValidationError,
|
|
32
31
|
UnsupportedFunctionalityError,
|
|
@@ -59,7 +58,7 @@ import {
|
|
|
59
58
|
withoutTrailingSlash,
|
|
60
59
|
wrapLanguageModel,
|
|
61
60
|
zodSchema
|
|
62
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-4SPBQLA5.js";
|
|
63
62
|
import "./chunk-DU4BGORD.js";
|
|
64
63
|
import {
|
|
65
64
|
MessageID,
|
|
@@ -754,7 +753,7 @@ import fs2 from "fs";
|
|
|
754
753
|
import readline from "readline";
|
|
755
754
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
756
755
|
|
|
757
|
-
// ../server/dist/chunk-
|
|
756
|
+
// ../server/dist/chunk-GNHGIOCL.js
|
|
758
757
|
import http from "http";
|
|
759
758
|
import https from "https";
|
|
760
759
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -11614,7 +11613,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
11614
11613
|
abortSignal: options.abortSignal,
|
|
11615
11614
|
fetch: this.config.fetch
|
|
11616
11615
|
});
|
|
11617
|
-
const
|
|
11616
|
+
const self2 = this;
|
|
11618
11617
|
const providerKey = this.config.provider.replace(".responses", "");
|
|
11619
11618
|
let finishReason = "unknown";
|
|
11620
11619
|
const usage = {
|
|
@@ -12028,7 +12027,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
12028
12027
|
controller.enqueue({
|
|
12029
12028
|
type: "source",
|
|
12030
12029
|
sourceType: "url",
|
|
12031
|
-
id: (_p = (_o = (_n =
|
|
12030
|
+
id: (_p = (_o = (_n = self2.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId(),
|
|
12032
12031
|
url: value.annotation.url,
|
|
12033
12032
|
title: value.annotation.title
|
|
12034
12033
|
});
|
|
@@ -12036,7 +12035,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
12036
12035
|
controller.enqueue({
|
|
12037
12036
|
type: "source",
|
|
12038
12037
|
sourceType: "document",
|
|
12039
|
-
id: (_s = (_r = (_q =
|
|
12038
|
+
id: (_s = (_r = (_q = self2.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : generateId(),
|
|
12040
12039
|
mediaType: "text/plain",
|
|
12041
12040
|
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
12042
12041
|
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
|
|
@@ -13920,6 +13919,103 @@ function createOpenAICompatible(options) {
|
|
|
13920
13919
|
import { spawn } from "child_process";
|
|
13921
13920
|
import { pathToFileURL, fileURLToPath } from "url";
|
|
13922
13921
|
var import_fuzzysort = __toESM(require_fuzzysort(), 1);
|
|
13922
|
+
|
|
13923
|
+
// ../../node_modules/.pnpm/ulid@3.0.1/node_modules/ulid/dist/node/index.js
|
|
13924
|
+
import crypto from "crypto";
|
|
13925
|
+
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
13926
|
+
var ENCODING_LEN = 32;
|
|
13927
|
+
var RANDOM_LEN = 16;
|
|
13928
|
+
var TIME_LEN = 10;
|
|
13929
|
+
var TIME_MAX = 281474976710655;
|
|
13930
|
+
var ULIDErrorCode;
|
|
13931
|
+
(function(ULIDErrorCode2) {
|
|
13932
|
+
ULIDErrorCode2["Base32IncorrectEncoding"] = "B32_ENC_INVALID";
|
|
13933
|
+
ULIDErrorCode2["DecodeTimeInvalidCharacter"] = "DEC_TIME_CHAR";
|
|
13934
|
+
ULIDErrorCode2["DecodeTimeValueMalformed"] = "DEC_TIME_MALFORMED";
|
|
13935
|
+
ULIDErrorCode2["EncodeTimeNegative"] = "ENC_TIME_NEG";
|
|
13936
|
+
ULIDErrorCode2["EncodeTimeSizeExceeded"] = "ENC_TIME_SIZE_EXCEED";
|
|
13937
|
+
ULIDErrorCode2["EncodeTimeValueMalformed"] = "ENC_TIME_MALFORMED";
|
|
13938
|
+
ULIDErrorCode2["PRNGDetectFailure"] = "PRNG_DETECT";
|
|
13939
|
+
ULIDErrorCode2["ULIDInvalid"] = "ULID_INVALID";
|
|
13940
|
+
ULIDErrorCode2["Unexpected"] = "UNEXPECTED";
|
|
13941
|
+
ULIDErrorCode2["UUIDInvalid"] = "UUID_INVALID";
|
|
13942
|
+
})(ULIDErrorCode || (ULIDErrorCode = {}));
|
|
13943
|
+
var ULIDError = class extends Error {
|
|
13944
|
+
constructor(errorCode, message) {
|
|
13945
|
+
super(`${message} (${errorCode})`);
|
|
13946
|
+
this.name = "ULIDError";
|
|
13947
|
+
this.code = errorCode;
|
|
13948
|
+
}
|
|
13949
|
+
};
|
|
13950
|
+
function randomChar(prng) {
|
|
13951
|
+
const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN;
|
|
13952
|
+
return ENCODING.charAt(randomPosition);
|
|
13953
|
+
}
|
|
13954
|
+
function detectPRNG(root) {
|
|
13955
|
+
const rootLookup = detectRoot();
|
|
13956
|
+
const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof crypto !== "undefined" ? crypto : null);
|
|
13957
|
+
if (typeof globalCrypto?.getRandomValues === "function") {
|
|
13958
|
+
return () => {
|
|
13959
|
+
const buffer = new Uint8Array(1);
|
|
13960
|
+
globalCrypto.getRandomValues(buffer);
|
|
13961
|
+
return buffer[0] / 255;
|
|
13962
|
+
};
|
|
13963
|
+
} else if (typeof globalCrypto?.randomBytes === "function") {
|
|
13964
|
+
return () => globalCrypto.randomBytes(1).readUInt8() / 255;
|
|
13965
|
+
} else if (crypto?.randomBytes) {
|
|
13966
|
+
return () => crypto.randomBytes(1).readUInt8() / 255;
|
|
13967
|
+
}
|
|
13968
|
+
throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
|
|
13969
|
+
}
|
|
13970
|
+
function detectRoot() {
|
|
13971
|
+
if (inWebWorker())
|
|
13972
|
+
return self;
|
|
13973
|
+
if (typeof window !== "undefined") {
|
|
13974
|
+
return window;
|
|
13975
|
+
}
|
|
13976
|
+
if (typeof global !== "undefined") {
|
|
13977
|
+
return global;
|
|
13978
|
+
}
|
|
13979
|
+
if (typeof globalThis !== "undefined") {
|
|
13980
|
+
return globalThis;
|
|
13981
|
+
}
|
|
13982
|
+
return null;
|
|
13983
|
+
}
|
|
13984
|
+
function encodeRandom(len, prng) {
|
|
13985
|
+
let str = "";
|
|
13986
|
+
for (; len > 0; len--) {
|
|
13987
|
+
str = randomChar(prng) + str;
|
|
13988
|
+
}
|
|
13989
|
+
return str;
|
|
13990
|
+
}
|
|
13991
|
+
function encodeTime(now, len = TIME_LEN) {
|
|
13992
|
+
if (isNaN(now)) {
|
|
13993
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now}`);
|
|
13994
|
+
} else if (now > TIME_MAX) {
|
|
13995
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now}`);
|
|
13996
|
+
} else if (now < 0) {
|
|
13997
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now}`);
|
|
13998
|
+
} else if (Number.isInteger(now) === false) {
|
|
13999
|
+
throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now}`);
|
|
14000
|
+
}
|
|
14001
|
+
let mod, str = "";
|
|
14002
|
+
for (let currentLen = len; currentLen > 0; currentLen--) {
|
|
14003
|
+
mod = now % ENCODING_LEN;
|
|
14004
|
+
str = ENCODING.charAt(mod) + str;
|
|
14005
|
+
now = (now - mod) / ENCODING_LEN;
|
|
14006
|
+
}
|
|
14007
|
+
return str;
|
|
14008
|
+
}
|
|
14009
|
+
function inWebWorker() {
|
|
14010
|
+
return typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
|
|
14011
|
+
}
|
|
14012
|
+
function ulid(seedTime, prng) {
|
|
14013
|
+
const currentPRNG = prng || detectPRNG();
|
|
14014
|
+
const seed = !seedTime || isNaN(seedTime) ? Date.now() : seedTime;
|
|
14015
|
+
return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);
|
|
14016
|
+
}
|
|
14017
|
+
|
|
14018
|
+
// ../agent/dist/index.js
|
|
13923
14019
|
var EnvService = class {
|
|
13924
14020
|
env;
|
|
13925
14021
|
constructor(initialEnv = {}) {
|
|
@@ -14007,41 +14103,41 @@ var Log = class {
|
|
|
14007
14103
|
return cached;
|
|
14008
14104
|
}
|
|
14009
14105
|
}
|
|
14010
|
-
const
|
|
14106
|
+
const self2 = this;
|
|
14011
14107
|
function build(message, extra) {
|
|
14012
14108
|
const prefix = Object.entries({
|
|
14013
14109
|
...tags,
|
|
14014
14110
|
...extra
|
|
14015
14111
|
}).filter(([_, value]) => value !== void 0 && value !== null).map(([key, value]) => {
|
|
14016
14112
|
const prefix2 = `${key}=`;
|
|
14017
|
-
if (value instanceof Error) return prefix2 +
|
|
14113
|
+
if (value instanceof Error) return prefix2 + self2.formatError(value);
|
|
14018
14114
|
if (typeof value === "object") return prefix2 + JSON.stringify(value);
|
|
14019
14115
|
return prefix2 + value;
|
|
14020
14116
|
}).join(" ");
|
|
14021
14117
|
const next = /* @__PURE__ */ new Date();
|
|
14022
|
-
const diff = next.getTime() -
|
|
14023
|
-
|
|
14118
|
+
const diff = next.getTime() - self2.last;
|
|
14119
|
+
self2.last = next.getTime();
|
|
14024
14120
|
return [next.toISOString().split(".")[0], "+" + diff + "ms", prefix, message].filter(Boolean).join(" ") + "\n";
|
|
14025
14121
|
}
|
|
14026
14122
|
const result = {
|
|
14027
14123
|
debug(message, extra) {
|
|
14028
|
-
if (
|
|
14029
|
-
|
|
14124
|
+
if (self2.shouldLog("DEBUG")) {
|
|
14125
|
+
self2.write("DEBUG " + build(message, extra));
|
|
14030
14126
|
}
|
|
14031
14127
|
},
|
|
14032
14128
|
info(message, extra) {
|
|
14033
|
-
if (
|
|
14034
|
-
|
|
14129
|
+
if (self2.shouldLog("INFO")) {
|
|
14130
|
+
self2.write("INFO " + build(message, extra));
|
|
14035
14131
|
}
|
|
14036
14132
|
},
|
|
14037
14133
|
error(message, extra) {
|
|
14038
|
-
if (
|
|
14039
|
-
|
|
14134
|
+
if (self2.shouldLog("ERROR")) {
|
|
14135
|
+
self2.write("ERROR " + build(message, extra));
|
|
14040
14136
|
}
|
|
14041
14137
|
},
|
|
14042
14138
|
warn(message, extra) {
|
|
14043
|
-
if (
|
|
14044
|
-
|
|
14139
|
+
if (self2.shouldLog("WARN")) {
|
|
14140
|
+
self2.write("WARN " + build(message, extra));
|
|
14045
14141
|
}
|
|
14046
14142
|
},
|
|
14047
14143
|
tag(key, value) {
|
|
@@ -14049,7 +14145,7 @@ var Log = class {
|
|
|
14049
14145
|
return result;
|
|
14050
14146
|
},
|
|
14051
14147
|
clone() {
|
|
14052
|
-
return
|
|
14148
|
+
return self2.create({ ...tags });
|
|
14053
14149
|
},
|
|
14054
14150
|
time(message, extra) {
|
|
14055
14151
|
const now = Date.now();
|
|
@@ -15506,6 +15602,7 @@ var SessionPrompt;
|
|
|
15506
15602
|
SessionPrompt2.PromptInput = zod_default.object({
|
|
15507
15603
|
sessionID: SessionID.zod,
|
|
15508
15604
|
messageID: MessageID.zod.optional(),
|
|
15605
|
+
chatId: zod_default.string().optional(),
|
|
15509
15606
|
model: zod_default.object({
|
|
15510
15607
|
providerID: ProviderID.zod,
|
|
15511
15608
|
modelID: ModelID.zod
|
|
@@ -15716,7 +15813,8 @@ var SessionPrompt;
|
|
|
15716
15813
|
model,
|
|
15717
15814
|
system: input.system,
|
|
15718
15815
|
format: input.format,
|
|
15719
|
-
variant
|
|
15816
|
+
variant,
|
|
15817
|
+
...input.chatId ? { chatId: input.chatId } : {}
|
|
15720
15818
|
};
|
|
15721
15819
|
const assign = (part) => ({
|
|
15722
15820
|
...part,
|
|
@@ -17041,7 +17139,7 @@ var LLMRunner;
|
|
|
17041
17139
|
state: {
|
|
17042
17140
|
status: "completed",
|
|
17043
17141
|
input: value.input ?? match.state.input,
|
|
17044
|
-
output: value.output.output,
|
|
17142
|
+
output: ContextCompaction.truncateToolOutput(value.output.output),
|
|
17045
17143
|
metadata: value.output.metadata,
|
|
17046
17144
|
title: value.output.title,
|
|
17047
17145
|
time: {
|
|
@@ -17091,8 +17189,6 @@ var LLMRunner;
|
|
|
17091
17189
|
metadata: value.providerMetadata
|
|
17092
17190
|
});
|
|
17093
17191
|
input.assistantMessage.finish = value.finishReason;
|
|
17094
|
-
input.assistantMessage.cost += usage.cost;
|
|
17095
|
-
input.assistantMessage.tokens = usage.tokens;
|
|
17096
17192
|
await input.context.session.updatePart({
|
|
17097
17193
|
id: PartID.ascending(),
|
|
17098
17194
|
reason: value.finishReason,
|
|
@@ -17221,63 +17317,68 @@ Do not respond to any questions in the conversation, only output the summary.
|
|
|
17221
17317
|
var ContextCompaction;
|
|
17222
17318
|
((ContextCompaction2) => {
|
|
17223
17319
|
const COMPACTION_BUFFER = 2e4;
|
|
17320
|
+
const MAX_TOOL_OUTPUT_TOKENS = 4e4;
|
|
17321
|
+
const CHARS_PER_TOKEN = 4;
|
|
17322
|
+
function truncateToolOutput(output) {
|
|
17323
|
+
const maxChars = MAX_TOOL_OUTPUT_TOKENS * CHARS_PER_TOKEN;
|
|
17324
|
+
if (output.length <= maxChars) return output;
|
|
17325
|
+
return output.slice(0, maxChars) + "\n\n[TRUNCATED - Content exceeds " + MAX_TOOL_OUTPUT_TOKENS.toLocaleString() + " token limit]";
|
|
17326
|
+
}
|
|
17327
|
+
ContextCompaction2.truncateToolOutput = truncateToolOutput;
|
|
17328
|
+
function getLimits(model, config) {
|
|
17329
|
+
const contextLimit = model.limit.context ?? 0;
|
|
17330
|
+
const modelProvider = VendorRegistry.getModelProvider({ model });
|
|
17331
|
+
const reserved = config.compaction?.reserved ?? Math.min(COMPACTION_BUFFER, modelProvider.getMaxOutputTokens());
|
|
17332
|
+
const compactionThreshold = model.limit.input ? model.limit.input - reserved : contextLimit - modelProvider.getMaxOutputTokens();
|
|
17333
|
+
return { contextLimit, compactionThreshold };
|
|
17334
|
+
}
|
|
17335
|
+
function countInputTokens(tokens) {
|
|
17336
|
+
return tokens.total || tokens.input + tokens.output + tokens.cache.read + tokens.cache.write;
|
|
17337
|
+
}
|
|
17224
17338
|
async function isOverflow(input) {
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
const contextLimit = input.model.limit.context;
|
|
17339
|
+
if (input.context.config.compaction?.auto === false) return false;
|
|
17340
|
+
const { contextLimit, compactionThreshold } = getLimits(input.model, input.context.config);
|
|
17228
17341
|
if (contextLimit === 0) return false;
|
|
17229
|
-
|
|
17230
|
-
const modelProvider = VendorRegistry.getModelProvider({ model: input.model });
|
|
17231
|
-
const reserved = config.compaction?.reserved ?? Math.min(COMPACTION_BUFFER, modelProvider.getMaxOutputTokens());
|
|
17232
|
-
const usable = input.model.limit.input ? input.model.limit.input - reserved : contextLimit - modelProvider.getMaxOutputTokens();
|
|
17233
|
-
return count >= usable;
|
|
17342
|
+
return countInputTokens(input.tokens) >= compactionThreshold;
|
|
17234
17343
|
}
|
|
17235
17344
|
ContextCompaction2.isOverflow = isOverflow;
|
|
17236
|
-
|
|
17237
|
-
|
|
17238
|
-
|
|
17239
|
-
|
|
17240
|
-
|
|
17241
|
-
|
|
17242
|
-
|
|
17243
|
-
const msgs = await context.memory.messages({ sessionID: input.sessionID });
|
|
17244
|
-
let total = 0;
|
|
17245
|
-
let pruned = 0;
|
|
17246
|
-
const toPrune = [];
|
|
17247
|
-
let turns = 0;
|
|
17248
|
-
loop: for (let msgIndex = msgs.length - 1; msgIndex >= 0; msgIndex--) {
|
|
17249
|
-
const msg = msgs[msgIndex];
|
|
17250
|
-
if (msg.info.role === "user") turns++;
|
|
17251
|
-
if (turns < 2) continue;
|
|
17252
|
-
if (msg.info.role === "assistant" && msg.info.summary) break loop;
|
|
17253
|
-
for (let partIndex = msg.parts.length - 1; partIndex >= 0; partIndex--) {
|
|
17254
|
-
const part = msg.parts[partIndex];
|
|
17255
|
-
if (part.type === "tool") {
|
|
17256
|
-
if (part.state.status === "completed") {
|
|
17257
|
-
if (PRUNE_PROTECTED_TOOLS.includes(part.tool)) continue;
|
|
17258
|
-
if (part.state.time.compacted) break loop;
|
|
17259
|
-
const estimate = Token.estimate(part.state.output);
|
|
17260
|
-
total += estimate;
|
|
17261
|
-
if (total > ContextCompaction2.PRUNE_PROTECT) {
|
|
17262
|
-
pruned += estimate;
|
|
17263
|
-
toPrune.push(part);
|
|
17264
|
-
}
|
|
17265
|
-
}
|
|
17266
|
-
}
|
|
17267
|
-
}
|
|
17345
|
+
function getLastStepTokens(context, sessionID) {
|
|
17346
|
+
const parts = context.db.findMany("part", {
|
|
17347
|
+
filter: { op: "eq", field: "session_id", value: sessionID },
|
|
17348
|
+
orderBy: [{ field: "id", direction: "desc" }]
|
|
17349
|
+
});
|
|
17350
|
+
for (const row of parts) {
|
|
17351
|
+
if (row.data?.type === "step-finish" && row.data.tokens) return row.data.tokens;
|
|
17268
17352
|
}
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
|
|
17353
|
+
return void 0;
|
|
17354
|
+
}
|
|
17355
|
+
async function isOverflowForSession(context, sessionID, model) {
|
|
17356
|
+
const tokens = getLastStepTokens(context, sessionID);
|
|
17357
|
+
if (!tokens) return false;
|
|
17358
|
+
return isOverflow({ tokens, model, context });
|
|
17359
|
+
}
|
|
17360
|
+
ContextCompaction2.isOverflowForSession = isOverflowForSession;
|
|
17361
|
+
async function getStatus(context, sessionID) {
|
|
17362
|
+
const msgs = await context.memory.messages({ sessionID });
|
|
17363
|
+
let compactions = 0;
|
|
17364
|
+
for (const msg of msgs) {
|
|
17365
|
+
if (msg.info.role === "assistant" && msg.info.summary) compactions++;
|
|
17366
|
+
}
|
|
17367
|
+
const tokens = getLastStepTokens(context, sessionID);
|
|
17368
|
+
const contextUsed = tokens ? (tokens.input ?? 0) + (tokens.cache?.read ?? 0) + (tokens.cache?.write ?? 0) : 0;
|
|
17369
|
+
let contextLimit = 0;
|
|
17370
|
+
let compactionThreshold = 0;
|
|
17371
|
+
const lastUser = msgs.findLast((m2) => m2.info.role === "user");
|
|
17372
|
+
if (lastUser?.info?.model) {
|
|
17373
|
+
try {
|
|
17374
|
+
const model = await context.provider.getModel(lastUser.info.model.providerID, lastUser.info.model.modelID);
|
|
17375
|
+
({ contextLimit, compactionThreshold } = getLimits(model, context.config));
|
|
17376
|
+
} catch {
|
|
17276
17377
|
}
|
|
17277
|
-
context.log.create({ service: "context.compaction" }).info("pruned", { count: toPrune.length });
|
|
17278
17378
|
}
|
|
17379
|
+
return { contextUsed, contextLimit, compactionThreshold, compactions };
|
|
17279
17380
|
}
|
|
17280
|
-
ContextCompaction2.
|
|
17381
|
+
ContextCompaction2.getStatus = getStatus;
|
|
17281
17382
|
async function process2(context, input) {
|
|
17282
17383
|
const userMessage = input.messages.findLast((m2) => m2.info.id === input.parentID).info;
|
|
17283
17384
|
let messages = input.messages;
|
|
@@ -17313,13 +17414,6 @@ var ContextCompaction;
|
|
|
17313
17414
|
cwd: input.context.directory,
|
|
17314
17415
|
root: input.context.worktree
|
|
17315
17416
|
},
|
|
17316
|
-
cost: 0,
|
|
17317
|
-
tokens: {
|
|
17318
|
-
output: 0,
|
|
17319
|
-
input: 0,
|
|
17320
|
-
reasoning: 0,
|
|
17321
|
-
cache: { read: 0, write: 0 }
|
|
17322
|
-
},
|
|
17323
17417
|
modelID: model.id,
|
|
17324
17418
|
providerID: model.providerID,
|
|
17325
17419
|
time: {
|
|
@@ -17593,10 +17687,33 @@ var CodeAgent = class extends EventEmitter {
|
|
|
17593
17687
|
},
|
|
17594
17688
|
search: this.options.search,
|
|
17595
17689
|
dataPath: this.options.dataPath,
|
|
17596
|
-
configOverrides:
|
|
17690
|
+
configOverrides: {
|
|
17691
|
+
...this.options.config,
|
|
17692
|
+
// Inject cost from CodeAgentProvider into the provider model definition
|
|
17693
|
+
...this.options.provider.cost ? {
|
|
17694
|
+
provider: {
|
|
17695
|
+
...this.options.config?.provider,
|
|
17696
|
+
[this.options.provider.id]: {
|
|
17697
|
+
...this.options.config?.provider?.[this.options.provider.id],
|
|
17698
|
+
models: {
|
|
17699
|
+
...this.options.config?.provider?.[this.options.provider.id]?.models,
|
|
17700
|
+
[this.options.provider.model]: {
|
|
17701
|
+
...this.options.config?.provider?.[this.options.provider.id]?.models?.[this.options.provider.model],
|
|
17702
|
+
cost: {
|
|
17703
|
+
input: this.options.provider.cost.input,
|
|
17704
|
+
output: this.options.provider.cost.output,
|
|
17705
|
+
cache_read: this.options.provider.cost.cacheRead ?? 0,
|
|
17706
|
+
cache_write: this.options.provider.cost.cacheWrite ?? 0
|
|
17707
|
+
}
|
|
17708
|
+
}
|
|
17709
|
+
}
|
|
17710
|
+
}
|
|
17711
|
+
}
|
|
17712
|
+
} : {}
|
|
17713
|
+
},
|
|
17597
17714
|
instructions: this.options.instructions,
|
|
17598
17715
|
db: this._dbClient,
|
|
17599
|
-
|
|
17716
|
+
tools: [...this.options.tools ?? []],
|
|
17600
17717
|
containsPath: (filepath) => {
|
|
17601
17718
|
const normalized = resolve(filepath);
|
|
17602
17719
|
return normalized.startsWith(resolve(worktree)) || normalized.startsWith(resolve(this.options.dataPath));
|
|
@@ -17631,25 +17748,6 @@ var CodeAgent = class extends EventEmitter {
|
|
|
17631
17748
|
ctx.skill = new Skill.SkillService(ctx);
|
|
17632
17749
|
ctx.provider.bind(ctx);
|
|
17633
17750
|
this._context = ctx;
|
|
17634
|
-
if (this.options.tools) {
|
|
17635
|
-
for (const [name2, def] of Object.entries(this.options.tools)) {
|
|
17636
|
-
this._context.toolRegistry.register({
|
|
17637
|
-
id: name2,
|
|
17638
|
-
init: async () => ({
|
|
17639
|
-
parameters: zod_default.object(def.args),
|
|
17640
|
-
description: def.description,
|
|
17641
|
-
execute: async (args2, toolCtx) => {
|
|
17642
|
-
const result = await def.execute(args2, toolCtx);
|
|
17643
|
-
return {
|
|
17644
|
-
title: "",
|
|
17645
|
-
output: typeof result === "string" ? result : JSON.stringify(result),
|
|
17646
|
-
metadata: {}
|
|
17647
|
-
};
|
|
17648
|
-
}
|
|
17649
|
-
})
|
|
17650
|
-
});
|
|
17651
|
-
}
|
|
17652
|
-
}
|
|
17653
17751
|
if (!this._dbClient.findOne("project", { op: "eq", field: "id", value: "global" })) {
|
|
17654
17752
|
this._dbClient.insert("project", {
|
|
17655
17753
|
id: "global",
|
|
@@ -17687,12 +17785,13 @@ var CodeAgent = class extends EventEmitter {
|
|
|
17687
17785
|
/**
|
|
17688
17786
|
* Send a message to the agent and receive streaming responses.
|
|
17689
17787
|
*/
|
|
17690
|
-
async *chat(message) {
|
|
17788
|
+
async *chat(message, options) {
|
|
17691
17789
|
this.assertInitialized();
|
|
17692
17790
|
if (this._chatPromise) {
|
|
17693
17791
|
throw new Error("chat() is already running. Call abort() and await it first.");
|
|
17694
17792
|
}
|
|
17695
17793
|
const sessionId = this._currentSessionId;
|
|
17794
|
+
const chatId = options?.chatId ?? ulid();
|
|
17696
17795
|
const events = [];
|
|
17697
17796
|
let resolve22 = null;
|
|
17698
17797
|
let done = false;
|
|
@@ -17823,6 +17922,7 @@ var CodeAgent = class extends EventEmitter {
|
|
|
17823
17922
|
const modelID = this.options.provider.model;
|
|
17824
17923
|
await this.runLoop({
|
|
17825
17924
|
sessionID: sessionId,
|
|
17925
|
+
chatId,
|
|
17826
17926
|
model: {
|
|
17827
17927
|
providerID,
|
|
17828
17928
|
modelID
|
|
@@ -17856,7 +17956,6 @@ var CodeAgent = class extends EventEmitter {
|
|
|
17856
17956
|
while (!done || events.length > 0) {
|
|
17857
17957
|
if (events.length > 0) {
|
|
17858
17958
|
const event = events.shift();
|
|
17859
|
-
this.recordEvent(event);
|
|
17860
17959
|
yield event;
|
|
17861
17960
|
if (event.type === "done") return;
|
|
17862
17961
|
} else {
|
|
@@ -17892,29 +17991,16 @@ var CodeAgent = class extends EventEmitter {
|
|
|
17892
17991
|
});
|
|
17893
17992
|
}
|
|
17894
17993
|
/**
|
|
17895
|
-
* Register a custom tool at runtime
|
|
17994
|
+
* Register a custom tool at runtime.
|
|
17995
|
+
* Tool must follow the Tool.Info format: { id, init }.
|
|
17896
17996
|
*/
|
|
17897
|
-
async registerTool(
|
|
17997
|
+
async registerTool(tool3) {
|
|
17898
17998
|
if (!this.options.tools) {
|
|
17899
|
-
this.options.tools =
|
|
17999
|
+
this.options.tools = [];
|
|
17900
18000
|
}
|
|
17901
|
-
this.options.tools
|
|
18001
|
+
this.options.tools.push(tool3);
|
|
17902
18002
|
if (this.initialized) {
|
|
17903
|
-
this.agentContext.toolRegistry.register(
|
|
17904
|
-
id: name2,
|
|
17905
|
-
init: async () => ({
|
|
17906
|
-
parameters: zod_default.object(tool3.args),
|
|
17907
|
-
description: tool3.description,
|
|
17908
|
-
execute: async (args2, ctx) => {
|
|
17909
|
-
const result = await tool3.execute(args2, ctx);
|
|
17910
|
-
return {
|
|
17911
|
-
title: "",
|
|
17912
|
-
output: typeof result === "string" ? result : JSON.stringify(result),
|
|
17913
|
-
metadata: {}
|
|
17914
|
-
};
|
|
17915
|
-
}
|
|
17916
|
-
})
|
|
17917
|
-
});
|
|
18003
|
+
this.agentContext.toolRegistry.register(tool3);
|
|
17918
18004
|
}
|
|
17919
18005
|
}
|
|
17920
18006
|
/**
|
|
@@ -17923,42 +18009,49 @@ var CodeAgent = class extends EventEmitter {
|
|
|
17923
18009
|
get config() {
|
|
17924
18010
|
return this.options;
|
|
17925
18011
|
}
|
|
17926
|
-
// ──
|
|
17927
|
-
_stats = {
|
|
17928
|
-
startedAt: Date.now(),
|
|
17929
|
-
totalMessages: 0,
|
|
17930
|
-
totalTokens: { input: 0, output: 0, reasoning: 0 },
|
|
17931
|
-
totalCost: 0,
|
|
17932
|
-
errors: []
|
|
17933
|
-
};
|
|
17934
|
-
/** Record stats from a chat event (called internally) */
|
|
17935
|
-
recordEvent(event) {
|
|
17936
|
-
if (event.type === "message.done" && event.usage) {
|
|
17937
|
-
this._stats.totalMessages++;
|
|
17938
|
-
this._stats.totalTokens.input += event.usage.inputTokens;
|
|
17939
|
-
this._stats.totalTokens.output += event.usage.outputTokens;
|
|
17940
|
-
this._stats.totalTokens.reasoning += event.usage.reasoningTokens;
|
|
17941
|
-
this._stats.totalCost += event.usage.cost;
|
|
17942
|
-
}
|
|
17943
|
-
if (event.type === "error" && event.error) {
|
|
17944
|
-
this._stats.errors.push({ time: Date.now(), message: event.error });
|
|
17945
|
-
if (this._stats.errors.length > 20) this._stats.errors.shift();
|
|
17946
|
-
}
|
|
17947
|
-
}
|
|
17948
|
-
// ── Debug APIs ─────────────────────────────────────────────────
|
|
18012
|
+
// ── Stats ──────────────────────────────────────────────────────
|
|
17949
18013
|
/**
|
|
17950
|
-
* Get
|
|
18014
|
+
* Get usage stats aggregated from step-finish parts in DB.
|
|
17951
18015
|
*/
|
|
17952
|
-
|
|
17953
|
-
const
|
|
18016
|
+
async getUsage() {
|
|
18017
|
+
const totals = { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } };
|
|
18018
|
+
let totalCost = 0;
|
|
18019
|
+
let totalSteps = 0;
|
|
18020
|
+
if (this._currentSessionId) {
|
|
18021
|
+
const parts = this._dbClient.findMany("part", {
|
|
18022
|
+
op: "eq",
|
|
18023
|
+
field: "session_id",
|
|
18024
|
+
value: this._currentSessionId
|
|
18025
|
+
});
|
|
18026
|
+
for (const part of parts) {
|
|
18027
|
+
if (part.data?.type !== "step-finish") continue;
|
|
18028
|
+
totalSteps++;
|
|
18029
|
+
totalCost += part.data.cost ?? 0;
|
|
18030
|
+
const t = part.data.tokens;
|
|
18031
|
+
if (t) {
|
|
18032
|
+
totals.input += t.input ?? 0;
|
|
18033
|
+
totals.output += t.output ?? 0;
|
|
18034
|
+
totals.reasoning += t.reasoning ?? 0;
|
|
18035
|
+
totals.cache.read += t.cache?.read ?? 0;
|
|
18036
|
+
totals.cache.write += t.cache?.write ?? 0;
|
|
18037
|
+
}
|
|
18038
|
+
}
|
|
18039
|
+
}
|
|
17954
18040
|
return {
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
totalCost: this._stats.totalCost,
|
|
17959
|
-
errors: [...this._stats.errors]
|
|
18041
|
+
totalSteps,
|
|
18042
|
+
totalTokens: totals,
|
|
18043
|
+
totalCost
|
|
17960
18044
|
};
|
|
17961
18045
|
}
|
|
18046
|
+
/**
|
|
18047
|
+
* Get current context window status.
|
|
18048
|
+
*/
|
|
18049
|
+
async getContext() {
|
|
18050
|
+
if (!this._currentSessionId) {
|
|
18051
|
+
return { contextUsed: 0, contextLimit: 0, compactionThreshold: 0, compactions: 0 };
|
|
18052
|
+
}
|
|
18053
|
+
return ContextCompaction.getStatus(this.agentContext, this._currentSessionId);
|
|
18054
|
+
}
|
|
17962
18055
|
/**
|
|
17963
18056
|
* Get messages for the current session (for history restoration and admin display).
|
|
17964
18057
|
*/
|
|
@@ -17992,6 +18085,29 @@ var CodeAgent = class extends EventEmitter {
|
|
|
17992
18085
|
}
|
|
17993
18086
|
return messages;
|
|
17994
18087
|
}
|
|
18088
|
+
/**
|
|
18089
|
+
* Clear session messages.
|
|
18090
|
+
* - No args: clear ALL messages for this session
|
|
18091
|
+
* - With chatId: clear only messages created during that specific chat() call
|
|
18092
|
+
*/
|
|
18093
|
+
async clearMessages(chatId) {
|
|
18094
|
+
this.assertInitialized();
|
|
18095
|
+
if (chatId) {
|
|
18096
|
+
await this._context.memory.clearMessagesByChatId(chatId);
|
|
18097
|
+
} else {
|
|
18098
|
+
const sessionId = this._currentSessionId;
|
|
18099
|
+
const rows = this._context.db.findMany("message", { op: "eq", field: "session_id", value: sessionId });
|
|
18100
|
+
for (const row of rows) {
|
|
18101
|
+
this._context.db.remove("message", {
|
|
18102
|
+
op: "and",
|
|
18103
|
+
conditions: [
|
|
18104
|
+
{ op: "eq", field: "id", value: row.id },
|
|
18105
|
+
{ op: "eq", field: "session_id", value: sessionId }
|
|
18106
|
+
]
|
|
18107
|
+
});
|
|
18108
|
+
}
|
|
18109
|
+
}
|
|
18110
|
+
}
|
|
17995
18111
|
/**
|
|
17996
18112
|
* Get current session status (busy/idle/retry).
|
|
17997
18113
|
*/
|
|
@@ -18054,7 +18170,7 @@ var CodeAgent = class extends EventEmitter {
|
|
|
18054
18170
|
if (recentUser && recentAssistant && !recentAssistant.summary) {
|
|
18055
18171
|
const userInfo = recentUser.info;
|
|
18056
18172
|
const model2 = await context.provider.getModel(userInfo.model.providerID, userInfo.model.modelID).catch(() => null);
|
|
18057
|
-
const tokenOverflow = model2 &&
|
|
18173
|
+
const tokenOverflow = model2 && await ContextCompaction.isOverflowForSession(context, sessionID, model2);
|
|
18058
18174
|
if (tokenOverflow || msgs.length > 200) {
|
|
18059
18175
|
const compactResult = await ContextCompaction.process(context, {
|
|
18060
18176
|
messages: msgs,
|
|
@@ -18114,7 +18230,6 @@ var CodeAgent = class extends EventEmitter {
|
|
|
18114
18230
|
if (structuredOutput !== void 0) break;
|
|
18115
18231
|
if (result === "stop") break;
|
|
18116
18232
|
}
|
|
18117
|
-
ContextCompaction.prune(context, { sessionID });
|
|
18118
18233
|
for await (const item of MessageV2.stream(context, sessionID)) {
|
|
18119
18234
|
if (item.info.role === "user") continue;
|
|
18120
18235
|
const queued = context.sessionPrompt.callbacks ?? [];
|
|
@@ -18143,12 +18258,11 @@ var CodeAgent = class extends EventEmitter {
|
|
|
18143
18258
|
agent: "build",
|
|
18144
18259
|
variant: lastUser.variant,
|
|
18145
18260
|
path: { cwd: context.directory, root: context.worktree },
|
|
18146
|
-
cost: 0,
|
|
18147
|
-
tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
|
|
18148
18261
|
modelID: model.id,
|
|
18149
18262
|
providerID: model.providerID,
|
|
18150
18263
|
time: { created: Date.now() },
|
|
18151
|
-
sessionID
|
|
18264
|
+
sessionID,
|
|
18265
|
+
...lastUser.chatId ? { chatId: lastUser.chatId } : {}
|
|
18152
18266
|
}),
|
|
18153
18267
|
sessionID,
|
|
18154
18268
|
model,
|
|
@@ -18267,7 +18381,7 @@ var CodeAgent = class extends EventEmitter {
|
|
|
18267
18381
|
}
|
|
18268
18382
|
};
|
|
18269
18383
|
|
|
18270
|
-
// ../server/dist/chunk-
|
|
18384
|
+
// ../server/dist/chunk-GNHGIOCL.js
|
|
18271
18385
|
import { WebSocketServer, WebSocket as WS } from "ws";
|
|
18272
18386
|
import * as pty from "@lydell/node-pty";
|
|
18273
18387
|
|
|
@@ -19961,7 +20075,7 @@ function watch(paths, options = {}) {
|
|
|
19961
20075
|
return watcher;
|
|
19962
20076
|
}
|
|
19963
20077
|
|
|
19964
|
-
// ../server/dist/chunk-
|
|
20078
|
+
// ../server/dist/chunk-GNHGIOCL.js
|
|
19965
20079
|
var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
19966
20080
|
get: (a3, b) => (typeof __require !== "undefined" ? __require : a3)[b]
|
|
19967
20081
|
}) : x)(function(x) {
|
|
@@ -20164,28 +20278,29 @@ var SetPreviewUrlTool = Tool.define("set_preview_url", async () => {
|
|
|
20164
20278
|
};
|
|
20165
20279
|
});
|
|
20166
20280
|
var AnyCodeAgent = class {
|
|
20167
|
-
name
|
|
20281
|
+
name;
|
|
20168
20282
|
config;
|
|
20169
20283
|
_codeAgent;
|
|
20170
20284
|
_initialized = false;
|
|
20171
20285
|
constructor(config) {
|
|
20172
20286
|
this.config = config;
|
|
20287
|
+
this.name = config.name || "AnyCode Agent";
|
|
20173
20288
|
if (!config.codeAgentOptions) {
|
|
20174
20289
|
throw new Error("AnyCodeAgent requires codeAgentOptions in ChatAgentConfig");
|
|
20175
20290
|
}
|
|
20176
20291
|
this._codeAgent = new CodeAgent(config.codeAgentOptions);
|
|
20177
20292
|
}
|
|
20178
|
-
async
|
|
20293
|
+
async init() {
|
|
20179
20294
|
if (!this._initialized) {
|
|
20180
|
-
await this._codeAgent.init();
|
|
20181
20295
|
this._initialized = true;
|
|
20296
|
+
await this._codeAgent.init();
|
|
20182
20297
|
}
|
|
20183
20298
|
}
|
|
20184
20299
|
get sessionId() {
|
|
20185
20300
|
return this._codeAgent.sessionId;
|
|
20186
20301
|
}
|
|
20187
20302
|
async *chat(input) {
|
|
20188
|
-
await this.
|
|
20303
|
+
await this.init();
|
|
20189
20304
|
yield* this._codeAgent.chat(input);
|
|
20190
20305
|
}
|
|
20191
20306
|
abort() {
|
|
@@ -20197,8 +20312,11 @@ var AnyCodeAgent = class {
|
|
|
20197
20312
|
setWorkingDirectory(dir) {
|
|
20198
20313
|
this._codeAgent.setWorkingDirectory(dir);
|
|
20199
20314
|
}
|
|
20200
|
-
|
|
20201
|
-
return this._codeAgent.
|
|
20315
|
+
async getUsage() {
|
|
20316
|
+
return this._codeAgent.getUsage();
|
|
20317
|
+
}
|
|
20318
|
+
async getContext() {
|
|
20319
|
+
return this._codeAgent.getContext();
|
|
20202
20320
|
}
|
|
20203
20321
|
getSessionMessages(opts) {
|
|
20204
20322
|
return this._codeAgent.getSessionMessages(opts);
|
|
@@ -20325,7 +20443,7 @@ function createAgentConfig(cfg, directory, sessionId, terminal, preview) {
|
|
|
20325
20443
|
...sessionId ? { sessionId } : {},
|
|
20326
20444
|
...terminal ? { terminal } : {},
|
|
20327
20445
|
...preview ? { preview } : {},
|
|
20328
|
-
|
|
20446
|
+
tools: [
|
|
20329
20447
|
SetWorkingDirectoryTool,
|
|
20330
20448
|
TerminalWriteTool,
|
|
20331
20449
|
TerminalReadTool,
|
|
@@ -20432,7 +20550,7 @@ async function createNewWindow(cfg, isDefault = false) {
|
|
|
20432
20550
|
const tp = getOrCreateTerminalProvider(tempId);
|
|
20433
20551
|
const pp = getOrCreatePreviewProvider(cfg, tempId);
|
|
20434
20552
|
const chatAgent = createChatAgent(cfg.agent, createChatAgentConfig(cfg, "", void 0, tp, pp));
|
|
20435
|
-
await chatAgent.
|
|
20553
|
+
await chatAgent.init();
|
|
20436
20554
|
const sessionId = chatAgent.sessionId;
|
|
20437
20555
|
const now = Date.now();
|
|
20438
20556
|
terminalProviders.delete(tempId);
|
|
@@ -21423,12 +21541,12 @@ function createMainServer(cfg) {
|
|
|
21423
21541
|
return;
|
|
21424
21542
|
}
|
|
21425
21543
|
if (req.method === "GET" && req.url === "/api/status") {
|
|
21426
|
-
const list = Array.from(sessions.values()).map((s4) => ({
|
|
21544
|
+
const list = await Promise.all(Array.from(sessions.values()).map(async (s4) => ({
|
|
21427
21545
|
id: s4.id,
|
|
21428
21546
|
directory: s4.directory,
|
|
21429
|
-
stats: s4.chatAgent.
|
|
21547
|
+
stats: await s4.chatAgent.getUsage(),
|
|
21430
21548
|
sessionId: s4.chatAgent.sessionId
|
|
21431
|
-
}));
|
|
21549
|
+
})));
|
|
21432
21550
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
21433
21551
|
res.end(JSON.stringify({ sessions: list }));
|
|
21434
21552
|
return;
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ProviderID,
|
|
6
6
|
Todo,
|
|
7
7
|
iife
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4SPBQLA5.js";
|
|
9
9
|
import {
|
|
10
10
|
Identifier,
|
|
11
11
|
MessageID,
|
|
@@ -17826,7 +17826,7 @@ function canConvert(input) {
|
|
|
17826
17826
|
}
|
|
17827
17827
|
var turndown_es_default = TurndownService;
|
|
17828
17828
|
|
|
17829
|
-
// ../agent/dist/chunk-
|
|
17829
|
+
// ../agent/dist/chunk-MD6BEIK2.js
|
|
17830
17830
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
17831
17831
|
import { pathToFileURL } from "url";
|
|
17832
17832
|
var SchedulerService = class {
|
|
@@ -19199,11 +19199,11 @@ Expected payload format:
|
|
|
19199
19199
|
[{"tool": "tool_name", "parameters": {...}}, {...}]`;
|
|
19200
19200
|
},
|
|
19201
19201
|
async execute(params, ctx) {
|
|
19202
|
-
const { Session } = await import("./session-
|
|
19202
|
+
const { Session } = await import("./session-3H7MDN6G-ILPE3VAH.js");
|
|
19203
19203
|
const { PartID: PartID2 } = await import("./schema-2CACIKZR-3CAWV3IP.js");
|
|
19204
19204
|
const toolCalls = params.tool_calls.slice(0, 25);
|
|
19205
19205
|
const discardedCalls = params.tool_calls.slice(25);
|
|
19206
|
-
const { ToolRegistry: ToolRegistry2 } = await import("./registry-
|
|
19206
|
+
const { ToolRegistry: ToolRegistry2 } = await import("./registry-N6XVTLPC-H2PNFK4G.js");
|
|
19207
19207
|
const availableTools = await ctx.toolRegistry.tools({ modelID: ModelID.make(""), providerID: ProviderID.make("") });
|
|
19208
19208
|
const toolMap = new Map(availableTools.map((t) => [t.id, t]));
|
|
19209
19209
|
const executeCall = async (call) => {
|
|
@@ -21315,7 +21315,7 @@ var ToolRegistry;
|
|
|
21315
21315
|
CodeSearchTool,
|
|
21316
21316
|
SkillTool,
|
|
21317
21317
|
ApplyPatchTool,
|
|
21318
|
-
...context.
|
|
21318
|
+
...context.tools ?? [],
|
|
21319
21319
|
...config.experimental?.batch_tool === true ? [BatchTool] : [],
|
|
21320
21320
|
...Flag.OPENCODE_EXPERIMENTAL_PLAN_MODE && Flag.OPENCODE_CLIENT === "cli" ? [PlanExitTool] : [],
|
|
21321
21321
|
...custom
|
|
@@ -165,7 +165,7 @@ var require_dist = __commonJS({
|
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
// ../agent/dist/chunk-
|
|
168
|
+
// ../agent/dist/chunk-QSYBKVFM.js
|
|
169
169
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
170
170
|
|
|
171
171
|
// ../../node_modules/.pnpm/decimal.js@10.5.0/node_modules/decimal.js/decimal.mjs
|
|
@@ -2344,7 +2344,7 @@ var Decimal = P.constructor = clone(DEFAULTS);
|
|
|
2344
2344
|
LN10 = new Decimal(LN10);
|
|
2345
2345
|
PI = new Decimal(PI);
|
|
2346
2346
|
|
|
2347
|
-
// ../agent/dist/chunk-
|
|
2347
|
+
// ../agent/dist/chunk-QSYBKVFM.js
|
|
2348
2348
|
import { EventEmitter } from "events";
|
|
2349
2349
|
|
|
2350
2350
|
// ../../node_modules/.pnpm/@ai-sdk+provider@2.0.1/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
@@ -15661,7 +15661,7 @@ var uiMessagesSchema = lazyValidator(
|
|
|
15661
15661
|
)
|
|
15662
15662
|
);
|
|
15663
15663
|
|
|
15664
|
-
// ../agent/dist/chunk-
|
|
15664
|
+
// ../agent/dist/chunk-QSYBKVFM.js
|
|
15665
15665
|
import { STATUS_CODES } from "http";
|
|
15666
15666
|
var Slug;
|
|
15667
15667
|
((Slug2) => {
|
|
@@ -16277,7 +16277,7 @@ var MessageV2;
|
|
|
16277
16277
|
root: zod_default.string()
|
|
16278
16278
|
}),
|
|
16279
16279
|
summary: zod_default.boolean().optional(),
|
|
16280
|
-
cost: zod_default.number(),
|
|
16280
|
+
cost: zod_default.number().optional(),
|
|
16281
16281
|
tokens: zod_default.object({
|
|
16282
16282
|
total: zod_default.number().optional(),
|
|
16283
16283
|
input: zod_default.number(),
|
|
@@ -16287,7 +16287,7 @@ var MessageV2;
|
|
|
16287
16287
|
read: zod_default.number(),
|
|
16288
16288
|
write: zod_default.number()
|
|
16289
16289
|
})
|
|
16290
|
-
}),
|
|
16290
|
+
}).optional(),
|
|
16291
16291
|
structured: zod_default.any().optional(),
|
|
16292
16292
|
variant: zod_default.string().optional(),
|
|
16293
16293
|
finish: zod_default.string().optional()
|
|
@@ -16774,6 +16774,24 @@ var MemoryService = class extends EventEmitter {
|
|
|
16774
16774
|
result.reverse();
|
|
16775
16775
|
return result;
|
|
16776
16776
|
}
|
|
16777
|
+
/**
|
|
16778
|
+
* Remove all messages tagged with a specific chatId.
|
|
16779
|
+
* Queries from DB so this works even after process restart.
|
|
16780
|
+
*/
|
|
16781
|
+
async clearMessagesByChatId(chatId) {
|
|
16782
|
+
const rows = this.context.db.findMany("message", {});
|
|
16783
|
+
for (const row of rows) {
|
|
16784
|
+
if (row.data?.chatId === chatId) {
|
|
16785
|
+
this.context.db.remove("message", {
|
|
16786
|
+
op: "and",
|
|
16787
|
+
conditions: [
|
|
16788
|
+
{ op: "eq", field: "id", value: row.id },
|
|
16789
|
+
{ op: "eq", field: "session_id", value: row.session_id }
|
|
16790
|
+
]
|
|
16791
|
+
});
|
|
16792
|
+
}
|
|
16793
|
+
}
|
|
16794
|
+
}
|
|
16777
16795
|
};
|
|
16778
16796
|
var Memory;
|
|
16779
16797
|
((Memory2) => {
|
|
@@ -17209,7 +17227,6 @@ export {
|
|
|
17209
17227
|
Installation,
|
|
17210
17228
|
iife,
|
|
17211
17229
|
defer,
|
|
17212
|
-
Token,
|
|
17213
17230
|
ProviderID,
|
|
17214
17231
|
ModelID,
|
|
17215
17232
|
MessageV2,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ToolRegistry
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-2X6YJUFL.js";
|
|
5
|
+
import "./chunk-4SPBQLA5.js";
|
|
6
6
|
import "./chunk-DU4BGORD.js";
|
|
7
7
|
import "./chunk-6Q6QFZOB.js";
|
|
8
8
|
import "./chunk-NRFXEZ7N.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anycodex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"@types/node": "^25.5.0",
|
|
19
19
|
"tsup": "^8.4.0",
|
|
20
20
|
"typescript": "^5.7.0",
|
|
21
|
-
"@any-code/server": "0.0.
|
|
22
|
-
"@any-code/app": "0.0.
|
|
21
|
+
"@any-code/server": "0.0.7",
|
|
22
|
+
"@any-code/app": "0.0.3"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsup"
|