@inkeep/agents-core 0.48.6 → 0.49.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.
Files changed (32) hide show
  1. package/dist/auth/auth.d.ts +22 -22
  2. package/dist/auth/auth.js +8 -2
  3. package/dist/auth/authz/config.d.ts +20 -1
  4. package/dist/auth/authz/config.js +27 -1
  5. package/dist/auth/authz/index.d.ts +2 -2
  6. package/dist/auth/authz/index.js +2 -2
  7. package/dist/auth/authz/permissions.d.ts +6 -0
  8. package/dist/auth/authz/permissions.js +21 -6
  9. package/dist/auth/authz/sync.js +31 -18
  10. package/dist/auth/permissions.d.ts +9 -9
  11. package/dist/client-exports.d.ts +1 -1
  12. package/dist/data-access/manage/agents.d.ts +5 -5
  13. package/dist/data-access/manage/artifactComponents.d.ts +2 -2
  14. package/dist/data-access/manage/functionTools.d.ts +4 -4
  15. package/dist/data-access/manage/skills.d.ts +6 -6
  16. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +6 -6
  17. package/dist/data-access/manage/subAgentRelations.d.ts +2 -2
  18. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +6 -6
  19. package/dist/data-access/manage/subAgents.d.ts +3 -3
  20. package/dist/data-access/manage/tools.d.ts +9 -9
  21. package/dist/data-access/manage/triggers.d.ts +2 -2
  22. package/dist/data-access/runtime/apiKeys.d.ts +8 -8
  23. package/dist/data-access/runtime/conversations.d.ts +24 -24
  24. package/dist/data-access/runtime/messages.d.ts +15 -15
  25. package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
  26. package/dist/data-access/runtime/tasks.d.ts +5 -5
  27. package/dist/db/manage/manage-schema.d.ts +449 -449
  28. package/dist/db/runtime/runtime-schema.d.ts +290 -290
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.js +2 -2
  31. package/dist/validation/schemas.d.ts +1505 -1505
  32. package/package.json +1 -1
@@ -880,25 +880,25 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
880
880
  ac: better_auth_plugins0.AccessControl;
881
881
  roles: {
882
882
  member: {
883
- authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
884
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
883
+ 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] | {
884
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
885
885
  connector: "OR" | "AND";
886
886
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
887
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
887
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
888
888
  };
889
889
  admin: {
890
- authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
891
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
890
+ 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] | {
891
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
892
892
  connector: "OR" | "AND";
893
893
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
894
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
894
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
895
895
  };
896
896
  owner: {
897
- authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
898
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
897
+ 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] | {
898
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
899
899
  connector: "OR" | "AND";
900
900
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
901
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
901
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
902
902
  };
903
903
  };
904
904
  creatorRole: "admin";
@@ -1084,7 +1084,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1084
1084
  id: string;
1085
1085
  organizationId: string;
1086
1086
  email: string;
1087
- role: "member" | "admin" | "owner";
1087
+ role: "member" | "owner" | "admin";
1088
1088
  status: better_auth_plugins0.InvitationStatus;
1089
1089
  inviterId: string;
1090
1090
  expiresAt: Date;
