@objectstack/service-ai 7.2.0 → 7.2.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/index.cjs +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +165 -3
- package/dist/index.d.ts +165 -3
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -201,6 +201,7 @@ var init_data_tools = __esm({
|
|
|
201
201
|
DEFAULT_QUERY_LIMIT = 20;
|
|
202
202
|
QUERY_RECORDS_TOOL = {
|
|
203
203
|
name: "query_records",
|
|
204
|
+
label: "Query Records",
|
|
204
205
|
description: "Query records from a data object with optional filters, field selection, sorting, and pagination. Returns an array of matching records.",
|
|
205
206
|
parameters: {
|
|
206
207
|
type: "object",
|
|
@@ -246,6 +247,7 @@ var init_data_tools = __esm({
|
|
|
246
247
|
};
|
|
247
248
|
GET_RECORD_TOOL = {
|
|
248
249
|
name: "get_record",
|
|
250
|
+
label: "Get Record",
|
|
249
251
|
description: "Get a single record by its ID from a data object.",
|
|
250
252
|
parameters: {
|
|
251
253
|
type: "object",
|
|
@@ -270,6 +272,7 @@ var init_data_tools = __esm({
|
|
|
270
272
|
};
|
|
271
273
|
AGGREGATE_DATA_TOOL = {
|
|
272
274
|
name: "aggregate_data",
|
|
275
|
+
label: "Aggregate Data",
|
|
273
276
|
description: "Perform aggregation/statistical operations on a data object. Supports count, sum, avg, min, max with optional groupBy and where filters.",
|
|
274
277
|
parameters: {
|
|
275
278
|
type: "object",
|
|
@@ -2379,6 +2382,7 @@ function cryptoRandomId() {
|
|
|
2379
2382
|
}
|
|
2380
2383
|
|
|
2381
2384
|
// src/plugin.ts
|
|
2385
|
+
var import_types = require("@objectstack/types");
|
|
2382
2386
|
var import_contracts = require("@objectstack/spec/contracts");
|
|
2383
2387
|
|
|
2384
2388
|
// src/stream/vercel-stream-encoder.ts
|
|
@@ -5268,6 +5272,7 @@ var QueryPlanSchema = import_zod2.z.object({
|
|
|
5268
5272
|
});
|
|
5269
5273
|
var QUERY_DATA_TOOL = {
|
|
5270
5274
|
name: "query_data",
|
|
5275
|
+
label: "Query Data (Natural Language)",
|
|
5271
5276
|
description: "Answer a natural-language question about the user's data. Internally retrieves the relevant object schema, generates an ObjectQL query, executes it, and returns the matching records. Prefer this tool over `query_records` / `aggregate_data` when the user's intent is expressed in plain language.",
|
|
5272
5277
|
parameters: {
|
|
5273
5278
|
type: "object",
|
|
@@ -6784,7 +6789,7 @@ var _AIServicePlugin = class _AIServicePlugin {
|
|
|
6784
6789
|
);
|
|
6785
6790
|
const provider = mod[factory] ?? mod.default;
|
|
6786
6791
|
if (typeof provider === "function") {
|
|
6787
|
-
const modelId =
|
|
6792
|
+
const modelId = (0, import_types.readEnvWithDeprecation)("OS_AI_MODEL", "AI_MODEL") ?? defaultModel;
|
|
6788
6793
|
const useChatApi = factory === "openai" && typeof provider.chat === "function";
|
|
6789
6794
|
const model = useChatApi ? provider.chat(modelId) : provider(modelId);
|
|
6790
6795
|
const adapter = new VercelLLMAdapter({ model });
|
|
@@ -6877,7 +6882,7 @@ var _AIServicePlugin = class _AIServicePlugin {
|
|
|
6877
6882
|
name: "AI Service",
|
|
6878
6883
|
version: "1.0.0",
|
|
6879
6884
|
type: "plugin",
|
|
6880
|
-
scope: "
|
|
6885
|
+
scope: "system",
|
|
6881
6886
|
namespace: "ai",
|
|
6882
6887
|
objects: [AiConversationObject, AiMessageObject, AiTraceObject, AiPendingActionObject, AiEvalCaseObject, AiEvalRunObject],
|
|
6883
6888
|
views: [AiTraceView, AiMessageView, AiPendingActionView, AiEvalCaseView, AiEvalRunView]
|
|
@@ -6980,7 +6985,8 @@ var _AIServicePlugin = class _AIServicePlugin {
|
|
|
6980
6985
|
}
|
|
6981
6986
|
if (!toolExists) {
|
|
6982
6987
|
try {
|
|
6983
|
-
|
|
6988
|
+
const label = toolDef.label ?? toToolLabel(toolDef.name);
|
|
6989
|
+
await withTimeout(metadataService.register("tool", toolDef.name, { ...toolDef, label }));
|
|
6984
6990
|
} catch (err) {
|
|
6985
6991
|
ctx.logger.warn(
|
|
6986
6992
|
"[AI] Failed to persist tool metadata (non-fatal)",
|
|
@@ -7398,6 +7404,9 @@ _AIServicePlugin.OPENAI_COMPATIBLE_PRESETS = {
|
|
|
7398
7404
|
openrouter: { baseURL: "https://openrouter.ai/api/v1", defaultModel: "openai/gpt-4o-mini" }
|
|
7399
7405
|
};
|
|
7400
7406
|
var AIServicePlugin = _AIServicePlugin;
|
|
7407
|
+
function toToolLabel(name) {
|
|
7408
|
+
return name.split("_").filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
7409
|
+
}
|
|
7401
7410
|
function extractOverrides(payload) {
|
|
7402
7411
|
if (!payload || typeof payload !== "object") return {};
|
|
7403
7412
|
const p = payload;
|