@dudousxd/nestjs-agent 1.1.1 → 1.2.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 +29 -0
- package/dist/durable/index.cjs +224 -138
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.js +154 -68
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +226 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -2
- package/dist/index.d.ts +42 -2
- package/dist/index.js +150 -64
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -50,6 +50,7 @@ __export(index_exports, {
|
|
|
50
50
|
SkillsController: () => SkillsController,
|
|
51
51
|
SystemPrompt: () => SystemPrompt,
|
|
52
52
|
SystemPromptContributor: () => SystemPromptContributor,
|
|
53
|
+
ToolsController: () => ToolsController,
|
|
53
54
|
declaredSkillProvider: () => declaredSkillProvider,
|
|
54
55
|
delegateToolName: () => delegateToolName,
|
|
55
56
|
provideAgentTool: () => provideAgentTool,
|
|
@@ -63,8 +64,8 @@ __export(index_exports, {
|
|
|
63
64
|
module.exports = __toCommonJS(index_exports);
|
|
64
65
|
|
|
65
66
|
// src/agent.module.ts
|
|
66
|
-
var
|
|
67
|
-
var
|
|
67
|
+
var import_nestjs_agent_core20 = require("@dudousxd/nestjs-agent-core");
|
|
68
|
+
var import_common17 = require("@nestjs/common");
|
|
68
69
|
var import_core4 = require("@nestjs/core");
|
|
69
70
|
|
|
70
71
|
// src/agent-deps.factory.ts
|
|
@@ -1932,9 +1933,90 @@ ToolCallController = _ts_decorate11([
|
|
|
1932
1933
|
])
|
|
1933
1934
|
], ToolCallController);
|
|
1934
1935
|
|
|
1935
|
-
// src/
|
|
1936
|
+
// src/controller/tools.controller.ts
|
|
1936
1937
|
var import_nestjs_agent_core12 = require("@dudousxd/nestjs-agent-core");
|
|
1937
1938
|
var import_common12 = require("@nestjs/common");
|
|
1939
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1940
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1941
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1942
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1943
|
+
} else {
|
|
1944
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1945
|
+
if (d = decorators[i]) {
|
|
1946
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1951
|
+
}
|
|
1952
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1953
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
1954
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1955
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
1959
|
+
function _ts_param11(paramIndex, decorator) {
|
|
1960
|
+
return function(target, key) {
|
|
1961
|
+
decorator(target, key, paramIndex);
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
__name(_ts_param11, "_ts_param");
|
|
1965
|
+
var ToolsController = class {
|
|
1966
|
+
static {
|
|
1967
|
+
__name(this, "ToolsController");
|
|
1968
|
+
}
|
|
1969
|
+
actorResolver;
|
|
1970
|
+
depsFactory;
|
|
1971
|
+
agents;
|
|
1972
|
+
constructor(actorResolver, depsFactory, agents) {
|
|
1973
|
+
this.actorResolver = actorResolver;
|
|
1974
|
+
this.depsFactory = depsFactory;
|
|
1975
|
+
this.agents = agents;
|
|
1976
|
+
}
|
|
1977
|
+
async list(req, agent) {
|
|
1978
|
+
if (agent !== void 0 && this.agents.get(agent) === void 0) {
|
|
1979
|
+
throw new import_common12.NotFoundException(`No agent named "${agent}"`);
|
|
1980
|
+
}
|
|
1981
|
+
const actor = await this.actorResolver.resolve(req);
|
|
1982
|
+
const deps = this.depsFactory.forAgent(agent);
|
|
1983
|
+
const specs = await deps.registry.visibleSpecs(actor, deps.rolesPolicy, deps.toolAllowList);
|
|
1984
|
+
return specs.map((spec) => ({
|
|
1985
|
+
name: spec.name,
|
|
1986
|
+
kind: spec.kind,
|
|
1987
|
+
...spec.presentation !== void 0 ? {
|
|
1988
|
+
presentation: spec.presentation
|
|
1989
|
+
} : {}
|
|
1990
|
+
}));
|
|
1991
|
+
}
|
|
1992
|
+
};
|
|
1993
|
+
_ts_decorate12([
|
|
1994
|
+
(0, import_common12.Get)(),
|
|
1995
|
+
_ts_param11(0, (0, import_common12.Req)()),
|
|
1996
|
+
_ts_param11(1, (0, import_common12.Query)("agent")),
|
|
1997
|
+
_ts_metadata12("design:type", Function),
|
|
1998
|
+
_ts_metadata12("design:paramtypes", [
|
|
1999
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2000
|
+
String
|
|
2001
|
+
]),
|
|
2002
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2003
|
+
], ToolsController.prototype, "list", null);
|
|
2004
|
+
ToolsController = _ts_decorate12([
|
|
2005
|
+
(0, import_common12.Controller)("tools"),
|
|
2006
|
+
_ts_param11(0, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_ACTOR_RESOLVER)),
|
|
2007
|
+
_ts_param11(1, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_DEPS_FACTORY)),
|
|
2008
|
+
_ts_param11(2, (0, import_common12.Inject)(import_nestjs_agent_core12.AGENT_REGISTRY)),
|
|
2009
|
+
_ts_metadata12("design:type", Function),
|
|
2010
|
+
_ts_metadata12("design:paramtypes", [
|
|
2011
|
+
typeof ActorResolver === "undefined" ? Object : ActorResolver,
|
|
2012
|
+
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2013
|
+
typeof import_nestjs_agent_core12.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core12.AgentRegistry
|
|
2014
|
+
])
|
|
2015
|
+
], ToolsController);
|
|
2016
|
+
|
|
2017
|
+
// src/discovery/agent-discovery.service.ts
|
|
2018
|
+
var import_nestjs_agent_core13 = require("@dudousxd/nestjs-agent-core");
|
|
2019
|
+
var import_common13 = require("@nestjs/common");
|
|
1938
2020
|
var import_core = require("@nestjs/core");
|
|
1939
2021
|
|
|
1940
2022
|
// src/decorator/agent.decorator.ts
|
|
@@ -1969,7 +2051,7 @@ function SystemPromptContributor() {
|
|
|
1969
2051
|
__name(SystemPromptContributor, "SystemPromptContributor");
|
|
1970
2052
|
|
|
1971
2053
|
// src/discovery/agent-discovery.service.ts
|
|
1972
|
-
function
|
|
2054
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
1973
2055
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1974
2056
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1975
2057
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1982,19 +2064,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
1982
2064
|
}
|
|
1983
2065
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1984
2066
|
}
|
|
1985
|
-
__name(
|
|
1986
|
-
function
|
|
2067
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
2068
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
1987
2069
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1988
2070
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
1989
2071
|
}
|
|
1990
2072
|
}
|
|
1991
|
-
__name(
|
|
1992
|
-
function
|
|
2073
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
2074
|
+
function _ts_param12(paramIndex, decorator) {
|
|
1993
2075
|
return function(target, key) {
|
|
1994
2076
|
decorator(target, key, paramIndex);
|
|
1995
2077
|
};
|
|
1996
2078
|
}
|
|
1997
|
-
__name(
|
|
2079
|
+
__name(_ts_param12, "_ts_param");
|
|
1998
2080
|
var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
1999
2081
|
static {
|
|
2000
2082
|
__name(this, "AgentDiscoveryService");
|
|
@@ -2003,7 +2085,7 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2003
2085
|
scanner;
|
|
2004
2086
|
registry;
|
|
2005
2087
|
contributors;
|
|
2006
|
-
logger = new
|
|
2088
|
+
logger = new import_common13.Logger(_AgentDiscoveryService.name);
|
|
2007
2089
|
constructor(discovery, scanner, registry, contributors) {
|
|
2008
2090
|
this.discovery = discovery;
|
|
2009
2091
|
this.scanner = scanner;
|
|
@@ -2121,22 +2203,22 @@ var AgentDiscoveryService = class _AgentDiscoveryService {
|
|
|
2121
2203
|
return (ctx) => candidate.call(instance, ctx);
|
|
2122
2204
|
}
|
|
2123
2205
|
};
|
|
2124
|
-
AgentDiscoveryService =
|
|
2125
|
-
(0,
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2206
|
+
AgentDiscoveryService = _ts_decorate13([
|
|
2207
|
+
(0, import_common13.Injectable)(),
|
|
2208
|
+
_ts_param12(2, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_REGISTRY)),
|
|
2209
|
+
_ts_param12(3, (0, import_common13.Inject)(import_nestjs_agent_core13.AGENT_PROMPT_CONTRIBUTORS)),
|
|
2210
|
+
_ts_metadata13("design:type", Function),
|
|
2211
|
+
_ts_metadata13("design:paramtypes", [
|
|
2130
2212
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
2131
2213
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
2132
|
-
typeof
|
|
2214
|
+
typeof import_nestjs_agent_core13.AgentRegistry === "undefined" ? Object : import_nestjs_agent_core13.AgentRegistry,
|
|
2133
2215
|
Array
|
|
2134
2216
|
])
|
|
2135
2217
|
], AgentDiscoveryService);
|
|
2136
2218
|
|
|
2137
2219
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2138
|
-
var
|
|
2139
|
-
var
|
|
2220
|
+
var import_nestjs_agent_core14 = require("@dudousxd/nestjs-agent-core");
|
|
2221
|
+
var import_common14 = require("@nestjs/common");
|
|
2140
2222
|
var import_core2 = require("@nestjs/core");
|
|
2141
2223
|
var import_zod = require("zod");
|
|
2142
2224
|
|
|
@@ -2185,7 +2267,7 @@ function provideAgentTool(factoryOrTool, inject) {
|
|
|
2185
2267
|
__name(provideAgentTool, "provideAgentTool");
|
|
2186
2268
|
|
|
2187
2269
|
// src/discovery/ai-tool-discovery.service.ts
|
|
2188
|
-
function
|
|
2270
|
+
function _ts_decorate14(decorators, target, key, desc) {
|
|
2189
2271
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2190
2272
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2191
2273
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2198,19 +2280,19 @@ function _ts_decorate13(decorators, target, key, desc) {
|
|
|
2198
2280
|
}
|
|
2199
2281
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2200
2282
|
}
|
|
2201
|
-
__name(
|
|
2202
|
-
function
|
|
2283
|
+
__name(_ts_decorate14, "_ts_decorate");
|
|
2284
|
+
function _ts_metadata14(metadataKey, metadataValue) {
|
|
2203
2285
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2204
2286
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2205
2287
|
}
|
|
2206
2288
|
}
|
|
2207
|
-
__name(
|
|
2208
|
-
function
|
|
2289
|
+
__name(_ts_metadata14, "_ts_metadata");
|
|
2290
|
+
function _ts_param13(paramIndex, decorator) {
|
|
2209
2291
|
return function(target, key) {
|
|
2210
2292
|
decorator(target, key, paramIndex);
|
|
2211
2293
|
};
|
|
2212
2294
|
}
|
|
2213
|
-
__name(
|
|
2295
|
+
__name(_ts_param13, "_ts_param");
|
|
2214
2296
|
var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
2215
2297
|
static {
|
|
2216
2298
|
__name(this, "AiToolDiscoveryService");
|
|
@@ -2219,7 +2301,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2219
2301
|
registry;
|
|
2220
2302
|
agents;
|
|
2221
2303
|
options;
|
|
2222
|
-
logger = new
|
|
2304
|
+
logger = new import_common14.Logger(_AiToolDiscoveryService.name);
|
|
2223
2305
|
constructor(discovery, registry, agents, options) {
|
|
2224
2306
|
this.discovery = discovery;
|
|
2225
2307
|
this.registry = registry;
|
|
@@ -2264,6 +2346,9 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2264
2346
|
} : {},
|
|
2265
2347
|
...meta.enabled !== void 0 ? {
|
|
2266
2348
|
enabled: meta.enabled
|
|
2349
|
+
} : {},
|
|
2350
|
+
...meta.presentation !== void 0 ? {
|
|
2351
|
+
presentation: meta.presentation
|
|
2267
2352
|
} : {}
|
|
2268
2353
|
}, {
|
|
2269
2354
|
execute: /* @__PURE__ */ __name((input, ctx) => instance.execute(input, ctx), "execute"),
|
|
@@ -2287,7 +2372,7 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2287
2372
|
let delegates = 0;
|
|
2288
2373
|
for (const definition of this.agents.list()) {
|
|
2289
2374
|
for (const edge of definition.delegatesTo ?? []) {
|
|
2290
|
-
const { agent: target, detached } = (0,
|
|
2375
|
+
const { agent: target, detached } = (0, import_nestjs_agent_core14.normalizeDelegation)(edge);
|
|
2291
2376
|
const targetDefinition = this.agents.get(target);
|
|
2292
2377
|
if (targetDefinition === void 0) {
|
|
2293
2378
|
throw new Error(`Agent "${definition.name}" hands off to "${target}", which is not a registered @Agent. Declare it as an @Agent provider or fix the reference.`);
|
|
@@ -2337,13 +2422,13 @@ var AiToolDiscoveryService = class _AiToolDiscoveryService {
|
|
|
2337
2422
|
return true;
|
|
2338
2423
|
}
|
|
2339
2424
|
};
|
|
2340
|
-
AiToolDiscoveryService =
|
|
2341
|
-
(0,
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2425
|
+
AiToolDiscoveryService = _ts_decorate14([
|
|
2426
|
+
(0, import_common14.Injectable)(),
|
|
2427
|
+
_ts_param13(1, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_TOOL_REGISTRY)),
|
|
2428
|
+
_ts_param13(2, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_REGISTRY)),
|
|
2429
|
+
_ts_param13(3, (0, import_common14.Inject)(import_nestjs_agent_core14.AGENT_OPTIONS)),
|
|
2430
|
+
_ts_metadata14("design:type", Function),
|
|
2431
|
+
_ts_metadata14("design:paramtypes", [
|
|
2347
2432
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
2348
2433
|
typeof ToolRegistry === "undefined" ? Object : ToolRegistry,
|
|
2349
2434
|
typeof AgentRegistry === "undefined" ? Object : AgentRegistry,
|
|
@@ -2352,13 +2437,13 @@ AiToolDiscoveryService = _ts_decorate13([
|
|
|
2352
2437
|
], AiToolDiscoveryService);
|
|
2353
2438
|
|
|
2354
2439
|
// src/discovery/skill-discovery.service.ts
|
|
2355
|
-
var
|
|
2356
|
-
var
|
|
2440
|
+
var import_nestjs_agent_core16 = require("@dudousxd/nestjs-agent-core");
|
|
2441
|
+
var import_common15 = require("@nestjs/common");
|
|
2357
2442
|
var import_core3 = require("@nestjs/core");
|
|
2358
2443
|
|
|
2359
2444
|
// src/decorator/skill.decorator.ts
|
|
2360
2445
|
var import_reflect_metadata4 = require("reflect-metadata");
|
|
2361
|
-
var
|
|
2446
|
+
var import_nestjs_agent_core15 = require("@dudousxd/nestjs-agent-core");
|
|
2362
2447
|
var SKILL_METADATA = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-metadata");
|
|
2363
2448
|
function Skill(options) {
|
|
2364
2449
|
return (target) => {
|
|
@@ -2371,12 +2456,12 @@ function readSkillMetadata(target) {
|
|
|
2371
2456
|
}
|
|
2372
2457
|
__name(readSkillMetadata, "readSkillMetadata");
|
|
2373
2458
|
function skillScope(options) {
|
|
2374
|
-
return options.scope ??
|
|
2459
|
+
return options.scope ?? import_nestjs_agent_core15.GLOBAL_SCOPE;
|
|
2375
2460
|
}
|
|
2376
2461
|
__name(skillScope, "skillScope");
|
|
2377
2462
|
|
|
2378
2463
|
// src/discovery/skill-discovery.service.ts
|
|
2379
|
-
function
|
|
2464
|
+
function _ts_decorate15(decorators, target, key, desc) {
|
|
2380
2465
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2381
2466
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2382
2467
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2389,26 +2474,26 @@ function _ts_decorate14(decorators, target, key, desc) {
|
|
|
2389
2474
|
}
|
|
2390
2475
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2391
2476
|
}
|
|
2392
|
-
__name(
|
|
2393
|
-
function
|
|
2477
|
+
__name(_ts_decorate15, "_ts_decorate");
|
|
2478
|
+
function _ts_metadata15(metadataKey, metadataValue) {
|
|
2394
2479
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2395
2480
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2396
2481
|
}
|
|
2397
2482
|
}
|
|
2398
|
-
__name(
|
|
2399
|
-
function
|
|
2483
|
+
__name(_ts_metadata15, "_ts_metadata");
|
|
2484
|
+
function _ts_param14(paramIndex, decorator) {
|
|
2400
2485
|
return function(target, key) {
|
|
2401
2486
|
decorator(target, key, paramIndex);
|
|
2402
2487
|
};
|
|
2403
2488
|
}
|
|
2404
|
-
__name(
|
|
2489
|
+
__name(_ts_param14, "_ts_param");
|
|
2405
2490
|
var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
2406
2491
|
static {
|
|
2407
2492
|
__name(this, "SkillDiscoveryService");
|
|
2408
2493
|
}
|
|
2409
2494
|
discovery;
|
|
2410
2495
|
declared;
|
|
2411
|
-
logger = new
|
|
2496
|
+
logger = new import_common15.Logger(_SkillDiscoveryService.name);
|
|
2412
2497
|
constructor(discovery, declared) {
|
|
2413
2498
|
this.discovery = discovery;
|
|
2414
2499
|
this.declared = declared;
|
|
@@ -2445,18 +2530,18 @@ var SkillDiscoveryService = class _SkillDiscoveryService {
|
|
|
2445
2530
|
return flat === void 0 ? void 0 : () => flat;
|
|
2446
2531
|
}
|
|
2447
2532
|
};
|
|
2448
|
-
SkillDiscoveryService =
|
|
2449
|
-
(0,
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2533
|
+
SkillDiscoveryService = _ts_decorate15([
|
|
2534
|
+
(0, import_common15.Injectable)(),
|
|
2535
|
+
_ts_param14(1, (0, import_common15.Inject)(import_nestjs_agent_core16.AGENT_SKILL_SOURCES)),
|
|
2536
|
+
_ts_metadata15("design:type", Function),
|
|
2537
|
+
_ts_metadata15("design:paramtypes", [
|
|
2453
2538
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
2454
2539
|
Array
|
|
2455
2540
|
])
|
|
2456
2541
|
], SkillDiscoveryService);
|
|
2457
2542
|
|
|
2458
2543
|
// src/in-process-sink.ts
|
|
2459
|
-
var
|
|
2544
|
+
var import_nestjs_agent_core17 = require("@dudousxd/nestjs-agent-core");
|
|
2460
2545
|
var InProcessTokenStreamSink = class {
|
|
2461
2546
|
static {
|
|
2462
2547
|
__name(this, "InProcessTokenStreamSink");
|
|
@@ -2511,7 +2596,7 @@ var InProcessTokenStreamSink = class {
|
|
|
2511
2596
|
}
|
|
2512
2597
|
if (buf.ended) {
|
|
2513
2598
|
if (buf.failure !== void 0) {
|
|
2514
|
-
throw new
|
|
2599
|
+
throw new import_nestjs_agent_core17.AgentStreamError(buf.failure);
|
|
2515
2600
|
}
|
|
2516
2601
|
return;
|
|
2517
2602
|
}
|
|
@@ -2547,9 +2632,9 @@ var LedgerQuotaStore = class {
|
|
|
2547
2632
|
};
|
|
2548
2633
|
|
|
2549
2634
|
// src/runner/inline-agent-runner.ts
|
|
2550
|
-
var
|
|
2551
|
-
var
|
|
2552
|
-
function
|
|
2635
|
+
var import_nestjs_agent_core18 = require("@dudousxd/nestjs-agent-core");
|
|
2636
|
+
var import_common16 = require("@nestjs/common");
|
|
2637
|
+
function _ts_decorate16(decorators, target, key, desc) {
|
|
2553
2638
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2554
2639
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2555
2640
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2562,26 +2647,26 @@ function _ts_decorate15(decorators, target, key, desc) {
|
|
|
2562
2647
|
}
|
|
2563
2648
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2564
2649
|
}
|
|
2565
|
-
__name(
|
|
2566
|
-
function
|
|
2650
|
+
__name(_ts_decorate16, "_ts_decorate");
|
|
2651
|
+
function _ts_metadata16(metadataKey, metadataValue) {
|
|
2567
2652
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2568
2653
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2569
2654
|
}
|
|
2570
2655
|
}
|
|
2571
|
-
__name(
|
|
2572
|
-
function
|
|
2656
|
+
__name(_ts_metadata16, "_ts_metadata");
|
|
2657
|
+
function _ts_param15(paramIndex, decorator) {
|
|
2573
2658
|
return function(target, key) {
|
|
2574
2659
|
decorator(target, key, paramIndex);
|
|
2575
2660
|
};
|
|
2576
2661
|
}
|
|
2577
|
-
__name(
|
|
2662
|
+
__name(_ts_param15, "_ts_param");
|
|
2578
2663
|
var InlineAgentRunner = class _InlineAgentRunner {
|
|
2579
2664
|
static {
|
|
2580
2665
|
__name(this, "InlineAgentRunner");
|
|
2581
2666
|
}
|
|
2582
2667
|
factory;
|
|
2583
2668
|
store;
|
|
2584
|
-
logger = new
|
|
2669
|
+
logger = new import_common16.Logger(_InlineAgentRunner.name);
|
|
2585
2670
|
pending = /* @__PURE__ */ new Map();
|
|
2586
2671
|
/**
|
|
2587
2672
|
* Runs someone has asked to stop. In-process, like `pending`, and for the same reason: this runner
|
|
@@ -2610,18 +2695,18 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2610
2695
|
] : []
|
|
2611
2696
|
]
|
|
2612
2697
|
});
|
|
2613
|
-
void (0,
|
|
2698
|
+
void (0, import_nestjs_agent_core18.runAgentLoop)({
|
|
2614
2699
|
...deps,
|
|
2615
2700
|
day
|
|
2616
2701
|
}, input, hooks).then(() => this.store.setActiveStream(input.threadId, null)).catch(async (error) => {
|
|
2617
|
-
if (error instanceof
|
|
2702
|
+
if (error instanceof import_nestjs_agent_core18.RunCancelledError) {
|
|
2618
2703
|
await this.settleCancelled(runId, input.threadId, deps);
|
|
2619
2704
|
return;
|
|
2620
2705
|
}
|
|
2621
2706
|
const message = error instanceof Error ? error.message : String(error);
|
|
2622
|
-
const code = (0,
|
|
2707
|
+
const code = (0, import_nestjs_agent_core18.agentFailureCode)(error);
|
|
2623
2708
|
this.logger.error(`agent run ${runId} failed (${code}): ${message}`);
|
|
2624
|
-
(0,
|
|
2709
|
+
(0, import_nestjs_agent_core18.publishAgentRunFailed)({
|
|
2625
2710
|
runId,
|
|
2626
2711
|
code,
|
|
2627
2712
|
message
|
|
@@ -2670,7 +2755,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2670
2755
|
for (const [key, waiter] of this.pending) {
|
|
2671
2756
|
if (key.startsWith(`${runId}:`)) {
|
|
2672
2757
|
this.pending.delete(key);
|
|
2673
|
-
waiter.reject(new
|
|
2758
|
+
waiter.reject(new import_nestjs_agent_core18.RunCancelledError());
|
|
2674
2759
|
}
|
|
2675
2760
|
}
|
|
2676
2761
|
await Promise.resolve();
|
|
@@ -2685,7 +2770,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2685
2770
|
this.logger.log(`agent run ${runId} cancelled`);
|
|
2686
2771
|
await this.store.setActiveStream(threadId, null);
|
|
2687
2772
|
const writer = await deps.sink.open(runId);
|
|
2688
|
-
await writer.write((0,
|
|
2773
|
+
await writer.write((0, import_nestjs_agent_core18.encodeStreamEvent)({
|
|
2689
2774
|
kind: "cancelled"
|
|
2690
2775
|
}));
|
|
2691
2776
|
await writer.end();
|
|
@@ -2716,7 +2801,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2716
2801
|
awaitApproval: /* @__PURE__ */ __name((call) => this.park(runId, call.id), "awaitApproval"),
|
|
2717
2802
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
2718
2803
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
2719
|
-
parallel:
|
|
2804
|
+
parallel: import_nestjs_agent_core18.settleAll,
|
|
2720
2805
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
2721
2806
|
runAgent: /* @__PURE__ */ __name((agentName, task) => this.runNested({
|
|
2722
2807
|
agentName,
|
|
@@ -2767,7 +2852,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2767
2852
|
awaitApproval: /* @__PURE__ */ __name((call) => this.park(runId, call.id), "awaitApproval"),
|
|
2768
2853
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
2769
2854
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
2770
|
-
parallel:
|
|
2855
|
+
parallel: import_nestjs_agent_core18.settleAll,
|
|
2771
2856
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId), "cancelled"),
|
|
2772
2857
|
runAgent: /* @__PURE__ */ __name((childName, childTask) => this.runNested({
|
|
2773
2858
|
agentName: childName,
|
|
@@ -2800,7 +2885,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2800
2885
|
}
|
|
2801
2886
|
}), "startAgent")
|
|
2802
2887
|
};
|
|
2803
|
-
void (0,
|
|
2888
|
+
void (0, import_nestjs_agent_core18.runAgentLoop)({
|
|
2804
2889
|
...deps,
|
|
2805
2890
|
day
|
|
2806
2891
|
}, {
|
|
@@ -2814,13 +2899,13 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2814
2899
|
parentRunId,
|
|
2815
2900
|
deliverTo
|
|
2816
2901
|
}, hooks).catch(async (error) => {
|
|
2817
|
-
const cancelled = error instanceof
|
|
2902
|
+
const cancelled = error instanceof import_nestjs_agent_core18.RunCancelledError;
|
|
2818
2903
|
const message = error instanceof Error ? error.message : String(error);
|
|
2819
2904
|
if (!cancelled) {
|
|
2820
2905
|
this.logger.error(`detached agent run ${runId} failed: ${message}`);
|
|
2821
|
-
(0,
|
|
2906
|
+
(0, import_nestjs_agent_core18.publishAgentRunFailed)({
|
|
2822
2907
|
runId,
|
|
2823
|
-
code: (0,
|
|
2908
|
+
code: (0, import_nestjs_agent_core18.agentFailureCode)(error),
|
|
2824
2909
|
message
|
|
2825
2910
|
});
|
|
2826
2911
|
}
|
|
@@ -2828,11 +2913,11 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2828
2913
|
runId,
|
|
2829
2914
|
status: cancelled ? "cancelled" : "failed",
|
|
2830
2915
|
...cancelled ? {} : {
|
|
2831
|
-
errorCode: (0,
|
|
2916
|
+
errorCode: (0, import_nestjs_agent_core18.agentFailureCode)(error),
|
|
2832
2917
|
errorMessage: message
|
|
2833
2918
|
}
|
|
2834
2919
|
});
|
|
2835
|
-
await (0,
|
|
2920
|
+
await (0, import_nestjs_agent_core18.settleUnsettledDelegation)({
|
|
2836
2921
|
store: this.store,
|
|
2837
2922
|
delivery: deliverTo,
|
|
2838
2923
|
agent: agentName,
|
|
@@ -2871,7 +2956,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2871
2956
|
awaitApproval: /* @__PURE__ */ __name((call) => this.park(runId, call.id), "awaitApproval"),
|
|
2872
2957
|
awaitAnswers: /* @__PURE__ */ __name((request) => this.park(runId, request.id), "awaitAnswers"),
|
|
2873
2958
|
step: /* @__PURE__ */ __name((_name, fn) => fn(), "step"),
|
|
2874
|
-
parallel:
|
|
2959
|
+
parallel: import_nestjs_agent_core18.settleAll,
|
|
2875
2960
|
// A child stops when it is cancelled OR when the run a human is actually watching is: the
|
|
2876
2961
|
// canceller names the top-level run, which is the only id that ever left the server.
|
|
2877
2962
|
cancelled: /* @__PURE__ */ __name(async () => this.cancelled.has(runId) || this.cancelled.has(sinkRunId), "cancelled"),
|
|
@@ -2906,7 +2991,7 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2906
2991
|
}), "startAgent")
|
|
2907
2992
|
};
|
|
2908
2993
|
try {
|
|
2909
|
-
return await (0,
|
|
2994
|
+
return await (0, import_nestjs_agent_core18.runAgentLoop)({
|
|
2910
2995
|
...deps,
|
|
2911
2996
|
day
|
|
2912
2997
|
}, {
|
|
@@ -2925,19 +3010,19 @@ var InlineAgentRunner = class _InlineAgentRunner {
|
|
|
2925
3010
|
}
|
|
2926
3011
|
}
|
|
2927
3012
|
};
|
|
2928
|
-
InlineAgentRunner =
|
|
2929
|
-
(0,
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
3013
|
+
InlineAgentRunner = _ts_decorate16([
|
|
3014
|
+
(0, import_common16.Injectable)(),
|
|
3015
|
+
_ts_param15(0, (0, import_common16.Inject)(import_nestjs_agent_core18.AGENT_DEPS_FACTORY)),
|
|
3016
|
+
_ts_param15(1, (0, import_common16.Inject)(import_nestjs_agent_core18.AGENT_STORE)),
|
|
3017
|
+
_ts_metadata16("design:type", Function),
|
|
3018
|
+
_ts_metadata16("design:paramtypes", [
|
|
2934
3019
|
typeof AgentDepsFactory === "undefined" ? Object : AgentDepsFactory,
|
|
2935
3020
|
typeof AgentStore === "undefined" ? Object : AgentStore
|
|
2936
3021
|
])
|
|
2937
3022
|
], InlineAgentRunner);
|
|
2938
3023
|
|
|
2939
3024
|
// src/skills-config.ts
|
|
2940
|
-
var
|
|
3025
|
+
var import_nestjs_agent_core19 = require("@dudousxd/nestjs-agent-core");
|
|
2941
3026
|
function declaredSkillProvider(declared) {
|
|
2942
3027
|
return {
|
|
2943
3028
|
list: /* @__PURE__ */ __name(({ scopes }) => declared.filter((skill) => scopes.includes(skill.scope)).map(({ name, description, scope }) => ({
|
|
@@ -2963,7 +3048,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
2963
3048
|
declaredSkillProvider(declared)
|
|
2964
3049
|
];
|
|
2965
3050
|
return {
|
|
2966
|
-
provider: providers.length === 1 ? providers[0] : (0,
|
|
3051
|
+
provider: providers.length === 1 ? providers[0] : (0, import_nestjs_agent_core19.compositeSkillProvider)(providers),
|
|
2967
3052
|
...options.scopes !== void 0 ? {
|
|
2968
3053
|
scopes: options.scopes
|
|
2969
3054
|
} : {},
|
|
@@ -2975,7 +3060,7 @@ function resolveSkillsConfig(options, declared) {
|
|
|
2975
3060
|
__name(resolveSkillsConfig, "resolveSkillsConfig");
|
|
2976
3061
|
|
|
2977
3062
|
// src/agent.module.ts
|
|
2978
|
-
function
|
|
3063
|
+
function _ts_decorate17(decorators, target, key, desc) {
|
|
2979
3064
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2980
3065
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2981
3066
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2988,92 +3073,92 @@ function _ts_decorate16(decorators, target, key, desc) {
|
|
|
2988
3073
|
}
|
|
2989
3074
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2990
3075
|
}
|
|
2991
|
-
__name(
|
|
3076
|
+
__name(_ts_decorate17, "_ts_decorate");
|
|
2992
3077
|
var DEFAULT_PATH = "agent";
|
|
2993
3078
|
function sharedProviders(durable, includeStore) {
|
|
2994
3079
|
const providers = [
|
|
2995
3080
|
{
|
|
2996
|
-
provide:
|
|
2997
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
3081
|
+
provide: import_nestjs_agent_core20.AGENT_TOOL_REGISTRY,
|
|
3082
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core20.ToolRegistry(), "useFactory")
|
|
2998
3083
|
},
|
|
2999
3084
|
// Starts empty; AgentDiscoveryService populates it from `@Agent`-decorated providers at boot.
|
|
3000
3085
|
{
|
|
3001
|
-
provide:
|
|
3002
|
-
useFactory: /* @__PURE__ */ __name(() => new
|
|
3086
|
+
provide: import_nestjs_agent_core20.AGENT_REGISTRY,
|
|
3087
|
+
useFactory: /* @__PURE__ */ __name(() => new import_nestjs_agent_core20.AgentRegistry(), "useFactory")
|
|
3003
3088
|
},
|
|
3004
3089
|
// A shared, mutable list AgentDiscoveryService fills with `@SystemPromptContributor()` methods.
|
|
3005
3090
|
{
|
|
3006
|
-
provide:
|
|
3091
|
+
provide: import_nestjs_agent_core20.AGENT_PROMPT_CONTRIBUTORS,
|
|
3007
3092
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3008
3093
|
},
|
|
3009
3094
|
// Likewise for `@Skill`-decorated providers — filled by SkillDiscoveryService at onModuleInit,
|
|
3010
3095
|
// read lazily by the AGENT_SKILLS provider below (which DI builds before discovery has run).
|
|
3011
3096
|
{
|
|
3012
|
-
provide:
|
|
3097
|
+
provide: import_nestjs_agent_core20.AGENT_SKILL_SOURCES,
|
|
3013
3098
|
useFactory: /* @__PURE__ */ __name(() => [], "useFactory")
|
|
3014
3099
|
},
|
|
3015
3100
|
{
|
|
3016
3101
|
// One resolution, shared by the loop's deps and the listing endpoint: a second one would
|
|
3017
3102
|
// drift, and a user would be offered a skill the agent cannot reach. `undefined` when the
|
|
3018
3103
|
// host configured none — which is what keeps the turn's checkpoint sequence unchanged.
|
|
3019
|
-
provide:
|
|
3104
|
+
provide: import_nestjs_agent_core20.AGENT_SKILLS,
|
|
3020
3105
|
useFactory: /* @__PURE__ */ __name((options, declared) => resolveSkillsConfig(options.skills, declared), "useFactory"),
|
|
3021
3106
|
inject: [
|
|
3022
|
-
|
|
3023
|
-
|
|
3107
|
+
import_nestjs_agent_core20.AGENT_OPTIONS,
|
|
3108
|
+
import_nestjs_agent_core20.AGENT_SKILL_SOURCES
|
|
3024
3109
|
]
|
|
3025
3110
|
},
|
|
3026
3111
|
{
|
|
3027
3112
|
// One resolution, shared by the loop's deps and the read-back endpoint: a person has to be
|
|
3028
3113
|
// shown what the model was shown, and two resolutions would eventually disagree about that.
|
|
3029
|
-
provide:
|
|
3114
|
+
provide: import_nestjs_agent_core20.AGENT_MEMORY,
|
|
3030
3115
|
useFactory: /* @__PURE__ */ __name((options) => options.memory, "useFactory"),
|
|
3031
3116
|
inject: [
|
|
3032
|
-
|
|
3117
|
+
import_nestjs_agent_core20.AGENT_OPTIONS
|
|
3033
3118
|
]
|
|
3034
3119
|
},
|
|
3035
3120
|
{
|
|
3036
|
-
provide:
|
|
3121
|
+
provide: import_nestjs_agent_core20.AGENT_SINK,
|
|
3037
3122
|
useFactory: /* @__PURE__ */ __name((options) => options.sink ?? new InProcessTokenStreamSink(), "useFactory"),
|
|
3038
3123
|
inject: [
|
|
3039
|
-
|
|
3124
|
+
import_nestjs_agent_core20.AGENT_OPTIONS
|
|
3040
3125
|
]
|
|
3041
3126
|
},
|
|
3042
3127
|
{
|
|
3043
|
-
provide:
|
|
3044
|
-
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new
|
|
3128
|
+
provide: import_nestjs_agent_core20.AGENT_ROLES_POLICY,
|
|
3129
|
+
useFactory: /* @__PURE__ */ __name((options) => options.rolesPolicy ?? new import_nestjs_agent_core20.DefaultRolesPolicy(options.defaultRoles), "useFactory"),
|
|
3045
3130
|
inject: [
|
|
3046
|
-
|
|
3131
|
+
import_nestjs_agent_core20.AGENT_OPTIONS
|
|
3047
3132
|
]
|
|
3048
3133
|
},
|
|
3049
3134
|
{
|
|
3050
|
-
provide:
|
|
3135
|
+
provide: import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER,
|
|
3051
3136
|
useFactory: /* @__PURE__ */ __name((options) => options.actorResolver, "useFactory"),
|
|
3052
3137
|
inject: [
|
|
3053
|
-
|
|
3138
|
+
import_nestjs_agent_core20.AGENT_OPTIONS
|
|
3054
3139
|
]
|
|
3055
3140
|
},
|
|
3056
3141
|
{
|
|
3057
|
-
provide:
|
|
3142
|
+
provide: import_nestjs_agent_core20.AGENT_MODEL,
|
|
3058
3143
|
useFactory: /* @__PURE__ */ __name((o) => o.model, "useFactory"),
|
|
3059
3144
|
inject: [
|
|
3060
|
-
|
|
3145
|
+
import_nestjs_agent_core20.AGENT_OPTIONS
|
|
3061
3146
|
]
|
|
3062
3147
|
},
|
|
3063
3148
|
{
|
|
3064
3149
|
// An explicit `quota` wins; otherwise `quotaLimitTokens` binds the built-in ledger-backed
|
|
3065
3150
|
// store; otherwise quotas are off (undefined). The ledger store reads the same usage rows
|
|
3066
3151
|
// the loop already writes, so enforcement needs no extra shared state across replicas.
|
|
3067
|
-
provide:
|
|
3152
|
+
provide: import_nestjs_agent_core20.AGENT_QUOTA_STORE,
|
|
3068
3153
|
useFactory: /* @__PURE__ */ __name((o, store) => o.quota ?? (o.quotaLimitTokens !== void 0 ? new LedgerQuotaStore(store, o.quotaLimitTokens) : void 0), "useFactory"),
|
|
3069
3154
|
inject: [
|
|
3070
|
-
|
|
3071
|
-
|
|
3155
|
+
import_nestjs_agent_core20.AGENT_OPTIONS,
|
|
3156
|
+
import_nestjs_agent_core20.AGENT_STORE
|
|
3072
3157
|
]
|
|
3073
3158
|
},
|
|
3074
3159
|
AgentDepsFactory2,
|
|
3075
3160
|
{
|
|
3076
|
-
provide:
|
|
3161
|
+
provide: import_nestjs_agent_core20.AGENT_DEPS_FACTORY,
|
|
3077
3162
|
useExisting: AgentDepsFactory2
|
|
3078
3163
|
},
|
|
3079
3164
|
// Populates the registry + contributors (onModuleInit) BEFORE AiToolDiscoveryService synthesizes
|
|
@@ -3087,22 +3172,22 @@ function sharedProviders(durable, includeStore) {
|
|
|
3087
3172
|
// through AgentService.signalToolCall, which reaches whichever AGENT_RUNNER is bound above.
|
|
3088
3173
|
AgentApprovalPortAdapter,
|
|
3089
3174
|
{
|
|
3090
|
-
provide:
|
|
3175
|
+
provide: import_nestjs_agent_core20.AGENT_APPROVAL_PORT,
|
|
3091
3176
|
useExisting: AgentApprovalPortAdapter
|
|
3092
3177
|
}
|
|
3093
3178
|
];
|
|
3094
3179
|
if (includeStore) {
|
|
3095
3180
|
providers.push({
|
|
3096
|
-
provide:
|
|
3181
|
+
provide: import_nestjs_agent_core20.AGENT_STORE,
|
|
3097
3182
|
useFactory: /* @__PURE__ */ __name((o) => o.store, "useFactory"),
|
|
3098
3183
|
inject: [
|
|
3099
|
-
|
|
3184
|
+
import_nestjs_agent_core20.AGENT_OPTIONS
|
|
3100
3185
|
]
|
|
3101
3186
|
});
|
|
3102
3187
|
}
|
|
3103
3188
|
if (durable) {
|
|
3104
3189
|
providers.push({
|
|
3105
|
-
provide:
|
|
3190
|
+
provide: import_nestjs_agent_core20.AGENT_RUNNER,
|
|
3106
3191
|
useFactory: /* @__PURE__ */ __name((durableRunner) => {
|
|
3107
3192
|
if (durableRunner === void 0) {
|
|
3108
3193
|
throw new Error("AgentModule.forRoot({ durable: true }) requires importing AgentDurableModule from '@dudousxd/nestjs-agent/durable' (alongside a configured DurableModule). It was not found.");
|
|
@@ -3111,14 +3196,14 @@ function sharedProviders(durable, includeStore) {
|
|
|
3111
3196
|
}, "useFactory"),
|
|
3112
3197
|
inject: [
|
|
3113
3198
|
{
|
|
3114
|
-
token:
|
|
3199
|
+
token: import_nestjs_agent_core20.AGENT_DURABLE_RUNNER,
|
|
3115
3200
|
optional: true
|
|
3116
3201
|
}
|
|
3117
3202
|
]
|
|
3118
3203
|
});
|
|
3119
3204
|
} else {
|
|
3120
3205
|
providers.push({
|
|
3121
|
-
provide:
|
|
3206
|
+
provide: import_nestjs_agent_core20.AGENT_RUNNER,
|
|
3122
3207
|
useExisting: InlineAgentRunner
|
|
3123
3208
|
});
|
|
3124
3209
|
}
|
|
@@ -3127,25 +3212,25 @@ function sharedProviders(durable, includeStore) {
|
|
|
3127
3212
|
__name(sharedProviders, "sharedProviders");
|
|
3128
3213
|
function exportsFor(includeStore) {
|
|
3129
3214
|
return [
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3215
|
+
import_nestjs_agent_core20.AGENT_OPTIONS,
|
|
3216
|
+
import_nestjs_agent_core20.AGENT_TOOL_REGISTRY,
|
|
3217
|
+
import_nestjs_agent_core20.AGENT_REGISTRY,
|
|
3218
|
+
import_nestjs_agent_core20.AGENT_SINK,
|
|
3219
|
+
import_nestjs_agent_core20.AGENT_ROLES_POLICY,
|
|
3220
|
+
import_nestjs_agent_core20.AGENT_ACTOR_RESOLVER,
|
|
3221
|
+
import_nestjs_agent_core20.AGENT_MODEL,
|
|
3137
3222
|
...includeStore ? [
|
|
3138
|
-
|
|
3223
|
+
import_nestjs_agent_core20.AGENT_STORE
|
|
3139
3224
|
] : [],
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3225
|
+
import_nestjs_agent_core20.AGENT_QUOTA_STORE,
|
|
3226
|
+
import_nestjs_agent_core20.AGENT_PROMPT_CONTRIBUTORS,
|
|
3227
|
+
import_nestjs_agent_core20.AGENT_SKILLS,
|
|
3228
|
+
import_nestjs_agent_core20.AGENT_MEMORY,
|
|
3229
|
+
import_nestjs_agent_core20.AGENT_DEPS_FACTORY,
|
|
3145
3230
|
AgentDepsFactory2,
|
|
3146
3231
|
AgentService,
|
|
3147
3232
|
InlineAgentRunner,
|
|
3148
|
-
|
|
3233
|
+
import_nestjs_agent_core20.AGENT_APPROVAL_PORT
|
|
3149
3234
|
];
|
|
3150
3235
|
}
|
|
3151
3236
|
__name(exportsFor, "exportsFor");
|
|
@@ -3156,7 +3241,8 @@ var BASE_CONTROLLERS = [
|
|
|
3156
3241
|
QuotaController,
|
|
3157
3242
|
AgentsController,
|
|
3158
3243
|
SkillsController,
|
|
3159
|
-
MemoriesController
|
|
3244
|
+
MemoriesController,
|
|
3245
|
+
ToolsController
|
|
3160
3246
|
];
|
|
3161
3247
|
var GUARDABLE_CONTROLLERS = [
|
|
3162
3248
|
...BASE_CONTROLLERS,
|
|
@@ -3214,7 +3300,7 @@ var AgentModule = class _AgentModule {
|
|
|
3214
3300
|
controllers: controllersForSurface(options.surface, options.attachments?.upload === true),
|
|
3215
3301
|
providers: [
|
|
3216
3302
|
{
|
|
3217
|
-
provide:
|
|
3303
|
+
provide: import_nestjs_agent_core20.AGENT_OPTIONS,
|
|
3218
3304
|
useValue: options
|
|
3219
3305
|
},
|
|
3220
3306
|
...sharedProviders(options.durable ?? false, includeStore),
|
|
@@ -3238,7 +3324,7 @@ var AgentModule = class _AgentModule {
|
|
|
3238
3324
|
controllers: controllersForSurface(options.surface, options.attachmentsUpload === true),
|
|
3239
3325
|
providers: [
|
|
3240
3326
|
{
|
|
3241
|
-
provide:
|
|
3327
|
+
provide: import_nestjs_agent_core20.AGENT_OPTIONS,
|
|
3242
3328
|
// Stamp the STATIC wiring flags onto the factory result: `durable`/`surface` are
|
|
3243
3329
|
// authoritative on the async config object (they decided the actual wiring above), and
|
|
3244
3330
|
// the durable module reads `durable` back off AGENT_OPTIONS. `surface` isn't read back by
|
|
@@ -3259,13 +3345,13 @@ var AgentModule = class _AgentModule {
|
|
|
3259
3345
|
};
|
|
3260
3346
|
}
|
|
3261
3347
|
};
|
|
3262
|
-
AgentModule =
|
|
3263
|
-
(0,
|
|
3264
|
-
(0,
|
|
3348
|
+
AgentModule = _ts_decorate17([
|
|
3349
|
+
(0, import_common17.Global)(),
|
|
3350
|
+
(0, import_common17.Module)({})
|
|
3265
3351
|
], AgentModule);
|
|
3266
3352
|
|
|
3267
3353
|
// src/resolver/header-actor-resolver.ts
|
|
3268
|
-
var
|
|
3354
|
+
var import_common18 = require("@nestjs/common");
|
|
3269
3355
|
function readHeader(req, name) {
|
|
3270
3356
|
if (typeof req !== "object" || req === null || !("headers" in req)) return void 0;
|
|
3271
3357
|
const { headers } = req;
|
|
@@ -3281,7 +3367,7 @@ var HeaderActorResolver = class {
|
|
|
3281
3367
|
resolve(req) {
|
|
3282
3368
|
const id = readHeader(req, "x-actor-id");
|
|
3283
3369
|
if (id === void 0 || id.length === 0) {
|
|
3284
|
-
throw new
|
|
3370
|
+
throw new import_common18.UnauthorizedException("HeaderActorResolver: missing x-actor-id header. No default actor is fabricated. Send x-actor-id from a trusted gateway, or configure AgentModule.forRoot({ actorResolver }) with a resolver that reads your authenticated principal.");
|
|
3285
3371
|
}
|
|
3286
3372
|
const roles = (readHeader(req, "x-actor-role") ?? "").split(",").map((role) => role.trim()).filter((role) => role.length > 0);
|
|
3287
3373
|
const tenantRef = readHeader(req, "x-tenant-ref");
|
|
@@ -3327,6 +3413,7 @@ __reExport(index_exports, require("@dudousxd/nestjs-agent-core"), module.exports
|
|
|
3327
3413
|
SkillsController,
|
|
3328
3414
|
SystemPrompt,
|
|
3329
3415
|
SystemPromptContributor,
|
|
3416
|
+
ToolsController,
|
|
3330
3417
|
declaredSkillProvider,
|
|
3331
3418
|
delegateToolName,
|
|
3332
3419
|
provideAgentTool,
|