@inkeep/agents-core 0.9.0 → 0.10.1
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/client-exports.d.cts +7 -7
- package/dist/client-exports.d.ts +7 -7
- package/dist/db/schema.d.cts +2 -2
- package/dist/db/schema.d.ts +2 -2
- package/dist/index.cjs +192 -73
- package/dist/index.d.cts +135 -156
- package/dist/index.d.ts +135 -156
- package/dist/index.js +193 -73
- package/dist/{schema-B0z-X5Hq.d.cts → schema-BXVLXPQq.d.cts} +1 -1
- package/dist/{schema-BQoMyAN6.d.ts → schema-D66X7wP_.d.ts} +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/validation/index.d.cts +2 -2
- package/dist/validation/index.d.ts +2 -2
- package/package.json +4 -2
- package/dist/{utility-8RXSemmL.d.cts → utility-D7QP8MkV.d.cts} +163 -163
- package/dist/{utility-8RXSemmL.d.ts → utility-D7QP8MkV.d.ts} +163 -163
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-
|
|
3
|
-
export { d as AgentStopWhen, a as AgentStopWhenSchema, e as CredentialStoreType, c as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, b as StopWhen, S as StopWhenSchema } from './utility-
|
|
2
|
+
import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-D7QP8MkV.cjs';
|
|
3
|
+
export { d as AgentStopWhen, a as AgentStopWhenSchema, e as CredentialStoreType, c as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, b as StopWhen, S as StopWhenSchema } from './utility-D7QP8MkV.cjs';
|
|
4
4
|
import 'drizzle-zod';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
|
6
6
|
import '@hono/zod-openapi';
|
|
@@ -67,8 +67,8 @@ declare const AgentApiInsertSchema: z.ZodObject<{
|
|
|
67
67
|
canTransferTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
68
|
canDelegateTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
69
|
type: z.ZodOptional<z.ZodEnum<{
|
|
70
|
-
internal: "internal";
|
|
71
70
|
external: "external";
|
|
71
|
+
internal: "internal";
|
|
72
72
|
}>>;
|
|
73
73
|
}, z.core.$strip>;
|
|
74
74
|
declare const ToolApiInsertSchema: z.ZodObject<{
|
|
@@ -168,13 +168,11 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
|
|
|
168
168
|
description: z.ZodOptional<z.ZodString>;
|
|
169
169
|
defaultAgentId: z.ZodOptional<z.ZodString>;
|
|
170
170
|
agents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
171
|
-
id: z.ZodString;
|
|
172
171
|
name: z.ZodString;
|
|
173
|
-
|
|
174
|
-
prompt: z.ZodString;
|
|
172
|
+
id: z.ZodString;
|
|
175
173
|
createdAt: z.ZodOptional<z.ZodString>;
|
|
176
174
|
updatedAt: z.ZodOptional<z.ZodString>;
|
|
177
|
-
|
|
175
|
+
description: z.ZodString;
|
|
178
176
|
models: z.ZodOptional<z.ZodObject<{
|
|
179
177
|
base: z.ZodOptional<z.ZodObject<{
|
|
180
178
|
model: z.ZodOptional<z.ZodString>;
|
|
@@ -198,6 +196,8 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
|
|
|
198
196
|
}, {
|
|
199
197
|
stepCountIs?: number | undefined;
|
|
200
198
|
}>>>>;
|
|
199
|
+
prompt: z.ZodString;
|
|
200
|
+
conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
|
|
201
201
|
type: z.ZodLiteral<"internal">;
|
|
202
202
|
canUse: z.ZodArray<z.ZodObject<{
|
|
203
203
|
agentToolRelationId: z.ZodOptional<z.ZodString>;
|
package/dist/client-exports.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-
|
|
3
|
-
export { d as AgentStopWhen, a as AgentStopWhenSchema, e as CredentialStoreType, c as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, b as StopWhen, S as StopWhenSchema } from './utility-
|
|
2
|
+
import { C as ConversationHistoryConfig, A as ApiKeyApiUpdateSchema, F as FullGraphAgentInsertSchema } from './utility-D7QP8MkV.js';
|
|
3
|
+
export { d as AgentStopWhen, a as AgentStopWhenSchema, e as CredentialStoreType, c as GraphStopWhen, G as GraphStopWhenSchema, M as MCPTransportType, b as StopWhen, S as StopWhenSchema } from './utility-D7QP8MkV.js';
|
|
4
4
|
import 'drizzle-zod';
|
|
5
5
|
import 'drizzle-orm/sqlite-core';
|
|
6
6
|
import '@hono/zod-openapi';
|
|
@@ -67,8 +67,8 @@ declare const AgentApiInsertSchema: z.ZodObject<{
|
|
|
67
67
|
canTransferTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
68
|
canDelegateTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
69
|
type: z.ZodOptional<z.ZodEnum<{
|
|
70
|
-
internal: "internal";
|
|
71
70
|
external: "external";
|
|
71
|
+
internal: "internal";
|
|
72
72
|
}>>;
|
|
73
73
|
}, z.core.$strip>;
|
|
74
74
|
declare const ToolApiInsertSchema: z.ZodObject<{
|
|
@@ -168,13 +168,11 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
|
|
|
168
168
|
description: z.ZodOptional<z.ZodString>;
|
|
169
169
|
defaultAgentId: z.ZodOptional<z.ZodString>;
|
|
170
170
|
agents: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
171
|
-
id: z.ZodString;
|
|
172
171
|
name: z.ZodString;
|
|
173
|
-
|
|
174
|
-
prompt: z.ZodString;
|
|
172
|
+
id: z.ZodString;
|
|
175
173
|
createdAt: z.ZodOptional<z.ZodString>;
|
|
176
174
|
updatedAt: z.ZodOptional<z.ZodString>;
|
|
177
|
-
|
|
175
|
+
description: z.ZodString;
|
|
178
176
|
models: z.ZodOptional<z.ZodObject<{
|
|
179
177
|
base: z.ZodOptional<z.ZodObject<{
|
|
180
178
|
model: z.ZodOptional<z.ZodString>;
|
|
@@ -198,6 +196,8 @@ declare const FullGraphDefinitionSchema: z.ZodObject<{
|
|
|
198
196
|
}, {
|
|
199
197
|
stepCountIs?: number | undefined;
|
|
200
198
|
}>>>>;
|
|
199
|
+
prompt: z.ZodString;
|
|
200
|
+
conversationHistoryConfig: z.ZodOptional<z.ZodNullable<z.ZodType<ConversationHistoryConfig, ConversationHistoryConfig, z.core.$ZodTypeInternals<ConversationHistoryConfig, ConversationHistoryConfig>>>>;
|
|
201
201
|
type: z.ZodLiteral<"internal">;
|
|
202
202
|
canUse: z.ZodArray<z.ZodObject<{
|
|
203
203
|
agentToolRelationId: z.ZodOptional<z.ZodString>;
|
package/dist/db/schema.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'drizzle-orm';
|
|
2
2
|
import 'drizzle-orm/sqlite-core';
|
|
3
|
-
import '../utility-
|
|
4
|
-
export { k as agentArtifactComponents, O as agentArtifactComponentsRelations, i as agentDataComponents, Q as agentDataComponentsRelations, a as agentGraph, F as agentGraphRelations, e as agentRelations, S as agentRelationsRelations, m as agentToolRelations, I as agentToolRelationsRelations, d as agents, E as agentsRelations, r as apiKeys, H as apiKeysRelations, j as artifactComponents, N as artifactComponentsRelations, b as contextCache, D as contextCacheRelations, c as contextConfigs, C as contextConfigsRelations, n as conversations, L as conversationsRelations, u as credentialReferences, J as credentialReferencesRelations, h as dataComponents, P as dataComponentsRelations, f as externalAgents, G as externalAgentsRelations, q as ledgerArtifacts, x as ledgerArtifactsContextIdIdx, R as ledgerArtifactsRelations, y as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, w as ledgerArtifactsToolCallIdIdx, o as messages, M as messagesRelations, p as projects, A as projectsRelations, g as taskRelations, B as taskRelationsRelations, t as tasks, z as tasksRelations, l as tools, K as toolsRelations } from '../schema-
|
|
3
|
+
import '../utility-D7QP8MkV.cjs';
|
|
4
|
+
export { k as agentArtifactComponents, O as agentArtifactComponentsRelations, i as agentDataComponents, Q as agentDataComponentsRelations, a as agentGraph, F as agentGraphRelations, e as agentRelations, S as agentRelationsRelations, m as agentToolRelations, I as agentToolRelationsRelations, d as agents, E as agentsRelations, r as apiKeys, H as apiKeysRelations, j as artifactComponents, N as artifactComponentsRelations, b as contextCache, D as contextCacheRelations, c as contextConfigs, C as contextConfigsRelations, n as conversations, L as conversationsRelations, u as credentialReferences, J as credentialReferencesRelations, h as dataComponents, P as dataComponentsRelations, f as externalAgents, G as externalAgentsRelations, q as ledgerArtifacts, x as ledgerArtifactsContextIdIdx, R as ledgerArtifactsRelations, y as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, w as ledgerArtifactsToolCallIdIdx, o as messages, M as messagesRelations, p as projects, A as projectsRelations, g as taskRelations, B as taskRelationsRelations, t as tasks, z as tasksRelations, l as tools, K as toolsRelations } from '../schema-BXVLXPQq.cjs';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'drizzle-zod';
|
|
7
7
|
import '@hono/zod-openapi';
|
package/dist/db/schema.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'drizzle-orm';
|
|
2
2
|
import 'drizzle-orm/sqlite-core';
|
|
3
|
-
import '../utility-
|
|
4
|
-
export { k as agentArtifactComponents, O as agentArtifactComponentsRelations, i as agentDataComponents, Q as agentDataComponentsRelations, a as agentGraph, F as agentGraphRelations, e as agentRelations, S as agentRelationsRelations, m as agentToolRelations, I as agentToolRelationsRelations, d as agents, E as agentsRelations, r as apiKeys, H as apiKeysRelations, j as artifactComponents, N as artifactComponentsRelations, b as contextCache, D as contextCacheRelations, c as contextConfigs, C as contextConfigsRelations, n as conversations, L as conversationsRelations, u as credentialReferences, J as credentialReferencesRelations, h as dataComponents, P as dataComponentsRelations, f as externalAgents, G as externalAgentsRelations, q as ledgerArtifacts, x as ledgerArtifactsContextIdIdx, R as ledgerArtifactsRelations, y as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, w as ledgerArtifactsToolCallIdIdx, o as messages, M as messagesRelations, p as projects, A as projectsRelations, g as taskRelations, B as taskRelationsRelations, t as tasks, z as tasksRelations, l as tools, K as toolsRelations } from '../schema-
|
|
3
|
+
import '../utility-D7QP8MkV.js';
|
|
4
|
+
export { k as agentArtifactComponents, O as agentArtifactComponentsRelations, i as agentDataComponents, Q as agentDataComponentsRelations, a as agentGraph, F as agentGraphRelations, e as agentRelations, S as agentRelationsRelations, m as agentToolRelations, I as agentToolRelationsRelations, d as agents, E as agentsRelations, r as apiKeys, H as apiKeysRelations, j as artifactComponents, N as artifactComponentsRelations, b as contextCache, D as contextCacheRelations, c as contextConfigs, C as contextConfigsRelations, n as conversations, L as conversationsRelations, u as credentialReferences, J as credentialReferencesRelations, h as dataComponents, P as dataComponentsRelations, f as externalAgents, G as externalAgentsRelations, q as ledgerArtifacts, x as ledgerArtifactsContextIdIdx, R as ledgerArtifactsRelations, y as ledgerArtifactsTaskContextNameUnique, v as ledgerArtifactsTaskIdIdx, w as ledgerArtifactsToolCallIdIdx, o as messages, M as messagesRelations, p as projects, A as projectsRelations, g as taskRelations, B as taskRelationsRelations, t as tasks, z as tasksRelations, l as tools, K as toolsRelations } from '../schema-D66X7wP_.js';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import 'drizzle-zod';
|
|
7
7
|
import '@hono/zod-openapi';
|
package/dist/index.cjs
CHANGED
|
@@ -9046,7 +9046,42 @@ var ContextResolver = class {
|
|
|
9046
9046
|
* Resolve a single context variable
|
|
9047
9047
|
*/
|
|
9048
9048
|
async resolveSingleFetchDefinition(contextConfig2, definition, templateKey, options, requestHash, result) {
|
|
9049
|
-
|
|
9049
|
+
const cachedEntry = await this.cache.get({
|
|
9050
|
+
conversationId: options.conversationId,
|
|
9051
|
+
contextConfigId: contextConfig2.id,
|
|
9052
|
+
contextVariableKey: templateKey,
|
|
9053
|
+
requestHash
|
|
9054
|
+
});
|
|
9055
|
+
if (cachedEntry) {
|
|
9056
|
+
result.resolvedContext[templateKey] = cachedEntry.value;
|
|
9057
|
+
result.cacheHits.push(definition.id);
|
|
9058
|
+
logger7.debug(
|
|
9059
|
+
{
|
|
9060
|
+
definitionId: definition.id,
|
|
9061
|
+
templateKey,
|
|
9062
|
+
conversationId: options.conversationId
|
|
9063
|
+
},
|
|
9064
|
+
"Cache hit for context variable"
|
|
9065
|
+
);
|
|
9066
|
+
return;
|
|
9067
|
+
}
|
|
9068
|
+
result.cacheMisses.push(definition.id);
|
|
9069
|
+
logger7.debug(
|
|
9070
|
+
{
|
|
9071
|
+
definitionId: definition.id,
|
|
9072
|
+
templateKey,
|
|
9073
|
+
conversationId: options.conversationId
|
|
9074
|
+
},
|
|
9075
|
+
"Cache miss for context variable, fetching data"
|
|
9076
|
+
);
|
|
9077
|
+
const definitionWithConversationId = {
|
|
9078
|
+
...definition,
|
|
9079
|
+
fetchConfig: {
|
|
9080
|
+
...definition.fetchConfig,
|
|
9081
|
+
conversationId: options.conversationId
|
|
9082
|
+
}
|
|
9083
|
+
};
|
|
9084
|
+
const fetchedData = await tracer.startActiveSpan(
|
|
9050
9085
|
"context-resolver.resolve_single_fetch_definition",
|
|
9051
9086
|
{
|
|
9052
9087
|
attributes: {
|
|
@@ -9059,78 +9094,17 @@ var ContextResolver = class {
|
|
|
9059
9094
|
},
|
|
9060
9095
|
async (parentSpan) => {
|
|
9061
9096
|
try {
|
|
9062
|
-
const
|
|
9063
|
-
conversationId: options.conversationId,
|
|
9064
|
-
contextConfigId: contextConfig2.id,
|
|
9065
|
-
contextVariableKey: templateKey,
|
|
9066
|
-
requestHash
|
|
9067
|
-
});
|
|
9068
|
-
if (cachedEntry) {
|
|
9069
|
-
result.resolvedContext[templateKey] = cachedEntry.value;
|
|
9070
|
-
result.cacheHits.push(definition.id);
|
|
9071
|
-
parentSpan.setStatus({ code: api.SpanStatusCode.OK });
|
|
9072
|
-
parentSpan.addEvent("context.cache_hit", {
|
|
9073
|
-
definition_id: definition.id,
|
|
9074
|
-
template_key: templateKey
|
|
9075
|
-
});
|
|
9076
|
-
logger7.debug(
|
|
9077
|
-
{
|
|
9078
|
-
definitionId: definition.id,
|
|
9079
|
-
templateKey,
|
|
9080
|
-
conversationId: options.conversationId
|
|
9081
|
-
},
|
|
9082
|
-
"Cache hit for context variable"
|
|
9083
|
-
);
|
|
9084
|
-
return;
|
|
9085
|
-
}
|
|
9086
|
-
result.cacheMisses.push(definition.id);
|
|
9087
|
-
parentSpan.addEvent("context.cache_miss", {
|
|
9088
|
-
definition_id: definition.id,
|
|
9089
|
-
template_key: templateKey
|
|
9090
|
-
});
|
|
9091
|
-
logger7.debug(
|
|
9092
|
-
{
|
|
9093
|
-
definitionId: definition.id,
|
|
9094
|
-
templateKey,
|
|
9095
|
-
conversationId: options.conversationId
|
|
9096
|
-
},
|
|
9097
|
-
"Cache miss for context variable, fetching data"
|
|
9098
|
-
);
|
|
9099
|
-
const definitionWithConversationId = {
|
|
9100
|
-
...definition,
|
|
9101
|
-
fetchConfig: {
|
|
9102
|
-
...definition.fetchConfig,
|
|
9103
|
-
conversationId: options.conversationId
|
|
9104
|
-
}
|
|
9105
|
-
};
|
|
9106
|
-
const fetchedData = await this.fetcher.fetch(
|
|
9097
|
+
const data = await this.fetcher.fetch(
|
|
9107
9098
|
definitionWithConversationId,
|
|
9108
9099
|
result.resolvedContext
|
|
9109
9100
|
);
|
|
9110
|
-
result.resolvedContext[templateKey] = fetchedData;
|
|
9111
|
-
result.fetchedDefinitions.push(definition.id);
|
|
9112
|
-
await this.cache.set({
|
|
9113
|
-
contextConfigId: contextConfig2.id,
|
|
9114
|
-
contextVariableKey: templateKey,
|
|
9115
|
-
conversationId: options.conversationId,
|
|
9116
|
-
value: fetchedData,
|
|
9117
|
-
requestHash,
|
|
9118
|
-
tenantId: this.tenantId
|
|
9119
|
-
});
|
|
9120
9101
|
parentSpan.setStatus({ code: api.SpanStatusCode.OK });
|
|
9121
9102
|
parentSpan.addEvent("context.fetch_success", {
|
|
9122
9103
|
definition_id: definition.id,
|
|
9123
9104
|
template_key: templateKey,
|
|
9124
9105
|
source: definition.fetchConfig.url
|
|
9125
9106
|
});
|
|
9126
|
-
|
|
9127
|
-
{
|
|
9128
|
-
definitionId: definition.id,
|
|
9129
|
-
templateKey,
|
|
9130
|
-
conversationId: options.conversationId
|
|
9131
|
-
},
|
|
9132
|
-
"Context variable resolved and cached"
|
|
9133
|
-
);
|
|
9107
|
+
return data;
|
|
9134
9108
|
} catch (error) {
|
|
9135
9109
|
setSpanWithError(parentSpan, error);
|
|
9136
9110
|
throw error;
|
|
@@ -9139,6 +9113,24 @@ var ContextResolver = class {
|
|
|
9139
9113
|
}
|
|
9140
9114
|
}
|
|
9141
9115
|
);
|
|
9116
|
+
result.resolvedContext[templateKey] = fetchedData;
|
|
9117
|
+
result.fetchedDefinitions.push(definition.id);
|
|
9118
|
+
await this.cache.set({
|
|
9119
|
+
contextConfigId: contextConfig2.id,
|
|
9120
|
+
contextVariableKey: templateKey,
|
|
9121
|
+
conversationId: options.conversationId,
|
|
9122
|
+
value: fetchedData,
|
|
9123
|
+
requestHash,
|
|
9124
|
+
tenantId: this.tenantId
|
|
9125
|
+
});
|
|
9126
|
+
logger7.debug(
|
|
9127
|
+
{
|
|
9128
|
+
definitionId: definition.id,
|
|
9129
|
+
templateKey,
|
|
9130
|
+
conversationId: options.conversationId
|
|
9131
|
+
},
|
|
9132
|
+
"Context variable resolved and cached"
|
|
9133
|
+
);
|
|
9142
9134
|
}
|
|
9143
9135
|
/**
|
|
9144
9136
|
* Resolve the request context for a given conversation
|
|
@@ -10406,14 +10398,31 @@ var NangoCredentialStore = class {
|
|
|
10406
10398
|
if (!isSupportedAuthMode(type)) {
|
|
10407
10399
|
return null;
|
|
10408
10400
|
}
|
|
10401
|
+
const extractAccessTokenForBearerType = (tokenString) => {
|
|
10402
|
+
if (tokenString && typeof tokenString === "string") {
|
|
10403
|
+
try {
|
|
10404
|
+
const parsedToken = JSON.parse(tokenString);
|
|
10405
|
+
if (parsedToken.access_token && typeof parsedToken.access_token === "string") {
|
|
10406
|
+
return parsedToken.access_token;
|
|
10407
|
+
}
|
|
10408
|
+
} catch {
|
|
10409
|
+
}
|
|
10410
|
+
return tokenString;
|
|
10411
|
+
}
|
|
10412
|
+
return void 0;
|
|
10413
|
+
};
|
|
10409
10414
|
switch (type) {
|
|
10410
10415
|
case "API_KEY":
|
|
10411
10416
|
return {
|
|
10412
|
-
token:
|
|
10417
|
+
token: extractAccessTokenForBearerType(
|
|
10418
|
+
credentials.apiKey || credentials.api_key
|
|
10419
|
+
)
|
|
10413
10420
|
};
|
|
10414
10421
|
case "APP":
|
|
10415
10422
|
return {
|
|
10416
|
-
token:
|
|
10423
|
+
token: extractAccessTokenForBearerType(
|
|
10424
|
+
credentials.accessToken || credentials.access_token
|
|
10425
|
+
)
|
|
10417
10426
|
};
|
|
10418
10427
|
case "BASIC":
|
|
10419
10428
|
return {
|
|
@@ -10424,7 +10433,7 @@ var NangoCredentialStore = class {
|
|
|
10424
10433
|
return credentials.raw;
|
|
10425
10434
|
case "JWT":
|
|
10426
10435
|
return {
|
|
10427
|
-
token: credentials.token
|
|
10436
|
+
token: extractAccessTokenForBearerType(credentials.token)
|
|
10428
10437
|
};
|
|
10429
10438
|
case "OAUTH1":
|
|
10430
10439
|
return {
|
|
@@ -10433,12 +10442,12 @@ var NangoCredentialStore = class {
|
|
|
10433
10442
|
};
|
|
10434
10443
|
case "OAUTH2":
|
|
10435
10444
|
return {
|
|
10436
|
-
token: credentials.access_token,
|
|
10445
|
+
token: extractAccessTokenForBearerType(credentials.access_token),
|
|
10437
10446
|
refresh_token: credentials.refresh_token
|
|
10438
10447
|
};
|
|
10439
10448
|
case "OAUTH2_CC":
|
|
10440
10449
|
return {
|
|
10441
|
-
token: credentials.token,
|
|
10450
|
+
token: extractAccessTokenForBearerType(credentials.token),
|
|
10442
10451
|
client_certificate: credentials.client_certificate,
|
|
10443
10452
|
client_id: credentials.client_id,
|
|
10444
10453
|
client_private_key: credentials.client_private_key,
|
|
@@ -10464,6 +10473,104 @@ var NangoCredentialStore = class {
|
|
|
10464
10473
|
}
|
|
10465
10474
|
return result;
|
|
10466
10475
|
}
|
|
10476
|
+
/**
|
|
10477
|
+
* Fetch a specific Nango integration
|
|
10478
|
+
*/
|
|
10479
|
+
async fetchNangoIntegration(uniqueKey) {
|
|
10480
|
+
try {
|
|
10481
|
+
const response = await this.nangoClient.getIntegration(
|
|
10482
|
+
{ uniqueKey },
|
|
10483
|
+
{ include: ["credentials"] }
|
|
10484
|
+
);
|
|
10485
|
+
const integration = response.data;
|
|
10486
|
+
let areCredentialsSet = false;
|
|
10487
|
+
if (integration.credentials?.type === "OAUTH2" || integration.credentials?.type === "OAUTH1" || integration.credentials?.type === "TBA") {
|
|
10488
|
+
areCredentialsSet = !!(integration.credentials?.client_id && integration.credentials?.client_secret);
|
|
10489
|
+
} else if (integration.credentials?.type === "APP") {
|
|
10490
|
+
areCredentialsSet = !!(integration.credentials?.app_id && integration.credentials?.app_link);
|
|
10491
|
+
} else {
|
|
10492
|
+
areCredentialsSet = true;
|
|
10493
|
+
}
|
|
10494
|
+
const { credentials: _credentials, ...integrationWithoutCredentials } = integration;
|
|
10495
|
+
return {
|
|
10496
|
+
...integrationWithoutCredentials,
|
|
10497
|
+
areCredentialsSet
|
|
10498
|
+
};
|
|
10499
|
+
} catch (error) {
|
|
10500
|
+
if (error && typeof error === "object" && "status" in error && error.status === 404) {
|
|
10501
|
+
return null;
|
|
10502
|
+
}
|
|
10503
|
+
console.error(`Failed to fetch integration ${uniqueKey}:`, error);
|
|
10504
|
+
return null;
|
|
10505
|
+
}
|
|
10506
|
+
}
|
|
10507
|
+
/**
|
|
10508
|
+
* Create an API key credential by setting up Nango integration and importing the connection
|
|
10509
|
+
*/
|
|
10510
|
+
async createNangoApiKeyConnection({
|
|
10511
|
+
name,
|
|
10512
|
+
apiKeyToSet,
|
|
10513
|
+
metadata
|
|
10514
|
+
}) {
|
|
10515
|
+
const provider = "private-api-bearer";
|
|
10516
|
+
try {
|
|
10517
|
+
let integration;
|
|
10518
|
+
try {
|
|
10519
|
+
const response2 = await this.nangoClient.createIntegration({
|
|
10520
|
+
provider,
|
|
10521
|
+
unique_key: name,
|
|
10522
|
+
display_name: name
|
|
10523
|
+
});
|
|
10524
|
+
integration = response2.data;
|
|
10525
|
+
} catch (error) {
|
|
10526
|
+
const existingIntegration = await this.fetchNangoIntegration(name);
|
|
10527
|
+
if (existingIntegration) {
|
|
10528
|
+
integration = existingIntegration;
|
|
10529
|
+
} else {
|
|
10530
|
+
console.log(`Integration creation failed for unexpected reasons`, error);
|
|
10531
|
+
}
|
|
10532
|
+
}
|
|
10533
|
+
if (!integration) {
|
|
10534
|
+
throw new Error(`Integration '${name}' not found`);
|
|
10535
|
+
}
|
|
10536
|
+
const importConnectionUrl = `${process.env.NANGO_SERVER_URL || "https://api.nango.dev"}/connections`;
|
|
10537
|
+
const credentials = {
|
|
10538
|
+
type: "API_KEY",
|
|
10539
|
+
apiKey: apiKeyToSet
|
|
10540
|
+
};
|
|
10541
|
+
const body = {
|
|
10542
|
+
provider_config_key: integration.unique_key,
|
|
10543
|
+
connection_id: name,
|
|
10544
|
+
metadata,
|
|
10545
|
+
credentials
|
|
10546
|
+
};
|
|
10547
|
+
const response = await fetch(importConnectionUrl, {
|
|
10548
|
+
method: "POST",
|
|
10549
|
+
headers: {
|
|
10550
|
+
Authorization: `Bearer ${process.env.NANGO_SECRET_KEY}`,
|
|
10551
|
+
"Content-Type": "application/json"
|
|
10552
|
+
},
|
|
10553
|
+
body: JSON.stringify(body)
|
|
10554
|
+
});
|
|
10555
|
+
if (!response.ok) {
|
|
10556
|
+
throw new Error(
|
|
10557
|
+
`Failed to import connection: HTTP ${response.status} - ${response.statusText}`
|
|
10558
|
+
);
|
|
10559
|
+
}
|
|
10560
|
+
} catch (error) {
|
|
10561
|
+
console.error("Unexpected error creating API key credential:", error);
|
|
10562
|
+
logger11.error(
|
|
10563
|
+
{
|
|
10564
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
10565
|
+
name
|
|
10566
|
+
},
|
|
10567
|
+
`Unexpected error creating API key credential '${name}'`
|
|
10568
|
+
);
|
|
10569
|
+
throw new Error(
|
|
10570
|
+
`Failed to create API key credential '${name}': ${error instanceof Error ? error.message : "Unknown error"}`
|
|
10571
|
+
);
|
|
10572
|
+
}
|
|
10573
|
+
}
|
|
10467
10574
|
/**
|
|
10468
10575
|
* Fetch credentials from Nango API using connection information
|
|
10469
10576
|
* @param connectionId - The connection ID for the Nango connection
|
|
@@ -10553,8 +10660,12 @@ var NangoCredentialStore = class {
|
|
|
10553
10660
|
/**
|
|
10554
10661
|
* Set credentials - not supported for Nango (OAuth flow handles this)
|
|
10555
10662
|
*/
|
|
10556
|
-
async set(
|
|
10557
|
-
|
|
10663
|
+
async set(key, value) {
|
|
10664
|
+
await this.createNangoApiKeyConnection({
|
|
10665
|
+
name: key,
|
|
10666
|
+
apiKeyToSet: value,
|
|
10667
|
+
metadata: {}
|
|
10668
|
+
});
|
|
10558
10669
|
}
|
|
10559
10670
|
/**
|
|
10560
10671
|
* Check if credentials exist by attempting to fetch them
|
|
@@ -10648,7 +10759,16 @@ function createDefaultCredentialStores() {
|
|
|
10648
10759
|
})
|
|
10649
10760
|
);
|
|
10650
10761
|
}
|
|
10651
|
-
|
|
10762
|
+
if (process.env.ENABLE_KEYCHAIN_STORE === "true") {
|
|
10763
|
+
try {
|
|
10764
|
+
stores.push(createKeyChainStore("keychain-default"));
|
|
10765
|
+
} catch (error) {
|
|
10766
|
+
console.warn(
|
|
10767
|
+
"Failed to create keychain store:",
|
|
10768
|
+
error instanceof Error ? error.message : error
|
|
10769
|
+
);
|
|
10770
|
+
}
|
|
10771
|
+
}
|
|
10652
10772
|
return stores;
|
|
10653
10773
|
}
|
|
10654
10774
|
var loadEnvironmentFiles = () => {
|
|
@@ -10968,7 +11088,6 @@ exports.createExternalAgentRelation = createExternalAgentRelation;
|
|
|
10968
11088
|
exports.createFullGraphServerSide = createFullGraphServerSide;
|
|
10969
11089
|
exports.createFullProjectServerSide = createFullProjectServerSide;
|
|
10970
11090
|
exports.createInMemoryDatabaseClient = createInMemoryDatabaseClient;
|
|
10971
|
-
exports.createKeyChainStore = createKeyChainStore;
|
|
10972
11091
|
exports.createMessage = createMessage;
|
|
10973
11092
|
exports.createNangoCredentialStore = createNangoCredentialStore;
|
|
10974
11093
|
exports.createOrGetConversation = createOrGetConversation;
|