@jskit-ai/assistant-core 0.1.135 → 0.1.136
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/package.json +6 -30
- package/src/server/lib/serviceToolCatalog.js +16 -53
- package/test/packageMetadata.test.js +4 -3
- package/test/serviceToolCatalog.test.js +122 -1250
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/assistant-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.136",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"./shared": "./src/shared/index.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@jskit-ai/http-runtime": "0.1.
|
|
15
|
-
"@jskit-ai/kernel": "0.1.
|
|
16
|
-
"@jskit-ai/resource-core": "0.1.
|
|
17
|
-
"@jskit-ai/resource-crud-core": "0.1.
|
|
14
|
+
"@jskit-ai/http-runtime": "0.1.158",
|
|
15
|
+
"@jskit-ai/kernel": "0.1.160",
|
|
16
|
+
"@jskit-ai/resource-core": "0.1.102",
|
|
17
|
+
"@jskit-ai/resource-crud-core": "0.1.102",
|
|
18
18
|
"dompurify": "^3.4.13",
|
|
19
19
|
"json-rest-schema": "^1.0.17",
|
|
20
20
|
"marked": "^17.0.4",
|
|
@@ -57,32 +57,8 @@
|
|
|
57
57
|
"summary": "Exports reusable assistant validators, path helpers, query keys, and stream/settings events."
|
|
58
58
|
}
|
|
59
59
|
],
|
|
60
|
-
"
|
|
61
|
-
"server": [],
|
|
62
|
-
"client": []
|
|
63
|
-
}
|
|
60
|
+
"capabilities": []
|
|
64
61
|
}
|
|
65
|
-
},
|
|
66
|
-
"mutations": {
|
|
67
|
-
"dependencies": {
|
|
68
|
-
"runtime": {
|
|
69
|
-
"@jskit-ai/http-runtime": "0.1.157",
|
|
70
|
-
"@jskit-ai/kernel": "0.1.159",
|
|
71
|
-
"@jskit-ai/resource-core": "0.1.101",
|
|
72
|
-
"@jskit-ai/resource-crud-core": "0.1.101",
|
|
73
|
-
"dompurify": "^3.4.13",
|
|
74
|
-
"json-rest-schema": "^1.0.17",
|
|
75
|
-
"marked": "^17.0.4",
|
|
76
|
-
"openai": "^6.22.0"
|
|
77
|
-
},
|
|
78
|
-
"dev": {}
|
|
79
|
-
},
|
|
80
|
-
"packageJson": {
|
|
81
|
-
"scripts": {}
|
|
82
|
-
},
|
|
83
|
-
"procfile": {},
|
|
84
|
-
"files": [],
|
|
85
|
-
"text": []
|
|
86
62
|
}
|
|
87
63
|
}
|
|
88
64
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { requireAuth } from "@jskit-ai/kernel/server/runtime";
|
|
2
|
-
import { resolveActionContributors } from "@jskit-ai/kernel/server/actions";
|
|
3
|
-
import { normalizeActionDefinition } from "@jskit-ai/kernel/shared/actions";
|
|
4
2
|
import { normalizeSurfaceId } from "@jskit-ai/kernel/shared/surface/registry";
|
|
5
3
|
import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
6
4
|
import { resolveStructuredSchemaTransportSchema } from "@jskit-ai/kernel/shared/validators";
|
|
@@ -239,20 +237,12 @@ function canUseToolOnSurface(entry = {}, context = {}) {
|
|
|
239
237
|
return toolSurfaces.includes(contextSurfaceId);
|
|
240
238
|
}
|
|
241
239
|
|
|
242
|
-
function resolveActionBackedToolEntries(
|
|
243
|
-
if (!
|
|
244
|
-
|
|
240
|
+
function resolveActionBackedToolEntries(actions) {
|
|
241
|
+
if (!actions || typeof actions.listDefinitions !== "function") {
|
|
242
|
+
throw new TypeError("Assistant tool catalog requires runtime.actions.");
|
|
245
243
|
}
|
|
246
|
-
if (typeof scope.resolveTag !== "function") {
|
|
247
|
-
return new Map();
|
|
248
|
-
}
|
|
249
|
-
|
|
250
244
|
const entriesByActionId = new Map();
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
for (const contributor of contributors) {
|
|
254
|
-
const actions = Array.isArray(contributor?.actions) ? contributor.actions : [];
|
|
255
|
-
for (const action of actions) {
|
|
245
|
+
for (const action of actions.listDefinitions()) {
|
|
256
246
|
if (!action || typeof action !== "object") {
|
|
257
247
|
continue;
|
|
258
248
|
}
|
|
@@ -265,22 +255,18 @@ function resolveActionBackedToolEntries(scope) {
|
|
|
265
255
|
continue;
|
|
266
256
|
}
|
|
267
257
|
|
|
268
|
-
let normalizedAction = null;
|
|
269
258
|
let assistantExtension = null;
|
|
270
259
|
try {
|
|
271
260
|
assistantExtension = normalizeAssistantActionExtension(action);
|
|
272
|
-
normalizedAction = normalizeActionDefinition(action, {
|
|
273
|
-
contributorDomain: action.domain
|
|
274
|
-
});
|
|
275
261
|
} catch {
|
|
276
262
|
continue;
|
|
277
263
|
}
|
|
278
264
|
|
|
279
|
-
const inputSchema = resolveStructuredSchemaTransportSchema(
|
|
265
|
+
const inputSchema = resolveStructuredSchemaTransportSchema(action.input, {
|
|
280
266
|
context: `Action definition "${actionId}" input`,
|
|
281
267
|
defaultMode: "patch"
|
|
282
268
|
}) || null;
|
|
283
|
-
const outputSchema = resolveStructuredSchemaTransportSchema(
|
|
269
|
+
const outputSchema = resolveStructuredSchemaTransportSchema(action.output, {
|
|
284
270
|
context: `Action definition "${actionId}" output`,
|
|
285
271
|
defaultMode: "replace"
|
|
286
272
|
}) || null;
|
|
@@ -288,7 +274,7 @@ function resolveActionBackedToolEntries(scope) {
|
|
|
288
274
|
continue;
|
|
289
275
|
}
|
|
290
276
|
|
|
291
|
-
const actionVersion = Number(
|
|
277
|
+
const actionVersion = Number(action.version) || 1;
|
|
292
278
|
const actionKey = actionId.toLowerCase();
|
|
293
279
|
const nextEntry = Object.freeze({
|
|
294
280
|
actionId,
|
|
@@ -297,24 +283,23 @@ function resolveActionBackedToolEntries(scope) {
|
|
|
297
283
|
description: assistantExtension.description || `Run ${actionId}.`,
|
|
298
284
|
inputSchema,
|
|
299
285
|
outputSchema,
|
|
300
|
-
permission: normalizePermissionSpec(
|
|
301
|
-
surfaces: normalizeSurfaceList(
|
|
286
|
+
permission: normalizePermissionSpec(action.permission),
|
|
287
|
+
surfaces: normalizeSurfaceList(action.surfaces)
|
|
302
288
|
});
|
|
303
289
|
const existing = entriesByActionId.get(actionKey);
|
|
304
290
|
if (!existing || actionVersion >= Number(existing.actionVersion || 0)) {
|
|
305
291
|
entriesByActionId.set(actionKey, nextEntry);
|
|
306
292
|
}
|
|
307
|
-
}
|
|
308
293
|
}
|
|
309
294
|
|
|
310
295
|
return entriesByActionId;
|
|
311
296
|
}
|
|
312
297
|
|
|
313
298
|
function resolveActionToolEntries(
|
|
314
|
-
|
|
299
|
+
actions,
|
|
315
300
|
{ barredActionIds = [], skipActionPrefixes = [] } = {}
|
|
316
301
|
) {
|
|
317
|
-
const actionBackedEntries = resolveActionBackedToolEntries(
|
|
302
|
+
const actionBackedEntries = resolveActionBackedToolEntries(actions);
|
|
318
303
|
const barredRules = normalizeBarredActionSet(barredActionIds);
|
|
319
304
|
const usedToolNames = new Set();
|
|
320
305
|
const entries = [];
|
|
@@ -356,11 +341,11 @@ function resolveActionToolEntries(
|
|
|
356
341
|
}
|
|
357
342
|
|
|
358
343
|
function createServiceToolCatalog(
|
|
359
|
-
|
|
344
|
+
actions,
|
|
360
345
|
{ barredActionIds = [], skipActionPrefixes = [] } = {}
|
|
361
346
|
) {
|
|
362
|
-
if (!
|
|
363
|
-
throw new
|
|
347
|
+
if (!actions || typeof actions.listDefinitions !== "function" || typeof actions.execute !== "function") {
|
|
348
|
+
throw new TypeError("createServiceToolCatalog requires runtime.actions.");
|
|
364
349
|
}
|
|
365
350
|
|
|
366
351
|
const normalizedSkipPrefixes = (Array.isArray(skipActionPrefixes) ? skipActionPrefixes : [skipActionPrefixes])
|
|
@@ -373,7 +358,7 @@ function createServiceToolCatalog(
|
|
|
373
358
|
return methodEntries;
|
|
374
359
|
}
|
|
375
360
|
|
|
376
|
-
methodEntries = resolveActionToolEntries(
|
|
361
|
+
methodEntries = resolveActionToolEntries(actions, {
|
|
377
362
|
barredActionIds,
|
|
378
363
|
skipActionPrefixes: normalizedSkipPrefixes
|
|
379
364
|
});
|
|
@@ -432,28 +417,6 @@ function createServiceToolCatalog(
|
|
|
432
417
|
};
|
|
433
418
|
}
|
|
434
419
|
|
|
435
|
-
if (!scope.has("actionExecutor")) {
|
|
436
|
-
return {
|
|
437
|
-
ok: false,
|
|
438
|
-
error: {
|
|
439
|
-
code: "assistant_tool_unavailable",
|
|
440
|
-
message: "Tool executor is unavailable.",
|
|
441
|
-
status: 500
|
|
442
|
-
}
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
const actionExecutor = scope.make("actionExecutor");
|
|
446
|
-
if (!actionExecutor || typeof actionExecutor.execute !== "function") {
|
|
447
|
-
return {
|
|
448
|
-
ok: false,
|
|
449
|
-
error: {
|
|
450
|
-
code: "assistant_tool_unavailable",
|
|
451
|
-
message: "Tool executor is unavailable.",
|
|
452
|
-
status: 500
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
|
|
457
420
|
try {
|
|
458
421
|
const actionInput = parseToolPayload(argumentsText);
|
|
459
422
|
if (actionInput && typeof actionInput === "object" && !Array.isArray(actionInput)) {
|
|
@@ -467,7 +430,7 @@ function createServiceToolCatalog(
|
|
|
467
430
|
channel: AUTOMATION_CHANNEL
|
|
468
431
|
};
|
|
469
432
|
|
|
470
|
-
const result = await
|
|
433
|
+
const result = await actions.execute({
|
|
471
434
|
actionId: descriptor.actionId,
|
|
472
435
|
version: descriptor.actionVersion || null,
|
|
473
436
|
input: actionInput,
|
|
@@ -4,12 +4,13 @@ import packageJson from "../package.json" with { type: "json" };
|
|
|
4
4
|
|
|
5
5
|
const packageMetadata = packageJson.jskit;
|
|
6
6
|
|
|
7
|
-
test("assistant-core
|
|
8
|
-
const specifier = String(
|
|
7
|
+
test("assistant-core owns its portable json-rest-schema dependency directly", () => {
|
|
8
|
+
const specifier = String(packageJson.dependencies?.["json-rest-schema"] || "");
|
|
9
9
|
|
|
10
10
|
assert.match(
|
|
11
11
|
specifier,
|
|
12
12
|
/^(?:[~^]?\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?|\d+\.x\.x)$/,
|
|
13
|
-
"assistant-core
|
|
13
|
+
"assistant-core must declare a publishable json-rest-schema dependency"
|
|
14
14
|
);
|
|
15
|
+
assert.equal(Object.hasOwn(packageMetadata, "mutations"), false);
|
|
15
16
|
});
|