@dudousxd/nestjs-agent 1.9.0 → 1.11.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/README.md +159 -34
- package/dist/{agent-deps.factory-DuTy1UyU.d.cts → agent-deps.factory-BRTBu0lV.d.cts} +25 -21
- package/dist/{agent-deps.factory-DuTy1UyU.d.ts → agent-deps.factory-BRTBu0lV.d.ts} +25 -21
- package/dist/durable/index.cjs +153 -23
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +1 -1
- package/dist/durable/index.d.ts +1 -1
- package/dist/durable/index.js +156 -26
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +219 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +100 -11
- package/dist/index.d.ts +100 -11
- package/dist/index.js +218 -27
- package/dist/index.js.map +1 -1
- package/dist/media/index.cjs +641 -0
- package/dist/media/index.cjs.map +1 -0
- package/dist/media/index.d.cts +238 -0
- package/dist/media/index.d.ts +238 -0
- package/dist/media/index.js +608 -0
- package/dist/media/index.js.map +1 -0
- package/package.json +20 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, OnModuleInit, Type, OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
-
import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, d as AgentSkillsOptions } from './agent-deps.factory-
|
|
3
|
-
export { e as AGENT_TOOL_BRAND, f as AgentAttachmentsOptions, g as AgentDeps, h as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QuotaLimits, i as QuotaWindowLimits, j as delegateToolName, p as provideAgentTool, k as provideAgentTools, u as utcDay } from './agent-deps.factory-
|
|
2
|
+
import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, d as AgentSkillsOptions } from './agent-deps.factory-BRTBu0lV.cjs';
|
|
3
|
+
export { e as AGENT_TOOL_BRAND, f as AgentAttachmentsOptions, g as AgentDeps, h as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QuotaLimits, i as QuotaWindowLimits, j as delegateToolName, p as provideAgentTool, k as provideAgentTools, u as utcDay } from './agent-deps.factory-BRTBu0lV.cjs';
|
|
4
4
|
import { AgentRunner, AgentStore, QuotaStore, AttachmentStagingStore, ModelCatalog, QuotaProvider, Actor, QuotaReport, ModelCatalogView, AttachmentRef, PageContext, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, QuotaView, AgentApprovalPort, ActorResolver, MessageAttachment, ToolPresentation, AgentHistoryWindow, AgentIntake, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, TokenStreamSink, SinkWriter, QuotaState } from '@dudousxd/nestjs-agent-core';
|
|
5
5
|
export * from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
import { Request } from 'express';
|
|
@@ -367,19 +367,27 @@ declare class AttachmentsController implements OnModuleInit {
|
|
|
367
367
|
|
|
368
368
|
declare const AI_TOOL_METADATA: unique symbol;
|
|
369
369
|
interface AiToolOptions {
|
|
370
|
-
name: string;
|
|
371
370
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
371
|
+
* What the model calls it. Omit → the class name, camelCased, with a trailing `Tool` dropped
|
|
372
|
+
* (`GetWeatherTool` → `getWeather`).
|
|
374
373
|
*/
|
|
375
|
-
|
|
374
|
+
name?: string;
|
|
375
|
+
/**
|
|
376
|
+
* `read` (the default) auto-executes; `action` requires HITL approval. (Core's `ToolKind` also
|
|
377
|
+
* has `agent` for delegation, but that kind is synthesized from `delegatesTo` — never authored
|
|
378
|
+
* here.)
|
|
379
|
+
*/
|
|
380
|
+
kind?: 'read' | 'action';
|
|
376
381
|
description: string;
|
|
377
382
|
/**
|
|
378
383
|
* Input schema as a [Standard Schema](https://standardschema.dev) — Zod, Valibot, or ArkType.
|
|
379
384
|
* Validated before the handler runs.
|
|
380
385
|
*/
|
|
381
386
|
input: StandardSchemaV1;
|
|
382
|
-
/**
|
|
387
|
+
/**
|
|
388
|
+
* Roles allowed to invoke. Omit → the module's `defaultRoles`, which by default restrict nobody:
|
|
389
|
+
* any resolved actor — an anonymous visitor included, when no `actorResolver` is configured.
|
|
390
|
+
*/
|
|
383
391
|
roles?: string[];
|
|
384
392
|
/**
|
|
385
393
|
* Whether this tool exists in this deployment. `false` — or a predicate returning `false`, which
|
|
@@ -420,13 +428,21 @@ interface AiToolOptions {
|
|
|
420
428
|
*/
|
|
421
429
|
terminal?: boolean;
|
|
422
430
|
}
|
|
431
|
+
/** {@link AiToolOptions} with the defaults applied — what discovery reads. */
|
|
432
|
+
interface ResolvedAiToolOptions extends AiToolOptions {
|
|
433
|
+
name: string;
|
|
434
|
+
kind: 'read' | 'action';
|
|
435
|
+
}
|
|
436
|
+
/** `GetWeatherTool` → `getWeather`; `SQLQueryTool` → `sqlQuery`. */
|
|
437
|
+
declare function toolNameFromClass(className: string): string;
|
|
423
438
|
/**
|
|
424
439
|
* Marks a provider class as an AI tool. The class must implement `execute(input, ctx)`.
|
|
425
440
|
* `AiToolDiscoveryService` registers every `@AiTool` provider into the `ToolRegistry` at boot.
|
|
441
|
+
* Only `description` and `input` are required:
|
|
426
442
|
*
|
|
427
443
|
* ```ts
|
|
428
|
-
* @AiTool({
|
|
429
|
-
* class GetWeatherTool implements ToolHandler<{ city: string }> {
|
|
444
|
+
* @AiTool({ description: 'Current weather for a city', input: z.object({ city: z.string() }) })
|
|
445
|
+
* class GetWeatherTool implements ToolHandler<{ city: string }> { // name: getWeather, kind: read
|
|
430
446
|
* async execute(input, ctx) { return { tempC: 21 }; }
|
|
431
447
|
* }
|
|
432
448
|
* ```
|
|
@@ -444,7 +460,7 @@ interface AiToolOptions {
|
|
|
444
460
|
* ```
|
|
445
461
|
*/
|
|
446
462
|
declare function AiTool(options: AiToolOptions): ClassDecorator;
|
|
447
|
-
declare function readAiToolMetadata(target: object):
|
|
463
|
+
declare function readAiToolMetadata(target: object): ResolvedAiToolOptions | undefined;
|
|
448
464
|
|
|
449
465
|
/**
|
|
450
466
|
* Declares a class as an agent. The class is discovered at boot (via `DiscoveryService`) and
|
|
@@ -946,4 +962,77 @@ declare class HeaderActorResolver implements ActorResolver {
|
|
|
946
962
|
resolve(req: unknown): Actor;
|
|
947
963
|
}
|
|
948
964
|
|
|
949
|
-
|
|
965
|
+
interface AnonymousActorOptions {
|
|
966
|
+
/** The cookie holding the browser's anonymous token. Default `agent_anon`. */
|
|
967
|
+
cookieName?: string;
|
|
968
|
+
/** How long a browser keeps its identity (and so its threads). Default 365 days. */
|
|
969
|
+
maxAgeDays?: number;
|
|
970
|
+
/**
|
|
971
|
+
* `SameSite` of the cookie. Default `'lax'` — sent on same-site requests, not on cross-site
|
|
972
|
+
* POSTs. A SPA on another SITE than the API needs `'none'` (which forces `Secure`) plus
|
|
973
|
+
* `credentials: 'include'` on the client.
|
|
974
|
+
*/
|
|
975
|
+
sameSite?: 'lax' | 'strict' | 'none';
|
|
976
|
+
/**
|
|
977
|
+
* `Secure` flag. Default `'auto'`: set when the request arrived over HTTPS (`req.secure`, or an
|
|
978
|
+
* `x-forwarded-proto: https` from a proxy).
|
|
979
|
+
*/
|
|
980
|
+
secure?: boolean | 'auto';
|
|
981
|
+
/** Cookie path. Default `/`. */
|
|
982
|
+
path?: string;
|
|
983
|
+
/** Roles every anonymous actor carries. Default `['anonymous']`. */
|
|
984
|
+
roles?: string[];
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* The zero-config identity: every browser is its own anonymous actor, so a login-less chat still
|
|
988
|
+
* keeps each visitor's threads, quota and attachments apart from everyone else's.
|
|
989
|
+
*
|
|
990
|
+
* On a browser's first request the resolver mints 32 random bytes and sets them as an `HttpOnly`
|
|
991
|
+
* cookie (`SameSite=Lax`, `Secure` over HTTPS). The actor id is a SHA-256 digest of that token —
|
|
992
|
+
* `anon:<digest>` — never the token itself, so an id that surfaces anywhere (a thread row, a log, an
|
|
993
|
+
* approval's `decidedBy`) cannot be replayed as the cookie.
|
|
994
|
+
*
|
|
995
|
+
* Why a server-minted cookie and not an id the client makes up and sends in a header: an
|
|
996
|
+
* `HttpOnly` cookie is out of reach of page scripts (an XSS cannot lift it), the server — not the
|
|
997
|
+
* client — decides the value, and it needs no client code at all. There is no signing secret to
|
|
998
|
+
* configure: the token is unguessable on its own, and the digest works the same on every pod and
|
|
999
|
+
* after a restart.
|
|
1000
|
+
*
|
|
1001
|
+
* Anonymous identities are per browser, not per person: clearing cookies starts over, and there is
|
|
1002
|
+
* nothing to recover them with. Require login with an `ActorResolver` that reads your session —
|
|
1003
|
+
* `requestUserActorResolver()` for `req.user` (Passport / cookie-session apps).
|
|
1004
|
+
*/
|
|
1005
|
+
declare class AnonymousActorResolver implements ActorResolver {
|
|
1006
|
+
private readonly options;
|
|
1007
|
+
private readonly cookieName;
|
|
1008
|
+
private readonly roles;
|
|
1009
|
+
constructor(options?: AnonymousActorOptions);
|
|
1010
|
+
resolve(request: unknown): Actor;
|
|
1011
|
+
private setCookie;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/** Turns whatever your auth put on `req.user` into the agent's {@link Actor}. */
|
|
1015
|
+
type RequestUserMapper<TUser = Record<string, unknown>> = (user: TUser, req: unknown) => Actor | Promise<Actor>;
|
|
1016
|
+
/**
|
|
1017
|
+
* The default mapping: `id` from `id` / `sub` / `_id` / `userId`, `roles` from `roles` (an array)
|
|
1018
|
+
* or `role` (a string), `tenantRef` from `tenantRef` / `tenantId` / `orgId`.
|
|
1019
|
+
*/
|
|
1020
|
+
declare function defaultRequestUserMapper(user: Record<string, unknown>): Actor;
|
|
1021
|
+
/**
|
|
1022
|
+
* Authenticated mode in one line, for apps whose auth already puts the principal on `req.user` —
|
|
1023
|
+
* Passport strategies, `express-session` / cookie-session middleware, a Nest guard that assigns it:
|
|
1024
|
+
*
|
|
1025
|
+
* ```ts
|
|
1026
|
+
* AgentModule.forRoot({ model, actorResolver: requestUserActorResolver() })
|
|
1027
|
+
* ```
|
|
1028
|
+
*
|
|
1029
|
+
* A request without `req.user` is refused with `401` — the agent never invents a caller. Pass a
|
|
1030
|
+
* mapper when your user object is shaped differently:
|
|
1031
|
+
*
|
|
1032
|
+
* ```ts
|
|
1033
|
+
* requestUserActorResolver((user: SessionUser) => ({ id: user.uuid, roles: user.permissions }))
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
declare function requestUserActorResolver<TUser = Record<string, unknown>>(map?: RequestUserMapper<TUser>): ActorResolver;
|
|
1037
|
+
|
|
1038
|
+
export { AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, type AnonymousActorOptions, AnonymousActorResolver, AttachmentsController, type ChatParams, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, MemoriesController, MessagesController, ModelsController, type RequestUserMapper, type ResolvedAiToolOptions, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, type ThreadModelReader, ToolsController, declaredSkillProvider, defaultRequestUserMapper, readAgentMetadata, readAiToolMetadata, readSkillMetadata, requestUserActorResolver, resolveSkillsConfig, skillScope, toolNameFromClass };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, OnModuleInit, Type, OnApplicationBootstrap } from '@nestjs/common';
|
|
2
|
-
import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, d as AgentSkillsOptions } from './agent-deps.factory-
|
|
3
|
-
export { e as AGENT_TOOL_BRAND, f as AgentAttachmentsOptions, g as AgentDeps, h as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QuotaLimits, i as QuotaWindowLimits, j as delegateToolName, p as provideAgentTool, k as provideAgentTools, u as utcDay } from './agent-deps.factory-
|
|
2
|
+
import { b as AgentModuleOptions, c as AgentModuleAsyncOptions, A as AgentDepsFactory, d as AgentSkillsOptions } from './agent-deps.factory-BRTBu0lV.js';
|
|
3
|
+
export { e as AGENT_TOOL_BRAND, f as AgentAttachmentsOptions, g as AgentDeps, h as AgentMemoryOptions, a as AgentSurface, F as FunctionalTool, L as LedgerQuotaProvider, Q as QuotaLimits, i as QuotaWindowLimits, j as delegateToolName, p as provideAgentTool, k as provideAgentTools, u as utcDay } from './agent-deps.factory-BRTBu0lV.js';
|
|
4
4
|
import { AgentRunner, AgentStore, QuotaStore, AttachmentStagingStore, ModelCatalog, QuotaProvider, Actor, QuotaReport, ModelCatalogView, AttachmentRef, PageContext, HumanReply, ThreadSummary, ThreadDetail, UpdateThreadInput, MessageFeedbackValue, MessageFeedback, StagedAttachment, QuotaView, AgentApprovalPort, ActorResolver, MessageAttachment, ToolPresentation, AgentHistoryWindow, AgentIntake, SkillContext, ToolRegistry, AgentRegistry, PromptContributor, SkillsConfig, SkillCatalogEntry, ToolCatalogEntry, MemoryConfig, MemoryDigestEntry, SkillProvider, AgentRunInput, TokenStreamSink, SinkWriter, QuotaState } from '@dudousxd/nestjs-agent-core';
|
|
5
5
|
export * from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
import { Request } from 'express';
|
|
@@ -367,19 +367,27 @@ declare class AttachmentsController implements OnModuleInit {
|
|
|
367
367
|
|
|
368
368
|
declare const AI_TOOL_METADATA: unique symbol;
|
|
369
369
|
interface AiToolOptions {
|
|
370
|
-
name: string;
|
|
371
370
|
/**
|
|
372
|
-
*
|
|
373
|
-
*
|
|
371
|
+
* What the model calls it. Omit → the class name, camelCased, with a trailing `Tool` dropped
|
|
372
|
+
* (`GetWeatherTool` → `getWeather`).
|
|
374
373
|
*/
|
|
375
|
-
|
|
374
|
+
name?: string;
|
|
375
|
+
/**
|
|
376
|
+
* `read` (the default) auto-executes; `action` requires HITL approval. (Core's `ToolKind` also
|
|
377
|
+
* has `agent` for delegation, but that kind is synthesized from `delegatesTo` — never authored
|
|
378
|
+
* here.)
|
|
379
|
+
*/
|
|
380
|
+
kind?: 'read' | 'action';
|
|
376
381
|
description: string;
|
|
377
382
|
/**
|
|
378
383
|
* Input schema as a [Standard Schema](https://standardschema.dev) — Zod, Valibot, or ArkType.
|
|
379
384
|
* Validated before the handler runs.
|
|
380
385
|
*/
|
|
381
386
|
input: StandardSchemaV1;
|
|
382
|
-
/**
|
|
387
|
+
/**
|
|
388
|
+
* Roles allowed to invoke. Omit → the module's `defaultRoles`, which by default restrict nobody:
|
|
389
|
+
* any resolved actor — an anonymous visitor included, when no `actorResolver` is configured.
|
|
390
|
+
*/
|
|
383
391
|
roles?: string[];
|
|
384
392
|
/**
|
|
385
393
|
* Whether this tool exists in this deployment. `false` — or a predicate returning `false`, which
|
|
@@ -420,13 +428,21 @@ interface AiToolOptions {
|
|
|
420
428
|
*/
|
|
421
429
|
terminal?: boolean;
|
|
422
430
|
}
|
|
431
|
+
/** {@link AiToolOptions} with the defaults applied — what discovery reads. */
|
|
432
|
+
interface ResolvedAiToolOptions extends AiToolOptions {
|
|
433
|
+
name: string;
|
|
434
|
+
kind: 'read' | 'action';
|
|
435
|
+
}
|
|
436
|
+
/** `GetWeatherTool` → `getWeather`; `SQLQueryTool` → `sqlQuery`. */
|
|
437
|
+
declare function toolNameFromClass(className: string): string;
|
|
423
438
|
/**
|
|
424
439
|
* Marks a provider class as an AI tool. The class must implement `execute(input, ctx)`.
|
|
425
440
|
* `AiToolDiscoveryService` registers every `@AiTool` provider into the `ToolRegistry` at boot.
|
|
441
|
+
* Only `description` and `input` are required:
|
|
426
442
|
*
|
|
427
443
|
* ```ts
|
|
428
|
-
* @AiTool({
|
|
429
|
-
* class GetWeatherTool implements ToolHandler<{ city: string }> {
|
|
444
|
+
* @AiTool({ description: 'Current weather for a city', input: z.object({ city: z.string() }) })
|
|
445
|
+
* class GetWeatherTool implements ToolHandler<{ city: string }> { // name: getWeather, kind: read
|
|
430
446
|
* async execute(input, ctx) { return { tempC: 21 }; }
|
|
431
447
|
* }
|
|
432
448
|
* ```
|
|
@@ -444,7 +460,7 @@ interface AiToolOptions {
|
|
|
444
460
|
* ```
|
|
445
461
|
*/
|
|
446
462
|
declare function AiTool(options: AiToolOptions): ClassDecorator;
|
|
447
|
-
declare function readAiToolMetadata(target: object):
|
|
463
|
+
declare function readAiToolMetadata(target: object): ResolvedAiToolOptions | undefined;
|
|
448
464
|
|
|
449
465
|
/**
|
|
450
466
|
* Declares a class as an agent. The class is discovered at boot (via `DiscoveryService`) and
|
|
@@ -946,4 +962,77 @@ declare class HeaderActorResolver implements ActorResolver {
|
|
|
946
962
|
resolve(req: unknown): Actor;
|
|
947
963
|
}
|
|
948
964
|
|
|
949
|
-
|
|
965
|
+
interface AnonymousActorOptions {
|
|
966
|
+
/** The cookie holding the browser's anonymous token. Default `agent_anon`. */
|
|
967
|
+
cookieName?: string;
|
|
968
|
+
/** How long a browser keeps its identity (and so its threads). Default 365 days. */
|
|
969
|
+
maxAgeDays?: number;
|
|
970
|
+
/**
|
|
971
|
+
* `SameSite` of the cookie. Default `'lax'` — sent on same-site requests, not on cross-site
|
|
972
|
+
* POSTs. A SPA on another SITE than the API needs `'none'` (which forces `Secure`) plus
|
|
973
|
+
* `credentials: 'include'` on the client.
|
|
974
|
+
*/
|
|
975
|
+
sameSite?: 'lax' | 'strict' | 'none';
|
|
976
|
+
/**
|
|
977
|
+
* `Secure` flag. Default `'auto'`: set when the request arrived over HTTPS (`req.secure`, or an
|
|
978
|
+
* `x-forwarded-proto: https` from a proxy).
|
|
979
|
+
*/
|
|
980
|
+
secure?: boolean | 'auto';
|
|
981
|
+
/** Cookie path. Default `/`. */
|
|
982
|
+
path?: string;
|
|
983
|
+
/** Roles every anonymous actor carries. Default `['anonymous']`. */
|
|
984
|
+
roles?: string[];
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* The zero-config identity: every browser is its own anonymous actor, so a login-less chat still
|
|
988
|
+
* keeps each visitor's threads, quota and attachments apart from everyone else's.
|
|
989
|
+
*
|
|
990
|
+
* On a browser's first request the resolver mints 32 random bytes and sets them as an `HttpOnly`
|
|
991
|
+
* cookie (`SameSite=Lax`, `Secure` over HTTPS). The actor id is a SHA-256 digest of that token —
|
|
992
|
+
* `anon:<digest>` — never the token itself, so an id that surfaces anywhere (a thread row, a log, an
|
|
993
|
+
* approval's `decidedBy`) cannot be replayed as the cookie.
|
|
994
|
+
*
|
|
995
|
+
* Why a server-minted cookie and not an id the client makes up and sends in a header: an
|
|
996
|
+
* `HttpOnly` cookie is out of reach of page scripts (an XSS cannot lift it), the server — not the
|
|
997
|
+
* client — decides the value, and it needs no client code at all. There is no signing secret to
|
|
998
|
+
* configure: the token is unguessable on its own, and the digest works the same on every pod and
|
|
999
|
+
* after a restart.
|
|
1000
|
+
*
|
|
1001
|
+
* Anonymous identities are per browser, not per person: clearing cookies starts over, and there is
|
|
1002
|
+
* nothing to recover them with. Require login with an `ActorResolver` that reads your session —
|
|
1003
|
+
* `requestUserActorResolver()` for `req.user` (Passport / cookie-session apps).
|
|
1004
|
+
*/
|
|
1005
|
+
declare class AnonymousActorResolver implements ActorResolver {
|
|
1006
|
+
private readonly options;
|
|
1007
|
+
private readonly cookieName;
|
|
1008
|
+
private readonly roles;
|
|
1009
|
+
constructor(options?: AnonymousActorOptions);
|
|
1010
|
+
resolve(request: unknown): Actor;
|
|
1011
|
+
private setCookie;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/** Turns whatever your auth put on `req.user` into the agent's {@link Actor}. */
|
|
1015
|
+
type RequestUserMapper<TUser = Record<string, unknown>> = (user: TUser, req: unknown) => Actor | Promise<Actor>;
|
|
1016
|
+
/**
|
|
1017
|
+
* The default mapping: `id` from `id` / `sub` / `_id` / `userId`, `roles` from `roles` (an array)
|
|
1018
|
+
* or `role` (a string), `tenantRef` from `tenantRef` / `tenantId` / `orgId`.
|
|
1019
|
+
*/
|
|
1020
|
+
declare function defaultRequestUserMapper(user: Record<string, unknown>): Actor;
|
|
1021
|
+
/**
|
|
1022
|
+
* Authenticated mode in one line, for apps whose auth already puts the principal on `req.user` —
|
|
1023
|
+
* Passport strategies, `express-session` / cookie-session middleware, a Nest guard that assigns it:
|
|
1024
|
+
*
|
|
1025
|
+
* ```ts
|
|
1026
|
+
* AgentModule.forRoot({ model, actorResolver: requestUserActorResolver() })
|
|
1027
|
+
* ```
|
|
1028
|
+
*
|
|
1029
|
+
* A request without `req.user` is refused with `401` — the agent never invents a caller. Pass a
|
|
1030
|
+
* mapper when your user object is shaped differently:
|
|
1031
|
+
*
|
|
1032
|
+
* ```ts
|
|
1033
|
+
* requestUserActorResolver((user: SessionUser) => ({ id: user.uuid, roles: user.permissions }))
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
declare function requestUserActorResolver<TUser = Record<string, unknown>>(map?: RequestUserMapper<TUser>): ActorResolver;
|
|
1037
|
+
|
|
1038
|
+
export { AGENT_METADATA, AI_TOOL_METADATA, ATTACHMENT_PAGE_SIZE, Agent, AgentApprovalPortAdapter, AgentDepsFactory, AgentDiscoveryService, AgentModule, AgentModuleAsyncOptions, AgentModuleOptions, type AgentOptions, AgentService, AgentSkillsOptions, AiTool, AiToolDiscoveryService, type AiToolOptions, type AnonymousActorOptions, AnonymousActorResolver, AttachmentsController, type ChatParams, DEFAULT_ALLOWED_ATTACHMENT_CONTENT_TYPES, DEFAULT_MAX_ATTACHMENT_BYTES, type DeclaredSkill, HeaderActorResolver, InProcessTokenStreamSink, InlineAgentRunner, LedgerQuotaStore, MemoriesController, MessagesController, ModelsController, type RequestUserMapper, type ResolvedAiToolOptions, SKILL_METADATA, SYSTEM_PROMPT_CONTRIBUTOR_METADATA, SYSTEM_PROMPT_METADATA, Skill, type SkillBody, SkillDiscoveryService, type SkillOptions, SkillsController, SystemPrompt, SystemPromptContributor, type ThreadDefaultAgentReader, type ThreadModelReader, ToolsController, declaredSkillProvider, defaultRequestUserMapper, readAgentMetadata, readAiToolMetadata, readSkillMetadata, requestUserActorResolver, resolveSkillsConfig, skillScope, toolNameFromClass };
|