@inkeep/agents-core 0.59.4 → 0.60.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 (66) hide show
  1. package/dist/auth/auth-schema.d.ts +86 -86
  2. package/dist/auth/auth-validation-schemas.d.ts +154 -154
  3. package/dist/auth/auth.d.ts +6 -6
  4. package/dist/auth/permissions.d.ts +13 -13
  5. package/dist/client-exports.d.ts +2 -2
  6. package/dist/client-exports.js +2 -2
  7. package/dist/constants/context-breakdown.js +5 -0
  8. package/dist/constants/otel-attributes.d.ts +25 -1
  9. package/dist/constants/otel-attributes.js +25 -1
  10. package/dist/data-access/manage/agentFull.js +5 -5
  11. package/dist/data-access/manage/agents.d.ts +31 -31
  12. package/dist/data-access/manage/artifactComponents.d.ts +14 -14
  13. package/dist/data-access/manage/contextConfigs.d.ts +8 -8
  14. package/dist/data-access/manage/dataComponents.d.ts +6 -6
  15. package/dist/data-access/manage/functionTools.d.ts +14 -14
  16. package/dist/data-access/manage/functionTools.js +2 -2
  17. package/dist/data-access/manage/skills.d.ts +13 -13
  18. package/dist/data-access/manage/skills.js +2 -3
  19. package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +18 -18
  20. package/dist/data-access/manage/subAgentExternalAgentRelations.js +2 -2
  21. package/dist/data-access/manage/subAgentRelations.d.ts +20 -20
  22. package/dist/data-access/manage/subAgentRelations.js +2 -2
  23. package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
  24. package/dist/data-access/manage/subAgentTeamAgentRelations.js +2 -2
  25. package/dist/data-access/manage/subAgents.d.ts +21 -21
  26. package/dist/data-access/manage/tools.d.ts +18 -18
  27. package/dist/data-access/manage/tools.js +2 -2
  28. package/dist/data-access/manage/triggers.d.ts +2 -2
  29. package/dist/data-access/runtime/apiKeys.d.ts +16 -16
  30. package/dist/data-access/runtime/apps.d.ts +13 -10
  31. package/dist/data-access/runtime/conversations.d.ts +18 -18
  32. package/dist/data-access/runtime/conversations.js +17 -1
  33. package/dist/data-access/runtime/messages.d.ts +27 -27
  34. package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
  35. package/dist/data-access/runtime/tasks.d.ts +4 -4
  36. package/dist/db/manage/manage-schema.d.ts +453 -453
  37. package/dist/db/runtime/runtime-schema.d.ts +353 -334
  38. package/dist/db/runtime/runtime-schema.js +4 -1
  39. package/dist/dolt/fk-map.d.ts +5 -0
  40. package/dist/dolt/fk-map.js +34 -0
  41. package/dist/dolt/index.d.ts +3 -2
  42. package/dist/dolt/index.js +3 -2
  43. package/dist/dolt/resolve-conflicts.d.ts +11 -1
  44. package/dist/dolt/resolve-conflicts.js +105 -47
  45. package/dist/index.d.ts +8 -5
  46. package/dist/index.js +7 -4
  47. package/dist/types/utility.d.ts +2 -0
  48. package/dist/utils/apiKeys.js +1 -1
  49. package/dist/utils/conversations.d.ts +7 -1
  50. package/dist/utils/conversations.js +10 -1
  51. package/dist/utils/error.d.ts +51 -51
  52. package/dist/utils/index.d.ts +6 -2
  53. package/dist/utils/index.js +4 -2
  54. package/dist/utils/model-factory.js +35 -10
  55. package/dist/utils/token-estimator.d.ts +19 -0
  56. package/dist/utils/token-estimator.js +17 -0
  57. package/dist/utils/usage-cost-middleware.d.ts +13 -0
  58. package/dist/utils/usage-cost-middleware.js +60 -0
  59. package/dist/utils/usage-tracker.d.ts +2 -0
  60. package/dist/utils/usage-tracker.js +1 -0
  61. package/dist/validation/drizzle-schema-helpers.d.ts +3 -3
  62. package/dist/validation/schemas.d.ts +2162 -2086
  63. package/drizzle/runtime/0025_faulty_kylun.sql +1 -0
  64. package/drizzle/runtime/meta/0025_snapshot.json +4276 -0
  65. package/drizzle/runtime/meta/_journal.json +7 -0
  66. package/package.json +1 -1
