@inkeep/agents-core 0.46.0 → 0.46.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.
Files changed (52) hide show
  1. package/dist/auth/auth-schema.d.ts +17 -0
  2. package/dist/auth/auth-schema.js +4 -3
  3. package/dist/auth/auth-validation-schemas.d.ts +180 -146
  4. package/dist/auth/auth.d.ts +52 -18
  5. package/dist/auth/auth.js +15 -1
  6. package/dist/auth/authz/config.d.ts +5 -1
  7. package/dist/auth/authz/config.js +8 -3
  8. package/dist/auth/init.js +13 -3
  9. package/dist/auth/password-reset-link-store.d.ts +26 -0
  10. package/dist/auth/password-reset-link-store.js +40 -0
  11. package/dist/auth/permissions.d.ts +9 -9
  12. package/dist/auth/spicedb-schema.d.ts +9 -0
  13. package/dist/auth/spicedb-schema.js +24 -0
  14. package/dist/client-exports.d.ts +5 -193
  15. package/dist/client-exports.js +2 -97
  16. package/dist/constants/models.d.ts +2 -0
  17. package/dist/constants/models.js +2 -0
  18. package/dist/data-access/index.d.ts +3 -3
  19. package/dist/data-access/index.js +3 -3
  20. package/dist/data-access/manage/agents.d.ts +25 -25
  21. package/dist/data-access/manage/agents.js +4 -4
  22. package/dist/data-access/manage/artifactComponents.d.ts +10 -10
  23. package/dist/data-access/manage/contextConfigs.d.ts +12 -12
  24. package/dist/data-access/manage/dataComponents.d.ts +4 -4
  25. package/dist/data-access/manage/functionTools.d.ts +14 -14
  26. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
  27. package/dist/data-access/manage/subAgentRelations.d.ts +26 -26
  28. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
  29. package/dist/data-access/manage/subAgents.d.ts +15 -15
  30. package/dist/data-access/manage/tools.d.ts +27 -27
  31. package/dist/data-access/manage/tools.js +1 -1
  32. package/dist/data-access/manage/triggers.d.ts +2 -2
  33. package/dist/data-access/runtime/apiKeys.d.ts +20 -20
  34. package/dist/data-access/runtime/conversations.d.ts +24 -24
  35. package/dist/data-access/runtime/messages.d.ts +18 -18
  36. package/dist/data-access/runtime/organizations.d.ts +10 -1
  37. package/dist/data-access/runtime/organizations.js +24 -3
  38. package/dist/data-access/runtime/tasks.d.ts +4 -4
  39. package/dist/db/manage/manage-schema.d.ts +306 -306
  40. package/dist/db/runtime/runtime-schema.d.ts +204 -204
  41. package/dist/index.d.ts +5 -4
  42. package/dist/index.js +8 -7
  43. package/dist/types/index.js +1 -1
  44. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  45. package/dist/validation/index.d.ts +2 -2
  46. package/dist/validation/index.js +2 -2
  47. package/dist/validation/schemas.d.ts +1602 -1601
  48. package/dist/validation/schemas.js +3 -2
  49. package/drizzle/runtime/0011_colorful_vivisector.sql +50 -0
  50. package/drizzle/runtime/meta/0011_snapshot.json +3088 -0
  51. package/drizzle/runtime/meta/_journal.json +7 -0
  52. package/package.json +9 -2
@@ -98,6 +98,16 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
98
98
  maxPasswordLength: number;
99
99
  requireEmailVerification: false;
100
100
  autoSignIn: true;
101
+ resetPasswordTokenExpiresIn: number;
102
+ sendResetPassword: ({
103
+ user,
104
+ url,
105
+ token
106
+ }: {
107
+ user: better_auth0.User;
108
+ url: string;
109
+ token: string;
110
+ }) => Promise<void>;
101
111
  };
