weave-typescript 0.48.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
@@ -13,6 +13,18 @@ export interface CreateUserRow {
13
13
  updatedAt: Date;
14
14
  }
15
15
  export declare function createUser(client: Client, args: CreateUserArgs): Promise<CreateUserRow | null>;
16
+ export declare const createUserWithIDQuery = "-- name: CreateUserWithID :one\nINSERT INTO weave.users (\n id,\n status\n) VALUES (\n $1,\n $2\n)\nON CONFLICT (id) DO NOTHING\nRETURNING id, status, created_at, updated_at";
17
+ export interface CreateUserWithIDArgs {
18
+ id: string;
19
+ status: string;
20
+ }
21
+ export interface CreateUserWithIDRow {
22
+ id: string;
23
+ status: string;
24
+ createdAt: Date;
25
+ updatedAt: Date;
26
+ }
27
+ export declare function createUserWithID(client: Client, args: CreateUserWithIDArgs): Promise<CreateUserWithIDRow | null>;
16
28
  export declare const getUserByIDQuery = "-- name: GetUserByID :one\nSELECT id, status, created_at, updated_at\nFROM weave.users\nWHERE id = $1";
17
29
  export interface GetUserByIDArgs {
18
30
  id: string;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listOrgTeamsQuery = exports.getOrgTeamQuery = exports.createOrgTeamQuery = exports.deleteExpiredAuthInviteSessionsQuery = exports.revokeAuthInviteSessionsByMemberQuery = exports.markAuthInviteSessionRecoveryRequiredQuery = exports.markAuthInviteSessionCompletedQuery = exports.setAuthInviteSessionOAuthStateQuery = exports.getAuthInviteSessionQuery = exports.createAuthInviteSessionQuery = exports.deleteExpiredApplicationSessionsQuery = exports.markApplicationSessionOrganizationSessionStateQuery = exports.listApplicationSessionOrganizationSessionStatesQuery = exports.getApplicationSessionOrganizationSessionQuery = exports.upsertApplicationSessionOrganizationSessionQuery = exports.revokeApplicationSessionQuery = exports.setApplicationSessionActiveOrganizationQuery = exports.getApplicationSessionQuery = exports.createApplicationSessionQuery = exports.listAuthorizationDecisionEventsByOrganizationQuery = exports.insertAuthorizationDecisionEventQuery = exports.insertAuthAuditEventQuery = exports.endSupportAccessSessionQuery = exports.createSupportAccessSessionQuery = exports.createPlatformAdminGrantQuery = exports.listActivePlatformAdminGrantsForUserQuery = exports.getOrganizationMemberAdminRecordQuery = exports.listOrganizationMembersQuery = exports.listOrganizationMembershipsForUserQuery = exports.getOrganizationMembershipQuery = exports.upsertOrganizationMembershipQuery = exports.upsertOrganizationAuthLinkQuery = exports.getOrganizationAuthLinkByOrganizationIDQuery = exports.getOrganizationAuthLinkByStytchIDQuery = exports.upsertIdentityLinkQuery = exports.getIdentityLinkByStytchMemberQuery = exports.getUserProfileQuery = exports.upsertUserProfileQuery = exports.deleteOrganizationAuthDomainQuery = exports.listOrganizationAuthDomainsQuery = exports.upsertOrganizationAuthDomainQuery = exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = exports.updateUserProfileThemeQuery = exports.setUserOrganizationPagePositionQuery = exports.setUserLastOrganizationQuery = exports.getUserAuthPreferencesQuery = exports.getUserPrimaryOrganizationAuthLinkQuery = exports.setUserPrimaryOrganizationQuery = exports.getUserByIDQuery = exports.createUserQuery = void 0;
4
- exports.deleteOrgTeamMembershipsForOrganizationMemberQuery = exports.listEffectiveOrganizationRoleIDsQuery = exports.listOrgTeamRoleGrantsQuery = exports.listOrgTeamMembersQuery = exports.addOrgTeamRoleGrantQuery = exports.deleteOrgTeamRoleGrantsQuery = exports.addOrgTeamMembershipQuery = exports.deleteOrgTeamMembershipsQuery = exports.deleteOrgTeamQuery = exports.updateOrgTeamQuery = void 0;
3
+ exports.getOrgTeamQuery = exports.createOrgTeamQuery = exports.deleteExpiredAuthInviteSessionsQuery = exports.revokeAuthInviteSessionsByMemberQuery = exports.markAuthInviteSessionRecoveryRequiredQuery = exports.markAuthInviteSessionCompletedQuery = exports.setAuthInviteSessionOAuthStateQuery = exports.getAuthInviteSessionQuery = exports.createAuthInviteSessionQuery = exports.deleteExpiredApplicationSessionsQuery = exports.markApplicationSessionOrganizationSessionStateQuery = exports.listApplicationSessionOrganizationSessionStatesQuery = exports.getApplicationSessionOrganizationSessionQuery = exports.upsertApplicationSessionOrganizationSessionQuery = exports.revokeApplicationSessionQuery = exports.setApplicationSessionActiveOrganizationQuery = exports.getApplicationSessionQuery = exports.createApplicationSessionQuery = exports.listAuthorizationDecisionEventsByOrganizationQuery = exports.insertAuthorizationDecisionEventQuery = exports.insertAuthAuditEventQuery = exports.endSupportAccessSessionQuery = exports.createSupportAccessSessionQuery = exports.createPlatformAdminGrantQuery = exports.listActivePlatformAdminGrantsForUserQuery = exports.getOrganizationMemberAdminRecordQuery = exports.listOrganizationMembersQuery = exports.listOrganizationMembershipsForUserQuery = exports.getOrganizationMembershipQuery = exports.upsertOrganizationMembershipQuery = exports.upsertOrganizationAuthLinkQuery = exports.getOrganizationAuthLinkByOrganizationIDQuery = exports.getOrganizationAuthLinkByStytchIDQuery = exports.upsertIdentityLinkQuery = exports.getIdentityLinkByStytchMemberQuery = exports.getUserProfileQuery = exports.upsertUserProfileQuery = exports.deleteOrganizationAuthDomainQuery = exports.listOrganizationAuthDomainsQuery = exports.upsertOrganizationAuthDomainQuery = exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = exports.updateUserProfileThemeQuery = exports.setUserOrganizationPagePositionQuery = exports.setUserLastOrganizationQuery = exports.getUserAuthPreferencesQuery = exports.getUserPrimaryOrganizationAuthLinkQuery = exports.setUserPrimaryOrganizationQuery = exports.getUserByIDQuery = exports.createUserWithIDQuery = exports.createUserQuery = void 0;
4
+ exports.deleteOrgTeamMembershipsForOrganizationMemberQuery = exports.listEffectiveOrganizationRoleIDsQuery = exports.listOrgTeamRoleGrantsQuery = exports.listOrgTeamMembersQuery = exports.addOrgTeamRoleGrantQuery = exports.deleteOrgTeamRoleGrantsQuery = exports.addOrgTeamMembershipQuery = exports.deleteOrgTeamMembershipsQuery = exports.deleteOrgTeamQuery = exports.updateOrgTeamQuery = exports.listOrgTeamsQuery = void 0;
5
5
  exports.createUser = createUser;
6
+ exports.createUserWithID = createUserWithID;
6
7
  exports.getUserByID = getUserByID;
7
8
  exports.setUserPrimaryOrganization = setUserPrimaryOrganization;
8
9
  exports.getUserPrimaryOrganizationAuthLink = getUserPrimaryOrganizationAuthLink;
@@ -73,6 +74,33 @@ async function createUser(client, args) {
73
74
  updatedAt: row[3]
74
75
  };
75
76
  }
