@dudousxd/nestjs-agent 1.6.0 → 1.7.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 +35 -0
- package/dist/{agent-deps.factory-CUyVPsa1.d.cts → agent-deps.factory-CiC5Va9J.d.cts} +7 -1
- package/dist/{agent-deps.factory-CUyVPsa1.d.ts → agent-deps.factory-CiC5Va9J.d.ts} +7 -1
- package/dist/durable/index.cjs +466 -309
- 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 +366 -209
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +468 -312
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -5
- package/dist/index.d.ts +40 -5
- package/dist/index.js +363 -208
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -144,6 +144,41 @@ one of the caller's threads (`null` clears it) and answers `{ feedback }`; `GET
|
|
|
144
144
|
returns it on the message. It needs a store with `threadOfMessage` + `setMessageFeedback` (both
|
|
145
145
|
bundled stores and `InMemoryAgentStore` have them) — `501` otherwise.
|
|
146
146
|
|
|
147
|
+
### Letting callers pick a model
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
AgentModule.forRoot({
|
|
151
|
+
model: aiSdkModel('openai/gpt-4o-mini', { resolveModel: (id) => gateway(id) }),
|
|
152
|
+
models: {
|
|
153
|
+
list: ({ actor }) => ({
|
|
154
|
+
default: 'openai/gpt-4o-mini',
|
|
155
|
+
providers: [
|
|
156
|
+
{
|
|
157
|
+
id: 'openai',
|
|
158
|
+
label: 'OpenAI',
|
|
159
|
+
models: [
|
|
160
|
+
{ id: 'openai/gpt-4o-mini', label: 'GPT-4o mini', badges: ['fast'], available: true },
|
|
161
|
+
{
|
|
162
|
+
id: 'openai/o3',
|
|
163
|
+
label: 'o3',
|
|
164
|
+
badges: ['reasoning'],
|
|
165
|
+
available: actor.roles?.includes('PRO') === true,
|
|
166
|
+
unavailableReason: 'Pro plan',
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
}),
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`GET /agent/models?agent=` answers the catalog for the caller (empty without one). A turn runs on
|
|
177
|
+
the send's `model`, else the thread's pinned one (`PATCH /agent/threads/:id { model }`), else the
|
|
178
|
+
provider's default; the id reaches the provider as `ModelTurnArgs.model` for every call of the turn.
|
|
179
|
+
A model the catalog does not list as available for that actor and agent is refused with `400` —
|
|
180
|
+
when pinned and again on each turn. `staticModelCatalog(view)` wraps a fixed list.
|
|
181
|
+
|
|
147
182
|
### Who approves an action, and for how long
|
|
148
183
|
|
|
149
184
|
Every `action` tool call waits on the person chatting by default. `approvalPolicy` changes that per
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModelProvider, AgentStore, ToolRegistry, RolesPolicy, ApprovalPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, ToolTransientRetrySetting, Retriever, AgentPricingStore, HistoryPolicy, InputProcessor, OutputProcessor, AgentIntake, SkillsConfig, MemoryConfig, ToolSpec, ToolHandler, ActorResolver, AgentHistoryWindow, SkillProvider, ScopeResolver, MemoryProvider, AgentRegistry } from '@dudousxd/nestjs-agent-core';
|
|
1
|
+
import { ModelProvider, AgentStore, ToolRegistry, RolesPolicy, ApprovalPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, ToolTransientRetrySetting, Retriever, AgentPricingStore, HistoryPolicy, InputProcessor, OutputProcessor, AgentIntake, SkillsConfig, MemoryConfig, ToolSpec, ToolHandler, ModelCatalog, ActorResolver, AgentHistoryWindow, SkillProvider, ScopeResolver, MemoryProvider, AgentRegistry } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
import { Provider, FactoryProvider, Type, CanActivate, ModuleMetadata, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
|
|
4
4
|
|
|
@@ -199,6 +199,12 @@ interface AgentModuleOptions {
|
|
|
199
199
|
* `quotaLimitTokens` instead, which binds the built-in ledger-backed store.
|
|
200
200
|
*/
|
|
201
201
|
quota?: QuotaStore;
|
|
202
|
+
/**
|
|
203
|
+
* Which models a caller may pick — `GET <base>/models`, a send's `model`, a thread's pinned model
|
|
204
|
+
* (`PATCH <base>/threads/:id { model }`). The picked id reaches the {@link ModelProvider} as
|
|
205
|
+
* `ModelTurnArgs.model`. Omit → an empty catalog, and a request naming a model is refused.
|
|
206
|
+
*/
|
|
207
|
+
models?: ModelCatalog;
|
|
202
208
|
/**
|
|
203
209
|
* Daily per-actor token budget, enforced against the persisted usage ledger by the built-in
|
|
204
210
|
* `LedgerQuotaStore`. A convenience over wiring a {@link QuotaStore} by hand — set this and quotas
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModelProvider, AgentStore, ToolRegistry, RolesPolicy, ApprovalPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, ToolTransientRetrySetting, Retriever, AgentPricingStore, HistoryPolicy, InputProcessor, OutputProcessor, AgentIntake, SkillsConfig, MemoryConfig, ToolSpec, ToolHandler, ActorResolver, AgentHistoryWindow, SkillProvider, ScopeResolver, MemoryProvider, AgentRegistry } from '@dudousxd/nestjs-agent-core';
|
|
1
|
+
import { ModelProvider, AgentStore, ToolRegistry, RolesPolicy, ApprovalPolicy, QuotaStore, TokenStreamSink, PromptBuilder, PromptContributor, ToolTransientRetrySetting, Retriever, AgentPricingStore, HistoryPolicy, InputProcessor, OutputProcessor, AgentIntake, SkillsConfig, MemoryConfig, ToolSpec, ToolHandler, ModelCatalog, ActorResolver, AgentHistoryWindow, SkillProvider, ScopeResolver, MemoryProvider, AgentRegistry } from '@dudousxd/nestjs-agent-core';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
import { Provider, FactoryProvider, Type, CanActivate, ModuleMetadata, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
|
|
4
4
|
|
|
@@ -199,6 +199,12 @@ interface AgentModuleOptions {
|
|
|
199
199
|
* `quotaLimitTokens` instead, which binds the built-in ledger-backed store.
|
|
200
200
|
*/
|
|
201
201
|
quota?: QuotaStore;
|
|
202
|
+
/**
|
|
203
|
+
* Which models a caller may pick — `GET <base>/models`, a send's `model`, a thread's pinned model
|
|
204
|
+
* (`PATCH <base>/threads/:id { model }`). The picked id reaches the {@link ModelProvider} as
|
|
205
|
+
* `ModelTurnArgs.model`. Omit → an empty catalog, and a request naming a model is refused.
|
|
206
|
+
*/
|
|
207
|
+
models?: ModelCatalog;
|
|
202
208
|
/**
|
|
203
209
|
* Daily per-actor token budget, enforced against the persisted usage ledger by the built-in
|
|
204
210
|
* `LedgerQuotaStore`. A convenience over wiring a {@link QuotaStore} by hand — set this and quotas
|