102
112
  account: {
103
113
  accountLinking: {
@@ -870,25 +880,25 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
870
880
  ac: better_auth_plugins0.AccessControl;
871
881
  roles: {
872
882
  member: {
873
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
874
- actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
883
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
884
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
875
885
  connector: "OR" | "AND";
876
886
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
877
- statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
887
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
878
888
  };
879
889
  admin: {
880
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
881
- actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
890
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
891
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
882
892
  connector: "OR" | "AND";
883
893
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
884
- statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
894
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
885
895
  };
886
896
  owner: {
887
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
888
- actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
897
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
898
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
889
899
  connector: "OR" | "AND";
890
900
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
891
- statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
901
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
892
902
  };
893
903
  };
894
904
  creatorRole: "admin";
@@ -905,6 +915,17 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
905
915
  user: better_auth0.User;
906
916
  };
907
917
  }): Promise<void>;
918
+ schema: {
919
+ invitation: {
920
+ additionalFields: {
921
+ authMethod: {
922
+ type: "string";
923
+ input: true;
924
+ required: false;
925
+ };
926
+ };
927
+ };
928
+ };
908
929
  organizationHooks: {
909
930
  afterAcceptInvitation: ({
910
931
  member,
@@ -1068,6 +1089,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1068
1089
  inviterId: string;
1069
1090
  expiresAt: Date;
1070
1091
  createdAt: Date;
1092
+ authMethod?: string | undefined;
1071
1093
  };
1072
1094
  Member: {
1073
1095
  id: string;
@@ -1107,6 +1129,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1107
1129
  inviterId: string;
1108
1130
  expiresAt: Date;
1109
1131
  createdAt: Date;
1132
+ authMethod?: string | undefined;
1110
1133
  }[];
1111
1134
  } & {
1112
1135
  id: string;
@@ -1180,25 +1203,25 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1180
1203
  ac: better_auth_plugins0.AccessControl;
1181
1204
  roles: {
1182
1205
  member: {
1183
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
1184
- actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
1206
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1207
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1185
1208
  connector: "OR" | "AND";
1186
1209
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1187
- statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
1210
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1188
1211
  };
1189
1212
  admin: {
1190
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
1191
- actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
1213
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1214
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1192
1215
  connector: "OR" | "AND";
1193
1216
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1194
- statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
1217
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1195
1218
  };
1196
1219
  owner: {
1197
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key] | {
1198
- actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
1220
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1221
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1199
1222
  connector: "OR" | "AND";
1200
1223
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1201
- statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
1224
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1202
1225
  };
1203
1226
  };
1204
1227
  creatorRole: "admin";
@@ -1215,6 +1238,17 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1215
1238
  user: better_auth0.User;
1216
1239
  };
1217
1240
  }): Promise<void>;
