@adonis-agora/agent 0.17.0 → 0.19.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 (82) hide show
  1. package/CHANGELOG.md +151 -0
  2. package/README.md +210 -0
  3. package/dist/configure.d.ts +4 -3
  4. package/dist/configure.d.ts.map +1 -1
  5. package/dist/configure.js +5 -3
  6. package/dist/configure.js.map +1 -1
  7. package/dist/providers/agent_provider.d.ts +6 -4
  8. package/dist/providers/agent_provider.d.ts.map +1 -1
  9. package/dist/providers/agent_provider.js +23 -16
  10. package/dist/providers/agent_provider.js.map +1 -1
  11. package/dist/providers/mcp_provider.d.ts +22 -0
  12. package/dist/providers/mcp_provider.d.ts.map +1 -0
  13. package/dist/providers/mcp_provider.js +229 -0
  14. package/dist/providers/mcp_provider.js.map +1 -0
  15. package/dist/src/agent-deps-factory.d.ts +6 -0
  16. package/dist/src/agent-deps-factory.d.ts.map +1 -1
  17. package/dist/src/agent-deps-factory.js +5 -1
  18. package/dist/src/agent-deps-factory.js.map +1 -1
  19. package/dist/src/agent-deps.d.ts +6 -1
  20. package/dist/src/agent-deps.d.ts.map +1 -1
  21. package/dist/src/agent-deps.js.map +1 -1
  22. package/dist/src/agent-loop.d.ts +11 -2
  23. package/dist/src/agent-loop.d.ts.map +1 -1
  24. package/dist/src/agent-loop.js +69 -2
  25. package/dist/src/agent-loop.js.map +1 -1
  26. package/dist/src/data/tenant-scope.d.ts +16 -1
  27. package/dist/src/data/tenant-scope.d.ts.map +1 -1
  28. package/dist/src/data/tenant-scope.js +50 -7
  29. package/dist/src/data/tenant-scope.js.map +1 -1
  30. package/dist/src/define_config.d.ts +25 -9
  31. package/dist/src/define_config.d.ts.map +1 -1
  32. package/dist/src/define_config.js.map +1 -1
  33. package/dist/src/governance-gate.d.ts +24 -8
  34. package/dist/src/governance-gate.d.ts.map +1 -1
  35. package/dist/src/governance-gate.js +14 -3
  36. package/dist/src/governance-gate.js.map +1 -1
  37. package/dist/src/index.d.ts +2 -1
  38. package/dist/src/index.d.ts.map +1 -1
  39. package/dist/src/index.js +5 -1
  40. package/dist/src/index.js.map +1 -1
  41. package/dist/src/mcp/auth.d.ts +90 -0
  42. package/dist/src/mcp/auth.d.ts.map +1 -0
  43. package/dist/src/mcp/auth.js +108 -0
  44. package/dist/src/mcp/auth.js.map +1 -0
  45. package/dist/src/mcp/define_config.d.ts +64 -0
  46. package/dist/src/mcp/define_config.d.ts.map +1 -0
  47. package/dist/src/mcp/define_config.js +8 -0
  48. package/dist/src/mcp/define_config.js.map +1 -0
  49. package/dist/src/mcp/index.d.ts +7 -0
  50. package/dist/src/mcp/index.d.ts.map +1 -0
  51. package/dist/src/mcp/index.js +4 -0
  52. package/dist/src/mcp/index.js.map +1 -0
  53. package/dist/src/mcp/server.d.ts +47 -0
  54. package/dist/src/mcp/server.d.ts.map +1 -0
  55. package/dist/src/mcp/server.js +94 -0
  56. package/dist/src/mcp/server.js.map +1 -0
  57. package/dist/src/rag/chunk.d.ts +35 -0
  58. package/dist/src/rag/chunk.d.ts.map +1 -1
  59. package/dist/src/rag/chunk.js +60 -0
  60. package/dist/src/rag/chunk.js.map +1 -1
  61. package/dist/src/rag/index.d.ts +1 -1
  62. package/dist/src/rag/index.d.ts.map +1 -1
  63. package/dist/src/rag/index.js +1 -1
  64. package/dist/src/rag/index.js.map +1 -1
  65. package/dist/src/rag/memory-vector-store.d.ts +20 -1
  66. package/dist/src/rag/memory-vector-store.d.ts.map +1 -1
  67. package/dist/src/rag/memory-vector-store.js +56 -1
  68. package/dist/src/rag/memory-vector-store.js.map +1 -1
  69. package/dist/src/rag/pg-vector-store.d.ts +32 -1
  70. package/dist/src/rag/pg-vector-store.d.ts.map +1 -1
  71. package/dist/src/rag/pg-vector-store.js +69 -0
  72. package/dist/src/rag/pg-vector-store.js.map +1 -1
  73. package/dist/src/rag/qdrant-store.d.ts +81 -2
  74. package/dist/src/rag/qdrant-store.d.ts.map +1 -1
  75. package/dist/src/rag/qdrant-store.js +148 -1
  76. package/dist/src/rag/qdrant-store.js.map +1 -1
  77. package/dist/src/rag/vector-store.d.ts +144 -0
  78. package/dist/src/rag/vector-store.d.ts.map +1 -1
  79. package/dist/src/rag/vector-store.js +73 -0
  80. package/dist/src/rag/vector-store.js.map +1 -1
  81. package/dist/stubs/config/mcp.stub +42 -0
  82. package/package.json +26 -10
@@ -0,0 +1,90 @@
1
+ import type { ApplicationService } from '@adonisjs/core/types';
2
+ import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
3
+ import type { Actor } from '../types.js';
4
+ /**
5
+ * Runtime context a {@link McpAuthFactory} thunk receives when the MCP provider builds the configured
6
+ * auth at boot. Carries the booted application so a driver can resolve a peer's service if it needs to.
7
+ */
8
+ export interface McpAuthContext {
9
+ app: ApplicationService;
10
+ }
11
+ /**
12
+ * OAuth metadata the MCP server advertises at `/.well-known/oauth-protected-resource{path}` (RFC 9728)
13
+ * so an MCP client can discover how to obtain a token. Omitted → the server exposes no OAuth metadata
14
+ * endpoint and clients must authenticate another way (e.g. a static API key).
15
+ */
16
+ export interface McpOAuthMetadata {
17
+ /** The OAuth 2.0 / OIDC authorization server (the authkit issuer, e.g. `http://localhost:3333/oidc`). */
18
+ issuer: string;
19
+ /** Authorization endpoint the MCP client redirects to (e.g. `${issuer}/auth`). */
20
+ authorizationEndpoint: string;
21
+ /** Token endpoint the MCP client exchanges the code at (e.g. `${issuer}/token`). */
22
+ tokenEndpoint: string;
23
+ /** Scopes supported by the authorization server. */
24
+ scopesSupported: string[];
25
+ /** Human label for the protected resource. */
26
+ resourceName: string;
27
+ }
28
+ /**
29
+ * A configured MCP auth strategy. `verify` validates a bearer token and resolves the acting {@link Actor}
30
+ * (attached to `AuthInfo.extra.actor`); it MUST throw when the token is missing/invalid/expired. The
31
+ * same `AuthInfo` is surfaced to the `tools/list` / `tools/call` handlers as `extra.authInfo`, so the
32
+ * actor the tool registry gates against is exactly the one the auth strategy resolved.
33
+ */
34
+ export interface McpAuth {
35
+ /** OAuth metadata to advertise, resolved lazily (the authkit peer may not be bootable until first use). */
36
+ oauth?: McpOAuthMetadata | (() => McpOAuthMetadata | Promise<McpOAuthMetadata>);
37
+ /** Validate `token` and resolve the acting actor. Throws `Error` on rejection. */
38
+ verify(token: string): Promise<AuthInfo>;
39
+ }
40
+ /**
41
+ * A configured MCP auth strategy, as a lazy thunk the provider calls at boot. Each factory lazily
42
+ * imports / resolves its peer inside the thunk, so nothing loads until the strategy is actually selected.
43
+ */
44
+ export type McpAuthFactory = (ctx: McpAuthContext) => McpAuth | Promise<McpAuth>;
45
+ /**
46
+ * Resolve a `McpAuth` config value (a ready instance or a lazy factory) at provider boot.
47
+ */
48
+ export declare function resolveMcpAuth(auth: McpAuth | McpAuthFactory, ctx: McpAuthContext): Promise<McpAuth>;
49
+ /** How `authKitAuth()` maps an access token to the MCP actor. Defaults to the account id. */
50
+ export type AuthKitActorResolver = (info: {
51
+ accountId: string;
52
+ scopes: string[];
53
+ clientId: string | undefined;
54
+ }) => Actor | Promise<Actor>;
55
+ /** Options for {@link authKitAuth}. */
56
+ export interface AuthKitMcpAuthOptions {
57
+ /** Scopes the authorization server advertises. Defaults to the standard authkit scopes. */
58
+ scopes?: string[];
59
+ /** Map a validated access token to the acting {@link Actor}. Defaults to `{ id: accountId }`. */
60
+ toActor?: AuthKitActorResolver;
61
+ /** Human label for the protected resource. Defaults to `'Agent MCP Server'`. */
62
+ resourceName?: string;
63
+ }
64
+ /**
65
+ * Authenticate MCP clients with `@adonis-agora/authkit-server`: verifies the bearer token against the
66
+ * authkit OIDC provider's stored access tokens (`provider.AccessToken.find`) and advertises OAuth
67
+ * metadata derived from the issuer so MCP clients can run the full OAuth login flow.
68
+ *
69
+ * The authkit peer is resolved lazily — the `verify`/`oauth` accessors touch the container only when
70
+ * a request actually arrives (by then the app is fully booted and the authkit keystore/encryption
71
+ * services are ready). `@adonis-agora/authkit-server` stays an optional dependency. Throws a clear
72
+ * error at first use if the binding isn't resolvable (authkit not installed / provider not registered).
73
+ */
74
+ export declare function authKitAuth(options?: AuthKitMcpAuthOptions): McpAuthFactory;
75
+ /** Resolve the MCP actor from a validated API key. Defaults to `{ id: apiKey }`. */
76
+ export type ApiKeyActorResolver = (apiKey: string) => Actor | Promise<Actor>;
77
+ /** Options for {@link apiKeyAuth}. */
78
+ export interface ApiKeyMcpAuthOptions {
79
+ /** Static API keys clients present in `Authorization: Bearer <key>`. */
80
+ apiKeys: string[];
81
+ /** Map a validated API key to the acting {@link Actor}. Defaults to `{ id: apiKey }`. */
82
+ toActor?: ApiKeyActorResolver;
83
+ }
84
+ /**
85
+ * Authenticate MCP clients with a static list of API keys (no OAuth metadata). Intended for trusted
86
+ * gateway / machine-to-machine integrations where the host proxies auth and this server just
87
+ * checks the key. Keys are compared with a constant-time compare to resist timing attacks.
88
+ */
89
+ export declare function apiKeyAuth(options: ApiKeyMcpAuthOptions): McpAuthFactory;
90
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/mcp/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,kBAAkB,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yGAAyG;IACzG,MAAM,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oFAAoF;IACpF,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;CACtB;A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,CAAC;IAClB,yFAAyF;IACzF,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,oBAAoB,GAAG,cAAc,CAcxE"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Resolve a `McpAuth` config value (a ready instance or a lazy factory) at provider boot.
3
+ */
4
+ export async function resolveMcpAuth(auth, ctx) {
5
+ if (typeof auth === 'function') {
6
+ return auth(ctx);
7
+ }
8
+ return auth;
9
+ }
10
+ /**
11
+ * Authenticate MCP clients with `@adonis-agora/authkit-server`: verifies the bearer token against the
12
+ * authkit OIDC provider's stored access tokens (`provider.AccessToken.find`) and advertises OAuth
13
+ * metadata derived from the issuer so MCP clients can run the full OAuth login flow.
14
+ *
15
+ * The authkit peer is resolved lazily — the `verify`/`oauth` accessors touch the container only when
16
+ * a request actually arrives (by then the app is fully booted and the authkit keystore/encryption
17
+ * services are ready). `@adonis-agora/authkit-server` stays an optional dependency. Throws a clear
18
+ * error at first use if the binding isn't resolvable (authkit not installed / provider not registered).
19
+ */
20
+ export function authKitAuth(options = {}) {
21
+ const scopes = options.scopes ?? ['openid', 'profile', 'email', 'offline_access', 'roles'];
22
+ const toActor = options.toActor ?? (({ accountId }) => ({ id: accountId }));
23
+ return async ({ app }) => {
24
+ let servicePromise;
25
+ const getService = () => {
26
+ servicePromise ??= resolveAuthKitService(app);
27
+ return servicePromise;
28
+ };
29
+ const oauth = async () => {
30
+ const service = await getService();
31
+ const issuer = service.config.issuer;
32
+ return {
33
+ issuer,
34
+ authorizationEndpoint: `${issuer}/auth`,
35
+ tokenEndpoint: `${issuer}/token`,
36
+ scopesSupported: scopes,
37
+ resourceName: options.resourceName ?? 'Agent MCP Server',
38
+ };
39
+ };
40
+ return {
41
+ oauth,
42
+ async verify(token) {
43
+ const service = await getService();
44
+ const at = await service.provider.AccessToken.find(token);
45
+ if (!at || at.isExpired) {
46
+ throw new Error('invalid or expired access token');
47
+ }
48
+ const tokenScopes = (at.scope ?? '').split(' ').filter(Boolean);
49
+ const actor = await toActor({
50
+ accountId: at.accountId,
51
+ scopes: tokenScopes,
52
+ clientId: at.clientId,
53
+ });
54
+ return {
55
+ token,
56
+ clientId: at.clientId ?? '',
57
+ scopes: tokenScopes,
58
+ ...(at.exp !== undefined ? { expiresAt: at.exp } : {}),
59
+ extra: { actor },
60
+ };
61
+ },
62
+ };
63
+ };
64
+ }
65
+ /**
66
+ * Resolve the authkit `OidcService` from the container. `@adonis-agora/authkit-server` augments
67
+ * `ContainerBindings` with `'authkit.server'`, so `make` is fully typed with no cast.
68
+ */
69
+ async function resolveAuthKitService(app) {
70
+ try {
71
+ return await app.container.make('authkit.server');
72
+ }
73
+ catch (error) {
74
+ const message = error instanceof Error ? error.message : String(error);
75
+ throw new Error(`[@adonis-agora/agent] \`authKitAuth()\` could not resolve the authkit server (${message}). Is \`@adonis-agora/authkit-server\` installed and its provider registered in adonisrc.ts?`);
76
+ }
77
+ }
78
+ /**
79
+ * Authenticate MCP clients with a static list of API keys (no OAuth metadata). Intended for trusted
80
+ * gateway / machine-to-machine integrations where the host proxies auth and this server just
81
+ * checks the key. Keys are compared with a constant-time compare to resist timing attacks.
82
+ */
83
+ export function apiKeyAuth(options) {
84
+ const keys = new Set(options.apiKeys);
85
+ const toActor = options.toActor ?? ((apiKey) => ({ id: apiKey }));
86
+ return async () => {
87
+ return {
88
+ async verify(token) {
89
+ if (![...keys].some((key) => timingSafeEqual(key, token))) {
90
+ throw new Error('invalid API key');
91
+ }
92
+ const actor = await toActor(token);
93
+ return { token, clientId: token, scopes: [], extra: { actor } };
94
+ },
95
+ };
96
+ };
97
+ }
98
+ /** Constant-time string comparison (no `node:crypto` import at module top to keep the browser-safe build). */
99
+ function timingSafeEqual(a, b) {
100
+ if (a.length !== b.length)
101
+ return false;
102
+ let diff = 0;
103
+ for (let i = 0; i < a.length; i++) {
104
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
105
+ }
106
+ return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ClC,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { RolesPolicy } from '../spi/roles-policy.js';
2
+ import { apiKeyAuth, authKitAuth } from './auth.js';
3
+ import type { McpAuth, McpAuthFactory } from './auth.js';
4
+ /**
5
+ * Shape of `config/mcp.ts`. The MCP provider exposes the agent's {@link ToolRegistry} over the Model
6
+ * Context Protocol (Streamable HTTP): `tools/list` mirrors the tools the acting actor may call
7
+ * (role-filtered), `tools/call` runs them through the registry (role re-check + schema re-validation).
8
+ *
9
+ * ```ts
10
+ * import { defineMcpConfig, authKitAuth } from '@adonis-agora/agent/mcp'
11
+ *
12
+ * export default defineMcpConfig({
13
+ * name: 'Lumen Agent',
14
+ * version: '1.0.0',
15
+ * auth: authKitAuth(),
16
+ * path: 'mcp',
17
+ * })
18
+ * ```
19
+ */
20
+ export interface McpConfig {
21
+ /** Server name reported to MCP clients in the initialize handshake. */
22
+ name: string;
23
+ /** Server version reported to MCP clients. */
24
+ version: string;
25
+ /**
26
+ * Route prefix the MCP Streamable HTTP endpoint mounts under. Defaults to `'mcp'` (→ `/mcp`).
27
+ * OAuth metadata (when `auth.oauth` is set) is served at `/.well-known/oauth-protected-resource{path}`.
28
+ */
29
+ path?: string;
30
+ /**
31
+ * How MCP clients authenticate. Pass a ready {@link McpAuth} or a lazy {@link McpAuthFactory} thunk
32
+ * (`authKitAuth()` / `apiKeyAuth()`). Omit → the server is open (no bearer check); the acting actor
33
+ * falls back to `actor`. Fail-closed: with no `auth` AND no `actor`, requests are rejected.
34
+ */
35
+ auth?: McpAuth | McpAuthFactory;
36
+ /**
37
+ * The acting actor when `auth` is omitted (dev/open mode). Fail-closed default: omitted → requests
38
+ * are rejected 401. Set it (e.g. `{ id: 'mcp', roles: ['ADMIN'] }`) to let unauthenticated clients
39
+ * run tools under that identity.
40
+ */
41
+ actor?: {
42
+ id: string;
43
+ roles?: string[];
44
+ tenantRef?: string;
45
+ };
46
+ /**
47
+ * Tool authorization gate. Defaults to `DefaultToolAuthorizer(config.defaultRoles ?? ['ADMIN'])` —
48
+ * same fail-closed default as the agent provider.
49
+ */
50
+ authorizer?: RolesPolicy;
51
+ /** Roles a tool requires when it declares none. Defaults to `['ADMIN']`. */
52
+ defaultRoles?: string[];
53
+ /**
54
+ * Restrict the exposed tools to this allow-list of names. Omit → all tools the acting actor's roles
55
+ * permit are exposed.
56
+ */
57
+ allowedTools?: string[];
58
+ }
59
+ /** Identity helper giving `config/mcp.ts` full type-checking. */
60
+ export declare function defineMcpConfig(config: McpConfig): McpConfig;
61
+ export { authKitAuth, apiKeyAuth };
62
+ export type { McpAuth, McpAuthFactory, McpAuthContext, McpOAuthMetadata, AuthKitMcpAuthOptions, AuthKitActorResolver, ApiKeyMcpAuthOptions, ApiKeyActorResolver, } from './auth.js';
63
+ export { resolveMcpAuth } from './auth.js';
64
+ //# sourceMappingURL=define_config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../../src/mcp/define_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IAChC;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAE5D;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACnC,YAAY,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { apiKeyAuth, authKitAuth } from './auth.js';
2
+ /** Identity helper giving `config/mcp.ts` full type-checking. */
3
+ export function defineMcpConfig(config) {
4
+ return config;
5
+ }
6
+ export { authKitAuth, apiKeyAuth };
7
+ export { resolveMcpAuth } from './auth.js';
8
+ //# sourceMappingURL=define_config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define_config.js","sourceRoot":"","sources":["../../../src/mcp/define_config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAuDpD,iEAAiE;AACjE,MAAM,UAAU,eAAe,CAAC,MAAiB;IAC/C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AAWnC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { defineMcpConfig } from './define_config.js';
2
+ export { authKitAuth, apiKeyAuth, resolveMcpAuth } from './auth.js';
3
+ export { createMcpServer } from './server.js';
4
+ export type { McpConfig } from './define_config.js';
5
+ export type { McpAuth, McpAuthFactory, McpAuthContext, McpOAuthMetadata, AuthKitMcpAuthOptions, AuthKitActorResolver, ApiKeyMcpAuthOptions, ApiKeyActorResolver, } from './auth.js';
6
+ export type { CreateMcpServerOptions, McpToolContextOptions } from './server.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { defineMcpConfig } from './define_config.js';
2
+ export { authKitAuth, apiKeyAuth, resolveMcpAuth } from './auth.js';
3
+ export { createMcpServer } from './server.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import type { RolesPolicy } from '../spi/roles-policy.js';
4
+ import { ToolRegistry } from '../tool-registry.js';
5
+ import type { Actor } from '../types.js';
6
+ /**
7
+ * Runtime context a MCP handler synthesizes for {@link ToolRegistry.invoke}: the acting {@link Actor}
8
+ * comes from the verified auth, and the run/request ids from the MCP request so tool traces map back
9
+ * to the MCP session.
10
+ */
11
+ export interface McpToolContextOptions {
12
+ /** How the actor is resolved from the transport's verified auth info. */
13
+ actorFromAuth: (authInfo: AuthInfo | undefined) => Actor;
14
+ /** How run/thread/request ids are derived. Defaults to the MCP session + request ids. */
15
+ idsFromRequest?: (sessionId: string | undefined, requestId: string | number | undefined) => {
16
+ threadId: string;
17
+ runId: string;
18
+ requestId: string;
19
+ };
20
+ }
21
+ /** Options for {@link createMcpServer}. */
22
+ export interface CreateMcpServerOptions extends McpToolContextOptions {
23
+ /** Server name reported in the initialize handshake. */
24
+ name: string;
25
+ /** Server version reported in the initialize handshake. */
26
+ version: string;
27
+ /** The agent tool registry to expose. */
28
+ registry: ToolRegistry;
29
+ /** Tool authorization gate (role re-check happens per call, defense-in-depth). */
30
+ policy: RolesPolicy;
31
+ /** Optional allow-list restricting which tools are exposed. */
32
+ allowedTools?: string[];
33
+ }
34
+ /**
35
+ * Build a low-level MCP `Server` that exposes the agent's {@link ToolRegistry} over the wire:
36
+ *
37
+ * - `tools/list` → `registry.definitionsFor(actor, policy, allowedTools)` — the tools the acting
38
+ * actor's roles permit (fail-closed via the same `RolesPolicy` the agent loop uses), converted to
39
+ * MCP `Tool` descriptors with JSON-Schema inputs.
40
+ * - `tools/call` → `registry.invoke(name, args, ctx, policy)` — role re-check + input re-validation
41
+ * before the handler runs (the registry's own defense-in-depth), so a stale tool list can never
42
+ * bypass the gate.
43
+ *
44
+ * Use this in the MCP provider (one server per session, connected to that session's transport).
45
+ */
46
+ export declare function createMcpServer(options: CreateMcpServerOptions): Server;
47
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,aAAa,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,KAAK,KAAK,CAAC;IACzD,yFAAyF;IACzF,cAAc,CAAC,EAAE,CACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,KACnC;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,2CAA2C;AAC3C,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACnE,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,QAAQ,EAAE,YAAY,CAAC;IACvB,kFAAkF;IAClF,MAAM,EAAE,WAAW,CAAC;IACpB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AA4CD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAgDvE"}
@@ -0,0 +1,94 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { toJsonSchemaCompat } from '@modelcontextprotocol/sdk/server/zod-json-schema-compat.js';
3
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
+ /**
5
+ * True for a Zod schema (tags its Standard Schema props with `vendor: 'zod'`). Narrows to the SDK's
6
+ * `AnyObjectSchema` so `toJsonSchemaCompat` can consume it without a cast.
7
+ */
8
+ function isZodSchema(schema) {
9
+ return schema['~standard'].vendor === 'zod';
10
+ }
11
+ /** True when the schema carries the Standard JSON Schema converter (`~standard.jsonSchema.input`). */
12
+ function hasStandardJsonSchema(schema) {
13
+ const standard = schema['~standard'];
14
+ if (!('jsonSchema' in standard)) {
15
+ return false;
16
+ }
17
+ const converter = standard.jsonSchema;
18
+ return (typeof converter === 'object' &&
19
+ converter !== null &&
20
+ 'input' in converter &&
21
+ typeof converter.input === 'function');
22
+ }
23
+ /**
24
+ * Convert a core `StandardSchemaV1` tool schema into the JSON Schema MCP clients see in `tools/list`.
25
+ * Zod schemas are converted with the SDK's compat helper (handles both v3 and v4); schemas that expose
26
+ * the Standard JSON Schema extension (Valibot/ArkType/Zod 4) hand their `input()` schema straight
27
+ * through. Anything else degrades to a permissive object schema — the loop still validates the real
28
+ * schema on call via `~standard.validate`.
29
+ */
30
+ function toJsonSchema(schema) {
31
+ if (isZodSchema(schema)) {
32
+ return toJsonSchemaCompat(schema);
33
+ }
34
+ if (hasStandardJsonSchema(schema)) {
35
+ return schema['~standard'].jsonSchema.input();
36
+ }
37
+ return { type: 'object', properties: {}, additionalProperties: true };
38
+ }
39
+ /**
40
+ * Build a low-level MCP `Server` that exposes the agent's {@link ToolRegistry} over the wire:
41
+ *
42
+ * - `tools/list` → `registry.definitionsFor(actor, policy, allowedTools)` — the tools the acting
43
+ * actor's roles permit (fail-closed via the same `RolesPolicy` the agent loop uses), converted to
44
+ * MCP `Tool` descriptors with JSON-Schema inputs.
45
+ * - `tools/call` → `registry.invoke(name, args, ctx, policy)` — role re-check + input re-validation
46
+ * before the handler runs (the registry's own defense-in-depth), so a stale tool list can never
47
+ * bypass the gate.
48
+ *
49
+ * Use this in the MCP provider (one server per session, connected to that session's transport).
50
+ */
51
+ export function createMcpServer(options) {
52
+ const { registry, policy, allowedTools, actorFromAuth, idsFromRequest } = options;
53
+ const server = new Server({ name: options.name, version: options.version }, { capabilities: { tools: {} } });
54
+ const buildCtx = (authInfo, sessionId) => {
55
+ const actor = actorFromAuth(authInfo);
56
+ const ids = idsFromRequest
57
+ ? idsFromRequest(sessionId, undefined)
58
+ : {
59
+ threadId: `mcp:${sessionId ?? actor.id}`,
60
+ runId: `mcp:${sessionId ?? 'run'}`,
61
+ requestId: `mcp:${sessionId ?? 'req'}`,
62
+ };
63
+ return { actor, ...ids };
64
+ };
65
+ server.setRequestHandler(ListToolsRequestSchema, async (request, extra) => {
66
+ const actor = actorFromAuth(extra.authInfo);
67
+ const defs = await registry.definitionsFor(actor, policy, allowedTools);
68
+ return {
69
+ tools: defs.map((definition) => ({
70
+ name: definition.name,
71
+ description: definition.description,
72
+ inputSchema: toJsonSchema(definition.inputSchema),
73
+ })),
74
+ };
75
+ });
76
+ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
77
+ const ctx = buildCtx(extra.authInfo, extra.sessionId);
78
+ const { name, arguments: args } = request.params;
79
+ try {
80
+ const output = await registry.invoke(name, args ?? {}, ctx, policy);
81
+ return {
82
+ content: [
83
+ { type: 'text', text: typeof output === 'string' ? output : JSON.stringify(output) },
84
+ ],
85
+ };
86
+ }
87
+ catch (error) {
88
+ const message = error instanceof Error ? error.message : String(error);
89
+ return { content: [{ type: 'text', text: message }], isError: true };
90
+ }
91
+ });
92
+ return server;
93
+ }
94
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAA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K,EAAE,EAAE;QACvE,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;QACtD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QACjD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;YACpE,OAAO;gBACL,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;iBACrF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACvE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -3,12 +3,47 @@ export interface ChunkOptions {
3
3
  chunkSize?: number;
4
4
  /** Characters of overlap carried from the end of one chunk into the next. Default 100. */
5
5
  overlap?: number;
6
+ /**
7
+ * The record delimiter, when the text has boundaries that *mean* something. Pass it and the chunker
8
+ * cuts ONLY on this string — never inside a record.
9
+ *
10
+ * Prose has no real boundaries, so the default heuristic (paragraph → sentence → word, in the back
11
+ * half of the window) is the right guess. Machine-shaped text is the opposite case: a spreadsheet
12
+ * flattened to one field-labelled record per line, a log, a JSONL export. There the boundaries are
13
+ * known exactly, and a heuristic cut lands mid-record — stranding the half that carries the row
14
+ * identifier in a different chunk from the half that carries the value, so neither chunk can answer
15
+ * a question about that row. `separator: '\n'` says "the lines are the records".
16
+ *
17
+ * Two consequences worth knowing before you pass it, both by design:
18
+ *
19
+ * 1. **`chunkSize` becomes a target, not a cap.** A single record longer than `chunkSize` is emitted
20
+ * whole, as its own over-size chunk. It is NOT split, and it does NOT fall back to the prose
21
+ * heuristic — a mid-record cut is the exact failure `separator` exists to prevent, so silently
22
+ * performing one to respect a size limit would defeat the feature. An over-size chunk is visible
23
+ * (you can see the record, and shorten it or raise `chunkSize`); a mangled record is not. It never
24
+ * drags its neighbours over the limit either: it always chunks alone.
25
+ * 2. **`overlap` is spent on whole records.** It stops being a character count and becomes a
26
+ * character *budget*, filled with entire trailing records of the previous chunk — as many as fit,
27
+ * never a partial one, and never so many that a chunk fails to advance. Half a record is not
28
+ * useful context; it is the same mid-record cut by another name. `overlap: 0` carries nothing,
29
+ * which is usually what self-contained records want.
30
+ *
31
+ * Empty or whitespace-only records are dropped. An empty string is treated as "not passed" (it would
32
+ * otherwise split every character), leaving the prose path. Omit it and NOTHING changes: the prose
33
+ * path below is untouched, byte-for-byte, so no existing corpus is re-chunked (and so none has to be
34
+ * re-embedded).
35
+ */
36
+ separator?: string;
6
37
  }
7
38
  /**
8
39
  * Splits text into overlapping chunks for embedding. Greedy up to `chunkSize`, but prefers to break on
9
40
  * a paragraph → sentence → word boundary in the back half of the window (so a chunk rarely cuts
10
41
  * mid-sentence), then carries `overlap` characters into the next chunk to preserve context across the
11
42
  * seam. Pure and deterministic.
43
+ *
44
+ * Pass {@link ChunkOptions.separator} for text whose record boundaries are known rather than guessed;
45
+ * that path cuts only on the separator, and its two deviations (`chunkSize` becomes a target,
46
+ * `overlap` is spent on whole records) are documented there.
12
47
  */
13
48
  export declare function chunkText(text: string, options?: ChunkOptions): string[];
14
49
  //# sourceMappingURL=chunk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../src/rag/chunk.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,EAAE,CAuC5E"}
1
+ {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../src/rag/chunk.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,EAAE,CA2C5E"}
@@ -3,10 +3,18 @@
3
3
  * a paragraph → sentence → word boundary in the back half of the window (so a chunk rarely cuts
4
4
  * mid-sentence), then carries `overlap` characters into the next chunk to preserve context across the
5
5
  * seam. Pure and deterministic.
6
+ *
7
+ * Pass {@link ChunkOptions.separator} for text whose record boundaries are known rather than guessed;
8
+ * that path cuts only on the separator, and its two deviations (`chunkSize` becomes a target,
9
+ * `overlap` is spent on whole records) are documented there.
6
10
  */
7
11
  export function chunkText(text, options = {}) {
8
12
  const chunkSize = options.chunkSize ?? 800;
9
13
  const overlap = options.overlap ?? 100;
14
+ const separator = options.separator;
15
+ if (separator !== undefined && separator.length > 0) {
16
+ return chunkRecords(text, separator, chunkSize, overlap);
17
+ }
10
18
  const normalized = text.trim();
11
19
  if (normalized.length === 0) {
12
20
  return [];
@@ -39,4 +47,56 @@ export function chunkText(text, options = {}) {
39
47
  }
40
48
  return chunks;
41
49
  }
50
+ /**
51
+ * The {@link ChunkOptions.separator} path: pack WHOLE records into chunks. Records are the atoms here —
52
+ * no chunk ever contains a fragment of one — so `chunkSize` is honoured by taking fewer records rather
53
+ * than by cutting one, and `overlap` is honoured by repeating trailing records rather than by repeating
54
+ * characters. Pure and deterministic; see {@link ChunkOptions.separator} for the two trades.
55
+ */
56
+ function chunkRecords(text, separator, chunkSize, overlap) {
57
+ const records = text
58
+ .split(separator)
59
+ .map((record) => record.trim())
60
+ .filter((record) => record.length > 0);
61
+ if (records.length === 0) {
62
+ return [];
63
+ }
64
+ const chunks = [];
65
+ let start = 0;
66
+ while (start < records.length) {
67
+ // Pack forward while the joined length fits. The FIRST record is taken unconditionally: that is
68
+ // what emits an over-long record whole instead of cutting it (trade 1).
69
+ let end = start;
70
+ let length = 0;
71
+ while (end < records.length) {
72
+ const record = records[end] ?? '';
73
+ const cost = end === start ? record.length : separator.length + record.length;
74
+ if (end > start && length + cost > chunkSize) {
75
+ break;
76
+ }
77
+ length += cost;
78
+ end += 1;
79
+ }
80
+ chunks.push(records.slice(start, end).join(separator));
81
+ if (end >= records.length) {
82
+ break;
83
+ }
84
+ // Overlap as a whole-record budget: walk back over trailing records while they fit in `overlap`.
85
+ // `back > start + 1` keeps at least one record consumed by this chunk, so `start` strictly
86
+ // increases — an over-long record (which always chunks alone) is therefore never carried forward,
87
+ // and no `overlap`, however large, can stall the loop.
88
+ let back = end;
89
+ let carried = 0;
90
+ while (back > start + 1) {
91
+ const cost = (records[back - 1] ?? '').length + separator.length;
92
+ if (carried + cost > overlap) {
93
+ break;
94
+ }
95
+ carried += cost;
96
+ back -= 1;
97
+ }
98
+ start = back;
99
+ }
100
+ return chunks;
101
+ }
42
102
  //# sourceMappingURL=chunk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/rag/chunk.ts"],"names":[],"mappings":"AAOA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I,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;YACjE,IAAI,OAAO,GAAG,IAAI,GAAG,OAAO,EAAE,CAAC;gBAC7B,MAAM;YACR,CAAC;YACD,OAAO,IAAI,IAAI,CAAC;YAChB,IAAI,IAAI,CAAC,CAAC;QACZ,CAAC;QACD,KAAK,GAAG,IAAI,CAAC;IACf,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { chunkText, type ChunkOptions } from './chunk.js';
2
- export { documentIdOf, type IndexedDocument, type VectorRecord, type VectorSearchOptions, type VectorStore, } from './vector-store.js';
2
+ export { applyMetadataPatch, assertRemovalFilter, documentIdOf, effectivePatchKeys, filterDeniesAll, UnsafeRemovalError, type IndexedDocument, type MetadataPatch, type VectorRecord, type VectorSearchOptions, type VectorStore, } from './vector-store.js';
3
3
  export { matchesFilter } from './filter.js';
4
4
  export { MemoryVectorStore, cosineSimilarity } from './memory-vector-store.js';
5
5
  export { EmbeddingRetriever } from './embedding-retriever.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rag/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,E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