@inkeep/agents-api 0.42.0 → 0.43.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 (130) hide show
  1. package/dist/.well-known/workflow/v1/manifest.debug.json +15 -15
  2. package/dist/.well-known/workflow/v1/step.cjs +45672 -44470
  3. package/dist/_virtual/rolldown_runtime.js +7 -0
  4. package/dist/createApp.js +40 -12
  5. package/dist/domains/evals/api/.well-known/workflow/v1/flow.d.ts +4 -0
  6. package/dist/domains/evals/api/.well-known/workflow/v1/flow.js +12 -0
  7. package/dist/domains/evals/api/.well-known/workflow/v1/step.d.ts +4 -0
  8. package/dist/domains/evals/api/.well-known/workflow/v1/step.js +12 -0
  9. package/dist/domains/evals/routes/datasetTriggers.d.ts +2 -2
  10. package/dist/domains/evals/routes/index.d.ts +2 -2
  11. package/dist/domains/evals/scripts/build-workflow.js +2 -2
  12. package/dist/domains/evals/workflow/routes.d.ts +2 -2
  13. package/dist/domains/evals/workflow/world.js +3 -2
  14. package/dist/domains/github/config.d.ts +14 -0
  15. package/dist/domains/github/config.js +47 -0
  16. package/dist/domains/github/index.d.ts +12 -0
  17. package/dist/domains/github/index.js +18 -0
  18. package/dist/domains/github/installation.d.ts +34 -0
  19. package/dist/domains/github/installation.js +172 -0
  20. package/dist/domains/github/jwks.d.ts +20 -0
  21. package/dist/domains/github/jwks.js +85 -0
  22. package/dist/domains/github/oidcToken.d.ts +22 -0
  23. package/dist/domains/github/oidcToken.js +140 -0
  24. package/dist/domains/github/routes/tokenExchange.d.ts +7 -0
  25. package/dist/domains/github/routes/tokenExchange.js +130 -0
  26. package/dist/domains/manage/index.js +0 -2
  27. package/dist/domains/manage/routes/agent.js +7 -4
  28. package/dist/domains/manage/routes/agentFull.js +9 -6
  29. package/dist/domains/manage/routes/apiKeys.js +1 -2
  30. package/dist/domains/manage/routes/artifactComponents.js +5 -5
  31. package/dist/domains/manage/routes/cliAuth.js +3 -3
  32. package/dist/domains/manage/routes/contextConfigs.js +5 -5
  33. package/dist/domains/manage/routes/conversations.d.ts +2 -2
  34. package/dist/domains/manage/routes/credentialStores.js +2 -2
  35. package/dist/domains/manage/routes/credentials.js +6 -7
  36. package/dist/domains/manage/routes/dataComponents.js +6 -7
  37. package/dist/domains/manage/routes/externalAgents.js +1 -2
  38. package/dist/domains/manage/routes/index.d.ts +2 -2
  39. package/dist/domains/manage/routes/index.js +4 -0
  40. package/dist/domains/manage/routes/invitations.js +1 -1
  41. package/dist/domains/manage/routes/mcp.d.ts +2 -2
  42. package/dist/domains/manage/routes/playgroundToken.js +1 -2
  43. package/dist/domains/manage/routes/projectFull.js +33 -11
  44. package/dist/domains/manage/routes/projectMembers.js +16 -35
  45. package/dist/domains/manage/routes/projectPermissions.js +17 -10
  46. package/dist/domains/manage/routes/projects.js +4 -5
  47. package/dist/domains/manage/routes/signoz.d.ts +2 -2
  48. package/dist/domains/manage/routes/signoz.js +6 -3
  49. package/dist/domains/manage/routes/subAgentArtifactComponents.js +5 -5
  50. package/dist/domains/manage/routes/subAgentDataComponents.js +5 -5
  51. package/dist/domains/manage/routes/subAgentExternalAgentRelations.js +5 -5
  52. package/dist/domains/manage/routes/subAgentFunctionTools.js +5 -5
  53. package/dist/domains/manage/routes/subAgentRelations.js +6 -6
  54. package/dist/domains/manage/routes/subAgentTeamAgentRelations.js +6 -6
  55. package/dist/domains/manage/routes/subAgentToolRelations.js +6 -6
  56. package/dist/domains/manage/routes/subAgents.js +5 -5
  57. package/dist/domains/manage/routes/tools.js +24 -3
  58. package/dist/domains/manage/routes/triggers.js +49 -24
  59. package/dist/domains/manage/routes/userOrganizations.js +4 -4
  60. package/dist/domains/manage/routes/{agentToolRelations.d.ts → userProjectMemberships.d.ts} +1 -1
  61. package/dist/domains/manage/routes/userProjectMemberships.js +45 -0
  62. package/dist/domains/mcp/routes/mcp.d.ts +7 -0
  63. package/dist/domains/mcp/routes/mcp.js +45 -0
  64. package/dist/domains/run/agents/Agent.d.ts +1 -0
  65. package/dist/domains/run/agents/Agent.js +207 -44
  66. package/dist/domains/run/agents/relationTools.d.ts +2 -2
  67. package/dist/domains/run/context/ContextFetcher.js +8 -7
  68. package/dist/domains/run/context/ContextResolver.js +1 -1
  69. package/dist/domains/run/handlers/executionHandler.js +143 -79
  70. package/dist/domains/run/routes/agents.js +1 -1
  71. package/dist/domains/run/routes/chat.js +47 -1
  72. package/dist/domains/run/routes/chatDataStream.js +107 -14
  73. package/dist/domains/run/routes/webhooks.js +40 -348
  74. package/dist/domains/run/services/AgentSession.d.ts +3 -0
  75. package/dist/domains/run/services/AgentSession.js +9 -0
  76. package/dist/domains/run/services/BaseCompressor.js +1 -1
  77. package/dist/domains/run/services/ToolApprovalUiBus.d.ts +28 -0
  78. package/dist/domains/run/services/ToolApprovalUiBus.js +44 -0
  79. package/dist/domains/run/services/TriggerService.d.ts +31 -0
  80. package/dist/domains/run/services/TriggerService.js +543 -0
  81. package/dist/domains/run/tools/NativeSandboxExecutor.d.ts +3 -2
  82. package/dist/domains/run/tools/NativeSandboxExecutor.js +76 -48
  83. package/dist/domains/run/tools/SandboxExecutorFactory.d.ts +11 -1
  84. package/dist/domains/run/tools/SandboxExecutorFactory.js +27 -3
  85. package/dist/domains/run/tools/VercelSandboxExecutor.d.ts +3 -11
  86. package/dist/domains/run/tools/VercelSandboxExecutor.js +137 -127
  87. package/dist/domains/run/utils/stream-helpers.d.ts +134 -0
  88. package/dist/domains/run/utils/stream-helpers.js +182 -0
  89. package/dist/domains/run/utils/token-estimator.d.ts +2 -2
  90. package/dist/factory.d.ts +24 -24
  91. package/dist/index.d.ts +24 -24
  92. package/dist/initialization.js +9 -2
  93. package/dist/middleware/cors.js +1 -1
  94. package/dist/middleware/manageAuth.d.ts +2 -2
  95. package/dist/middleware/projectAccess.d.ts +4 -11
  96. package/dist/middleware/projectAccess.js +1 -17
  97. package/dist/middleware/projectConfig.d.ts +3 -3
  98. package/dist/middleware/requirePermission.d.ts +2 -2
  99. package/dist/middleware/runAuth.d.ts +4 -4
  100. package/dist/middleware/sessionAuth.d.ts +3 -3
  101. package/dist/middleware/tenantAccess.d.ts +2 -2
  102. package/dist/middleware/tenantAccess.js +4 -4
  103. package/dist/middleware/tracing.d.ts +3 -3
  104. package/dist/openapi.d.ts +35 -1
  105. package/dist/openapi.js +39 -95
  106. package/dist/routes/healthChecks.d.ts +10 -0
  107. package/dist/routes/healthChecks.js +75 -0
  108. package/dist/types/app.d.ts +2 -0
  109. package/dist/utils/healthChecks.d.ts +8 -0
  110. package/dist/utils/healthChecks.js +38 -0
  111. package/dist/utils/signozHelpers.d.ts +2 -2
  112. package/dist/utils/signozHelpers.js +15 -3
  113. package/package.json +7 -9
  114. package/dist/domains/evals/services/startEvaluation.d.ts +0 -19
  115. package/dist/domains/evals/services/startEvaluation.js +0 -18
  116. package/dist/domains/index.d.ts +0 -4
  117. package/dist/domains/index.js +0 -5
  118. package/dist/domains/manage/routes/agentToolRelations.js +0 -289
  119. package/dist/domains/run/agents/ModelFactory.d.ts +0 -63
  120. package/dist/domains/run/agents/ModelFactory.js +0 -194
  121. package/dist/domains/run/data/agent.d.ts +0 -7
  122. package/dist/domains/run/data/agent.js +0 -67
  123. package/dist/domains/run/services/evaluationRunConfigMatcher.d.ts +0 -4
  124. package/dist/domains/run/services/evaluationRunConfigMatcher.js +0 -7
  125. package/dist/domains/run/utils/cleanup.d.ts +0 -21
  126. package/dist/domains/run/utils/cleanup.js +0 -59
  127. package/dist/utils/tempApiKeys.d.ts +0 -17
  128. package/dist/utils/tempApiKeys.js +0 -26
  129. package/dist/utils/workflowApiHelpers.d.ts +0 -1
  130. package/dist/utils/workflowApiHelpers.js +0 -1