1241
+ schema: {
1242
+ invitation: {
1243
+ additionalFields: {
1244
+ authMethod: {
1245
+ type: "string";
1246
+ input: true;
1247
+ required: false;
1248
+ };
1249
+ };
1250
+ };
1251
+ };
1218
1252
  organizationHooks: {
1219
1253
  afterAcceptInvitation: ({
1220
1254
  member,
package/dist/auth/auth.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { member, ssoProvider } from "./auth-schema.js";
2
2
  import { OrgRoles } from "./authz/config.js";
3
3
  import { env } from "../env.js";
4
+ import { setPasswordResetLink } from "./password-reset-link-store.js";
4
5
  import { generateId } from "../utils/conversations.js";
5
6
  import "../utils/index.js";
6
7
  import { ac, adminRole, memberRole, ownerRole } from "./permissions.js";
@@ -81,7 +82,15 @@ function createAuth(config) {
81
82
  minPasswordLength: 8,
82
83
  maxPasswordLength: 128,
83
84
  requireEmailVerification: false,
84
- autoSignIn: true
85
+ autoSignIn: true,
86
+ resetPasswordTokenExpiresIn: 1800,
87
+ sendResetPassword: async ({ user, url, token }) => {
88
+ setPasswordResetLink({
89
+ email: user.email,
90
+ url,
91
+ token
92
+ });
93
+ }
85
94
  },
86
95
  account: { accountLinking: {
87
96
  enabled: true,
@@ -155,6 +164,11 @@ function createAuth(config) {
155
164
  invitationId: data.id
156
165
  });
157
166
  },
167
+ schema: { invitation: { additionalFields: { authMethod: {
168
+ type: "string",
169
+ input: true,
170
+ required: false
171
+ } } } },
158
172
  organizationHooks: {
159
173
  afterAcceptInvitation: async ({ member: member$1, user, organization: org }) => {
160
174
  try {
@@ -1,4 +1,8 @@
1
1
  //#region src/auth/authz/config.d.ts
2
+ /**
3
+ * Check if a SpiceDB endpoint is localhost (used for TLS auto-detection).
4
+ */
5
+ declare function isLocalhostEndpoint(endpoint: string): boolean;
2
6
  /**
3
7
  * Get SpiceDB connection configuration from environment variables.
4
8
  * TLS is auto-detected: disabled for localhost, enabled for remote endpoints.
@@ -94,4 +98,4 @@ interface ProjectPermissions {
94
98
  canEdit: boolean;
95
99
  }
96
100
  //#endregion
97
- export { OrgRole, OrgRoles, ProjectPermissionLevel, ProjectPermissions, ProjectRole, ProjectRoles, SpiceDbOrgPermission, SpiceDbOrgPermissions, SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, getSpiceDbConfig };
101
+ export { OrgRole, OrgRoles, ProjectPermissionLevel, ProjectPermissions, ProjectRole, ProjectRoles, SpiceDbOrgPermission, SpiceDbOrgPermissions, SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, getSpiceDbConfig, isLocalhostEndpoint };
@@ -1,15 +1,20 @@
1
1
  //#region src/auth/authz/config.ts
2
2
  /**
3
+ * Check if a SpiceDB endpoint is localhost (used for TLS auto-detection).
4
+ */
5
+ function isLocalhostEndpoint(endpoint) {
6
+ return endpoint.startsWith("localhost") || endpoint.startsWith("127.0.0.1");
7
+ }
8
+ /**
3
9
  * Get SpiceDB connection configuration from environment variables.
4
10
  * TLS is auto-detected: disabled for localhost, enabled for remote endpoints.
5
11
  */
6
12
  function getSpiceDbConfig() {
7
13
  const endpoint = process.env.SPICEDB_ENDPOINT || "localhost:50051";
8
- const isLocalhost = endpoint.startsWith("localhost") || endpoint.startsWith("127.0.0.1");
9
14
  return {
10
15
  endpoint,
11
16
  token: process.env.SPICEDB_PRESHARED_KEY || "",
12
- tlsEnabled: !isLocalhost
17
+ tlsEnabled: !isLocalhostEndpoint(endpoint)
13
18
  };
14
19
  }
15
20
  /**
@@ -82,4 +87,4 @@ const ProjectRoles = {
82
87
  };
83
88
 
84
89
  //#endregion
85
- export { OrgRoles, ProjectRoles, SpiceDbOrgPermissions, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, getSpiceDbConfig };
90
+ export { OrgRoles, ProjectRoles, SpiceDbOrgPermissions, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, getSpiceDbConfig, isLocalhostEndpoint };
package/dist/auth/init.js CHANGED
@@ -6,6 +6,7 @@ import { createAgentsRunDatabaseClient } from "../db/runtime/runtime-client.js";
6
6
  import { addUserToOrganization, upsertOrganization } from "../data-access/runtime/organizations.js";
7
7
  import { getUserByEmail } from "../data-access/runtime/users.js";
8
8
  import { createAuth } from "./auth.js";
9
+ import { writeSpiceDbSchema } from "./spicedb-schema.js";
9
10
 
10
11
  //#region src/auth/init.ts
11
12
  /**
@@ -31,6 +32,15 @@ loadEnvironmentFiles();
31
32
  const TENANT_ID = process.env.TENANT_ID || "default";
32
33
  async function init() {
33
34
  console.log("🚀 Initializing database with default organization and user...\n");
35
+ console.log("📜 Writing SpiceDB schema...");
36
+ try {
37
+ await writeSpiceDbSchema();
38
+ console.log(" ✅ SpiceDB schema applied");
39
+ } catch (error) {
40
+ console.error(" ❌ Failed to write SpiceDB schema:", error);
41
+ console.error(" Make sure SpiceDB is running (docker-compose.dbs.yml)");
42
+ process.exit(1);
43
+ }
34
44
  const dbClient = createAgentsRunDatabaseClient();
35
45
  const username = process.env.INKEEP_AGENTS_MANAGE_UI_USERNAME;
36
46
  const password = process.env.INKEEP_AGENTS_MANAGE_UI_PASSWORD;
@@ -95,14 +105,14 @@ async function init() {
95
105
  action: "add"
96
106
  });
97
107
  console.log(" ✅ Synced to SpiceDB");
98
- } catch {
99
- console.log(" ℹ️ SpiceDB sync failed");
108
+ } catch (error) {
109
+ console.error("SpiceDB sync failed:", error);
100
110
  }
101
111
  console.log("\n================================================");
102
112
  console.log("✅ Initialization complete!");
103
113
  console.log("================================================");
104
114
  console.log(`\nOrganization: ${TENANT_ID}`);
105
- console.log(`Admin user: ${username} (owner)`);
115
+ console.log(`Admin user: ${username}`);
106
116
  console.log("\nYou can now log in with these credentials.\n");
107
117
  process.exit(0);
108
118
  }
@@ -0,0 +1,26 @@
1
+ //#region src/auth/password-reset-link-store.d.ts
2
+ type PasswordResetLinkEntry = {
3
+ email: string;
4
+ url: string;
5
+ token: string;
6
+ };
7
+ /**
8
+ * Sets up a listener that resolves when `setPasswordResetLink` fires for this email.
9
+ * Call BEFORE `auth.api.requestPasswordReset()`.
10
+ *
11
+ * This creates a per-request promise bridge: the `sendResetPassword` callback
12
+ * (configured in auth.ts) calls `setPasswordResetLink`, which resolves this promise
13
+ * within the same HTTP request on the same server instance.
14
+ */
15
+ declare function waitForPasswordResetLink(email: string, timeoutMs?: number): Promise<PasswordResetLinkEntry>;
16
+ /**
17
+ * Called from the `sendResetPassword` callback in auth config.
18
+ * Resolves the pending promise for this email (if any).
19
+ */
20
+ declare function setPasswordResetLink(entry: {
21
+ email: string;
22
+ url: string;
23
+ token: string;
24
+ }): void;
25
+ //#endregion
26
+ export { setPasswordResetLink, waitForPasswordResetLink };
@@ -0,0 +1,40 @@
1
+ //#region src/auth/password-reset-link-store.ts
2
+ const pendingResolvers = /* @__PURE__ */ new Map();
3
+ /**
4
+ * Sets up a listener that resolves when `setPasswordResetLink` fires for this email.
5
+ * Call BEFORE `auth.api.requestPasswordReset()`.
6
+ *
7
+ * This creates a per-request promise bridge: the `sendResetPassword` callback
8
+ * (configured in auth.ts) calls `setPasswordResetLink`, which resolves this promise
9
+ * within the same HTTP request on the same server instance.
10
+ */
11
+ function waitForPasswordResetLink(email, timeoutMs = 1e4) {
12
+ const key = email.toLowerCase();
13
+ return new Promise((resolve, reject) => {
14
+ const timeout = setTimeout(() => {
15
+ pendingResolvers.delete(key);
16
+ reject(/* @__PURE__ */ new Error("Timed out waiting for password reset link"));
17
+ }, timeoutMs);
18
+ pendingResolvers.set(key, (entry) => {
19
+ clearTimeout(timeout);
20
+ pendingResolvers.delete(key);
21
+ resolve(entry);
22
+ });
23
+ });
24
+ }
25
+ /**
26
+ * Called from the `sendResetPassword` callback in auth config.
27
+ * Resolves the pending promise for this email (if any).
28
+ */
29
+ function setPasswordResetLink(entry) {
30
+ const key = entry.email.toLowerCase();
31
+ const resolver = pendingResolvers.get(key);
32
+ if (resolver) resolver({
33
+ email: entry.email,
34
+ url: entry.url,
35
+ token: entry.token
36
+ });
37
+ }
38
+
39
+ //#endregion
40
+ export { setPasswordResetLink, waitForPasswordResetLink };
@@ -5,25 +5,25 @@ import { organizationClient } from "better-auth/client/plugins";
5
5
  //#region src/auth/permissions.d.ts
6
6
  declare const ac: AccessControl;
7
7
  declare const memberRole: {
8
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
9
- actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>[key];
8
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
9
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
10
10
  connector: "OR" | "AND";
11
11
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
12
- statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>;
12
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
13
13
  };
14
14
  declare const adminRole: {
15
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
16
- actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>[key];
15
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
16
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
17
17
  connector: "OR" | "AND";
18
18
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
19
- statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>;
19
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
20
20
  };
21
21
  declare const ownerRole: {
22
- authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "ac" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>[key] | {
23
- actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>[key];
22
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
23
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
24
24
  connector: "OR" | "AND";
25
25
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
26
- statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>;
26
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
27
27
  };
28
28
  //#endregion
29
29
  export { ac, adminRole, memberRole, organizationClient, ownerRole };
@@ -0,0 +1,9 @@
1
+ //#region src/auth/spicedb-schema.d.ts
2
+ declare function writeSpiceDbSchema(options?: {
3
+ endpoint?: string;
4
+ token?: string;
5
+ schemaPath?: string;
6
+ maxRetries?: number;
7
+ }): Promise<void>;
8
+ //#endregion
9
+ export { writeSpiceDbSchema };
@@ -0,0 +1,24 @@
1
+ import { getSpiceDbConfig, isLocalhostEndpoint } from "./authz/config.js";
2
+ import { readFileSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ import { v1 } from "@authzed/authzed-node";
5
+
6
+ //#region src/auth/spicedb-schema.ts
7
+ async function writeSpiceDbSchema(options) {
8
+ const config = getSpiceDbConfig();
9
+ const { endpoint = config.endpoint, token = config.token, schemaPath = resolve(import.meta.dirname, "../../spicedb/schema.zed"), maxRetries = 30 } = options ?? {};
10
+ const schema = readFileSync(schemaPath, "utf-8");
11
+ const client = v1.NewClient(token, endpoint, isLocalhostEndpoint(endpoint) ? v1.ClientSecurity.INSECURE_LOCALHOST_ALLOWED : v1.ClientSecurity.SECURE);
12
+ let lastError;
13
+ for (let attempt = 1; attempt <= maxRetries; attempt++) try {
14
+ await client.promises.writeSchema(v1.WriteSchemaRequest.create({ schema }));
15
+ return;
16
+ } catch (error) {
17
+ lastError = error;
18
+ if (attempt < maxRetries) await new Promise((r) => setTimeout(r, 1e3));
19
+ }
20
+ throw new Error(`Failed to write SpiceDB schema after ${maxRetries} attempts: ${lastError?.message}`);
21
+ }
22
+
23
+ //#endregion
24
+ export { writeSpiceDbSchema };