@inkeep/agents-core 0.37.0 → 0.37.2
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 +47 -1
- package/dist/auth/auth-schema.js +1 -1
- package/dist/auth/auth-validation-schemas.d.ts +35 -1
- package/dist/auth/auth-validation-schemas.js +18 -18
- package/dist/auth/auth.d.ts +23 -23
- package/dist/auth/auth.js +13 -5
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/auth/permissions.js +1 -1
- package/dist/{auth-detection-CGqhPDnj.d.ts → auth-detection-7G0Dxt55.d.ts} +11 -0
- package/dist/{chunk-ICZLNCX7.js → chunk-3HACEHXF.js} +370 -71
- package/dist/{chunk-32YRH2S7.js → chunk-5QZSNATS.js} +63 -67
- package/dist/{chunk-SSRRHYU4.js → chunk-6CYQZ5KX.js} +4 -5
- package/dist/{chunk-SLQW43IV.js → chunk-BJLC7EI4.js} +4 -5
- package/dist/chunk-CMNLBV2A.js +39 -0
- package/dist/{chunk-NFYCSHD3.js → chunk-DEYPSEXR.js} +2 -1
- package/dist/chunk-GENLXHZ4.js +159 -0
- package/dist/{chunk-VMSYBWFH.js → chunk-JNBVHWXX.js} +7 -4
- package/dist/{chunk-TGESM3JG.js → chunk-MQMMFK2K.js} +14 -3
- package/dist/{chunk-Q5U2SVA6.js → chunk-RUTYLJB7.js} +11 -7
- package/dist/{chunk-VQXQOGJU.js → chunk-XHODTX4H.js} +313 -315
- package/dist/{chunk-MB2ZIPZS.js → chunk-YSFXXC6K.js} +5 -5
- package/dist/{chunk-SG75RA63.js → chunk-ZSYMSL55.js} +2 -2
- package/dist/{client-CnpNkGsH.d.ts → client-B3nwdklT.d.ts} +1 -1
- package/dist/client-exports.d.ts +10 -8
- package/dist/client-exports.js +126 -127
- package/dist/constants/schema-validation/index.js +1 -1
- package/dist/credential-stores/index.d.ts +4 -5
- package/dist/credential-stores/index.js +1 -1
- package/dist/db/schema.d.ts +3 -4
- package/dist/db/schema.js +2 -2
- package/dist/db/test-client.d.ts +4 -5
- package/dist/db/test-client.js +1 -1
- package/dist/index.d.ts +675 -558
- package/dist/index.js +297 -76
- package/dist/{schema-Cgkp_geg.d.ts → schema-BhYTubhP.d.ts} +24 -1
- package/dist/server-CHLmv-Jb.d.ts +127 -0
- package/dist/types/index.d.ts +34 -115
- package/dist/types/index.js +1 -1
- package/dist/{utility-C_tTZ7-k.d.ts → utility-5USfJ5Xd.d.ts} +588 -459
- package/dist/utils/schema-conversion.d.ts +1 -1
- package/dist/utils/schema-conversion.js +1 -1
- package/dist/validation/index.d.ts +131 -132
- package/dist/validation/index.js +2 -2
- package/drizzle/{0001_fair_malice.sql → 0001_calm_sheva_callister.sql} +1 -16
- package/drizzle/0002_puzzling_goblin_queen.sql +8 -0
- package/drizzle/0003_sweet_human_robot.sql +8 -0
- package/drizzle/meta/0001_snapshot.json +7 -1
- package/drizzle/meta/0002_snapshot.json +3637 -0
- package/drizzle/meta/0003_snapshot.json +3643 -0
- package/drizzle/meta/_journal.json +16 -2
- package/package.json +11 -3
- package/dist/chunk-CUM6BY2Y.js +0 -320
- package/dist/chunk-H2F72PDA.js +0 -15
- package/dist/chunk-NOPEANIU.js +0 -82
- package/dist/chunk-OUXC23J7.js +0 -12534
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AgentWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-
|
|
2
|
-
import {
|
|
1
|
+
import { AgentWithinContextOfProjectSchema, resourceIdSchema, MAX_ID_LENGTH } from './chunk-XHODTX4H.js';
|
|
2
|
+
import { z } from '@hono/zod-openapi';
|
|
3
3
|
|
|
4
4
|
// src/validation/cycleDetection.ts
|
|
5
5
|
function detectDelegationCycles(agentData) {
|
|
@@ -181,44 +181,42 @@ function validateAgentStructure(agentData, projectResources) {
|
|
|
181
181
|
}
|
|
182
182
|
validateAgentRelationships(agentData);
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
reason: external_exports.string().optional().describe("Reason for the transfer"),
|
|
190
|
-
context: external_exports.any().optional().describe("Additional context data")
|
|
184
|
+
var TransferDataSchema = z.object({
|
|
185
|
+
fromSubAgent: z.string().describe("ID of the sub-agent transferring control"),
|
|
186
|
+
targetSubAgent: z.string().describe("ID of the sub-agent receiving control"),
|
|
187
|
+
reason: z.string().optional().describe("Reason for the transfer"),
|
|
188
|
+
context: z.any().optional().describe("Additional context data")
|
|
191
189
|
});
|
|
192
|
-
var DelegationSentDataSchema =
|
|
193
|
-
delegationId:
|
|
194
|
-
fromSubAgent:
|
|
195
|
-
targetSubAgent:
|
|
196
|
-
taskDescription:
|
|
197
|
-
context:
|
|
190
|
+
var DelegationSentDataSchema = z.object({
|
|
191
|
+
delegationId: z.string().describe("Unique identifier for this delegation"),
|
|
192
|
+
fromSubAgent: z.string().describe("ID of the delegating sub-agent"),
|
|
193
|
+
targetSubAgent: z.string().describe("ID of the sub-agent receiving the delegation"),
|
|
194
|
+
taskDescription: z.string().describe("Description of the delegated task"),
|
|
195
|
+
context: z.any().optional().describe("Additional context data")
|
|
198
196
|
});
|
|
199
|
-
var DelegationReturnedDataSchema =
|
|
200
|
-
delegationId:
|
|
201
|
-
fromSubAgent:
|
|
202
|
-
targetSubAgent:
|
|
203
|
-
result:
|
|
197
|
+
var DelegationReturnedDataSchema = z.object({
|
|
198
|
+
delegationId: z.string().describe("Unique identifier matching the original delegation"),
|
|
199
|
+
fromSubAgent: z.string().describe("ID of the sub-agent that completed the task"),
|
|
200
|
+
targetSubAgent: z.string().describe("ID of the sub-agent receiving the result"),
|
|
201
|
+
result: z.any().optional().describe("Result data from the delegated task")
|
|
204
202
|
});
|
|
205
|
-
var DataOperationDetailsSchema =
|
|
206
|
-
timestamp:
|
|
207
|
-
subAgentId:
|
|
208
|
-
data:
|
|
203
|
+
var DataOperationDetailsSchema = z.object({
|
|
204
|
+
timestamp: z.number().describe("Unix timestamp in milliseconds"),
|
|
205
|
+
subAgentId: z.string().describe("ID of the sub-agent that generated this data"),
|
|
206
|
+
data: z.any().describe("The actual data payload")
|
|
209
207
|
});
|
|
210
|
-
var DataOperationEventSchema =
|
|
211
|
-
type:
|
|
212
|
-
label:
|
|
208
|
+
var DataOperationEventSchema = z.object({
|
|
209
|
+
type: z.string().describe("Event type identifier"),
|
|
210
|
+
label: z.string().describe("Human-readable label for the event"),
|
|
213
211
|
details: DataOperationDetailsSchema
|
|
214
212
|
});
|
|
215
|
-
var A2AMessageMetadataSchema =
|
|
216
|
-
fromSubAgentId:
|
|
217
|
-
toSubAgentId:
|
|
218
|
-
fromExternalAgentId:
|
|
219
|
-
toExternalAgentId:
|
|
220
|
-
taskId:
|
|
221
|
-
a2aTaskId:
|
|
213
|
+
var A2AMessageMetadataSchema = z.object({
|
|
214
|
+
fromSubAgentId: z.string().optional().describe("ID of the sending sub-agent"),
|
|
215
|
+
toSubAgentId: z.string().optional().describe("ID of the receiving sub-agent"),
|
|
216
|
+
fromExternalAgentId: z.string().optional().describe("ID of the sending external agent"),
|
|
217
|
+
toExternalAgentId: z.string().optional().describe("ID of the receiving external agent"),
|
|
218
|
+
taskId: z.string().optional().describe("Associated task ID"),
|
|
219
|
+
a2aTaskId: z.string().optional().describe("A2A-specific task ID")
|
|
222
220
|
});
|
|
223
221
|
|
|
224
222
|
// src/validation/id-validation.ts
|
|
@@ -341,50 +339,48 @@ function validateRender(render) {
|
|
|
341
339
|
errors
|
|
342
340
|
};
|
|
343
341
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
type: external_exports.literal("text-start"),
|
|
348
|
-
id: external_exports.string()
|
|
342
|
+
var TextStartEventSchema = z.object({
|
|
343
|
+
type: z.literal("text-start"),
|
|
344
|
+
id: z.string()
|
|
349
345
|
});
|
|
350
|
-
var TextDeltaEventSchema =
|
|
351
|
-
type:
|
|
352
|
-
id:
|
|
353
|
-
delta:
|
|
346
|
+
var TextDeltaEventSchema = z.object({
|
|
347
|
+
type: z.literal("text-delta"),
|
|
348
|
+
id: z.string(),
|
|
349
|
+
delta: z.string()
|
|
354
350
|
});
|
|
355
|
-
var TextEndEventSchema =
|
|
356
|
-
type:
|
|
357
|
-
id:
|
|
351
|
+
var TextEndEventSchema = z.object({
|
|
352
|
+
type: z.literal("text-end"),
|
|
353
|
+
id: z.string()
|
|
358
354
|
});
|
|
359
|
-
var DataComponentStreamEventSchema =
|
|
360
|
-
type:
|
|
361
|
-
id:
|
|
362
|
-
data:
|
|
355
|
+
var DataComponentStreamEventSchema = z.object({
|
|
356
|
+
type: z.literal("data-component"),
|
|
357
|
+
id: z.string(),
|
|
358
|
+
data: z.any()
|
|
363
359
|
});
|
|
364
|
-
var DataOperationStreamEventSchema =
|
|
365
|
-
type:
|
|
366
|
-
data:
|
|
360
|
+
var DataOperationStreamEventSchema = z.object({
|
|
361
|
+
type: z.literal("data-operation"),
|
|
362
|
+
data: z.any()
|
|
367
363
|
// Contains OperationEvent types (AgentInitializingEvent, CompletionEvent, etc.)
|
|
368
364
|
});
|
|
369
|
-
var DataSummaryStreamEventSchema =
|
|
370
|
-
type:
|
|
371
|
-
data:
|
|
365
|
+
var DataSummaryStreamEventSchema = z.object({
|
|
366
|
+
type: z.literal("data-summary"),
|
|
367
|
+
data: z.any()
|
|
372
368
|
// Contains SummaryEvent from entities.ts
|
|
373
369
|
});
|
|
374
|
-
var StreamErrorEventSchema =
|
|
375
|
-
type:
|
|
376
|
-
error:
|
|
370
|
+
var StreamErrorEventSchema = z.object({
|
|
371
|
+
type: z.literal("error"),
|
|
372
|
+
error: z.string()
|
|
377
373
|
});
|
|
378
|
-
var StreamFinishEventSchema =
|
|
379
|
-
type:
|
|
380
|
-
finishReason:
|
|
381
|
-
usage:
|
|
382
|
-
promptTokens:
|
|
383
|
-
completionTokens:
|
|
384
|
-
totalTokens:
|
|
374
|
+
var StreamFinishEventSchema = z.object({
|
|
375
|
+
type: z.literal("finish"),
|
|
376
|
+
finishReason: z.string().optional(),
|
|
377
|
+
usage: z.object({
|
|
378
|
+
promptTokens: z.number().optional(),
|
|
379
|
+
completionTokens: z.number().optional(),
|
|
380
|
+
totalTokens: z.number().optional()
|
|
385
381
|
}).optional()
|
|
386
382
|
});
|
|
387
|
-
var StreamEventSchema =
|
|
383
|
+
var StreamEventSchema = z.discriminatedUnion("type", [
|
|
388
384
|
TextStartEventSchema,
|
|
389
385
|
TextDeltaEventSchema,
|
|
390
386
|
TextEndEventSchema,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { getLogger } from './chunk-DN4B564Y.js';
|
|
2
|
-
import {
|
|
2
|
+
import { z } from '@hono/zod-openapi';
|
|
3
3
|
|
|
4
|
-
// src/utils/schema-conversion.ts
|
|
5
4
|
var logger = getLogger("schema-conversion");
|
|
6
5
|
function convertZodToJsonSchema(zodSchema) {
|
|
7
6
|
try {
|
|
8
|
-
const jsonSchema =
|
|
7
|
+
const jsonSchema = z.toJSONSchema(zodSchema);
|
|
9
8
|
if (jsonSchema.$schema) {
|
|
10
9
|
delete jsonSchema.$schema;
|
|
11
10
|
}
|
|
@@ -27,7 +26,7 @@ var preview = (schema) => {
|
|
|
27
26
|
};
|
|
28
27
|
function convertZodToJsonSchemaWithPreview(zodSchema) {
|
|
29
28
|
const jsonSchema = convertZodToJsonSchema(zodSchema);
|
|
30
|
-
if (zodSchema instanceof
|
|
29
|
+
if (zodSchema instanceof z.ZodObject && jsonSchema.properties) {
|
|
31
30
|
const shape = zodSchema.shape;
|
|
32
31
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
33
32
|
if (fieldSchema?._def?.inPreview === true) {
|
|
@@ -42,7 +41,7 @@ function isZodSchema(value) {
|
|
|
42
41
|
}
|
|
43
42
|
function extractPreviewFields(schema) {
|
|
44
43
|
const previewFields = [];
|
|
45
|
-
if (schema instanceof
|
|
44
|
+
if (schema instanceof z.ZodObject) {
|
|
46
45
|
const shape = schema.shape;
|
|
47
46
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
48
47
|
if (fieldSchema?._def?.inPreview === true) {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { schemaValidationDefaults } from './chunk-Z64UK4CA.js';
|
|
2
|
-
import { loadEnvironmentFiles } from './chunk-
|
|
3
|
-
import {
|
|
2
|
+
import { loadEnvironmentFiles } from './chunk-RUTYLJB7.js';
|
|
3
|
+
import { z } from '@hono/zod-openapi';
|
|
4
4
|
|
|
5
|
-
// src/constants/schema-validation/index.ts
|
|
6
5
|
loadEnvironmentFiles();
|
|
7
|
-
var constantsSchema =
|
|
6
|
+
var constantsSchema = z.object(
|
|
8
7
|
Object.fromEntries(
|
|
9
8
|
Object.keys(schemaValidationDefaults).map((key) => [
|
|
10
9
|
`AGENTS_${key}`,
|
|
11
|
-
|
|
10
|
+
z.coerce.number().optional()
|
|
12
11
|
])
|
|
13
12
|
)
|
|
14
13
|
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/types/a2a.ts
|
|
2
|
+
var TaskState = /* @__PURE__ */ ((TaskState2) => {
|
|
3
|
+
TaskState2["Submitted"] = "submitted";
|
|
4
|
+
TaskState2["Working"] = "working";
|
|
5
|
+
TaskState2["InputRequired"] = "input-required";
|
|
6
|
+
TaskState2["Completed"] = "completed";
|
|
7
|
+
TaskState2["Canceled"] = "canceled";
|
|
8
|
+
TaskState2["Failed"] = "failed";
|
|
9
|
+
TaskState2["Rejected"] = "rejected";
|
|
10
|
+
TaskState2["AuthRequired"] = "auth-required";
|
|
11
|
+
TaskState2["Unknown"] = "unknown";
|
|
12
|
+
return TaskState2;
|
|
13
|
+
})(TaskState || {});
|
|
14
|
+
|
|
15
|
+
// src/types/tool-policies.ts
|
|
16
|
+
function normalizeToolSelections(selections) {
|
|
17
|
+
if (!selections || selections.length === 0) {
|
|
18
|
+
return { selectedTools: [], toolPolicies: {} };
|
|
19
|
+
}
|
|
20
|
+
const selectedTools = [];
|
|
21
|
+
const toolPolicies = {};
|
|
22
|
+
for (const selection of selections) {
|
|
23
|
+
if (typeof selection === "string") {
|
|
24
|
+
selectedTools.push(selection);
|
|
25
|
+
} else {
|
|
26
|
+
selectedTools.push(selection.name);
|
|
27
|
+
const policy = {};
|
|
28
|
+
if (selection.needsApproval !== void 0) {
|
|
29
|
+
policy.needsApproval = selection.needsApproval;
|
|
30
|
+
}
|
|
31
|
+
if (Object.keys(policy).length > 0) {
|
|
32
|
+
toolPolicies[selection.name] = policy;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { selectedTools, toolPolicies };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { TaskState, normalizeToolSelections };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { verification, user, ssoProvider, session, organization, member, invitation, account } from './chunk-
|
|
1
|
+
import { verification, user, ssoProvider, session, organization, member, invitation, account } from './chunk-GENLXHZ4.js';
|
|
2
2
|
import { __export } from './chunk-SIAA4J6H.js';
|
|
3
3
|
import { relations } from 'drizzle-orm';
|
|
4
4
|
import { pgTable, varchar, text, timestamp, jsonb, primaryKey, foreignKey, integer, index, unique } from 'drizzle-orm/pg-core';
|
|
@@ -436,6 +436,7 @@ var subAgentToolRelations = pgTable(
|
|
|
436
436
|
toolId: varchar("tool_id", { length: 256 }).notNull(),
|
|
437
437
|
selectedTools: jsonb("selected_tools").$type(),
|
|
438
438
|
headers: jsonb("headers").$type(),
|
|
439
|
+
toolPolicies: jsonb("tool_policies").$type(),
|
|
439
440
|
...timestamps
|
|
440
441
|
},
|
|
441
442
|
(table) => [
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { relations } from 'drizzle-orm';
|
|
2
|
+
import { pgTable, timestamp, text, boolean, index } from 'drizzle-orm/pg-core';
|
|
3
|
+
|
|
4
|
+
// src/auth/auth-schema.ts
|
|
5
|
+
var user = pgTable("user", {
|
|
6
|
+
id: text("id").primaryKey(),
|
|
7
|
+
name: text("name").notNull(),
|
|
8
|
+
email: text("email").notNull().unique(),
|
|
9
|
+
emailVerified: boolean("email_verified").default(false).notNull(),
|
|
10
|
+
image: text("image"),
|
|
11
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
12
|
+
updatedAt: timestamp("updated_at").defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
13
|
+
});
|
|
14
|
+
var session = pgTable(
|
|
15
|
+
"session",
|
|
16
|
+
{
|
|
17
|
+
id: text("id").primaryKey(),
|
|
18
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
19
|
+
token: text("token").notNull().unique(),
|
|
20
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
21
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date()).notNull(),
|
|
22
|
+
ipAddress: text("ip_address"),
|
|
23
|
+
userAgent: text("user_agent"),
|
|
24
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
25
|
+
activeOrganizationId: text("active_organization_id")
|
|
26
|
+
},
|
|
27
|
+
(table) => [index("session_userId_idx").on(table.userId)]
|
|
28
|
+
);
|
|
29
|
+
var account = pgTable(
|
|
30
|
+
"account",
|
|
31
|
+
{
|
|
32
|
+
id: text("id").primaryKey(),
|
|
33
|
+
accountId: text("account_id").notNull(),
|
|
34
|
+
providerId: text("provider_id").notNull(),
|
|
35
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
36
|
+
accessToken: text("access_token"),
|
|
37
|
+
refreshToken: text("refresh_token"),
|
|
38
|
+
idToken: text("id_token"),
|
|
39
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
|
|
40
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
|
|
41
|
+
scope: text("scope"),
|
|
42
|
+
password: text("password"),
|
|
43
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
44
|
+
updatedAt: timestamp("updated_at").$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
45
|
+
},
|
|
46
|
+
(table) => [index("account_userId_idx").on(table.userId)]
|
|
47
|
+
);
|
|
48
|
+
var verification = pgTable(
|
|
49
|
+
"verification",
|
|
50
|
+
{
|
|
51
|
+
id: text("id").primaryKey(),
|
|
52
|
+
identifier: text("identifier").notNull(),
|
|
53
|
+
value: text("value").notNull(),
|
|
54
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
55
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
56
|
+
updatedAt: timestamp("updated_at").defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()).notNull()
|
|
57
|
+
},
|
|
58
|
+
(table) => [index("verification_identifier_idx").on(table.identifier)]
|
|
59
|
+
);
|
|
60
|
+
var ssoProvider = pgTable("sso_provider", {
|
|
61
|
+
id: text("id").primaryKey(),
|
|
62
|
+
issuer: text("issuer").notNull(),
|
|
63
|
+
oidcConfig: text("oidc_config"),
|
|
64
|
+
samlConfig: text("saml_config"),
|
|
65
|
+
userId: text("user_id").references(() => user.id, { onDelete: "cascade" }),
|
|
66
|
+
providerId: text("provider_id").notNull().unique(),
|
|
67
|
+
organizationId: text("organization_id"),
|
|
68
|
+
domain: text("domain").notNull()
|
|
69
|
+
});
|
|
70
|
+
var organization = pgTable("organization", {
|
|
71
|
+
id: text("id").primaryKey(),
|
|
72
|
+
name: text("name").notNull(),
|
|
73
|
+
slug: text("slug").notNull().unique(),
|
|
74
|
+
logo: text("logo"),
|
|
75
|
+
createdAt: timestamp("created_at").notNull(),
|
|
76
|
+
metadata: text("metadata")
|
|
77
|
+
});
|
|
78
|
+
var member = pgTable(
|
|
79
|
+
"member",
|
|
80
|
+
{
|
|
81
|
+
id: text("id").primaryKey(),
|
|
82
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
83
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
84
|
+
role: text("role").default("member").notNull(),
|
|
85
|
+
createdAt: timestamp("created_at").notNull()
|
|
86
|
+
},
|
|
87
|
+
(table) => [
|
|
88
|
+
index("member_organizationId_idx").on(table.organizationId),
|
|
89
|
+
index("member_userId_idx").on(table.userId)
|
|
90
|
+
]
|
|
91
|
+
);
|
|
92
|
+
var invitation = pgTable(
|
|
93
|
+
"invitation",
|
|
94
|
+
{
|
|
95
|
+
id: text("id").primaryKey(),
|
|
96
|
+
organizationId: text("organization_id").notNull().references(() => organization.id, { onDelete: "cascade" }),
|
|
97
|
+
email: text("email").notNull(),
|
|
98
|
+
role: text("role"),
|
|
99
|
+
status: text("status").default("pending").notNull(),
|
|
100
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
101
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
102
|
+
inviterId: text("inviter_id").notNull().references(() => user.id, { onDelete: "cascade" })
|
|
103
|
+
},
|
|
104
|
+
(table) => [
|
|
105
|
+
index("invitation_organizationId_idx").on(table.organizationId),
|
|
106
|
+
index("invitation_email_idx").on(table.email)
|
|
107
|
+
]
|
|
108
|
+
);
|
|
109
|
+
var userRelations = relations(user, ({ many }) => ({
|
|
110
|
+
sessions: many(session),
|
|
111
|
+
accounts: many(account),
|
|
112
|
+
ssoProviders: many(ssoProvider),
|
|
113
|
+
members: many(member),
|
|
114
|
+
invitations: many(invitation)
|
|
115
|
+
}));
|
|
116
|
+
var sessionRelations = relations(session, ({ one }) => ({
|
|
117
|
+
user: one(user, {
|
|
118
|
+
fields: [session.userId],
|
|
119
|
+
references: [user.id]
|
|
120
|
+
})
|
|
121
|
+
}));
|
|
122
|
+
var accountRelations = relations(account, ({ one }) => ({
|
|
123
|
+
user: one(user, {
|
|
124
|
+
fields: [account.userId],
|
|
125
|
+
references: [user.id]
|
|
126
|
+
})
|
|
127
|
+
}));
|
|
128
|
+
var ssoProviderRelations = relations(ssoProvider, ({ one }) => ({
|
|
129
|
+
user: one(user, {
|
|
130
|
+
fields: [ssoProvider.userId],
|
|
131
|
+
references: [user.id]
|
|
132
|
+
})
|
|
133
|
+
}));
|
|
134
|
+
var organizationRelations = relations(organization, ({ many }) => ({
|
|
135
|
+
members: many(member),
|
|
136
|
+
invitations: many(invitation)
|
|
137
|
+
}));
|
|
138
|
+
var memberRelations = relations(member, ({ one }) => ({
|
|
139
|
+
organization: one(organization, {
|
|
140
|
+
fields: [member.organizationId],
|
|
141
|
+
references: [organization.id]
|
|
142
|
+
}),
|
|
143
|
+
user: one(user, {
|
|
144
|
+
fields: [member.userId],
|
|
145
|
+
references: [user.id]
|
|
146
|
+
})
|
|
147
|
+
}));
|
|
148
|
+
var invitationRelations = relations(invitation, ({ one }) => ({
|
|
149
|
+
organization: one(organization, {
|
|
150
|
+
fields: [invitation.organizationId],
|
|
151
|
+
references: [organization.id]
|
|
152
|
+
}),
|
|
153
|
+
user: one(user, {
|
|
154
|
+
fields: [invitation.inviterId],
|
|
155
|
+
references: [user.id]
|
|
156
|
+
})
|
|
157
|
+
}));
|
|
158
|
+
|
|
159
|
+
export { account, accountRelations, invitation, invitationRelations, member, memberRelations, organization, organizationRelations, session, sessionRelations, ssoProvider, ssoProviderRelations, user, userRelations, verification };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAccessControl } from 'better-auth/plugins/access';
|
|
2
|
-
import { defaultStatements } from 'better-auth/plugins/organization/access';
|
|
2
|
+
import { defaultStatements, memberAc, adminAc, ownerAc } from 'better-auth/plugins/organization/access';
|
|
3
3
|
|
|
4
4
|
// src/auth/permissions.ts
|
|
5
5
|
var statement = {
|
|
@@ -28,7 +28,8 @@ var memberRole = ac.newRole({
|
|
|
28
28
|
artifact_component: ["read"],
|
|
29
29
|
external_agent: ["read"],
|
|
30
30
|
function: ["read"],
|
|
31
|
-
context_config: ["read"]
|
|
31
|
+
context_config: ["read"],
|
|
32
|
+
...memberAc.statements
|
|
32
33
|
});
|
|
33
34
|
var adminRole = ac.newRole({
|
|
34
35
|
project: ["create", "read", "update"],
|
|
@@ -41,7 +42,8 @@ var adminRole = ac.newRole({
|
|
|
41
42
|
artifact_component: ["create", "read", "update"],
|
|
42
43
|
external_agent: ["create", "read", "update"],
|
|
43
44
|
function: ["create", "read", "update"],
|
|
44
|
-
context_config: ["create", "read", "update"]
|
|
45
|
+
context_config: ["create", "read", "update"],
|
|
46
|
+
...adminAc.statements
|
|
45
47
|
});
|
|
46
48
|
var ownerRole = ac.newRole({
|
|
47
49
|
project: ["create", "read", "update", "delete"],
|
|
@@ -54,7 +56,8 @@ var ownerRole = ac.newRole({
|
|
|
54
56
|
artifact_component: ["create", "read", "update", "delete"],
|
|
55
57
|
external_agent: ["create", "read", "update", "delete"],
|
|
56
58
|
function: ["create", "read", "update", "delete"],
|
|
57
|
-
context_config: ["create", "read", "update", "delete"]
|
|
59
|
+
context_config: ["create", "read", "update", "delete"],
|
|
60
|
+
...ownerAc.statements
|
|
58
61
|
});
|
|
59
62
|
|
|
60
63
|
export { ac, adminRole, memberRole, ownerRole };
|
|
@@ -10,7 +10,10 @@ var SPAN_NAMES = {
|
|
|
10
10
|
CONTEXT_HANDLE: "context.handle_context_resolution",
|
|
11
11
|
AGENT_GENERATION: "agent.generate",
|
|
12
12
|
CONTEXT_FETCHER: "context-fetcher.http-request",
|
|
13
|
-
ARTIFACT_PROCESSING: "agent_session.process_artifact"
|
|
13
|
+
ARTIFACT_PROCESSING: "agent_session.process_artifact",
|
|
14
|
+
TOOL_APPROVAL_REQUESTED: "tool.approval_requested",
|
|
15
|
+
TOOL_APPROVAL_APPROVED: "tool.approval_approved",
|
|
16
|
+
TOOL_APPROVAL_DENIED: "tool.approval_denied"
|
|
14
17
|
};
|
|
15
18
|
var AI_OPERATIONS = {
|
|
16
19
|
GENERATE_TEXT: "ai.generateText.doGenerate",
|
|
@@ -55,6 +58,8 @@ var SPAN_KEYS = {
|
|
|
55
58
|
AI_TOOL_CALL_ID: "ai.toolCall.id",
|
|
56
59
|
AI_TOOL_TYPE: "ai.toolType",
|
|
57
60
|
TOOL_PURPOSE: "tool.purpose",
|
|
61
|
+
TOOL_NAME: "tool.name",
|
|
62
|
+
TOOL_CALL_ID: "tool.callId",
|
|
58
63
|
// Token usage
|
|
59
64
|
GEN_AI_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens",
|
|
60
65
|
GEN_AI_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens",
|
|
@@ -99,7 +104,10 @@ var ACTIVITY_TYPES = {
|
|
|
99
104
|
USER_MESSAGE: "user_message",
|
|
100
105
|
AI_ASSISTANT_MESSAGE: "ai_assistant_message",
|
|
101
106
|
AI_MODEL_STREAMED_TEXT: "ai_model_streamed_text",
|
|
102
|
-
AI_MODEL_STREAMED_OBJECT: "ai_model_streamed_object"
|
|
107
|
+
AI_MODEL_STREAMED_OBJECT: "ai_model_streamed_object",
|
|
108
|
+
TOOL_APPROVAL_REQUESTED: "tool_approval_requested",
|
|
109
|
+
TOOL_APPROVAL_APPROVED: "tool_approval_approved",
|
|
110
|
+
TOOL_APPROVAL_DENIED: "tool_approval_denied"
|
|
103
111
|
};
|
|
104
112
|
var ACTIVITY_STATUS = {
|
|
105
113
|
SUCCESS: "success",
|
|
@@ -231,7 +239,10 @@ var QUERY_EXPRESSIONS = {
|
|
|
231
239
|
DURATION_SPANS: "durationSpans",
|
|
232
240
|
AGENT_GENERATIONS: "agentGenerations",
|
|
233
241
|
SPANS_WITH_ERRORS: "spansWithErrors",
|
|
234
|
-
ARTIFACT_PROCESSING: "artifactProcessing"
|
|
242
|
+
ARTIFACT_PROCESSING: "artifactProcessing",
|
|
243
|
+
TOOL_APPROVAL_REQUESTED: "toolApprovalRequested",
|
|
244
|
+
TOOL_APPROVAL_APPROVED: "toolApprovalApproved",
|
|
245
|
+
TOOL_APPROVAL_DENIED: "toolApprovalDenied"
|
|
235
246
|
};
|
|
236
247
|
var REDUCE_OPERATIONS = {
|
|
237
248
|
SUM: "sum",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { external_exports } from './chunk-OUXC23J7.js';
|
|
2
1
|
import fs from 'fs';
|
|
3
2
|
import os from 'os';
|
|
4
3
|
import path from 'path';
|
|
5
4
|
import dotenv from 'dotenv';
|
|
6
5
|
import { expand } from 'dotenv-expand';
|
|
7
6
|
import { findUpSync } from 'find-up';
|
|
7
|
+
import { z } from '@hono/zod-openapi';
|
|
8
8
|
|
|
9
|
+
// src/env.ts
|
|
9
10
|
var loadEnvironmentFiles = () => {
|
|
10
11
|
const environmentFiles = [];
|
|
11
12
|
const currentEnv = path.resolve(process.cwd(), ".env");
|
|
@@ -32,18 +33,21 @@ var loadEnvironmentFiles = () => {
|
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
35
|
loadEnvironmentFiles();
|
|
35
|
-
var envSchema =
|
|
36
|
-
ENVIRONMENT:
|
|
37
|
-
DATABASE_URL:
|
|
38
|
-
POSTGRES_POOL_SIZE:
|
|
39
|
-
INKEEP_AGENTS_JWT_SIGNING_SECRET:
|
|
36
|
+
var envSchema = z.object({
|
|
37
|
+
ENVIRONMENT: z.enum(["development", "production", "pentest", "test"]).optional(),
|
|
38
|
+
DATABASE_URL: z.string().optional(),
|
|
39
|
+
POSTGRES_POOL_SIZE: z.string().optional(),
|
|
40
|
+
INKEEP_AGENTS_JWT_SIGNING_SECRET: z.string().min(32, "INKEEP_AGENTS_JWT_SIGNING_SECRET must be at least 32 characters").optional(),
|
|
41
|
+
INKEEP_AGENTS_MANAGE_UI_URL: z.string().optional(),
|
|
42
|
+
INKEEP_AGENTS_MANAGE_API_URL: z.string().optional(),
|
|
43
|
+
BETTER_AUTH_SECRET: z.string().optional()
|
|
40
44
|
});
|
|
41
45
|
var parseEnv = () => {
|
|
42
46
|
try {
|
|
43
47
|
const parsedEnv = envSchema.parse(process.env);
|
|
44
48
|
return parsedEnv;
|
|
45
49
|
} catch (error) {
|
|
46
|
-
if (error instanceof
|
|
50
|
+
if (error instanceof z.ZodError) {
|
|
47
51
|
const missingVars = error.issues.map((issue) => issue.path.join("."));
|
|
48
52
|
throw new Error(
|
|
49
53
|
`\u274C Invalid environment variables: ${missingVars.join(", ")}
|