@@ -1094,7 +1094,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1094
1094
  Member: {
1095
1095
  id: string;
1096
1096
  organizationId: string;
1097
- role: "member" | "admin" | "owner";
1097
+ role: "member" | "owner" | "admin";
1098
1098
  createdAt: Date;
1099
1099
  userId: string;
1100
1100
  user: {
@@ -1110,7 +1110,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1110
1110
  members: {
1111
1111
  id: string;
1112
1112
  organizationId: string;
1113
- role: "member" | "admin" | "owner";
1113
+ role: "member" | "owner" | "admin";
1114
1114
  createdAt: Date;
1115
1115
  userId: string;
1116
1116
  user: {
@@ -1124,7 +1124,7 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1124
1124
  id: string;
1125
1125
  organizationId: string;
1126
1126
  email: string;
1127
- role: "member" | "admin" | "owner";
1127
+ role: "member" | "owner" | "admin";
1128
1128
  status: better_auth_plugins0.InvitationStatus;
1129
1129
  inviterId: string;
1130
1130
  expiresAt: Date;
@@ -1203,25 +1203,25 @@ declare function createAuth(config: BetterAuthConfig): better_auth0.Auth<{
1203
1203
  ac: better_auth_plugins0.AccessControl;
1204
1204
  roles: {
1205
1205
  member: {
1206
- authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
1207
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
1206
+ 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] | {
1207
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
1208
1208
  connector: "OR" | "AND";
1209
1209
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1210
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
1210
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
1211
1211
  };
1212
1212
  admin: {
1213
- authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
1214
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
1213
+ 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] | {
1214
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
1215
1215
  connector: "OR" | "AND";
1216
1216
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1217
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
1217
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
1218
1218
  };
1219
1219
  owner: {
1220
- authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key] | {
1221
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
1220
+ 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] | {
1221
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>[key];
1222
1222
  connector: "OR" | "AND";
1223
1223
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1224
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
1224
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins0.Statements>;
1225
1225
  };
1226
1226
  };
1227
1227
  creatorRole: "admin";
package/dist/auth/auth.js CHANGED
@@ -73,6 +73,7 @@ async function registerSSOProvider(dbClient, provider) {
73
73
  }
74
74
  function createAuth(config) {
75
75
  const cookieDomain = extractCookieDomain(config.baseURL, config.cookieDomain);
76
+ const isSecure = config.baseURL.startsWith("https://");
76
77
  const auth$1 = betterAuth({
77
78
  baseURL: config.baseURL,
78
79
  secret: config.secret,
@@ -126,9 +127,14 @@ function createAuth(config) {
126
127
  domain: cookieDomain
127
128
  } },
128
129
  defaultCookieAttributes: {
129
- sameSite: "none",
130
- secure: true,
131
130
  httpOnly: true,
131
+ ...isSecure ? {
132
+ sameSite: "none",
133
+ secure: true
134
+ } : {
135
+ sameSite: "lax",
136
+ secure: false
137
+ },
132
138
  ...cookieDomain && { domain: cookieDomain }
133
139
  },
134
140
  ...config.advanced
@@ -12,5 +12,24 @@ declare function getSpiceDbConfig(): {
12
12
  token: string;
13
13
  tlsEnabled: boolean;
14
14
  };
15
+ /**
16
+ * Compose a tenant-scoped SpiceDB project object ID.
17
+ *
18
+ * SpiceDB object IDs are global, so we namespace projects under their tenant
19
+ * to prevent cross-tenant collisions (e.g. two orgs with a project called "default").
20
+ *
21
+ * Format: `{tenantId}/{projectId}`
22
+ */
23
+ declare function toSpiceDbProjectId(tenantId: string, projectId: string): string;
24
+ /**
25
+ * Parse a tenant-scoped SpiceDB project object ID back into its parts.
26
+ *
27
+ * @returns `{ tenantId, projectId }` extracted from the composite ID.
28
+ * @throws if the ID does not contain the separator.
29
+ */
30
+ declare function fromSpiceDbProjectId(spiceDbProjectId: string): {
31
+ tenantId: string;
32
+ projectId: string;
33
+ };
15
34
  //#endregion
16
- export { getSpiceDbConfig, isLocalhostEndpoint };
35
+ export { fromSpiceDbProjectId, getSpiceDbConfig, isLocalhostEndpoint, toSpiceDbProjectId };
@@ -19,6 +19,32 @@ function getSpiceDbConfig() {
19
19
  tlsEnabled: env.SPICEDB_TLS_ENABLED ?? !isLocalhostEndpoint(endpoint)
20
20
  };
21
21
  }
22
+ const SPICEDB_PROJECT_ID_SEPARATOR = "/";
23
+ /**
24
+ * Compose a tenant-scoped SpiceDB project object ID.
25
+ *
26
+ * SpiceDB object IDs are global, so we namespace projects under their tenant
27
+ * to prevent cross-tenant collisions (e.g. two orgs with a project called "default").
28
+ *
29
+ * Format: `{tenantId}/{projectId}`
30
+ */
31
+ function toSpiceDbProjectId(tenantId, projectId) {
32
+ return `${tenantId}${SPICEDB_PROJECT_ID_SEPARATOR}${projectId}`;
33
+ }
34
+ /**
35
+ * Parse a tenant-scoped SpiceDB project object ID back into its parts.
36
+ *
37
+ * @returns `{ tenantId, projectId }` extracted from the composite ID.
38
+ * @throws if the ID does not contain the separator.
39
+ */
40
+ function fromSpiceDbProjectId(spiceDbProjectId) {
41
+ const separatorIndex = spiceDbProjectId.indexOf(SPICEDB_PROJECT_ID_SEPARATOR);
42
+ if (separatorIndex === -1) throw new Error(`Invalid SpiceDB project ID format: ${spiceDbProjectId}`);
43
+ return {
44
+ tenantId: spiceDbProjectId.substring(0, separatorIndex),
45
+ projectId: spiceDbProjectId.substring(separatorIndex + 1)
46
+ };
47
+ }
22
48
 
23
49
  //#endregion
24
- export { getSpiceDbConfig, isLocalhostEndpoint };
50
+ export { fromSpiceDbProjectId, getSpiceDbConfig, isLocalhostEndpoint, toSpiceDbProjectId };
@@ -1,6 +1,6 @@
1
1
  import { checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, lookupResources, readRelationships, resetSpiceClient, writeRelationship } from "./client.js";
2
- import { getSpiceDbConfig } from "./config.js";
2
+ import { fromSpiceDbProjectId, getSpiceDbConfig, toSpiceDbProjectId } from "./config.js";
3
3
  import { OrgRole, OrgRoles, ProjectPermissionLevel, ProjectPermissions, ProjectRole, ProjectRoles, SpiceDbOrgPermission, SpiceDbOrgPermissions, SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes } from "./types.js";
4
4
  import { canEditProject, canUseProject, canUseProjectStrict, canViewProject, listAccessibleProjectIds, listUsableProjectIds } from "./permissions.js";
5
5
  import { changeOrgRole, changeProjectRole, grantProjectAccess, listProjectMembers, listUserProjectMembershipsInSpiceDb, removeProjectFromSpiceDb, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb } from "./sync.js";
6
- export { type OrgRole, OrgRoles, type ProjectPermissionLevel, type ProjectPermissions, type ProjectRole, ProjectRoles, type SpiceDbOrgPermission, SpiceDbOrgPermissions, type SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, canEditProject, canUseProject, canUseProjectStrict, canViewProject, changeOrgRole, changeProjectRole, checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, getSpiceDbConfig, grantProjectAccess, listAccessibleProjectIds, listProjectMembers, listUsableProjectIds, listUserProjectMembershipsInSpiceDb, lookupResources, readRelationships, removeProjectFromSpiceDb, resetSpiceClient, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb, writeRelationship };
6
+ export { type OrgRole, OrgRoles, type ProjectPermissionLevel, type ProjectPermissions, type ProjectRole, ProjectRoles, type SpiceDbOrgPermission, SpiceDbOrgPermissions, type SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, canEditProject, canUseProject, canUseProjectStrict, canViewProject, changeOrgRole, changeProjectRole, checkBulkPermissions, checkPermission, deleteRelationship, fromSpiceDbProjectId, getSpiceClient, getSpiceDbConfig, grantProjectAccess, listAccessibleProjectIds, listProjectMembers, listUsableProjectIds, listUserProjectMembershipsInSpiceDb, lookupResources, readRelationships, removeProjectFromSpiceDb, resetSpiceClient, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb, toSpiceDbProjectId, writeRelationship };
@@ -1,7 +1,7 @@
1
1
  import { OrgRoles, ProjectRoles, SpiceDbOrgPermissions, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes } from "./types.js";
2
- import { getSpiceDbConfig } from "./config.js";
2
+ import { fromSpiceDbProjectId, getSpiceDbConfig, toSpiceDbProjectId } from "./config.js";
3
3
  import { checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, lookupResources, readRelationships, resetSpiceClient, writeRelationship } from "./client.js";
4
4
  import { canEditProject, canUseProject, canUseProjectStrict, canViewProject, listAccessibleProjectIds, listUsableProjectIds } from "./permissions.js";
5
5
  import { changeOrgRole, changeProjectRole, grantProjectAccess, listProjectMembers, listUserProjectMembershipsInSpiceDb, removeProjectFromSpiceDb, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb } from "./sync.js";
6
6
 
7
- export { OrgRoles, ProjectRoles, SpiceDbOrgPermissions, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, canEditProject, canUseProject, canUseProjectStrict, canViewProject, changeOrgRole, changeProjectRole, checkBulkPermissions, checkPermission, deleteRelationship, getSpiceClient, getSpiceDbConfig, grantProjectAccess, listAccessibleProjectIds, listProjectMembers, listUsableProjectIds, listUserProjectMembershipsInSpiceDb, lookupResources, readRelationships, removeProjectFromSpiceDb, resetSpiceClient, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb, writeRelationship };
7
+ export { OrgRoles, ProjectRoles, SpiceDbOrgPermissions, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes, canEditProject, canUseProject, canUseProjectStrict, canViewProject, changeOrgRole, changeProjectRole, checkBulkPermissions, checkPermission, deleteRelationship, fromSpiceDbProjectId, getSpiceClient, getSpiceDbConfig, grantProjectAccess, listAccessibleProjectIds, listProjectMembers, listUsableProjectIds, listUserProjectMembershipsInSpiceDb, lookupResources, readRelationships, removeProjectFromSpiceDb, resetSpiceClient, revokeAllProjectMemberships, revokeProjectAccess, syncOrgMemberToSpiceDb, syncProjectToSpiceDb, toSpiceDbProjectId, writeRelationship };
@@ -11,6 +11,7 @@ import { OrgRole } from "./types.js";
11
11
  */
12
12
  declare function canViewProject(params: {
13
13
  userId: string;
14
+ tenantId: string;
14
15
  projectId: string;
15
16
  orgRole: OrgRole;
16
17
  }): Promise<boolean>;
@@ -23,6 +24,7 @@ declare function canViewProject(params: {
23
24
  */
24
25
  declare function canUseProject(params: {
25
26
  userId: string;
27
+ tenantId: string;
26
28
  projectId: string;
27
29
  orgRole: OrgRole;
28
30
  }): Promise<boolean>;
@@ -33,6 +35,7 @@ declare function canUseProject(params: {
33
35
  */
34
36
  declare function canUseProjectStrict(params: {
35
37
  userId: string;
38
+ tenantId: string;
36
39
  projectId: string;
37
40
  }): Promise<boolean>;
38
41
  /**
@@ -44,6 +47,7 @@ declare function canUseProjectStrict(params: {
44
47
  */
45
48
  declare function canEditProject(params: {
46
49
  userId: string;
50
+ tenantId: string;
47
51
  projectId: string;
48
52
  orgRole: OrgRole;
49
53
  }): Promise<boolean>;
@@ -56,6 +60,7 @@ declare function canEditProject(params: {
56
60
  */
57
61
  declare function listAccessibleProjectIds(params: {
58
62
  userId: string;
63
+ tenantId: string;
59
64
  orgRole: OrgRole;
60
65
  }): Promise<string[] | 'all'>;
61
66
  /**
@@ -63,6 +68,7 @@ declare function listAccessibleProjectIds(params: {
63
68
  */
64
69
  declare function listUsableProjectIds(params: {
65
70
  userId: string;
71
+ tenantId: string;
66
72
  }): Promise<string[]>;
67
73
  //#endregion
68
74
  export { canEditProject, canUseProject, canUseProjectStrict, canViewProject, listAccessibleProjectIds, listUsableProjectIds };
@@ -1,4 +1,5 @@
1
1
  import { OrgRoles, SpiceDbProjectPermissions, SpiceDbResourceTypes } from "./types.js";
2
+ import { fromSpiceDbProjectId, toSpiceDbProjectId } from "./config.js";
2
3
  import { checkPermission, lookupResources } from "./client.js";
3
4
 
4
5
  //#region src/auth/authz/permissions.ts
@@ -18,7 +19,7 @@ async function canViewProject(params) {
18
19
  if (params.orgRole === OrgRoles.OWNER || params.orgRole === OrgRoles.ADMIN) return true;
19
20
  return checkPermission({
20
21
  resourceType: SpiceDbResourceTypes.PROJECT,
21
- resourceId: params.projectId,
22
+ resourceId: toSpiceDbProjectId(params.tenantId, params.projectId),
22
23
  permission: SpiceDbProjectPermissions.VIEW,
23
24
  subjectType: SpiceDbResourceTypes.USER,
24
25
  subjectId: params.userId
@@ -35,7 +36,7 @@ async function canUseProject(params) {
35
36
  if (params.orgRole === OrgRoles.OWNER || params.orgRole === OrgRoles.ADMIN) return true;
36
37
  return checkPermission({
37
38
  resourceType: SpiceDbResourceTypes.PROJECT,
38
- resourceId: params.projectId,
39
+ resourceId: toSpiceDbProjectId(params.tenantId, params.projectId),
39
40
  permission: SpiceDbProjectPermissions.USE,
40
41
  subjectType: SpiceDbResourceTypes.USER,
41
42
  subjectId: params.userId
@@ -50,7 +51,7 @@ async function canUseProjectStrict(params) {
50
51
  if (params.userId === "system" || params.userId.startsWith("apikey:")) return true;
51
52
  return checkPermission({
52
53
  resourceType: SpiceDbResourceTypes.PROJECT,
53
- resourceId: params.projectId,
54
+ resourceId: toSpiceDbProjectId(params.tenantId, params.projectId),
54
55
  permission: SpiceDbProjectPermissions.USE,
55
56
  subjectType: SpiceDbResourceTypes.USER,
56
57
  subjectId: params.userId
@@ -67,7 +68,7 @@ async function canEditProject(params) {
67
68
  if (params.orgRole === OrgRoles.OWNER || params.orgRole === OrgRoles.ADMIN) return true;
68
69
  return checkPermission({
69
70
  resourceType: SpiceDbResourceTypes.PROJECT,
70
- resourceId: params.projectId,
71
+ resourceId: toSpiceDbProjectId(params.tenantId, params.projectId),
71
72
  permission: SpiceDbProjectPermissions.EDIT,
72
73
  subjectType: SpiceDbResourceTypes.USER,
73
74
  subjectId: params.userId
@@ -82,22 +83,36 @@ async function canEditProject(params) {
82
83
  */
83
84
  async function listAccessibleProjectIds(params) {
84
85
  if (params.orgRole === OrgRoles.OWNER || params.orgRole === OrgRoles.ADMIN) return "all";
85
- return lookupResources({
86
+ return (await lookupResources({
86
87
  resourceType: SpiceDbResourceTypes.PROJECT,
87
88
  permission: SpiceDbProjectPermissions.VIEW,
88
89
  subjectType: SpiceDbResourceTypes.USER,
89
90
  subjectId: params.userId
91
+ })).flatMap((id) => {
92
+ try {
93
+ const parsed = fromSpiceDbProjectId(id);
94
+ return parsed.tenantId === params.tenantId ? [parsed.projectId] : [];
95
+ } catch {
96
+ return [];
97
+ }
90
98
  });
91
99
  }
92
100
  /**
93
101
  * Get list of usable project IDs for a user - always checks SpiceDB.
94
102
  */
95
103
  async function listUsableProjectIds(params) {
96
- return lookupResources({
104
+ return (await lookupResources({
97
105
  resourceType: SpiceDbResourceTypes.PROJECT,
98
106
  permission: SpiceDbProjectPermissions.USE,
99
107
  subjectType: SpiceDbResourceTypes.USER,
100
108
  subjectId: params.userId
109
+ })).flatMap((id) => {
110
+ try {
111
+ const parsed = fromSpiceDbProjectId(id);
112
+ return parsed.tenantId === params.tenantId ? [parsed.projectId] : [];
113
+ } catch {
114
+ return [];
115
+ }
101
116
  });
102
117
  }
103
118
 
@@ -1,4 +1,5 @@
1
1
  import { SpiceDbRelations, SpiceDbResourceTypes } from "./types.js";
2
+ import { fromSpiceDbProjectId, toSpiceDbProjectId } from "./config.js";
2
3
  import { RelationshipOperation, deleteRelationship, getSpiceClient, readRelationships, writeRelationship } from "./client.js";
3
4
 
4
5
  //#region src/auth/authz/sync.ts
@@ -87,12 +88,13 @@ async function syncProjectToSpiceDb(params) {
87
88
  subjectType: SpiceDbResourceTypes.USER,
88
89
  subjectId: params.creatorUserId
89
90
  })).some((r) => r.relation === SpiceDbRelations.ADMIN || r.relation === SpiceDbRelations.OWNER);
91
+ const spiceProjectId = toSpiceDbProjectId(params.tenantId, params.projectId);
90
92
  const updates = [{
91
- operation: RelationshipOperation.CREATE,
93
+ operation: RelationshipOperation.TOUCH,
92
94
  relationship: {
93
95
  resource: {
94
96
  objectType: SpiceDbResourceTypes.PROJECT,
95
- objectId: params.projectId
97
+ objectId: spiceProjectId
96
98
  },
97
99
  relation: SpiceDbRelations.ORGANIZATION,
98
100
  subject: {
@@ -106,11 +108,11 @@ async function syncProjectToSpiceDb(params) {
106
108
  }
107
109
  }];
108
110
  if (!isOrgAdminOrOwner) updates.push({
109
- operation: RelationshipOperation.CREATE,
111
+ operation: RelationshipOperation.TOUCH,
110
112
  relationship: {
111
113
  resource: {
112
114
  objectType: SpiceDbResourceTypes.PROJECT,
113
- objectId: params.projectId
115
+ objectId: spiceProjectId
114
116
  },
115
117
  relation: SpiceDbRelations.PROJECT_ADMIN,
116
118
  subject: {
@@ -135,7 +137,7 @@ async function syncProjectToSpiceDb(params) {
135
137
  async function grantProjectAccess(params) {
136
138
  await writeRelationship({
137
139
  resourceType: SpiceDbResourceTypes.PROJECT,
138
- resourceId: params.projectId,
140
+ resourceId: toSpiceDbProjectId(params.tenantId, params.projectId),
139
141
  relation: params.role,
140
142
  subjectType: SpiceDbResourceTypes.USER,
141
143
  subjectId: params.userId
@@ -147,7 +149,7 @@ async function grantProjectAccess(params) {
147
149
  async function revokeProjectAccess(params) {
148
150
  await deleteRelationship({
149
151
  resourceType: SpiceDbResourceTypes.PROJECT,
150
- resourceId: params.projectId,
152
+ resourceId: toSpiceDbProjectId(params.tenantId, params.projectId),
151
153
  relation: params.role,
152
154
  subjectType: SpiceDbResourceTypes.USER,
153
155
  subjectId: params.userId
@@ -159,13 +161,15 @@ async function revokeProjectAccess(params) {
159
161
  */
160
162
  async function changeProjectRole(params) {
161
163
  if (params.oldRole === params.newRole) return;
162
- await getSpiceClient().promises.writeRelationships({
164
+ const spice = getSpiceClient();
165
+ const spiceProjectId = toSpiceDbProjectId(params.tenantId, params.projectId);
166
+ await spice.promises.writeRelationships({
163
167
  updates: [{
164
168
  operation: RelationshipOperation.DELETE,
165
169
  relationship: {
166
170
  resource: {
167
171
  objectType: SpiceDbResourceTypes.PROJECT,
168
- objectId: params.projectId
172
+ objectId: spiceProjectId
169
173
  },
170
174
  relation: params.oldRole,
171
175
  subject: {
@@ -182,7 +186,7 @@ async function changeProjectRole(params) {
182
186
  relationship: {
183
187
  resource: {
184
188
  objectType: SpiceDbResourceTypes.PROJECT,
185
- objectId: params.projectId
189
+ objectId: spiceProjectId
186
190
  },
187
191
  relation: params.newRole,
188
192
  subject: {
@@ -207,7 +211,7 @@ async function removeProjectFromSpiceDb(params) {
207
211
  await getSpiceClient().promises.deleteRelationships({
208
212
  relationshipFilter: {
209
213
  resourceType: SpiceDbResourceTypes.PROJECT,
210
- optionalResourceId: params.projectId,
214
+ optionalResourceId: toSpiceDbProjectId(params.tenantId, params.projectId),
211
215
  optionalResourceIdPrefix: "",
212
216
  optionalRelation: ""
213
217
  },
@@ -224,7 +228,7 @@ async function removeProjectFromSpiceDb(params) {
224
228
  async function listProjectMembers(params) {
225
229
  return (await readRelationships({
226
230
  resourceType: SpiceDbResourceTypes.PROJECT,
227
- resourceId: params.projectId
231
+ resourceId: toSpiceDbProjectId(params.tenantId, params.projectId)
228
232
  })).filter((rel) => rel.subjectType === SpiceDbResourceTypes.USER && (rel.relation === SpiceDbRelations.PROJECT_ADMIN || rel.relation === SpiceDbRelations.PROJECT_MEMBER || rel.relation === SpiceDbRelations.PROJECT_VIEWER)).map((rel) => ({
229
233
  userId: rel.subjectId,
230
234
  role: rel.relation
@@ -239,10 +243,18 @@ async function listUserProjectMembershipsInSpiceDb(params) {
239
243
  resourceType: SpiceDbResourceTypes.PROJECT,
240
244
  subjectType: SpiceDbResourceTypes.USER,
241
245
  subjectId: params.userId
242
- })).filter((rel) => rel.relation === SpiceDbRelations.PROJECT_ADMIN || rel.relation === SpiceDbRelations.PROJECT_MEMBER || rel.relation === SpiceDbRelations.PROJECT_VIEWER).map((rel) => ({
243
- projectId: rel.resourceId,
244
- role: rel.relation
245
- }));
246
+ })).filter((rel) => rel.relation === SpiceDbRelations.PROJECT_ADMIN || rel.relation === SpiceDbRelations.PROJECT_MEMBER || rel.relation === SpiceDbRelations.PROJECT_VIEWER).flatMap((rel) => {
247
+ try {
248
+ const parsed = fromSpiceDbProjectId(rel.resourceId);
249
+ if (parsed.tenantId !== params.tenantId) return [];
250
+ return [{
251
+ projectId: parsed.projectId,
252
+ role: rel.relation
253
+ }];
254
+ } catch {
255
+ return [];
256
+ }
257
+ });
246
258
  }
247
259
  /**
248
260
  * Revoke all project memberships for a user.
@@ -252,12 +264,13 @@ async function listUserProjectMembershipsInSpiceDb(params) {
252
264
  */
253
265
  async function revokeAllProjectMemberships(params) {
254
266
  const spice = getSpiceClient();
267
+ const tenantPrefix = `${params.tenantId}/`;
255
268
  await Promise.all([
256
269
  spice.promises.deleteRelationships({
257
270
  relationshipFilter: {
258
271
  resourceType: SpiceDbResourceTypes.PROJECT,
259
272
  optionalResourceId: "",
260
- optionalResourceIdPrefix: "",
273
+ optionalResourceIdPrefix: tenantPrefix,
261
274
  optionalRelation: SpiceDbRelations.PROJECT_ADMIN,
262
275
  optionalSubjectFilter: {
263
276
  subjectType: SpiceDbResourceTypes.USER,
@@ -274,7 +287,7 @@ async function revokeAllProjectMemberships(params) {
274
287
  relationshipFilter: {
275
288
  resourceType: SpiceDbResourceTypes.PROJECT,
276
289
  optionalResourceId: "",
277
- optionalResourceIdPrefix: "",
290
+ optionalResourceIdPrefix: tenantPrefix,
278
291
  optionalRelation: SpiceDbRelations.PROJECT_MEMBER,
279
292
  optionalSubjectFilter: {
280
293
  subjectType: SpiceDbResourceTypes.USER,
@@ -291,7 +304,7 @@ async function revokeAllProjectMemberships(params) {
291
304
  relationshipFilter: {
292
305
  resourceType: SpiceDbResourceTypes.PROJECT,
293
306
  optionalResourceId: "",
294
- optionalResourceIdPrefix: "",
307
+ optionalResourceIdPrefix: tenantPrefix,
295
308
  optionalRelation: SpiceDbRelations.PROJECT_VIEWER,
296
309
  optionalSubjectFilter: {
297
310
  subjectType: SpiceDbResourceTypes.USER,
@@ -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" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key] | {
9
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
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];
10
10
  connector: "OR" | "AND";
11
11
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
12
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
12
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>;
13
13
  };
14
14
  declare const adminRole: {
15
- authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key] | {
16
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
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];
17
17
  connector: "OR" | "AND";
18
18
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
19
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
19
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>;
20
20
  };
21
21
  declare const ownerRole: {
22
- authorize<K_1 extends "organization" | "ac" | "member" | "project" | "team" | "invitation">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key] | {
23
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
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];
24
24
  connector: "OR" | "AND";
25
25
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
26
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
26
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "project" | "ac" | "team", better_auth_plugins69.Statements>;
27
27
  };
28
28
  //#endregion
29
29
  export { ac, adminRole, memberRole, organizationClient, ownerRole };
@@ -18,9 +18,9 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
18
18
  defaultSubAgentId: z.ZodOptional<z.ZodString>;
19
19
  subAgents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
20
20
  id: z.ZodString;
21
+ name: z.ZodString;
21
22
  createdAt: z.ZodOptional<z.ZodString>;
22
23
  updatedAt: z.ZodOptional<z.ZodString>;
23
- name: z.ZodString;
24
24
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
25
  conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
26
26
  models: z.ZodOptional<z.ZodObject<{
@@ -9,9 +9,9 @@ declare const getAgentById: (db: AgentsManageDatabaseClient) => (params: {
9
9
  scopes: AgentScopeConfig;
10
10
  }) => Promise<{
11
11
  id: string;
12
+ name: string;
12
13
  createdAt: string;
13
14
  updatedAt: string;
14
- name: string;
15
15
  description: string | null;
16
16
  defaultSubAgentId: string | null;
17
17
  tenantId: string;
@@ -55,9 +55,9 @@ declare const getAgentWithDefaultSubAgent: (db: AgentsManageDatabaseClient) => (
55
55
  scopes: AgentScopeConfig;
56
56
  }) => Promise<{
57
57
  id: string;
58
+ name: string;
58
59
  createdAt: string;
59
60
  updatedAt: string;
60
- name: string;
61
61
  description: string | null;
62
62
  defaultSubAgentId: string | null;
63
63
  tenantId: string;
@@ -98,9 +98,9 @@ declare const getAgentWithDefaultSubAgent: (db: AgentsManageDatabaseClient) => (
98
98
  } | null;
99
99
  defaultSubAgent: {
100
100
  id: string;
101
+ name: string;
101
102
  createdAt: string;
102
103
  updatedAt: string;
103
- name: string;
104
104
  description: string | null;
105
105
  tenantId: string;
106
106
  projectId: string;
@@ -130,9 +130,9 @@ declare const listAgents: (db: AgentsManageDatabaseClient) => (params: {
130
130
  scopes: ProjectScopeConfig;
131
131
  }) => Promise<{
132
132
  id: string;
133
+ name: string;
133
134
  createdAt: string;
134
135
  updatedAt: string;
135
- name: string;
136
136
  description: string | null;
137
137
  defaultSubAgentId: string | null;
138
138
  tenantId: string;
@@ -246,9 +246,9 @@ declare function listAgentsAcrossProjectMainBranches(db: AgentsManageDatabaseCli
246
246
  }): Promise<AvailableAgentInfo[]>;
247
247
  declare const createAgent: (db: AgentsManageDatabaseClient) => (data: AgentInsert) => Promise<{
248
248
  id: string;
249
+ name: string;
249
250
  createdAt: string;
250
251
  updatedAt: string;
251
- name: string;
252
252
  description: string | null;
253
253
  defaultSubAgentId: string | null;
254
254
  tenantId: string;
@@ -9,9 +9,9 @@ declare const getArtifactComponentById: (db: AgentsManageDatabaseClient) => (par
9
9
  id: string;
10
10
  }) => Promise<{
11
11
  id: string;
12
+ name: string;
12
13
  createdAt: string;
13
14
  updatedAt: string;
14
- name: string;
15
15
  description: string | null;
16
16
  tenantId: string;
17
17
  projectId: string;
@@ -65,9 +65,9 @@ declare const listArtifactComponentsPaginated: (db: AgentsManageDatabaseClient)
65
65
  }>;
66
66
  declare const createArtifactComponent: (db: AgentsManageDatabaseClient) => (params: ArtifactComponentInsert) => Promise<{
67
67
  id: string;
68
+ name: string;
68
69
  createdAt: string;
69
70
  updatedAt: string;
70
- name: string;
71
71
  description: string | null;
72
72
  tenantId: string;
73
73
  projectId: string;