@inkeep/agents-core 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth-schema.d.ts +17 -0
- package/dist/auth/auth-schema.js +4 -3
- package/dist/auth/auth-validation-schemas.d.ts +163 -129
- package/dist/auth/auth.d.ts +91 -57
- package/dist/auth/auth.js +16 -2
- package/dist/auth/authz/config.d.ts +5 -86
- package/dist/auth/authz/config.js +12 -73
- package/dist/auth/authz/index.d.ts +2 -1
- package/dist/auth/authz/index.js +2 -1
- package/dist/auth/authz/permissions.d.ts +1 -1
- package/dist/auth/authz/permissions.js +1 -1
- package/dist/auth/authz/sync.d.ts +1 -1
- package/dist/auth/authz/sync.js +1 -1
- package/dist/auth/authz/types.d.ts +92 -0
- package/dist/auth/authz/types.js +76 -0
- package/dist/auth/init.js +14 -4
- package/dist/auth/password-reset-link-store.d.ts +26 -0
- package/dist/auth/password-reset-link-store.js +40 -0
- package/dist/auth/permissions.d.ts +13 -13
- package/dist/auth/spicedb-schema.d.ts +9 -0
- package/dist/auth/spicedb-schema.js +24 -0
- package/dist/client-exports.d.ts +6 -194
- package/dist/client-exports.js +3 -98
- package/dist/constants/models.d.ts +2 -0
- package/dist/constants/models.js +2 -0
- package/dist/data-access/index.d.ts +3 -3
- package/dist/data-access/index.js +3 -3
- package/dist/data-access/manage/agents.d.ts +30 -30
- package/dist/data-access/manage/agents.js +4 -4
- package/dist/data-access/manage/artifactComponents.d.ts +6 -6
- package/dist/data-access/manage/contextConfigs.d.ts +4 -4
- package/dist/data-access/manage/dataComponents.d.ts +2 -2
- package/dist/data-access/manage/functionTools.d.ts +6 -6
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +6 -6
- package/dist/data-access/manage/subAgentRelations.d.ts +8 -8
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +6 -6
- package/dist/data-access/manage/subAgents.d.ts +18 -18
- package/dist/data-access/manage/tools.d.ts +18 -18
- package/dist/data-access/manage/tools.js +1 -1
- package/dist/data-access/runtime/apiKeys.d.ts +20 -20
- package/dist/data-access/runtime/conversations.d.ts +12 -12
- package/dist/data-access/runtime/messages.d.ts +3 -3
- package/dist/data-access/runtime/organizations.d.ts +10 -1
- package/dist/data-access/runtime/organizations.js +24 -3
- package/dist/data-access/runtime/tasks.d.ts +1 -1
- package/dist/db/manage/manage-schema.d.ts +302 -302
- package/dist/db/runtime/runtime-schema.d.ts +206 -206
- package/dist/env.d.ts +6 -0
- package/dist/env.js +4 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +10 -8
- package/dist/types/index.js +1 -1
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/schemas.d.ts +1344 -1343
- package/dist/validation/schemas.js +3 -2
- package/drizzle/runtime/0011_colorful_vivisector.sql +50 -0
- package/drizzle/runtime/meta/0011_snapshot.json +3088 -0
- package/drizzle/runtime/meta/_journal.json +7 -0
- package/package.json +9 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/auth/authz/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Client-safe authz types and constants.
|
|
4
|
+
* These can be safely imported in client-side code without any Node.js dependencies.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* SpiceDB resource types used in the schema
|
|
8
|
+
*/
|
|
9
|
+
declare const SpiceDbResourceTypes: {
|
|
10
|
+
readonly USER: "user";
|
|
11
|
+
readonly ORGANIZATION: "organization";
|
|
12
|
+
readonly PROJECT: "project";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* SpiceDB relations used in the schema
|
|
16
|
+
*
|
|
17
|
+
* Relations are named as nouns (roles) per SpiceDB best practices.
|
|
18
|
+
* Project roles are prefixed for clarity when debugging/grepping.
|
|
19
|
+
*/
|
|
20
|
+
declare const SpiceDbRelations: {
|
|
21
|
+
readonly OWNER: "owner";
|
|
22
|
+
readonly ADMIN: "admin";
|
|
23
|
+
readonly MEMBER: "member";
|
|
24
|
+
readonly ORGANIZATION: "organization";
|
|
25
|
+
readonly PROJECT_ADMIN: "project_admin";
|
|
26
|
+
readonly PROJECT_MEMBER: "project_member";
|
|
27
|
+
readonly PROJECT_VIEWER: "project_viewer";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* SpiceDB permissions for organization resources.
|
|
31
|
+
*
|
|
32
|
+
* From schema.zed definition organization:
|
|
33
|
+
* - view: owner + admin + member
|
|
34
|
+
* - manage: owner + admin (includes managing org settings and all projects)
|
|
35
|
+
*/
|
|
36
|
+
declare const SpiceDbOrgPermissions: {
|
|
37
|
+
readonly VIEW: "view";
|
|
38
|
+
readonly MANAGE: "manage";
|
|
39
|
+
};
|
|
40
|
+
type SpiceDbOrgPermission = (typeof SpiceDbOrgPermissions)[keyof typeof SpiceDbOrgPermissions];
|
|
41
|
+
/**
|
|
42
|
+
* SpiceDB permissions for project resources.
|
|
43
|
+
*
|
|
44
|
+
* From schema.zed definition project:
|
|
45
|
+
* - view: read-only access to project and its resources
|
|
46
|
+
* - use: invoke agents, create API keys, view traces
|
|
47
|
+
* - edit: modify configurations, manage members
|
|
48
|
+
*/
|
|
49
|
+
declare const SpiceDbProjectPermissions: {
|
|
50
|
+
readonly VIEW: "view";
|
|
51
|
+
readonly USE: "use";
|
|
52
|
+
readonly EDIT: "edit";
|
|
53
|
+
};
|
|
54
|
+
type SpiceDbProjectPermission = (typeof SpiceDbProjectPermissions)[keyof typeof SpiceDbProjectPermissions];
|
|
55
|
+
/**
|
|
56
|
+
* Permission levels for project access checks.
|
|
57
|
+
*/
|
|
58
|
+
type ProjectPermissionLevel = SpiceDbProjectPermission;
|
|
59
|
+
/**
|
|
60
|
+
* Organization roles from SpiceDB schema.
|
|
61
|
+
*/
|
|
62
|
+
declare const OrgRoles: {
|
|
63
|
+
readonly OWNER: "owner";
|
|
64
|
+
readonly ADMIN: "admin";
|
|
65
|
+
readonly MEMBER: "member";
|
|
66
|
+
};
|
|
67
|
+
type OrgRole = (typeof OrgRoles)[keyof typeof OrgRoles];
|
|
68
|
+
/**
|
|
69
|
+
* Project roles from SpiceDB schema.
|
|
70
|
+
*
|
|
71
|
+
* Hierarchy:
|
|
72
|
+
* - project_admin: Full access (view + use + edit + manage members)
|
|
73
|
+
* - project_member: Operator access (view + use: invoke agents, create API keys)
|
|
74
|
+
* - project_viewer: Read-only access (view only)
|
|
75
|
+
*/
|
|
76
|
+
declare const ProjectRoles: {
|
|
77
|
+
readonly ADMIN: "project_admin";
|
|
78
|
+
readonly MEMBER: "project_member";
|
|
79
|
+
readonly VIEWER: "project_viewer";
|
|
80
|
+
};
|
|
81
|
+
type ProjectRole = (typeof ProjectRoles)[keyof typeof ProjectRoles];
|
|
82
|
+
/**
|
|
83
|
+
* Project permission capabilities.
|
|
84
|
+
* Maps to the SpiceDB permission checks (view, use, edit).
|
|
85
|
+
*/
|
|
86
|
+
interface ProjectPermissions {
|
|
87
|
+
canView: boolean;
|
|
88
|
+
canUse: boolean;
|
|
89
|
+
canEdit: boolean;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { OrgRole, OrgRoles, ProjectPermissionLevel, ProjectPermissions, ProjectRole, ProjectRoles, SpiceDbOrgPermission, SpiceDbOrgPermissions, SpiceDbProjectPermission, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region src/auth/authz/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Client-safe authz types and constants.
|
|
4
|
+
* These can be safely imported in client-side code without any Node.js dependencies.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* SpiceDB resource types used in the schema
|
|
8
|
+
*/
|
|
9
|
+
const SpiceDbResourceTypes = {
|
|
10
|
+
USER: "user",
|
|
11
|
+
ORGANIZATION: "organization",
|
|
12
|
+
PROJECT: "project"
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* SpiceDB relations used in the schema
|
|
16
|
+
*
|
|
17
|
+
* Relations are named as nouns (roles) per SpiceDB best practices.
|
|
18
|
+
* Project roles are prefixed for clarity when debugging/grepping.
|
|
19
|
+
*/
|
|
20
|
+
const SpiceDbRelations = {
|
|
21
|
+
OWNER: "owner",
|
|
22
|
+
ADMIN: "admin",
|
|
23
|
+
MEMBER: "member",
|
|
24
|
+
ORGANIZATION: "organization",
|
|
25
|
+
PROJECT_ADMIN: "project_admin",
|
|
26
|
+
PROJECT_MEMBER: "project_member",
|
|
27
|
+
PROJECT_VIEWER: "project_viewer"
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* SpiceDB permissions for organization resources.
|
|
31
|
+
*
|
|
32
|
+
* From schema.zed definition organization:
|
|
33
|
+
* - view: owner + admin + member
|
|
34
|
+
* - manage: owner + admin (includes managing org settings and all projects)
|
|
35
|
+
*/
|
|
36
|
+
const SpiceDbOrgPermissions = {
|
|
37
|
+
VIEW: "view",
|
|
38
|
+
MANAGE: "manage"
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* SpiceDB permissions for project resources.
|
|
42
|
+
*
|
|
43
|
+
* From schema.zed definition project:
|
|
44
|
+
* - view: read-only access to project and its resources
|
|
45
|
+
* - use: invoke agents, create API keys, view traces
|
|
46
|
+
* - edit: modify configurations, manage members
|
|
47
|
+
*/
|
|
48
|
+
const SpiceDbProjectPermissions = {
|
|
49
|
+
VIEW: "view",
|
|
50
|
+
USE: "use",
|
|
51
|
+
EDIT: "edit"
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Organization roles from SpiceDB schema.
|
|
55
|
+
*/
|
|
56
|
+
const OrgRoles = {
|
|
57
|
+
OWNER: "owner",
|
|
58
|
+
ADMIN: "admin",
|
|
59
|
+
MEMBER: "member"
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Project roles from SpiceDB schema.
|
|
63
|
+
*
|
|
64
|
+
* Hierarchy:
|
|
65
|
+
* - project_admin: Full access (view + use + edit + manage members)
|
|
66
|
+
* - project_member: Operator access (view + use: invoke agents, create API keys)
|
|
67
|
+
* - project_viewer: Read-only access (view only)
|
|
68
|
+
*/
|
|
69
|
+
const ProjectRoles = {
|
|
70
|
+
ADMIN: "project_admin",
|
|
71
|
+
MEMBER: "project_member",
|
|
72
|
+
VIEWER: "project_viewer"
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { OrgRoles, ProjectRoles, SpiceDbOrgPermissions, SpiceDbProjectPermissions, SpiceDbRelations, SpiceDbResourceTypes };
|
package/dist/auth/init.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OrgRoles } from "./authz/
|
|
1
|
+
import { OrgRoles } from "./authz/types.js";
|
|
2
2
|
import { loadEnvironmentFiles } from "../env.js";
|
|
3
3
|
import { syncOrgMemberToSpiceDb } from "./authz/sync.js";
|
|
4
4
|
import "./authz/index.js";
|
|
@@ -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.
|
|
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}
|
|
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 };
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as better_auth_plugins0 from "better-auth/plugins";
|
|
2
2
|
import { AccessControl } from "better-auth/plugins/access";
|
|
3
3
|
import { organizationClient } from "better-auth/client/plugins";
|
|
4
4
|
|
|
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" | "
|
|
9
|
-
actions:
|
|
8
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>[key] | {
|
|
9
|
+
actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>[key];
|
|
10
10
|
connector: "OR" | "AND";
|
|
11
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
12
|
-
statements:
|
|
11
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
12
|
+
statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>;
|
|
13
13
|
};
|
|
14
14
|
declare const adminRole: {
|
|
15
|
-
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "
|
|
16
|
-
actions:
|
|
15
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>[key] | {
|
|
16
|
+
actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>[key];
|
|
17
17
|
connector: "OR" | "AND";
|
|
18
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
19
|
-
statements:
|
|
18
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
19
|
+
statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>;
|
|
20
20
|
};
|
|
21
21
|
declare const ownerRole: {
|
|
22
|
-
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "
|
|
23
|
-
actions:
|
|
22
|
+
authorize<K_1 extends "organization" | "member" | "invitation" | "project" | "team" | "ac">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>[key] | {
|
|
23
|
+
actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>[key];
|
|
24
24
|
connector: "OR" | "AND";
|
|
25
|
-
} | undefined } : never, connector?: "OR" | "AND"):
|
|
26
|
-
statements:
|
|
25
|
+
} | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
|
|
26
|
+
statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "project" | "team" | "ac", better_auth_plugins0.Statements>;
|
|
27
27
|
};
|
|
28
28
|
//#endregion
|
|
29
29
|
export { ac, adminRole, memberRole, organizationClient, ownerRole };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getSpiceDbConfig } 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, config.tlsEnabled ? v1.ClientSecurity.SECURE : v1.ClientSecurity.INSECURE_LOCALHOST_ALLOWED);
|
|
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 };
|
package/dist/client-exports.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OrgRole, OrgRoles, ProjectRole, ProjectRoles } from "./auth/authz/
|
|
1
|
+
import { OrgRole, OrgRoles, ProjectRole, ProjectRoles } from "./auth/authz/types.js";
|
|
2
2
|
import { BreakdownComponentDef, CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE, ContextBreakdown, V1_BREAKDOWN_SCHEMA, calculateBreakdownTotal, createEmptyBreakdown, parseContextBreakdownFromSpan } from "./constants/context-breakdown.js";
|
|
3
3
|
import { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AI_OPERATIONS, AI_TOOL_TYPES, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, SPAN_KEYS, SPAN_NAMES, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, UNKNOWN_VALUE } from "./constants/otel-attributes.js";
|
|
4
4
|
import { AGGREGATE_OPERATORS, DATA_SOURCES, DATA_TYPES, FIELD_TYPES, OPERATORS, ORDER_DIRECTIONS, PANEL_TYPES, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS } from "./constants/signoz-queries.js";
|
|
@@ -6,186 +6,10 @@ import { ConversationHistoryConfig, CredentialStoreType, MCPTransportType } from
|
|
|
6
6
|
import "./types/index.js";
|
|
7
7
|
import { DEFAULT_NANGO_STORE_ID } from "./credential-stores/default-constants.js";
|
|
8
8
|
import { detectAuthenticationRequired } from "./utils/auth-detection.js";
|
|
9
|
-
import {
|
|
10
|
-
import "./index.js";
|
|
11
|
-
import { AgentStopWhen, AgentStopWhenSchema, ApiKeyApiUpdateSchema, FullAgentAgentInsertSchema, FunctionApiInsertSchema, FunctionApiSelectSchema, FunctionApiUpdateSchema, ModelSettings, ModelSettingsSchema, ResourceIdSchema, SignatureSource, SignatureVerificationConfig, SignatureVerificationConfigSchema, SignedComponent, StopWhen, StopWhenSchema, SubAgentStopWhen, SubAgentStopWhenSchema, TriggerApiInsertSchema, TriggerApiSelectSchema, TriggerApiUpdateSchema, TriggerInvocationApiSelectSchema, TriggerInvocationListResponse, TriggerInvocationResponse, TriggerInvocationStatusEnum, TriggerListResponse, TriggerResponse, TriggerWithWebhookUrlListResponse, TriggerWithWebhookUrlResponse, TriggerWithWebhookUrlSchema } from "./validation/schemas.js";
|
|
9
|
+
import { AgentApiInsertSchema, AgentStopWhen, AgentWithinContextOfProjectResponse, AgentWithinContextOfProjectSchema, ApiKeyApiCreationResponseSchema, ApiKeyApiSelectSchema, CredentialReferenceApiInsertSchema, ExternalAgentApiInsertSchema, FullAgentAgentInsertSchema, FunctionApiInsertSchema, HeadersSchema, ModelSettings, StopWhen, ToolApiInsertSchema, TriggerApiSelectSchema, TriggerInvocationApiSelectSchema } from "./validation/schemas.js";
|
|
12
10
|
import { z } from "@hono/zod-openapi";
|
|
13
|
-
import { convertJsonSchemaToZod } from "zod-from-json-schema";
|
|
14
11
|
|
|
15
12
|
//#region src/client-exports.d.ts
|
|
16
|
-
declare const TenantParamsSchema: z.ZodObject<{
|
|
17
|
-
tenantId: z.ZodString;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
declare const TenantProjectParamsSchema: z.ZodObject<{
|
|
20
|
-
tenantId: z.ZodString;
|
|
21
|
-
projectId: z.ZodString;
|
|
22
|
-
}, z.core.$strip>;
|
|
23
|
-
declare const TenantProjectIdParamsSchema: z.ZodObject<{
|
|
24
|
-
tenantId: z.ZodString;
|
|
25
|
-
projectId: z.ZodString;
|
|
26
|
-
id: z.ZodString;
|
|
27
|
-
}, z.core.$strip>;
|
|
28
|
-
declare const IdParamsSchema: z.ZodObject<{
|
|
29
|
-
id: z.ZodString;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
declare const PaginationSchema: z.ZodObject<{
|
|
32
|
-
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
33
|
-
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
34
|
-
total: z.ZodNumber;
|
|
35
|
-
pages: z.ZodNumber;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
declare const ListResponseSchema: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodObject<{
|
|
38
|
-
data: z.ZodArray<T>;
|
|
39
|
-
pagination: z.ZodObject<{
|
|
40
|
-
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
41
|
-
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
42
|
-
total: z.ZodNumber;
|
|
43
|
-
pages: z.ZodNumber;
|
|
44
|
-
}, z.core.$strip>;
|
|
45
|
-
}, z.core.$strip>;
|
|
46
|
-
declare const SingleResponseSchema: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodObject<{
|
|
47
|
-
data: T;
|
|
48
|
-
}, z.core.$strip>;
|
|
49
|
-
declare const ErrorResponseSchema: z.ZodObject<{
|
|
50
|
-
error: z.ZodString;
|
|
51
|
-
message: z.ZodOptional<z.ZodString>;
|
|
52
|
-
details: z.ZodOptional<z.ZodUnknown>;
|
|
53
|
-
}, z.core.$strip>;
|
|
54
|
-
declare const AgentApiInsertSchema: z.ZodObject<{
|
|
55
|
-
id: z.ZodOptional<z.ZodString>;
|
|
56
|
-
name: z.ZodString;
|
|
57
|
-
description: z.ZodOptional<z.ZodString>;
|
|
58
|
-
prompt: z.ZodOptional<z.ZodString>;
|
|
59
|
-
model: z.ZodOptional<z.ZodObject<{
|
|
60
|
-
model: z.ZodOptional<z.ZodString>;
|
|
61
|
-
providerOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
62
|
-
}, z.core.$strip>>;
|
|
63
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
-
dataComponents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
-
artifactComponents: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
66
|
-
canTransferTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
|
-
canDelegateTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
-
type: z.ZodOptional<z.ZodEnum<{
|
|
69
|
-
internal: "internal";
|
|
70
|
-
external: "external";
|
|
71
|
-
}>>;
|
|
72
|
-
}, z.core.$strip>;
|
|
73
|
-
declare const ToolApiInsertSchema: z.ZodObject<{
|
|
74
|
-
id: z.ZodOptional<z.ZodString>;
|
|
75
|
-
name: z.ZodString;
|
|
76
|
-
description: z.ZodOptional<z.ZodString>;
|
|
77
|
-
type: z.ZodEnum<{
|
|
78
|
-
mcp: "mcp";
|
|
79
|
-
hosted: "hosted";
|
|
80
|
-
}>;
|
|
81
|
-
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
82
|
-
credentialReferenceId: z.ZodOptional<z.ZodString>;
|
|
83
|
-
}, z.core.$strip>;
|
|
84
|
-
declare const ApiKeyApiSelectSchema: z.ZodObject<{
|
|
85
|
-
id: z.ZodString;
|
|
86
|
-
tenantId: z.ZodString;
|
|
87
|
-
projectId: z.ZodString;
|
|
88
|
-
agentId: z.ZodString;
|
|
89
|
-
publicId: z.ZodString;
|
|
90
|
-
keyHash: z.ZodString;
|
|
91
|
-
keyPrefix: z.ZodString;
|
|
92
|
-
name: z.ZodOptional<z.ZodString>;
|
|
93
|
-
lastUsedAt: z.ZodOptional<z.ZodString>;
|
|
94
|
-
expiresAt: z.ZodOptional<z.ZodString>;
|
|
95
|
-
createdAt: z.ZodString;
|
|
96
|
-
updatedAt: z.ZodString;
|
|
97
|
-
}, z.core.$strip>;
|
|
98
|
-
declare const ApiKeyApiCreationResponseSchema: z.ZodObject<{
|
|
99
|
-
data: z.ZodObject<{
|
|
100
|
-
apiKey: z.ZodObject<{
|
|
101
|
-
id: z.ZodString;
|
|
102
|
-
tenantId: z.ZodString;
|
|
103
|
-
projectId: z.ZodString;
|
|
104
|
-
agentId: z.ZodString;
|
|
105
|
-
publicId: z.ZodString;
|
|
106
|
-
keyHash: z.ZodString;
|
|
107
|
-
keyPrefix: z.ZodString;
|
|
108
|
-
name: z.ZodOptional<z.ZodString>;
|
|
109
|
-
lastUsedAt: z.ZodOptional<z.ZodString>;
|
|
110
|
-
expiresAt: z.ZodOptional<z.ZodString>;
|
|
111
|
-
createdAt: z.ZodString;
|
|
112
|
-
updatedAt: z.ZodString;
|
|
113
|
-
}, z.core.$strip>;
|
|
114
|
-
key: z.ZodString;
|
|
115
|
-
}, z.core.$strip>;
|
|
116
|
-
}, z.core.$strip>;
|
|
117
|
-
declare const CredentialReferenceApiInsertSchema: z.ZodObject<{
|
|
118
|
-
id: z.ZodString;
|
|
119
|
-
tenantId: z.ZodOptional<z.ZodString>;
|
|
120
|
-
projectId: z.ZodOptional<z.ZodString>;
|
|
121
|
-
name: z.ZodString;
|
|
122
|
-
type: z.ZodEnum<{
|
|
123
|
-
readonly memory: "memory";
|
|
124
|
-
readonly keychain: "keychain";
|
|
125
|
-
readonly nango: "nango";
|
|
126
|
-
}>;
|
|
127
|
-
credentialStoreId: z.ZodString;
|
|
128
|
-
retrievalParams: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
129
|
-
createdAt: z.ZodOptional<z.ZodString>;
|
|
130
|
-
updatedAt: z.ZodOptional<z.ZodString>;
|
|
131
|
-
userId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
132
|
-
toolId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
|
-
createdBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
134
|
-
}, z.core.$strip>;
|
|
135
|
-
declare const DataComponentApiInsertSchema: z.ZodObject<{
|
|
136
|
-
id: z.ZodString;
|
|
137
|
-
name: z.ZodString;
|
|
138
|
-
description: z.ZodOptional<z.ZodString>;
|
|
139
|
-
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
140
|
-
render: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
141
|
-
component: z.ZodString;
|
|
142
|
-
mockData: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
143
|
-
}, z.core.$strip>>>;
|
|
144
|
-
}, z.core.$strip>;
|
|
145
|
-
declare const ArtifactComponentApiInsertSchema: z.ZodObject<{
|
|
146
|
-
id: z.ZodString;
|
|
147
|
-
name: z.ZodString;
|
|
148
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
149
|
-
props: z.ZodOptional<z.ZodNullable<z.ZodType<Record<string, unknown>, Record<string, unknown>, z.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>>>;
|
|
150
|
-
render: z.ZodOptional<z.ZodNullable<z.ZodType<{
|
|
151
|
-
component: string;
|
|
152
|
-
mockData: Record<string, unknown>;
|
|
153
|
-
}, {
|
|
154
|
-
component: string;
|
|
155
|
-
mockData: Record<string, unknown>;
|
|
156
|
-
}, z.core.$ZodTypeInternals<{
|
|
157
|
-
component: string;
|
|
158
|
-
mockData: Record<string, unknown>;
|
|
159
|
-
}, {
|
|
160
|
-
component: string;
|
|
161
|
-
mockData: Record<string, unknown>;
|
|
162
|
-
}>>>>;
|
|
163
|
-
}, {
|
|
164
|
-
out: {};
|
|
165
|
-
in: {};
|
|
166
|
-
}>;
|
|
167
|
-
declare const ContextConfigApiInsertSchema: z.ZodObject<{
|
|
168
|
-
id: z.ZodOptional<z.ZodString>;
|
|
169
|
-
name: z.ZodOptional<z.ZodString>;
|
|
170
|
-
description: z.ZodOptional<z.ZodString>;
|
|
171
|
-
type: z.ZodOptional<z.ZodString>;
|
|
172
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
173
|
-
}, z.core.$strip>;
|
|
174
|
-
declare const ExternalAgentApiInsertSchema: z.ZodObject<{
|
|
175
|
-
id: z.ZodOptional<z.ZodString>;
|
|
176
|
-
name: z.ZodString;
|
|
177
|
-
description: z.ZodOptional<z.ZodString>;
|
|
178
|
-
baseUrl: z.ZodString;
|
|
179
|
-
headers: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
180
|
-
credentialReferenceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
181
|
-
type: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
182
|
-
}, z.core.$strip>;
|
|
183
|
-
declare const AgentAgentApiInsertSchema: z.ZodObject<{
|
|
184
|
-
id: z.ZodOptional<z.ZodString>;
|
|
185
|
-
name: z.ZodString;
|
|
186
|
-
description: z.ZodOptional<z.ZodString>;
|
|
187
|
-
defaultSubAgentId: z.ZodOptional<z.ZodString>;
|
|
188
|
-
}, z.core.$strip>;
|
|
189
13
|
declare const FullAgentDefinitionSchema: z.ZodObject<{
|
|
190
14
|
id: z.ZodOptional<z.ZodString>;
|
|
191
15
|
name: z.ZodString;
|
|
@@ -195,8 +19,7 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
|
|
|
195
19
|
id: z.ZodString;
|
|
196
20
|
name: z.ZodString;
|
|
197
21
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
198
|
-
|
|
199
|
-
updatedAt: z.ZodOptional<z.ZodString>;
|
|
22
|
+
conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
|
|
200
23
|
models: z.ZodOptional<z.ZodObject<{
|
|
201
24
|
base: z.ZodOptional<z.ZodObject<{
|
|
202
25
|
model: z.ZodOptional<z.ZodString>;
|
|
@@ -220,7 +43,8 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
|
|
|
220
43
|
}, {
|
|
221
44
|
stepCountIs?: number | undefined;
|
|
222
45
|
}>>>>;
|
|
223
|
-
|
|
46
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
47
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
224
48
|
type: z.ZodLiteral<"internal">;
|
|
225
49
|
canUse: z.ZodArray<z.ZodObject<{
|
|
226
50
|
agentToolRelationId: z.ZodOptional<z.ZodString>;
|
|
@@ -289,26 +113,14 @@ declare const FullAgentDefinitionSchema: z.ZodObject<{
|
|
|
289
113
|
type AgentApiInsert = z.infer<typeof AgentApiInsertSchema>;
|
|
290
114
|
type ToolApiInsert = z.infer<typeof ToolApiInsertSchema>;
|
|
291
115
|
type FunctionApiInsert = z.infer<typeof FunctionApiInsertSchema>;
|
|
292
|
-
type TriggerApiInsert = z.infer<typeof TriggerApiInsertSchema>;
|
|
293
116
|
type TriggerApiSelect = z.infer<typeof TriggerApiSelectSchema>;
|
|
294
|
-
type TriggerApiUpdate = z.infer<typeof TriggerApiUpdateSchema>;
|
|
295
117
|
type TriggerInvocationApiSelect = z.infer<typeof TriggerInvocationApiSelectSchema>;
|
|
296
118
|
type ApiKeyApiSelect = z.infer<typeof ApiKeyApiSelectSchema>;
|
|
297
119
|
type ApiKeyApiCreationResponse = z.infer<typeof ApiKeyApiCreationResponseSchema>;
|
|
298
|
-
type ApiKeyApiUpdateResponse = z.infer<typeof ApiKeyApiUpdateSchema>;
|
|
299
120
|
type CredentialReferenceApiInsert = z.infer<typeof CredentialReferenceApiInsertSchema>;
|
|
300
|
-
type DataComponentApiInsert = z.infer<typeof DataComponentApiInsertSchema>;
|
|
301
|
-
type ArtifactComponentApiInsert = z.infer<typeof ArtifactComponentApiInsertSchema>;
|
|
302
|
-
type ContextConfigApiInsert = z.infer<typeof ContextConfigApiInsertSchema>;
|
|
303
121
|
type ExternalAgentApiInsert = z.infer<typeof ExternalAgentApiInsertSchema>;
|
|
304
|
-
type AgentAgentApiInsert = z.infer<typeof AgentAgentApiInsertSchema>;
|
|
305
122
|
type FullAgentDefinition = z.infer<typeof FullAgentDefinitionSchema>;
|
|
306
123
|
type InternalAgentDefinition = z.infer<typeof FullAgentAgentInsertSchema>;
|
|
307
|
-
type ExternalAgentDefinition = z.infer<typeof ExternalAgentApiInsertSchema>;
|
|
308
|
-
type TenantParams = z.infer<typeof TenantParamsSchema>;
|
|
309
|
-
type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
|
|
310
124
|
declare function generateIdFromName(name: string): string;
|
|
311
|
-
type ToolInsert = ToolApiInsert;
|
|
312
|
-
type AgentAgentInsert = AgentAgentApiInsert;
|
|
313
125
|
//#endregion
|
|
314
|
-
export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES,
|
|
126
|
+
export { ACTIVITY_NAMES, ACTIVITY_STATUS, ACTIVITY_TYPES, AGENT_IDS, AGGREGATE_OPERATORS, AI_OPERATIONS, AI_TOOL_TYPES, AgentApiInsert, type AgentStopWhen, AgentWithinContextOfProjectResponse, AgentWithinContextOfProjectSchema, ApiKeyApiCreationResponse, ApiKeyApiSelect, BreakdownComponentDef, CONTEXT_BREAKDOWN_TOTAL_SPAN_ATTRIBUTE, ContextBreakdown, CredentialReferenceApiInsert, CredentialStoreType, DATA_SOURCES, DATA_TYPES, DEFAULT_NANGO_STORE_ID, DELEGATION_FROM_SUB_AGENT_ID, DELEGATION_ID, DELEGATION_TO_SUB_AGENT_ID, ExternalAgentApiInsert, FIELD_TYPES, FullAgentDefinition, FullAgentDefinitionSchema, FunctionApiInsert, HeadersSchema, InternalAgentDefinition, MCPTransportType, type ModelSettings, OPERATORS, ORDER_DIRECTIONS, type OrgRole, OrgRoles, PANEL_TYPES, type ProjectRole, ProjectRoles, QUERY_DEFAULTS, QUERY_EXPRESSIONS, QUERY_FIELD_CONFIGS, QUERY_TYPES, REDUCE_OPERATIONS, SPAN_KEYS, SPAN_NAMES, type StopWhen, TRANSFER_FROM_SUB_AGENT_ID, TRANSFER_TO_SUB_AGENT_ID, ToolApiInsert, TriggerApiSelect, TriggerInvocationApiSelect, UNKNOWN_VALUE, V1_BREAKDOWN_SCHEMA, calculateBreakdownTotal, createEmptyBreakdown, detectAuthenticationRequired, generateIdFromName, parseContextBreakdownFromSpan };
|