@@ -5,6 +5,7 @@ import { parsePartialJson } from "ai";
5
5
  var SSEStreamHelper = class {
6
6
  isTextStreaming = false;
7
7
  queuedEvents = [];
8
+ toolCallIndexById = /* @__PURE__ */ new Map();
8
9
  constructor(stream, requestId, timestamp) {
9
10
  this.stream = stream;
10
11
  this.requestId = requestId;
@@ -40,6 +41,25 @@ var SSEStreamHelper = class {
40
41
  }]
41
42
  }) });
42
43
  }
44
+ getToolIndex(toolCallId) {
45
+ const existing = this.toolCallIndexById.get(toolCallId);
46
+ if (existing !== void 0) return existing;
47
+ const next = this.toolCallIndexById.size;
48
+ this.toolCallIndexById.set(toolCallId, next);
49
+ return next;
50
+ }
51
+ async writeToolCallsDelta(toolCalls) {
52
+ await this.stream.writeSSE({ data: JSON.stringify({
53
+ id: this.requestId,
54
+ object: "chat.completion.chunk",
55
+ created: this.timestamp,
56
+ choices: [{
57
+ index: 0,
58
+ delta: { tool_calls: toolCalls },
59
+ finish_reason: null
60
+ }]
61
+ }) });
62
+ }
43
63
  /**
44
64
  * Stream text word by word with optional delay
45
65
  */
