@inkeep/agents-core 0.24.1 → 0.25.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/{chunk-5B6IOJZY.js → chunk-ALZI4IXB.js} +57 -17
- package/dist/{chunk-ZGJI6UNK.js → chunk-HMVAAUTK.js} +42 -23
- package/dist/{chunk-HN77JIDP.js → chunk-NXC2HZQL.js} +46 -13
- package/dist/client-exports.cjs +99 -36
- package/dist/client-exports.d.cts +7 -11
- package/dist/client-exports.d.ts +7 -11
- package/dist/client-exports.js +3 -11
- package/dist/db/schema.cjs +56 -16
- package/dist/db/schema.d.cts +2 -2
- package/dist/db/schema.d.ts +2 -2
- package/dist/db/schema.js +1 -1
- package/dist/index.cjs +1069 -592
- package/dist/index.d.cts +276 -86
- package/dist/index.d.ts +276 -86
- package/dist/index.js +910 -544
- package/dist/{schema-PgBNwsV-.d.ts → schema-CDKDLrBu.d.ts} +188 -62
- package/dist/{schema-B8NMPwEM.d.cts → schema-P1kG10Kn.d.cts} +188 -62
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/{utility-mGrlR4Ta.d.cts → utility-CWjvUL4k.d.cts} +329 -71
- package/dist/{utility-mGrlR4Ta.d.ts → utility-CWjvUL4k.d.ts} +329 -71
- package/dist/validation/index.cjs +146 -50
- package/dist/validation/index.d.cts +5 -5
- package/dist/validation/index.d.ts +5 -5
- package/dist/validation/index.js +2 -2
- package/drizzle/0011_slippery_korg.sql +36 -0
- package/drizzle/meta/0011_snapshot.json +2849 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2519,7 +2519,7 @@ var require_typescript = __commonJS({
|
|
|
2519
2519
|
affectsEmitOptionDeclarations: () => affectsEmitOptionDeclarations,
|
|
2520
2520
|
allKeysStartWithDot: () => allKeysStartWithDot,
|
|
2521
2521
|
altDirectorySeparator: () => altDirectorySeparator,
|
|
2522
|
-
and: () =>
|
|
2522
|
+
and: () => and21,
|
|
2523
2523
|
append: () => append,
|
|
2524
2524
|
appendIfUnique: () => appendIfUnique,
|
|
2525
2525
|
arrayFrom: () => arrayFrom,
|
|
@@ -4741,16 +4741,16 @@ var require_typescript = __commonJS({
|
|
|
4741
4741
|
return -1;
|
|
4742
4742
|
}
|
|
4743
4743
|
function countWhere(array, predicate) {
|
|
4744
|
-
let
|
|
4744
|
+
let count17 = 0;
|
|
4745
4745
|
if (array !== void 0) {
|
|
4746
4746
|
for (let i = 0; i < array.length; i++) {
|
|
4747
4747
|
const v = array[i];
|
|
4748
4748
|
if (predicate(v, i)) {
|
|
4749
|
-
|
|
4749
|
+
count17++;
|
|
4750
4750
|
}
|
|
4751
4751
|
}
|
|
4752
4752
|
}
|
|
4753
|
-
return
|
|
4753
|
+
return count17;
|
|
4754
4754
|
}
|
|
4755
4755
|
function filter(array, f) {
|
|
4756
4756
|
if (array !== void 0) {
|
|
@@ -5303,12 +5303,12 @@ var require_typescript = __commonJS({
|
|
|
5303
5303
|
}
|
|
5304
5304
|
return ~low;
|
|
5305
5305
|
}
|
|
5306
|
-
function reduceLeft(array, f, initial, start,
|
|
5306
|
+
function reduceLeft(array, f, initial, start, count17) {
|
|
5307
5307
|
if (array && array.length > 0) {
|
|
5308
5308
|
const size = array.length;
|
|
5309
5309
|
if (size > 0) {
|
|
5310
5310
|
let pos = start === void 0 || start < 0 ? 0 : start;
|
|
5311
|
-
const end =
|
|
5311
|
+
const end = count17 === void 0 || pos + count17 > size - 1 ? size - 1 : pos + count17;
|
|
5312
5312
|
let result;
|
|
5313
5313
|
if (arguments.length <= 2) {
|
|
5314
5314
|
result = array[pos];
|
|
@@ -5360,9 +5360,9 @@ var require_typescript = __commonJS({
|
|
|
5360
5360
|
}
|
|
5361
5361
|
return values;
|
|
5362
5362
|
}
|
|
5363
|
-
function arrayOf(
|
|
5364
|
-
const result = new Array(
|
|
5365
|
-
for (let i = 0; i <
|
|
5363
|
+
function arrayOf(count17, f) {
|
|
5364
|
+
const result = new Array(count17);
|
|
5365
|
+
for (let i = 0; i < count17; i++) {
|
|
5366
5366
|
result[i] = f(i);
|
|
5367
5367
|
}
|
|
5368
5368
|
return result;
|
|
@@ -5970,7 +5970,7 @@ var require_typescript = __commonJS({
|
|
|
5970
5970
|
function isPatternMatch({ prefix, suffix }, candidate) {
|
|
5971
5971
|
return candidate.length >= prefix.length + suffix.length && startsWith(candidate, prefix) && endsWith(candidate, suffix);
|
|
5972
5972
|
}
|
|
5973
|
-
function
|
|
5973
|
+
function and21(f, g) {
|
|
5974
5974
|
return (arg) => f(arg) && g(arg);
|
|
5975
5975
|
}
|
|
5976
5976
|
function or(...fs2) {
|
|
@@ -7474,8 +7474,8 @@ ${lanes.join("\n")}
|
|
|
7474
7474
|
var durations = /* @__PURE__ */ new Map();
|
|
7475
7475
|
function mark(markName) {
|
|
7476
7476
|
if (enabled) {
|
|
7477
|
-
const
|
|
7478
|
-
counts.set(markName,
|
|
7477
|
+
const count17 = counts.get(markName) ?? 0;
|
|
7478
|
+
counts.set(markName, count17 + 1);
|
|
7479
7479
|
marks.set(markName, timestamp());
|
|
7480
7480
|
performanceImpl == null ? void 0 : performanceImpl.mark(markName);
|
|
7481
7481
|
if (typeof onProfilerEvent === "function") {
|
|
@@ -14985,20 +14985,20 @@ ${lanes.join("\n")}
|
|
|
14985
14985
|
tokenValue = text2.substring(start2, pos);
|
|
14986
14986
|
return isOctal;
|
|
14987
14987
|
}
|
|
14988
|
-
function scanExactNumberOfHexDigits(
|
|
14988
|
+
function scanExactNumberOfHexDigits(count17, canHaveSeparators) {
|
|
14989
14989
|
const valueString = scanHexDigits(
|
|
14990
14990
|
/*minCount*/
|
|
14991
|
-
|
|
14991
|
+
count17,
|
|
14992
14992
|
/*scanAsManyAsPossible*/
|
|
14993
14993
|
false,
|
|
14994
14994
|
canHaveSeparators
|
|
14995
14995
|
);
|
|
14996
14996
|
return valueString ? parseInt(valueString, 16) : -1;
|
|
14997
14997
|
}
|
|
14998
|
-
function scanMinimumNumberOfHexDigits(
|
|
14998
|
+
function scanMinimumNumberOfHexDigits(count17, canHaveSeparators) {
|
|
14999
14999
|
return scanHexDigits(
|
|
15000
15000
|
/*minCount*/
|
|
15001
|
-
|
|
15001
|
+
count17,
|
|
15002
15002
|
/*scanAsManyAsPossible*/
|
|
15003
15003
|
true,
|
|
15004
15004
|
canHaveSeparators
|
|
@@ -33815,13 +33815,13 @@ ${lanes.join("\n")}
|
|
|
33815
33815
|
[expression]
|
|
33816
33816
|
);
|
|
33817
33817
|
}
|
|
33818
|
-
function createReadHelper(iteratorRecord,
|
|
33818
|
+
function createReadHelper(iteratorRecord, count17) {
|
|
33819
33819
|
context.requestEmitHelper(readHelper);
|
|
33820
33820
|
return factory2.createCallExpression(
|
|
33821
33821
|
getUnscopedHelperName("__read"),
|
|
33822
33822
|
/*typeArguments*/
|
|
33823
33823
|
void 0,
|
|
33824
|
-
|
|
33824
|
+
count17 !== void 0 ? [iteratorRecord, factory2.createNumericLiteral(count17 + "")] : [iteratorRecord]
|
|
33825
33825
|
);
|
|
33826
33826
|
}
|
|
33827
33827
|
function createGeneratorHelper(body) {
|
|
@@ -56128,11 +56128,11 @@ ${lanes.join("\n")}
|
|
|
56128
56128
|
return comparePaths(a, b, ignoreCase) === 0;
|
|
56129
56129
|
}
|
|
56130
56130
|
function countPathComponents(path2) {
|
|
56131
|
-
let
|
|
56131
|
+
let count17 = 0;
|
|
56132
56132
|
for (let i = startsWith(path2, "./") ? 2 : 0; i < path2.length; i++) {
|
|
56133
|
-
if (path2.charCodeAt(i) === 47)
|
|
56133
|
+
if (path2.charCodeAt(i) === 47) count17++;
|
|
56134
56134
|
}
|
|
56135
|
-
return
|
|
56135
|
+
return count17;
|
|
56136
56136
|
}
|
|
56137
56137
|
function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) {
|
|
56138
56138
|
return compareBooleans(b.isRedirect, a.isRedirect) || compareNumberOfDirectorySeparators(a.path, b.path);
|
|
@@ -56965,7 +56965,7 @@ ${lanes.join("\n")}
|
|
|
56965
56965
|
SignatureCheckMode3[SignatureCheckMode3["Callback"] = 3] = "Callback";
|
|
56966
56966
|
return SignatureCheckMode3;
|
|
56967
56967
|
})(SignatureCheckMode || {});
|
|
56968
|
-
var isNotOverloadAndNotAccessor =
|
|
56968
|
+
var isNotOverloadAndNotAccessor = and21(isNotOverload, isNotAccessor);
|
|
56969
56969
|
var intrinsicTypeKinds = new Map(Object.entries({
|
|
56970
56970
|
Uppercase: 0,
|
|
56971
56971
|
Lowercase: 1,
|
|
@@ -62705,7 +62705,7 @@ ${lanes.join("\n")}
|
|
|
62705
62705
|
deepCloneOrReuseNode
|
|
62706
62706
|
)), node);
|
|
62707
62707
|
}
|
|
62708
|
-
function deepCloneOrReuseNodes(nodes, visitor, test, start,
|
|
62708
|
+
function deepCloneOrReuseNodes(nodes, visitor, test, start, count17) {
|
|
62709
62709
|
if (nodes && nodes.length === 0) {
|
|
62710
62710
|
return setTextRange(factory.createNodeArray(
|
|
62711
62711
|
/*elements*/
|
|
@@ -62713,7 +62713,7 @@ ${lanes.join("\n")}
|
|
|
62713
62713
|
nodes.hasTrailingComma
|
|
62714
62714
|
), nodes);
|
|
62715
62715
|
}
|
|
62716
|
-
return visitNodes2(nodes, visitor, test, start,
|
|
62716
|
+
return visitNodes2(nodes, visitor, test, start, count17);
|
|
62717
62717
|
}
|
|
62718
62718
|
}
|
|
62719
62719
|
function createTypeNodeFromObjectType(type2) {
|
|
@@ -66669,10 +66669,10 @@ ${lanes.join("\n")}
|
|
|
66669
66669
|
if (t.flags & 512 || !expandingEnum && t.flags | 1056) {
|
|
66670
66670
|
const baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLikeType(t);
|
|
66671
66671
|
if (baseType.flags & 1048576) {
|
|
66672
|
-
const
|
|
66673
|
-
if (i +
|
|
66672
|
+
const count17 = baseType.types.length;
|
|
66673
|
+
if (i + count17 <= types.length && getRegularTypeOfLiteralType(types[i + count17 - 1]) === getRegularTypeOfLiteralType(baseType.types[count17 - 1])) {
|
|
66674
66674
|
result.push(baseType);
|
|
66675
|
-
i +=
|
|
66675
|
+
i += count17 - 1;
|
|
66676
66676
|
continue;
|
|
66677
66677
|
}
|
|
66678
66678
|
}
|
|
@@ -71638,18 +71638,18 @@ ${lanes.join("\n")}
|
|
|
71638
71638
|
let i = 0;
|
|
71639
71639
|
while (i < length2) {
|
|
71640
71640
|
const startId = types[i].id;
|
|
71641
|
-
let
|
|
71642
|
-
while (i +
|
|
71643
|
-
|
|
71641
|
+
let count17 = 1;
|
|
71642
|
+
while (i + count17 < length2 && types[i + count17].id === startId + count17) {
|
|
71643
|
+
count17++;
|
|
71644
71644
|
}
|
|
71645
71645
|
if (result.length) {
|
|
71646
71646
|
result += ",";
|
|
71647
71647
|
}
|
|
71648
71648
|
result += startId;
|
|
71649
|
-
if (
|
|
71650
|
-
result += ":" +
|
|
71649
|
+
if (count17 > 1) {
|
|
71650
|
+
result += ":" + count17;
|
|
71651
71651
|
}
|
|
71652
|
-
i +=
|
|
71652
|
+
i += count17;
|
|
71653
71653
|
}
|
|
71654
71654
|
}
|
|
71655
71655
|
return result;
|
|
@@ -72929,7 +72929,7 @@ ${lanes.join("\n")}
|
|
|
72929
72929
|
const hasEmptyObject = hasObjectTypes && some(types, (t) => !!(t.flags & 524288) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)));
|
|
72930
72930
|
const len = types.length;
|
|
72931
72931
|
let i = len;
|
|
72932
|
-
let
|
|
72932
|
+
let count17 = 0;
|
|
72933
72933
|
while (i > 0) {
|
|
72934
72934
|
i--;
|
|
72935
72935
|
const source = types[i];
|
|
@@ -72944,15 +72944,15 @@ ${lanes.join("\n")}
|
|
|
72944
72944
|
const keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty));
|
|
72945
72945
|
for (const target of types) {
|
|
72946
72946
|
if (source !== target) {
|
|
72947
|
-
if (
|
|
72948
|
-
const estimatedCount =
|
|
72947
|
+
if (count17 === 1e5) {
|
|
72948
|
+
const estimatedCount = count17 / (len - i) * len;
|
|
72949
72949
|
if (estimatedCount > 1e6) {
|
|
72950
72950
|
(_a = tracing) == null ? void 0 : _a.instant(tracing.Phase.CheckTypes, "removeSubtypes_DepthLimit", { typeIds: types.map((t) => t.id) });
|
|
72951
72951
|
error2(currentNode, Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
|
|
72952
72952
|
return void 0;
|
|
72953
72953
|
}
|
|
72954
72954
|
}
|
|
72955
|
-
|
|
72955
|
+
count17++;
|
|
72956
72956
|
if (keyProperty && target.flags & (524288 | 2097152 | 58982400)) {
|
|
72957
72957
|
const t = getTypeOfPropertyOfType(target, keyProperty.escapedName);
|
|
72958
72958
|
if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) {
|
|
@@ -73453,9 +73453,9 @@ ${lanes.join("\n")}
|
|
|
73453
73453
|
return true;
|
|
73454
73454
|
}
|
|
73455
73455
|
function getCrossProductIntersections(types, flags) {
|
|
73456
|
-
const
|
|
73456
|
+
const count17 = getCrossProductUnionSize(types);
|
|
73457
73457
|
const intersections = [];
|
|
73458
|
-
for (let i = 0; i <
|
|
73458
|
+
for (let i = 0; i < count17; i++) {
|
|
73459
73459
|
const constituents = types.slice();
|
|
73460
73460
|
let n = i;
|
|
73461
73461
|
for (let j = types.length - 1; j >= 0; j--) {
|
|
@@ -79317,14 +79317,14 @@ ${lanes.join("\n")}
|
|
|
79317
79317
|
return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth));
|
|
79318
79318
|
}
|
|
79319
79319
|
const identity2 = getRecursionIdentity(type);
|
|
79320
|
-
let
|
|
79320
|
+
let count17 = 0;
|
|
79321
79321
|
let lastTypeId = 0;
|
|
79322
79322
|
for (let i = 0; i < depth; i++) {
|
|
79323
79323
|
const t = stack[i];
|
|
79324
79324
|
if (hasMatchingRecursionIdentity(t, identity2)) {
|
|
79325
79325
|
if (t.id >= lastTypeId) {
|
|
79326
|
-
|
|
79327
|
-
if (
|
|
79326
|
+
count17++;
|
|
79327
|
+
if (count17 >= maxDepth) {
|
|
79328
79328
|
return true;
|
|
79329
79329
|
}
|
|
79330
79330
|
}
|
|
@@ -80784,8 +80784,8 @@ ${lanes.join("\n")}
|
|
|
80784
80784
|
];
|
|
80785
80785
|
}
|
|
80786
80786
|
function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
|
|
80787
|
-
const
|
|
80788
|
-
for (let i = 0; i <
|
|
80787
|
+
const count17 = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
|
|
80788
|
+
for (let i = 0; i < count17; i++) {
|
|
80789
80789
|
if (i < variances.length && (variances[i] & 7) === 2) {
|
|
80790
80790
|
inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
|
|
80791
80791
|
} else {
|
|
@@ -81529,7 +81529,7 @@ ${lanes.join("\n")}
|
|
|
81529
81529
|
}
|
|
81530
81530
|
function mapTypesByKeyProperty(types, name) {
|
|
81531
81531
|
const map2 = /* @__PURE__ */ new Map();
|
|
81532
|
-
let
|
|
81532
|
+
let count17 = 0;
|
|
81533
81533
|
for (const type of types) {
|
|
81534
81534
|
if (type.flags & (524288 | 2097152 | 58982400)) {
|
|
81535
81535
|
const discriminant = getTypeOfPropertyOfType(type, name);
|
|
@@ -81548,11 +81548,11 @@ ${lanes.join("\n")}
|
|
|
81548
81548
|
duplicate = true;
|
|
81549
81549
|
}
|
|
81550
81550
|
});
|
|
81551
|
-
if (!duplicate)
|
|
81551
|
+
if (!duplicate) count17++;
|
|
81552
81552
|
}
|
|
81553
81553
|
}
|
|
81554
81554
|
}
|
|
81555
|
-
return
|
|
81555
|
+
return count17 >= 10 && count17 * 2 >= types.length ? map2 : void 0;
|
|
81556
81556
|
}
|
|
81557
81557
|
function getKeyPropertyName(unionType) {
|
|
81558
81558
|
const types = unionType.types;
|
|
@@ -99776,7 +99776,7 @@ ${lanes.join("\n")}
|
|
|
99776
99776
|
if (flags & (1920 | 384)) {
|
|
99777
99777
|
return;
|
|
99778
99778
|
}
|
|
99779
|
-
const exportedDeclarationsCount = countWhere(declarations,
|
|
99779
|
+
const exportedDeclarationsCount = countWhere(declarations, and21(isNotOverloadAndNotAccessor, not2(isInterfaceDeclaration)));
|
|
99780
99780
|
if (flags & 524288 && exportedDeclarationsCount <= 2) {
|
|
99781
99781
|
return;
|
|
99782
99782
|
}
|
|
@@ -104164,7 +104164,7 @@ ${lanes.join("\n")}
|
|
|
104164
104164
|
Debug.assertNode(visitedNode, test);
|
|
104165
104165
|
return visitedNode;
|
|
104166
104166
|
}
|
|
104167
|
-
function visitNodes2(nodes, visitor, test, start,
|
|
104167
|
+
function visitNodes2(nodes, visitor, test, start, count17) {
|
|
104168
104168
|
if (nodes === void 0) {
|
|
104169
104169
|
return nodes;
|
|
104170
104170
|
}
|
|
@@ -104172,20 +104172,20 @@ ${lanes.join("\n")}
|
|
|
104172
104172
|
if (start === void 0 || start < 0) {
|
|
104173
104173
|
start = 0;
|
|
104174
104174
|
}
|
|
104175
|
-
if (
|
|
104176
|
-
|
|
104175
|
+
if (count17 === void 0 || count17 > length2 - start) {
|
|
104176
|
+
count17 = length2 - start;
|
|
104177
104177
|
}
|
|
104178
104178
|
let hasTrailingComma;
|
|
104179
104179
|
let pos = -1;
|
|
104180
104180
|
let end = -1;
|
|
104181
|
-
if (start > 0 ||
|
|
104182
|
-
hasTrailingComma = nodes.hasTrailingComma && start +
|
|
104181
|
+
if (start > 0 || count17 < length2) {
|
|
104182
|
+
hasTrailingComma = nodes.hasTrailingComma && start + count17 === length2;
|
|
104183
104183
|
} else {
|
|
104184
104184
|
pos = nodes.pos;
|
|
104185
104185
|
end = nodes.end;
|
|
104186
104186
|
hasTrailingComma = nodes.hasTrailingComma;
|
|
104187
104187
|
}
|
|
104188
|
-
const updated = visitArrayWorker(nodes, visitor, test, start,
|
|
104188
|
+
const updated = visitArrayWorker(nodes, visitor, test, start, count17);
|
|
104189
104189
|
if (updated !== nodes) {
|
|
104190
104190
|
const updatedArray = factory.createNodeArray(updated, hasTrailingComma);
|
|
104191
104191
|
setTextRangePosEnd(updatedArray, pos, end);
|
|
@@ -104193,7 +104193,7 @@ ${lanes.join("\n")}
|
|
|
104193
104193
|
}
|
|
104194
104194
|
return nodes;
|
|
104195
104195
|
}
|
|
104196
|
-
function visitArray(nodes, visitor, test, start,
|
|
104196
|
+
function visitArray(nodes, visitor, test, start, count17) {
|
|
104197
104197
|
if (nodes === void 0) {
|
|
104198
104198
|
return nodes;
|
|
104199
104199
|
}
|
|
@@ -104201,18 +104201,18 @@ ${lanes.join("\n")}
|
|
|
104201
104201
|
if (start === void 0 || start < 0) {
|
|
104202
104202
|
start = 0;
|
|
104203
104203
|
}
|
|
104204
|
-
if (
|
|
104205
|
-
|
|
104204
|
+
if (count17 === void 0 || count17 > length2 - start) {
|
|
104205
|
+
count17 = length2 - start;
|
|
104206
104206
|
}
|
|
104207
|
-
return visitArrayWorker(nodes, visitor, test, start,
|
|
104207
|
+
return visitArrayWorker(nodes, visitor, test, start, count17);
|
|
104208
104208
|
}
|
|
104209
|
-
function visitArrayWorker(nodes, visitor, test, start,
|
|
104209
|
+
function visitArrayWorker(nodes, visitor, test, start, count17) {
|
|
104210
104210
|
let updated;
|
|
104211
104211
|
const length2 = nodes.length;
|
|
104212
|
-
if (start > 0 ||
|
|
104212
|
+
if (start > 0 || count17 < length2) {
|
|
104213
104213
|
updated = [];
|
|
104214
104214
|
}
|
|
104215
|
-
for (let i = 0; i <
|
|
104215
|
+
for (let i = 0; i < count17; i++) {
|
|
104216
104216
|
const node = nodes[i + start];
|
|
104217
104217
|
const visited = node !== void 0 ? visitor ? visitor(node) : node : void 0;
|
|
104218
104218
|
if (updated !== void 0 || visited === void 0 || visited !== node) {
|
|
@@ -135496,7 +135496,7 @@ ${lanes.join("\n")}
|
|
|
135496
135496
|
break;
|
|
135497
135497
|
}
|
|
135498
135498
|
}
|
|
135499
|
-
function emitList(parentNode, children, format, parenthesizerRule, start,
|
|
135499
|
+
function emitList(parentNode, children, format, parenthesizerRule, start, count17) {
|
|
135500
135500
|
emitNodeList(
|
|
135501
135501
|
emit,
|
|
135502
135502
|
parentNode,
|
|
@@ -135504,18 +135504,18 @@ ${lanes.join("\n")}
|
|
|
135504
135504
|
format | (parentNode && getEmitFlags(parentNode) & 2 ? 65536 : 0),
|
|
135505
135505
|
parenthesizerRule,
|
|
135506
135506
|
start,
|
|
135507
|
-
|
|
135507
|
+
count17
|
|
135508
135508
|
);
|
|
135509
135509
|
}
|
|
135510
|
-
function emitExpressionList(parentNode, children, format, parenthesizerRule, start,
|
|
135511
|
-
emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start,
|
|
135510
|
+
function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count17) {
|
|
135511
|
+
emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count17);
|
|
135512
135512
|
}
|
|
135513
|
-
function emitNodeList(emit2, parentNode, children, format, parenthesizerRule, start = 0,
|
|
135513
|
+
function emitNodeList(emit2, parentNode, children, format, parenthesizerRule, start = 0, count17 = children ? children.length - start : 0) {
|
|
135514
135514
|
const isUndefined = children === void 0;
|
|
135515
135515
|
if (isUndefined && format & 16384) {
|
|
135516
135516
|
return;
|
|
135517
135517
|
}
|
|
135518
|
-
const isEmpty = children === void 0 || start >= children.length ||
|
|
135518
|
+
const isEmpty = children === void 0 || start >= children.length || count17 === 0;
|
|
135519
135519
|
if (isEmpty && format & 32768) {
|
|
135520
135520
|
onBeforeEmitNodeArray == null ? void 0 : onBeforeEmitNodeArray(children);
|
|
135521
135521
|
onAfterEmitNodeArray == null ? void 0 : onAfterEmitNodeArray(children);
|
|
@@ -135539,7 +135539,7 @@ ${lanes.join("\n")}
|
|
|
135539
135539
|
writeSpace();
|
|
135540
135540
|
}
|
|
135541
135541
|
} else {
|
|
135542
|
-
emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start,
|
|
135542
|
+
emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count17, children.hasTrailingComma, children);
|
|
135543
135543
|
}
|
|
135544
135544
|
onAfterEmitNodeArray == null ? void 0 : onAfterEmitNodeArray(children);
|
|
135545
135545
|
if (format & 15360) {
|
|
@@ -135549,7 +135549,7 @@ ${lanes.join("\n")}
|
|
|
135549
135549
|
writePunctuation(getClosingBracket(format));
|
|
135550
135550
|
}
|
|
135551
135551
|
}
|
|
135552
|
-
function emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start,
|
|
135552
|
+
function emitNodeListItems(emit2, parentNode, children, format, parenthesizerRule, start, count17, hasTrailingComma, childrenTextRange) {
|
|
135553
135553
|
const mayEmitInterveningComments = (format & 262144) === 0;
|
|
135554
135554
|
let shouldEmitInterveningComments = mayEmitInterveningComments;
|
|
135555
135555
|
const leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format);
|
|
@@ -135565,7 +135565,7 @@ ${lanes.join("\n")}
|
|
|
135565
135565
|
const emitListItem = getEmitListItem(emit2, parenthesizerRule);
|
|
135566
135566
|
let previousSibling;
|
|
135567
135567
|
let shouldDecreaseIndentAfterEmit = false;
|
|
135568
|
-
for (let i = 0; i <
|
|
135568
|
+
for (let i = 0; i < count17; i++) {
|
|
135569
135569
|
const child = children[start + i];
|
|
135570
135570
|
if (format & 32) {
|
|
135571
135571
|
writeLine();
|
|
@@ -135630,7 +135630,7 @@ ${lanes.join("\n")}
|
|
|
135630
135630
|
if (format & 128) {
|
|
135631
135631
|
decreaseIndent();
|
|
135632
135632
|
}
|
|
135633
|
-
const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start +
|
|
135633
|
+
const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count17 - 1], format, childrenTextRange);
|
|
135634
135634
|
if (closingLineTerminatorCount) {
|
|
135635
135635
|
writeLine(closingLineTerminatorCount);
|
|
135636
135636
|
} else if (format & (2097152 | 256)) {
|
|
@@ -135680,8 +135680,8 @@ ${lanes.join("\n")}
|
|
|
135680
135680
|
writer.write(s);
|
|
135681
135681
|
}
|
|
135682
135682
|
}
|
|
135683
|
-
function writeLine(
|
|
135684
|
-
for (let i = 0; i <
|
|
135683
|
+
function writeLine(count17 = 1) {
|
|
135684
|
+
for (let i = 0; i < count17; i++) {
|
|
135685
135685
|
writer.writeLine(i > 0);
|
|
135686
135686
|
}
|
|
135687
135687
|
}
|
|
@@ -136210,10 +136210,10 @@ ${lanes.join("\n")}
|
|
|
136210
136210
|
}
|
|
136211
136211
|
}
|
|
136212
136212
|
while (true) {
|
|
136213
|
-
const
|
|
136213
|
+
const count17 = tempFlags2 & 268435455;
|
|
136214
136214
|
tempFlags2++;
|
|
136215
|
-
if (
|
|
136216
|
-
const name =
|
|
136215
|
+
if (count17 !== 8 && count17 !== 13) {
|
|
136216
|
+
const name = count17 < 26 ? "_" + String.fromCharCode(97 + count17) : "_" + (count17 - 26);
|
|
136217
136217
|
const fullName = formatGeneratedName(privateName, prefix, name, suffix);
|
|
136218
136218
|
if (isUniqueName(fullName, privateName)) {
|
|
136219
136219
|
if (privateName) {
|
|
@@ -148280,12 +148280,12 @@ ${lanes.join("\n")}
|
|
|
148280
148280
|
for (const line of output) {
|
|
148281
148281
|
sys2.write(line);
|
|
148282
148282
|
}
|
|
148283
|
-
function example(ex,
|
|
148283
|
+
function example(ex, desc16) {
|
|
148284
148284
|
const examples = typeof ex === "string" ? [ex] : ex;
|
|
148285
148285
|
for (const example2 of examples) {
|
|
148286
148286
|
output.push(" " + colors.blue(example2) + sys2.newLine);
|
|
148287
148287
|
}
|
|
148288
|
-
output.push(" " + getDiagnosticText(
|
|
148288
|
+
output.push(" " + getDiagnosticText(desc16) + sys2.newLine + sys2.newLine);
|
|
148289
148289
|
}
|
|
148290
148290
|
}
|
|
148291
148291
|
function printAllHelp(sys2, compilerOptions, buildOptions, watchOptions) {
|
|
@@ -148937,7 +148937,7 @@ ${lanes.join("\n")}
|
|
|
148937
148937
|
reportCountStatistic("Lines of " + key, value);
|
|
148938
148938
|
}
|
|
148939
148939
|
} else {
|
|
148940
|
-
reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum,
|
|
148940
|
+
reportCountStatistic("Lines", reduceLeftIterator(lineCounts.values(), (sum, count17) => sum + count17, 0));
|
|
148941
148941
|
}
|
|
148942
148942
|
reportCountStatistic("Identifiers", program.getIdentifierCount());
|
|
148943
148943
|
reportCountStatistic("Symbols", program.getSymbolCount());
|
|
@@ -149042,11 +149042,11 @@ ${lanes.join("\n")}
|
|
|
149042
149042
|
statistics.push(s);
|
|
149043
149043
|
if (aggregate) solutionPerformance == null ? void 0 : solutionPerformance.addAggregateStatistic(s);
|
|
149044
149044
|
}
|
|
149045
|
-
function reportCountStatistic(name,
|
|
149045
|
+
function reportCountStatistic(name, count17) {
|
|
149046
149046
|
reportStatisticalValue(
|
|
149047
149047
|
{
|
|
149048
149048
|
name,
|
|
149049
|
-
value:
|
|
149049
|
+
value: count17,
|
|
149050
149050
|
type: 1
|
|
149051
149051
|
/* count */
|
|
149052
149052
|
},
|
|
@@ -149547,8 +149547,8 @@ ${lanes.join("\n")}
|
|
|
149547
149547
|
nonlocalNode ? visitNodesWithoutCopyingPositions : void 0
|
|
149548
149548
|
);
|
|
149549
149549
|
}
|
|
149550
|
-
function visitNodesWithoutCopyingPositions(nodes, visitor, test, start,
|
|
149551
|
-
let result = visitNodes2(nodes, visitor, test, start,
|
|
149550
|
+
function visitNodesWithoutCopyingPositions(nodes, visitor, test, start, count17) {
|
|
149551
|
+
let result = visitNodes2(nodes, visitor, test, start, count17);
|
|
149552
149552
|
if (result) {
|
|
149553
149553
|
if (result.pos !== -1 || result.end !== -1) {
|
|
149554
149554
|
if (result === nodes) {
|
|
@@ -152441,9 +152441,9 @@ ${lanes.join("\n")}
|
|
|
152441
152441
|
function getSnapshotText(snap) {
|
|
152442
152442
|
return snap.getText(0, snap.getLength());
|
|
152443
152443
|
}
|
|
152444
|
-
function repeatString(str,
|
|
152444
|
+
function repeatString(str, count17) {
|
|
152445
152445
|
let result = "";
|
|
152446
|
-
for (let i = 0; i <
|
|
152446
|
+
for (let i = 0; i < count17; i++) {
|
|
152447
152447
|
result += str;
|
|
152448
152448
|
}
|
|
152449
152449
|
return result;
|
|
@@ -170564,7 +170564,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
170564
170564
|
const maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker);
|
|
170565
170565
|
const implementedType = checker.getTypeAtLocation(implementedTypeNode);
|
|
170566
170566
|
const implementedTypeSymbols = checker.getPropertiesOfType(implementedType);
|
|
170567
|
-
const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(
|
|
170567
|
+
const nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(and21(symbolPointsToNonPrivateMember, (symbol) => !maybeHeritageClauseSymbol.has(symbol.escapedName)));
|
|
170568
170568
|
const classType = checker.getTypeAtLocation(classDeclaration);
|
|
170569
170569
|
const constructor = find(classDeclaration.members, (m) => isConstructorDeclaration(m));
|
|
170570
170570
|
if (!classType.getNumberIndexType()) {
|
|
@@ -185221,8 +185221,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
|
|
|
185221
185221
|
function isAmbientModuleDeclaration(node) {
|
|
185222
185222
|
return node.kind === 268 && node.name.kind === 11;
|
|
185223
185223
|
}
|
|
185224
|
-
function isExternalModuleImportEquals(
|
|
185225
|
-
return
|
|
185224
|
+
function isExternalModuleImportEquals(eq21) {
|
|
185225
|
+
return eq21.moduleReference.kind === 284 && eq21.moduleReference.expression.kind === 11;
|
|
185226
185226
|
}
|
|
185227
185227
|
var DefinitionKind = /* @__PURE__ */ ((DefinitionKind2) => {
|
|
185228
185228
|
DefinitionKind2[DefinitionKind2["Symbol"] = 0] = "Symbol";
|
|
@@ -190869,13 +190869,13 @@ ${content}
|
|
|
190869
190869
|
if (candidates[i] === resolvedSignature) {
|
|
190870
190870
|
selectedItemIndex = itemsSeen;
|
|
190871
190871
|
if (item.length > 1) {
|
|
190872
|
-
let
|
|
190872
|
+
let count17 = 0;
|
|
190873
190873
|
for (const i2 of item) {
|
|
190874
190874
|
if (i2.isVariadic || i2.parameters.length >= argumentCount) {
|
|
190875
|
-
selectedItemIndex = itemsSeen +
|
|
190875
|
+
selectedItemIndex = itemsSeen + count17;
|
|
190876
190876
|
break;
|
|
190877
190877
|
}
|
|
190878
|
-
|
|
190878
|
+
count17++;
|
|
190879
190879
|
}
|
|
190880
190880
|
}
|
|
190881
190881
|
}
|
|
@@ -193176,8 +193176,8 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
193176
193176
|
setTextRangePosEnd(newNode, getPos2(node), getEnd(node));
|
|
193177
193177
|
return newNode;
|
|
193178
193178
|
}
|
|
193179
|
-
function assignPositionsToNodeArray(nodes, visitor, test, start,
|
|
193180
|
-
const visited = visitNodes2(nodes, visitor, test, start,
|
|
193179
|
+
function assignPositionsToNodeArray(nodes, visitor, test, start, count17) {
|
|
193180
|
+
const visited = visitNodes2(nodes, visitor, test, start, count17);
|
|
193181
193181
|
if (!visited) {
|
|
193182
193182
|
return visited;
|
|
193183
193183
|
}
|
|
@@ -197854,7 +197854,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
197854
197854
|
affectsEmitOptionDeclarations: () => affectsEmitOptionDeclarations,
|
|
197855
197855
|
allKeysStartWithDot: () => allKeysStartWithDot,
|
|
197856
197856
|
altDirectorySeparator: () => altDirectorySeparator,
|
|
197857
|
-
and: () =>
|
|
197857
|
+
and: () => and21,
|
|
197858
197858
|
append: () => append,
|
|
197859
197859
|
appendIfUnique: () => appendIfUnique,
|
|
197860
197860
|
arrayFrom: () => arrayFrom,
|
|
@@ -213467,6 +213467,8 @@ __export(schema_exports, {
|
|
|
213467
213467
|
subAgentArtifactComponentsRelations: () => subAgentArtifactComponentsRelations,
|
|
213468
213468
|
subAgentDataComponents: () => subAgentDataComponents,
|
|
213469
213469
|
subAgentDataComponentsRelations: () => subAgentDataComponentsRelations,
|
|
213470
|
+
subAgentExternalAgentRelations: () => subAgentExternalAgentRelations,
|
|
213471
|
+
subAgentExternalAgentRelationsRelations: () => subAgentExternalAgentRelationsRelations,
|
|
213470
213472
|
subAgentFunctionToolRelations: () => subAgentFunctionToolRelations,
|
|
213471
213473
|
subAgentFunctionToolRelationsRelations: () => subAgentFunctionToolRelationsRelations,
|
|
213472
213474
|
subAgentRelations: () => subAgentRelations,
|
|
@@ -213612,7 +213614,6 @@ var subAgentRelations = sqliteCore.sqliteTable(
|
|
|
213612
213614
|
...agentScoped,
|
|
213613
213615
|
sourceSubAgentId: sqliteCore.text("source_sub_agent_id").notNull(),
|
|
213614
213616
|
targetSubAgentId: sqliteCore.text("target_sub_agent_id"),
|
|
213615
|
-
externalSubAgentId: sqliteCore.text("external_sub_agent_id"),
|
|
213616
213617
|
relationType: sqliteCore.text("relation_type"),
|
|
213617
213618
|
...timestamps
|
|
213618
213619
|
},
|
|
@@ -213628,19 +213629,18 @@ var subAgentRelations = sqliteCore.sqliteTable(
|
|
|
213628
213629
|
var externalAgents = sqliteCore.sqliteTable(
|
|
213629
213630
|
"external_agents",
|
|
213630
213631
|
{
|
|
213631
|
-
...
|
|
213632
|
+
...projectScoped,
|
|
213632
213633
|
...uiProperties,
|
|
213633
213634
|
baseUrl: sqliteCore.text("base_url").notNull(),
|
|
213634
213635
|
credentialReferenceId: sqliteCore.text("credential_reference_id"),
|
|
213635
|
-
headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
|
|
213636
213636
|
...timestamps
|
|
213637
213637
|
},
|
|
213638
213638
|
(table) => [
|
|
213639
|
-
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.
|
|
213639
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.id] }),
|
|
213640
213640
|
sqliteCore.foreignKey({
|
|
213641
|
-
columns: [table.tenantId, table.projectId
|
|
213642
|
-
foreignColumns: [
|
|
213643
|
-
name: "
|
|
213641
|
+
columns: [table.tenantId, table.projectId],
|
|
213642
|
+
foreignColumns: [projects.tenantId, projects.id],
|
|
213643
|
+
name: "external_agents_project_fk"
|
|
213644
213644
|
}).onDelete("cascade"),
|
|
213645
213645
|
sqliteCore.foreignKey({
|
|
213646
213646
|
columns: [table.tenantId, table.projectId, table.credentialReferenceId],
|
|
@@ -213859,6 +213859,28 @@ var subAgentToolRelations = sqliteCore.sqliteTable(
|
|
|
213859
213859
|
}).onDelete("cascade")
|
|
213860
213860
|
]
|
|
213861
213861
|
);
|
|
213862
|
+
var subAgentExternalAgentRelations = sqliteCore.sqliteTable(
|
|
213863
|
+
"sub_agent_external_agent_relations",
|
|
213864
|
+
{
|
|
213865
|
+
...subAgentScoped,
|
|
213866
|
+
externalAgentId: sqliteCore.text("external_agent_id").notNull(),
|
|
213867
|
+
headers: sqliteCore.blob("headers", { mode: "json" }).$type(),
|
|
213868
|
+
...timestamps
|
|
213869
|
+
},
|
|
213870
|
+
(table) => [
|
|
213871
|
+
sqliteCore.primaryKey({ columns: [table.tenantId, table.projectId, table.agentId, table.id] }),
|
|
213872
|
+
sqliteCore.foreignKey({
|
|
213873
|
+
columns: [table.tenantId, table.projectId, table.agentId, table.subAgentId],
|
|
213874
|
+
foreignColumns: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id],
|
|
213875
|
+
name: "sub_agent_external_agent_relations_sub_agent_fk"
|
|
213876
|
+
}).onDelete("cascade"),
|
|
213877
|
+
sqliteCore.foreignKey({
|
|
213878
|
+
columns: [table.tenantId, table.projectId, table.externalAgentId],
|
|
213879
|
+
foreignColumns: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
|
|
213880
|
+
name: "sub_agent_external_agent_relations_external_agent_fk"
|
|
213881
|
+
}).onDelete("cascade")
|
|
213882
|
+
]
|
|
213883
|
+
);
|
|
213862
213884
|
var subAgentFunctionToolRelations = sqliteCore.sqliteTable(
|
|
213863
213885
|
"sub_agent_function_tool_relations",
|
|
213864
213886
|
{
|
|
@@ -214120,7 +214142,7 @@ var externalAgentsRelations = drizzleOrm.relations(externalAgents, ({ one, many
|
|
|
214120
214142
|
fields: [externalAgents.tenantId, externalAgents.projectId],
|
|
214121
214143
|
references: [projects.tenantId, projects.id]
|
|
214122
214144
|
}),
|
|
214123
|
-
|
|
214145
|
+
subAgentExternalAgentRelations: many(subAgentExternalAgentRelations),
|
|
214124
214146
|
credentialReference: one(credentialReferences, {
|
|
214125
214147
|
fields: [externalAgents.credentialReferenceId],
|
|
214126
214148
|
references: [credentialReferences.id]
|
|
@@ -214192,13 +214214,13 @@ var messagesRelations = drizzleOrm.relations(messages, ({ one, many }) => ({
|
|
|
214192
214214
|
relationName: "receivedMessages"
|
|
214193
214215
|
}),
|
|
214194
214216
|
fromExternalAgent: one(externalAgents, {
|
|
214195
|
-
fields: [messages.fromExternalAgentId],
|
|
214196
|
-
references: [externalAgents.id],
|
|
214217
|
+
fields: [messages.tenantId, messages.projectId, messages.fromExternalAgentId],
|
|
214218
|
+
references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
|
|
214197
214219
|
relationName: "receivedExternalMessages"
|
|
214198
214220
|
}),
|
|
214199
214221
|
toExternalAgent: one(externalAgents, {
|
|
214200
|
-
fields: [messages.toExternalAgentId],
|
|
214201
|
-
references: [externalAgents.id],
|
|
214222
|
+
fields: [messages.tenantId, messages.projectId, messages.toExternalAgentId],
|
|
214223
|
+
references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id],
|
|
214202
214224
|
relationName: "sentExternalMessages"
|
|
214203
214225
|
}),
|
|
214204
214226
|
task: one(tasks, {
|
|
@@ -214282,10 +214304,6 @@ var subAgentRelationsRelations = drizzleOrm.relations(subAgentRelations, ({ one
|
|
|
214282
214304
|
fields: [subAgentRelations.targetSubAgentId],
|
|
214283
214305
|
references: [subAgents.id],
|
|
214284
214306
|
relationName: "targetRelations"
|
|
214285
|
-
}),
|
|
214286
|
-
externalAgent: one(externalAgents, {
|
|
214287
|
-
fields: [subAgentRelations.externalSubAgentId],
|
|
214288
|
-
references: [externalAgents.id]
|
|
214289
214307
|
})
|
|
214290
214308
|
}));
|
|
214291
214309
|
var functionToolsRelations = drizzleOrm.relations(functionTools, ({ one, many }) => ({
|
|
@@ -214316,6 +214334,28 @@ var subAgentFunctionToolRelationsRelations = drizzleOrm.relations(
|
|
|
214316
214334
|
})
|
|
214317
214335
|
})
|
|
214318
214336
|
);
|
|
214337
|
+
var subAgentExternalAgentRelationsRelations = drizzleOrm.relations(
|
|
214338
|
+
subAgentExternalAgentRelations,
|
|
214339
|
+
({ one }) => ({
|
|
214340
|
+
subAgent: one(subAgents, {
|
|
214341
|
+
fields: [
|
|
214342
|
+
subAgentExternalAgentRelations.tenantId,
|
|
214343
|
+
subAgentExternalAgentRelations.projectId,
|
|
214344
|
+
subAgentExternalAgentRelations.agentId,
|
|
214345
|
+
subAgentExternalAgentRelations.subAgentId
|
|
214346
|
+
],
|
|
214347
|
+
references: [subAgents.tenantId, subAgents.projectId, subAgents.agentId, subAgents.id]
|
|
214348
|
+
}),
|
|
214349
|
+
externalAgent: one(externalAgents, {
|
|
214350
|
+
fields: [
|
|
214351
|
+
subAgentExternalAgentRelations.tenantId,
|
|
214352
|
+
subAgentExternalAgentRelations.projectId,
|
|
214353
|
+
subAgentExternalAgentRelations.externalAgentId
|
|
214354
|
+
],
|
|
214355
|
+
references: [externalAgents.tenantId, externalAgents.projectId, externalAgents.id]
|
|
214356
|
+
})
|
|
214357
|
+
})
|
|
214358
|
+
);
|
|
214319
214359
|
|
|
214320
214360
|
// src/types/utility.ts
|
|
214321
214361
|
var TOOL_STATUS_VALUES = ["healthy", "unhealthy", "unknown", "needs_auth"];
|
|
@@ -214628,16 +214668,15 @@ var SubAgentArtifactComponentApiUpdateSchema = createAgentScopedApiUpdateSchema(
|
|
|
214628
214668
|
SubAgentArtifactComponentUpdateSchema
|
|
214629
214669
|
);
|
|
214630
214670
|
var ExternalAgentSelectSchema = drizzleZod.createSelectSchema(externalAgents).extend({
|
|
214631
|
-
credentialReferenceId: zodOpenapi.z.string().nullable().optional()
|
|
214632
|
-
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullable().optional()
|
|
214671
|
+
credentialReferenceId: zodOpenapi.z.string().nullable().optional()
|
|
214633
214672
|
});
|
|
214634
214673
|
var ExternalAgentInsertSchema = drizzleZod.createInsertSchema(externalAgents).extend({
|
|
214635
214674
|
id: resourceIdSchema
|
|
214636
214675
|
});
|
|
214637
214676
|
var ExternalAgentUpdateSchema = ExternalAgentInsertSchema.partial();
|
|
214638
|
-
var ExternalAgentApiSelectSchema =
|
|
214639
|
-
var ExternalAgentApiInsertSchema =
|
|
214640
|
-
var ExternalAgentApiUpdateSchema =
|
|
214677
|
+
var ExternalAgentApiSelectSchema = createApiSchema(ExternalAgentSelectSchema).openapi("ExternalAgent");
|
|
214678
|
+
var ExternalAgentApiInsertSchema = createApiInsertSchema(ExternalAgentInsertSchema).openapi("ExternalAgentCreate");
|
|
214679
|
+
var ExternalAgentApiUpdateSchema = createApiUpdateSchema(ExternalAgentUpdateSchema).openapi("ExternalAgentUpdate");
|
|
214641
214680
|
var AllAgentSchema = zodOpenapi.z.discriminatedUnion("type", [
|
|
214642
214681
|
SubAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("internal") }),
|
|
214643
214682
|
ExternalAgentApiSelectSchema.extend({ type: zodOpenapi.z.literal("external") })
|
|
@@ -214702,7 +214741,8 @@ var CredentialReferenceInsertSchema = drizzleZod.createInsertSchema(credentialRe
|
|
|
214702
214741
|
var CredentialReferenceUpdateSchema = CredentialReferenceInsertSchema.partial();
|
|
214703
214742
|
var CredentialReferenceApiSelectSchema = createApiSchema(CredentialReferenceSelectSchema).extend({
|
|
214704
214743
|
type: zodOpenapi.z.enum(CredentialStoreType),
|
|
214705
|
-
tools: zodOpenapi.z.array(ToolSelectSchema).optional()
|
|
214744
|
+
tools: zodOpenapi.z.array(ToolSelectSchema).optional(),
|
|
214745
|
+
externalAgents: zodOpenapi.z.array(ExternalAgentSelectSchema).optional()
|
|
214706
214746
|
}).openapi("CredentialReference");
|
|
214707
214747
|
var CredentialReferenceApiInsertSchema = createApiInsertSchema(
|
|
214708
214748
|
CredentialReferenceInsertSchema
|
|
@@ -214831,6 +214871,27 @@ var SubAgentToolRelationApiInsertSchema = createAgentScopedApiInsertSchema(
|
|
|
214831
214871
|
var SubAgentToolRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
|
|
214832
214872
|
SubAgentToolRelationUpdateSchema
|
|
214833
214873
|
).openapi("SubAgentToolRelationUpdate");
|
|
214874
|
+
var SubAgentExternalAgentRelationSelectSchema = drizzleZod.createSelectSchema(
|
|
214875
|
+
subAgentExternalAgentRelations
|
|
214876
|
+
);
|
|
214877
|
+
var SubAgentExternalAgentRelationInsertSchema = drizzleZod.createInsertSchema(
|
|
214878
|
+
subAgentExternalAgentRelations
|
|
214879
|
+
).extend({
|
|
214880
|
+
id: resourceIdSchema,
|
|
214881
|
+
subAgentId: resourceIdSchema,
|
|
214882
|
+
externalAgentId: resourceIdSchema,
|
|
214883
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
214884
|
+
});
|
|
214885
|
+
var SubAgentExternalAgentRelationUpdateSchema = SubAgentExternalAgentRelationInsertSchema.partial();
|
|
214886
|
+
var SubAgentExternalAgentRelationApiSelectSchema = createAgentScopedApiSchema(
|
|
214887
|
+
SubAgentExternalAgentRelationSelectSchema
|
|
214888
|
+
).openapi("SubAgentExternalAgentRelation");
|
|
214889
|
+
var SubAgentExternalAgentRelationApiInsertSchema = createAgentScopedApiInsertSchema(
|
|
214890
|
+
SubAgentExternalAgentRelationInsertSchema
|
|
214891
|
+
).omit({ id: true, subAgentId: true }).openapi("SubAgentExternalAgentRelationCreate");
|
|
214892
|
+
var SubAgentExternalAgentRelationApiUpdateSchema = createAgentScopedApiUpdateSchema(
|
|
214893
|
+
SubAgentExternalAgentRelationUpdateSchema
|
|
214894
|
+
).openapi("SubAgentExternalAgentRelationUpdate");
|
|
214834
214895
|
var LedgerArtifactSelectSchema = drizzleZod.createSelectSchema(ledgerArtifacts);
|
|
214835
214896
|
var LedgerArtifactInsertSchema = drizzleZod.createInsertSchema(ledgerArtifacts);
|
|
214836
214897
|
var LedgerArtifactUpdateSchema = LedgerArtifactInsertSchema.partial();
|
|
@@ -214859,6 +214920,11 @@ var CanUseItemSchema = zodOpenapi.z.object({
|
|
|
214859
214920
|
toolSelection: zodOpenapi.z.array(zodOpenapi.z.string()).nullish(),
|
|
214860
214921
|
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
214861
214922
|
}).openapi("CanUseItem");
|
|
214923
|
+
var canDelegateToExternalAgentSchema = zodOpenapi.z.object({
|
|
214924
|
+
externalAgentId: zodOpenapi.z.string(),
|
|
214925
|
+
subAgentExternalAgentRelationId: zodOpenapi.z.string().optional(),
|
|
214926
|
+
headers: zodOpenapi.z.record(zodOpenapi.z.string(), zodOpenapi.z.string()).nullish()
|
|
214927
|
+
});
|
|
214862
214928
|
var FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
|
|
214863
214929
|
type: zodOpenapi.z.literal("internal"),
|
|
214864
214930
|
canUse: zodOpenapi.z.array(CanUseItemSchema),
|
|
@@ -214866,16 +214932,22 @@ var FullAgentAgentInsertSchema = SubAgentApiInsertSchema.extend({
|
|
|
214866
214932
|
dataComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
214867
214933
|
artifactComponents: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
214868
214934
|
canTransferTo: zodOpenapi.z.array(zodOpenapi.z.string()).optional(),
|
|
214869
|
-
canDelegateTo: zodOpenapi.z.array(
|
|
214935
|
+
canDelegateTo: zodOpenapi.z.array(
|
|
214936
|
+
zodOpenapi.z.union([
|
|
214937
|
+
zodOpenapi.z.string(),
|
|
214938
|
+
// Internal subAgent ID
|
|
214939
|
+
canDelegateToExternalAgentSchema
|
|
214940
|
+
// External agent with headers
|
|
214941
|
+
])
|
|
214942
|
+
).optional()
|
|
214870
214943
|
});
|
|
214871
214944
|
var AgentWithinContextOfProjectSchema = AgentApiInsertSchema.extend({
|
|
214872
|
-
subAgents: zodOpenapi.z.record(
|
|
214873
|
-
zodOpenapi.z.string(),
|
|
214874
|
-
zodOpenapi.z.union([FullAgentAgentInsertSchema, ExternalAgentApiInsertSchema])
|
|
214875
|
-
),
|
|
214945
|
+
subAgents: zodOpenapi.z.record(zodOpenapi.z.string(), FullAgentAgentInsertSchema),
|
|
214876
214946
|
// Lookup maps for UI to resolve canUse items
|
|
214877
214947
|
tools: zodOpenapi.z.record(zodOpenapi.z.string(), ToolApiInsertSchema).optional(),
|
|
214878
214948
|
// MCP tools (project-scoped)
|
|
214949
|
+
externalAgents: zodOpenapi.z.record(zodOpenapi.z.string(), ExternalAgentApiInsertSchema).optional(),
|
|
214950
|
+
// External agents (project-scoped)
|
|
214879
214951
|
functionTools: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionToolApiInsertSchema).optional(),
|
|
214880
214952
|
// Function tools (agent-scoped)
|
|
214881
214953
|
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
@@ -214937,6 +215009,7 @@ var FullProjectDefinitionSchema = ProjectApiInsertSchema.extend({
|
|
|
214937
215009
|
functions: zodOpenapi.z.record(zodOpenapi.z.string(), FunctionApiInsertSchema).optional(),
|
|
214938
215010
|
dataComponents: zodOpenapi.z.record(zodOpenapi.z.string(), DataComponentApiInsertSchema).optional(),
|
|
214939
215011
|
artifactComponents: zodOpenapi.z.record(zodOpenapi.z.string(), ArtifactComponentApiInsertSchema).optional(),
|
|
215012
|
+
externalAgents: zodOpenapi.z.record(zodOpenapi.z.string(), ExternalAgentApiInsertSchema).optional(),
|
|
214940
215013
|
statusUpdates: zodOpenapi.z.optional(StatusUpdateSchema),
|
|
214941
215014
|
credentialReferences: zodOpenapi.z.record(zodOpenapi.z.string(), CredentialReferenceApiInsertSchema).optional(),
|
|
214942
215015
|
createdAt: zodOpenapi.z.string().optional(),
|
|
@@ -215842,7 +215915,7 @@ var listContextConfigsPaginated = (db) => async (params) => {
|
|
|
215842
215915
|
};
|
|
215843
215916
|
};
|
|
215844
215917
|
var createContextConfig = (db) => async (params) => {
|
|
215845
|
-
const id = params.id ||
|
|
215918
|
+
const id = params.id || generateId();
|
|
215846
215919
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
215847
215920
|
let contextVariables = params.contextVariables;
|
|
215848
215921
|
if (contextVariables !== void 0 && contextVariables !== null && typeof contextVariables === "object" && Object.keys(contextVariables).length === 0) {
|
|
@@ -215948,8 +216021,7 @@ var getExternalAgent = (db) => async (params) => {
|
|
|
215948
216021
|
where: drizzleOrm.and(
|
|
215949
216022
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215950
216023
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
215951
|
-
drizzleOrm.eq(externalAgents.
|
|
215952
|
-
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
216024
|
+
drizzleOrm.eq(externalAgents.id, params.externalAgentId)
|
|
215953
216025
|
)
|
|
215954
216026
|
});
|
|
215955
216027
|
return result || null;
|
|
@@ -215959,7 +216031,6 @@ var getExternalAgentByUrl = (db) => async (params) => {
|
|
|
215959
216031
|
where: drizzleOrm.and(
|
|
215960
216032
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215961
216033
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
215962
|
-
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId),
|
|
215963
216034
|
drizzleOrm.eq(externalAgents.baseUrl, params.baseUrl)
|
|
215964
216035
|
)
|
|
215965
216036
|
});
|
|
@@ -215969,8 +216040,7 @@ var listExternalAgents = (db) => async (params) => {
|
|
|
215969
216040
|
return await db.query.externalAgents.findMany({
|
|
215970
216041
|
where: drizzleOrm.and(
|
|
215971
216042
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215972
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
215973
|
-
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId)
|
|
216043
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
215974
216044
|
),
|
|
215975
216045
|
orderBy: [drizzleOrm.asc(externalAgents.name)]
|
|
215976
216046
|
});
|
|
@@ -215983,15 +216053,13 @@ var listExternalAgentsPaginated = (db) => async (params) => {
|
|
|
215983
216053
|
db.select().from(externalAgents).where(
|
|
215984
216054
|
drizzleOrm.and(
|
|
215985
216055
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215986
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
215987
|
-
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId)
|
|
216056
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
215988
216057
|
)
|
|
215989
216058
|
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(externalAgents.createdAt)),
|
|
215990
216059
|
db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
215991
216060
|
drizzleOrm.and(
|
|
215992
216061
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
215993
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
215994
|
-
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId)
|
|
216062
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
215995
216063
|
)
|
|
215996
216064
|
)
|
|
215997
216065
|
]);
|
|
@@ -216010,9 +216078,6 @@ var updateExternalAgent = (db) => async (params) => {
|
|
|
216010
216078
|
if (Object.keys(updateData).length === 1) {
|
|
216011
216079
|
throw new Error("No fields to update");
|
|
216012
216080
|
}
|
|
216013
|
-
if (updateData.headers !== void 0 && (updateData.headers === null || Object.keys(updateData.headers || {}).length === 0)) {
|
|
216014
|
-
updateData.headers = null;
|
|
216015
|
-
}
|
|
216016
216081
|
if (updateData.credentialReferenceId === void 0) {
|
|
216017
216082
|
updateData.credentialReferenceId = null;
|
|
216018
216083
|
}
|
|
@@ -216020,8 +216085,7 @@ var updateExternalAgent = (db) => async (params) => {
|
|
|
216020
216085
|
drizzleOrm.and(
|
|
216021
216086
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
216022
216087
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
216023
|
-
drizzleOrm.eq(externalAgents.
|
|
216024
|
-
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
216088
|
+
drizzleOrm.eq(externalAgents.id, params.externalAgentId)
|
|
216025
216089
|
)
|
|
216026
216090
|
).returning();
|
|
216027
216091
|
return result[0] || null;
|
|
@@ -216029,23 +216093,21 @@ var updateExternalAgent = (db) => async (params) => {
|
|
|
216029
216093
|
var upsertExternalAgent = (db) => async (params) => {
|
|
216030
216094
|
const scopes = {
|
|
216031
216095
|
tenantId: params.data.tenantId,
|
|
216032
|
-
projectId: params.data.projectId
|
|
216033
|
-
agentId: params.data.agentId
|
|
216096
|
+
projectId: params.data.projectId
|
|
216034
216097
|
};
|
|
216035
216098
|
const existing = await getExternalAgent(db)({
|
|
216036
216099
|
scopes,
|
|
216037
|
-
|
|
216100
|
+
externalAgentId: params.data.id
|
|
216038
216101
|
});
|
|
216039
216102
|
if (existing) {
|
|
216040
216103
|
const updated = await updateExternalAgent(db)({
|
|
216041
216104
|
scopes,
|
|
216042
|
-
|
|
216105
|
+
externalAgentId: params.data.id,
|
|
216043
216106
|
data: {
|
|
216044
216107
|
name: params.data.name,
|
|
216045
216108
|
description: params.data.description,
|
|
216046
216109
|
baseUrl: params.data.baseUrl,
|
|
216047
|
-
credentialReferenceId: params.data.credentialReferenceId
|
|
216048
|
-
headers: params.data.headers
|
|
216110
|
+
credentialReferenceId: params.data.credentialReferenceId
|
|
216049
216111
|
}
|
|
216050
216112
|
});
|
|
216051
216113
|
if (!updated) {
|
|
@@ -216062,8 +216124,7 @@ var deleteExternalAgent = (db) => async (params) => {
|
|
|
216062
216124
|
drizzleOrm.and(
|
|
216063
216125
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
216064
216126
|
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
216065
|
-
drizzleOrm.eq(externalAgents.
|
|
216066
|
-
drizzleOrm.eq(externalAgents.id, params.subAgentId)
|
|
216127
|
+
drizzleOrm.eq(externalAgents.id, params.externalAgentId)
|
|
216067
216128
|
)
|
|
216068
216129
|
).returning();
|
|
216069
216130
|
return result.length > 0;
|
|
@@ -216084,8 +216145,7 @@ var countExternalAgents = (db) => async (params) => {
|
|
|
216084
216145
|
const result = await db.select({ count: drizzleOrm.count() }).from(externalAgents).where(
|
|
216085
216146
|
drizzleOrm.and(
|
|
216086
216147
|
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
216087
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
216088
|
-
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId)
|
|
216148
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId)
|
|
216089
216149
|
)
|
|
216090
216150
|
);
|
|
216091
216151
|
const countValue = result[0]?.count;
|
|
@@ -216402,7 +216462,7 @@ var addFunctionToolToSubAgent = (db) => {
|
|
|
216402
216462
|
const { scopes, subAgentId, functionToolId } = params;
|
|
216403
216463
|
const { tenantId, projectId, agentId } = scopes;
|
|
216404
216464
|
try {
|
|
216405
|
-
const relationId =
|
|
216465
|
+
const relationId = generateId();
|
|
216406
216466
|
await db.insert(subAgentFunctionToolRelations).values({
|
|
216407
216467
|
id: relationId,
|
|
216408
216468
|
tenantId,
|
|
@@ -216455,6 +216515,284 @@ var updateSubAgentFunctionToolRelation = (db) => {
|
|
|
216455
216515
|
}
|
|
216456
216516
|
};
|
|
216457
216517
|
};
|
|
216518
|
+
var getSubAgentExternalAgentRelationById = (db) => async (params) => {
|
|
216519
|
+
return db.query.subAgentExternalAgentRelations.findFirst({
|
|
216520
|
+
where: drizzleOrm.and(
|
|
216521
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216522
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216523
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216524
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
|
|
216525
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.id, params.relationId)
|
|
216526
|
+
)
|
|
216527
|
+
});
|
|
216528
|
+
};
|
|
216529
|
+
var listSubAgentExternalAgentRelations = (db) => async (params) => {
|
|
216530
|
+
const page = params.pagination?.page || 1;
|
|
216531
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
216532
|
+
const offset = (page - 1) * limit;
|
|
216533
|
+
const whereClause = drizzleOrm.and(
|
|
216534
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216535
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216536
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216537
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
|
|
216538
|
+
);
|
|
216539
|
+
const [data, totalResult] = await Promise.all([
|
|
216540
|
+
db.select().from(subAgentExternalAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentExternalAgentRelations.createdAt)),
|
|
216541
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentExternalAgentRelations).where(whereClause)
|
|
216542
|
+
]);
|
|
216543
|
+
const total = totalResult[0]?.count || 0;
|
|
216544
|
+
const pages = Math.ceil(total / limit);
|
|
216545
|
+
return { data, pagination: { page, limit, total, pages } };
|
|
216546
|
+
};
|
|
216547
|
+
var getSubAgentExternalAgentRelations = (db) => async (params) => {
|
|
216548
|
+
return await db.query.subAgentExternalAgentRelations.findMany({
|
|
216549
|
+
where: drizzleOrm.and(
|
|
216550
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216551
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216552
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216553
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
|
|
216554
|
+
)
|
|
216555
|
+
});
|
|
216556
|
+
};
|
|
216557
|
+
var getSubAgentExternalAgentRelationsByAgent = (db) => async (params) => {
|
|
216558
|
+
return await db.query.subAgentExternalAgentRelations.findMany({
|
|
216559
|
+
where: drizzleOrm.and(
|
|
216560
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216561
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216562
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId)
|
|
216563
|
+
)
|
|
216564
|
+
});
|
|
216565
|
+
};
|
|
216566
|
+
var getSubAgentExternalAgentRelationsByExternalAgent = (db) => async (params) => {
|
|
216567
|
+
const page = params.pagination?.page || 1;
|
|
216568
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
216569
|
+
const offset = (page - 1) * limit;
|
|
216570
|
+
const whereClause = drizzleOrm.and(
|
|
216571
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216572
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216573
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216574
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)
|
|
216575
|
+
);
|
|
216576
|
+
const [data, totalResult] = await Promise.all([
|
|
216577
|
+
db.select().from(subAgentExternalAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentExternalAgentRelations.createdAt)),
|
|
216578
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentExternalAgentRelations).where(whereClause)
|
|
216579
|
+
]);
|
|
216580
|
+
const total = totalResult[0]?.count || 0;
|
|
216581
|
+
const pages = Math.ceil(total / limit);
|
|
216582
|
+
return {
|
|
216583
|
+
data,
|
|
216584
|
+
pagination: { page, limit, total, pages }
|
|
216585
|
+
};
|
|
216586
|
+
};
|
|
216587
|
+
var getExternalAgentsForSubAgent = (db) => async (params) => {
|
|
216588
|
+
const page = params.pagination?.page || 1;
|
|
216589
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
216590
|
+
const offset = (page - 1) * limit;
|
|
216591
|
+
const [data, totalResult] = await Promise.all([
|
|
216592
|
+
db.select({
|
|
216593
|
+
id: subAgentExternalAgentRelations.id,
|
|
216594
|
+
tenantId: subAgentExternalAgentRelations.tenantId,
|
|
216595
|
+
projectId: subAgentExternalAgentRelations.projectId,
|
|
216596
|
+
agentId: subAgentExternalAgentRelations.agentId,
|
|
216597
|
+
subAgentId: subAgentExternalAgentRelations.subAgentId,
|
|
216598
|
+
externalAgentId: subAgentExternalAgentRelations.externalAgentId,
|
|
216599
|
+
headers: subAgentExternalAgentRelations.headers,
|
|
216600
|
+
createdAt: subAgentExternalAgentRelations.createdAt,
|
|
216601
|
+
updatedAt: subAgentExternalAgentRelations.updatedAt,
|
|
216602
|
+
externalAgent: {
|
|
216603
|
+
id: externalAgents.id,
|
|
216604
|
+
name: externalAgents.name,
|
|
216605
|
+
description: externalAgents.description,
|
|
216606
|
+
baseUrl: externalAgents.baseUrl,
|
|
216607
|
+
credentialReferenceId: externalAgents.credentialReferenceId,
|
|
216608
|
+
tenantId: externalAgents.tenantId,
|
|
216609
|
+
projectId: externalAgents.projectId,
|
|
216610
|
+
createdAt: externalAgents.createdAt,
|
|
216611
|
+
updatedAt: externalAgents.updatedAt
|
|
216612
|
+
}
|
|
216613
|
+
}).from(subAgentExternalAgentRelations).innerJoin(
|
|
216614
|
+
externalAgents,
|
|
216615
|
+
drizzleOrm.and(
|
|
216616
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, externalAgents.tenantId),
|
|
216617
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, externalAgents.projectId),
|
|
216618
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.externalAgentId, externalAgents.id)
|
|
216619
|
+
)
|
|
216620
|
+
).where(
|
|
216621
|
+
drizzleOrm.and(
|
|
216622
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216623
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216624
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216625
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
|
|
216626
|
+
)
|
|
216627
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentExternalAgentRelations.createdAt)),
|
|
216628
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentExternalAgentRelations).where(
|
|
216629
|
+
drizzleOrm.and(
|
|
216630
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216631
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216632
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216633
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
|
|
216634
|
+
)
|
|
216635
|
+
)
|
|
216636
|
+
]);
|
|
216637
|
+
const total = totalResult[0]?.count || 0;
|
|
216638
|
+
const pages = Math.ceil(total / limit);
|
|
216639
|
+
return {
|
|
216640
|
+
data,
|
|
216641
|
+
pagination: { page, limit, total, pages }
|
|
216642
|
+
};
|
|
216643
|
+
};
|
|
216644
|
+
var getSubAgentsForExternalAgent = (db) => async (params) => {
|
|
216645
|
+
const page = params.pagination?.page || 1;
|
|
216646
|
+
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
216647
|
+
const offset = (page - 1) * limit;
|
|
216648
|
+
const [data, totalResult] = await Promise.all([
|
|
216649
|
+
db.select({
|
|
216650
|
+
id: subAgentExternalAgentRelations.id,
|
|
216651
|
+
tenantId: subAgentExternalAgentRelations.tenantId,
|
|
216652
|
+
projectId: subAgentExternalAgentRelations.projectId,
|
|
216653
|
+
agentId: subAgentExternalAgentRelations.agentId,
|
|
216654
|
+
subAgentId: subAgentExternalAgentRelations.subAgentId,
|
|
216655
|
+
externalAgentId: subAgentExternalAgentRelations.externalAgentId,
|
|
216656
|
+
headers: subAgentExternalAgentRelations.headers,
|
|
216657
|
+
createdAt: subAgentExternalAgentRelations.createdAt,
|
|
216658
|
+
updatedAt: subAgentExternalAgentRelations.updatedAt,
|
|
216659
|
+
subAgent: {
|
|
216660
|
+
id: subAgents.id,
|
|
216661
|
+
name: subAgents.name,
|
|
216662
|
+
description: subAgents.description,
|
|
216663
|
+
prompt: subAgents.prompt,
|
|
216664
|
+
conversationHistoryConfig: subAgents.conversationHistoryConfig,
|
|
216665
|
+
models: subAgents.models,
|
|
216666
|
+
stopWhen: subAgents.stopWhen,
|
|
216667
|
+
createdAt: subAgents.createdAt,
|
|
216668
|
+
updatedAt: subAgents.updatedAt
|
|
216669
|
+
}
|
|
216670
|
+
}).from(subAgentExternalAgentRelations).innerJoin(
|
|
216671
|
+
subAgents,
|
|
216672
|
+
drizzleOrm.and(
|
|
216673
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, subAgents.id),
|
|
216674
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, subAgents.tenantId),
|
|
216675
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, subAgents.projectId),
|
|
216676
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, subAgents.agentId)
|
|
216677
|
+
)
|
|
216678
|
+
).where(
|
|
216679
|
+
drizzleOrm.and(
|
|
216680
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216681
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216682
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216683
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)
|
|
216684
|
+
)
|
|
216685
|
+
).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentExternalAgentRelations.createdAt)),
|
|
216686
|
+
db.select({ count: drizzleOrm.count() }).from(subAgentExternalAgentRelations).where(
|
|
216687
|
+
drizzleOrm.and(
|
|
216688
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216689
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216690
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216691
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)
|
|
216692
|
+
)
|
|
216693
|
+
)
|
|
216694
|
+
]);
|
|
216695
|
+
const total = totalResult[0]?.count || 0;
|
|
216696
|
+
const pages = Math.ceil(total / limit);
|
|
216697
|
+
return {
|
|
216698
|
+
data,
|
|
216699
|
+
pagination: { page, limit, total, pages }
|
|
216700
|
+
};
|
|
216701
|
+
};
|
|
216702
|
+
var createSubAgentExternalAgentRelation = (db) => async (params) => {
|
|
216703
|
+
const finalRelationId = params.relationId ?? nanoid.nanoid();
|
|
216704
|
+
const relation = await db.insert(subAgentExternalAgentRelations).values({
|
|
216705
|
+
id: finalRelationId,
|
|
216706
|
+
tenantId: params.scopes.tenantId,
|
|
216707
|
+
projectId: params.scopes.projectId,
|
|
216708
|
+
agentId: params.scopes.agentId,
|
|
216709
|
+
subAgentId: params.scopes.subAgentId,
|
|
216710
|
+
externalAgentId: params.data.externalAgentId,
|
|
216711
|
+
headers: params.data.headers
|
|
216712
|
+
}).returning();
|
|
216713
|
+
return relation[0];
|
|
216714
|
+
};
|
|
216715
|
+
var getSubAgentExternalAgentRelationByParams = (db) => async (params) => {
|
|
216716
|
+
return db.query.subAgentExternalAgentRelations.findFirst({
|
|
216717
|
+
where: drizzleOrm.and(
|
|
216718
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216719
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216720
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216721
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
|
|
216722
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.externalAgentId, params.externalAgentId)
|
|
216723
|
+
)
|
|
216724
|
+
});
|
|
216725
|
+
};
|
|
216726
|
+
var upsertSubAgentExternalAgentRelation = (db) => async (params) => {
|
|
216727
|
+
if (params.relationId) {
|
|
216728
|
+
return await updateSubAgentExternalAgentRelation(db)({
|
|
216729
|
+
scopes: params.scopes,
|
|
216730
|
+
relationId: params.relationId,
|
|
216731
|
+
data: params.data
|
|
216732
|
+
});
|
|
216733
|
+
}
|
|
216734
|
+
const existing = await getSubAgentExternalAgentRelationByParams(db)({
|
|
216735
|
+
scopes: params.scopes,
|
|
216736
|
+
externalAgentId: params.data.externalAgentId
|
|
216737
|
+
});
|
|
216738
|
+
if (existing) {
|
|
216739
|
+
return await updateSubAgentExternalAgentRelation(db)({
|
|
216740
|
+
scopes: params.scopes,
|
|
216741
|
+
relationId: existing.id,
|
|
216742
|
+
data: params.data
|
|
216743
|
+
});
|
|
216744
|
+
}
|
|
216745
|
+
return await createSubAgentExternalAgentRelation(db)(params);
|
|
216746
|
+
};
|
|
216747
|
+
var updateSubAgentExternalAgentRelation = (db) => async (params) => {
|
|
216748
|
+
const updateData = {
|
|
216749
|
+
...params.data,
|
|
216750
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
216751
|
+
};
|
|
216752
|
+
const relation = await db.update(subAgentExternalAgentRelations).set(updateData).where(
|
|
216753
|
+
drizzleOrm.and(
|
|
216754
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216755
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216756
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216757
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
|
|
216758
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.id, params.relationId)
|
|
216759
|
+
)
|
|
216760
|
+
).returning();
|
|
216761
|
+
return relation[0];
|
|
216762
|
+
};
|
|
216763
|
+
var deleteSubAgentExternalAgentRelation = (db) => async (params) => {
|
|
216764
|
+
const result = await db.delete(subAgentExternalAgentRelations).where(
|
|
216765
|
+
drizzleOrm.and(
|
|
216766
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216767
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216768
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216769
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId),
|
|
216770
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.id, params.relationId)
|
|
216771
|
+
)
|
|
216772
|
+
);
|
|
216773
|
+
return (result.rowsAffected || 0) > 0;
|
|
216774
|
+
};
|
|
216775
|
+
var deleteSubAgentExternalAgentRelationsBySubAgent = (db) => async (params) => {
|
|
216776
|
+
const result = await db.delete(subAgentExternalAgentRelations).where(
|
|
216777
|
+
drizzleOrm.and(
|
|
216778
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216779
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216780
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId),
|
|
216781
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.subAgentId, params.scopes.subAgentId)
|
|
216782
|
+
)
|
|
216783
|
+
);
|
|
216784
|
+
return (result.rowsAffected || 0) > 0;
|
|
216785
|
+
};
|
|
216786
|
+
var deleteSubAgentExternalAgentRelationsByAgent = (db) => async (params) => {
|
|
216787
|
+
const result = await db.delete(subAgentExternalAgentRelations).where(
|
|
216788
|
+
drizzleOrm.and(
|
|
216789
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.tenantId, params.scopes.tenantId),
|
|
216790
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.projectId, params.scopes.projectId),
|
|
216791
|
+
drizzleOrm.eq(subAgentExternalAgentRelations.agentId, params.scopes.agentId)
|
|
216792
|
+
)
|
|
216793
|
+
);
|
|
216794
|
+
return (result.rowsAffected || 0) > 0;
|
|
216795
|
+
};
|
|
216458
216796
|
var getAgentRelationById = (db) => async (params) => {
|
|
216459
216797
|
return db.query.subAgentRelations.findFirst({
|
|
216460
216798
|
where: drizzleOrm.and(
|
|
@@ -216543,29 +216881,8 @@ var getSubAgentRelationsByTarget = (db) => async (params) => {
|
|
|
216543
216881
|
pagination: { page, limit, total, pages }
|
|
216544
216882
|
};
|
|
216545
216883
|
};
|
|
216546
|
-
var getExternalAgentRelations = (db) => async (params) => {
|
|
216547
|
-
const page = params.pagination?.page || 1;
|
|
216548
|
-
const limit = Math.min(params.pagination?.limit || 10, 100);
|
|
216549
|
-
const offset = (page - 1) * limit;
|
|
216550
|
-
const whereClause = drizzleOrm.and(
|
|
216551
|
-
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216552
|
-
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216553
|
-
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216554
|
-
drizzleOrm.eq(subAgentRelations.externalSubAgentId, params.externalSubAgentId)
|
|
216555
|
-
);
|
|
216556
|
-
const [data, totalResult] = await Promise.all([
|
|
216557
|
-
db.select().from(subAgentRelations).where(whereClause).limit(limit).offset(offset).orderBy(drizzleOrm.desc(subAgentRelations.createdAt)),
|
|
216558
|
-
db.select({ count: drizzleOrm.count() }).from(subAgentRelations).where(whereClause)
|
|
216559
|
-
]);
|
|
216560
|
-
const total = totalResult[0]?.count || 0;
|
|
216561
|
-
const pages = Math.ceil(total / limit);
|
|
216562
|
-
return {
|
|
216563
|
-
data,
|
|
216564
|
-
pagination: { page, limit, total, pages }
|
|
216565
|
-
};
|
|
216566
|
-
};
|
|
216567
216884
|
var getRelatedAgentsForAgent = (db) => async (params) => {
|
|
216568
|
-
const
|
|
216885
|
+
const data = await db.select({
|
|
216569
216886
|
id: subAgents.id,
|
|
216570
216887
|
name: subAgents.name,
|
|
216571
216888
|
description: subAgents.description,
|
|
@@ -216587,35 +216904,8 @@ var getRelatedAgentsForAgent = (db) => async (params) => {
|
|
|
216587
216904
|
drizzleOrm.isNotNull(subAgentRelations.targetSubAgentId)
|
|
216588
216905
|
)
|
|
216589
216906
|
);
|
|
216590
|
-
const externalRelations = await db.select({
|
|
216591
|
-
id: subAgentRelations.id,
|
|
216592
|
-
relationType: subAgentRelations.relationType,
|
|
216593
|
-
externalAgent: {
|
|
216594
|
-
id: externalAgents.id,
|
|
216595
|
-
name: externalAgents.name,
|
|
216596
|
-
description: externalAgents.description,
|
|
216597
|
-
baseUrl: externalAgents.baseUrl
|
|
216598
|
-
}
|
|
216599
|
-
}).from(subAgentRelations).innerJoin(
|
|
216600
|
-
externalAgents,
|
|
216601
|
-
drizzleOrm.and(
|
|
216602
|
-
drizzleOrm.eq(subAgentRelations.externalSubAgentId, externalAgents.id),
|
|
216603
|
-
drizzleOrm.eq(subAgentRelations.tenantId, externalAgents.tenantId),
|
|
216604
|
-
drizzleOrm.eq(subAgentRelations.projectId, externalAgents.projectId),
|
|
216605
|
-
drizzleOrm.eq(subAgentRelations.agentId, externalAgents.agentId)
|
|
216606
|
-
)
|
|
216607
|
-
).where(
|
|
216608
|
-
drizzleOrm.and(
|
|
216609
|
-
drizzleOrm.eq(subAgentRelations.tenantId, params.scopes.tenantId),
|
|
216610
|
-
drizzleOrm.eq(subAgentRelations.projectId, params.scopes.projectId),
|
|
216611
|
-
drizzleOrm.eq(subAgentRelations.agentId, params.scopes.agentId),
|
|
216612
|
-
drizzleOrm.eq(subAgentRelations.sourceSubAgentId, params.subAgentId),
|
|
216613
|
-
drizzleOrm.isNotNull(subAgentRelations.externalSubAgentId)
|
|
216614
|
-
)
|
|
216615
|
-
);
|
|
216616
216907
|
return {
|
|
216617
|
-
|
|
216618
|
-
externalRelations
|
|
216908
|
+
data
|
|
216619
216909
|
};
|
|
216620
216910
|
};
|
|
216621
216911
|
var createSubAgentRelation = (db) => async (params) => {
|
|
@@ -216643,9 +216933,6 @@ var getAgentRelationByParams = (db) => async (params) => {
|
|
|
216643
216933
|
if (params.targetSubAgentId) {
|
|
216644
216934
|
whereConditions.push(drizzleOrm.eq(subAgentRelations.targetSubAgentId, params.targetSubAgentId));
|
|
216645
216935
|
}
|
|
216646
|
-
if (params.externalSubAgentId) {
|
|
216647
|
-
whereConditions.push(drizzleOrm.eq(subAgentRelations.externalSubAgentId, params.externalSubAgentId));
|
|
216648
|
-
}
|
|
216649
216936
|
return db.query.subAgentRelations.findFirst({
|
|
216650
216937
|
where: drizzleOrm.and(...whereConditions)
|
|
216651
216938
|
});
|
|
@@ -216655,7 +216942,6 @@ var upsertSubAgentRelation = (db) => async (params) => {
|
|
|
216655
216942
|
scopes: { tenantId: params.tenantId, projectId: params.projectId, agentId: params.agentId },
|
|
216656
216943
|
sourceSubAgentId: params.sourceSubAgentId,
|
|
216657
216944
|
targetSubAgentId: params.targetSubAgentId,
|
|
216658
|
-
externalSubAgentId: params.externalSubAgentId,
|
|
216659
216945
|
relationType: params.relationType ?? ""
|
|
216660
216946
|
});
|
|
216661
216947
|
if (!existing) {
|
|
@@ -216663,12 +216949,6 @@ var upsertSubAgentRelation = (db) => async (params) => {
|
|
|
216663
216949
|
}
|
|
216664
216950
|
return existing;
|
|
216665
216951
|
};
|
|
216666
|
-
var createExternalAgentRelation = (db) => async (params) => {
|
|
216667
|
-
return await createSubAgentRelation(db)({
|
|
216668
|
-
...params,
|
|
216669
|
-
targetSubAgentId: void 0
|
|
216670
|
-
});
|
|
216671
|
-
};
|
|
216672
216952
|
var updateAgentRelation = (db) => async (params) => {
|
|
216673
216953
|
const updateData = {
|
|
216674
216954
|
...params.data,
|
|
@@ -216705,7 +216985,7 @@ var deleteAgentRelationsByAgent = (db) => async (params) => {
|
|
|
216705
216985
|
return (result.rowsAffected || 0) > 0;
|
|
216706
216986
|
};
|
|
216707
216987
|
var createAgentToolRelation = (db) => async (params) => {
|
|
216708
|
-
const finalRelationId = params.relationId ??
|
|
216988
|
+
const finalRelationId = params.relationId ?? generateId();
|
|
216709
216989
|
const relation = await db.insert(subAgentToolRelations).values({
|
|
216710
216990
|
id: finalRelationId,
|
|
216711
216991
|
tenantId: params.scopes.tenantId,
|
|
@@ -216965,7 +217245,7 @@ var getAgentsForTool = (db) => async (params) => {
|
|
|
216965
217245
|
pagination: { page, limit, total, pages }
|
|
216966
217246
|
};
|
|
216967
217247
|
};
|
|
216968
|
-
var
|
|
217248
|
+
var validateSubAgent = (db) => async (params) => {
|
|
216969
217249
|
const result = await db.select({ id: subAgents.id }).from(subAgents).where(
|
|
216970
217250
|
drizzleOrm.and(
|
|
216971
217251
|
drizzleOrm.eq(subAgents.tenantId, params.scopes.tenantId),
|
|
@@ -216976,17 +217256,6 @@ var validateInternalSubAgent = (db) => async (params) => {
|
|
|
216976
217256
|
).limit(1);
|
|
216977
217257
|
return result.length > 0;
|
|
216978
217258
|
};
|
|
216979
|
-
var validateExternalAgent = (db) => async (params) => {
|
|
216980
|
-
const result = await db.select({ id: externalAgents.id }).from(externalAgents).where(
|
|
216981
|
-
drizzleOrm.and(
|
|
216982
|
-
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
216983
|
-
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
216984
|
-
drizzleOrm.eq(externalAgents.agentId, params.scopes.agentId),
|
|
216985
|
-
drizzleOrm.eq(externalAgents.id, params.scopes.subAgentId)
|
|
216986
|
-
)
|
|
216987
|
-
).limit(1);
|
|
216988
|
-
return result.length > 0;
|
|
216989
|
-
};
|
|
216990
217259
|
var getSubAgentById = (db) => async (params) => {
|
|
216991
217260
|
const result = await db.query.subAgents.findFirst({
|
|
216992
217261
|
where: drizzleOrm.and(
|
|
@@ -217126,7 +217395,7 @@ async function generateApiKey() {
|
|
|
217126
217395
|
const key = `sk_${publicId}.${secret}`;
|
|
217127
217396
|
const keyPrefix = key.substring(0, 12);
|
|
217128
217397
|
const keyHash = await hashApiKey(key);
|
|
217129
|
-
const id =
|
|
217398
|
+
const id = generateId();
|
|
217130
217399
|
return {
|
|
217131
217400
|
id,
|
|
217132
217401
|
publicId,
|
|
@@ -217854,8 +218123,8 @@ var getCredentialReference = (db) => async (params) => {
|
|
|
217854
218123
|
)
|
|
217855
218124
|
});
|
|
217856
218125
|
};
|
|
217857
|
-
var
|
|
217858
|
-
const [credential, relatedTools] = await Promise.all([
|
|
218126
|
+
var getCredentialReferenceWithResources = (db) => async (params) => {
|
|
218127
|
+
const [credential, relatedTools, relatedExternalAgents] = await Promise.all([
|
|
217859
218128
|
db.query.credentialReferences.findFirst({
|
|
217860
218129
|
where: drizzleOrm.and(
|
|
217861
218130
|
drizzleOrm.eq(credentialReferences.tenantId, params.scopes.tenantId),
|
|
@@ -217869,6 +218138,13 @@ var getCredentialReferenceWithTools = (db) => async (params) => {
|
|
|
217869
218138
|
drizzleOrm.eq(tools.projectId, params.scopes.projectId),
|
|
217870
218139
|
drizzleOrm.eq(tools.credentialReferenceId, params.id)
|
|
217871
218140
|
)
|
|
218141
|
+
),
|
|
218142
|
+
db.select().from(externalAgents).where(
|
|
218143
|
+
drizzleOrm.and(
|
|
218144
|
+
drizzleOrm.eq(externalAgents.tenantId, params.scopes.tenantId),
|
|
218145
|
+
drizzleOrm.eq(externalAgents.projectId, params.scopes.projectId),
|
|
218146
|
+
drizzleOrm.eq(externalAgents.credentialReferenceId, params.id)
|
|
218147
|
+
)
|
|
217872
218148
|
)
|
|
217873
218149
|
]);
|
|
217874
218150
|
if (!credential) {
|
|
@@ -217876,7 +218152,8 @@ var getCredentialReferenceWithTools = (db) => async (params) => {
|
|
|
217876
218152
|
}
|
|
217877
218153
|
return {
|
|
217878
218154
|
...credential,
|
|
217879
|
-
tools: relatedTools
|
|
218155
|
+
tools: relatedTools,
|
|
218156
|
+
externalAgents: relatedExternalAgents
|
|
217880
218157
|
};
|
|
217881
218158
|
};
|
|
217882
218159
|
var listCredentialReferences = (db) => async (params) => {
|
|
@@ -217928,7 +218205,7 @@ var updateCredentialReference = (db) => async (params) => {
|
|
|
217928
218205
|
drizzleOrm.eq(credentialReferences.id, params.id)
|
|
217929
218206
|
)
|
|
217930
218207
|
);
|
|
217931
|
-
return await
|
|
218208
|
+
return await getCredentialReferenceWithResources(db)({
|
|
217932
218209
|
scopes: params.scopes,
|
|
217933
218210
|
id: params.id
|
|
217934
218211
|
});
|
|
@@ -218259,7 +218536,7 @@ var deleteTool = (db) => async (params) => {
|
|
|
218259
218536
|
return !!deleted;
|
|
218260
218537
|
};
|
|
218261
218538
|
var addToolToAgent = (db) => async (params) => {
|
|
218262
|
-
const id =
|
|
218539
|
+
const id = generateId();
|
|
218263
218540
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
218264
218541
|
const [created] = await db.insert(subAgentToolRelations).values({
|
|
218265
218542
|
id,
|
|
@@ -218504,11 +218781,12 @@ var getFullAgentDefinition = (db) => async ({
|
|
|
218504
218781
|
drizzleOrm.eq(subAgents.agentId, agentId)
|
|
218505
218782
|
)
|
|
218506
218783
|
});
|
|
218784
|
+
const externalAgentRelations = await getSubAgentExternalAgentRelationsByAgent(db)({
|
|
218785
|
+
scopes: { tenantId, projectId, agentId }
|
|
218786
|
+
});
|
|
218507
218787
|
const externalSubAgentIds = /* @__PURE__ */ new Set();
|
|
218508
|
-
for (const relation of
|
|
218509
|
-
|
|
218510
|
-
externalSubAgentIds.add(relation.externalSubAgentId);
|
|
218511
|
-
}
|
|
218788
|
+
for (const relation of externalAgentRelations) {
|
|
218789
|
+
externalSubAgentIds.add(relation.externalAgentId);
|
|
218512
218790
|
}
|
|
218513
218791
|
const processedSubAgents = await Promise.all(
|
|
218514
218792
|
agentSubAgents.map(async (agent2) => {
|
|
@@ -218517,7 +218795,13 @@ var getFullAgentDefinition = (db) => async ({
|
|
|
218517
218795
|
(relation) => relation.sourceSubAgentId === agent2.id
|
|
218518
218796
|
);
|
|
218519
218797
|
const canTransferTo = subAgentRelationsList.filter((rel) => rel.relationType === "transfer" || rel.relationType === "transfer_to").map((rel) => rel.targetSubAgentId).filter((id) => id !== null);
|
|
218520
|
-
const
|
|
218798
|
+
const canDelegateToInternal = subAgentRelationsList.filter((rel) => rel.relationType === "delegate" || rel.relationType === "delegate_to").map((rel) => rel.targetSubAgentId).filter((id) => id !== null);
|
|
218799
|
+
const canDelegateToExternal = externalAgentRelations.filter((rel) => rel.subAgentId === agent2.id).map((rel) => ({
|
|
218800
|
+
externalAgentId: rel.externalAgentId,
|
|
218801
|
+
subAgentExternalAgentRelationId: rel.id,
|
|
218802
|
+
headers: rel.headers
|
|
218803
|
+
}));
|
|
218804
|
+
const canDelegateTo = [...canDelegateToInternal, ...canDelegateToExternal];
|
|
218521
218805
|
const subAgentTools = await db.select({
|
|
218522
218806
|
id: tools.id,
|
|
218523
218807
|
name: tools.name,
|
|
@@ -218622,10 +218906,10 @@ var getFullAgentDefinition = (db) => async ({
|
|
|
218622
218906
|
})
|
|
218623
218907
|
);
|
|
218624
218908
|
const externalAgents2 = await Promise.all(
|
|
218625
|
-
Array.from(externalSubAgentIds).map(async (
|
|
218909
|
+
Array.from(externalSubAgentIds).map(async (externalAgentId) => {
|
|
218626
218910
|
const subAgent = await getExternalAgent(db)({
|
|
218627
|
-
scopes: { tenantId, projectId
|
|
218628
|
-
|
|
218911
|
+
scopes: { tenantId, projectId },
|
|
218912
|
+
externalAgentId
|
|
218629
218913
|
});
|
|
218630
218914
|
if (!subAgent) return null;
|
|
218631
218915
|
return {
|
|
@@ -218634,24 +218918,26 @@ var getFullAgentDefinition = (db) => async ({
|
|
|
218634
218918
|
};
|
|
218635
218919
|
})
|
|
218636
218920
|
);
|
|
218637
|
-
const validSubAgents =
|
|
218921
|
+
const validSubAgents = processedSubAgents.filter(
|
|
218922
|
+
(agent2) => agent2 !== null
|
|
218923
|
+
);
|
|
218924
|
+
const validExternalAgents = externalAgents2.filter(
|
|
218638
218925
|
(agent2) => agent2 !== null
|
|
218639
218926
|
);
|
|
218640
218927
|
const agentsObject = {};
|
|
218928
|
+
const externalAgentsObject = {};
|
|
218641
218929
|
for (const subAgent of validSubAgents) {
|
|
218642
|
-
|
|
218643
|
-
|
|
218644
|
-
|
|
218645
|
-
|
|
218646
|
-
|
|
218647
|
-
|
|
218648
|
-
|
|
218649
|
-
|
|
218650
|
-
|
|
218651
|
-
|
|
218652
|
-
}
|
|
218653
|
-
agentsObject[subAgent.id] = subAgent;
|
|
218654
|
-
}
|
|
218930
|
+
agentsObject[subAgent.id] = subAgent;
|
|
218931
|
+
}
|
|
218932
|
+
for (const externalAgent of validExternalAgents) {
|
|
218933
|
+
externalAgentsObject[externalAgent.id] = {
|
|
218934
|
+
id: externalAgent.id,
|
|
218935
|
+
name: externalAgent.name,
|
|
218936
|
+
description: externalAgent.description,
|
|
218937
|
+
baseUrl: externalAgent.baseUrl,
|
|
218938
|
+
credentialReferenceId: externalAgent.credentialReferenceId,
|
|
218939
|
+
type: "external"
|
|
218940
|
+
};
|
|
218655
218941
|
}
|
|
218656
218942
|
let contextConfig2 = null;
|
|
218657
218943
|
if (agent.contextConfigId) {
|
|
@@ -218711,6 +218997,9 @@ var getFullAgentDefinition = (db) => async ({
|
|
|
218711
218997
|
createdAt: agent.createdAt && !Number.isNaN(new Date(agent.createdAt).getTime()) ? new Date(agent.createdAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
218712
218998
|
updatedAt: agent.updatedAt && !Number.isNaN(new Date(agent.updatedAt).getTime()) ? new Date(agent.updatedAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString()
|
|
218713
218999
|
};
|
|
219000
|
+
if (Object.keys(externalAgentsObject).length > 0) {
|
|
219001
|
+
result.externalAgents = externalAgentsObject;
|
|
219002
|
+
}
|
|
218714
219003
|
if (agent.models) {
|
|
218715
219004
|
result.models = agent.models;
|
|
218716
219005
|
}
|
|
@@ -218838,7 +219127,7 @@ var getFullAgentDefinition = (db) => async ({
|
|
|
218838
219127
|
return result;
|
|
218839
219128
|
};
|
|
218840
219129
|
var upsertAgent = (db) => async (params) => {
|
|
218841
|
-
const agentId = params.data.id ||
|
|
219130
|
+
const agentId = params.data.id || generateId();
|
|
218842
219131
|
const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId, agentId };
|
|
218843
219132
|
const existing = await getAgentById(db)({
|
|
218844
219133
|
scopes
|
|
@@ -219242,7 +219531,7 @@ var getArtifactComponentsForAgent = (db) => async (params) => {
|
|
|
219242
219531
|
};
|
|
219243
219532
|
var associateArtifactComponentWithAgent = (db) => async (params) => {
|
|
219244
219533
|
const [association] = await db.insert(subAgentArtifactComponents).values({
|
|
219245
|
-
id:
|
|
219534
|
+
id: generateId(),
|
|
219246
219535
|
tenantId: params.scopes.tenantId,
|
|
219247
219536
|
projectId: params.scopes.projectId,
|
|
219248
219537
|
agentId: params.scopes.agentId,
|
|
@@ -219405,7 +219694,7 @@ var getCacheEntry = (db) => async (params) => {
|
|
|
219405
219694
|
var setCacheEntry = (db) => async (entry) => {
|
|
219406
219695
|
try {
|
|
219407
219696
|
const cacheData = {
|
|
219408
|
-
id:
|
|
219697
|
+
id: generateId(),
|
|
219409
219698
|
tenantId: entry.tenantId,
|
|
219410
219699
|
projectId: entry.projectId,
|
|
219411
219700
|
conversationId: entry.conversationId,
|
|
@@ -219962,7 +220251,7 @@ var getDataComponentsForAgent = (db) => async (params) => {
|
|
|
219962
220251
|
};
|
|
219963
220252
|
var associateDataComponentWithAgent = (db) => async (params) => {
|
|
219964
220253
|
const association = await db.insert(subAgentDataComponents).values({
|
|
219965
|
-
id:
|
|
220254
|
+
id: generateId(),
|
|
219966
220255
|
tenantId: params.scopes.tenantId,
|
|
219967
220256
|
projectId: params.scopes.projectId,
|
|
219968
220257
|
agentId: params.scopes.agentId,
|
|
@@ -220056,12 +220345,6 @@ var upsertDataComponent = (db) => async (params) => {
|
|
|
220056
220345
|
};
|
|
220057
220346
|
|
|
220058
220347
|
// src/validation/agentFull.ts
|
|
220059
|
-
function isInternalAgent(agent) {
|
|
220060
|
-
return "prompt" in agent;
|
|
220061
|
-
}
|
|
220062
|
-
function isExternalAgent(agent) {
|
|
220063
|
-
return "baseUrl" in agent;
|
|
220064
|
-
}
|
|
220065
220348
|
function validateAndTypeAgentData(data) {
|
|
220066
220349
|
return AgentWithinContextOfProjectSchema.parse(data);
|
|
220067
220350
|
}
|
|
@@ -220071,7 +220354,7 @@ function validateToolReferences(agentData, availableToolIds) {
|
|
|
220071
220354
|
}
|
|
220072
220355
|
const errors = [];
|
|
220073
220356
|
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
220074
|
-
if (
|
|
220357
|
+
if (subAgent.canUse && Array.isArray(subAgent.canUse)) {
|
|
220075
220358
|
for (const canUseItem of subAgent.canUse) {
|
|
220076
220359
|
if (!availableToolIds.has(canUseItem.toolId)) {
|
|
220077
220360
|
errors.push(`Agent '${subAgentId}' references non-existent tool '${canUseItem.toolId}'`);
|
|
@@ -220090,7 +220373,7 @@ function validateDataComponentReferences(agentData, availableDataComponentIds) {
|
|
|
220090
220373
|
}
|
|
220091
220374
|
const errors = [];
|
|
220092
220375
|
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
220093
|
-
if (
|
|
220376
|
+
if (subAgent.dataComponents) {
|
|
220094
220377
|
for (const dataComponentId of subAgent.dataComponents) {
|
|
220095
220378
|
if (!availableDataComponentIds.has(dataComponentId)) {
|
|
220096
220379
|
errors.push(
|
|
@@ -220111,7 +220394,7 @@ function validateArtifactComponentReferences(agentData, availableArtifactCompone
|
|
|
220111
220394
|
}
|
|
220112
220395
|
const errors = [];
|
|
220113
220396
|
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
220114
|
-
if (
|
|
220397
|
+
if (subAgent.artifactComponents) {
|
|
220115
220398
|
for (const artifactComponentId of subAgent.artifactComponents) {
|
|
220116
220399
|
if (!availableArtifactComponentIds.has(artifactComponentId)) {
|
|
220117
220400
|
errors.push(
|
|
@@ -220129,32 +220412,56 @@ ${errors.join("\n")}`);
|
|
|
220129
220412
|
function validateAgentRelationships(agentData) {
|
|
220130
220413
|
const errors = [];
|
|
220131
220414
|
const availableAgentIds = new Set(Object.keys(agentData.subAgents));
|
|
220415
|
+
const availableExternalAgentIds = new Set(Object.keys(agentData.externalAgents ?? {}));
|
|
220132
220416
|
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
220133
|
-
if (
|
|
220134
|
-
|
|
220135
|
-
|
|
220136
|
-
|
|
220417
|
+
if (subAgent.canTransferTo && Array.isArray(subAgent.canTransferTo)) {
|
|
220418
|
+
for (const targetId of subAgent.canTransferTo) {
|
|
220419
|
+
if (!availableAgentIds.has(targetId)) {
|
|
220420
|
+
errors.push(
|
|
220421
|
+
`Agent '${subAgentId}' has transfer target '${targetId}' that doesn't exist in agent`
|
|
220422
|
+
);
|
|
220423
|
+
}
|
|
220424
|
+
}
|
|
220425
|
+
}
|
|
220426
|
+
if (subAgent.canDelegateTo && Array.isArray(subAgent.canDelegateTo)) {
|
|
220427
|
+
for (const targetItem of subAgent.canDelegateTo) {
|
|
220428
|
+
console.log("targetItem", targetItem);
|
|
220429
|
+
if (typeof targetItem === "string") {
|
|
220430
|
+
console.log("targetItem is string", targetItem);
|
|
220431
|
+
if (!availableAgentIds.has(targetItem) && !availableExternalAgentIds.has(targetItem)) {
|
|
220137
220432
|
errors.push(
|
|
220138
|
-
`Agent '${subAgentId}' has
|
|
220433
|
+
`Agent '${subAgentId}' has delegation target '${targetItem}' that doesn't exist in agent`
|
|
220139
220434
|
);
|
|
220140
220435
|
}
|
|
220141
220436
|
}
|
|
220142
220437
|
}
|
|
220143
|
-
|
|
220144
|
-
|
|
220145
|
-
|
|
220438
|
+
}
|
|
220439
|
+
}
|
|
220440
|
+
if (errors.length > 0)
|
|
220441
|
+
throw new Error(`Agent relationship validation failed:
|
|
220442
|
+
${errors.join("\n")}`);
|
|
220443
|
+
}
|
|
220444
|
+
function validateSubAgentExternalAgentRelations(agentData, availableExternalAgentIds) {
|
|
220445
|
+
if (!availableExternalAgentIds) {
|
|
220446
|
+
return;
|
|
220447
|
+
}
|
|
220448
|
+
const errors = [];
|
|
220449
|
+
for (const [subAgentId, subAgent] of Object.entries(agentData.subAgents)) {
|
|
220450
|
+
if (subAgent.canDelegateTo && Array.isArray(subAgent.canDelegateTo)) {
|
|
220451
|
+
for (const targetItem of subAgent.canDelegateTo) {
|
|
220452
|
+
if (typeof targetItem === "object" && "externalAgentId" in targetItem) {
|
|
220453
|
+
if (!availableExternalAgentIds.has(targetItem.externalAgentId)) {
|
|
220146
220454
|
errors.push(
|
|
220147
|
-
`Agent '${subAgentId}' has delegation target '${
|
|
220455
|
+
`Agent '${subAgentId}' has delegation target '${targetItem.externalAgentId}' that doesn't exist in agent`
|
|
220148
220456
|
);
|
|
220149
220457
|
}
|
|
220150
220458
|
}
|
|
220151
220459
|
}
|
|
220152
220460
|
}
|
|
220153
220461
|
}
|
|
220154
|
-
if (errors.length > 0)
|
|
220155
|
-
throw new Error(`
|
|
220462
|
+
if (errors.length > 0)
|
|
220463
|
+
throw new Error(`Sub agent external agent relation validation failed:
|
|
220156
220464
|
${errors.join("\n")}`);
|
|
220157
|
-
}
|
|
220158
220465
|
}
|
|
220159
220466
|
function validateAgentStructure(agentData, projectResources) {
|
|
220160
220467
|
if (agentData.defaultSubAgentId && !agentData.subAgents[agentData.defaultSubAgentId]) {
|
|
@@ -220164,6 +220471,7 @@ function validateAgentStructure(agentData, projectResources) {
|
|
|
220164
220471
|
validateToolReferences(agentData, projectResources.toolIds);
|
|
220165
220472
|
validateDataComponentReferences(agentData, projectResources.dataComponentIds);
|
|
220166
220473
|
validateArtifactComponentReferences(agentData, projectResources.artifactComponentIds);
|
|
220474
|
+
validateSubAgentExternalAgentRelations(agentData, projectResources.externalAgentIds);
|
|
220167
220475
|
}
|
|
220168
220476
|
validateAgentRelationships(agentData);
|
|
220169
220477
|
}
|
|
@@ -220225,7 +220533,7 @@ async function applyExecutionLimitsInheritance(db, logger14, scopes, agentData)
|
|
|
220225
220533
|
"Propagating stepCountIs to agents"
|
|
220226
220534
|
);
|
|
220227
220535
|
for (const [subAgentId, subAgentData] of Object.entries(agentData.subAgents)) {
|
|
220228
|
-
if (
|
|
220536
|
+
if (subAgentData.canTransferTo && Array.isArray(subAgentData.canTransferTo)) {
|
|
220229
220537
|
const agent = agentData;
|
|
220230
220538
|
if (!agent.stopWhen) {
|
|
220231
220539
|
agent.stopWhen = {};
|
|
@@ -220266,7 +220574,7 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220266
220574
|
logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in agent");
|
|
220267
220575
|
let finalAgentId;
|
|
220268
220576
|
try {
|
|
220269
|
-
const agentId = typed.id ||
|
|
220577
|
+
const agentId = typed.id || generateId();
|
|
220270
220578
|
logger14.info({ agentId }, "Creating agent metadata");
|
|
220271
220579
|
const agent = await upsertAgent(db)({
|
|
220272
220580
|
data: {
|
|
@@ -220438,85 +220746,39 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220438
220746
|
"All function tools created successfully"
|
|
220439
220747
|
);
|
|
220440
220748
|
}
|
|
220441
|
-
const
|
|
220442
|
-
|
|
220443
|
-
|
|
220444
|
-
|
|
220445
|
-
|
|
220446
|
-
|
|
220447
|
-
|
|
220448
|
-
|
|
220449
|
-
|
|
220450
|
-
|
|
220451
|
-
|
|
220452
|
-
|
|
220453
|
-
|
|
220454
|
-
|
|
220455
|
-
|
|
220456
|
-
|
|
220457
|
-
|
|
220458
|
-
|
|
220459
|
-
|
|
220460
|
-
|
|
220461
|
-
|
|
220462
|
-
|
|
220463
|
-
|
|
220464
|
-
|
|
220465
|
-
await Promise.all(internalAgentPromises);
|
|
220466
|
-
const internalAgentCount = Object.entries(typed.subAgents).filter(
|
|
220467
|
-
([_, agentData2]) => isInternalAgent(agentData2)
|
|
220468
|
-
).length;
|
|
220469
|
-
logger14.info({ internalAgentCount }, "All internal agents created/updated successfully");
|
|
220470
|
-
const externalAgentPromises = Object.entries(typed.subAgents).filter(([_, agentData2]) => isExternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
|
|
220471
|
-
const externalAgent = agentData2;
|
|
220472
|
-
try {
|
|
220473
|
-
logger14.info({ subAgentId }, "Processing external agent");
|
|
220474
|
-
await upsertExternalAgent(db)({
|
|
220475
|
-
data: {
|
|
220476
|
-
id: subAgentId,
|
|
220477
|
-
tenantId,
|
|
220478
|
-
projectId,
|
|
220479
|
-
agentId: finalAgentId,
|
|
220480
|
-
name: externalAgent.name,
|
|
220481
|
-
description: externalAgent.description || "",
|
|
220482
|
-
baseUrl: externalAgent.baseUrl,
|
|
220483
|
-
credentialReferenceId: externalAgent.credentialReferenceId || void 0,
|
|
220484
|
-
headers: externalAgent.headers || void 0
|
|
220485
|
-
}
|
|
220486
|
-
});
|
|
220487
|
-
logger14.info({ subAgentId }, "External agent processed successfully");
|
|
220488
|
-
} catch (error) {
|
|
220489
|
-
logger14.error({ subAgentId, error }, "Failed to create/update external agent");
|
|
220490
|
-
throw error;
|
|
220491
|
-
}
|
|
220492
|
-
});
|
|
220493
|
-
await Promise.all(externalAgentPromises);
|
|
220494
|
-
const externalAgentCount = Object.entries(typed.subAgents).filter(
|
|
220495
|
-
([_, agentData2]) => isExternalAgent(agentData2)
|
|
220496
|
-
).length;
|
|
220497
|
-
logger14.info({ externalAgentCount }, "All external agents created/updated successfully");
|
|
220498
|
-
if (contextConfigId) {
|
|
220499
|
-
try {
|
|
220500
|
-
logger14.info(
|
|
220501
|
-
{ agentId: finalAgentId, contextConfigId },
|
|
220502
|
-
"Updating agent with context config"
|
|
220503
|
-
);
|
|
220504
|
-
await updateAgent(db)({
|
|
220505
|
-
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
220506
|
-
data: { contextConfigId }
|
|
220507
|
-
});
|
|
220508
|
-
logger14.info({ agentId: finalAgentId }, "Agent updated with context config");
|
|
220509
|
-
} catch (error) {
|
|
220510
|
-
logger14.error(
|
|
220511
|
-
{ agentId: finalAgentId, error },
|
|
220512
|
-
"Failed to update agent with context config"
|
|
220513
|
-
);
|
|
220514
|
-
throw error;
|
|
220749
|
+
const subAgentPromises = Object.entries(typed.subAgents).map(
|
|
220750
|
+
async ([subAgentId, agentData2]) => {
|
|
220751
|
+
const subAgent = agentData2;
|
|
220752
|
+
try {
|
|
220753
|
+
logger14.info({ subAgentId }, "Processing sub-agent");
|
|
220754
|
+
await upsertSubAgent(db)({
|
|
220755
|
+
data: {
|
|
220756
|
+
id: subAgentId,
|
|
220757
|
+
tenantId,
|
|
220758
|
+
projectId,
|
|
220759
|
+
agentId: finalAgentId,
|
|
220760
|
+
name: subAgent.name || "",
|
|
220761
|
+
description: subAgent.description || "",
|
|
220762
|
+
prompt: subAgent.prompt || "",
|
|
220763
|
+
conversationHistoryConfig: subAgent.conversationHistoryConfig,
|
|
220764
|
+
models: subAgent.models,
|
|
220765
|
+
stopWhen: subAgent.stopWhen
|
|
220766
|
+
}
|
|
220767
|
+
});
|
|
220768
|
+
logger14.info({ subAgentId }, "Sub-agent processed successfully");
|
|
220769
|
+
} catch (error) {
|
|
220770
|
+
logger14.error({ subAgentId, error }, "Failed to create/update sub-agent");
|
|
220771
|
+
throw error;
|
|
220772
|
+
}
|
|
220515
220773
|
}
|
|
220516
|
-
|
|
220774
|
+
);
|
|
220775
|
+
await Promise.all(subAgentPromises);
|
|
220776
|
+
const subAgentCount = Object.entries(typed.subAgents).length;
|
|
220777
|
+
logger14.info({ subAgentCount }, "All sub-agents created/updated successfully");
|
|
220778
|
+
logger14.info({}, "External agents are project-scoped and managed at the project level.");
|
|
220517
220779
|
const agentToolPromises = [];
|
|
220518
220780
|
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220519
|
-
if (
|
|
220781
|
+
if (agentData2.canUse && Array.isArray(agentData2.canUse)) {
|
|
220520
220782
|
for (const canUseItem of agentData2.canUse) {
|
|
220521
220783
|
agentToolPromises.push(
|
|
220522
220784
|
(async () => {
|
|
@@ -220578,7 +220840,7 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220578
220840
|
);
|
|
220579
220841
|
const agentDataComponentPromises = [];
|
|
220580
220842
|
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220581
|
-
if (
|
|
220843
|
+
if (agentData2.dataComponents) {
|
|
220582
220844
|
for (const dataComponentId of agentData2.dataComponents) {
|
|
220583
220845
|
agentDataComponentPromises.push(
|
|
220584
220846
|
(async () => {
|
|
@@ -220610,7 +220872,7 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220610
220872
|
logger14.info({}, "All agent-data component relations created");
|
|
220611
220873
|
const agentArtifactComponentPromises = [];
|
|
220612
220874
|
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220613
|
-
if (
|
|
220875
|
+
if (agentData2.artifactComponents) {
|
|
220614
220876
|
for (const artifactComponentId of agentData2.artifactComponents) {
|
|
220615
220877
|
agentArtifactComponentPromises.push(
|
|
220616
220878
|
(async () => {
|
|
@@ -220641,8 +220903,9 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220641
220903
|
await Promise.all(agentArtifactComponentPromises);
|
|
220642
220904
|
logger14.info({}, "All agent-artifact component relations created");
|
|
220643
220905
|
const subAgentRelationPromises = [];
|
|
220906
|
+
const subAgentExternalAgentRelationPromises = [];
|
|
220644
220907
|
for (const [subAgentId, agentData2] of Object.entries(typed.subAgents)) {
|
|
220645
|
-
if (
|
|
220908
|
+
if (agentData2.canTransferTo) {
|
|
220646
220909
|
for (const targetSubAgentId of agentData2.canTransferTo) {
|
|
220647
220910
|
subAgentRelationPromises.push(
|
|
220648
220911
|
(async () => {
|
|
@@ -220652,7 +220915,7 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220652
220915
|
"Processing agent transfer relation"
|
|
220653
220916
|
);
|
|
220654
220917
|
await upsertSubAgentRelation(db)({
|
|
220655
|
-
id:
|
|
220918
|
+
id: generateId(),
|
|
220656
220919
|
tenantId,
|
|
220657
220920
|
projectId,
|
|
220658
220921
|
agentId: finalAgentId,
|
|
@@ -220673,48 +220936,98 @@ var createFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220673
220936
|
})()
|
|
220674
220937
|
);
|
|
220675
220938
|
}
|
|
220676
|
-
|
|
220677
|
-
|
|
220678
|
-
|
|
220679
|
-
|
|
220680
|
-
|
|
220681
|
-
|
|
220682
|
-
|
|
220683
|
-
|
|
220684
|
-
|
|
220685
|
-
|
|
220686
|
-
|
|
220687
|
-
|
|
220688
|
-
|
|
220689
|
-
|
|
220690
|
-
|
|
220691
|
-
|
|
220692
|
-
|
|
220693
|
-
|
|
220694
|
-
|
|
220695
|
-
|
|
220696
|
-
|
|
220697
|
-
|
|
220698
|
-
|
|
220699
|
-
|
|
220700
|
-
|
|
220701
|
-
|
|
220702
|
-
|
|
220703
|
-
|
|
220704
|
-
|
|
220705
|
-
|
|
220706
|
-
|
|
220707
|
-
|
|
220708
|
-
|
|
220709
|
-
|
|
220939
|
+
if (agentData2.canDelegateTo) {
|
|
220940
|
+
for (const targetItem of agentData2.canDelegateTo) {
|
|
220941
|
+
if (typeof targetItem === "string") {
|
|
220942
|
+
subAgentRelationPromises.push(
|
|
220943
|
+
(async () => {
|
|
220944
|
+
try {
|
|
220945
|
+
logger14.info(
|
|
220946
|
+
{ subAgentId, targetSubAgentId: targetItem, type: "delegate" },
|
|
220947
|
+
"Processing sub-agent delegation relation"
|
|
220948
|
+
);
|
|
220949
|
+
await upsertSubAgentRelation(db)({
|
|
220950
|
+
id: generateId(),
|
|
220951
|
+
tenantId,
|
|
220952
|
+
projectId,
|
|
220953
|
+
agentId: finalAgentId,
|
|
220954
|
+
sourceSubAgentId: subAgentId,
|
|
220955
|
+
targetSubAgentId: targetItem,
|
|
220956
|
+
relationType: "delegate"
|
|
220957
|
+
});
|
|
220958
|
+
logger14.info(
|
|
220959
|
+
{ subAgentId, targetSubAgentId: targetItem, type: "delegate" },
|
|
220960
|
+
"Sub-agent delegation relation processed successfully"
|
|
220961
|
+
);
|
|
220962
|
+
} catch (error) {
|
|
220963
|
+
logger14.error(
|
|
220964
|
+
{ subAgentId, targetSubAgentId: targetItem, type: "delegate", error },
|
|
220965
|
+
"Failed to create sub-agent delegation relation"
|
|
220966
|
+
);
|
|
220967
|
+
}
|
|
220968
|
+
})()
|
|
220969
|
+
);
|
|
220970
|
+
} else {
|
|
220971
|
+
subAgentExternalAgentRelationPromises.push(
|
|
220972
|
+
(async () => {
|
|
220973
|
+
try {
|
|
220974
|
+
logger14.info(
|
|
220975
|
+
{
|
|
220976
|
+
subAgentId,
|
|
220977
|
+
externalAgentId: targetItem.externalAgentId,
|
|
220978
|
+
type: "delegate"
|
|
220979
|
+
},
|
|
220980
|
+
"Processing external agent delegation relation"
|
|
220981
|
+
);
|
|
220982
|
+
await upsertSubAgentExternalAgentRelation(db)({
|
|
220983
|
+
scopes: {
|
|
220984
|
+
tenantId,
|
|
220985
|
+
projectId,
|
|
220986
|
+
agentId: finalAgentId,
|
|
220987
|
+
subAgentId
|
|
220988
|
+
},
|
|
220989
|
+
relationId: targetItem.subAgentExternalAgentRelationId,
|
|
220990
|
+
data: {
|
|
220991
|
+
externalAgentId: targetItem.externalAgentId,
|
|
220992
|
+
headers: targetItem.headers || null
|
|
220993
|
+
}
|
|
220994
|
+
});
|
|
220995
|
+
logger14.info(
|
|
220996
|
+
{
|
|
220997
|
+
subAgentId,
|
|
220998
|
+
externalAgentId: targetItem.externalAgentId,
|
|
220999
|
+
type: "delegate"
|
|
221000
|
+
},
|
|
221001
|
+
"External agent delegation relation processed successfully"
|
|
221002
|
+
);
|
|
221003
|
+
} catch (error) {
|
|
221004
|
+
logger14.error(
|
|
221005
|
+
{
|
|
221006
|
+
subAgentId,
|
|
221007
|
+
externalAgentId: targetItem.externalAgentId,
|
|
221008
|
+
type: "delegate",
|
|
221009
|
+
error
|
|
221010
|
+
},
|
|
221011
|
+
"Failed to create external delegation relation"
|
|
221012
|
+
);
|
|
221013
|
+
}
|
|
221014
|
+
})()
|
|
221015
|
+
);
|
|
221016
|
+
}
|
|
221017
|
+
}
|
|
220710
221018
|
}
|
|
220711
221019
|
}
|
|
220712
221020
|
}
|
|
220713
221021
|
await Promise.all(subAgentRelationPromises);
|
|
221022
|
+
await Promise.all(subAgentExternalAgentRelationPromises);
|
|
220714
221023
|
logger14.info(
|
|
220715
221024
|
{ subAgentRelationCount: subAgentRelationPromises.length },
|
|
220716
221025
|
"All sub-agent relations created"
|
|
220717
221026
|
);
|
|
221027
|
+
logger14.info(
|
|
221028
|
+
{ subAgentExternalAgentRelationCount: subAgentExternalAgentRelationPromises.length },
|
|
221029
|
+
"All sub-agent external agent relations created"
|
|
221030
|
+
);
|
|
220718
221031
|
const createdAgent = await getFullAgentDefinition(db)({
|
|
220719
221032
|
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
220720
221033
|
});
|
|
@@ -220769,7 +221082,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220769
221082
|
logger14.info({}, "MCP Tools are project-scoped - skipping tool creation in agent update");
|
|
220770
221083
|
let finalAgentId;
|
|
220771
221084
|
try {
|
|
220772
|
-
const agentId = typedAgentDefinition.id ||
|
|
221085
|
+
const agentId = typedAgentDefinition.id || generateId();
|
|
220773
221086
|
logger14.info({ agentId }, "Getting/creating agent metadata");
|
|
220774
221087
|
const agent = await upsertAgent(db)({
|
|
220775
221088
|
data: {
|
|
@@ -220946,151 +221259,147 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
220946
221259
|
"All function tools updated successfully"
|
|
220947
221260
|
);
|
|
220948
221261
|
}
|
|
220949
|
-
const
|
|
220950
|
-
|
|
220951
|
-
|
|
220952
|
-
|
|
220953
|
-
|
|
220954
|
-
|
|
220955
|
-
drizzleOrm.
|
|
220956
|
-
|
|
220957
|
-
|
|
220958
|
-
|
|
220959
|
-
|
|
220960
|
-
|
|
220961
|
-
|
|
220962
|
-
|
|
220963
|
-
|
|
220964
|
-
|
|
220965
|
-
|
|
220966
|
-
|
|
220967
|
-
|
|
220968
|
-
|
|
220969
|
-
|
|
220970
|
-
|
|
220971
|
-
|
|
220972
|
-
|
|
220973
|
-
|
|
220974
|
-
|
|
220975
|
-
|
|
220976
|
-
|
|
220977
|
-
|
|
220978
|
-
|
|
220979
|
-
|
|
220980
|
-
|
|
220981
|
-
|
|
220982
|
-
|
|
220983
|
-
|
|
221262
|
+
const subAgentPromises = Object.entries(typedAgentDefinition.subAgents).map(
|
|
221263
|
+
async ([subAgentId, agentData2]) => {
|
|
221264
|
+
const subAgent = agentData2;
|
|
221265
|
+
let existingSubAgent = null;
|
|
221266
|
+
try {
|
|
221267
|
+
existingSubAgent = await db.query.subAgents.findFirst({
|
|
221268
|
+
where: drizzleOrm.and(
|
|
221269
|
+
drizzleOrm.eq(subAgents.id, subAgentId),
|
|
221270
|
+
drizzleOrm.eq(subAgents.tenantId, tenantId),
|
|
221271
|
+
drizzleOrm.eq(subAgents.projectId, projectId)
|
|
221272
|
+
),
|
|
221273
|
+
columns: {
|
|
221274
|
+
models: true
|
|
221275
|
+
}
|
|
221276
|
+
});
|
|
221277
|
+
} catch (_error) {
|
|
221278
|
+
}
|
|
221279
|
+
let finalModelSettings = subAgent.models === void 0 ? void 0 : subAgent.models;
|
|
221280
|
+
if (existingSubAgent?.models && typedAgentDefinition.models) {
|
|
221281
|
+
const subAgentModels = existingSubAgent.models;
|
|
221282
|
+
const agentModels = typedAgentDefinition.models;
|
|
221283
|
+
const modelTypes = ["base", "structuredOutput", "summarizer"];
|
|
221284
|
+
const cascadedModels = { ...finalModelSettings };
|
|
221285
|
+
for (const modelType of modelTypes) {
|
|
221286
|
+
if (subAgentModels[modelType]?.model && existingAgentModels?.[modelType]?.model && subAgentModels[modelType].model === existingAgentModels[modelType].model && agentModels[modelType] && (agentModels[modelType].model !== existingAgentModels[modelType]?.model || JSON.stringify(agentModels[modelType].providerOptions) !== JSON.stringify(existingAgentModels[modelType]?.providerOptions))) {
|
|
221287
|
+
cascadedModels[modelType] = agentModels[modelType];
|
|
221288
|
+
logger14.info(
|
|
221289
|
+
{
|
|
221290
|
+
subAgentId,
|
|
221291
|
+
modelType,
|
|
221292
|
+
oldModel: existingAgentModels[modelType]?.model,
|
|
221293
|
+
newModel: agentModels[modelType].model,
|
|
221294
|
+
hasProviderOptions: !!agentModels[modelType].providerOptions
|
|
221295
|
+
},
|
|
221296
|
+
"Cascading model change from parent agent to subAgent"
|
|
221297
|
+
);
|
|
221298
|
+
}
|
|
220984
221299
|
}
|
|
221300
|
+
finalModelSettings = cascadedModels;
|
|
221301
|
+
}
|
|
221302
|
+
try {
|
|
221303
|
+
logger14.info({ subAgentId }, "Processing sub-agent");
|
|
221304
|
+
await upsertSubAgent(db)({
|
|
221305
|
+
data: {
|
|
221306
|
+
id: subAgentId,
|
|
221307
|
+
tenantId,
|
|
221308
|
+
projectId,
|
|
221309
|
+
agentId: finalAgentId,
|
|
221310
|
+
name: subAgent.name || "",
|
|
221311
|
+
description: subAgent.description || "",
|
|
221312
|
+
prompt: subAgent.prompt || "",
|
|
221313
|
+
conversationHistoryConfig: subAgent.conversationHistoryConfig,
|
|
221314
|
+
models: finalModelSettings,
|
|
221315
|
+
stopWhen: subAgent.stopWhen
|
|
221316
|
+
}
|
|
221317
|
+
});
|
|
221318
|
+
logger14.info({ subAgentId }, "Sub-agent processed successfully");
|
|
221319
|
+
} catch (error) {
|
|
221320
|
+
logger14.error({ subAgentId, error }, "Failed to create/update sub-agent");
|
|
221321
|
+
throw error;
|
|
220985
221322
|
}
|
|
220986
|
-
finalModelSettings = cascadedModels;
|
|
220987
|
-
}
|
|
220988
|
-
try {
|
|
220989
|
-
logger14.info({ subAgentId }, "Processing internal agent");
|
|
220990
|
-
await upsertSubAgent(db)({
|
|
220991
|
-
data: {
|
|
220992
|
-
id: subAgentId,
|
|
220993
|
-
tenantId,
|
|
220994
|
-
projectId,
|
|
220995
|
-
agentId: finalAgentId,
|
|
220996
|
-
name: internalAgent.name || "",
|
|
220997
|
-
description: internalAgent.description || "",
|
|
220998
|
-
prompt: internalAgent.prompt || "",
|
|
220999
|
-
conversationHistoryConfig: internalAgent.conversationHistoryConfig,
|
|
221000
|
-
models: finalModelSettings,
|
|
221001
|
-
stopWhen: internalAgent.stopWhen
|
|
221002
|
-
}
|
|
221003
|
-
});
|
|
221004
|
-
logger14.info({ subAgentId }, "Internal agent processed successfully");
|
|
221005
|
-
} catch (error) {
|
|
221006
|
-
logger14.error({ subAgentId, error }, "Failed to create/update internal agent");
|
|
221007
|
-
throw error;
|
|
221008
|
-
}
|
|
221009
|
-
});
|
|
221010
|
-
await Promise.all(internalAgentPromises);
|
|
221011
|
-
const internalAgentCount = Object.entries(typedAgentDefinition.subAgents).filter(
|
|
221012
|
-
([_, agentData2]) => isInternalAgent(agentData2)
|
|
221013
|
-
).length;
|
|
221014
|
-
logger14.info({ internalAgentCount }, "All internal agents created/updated successfully");
|
|
221015
|
-
const externalAgentPromises = Object.entries(typedAgentDefinition.subAgents).filter(([_, agentData2]) => isExternalAgent(agentData2)).map(async ([subAgentId, agentData2]) => {
|
|
221016
|
-
const externalAgent = agentData2;
|
|
221017
|
-
try {
|
|
221018
|
-
logger14.info({ subAgentId }, "Processing external agent");
|
|
221019
|
-
await upsertExternalAgent(db)({
|
|
221020
|
-
data: {
|
|
221021
|
-
id: subAgentId,
|
|
221022
|
-
tenantId,
|
|
221023
|
-
projectId,
|
|
221024
|
-
agentId: finalAgentId,
|
|
221025
|
-
name: externalAgent.name,
|
|
221026
|
-
description: externalAgent.description || "",
|
|
221027
|
-
baseUrl: externalAgent.baseUrl,
|
|
221028
|
-
credentialReferenceId: externalAgent.credentialReferenceId || void 0,
|
|
221029
|
-
headers: externalAgent.headers || void 0
|
|
221030
|
-
}
|
|
221031
|
-
});
|
|
221032
|
-
logger14.info({ subAgentId }, "External agent processed successfully");
|
|
221033
|
-
} catch (error) {
|
|
221034
|
-
logger14.error({ subAgentId, error }, "Failed to create/update external agent");
|
|
221035
|
-
throw error;
|
|
221036
221323
|
}
|
|
221037
|
-
|
|
221038
|
-
await Promise.all(
|
|
221039
|
-
const
|
|
221040
|
-
|
|
221041
|
-
)
|
|
221042
|
-
|
|
221043
|
-
const
|
|
221044
|
-
const existingInternalAgents = await listSubAgents(db)({
|
|
221045
|
-
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
221046
|
-
});
|
|
221047
|
-
const existingExternalAgents = await listExternalAgents(db)({
|
|
221324
|
+
);
|
|
221325
|
+
await Promise.all(subAgentPromises);
|
|
221326
|
+
const subAgentCount = Object.entries(typedAgentDefinition.subAgents).length;
|
|
221327
|
+
logger14.info({ subAgentCount }, "All sub-agents created/updated successfully");
|
|
221328
|
+
logger14.info({}, "External agents are project-scoped and managed at the project level.");
|
|
221329
|
+
const incomingSubAgentIds = new Set(Object.keys(typedAgentDefinition.subAgents));
|
|
221330
|
+
const existingSubAgents = await listSubAgents(db)({
|
|
221048
221331
|
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
221049
221332
|
});
|
|
221050
|
-
let
|
|
221051
|
-
for (const
|
|
221052
|
-
if (!
|
|
221333
|
+
let deletedSubAgentCount = 0;
|
|
221334
|
+
for (const subAgent of existingSubAgents) {
|
|
221335
|
+
if (!incomingSubAgentIds.has(subAgent.id)) {
|
|
221053
221336
|
try {
|
|
221054
221337
|
await deleteSubAgent(db)({
|
|
221055
221338
|
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
221056
|
-
subAgentId:
|
|
221339
|
+
subAgentId: subAgent.id
|
|
221057
221340
|
});
|
|
221058
|
-
|
|
221059
|
-
logger14.info({ subAgentId:
|
|
221341
|
+
deletedSubAgentCount++;
|
|
221342
|
+
logger14.info({ subAgentId: subAgent.id }, "Deleted orphaned sub-agent");
|
|
221060
221343
|
} catch (error) {
|
|
221061
|
-
logger14.error(
|
|
221062
|
-
{ subAgentId: agent.id, error },
|
|
221063
|
-
"Failed to delete orphaned internal agent"
|
|
221064
|
-
);
|
|
221344
|
+
logger14.error({ subAgentId: subAgent.id, error }, "Failed to delete orphaned sub-agent");
|
|
221065
221345
|
}
|
|
221066
221346
|
}
|
|
221067
221347
|
}
|
|
221068
|
-
|
|
221069
|
-
|
|
221070
|
-
|
|
221348
|
+
if (deletedSubAgentCount > 0) {
|
|
221349
|
+
logger14.info(
|
|
221350
|
+
{
|
|
221351
|
+
deletedSubAgentCount
|
|
221352
|
+
},
|
|
221353
|
+
"Deleted orphaned sub-agents from agent"
|
|
221354
|
+
);
|
|
221355
|
+
}
|
|
221356
|
+
const incomingExternalAgentRelationIds = /* @__PURE__ */ new Set();
|
|
221357
|
+
for (const [_subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
221358
|
+
if (agentData2.canDelegateTo && Array.isArray(agentData2.canDelegateTo)) {
|
|
221359
|
+
for (const delegateItem of agentData2.canDelegateTo) {
|
|
221360
|
+
if (typeof delegateItem === "object" && delegateItem.subAgentExternalAgentRelationId) {
|
|
221361
|
+
incomingExternalAgentRelationIds.add(delegateItem.subAgentExternalAgentRelationId);
|
|
221362
|
+
}
|
|
221363
|
+
}
|
|
221364
|
+
}
|
|
221365
|
+
}
|
|
221366
|
+
const existingExternalAgentRelations = await getSubAgentExternalAgentRelationsByAgent(db)({
|
|
221367
|
+
scopes: { tenantId, projectId, agentId: finalAgentId }
|
|
221368
|
+
});
|
|
221369
|
+
let deletedExternalAgentRelationCount = 0;
|
|
221370
|
+
for (const relation of existingExternalAgentRelations) {
|
|
221371
|
+
if (!incomingExternalAgentRelationIds.has(relation.id)) {
|
|
221071
221372
|
try {
|
|
221072
|
-
await
|
|
221073
|
-
scopes: {
|
|
221074
|
-
|
|
221373
|
+
await deleteSubAgentExternalAgentRelation(db)({
|
|
221374
|
+
scopes: {
|
|
221375
|
+
tenantId,
|
|
221376
|
+
projectId,
|
|
221377
|
+
agentId: finalAgentId,
|
|
221378
|
+
subAgentId: relation.subAgentId
|
|
221379
|
+
},
|
|
221380
|
+
relationId: relation.id
|
|
221075
221381
|
});
|
|
221076
|
-
|
|
221077
|
-
logger14.info(
|
|
221382
|
+
deletedExternalAgentRelationCount++;
|
|
221383
|
+
logger14.info(
|
|
221384
|
+
{
|
|
221385
|
+
relationId: relation.id,
|
|
221386
|
+
subAgentId: relation.subAgentId,
|
|
221387
|
+
externalAgentId: relation.externalAgentId
|
|
221388
|
+
},
|
|
221389
|
+
"Deleted orphaned external agent relation"
|
|
221390
|
+
);
|
|
221078
221391
|
} catch (error) {
|
|
221079
221392
|
logger14.error(
|
|
221080
|
-
{
|
|
221081
|
-
"Failed to delete orphaned external agent"
|
|
221393
|
+
{ relationId: relation.id, error },
|
|
221394
|
+
"Failed to delete orphaned external agent relation"
|
|
221082
221395
|
);
|
|
221083
221396
|
}
|
|
221084
221397
|
}
|
|
221085
221398
|
}
|
|
221086
|
-
if (
|
|
221399
|
+
if (deletedExternalAgentRelationCount > 0) {
|
|
221087
221400
|
logger14.info(
|
|
221088
|
-
{
|
|
221089
|
-
|
|
221090
|
-
deletedExternalCount,
|
|
221091
|
-
totalDeleted: deletedInternalCount + deletedExternalCount
|
|
221092
|
-
},
|
|
221093
|
-
"Deleted orphaned agents from agent"
|
|
221401
|
+
{ deletedExternalAgentRelationCount },
|
|
221402
|
+
"Deleted orphaned external agent relations from agent"
|
|
221094
221403
|
);
|
|
221095
221404
|
}
|
|
221096
221405
|
await updateAgent(db)({
|
|
@@ -221109,7 +221418,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221109
221418
|
logger14.info({ agentId: typedAgentDefinition.id }, "Agent metadata updated");
|
|
221110
221419
|
const incomingRelationshipIds = /* @__PURE__ */ new Set();
|
|
221111
221420
|
for (const [_subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
221112
|
-
if (
|
|
221421
|
+
if (agentData2.canUse && Array.isArray(agentData2.canUse)) {
|
|
221113
221422
|
for (const canUseItem of agentData2.canUse) {
|
|
221114
221423
|
if (canUseItem.agentToolRelationId) {
|
|
221115
221424
|
incomingRelationshipIds.add(canUseItem.agentToolRelationId);
|
|
@@ -221149,17 +221458,20 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221149
221458
|
logger14.error({ subAgentId, error }, "Failed to delete orphaned agent-tool relations");
|
|
221150
221459
|
}
|
|
221151
221460
|
}
|
|
221152
|
-
const
|
|
221461
|
+
const subAgentToolPromises = [];
|
|
221153
221462
|
for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
221154
|
-
if (
|
|
221463
|
+
if (agentData2.canUse && Array.isArray(agentData2.canUse)) {
|
|
221155
221464
|
for (const canUseItem of agentData2.canUse) {
|
|
221156
|
-
|
|
221465
|
+
subAgentToolPromises.push(
|
|
221157
221466
|
(async () => {
|
|
221158
221467
|
try {
|
|
221159
221468
|
const { toolId, toolSelection, headers: headers2, agentToolRelationId } = canUseItem;
|
|
221160
221469
|
const isFunctionTool = typedAgentDefinition.functionTools && toolId in typedAgentDefinition.functionTools;
|
|
221161
221470
|
if (isFunctionTool) {
|
|
221162
|
-
logger14.info(
|
|
221471
|
+
logger14.info(
|
|
221472
|
+
{ subAgentId, toolId },
|
|
221473
|
+
"Processing sub-agent-function tool relation"
|
|
221474
|
+
);
|
|
221163
221475
|
await upsertSubAgentFunctionToolRelation(db)({
|
|
221164
221476
|
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
221165
221477
|
subAgentId,
|
|
@@ -221168,10 +221480,10 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221168
221480
|
});
|
|
221169
221481
|
logger14.info(
|
|
221170
221482
|
{ subAgentId, toolId, relationId: agentToolRelationId },
|
|
221171
|
-
"
|
|
221483
|
+
"Sub-agent-function tool relation upserted"
|
|
221172
221484
|
);
|
|
221173
221485
|
} else {
|
|
221174
|
-
logger14.info({ subAgentId, toolId }, "Processing agent-MCP tool relation");
|
|
221486
|
+
logger14.info({ subAgentId, toolId }, "Processing sub-agent-MCP tool relation");
|
|
221175
221487
|
await upsertSubAgentToolRelation(db)({
|
|
221176
221488
|
scopes: { tenantId, projectId, agentId: finalAgentId },
|
|
221177
221489
|
subAgentId,
|
|
@@ -221182,7 +221494,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221182
221494
|
});
|
|
221183
221495
|
logger14.info(
|
|
221184
221496
|
{ subAgentId, toolId, relationId: agentToolRelationId },
|
|
221185
|
-
"
|
|
221497
|
+
"Sub-agent-MCP tool relation upserted"
|
|
221186
221498
|
);
|
|
221187
221499
|
}
|
|
221188
221500
|
} catch (error) {
|
|
@@ -221201,10 +221513,10 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221201
221513
|
}
|
|
221202
221514
|
}
|
|
221203
221515
|
}
|
|
221204
|
-
await Promise.all(
|
|
221516
|
+
await Promise.all(subAgentToolPromises);
|
|
221205
221517
|
logger14.info(
|
|
221206
|
-
{
|
|
221207
|
-
"All agent-tool relations updated"
|
|
221518
|
+
{ subAgentToolPromisesCount: subAgentToolPromises.length },
|
|
221519
|
+
"All sub-agent-tool relations updated"
|
|
221208
221520
|
);
|
|
221209
221521
|
for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
|
|
221210
221522
|
await deleteAgentDataComponentRelationByAgent(db)({
|
|
@@ -221213,7 +221525,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221213
221525
|
}
|
|
221214
221526
|
const agentDataComponentPromises = [];
|
|
221215
221527
|
for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
221216
|
-
if (
|
|
221528
|
+
if (agentData2.dataComponents) {
|
|
221217
221529
|
for (const dataComponentId of agentData2.dataComponents) {
|
|
221218
221530
|
agentDataComponentPromises.push(
|
|
221219
221531
|
(async () => {
|
|
@@ -221224,12 +221536,12 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221224
221536
|
});
|
|
221225
221537
|
logger14.info(
|
|
221226
221538
|
{ subAgentId, dataComponentId },
|
|
221227
|
-
"
|
|
221539
|
+
"Sub-agent-dataComponent relation created"
|
|
221228
221540
|
);
|
|
221229
221541
|
} catch (error) {
|
|
221230
221542
|
logger14.error(
|
|
221231
221543
|
{ subAgentId, dataComponentId, error },
|
|
221232
|
-
"Failed to create agent-dataComponent relation"
|
|
221544
|
+
"Failed to create sub-agent-dataComponent relation"
|
|
221233
221545
|
);
|
|
221234
221546
|
}
|
|
221235
221547
|
})()
|
|
@@ -221240,7 +221552,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221240
221552
|
await Promise.all(agentDataComponentPromises);
|
|
221241
221553
|
logger14.info(
|
|
221242
221554
|
{ agentDataComponentPromisesCount: agentDataComponentPromises.length },
|
|
221243
|
-
"All agent-dataComponent relations updated"
|
|
221555
|
+
"All sub-agent-dataComponent relations updated"
|
|
221244
221556
|
);
|
|
221245
221557
|
for (const subAgentId of Object.keys(typedAgentDefinition.subAgents)) {
|
|
221246
221558
|
await deleteAgentArtifactComponentRelationByAgent(db)({
|
|
@@ -221249,7 +221561,7 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221249
221561
|
}
|
|
221250
221562
|
const agentArtifactComponentPromises = [];
|
|
221251
221563
|
for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
221252
|
-
if (
|
|
221564
|
+
if (agentData2.artifactComponents) {
|
|
221253
221565
|
for (const artifactComponentId of agentData2.artifactComponents) {
|
|
221254
221566
|
agentArtifactComponentPromises.push(
|
|
221255
221567
|
(async () => {
|
|
@@ -221260,12 +221572,12 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221260
221572
|
});
|
|
221261
221573
|
logger14.info(
|
|
221262
221574
|
{ subAgentId, artifactComponentId },
|
|
221263
|
-
"
|
|
221575
|
+
"Sub-agent-artifactComponent relation created"
|
|
221264
221576
|
);
|
|
221265
221577
|
} catch (error) {
|
|
221266
221578
|
logger14.error(
|
|
221267
221579
|
{ subAgentId, artifactComponentId, error },
|
|
221268
|
-
"Failed to create agent-artifactComponent relation"
|
|
221580
|
+
"Failed to create sub-agent-artifactComponent relation"
|
|
221269
221581
|
);
|
|
221270
221582
|
}
|
|
221271
221583
|
})()
|
|
@@ -221276,37 +221588,29 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221276
221588
|
await Promise.all(agentArtifactComponentPromises);
|
|
221277
221589
|
logger14.info(
|
|
221278
221590
|
{ agentArtifactComponentPromisesCount: agentArtifactComponentPromises.length },
|
|
221279
|
-
"All agent-artifactComponent relations updated"
|
|
221591
|
+
"All sub-agent-artifactComponent relations updated"
|
|
221280
221592
|
);
|
|
221281
221593
|
await deleteAgentRelationsByAgent(db)({
|
|
221282
221594
|
scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
|
|
221283
221595
|
});
|
|
221284
|
-
const
|
|
221596
|
+
const subAgentRelationPromises = [];
|
|
221597
|
+
const subAgentExternalAgentRelationPromises = [];
|
|
221285
221598
|
for (const [subAgentId, agentData2] of Object.entries(typedAgentDefinition.subAgents)) {
|
|
221286
|
-
if (
|
|
221599
|
+
if (agentData2.canTransferTo) {
|
|
221287
221600
|
for (const targetSubAgentId of agentData2.canTransferTo) {
|
|
221288
|
-
|
|
221601
|
+
subAgentRelationPromises.push(
|
|
221289
221602
|
(async () => {
|
|
221290
221603
|
try {
|
|
221291
|
-
const targetAgentData = typedAgentDefinition.subAgents[targetSubAgentId];
|
|
221292
|
-
const isTargetExternal = isExternalAgent(targetAgentData);
|
|
221293
|
-
const targetField = isTargetExternal ? "externalSubAgentId" : "targetSubAgentId";
|
|
221294
|
-
const relationData = {
|
|
221295
|
-
id: nanoid.nanoid(),
|
|
221296
|
-
agentId: typedAgentDefinition.id || "",
|
|
221297
|
-
sourceSubAgentId: subAgentId,
|
|
221298
|
-
relationType: "transfer",
|
|
221299
|
-
[targetField]: targetSubAgentId
|
|
221300
|
-
};
|
|
221301
221604
|
await createSubAgentRelation(db)({
|
|
221302
221605
|
tenantId,
|
|
221303
221606
|
projectId,
|
|
221304
|
-
|
|
221607
|
+
id: generateId(),
|
|
221608
|
+
agentId: typedAgentDefinition.id || "",
|
|
221609
|
+
sourceSubAgentId: subAgentId,
|
|
221610
|
+
targetSubAgentId,
|
|
221611
|
+
relationType: "transfer"
|
|
221305
221612
|
});
|
|
221306
|
-
logger14.info(
|
|
221307
|
-
{ subAgentId, targetSubAgentId, isTargetExternal },
|
|
221308
|
-
"Transfer relation created"
|
|
221309
|
-
);
|
|
221613
|
+
logger14.info({ subAgentId, targetSubAgentId }, "Transfer relation created");
|
|
221310
221614
|
} catch (error) {
|
|
221311
221615
|
logger14.error(
|
|
221312
221616
|
{ subAgentId, targetSubAgentId, error },
|
|
@@ -221317,42 +221621,77 @@ var updateFullAgentServerSide = (db, logger14 = defaultLogger) => async (scopes,
|
|
|
221317
221621
|
);
|
|
221318
221622
|
}
|
|
221319
221623
|
}
|
|
221320
|
-
if (
|
|
221321
|
-
for (const
|
|
221322
|
-
|
|
221323
|
-
|
|
221324
|
-
|
|
221325
|
-
|
|
221326
|
-
|
|
221327
|
-
|
|
221328
|
-
|
|
221329
|
-
|
|
221330
|
-
|
|
221331
|
-
|
|
221332
|
-
|
|
221333
|
-
|
|
221334
|
-
|
|
221335
|
-
|
|
221336
|
-
|
|
221337
|
-
|
|
221338
|
-
|
|
221339
|
-
})
|
|
221340
|
-
|
|
221341
|
-
|
|
221342
|
-
|
|
221343
|
-
|
|
221344
|
-
|
|
221345
|
-
|
|
221346
|
-
|
|
221347
|
-
|
|
221348
|
-
|
|
221624
|
+
if (agentData2.canDelegateTo) {
|
|
221625
|
+
for (const targetItem of agentData2.canDelegateTo) {
|
|
221626
|
+
if (typeof targetItem === "string") {
|
|
221627
|
+
subAgentRelationPromises.push(
|
|
221628
|
+
(async () => {
|
|
221629
|
+
try {
|
|
221630
|
+
await createSubAgentRelation(db)({
|
|
221631
|
+
tenantId,
|
|
221632
|
+
projectId,
|
|
221633
|
+
id: generateId(),
|
|
221634
|
+
agentId: typedAgentDefinition.id || "",
|
|
221635
|
+
sourceSubAgentId: subAgentId,
|
|
221636
|
+
targetSubAgentId: targetItem,
|
|
221637
|
+
relationType: "delegate"
|
|
221638
|
+
});
|
|
221639
|
+
logger14.info(
|
|
221640
|
+
{ subAgentId, targetSubAgentId: targetItem },
|
|
221641
|
+
"Sub-agent delegation relation created"
|
|
221642
|
+
);
|
|
221643
|
+
} catch (error) {
|
|
221644
|
+
logger14.error(
|
|
221645
|
+
{ subAgentId, targetSubAgentId: targetItem, error },
|
|
221646
|
+
"Failed to create sub-agent delegation relation"
|
|
221647
|
+
);
|
|
221648
|
+
}
|
|
221649
|
+
})()
|
|
221650
|
+
);
|
|
221651
|
+
} else {
|
|
221652
|
+
subAgentExternalAgentRelationPromises.push(
|
|
221653
|
+
(async () => {
|
|
221654
|
+
try {
|
|
221655
|
+
await upsertSubAgentExternalAgentRelation(db)({
|
|
221656
|
+
scopes: {
|
|
221657
|
+
tenantId,
|
|
221658
|
+
projectId,
|
|
221659
|
+
agentId: typedAgentDefinition.id || "",
|
|
221660
|
+
subAgentId
|
|
221661
|
+
},
|
|
221662
|
+
relationId: targetItem.subAgentExternalAgentRelationId,
|
|
221663
|
+
data: {
|
|
221664
|
+
externalAgentId: targetItem.externalAgentId,
|
|
221665
|
+
headers: targetItem.headers || null
|
|
221666
|
+
}
|
|
221667
|
+
});
|
|
221668
|
+
logger14.info(
|
|
221669
|
+
{ subAgentId, externalAgentId: targetItem.externalAgentId },
|
|
221670
|
+
"External delegation relation created"
|
|
221671
|
+
);
|
|
221672
|
+
} catch (error) {
|
|
221673
|
+
logger14.error(
|
|
221674
|
+
{ subAgentId, externalAgentId: targetItem.externalAgentId, error },
|
|
221675
|
+
"Failed to create external delegation relation"
|
|
221676
|
+
);
|
|
221677
|
+
}
|
|
221678
|
+
})()
|
|
221679
|
+
);
|
|
221680
|
+
}
|
|
221349
221681
|
}
|
|
221350
221682
|
}
|
|
221351
221683
|
}
|
|
221352
|
-
await Promise.all(
|
|
221684
|
+
await Promise.all(subAgentRelationPromises);
|
|
221685
|
+
logger14.info(
|
|
221686
|
+
{ subAgentRelationPromisesCount: subAgentRelationPromises.length },
|
|
221687
|
+
"All sub-agent relations updated"
|
|
221688
|
+
);
|
|
221689
|
+
await Promise.all(subAgentExternalAgentRelationPromises);
|
|
221353
221690
|
logger14.info(
|
|
221354
|
-
{
|
|
221355
|
-
|
|
221691
|
+
{
|
|
221692
|
+
subAgentExternalAgentRelationPromisesCount: subAgentExternalAgentRelationPromises.length
|
|
221693
|
+
},
|
|
221694
|
+
"All sub-agent external agent relations updated"
|
|
221356
221695
|
);
|
|
221357
221696
|
const updatedAgent = await getFullAgentDefinition(db)({
|
|
221358
221697
|
scopes: { tenantId, projectId, agentId: typedAgentDefinition.id }
|
|
@@ -221541,7 +221880,7 @@ var upsertLedgerArtifact = (db) => async (params) => {
|
|
|
221541
221880
|
const sanitizedArt = sanitizeArtifactForDatabase(artifact);
|
|
221542
221881
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
221543
221882
|
const artifactRow = {
|
|
221544
|
-
id: sanitizedArt.artifactId ??
|
|
221883
|
+
id: sanitizedArt.artifactId ?? generateId(),
|
|
221545
221884
|
tenantId: scopes.tenantId,
|
|
221546
221885
|
projectId: scopes.projectId,
|
|
221547
221886
|
taskId,
|
|
@@ -221591,7 +221930,7 @@ var addLedgerArtifacts = (db) => async (params) => {
|
|
|
221591
221930
|
const sanitizedArt = sanitizeArtifactForDatabase(art);
|
|
221592
221931
|
const resolvedTaskId = taskId ?? sanitizedArt.taskId ?? sanitizedArt.metadata?.taskId ?? null;
|
|
221593
221932
|
return {
|
|
221594
|
-
id: sanitizedArt.artifactId ??
|
|
221933
|
+
id: sanitizedArt.artifactId ?? generateId(),
|
|
221595
221934
|
tenantId: scopes.tenantId,
|
|
221596
221935
|
projectId: scopes.projectId,
|
|
221597
221936
|
taskId: resolvedTaskId,
|
|
@@ -222159,6 +222498,50 @@ var createFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222159
222498
|
"All project tools created successfully"
|
|
222160
222499
|
);
|
|
222161
222500
|
}
|
|
222501
|
+
if (typed.externalAgents && Object.keys(typed.externalAgents).length > 0) {
|
|
222502
|
+
logger14.info(
|
|
222503
|
+
{
|
|
222504
|
+
projectId: typed.id,
|
|
222505
|
+
count: Object.keys(typed.externalAgents).length
|
|
222506
|
+
},
|
|
222507
|
+
"Creating project externalAgents"
|
|
222508
|
+
);
|
|
222509
|
+
const externalAgentPromises = Object.entries(typed.externalAgents).map(
|
|
222510
|
+
async ([externalAgentId, externalAgentData]) => {
|
|
222511
|
+
try {
|
|
222512
|
+
logger14.info(
|
|
222513
|
+
{ projectId: typed.id, externalAgentId },
|
|
222514
|
+
"Creating externalAgent in project"
|
|
222515
|
+
);
|
|
222516
|
+
await upsertExternalAgent(db)({
|
|
222517
|
+
data: {
|
|
222518
|
+
...externalAgentData,
|
|
222519
|
+
tenantId,
|
|
222520
|
+
projectId: typed.id
|
|
222521
|
+
}
|
|
222522
|
+
});
|
|
222523
|
+
logger14.info(
|
|
222524
|
+
{ projectId: typed.id, externalAgentId },
|
|
222525
|
+
"ExternalAgent created successfully"
|
|
222526
|
+
);
|
|
222527
|
+
} catch (error) {
|
|
222528
|
+
logger14.error(
|
|
222529
|
+
{ projectId: typed.id, externalAgentId, error },
|
|
222530
|
+
"Failed to create externalAgent in project"
|
|
222531
|
+
);
|
|
222532
|
+
throw error;
|
|
222533
|
+
}
|
|
222534
|
+
}
|
|
222535
|
+
);
|
|
222536
|
+
await Promise.all(externalAgentPromises);
|
|
222537
|
+
logger14.info(
|
|
222538
|
+
{
|
|
222539
|
+
projectId: typed.id,
|
|
222540
|
+
count: Object.keys(typed.externalAgents).length
|
|
222541
|
+
},
|
|
222542
|
+
"All project externalAgents created successfully"
|
|
222543
|
+
);
|
|
222544
|
+
}
|
|
222162
222545
|
if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
|
|
222163
222546
|
logger14.info(
|
|
222164
222547
|
{
|
|
@@ -222266,6 +222649,8 @@ var createFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222266
222649
|
// Pass project-level functions for validation
|
|
222267
222650
|
dataComponents: typed.dataComponents || {},
|
|
222268
222651
|
artifactComponents: typed.artifactComponents || {},
|
|
222652
|
+
externalAgents: typed.externalAgents || {},
|
|
222653
|
+
// Pass project-level external agents
|
|
222269
222654
|
credentialReferences: typed.credentialReferences || {},
|
|
222270
222655
|
statusUpdates: agentData.statusUpdates === null ? void 0 : agentData.statusUpdates
|
|
222271
222656
|
};
|
|
@@ -222467,6 +222852,50 @@ var updateFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222467
222852
|
"All project tools updated successfully"
|
|
222468
222853
|
);
|
|
222469
222854
|
}
|
|
222855
|
+
if (typed.externalAgents && Object.keys(typed.externalAgents).length > 0) {
|
|
222856
|
+
logger14.info(
|
|
222857
|
+
{
|
|
222858
|
+
projectId: typed.id,
|
|
222859
|
+
count: Object.keys(typed.externalAgents).length
|
|
222860
|
+
},
|
|
222861
|
+
"Updating project externalAgents"
|
|
222862
|
+
);
|
|
222863
|
+
const externalAgentPromises = Object.entries(typed.externalAgents).map(
|
|
222864
|
+
async ([externalAgentId, externalAgentData]) => {
|
|
222865
|
+
try {
|
|
222866
|
+
logger14.info(
|
|
222867
|
+
{ projectId: typed.id, externalAgentId },
|
|
222868
|
+
"Updating externalAgent in project"
|
|
222869
|
+
);
|
|
222870
|
+
await upsertExternalAgent(db)({
|
|
222871
|
+
data: {
|
|
222872
|
+
...externalAgentData,
|
|
222873
|
+
tenantId,
|
|
222874
|
+
projectId: typed.id
|
|
222875
|
+
}
|
|
222876
|
+
});
|
|
222877
|
+
logger14.info(
|
|
222878
|
+
{ projectId: typed.id, externalAgentId },
|
|
222879
|
+
"ExternalAgent updated successfully"
|
|
222880
|
+
);
|
|
222881
|
+
} catch (error) {
|
|
222882
|
+
logger14.error(
|
|
222883
|
+
{ projectId: typed.id, externalAgentId, error },
|
|
222884
|
+
"Failed to update externalAgent in project"
|
|
222885
|
+
);
|
|
222886
|
+
throw error;
|
|
222887
|
+
}
|
|
222888
|
+
}
|
|
222889
|
+
);
|
|
222890
|
+
await Promise.all(externalAgentPromises);
|
|
222891
|
+
logger14.info(
|
|
222892
|
+
{
|
|
222893
|
+
projectId: typed.id,
|
|
222894
|
+
count: Object.keys(typed.externalAgents).length
|
|
222895
|
+
},
|
|
222896
|
+
"All project externalAgents updated successfully"
|
|
222897
|
+
);
|
|
222898
|
+
}
|
|
222470
222899
|
if (typed.dataComponents && Object.keys(typed.dataComponents).length > 0) {
|
|
222471
222900
|
logger14.info(
|
|
222472
222901
|
{
|
|
@@ -222607,6 +223036,8 @@ var updateFullProjectServerSide = (db, logger14 = defaultLogger2) => async (scop
|
|
|
222607
223036
|
// Pass project-level functions for validation
|
|
222608
223037
|
dataComponents: typed.dataComponents || {},
|
|
222609
223038
|
artifactComponents: typed.artifactComponents || {},
|
|
223039
|
+
externalAgents: typed.externalAgents || {},
|
|
223040
|
+
// Pass project-level external agents
|
|
222610
223041
|
credentialReferences: typed.credentialReferences || {},
|
|
222611
223042
|
statusUpdates: agentData.statusUpdates === null ? void 0 : agentData.statusUpdates
|
|
222612
223043
|
};
|
|
@@ -222700,6 +223131,30 @@ var getFullProject = (db, logger14 = defaultLogger2) => async (params) => {
|
|
|
222700
223131
|
} catch (error) {
|
|
222701
223132
|
logger14.warn({ tenantId, projectId, error }, "Failed to retrieve tools for project");
|
|
222702
223133
|
}
|
|
223134
|
+
const projectExternalAgents = {};
|
|
223135
|
+
try {
|
|
223136
|
+
const externalAgentsList = await listExternalAgents(db)({
|
|
223137
|
+
scopes: { tenantId, projectId }
|
|
223138
|
+
});
|
|
223139
|
+
for (const externalAgent of externalAgentsList) {
|
|
223140
|
+
projectExternalAgents[externalAgent.id] = {
|
|
223141
|
+
id: externalAgent.id,
|
|
223142
|
+
name: externalAgent.name,
|
|
223143
|
+
description: externalAgent.description,
|
|
223144
|
+
baseUrl: externalAgent.baseUrl,
|
|
223145
|
+
credentialReferenceId: externalAgent.credentialReferenceId || void 0
|
|
223146
|
+
};
|
|
223147
|
+
}
|
|
223148
|
+
logger14.info(
|
|
223149
|
+
{ tenantId, projectId, count: Object.keys(projectExternalAgents).length },
|
|
223150
|
+
"ExternalAgents retrieved for project"
|
|
223151
|
+
);
|
|
223152
|
+
} catch (error) {
|
|
223153
|
+
logger14.warn(
|
|
223154
|
+
{ tenantId, projectId, error },
|
|
223155
|
+
"Failed to retrieve externalAgents for project"
|
|
223156
|
+
);
|
|
223157
|
+
}
|
|
222703
223158
|
const projectDataComponents = {};
|
|
222704
223159
|
try {
|
|
222705
223160
|
const dataComponentsList = await listDataComponents(db)({
|
|
@@ -222811,6 +223266,7 @@ var getFullProject = (db, logger14 = defaultLogger2) => async (params) => {
|
|
|
222811
223266
|
stopWhen: project.stopWhen || void 0,
|
|
222812
223267
|
agents: agents2,
|
|
222813
223268
|
tools: projectTools,
|
|
223269
|
+
externalAgents: projectExternalAgents,
|
|
222814
223270
|
dataComponents: projectDataComponents,
|
|
222815
223271
|
artifactComponents: projectArtifactComponents,
|
|
222816
223272
|
credentialReferences: projectCredentialReferences,
|
|
@@ -222981,6 +223437,8 @@ var createValidatedDataAccess = (db, dataAccessFunctions) => {
|
|
|
222981
223437
|
|
|
222982
223438
|
// src/utils/tracer.ts
|
|
222983
223439
|
var tracer = getTracer("agents-core");
|
|
223440
|
+
|
|
223441
|
+
// src/context/contextCache.ts
|
|
222984
223442
|
var logger8 = getLogger("context-cache");
|
|
222985
223443
|
var ContextCache = class {
|
|
222986
223444
|
constructor(tenantId, projectId, dbClient) {
|
|
@@ -223043,7 +223501,7 @@ var ContextCache = class {
|
|
|
223043
223501
|
async set(entry) {
|
|
223044
223502
|
try {
|
|
223045
223503
|
const cacheData = {
|
|
223046
|
-
id:
|
|
223504
|
+
id: generateId(),
|
|
223047
223505
|
tenantId: this.tenantId,
|
|
223048
223506
|
projectId: this.projectId,
|
|
223049
223507
|
conversationId: entry.conversationId,
|
|
@@ -225513,6 +225971,12 @@ exports.SubAgentDataComponentListResponse = SubAgentDataComponentListResponse;
|
|
|
225513
225971
|
exports.SubAgentDataComponentResponse = SubAgentDataComponentResponse;
|
|
225514
225972
|
exports.SubAgentDataComponentSelectSchema = SubAgentDataComponentSelectSchema;
|
|
225515
225973
|
exports.SubAgentDataComponentUpdateSchema = SubAgentDataComponentUpdateSchema;
|
|
225974
|
+
exports.SubAgentExternalAgentRelationApiInsertSchema = SubAgentExternalAgentRelationApiInsertSchema;
|
|
225975
|
+
exports.SubAgentExternalAgentRelationApiSelectSchema = SubAgentExternalAgentRelationApiSelectSchema;
|
|
225976
|
+
exports.SubAgentExternalAgentRelationApiUpdateSchema = SubAgentExternalAgentRelationApiUpdateSchema;
|
|
225977
|
+
exports.SubAgentExternalAgentRelationInsertSchema = SubAgentExternalAgentRelationInsertSchema;
|
|
225978
|
+
exports.SubAgentExternalAgentRelationSelectSchema = SubAgentExternalAgentRelationSelectSchema;
|
|
225979
|
+
exports.SubAgentExternalAgentRelationUpdateSchema = SubAgentExternalAgentRelationUpdateSchema;
|
|
225516
225980
|
exports.SubAgentInsertSchema = SubAgentInsertSchema;
|
|
225517
225981
|
exports.SubAgentListResponse = SubAgentListResponse;
|
|
225518
225982
|
exports.SubAgentRelationApiInsertSchema = SubAgentRelationApiInsertSchema;
|
|
@@ -225588,6 +226052,7 @@ exports.artifactComponents = artifactComponents;
|
|
|
225588
226052
|
exports.artifactComponentsRelations = artifactComponentsRelations;
|
|
225589
226053
|
exports.associateArtifactComponentWithAgent = associateArtifactComponentWithAgent;
|
|
225590
226054
|
exports.associateDataComponentWithAgent = associateDataComponentWithAgent;
|
|
226055
|
+
exports.canDelegateToExternalAgentSchema = canDelegateToExternalAgentSchema;
|
|
225591
226056
|
exports.cleanupTenantCache = cleanupTenantCache;
|
|
225592
226057
|
exports.clearContextConfigCache = clearContextConfigCache;
|
|
225593
226058
|
exports.clearConversationCache = clearConversationCache;
|
|
@@ -225628,7 +226093,6 @@ exports.createDatabaseClient = createDatabaseClient;
|
|
|
225628
226093
|
exports.createDefaultCredentialStores = createDefaultCredentialStores;
|
|
225629
226094
|
exports.createExecutionContext = createExecutionContext;
|
|
225630
226095
|
exports.createExternalAgent = createExternalAgent;
|
|
225631
|
-
exports.createExternalAgentRelation = createExternalAgentRelation;
|
|
225632
226096
|
exports.createFullAgentServerSide = createFullAgentServerSide;
|
|
225633
226097
|
exports.createFullProjectServerSide = createFullProjectServerSide;
|
|
225634
226098
|
exports.createFunctionTool = createFunctionTool;
|
|
@@ -225639,6 +226103,7 @@ exports.createNangoCredentialStore = createNangoCredentialStore;
|
|
|
225639
226103
|
exports.createOrGetConversation = createOrGetConversation;
|
|
225640
226104
|
exports.createProject = createProject;
|
|
225641
226105
|
exports.createSubAgent = createSubAgent;
|
|
226106
|
+
exports.createSubAgentExternalAgentRelation = createSubAgentExternalAgentRelation;
|
|
225642
226107
|
exports.createSubAgentRelation = createSubAgentRelation;
|
|
225643
226108
|
exports.createTask = createTask;
|
|
225644
226109
|
exports.createTool = createTool;
|
|
@@ -225670,6 +226135,9 @@ exports.deleteLedgerArtifactsByTask = deleteLedgerArtifactsByTask;
|
|
|
225670
226135
|
exports.deleteMessage = deleteMessage;
|
|
225671
226136
|
exports.deleteProject = deleteProject;
|
|
225672
226137
|
exports.deleteSubAgent = deleteSubAgent;
|
|
226138
|
+
exports.deleteSubAgentExternalAgentRelation = deleteSubAgentExternalAgentRelation;
|
|
226139
|
+
exports.deleteSubAgentExternalAgentRelationsByAgent = deleteSubAgentExternalAgentRelationsByAgent;
|
|
226140
|
+
exports.deleteSubAgentExternalAgentRelationsBySubAgent = deleteSubAgentExternalAgentRelationsBySubAgent;
|
|
225673
226141
|
exports.deleteSubAgentRelation = deleteSubAgentRelation;
|
|
225674
226142
|
exports.deleteTool = deleteTool;
|
|
225675
226143
|
exports.detectAuthenticationRequired = detectAuthenticationRequired;
|
|
@@ -225722,13 +226190,13 @@ exports.getConversationHistory = getConversationHistory;
|
|
|
225722
226190
|
exports.getConversationId = getConversationId;
|
|
225723
226191
|
exports.getCredentialReference = getCredentialReference;
|
|
225724
226192
|
exports.getCredentialReferenceById = getCredentialReferenceById;
|
|
225725
|
-
exports.
|
|
226193
|
+
exports.getCredentialReferenceWithResources = getCredentialReferenceWithResources;
|
|
225726
226194
|
exports.getCredentialStoreLookupKeyFromRetrievalParams = getCredentialStoreLookupKeyFromRetrievalParams;
|
|
225727
226195
|
exports.getDataComponent = getDataComponent;
|
|
225728
226196
|
exports.getDataComponentsForAgent = getDataComponentsForAgent;
|
|
225729
226197
|
exports.getExternalAgent = getExternalAgent;
|
|
225730
226198
|
exports.getExternalAgentByUrl = getExternalAgentByUrl;
|
|
225731
|
-
exports.
|
|
226199
|
+
exports.getExternalAgentsForSubAgent = getExternalAgentsForSubAgent;
|
|
225732
226200
|
exports.getFullAgent = getFullAgent;
|
|
225733
226201
|
exports.getFullAgentDefinition = getFullAgentDefinition;
|
|
225734
226202
|
exports.getFullProject = getFullProject;
|
|
@@ -225746,8 +226214,14 @@ exports.getProjectResourceCounts = getProjectResourceCounts;
|
|
|
225746
226214
|
exports.getRelatedAgentsForAgent = getRelatedAgentsForAgent;
|
|
225747
226215
|
exports.getRequestExecutionContext = getRequestExecutionContext;
|
|
225748
226216
|
exports.getSubAgentById = getSubAgentById;
|
|
226217
|
+
exports.getSubAgentExternalAgentRelationById = getSubAgentExternalAgentRelationById;
|
|
226218
|
+
exports.getSubAgentExternalAgentRelationByParams = getSubAgentExternalAgentRelationByParams;
|
|
226219
|
+
exports.getSubAgentExternalAgentRelations = getSubAgentExternalAgentRelations;
|
|
226220
|
+
exports.getSubAgentExternalAgentRelationsByAgent = getSubAgentExternalAgentRelationsByAgent;
|
|
226221
|
+
exports.getSubAgentExternalAgentRelationsByExternalAgent = getSubAgentExternalAgentRelationsByExternalAgent;
|
|
225749
226222
|
exports.getSubAgentRelationsByTarget = getSubAgentRelationsByTarget;
|
|
225750
226223
|
exports.getSubAgentsByIds = getSubAgentsByIds;
|
|
226224
|
+
exports.getSubAgentsForExternalAgent = getSubAgentsForExternalAgent;
|
|
225751
226225
|
exports.getTask = getTask;
|
|
225752
226226
|
exports.getToolById = getToolById;
|
|
225753
226227
|
exports.getToolsForAgent = getToolsForAgent;
|
|
@@ -225767,8 +226241,6 @@ exports.invalidateInvocationDefinitionsCache = invalidateInvocationDefinitionsCa
|
|
|
225767
226241
|
exports.isApiKeyExpired = isApiKeyExpired;
|
|
225768
226242
|
exports.isArtifactComponentAssociatedWithAgent = isArtifactComponentAssociatedWithAgent;
|
|
225769
226243
|
exports.isDataComponentAssociatedWithAgent = isDataComponentAssociatedWithAgent;
|
|
225770
|
-
exports.isExternalAgent = isExternalAgent;
|
|
225771
|
-
exports.isInternalAgent = isInternalAgent;
|
|
225772
226244
|
exports.isValidHttpRequest = isValidHttpRequest;
|
|
225773
226245
|
exports.isValidResourceId = isValidResourceId;
|
|
225774
226246
|
exports.isZodSchema = isZodSchema;
|
|
@@ -225796,6 +226268,7 @@ exports.listFunctions = listFunctions;
|
|
|
225796
226268
|
exports.listMessages = listMessages;
|
|
225797
226269
|
exports.listProjects = listProjects;
|
|
225798
226270
|
exports.listProjectsPaginated = listProjectsPaginated;
|
|
226271
|
+
exports.listSubAgentExternalAgentRelations = listSubAgentExternalAgentRelations;
|
|
225799
226272
|
exports.listSubAgents = listSubAgents;
|
|
225800
226273
|
exports.listSubAgentsPaginated = listSubAgentsPaginated;
|
|
225801
226274
|
exports.listTaskIdsByContextId = listTaskIdsByContextId;
|
|
@@ -225824,6 +226297,8 @@ exports.subAgentArtifactComponents = subAgentArtifactComponents;
|
|
|
225824
226297
|
exports.subAgentArtifactComponentsRelations = subAgentArtifactComponentsRelations;
|
|
225825
226298
|
exports.subAgentDataComponents = subAgentDataComponents;
|
|
225826
226299
|
exports.subAgentDataComponentsRelations = subAgentDataComponentsRelations;
|
|
226300
|
+
exports.subAgentExternalAgentRelations = subAgentExternalAgentRelations;
|
|
226301
|
+
exports.subAgentExternalAgentRelationsRelations = subAgentExternalAgentRelationsRelations;
|
|
225827
226302
|
exports.subAgentFunctionToolRelations = subAgentFunctionToolRelations;
|
|
225828
226303
|
exports.subAgentFunctionToolRelationsRelations = subAgentFunctionToolRelationsRelations;
|
|
225829
226304
|
exports.subAgentRelations = subAgentRelations;
|
|
@@ -225855,6 +226330,7 @@ exports.updateFunctionTool = updateFunctionTool;
|
|
|
225855
226330
|
exports.updateMessage = updateMessage;
|
|
225856
226331
|
exports.updateProject = updateProject;
|
|
225857
226332
|
exports.updateSubAgent = updateSubAgent;
|
|
226333
|
+
exports.updateSubAgentExternalAgentRelation = updateSubAgentExternalAgentRelation;
|
|
225858
226334
|
exports.updateSubAgentFunctionToolRelation = updateSubAgentFunctionToolRelation;
|
|
225859
226335
|
exports.updateTask = updateTask;
|
|
225860
226336
|
exports.updateTool = updateTool;
|
|
@@ -225870,6 +226346,7 @@ exports.upsertFunction = upsertFunction;
|
|
|
225870
226346
|
exports.upsertFunctionTool = upsertFunctionTool;
|
|
225871
226347
|
exports.upsertLedgerArtifact = upsertLedgerArtifact;
|
|
225872
226348
|
exports.upsertSubAgent = upsertSubAgent;
|
|
226349
|
+
exports.upsertSubAgentExternalAgentRelation = upsertSubAgentExternalAgentRelation;
|
|
225873
226350
|
exports.upsertSubAgentFunctionToolRelation = upsertSubAgentFunctionToolRelation;
|
|
225874
226351
|
exports.upsertSubAgentRelation = upsertSubAgentRelation;
|
|
225875
226352
|
exports.upsertSubAgentToolRelation = upsertSubAgentToolRelation;
|
|
@@ -225882,13 +226359,13 @@ exports.validateAndTypeAgentData = validateAndTypeAgentData;
|
|
|
225882
226359
|
exports.validateApiKey = validateApiKey;
|
|
225883
226360
|
exports.validateArtifactComponentReferences = validateArtifactComponentReferences;
|
|
225884
226361
|
exports.validateDataComponentReferences = validateDataComponentReferences;
|
|
225885
|
-
exports.validateExternalAgent = validateExternalAgent;
|
|
225886
226362
|
exports.validateHeaders = validateHeaders;
|
|
225887
226363
|
exports.validateHttpRequestHeaders = validateHttpRequestHeaders;
|
|
225888
|
-
exports.validateInternalSubAgent = validateInternalSubAgent;
|
|
225889
226364
|
exports.validatePreview = validatePreview;
|
|
225890
226365
|
exports.validateProjectExists = validateProjectExists;
|
|
225891
226366
|
exports.validatePropsAsJsonSchema = validatePropsAsJsonSchema;
|
|
226367
|
+
exports.validateSubAgent = validateSubAgent;
|
|
226368
|
+
exports.validateSubAgentExternalAgentRelations = validateSubAgentExternalAgentRelations;
|
|
225892
226369
|
exports.validateToolReferences = validateToolReferences;
|
|
225893
226370
|
exports.validationHelper = validationHelper;
|
|
225894
226371
|
exports.withProjectValidation = withProjectValidation;
|