@@ -0,0 +1,60 @@
1
+ import { SPAN_KEYS } from "../constants/otel-attributes.js";
2
+ import { getLogger } from "./logger.js";
3
+ import { trace } from "@opentelemetry/api";
4
+
5
+ //#region src/utils/usage-cost-middleware.ts
6
+ const logger = getLogger("usage-cost-middleware");
7
+ function extractUsageTokens(usage) {
8
+ return {
9
+ inputTokens: typeof usage?.inputTokens === "object" ? usage.inputTokens.total ?? 0 : usage?.inputTokens ?? 0,
10
+ outputTokens: typeof usage?.outputTokens === "object" ? usage.outputTokens.total ?? 0 : usage?.outputTokens ?? 0,
11
+ reasoningTokens: typeof usage?.outputTokens === "object" ? usage.outputTokens.reasoning : void 0,
12
+ cachedReadTokens: typeof usage?.inputTokens === "object" ? usage.inputTokens.cacheRead : void 0,
13
+ cachedWriteTokens: typeof usage?.inputTokens === "object" ? usage.inputTokens.cacheWrite : void 0
14
+ };
15
+ }
16
+ function extractGatewayCost(providerMetadata) {
17
+ const gw = providerMetadata?.gateway;
18
+ if (!gw) return 0;
19
+ const cost = parseFloat(gw.cost);
20
+ if (!Number.isNaN(cost) && cost > 0) return cost;
21
+ const marketCost = parseFloat(gw.marketCost);
22
+ if (!Number.isNaN(marketCost) && marketCost > 0) return marketCost;
23
+ return 0;
24
+ }
25
+ function setGatewayCostOnSpan(providerMetadata) {
26
+ const activeSpan = trace.getActiveSpan();
27
+ if (!activeSpan) return;
28
+ const cost = extractGatewayCost(providerMetadata);
29
+ activeSpan.setAttribute(SPAN_KEYS.GEN_AI_COST_ESTIMATED_USD, cost);
30
+ if (providerMetadata?.gateway && cost === 0) logger.warn({ gateway: providerMetadata.gateway }, "Routed through gateway but no cost data in response");
31
+ }
32
+ const gatewayCostMiddleware = {
33
+ specificationVersion: "v3",
34
+ async wrapGenerate({ doGenerate }) {
35
+ const result = await doGenerate();
36
+ try {
37
+ setGatewayCostOnSpan(result.providerMetadata);
38
+ } catch (error) {
39
+ logger.warn({ error }, "Failed to extract gateway cost in wrapGenerate");
40
+ }
41
+ return result;
42
+ },
43
+ async wrapStream({ doStream }) {
44
+ const { stream, ...rest } = await doStream();
45
+ return {
46
+ stream: stream.pipeThrough(new TransformStream({ transform(chunk, controller) {
47
+ controller.enqueue(chunk);
48
+ if (chunk.type === "finish") try {
49
+ setGatewayCostOnSpan(chunk.providerMetadata);
50
+ } catch (error) {
51
+ logger.warn({ error }, "Failed to extract gateway cost in wrapStream");
52
+ }
53
+ } })),
54
+ ...rest
55
+ };
56
+ }
57
+ };
58
+
59
+ //#endregion
60
+ export { extractUsageTokens, gatewayCostMiddleware };
@@ -0,0 +1,2 @@
1
+ import { GenerationType } from "../db/runtime/runtime-schema.js";
2
+ export { type GenerationType };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,10 +1,10 @@
1
1
  import { z } from "@hono/zod-openapi";
2
- import * as drizzle_zod15 from "drizzle-zod";
2
+ import * as drizzle_zod0 from "drizzle-zod";
3
3
  import { AnySQLiteTable } from "drizzle-orm/sqlite-core";
4
4
 
5
5
  //#region src/validation/drizzle-schema-helpers.d.ts
6
- declare function createSelectSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod15.BuildSchema<"select", T["_"]["columns"], drizzle_zod15.BuildRefine<T["_"]["columns"], undefined>, undefined>;
7
- declare function createInsertSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod15.BuildSchema<"insert", T["_"]["columns"], drizzle_zod15.BuildRefine<Pick<T["_"]["columns"], keyof T["$inferInsert"]>, undefined>, undefined>;
6
+ declare function createSelectSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod0.BuildSchema<"select", T["_"]["columns"], drizzle_zod0.BuildRefine<T["_"]["columns"], undefined>, undefined>;
7
+ declare function createInsertSchemaWithModifiers<T extends AnySQLiteTable>(table: T, overrides?: Partial<Record<keyof T['_']['columns'], (schema: z.ZodTypeAny) => z.ZodTypeAny>>): drizzle_zod0.BuildSchema<"insert", T["_"]["columns"], drizzle_zod0.BuildRefine<Pick<T["_"]["columns"], keyof T["$inferInsert"]>, undefined>, undefined>;
8
8
  declare const createSelectSchema: typeof createSelectSchemaWithModifiers;
9
9
  declare const createInsertSchema: typeof createInsertSchemaWithModifiers;
10
10
  /**