duclaw-cli 2.0.0 → 3.0.0
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/agent/coreHooks.d.ts +38 -0
- package/dist/agent/coreHooks.d.ts.map +1 -0
- package/dist/agent/createAgentCore.d.ts.map +1 -1
- package/dist/agent/duclawAgentConfig.d.ts.map +1 -1
- package/dist/agent/duclawCoreHooks.d.ts +5 -0
- package/dist/agent/duclawCoreHooks.d.ts.map +1 -0
- package/dist/agent/types.d.ts +2 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/bundle.js +1246 -1190
- package/dist/files/fileType.d.ts +2 -0
- package/dist/files/fileType.d.ts.map +1 -0
- package/dist/main.js +1 -1
- package/dist/sdk/core.d.ts +40 -0
- package/dist/sdk/core.d.ts.map +1 -0
- package/dist/sdk/core.js +40900 -0
- package/dist/sdk/createSdkAgent.d.ts +5 -0
- package/dist/sdk/createSdkAgent.d.ts.map +1 -0
- package/dist/sdk/duclaw.d.ts +15 -0
- package/dist/sdk/duclaw.d.ts.map +1 -1
- package/dist/sdk/duclaw.js +899 -488
- package/dist/sdk/duclawPreset.d.ts +21 -0
- package/dist/sdk/duclawPreset.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +7 -24
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +6411 -40161
- package/dist/sdk/models/anthropic.d.ts +2 -0
- package/dist/sdk/models/anthropic.d.ts.map +1 -0
- package/dist/sdk/publicTypes.d.ts +33 -0
- package/dist/sdk/publicTypes.d.ts.map +1 -0
- package/dist/sdk/storage/memoryStorage.d.ts +3 -0
- package/dist/sdk/storage/memoryStorage.d.ts.map +1 -0
- package/dist/sdk/tool.d.ts +12 -0
- package/dist/sdk/tool.d.ts.map +1 -0
- package/dist/tools/Tool.d.ts +13 -7
- package/dist/tools/Tool.d.ts.map +1 -1
- package/dist/tools/tools/SendFile.d.ts +1 -1
- package/dist/tools/tools/SendFile.d.ts.map +1 -1
- package/dist/types/context.d.ts +1 -1
- package/dist/types/context.d.ts.map +1 -1
- package/dist/worker-main.js +1 -1
- package/package.json +11 -2
package/dist/sdk/duclaw.js
CHANGED
|
@@ -30129,39 +30129,39 @@ var require_timezone = __commonJS({
|
|
|
30129
30129
|
}
|
|
30130
30130
|
});
|
|
30131
30131
|
|
|
30132
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30132
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/max.js
|
|
30133
30133
|
var init_max = __esm({
|
|
30134
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30134
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/max.js"() {
|
|
30135
30135
|
}
|
|
30136
30136
|
});
|
|
30137
30137
|
|
|
30138
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30138
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/nil.js
|
|
30139
30139
|
var init_nil = __esm({
|
|
30140
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30140
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/nil.js"() {
|
|
30141
30141
|
}
|
|
30142
30142
|
});
|
|
30143
30143
|
|
|
30144
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30144
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/regex.js
|
|
30145
30145
|
var regex_default;
|
|
30146
30146
|
var init_regex = __esm({
|
|
30147
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30147
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/regex.js"() {
|
|
30148
30148
|
regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
30149
30149
|
}
|
|
30150
30150
|
});
|
|
30151
30151
|
|
|
30152
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30152
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/validate.js
|
|
30153
30153
|
function validate(uuid) {
|
|
30154
30154
|
return typeof uuid === "string" && regex_default.test(uuid);
|
|
30155
30155
|
}
|
|
30156
30156
|
var validate_default;
|
|
30157
30157
|
var init_validate = __esm({
|
|
30158
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30158
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/validate.js"() {
|
|
30159
30159
|
init_regex();
|
|
30160
30160
|
validate_default = validate;
|
|
30161
30161
|
}
|
|
30162
30162
|
});
|
|
30163
30163
|
|
|
30164
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30164
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/parse.js
|
|
30165
30165
|
function parse(uuid) {
|
|
30166
30166
|
if (!validate_default(uuid)) {
|
|
30167
30167
|
throw TypeError("Invalid UUID");
|
|
@@ -30193,19 +30193,19 @@ function parse(uuid) {
|
|
|
30193
30193
|
}
|
|
30194
30194
|
var parse_default;
|
|
30195
30195
|
var init_parse = __esm({
|
|
30196
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30196
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/parse.js"() {
|
|
30197
30197
|
init_validate();
|
|
30198
30198
|
parse_default = parse;
|
|
30199
30199
|
}
|
|
30200
30200
|
});
|
|
30201
30201
|
|
|
30202
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30202
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/stringify.js
|
|
30203
30203
|
function unsafeStringify(arr2, offset = 0) {
|
|
30204
30204
|
return (byteToHex[arr2[offset + 0]] + byteToHex[arr2[offset + 1]] + byteToHex[arr2[offset + 2]] + byteToHex[arr2[offset + 3]] + "-" + byteToHex[arr2[offset + 4]] + byteToHex[arr2[offset + 5]] + "-" + byteToHex[arr2[offset + 6]] + byteToHex[arr2[offset + 7]] + "-" + byteToHex[arr2[offset + 8]] + byteToHex[arr2[offset + 9]] + "-" + byteToHex[arr2[offset + 10]] + byteToHex[arr2[offset + 11]] + byteToHex[arr2[offset + 12]] + byteToHex[arr2[offset + 13]] + byteToHex[arr2[offset + 14]] + byteToHex[arr2[offset + 15]]).toLowerCase();
|
|
30205
30205
|
}
|
|
30206
30206
|
var byteToHex;
|
|
30207
30207
|
var init_stringify = __esm({
|
|
30208
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30208
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/stringify.js"() {
|
|
30209
30209
|
init_validate();
|
|
30210
30210
|
byteToHex = [];
|
|
30211
30211
|
for (let i = 0; i < 256; ++i) {
|
|
@@ -30214,18 +30214,18 @@ var init_stringify = __esm({
|
|
|
30214
30214
|
}
|
|
30215
30215
|
});
|
|
30216
30216
|
|
|
30217
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30217
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/rng.js
|
|
30218
30218
|
function rng() {
|
|
30219
30219
|
return crypto.getRandomValues(rnds8);
|
|
30220
30220
|
}
|
|
30221
30221
|
var rnds8;
|
|
30222
30222
|
var init_rng = __esm({
|
|
30223
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30223
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/rng.js"() {
|
|
30224
30224
|
rnds8 = new Uint8Array(16);
|
|
30225
30225
|
}
|
|
30226
30226
|
});
|
|
30227
30227
|
|
|
30228
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30228
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/v4.js
|
|
30229
30229
|
function v4(options, buf, offset) {
|
|
30230
30230
|
if (!buf && !options && crypto.randomUUID) {
|
|
30231
30231
|
return crypto.randomUUID();
|
|
@@ -30254,14 +30254,14 @@ function _v4(options, buf, offset) {
|
|
|
30254
30254
|
}
|
|
30255
30255
|
var v4_default;
|
|
30256
30256
|
var init_v4 = __esm({
|
|
30257
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30257
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/v4.js"() {
|
|
30258
30258
|
init_rng();
|
|
30259
30259
|
init_stringify();
|
|
30260
30260
|
v4_default = v4;
|
|
30261
30261
|
}
|
|
30262
30262
|
});
|
|
30263
30263
|
|
|
30264
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30264
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/sha1.js
|
|
30265
30265
|
function f(s, x, y, z) {
|
|
30266
30266
|
switch (s) {
|
|
30267
30267
|
case 0:
|
|
@@ -30329,12 +30329,12 @@ function sha1(bytes) {
|
|
|
30329
30329
|
}
|
|
30330
30330
|
var sha1_default;
|
|
30331
30331
|
var init_sha1 = __esm({
|
|
30332
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30332
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/sha1.js"() {
|
|
30333
30333
|
sha1_default = sha1;
|
|
30334
30334
|
}
|
|
30335
30335
|
});
|
|
30336
30336
|
|
|
30337
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30337
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/v35.js
|
|
30338
30338
|
function stringToBytes(str) {
|
|
30339
30339
|
str = unescape(encodeURIComponent(str));
|
|
30340
30340
|
const bytes = new Uint8Array(str.length);
|
|
@@ -30372,7 +30372,7 @@ function v35(version, hash, value, namespace, buf, offset) {
|
|
|
30372
30372
|
}
|
|
30373
30373
|
var DNS, URL2;
|
|
30374
30374
|
var init_v35 = __esm({
|
|
30375
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30375
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/v35.js"() {
|
|
30376
30376
|
init_parse();
|
|
30377
30377
|
init_stringify();
|
|
30378
30378
|
DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
@@ -30380,13 +30380,13 @@ var init_v35 = __esm({
|
|
|
30380
30380
|
}
|
|
30381
30381
|
});
|
|
30382
30382
|
|
|
30383
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30383
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/v5.js
|
|
30384
30384
|
function v5(value, namespace, buf, offset) {
|
|
30385
30385
|
return v35(80, sha1_default, value, namespace, buf, offset);
|
|
30386
30386
|
}
|
|
30387
30387
|
var v5_default;
|
|
30388
30388
|
var init_v5 = __esm({
|
|
30389
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30389
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/v5.js"() {
|
|
30390
30390
|
init_sha1();
|
|
30391
30391
|
init_v35();
|
|
30392
30392
|
init_v35();
|
|
@@ -30396,7 +30396,7 @@ var init_v5 = __esm({
|
|
|
30396
30396
|
}
|
|
30397
30397
|
});
|
|
30398
30398
|
|
|
30399
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30399
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/v7.js
|
|
30400
30400
|
function v7(options, buf, offset) {
|
|
30401
30401
|
let bytes;
|
|
30402
30402
|
if (options) {
|
|
@@ -30457,7 +30457,7 @@ function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
|
|
|
30457
30457
|
}
|
|
30458
30458
|
var _state, v7_default;
|
|
30459
30459
|
var init_v7 = __esm({
|
|
30460
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30460
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/v7.js"() {
|
|
30461
30461
|
init_rng();
|
|
30462
30462
|
init_stringify();
|
|
30463
30463
|
_state = {};
|
|
@@ -30465,16 +30465,16 @@ var init_v7 = __esm({
|
|
|
30465
30465
|
}
|
|
30466
30466
|
});
|
|
30467
30467
|
|
|
30468
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30468
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/version.js
|
|
30469
30469
|
var init_version = __esm({
|
|
30470
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30470
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/version.js"() {
|
|
30471
30471
|
init_validate();
|
|
30472
30472
|
}
|
|
30473
30473
|
});
|
|
30474
30474
|
|
|
30475
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30475
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/index.js
|
|
30476
30476
|
var init_src = __esm({
|
|
30477
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30477
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/uuid/src/index.js"() {
|
|
30478
30478
|
init_max();
|
|
30479
30479
|
init_nil();
|
|
30480
30480
|
init_parse();
|
|
@@ -30487,10 +30487,10 @@ var init_src = __esm({
|
|
|
30487
30487
|
}
|
|
30488
30488
|
});
|
|
30489
30489
|
|
|
30490
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30490
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/experimental/otel/constants.js
|
|
30491
30491
|
var GEN_AI_OPERATION_NAME, GEN_AI_SYSTEM, GEN_AI_REQUEST_MODEL, GEN_AI_RESPONSE_MODEL, GEN_AI_USAGE_INPUT_TOKENS, GEN_AI_USAGE_OUTPUT_TOKENS, GEN_AI_USAGE_TOTAL_TOKENS, GEN_AI_REQUEST_MAX_TOKENS, GEN_AI_REQUEST_TEMPERATURE, GEN_AI_REQUEST_TOP_P, GEN_AI_REQUEST_FREQUENCY_PENALTY, GEN_AI_REQUEST_PRESENCE_PENALTY, GEN_AI_RESPONSE_FINISH_REASONS, GENAI_PROMPT, GENAI_COMPLETION, GEN_AI_REQUEST_EXTRA_QUERY, GEN_AI_REQUEST_EXTRA_BODY, GEN_AI_SERIALIZED_NAME, GEN_AI_SERIALIZED_SIGNATURE, GEN_AI_SERIALIZED_DOC, GEN_AI_RESPONSE_ID, GEN_AI_RESPONSE_SERVICE_TIER, GEN_AI_RESPONSE_SYSTEM_FINGERPRINT, GEN_AI_USAGE_INPUT_TOKEN_DETAILS, GEN_AI_USAGE_OUTPUT_TOKEN_DETAILS, LANGSMITH_SESSION_ID, LANGSMITH_SESSION_NAME, LANGSMITH_RUN_TYPE, LANGSMITH_NAME, LANGSMITH_METADATA, LANGSMITH_TAGS, LANGSMITH_REQUEST_STREAMING, LANGSMITH_REQUEST_HEADERS, LANGSMITH_USAGE_METADATA;
|
|
30492
30492
|
var init_constants = __esm({
|
|
30493
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30493
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/experimental/otel/constants.js"() {
|
|
30494
30494
|
GEN_AI_OPERATION_NAME = "gen_ai.operation.name";
|
|
30495
30495
|
GEN_AI_SYSTEM = "gen_ai.system";
|
|
30496
30496
|
GEN_AI_REQUEST_MODEL = "gen_ai.request.model";
|
|
@@ -30528,7 +30528,7 @@ var init_constants = __esm({
|
|
|
30528
30528
|
}
|
|
30529
30529
|
});
|
|
30530
30530
|
|
|
30531
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30531
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/env.js
|
|
30532
30532
|
function getRuntimeEnvironment() {
|
|
30533
30533
|
if (runtimeEnvironment === void 0) {
|
|
30534
30534
|
const env = getEnv();
|
|
@@ -30661,7 +30661,7 @@ function resolveTracingMode(configValue) {
|
|
|
30661
30661
|
}
|
|
30662
30662
|
var globalEnv, isBrowser, isWebWorker, isJsDom, isDeno, isNode, getEnv, runtimeEnvironment, cachedCommitSHAs, _VALID_TRACING_MODES;
|
|
30663
30663
|
var init_env = __esm({
|
|
30664
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30664
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/env.js"() {
|
|
30665
30665
|
init_dist();
|
|
30666
30666
|
isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
30667
30667
|
isWebWorker = () => typeof globalThis === "object" && globalThis.constructor && globalThis.constructor.name === "DedicatedWorkerGlobalScope";
|
|
@@ -30693,7 +30693,7 @@ var init_env = __esm({
|
|
|
30693
30693
|
}
|
|
30694
30694
|
});
|
|
30695
30695
|
|
|
30696
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30696
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/singletons/otel.js
|
|
30697
30697
|
function getOTELTrace() {
|
|
30698
30698
|
return OTELProviderSingleton.getTraceInstance();
|
|
30699
30699
|
}
|
|
@@ -30705,7 +30705,7 @@ function getDefaultOTLPTracerComponents() {
|
|
|
30705
30705
|
}
|
|
30706
30706
|
var MockTracer, MockOTELTrace, MockOTELContext, OTEL_TRACE_KEY, OTEL_CONTEXT_KEY, OTEL_GET_DEFAULT_OTLP_TRACER_PROVIDER_KEY, mockOTELTrace, mockOTELContext, OTELProvider, OTELProviderSingleton;
|
|
30707
30707
|
var init_otel = __esm({
|
|
30708
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30708
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/singletons/otel.js"() {
|
|
30709
30709
|
init_env();
|
|
30710
30710
|
MockTracer = class {
|
|
30711
30711
|
constructor() {
|
|
@@ -30805,7 +30805,7 @@ var init_otel = __esm({
|
|
|
30805
30805
|
}
|
|
30806
30806
|
});
|
|
30807
30807
|
|
|
30808
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30808
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/experimental/otel/translator.js
|
|
30809
30809
|
function getOperationName(runType) {
|
|
30810
30810
|
return WELL_KNOWN_OPERATION_NAMES[runType] || runType;
|
|
30811
30811
|
}
|
|
@@ -30814,7 +30814,7 @@ function isPrimitive(value) {
|
|
|
30814
30814
|
}
|
|
30815
30815
|
var WELL_KNOWN_OPERATION_NAMES, LangSmithToOTELTranslator;
|
|
30816
30816
|
var init_translator = __esm({
|
|
30817
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
30817
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/experimental/otel/translator.js"() {
|
|
30818
30818
|
init_constants();
|
|
30819
30819
|
init_otel();
|
|
30820
30820
|
WELL_KNOWN_OPERATION_NAMES = {
|
|
@@ -31160,7 +31160,7 @@ var init_translator = __esm({
|
|
|
31160
31160
|
}
|
|
31161
31161
|
});
|
|
31162
31162
|
|
|
31163
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
31163
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/is-network-error/index.js
|
|
31164
31164
|
function isNetworkError(error) {
|
|
31165
31165
|
const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
|
|
31166
31166
|
if (!isValid) {
|
|
@@ -31178,7 +31178,7 @@ function isNetworkError(error) {
|
|
|
31178
31178
|
}
|
|
31179
31179
|
var objectToString, isError, errorMessages;
|
|
31180
31180
|
var init_is_network_error = __esm({
|
|
31181
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
31181
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/is-network-error/index.js"() {
|
|
31182
31182
|
objectToString = Object.prototype.toString;
|
|
31183
31183
|
isError = (value) => objectToString.call(value) === "[object Error]";
|
|
31184
31184
|
errorMessages = /* @__PURE__ */ new Set([
|
|
@@ -31204,7 +31204,7 @@ var init_is_network_error = __esm({
|
|
|
31204
31204
|
}
|
|
31205
31205
|
});
|
|
31206
31206
|
|
|
31207
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
31207
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/p-retry/index.js
|
|
31208
31208
|
function validateRetries(retries) {
|
|
31209
31209
|
if (typeof retries === "number") {
|
|
31210
31210
|
if (retries < 0) {
|
|
@@ -31364,7 +31364,7 @@ async function pRetry(input, options = {}) {
|
|
|
31364
31364
|
}
|
|
31365
31365
|
var AbortError;
|
|
31366
31366
|
var init_p_retry = __esm({
|
|
31367
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
31367
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/p-retry/index.js"() {
|
|
31368
31368
|
init_is_network_error();
|
|
31369
31369
|
AbortError = class extends Error {
|
|
31370
31370
|
constructor(message) {
|
|
@@ -31948,19 +31948,19 @@ var require_dist3 = __commonJS({
|
|
|
31948
31948
|
}
|
|
31949
31949
|
});
|
|
31950
31950
|
|
|
31951
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
31951
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/p-queue.js
|
|
31952
31952
|
var import_p_queue, PQueue;
|
|
31953
31953
|
var init_p_queue = __esm({
|
|
31954
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
31954
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/p-queue.js"() {
|
|
31955
31955
|
import_p_queue = __toESM(require_dist3(), 1);
|
|
31956
31956
|
PQueue = "default" in import_p_queue.default ? import_p_queue.default.default : import_p_queue.default;
|
|
31957
31957
|
}
|
|
31958
31958
|
});
|
|
31959
31959
|
|
|
31960
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
31960
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/async_caller.js
|
|
31961
31961
|
var STATUS_RETRYABLE, AsyncCaller;
|
|
31962
31962
|
var init_async_caller = __esm({
|
|
31963
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
31963
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/async_caller.js"() {
|
|
31964
31964
|
init_p_retry();
|
|
31965
31965
|
init_p_queue();
|
|
31966
31966
|
STATUS_RETRYABLE = [
|
|
@@ -32092,7 +32092,7 @@ var init_async_caller = __esm({
|
|
|
32092
32092
|
}
|
|
32093
32093
|
});
|
|
32094
32094
|
|
|
32095
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32095
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/messages.js
|
|
32096
32096
|
function isLangChainMessage(message) {
|
|
32097
32097
|
return typeof message?._getType === "function";
|
|
32098
32098
|
}
|
|
@@ -32107,11 +32107,11 @@ function convertLangChainMessageToExample(message) {
|
|
|
32107
32107
|
return converted;
|
|
32108
32108
|
}
|
|
32109
32109
|
var init_messages = __esm({
|
|
32110
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32110
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/messages.js"() {
|
|
32111
32111
|
}
|
|
32112
32112
|
});
|
|
32113
32113
|
|
|
32114
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32114
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/warn.js
|
|
32115
32115
|
function warnOnce(message) {
|
|
32116
32116
|
if (!warnedMessages[message]) {
|
|
32117
32117
|
console.warn(message);
|
|
@@ -32120,12 +32120,12 @@ function warnOnce(message) {
|
|
|
32120
32120
|
}
|
|
32121
32121
|
var warnedMessages;
|
|
32122
32122
|
var init_warn = __esm({
|
|
32123
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32123
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/warn.js"() {
|
|
32124
32124
|
warnedMessages = {};
|
|
32125
32125
|
}
|
|
32126
32126
|
});
|
|
32127
32127
|
|
|
32128
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32128
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/xxhash/xxhash.js
|
|
32129
32129
|
function hexToBytes(hex) {
|
|
32130
32130
|
const bytes = new Uint8Array(hex.length / 2);
|
|
32131
32131
|
for (let i = 0; i < hex.length; i += 2) {
|
|
@@ -32374,7 +32374,7 @@ function xxh128ToBytes(hash128) {
|
|
|
32374
32374
|
}
|
|
32375
32375
|
var n, PRIME32_1, PRIME32_2, PRIME32_3, PRIME64_1, PRIME64_2, PRIME64_3, PRIME64_4, PRIME64_5, PRIME_MX1, PRIME_MX2, kkey, mask128, mask64, mask32, STRIPE_LEN, ACC_NB, _U64, _U32, bswap64, bswap32, XXH_mult32to64, assert;
|
|
32376
32376
|
var init_xxhash = __esm({
|
|
32377
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32377
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/xxhash/xxhash.js"() {
|
|
32378
32378
|
n = (n2) => BigInt(n2);
|
|
32379
32379
|
PRIME32_1 = n("0x9E3779B1");
|
|
32380
32380
|
PRIME32_2 = n("0x85EBCA77");
|
|
@@ -32410,7 +32410,7 @@ var init_xxhash = __esm({
|
|
|
32410
32410
|
}
|
|
32411
32411
|
});
|
|
32412
32412
|
|
|
32413
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32413
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/_uuid.js
|
|
32414
32414
|
function assertUuid(str, which) {
|
|
32415
32415
|
if (!UUID_REGEX.test(str)) {
|
|
32416
32416
|
const msg = which !== void 0 ? `Invalid UUID for ${which}: ${str}` : `Invalid UUID: ${str}`;
|
|
@@ -32471,7 +32471,7 @@ function nonCryptographicUuid7Deterministic(originalId, key) {
|
|
|
32471
32471
|
}
|
|
32472
32472
|
var UUID_REGEX, _textEncoder;
|
|
32473
32473
|
var init_uuid = __esm({
|
|
32474
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32474
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/_uuid.js"() {
|
|
32475
32475
|
init_src();
|
|
32476
32476
|
init_warn();
|
|
32477
32477
|
init_xxhash();
|
|
@@ -32480,7 +32480,7 @@ var init_uuid = __esm({
|
|
|
32480
32480
|
}
|
|
32481
32481
|
});
|
|
32482
32482
|
|
|
32483
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32483
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/error.js
|
|
32484
32484
|
function getInvalidPromptIdentifierMsg(identifier) {
|
|
32485
32485
|
return `Invalid prompt identifier format: "${identifier}". Expected one of:
|
|
32486
32486
|
- "prompt-name" (for private prompts)
|
|
@@ -32538,7 +32538,7 @@ function isConflictingEndpointsError(err) {
|
|
|
32538
32538
|
}
|
|
32539
32539
|
var LangSmithConflictError, LangSmithNotFoundError, ERR_CONFLICTING_ENDPOINTS, ConflictingEndpointsError;
|
|
32540
32540
|
var init_error = __esm({
|
|
32541
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32541
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/error.js"() {
|
|
32542
32542
|
LangSmithConflictError = class extends Error {
|
|
32543
32543
|
constructor(message) {
|
|
32544
32544
|
super(message);
|
|
@@ -32581,7 +32581,7 @@ var init_error = __esm({
|
|
|
32581
32581
|
}
|
|
32582
32582
|
});
|
|
32583
32583
|
|
|
32584
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32584
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/prompts.js
|
|
32585
32585
|
function parseHubIdentifier(identifier) {
|
|
32586
32586
|
if (!identifier || identifier.split("/").length > 2 || identifier.startsWith("/") || identifier.endsWith("/") || identifier.split(":").length > 2) {
|
|
32587
32587
|
throw new Error(getInvalidPromptIdentifierMsg(identifier));
|
|
@@ -32602,12 +32602,12 @@ function parseHubIdentifier(identifier) {
|
|
|
32602
32602
|
}
|
|
32603
32603
|
}
|
|
32604
32604
|
var init_prompts = __esm({
|
|
32605
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32605
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/prompts.js"() {
|
|
32606
32606
|
init_error();
|
|
32607
32607
|
}
|
|
32608
32608
|
});
|
|
32609
32609
|
|
|
32610
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32610
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/fs.js
|
|
32611
32611
|
async function mkdir7(dir) {
|
|
32612
32612
|
await nodeFsPromises.mkdir(dir, { recursive: true });
|
|
32613
32613
|
}
|
|
@@ -32658,7 +32658,7 @@ async function rmRecursive(filePath) {
|
|
|
32658
32658
|
}
|
|
32659
32659
|
var nodeFs, nodeFsPromises, nodePath, path17;
|
|
32660
32660
|
var init_fs = __esm({
|
|
32661
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32661
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/fs.js"() {
|
|
32662
32662
|
nodeFs = __toESM(require("node:fs"), 1);
|
|
32663
32663
|
nodeFsPromises = __toESM(require("node:fs/promises"), 1);
|
|
32664
32664
|
nodePath = __toESM(require("node:path"), 1);
|
|
@@ -32666,7 +32666,7 @@ var init_fs = __esm({
|
|
|
32666
32666
|
}
|
|
32667
32667
|
});
|
|
32668
32668
|
|
|
32669
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32669
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/prompt_cache/index.js
|
|
32670
32670
|
function isStale(entry, ttlSeconds) {
|
|
32671
32671
|
if (ttlSeconds === null) {
|
|
32672
32672
|
return false;
|
|
@@ -32679,7 +32679,7 @@ function configureGlobalPromptCache(config2) {
|
|
|
32679
32679
|
}
|
|
32680
32680
|
var PromptCache, promptCacheSingleton, Cache;
|
|
32681
32681
|
var init_prompt_cache = __esm({
|
|
32682
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32682
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/prompt_cache/index.js"() {
|
|
32683
32683
|
init_fs();
|
|
32684
32684
|
PromptCache = class {
|
|
32685
32685
|
constructor(config2 = {}) {
|
|
@@ -32955,10 +32955,10 @@ var init_prompt_cache = __esm({
|
|
|
32955
32955
|
}
|
|
32956
32956
|
});
|
|
32957
32957
|
|
|
32958
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32958
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/singletons/fetch.js
|
|
32959
32959
|
var DEFAULT_FETCH_IMPLEMENTATION, globalFetchSupportsWebStreaming, LANGSMITH_FETCH_IMPLEMENTATION_KEY, overrideFetchImplementation, _shouldStreamForGlobalFetchImplementation, _getFetchImplementation;
|
|
32960
32960
|
var init_fetch = __esm({
|
|
32961
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32961
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/singletons/fetch.js"() {
|
|
32962
32962
|
init_env();
|
|
32963
32963
|
DEFAULT_FETCH_IMPLEMENTATION = (...args) => fetch(...args);
|
|
32964
32964
|
globalFetchSupportsWebStreaming = void 0;
|
|
@@ -32990,7 +32990,7 @@ var init_fetch = __esm({
|
|
|
32990
32990
|
}
|
|
32991
32991
|
});
|
|
32992
32992
|
|
|
32993
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
32993
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/profile-lock.js
|
|
32994
32994
|
function sleep3(ms) {
|
|
32995
32995
|
return new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
32996
32996
|
}
|
|
@@ -33071,7 +33071,7 @@ ${owner}
|
|
|
33071
33071
|
}
|
|
33072
33072
|
var LOCK_POLL_INTERVAL_MS, LOCK_STALE_AFTER_MS, LOCK_METADATA_FILE;
|
|
33073
33073
|
var init_profile_lock = __esm({
|
|
33074
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33074
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/profile-lock.js"() {
|
|
33075
33075
|
init_fs();
|
|
33076
33076
|
LOCK_POLL_INTERVAL_MS = 10;
|
|
33077
33077
|
LOCK_STALE_AFTER_MS = 1e4;
|
|
@@ -33079,7 +33079,7 @@ var init_profile_lock = __esm({
|
|
|
33079
33079
|
}
|
|
33080
33080
|
});
|
|
33081
33081
|
|
|
33082
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33082
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/profiles.js
|
|
33083
33083
|
function isBrowserLikeRuntime() {
|
|
33084
33084
|
const env = getEnv();
|
|
33085
33085
|
return env === "browser" || env === "webworker";
|
|
@@ -33238,7 +33238,7 @@ function authHeaderFromProfile(profile) {
|
|
|
33238
33238
|
}
|
|
33239
33239
|
var DEFAULT_API_URL, OAUTH_CLIENT_ID, TOKEN_REFRESH_LEEWAY_MS, TOKEN_REFRESH_TIMEOUT_MS, ProfileAuth;
|
|
33240
33240
|
var init_profiles = __esm({
|
|
33241
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33241
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/profiles.js"() {
|
|
33242
33242
|
init_env();
|
|
33243
33243
|
init_fs();
|
|
33244
33244
|
init_profile_lock();
|
|
@@ -33355,7 +33355,7 @@ var init_profiles = __esm({
|
|
|
33355
33355
|
}
|
|
33356
33356
|
});
|
|
33357
33357
|
|
|
33358
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33358
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js
|
|
33359
33359
|
function defaultOptions() {
|
|
33360
33360
|
return {
|
|
33361
33361
|
depthLimit: Number.MAX_SAFE_INTEGER,
|
|
@@ -33641,7 +33641,7 @@ function replaceGetterValues(replacer) {
|
|
|
33641
33641
|
}
|
|
33642
33642
|
var LIMIT_REPLACE_NODE, CIRCULAR_REPLACE_NODE, arr, replacerStack, encoder;
|
|
33643
33643
|
var init_fast_safe_stringify = __esm({
|
|
33644
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33644
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/fast-safe-stringify/index.js"() {
|
|
33645
33645
|
init_env();
|
|
33646
33646
|
LIMIT_REPLACE_NODE = "[...]";
|
|
33647
33647
|
CIRCULAR_REPLACE_NODE = { result: "[Circular]" };
|
|
@@ -33651,17 +33651,17 @@ var init_fast_safe_stringify = __esm({
|
|
|
33651
33651
|
}
|
|
33652
33652
|
});
|
|
33653
33653
|
|
|
33654
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33654
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/worker_threads.js
|
|
33655
33655
|
var import_node_worker_threads, Worker, WORKER_THREADS_AVAILABLE;
|
|
33656
33656
|
var init_worker_threads = __esm({
|
|
33657
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33657
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/worker_threads.js"() {
|
|
33658
33658
|
import_node_worker_threads = require("node:worker_threads");
|
|
33659
33659
|
Worker = import_node_worker_threads.Worker;
|
|
33660
33660
|
WORKER_THREADS_AVAILABLE = true;
|
|
33661
33661
|
}
|
|
33662
33662
|
});
|
|
33663
33663
|
|
|
33664
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33664
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/serialize_worker.js
|
|
33665
33665
|
function getSharedSerializeWorker() {
|
|
33666
33666
|
if (sharedWorker === null)
|
|
33667
33667
|
sharedWorker = new SerializeWorker();
|
|
@@ -33719,7 +33719,7 @@ function hasLargeString(value, threshold = LARGE_STRING_THRESHOLD, nodeBudget =
|
|
|
33719
33719
|
}
|
|
33720
33720
|
var WORKER_SOURCE, SerializeWorker, sharedWorker, LARGE_STRING_THRESHOLD, NODE_BUDGET;
|
|
33721
33721
|
var init_serialize_worker = __esm({
|
|
33722
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33722
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/serialize_worker.js"() {
|
|
33723
33723
|
init_worker_threads();
|
|
33724
33724
|
WORKER_SOURCE = /* js */
|
|
33725
33725
|
`
|
|
@@ -33950,7 +33950,7 @@ parentPort.on("message", (msg) => {
|
|
|
33950
33950
|
}
|
|
33951
33951
|
});
|
|
33952
33952
|
|
|
33953
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
33953
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/client.js
|
|
33954
33954
|
function assertPullPublicPromptAllowed(promptIdentifier, dangerouslyPullPublicPrompt) {
|
|
33955
33955
|
const [owner] = parseHubIdentifier(promptIdentifier);
|
|
33956
33956
|
if (owner !== "-" && !dangerouslyPullPublicPrompt) {
|
|
@@ -34018,7 +34018,7 @@ function isExampleCreate(input) {
|
|
|
34018
34018
|
}
|
|
34019
34019
|
var getTracingSamplingRate, isLocalhost, handle429, DEFAULT_UNCOMPRESSED_BATCH_SIZE_LIMIT_BYTES, DEFAULT_MAX_SIZE_BYTES, SERVER_INFO_REQUEST_TIMEOUT_MS, DEFAULT_BATCH_SIZE_LIMIT, AutoBatchQueue, Client2;
|
|
34020
34020
|
var init_client = __esm({
|
|
34021
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
34021
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/client.js"() {
|
|
34022
34022
|
init_src();
|
|
34023
34023
|
init_translator();
|
|
34024
34024
|
init_otel();
|
|
@@ -38812,10 +38812,10 @@ Message: ${Array.isArray(result.detail) ? result.detail.join("\n") : "Unspecifie
|
|
|
38812
38812
|
}
|
|
38813
38813
|
});
|
|
38814
38814
|
|
|
38815
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38815
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/env.js
|
|
38816
38816
|
var isTracingEnabled;
|
|
38817
38817
|
var init_env2 = __esm({
|
|
38818
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38818
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/env.js"() {
|
|
38819
38819
|
init_env();
|
|
38820
38820
|
isTracingEnabled = (tracingEnabled) => {
|
|
38821
38821
|
if (tracingEnabled !== void 0) {
|
|
@@ -38827,16 +38827,16 @@ var init_env2 = __esm({
|
|
|
38827
38827
|
}
|
|
38828
38828
|
});
|
|
38829
38829
|
|
|
38830
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38830
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/singletons/constants.js
|
|
38831
38831
|
var _LC_CONTEXT_VARIABLES_KEY, _REPLICA_TRACE_ROOTS_KEY;
|
|
38832
38832
|
var init_constants2 = __esm({
|
|
38833
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38833
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/singletons/constants.js"() {
|
|
38834
38834
|
_LC_CONTEXT_VARIABLES_KEY = /* @__PURE__ */ Symbol.for("lc:context_variables");
|
|
38835
38835
|
_REPLICA_TRACE_ROOTS_KEY = /* @__PURE__ */ Symbol.for("langsmith:replica_trace_roots");
|
|
38836
38836
|
}
|
|
38837
38837
|
});
|
|
38838
38838
|
|
|
38839
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38839
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/context_vars.js
|
|
38840
38840
|
function getContextVar(runTree, key) {
|
|
38841
38841
|
if (_LC_CONTEXT_VARIABLES_KEY in runTree) {
|
|
38842
38842
|
const contextVars = runTree[_LC_CONTEXT_VARIABLES_KEY];
|
|
@@ -38853,15 +38853,15 @@ function setContextVar(runTree, key, value) {
|
|
|
38853
38853
|
runTree[_LC_CONTEXT_VARIABLES_KEY] = contextVars;
|
|
38854
38854
|
}
|
|
38855
38855
|
var init_context_vars = __esm({
|
|
38856
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38856
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/context_vars.js"() {
|
|
38857
38857
|
init_constants2();
|
|
38858
38858
|
}
|
|
38859
38859
|
});
|
|
38860
38860
|
|
|
38861
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38861
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/project.js
|
|
38862
38862
|
var getDefaultProjectName;
|
|
38863
38863
|
var init_project = __esm({
|
|
38864
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38864
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/utils/project.js"() {
|
|
38865
38865
|
init_env();
|
|
38866
38866
|
getDefaultProjectName = () => {
|
|
38867
38867
|
return getLangSmithEnvironmentVariable("PROJECT") ?? getEnvironmentVariable("LANGCHAIN_SESSION") ?? // TODO: Deprecate
|
|
@@ -38870,7 +38870,7 @@ var init_project = __esm({
|
|
|
38870
38870
|
}
|
|
38871
38871
|
});
|
|
38872
38872
|
|
|
38873
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38873
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/run_trees.js
|
|
38874
38874
|
function getReplicaKey(replica) {
|
|
38875
38875
|
const sortedKeys = Object.keys(replica).sort();
|
|
38876
38876
|
const keyData = sortedKeys.map((key) => `${key}:${replica[key] ?? ""}`).join("|");
|
|
@@ -38994,7 +38994,7 @@ function _checkEndpointEnvUnset(parsed) {
|
|
|
38994
38994
|
}
|
|
38995
38995
|
var TIMESTAMP_LENGTH, UUID_NAMESPACE_DNS, HEADER_SAFE_REPLICA_FIELDS, Baggage, RunTree;
|
|
38996
38996
|
var init_run_trees = __esm({
|
|
38997
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
38997
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/run_trees.js"() {
|
|
38998
38998
|
init_client();
|
|
38999
38999
|
init_env2();
|
|
39000
39000
|
init_error();
|
|
@@ -39789,21 +39789,21 @@ var init_run_trees = __esm({
|
|
|
39789
39789
|
}
|
|
39790
39790
|
});
|
|
39791
39791
|
|
|
39792
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
39792
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/uuid.js
|
|
39793
39793
|
function uuid7() {
|
|
39794
39794
|
return v7_default();
|
|
39795
39795
|
}
|
|
39796
39796
|
var init_uuid2 = __esm({
|
|
39797
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
39797
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/uuid.js"() {
|
|
39798
39798
|
init_src();
|
|
39799
39799
|
init_uuid();
|
|
39800
39800
|
}
|
|
39801
39801
|
});
|
|
39802
39802
|
|
|
39803
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
39803
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/index.js
|
|
39804
39804
|
var __version__, LS_MESSAGE_VIEW_EXCLUDE;
|
|
39805
39805
|
var init_dist = __esm({
|
|
39806
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
39806
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/dist/index.js"() {
|
|
39807
39807
|
init_client();
|
|
39808
39808
|
init_run_trees();
|
|
39809
39809
|
init_fetch();
|
|
@@ -39815,7 +39815,7 @@ var init_dist = __esm({
|
|
|
39815
39815
|
}
|
|
39816
39816
|
});
|
|
39817
39817
|
|
|
39818
|
-
// node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
39818
|
+
// node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/index.js
|
|
39819
39819
|
var langsmith_exports = {};
|
|
39820
39820
|
__export(langsmith_exports, {
|
|
39821
39821
|
Cache: () => Cache,
|
|
@@ -39832,7 +39832,7 @@ __export(langsmith_exports, {
|
|
|
39832
39832
|
uuid7FromTime: () => uuid7FromTime
|
|
39833
39833
|
});
|
|
39834
39834
|
var init_langsmith = __esm({
|
|
39835
|
-
"node_modules/.pnpm/langsmith@0.7.7_ws@8.
|
|
39835
|
+
"node_modules/.pnpm/langsmith@0.7.7_ws@8.21.0/node_modules/langsmith/index.js"() {
|
|
39836
39836
|
init_dist();
|
|
39837
39837
|
}
|
|
39838
39838
|
});
|
|
@@ -39843,6 +39843,7 @@ __export(duclaw_exports, {
|
|
|
39843
39843
|
createDefaultToolHookPlugins: () => createDefaultToolHookPlugins,
|
|
39844
39844
|
createDefaultTools: () => createDefaultTools,
|
|
39845
39845
|
createDuclawTools: () => createDuclawTools,
|
|
39846
|
+
duclawPreset: () => duclawPreset,
|
|
39846
39847
|
getDefaultAgentConfig: () => getDefaultAgentConfig
|
|
39847
39848
|
});
|
|
39848
39849
|
module.exports = __toCommonJS(duclaw_exports);
|
|
@@ -49570,8 +49571,22 @@ var import_node_path13 = __toESM(require("node:path"));
|
|
|
49570
49571
|
var import_node_zlib = require("node:zlib");
|
|
49571
49572
|
|
|
49572
49573
|
// src/attachments/attachmentContext.ts
|
|
49574
|
+
var import_node_crypto6 = require("node:crypto");
|
|
49573
49575
|
var import_node_fs6 = require("node:fs");
|
|
49574
49576
|
var import_node_path12 = require("node:path");
|
|
49577
|
+
var MAX_ATTACHMENT_RECORDS = 100;
|
|
49578
|
+
var RECENT_ATTACHMENT_LIMIT = 5;
|
|
49579
|
+
function makeAttachmentId(input) {
|
|
49580
|
+
const raw = [
|
|
49581
|
+
input.userId,
|
|
49582
|
+
input.platform,
|
|
49583
|
+
input.messageId,
|
|
49584
|
+
input.resourceKey,
|
|
49585
|
+
input.kind
|
|
49586
|
+
].join(":");
|
|
49587
|
+
const digest = (0, import_node_crypto6.createHash)("sha256").update(raw).digest("hex").slice(0, 16);
|
|
49588
|
+
return `att_${input.kind === "image" ? "img" : "file"}_${digest}`;
|
|
49589
|
+
}
|
|
49575
49590
|
function indexPath(userId) {
|
|
49576
49591
|
return (0, import_node_path12.join)(getDuclawWorkspaceDir(), userId, "attachments", "index.json");
|
|
49577
49592
|
}
|
|
@@ -49586,13 +49601,152 @@ function readIndex(userId) {
|
|
|
49586
49601
|
return [];
|
|
49587
49602
|
}
|
|
49588
49603
|
}
|
|
49604
|
+
function writeIndex(userId, records) {
|
|
49605
|
+
const filePath = indexPath(userId);
|
|
49606
|
+
(0, import_node_fs6.mkdirSync)((0, import_node_path12.dirname)(filePath), { recursive: true });
|
|
49607
|
+
(0, import_node_fs6.writeFileSync)(filePath, JSON.stringify(records.slice(0, MAX_ATTACHMENT_RECORDS), null, 2));
|
|
49608
|
+
}
|
|
49589
49609
|
function isAttachmentRecord(value) {
|
|
49590
49610
|
const record2 = value;
|
|
49591
49611
|
return Boolean(record2) && typeof record2.id === "string" && (record2.kind === "image" || record2.kind === "file") && typeof record2.userId === "string" && typeof record2.pathOrUrl === "string";
|
|
49592
49612
|
}
|
|
49613
|
+
function stringValue(value) {
|
|
49614
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
49615
|
+
}
|
|
49616
|
+
function attachmentKind(value) {
|
|
49617
|
+
const type = stringValue(value.type);
|
|
49618
|
+
const mimeType = stringValue(value.mimeType);
|
|
49619
|
+
const name = stringValue(value.name) ?? stringValue(value.path) ?? stringValue(value.url) ?? "";
|
|
49620
|
+
if (type === "image" || mimeType?.startsWith("image/") || /\.(png|jpe?g|gif|webp)$/i.test(name)) {
|
|
49621
|
+
return "image";
|
|
49622
|
+
}
|
|
49623
|
+
return "file";
|
|
49624
|
+
}
|
|
49625
|
+
function xmlEscape(value) {
|
|
49626
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
49627
|
+
}
|
|
49628
|
+
function upsertAttachments(userId, records) {
|
|
49629
|
+
if (records.length === 0) return;
|
|
49630
|
+
const existing = readIndex(userId);
|
|
49631
|
+
const byId = /* @__PURE__ */ new Map();
|
|
49632
|
+
for (const record2 of [...records, ...existing]) {
|
|
49633
|
+
if (!byId.has(record2.id)) byId.set(record2.id, record2);
|
|
49634
|
+
}
|
|
49635
|
+
writeIndex(userId, Array.from(byId.values()).sort((a, b) => b.receivedAt.localeCompare(a.receivedAt)));
|
|
49636
|
+
}
|
|
49637
|
+
function listRecentAttachments(userId, limit = RECENT_ATTACHMENT_LIMIT) {
|
|
49638
|
+
return readIndex(userId).sort((a, b) => b.receivedAt.localeCompare(a.receivedAt)).slice(0, limit);
|
|
49639
|
+
}
|
|
49593
49640
|
function resolveAttachmentPathOrUrl(userId, attachmentId) {
|
|
49594
49641
|
return readIndex(userId).find((record2) => record2.id === attachmentId)?.pathOrUrl;
|
|
49595
49642
|
}
|
|
49643
|
+
function collectAttachmentsFromRequest(request) {
|
|
49644
|
+
const metadata = request.metadata ?? {};
|
|
49645
|
+
const platform = request.platform || "unknown";
|
|
49646
|
+
const messageId = request.requestId;
|
|
49647
|
+
const receivedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
49648
|
+
const records = [];
|
|
49649
|
+
const seen = /* @__PURE__ */ new Set();
|
|
49650
|
+
const addRecord = (input) => {
|
|
49651
|
+
if (!input.pathOrUrl) return;
|
|
49652
|
+
const id = makeAttachmentId({
|
|
49653
|
+
userId: request.userId,
|
|
49654
|
+
platform,
|
|
49655
|
+
messageId,
|
|
49656
|
+
resourceKey: input.resourceKey,
|
|
49657
|
+
kind: input.kind
|
|
49658
|
+
});
|
|
49659
|
+
if (seen.has(id)) return;
|
|
49660
|
+
seen.add(id);
|
|
49661
|
+
records.push({
|
|
49662
|
+
id,
|
|
49663
|
+
kind: input.kind,
|
|
49664
|
+
platform,
|
|
49665
|
+
userId: request.userId,
|
|
49666
|
+
messageId,
|
|
49667
|
+
resourceKey: input.resourceKey,
|
|
49668
|
+
pathOrUrl: input.pathOrUrl,
|
|
49669
|
+
name: input.name,
|
|
49670
|
+
mimeType: input.mimeType,
|
|
49671
|
+
source: input.source,
|
|
49672
|
+
receivedAt
|
|
49673
|
+
});
|
|
49674
|
+
};
|
|
49675
|
+
const imageUrl = stringValue(metadata.imageUrl);
|
|
49676
|
+
const imageKey = stringValue(metadata.imageKey);
|
|
49677
|
+
if (imageUrl && imageKey) {
|
|
49678
|
+
addRecord({
|
|
49679
|
+
kind: "image",
|
|
49680
|
+
resourceKey: imageKey,
|
|
49681
|
+
pathOrUrl: imageUrl,
|
|
49682
|
+
source: `${platform}_metadata`
|
|
49683
|
+
});
|
|
49684
|
+
}
|
|
49685
|
+
const fileUrl = stringValue(metadata.fileUrl);
|
|
49686
|
+
const fileName = stringValue(metadata.fileName);
|
|
49687
|
+
if (fileUrl && fileName) {
|
|
49688
|
+
addRecord({
|
|
49689
|
+
kind: "file",
|
|
49690
|
+
resourceKey: fileName,
|
|
49691
|
+
pathOrUrl: fileUrl,
|
|
49692
|
+
name: fileName,
|
|
49693
|
+
source: `${platform}_metadata`
|
|
49694
|
+
});
|
|
49695
|
+
}
|
|
49696
|
+
const attachments = Array.isArray(metadata.attachments) ? metadata.attachments : [];
|
|
49697
|
+
for (const attachment of attachments) {
|
|
49698
|
+
const resourceKey = stringValue(attachment.id) ?? stringValue(attachment.name);
|
|
49699
|
+
const pathOrUrl = stringValue(attachment.url) ?? stringValue(attachment.path);
|
|
49700
|
+
if (!resourceKey || !pathOrUrl) continue;
|
|
49701
|
+
addRecord({
|
|
49702
|
+
kind: attachmentKind(attachment),
|
|
49703
|
+
resourceKey,
|
|
49704
|
+
pathOrUrl,
|
|
49705
|
+
name: stringValue(attachment.name),
|
|
49706
|
+
mimeType: stringValue(attachment.mimeType),
|
|
49707
|
+
source: `${platform}_attachment`
|
|
49708
|
+
});
|
|
49709
|
+
}
|
|
49710
|
+
return records;
|
|
49711
|
+
}
|
|
49712
|
+
function buildAttachmentContextXml(records) {
|
|
49713
|
+
if (records.length === 0) return "";
|
|
49714
|
+
const lines = [
|
|
49715
|
+
`<recent-attachments>`,
|
|
49716
|
+
` <system-note>Recent attachments are available assets, not automatic task inputs. Use attachment_id only when the current user message explicitly refers to an attachment/image/file, asks to use previous assets, or says \u56FE\u4E00/\u56FE\u4E8C/\u7B2C\u4E00\u5F20/\u7B2C\u4E8C\u5F20. If the current request is unrelated pure text, Do not call image_understand or image_generate just because recent attachments are listed. Do not invent or reproduce long URLs; tools can resolve the real file source from attachment_id. \u56FE\u4E00/\u7B2C\u4E00\u5F20\u56FE\u7247 maps to image number 1, \u56FE\u4E8C/\u7B2C\u4E8C\u5F20\u56FE\u7247 maps to image number 2, following the order below. For image_generate edits, put the destination/base image in target_attachment_id or attachment_id, and put source/reference/material images in reference_attachment_id(s).</system-note>`
|
|
49717
|
+
];
|
|
49718
|
+
for (const [index, record2] of records.entries()) {
|
|
49719
|
+
lines.push(` <${record2.kind} id="${xmlEscape(record2.id)}">`);
|
|
49720
|
+
lines.push(` <number>${index + 1}</number>`);
|
|
49721
|
+
lines.push(` <source>${xmlEscape(record2.source ?? record2.platform)}</source>`);
|
|
49722
|
+
lines.push(` <message_id>${xmlEscape(record2.messageId)}</message_id>`);
|
|
49723
|
+
lines.push(` <resource_key>${xmlEscape(record2.resourceKey)}</resource_key>`);
|
|
49724
|
+
if (record2.name) lines.push(` <name>${xmlEscape(record2.name)}</name>`);
|
|
49725
|
+
if (record2.mimeType) lines.push(` <mime_type>${xmlEscape(record2.mimeType)}</mime_type>`);
|
|
49726
|
+
lines.push(` <received_at>${xmlEscape(record2.receivedAt)}</received_at>`);
|
|
49727
|
+
lines.push(` </${record2.kind}>`);
|
|
49728
|
+
}
|
|
49729
|
+
lines.push(`</recent-attachments>`);
|
|
49730
|
+
return lines.join("\n");
|
|
49731
|
+
}
|
|
49732
|
+
function attachRecentAttachmentContext(request, content) {
|
|
49733
|
+
const current = collectAttachmentsFromRequest(request);
|
|
49734
|
+
if (current.length > 0) {
|
|
49735
|
+
upsertAttachments(request.userId, current);
|
|
49736
|
+
request.metadata = {
|
|
49737
|
+
...request.metadata ?? {},
|
|
49738
|
+
attachmentIds: current.map((record2) => record2.id),
|
|
49739
|
+
attachmentId: current[0]?.id
|
|
49740
|
+
};
|
|
49741
|
+
}
|
|
49742
|
+
const context = buildAttachmentContextXml(listRecentAttachments(request.userId));
|
|
49743
|
+
if (!context) return content;
|
|
49744
|
+
return `${content}
|
|
49745
|
+
|
|
49746
|
+
<system-reminder>
|
|
49747
|
+
${context}
|
|
49748
|
+
</system-reminder>`;
|
|
49749
|
+
}
|
|
49596
49750
|
|
|
49597
49751
|
// src/tools/tools/ImageGenerate.ts
|
|
49598
49752
|
var DEFAULT_BASE_URL = "https://direct.shanyiapi.com";
|
|
@@ -50292,7 +50446,7 @@ var isTextBlock = (block) => block.type === `text`;
|
|
|
50292
50446
|
var extractText = (blocks) => blocks.filter(isTextBlock).map((b) => b.text).join("\n");
|
|
50293
50447
|
|
|
50294
50448
|
// src/tools/tools/ImageUnderstandMetering.ts
|
|
50295
|
-
var
|
|
50449
|
+
var import_node_crypto7 = require("node:crypto");
|
|
50296
50450
|
var ImageUnderstandMeteringError = class extends Error {
|
|
50297
50451
|
constructor(message, statusCode, meteringStatus) {
|
|
50298
50452
|
super(message);
|
|
@@ -50345,27 +50499,27 @@ async function reportImageUnderstandUsage(input) {
|
|
|
50345
50499
|
}
|
|
50346
50500
|
function buildImageUnderstandMeteringPayload(input) {
|
|
50347
50501
|
const metadata = input.userRequest?.metadata ?? {};
|
|
50348
|
-
const messageId =
|
|
50349
|
-
const imageKey =
|
|
50502
|
+
const messageId = stringValue2(metadata.message_id) ?? nestedMessageId(metadata) ?? stringValue2(input.userRequest?.requestId);
|
|
50503
|
+
const imageKey = stringValue2(metadata.imageKey) ?? stringValue2(metadata.image_key) ?? firstString(metadata.imageKeys);
|
|
50350
50504
|
return {
|
|
50351
50505
|
tenantId: input.tenantId,
|
|
50352
50506
|
provider: input.provider,
|
|
50353
50507
|
model: input.model,
|
|
50354
|
-
requestId:
|
|
50508
|
+
requestId: stringValue2(input.userRequest?.requestId),
|
|
50355
50509
|
messageId,
|
|
50356
50510
|
imageKey,
|
|
50357
50511
|
imageFingerprint: fingerprintImageSource(input.imageSource),
|
|
50358
|
-
toolCallId:
|
|
50512
|
+
toolCallId: stringValue2(metadata.toolCallId),
|
|
50359
50513
|
promptChars: input.prompt.length,
|
|
50360
50514
|
resultChars: input.resultText.length,
|
|
50361
50515
|
usage: input.usage ?? null,
|
|
50362
|
-
providerResponseId:
|
|
50363
|
-
platform:
|
|
50516
|
+
providerResponseId: stringValue2(input.providerResponseId),
|
|
50517
|
+
platform: stringValue2(input.userRequest?.platform),
|
|
50364
50518
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
50365
50519
|
metadata: {
|
|
50366
50520
|
imageSourceKind: imageSourceKind(input.imageSource),
|
|
50367
|
-
chatType:
|
|
50368
|
-
authStyle:
|
|
50521
|
+
chatType: stringValue2(input.userRequest?.chatType),
|
|
50522
|
+
authStyle: stringValue2(input.authStyle)
|
|
50369
50523
|
}
|
|
50370
50524
|
};
|
|
50371
50525
|
}
|
|
@@ -50382,7 +50536,7 @@ function inferImageProvider(baseUrl) {
|
|
|
50382
50536
|
}
|
|
50383
50537
|
}
|
|
50384
50538
|
function fingerprintImageSource(imageSource) {
|
|
50385
|
-
return (0,
|
|
50539
|
+
return (0, import_node_crypto7.createHash)("sha256").update(imageSource).digest("hex");
|
|
50386
50540
|
}
|
|
50387
50541
|
function imageSourceKind(imageSource) {
|
|
50388
50542
|
if (imageSource.startsWith("http://") || imageSource.startsWith("https://")) return "url";
|
|
@@ -50392,17 +50546,17 @@ function imageSourceKind(imageSource) {
|
|
|
50392
50546
|
function nestedMessageId(metadata) {
|
|
50393
50547
|
const message = metadata.message;
|
|
50394
50548
|
if (!message || typeof message !== "object" || Array.isArray(message)) return null;
|
|
50395
|
-
return
|
|
50549
|
+
return stringValue2(message.message_id);
|
|
50396
50550
|
}
|
|
50397
50551
|
function firstString(value) {
|
|
50398
50552
|
if (!Array.isArray(value)) return null;
|
|
50399
50553
|
for (const item of value) {
|
|
50400
|
-
const normalized =
|
|
50554
|
+
const normalized = stringValue2(item);
|
|
50401
50555
|
if (normalized) return normalized;
|
|
50402
50556
|
}
|
|
50403
50557
|
return null;
|
|
50404
50558
|
}
|
|
50405
|
-
function
|
|
50559
|
+
function stringValue2(value) {
|
|
50406
50560
|
if (typeof value !== "string") return null;
|
|
50407
50561
|
const normalized = value.trim();
|
|
50408
50562
|
return normalized ? normalized : null;
|
|
@@ -51505,7 +51659,7 @@ var createBaseTools = (options = []) => {
|
|
|
51505
51659
|
};
|
|
51506
51660
|
|
|
51507
51661
|
// src/agent/events.ts
|
|
51508
|
-
var
|
|
51662
|
+
var import_node_crypto8 = require("node:crypto");
|
|
51509
51663
|
var rowToEvent = (row) => ({
|
|
51510
51664
|
id: row.id,
|
|
51511
51665
|
userId: row.userId,
|
|
@@ -51522,7 +51676,7 @@ var rowToEvent = (row) => ({
|
|
|
51522
51676
|
var recordAgentEvent = (input) => {
|
|
51523
51677
|
const db2 = createSqliteDB();
|
|
51524
51678
|
const now = Date.now();
|
|
51525
|
-
const id = `evt_${(0,
|
|
51679
|
+
const id = `evt_${(0, import_node_crypto8.randomUUID)().slice(0, 12)}`;
|
|
51526
51680
|
const payloadJson = JSON.stringify(input.payload);
|
|
51527
51681
|
db2.prepare(`
|
|
51528
51682
|
INSERT INTO agent_events (
|
|
@@ -52084,314 +52238,16 @@ var searchRecallIndex = async (storage, userId, query, date, limit = 8) => {
|
|
|
52084
52238
|
};
|
|
52085
52239
|
};
|
|
52086
52240
|
|
|
52087
|
-
// src/department/mailbox/ceoFollowup.ts
|
|
52088
|
-
var import_node_crypto8 = require("node:crypto");
|
|
52089
|
-
var rowToFollowup = (row) => ({
|
|
52090
|
-
id: row.id,
|
|
52091
|
-
sourceMessageId: row.sourceMessageId,
|
|
52092
|
-
status: row.status,
|
|
52093
|
-
originUserId: row.originUserId,
|
|
52094
|
-
originPlatform: row.originPlatform,
|
|
52095
|
-
fromMailboxId: row.fromMailboxId,
|
|
52096
|
-
threadId: row.threadId ?? void 0,
|
|
52097
|
-
parentMessageId: row.parentMessageId ?? void 0,
|
|
52098
|
-
workItemId: row.workItemId ?? void 0,
|
|
52099
|
-
content: row.content,
|
|
52100
|
-
attempts: row.attempts,
|
|
52101
|
-
lastError: row.lastError ?? void 0,
|
|
52102
|
-
createdAt: row.createdAt,
|
|
52103
|
-
updatedAt: row.updatedAt,
|
|
52104
|
-
completedAt: row.completedAt ?? void 0
|
|
52105
|
-
});
|
|
52106
|
-
var selectById = (id) => {
|
|
52107
|
-
const db2 = createSqliteDB();
|
|
52108
|
-
const row = db2.prepare(`
|
|
52109
|
-
SELECT
|
|
52110
|
-
id,
|
|
52111
|
-
source_message_id as sourceMessageId,
|
|
52112
|
-
status,
|
|
52113
|
-
origin_user_id as originUserId,
|
|
52114
|
-
origin_platform as originPlatform,
|
|
52115
|
-
from_mailbox_id as fromMailboxId,
|
|
52116
|
-
thread_id as threadId,
|
|
52117
|
-
parent_message_id as parentMessageId,
|
|
52118
|
-
work_item_id as workItemId,
|
|
52119
|
-
content,
|
|
52120
|
-
attempts,
|
|
52121
|
-
last_error as lastError,
|
|
52122
|
-
created_at as createdAt,
|
|
52123
|
-
updated_at as updatedAt,
|
|
52124
|
-
completed_at as completedAt
|
|
52125
|
-
FROM ceo_followups
|
|
52126
|
-
WHERE id = ?
|
|
52127
|
-
`).get(id);
|
|
52128
|
-
return row ? rowToFollowup(row) : null;
|
|
52129
|
-
};
|
|
52130
|
-
var enqueueCeoFollowupFromMailbox = (message) => {
|
|
52131
|
-
if (message.toMailboxId !== "manager") return null;
|
|
52132
|
-
if (message.workItemRole === "followup") return null;
|
|
52133
|
-
if (!message.originUserId || !message.originPlatform) return null;
|
|
52134
|
-
const db2 = createSqliteDB();
|
|
52135
|
-
const now = Date.now();
|
|
52136
|
-
const id = `cfu_${(0, import_node_crypto8.randomUUID)().slice(0, 12)}`;
|
|
52137
|
-
db2.prepare(`
|
|
52138
|
-
INSERT INTO ceo_followups (
|
|
52139
|
-
id,
|
|
52140
|
-
source_message_id,
|
|
52141
|
-
status,
|
|
52142
|
-
origin_user_id,
|
|
52143
|
-
origin_platform,
|
|
52144
|
-
from_mailbox_id,
|
|
52145
|
-
thread_id,
|
|
52146
|
-
parent_message_id,
|
|
52147
|
-
work_item_id,
|
|
52148
|
-
content,
|
|
52149
|
-
created_at,
|
|
52150
|
-
updated_at
|
|
52151
|
-
) VALUES (?, ?, 'pending', ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
52152
|
-
ON CONFLICT(source_message_id) DO UPDATE SET
|
|
52153
|
-
status = CASE
|
|
52154
|
-
WHEN ceo_followups.status = 'completed' THEN ceo_followups.status
|
|
52155
|
-
ELSE 'pending'
|
|
52156
|
-
END,
|
|
52157
|
-
origin_user_id = excluded.origin_user_id,
|
|
52158
|
-
origin_platform = excluded.origin_platform,
|
|
52159
|
-
from_mailbox_id = excluded.from_mailbox_id,
|
|
52160
|
-
thread_id = excluded.thread_id,
|
|
52161
|
-
parent_message_id = excluded.parent_message_id,
|
|
52162
|
-
work_item_id = excluded.work_item_id,
|
|
52163
|
-
content = excluded.content,
|
|
52164
|
-
updated_at = excluded.updated_at
|
|
52165
|
-
`).run(
|
|
52166
|
-
id,
|
|
52167
|
-
message.id,
|
|
52168
|
-
message.originUserId,
|
|
52169
|
-
message.originPlatform,
|
|
52170
|
-
message.fromMailboxId,
|
|
52171
|
-
message.threadId ?? message.id,
|
|
52172
|
-
message.parentMessageId ?? null,
|
|
52173
|
-
message.workItemId ?? null,
|
|
52174
|
-
message.content,
|
|
52175
|
-
now,
|
|
52176
|
-
now
|
|
52177
|
-
);
|
|
52178
|
-
const row = db2.prepare(`
|
|
52179
|
-
SELECT id FROM ceo_followups WHERE source_message_id = ?
|
|
52180
|
-
`).get(message.id);
|
|
52181
|
-
return row ? selectById(row.id) : null;
|
|
52182
|
-
};
|
|
52183
|
-
|
|
52184
|
-
// src/department/DepartmentMember.ts
|
|
52185
|
-
var import_fs10 = require("fs");
|
|
52186
|
-
var import_path15 = __toESM(require("path"));
|
|
52187
|
-
|
|
52188
|
-
// src/department/Department.ts
|
|
52189
|
-
var import_path14 = __toESM(require("path"));
|
|
52190
|
-
var import_fs9 = require("fs");
|
|
52191
|
-
var legacyMigrationChecked = false;
|
|
52192
|
-
var getDepartmentBaseDir = () => {
|
|
52193
|
-
return import_path14.default.join(getDuclawHomeDir(), "department");
|
|
52194
|
-
};
|
|
52195
|
-
var getLegacyTeamBaseDir = () => {
|
|
52196
|
-
return import_path14.default.join(getDuclawHomeDir(), "team");
|
|
52197
|
-
};
|
|
52198
|
-
var getDepartmentWorkSpaceDir = (departmentName) => {
|
|
52199
|
-
return import_path14.default.join(getDepartmentBaseDir(), "workspace", departmentName);
|
|
52200
|
-
};
|
|
52201
|
-
var getLegacyTeamWorkSpaceDir = (teamName) => {
|
|
52202
|
-
return import_path14.default.join(getLegacyTeamBaseDir(), "workspace", teamName);
|
|
52203
|
-
};
|
|
52204
|
-
var getDepartmentJsonPath = (departmentName) => {
|
|
52205
|
-
return import_path14.default.join(getDepartmentWorkSpaceDir(departmentName), "department.json");
|
|
52206
|
-
};
|
|
52207
|
-
var getLegacyTeamJsonPath = (teamName) => {
|
|
52208
|
-
return import_path14.default.join(getLegacyTeamWorkSpaceDir(teamName), "team.json");
|
|
52209
|
-
};
|
|
52210
|
-
var mapLegacyRole = (role) => {
|
|
52211
|
-
return role === "team_manager" ? "department_head" : "executor";
|
|
52212
|
-
};
|
|
52213
|
-
var mapLegacyDepartment = (legacy) => {
|
|
52214
|
-
const departmentMembers = (legacy.teamMembers ?? []).map((member) => ({
|
|
52215
|
-
id: member.id,
|
|
52216
|
-
name: member.name,
|
|
52217
|
-
departmentId: legacy.id,
|
|
52218
|
-
mailBoxId: member.mailBoxId,
|
|
52219
|
-
workspaceId: member.workspaceId,
|
|
52220
|
-
role: mapLegacyRole(member.role),
|
|
52221
|
-
focusOn: member.focusOn
|
|
52222
|
-
}));
|
|
52223
|
-
const headMemberId = legacy.managerMemberId ?? departmentMembers.find((member) => member.role === "department_head")?.id;
|
|
52224
|
-
return {
|
|
52225
|
-
id: legacy.id,
|
|
52226
|
-
name: legacy.name,
|
|
52227
|
-
sourceGoalId: legacy.goalId,
|
|
52228
|
-
charter: legacy.goalId ? `Legacy department migrated from team goal ${legacy.goalId}.` : "Legacy department migrated from team data.",
|
|
52229
|
-
workpath: legacy.workpath,
|
|
52230
|
-
headMemberId,
|
|
52231
|
-
departmentMembers
|
|
52232
|
-
};
|
|
52233
|
-
};
|
|
52234
|
-
var migrateLegacyTeamsToDepartments = () => {
|
|
52235
|
-
if (legacyMigrationChecked) return;
|
|
52236
|
-
legacyMigrationChecked = true;
|
|
52237
|
-
const legacyWorkspaceDir = import_path14.default.join(getLegacyTeamBaseDir(), "workspace");
|
|
52238
|
-
if (!(0, import_fs9.existsSync)(legacyWorkspaceDir)) return;
|
|
52239
|
-
for (const legacyName of (0, import_fs9.readdirSync)(legacyWorkspaceDir)) {
|
|
52240
|
-
const legacyJsonPath = getLegacyTeamJsonPath(legacyName);
|
|
52241
|
-
if (!(0, import_fs9.existsSync)(legacyJsonPath)) continue;
|
|
52242
|
-
const departmentJsonPath = getDepartmentJsonPath(legacyName);
|
|
52243
|
-
if ((0, import_fs9.existsSync)(departmentJsonPath)) continue;
|
|
52244
|
-
try {
|
|
52245
|
-
const legacy = JSON.parse((0, import_fs9.readFileSync)(legacyJsonPath, "utf-8"));
|
|
52246
|
-
const department = mapLegacyDepartment(legacy);
|
|
52247
|
-
(0, import_fs9.mkdirSync)(getDepartmentWorkSpaceDir(department.name), { recursive: true });
|
|
52248
|
-
(0, import_fs9.writeFileSync)(departmentJsonPath, JSON.stringify(department, null, " "), "utf-8");
|
|
52249
|
-
} catch (err) {
|
|
52250
|
-
console.warn(`[department] Failed to migrate legacy team ${legacyName}: ${err.message}`);
|
|
52251
|
-
}
|
|
52252
|
-
}
|
|
52253
|
-
};
|
|
52254
|
-
var createDepartment = (departmentDefinition) => {
|
|
52255
|
-
if (!departmentDefinition) throw new Error(`[createDepartment] departmentDefinition\u4E0D\u80FD\u4E3A\u7A7A`);
|
|
52256
|
-
const departmentPath = getDepartmentWorkSpaceDir(departmentDefinition.name);
|
|
52257
|
-
(0, import_fs9.mkdirSync)(departmentPath, { recursive: true });
|
|
52258
|
-
(0, import_fs9.writeFileSync)(getDepartmentJsonPath(departmentDefinition.name), JSON.stringify(departmentDefinition, null, " "), "utf-8");
|
|
52259
|
-
return departmentDefinition;
|
|
52260
|
-
};
|
|
52261
|
-
var getDepartment = (name) => {
|
|
52262
|
-
migrateLegacyTeamsToDepartments();
|
|
52263
|
-
const departmentJsonPath = getDepartmentJsonPath(name);
|
|
52264
|
-
if (!(0, import_fs9.existsSync)(departmentJsonPath)) return null;
|
|
52265
|
-
const text2 = (0, import_fs9.readFileSync)(departmentJsonPath, "utf-8");
|
|
52266
|
-
return JSON.parse(text2);
|
|
52267
|
-
};
|
|
52268
|
-
var listDepartments = () => {
|
|
52269
|
-
migrateLegacyTeamsToDepartments();
|
|
52270
|
-
const workspaceDir = import_path14.default.join(getDepartmentBaseDir(), "workspace");
|
|
52271
|
-
if (!(0, import_fs9.existsSync)(workspaceDir)) return [];
|
|
52272
|
-
const departments = [];
|
|
52273
|
-
for (const departmentName of (0, import_fs9.readdirSync)(workspaceDir)) {
|
|
52274
|
-
const department = getDepartment(departmentName);
|
|
52275
|
-
if (department) departments.push(department);
|
|
52276
|
-
}
|
|
52277
|
-
return departments;
|
|
52278
|
-
};
|
|
52279
|
-
var getDepartmentById = (id) => {
|
|
52280
|
-
const department = listDepartments().find((item) => item.id === id);
|
|
52281
|
-
return department ?? null;
|
|
52282
|
-
};
|
|
52283
|
-
var deleteDepartment = (name) => {
|
|
52284
|
-
if (!(0, import_fs9.existsSync)(getDepartmentJsonPath(name))) {
|
|
52285
|
-
throw new Error(`[deleteDepartment] \u4E0D\u5B58\u5728\u5BF9\u5E94\u7684\u90E8\u95E8 ${name} \u7684 department.json \u6587\u4EF6`);
|
|
52286
|
-
}
|
|
52287
|
-
(0, import_fs9.rmSync)(getDepartmentJsonPath(name));
|
|
52288
|
-
};
|
|
52289
|
-
|
|
52290
|
-
// src/department/workspace/workspace.ts
|
|
52291
|
-
var db = createSqliteDB();
|
|
52292
|
-
var getWorkspaceId = (departmentName, memberName) => {
|
|
52293
|
-
return `${departmentName}::${memberName}`;
|
|
52294
|
-
};
|
|
52295
|
-
var createWorkspace = (workspace) => {
|
|
52296
|
-
const stmt = db.prepare(`INSERT INTO workspace (id, team_name, teammate_name, team_workpath) VALUES (?, ?, ?, ?) `);
|
|
52297
|
-
stmt.run(
|
|
52298
|
-
workspace.id,
|
|
52299
|
-
workspace.departmentName,
|
|
52300
|
-
workspace.memberName,
|
|
52301
|
-
workspace.departmentWorkPath
|
|
52302
|
-
);
|
|
52303
|
-
};
|
|
52304
|
-
var deleteWorkspace = (workspaceId) => {
|
|
52305
|
-
const stmt = db.prepare(`delete from workspace where id = ?`);
|
|
52306
|
-
stmt.run(workspaceId);
|
|
52307
|
-
};
|
|
52308
|
-
|
|
52309
|
-
// src/department/DepartmentMember.ts
|
|
52310
|
-
var createDepartmentMember = (departmentMemberDefinition) => {
|
|
52311
|
-
if (!departmentMemberDefinition) throw new Error(`[createDepartmentMember] departmentMemberDefinition\u4E0D\u80FD\u4E3A\u7A7A`);
|
|
52312
|
-
const { name, departmentId, workspaceId } = departmentMemberDefinition;
|
|
52313
|
-
const department = getDepartmentById(departmentId);
|
|
52314
|
-
if (!department) throw new Error(`[createDepartmentMember] \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 department: ${departmentId}`);
|
|
52315
|
-
const memberPath = import_path15.default.join(getDepartmentWorkSpaceDir(department.name), name);
|
|
52316
|
-
(0, import_fs10.mkdirSync)(memberPath, { recursive: true });
|
|
52317
|
-
const workspace = {
|
|
52318
|
-
id: getWorkspaceId(department.name, departmentMemberDefinition.name),
|
|
52319
|
-
departmentName: department.name,
|
|
52320
|
-
memberName: name,
|
|
52321
|
-
departmentWorkPath: memberPath
|
|
52322
|
-
};
|
|
52323
|
-
createWorkspace(workspace);
|
|
52324
|
-
if (!department.departmentMembers) {
|
|
52325
|
-
department.departmentMembers = [];
|
|
52326
|
-
}
|
|
52327
|
-
if (department.departmentMembers.some((member) => member.id === departmentMemberDefinition.id || member.name === departmentMemberDefinition.name)) {
|
|
52328
|
-
throw new Error(`[createDepartmentMember] \u90E8\u95E8 ${department.name} \u5DF2\u5B58\u5728\u540C\u540D\u6216\u540C id \u6210\u5458: ${departmentMemberDefinition.name}/${departmentMemberDefinition.id}`);
|
|
52329
|
-
}
|
|
52330
|
-
if (departmentMemberDefinition.role === "department_head") {
|
|
52331
|
-
const existingHead = department.headMemberId ? department.departmentMembers.find((member) => member.id === department.headMemberId) : department.departmentMembers.find((member) => member.role === "department_head");
|
|
52332
|
-
if (existingHead) {
|
|
52333
|
-
throw new Error(`[createDepartmentMember] \u90E8\u95E8 ${department.name} \u5DF2\u5B58\u5728 Department Head: ${existingHead.name}`);
|
|
52334
|
-
}
|
|
52335
|
-
department.headMemberId = departmentMemberDefinition.id;
|
|
52336
|
-
}
|
|
52337
|
-
department.departmentMembers.push(departmentMemberDefinition);
|
|
52338
|
-
(0, import_fs10.writeFileSync)(getDepartmentJsonPath(department.name), JSON.stringify(department, null, " "), "utf-8");
|
|
52339
|
-
return departmentMemberDefinition;
|
|
52340
|
-
};
|
|
52341
|
-
var listDepartmentMembers = (departmentName) => {
|
|
52342
|
-
const departmentJsonPath = getDepartmentJsonPath(departmentName);
|
|
52343
|
-
if (!(0, import_fs10.existsSync)(departmentJsonPath)) return [];
|
|
52344
|
-
const text2 = (0, import_fs10.readFileSync)(departmentJsonPath, "utf-8");
|
|
52345
|
-
const department = JSON.parse(text2);
|
|
52346
|
-
if (!department) throw new Error(`[listDepartmentMembers] \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 department: ${departmentName}`);
|
|
52347
|
-
return department.departmentMembers ?? [];
|
|
52348
|
-
};
|
|
52349
|
-
var getDepartmentMember = (departmentName, departmentMemberId) => {
|
|
52350
|
-
const members = listDepartmentMembers(departmentName);
|
|
52351
|
-
return members.find((member) => member.id === departmentMemberId) || null;
|
|
52352
|
-
};
|
|
52353
|
-
var getDepartmentMemberByName = (departmentName, departmentMemberName) => {
|
|
52354
|
-
const members = listDepartmentMembers(departmentName);
|
|
52355
|
-
return members.find((member) => member.name === departmentMemberName) || null;
|
|
52356
|
-
};
|
|
52357
|
-
var getDepartmentMemberByMailboxId = (mailboxId) => {
|
|
52358
|
-
const [departmentName, memberName] = mailboxId.split("::");
|
|
52359
|
-
if (!departmentName || !memberName) return null;
|
|
52360
|
-
return getDepartmentMemberByName(departmentName, memberName);
|
|
52361
|
-
};
|
|
52362
|
-
var getDepartmentMemberById = (memberId) => {
|
|
52363
|
-
for (const department of listDepartments()) {
|
|
52364
|
-
const targetMember = department.departmentMembers.find((member) => member.id === memberId);
|
|
52365
|
-
if (targetMember) return targetMember;
|
|
52366
|
-
}
|
|
52367
|
-
return null;
|
|
52368
|
-
};
|
|
52369
|
-
var deleteDepartmentMemberById = (departmentName, memberId) => {
|
|
52370
|
-
const department = getDepartment(departmentName);
|
|
52371
|
-
if (!department) throw new Error(`[deleteDepartmentMemberById] \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 department: ${departmentName}`);
|
|
52372
|
-
const memberIdx = department.departmentMembers.findIndex((member) => member.id === memberId);
|
|
52373
|
-
if (memberIdx === -1) {
|
|
52374
|
-
throw new Error(`[deleteDepartmentMemberById] \u627E\u4E0D\u5230\u5BF9\u5E94 id \u7684 department member: ${memberId}`);
|
|
52375
|
-
}
|
|
52376
|
-
const workspaceId = department.departmentMembers[memberIdx].workspaceId;
|
|
52377
|
-
if (department.headMemberId === memberId) {
|
|
52378
|
-
delete department.headMemberId;
|
|
52379
|
-
}
|
|
52380
|
-
department.departmentMembers = department.departmentMembers.filter((_, index) => index !== memberIdx);
|
|
52381
|
-
(0, import_fs10.writeFileSync)(getDepartmentJsonPath(departmentName), JSON.stringify(department, null, " "), "utf-8");
|
|
52382
|
-
deleteWorkspace(workspaceId);
|
|
52383
|
-
};
|
|
52384
|
-
|
|
52385
52241
|
// src/tasks/goal.ts
|
|
52386
52242
|
var import_dayjs2 = __toESM(require_dayjs_min());
|
|
52387
52243
|
var import_utc2 = __toESM(require_utc());
|
|
52388
52244
|
var import_timezone2 = __toESM(require_timezone());
|
|
52389
|
-
var
|
|
52390
|
-
var
|
|
52245
|
+
var import_fs10 = require("fs");
|
|
52246
|
+
var import_path15 = __toESM(require("path"));
|
|
52391
52247
|
|
|
52392
52248
|
// src/tasks/goalConversation.ts
|
|
52393
|
-
var
|
|
52394
|
-
var
|
|
52249
|
+
var import_fs9 = require("fs");
|
|
52250
|
+
var import_path14 = __toESM(require("path"));
|
|
52395
52251
|
|
|
52396
52252
|
// src/common/date.ts
|
|
52397
52253
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
@@ -52409,16 +52265,16 @@ var getDate = (format) => {
|
|
|
52409
52265
|
|
|
52410
52266
|
// src/tasks/goalConversation.ts
|
|
52411
52267
|
var getGoalConversationDir = () => {
|
|
52412
|
-
const dir =
|
|
52413
|
-
(0,
|
|
52268
|
+
const dir = import_path14.default.join(getDuclawHomeDir(), "goal-context");
|
|
52269
|
+
(0, import_fs9.mkdirSync)(dir, { recursive: true });
|
|
52414
52270
|
return dir;
|
|
52415
52271
|
};
|
|
52416
|
-
var getGoalConversationPath = (goalId) =>
|
|
52272
|
+
var getGoalConversationPath = (goalId) => import_path14.default.join(getGoalConversationDir(), `${goalId}.json`);
|
|
52417
52273
|
var getGoalThreadId = (goalId) => `kanban:goal:${goalId}`;
|
|
52418
52274
|
var getGoalConversationContext = (goalId) => {
|
|
52419
52275
|
const file = getGoalConversationPath(goalId);
|
|
52420
|
-
if (!(0,
|
|
52421
|
-
const context = JSON.parse((0,
|
|
52276
|
+
if (!(0, import_fs9.existsSync)(file)) return null;
|
|
52277
|
+
const context = JSON.parse((0, import_fs9.readFileSync)(file, "utf-8"));
|
|
52422
52278
|
const defaultThreadId = getGoalThreadId(goalId);
|
|
52423
52279
|
return {
|
|
52424
52280
|
...context,
|
|
@@ -52442,13 +52298,13 @@ var ensureGoalConversationContext = (goalId, patch) => {
|
|
|
52442
52298
|
createdAt: existing?.createdAt ?? now,
|
|
52443
52299
|
updatedAt: now
|
|
52444
52300
|
};
|
|
52445
|
-
(0,
|
|
52301
|
+
(0, import_fs9.writeFileSync)(getGoalConversationPath(goalId), JSON.stringify(context, null, " "), "utf-8");
|
|
52446
52302
|
return context;
|
|
52447
52303
|
};
|
|
52448
52304
|
var deleteGoalConversationContext = (goalId) => {
|
|
52449
52305
|
const file = getGoalConversationPath(goalId);
|
|
52450
|
-
if (!(0,
|
|
52451
|
-
(0,
|
|
52306
|
+
if (!(0, import_fs9.existsSync)(file)) return;
|
|
52307
|
+
(0, import_fs9.rmSync)(file);
|
|
52452
52308
|
};
|
|
52453
52309
|
|
|
52454
52310
|
// src/tasks/goal.ts
|
|
@@ -52456,11 +52312,11 @@ import_dayjs2.default.extend(import_utc2.default);
|
|
|
52456
52312
|
import_dayjs2.default.extend(import_timezone2.default);
|
|
52457
52313
|
var getGoalDir = () => {
|
|
52458
52314
|
const goalDir = getDuclawTasksDir();
|
|
52459
|
-
(0,
|
|
52315
|
+
(0, import_fs10.mkdirSync)(goalDir, { recursive: true });
|
|
52460
52316
|
return goalDir;
|
|
52461
52317
|
};
|
|
52462
52318
|
var getGoalPath = (goalId) => {
|
|
52463
|
-
return
|
|
52319
|
+
return import_path15.default.join(getGoalDir(), `${goalId}.json`);
|
|
52464
52320
|
};
|
|
52465
52321
|
var sanitizeGoalDraft = (draft) => {
|
|
52466
52322
|
return {
|
|
@@ -52488,7 +52344,7 @@ var createGoal = (subjectOrInput, description = "") => {
|
|
|
52488
52344
|
createdAt: (0, import_dayjs2.default)().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss"),
|
|
52489
52345
|
updateAt: (0, import_dayjs2.default)().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss")
|
|
52490
52346
|
});
|
|
52491
|
-
(0,
|
|
52347
|
+
(0, import_fs10.writeFileSync)(`${getGoalPath(goalId)}`, JSON.stringify(goal, null, ` `), `utf-8`);
|
|
52492
52348
|
return goal;
|
|
52493
52349
|
};
|
|
52494
52350
|
var getGoalById = (id) => {
|
|
@@ -52503,11 +52359,11 @@ var getGoalBySubject = (subject) => {
|
|
|
52503
52359
|
};
|
|
52504
52360
|
var listGoal = () => {
|
|
52505
52361
|
const goalDir = getGoalDir();
|
|
52506
|
-
const files = (0,
|
|
52362
|
+
const files = (0, import_fs10.readdirSync)(goalDir);
|
|
52507
52363
|
let goals = [];
|
|
52508
52364
|
for (let file of files) {
|
|
52509
52365
|
if (file.endsWith(`.json`)) {
|
|
52510
|
-
const text2 = (0,
|
|
52366
|
+
const text2 = (0, import_fs10.readFileSync)(import_path15.default.join(goalDir, file), `utf-8`);
|
|
52511
52367
|
const goal = JSON.parse(text2);
|
|
52512
52368
|
goals.push(goal);
|
|
52513
52369
|
}
|
|
@@ -52543,13 +52399,13 @@ ${preview}${more}`
|
|
|
52543
52399
|
);
|
|
52544
52400
|
}
|
|
52545
52401
|
}
|
|
52546
|
-
(0,
|
|
52402
|
+
(0, import_fs10.writeFileSync)(getGoalPath(id), JSON.stringify(merged, null, " "), "utf-8");
|
|
52547
52403
|
return { ...merged };
|
|
52548
52404
|
};
|
|
52549
52405
|
var deleteGoal = (id) => {
|
|
52550
52406
|
const goalPath = getGoalPath(id);
|
|
52551
|
-
if (!(0,
|
|
52552
|
-
(0,
|
|
52407
|
+
if (!(0, import_fs10.existsSync)(goalPath)) return false;
|
|
52408
|
+
(0, import_fs10.unlinkSync)(goalPath);
|
|
52553
52409
|
deleteGoalConversationContext(id);
|
|
52554
52410
|
return true;
|
|
52555
52411
|
};
|
|
@@ -52963,63 +52819,415 @@ ${replies}`;
|
|
|
52963
52819
|
}
|
|
52964
52820
|
};
|
|
52965
52821
|
|
|
52966
|
-
// src/department/mailbox/mailbox.ts
|
|
52822
|
+
// src/department/mailbox/mailbox.ts
|
|
52823
|
+
var import_node_crypto11 = require("node:crypto");
|
|
52824
|
+
|
|
52825
|
+
// src/department/mailbox/events.ts
|
|
52826
|
+
var import_node_crypto9 = require("node:crypto");
|
|
52827
|
+
var recordMailboxEvent = (input) => {
|
|
52828
|
+
const db2 = createSqliteDB();
|
|
52829
|
+
const event = {
|
|
52830
|
+
id: (0, import_node_crypto9.randomUUID)().slice(0, 12),
|
|
52831
|
+
messageId: input.messageId,
|
|
52832
|
+
mailboxId: input.mailboxId,
|
|
52833
|
+
actorMailboxId: input.actorMailboxId,
|
|
52834
|
+
counterpartMailboxId: input.counterpartMailboxId,
|
|
52835
|
+
eventType: input.eventType,
|
|
52836
|
+
detail: input.detail,
|
|
52837
|
+
createdAt: input.createdAt ?? Date.now()
|
|
52838
|
+
};
|
|
52839
|
+
const stmt = db2.prepare(
|
|
52840
|
+
`INSERT INTO mailbox_events (
|
|
52841
|
+
id,
|
|
52842
|
+
message_id,
|
|
52843
|
+
mailbox_id,
|
|
52844
|
+
actor_mailbox_id,
|
|
52845
|
+
counterpart_mailbox_id,
|
|
52846
|
+
event_type,
|
|
52847
|
+
detail_json,
|
|
52848
|
+
created_at
|
|
52849
|
+
) VALUES (?,?,?,?,?,?,?,?)`
|
|
52850
|
+
);
|
|
52851
|
+
stmt.run(
|
|
52852
|
+
event.id,
|
|
52853
|
+
event.messageId || null,
|
|
52854
|
+
event.mailboxId,
|
|
52855
|
+
event.actorMailboxId || null,
|
|
52856
|
+
event.counterpartMailboxId || null,
|
|
52857
|
+
event.eventType,
|
|
52858
|
+
event.detail ? JSON.stringify(event.detail) : null,
|
|
52859
|
+
event.createdAt
|
|
52860
|
+
);
|
|
52861
|
+
return event;
|
|
52862
|
+
};
|
|
52863
|
+
var recordMailboxStatusChange = (params) => {
|
|
52864
|
+
if (params.previousStatus === params.nextStatus) {
|
|
52865
|
+
return null;
|
|
52866
|
+
}
|
|
52867
|
+
return recordMailboxEvent({
|
|
52868
|
+
messageId: params.messageId,
|
|
52869
|
+
mailboxId: params.mailboxId,
|
|
52870
|
+
actorMailboxId: params.actorMailboxId,
|
|
52871
|
+
counterpartMailboxId: params.counterpartMailboxId,
|
|
52872
|
+
eventType: "message_status_changed",
|
|
52873
|
+
detail: {
|
|
52874
|
+
previousStatus: params.previousStatus,
|
|
52875
|
+
nextStatus: params.nextStatus,
|
|
52876
|
+
reason: params.reason
|
|
52877
|
+
}
|
|
52878
|
+
});
|
|
52879
|
+
};
|
|
52880
|
+
|
|
52881
|
+
// src/department/DepartmentMember.ts
|
|
52882
|
+
var import_fs12 = require("fs");
|
|
52883
|
+
var import_path17 = __toESM(require("path"));
|
|
52884
|
+
|
|
52885
|
+
// src/department/Department.ts
|
|
52886
|
+
var import_path16 = __toESM(require("path"));
|
|
52887
|
+
var import_fs11 = require("fs");
|
|
52888
|
+
var legacyMigrationChecked = false;
|
|
52889
|
+
var getDepartmentBaseDir = () => {
|
|
52890
|
+
return import_path16.default.join(getDuclawHomeDir(), "department");
|
|
52891
|
+
};
|
|
52892
|
+
var getLegacyTeamBaseDir = () => {
|
|
52893
|
+
return import_path16.default.join(getDuclawHomeDir(), "team");
|
|
52894
|
+
};
|
|
52895
|
+
var getDepartmentWorkSpaceDir = (departmentName) => {
|
|
52896
|
+
return import_path16.default.join(getDepartmentBaseDir(), "workspace", departmentName);
|
|
52897
|
+
};
|
|
52898
|
+
var getLegacyTeamWorkSpaceDir = (teamName) => {
|
|
52899
|
+
return import_path16.default.join(getLegacyTeamBaseDir(), "workspace", teamName);
|
|
52900
|
+
};
|
|
52901
|
+
var getDepartmentJsonPath = (departmentName) => {
|
|
52902
|
+
return import_path16.default.join(getDepartmentWorkSpaceDir(departmentName), "department.json");
|
|
52903
|
+
};
|
|
52904
|
+
var getLegacyTeamJsonPath = (teamName) => {
|
|
52905
|
+
return import_path16.default.join(getLegacyTeamWorkSpaceDir(teamName), "team.json");
|
|
52906
|
+
};
|
|
52907
|
+
var mapLegacyRole = (role) => {
|
|
52908
|
+
return role === "team_manager" ? "department_head" : "executor";
|
|
52909
|
+
};
|
|
52910
|
+
var mapLegacyDepartment = (legacy) => {
|
|
52911
|
+
const departmentMembers = (legacy.teamMembers ?? []).map((member) => ({
|
|
52912
|
+
id: member.id,
|
|
52913
|
+
name: member.name,
|
|
52914
|
+
departmentId: legacy.id,
|
|
52915
|
+
mailBoxId: member.mailBoxId,
|
|
52916
|
+
workspaceId: member.workspaceId,
|
|
52917
|
+
role: mapLegacyRole(member.role),
|
|
52918
|
+
focusOn: member.focusOn
|
|
52919
|
+
}));
|
|
52920
|
+
const headMemberId = legacy.managerMemberId ?? departmentMembers.find((member) => member.role === "department_head")?.id;
|
|
52921
|
+
return {
|
|
52922
|
+
id: legacy.id,
|
|
52923
|
+
name: legacy.name,
|
|
52924
|
+
sourceGoalId: legacy.goalId,
|
|
52925
|
+
charter: legacy.goalId ? `Legacy department migrated from team goal ${legacy.goalId}.` : "Legacy department migrated from team data.",
|
|
52926
|
+
workpath: legacy.workpath,
|
|
52927
|
+
headMemberId,
|
|
52928
|
+
departmentMembers
|
|
52929
|
+
};
|
|
52930
|
+
};
|
|
52931
|
+
var migrateLegacyTeamsToDepartments = () => {
|
|
52932
|
+
if (legacyMigrationChecked) return;
|
|
52933
|
+
legacyMigrationChecked = true;
|
|
52934
|
+
const legacyWorkspaceDir = import_path16.default.join(getLegacyTeamBaseDir(), "workspace");
|
|
52935
|
+
if (!(0, import_fs11.existsSync)(legacyWorkspaceDir)) return;
|
|
52936
|
+
for (const legacyName of (0, import_fs11.readdirSync)(legacyWorkspaceDir)) {
|
|
52937
|
+
const legacyJsonPath = getLegacyTeamJsonPath(legacyName);
|
|
52938
|
+
if (!(0, import_fs11.existsSync)(legacyJsonPath)) continue;
|
|
52939
|
+
const departmentJsonPath = getDepartmentJsonPath(legacyName);
|
|
52940
|
+
if ((0, import_fs11.existsSync)(departmentJsonPath)) continue;
|
|
52941
|
+
try {
|
|
52942
|
+
const legacy = JSON.parse((0, import_fs11.readFileSync)(legacyJsonPath, "utf-8"));
|
|
52943
|
+
const department = mapLegacyDepartment(legacy);
|
|
52944
|
+
(0, import_fs11.mkdirSync)(getDepartmentWorkSpaceDir(department.name), { recursive: true });
|
|
52945
|
+
(0, import_fs11.writeFileSync)(departmentJsonPath, JSON.stringify(department, null, " "), "utf-8");
|
|
52946
|
+
} catch (err) {
|
|
52947
|
+
console.warn(`[department] Failed to migrate legacy team ${legacyName}: ${err.message}`);
|
|
52948
|
+
}
|
|
52949
|
+
}
|
|
52950
|
+
};
|
|
52951
|
+
var createDepartment = (departmentDefinition) => {
|
|
52952
|
+
if (!departmentDefinition) throw new Error(`[createDepartment] departmentDefinition\u4E0D\u80FD\u4E3A\u7A7A`);
|
|
52953
|
+
const departmentPath = getDepartmentWorkSpaceDir(departmentDefinition.name);
|
|
52954
|
+
(0, import_fs11.mkdirSync)(departmentPath, { recursive: true });
|
|
52955
|
+
(0, import_fs11.writeFileSync)(getDepartmentJsonPath(departmentDefinition.name), JSON.stringify(departmentDefinition, null, " "), "utf-8");
|
|
52956
|
+
return departmentDefinition;
|
|
52957
|
+
};
|
|
52958
|
+
var getDepartment = (name) => {
|
|
52959
|
+
migrateLegacyTeamsToDepartments();
|
|
52960
|
+
const departmentJsonPath = getDepartmentJsonPath(name);
|
|
52961
|
+
if (!(0, import_fs11.existsSync)(departmentJsonPath)) return null;
|
|
52962
|
+
const text2 = (0, import_fs11.readFileSync)(departmentJsonPath, "utf-8");
|
|
52963
|
+
return JSON.parse(text2);
|
|
52964
|
+
};
|
|
52965
|
+
var listDepartments = () => {
|
|
52966
|
+
migrateLegacyTeamsToDepartments();
|
|
52967
|
+
const workspaceDir = import_path16.default.join(getDepartmentBaseDir(), "workspace");
|
|
52968
|
+
if (!(0, import_fs11.existsSync)(workspaceDir)) return [];
|
|
52969
|
+
const departments = [];
|
|
52970
|
+
for (const departmentName of (0, import_fs11.readdirSync)(workspaceDir)) {
|
|
52971
|
+
const department = getDepartment(departmentName);
|
|
52972
|
+
if (department) departments.push(department);
|
|
52973
|
+
}
|
|
52974
|
+
return departments;
|
|
52975
|
+
};
|
|
52976
|
+
var getDepartmentById = (id) => {
|
|
52977
|
+
const department = listDepartments().find((item) => item.id === id);
|
|
52978
|
+
return department ?? null;
|
|
52979
|
+
};
|
|
52980
|
+
var deleteDepartment = (name) => {
|
|
52981
|
+
if (!(0, import_fs11.existsSync)(getDepartmentJsonPath(name))) {
|
|
52982
|
+
throw new Error(`[deleteDepartment] \u4E0D\u5B58\u5728\u5BF9\u5E94\u7684\u90E8\u95E8 ${name} \u7684 department.json \u6587\u4EF6`);
|
|
52983
|
+
}
|
|
52984
|
+
(0, import_fs11.rmSync)(getDepartmentJsonPath(name));
|
|
52985
|
+
};
|
|
52986
|
+
|
|
52987
|
+
// src/department/workspace/workspace.ts
|
|
52988
|
+
var db = createSqliteDB();
|
|
52989
|
+
var getWorkspaceId = (departmentName, memberName) => {
|
|
52990
|
+
return `${departmentName}::${memberName}`;
|
|
52991
|
+
};
|
|
52992
|
+
var createWorkspace = (workspace) => {
|
|
52993
|
+
const stmt = db.prepare(`INSERT INTO workspace (id, team_name, teammate_name, team_workpath) VALUES (?, ?, ?, ?) `);
|
|
52994
|
+
stmt.run(
|
|
52995
|
+
workspace.id,
|
|
52996
|
+
workspace.departmentName,
|
|
52997
|
+
workspace.memberName,
|
|
52998
|
+
workspace.departmentWorkPath
|
|
52999
|
+
);
|
|
53000
|
+
};
|
|
53001
|
+
var deleteWorkspace = (workspaceId) => {
|
|
53002
|
+
const stmt = db.prepare(`delete from workspace where id = ?`);
|
|
53003
|
+
stmt.run(workspaceId);
|
|
53004
|
+
};
|
|
53005
|
+
|
|
53006
|
+
// src/department/DepartmentMember.ts
|
|
53007
|
+
var createDepartmentMember = (departmentMemberDefinition) => {
|
|
53008
|
+
if (!departmentMemberDefinition) throw new Error(`[createDepartmentMember] departmentMemberDefinition\u4E0D\u80FD\u4E3A\u7A7A`);
|
|
53009
|
+
const { name, departmentId, workspaceId } = departmentMemberDefinition;
|
|
53010
|
+
const department = getDepartmentById(departmentId);
|
|
53011
|
+
if (!department) throw new Error(`[createDepartmentMember] \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 department: ${departmentId}`);
|
|
53012
|
+
const memberPath = import_path17.default.join(getDepartmentWorkSpaceDir(department.name), name);
|
|
53013
|
+
(0, import_fs12.mkdirSync)(memberPath, { recursive: true });
|
|
53014
|
+
const workspace = {
|
|
53015
|
+
id: getWorkspaceId(department.name, departmentMemberDefinition.name),
|
|
53016
|
+
departmentName: department.name,
|
|
53017
|
+
memberName: name,
|
|
53018
|
+
departmentWorkPath: memberPath
|
|
53019
|
+
};
|
|
53020
|
+
createWorkspace(workspace);
|
|
53021
|
+
if (!department.departmentMembers) {
|
|
53022
|
+
department.departmentMembers = [];
|
|
53023
|
+
}
|
|
53024
|
+
if (department.departmentMembers.some((member) => member.id === departmentMemberDefinition.id || member.name === departmentMemberDefinition.name)) {
|
|
53025
|
+
throw new Error(`[createDepartmentMember] \u90E8\u95E8 ${department.name} \u5DF2\u5B58\u5728\u540C\u540D\u6216\u540C id \u6210\u5458: ${departmentMemberDefinition.name}/${departmentMemberDefinition.id}`);
|
|
53026
|
+
}
|
|
53027
|
+
if (departmentMemberDefinition.role === "department_head") {
|
|
53028
|
+
const existingHead = department.headMemberId ? department.departmentMembers.find((member) => member.id === department.headMemberId) : department.departmentMembers.find((member) => member.role === "department_head");
|
|
53029
|
+
if (existingHead) {
|
|
53030
|
+
throw new Error(`[createDepartmentMember] \u90E8\u95E8 ${department.name} \u5DF2\u5B58\u5728 Department Head: ${existingHead.name}`);
|
|
53031
|
+
}
|
|
53032
|
+
department.headMemberId = departmentMemberDefinition.id;
|
|
53033
|
+
}
|
|
53034
|
+
department.departmentMembers.push(departmentMemberDefinition);
|
|
53035
|
+
(0, import_fs12.writeFileSync)(getDepartmentJsonPath(department.name), JSON.stringify(department, null, " "), "utf-8");
|
|
53036
|
+
return departmentMemberDefinition;
|
|
53037
|
+
};
|
|
53038
|
+
var listDepartmentMembers = (departmentName) => {
|
|
53039
|
+
const departmentJsonPath = getDepartmentJsonPath(departmentName);
|
|
53040
|
+
if (!(0, import_fs12.existsSync)(departmentJsonPath)) return [];
|
|
53041
|
+
const text2 = (0, import_fs12.readFileSync)(departmentJsonPath, "utf-8");
|
|
53042
|
+
const department = JSON.parse(text2);
|
|
53043
|
+
if (!department) throw new Error(`[listDepartmentMembers] \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 department: ${departmentName}`);
|
|
53044
|
+
return department.departmentMembers ?? [];
|
|
53045
|
+
};
|
|
53046
|
+
var getDepartmentMember = (departmentName, departmentMemberId) => {
|
|
53047
|
+
const members = listDepartmentMembers(departmentName);
|
|
53048
|
+
return members.find((member) => member.id === departmentMemberId) || null;
|
|
53049
|
+
};
|
|
53050
|
+
var getDepartmentMemberByName = (departmentName, departmentMemberName) => {
|
|
53051
|
+
const members = listDepartmentMembers(departmentName);
|
|
53052
|
+
return members.find((member) => member.name === departmentMemberName) || null;
|
|
53053
|
+
};
|
|
53054
|
+
var getDepartmentMemberByMailboxId = (mailboxId) => {
|
|
53055
|
+
const [departmentName, memberName] = mailboxId.split("::");
|
|
53056
|
+
if (!departmentName || !memberName) return null;
|
|
53057
|
+
return getDepartmentMemberByName(departmentName, memberName);
|
|
53058
|
+
};
|
|
53059
|
+
var getDepartmentMemberById = (memberId) => {
|
|
53060
|
+
for (const department of listDepartments()) {
|
|
53061
|
+
const targetMember = department.departmentMembers.find((member) => member.id === memberId);
|
|
53062
|
+
if (targetMember) return targetMember;
|
|
53063
|
+
}
|
|
53064
|
+
return null;
|
|
53065
|
+
};
|
|
53066
|
+
var deleteDepartmentMemberById = (departmentName, memberId) => {
|
|
53067
|
+
const department = getDepartment(departmentName);
|
|
53068
|
+
if (!department) throw new Error(`[deleteDepartmentMemberById] \u627E\u4E0D\u5230\u5BF9\u5E94\u7684 department: ${departmentName}`);
|
|
53069
|
+
const memberIdx = department.departmentMembers.findIndex((member) => member.id === memberId);
|
|
53070
|
+
if (memberIdx === -1) {
|
|
53071
|
+
throw new Error(`[deleteDepartmentMemberById] \u627E\u4E0D\u5230\u5BF9\u5E94 id \u7684 department member: ${memberId}`);
|
|
53072
|
+
}
|
|
53073
|
+
const workspaceId = department.departmentMembers[memberIdx].workspaceId;
|
|
53074
|
+
if (department.headMemberId === memberId) {
|
|
53075
|
+
delete department.headMemberId;
|
|
53076
|
+
}
|
|
53077
|
+
department.departmentMembers = department.departmentMembers.filter((_, index) => index !== memberIdx);
|
|
53078
|
+
(0, import_fs12.writeFileSync)(getDepartmentJsonPath(departmentName), JSON.stringify(department, null, " "), "utf-8");
|
|
53079
|
+
deleteWorkspace(workspaceId);
|
|
53080
|
+
};
|
|
53081
|
+
|
|
53082
|
+
// src/department/mailbox/ceoFollowup.ts
|
|
52967
53083
|
var import_node_crypto10 = require("node:crypto");
|
|
52968
|
-
|
|
52969
|
-
|
|
52970
|
-
|
|
52971
|
-
|
|
53084
|
+
var rowToFollowup = (row) => ({
|
|
53085
|
+
id: row.id,
|
|
53086
|
+
sourceMessageId: row.sourceMessageId,
|
|
53087
|
+
status: row.status,
|
|
53088
|
+
originUserId: row.originUserId,
|
|
53089
|
+
originPlatform: row.originPlatform,
|
|
53090
|
+
fromMailboxId: row.fromMailboxId,
|
|
53091
|
+
threadId: row.threadId ?? void 0,
|
|
53092
|
+
parentMessageId: row.parentMessageId ?? void 0,
|
|
53093
|
+
workItemId: row.workItemId ?? void 0,
|
|
53094
|
+
content: row.content,
|
|
53095
|
+
attempts: row.attempts,
|
|
53096
|
+
lastError: row.lastError ?? void 0,
|
|
53097
|
+
createdAt: row.createdAt,
|
|
53098
|
+
updatedAt: row.updatedAt,
|
|
53099
|
+
completedAt: row.completedAt ?? void 0
|
|
53100
|
+
});
|
|
53101
|
+
var selectById = (id) => {
|
|
52972
53102
|
const db2 = createSqliteDB();
|
|
52973
|
-
const
|
|
52974
|
-
|
|
52975
|
-
messageId: input.messageId,
|
|
52976
|
-
mailboxId: input.mailboxId,
|
|
52977
|
-
actorMailboxId: input.actorMailboxId,
|
|
52978
|
-
counterpartMailboxId: input.counterpartMailboxId,
|
|
52979
|
-
eventType: input.eventType,
|
|
52980
|
-
detail: input.detail,
|
|
52981
|
-
createdAt: input.createdAt ?? Date.now()
|
|
52982
|
-
};
|
|
52983
|
-
const stmt = db2.prepare(
|
|
52984
|
-
`INSERT INTO mailbox_events (
|
|
53103
|
+
const row = db2.prepare(`
|
|
53104
|
+
SELECT
|
|
52985
53105
|
id,
|
|
52986
|
-
|
|
52987
|
-
|
|
52988
|
-
|
|
52989
|
-
|
|
52990
|
-
|
|
52991
|
-
|
|
52992
|
-
|
|
52993
|
-
|
|
52994
|
-
|
|
52995
|
-
|
|
52996
|
-
|
|
52997
|
-
|
|
52998
|
-
|
|
52999
|
-
|
|
53000
|
-
|
|
53001
|
-
|
|
53002
|
-
|
|
53003
|
-
|
|
53106
|
+
source_message_id as sourceMessageId,
|
|
53107
|
+
status,
|
|
53108
|
+
origin_user_id as originUserId,
|
|
53109
|
+
origin_platform as originPlatform,
|
|
53110
|
+
from_mailbox_id as fromMailboxId,
|
|
53111
|
+
thread_id as threadId,
|
|
53112
|
+
parent_message_id as parentMessageId,
|
|
53113
|
+
work_item_id as workItemId,
|
|
53114
|
+
content,
|
|
53115
|
+
attempts,
|
|
53116
|
+
last_error as lastError,
|
|
53117
|
+
created_at as createdAt,
|
|
53118
|
+
updated_at as updatedAt,
|
|
53119
|
+
completed_at as completedAt
|
|
53120
|
+
FROM ceo_followups
|
|
53121
|
+
WHERE id = ?
|
|
53122
|
+
`).get(id);
|
|
53123
|
+
return row ? rowToFollowup(row) : null;
|
|
53124
|
+
};
|
|
53125
|
+
var enqueueCeoFollowupFromMailbox = (message) => {
|
|
53126
|
+
if (message.toMailboxId !== "manager") return null;
|
|
53127
|
+
if (message.workItemRole === "followup") return null;
|
|
53128
|
+
if (!message.originUserId || !message.originPlatform) return null;
|
|
53129
|
+
const db2 = createSqliteDB();
|
|
53130
|
+
const now = Date.now();
|
|
53131
|
+
const id = `cfu_${(0, import_node_crypto10.randomUUID)().slice(0, 12)}`;
|
|
53132
|
+
db2.prepare(`
|
|
53133
|
+
INSERT INTO ceo_followups (
|
|
53134
|
+
id,
|
|
53135
|
+
source_message_id,
|
|
53136
|
+
status,
|
|
53137
|
+
origin_user_id,
|
|
53138
|
+
origin_platform,
|
|
53139
|
+
from_mailbox_id,
|
|
53140
|
+
thread_id,
|
|
53141
|
+
parent_message_id,
|
|
53142
|
+
work_item_id,
|
|
53143
|
+
content,
|
|
53144
|
+
created_at,
|
|
53145
|
+
updated_at
|
|
53146
|
+
) VALUES (?, ?, 'pending', ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
53147
|
+
ON CONFLICT(source_message_id) DO UPDATE SET
|
|
53148
|
+
status = CASE
|
|
53149
|
+
WHEN ceo_followups.status = 'completed' THEN ceo_followups.status
|
|
53150
|
+
ELSE 'pending'
|
|
53151
|
+
END,
|
|
53152
|
+
origin_user_id = excluded.origin_user_id,
|
|
53153
|
+
origin_platform = excluded.origin_platform,
|
|
53154
|
+
from_mailbox_id = excluded.from_mailbox_id,
|
|
53155
|
+
thread_id = excluded.thread_id,
|
|
53156
|
+
parent_message_id = excluded.parent_message_id,
|
|
53157
|
+
work_item_id = excluded.work_item_id,
|
|
53158
|
+
content = excluded.content,
|
|
53159
|
+
updated_at = excluded.updated_at
|
|
53160
|
+
`).run(
|
|
53161
|
+
id,
|
|
53162
|
+
message.id,
|
|
53163
|
+
message.originUserId,
|
|
53164
|
+
message.originPlatform,
|
|
53165
|
+
message.fromMailboxId,
|
|
53166
|
+
message.threadId ?? message.id,
|
|
53167
|
+
message.parentMessageId ?? null,
|
|
53168
|
+
message.workItemId ?? null,
|
|
53169
|
+
message.content,
|
|
53170
|
+
now,
|
|
53171
|
+
now
|
|
53004
53172
|
);
|
|
53005
|
-
|
|
53173
|
+
const row = db2.prepare(`
|
|
53174
|
+
SELECT id FROM ceo_followups WHERE source_message_id = ?
|
|
53175
|
+
`).get(message.id);
|
|
53176
|
+
return row ? selectById(row.id) : null;
|
|
53006
53177
|
};
|
|
53007
|
-
var
|
|
53008
|
-
|
|
53009
|
-
|
|
53010
|
-
|
|
53011
|
-
|
|
53012
|
-
|
|
53013
|
-
|
|
53014
|
-
|
|
53015
|
-
|
|
53016
|
-
|
|
53017
|
-
|
|
53018
|
-
|
|
53019
|
-
|
|
53020
|
-
|
|
53178
|
+
var completeCeoFollowup = (id) => {
|
|
53179
|
+
const db2 = createSqliteDB();
|
|
53180
|
+
const now = Date.now();
|
|
53181
|
+
db2.prepare(`
|
|
53182
|
+
UPDATE ceo_followups
|
|
53183
|
+
SET status = 'completed',
|
|
53184
|
+
completed_at = COALESCE(completed_at, ?),
|
|
53185
|
+
updated_at = ?,
|
|
53186
|
+
last_error = NULL
|
|
53187
|
+
WHERE id = ?
|
|
53188
|
+
AND status IN ('pending', 'processing', 'failed')
|
|
53189
|
+
`).run(now, now, id);
|
|
53190
|
+
db2.prepare(`
|
|
53191
|
+
UPDATE mailbox
|
|
53192
|
+
SET status = 'done',
|
|
53193
|
+
updated_at = ?
|
|
53194
|
+
WHERE id = (SELECT source_message_id FROM ceo_followups WHERE id = ?)
|
|
53195
|
+
AND status IN ('pending', 'processing', 'read')
|
|
53196
|
+
`).run(now, id);
|
|
53197
|
+
};
|
|
53198
|
+
var completePendingCeoFollowupsForUser = (originUserId) => {
|
|
53199
|
+
const db2 = createSqliteDB();
|
|
53200
|
+
const now = Date.now();
|
|
53201
|
+
const rows = db2.prepare(`
|
|
53202
|
+
SELECT id, source_message_id as sourceMessageId
|
|
53203
|
+
FROM ceo_followups
|
|
53204
|
+
WHERE origin_user_id = ?
|
|
53205
|
+
AND status IN ('pending', 'processing', 'failed')
|
|
53206
|
+
`).all(originUserId);
|
|
53207
|
+
const tx = db2.transaction((items) => {
|
|
53208
|
+
const completeStmt = db2.prepare(`
|
|
53209
|
+
UPDATE ceo_followups
|
|
53210
|
+
SET status = 'completed',
|
|
53211
|
+
completed_at = COALESCE(completed_at, ?),
|
|
53212
|
+
updated_at = ?,
|
|
53213
|
+
last_error = NULL
|
|
53214
|
+
WHERE id = ?
|
|
53215
|
+
AND status IN ('pending', 'processing', 'failed')
|
|
53216
|
+
`);
|
|
53217
|
+
const doneStmt = db2.prepare(`
|
|
53218
|
+
UPDATE mailbox
|
|
53219
|
+
SET status = 'done',
|
|
53220
|
+
updated_at = ?
|
|
53221
|
+
WHERE id = ?
|
|
53222
|
+
AND status IN ('pending', 'processing', 'read')
|
|
53223
|
+
`);
|
|
53224
|
+
for (const item of items) {
|
|
53225
|
+
completeStmt.run(now, now, item.id);
|
|
53226
|
+
doneStmt.run(now, item.sourceMessageId);
|
|
53021
53227
|
}
|
|
53022
53228
|
});
|
|
53229
|
+
tx(rows);
|
|
53230
|
+
return rows.length;
|
|
53023
53231
|
};
|
|
53024
53232
|
|
|
53025
53233
|
// src/department/mailbox/mailbox.ts
|
|
@@ -53217,7 +53425,7 @@ var recordMailboxReceivedAgentEvent = (msg) => {
|
|
|
53217
53425
|
};
|
|
53218
53426
|
var sendMessage2 = (fromMailboxId, toMailboxId, content, options) => {
|
|
53219
53427
|
const db2 = createSqliteDB();
|
|
53220
|
-
const id = (0,
|
|
53428
|
+
const id = (0, import_node_crypto11.randomUUID)().slice(0, 8);
|
|
53221
53429
|
const threadId = options?.threadId || id;
|
|
53222
53430
|
const workItemContext = resolveWorkItemContext(fromMailboxId, toMailboxId, id, options);
|
|
53223
53431
|
const stmt = db2.prepare(`insert into mailbox (
|
|
@@ -53508,7 +53716,7 @@ var departmentCommunicate = {
|
|
|
53508
53716
|
};
|
|
53509
53717
|
|
|
53510
53718
|
// src/tools/tools/department/DepartmentCreate.ts
|
|
53511
|
-
var
|
|
53719
|
+
var import_node_crypto12 = require("node:crypto");
|
|
53512
53720
|
var DESCRIPTION23 = `
|
|
53513
53721
|
\u521B\u5EFA\u90E8\u95E8\u3002Department \u662F\u516C\u53F8\u7EC4\u7EC7\u4E2D\u7684\u957F\u671F\u804C\u8D23\u5355\u5143\uFF0C\u4E0D\u662F\u4E00\u6B21\u6027\u9879\u76EE\u5C0F\u961F\u3002
|
|
53514
53722
|
|
|
@@ -53551,7 +53759,7 @@ var departmentCreate = {
|
|
|
53551
53759
|
return `[departmentCreate] \u4E0D\u5B58\u5728 id=${sourceGoalId} \u7684\u76EE\u6807`;
|
|
53552
53760
|
}
|
|
53553
53761
|
let departmentDefinition = {
|
|
53554
|
-
id: (0,
|
|
53762
|
+
id: (0, import_node_crypto12.randomUUID)().slice(0, 8),
|
|
53555
53763
|
name,
|
|
53556
53764
|
charter,
|
|
53557
53765
|
sourceGoalId,
|
|
@@ -53620,7 +53828,7 @@ var departmentDelete = {
|
|
|
53620
53828
|
// src/department/learning.ts
|
|
53621
53829
|
var import_node_fs8 = require("node:fs");
|
|
53622
53830
|
var import_node_path18 = __toESM(require("node:path"));
|
|
53623
|
-
var
|
|
53831
|
+
var import_node_crypto13 = require("node:crypto");
|
|
53624
53832
|
|
|
53625
53833
|
// src/skill/SkillValidator.ts
|
|
53626
53834
|
var import_node_fs7 = require("node:fs");
|
|
@@ -53858,7 +54066,7 @@ var listDepartmentMemories = (departmentName) => {
|
|
|
53858
54066
|
var createDepartmentMemory = (departmentName, input) => {
|
|
53859
54067
|
const now = Date.now();
|
|
53860
54068
|
const memory = {
|
|
53861
|
-
id: (0,
|
|
54069
|
+
id: (0, import_node_crypto13.randomUUID)().slice(0, 8),
|
|
53862
54070
|
departmentName,
|
|
53863
54071
|
title: input.title,
|
|
53864
54072
|
content: input.content,
|
|
@@ -53909,7 +54117,7 @@ ${formatSkillValidationIssues(validation)}`);
|
|
|
53909
54117
|
}
|
|
53910
54118
|
const now = Date.now();
|
|
53911
54119
|
const skill = {
|
|
53912
|
-
id: (0,
|
|
54120
|
+
id: (0, import_node_crypto13.randomUUID)().slice(0, 8),
|
|
53913
54121
|
departmentName,
|
|
53914
54122
|
skillName: input.skillName,
|
|
53915
54123
|
description: input.description,
|
|
@@ -53961,7 +54169,7 @@ var createDepartmentProposal = (input) => {
|
|
|
53961
54169
|
const records = readJsonArray(proposalsPath());
|
|
53962
54170
|
const proposal = {
|
|
53963
54171
|
...input,
|
|
53964
|
-
id: (0,
|
|
54172
|
+
id: (0, import_node_crypto13.randomUUID)().slice(0, 8),
|
|
53965
54173
|
status: "pending",
|
|
53966
54174
|
createdAt: Date.now()
|
|
53967
54175
|
};
|
|
@@ -54218,7 +54426,7 @@ var departmentList = {
|
|
|
54218
54426
|
};
|
|
54219
54427
|
|
|
54220
54428
|
// src/tools/tools/department/DepartmentMemberCreate.ts
|
|
54221
|
-
var
|
|
54429
|
+
var import_node_crypto14 = require("node:crypto");
|
|
54222
54430
|
var DESCRIPTION26 = `
|
|
54223
54431
|
\u521B\u5EFA\u90E8\u95E8\u6210\u5458\u3002
|
|
54224
54432
|
|
|
@@ -54284,7 +54492,7 @@ var departmentMemberCreate = {
|
|
|
54284
54492
|
}
|
|
54285
54493
|
}
|
|
54286
54494
|
let departmentMember = {
|
|
54287
|
-
id: (0,
|
|
54495
|
+
id: (0, import_node_crypto14.randomUUID)().slice(0, 8),
|
|
54288
54496
|
name,
|
|
54289
54497
|
departmentId: department.id,
|
|
54290
54498
|
mailBoxId: getMailBoxId(department.name, name),
|
|
@@ -55158,7 +55366,7 @@ var readDreamHistoryLimit = () => {
|
|
|
55158
55366
|
var import_node_fs9 = require("node:fs");
|
|
55159
55367
|
var import_node_os2 = require("node:os");
|
|
55160
55368
|
var import_node_path19 = require("node:path");
|
|
55161
|
-
var
|
|
55369
|
+
var import_node_crypto15 = require("node:crypto");
|
|
55162
55370
|
var SkillForgeEngine = class {
|
|
55163
55371
|
proposalStorage;
|
|
55164
55372
|
draftRoot;
|
|
@@ -55192,7 +55400,7 @@ ${formatSkillValidationIssues(validation)}`);
|
|
|
55192
55400
|
if (pending.some((p) => p.skillName === skillName)) {
|
|
55193
55401
|
return null;
|
|
55194
55402
|
}
|
|
55195
|
-
const id = (0,
|
|
55403
|
+
const id = (0, import_node_crypto15.randomBytes)(4).toString("hex");
|
|
55196
55404
|
const draftDir = (0, import_node_path19.join)(this.draftRoot, userId, id);
|
|
55197
55405
|
(0, import_node_fs9.mkdirSync)(draftDir, { recursive: true });
|
|
55198
55406
|
(0, import_node_fs9.writeFileSync)((0, import_node_path19.join)(draftDir, "SKILL.md"), skillMd, "utf-8");
|
|
@@ -56129,7 +56337,7 @@ var RUNTIME_PROCESS_SAFETY_PROMPT = `
|
|
|
56129
56337
|
`.trim();
|
|
56130
56338
|
|
|
56131
56339
|
// src/tracing/runtimeTracer.ts
|
|
56132
|
-
var
|
|
56340
|
+
var import_node_crypto16 = require("node:crypto");
|
|
56133
56341
|
|
|
56134
56342
|
// src/tracing/redact.ts
|
|
56135
56343
|
var SECRET_KEY_PATTERN = /(api[-_]?key|token|secret|password|authorization|cookie|private[-_]?key)/i;
|
|
@@ -56191,7 +56399,7 @@ var LangSmithRun = class _LangSmithRun {
|
|
|
56191
56399
|
extra: { metadata: redactForTrace(input.metadata) }
|
|
56192
56400
|
});
|
|
56193
56401
|
await child.postRun();
|
|
56194
|
-
return new _LangSmithRun(child.id ?? (0,
|
|
56402
|
+
return new _LangSmithRun(child.id ?? (0, import_node_crypto16.randomUUID)(), child);
|
|
56195
56403
|
}
|
|
56196
56404
|
async end(result) {
|
|
56197
56405
|
await this.run.end(redactForTrace(result.outputs), result.error);
|
|
@@ -56223,11 +56431,186 @@ var createRuntimeTracer = () => {
|
|
|
56223
56431
|
})
|
|
56224
56432
|
});
|
|
56225
56433
|
await run.postRun();
|
|
56226
|
-
return new LangSmithRun(run.id ?? (0,
|
|
56434
|
+
return new LangSmithRun(run.id ?? (0, import_node_crypto16.randomUUID)(), run);
|
|
56227
56435
|
}
|
|
56228
56436
|
};
|
|
56229
56437
|
};
|
|
56230
56438
|
|
|
56439
|
+
// src/agent/outboundDedup.ts
|
|
56440
|
+
var import_node_crypto17 = require("node:crypto");
|
|
56441
|
+
var DEFAULT_WINDOW_MS = 15e3;
|
|
56442
|
+
var recentSends = /* @__PURE__ */ new Map();
|
|
56443
|
+
var lastSweepAt = 0;
|
|
56444
|
+
var normalize2 = (text2) => text2.replace(/\s+/g, " ").trim();
|
|
56445
|
+
var keyFor = (userId, normalized) => {
|
|
56446
|
+
const hash = (0, import_node_crypto17.createHash)("sha1").update(normalized).digest("hex");
|
|
56447
|
+
return `${userId}::${hash}`;
|
|
56448
|
+
};
|
|
56449
|
+
var sweep = (now, windowMs) => {
|
|
56450
|
+
if (now - lastSweepAt < windowMs) return;
|
|
56451
|
+
lastSweepAt = now;
|
|
56452
|
+
for (const [k, ts] of recentSends) {
|
|
56453
|
+
if (now - ts > windowMs) recentSends.delete(k);
|
|
56454
|
+
}
|
|
56455
|
+
};
|
|
56456
|
+
var claimOutboundSend = (userId, text2, windowMs = DEFAULT_WINDOW_MS) => {
|
|
56457
|
+
const normalized = normalize2(text2);
|
|
56458
|
+
if (!normalized) return true;
|
|
56459
|
+
const now = Date.now();
|
|
56460
|
+
sweep(now, windowMs);
|
|
56461
|
+
const key = keyFor(userId, normalized);
|
|
56462
|
+
const last = recentSends.get(key);
|
|
56463
|
+
if (last !== void 0 && now - last < windowMs) {
|
|
56464
|
+
return false;
|
|
56465
|
+
}
|
|
56466
|
+
recentSends.set(key, now);
|
|
56467
|
+
return true;
|
|
56468
|
+
};
|
|
56469
|
+
var claimOutboundFileSend = (userId, fileName, fileRef, windowMs = DEFAULT_WINDOW_MS) => claimOutboundSend(userId, `file:${fileName}:${fileRef}`, windowMs);
|
|
56470
|
+
|
|
56471
|
+
// src/agent/workDossier.ts
|
|
56472
|
+
var textPreview = (value, max = 240) => value.length <= max ? value : `${value.slice(0, max)}...`;
|
|
56473
|
+
var stringArray = (value) => {
|
|
56474
|
+
if (typeof value === `string` && value.trim()) return [value];
|
|
56475
|
+
if (!Array.isArray(value)) return [];
|
|
56476
|
+
return value.filter((item) => typeof item === `string` && item.trim().length > 0);
|
|
56477
|
+
};
|
|
56478
|
+
var findWorkItemIdFromCeoFollowups = (ids) => {
|
|
56479
|
+
if (ids.length === 0) return null;
|
|
56480
|
+
const db2 = createSqliteDB();
|
|
56481
|
+
const placeholders = ids.map(() => `?`).join(`,`);
|
|
56482
|
+
const row = db2.prepare(`
|
|
56483
|
+
SELECT work_item_id as workItemId
|
|
56484
|
+
FROM ceo_followups
|
|
56485
|
+
WHERE id IN (${placeholders})
|
|
56486
|
+
AND work_item_id IS NOT NULL
|
|
56487
|
+
ORDER BY created_at DESC
|
|
56488
|
+
LIMIT 1
|
|
56489
|
+
`).get(...ids);
|
|
56490
|
+
return row?.workItemId ?? null;
|
|
56491
|
+
};
|
|
56492
|
+
var findWorkItemIdFromMailbox = (messageId) => {
|
|
56493
|
+
const db2 = createSqliteDB();
|
|
56494
|
+
const row = db2.prepare(`
|
|
56495
|
+
SELECT work_item_id as workItemId
|
|
56496
|
+
FROM mailbox
|
|
56497
|
+
WHERE id = ?
|
|
56498
|
+
AND work_item_id IS NOT NULL
|
|
56499
|
+
`).get(messageId);
|
|
56500
|
+
return row?.workItemId ?? null;
|
|
56501
|
+
};
|
|
56502
|
+
var workItemIdFromRequest = (request) => {
|
|
56503
|
+
const fromMetadata = request.metadata?.workItemId;
|
|
56504
|
+
if (typeof fromMetadata === `string` && fromMetadata.trim()) return fromMetadata;
|
|
56505
|
+
const followupIds = [
|
|
56506
|
+
...stringArray(request.metadata?.ceoFollowupId),
|
|
56507
|
+
...stringArray(request.metadata?.ceoFollowupIds)
|
|
56508
|
+
];
|
|
56509
|
+
const fromFollowups = findWorkItemIdFromCeoFollowups(followupIds);
|
|
56510
|
+
if (fromFollowups) return fromFollowups;
|
|
56511
|
+
return findWorkItemIdFromMailbox(request.requestId);
|
|
56512
|
+
};
|
|
56513
|
+
var rowsForWorkItem = (workItemId) => {
|
|
56514
|
+
const db2 = createSqliteDB();
|
|
56515
|
+
return db2.prepare(`
|
|
56516
|
+
SELECT
|
|
56517
|
+
id,
|
|
56518
|
+
from_mailbox_id as fromMailboxId,
|
|
56519
|
+
to_mailbox_id as toMailboxId,
|
|
56520
|
+
content,
|
|
56521
|
+
status,
|
|
56522
|
+
work_item_role as workItemRole,
|
|
56523
|
+
send_time as sendTime
|
|
56524
|
+
FROM mailbox
|
|
56525
|
+
WHERE work_item_id = ?
|
|
56526
|
+
ORDER BY send_time ASC
|
|
56527
|
+
LIMIT 12
|
|
56528
|
+
`).all(workItemId);
|
|
56529
|
+
};
|
|
56530
|
+
var buildWorkDossier = (request) => {
|
|
56531
|
+
const role = request.departmentAgentId ? `Department Agent` : `Main Manager/CEO`;
|
|
56532
|
+
const workItemId = workItemIdFromRequest(request);
|
|
56533
|
+
const rows = workItemId ? rowsForWorkItem(workItemId) : [];
|
|
56534
|
+
const progressRows = rows.filter((row) => row.workItemRole === `followup`);
|
|
56535
|
+
const finalRows = rows.filter((row) => row.workItemRole === `upstream_report`);
|
|
56536
|
+
const lines = [
|
|
56537
|
+
`<work-dossier>`,
|
|
56538
|
+
`\u4F60\u7684\u89D2\u8272\uFF1A${role}`,
|
|
56539
|
+
request.departmentAgentId ? `\u5F53\u524D\u90AE\u7BB1\uFF1A${request.departmentAgentId}` : `\u5F53\u524D\u7528\u6237\uFF1A${request.userId}`,
|
|
56540
|
+
workItemId ? `work_item_id\uFF1A${workItemId}` : ``,
|
|
56541
|
+
finalRows.length > 0 ? `\u7528\u6237\u662F\u5426\u5DF2\u6536\u5230\u6700\u7EC8\u7ED3\u679C\uFF1A\u7B49\u5F85 CEO \u7528\u6237\u53EF\u89C1\u6C47\u62A5` : `\u7528\u6237\u662F\u5426\u5DF2\u6536\u5230\u6700\u7EC8\u7ED3\u679C\uFF1A\u5426\u6216\u672A\u77E5`,
|
|
56542
|
+
progressRows.length > 0 ? `\u5185\u90E8\u5F53\u524D\u8FDB\u5C55\uFF1A` : ``,
|
|
56543
|
+
...progressRows.map((row) => `- ${row.fromMailboxId} -> ${row.toMailboxId}: ${textPreview(row.content)}`),
|
|
56544
|
+
finalRows.length === 0 ? `\u5F53\u524D\u7F3A\u53E3\uFF1A\u8FD8\u6CA1\u6709\u6700\u7EC8\u62A5\u544A` : `\u5F53\u524D\u7F3A\u53E3\uFF1ACEO \u9700\u8981\u6C47\u603B\u6700\u7EC8\u62A5\u544A\u5E76\u5411\u7528\u6237\u4EA4\u4ED8`,
|
|
56545
|
+
finalRows.length === 0 ? `\u5EFA\u8BAE\u52A8\u4F5C\uFF1A\u4E0D\u8981\u91CD\u590D\u5411\u7528\u6237\u64AD\u62A5\u5185\u90E8\u8FDB\u5C55\uFF1B\u7B49\u5F85\u6700\u7EC8\u62A5\u544A\uFF0C\u6216\u5728\u5408\u7406\u7B49\u5F85\u65F6\u95F4\u540E\u5411\u8D1F\u8D23\u4EBA\u8BE2\u95EE\u4E00\u6B21\u3002` : `\u5EFA\u8BAE\u52A8\u4F5C\uFF1A\u6C47\u603B\u6700\u7EC8\u62A5\u544A\uFF0C\u5411\u7528\u6237\u53D1\u9001\u4E00\u6B21\u6E05\u6670\u7B54\u590D\uFF0C\u7136\u540E\u7ED3\u675F\u672C\u8F6E\u3002`,
|
|
56546
|
+
`</work-dossier>`
|
|
56547
|
+
].filter(Boolean);
|
|
56548
|
+
return lines.join(`
|
|
56549
|
+
`);
|
|
56550
|
+
};
|
|
56551
|
+
|
|
56552
|
+
// src/agent/duclawCoreHooks.ts
|
|
56553
|
+
var duclawTraceIdentity = (request) => {
|
|
56554
|
+
if (!request.departmentAgentId) {
|
|
56555
|
+
return { name: `CEO turn`, role: `ceo` };
|
|
56556
|
+
}
|
|
56557
|
+
const member = getDepartmentMemberByMailboxId(request.departmentAgentId);
|
|
56558
|
+
if (member?.role === `department_head`) {
|
|
56559
|
+
return {
|
|
56560
|
+
name: `Department Head turn: ${request.departmentAgentId}`,
|
|
56561
|
+
role: `department_head`,
|
|
56562
|
+
memberName: member.name,
|
|
56563
|
+
mailboxId: request.departmentAgentId
|
|
56564
|
+
};
|
|
56565
|
+
}
|
|
56566
|
+
if (member?.role === `executor`) {
|
|
56567
|
+
return {
|
|
56568
|
+
name: `Executor turn: ${request.departmentAgentId}`,
|
|
56569
|
+
role: `executor`,
|
|
56570
|
+
memberName: member.name,
|
|
56571
|
+
mailboxId: request.departmentAgentId
|
|
56572
|
+
};
|
|
56573
|
+
}
|
|
56574
|
+
return {
|
|
56575
|
+
name: `Department Agent turn: ${request.departmentAgentId}`,
|
|
56576
|
+
role: `department_agent`,
|
|
56577
|
+
mailboxId: request.departmentAgentId
|
|
56578
|
+
};
|
|
56579
|
+
};
|
|
56580
|
+
var createDuclawCoreHooks = () => ({
|
|
56581
|
+
augmentUserContent({ request, content }) {
|
|
56582
|
+
return attachRecentAttachmentContext(request, content);
|
|
56583
|
+
},
|
|
56584
|
+
completeUserVisibleDelivery({ request }) {
|
|
56585
|
+
const ids = ceoFollowupIdsFromMetadata(request.metadata);
|
|
56586
|
+
if (ids.length > 0) {
|
|
56587
|
+
for (const id of ids) completeCeoFollowup(id);
|
|
56588
|
+
return;
|
|
56589
|
+
}
|
|
56590
|
+
completePendingCeoFollowupsForUser(request.userId);
|
|
56591
|
+
},
|
|
56592
|
+
buildSystemContext({ request }) {
|
|
56593
|
+
return buildWorkDossier(request);
|
|
56594
|
+
},
|
|
56595
|
+
claimOutboundText({ request, text: text2 }) {
|
|
56596
|
+
return claimOutboundSend(request.userId, text2);
|
|
56597
|
+
},
|
|
56598
|
+
claimOutboundFile({ request, fileName, file }) {
|
|
56599
|
+
return claimOutboundFileSend(request.userId, fileName, file);
|
|
56600
|
+
},
|
|
56601
|
+
traceIdentity: duclawTraceIdentity
|
|
56602
|
+
});
|
|
56603
|
+
var ceoFollowupIdsFromMetadata = (metadata) => {
|
|
56604
|
+
const ids = /* @__PURE__ */ new Set();
|
|
56605
|
+
if (typeof metadata?.ceoFollowupId === "string") ids.add(metadata.ceoFollowupId);
|
|
56606
|
+
if (Array.isArray(metadata?.ceoFollowupIds)) {
|
|
56607
|
+
for (const id of metadata.ceoFollowupIds) {
|
|
56608
|
+
if (typeof id === "string") ids.add(id);
|
|
56609
|
+
}
|
|
56610
|
+
}
|
|
56611
|
+
return Array.from(ids);
|
|
56612
|
+
};
|
|
56613
|
+
|
|
56231
56614
|
// src/agent/duclawAgentConfig.ts
|
|
56232
56615
|
var DEFAULT_WORKSPACE_PATH = getDuclawWorkspaceDir();
|
|
56233
56616
|
var getDefaultAgentConfig = (tools, systemPrompt, options = {}) => {
|
|
@@ -56467,14 +56850,42 @@ ${getSkillMeta()}
|
|
|
56467
56850
|
dreamEngine,
|
|
56468
56851
|
skillForgeEngine,
|
|
56469
56852
|
memoryEngine,
|
|
56470
|
-
tracer: createRuntimeTracer()
|
|
56853
|
+
tracer: createRuntimeTracer(),
|
|
56854
|
+
hooks: createDuclawCoreHooks()
|
|
56471
56855
|
};
|
|
56472
56856
|
return agentConfig;
|
|
56473
56857
|
};
|
|
56858
|
+
|
|
56859
|
+
// src/sdk/duclawPreset.ts
|
|
56860
|
+
var duclawPreset = () => {
|
|
56861
|
+
const config2 = getDefaultAgentConfig();
|
|
56862
|
+
if (!config2.toolExecutor) {
|
|
56863
|
+
throw new Error("[duclawPreset] default toolExecutor is missing");
|
|
56864
|
+
}
|
|
56865
|
+
return {
|
|
56866
|
+
system: config2.systemPrompt,
|
|
56867
|
+
storage: config2.storage,
|
|
56868
|
+
tools: config2.tools,
|
|
56869
|
+
toolExecutor: config2.toolExecutor,
|
|
56870
|
+
maxIterations: config2.maxIterations,
|
|
56871
|
+
channelPlugin: config2.channelPlugin,
|
|
56872
|
+
workspacePath: config2.workspacePath,
|
|
56873
|
+
topicStorage: config2.topicStorage,
|
|
56874
|
+
compactSummaryStorage: config2.compactSummaryStorage,
|
|
56875
|
+
recallIndexStorage: config2.recallIndexStorage,
|
|
56876
|
+
backgroundManager: config2.backgroundManager,
|
|
56877
|
+
dreamEngine: config2.dreamEngine,
|
|
56878
|
+
skillForgeEngine: config2.skillForgeEngine,
|
|
56879
|
+
memoryEngine: config2.memoryEngine,
|
|
56880
|
+
tracer: config2.tracer,
|
|
56881
|
+
hooks: config2.hooks
|
|
56882
|
+
};
|
|
56883
|
+
};
|
|
56474
56884
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56475
56885
|
0 && (module.exports = {
|
|
56476
56886
|
createDefaultToolHookPlugins,
|
|
56477
56887
|
createDefaultTools,
|
|
56478
56888
|
createDuclawTools,
|
|
56889
|
+
duclawPreset,
|
|
56479
56890
|
getDefaultAgentConfig
|
|
56480
56891
|
});
|