77
+ exports.createUserWithIDQuery = `-- name: CreateUserWithID :one
78
+ INSERT INTO weave.users (
79
+ id,
80
+ status
81
+ ) VALUES (
82
+ $1,
83
+ $2
84
+ )
85
+ ON CONFLICT (id) DO NOTHING
86
+ RETURNING id, status, created_at, updated_at`;
87
+ async function createUserWithID(client, args) {
88
+ const result = await client.query({
89
+ text: exports.createUserWithIDQuery,
90
+ values: [args.id, args.status],
91
+ rowMode: "array"
92
+ });
93
+ if (result.rows.length !== 1) {
94
+ return null;
95
+ }
96
+ const row = result.rows[0];
97
+ return {
98
+ id: row[0],
99
+ status: row[1],
100
+ createdAt: row[2],
101
+ updatedAt: row[3]
102
+ };
103
+ }
76
104
  exports.getUserByIDQuery = `-- name: GetUserByID :one
77
105
  SELECT id, status, created_at, updated_at
78
106
  FROM weave.users
@@ -26,6 +26,31 @@ export interface CreateOrganizationRow {
26
26
  updatedAt: Date;
27
27
  }
28
28
  export declare function createOrganization(client: Client, args: CreateOrganizationArgs): Promise<CreateOrganizationRow | null>;
29
+ export declare const createOrganizationWithIDQuery = "-- name: CreateOrganizationWithID :one\nINSERT INTO weave.organizations (\n id,\n slug,\n name,\n description,\n primary_color,\n logo,\n logo_content_type,\n timezone,\n location\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9\n)\nON CONFLICT (slug) DO NOTHING\nRETURNING\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at";
30
+ export interface CreateOrganizationWithIDArgs {
31
+ id: string;
32
+ slug: string;
33
+ name: string;
34
+ description: string;
35
+ primaryColor: string;
36
+ logo: Buffer | null;
37
+ logoContentType: string | null;
38
+ timezone: string;
39
+ location: string;
40
+ }
41
+ export interface CreateOrganizationWithIDRow {
42
+ id: string;
43
+ slug: string;
44
+ name: string;
45
+ description: string;
46
+ primaryColor: string;
47
+ hasLogo: string | null;
48
+ timezone: string;
49
+ location: string;
50
+ createdAt: Date;
51
+ updatedAt: Date;
52
+ }
53
+ export declare function createOrganizationWithID(client: Client, args: CreateOrganizationWithIDArgs): Promise<CreateOrganizationWithIDRow | null>;
29
54
  export declare const getOrganizationBySlugQuery = "-- name: GetOrganizationBySlug :one\nSELECT\n id,\n slug,\n name,\n description,\n primary_color,\n (logo IS NOT NULL) AS has_logo,\n timezone,\n location,\n created_at,\n updated_at\nFROM weave.organizations\nWHERE slug = $1";
30
55
  export interface GetOrganizationBySlugArgs {
31
56
  slug: string;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clearOrganizationLogoQuery = exports.setOrganizationLogoQuery = exports.getOrganizationLogoQuery = exports.deleteOrganizationQuery = exports.updateOrganizationQuery = exports.listOrganizationsQuery = exports.getOrganizationByIDQuery = exports.getOrganizationBySlugQuery = exports.createOrganizationQuery = void 0;
3
+ exports.clearOrganizationLogoQuery = exports.setOrganizationLogoQuery = exports.getOrganizationLogoQuery = exports.deleteOrganizationQuery = exports.updateOrganizationQuery = exports.listOrganizationsQuery = exports.getOrganizationByIDQuery = exports.getOrganizationBySlugQuery = exports.createOrganizationWithIDQuery = exports.createOrganizationQuery = void 0;
4
4
  exports.createOrganization = createOrganization;
5
+ exports.createOrganizationWithID = createOrganizationWithID;
5
6
  exports.getOrganizationBySlug = getOrganizationBySlug;
6
7
  exports.getOrganizationByID = getOrganizationByID;
7
8
  exports.listOrganizations = listOrganizations;
@@ -62,6 +63,63 @@ async function createOrganization(client, args) {
62
63
  updatedAt: row[9]
63
64
  };
64
65
  }
66
+ exports.createOrganizationWithIDQuery = `-- name: CreateOrganizationWithID :one
67
+ INSERT INTO weave.organizations (
68
+ id,
69
+ slug,
70
+ name,
71
+ description,
72
+ primary_color,
73
+ logo,
74
+ logo_content_type,
75
+ timezone,
76
+ location
77
+ ) VALUES (
78
+ $1,
79
+ $2,
80
+ $3,
81
+ $4,
82
+ $5,
83
+ $6,
84
+ $7,
85
+ $8,
86
+ $9
87
+ )
88
+ ON CONFLICT (slug) DO NOTHING
89
+ RETURNING
90
+ id,
91
+ slug,
92
+ name,
93
+ description,
94
+ primary_color,
95
+ (logo IS NOT NULL) AS has_logo,
96
+ timezone,
97
+ location,
98
+ created_at,
99
+ updated_at`;
100
+ async function createOrganizationWithID(client, args) {
101
+ const result = await client.query({
102
+ text: exports.createOrganizationWithIDQuery,
103
+ values: [args.id, args.slug, args.name, args.description, args.primaryColor, args.logo, args.logoContentType, args.timezone, args.location],
104
+ rowMode: "array"
105
+ });
106
+ if (result.rows.length !== 1) {
107
+ return null;
108
+ }
109
+ const row = result.rows[0];
110
+ return {
111
+ id: row[0],
112
+ slug: row[1],
113
+ name: row[2],
114
+ description: row[3],
115
+ primaryColor: row[4],
116
+ hasLogo: row[5],
117
+ timezone: row[6],
118
+ location: row[7],
119
+ createdAt: row[8],
120
+ updatedAt: row[9]
121
+ };
122
+ }
65
123
  exports.getOrganizationBySlugQuery = `-- name: GetOrganizationBySlug :one
66
124
  SELECT
67
125
  id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weave-typescript",
3
- "version": "0.48.0",
3
+ "version": "0.50.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [