@inkeep/agents-core 0.65.1 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/rolldown_runtime.js +25 -1
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/constants/index.d.ts +14 -0
- package/dist/constants/index.js +15 -0
- package/dist/constants/relation-types.d.ts +5 -0
- package/dist/constants/relation-types.js +6 -0
- package/dist/constants/session-events.d.ts +13 -0
- package/dist/constants/session-events.js +14 -0
- package/dist/constants/tool-names.d.ts +7 -0
- package/dist/constants/tool-names.js +8 -0
- package/dist/constants/workflow.d.ts +7 -0
- package/dist/constants/workflow.js +8 -0
- package/dist/data-access/index.d.ts +3 -3
- package/dist/data-access/manage/agentFull.d.ts +7 -10
- package/dist/data-access/manage/agentFull.js +26 -28
- package/dist/data-access/manage/agents.d.ts +47 -47
- package/dist/data-access/manage/artifactComponents.d.ts +10 -10
- package/dist/data-access/manage/contextConfigs.d.ts +12 -12
- package/dist/data-access/manage/dataComponents.d.ts +4 -4
- package/dist/data-access/manage/dataComponents.js +1 -1
- package/dist/data-access/manage/functionTools.d.ts +16 -16
- package/dist/data-access/manage/projectFull.d.ts +6 -8
- package/dist/data-access/manage/projectFull.js +18 -18
- package/dist/data-access/manage/skills.d.ts +12 -12
- package/dist/data-access/manage/subAgentExternalAgentRelations.d.ts +24 -24
- package/dist/data-access/manage/subAgentRelations.d.ts +20 -20
- package/dist/data-access/manage/subAgentTeamAgentRelations.d.ts +18 -18
- package/dist/data-access/manage/subAgents.d.ts +21 -21
- package/dist/data-access/manage/tools.d.ts +24 -24
- package/dist/data-access/manage/triggers.d.ts +4 -4
- package/dist/data-access/runtime/apiKeys.d.ts +16 -16
- package/dist/data-access/runtime/apps.d.ts +10 -10
- package/dist/data-access/runtime/conversations.d.ts +24 -24
- package/dist/data-access/runtime/feedback.d.ts +4 -4
- package/dist/data-access/runtime/messages.d.ts +12 -12
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +4 -4
- package/dist/data-access/runtime/scheduledTriggerUsers.d.ts +1 -1
- package/dist/data-access/runtime/tasks.d.ts +5 -5
- package/dist/db/manage/dolt-safe-jsonb.d.ts +2 -2
- package/dist/db/manage/manage-client.js +15 -3
- package/dist/db/manage/manage-schema.d.ts +358 -358
- package/dist/db/runtime/runtime-client.js +7 -1
- package/dist/db/runtime/runtime-schema.d.ts +373 -373
- package/dist/dolt/merge.js +7 -9
- package/dist/dolt/ref-middleware.js +2 -2
- package/dist/dolt/ref-scope.js +9 -3
- package/dist/index.d.ts +9 -5
- package/dist/index.js +7 -3
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +77 -0
- package/dist/node_modules/.pnpm/@vitest_expect@3.2.4/node_modules/@vitest/expect/dist/index.js +1356 -0
- package/dist/node_modules/.pnpm/@vitest_pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.js +1119 -0
- package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js +982 -0
- package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/index.js +4 -0
- package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/utils.js +3 -0
- package/dist/node_modules/.pnpm/@vitest_snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.js +1821 -0
- package/dist/node_modules/.pnpm/@vitest_spy@3.2.4/node_modules/@vitest/spy/dist/index.js +171 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +124 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/diff.js +1334 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/error.js +105 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/helpers.js +118 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/index.js +455 -0
- package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/source-map.js +168 -0
- package/dist/node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js +3087 -0
- package/dist/node_modules/.pnpm/js-tokens@9.0.1/node_modules/js-tokens/index.js +384 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +11 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +16 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +11 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +15 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +13 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +34 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +12 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +122 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +39 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +99 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +25 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +14 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +21 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +6 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +12 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +18 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +25 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +8 -0
- package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +30 -0
- package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +939 -0
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +81 -0
- package/dist/node_modules/.pnpm/strip-literal@3.1.0/node_modules/strip-literal/dist/index.js +51 -0
- package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +81 -0
- package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js +9 -0
- package/dist/node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js +125 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@edge-runtime_vm@3.2.0_@types_debug@4.1.12_@types_node@20.19.27_jiti@2.6.1_93023d256ff9ed909ae8f0d436c922a0/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js +8 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@edge-runtime_vm@3.2.0_@types_debug@4.1.12_@types_node@20.19.27_jiti@2.6.1_93023d256ff9ed909ae8f0d436c922a0/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js +50 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@edge-runtime_vm@3.2.0_@types_debug@4.1.12_@types_node@20.19.27_jiti@2.6.1_93023d256ff9ed909ae8f0d436c922a0/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +48 -0
- package/dist/node_modules/.pnpm/vitest@3.2.4_@edge-runtime_vm@3.2.0_@types_debug@4.1.12_@types_node@20.19.27_jiti@2.6.1_93023d256ff9ed909ae8f0d436c922a0/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +2613 -0
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.js +3 -0
- package/dist/test-utils/mocks/index.d.ts +2 -0
- package/dist/test-utils/mocks/index.js +3 -0
- package/dist/test-utils/mocks/logger.d.ts +27 -0
- package/dist/test-utils/mocks/logger.js +48 -0
- package/dist/utils/error.d.ts +58 -52
- package/dist/utils/error.js +63 -21
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +3 -3
- package/dist/utils/jwt-helpers.js +1 -1
- package/dist/utils/logger.d.ts +21 -2
- package/dist/utils/logger.js +67 -11
- package/dist/utils/third-party-mcp-servers/composio-client.js +10 -10
- package/dist/utils/tracer-factory.js +1 -1
- package/dist/validation/schemas/skills.d.ts +45 -45
- package/dist/validation/schemas.d.ts +2289 -2289
- package/drizzle/runtime/meta/_journal.json +2 -2
- package/package.json +5 -1
package/dist/utils/error.js
CHANGED
|
@@ -3,6 +3,58 @@ import { z } from "@hono/zod-openapi";
|
|
|
3
3
|
import { HTTPException } from "hono/http-exception";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/error.ts
|
|
6
|
+
const PG_ERROR_KEYS = [
|
|
7
|
+
"code",
|
|
8
|
+
"detail",
|
|
9
|
+
"hint",
|
|
10
|
+
"severity",
|
|
11
|
+
"schema",
|
|
12
|
+
"table",
|
|
13
|
+
"column",
|
|
14
|
+
"constraint",
|
|
15
|
+
"routine",
|
|
16
|
+
"position",
|
|
17
|
+
"internalPosition",
|
|
18
|
+
"internalQuery",
|
|
19
|
+
"where",
|
|
20
|
+
"dataType",
|
|
21
|
+
"line",
|
|
22
|
+
"file"
|
|
23
|
+
];
|
|
24
|
+
const DRIZZLE_EXTRA_KEYS = ["query", "params"];
|
|
25
|
+
/**
|
|
26
|
+
* Builds structured fields from an error chain (Drizzle → pg DatabaseError / Doltgres).
|
|
27
|
+
* Outer wrappers often omit SQLSTATE and server detail; those live on nested `.cause`.
|
|
28
|
+
*/
|
|
29
|
+
function getDatabaseErrorLogContext(error) {
|
|
30
|
+
const chain = [];
|
|
31
|
+
const seen = /* @__PURE__ */ new Set();
|
|
32
|
+
let current = error;
|
|
33
|
+
let depth = 0;
|
|
34
|
+
while (current != null && typeof current === "object" && !seen.has(current)) {
|
|
35
|
+
seen.add(current);
|
|
36
|
+
const e = current;
|
|
37
|
+
const slice = {};
|
|
38
|
+
if (typeof e.message === "string" && e.message.length > 0) slice.message = e.message;
|
|
39
|
+
if (depth === 0 && typeof e.stack === "string" && e.stack.length > 0) slice.stack = e.stack;
|
|
40
|
+
for (const k of PG_ERROR_KEYS) {
|
|
41
|
+
const v = e[k];
|
|
42
|
+
if (v !== void 0 && v !== null && v !== "") slice[k] = v;
|
|
43
|
+
}
|
|
44
|
+
for (const k of DRIZZLE_EXTRA_KEYS) if (e[k] !== void 0) slice[k] = k === "params" ? `[${Array.isArray(e[k]) ? e[k].length : "?"} params redacted]` : e[k];
|
|
45
|
+
if (Object.keys(slice).length > 0) chain.push(slice);
|
|
46
|
+
depth += 1;
|
|
47
|
+
current = "cause" in e ? e.cause : void 0;
|
|
48
|
+
}
|
|
49
|
+
if (chain.length === 0) return {};
|
|
50
|
+
const root = chain[chain.length - 1];
|
|
51
|
+
const out = { dbErrorChain: chain };
|
|
52
|
+
if (root.message !== void 0) out.dbRootMessage = root.message;
|
|
53
|
+
if (root.code !== void 0) out.dbRootCode = root.code;
|
|
54
|
+
if (root.detail !== void 0) out.dbRootDetail = root.detail;
|
|
55
|
+
if (root.hint !== void 0) out.dbRootHint = root.hint;
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
6
58
|
const ErrorCode = z.enum([
|
|
7
59
|
"bad_request",
|
|
8
60
|
"unauthorized",
|
|
@@ -62,19 +114,21 @@ const errorResponseSchema = z.object({ error: z.object({
|
|
|
62
114
|
example: "The requested resource was not found."
|
|
63
115
|
})
|
|
64
116
|
}) }).openapi("ErrorResponse");
|
|
117
|
+
const STATIC_500_MESSAGE = "An internal server error occurred. Please try again later.";
|
|
65
118
|
function createApiError({ code, message, instance, requestId, extensions }) {
|
|
66
119
|
const status = errorCodeToHttpStatus[code];
|
|
67
120
|
const title = getTitleFromCode(code);
|
|
68
121
|
`${ERROR_DOCS_BASE_URL}${code}`;
|
|
122
|
+
const externalMessage = status >= 500 ? STATIC_500_MESSAGE : message;
|
|
69
123
|
const problemDetails = {
|
|
70
124
|
title,
|
|
71
125
|
status,
|
|
72
|
-
detail:
|
|
126
|
+
detail: externalMessage,
|
|
73
127
|
code,
|
|
74
128
|
...instance && { instance },
|
|
75
129
|
...requestId && { requestId }
|
|
76
130
|
};
|
|
77
|
-
const errorMessage =
|
|
131
|
+
const errorMessage = externalMessage.length > 100 ? `${externalMessage.substring(0, 97)}...` : externalMessage;
|
|
78
132
|
const responseBody = {
|
|
79
133
|
...problemDetails,
|
|
80
134
|
error: {
|
|
@@ -115,13 +169,10 @@ async function handleApiError(error, requestId) {
|
|
|
115
169
|
}
|
|
116
170
|
};
|
|
117
171
|
}
|
|
118
|
-
if (error.status >= 500)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
requestId: responseJson.requestId || requestId || "unknown"
|
|
123
|
-
}, "API server error occurred");
|
|
124
|
-
else getLogger("core").info({
|
|
172
|
+
if (error.status >= 500) {
|
|
173
|
+
responseJson.detail = STATIC_500_MESSAGE;
|
|
174
|
+
responseJson.error.message = STATIC_500_MESSAGE;
|
|
175
|
+
} else getLogger("core").info({
|
|
125
176
|
error,
|
|
126
177
|
status: error.status,
|
|
127
178
|
code: responseJson.code,
|
|
@@ -130,24 +181,15 @@ async function handleApiError(error, requestId) {
|
|
|
130
181
|
}, "API client error occurred");
|
|
131
182
|
return responseJson;
|
|
132
183
|
}
|
|
133
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
134
|
-
const errorStack = error instanceof Error ? error.stack : void 0;
|
|
135
|
-
getLogger("core").error({
|
|
136
|
-
error,
|
|
137
|
-
message: errorMessage,
|
|
138
|
-
stack: errorStack,
|
|
139
|
-
status: 500,
|
|
140
|
-
requestId: requestId || "unknown"
|
|
141
|
-
}, "Unhandled API error occurred");
|
|
142
184
|
return {
|
|
143
185
|
title: "Internal Server Error",
|
|
144
186
|
status: 500,
|
|
145
|
-
detail:
|
|
187
|
+
detail: STATIC_500_MESSAGE,
|
|
146
188
|
code: "internal_server_error",
|
|
147
189
|
...requestId && { requestId },
|
|
148
190
|
error: {
|
|
149
191
|
code: "internal_server_error",
|
|
150
|
-
message:
|
|
192
|
+
message: STATIC_500_MESSAGE
|
|
151
193
|
}
|
|
152
194
|
};
|
|
153
195
|
}
|
|
@@ -240,4 +282,4 @@ const commonDeleteErrorResponses = {
|
|
|
240
282
|
};
|
|
241
283
|
|
|
242
284
|
//#endregion
|
|
243
|
-
export { ERROR_DOCS_BASE_URL, ErrorCode, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError };
|
|
285
|
+
export { ERROR_DOCS_BASE_URL, ErrorCode, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, getDatabaseErrorLogContext, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JwtVerifyResult, SignJwtOptions, VerifyJwtOptions, decodeJwtPayload, deriveKidFromPublicKey, extractBearerToken, getJwtSecret, hasIssuer, signJwt, verifyJwt } from "./jwt-helpers.js";
|
|
2
2
|
import { GenerateInternalServiceTokenParams, InternalServiceId, InternalServiceTokenPayload, InternalServices, VerifyInternalServiceTokenResult, generateInternalServiceToken, isInternalServiceToken, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, verifyInternalServiceAuthHeader, verifyInternalServiceToken } from "./internal-service-auth.js";
|
|
3
3
|
import { GenerationType } from "../db/runtime/runtime-schema.js";
|
|
4
|
-
import { LoggerFactoryConfig, PinoLogger, PinoLoggerConfig, getLogger, loggerFactory } from "./logger.js";
|
|
4
|
+
import { LoggerFactoryConfig, PinoLogger, PinoLoggerConfig, getLogger, loggerFactory, runWithLogContext } from "./logger.js";
|
|
5
5
|
import { McpClient, McpClientOptions, McpSSEConfig, McpServerConfig, McpStreamableHttpConfig, activeMcpClients } from "./mcp-client.js";
|
|
6
6
|
import { ApiKeyGenerationResult, AppCredentialResult, extractPublicId, generateApiKey, generateAppCredential, getMetadataFromApiKey, hashApiKey, isApiKeyExpired, maskApiKey, sanitizeAppConfig, validateApiKey } from "./apiKeys.js";
|
|
7
7
|
import { McpOAuthFlowResult, McpTokenExchangeResult, OAuthConfig, detectAuthenticationRequired, exchangeMcpAuthorizationCode, initiateMcpOAuthFlow } from "./auth-detection.js";
|
|
@@ -11,7 +11,7 @@ import { getCredentialStoreLookupKeyFromRetrievalParams } from "./credential-sto
|
|
|
11
11
|
import { normalizeDateString, toISODateString } from "./date.js";
|
|
12
12
|
import { validateOrigin } from "./domain-validation.js";
|
|
13
13
|
import { isDevelopment, isProduction, isTest } from "./env-detection.js";
|
|
14
|
-
import { CommonCreateErrorResponses, CommonDeleteErrorResponses, CommonGetErrorResponses, CommonUpdateErrorResponses, ERROR_DOCS_BASE_URL, ErrorCode, ErrorCodes, ErrorResponse, ProblemDetails, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError } from "./error.js";
|
|
14
|
+
import { CommonCreateErrorResponses, CommonDeleteErrorResponses, CommonGetErrorResponses, CommonUpdateErrorResponses, ERROR_DOCS_BASE_URL, ErrorCode, ErrorCodes, ErrorResponse, ProblemDetails, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, getDatabaseErrorLogContext, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError } from "./error.js";
|
|
15
15
|
import { LLMMessage, formatMessagesForLLM, formatMessagesForLLMContext } from "./format-messages.js";
|
|
16
16
|
import { getInProcessFetch, registerAppFetch } from "./in-process-fetch.js";
|
|
17
17
|
import { JsonTransformer } from "./JsonTransformer.js";
|
|
@@ -39,4 +39,4 @@ import "./usage-tracker.js";
|
|
|
39
39
|
import { ValidatePublicKeyResult, validatePublicKey } from "./validate-public-key.js";
|
|
40
40
|
import { _resetWaitUntilCache, getWaitUntil } from "./wait-until.js";
|
|
41
41
|
import { TRUSTED_WORK_APP_MCP_PATHS, isTrustedWorkAppMcpUrl } from "./work-app-mcp.js";
|
|
42
|
-
export { ApiKeyGenerationResult, AppCredentialResult, AssembleResult, CommonCreateErrorResponses, CommonDeleteErrorResponses, CommonGetErrorResponses, CommonUpdateErrorResponses, ComposioAuthResult, CredentialScope, ERROR_DOCS_BASE_URL, ErrorCode, ErrorCodes, ErrorResponse, GenerateInternalServiceTokenParams, GenerateServiceTokenParams, GenerationType, HashedHeaderValue, InternalServiceId, InternalServiceTokenPayload, InternalServices, JsonTransformer, JwtVerifyResult, LLMMessage, LoggerFactoryConfig, McpClient, McpClientOptions, McpOAuthFlowResult, McpSSEConfig, McpServerConfig, McpStreamableHttpConfig, McpTokenExchangeResult, MockLanguageModel, ModelFactory, OAuthConfig, ParsedSSEResponse, PinoLogger, PinoLoggerConfig, PoWError, PoWResult, ProblemDetails, SKILL_ENTRY_FILE_PATH, ServiceTokenPayload, SignJwtOptions, SignSlackLinkTokenParams, SignSlackUserTokenParams, SignatureVerificationErrorCode, SignatureVerificationResult, SlackAccessTokenPayload, SlackAccessTokenPayloadSchema, SlackLinkIntent, SlackLinkIntentSchema, SlackLinkTokenPayload, SlackLinkTokenPayloadSchema, TRUSTED_WORK_APP_MCP_PATHS, TempTokenPayload, TriggerAuthResult, ValidatePublicKeyResult, VerifyInternalServiceTokenResult, VerifyJwtOptions, VerifyServiceTokenResult, VerifySlackLinkTokenResult, VerifySlackUserTokenResult, _resetWaitUntilCache, activeMcpClients, buildConversationMetadata, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, computeNextRunAt, configureComposioMCPServer, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, createApiError, createMockModel, decodeJwtPayload, deleteComposioConnectedAccount, deriveKidFromPublicKey, deriveRelationId, detectAuthenticationRequired, errorResponseSchema, errorSchemaFactory, estimateTokens, exchangeMcpAuthorizationCode, extractBearerToken, extractComposioServerId, extractPreviewFields, extractPublicId, extractUsageTokens, fetchComposioServers, fetchSingleComposioServer, flushTraces, formatMessagesForLLM, formatMessagesForLLMContext, gatewayCostMiddleware, generateApiKey, generateAppCredential, generateId, generateInternalServiceToken, generateServiceToken, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getInProcessFetch, getJwtSecret, getLogger, getMetadataFromApiKey, getPoWErrorMessage, getTracer, getWaitUntil, handleApiError, hasIssuer, hashApiKey, hashAuthenticationHeaders, hashTriggerHeaderValue, initiateMcpOAuthFlow, interpolateTemplate, isApiKeyExpired, isComposioMCPServerAuthenticated, isDevelopment, isInternalServiceToken, isPoWEnabled, isProduction, isSlackUserToken, isTest, isThirdPartyMCPServerAuthenticated, isTrustedWorkAppMcpUrl, isUniqueConstraintError, isZodSchema, loggerFactory, makeAllPropertiesRequired, maskApiKey, normalizeDataComponentSchema, normalizeDateString, normalizeModelId, parseEmbeddedJson, parseSSEResponse, parseSkillFromMarkdown, preview, problemDetailsSchema, registerAppFetch, retryWithBackoff, sanitizeAppConfig, serializeSkillToMarkdown, setSpanWithError, signJwt, signSlackLinkToken, signSlackUserToken, stripUnsupportedConstraints, throwIfUniqueConstraintError, toISODateString, unwrapError, validateApiKey, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, validateOrigin, validatePublicKey, validateTargetAgent, validateTenantId, validateTriggerHeaderValue, verifyAuthorizationHeader, verifyInternalServiceAuthHeader, verifyInternalServiceToken, verifyJwt, verifyPoW, verifyServiceToken, verifySignatureWithConfig, verifySlackLinkToken, verifySlackUserToken, verifyTempToken, verifyTriggerAuth };
|
|
42
|
+
export { ApiKeyGenerationResult, AppCredentialResult, AssembleResult, CommonCreateErrorResponses, CommonDeleteErrorResponses, CommonGetErrorResponses, CommonUpdateErrorResponses, ComposioAuthResult, CredentialScope, ERROR_DOCS_BASE_URL, ErrorCode, ErrorCodes, ErrorResponse, GenerateInternalServiceTokenParams, GenerateServiceTokenParams, GenerationType, HashedHeaderValue, InternalServiceId, InternalServiceTokenPayload, InternalServices, JsonTransformer, JwtVerifyResult, LLMMessage, LoggerFactoryConfig, McpClient, McpClientOptions, McpOAuthFlowResult, McpSSEConfig, McpServerConfig, McpStreamableHttpConfig, McpTokenExchangeResult, MockLanguageModel, ModelFactory, OAuthConfig, ParsedSSEResponse, PinoLogger, PinoLoggerConfig, PoWError, PoWResult, ProblemDetails, SKILL_ENTRY_FILE_PATH, ServiceTokenPayload, SignJwtOptions, SignSlackLinkTokenParams, SignSlackUserTokenParams, SignatureVerificationErrorCode, SignatureVerificationResult, SlackAccessTokenPayload, SlackAccessTokenPayloadSchema, SlackLinkIntent, SlackLinkIntentSchema, SlackLinkTokenPayload, SlackLinkTokenPayloadSchema, TRUSTED_WORK_APP_MCP_PATHS, TempTokenPayload, TriggerAuthResult, ValidatePublicKeyResult, VerifyInternalServiceTokenResult, VerifyJwtOptions, VerifyServiceTokenResult, VerifySlackLinkTokenResult, VerifySlackUserTokenResult, _resetWaitUntilCache, activeMcpClients, buildConversationMetadata, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, computeNextRunAt, configureComposioMCPServer, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, createApiError, createMockModel, decodeJwtPayload, deleteComposioConnectedAccount, deriveKidFromPublicKey, deriveRelationId, detectAuthenticationRequired, errorResponseSchema, errorSchemaFactory, estimateTokens, exchangeMcpAuthorizationCode, extractBearerToken, extractComposioServerId, extractPreviewFields, extractPublicId, extractUsageTokens, fetchComposioServers, fetchSingleComposioServer, flushTraces, formatMessagesForLLM, formatMessagesForLLMContext, gatewayCostMiddleware, generateApiKey, generateAppCredential, generateId, generateInternalServiceToken, generateServiceToken, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getDatabaseErrorLogContext, getInProcessFetch, getJwtSecret, getLogger, getMetadataFromApiKey, getPoWErrorMessage, getTracer, getWaitUntil, handleApiError, hasIssuer, hashApiKey, hashAuthenticationHeaders, hashTriggerHeaderValue, initiateMcpOAuthFlow, interpolateTemplate, isApiKeyExpired, isComposioMCPServerAuthenticated, isDevelopment, isInternalServiceToken, isPoWEnabled, isProduction, isSlackUserToken, isTest, isThirdPartyMCPServerAuthenticated, isTrustedWorkAppMcpUrl, isUniqueConstraintError, isZodSchema, loggerFactory, makeAllPropertiesRequired, maskApiKey, normalizeDataComponentSchema, normalizeDateString, normalizeModelId, parseEmbeddedJson, parseSSEResponse, parseSkillFromMarkdown, preview, problemDetailsSchema, registerAppFetch, retryWithBackoff, runWithLogContext, sanitizeAppConfig, serializeSkillToMarkdown, setSpanWithError, signJwt, signSlackLinkToken, signSlackUserToken, stripUnsupportedConstraints, throwIfUniqueConstraintError, toISODateString, unwrapError, validateApiKey, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, validateOrigin, validatePublicKey, validateTargetAgent, validateTenantId, validateTriggerHeaderValue, verifyAuthorizationHeader, verifyInternalServiceAuthHeader, verifyInternalServiceToken, verifyJwt, verifyPoW, verifyServiceToken, verifySignatureWithConfig, verifySlackLinkToken, verifySlackUserToken, verifyTempToken, verifyTriggerAuth };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SKILL_ENTRY_FILE_PATH, parseSkillFromMarkdown, serializeSkillToMarkdown } from "./skill-files.js";
|
|
2
2
|
import { detectAuthenticationRequired, exchangeMcpAuthorizationCode, initiateMcpOAuthFlow } from "./auth-detection.js";
|
|
3
|
-
import { PinoLogger, getLogger, loggerFactory } from "./logger.js";
|
|
3
|
+
import { PinoLogger, getLogger, loggerFactory, runWithLogContext } from "./logger.js";
|
|
4
4
|
import { decodeJwtPayload, deriveKidFromPublicKey, extractBearerToken, getJwtSecret, hasIssuer, signJwt, verifyJwt } from "./jwt-helpers.js";
|
|
5
5
|
import { InternalServices, generateInternalServiceToken, isInternalServiceToken, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, verifyInternalServiceAuthHeader, verifyInternalServiceToken } from "./internal-service-auth.js";
|
|
6
6
|
import { convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, extractPreviewFields, isZodSchema, makeAllPropertiesRequired, normalizeDataComponentSchema, preview, stripUnsupportedConstraints } from "./schema-conversion.js";
|
|
@@ -8,8 +8,8 @@ import { configureComposioMCPServer, deleteComposioConnectedAccount, extractComp
|
|
|
8
8
|
import { isThirdPartyMCPServerAuthenticated } from "./third-party-mcp-servers/third-party-check.js";
|
|
9
9
|
import "./third-party-mcp-servers/index.js";
|
|
10
10
|
import { getCredentialStoreLookupKeyFromRetrievalParams } from "./credential-store-utils.js";
|
|
11
|
+
import { ERROR_DOCS_BASE_URL, ErrorCode, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, getDatabaseErrorLogContext, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError } from "./error.js";
|
|
11
12
|
import { buildConversationMetadata, deriveRelationId, generateId, getConversationId } from "./conversations.js";
|
|
12
|
-
import { ERROR_DOCS_BASE_URL, ErrorCode, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, createApiError, errorResponseSchema, errorSchemaFactory, handleApiError, isUniqueConstraintError, problemDetailsSchema, throwIfUniqueConstraintError } from "./error.js";
|
|
13
13
|
import { extractPublicId, generateApiKey, generateAppCredential, getMetadataFromApiKey, hashApiKey, isApiKeyExpired, maskApiKey, sanitizeAppConfig, validateApiKey } from "./apiKeys.js";
|
|
14
14
|
import { computeNextRunAt } from "./compute-next-run-at.js";
|
|
15
15
|
import { normalizeDateString, toISODateString } from "./date.js";
|
|
@@ -38,4 +38,4 @@ import { validatePublicKey } from "./validate-public-key.js";
|
|
|
38
38
|
import { _resetWaitUntilCache, getWaitUntil } from "./wait-until.js";
|
|
39
39
|
import { TRUSTED_WORK_APP_MCP_PATHS, isTrustedWorkAppMcpUrl } from "./work-app-mcp.js";
|
|
40
40
|
|
|
41
|
-
export { ERROR_DOCS_BASE_URL, ErrorCode, InternalServices, JsonTransformer, McpClient, MockLanguageModel, ModelFactory, PinoLogger, SKILL_ENTRY_FILE_PATH, SlackAccessTokenPayloadSchema, SlackLinkIntentSchema, SlackLinkTokenPayloadSchema, TRUSTED_WORK_APP_MCP_PATHS, _resetWaitUntilCache, activeMcpClients, buildConversationMetadata, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, computeNextRunAt, configureComposioMCPServer, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, createApiError, createMockModel, decodeJwtPayload, deleteComposioConnectedAccount, deriveKidFromPublicKey, deriveRelationId, detectAuthenticationRequired, errorResponseSchema, errorSchemaFactory, estimateTokens, exchangeMcpAuthorizationCode, extractBearerToken, extractComposioServerId, extractPreviewFields, extractPublicId, extractUsageTokens, fetchComposioServers, fetchSingleComposioServer, flushTraces, formatMessagesForLLM, formatMessagesForLLMContext, gatewayCostMiddleware, generateApiKey, generateAppCredential, generateId, generateInternalServiceToken, generateServiceToken, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getInProcessFetch, getJwtSecret, getLogger, getMetadataFromApiKey, getPoWErrorMessage, getTracer, getWaitUntil, handleApiError, hasIssuer, hashApiKey, hashAuthenticationHeaders, hashTriggerHeaderValue, initiateMcpOAuthFlow, interpolateTemplate, isApiKeyExpired, isComposioMCPServerAuthenticated, isDevelopment, isInternalServiceToken, isPoWEnabled, isProduction, isSlackUserToken, isTest, isThirdPartyMCPServerAuthenticated, isTrustedWorkAppMcpUrl, isUniqueConstraintError, isZodSchema, loggerFactory, makeAllPropertiesRequired, maskApiKey, normalizeDataComponentSchema, normalizeDateString, normalizeModelId, parseEmbeddedJson, parseSSEResponse, parseSkillFromMarkdown, preview, problemDetailsSchema, registerAppFetch, retryWithBackoff, sanitizeAppConfig, serializeSkillToMarkdown, setSpanWithError, signJwt, signSlackLinkToken, signSlackUserToken, stripUnsupportedConstraints, throwIfUniqueConstraintError, toISODateString, unwrapError, validateApiKey, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, validateOrigin, validatePublicKey, validateTargetAgent, validateTenantId, validateTriggerHeaderValue, verifyAuthorizationHeader, verifyInternalServiceAuthHeader, verifyInternalServiceToken, verifyJwt, verifyPoW, verifyServiceToken, verifySignatureWithConfig, verifySlackLinkToken, verifySlackUserToken, verifyTempToken, verifyTriggerAuth };
|
|
41
|
+
export { ERROR_DOCS_BASE_URL, ErrorCode, InternalServices, JsonTransformer, McpClient, MockLanguageModel, ModelFactory, PinoLogger, SKILL_ENTRY_FILE_PATH, SlackAccessTokenPayloadSchema, SlackLinkIntentSchema, SlackLinkTokenPayloadSchema, TRUSTED_WORK_APP_MCP_PATHS, _resetWaitUntilCache, activeMcpClients, buildConversationMetadata, commonCreateErrorResponses, commonDeleteErrorResponses, commonGetErrorResponses, commonUpdateErrorResponses, computeNextRunAt, configureComposioMCPServer, convertZodToJsonSchema, convertZodToJsonSchemaWithPreview, createApiError, createMockModel, decodeJwtPayload, deleteComposioConnectedAccount, deriveKidFromPublicKey, deriveRelationId, detectAuthenticationRequired, errorResponseSchema, errorSchemaFactory, estimateTokens, exchangeMcpAuthorizationCode, extractBearerToken, extractComposioServerId, extractPreviewFields, extractPublicId, extractUsageTokens, fetchComposioServers, fetchSingleComposioServer, flushTraces, formatMessagesForLLM, formatMessagesForLLMContext, gatewayCostMiddleware, generateApiKey, generateAppCredential, generateId, generateInternalServiceToken, generateServiceToken, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, getConversationId, getCredentialStoreLookupKeyFromRetrievalParams, getDatabaseErrorLogContext, getInProcessFetch, getJwtSecret, getLogger, getMetadataFromApiKey, getPoWErrorMessage, getTracer, getWaitUntil, handleApiError, hasIssuer, hashApiKey, hashAuthenticationHeaders, hashTriggerHeaderValue, initiateMcpOAuthFlow, interpolateTemplate, isApiKeyExpired, isComposioMCPServerAuthenticated, isDevelopment, isInternalServiceToken, isPoWEnabled, isProduction, isSlackUserToken, isTest, isThirdPartyMCPServerAuthenticated, isTrustedWorkAppMcpUrl, isUniqueConstraintError, isZodSchema, loggerFactory, makeAllPropertiesRequired, maskApiKey, normalizeDataComponentSchema, normalizeDateString, normalizeModelId, parseEmbeddedJson, parseSSEResponse, parseSkillFromMarkdown, preview, problemDetailsSchema, registerAppFetch, retryWithBackoff, runWithLogContext, sanitizeAppConfig, serializeSkillToMarkdown, setSpanWithError, signJwt, signSlackLinkToken, signSlackUserToken, stripUnsupportedConstraints, throwIfUniqueConstraintError, toISODateString, unwrapError, validateApiKey, validateInternalServiceProjectAccess, validateInternalServiceTenantAccess, validateOrigin, validatePublicKey, validateTargetAgent, validateTenantId, validateTriggerHeaderValue, verifyAuthorizationHeader, verifyInternalServiceAuthHeader, verifyInternalServiceToken, verifyJwt, verifyPoW, verifyServiceToken, verifySignatureWithConfig, verifySlackLinkToken, verifySlackUserToken, verifyTempToken, verifyTriggerAuth };
|
|
@@ -13,7 +13,7 @@ function getJwtSecret() {
|
|
|
13
13
|
const secret = env.INKEEP_AGENTS_JWT_SIGNING_SECRET;
|
|
14
14
|
if (!secret) {
|
|
15
15
|
if (env.ENVIRONMENT === "production") throw new Error("INKEEP_AGENTS_JWT_SIGNING_SECRET environment variable is required in production");
|
|
16
|
-
logger.warn(
|
|
16
|
+
logger.warn("INKEEP_AGENTS_JWT_SIGNING_SECRET not set, using insecure default. DO NOT USE IN PRODUCTION!");
|
|
17
17
|
return new TextEncoder().encode(DEV_SECRET);
|
|
18
18
|
}
|
|
19
19
|
return new TextEncoder().encode(secret);
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger, LoggerOptions, TransportSingleOptions } from "pino";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/logger.d.ts
|
|
4
|
-
|
|
4
|
+
declare function runWithLogContext<T>(bindings: Record<string, unknown>, fn: () => T): T;
|
|
5
5
|
/**
|
|
6
6
|
* Configuration options for PinoLogger
|
|
7
7
|
*/
|
|
@@ -10,6 +10,10 @@ interface PinoLoggerConfig {
|
|
|
10
10
|
options?: LoggerOptions;
|
|
11
11
|
/** Pino transport configuration */
|
|
12
12
|
transportConfigs?: TransportSingleOptions[];
|
|
13
|
+
/** Pre-built pino instance (used internally by .with()) */
|
|
14
|
+
fromInstance?: Logger;
|
|
15
|
+
/** When true, disables ALS proxying (used by .with() for snapshot semantics) */
|
|
16
|
+
snapshot?: boolean;
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
19
|
* Pino logger implementation with transport customization support
|
|
@@ -19,6 +23,8 @@ declare class PinoLogger {
|
|
|
19
23
|
private transportConfigs;
|
|
20
24
|
private pinoInstance;
|
|
21
25
|
private options;
|
|
26
|
+
private alsChildCache;
|
|
27
|
+
private isSnapshot;
|
|
22
28
|
constructor(name: string, config?: PinoLoggerConfig);
|
|
23
29
|
/**
|
|
24
30
|
* Recreate the pino instance with current transports
|
|
@@ -44,9 +50,22 @@ declare class PinoLogger {
|
|
|
44
50
|
* Get the underlying pino instance for advanced usage
|
|
45
51
|
*/
|
|
46
52
|
getPinoInstance(): Logger;
|
|
53
|
+
private resolveInstance;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new PinoLogger with the given bindings baked in (snapshot semantics).
|
|
56
|
+
* Captures the current ALS context at call time. The returned logger does NOT
|
|
57
|
+
* pick up subsequent ALS context changes — use for class member loggers that
|
|
58
|
+
* are constructed once and reused within a request scope.
|
|
59
|
+
*/
|
|
60
|
+
with(bindings: Record<string, unknown>): PinoLogger;
|
|
61
|
+
child(bindings: Record<string, unknown>): PinoLogger;
|
|
62
|
+
error(message: string): void;
|
|
47
63
|
error(data: any, message: string): void;
|
|
64
|
+
warn(message: string): void;
|
|
48
65
|
warn(data: any, message: string): void;
|
|
66
|
+
info(message: string): void;
|
|
49
67
|
info(data: any, message: string): void;
|
|
68
|
+
debug(message: string): void;
|
|
50
69
|
debug(data: any, message: string): void;
|
|
51
70
|
}
|
|
52
71
|
/**
|
|
@@ -83,4 +102,4 @@ declare const loggerFactory: LoggerFactory;
|
|
|
83
102
|
*/
|
|
84
103
|
declare function getLogger(name: string): PinoLogger;
|
|
85
104
|
//#endregion
|
|
86
|
-
export { LoggerFactoryConfig, PinoLogger, PinoLoggerConfig, getLogger, loggerFactory };
|
|
105
|
+
export { LoggerFactoryConfig, PinoLogger, PinoLoggerConfig, getLogger, loggerFactory, runWithLogContext };
|
package/dist/utils/logger.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
1
2
|
import pino from "pino";
|
|
2
3
|
import pinoPretty from "pino-pretty";
|
|
3
4
|
|
|
@@ -13,19 +14,42 @@ function shouldColorize() {
|
|
|
13
14
|
if (process.env.NO_COLOR && process.env.NO_COLOR !== "") return false;
|
|
14
15
|
return process.stdout.isTTY ?? false;
|
|
15
16
|
}
|
|
17
|
+
const loggerStorage = new AsyncLocalStorage();
|
|
18
|
+
function runWithLogContext(bindings, fn) {
|
|
19
|
+
const child = (loggerStorage.getStore() ?? basePinoInstance).child(bindings);
|
|
20
|
+
return loggerStorage.run(child, fn);
|
|
21
|
+
}
|
|
22
|
+
let basePinoInstance = pino({ level: "silent" });
|
|
23
|
+
function setBasePinoInstance(instance) {
|
|
24
|
+
basePinoInstance = instance;
|
|
25
|
+
}
|
|
16
26
|
/**
|
|
17
27
|
* Pino logger implementation with transport customization support
|
|
18
28
|
*/
|
|
19
|
-
var PinoLogger = class {
|
|
29
|
+
var PinoLogger = class PinoLogger {
|
|
20
30
|
transportConfigs = [];
|
|
21
31
|
pinoInstance;
|
|
22
32
|
options;
|
|
33
|
+
alsChildCache = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
isSnapshot;
|
|
23
35
|
constructor(name, config = {}) {
|
|
24
36
|
this.name = name;
|
|
37
|
+
if (config.fromInstance) {
|
|
38
|
+
this.pinoInstance = config.fromInstance;
|
|
39
|
+
this.options = {};
|
|
40
|
+
this.isSnapshot = config.snapshot ?? false;
|
|
41
|
+
if (!this.isSnapshot) setBasePinoInstance(this.pinoInstance);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.isSnapshot = false;
|
|
25
45
|
this.options = {
|
|
26
46
|
name: this.name,
|
|
27
47
|
level: process.env.LOG_LEVEL || (process.env.ENVIRONMENT === "test" ? "silent" : "info"),
|
|
28
|
-
serializers: {
|
|
48
|
+
serializers: {
|
|
49
|
+
err: pino.stdSerializers.err,
|
|
50
|
+
error: pino.stdSerializers.err,
|
|
51
|
+
obj: (value) => ({ ...value })
|
|
52
|
+
},
|
|
29
53
|
redact: [
|
|
30
54
|
"req.headers.authorization",
|
|
31
55
|
"req.headers[\"x-inkeep-admin-authentication\"]",
|
|
@@ -47,12 +71,14 @@ var PinoLogger = class {
|
|
|
47
71
|
console.warn("Warning: pino-pretty failed, using standard JSON output:", error);
|
|
48
72
|
this.pinoInstance = pino(this.options);
|
|
49
73
|
}
|
|
74
|
+
setBasePinoInstance(this.pinoInstance);
|
|
50
75
|
}
|
|
51
76
|
/**
|
|
52
77
|
* Recreate the pino instance with current transports
|
|
53
78
|
*/
|
|
54
79
|
recreateInstance() {
|
|
55
80
|
if (this.pinoInstance && typeof this.pinoInstance.flush === "function") this.pinoInstance.flush();
|
|
81
|
+
this.alsChildCache = /* @__PURE__ */ new WeakMap();
|
|
56
82
|
if (this.transportConfigs.length === 0) try {
|
|
57
83
|
const prettyStream = pinoPretty({
|
|
58
84
|
colorize: shouldColorize(),
|
|
@@ -108,17 +134,47 @@ var PinoLogger = class {
|
|
|
108
134
|
getPinoInstance() {
|
|
109
135
|
return this.pinoInstance;
|
|
110
136
|
}
|
|
111
|
-
|
|
112
|
-
this.pinoInstance
|
|
137
|
+
resolveInstance() {
|
|
138
|
+
if (this.isSnapshot) return this.pinoInstance;
|
|
139
|
+
const alsInstance = loggerStorage.getStore();
|
|
140
|
+
if (!alsInstance) return this.pinoInstance;
|
|
141
|
+
let cached = this.alsChildCache.get(alsInstance);
|
|
142
|
+
if (!cached) {
|
|
143
|
+
cached = alsInstance.child({ module: this.name });
|
|
144
|
+
this.alsChildCache.set(alsInstance, cached);
|
|
145
|
+
}
|
|
146
|
+
return cached;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Creates a new PinoLogger with the given bindings baked in (snapshot semantics).
|
|
150
|
+
* Captures the current ALS context at call time. The returned logger does NOT
|
|
151
|
+
* pick up subsequent ALS context changes — use for class member loggers that
|
|
152
|
+
* are constructed once and reused within a request scope.
|
|
153
|
+
*/
|
|
154
|
+
with(bindings) {
|
|
155
|
+
return new PinoLogger(this.name, {
|
|
156
|
+
fromInstance: this.resolveInstance().child(bindings),
|
|
157
|
+
snapshot: true
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
child(bindings) {
|
|
161
|
+
return this.with(bindings);
|
|
162
|
+
}
|
|
163
|
+
error(dataOrMessage, message) {
|
|
164
|
+
if (message === void 0) this.resolveInstance().error(dataOrMessage);
|
|
165
|
+
else this.resolveInstance().error(dataOrMessage, message);
|
|
113
166
|
}
|
|
114
|
-
warn(
|
|
115
|
-
this.
|
|
167
|
+
warn(dataOrMessage, message) {
|
|
168
|
+
if (message === void 0) this.resolveInstance().warn(dataOrMessage);
|
|
169
|
+
else this.resolveInstance().warn(dataOrMessage, message);
|
|
116
170
|
}
|
|
117
|
-
info(
|
|
118
|
-
this.
|
|
171
|
+
info(dataOrMessage, message) {
|
|
172
|
+
if (message === void 0) this.resolveInstance().info(dataOrMessage);
|
|
173
|
+
else this.resolveInstance().info(dataOrMessage, message);
|
|
119
174
|
}
|
|
120
|
-
debug(
|
|
121
|
-
this.
|
|
175
|
+
debug(dataOrMessage, message) {
|
|
176
|
+
if (message === void 0) this.resolveInstance().debug(dataOrMessage);
|
|
177
|
+
else this.resolveInstance().debug(dataOrMessage, message);
|
|
122
178
|
}
|
|
123
179
|
};
|
|
124
180
|
/**
|
|
@@ -167,4 +223,4 @@ function getLogger(name) {
|
|
|
167
223
|
}
|
|
168
224
|
|
|
169
225
|
//#endregion
|
|
170
|
-
export { PinoLogger, getLogger, loggerFactory };
|
|
226
|
+
export { PinoLogger, getLogger, loggerFactory, runWithLogContext };
|
|
@@ -113,7 +113,7 @@ function extractComposioServerId(mcpUrl) {
|
|
|
113
113
|
async function deleteComposioConnectedAccount(accountId) {
|
|
114
114
|
const composioInstance = getComposioInstance();
|
|
115
115
|
if (!composioInstance) {
|
|
116
|
-
logger$1.info(
|
|
116
|
+
logger$1.info("Composio not configured, skipping account deletion");
|
|
117
117
|
return false;
|
|
118
118
|
}
|
|
119
119
|
try {
|
|
@@ -131,7 +131,7 @@ async function deleteComposioConnectedAccount(accountId) {
|
|
|
131
131
|
async function fetchComposioConnectedAccounts(derivedUserId) {
|
|
132
132
|
const composioInstance = getComposioInstance();
|
|
133
133
|
if (!composioInstance) {
|
|
134
|
-
logger$1.info(
|
|
134
|
+
logger$1.info("Composio not configured, skipping connected accounts fetch");
|
|
135
135
|
return null;
|
|
136
136
|
}
|
|
137
137
|
try {
|
|
@@ -155,7 +155,7 @@ async function fetchComposioConnectedAccounts(derivedUserId) {
|
|
|
155
155
|
*/
|
|
156
156
|
async function isComposioMCPServerAuthenticated(tenantId, projectId, mcpServerUrl, credentialScope = "project", userId) {
|
|
157
157
|
if (!process.env.COMPOSIO_API_KEY) {
|
|
158
|
-
logger$1.info(
|
|
158
|
+
logger$1.info("Composio API key not configured, skipping auth check");
|
|
159
159
|
return { authenticated: false };
|
|
160
160
|
}
|
|
161
161
|
const serverId = extractComposioServerId(mcpServerUrl);
|
|
@@ -166,7 +166,7 @@ async function isComposioMCPServerAuthenticated(tenantId, projectId, mcpServerUr
|
|
|
166
166
|
const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
|
|
167
167
|
const composioInstance = getComposioInstance();
|
|
168
168
|
if (!composioInstance) {
|
|
169
|
-
logger$1.info(
|
|
169
|
+
logger$1.info("Composio not configured, skipping auth check");
|
|
170
170
|
return { authenticated: false };
|
|
171
171
|
}
|
|
172
172
|
try {
|
|
@@ -250,7 +250,7 @@ async function ensureComposioAccount(composioMcpServer, derivedUserId, staleAcco
|
|
|
250
250
|
*/
|
|
251
251
|
async function getComposioOAuthRedirectUrl(tenantId, projectId, mcpServerUrl, credentialScope, userId) {
|
|
252
252
|
if (!process.env.COMPOSIO_API_KEY) {
|
|
253
|
-
logger$1.info(
|
|
253
|
+
logger$1.info("Composio API key not configured");
|
|
254
254
|
return null;
|
|
255
255
|
}
|
|
256
256
|
const serverId = extractComposioServerId(mcpServerUrl);
|
|
@@ -260,7 +260,7 @@ async function getComposioOAuthRedirectUrl(tenantId, projectId, mcpServerUrl, cr
|
|
|
260
260
|
}
|
|
261
261
|
const composioInstance = getComposioInstance();
|
|
262
262
|
if (!composioInstance) {
|
|
263
|
-
logger$1.info(
|
|
263
|
+
logger$1.info("Composio not configured");
|
|
264
264
|
return null;
|
|
265
265
|
}
|
|
266
266
|
const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
|
|
@@ -300,12 +300,12 @@ async function transformComposioServer(composioMcpServer, authenticatedAuthConfi
|
|
|
300
300
|
*/
|
|
301
301
|
async function fetchComposioServers() {
|
|
302
302
|
if (!process.env.COMPOSIO_API_KEY) {
|
|
303
|
-
logger$1.info(
|
|
303
|
+
logger$1.info("COMPOSIO_API_KEY not configured, skipping Composio servers");
|
|
304
304
|
return [];
|
|
305
305
|
}
|
|
306
306
|
const composioInstance = getComposioInstance();
|
|
307
307
|
if (!composioInstance) {
|
|
308
|
-
logger$1.info(
|
|
308
|
+
logger$1.info("Composio not configured, returning empty list");
|
|
309
309
|
return [];
|
|
310
310
|
}
|
|
311
311
|
try {
|
|
@@ -327,13 +327,13 @@ async function fetchComposioServers() {
|
|
|
327
327
|
*/
|
|
328
328
|
async function fetchSingleComposioServer(tenantId, projectId, mcpServerUrl, credentialScope = "project", userId) {
|
|
329
329
|
if (!process.env.COMPOSIO_API_KEY) {
|
|
330
|
-
logger$1.debug(
|
|
330
|
+
logger$1.debug("COMPOSIO_API_KEY not configured");
|
|
331
331
|
return null;
|
|
332
332
|
}
|
|
333
333
|
const composioUserId = getComposioUserId(tenantId, projectId, credentialScope, userId);
|
|
334
334
|
const composioInstance = getComposioInstance();
|
|
335
335
|
if (!composioInstance) {
|
|
336
|
-
logger$1.info(
|
|
336
|
+
logger$1.info("Composio not configured, returning null");
|
|
337
337
|
return null;
|
|
338
338
|
}
|
|
339
339
|
try {
|
|
@@ -70,7 +70,7 @@ function getTracer(serviceName, serviceVersion) {
|
|
|
70
70
|
try {
|
|
71
71
|
return trace.getTracer(serviceName, serviceVersion);
|
|
72
72
|
} catch (_error) {
|
|
73
|
-
logger.debug(
|
|
73
|
+
logger.debug("OpenTelemetry tracer not available, using no-op tracer");
|
|
74
74
|
return noopTracer;
|
|
75
75
|
}
|
|
76
76
|
}
|