@@ -97,6 +117,65 @@ var SSEStreamHelper = class {
97
117
  }]
98
118
  }) });
99
119
  }
120
+ async writeToolInputStart(params) {
121
+ const index = this.getToolIndex(params.toolCallId);
122
+ await this.writeToolCallsDelta([{
123
+ index,
124
+ id: params.toolCallId,
125
+ type: "function",
126
+ function: {
127
+ name: params.toolName,
128
+ arguments: ""
129
+ }
130
+ }]);
131
+ }
132
+ async writeToolInputDelta(params) {
133
+ const index = this.getToolIndex(params.toolCallId);
134
+ await this.writeToolCallsDelta([{
135
+ index,
136
+ id: null,
137
+ type: null,
138
+ function: {
139
+ name: null,
140
+ arguments: params.inputTextDelta
141
+ }
142
+ }]);
143
+ }
144
+ async writeToolInputAvailable(params) {
145
+ const fullArgs = JSON.stringify(params.input ?? {});
146
+ if (fullArgs) await this.writeToolInputDelta({
147
+ toolCallId: params.toolCallId,
148
+ inputTextDelta: fullArgs
149
+ });
150
+ }
151
+ async writeToolOutputAvailable(params) {
152
+ await this.writeContent(JSON.stringify({
153
+ type: "tool-output-available",
154
+ toolCallId: params.toolCallId,
155
+ output: params.output
156
+ }));
157
+ }
158
+ async writeToolOutputError(params) {
159
+ await this.writeContent(JSON.stringify({
160
+ type: "tool-output-error",
161
+ toolCallId: params.toolCallId,
162
+ errorText: params.errorText,
163
+ output: params.output ?? null
164
+ }));
165
+ }
166
+ async writeToolApprovalRequest(params) {
167
+ await this.writeContent(JSON.stringify({
168
+ type: "tool-approval-request",
169
+ approvalId: params.approvalId,
170
+ toolCallId: params.toolCallId
171
+ }));
172
+ }
173
+ async writeToolOutputDenied(params) {
174
+ await this.writeContent(JSON.stringify({
175
+ type: "tool-output-denied",
176
+ toolCallId: params.toolCallId
177
+ }));
178
+ }
100
179
  async writeSummary(summary) {
101
180
  if (this.isTextStreaming) {
102
181
  this.queuedEvents.push({
@@ -166,6 +245,7 @@ var VercelDataStreamHelper = class VercelDataStreamHelper {
166
245
  this.forceCleanup("Connection lifetime exceeded");
167
246
  }, STREAM_MAX_LIFETIME_MS);
168
247
  }
248
+ setSessionId(_sessionId) {}
169
249
  async writeRole(_ = "assistant") {}
170
250
  async writeContent(content) {
171
251
  if (this.isCompleted) {
@@ -272,6 +352,64 @@ var VercelDataStreamHelper = class VercelDataStreamHelper {
272
352
  type: "error"
273
353
  });
274
354
  }
355
+ async writeToolInputStart(params) {
356
+ if (this.isCompleted) return;
357
+ this.writer.write({
358
+ type: "tool-input-start",
359
+ toolCallId: params.toolCallId,
360
+ toolName: params.toolName
361
+ });
362
+ }
363
+ async writeToolInputDelta(params) {
364
+ if (this.isCompleted) return;
365
+ this.writer.write({
366
+ type: "tool-input-delta",
367
+ toolCallId: params.toolCallId,
368
+ inputTextDelta: params.inputTextDelta
369
+ });
370
+ }
371
+ async writeToolInputAvailable(params) {
372
+ if (this.isCompleted) return;
373
+ this.writer.write({
374
+ type: "tool-input-available",
375
+ toolCallId: params.toolCallId,
376
+ toolName: params.toolName,
377
+ input: params.input,
378
+ ...params.providerMetadata ? { providerMetadata: params.providerMetadata } : {}
379
+ });
380
+ }
381
+ async writeToolOutputAvailable(params) {
382
+ if (this.isCompleted) return;
383
+ this.writer.write({
384
+ type: "tool-output-available",
385
+ toolCallId: params.toolCallId,
386
+ output: params.output
387
+ });
388
+ }
389
+ async writeToolOutputError(params) {
390
+ if (this.isCompleted) return;
391
+ this.writer.write({
392
+ type: "tool-output-error",
393
+ toolCallId: params.toolCallId,
394
+ errorText: params.errorText,
395
+ output: params.output ?? null
396
+ });
397
+ }
398
+ async writeToolApprovalRequest(params) {
399
+ if (this.isCompleted) return;
400
+ this.writer.write({
401
+ type: "tool-approval-request",
402
+ approvalId: params.approvalId,
403
+ toolCallId: params.toolCallId
404
+ });
405
+ }
406
+ async writeToolOutputDenied(params) {
407
+ if (this.isCompleted) return;
408
+ this.writer.write({
409
+ type: "tool-output-denied",
410
+ toolCallId: params.toolCallId
411
+ });
412
+ }
275
413
  async streamData(data) {
276
414
  await this.writeContent(JSON.stringify(data));
277
415
  }
@@ -458,6 +596,7 @@ var BufferingStreamHelper = class {
458
596
  capturedSummaries = [];
459
597
  hasError = false;
460
598
  errorMessage = "";
599
+ setSessionId(_sessionId) {}
461
600
  async writeRole(_role) {}
462
601
  async writeContent(content) {
463
602
  this.capturedText += content;
@@ -487,6 +626,49 @@ var BufferingStreamHelper = class {
487
626
  this.hasError = true;
488
627
  this.errorMessage = typeof error === "string" ? error : error.message;
489
628
  }
629
+ async writeToolInputStart(params) {
630
+ this.capturedData.push({
631
+ type: "tool-input-start",
632
+ ...params
633
+ });
634
+ }
635
+ async writeToolInputDelta(params) {
636
+ this.capturedData.push({
637
+ type: "tool-input-delta",
638
+ ...params
639
+ });
640
+ }
641
+ async writeToolInputAvailable(params) {
642
+ this.capturedData.push({
643
+ type: "tool-input-available",
644
+ ...params
645
+ });
646
+ }
647
+ async writeToolOutputAvailable(params) {
648
+ this.capturedData.push({
649
+ type: "tool-output-available",
650
+ ...params
651
+ });
652
+ }
653
+ async writeToolOutputError(params) {
654
+ this.capturedData.push({
655
+ type: "tool-output-error",
656
+ ...params,
657
+ output: params.output ?? null
658
+ });
659
+ }
660
+ async writeToolApprovalRequest(params) {
661
+ this.capturedData.push({
662
+ type: "tool-approval-request",
663
+ ...params
664
+ });
665
+ }
666
+ async writeToolOutputDenied(params) {
667
+ this.capturedData.push({
668
+ type: "tool-output-denied",
669
+ ...params
670
+ });
671
+ }
490
672
  async complete() {}
491
673
  /**
492
674
  * Get the captured response for non-streaming output
@@ -1,4 +1,4 @@
1
- import * as _inkeep_agents_core3 from "@inkeep/agents-core";
1
+ import * as _inkeep_agents_core1 from "@inkeep/agents-core";
2
2
  import { BreakdownComponentDef, ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown } from "@inkeep/agents-core";
3
3
 
4
4
  //#region src/domains/run/utils/token-estimator.d.ts
@@ -17,7 +17,7 @@ interface AssembleResult {
17
17
  /** The assembled prompt string */
18
18
  prompt: string;
19
19
  /** Token breakdown for each component */
20
- breakdown: _inkeep_agents_core3.ContextBreakdown;
20
+ breakdown: _inkeep_agents_core1.ContextBreakdown;
21
21
  }
22
22
  //#endregion
23
23
  export { AssembleResult, type BreakdownComponentDef, type ContextBreakdown, calculateBreakdownTotal, createEmptyBreakdown, estimateTokens };
package/dist/factory.d.ts CHANGED
@@ -795,25 +795,25 @@ declare function createAgentsAuth(userAuthConfig?: UserAuthConfig): better_auth0
795
795
  ac: better_auth_plugins0.AccessControl;
796
796
  roles: {
797
797
  member: {
798
- 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] | {
799
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
798
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
799
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
800
800
  connector: "OR" | "AND";
801
801
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
802
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
802
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
803
803
  };
804
804
  admin: {
805
- 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] | {
806
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
805
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
806
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
807
807
  connector: "OR" | "AND";
808
808
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
809
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
809
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
810
810
  };
811
811
  owner: {
812
- 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] | {
813
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
812
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
813
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
814
814
  connector: "OR" | "AND";
815
815
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
816
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
816
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
817
817
  };
818
818
  };
819
819
  membershipLimit: number;
@@ -840,13 +840,13 @@ declare function createAgentsAuth(userAuthConfig?: UserAuthConfig): better_auth0
840
840
  user: better_auth0.User & Record<string, any>;
841
841
  organization: better_auth_plugins0.Organization & Record<string, any>;
842
842
  }) => Promise<void>;
843
- afterUpdateMemberRole: ({
843
+ beforeUpdateMemberRole: ({
844
844
  member,
845
845
  organization: org,
846
- previousRole
846
+ newRole
847
847
  }: {
848
848
  member: better_auth_plugins0.Member & Record<string, any>;
849
- previousRole: string;
849
+ newRole: string;
850
850
  user: better_auth0.User & Record<string, any>;
851
851
  organization: better_auth_plugins0.Organization & Record<string, any>;
852
852
  }) => Promise<void>;
@@ -1104,25 +1104,25 @@ declare function createAgentsAuth(userAuthConfig?: UserAuthConfig): better_auth0
1104
1104
  ac: better_auth_plugins0.AccessControl;
1105
1105
  roles: {
1106
1106
  member: {
1107
- 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] | {
1108
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
1107
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1108
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1109
1109
  connector: "OR" | "AND";
1110
1110
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1111
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
1111
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1112
1112
  };
1113
1113
  admin: {
1114
- 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] | {
1115
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
1114
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1115
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1116
1116
  connector: "OR" | "AND";
1117
1117
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1118
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
1118
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1119
1119
  };
1120
1120
  owner: {
1121
- 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] | {
1122
- actions: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>[key];
1121
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key] | {
1122
+ actions: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>[key];
1123
1123
  connector: "OR" | "AND";
1124
1124
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins0.AuthorizeResponse;
1125
- statements: better_auth_plugins0.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins0.Statements>;
1125
+ statements: better_auth_plugins0.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins0.Statements>;
1126
1126
  };
1127
1127
  };
1128
1128
  membershipLimit: number;
@@ -1149,13 +1149,13 @@ declare function createAgentsAuth(userAuthConfig?: UserAuthConfig): better_auth0
1149
1149
  user: better_auth0.User & Record<string, any>;
1150
1150
  organization: better_auth_plugins0.Organization & Record<string, any>;
1151
1151
  }) => Promise<void>;
1152
- afterUpdateMemberRole: ({
1152
+ beforeUpdateMemberRole: ({
1153
1153
  member,
1154
1154
  organization: org,
1155
- previousRole
1155
+ newRole
1156
1156
  }: {
1157
1157
  member: better_auth_plugins0.Member & Record<string, any>;
1158
- previousRole: string;
1158
+ newRole: string;
1159
1159
  user: better_auth0.User & Record<string, any>;
1160
1160
  organization: better_auth_plugins0.Organization & Record<string, any>;
1161
1161
  }) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -796,25 +796,25 @@ declare const auth: better_auth78.Auth<{
796
796
  ac: better_auth_plugins69.AccessControl;
797
797
  roles: {
798
798
  member: {
799
- 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] | {
800
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
799
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
800
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
801
801
  connector: "OR" | "AND";
802
802
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
803
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
803
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
804
804
  };
805
805
  admin: {
806
- 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] | {
807
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
806
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
807
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
808
808
  connector: "OR" | "AND";
809
809
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
810
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
810
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
811
811
  };
812
812
  owner: {
813
- 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] | {
814
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
813
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
814
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
815
815
  connector: "OR" | "AND";
816
816
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
817
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
817
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
818
818
  };
819
819
  };
820
820
  membershipLimit: number;
@@ -841,13 +841,13 @@ declare const auth: better_auth78.Auth<{
841
841
  user: better_auth78.User & Record<string, any>;
842
842
  organization: better_auth_plugins69.Organization & Record<string, any>;
843
843
  }) => Promise<void>;
844
- afterUpdateMemberRole: ({
844
+ beforeUpdateMemberRole: ({
845
845
  member,
846
846
  organization: org,
847
- previousRole
847
+ newRole
848
848
  }: {
849
849
  member: better_auth_plugins69.Member & Record<string, any>;
850
- previousRole: string;
850
+ newRole: string;
851
851
  user: better_auth78.User & Record<string, any>;
852
852
  organization: better_auth_plugins69.Organization & Record<string, any>;
853
853
  }) => Promise<void>;
@@ -1105,25 +1105,25 @@ declare const auth: better_auth78.Auth<{
1105
1105
  ac: better_auth_plugins69.AccessControl;
1106
1106
  roles: {
1107
1107
  member: {
1108
- 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] | {
1109
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
1108
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
1109
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
1110
1110
  connector: "OR" | "AND";
1111
1111
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
1112
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
1112
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
1113
1113
  };
1114
1114
  admin: {
1115
- 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] | {
1116
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
1115
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
1116
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
1117
1117
  connector: "OR" | "AND";
1118
1118
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
1119
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
1119
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
1120
1120
  };
1121
1121
  owner: {
1122
- 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] | {
1123
- actions: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>[key];
1122
+ authorize<K_1 extends "organization" | "member" | "invitation" | "ac" | "project" | "team">(request: K_1 extends infer T extends K ? { [key in T]?: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key] | {
1123
+ actions: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>[key];
1124
1124
  connector: "OR" | "AND";
1125
1125
  } | undefined } : never, connector?: "OR" | "AND"): better_auth_plugins69.AuthorizeResponse;
1126
- statements: better_auth_plugins69.Subset<"organization" | "ac" | "member" | "project" | "team" | "invitation", better_auth_plugins69.Statements>;
1126
+ statements: better_auth_plugins69.Subset<"organization" | "member" | "invitation" | "ac" | "project" | "team", better_auth_plugins69.Statements>;
1127
1127
  };
1128
1128
  };
1129
1129
  membershipLimit: number;
@@ -1150,13 +1150,13 @@ declare const auth: better_auth78.Auth<{
1150
1150
  user: better_auth78.User & Record<string, any>;
1151
1151
  organization: better_auth_plugins69.Organization & Record<string, any>;
1152
1152
  }) => Promise<void>;
1153
- afterUpdateMemberRole: ({
1153
+ beforeUpdateMemberRole: ({
1154
1154
  member,
1155
1155
  organization: org,
1156
- previousRole
1156
+ newRole
1157
1157
  }: {
1158
1158
  member: better_auth_plugins69.Member & Record<string, any>;
1159
- previousRole: string;
1159
+ newRole: string;
1160
1160
  user: better_auth78.User & Record<string, any>;
1161
1161
  organization: better_auth_plugins69.Organization & Record<string, any>;
1162
1162
  }) => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import { getLogger as getLogger$1 } from "./logger.js";
2
2
  import { env } from "./env.js";
3
3
  import runDbClient_default from "./data/db/runDbClient.js";
4
- import { addUserToOrganization, getUserByEmail, upsertOrganization } from "@inkeep/agents-core";
4
+ import { OrgRoles, addUserToOrganization, getUserByEmail, syncOrgMemberToSpiceDb, upsertOrganization } from "@inkeep/agents-core";
5
5
 
6
6
  //#region src/initialization.ts
7
7
  const logger = getLogger$1("initialization");
@@ -45,8 +45,15 @@ async function initializeDefaultUser(authInstance) {
45
45
  await addUserToOrganization(runDbClient_default)({
46
46
  userId: user.id,
47
47
  organizationId: orgId,
48
- role: "owner"
48
+ role: OrgRoles.ADMIN
49
49
  });
50
+ await syncOrgMemberToSpiceDb({
51
+ tenantId: orgId,
52
+ userId: user.id,
53
+ role: OrgRoles.ADMIN,
54
+ action: "add"
55
+ });
56
+ console.log(`🔐 SpiceDB: Synced member ${user.email} as ${OrgRoles.ADMIN} to org ${orgId}`);
50
57
  logger.info({
51
58
  organizationId: orgId,
52
59
  organizationSlug: env.TENANT_ID,
@@ -18,7 +18,7 @@ function isOriginAllowed(origin) {
18
18
  if (!origin) return false;
19
19
  try {
20
20
  const requestUrl = new URL(origin);
21
- const apiUrl = new URL(env.INKEEP_AGENTS_API_URL || `http://localhost:3002`);
21
+ const apiUrl = new URL(env.INKEEP_AGENTS_API_URL || "http://localhost:3002");
22
22
  const uiUrl = env.INKEEP_AGENTS_MANAGE_UI_URL ? new URL(env.INKEEP_AGENTS_MANAGE_UI_URL) : null;
23
23
  if (requestUrl.hostname === "localhost" || requestUrl.hostname === "127.0.0.1") return true;
24
24
  if (uiUrl && requestUrl.hostname === uiUrl.hostname) return true;
@@ -1,4 +1,4 @@
1
- import * as hono1 from "hono";
1
+ import * as hono4 from "hono";
2
2
  import { BaseExecutionContext } from "@inkeep/agents-core";
3
3
  import { createAuth } from "@inkeep/agents-core/auth";
4
4
 
@@ -12,7 +12,7 @@ import { createAuth } from "@inkeep/agents-core/auth";
12
12
  * 3. Database API key
13
13
  * 4. Internal service token
14
14
  */
15
- declare const manageApiKeyAuth: () => hono1.MiddlewareHandler<{
15
+ declare const manageApiKeyAuth: () => hono4.MiddlewareHandler<{
16
16
  Variables: {
17
17
  executionContext: BaseExecutionContext;
18
18
  userId?: string;
@@ -1,16 +1,9 @@
1
1
  import { ManageAppVariables } from "../types/app.js";
2
- import * as hono2 from "hono";
2
+ import * as hono3 from "hono";
3
+ import { ProjectPermissionLevel } from "@inkeep/agents-core";
3
4
 
4
5
  //#region src/middleware/projectAccess.d.ts
5
6
 
6
- /**
7
- * Permission levels for project access
8
- *
9
- * - view: Can see project and resources (read-only)
10
- * - use: Can invoke agents, create API keys, view traces
11
- * - edit: Can modify configurations and manage members
12
- */
13
- type ProjectPermission = 'view' | 'use' | 'edit';
14
7
  /**
15
8
  * Middleware to check project-level access.
16
9
  *
@@ -26,6 +19,6 @@ declare const requireProjectPermission: <Env$1 extends {
26
19
  Variables: ManageAppVariables;
27
20
  } = {
28
21
  Variables: ManageAppVariables;
29
- }>(permission?: ProjectPermission) => hono2.MiddlewareHandler<Env$1, string, {}, Response>;
22
+ }>(permission?: ProjectPermissionLevel) => hono3.MiddlewareHandler<Env$1, string, {}, Response>;
30
23
  //#endregion
31
- export { ProjectPermission, requireProjectPermission };
24
+ export { requireProjectPermission };
@@ -44,7 +44,6 @@ const requireProjectPermission = (permission = "view") => createMiddleware(async
44
44
  switch (permission) {
45
45
  case "view":
46
46
  hasAccess = await canViewProject({
47
- tenantId,
48
47
  userId,
49
48
  projectId,
50
49
  orgRole: tenantRole
@@ -52,7 +51,6 @@ const requireProjectPermission = (permission = "view") => createMiddleware(async
52
51
  break;
53
52
  case "use":
54
53
  hasAccess = await canUseProject({
55
- tenantId,
56
54
  userId,
57
55
  projectId,
58
56
  orgRole: tenantRole
@@ -60,7 +58,6 @@ const requireProjectPermission = (permission = "view") => createMiddleware(async
60
58
  break;
61
59
  case "edit":
62
60
  hasAccess = await canEditProject({
63
- tenantId,
64
61
  userId,
65
62
  projectId,
66
63
  orgRole: tenantRole
@@ -68,20 +65,7 @@ const requireProjectPermission = (permission = "view") => createMiddleware(async
68
65
  break;
69
66
  }
70
67
  if (!hasAccess) {
71
- if (isAuthzEnabled(tenantId) && permission !== "view") {
72
- if (await canViewProject({
73
- tenantId,
74
- userId,
75
- projectId,
76
- orgRole: tenantRole
77
- })) throw createApiError({
78
- code: "forbidden",
79
- message: `Permission denied. Required: project:${permission}`,
80
- instance: c.req.path,
81
- extensions: { requiredPermissions: [`project:${permission}`] }
82
- });
83
- }
84
- if (isAuthzEnabled(tenantId)) throw createApiError({
68
+ if (isAuthzEnabled()) throw createApiError({
85
69
  code: "not_found",
86
70
  message: "Project not found",
87
71
  instance: c.req.path
@@ -1,11 +1,11 @@
1
- import * as hono3 from "hono";
1
+ import * as hono1 from "hono";
2
2
  import { BaseExecutionContext, ResolvedRef } from "@inkeep/agents-core";
3
3
 
4
4
  //#region src/middleware/projectConfig.d.ts
5
5
  /**
6
6
  * Middleware that fetches the full project definition from the Management API
7
7
  */
8
- declare const projectConfigMiddleware: hono3.MiddlewareHandler<{
8
+ declare const projectConfigMiddleware: hono1.MiddlewareHandler<{
9
9
  Variables: {
10
10
  executionContext: BaseExecutionContext;
11
11
  resolvedRef: ResolvedRef;
@@ -15,7 +15,7 @@ declare const projectConfigMiddleware: hono3.MiddlewareHandler<{
15
15
  * Creates a middleware that applies project config fetching except for specified route patterns
16
16
  * @param skipRouteCheck - Function that returns true if the route should skip the middleware
17
17
  */
18
- declare const projectConfigMiddlewareExcept: (skipRouteCheck: (path: string) => boolean) => hono3.MiddlewareHandler<{
18
+ declare const projectConfigMiddlewareExcept: (skipRouteCheck: (path: string) => boolean) => hono1.MiddlewareHandler<{
19
19
  Variables: {
20
20
  executionContext: BaseExecutionContext;
21
21
  resolvedRef: ResolvedRef;
@@ -1,5 +1,5 @@
1
1
  import { ManageAppVariables } from "../types/app.js";
2
- import * as hono5 from "hono";
2
+ import * as hono14 from "hono";
3
3
 
4
4
  //#region src/middleware/requirePermission.d.ts
5
5
  type Permission = {
@@ -9,6 +9,6 @@ declare const requirePermission: <Env$1 extends {
9
9
  Variables: ManageAppVariables;
10
10
  } = {
11
11
  Variables: ManageAppVariables;
12
- }>(permissions: Permission) => hono5.MiddlewareHandler<Env$1, string, {}, Response>;
12
+ }>(permissions: Permission) => hono14.MiddlewareHandler<Env$1, string, {}, Response>;
13
13
  //#endregion
14
14
  export { requirePermission };