@genesislcap/ai-assistant 15.9.0 → 15.10.0-FUI-2597.1
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/chat-driver.cjs +196 -7
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +196 -7
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/dts/components/chat-driver/chat-driver.invocation-scope.test.d.ts +2 -0
- package/dist/dts/components/chat-driver/chat-driver.invocation-scope.test.d.ts.map +1 -0
- package/dist/esm/components/chat-driver/chat-driver.invocation-scope.test.js +238 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/src/components/chat-driver/chat-driver.invocation-scope.test.ts +285 -0
package/dist/chat-driver.cjs
CHANGED
|
@@ -46,6 +46,17 @@ __export(chat_driver_node_exports, {
|
|
|
46
46
|
module.exports = __toCommonJS(chat_driver_node_exports);
|
|
47
47
|
|
|
48
48
|
// ../../../../node_modules/tslib/tslib.es6.mjs
|
|
49
|
+
function __rest(s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
}
|
|
49
60
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
50
61
|
function adopt(value) {
|
|
51
62
|
return value instanceof P ? value : new P(function(resolve) {
|
|
@@ -1102,6 +1113,188 @@ function scaleTemperature(normalized, { defaultTemp, maxTemp }) {
|
|
|
1102
1113
|
return t <= DEFAULT_ANCHOR ? t / DEFAULT_ANCHOR * defaultTemp : defaultTemp + (t - DEFAULT_ANCHOR) / (1 - DEFAULT_ANCHOR) * (maxTemp - defaultTemp);
|
|
1103
1114
|
}
|
|
1104
1115
|
|
|
1116
|
+
// ../../foundation-ai/dist/esm/utils/tool-schema.js
|
|
1117
|
+
var SCHEMA_MAP_KEYS = ["properties", "patternProperties", "$defs", "definitions"];
|
|
1118
|
+
var SCHEMA_LIST_KEYS = ["anyOf", "oneOf", "allOf", "prefixItems"];
|
|
1119
|
+
var SCHEMA_VALUE_KEYS = [
|
|
1120
|
+
"items",
|
|
1121
|
+
"not",
|
|
1122
|
+
"additionalProperties",
|
|
1123
|
+
"propertyNames",
|
|
1124
|
+
"contains"
|
|
1125
|
+
];
|
|
1126
|
+
var isPlainObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1127
|
+
function cloneValue(value) {
|
|
1128
|
+
if (Array.isArray(value))
|
|
1129
|
+
return value.map(cloneValue);
|
|
1130
|
+
if (isPlainObject2(value)) {
|
|
1131
|
+
const out = {};
|
|
1132
|
+
for (const [k, v] of Object.entries(value))
|
|
1133
|
+
out[k] = cloneValue(v);
|
|
1134
|
+
return out;
|
|
1135
|
+
}
|
|
1136
|
+
return value;
|
|
1137
|
+
}
|
|
1138
|
+
function mapChildSchemas(node, visit, path) {
|
|
1139
|
+
const out = {};
|
|
1140
|
+
for (const [key, value] of Object.entries(node)) {
|
|
1141
|
+
const here = `${path}/${key}`;
|
|
1142
|
+
if (SCHEMA_MAP_KEYS.includes(key) && isPlainObject2(value)) {
|
|
1143
|
+
out[key] = Object.fromEntries(Object.entries(value).map(([name, child]) => [
|
|
1144
|
+
name,
|
|
1145
|
+
isPlainObject2(child) ? visit(child, `${here}/${name}`) : cloneValue(child)
|
|
1146
|
+
]));
|
|
1147
|
+
} else if (SCHEMA_LIST_KEYS.includes(key) && Array.isArray(value)) {
|
|
1148
|
+
out[key] = value.map((child, i) => isPlainObject2(child) ? visit(child, `${here}/${i}`) : cloneValue(child));
|
|
1149
|
+
} else if (SCHEMA_VALUE_KEYS.includes(key)) {
|
|
1150
|
+
if (isPlainObject2(value))
|
|
1151
|
+
out[key] = visit(value, here);
|
|
1152
|
+
else if (Array.isArray(value))
|
|
1153
|
+
out[key] = value.map((child, i) => isPlainObject2(child) ? visit(child, `${here}/${i}`) : cloneValue(child));
|
|
1154
|
+
else
|
|
1155
|
+
out[key] = cloneValue(value);
|
|
1156
|
+
} else {
|
|
1157
|
+
out[key] = cloneValue(value);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
return out;
|
|
1161
|
+
}
|
|
1162
|
+
function mapSchema(node, transform, path = "") {
|
|
1163
|
+
return transform(mapChildSchemas(node, (child, childPath) => mapSchema(child, transform, childPath), path), path);
|
|
1164
|
+
}
|
|
1165
|
+
var UNENFORCEABLE_KEYWORDS = [
|
|
1166
|
+
"minimum",
|
|
1167
|
+
"maximum",
|
|
1168
|
+
"exclusiveMinimum",
|
|
1169
|
+
"exclusiveMaximum",
|
|
1170
|
+
"multipleOf",
|
|
1171
|
+
"maxItems",
|
|
1172
|
+
"uniqueItems",
|
|
1173
|
+
"minProperties",
|
|
1174
|
+
"maxProperties"
|
|
1175
|
+
];
|
|
1176
|
+
var UNDROPPABLE_KEYWORDS = ["oneOf", "not"];
|
|
1177
|
+
function toEnforcedAnthropicSchema(parameters) {
|
|
1178
|
+
const stripped = [];
|
|
1179
|
+
const overridden = [];
|
|
1180
|
+
const undroppable = [];
|
|
1181
|
+
const schema = mapSchema(parameters, (node, path) => {
|
|
1182
|
+
for (const keyword of UNENFORCEABLE_KEYWORDS) {
|
|
1183
|
+
if (keyword in node) {
|
|
1184
|
+
delete node[keyword];
|
|
1185
|
+
stripped.push(`${path}/${keyword}`);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
if (typeof node.minItems === "number" && node.minItems > 1) {
|
|
1189
|
+
delete node.minItems;
|
|
1190
|
+
stripped.push(`${path}/minItems`);
|
|
1191
|
+
}
|
|
1192
|
+
for (const keyword of UNDROPPABLE_KEYWORDS) {
|
|
1193
|
+
if (keyword in node)
|
|
1194
|
+
undroppable.push(`${path}/${keyword}`);
|
|
1195
|
+
}
|
|
1196
|
+
const isObjectNode = node.type === "object" || Array.isArray(node.type) && node.type.includes("object") || isPlainObject2(node.properties);
|
|
1197
|
+
if (isObjectNode) {
|
|
1198
|
+
if (node.additionalProperties !== false) {
|
|
1199
|
+
if (node.additionalProperties !== void 0) {
|
|
1200
|
+
overridden.push(`${path}/additionalProperties`);
|
|
1201
|
+
}
|
|
1202
|
+
node.additionalProperties = false;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
return node;
|
|
1206
|
+
});
|
|
1207
|
+
return { schema, stripped, overridden, undroppable };
|
|
1208
|
+
}
|
|
1209
|
+
function enforceAnthropicToolSchema(parameters, toolName) {
|
|
1210
|
+
const { schema, stripped, overridden, undroppable } = toEnforcedAnthropicSchema(parameters);
|
|
1211
|
+
if (stripped.length) {
|
|
1212
|
+
logger.warn(`AnthropicTransport: tool "${toolName}" requested schema enforcement; these keywords cannot be enforced and were removed \u2014 validate them yourself: ${stripped.join(", ")}`);
|
|
1213
|
+
}
|
|
1214
|
+
if (overridden.length) {
|
|
1215
|
+
logger.warn(`AnthropicTransport: tool "${toolName}" requested schema enforcement, which requires closed objects; \`additionalProperties\` was set to false at: ${overridden.join(", ")}. The tool now accepts fewer inputs than its schema declared.`);
|
|
1216
|
+
}
|
|
1217
|
+
if (undroppable.length) {
|
|
1218
|
+
logger.warn(`AnthropicTransport: tool "${toolName}" uses schema keywords enforcement cannot express (${undroppable.join(", ")}). They cannot be removed without changing the schema's meaning, so the request will be rejected. Rewrite them or drop enforceSchema for this tool.`);
|
|
1219
|
+
}
|
|
1220
|
+
return schema;
|
|
1221
|
+
}
|
|
1222
|
+
var GEMINI_UNSUPPORTED_KEYWORDS = [
|
|
1223
|
+
"additionalProperties",
|
|
1224
|
+
"examples",
|
|
1225
|
+
"multipleOf",
|
|
1226
|
+
"patternProperties",
|
|
1227
|
+
// Both spellings of the definitions block. `$defs` would also fall to the
|
|
1228
|
+
// `$`-prefix sweep below, but the draft-07 spelling has no `$` and would
|
|
1229
|
+
// otherwise survive inlining and 400 the request — so list the pair together.
|
|
1230
|
+
"$defs",
|
|
1231
|
+
"definitions"
|
|
1232
|
+
];
|
|
1233
|
+
function resolvePointer(root, ref) {
|
|
1234
|
+
if (!ref.startsWith("#/"))
|
|
1235
|
+
return void 0;
|
|
1236
|
+
let current = root;
|
|
1237
|
+
for (const segment of ref.slice(2).split("/")) {
|
|
1238
|
+
if (!isPlainObject2(current))
|
|
1239
|
+
return void 0;
|
|
1240
|
+
current = current[segment.replace(/~1/g, "/").replace(/~0/g, "~")];
|
|
1241
|
+
}
|
|
1242
|
+
return isPlainObject2(current) ? current : void 0;
|
|
1243
|
+
}
|
|
1244
|
+
function inlineRefs(root, node, seen, unresolved) {
|
|
1245
|
+
let current = node;
|
|
1246
|
+
let visited = seen;
|
|
1247
|
+
let ref = typeof current.$ref === "string" ? current.$ref : void 0;
|
|
1248
|
+
while (ref && !visited.has(ref)) {
|
|
1249
|
+
const target = resolvePointer(root, ref);
|
|
1250
|
+
if (!target)
|
|
1251
|
+
break;
|
|
1252
|
+
const { $ref: _dropped } = current, siblings = __rest(current, ["$ref"]);
|
|
1253
|
+
current = Object.assign(Object.assign({}, cloneValue(target)), siblings);
|
|
1254
|
+
visited = /* @__PURE__ */ new Set([...visited, ref]);
|
|
1255
|
+
ref = typeof current.$ref === "string" ? current.$ref : void 0;
|
|
1256
|
+
}
|
|
1257
|
+
if (typeof current.$ref === "string")
|
|
1258
|
+
unresolved.push(current.$ref);
|
|
1259
|
+
return mapChildSchemas(current, (child) => inlineRefs(root, child, visited, unresolved), "");
|
|
1260
|
+
}
|
|
1261
|
+
function toGeminiSchema(parameters) {
|
|
1262
|
+
const unresolved = [];
|
|
1263
|
+
const inlined = inlineRefs(parameters, parameters, /* @__PURE__ */ new Set(), unresolved);
|
|
1264
|
+
if (unresolved.length) {
|
|
1265
|
+
logger.warn(`GeminiTransport: these \`$ref\` pointers could not be inlined \u2014 a cycle, a typo, or an external ref: ${[...new Set(unresolved)].join(", ")}. They are left in the schema, so Gemini will reject this declaration; that is deliberate, because dropping them would send a node that constrains nothing.`);
|
|
1266
|
+
}
|
|
1267
|
+
const translated = mapSchema(inlined, (node) => {
|
|
1268
|
+
if (Array.isArray(node.type)) {
|
|
1269
|
+
const types = node.type.filter((t) => t !== "null");
|
|
1270
|
+
if (types.length === 1 && node.type.length !== types.length) {
|
|
1271
|
+
node.type = types[0];
|
|
1272
|
+
node.nullable = true;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
if (Array.isArray(node.anyOf)) {
|
|
1276
|
+
const branches = node.anyOf.filter(isPlainObject2);
|
|
1277
|
+
const nonNull = branches.filter((b) => b.type !== "null");
|
|
1278
|
+
if (branches.length === 2 && nonNull.length === 1) {
|
|
1279
|
+
const { anyOf: _dropped } = node, siblings = __rest(node, ["anyOf"]);
|
|
1280
|
+
return Object.assign(Object.assign(Object.assign({}, nonNull[0]), siblings), { nullable: true });
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
if ("const" in node) {
|
|
1284
|
+
node.enum = [node.const];
|
|
1285
|
+
delete node.const;
|
|
1286
|
+
}
|
|
1287
|
+
for (const keyword of GEMINI_UNSUPPORTED_KEYWORDS)
|
|
1288
|
+
delete node[keyword];
|
|
1289
|
+
for (const key of Object.keys(node)) {
|
|
1290
|
+
if (key.startsWith("$") && key !== "$ref")
|
|
1291
|
+
delete node[key];
|
|
1292
|
+
}
|
|
1293
|
+
return node;
|
|
1294
|
+
});
|
|
1295
|
+
return translated;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1105
1298
|
// ../../foundation-ai/dist/esm/utils/abort-reason.js
|
|
1106
1299
|
function authoritativeAbortReason(error, timeoutSignal, callerSignal) {
|
|
1107
1300
|
const abortShaped = (error instanceof DOMException || error instanceof Error) && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
@@ -1452,11 +1645,7 @@ var AnthropicTransport = class _AnthropicTransport {
|
|
|
1452
1645
|
if (options === null || options === void 0 ? void 0 : options.systemPrompt)
|
|
1453
1646
|
body.system = options.systemPrompt;
|
|
1454
1647
|
if ((_a = options === null || options === void 0 ? void 0 : options.tools) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1455
|
-
body.tools = options.tools.map((t) => ({
|
|
1456
|
-
name: t.name,
|
|
1457
|
-
description: t.description,
|
|
1458
|
-
input_schema: t.parameters
|
|
1459
|
-
}));
|
|
1648
|
+
body.tools = options.tools.map((t) => Object.assign({ name: t.name, description: t.description, input_schema: t.enforceSchema ? enforceAnthropicToolSchema(t.parameters, t.name) : t.parameters }, t.enforceSchema ? { strict: true } : {}));
|
|
1460
1649
|
}
|
|
1461
1650
|
if ((_b = body.tools) === null || _b === void 0 ? void 0 : _b.length) {
|
|
1462
1651
|
const toolChoice = toAnthropicToolChoice(options === null || options === void 0 ? void 0 : options.toolChoice);
|
|
@@ -2106,7 +2295,7 @@ var GeminiTransport = class _GeminiTransport {
|
|
|
2106
2295
|
functionDeclarations: options.tools.map((t) => ({
|
|
2107
2296
|
name: t.name,
|
|
2108
2297
|
description: t.description,
|
|
2109
|
-
parameters: t.parameters
|
|
2298
|
+
parameters: toGeminiSchema(t.parameters)
|
|
2110
2299
|
}))
|
|
2111
2300
|
}
|
|
2112
2301
|
] : void 0;
|
|
@@ -2129,7 +2318,7 @@ var GeminiTransport = class _GeminiTransport {
|
|
|
2129
2318
|
systemInstruction,
|
|
2130
2319
|
toolConfig,
|
|
2131
2320
|
generationConfig
|
|
2132
|
-
}, applyResponseSchema ? { responseSchema: options.responseSchema } : {}), options === null || options === void 0 ? void 0 : options.signal);
|
|
2321
|
+
}, applyResponseSchema ? { responseSchema: toGeminiSchema(options.responseSchema) } : {}), options === null || options === void 0 ? void 0 : options.signal);
|
|
2133
2322
|
return this.fromGeminiResponse(response, offeredToolNames);
|
|
2134
2323
|
});
|
|
2135
2324
|
}
|