weave-typescript 0.46.0 → 0.47.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/weaveapi/agent/v1/agent.pb.d.ts +14 -14
- package/dist/weaveapi/agent/v1/agent.pb.js +88 -88
- package/dist/weaveapi/agent/v1/service.pb.d.ts +53 -53
- package/dist/weaveapi/agent/v1/service.pb.js +264 -250
- package/dist/weaveapi/chat/v1/chat.pb.d.ts +3 -3
- package/dist/weaveapi/chat/v1/chat.pb.js +33 -33
- package/dist/weaveapi/workflow/v1/service.pb.d.ts +55 -55
- package/dist/weaveapi/workflow/v1/service.pb.js +282 -268
- package/dist/weaveapi/workflow/v1/workflow.pb.d.ts +18 -18
- package/dist/weaveapi/workflow/v1/workflow.pb.js +111 -111
- package/dist/weavesql/weavedb/agent_sql.d.ts +83 -83
- package/dist/weavesql/weavedb/agent_sql.js +110 -110
- package/dist/weavesql/weavedb/workflow_sql.d.ts +93 -93
- package/dist/weavesql/weavedb/workflow_sql.js +120 -120
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listAgentRunEventsQuery = exports.insertAgentRunEventQuery = exports.updateAgentRunStatusQuery = exports.listAgentRunsQuery = exports.getAgentRunQuery = exports.createAgentRunQuery = exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
3
|
+
exports.listAgentRunEventsQuery = exports.insertAgentRunEventQuery = exports.updateAgentRunStatusQuery = exports.listAgentRunsQuery = exports.getAgentRunQuery = exports.createAgentRunQuery = exports.listAgentDefinitionVersionsQuery = exports.getAgentDefinitionVersionByIDQuery = exports.getAgentDefinitionVersionByNumberQuery = exports.setAgentDefinitionLatestVersionQuery = exports.insertAgentDefinitionVersionQuery = exports.insertAgentDraftPatchQuery = exports.updateAgentDraftQuery = exports.updateAgentDefinitionStatusQuery = exports.updateAgentDefinitionDraftMetadataQuery = exports.listAgentDefinitionsQuery = exports.getAgentDefinitionDraftQuery = exports.getAgentDefinitionBySlugQuery = exports.getAgentDefinitionByIDQuery = exports.createAgentDefinitionDraftQuery = exports.createAgentDefinitionQuery = void 0;
|
|
4
|
+
exports.createAgentDefinition = createAgentDefinition;
|
|
5
|
+
exports.createAgentDefinitionDraft = createAgentDefinitionDraft;
|
|
6
|
+
exports.getAgentDefinitionByID = getAgentDefinitionByID;
|
|
7
|
+
exports.getAgentDefinitionBySlug = getAgentDefinitionBySlug;
|
|
8
|
+
exports.getAgentDefinitionDraft = getAgentDefinitionDraft;
|
|
9
|
+
exports.listAgentDefinitions = listAgentDefinitions;
|
|
10
|
+
exports.updateAgentDefinitionDraftMetadata = updateAgentDefinitionDraftMetadata;
|
|
11
|
+
exports.updateAgentDefinitionStatus = updateAgentDefinitionStatus;
|
|
12
12
|
exports.updateAgentDraft = updateAgentDraft;
|
|
13
13
|
exports.insertAgentDraftPatch = insertAgentDraftPatch;
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
14
|
+
exports.insertAgentDefinitionVersion = insertAgentDefinitionVersion;
|
|
15
|
+
exports.setAgentDefinitionLatestVersion = setAgentDefinitionLatestVersion;
|
|
16
|
+
exports.getAgentDefinitionVersionByNumber = getAgentDefinitionVersionByNumber;
|
|
17
|
+
exports.getAgentDefinitionVersionByID = getAgentDefinitionVersionByID;
|
|
18
|
+
exports.listAgentDefinitionVersions = listAgentDefinitionVersions;
|
|
19
19
|
exports.createAgentRun = createAgentRun;
|
|
20
20
|
exports.getAgentRun = getAgentRun;
|
|
21
21
|
exports.listAgentRuns = listAgentRuns;
|
|
22
22
|
exports.updateAgentRunStatus = updateAgentRunStatus;
|
|
23
23
|
exports.insertAgentRunEvent = insertAgentRunEvent;
|
|
24
24
|
exports.listAgentRunEvents = listAgentRunEvents;
|
|
25
|
-
exports.
|
|
26
|
-
INSERT INTO weave.
|
|
25
|
+
exports.createAgentDefinitionQuery = `-- name: CreateAgentDefinition :one
|
|
26
|
+
INSERT INTO weave.agent_definitions (
|
|
27
27
|
id,
|
|
28
28
|
organization_id,
|
|
29
29
|
slug,
|
|
@@ -41,9 +41,9 @@ INSERT INTO weave.agent_templates (
|
|
|
41
41
|
$7
|
|
42
42
|
)
|
|
43
43
|
RETURNING id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at`;
|
|
44
|
-
async function
|
|
44
|
+
async function createAgentDefinition(client, args) {
|
|
45
45
|
const result = await client.query({
|
|
46
|
-
text: exports.
|
|
46
|
+
text: exports.createAgentDefinitionQuery,
|
|
47
47
|
values: [args.id, args.organizationId, args.slug, args.name, args.description, args.status, args.createdByUserId],
|
|
48
48
|
rowMode: "array"
|
|
49
49
|
});
|
|
@@ -66,10 +66,10 @@ async function createAgentTemplate(client, args) {
|
|
|
66
66
|
updatedAt: row[11]
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
-
exports.
|
|
70
|
-
INSERT INTO weave.
|
|
69
|
+
exports.createAgentDefinitionDraftQuery = `-- name: CreateAgentDefinitionDraft :one
|
|
70
|
+
INSERT INTO weave.agent_definition_drafts (
|
|
71
71
|
id,
|
|
72
|
-
|
|
72
|
+
definition_id,
|
|
73
73
|
organization_id,
|
|
74
74
|
base_version_id,
|
|
75
75
|
revision,
|
|
@@ -100,11 +100,11 @@ INSERT INTO weave.agent_template_drafts (
|
|
|
100
100
|
$14,
|
|
101
101
|
$15
|
|
102
102
|
)
|
|
103
|
-
RETURNING id,
|
|
104
|
-
async function
|
|
103
|
+
RETURNING id, definition_id, organization_id, base_version_id, revision, name, description, instructions, model_id, provider_configuration_id, tool_descriptors, input_schema, output_schema, metadata, updated_by_user_id, created_at, updated_at`;
|
|
104
|
+
async function createAgentDefinitionDraft(client, args) {
|
|
105
105
|
const result = await client.query({
|
|
106
|
-
text: exports.
|
|
107
|
-
values: [args.id, args.
|
|
106
|
+
text: exports.createAgentDefinitionDraftQuery,
|
|
107
|
+
values: [args.id, args.definitionId, args.organizationId, args.baseVersionId, args.revision, args.name, args.description, args.instructions, args.modelId, args.providerConfigurationId, args.toolDescriptors, args.inputSchema, args.outputSchema, args.metadata, args.updatedByUserId],
|
|
108
108
|
rowMode: "array"
|
|
109
109
|
});
|
|
110
110
|
if (result.rows.length !== 1) {
|
|
@@ -113,7 +113,7 @@ async function createAgentTemplateDraft(client, args) {
|
|
|
113
113
|
const row = result.rows[0];
|
|
114
114
|
return {
|
|
115
115
|
id: row[0],
|
|
116
|
-
|
|
116
|
+
definitionId: row[1],
|
|
117
117
|
organizationId: row[2],
|
|
118
118
|
baseVersionId: row[3],
|
|
119
119
|
revision: row[4],
|
|
@@ -131,14 +131,14 @@ async function createAgentTemplateDraft(client, args) {
|
|
|
131
131
|
updatedAt: row[16]
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
|
-
exports.
|
|
135
|
-
SELECT id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at FROM weave.
|
|
134
|
+
exports.getAgentDefinitionByIDQuery = `-- name: GetAgentDefinitionByID :one
|
|
135
|
+
SELECT id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at FROM weave.agent_definitions
|
|
136
136
|
WHERE organization_id = $1
|
|
137
137
|
AND id = $2`;
|
|
138
|
-
async function
|
|
138
|
+
async function getAgentDefinitionByID(client, args) {
|
|
139
139
|
const result = await client.query({
|
|
140
|
-
text: exports.
|
|
141
|
-
values: [args.organizationId, args.
|
|
140
|
+
text: exports.getAgentDefinitionByIDQuery,
|
|
141
|
+
values: [args.organizationId, args.definitionId],
|
|
142
142
|
rowMode: "array"
|
|
143
143
|
});
|
|
144
144
|
if (result.rows.length !== 1) {
|
|
@@ -160,13 +160,13 @@ async function getAgentTemplateByID(client, args) {
|
|
|
160
160
|
updatedAt: row[11]
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
-
exports.
|
|
164
|
-
SELECT id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at FROM weave.
|
|
163
|
+
exports.getAgentDefinitionBySlugQuery = `-- name: GetAgentDefinitionBySlug :one
|
|
164
|
+
SELECT id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at FROM weave.agent_definitions
|
|
165
165
|
WHERE organization_id = $1
|
|
166
166
|
AND slug = $2`;
|
|
167
|
-
async function
|
|
167
|
+
async function getAgentDefinitionBySlug(client, args) {
|
|
168
168
|
const result = await client.query({
|
|
169
|
-
text: exports.
|
|
169
|
+
text: exports.getAgentDefinitionBySlugQuery,
|
|
170
170
|
values: [args.organizationId, args.slug],
|
|
171
171
|
rowMode: "array"
|
|
172
172
|
});
|
|
@@ -189,14 +189,14 @@ async function getAgentTemplateBySlug(client, args) {
|
|
|
189
189
|
updatedAt: row[11]
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
exports.
|
|
193
|
-
SELECT id,
|
|
192
|
+
exports.getAgentDefinitionDraftQuery = `-- name: GetAgentDefinitionDraft :one
|
|
193
|
+
SELECT id, definition_id, organization_id, base_version_id, revision, name, description, instructions, model_id, provider_configuration_id, tool_descriptors, input_schema, output_schema, metadata, updated_by_user_id, created_at, updated_at FROM weave.agent_definition_drafts
|
|
194
194
|
WHERE organization_id = $1
|
|
195
|
-
AND
|
|
196
|
-
async function
|
|
195
|
+
AND definition_id = $2`;
|
|
196
|
+
async function getAgentDefinitionDraft(client, args) {
|
|
197
197
|
const result = await client.query({
|
|
198
|
-
text: exports.
|
|
199
|
-
values: [args.organizationId, args.
|
|
198
|
+
text: exports.getAgentDefinitionDraftQuery,
|
|
199
|
+
values: [args.organizationId, args.definitionId],
|
|
200
200
|
rowMode: "array"
|
|
201
201
|
});
|
|
202
202
|
if (result.rows.length !== 1) {
|
|
@@ -205,7 +205,7 @@ async function getAgentTemplateDraft(client, args) {
|
|
|
205
205
|
const row = result.rows[0];
|
|
206
206
|
return {
|
|
207
207
|
id: row[0],
|
|
208
|
-
|
|
208
|
+
definitionId: row[1],
|
|
209
209
|
organizationId: row[2],
|
|
210
210
|
baseVersionId: row[3],
|
|
211
211
|
revision: row[4],
|
|
@@ -223,8 +223,8 @@ async function getAgentTemplateDraft(client, args) {
|
|
|
223
223
|
updatedAt: row[16]
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
-
exports.
|
|
227
|
-
SELECT id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at FROM weave.
|
|
226
|
+
exports.listAgentDefinitionsQuery = `-- name: ListAgentDefinitions :many
|
|
227
|
+
SELECT id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at FROM weave.agent_definitions
|
|
228
228
|
WHERE organization_id = $1
|
|
229
229
|
AND (
|
|
230
230
|
$2::text IS NULL
|
|
@@ -232,9 +232,9 @@ WHERE organization_id = $1
|
|
|
232
232
|
)
|
|
233
233
|
ORDER BY updated_at DESC, created_at DESC
|
|
234
234
|
LIMIT $4 OFFSET $3`;
|
|
235
|
-
async function
|
|
235
|
+
async function listAgentDefinitions(client, args) {
|
|
236
236
|
const result = await client.query({
|
|
237
|
-
text: exports.
|
|
237
|
+
text: exports.listAgentDefinitionsQuery,
|
|
238
238
|
values: [args.organizationId, args.status, args.pageOffset, args.pageSize],
|
|
239
239
|
rowMode: "array"
|
|
240
240
|
});
|
|
@@ -255,8 +255,8 @@ async function listAgentTemplates(client, args) {
|
|
|
255
255
|
};
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
-
exports.
|
|
259
|
-
UPDATE weave.
|
|
258
|
+
exports.updateAgentDefinitionDraftMetadataQuery = `-- name: UpdateAgentDefinitionDraftMetadata :one
|
|
259
|
+
UPDATE weave.agent_definitions
|
|
260
260
|
SET
|
|
261
261
|
name = $1,
|
|
262
262
|
description = $2,
|
|
@@ -265,10 +265,10 @@ SET
|
|
|
265
265
|
WHERE organization_id = $4
|
|
266
266
|
AND id = $5
|
|
267
267
|
RETURNING id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at`;
|
|
268
|
-
async function
|
|
268
|
+
async function updateAgentDefinitionDraftMetadata(client, args) {
|
|
269
269
|
const result = await client.query({
|
|
270
|
-
text: exports.
|
|
271
|
-
values: [args.name, args.description, args.draftRevision, args.organizationId, args.
|
|
270
|
+
text: exports.updateAgentDefinitionDraftMetadataQuery,
|
|
271
|
+
values: [args.name, args.description, args.draftRevision, args.organizationId, args.definitionId],
|
|
272
272
|
rowMode: "array"
|
|
273
273
|
});
|
|
274
274
|
if (result.rows.length !== 1) {
|
|
@@ -290,18 +290,18 @@ async function updateAgentTemplateDraftMetadata(client, args) {
|
|
|
290
290
|
updatedAt: row[11]
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
|
-
exports.
|
|
294
|
-
UPDATE weave.
|
|
293
|
+
exports.updateAgentDefinitionStatusQuery = `-- name: UpdateAgentDefinitionStatus :one
|
|
294
|
+
UPDATE weave.agent_definitions
|
|
295
295
|
SET
|
|
296
296
|
status = $1,
|
|
297
297
|
updated_at = now()
|
|
298
298
|
WHERE organization_id = $2
|
|
299
299
|
AND id = $3
|
|
300
300
|
RETURNING id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at`;
|
|
301
|
-
async function
|
|
301
|
+
async function updateAgentDefinitionStatus(client, args) {
|
|
302
302
|
const result = await client.query({
|
|
303
|
-
text: exports.
|
|
304
|
-
values: [args.status, args.organizationId, args.
|
|
303
|
+
text: exports.updateAgentDefinitionStatusQuery,
|
|
304
|
+
values: [args.status, args.organizationId, args.definitionId],
|
|
305
305
|
rowMode: "array"
|
|
306
306
|
});
|
|
307
307
|
if (result.rows.length !== 1) {
|
|
@@ -324,7 +324,7 @@ async function updateAgentTemplateStatus(client, args) {
|
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
326
|
exports.updateAgentDraftQuery = `-- name: UpdateAgentDraft :one
|
|
327
|
-
UPDATE weave.
|
|
327
|
+
UPDATE weave.agent_definition_drafts
|
|
328
328
|
SET
|
|
329
329
|
base_version_id = $1::uuid,
|
|
330
330
|
revision = revision + 1,
|
|
@@ -340,13 +340,13 @@ SET
|
|
|
340
340
|
updated_by_user_id = $11,
|
|
341
341
|
updated_at = now()
|
|
342
342
|
WHERE organization_id = $12
|
|
343
|
-
AND
|
|
343
|
+
AND definition_id = $13
|
|
344
344
|
AND revision = $14
|
|
345
|
-
RETURNING id,
|
|
345
|
+
RETURNING id, definition_id, organization_id, base_version_id, revision, name, description, instructions, model_id, provider_configuration_id, tool_descriptors, input_schema, output_schema, metadata, updated_by_user_id, created_at, updated_at`;
|
|
346
346
|
async function updateAgentDraft(client, args) {
|
|
347
347
|
const result = await client.query({
|
|
348
348
|
text: exports.updateAgentDraftQuery,
|
|
349
|
-
values: [args.baseVersionId, args.name, args.description, args.instructions, args.modelId, args.providerConfigurationId, args.toolDescriptors, args.inputSchema, args.outputSchema, args.metadata, args.updatedByUserId, args.organizationId, args.
|
|
349
|
+
values: [args.baseVersionId, args.name, args.description, args.instructions, args.modelId, args.providerConfigurationId, args.toolDescriptors, args.inputSchema, args.outputSchema, args.metadata, args.updatedByUserId, args.organizationId, args.definitionId, args.expectedRevision],
|
|
350
350
|
rowMode: "array"
|
|
351
351
|
});
|
|
352
352
|
if (result.rows.length !== 1) {
|
|
@@ -355,7 +355,7 @@ async function updateAgentDraft(client, args) {
|
|
|
355
355
|
const row = result.rows[0];
|
|
356
356
|
return {
|
|
357
357
|
id: row[0],
|
|
358
|
-
|
|
358
|
+
definitionId: row[1],
|
|
359
359
|
organizationId: row[2],
|
|
360
360
|
baseVersionId: row[3],
|
|
361
361
|
revision: row[4],
|
|
@@ -374,9 +374,9 @@ async function updateAgentDraft(client, args) {
|
|
|
374
374
|
};
|
|
375
375
|
}
|
|
376
376
|
exports.insertAgentDraftPatchQuery = `-- name: InsertAgentDraftPatch :one
|
|
377
|
-
INSERT INTO weave.
|
|
377
|
+
INSERT INTO weave.agent_definition_draft_patches (
|
|
378
378
|
id,
|
|
379
|
-
|
|
379
|
+
definition_id,
|
|
380
380
|
organization_id,
|
|
381
381
|
revision,
|
|
382
382
|
patch,
|
|
@@ -389,11 +389,11 @@ INSERT INTO weave.agent_template_draft_patches (
|
|
|
389
389
|
$5,
|
|
390
390
|
$6
|
|
391
391
|
)
|
|
392
|
-
RETURNING id,
|
|
392
|
+
RETURNING id, definition_id, organization_id, revision, patch, created_by_user_id, created_at`;
|
|
393
393
|
async function insertAgentDraftPatch(client, args) {
|
|
394
394
|
const result = await client.query({
|
|
395
395
|
text: exports.insertAgentDraftPatchQuery,
|
|
396
|
-
values: [args.id, args.
|
|
396
|
+
values: [args.id, args.definitionId, args.organizationId, args.revision, args.patch, args.createdByUserId],
|
|
397
397
|
rowMode: "array"
|
|
398
398
|
});
|
|
399
399
|
if (result.rows.length !== 1) {
|
|
@@ -402,7 +402,7 @@ async function insertAgentDraftPatch(client, args) {
|
|
|
402
402
|
const row = result.rows[0];
|
|
403
403
|
return {
|
|
404
404
|
id: row[0],
|
|
405
|
-
|
|
405
|
+
definitionId: row[1],
|
|
406
406
|
organizationId: row[2],
|
|
407
407
|
revision: row[3],
|
|
408
408
|
patch: row[4],
|
|
@@ -410,10 +410,10 @@ async function insertAgentDraftPatch(client, args) {
|
|
|
410
410
|
createdAt: row[6]
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
|
-
exports.
|
|
414
|
-
INSERT INTO weave.
|
|
413
|
+
exports.insertAgentDefinitionVersionQuery = `-- name: InsertAgentDefinitionVersion :one
|
|
414
|
+
INSERT INTO weave.agent_definition_versions (
|
|
415
415
|
id,
|
|
416
|
-
|
|
416
|
+
definition_id,
|
|
417
417
|
organization_id,
|
|
418
418
|
version,
|
|
419
419
|
source_draft_revision,
|
|
@@ -444,11 +444,11 @@ INSERT INTO weave.agent_template_versions (
|
|
|
444
444
|
$14,
|
|
445
445
|
$15
|
|
446
446
|
)
|
|
447
|
-
RETURNING id,
|
|
448
|
-
async function
|
|
447
|
+
RETURNING id, definition_id, organization_id, version, source_draft_revision, name, description, instructions, model_id, provider_configuration_id, tool_descriptors, input_schema, output_schema, metadata, published_by_user_id, published_at`;
|
|
448
|
+
async function insertAgentDefinitionVersion(client, args) {
|
|
449
449
|
const result = await client.query({
|
|
450
|
-
text: exports.
|
|
451
|
-
values: [args.id, args.
|
|
450
|
+
text: exports.insertAgentDefinitionVersionQuery,
|
|
451
|
+
values: [args.id, args.definitionId, args.organizationId, args.version, args.sourceDraftRevision, args.name, args.description, args.instructions, args.modelId, args.providerConfigurationId, args.toolDescriptors, args.inputSchema, args.outputSchema, args.metadata, args.publishedByUserId],
|
|
452
452
|
rowMode: "array"
|
|
453
453
|
});
|
|
454
454
|
if (result.rows.length !== 1) {
|
|
@@ -457,7 +457,7 @@ async function insertAgentTemplateVersion(client, args) {
|
|
|
457
457
|
const row = result.rows[0];
|
|
458
458
|
return {
|
|
459
459
|
id: row[0],
|
|
460
|
-
|
|
460
|
+
definitionId: row[1],
|
|
461
461
|
organizationId: row[2],
|
|
462
462
|
version: row[3],
|
|
463
463
|
sourceDraftRevision: row[4],
|
|
@@ -474,8 +474,8 @@ async function insertAgentTemplateVersion(client, args) {
|
|
|
474
474
|
publishedAt: row[15]
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
|
-
exports.
|
|
478
|
-
UPDATE weave.
|
|
477
|
+
exports.setAgentDefinitionLatestVersionQuery = `-- name: SetAgentDefinitionLatestVersion :one
|
|
478
|
+
UPDATE weave.agent_definitions
|
|
479
479
|
SET
|
|
480
480
|
latest_version_id = $1,
|
|
481
481
|
latest_version = $2,
|
|
@@ -483,10 +483,10 @@ SET
|
|
|
483
483
|
WHERE organization_id = $3
|
|
484
484
|
AND id = $4
|
|
485
485
|
RETURNING id, organization_id, slug, name, description, status, created_by_user_id, draft_revision, latest_version_id, latest_version, created_at, updated_at`;
|
|
486
|
-
async function
|
|
486
|
+
async function setAgentDefinitionLatestVersion(client, args) {
|
|
487
487
|
const result = await client.query({
|
|
488
|
-
text: exports.
|
|
489
|
-
values: [args.versionId, args.version, args.organizationId, args.
|
|
488
|
+
text: exports.setAgentDefinitionLatestVersionQuery,
|
|
489
|
+
values: [args.versionId, args.version, args.organizationId, args.definitionId],
|
|
490
490
|
rowMode: "array"
|
|
491
491
|
});
|
|
492
492
|
if (result.rows.length !== 1) {
|
|
@@ -508,15 +508,15 @@ async function setAgentTemplateLatestVersion(client, args) {
|
|
|
508
508
|
updatedAt: row[11]
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
|
-
exports.
|
|
512
|
-
SELECT id,
|
|
511
|
+
exports.getAgentDefinitionVersionByNumberQuery = `-- name: GetAgentDefinitionVersionByNumber :one
|
|
512
|
+
SELECT id, definition_id, organization_id, version, source_draft_revision, name, description, instructions, model_id, provider_configuration_id, tool_descriptors, input_schema, output_schema, metadata, published_by_user_id, published_at FROM weave.agent_definition_versions
|
|
513
513
|
WHERE organization_id = $1
|
|
514
|
-
AND
|
|
514
|
+
AND definition_id = $2
|
|
515
515
|
AND version = $3`;
|
|
516
|
-
async function
|
|
516
|
+
async function getAgentDefinitionVersionByNumber(client, args) {
|
|
517
517
|
const result = await client.query({
|
|
518
|
-
text: exports.
|
|
519
|
-
values: [args.organizationId, args.
|
|
518
|
+
text: exports.getAgentDefinitionVersionByNumberQuery,
|
|
519
|
+
values: [args.organizationId, args.definitionId, args.version],
|
|
520
520
|
rowMode: "array"
|
|
521
521
|
});
|
|
522
522
|
if (result.rows.length !== 1) {
|
|
@@ -525,7 +525,7 @@ async function getAgentTemplateVersionByNumber(client, args) {
|
|
|
525
525
|
const row = result.rows[0];
|
|
526
526
|
return {
|
|
527
527
|
id: row[0],
|
|
528
|
-
|
|
528
|
+
definitionId: row[1],
|
|
529
529
|
organizationId: row[2],
|
|
530
530
|
version: row[3],
|
|
531
531
|
sourceDraftRevision: row[4],
|
|
@@ -542,13 +542,13 @@ async function getAgentTemplateVersionByNumber(client, args) {
|
|
|
542
542
|
publishedAt: row[15]
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
|
-
exports.
|
|
546
|
-
SELECT id,
|
|
545
|
+
exports.getAgentDefinitionVersionByIDQuery = `-- name: GetAgentDefinitionVersionByID :one
|
|
546
|
+
SELECT id, definition_id, organization_id, version, source_draft_revision, name, description, instructions, model_id, provider_configuration_id, tool_descriptors, input_schema, output_schema, metadata, published_by_user_id, published_at FROM weave.agent_definition_versions
|
|
547
547
|
WHERE organization_id = $1
|
|
548
548
|
AND id = $2`;
|
|
549
|
-
async function
|
|
549
|
+
async function getAgentDefinitionVersionByID(client, args) {
|
|
550
550
|
const result = await client.query({
|
|
551
|
-
text: exports.
|
|
551
|
+
text: exports.getAgentDefinitionVersionByIDQuery,
|
|
552
552
|
values: [args.organizationId, args.versionId],
|
|
553
553
|
rowMode: "array"
|
|
554
554
|
});
|
|
@@ -558,7 +558,7 @@ async function getAgentTemplateVersionByID(client, args) {
|
|
|
558
558
|
const row = result.rows[0];
|
|
559
559
|
return {
|
|
560
560
|
id: row[0],
|
|
561
|
-
|
|
561
|
+
definitionId: row[1],
|
|
562
562
|
organizationId: row[2],
|
|
563
563
|
version: row[3],
|
|
564
564
|
sourceDraftRevision: row[4],
|
|
@@ -575,22 +575,22 @@ async function getAgentTemplateVersionByID(client, args) {
|
|
|
575
575
|
publishedAt: row[15]
|
|
576
576
|
};
|
|
577
577
|
}
|
|
578
|
-
exports.
|
|
579
|
-
SELECT id,
|
|
578
|
+
exports.listAgentDefinitionVersionsQuery = `-- name: ListAgentDefinitionVersions :many
|
|
579
|
+
SELECT id, definition_id, organization_id, version, source_draft_revision, name, description, instructions, model_id, provider_configuration_id, tool_descriptors, input_schema, output_schema, metadata, published_by_user_id, published_at FROM weave.agent_definition_versions
|
|
580
580
|
WHERE organization_id = $1
|
|
581
|
-
AND
|
|
581
|
+
AND definition_id = $2
|
|
582
582
|
ORDER BY version DESC
|
|
583
583
|
LIMIT $4 OFFSET $3`;
|
|
584
|
-
async function
|
|
584
|
+
async function listAgentDefinitionVersions(client, args) {
|
|
585
585
|
const result = await client.query({
|
|
586
|
-
text: exports.
|
|
587
|
-
values: [args.organizationId, args.
|
|
586
|
+
text: exports.listAgentDefinitionVersionsQuery,
|
|
587
|
+
values: [args.organizationId, args.definitionId, args.pageOffset, args.pageSize],
|
|
588
588
|
rowMode: "array"
|
|
589
589
|
});
|
|
590
590
|
return result.rows.map(row => {
|
|
591
591
|
return {
|
|
592
592
|
id: row[0],
|
|
593
|
-
|
|
593
|
+
definitionId: row[1],
|
|
594
594
|
organizationId: row[2],
|
|
595
595
|
version: row[3],
|
|
596
596
|
sourceDraftRevision: row[4],
|
|
@@ -612,7 +612,7 @@ exports.createAgentRunQuery = `-- name: CreateAgentRun :one
|
|
|
612
612
|
INSERT INTO weave.agent_runs (
|
|
613
613
|
id,
|
|
614
614
|
organization_id,
|
|
615
|
-
|
|
615
|
+
agent_definition_id,
|
|
616
616
|
agent_version_id,
|
|
617
617
|
status,
|
|
618
618
|
created_by_user_id,
|
|
@@ -632,11 +632,11 @@ INSERT INTO weave.agent_runs (
|
|
|
632
632
|
$9::uuid,
|
|
633
633
|
$10
|
|
634
634
|
)
|
|
635
|
-
RETURNING id, organization_id,
|
|
635
|
+
RETURNING id, organization_id, agent_definition_id, agent_version_id, status, created_by_user_id, chat_session_id, workflow_run_id, workflow_step_run_id, input, output, error_code, safe_error_message, created_at, started_at, finished_at`;
|
|
636
636
|
async function createAgentRun(client, args) {
|
|
637
637
|
const result = await client.query({
|
|
638
638
|
text: exports.createAgentRunQuery,
|
|
639
|
-
values: [args.id, args.organizationId, args.
|
|
639
|
+
values: [args.id, args.organizationId, args.agentDefinitionId, args.agentVersionId, args.status, args.createdByUserId, args.chatSessionId, args.workflowRunId, args.workflowStepRunId, args.input],
|
|
640
640
|
rowMode: "array"
|
|
641
641
|
});
|
|
642
642
|
if (result.rows.length !== 1) {
|
|
@@ -646,7 +646,7 @@ async function createAgentRun(client, args) {
|
|
|
646
646
|
return {
|
|
647
647
|
id: row[0],
|
|
648
648
|
organizationId: row[1],
|
|
649
|
-
|
|
649
|
+
agentDefinitionId: row[2],
|
|
650
650
|
agentVersionId: row[3],
|
|
651
651
|
status: row[4],
|
|
652
652
|
createdByUserId: row[5],
|
|
@@ -663,7 +663,7 @@ async function createAgentRun(client, args) {
|
|
|
663
663
|
};
|
|
664
664
|
}
|
|
665
665
|
exports.getAgentRunQuery = `-- name: GetAgentRun :one
|
|
666
|
-
SELECT id, organization_id,
|
|
666
|
+
SELECT id, organization_id, agent_definition_id, agent_version_id, status, created_by_user_id, chat_session_id, workflow_run_id, workflow_step_run_id, input, output, error_code, safe_error_message, created_at, started_at, finished_at FROM weave.agent_runs
|
|
667
667
|
WHERE organization_id = $1
|
|
668
668
|
AND id = $2`;
|
|
669
669
|
async function getAgentRun(client, args) {
|
|
@@ -679,7 +679,7 @@ async function getAgentRun(client, args) {
|
|
|
679
679
|
return {
|
|
680
680
|
id: row[0],
|
|
681
681
|
organizationId: row[1],
|
|
682
|
-
|
|
682
|
+
agentDefinitionId: row[2],
|
|
683
683
|
agentVersionId: row[3],
|
|
684
684
|
status: row[4],
|
|
685
685
|
createdByUserId: row[5],
|
|
@@ -696,11 +696,11 @@ async function getAgentRun(client, args) {
|
|
|
696
696
|
};
|
|
697
697
|
}
|
|
698
698
|
exports.listAgentRunsQuery = `-- name: ListAgentRuns :many
|
|
699
|
-
SELECT id, organization_id,
|
|
699
|
+
SELECT id, organization_id, agent_definition_id, agent_version_id, status, created_by_user_id, chat_session_id, workflow_run_id, workflow_step_run_id, input, output, error_code, safe_error_message, created_at, started_at, finished_at FROM weave.agent_runs
|
|
700
700
|
WHERE organization_id = $1
|
|
701
701
|
AND (
|
|
702
702
|
$2::uuid IS NULL
|
|
703
|
-
OR
|
|
703
|
+
OR agent_definition_id = $2::uuid
|
|
704
704
|
)
|
|
705
705
|
AND (
|
|
706
706
|
$3::text IS NULL
|
|
@@ -711,14 +711,14 @@ LIMIT $5 OFFSET $4`;
|
|
|
711
711
|
async function listAgentRuns(client, args) {
|
|
712
712
|
const result = await client.query({
|
|
713
713
|
text: exports.listAgentRunsQuery,
|
|
714
|
-
values: [args.organizationId, args.
|
|
714
|
+
values: [args.organizationId, args.agentDefinitionId, args.status, args.pageOffset, args.pageSize],
|
|
715
715
|
rowMode: "array"
|
|
716
716
|
});
|
|
717
717
|
return result.rows.map(row => {
|
|
718
718
|
return {
|
|
719
719
|
id: row[0],
|
|
720
720
|
organizationId: row[1],
|
|
721
|
-
|
|
721
|
+
agentDefinitionId: row[2],
|
|
722
722
|
agentVersionId: row[3],
|
|
723
723
|
status: row[4],
|
|
724
724
|
createdByUserId: row[5],
|
|
@@ -746,7 +746,7 @@ SET
|
|
|
746
746
|
finished_at = $6::timestamptz
|
|
747
747
|
WHERE organization_id = $7
|
|
748
748
|
AND id = $8
|
|
749
|
-
RETURNING id, organization_id,
|
|
749
|
+
RETURNING id, organization_id, agent_definition_id, agent_version_id, status, created_by_user_id, chat_session_id, workflow_run_id, workflow_step_run_id, input, output, error_code, safe_error_message, created_at, started_at, finished_at`;
|
|
750
750
|
async function updateAgentRunStatus(client, args) {
|
|
751
751
|
const result = await client.query({
|
|
752
752
|
text: exports.updateAgentRunStatusQuery,
|
|
@@ -760,7 +760,7 @@ async function updateAgentRunStatus(client, args) {
|
|
|
760
760
|
return {
|
|
761
761
|
id: row[0],
|
|
762
762
|
organizationId: row[1],
|
|
763
|
-
|
|
763
|
+
agentDefinitionId: row[2],
|
|
764
764
|
agentVersionId: row[3],
|
|
765
765
|
status: row[4],
|
|
766
766
|
createdByUserId: row[5],
|