weave-typescript 0.49.0 → 0.50.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.
|
@@ -498,6 +498,33 @@ export interface GetAgentRunRow {
|
|
|
498
498
|
finishedAt: Date | null;
|
|
499
499
|
}
|
|
500
500
|
export declare function getAgentRun(client: Client, args: GetAgentRunArgs): Promise<GetAgentRunRow | null>;
|
|
501
|
+
export declare const claimAgentRunQuery = "-- name: ClaimAgentRun :one\nUPDATE weave.agent_runs\nSET\n status = $1,\n error_code = '',\n safe_error_message = '',\n started_at = COALESCE(started_at, $2::timestamptz),\n finished_at = NULL\nWHERE organization_id = $3\n AND id = $4\n AND status = $5\nRETURNING 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";
|
|
502
|
+
export interface ClaimAgentRunArgs {
|
|
503
|
+
status: string;
|
|
504
|
+
startedAt: Date;
|
|
505
|
+
organizationId: string;
|
|
506
|
+
agentRunId: string;
|
|
507
|
+
expectedStatus: string;
|
|
508
|
+
}
|
|
509
|
+
export interface ClaimAgentRunRow {
|
|
510
|
+
id: string;
|
|
511
|
+
organizationId: string;
|
|
512
|
+
agentDefinitionId: string;
|
|
513
|
+
agentVersionId: string;
|
|
514
|
+
status: string;
|
|
515
|
+
createdByUserId: string;
|
|
516
|
+
chatSessionId: string | null;
|
|
517
|
+
workflowRunId: string | null;
|
|
518
|
+
workflowStepRunId: string | null;
|
|
519
|
+
input: any;
|
|
520
|
+
output: any;
|
|
521
|
+
errorCode: string;
|
|
522
|
+
safeErrorMessage: string;
|
|
523
|
+
createdAt: Date;
|
|
524
|
+
startedAt: Date | null;
|
|
525
|
+
finishedAt: Date | null;
|
|
526
|
+
}
|
|
527
|
+
export declare function claimAgentRun(client: Client, args: ClaimAgentRunArgs): Promise<ClaimAgentRunRow | null>;
|
|
501
528
|
export declare const listAgentRunsQuery = "-- name: ListAgentRuns :many\nSELECT 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\nWHERE organization_id = $1\n AND (\n $2::uuid IS NULL\n OR agent_definition_id = $2::uuid\n )\n AND (\n $3::text IS NULL\n OR status = $3::text\n )\nORDER BY created_at DESC\nLIMIT $5 OFFSET $4";
|
|
502
529
|
export interface ListAgentRunsArgs {
|
|
503
530
|
organizationId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
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.listAgentDefinitionVersionsQuery = exports.getAgentDefinitionVersionByIDQuery = exports.getAgentDefinitionVersionByNumberQuery = exports.setAgentDefinitionLatestVersionQuery = exports.insertAgentDefinitionVersionQuery = exports.listAgentDraftEventsQuery = exports.insertAgentDraftEventQuery = exports.insertAgentDraftPatchQuery = exports.updateAgentDraftQuery = exports.updateAgentDefinitionStatusQuery = exports.updateAgentDefinitionDraftMetadataQuery = exports.listAgentDefinitionsQuery = exports.getAgentDefinitionDraftQuery = exports.getAgentDefinitionBySlugQuery = exports.getAgentDefinitionByIDQuery = exports.createAgentDefinitionDraftQuery = exports.createAgentDefinitionQuery = void 0;
|
|
3
|
+
exports.listAgentRunEventsQuery = exports.insertAgentRunEventQuery = exports.updateAgentRunStatusQuery = exports.listAgentRunsQuery = exports.claimAgentRunQuery = exports.getAgentRunQuery = exports.createAgentRunQuery = exports.listAgentDefinitionVersionsQuery = exports.getAgentDefinitionVersionByIDQuery = exports.getAgentDefinitionVersionByNumberQuery = exports.setAgentDefinitionLatestVersionQuery = exports.insertAgentDefinitionVersionQuery = exports.listAgentDraftEventsQuery = exports.insertAgentDraftEventQuery = exports.insertAgentDraftPatchQuery = exports.updateAgentDraftQuery = exports.updateAgentDefinitionStatusQuery = exports.updateAgentDefinitionDraftMetadataQuery = exports.listAgentDefinitionsQuery = exports.getAgentDefinitionDraftQuery = exports.getAgentDefinitionBySlugQuery = exports.getAgentDefinitionByIDQuery = exports.createAgentDefinitionDraftQuery = exports.createAgentDefinitionQuery = void 0;
|
|
4
4
|
exports.createAgentDefinition = createAgentDefinition;
|
|
5
5
|
exports.createAgentDefinitionDraft = createAgentDefinitionDraft;
|
|
6
6
|
exports.getAgentDefinitionByID = getAgentDefinitionByID;
|
|
@@ -20,6 +20,7 @@ exports.getAgentDefinitionVersionByID = getAgentDefinitionVersionByID;
|
|
|
20
20
|
exports.listAgentDefinitionVersions = listAgentDefinitionVersions;
|
|
21
21
|
exports.createAgentRun = createAgentRun;
|
|
22
22
|
exports.getAgentRun = getAgentRun;
|
|
23
|
+
exports.claimAgentRun = claimAgentRun;
|
|
23
24
|
exports.listAgentRuns = listAgentRuns;
|
|
24
25
|
exports.updateAgentRunStatus = updateAgentRunStatus;
|
|
25
26
|
exports.insertAgentRunEvent = insertAgentRunEvent;
|
|
@@ -794,6 +795,47 @@ async function getAgentRun(client, args) {
|
|
|
794
795
|
finishedAt: row[15]
|
|
795
796
|
};
|
|
796
797
|
}
|
|
798
|
+
exports.claimAgentRunQuery = `-- name: ClaimAgentRun :one
|
|
799
|
+
UPDATE weave.agent_runs
|
|
800
|
+
SET
|
|
801
|
+
status = $1,
|
|
802
|
+
error_code = '',
|
|
803
|
+
safe_error_message = '',
|
|
804
|
+
started_at = COALESCE(started_at, $2::timestamptz),
|
|
805
|
+
finished_at = NULL
|
|
806
|
+
WHERE organization_id = $3
|
|
807
|
+
AND id = $4
|
|
808
|
+
AND status = $5
|
|
809
|
+
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`;
|
|
810
|
+
async function claimAgentRun(client, args) {
|
|
811
|
+
const result = await client.query({
|
|
812
|
+
text: exports.claimAgentRunQuery,
|
|
813
|
+
values: [args.status, args.startedAt, args.organizationId, args.agentRunId, args.expectedStatus],
|
|
814
|
+
rowMode: "array"
|
|
815
|
+
});
|
|
816
|
+
if (result.rows.length !== 1) {
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
const row = result.rows[0];
|
|
820
|
+
return {
|
|
821
|
+
id: row[0],
|
|
822
|
+
organizationId: row[1],
|
|
823
|
+
agentDefinitionId: row[2],
|
|
824
|
+
agentVersionId: row[3],
|
|
825
|
+
status: row[4],
|
|
826
|
+
createdByUserId: row[5],
|
|
827
|
+
chatSessionId: row[6],
|
|
828
|
+
workflowRunId: row[7],
|
|
829
|
+
workflowStepRunId: row[8],
|
|
830
|
+
input: row[9],
|
|
831
|
+
output: row[10],
|
|
832
|
+
errorCode: row[11],
|
|
833
|
+
safeErrorMessage: row[12],
|
|
834
|
+
createdAt: row[13],
|
|
835
|
+
startedAt: row[14],
|
|
836
|
+
finishedAt: row[15]
|
|
837
|
+
};
|
|
838
|
+
}
|
|
797
839
|
exports.listAgentRunsQuery = `-- name: ListAgentRuns :many
|
|
798
840
|
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
|
|
799
841
|
WHERE organization_id = $1
|