@dudousxd/nestjs-agent-core 0.38.1 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ag-ui/index.d.cts +1 -1
- package/dist/ag-ui/index.d.ts +1 -1
- package/dist/genui/index.d.cts +2 -2
- package/dist/genui/index.d.ts +2 -2
- package/dist/guardrails/index.d.cts +3 -3
- package/dist/guardrails/index.d.ts +3 -3
- package/dist/index.cjs +189 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -9
- package/dist/index.d.ts +48 -9
- package/dist/index.js +185 -17
- package/dist/index.js.map +1 -1
- package/dist/{processors-CAVevaYJ.d.cts → processors-6p9nrqEi.d.cts} +3 -1
- package/dist/{processors-C-FP4nDy.d.ts → processors-Bp5XmF6V.d.ts} +3 -1
- package/dist/{stream-events-rpd3d6gh.d.cts → stream-events-CbVEowYb.d.cts} +110 -1
- package/dist/{stream-events-rpd3d6gh.d.ts → stream-events-CbVEowYb.d.ts} +110 -1
- package/dist/{tool-hhssZ_HW.d.ts → tool-DZYLEKnl.d.cts} +3 -1
- package/dist/{tool-Dp8HA_f4.d.cts → tool-_iq4xRyk.d.ts} +3 -1
- package/package.json +1 -1
package/dist/ag-ui/index.d.cts
CHANGED
package/dist/ag-ui/index.d.ts
CHANGED
package/dist/genui/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-CrzetM3_.cjs';
|
|
2
2
|
export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as formatIssues, k as isStandardSchema, t as toJsonSchema, l as toSnakeCase, m as toolNameFor, v as validateProps, n as validatePropsSync } from '../catalog-CrzetM3_.cjs';
|
|
3
3
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import { T as ToolHandler } from '../tool-
|
|
5
|
-
import { a as Actor, T as ToolSpec, b as ToolPresentation } from '../stream-events-
|
|
4
|
+
import { T as ToolHandler } from '../tool-DZYLEKnl.cjs';
|
|
5
|
+
import { a as Actor, T as ToolSpec, b as ToolPresentation } from '../stream-events-CbVEowYb.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* One node of a composed UI: a catalog component, its props, and — for components declared with
|
package/dist/genui/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as Catalog, J as JsonSchema, G as GenuiValidation, b as GenuiIssue } from '../catalog-CrzetM3_.js';
|
|
2
2
|
export { A as AjvLike, c as COMPONENT_NAME, d as CatalogOptions, C as ComponentDefinition, e as JsonSchemaValidator, P as PropsSchema, f as ajvValidator, g as builtinJsonSchemaValidator, h as defineCatalog, i as defineComponent, j as formatIssues, k as isStandardSchema, t as toJsonSchema, l as toSnakeCase, m as toolNameFor, v as validateProps, n as validatePropsSync } from '../catalog-CrzetM3_.js';
|
|
3
3
|
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
import { T as ToolHandler } from '../tool-
|
|
5
|
-
import { a as Actor, T as ToolSpec, b as ToolPresentation } from '../stream-events-
|
|
4
|
+
import { T as ToolHandler } from '../tool-_iq4xRyk.js';
|
|
5
|
+
import { a as Actor, T as ToolSpec, b as ToolPresentation } from '../stream-events-CbVEowYb.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* One node of a composed UI: a catalog component, its props, and — for components declared with
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as InputProcessor, O as OutputProcessor } from '../processors-
|
|
2
|
-
import { T as ToolHandler } from '../tool-
|
|
3
|
-
import { a as Actor } from '../stream-events-
|
|
1
|
+
import { I as InputProcessor, O as OutputProcessor } from '../processors-6p9nrqEi.cjs';
|
|
2
|
+
import { T as ToolHandler } from '../tool-DZYLEKnl.cjs';
|
|
3
|
+
import { a as Actor } from '../stream-events-CbVEowYb.cjs';
|
|
4
4
|
import '@standard-schema/spec';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { I as InputProcessor, O as OutputProcessor } from '../processors-
|
|
2
|
-
import { T as ToolHandler } from '../tool-
|
|
3
|
-
import { a as Actor } from '../stream-events-
|
|
1
|
+
import { I as InputProcessor, O as OutputProcessor } from '../processors-Bp5XmF6V.js';
|
|
2
|
+
import { T as ToolHandler } from '../tool-_iq4xRyk.js';
|
|
3
|
+
import { a as Actor } from '../stream-events-CbVEowYb.js';
|
|
4
4
|
import '@standard-schema/spec';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -140,9 +140,11 @@ __export(src_exports, {
|
|
|
140
140
|
filterToolsByEnabled: () => filterToolsByEnabled,
|
|
141
141
|
filterToolsByRole: () => filterToolsByRole,
|
|
142
142
|
findCatalogModel: () => findCatalogModel,
|
|
143
|
+
findPersona: () => findPersona,
|
|
143
144
|
gateFollowUps: () => gateFollowUps,
|
|
144
145
|
gateTail: () => gateTail,
|
|
145
146
|
hashConfirmToken: () => hashConfirmToken,
|
|
147
|
+
intersectAllowLists: () => intersectAllowLists,
|
|
146
148
|
invokeWithTransientRetry: () => invokeWithTransientRetry,
|
|
147
149
|
isChatQueueStore: () => isChatQueueStore,
|
|
148
150
|
isControlFlowSignal: () => isControlFlowSignal,
|
|
@@ -160,6 +162,7 @@ __export(src_exports, {
|
|
|
160
162
|
observeTurnFrames: () => observeTurnFrames,
|
|
161
163
|
offerMemories: () => offerMemories,
|
|
162
164
|
offerSkills: () => offerSkills,
|
|
165
|
+
personaCatalogEntry: () => personaCatalogEntry,
|
|
163
166
|
publishAgentDelegated: () => publishAgentDelegated,
|
|
164
167
|
publishAgentMemoryResolved: () => publishAgentMemoryResolved,
|
|
165
168
|
publishAgentMemoryWritten: () => publishAgentMemoryWritten,
|
|
@@ -189,6 +192,7 @@ __export(src_exports, {
|
|
|
189
192
|
resolveGateLookback: () => resolveGateLookback,
|
|
190
193
|
resolveMemoryDigest: () => resolveMemoryDigest,
|
|
191
194
|
resolveOutputGateMode: () => resolveOutputGateMode,
|
|
195
|
+
resolvePersonaAlias: () => resolvePersonaAlias,
|
|
192
196
|
resolveSkillCatalog: () => resolveSkillCatalog,
|
|
193
197
|
resolveToolTransientRetryNumbers: () => resolveToolTransientRetryNumbers,
|
|
194
198
|
rollupThreadUsage: () => rollupThreadUsage,
|
|
@@ -565,6 +569,9 @@ function queuedMessageView(message) {
|
|
|
565
569
|
...message.agentName !== void 0 ? {
|
|
566
570
|
agentName: message.agentName
|
|
567
571
|
} : {},
|
|
572
|
+
...message.persona !== void 0 ? {
|
|
573
|
+
persona: message.persona
|
|
574
|
+
} : {},
|
|
568
575
|
...message.model !== void 0 ? {
|
|
569
576
|
model: message.model
|
|
570
577
|
} : {},
|
|
@@ -957,6 +964,54 @@ function filterToolsByAllowList(tools, allowedTools) {
|
|
|
957
964
|
}
|
|
958
965
|
__name(filterToolsByAllowList, "filterToolsByAllowList");
|
|
959
966
|
|
|
967
|
+
// src/personas.ts
|
|
968
|
+
function intersectAllowLists(first, second) {
|
|
969
|
+
if (first === void 0) {
|
|
970
|
+
return second === void 0 ? void 0 : [
|
|
971
|
+
...second
|
|
972
|
+
];
|
|
973
|
+
}
|
|
974
|
+
if (second === void 0) {
|
|
975
|
+
return [
|
|
976
|
+
...first
|
|
977
|
+
];
|
|
978
|
+
}
|
|
979
|
+
const allowed = new Set(second);
|
|
980
|
+
return first.filter((name) => allowed.has(name));
|
|
981
|
+
}
|
|
982
|
+
__name(intersectAllowLists, "intersectAllowLists");
|
|
983
|
+
function findPersona(definition, id) {
|
|
984
|
+
if (id === void 0) {
|
|
985
|
+
return void 0;
|
|
986
|
+
}
|
|
987
|
+
return definition?.personas?.find((persona) => persona.id === id);
|
|
988
|
+
}
|
|
989
|
+
__name(findPersona, "findPersona");
|
|
990
|
+
function personaCatalogEntry(persona) {
|
|
991
|
+
return {
|
|
992
|
+
id: persona.id,
|
|
993
|
+
label: persona.label,
|
|
994
|
+
...persona.description !== void 0 ? {
|
|
995
|
+
description: persona.description
|
|
996
|
+
} : {}
|
|
997
|
+
};
|
|
998
|
+
}
|
|
999
|
+
__name(personaCatalogEntry, "personaCatalogEntry");
|
|
1000
|
+
function resolvePersonaAlias(definitions, name) {
|
|
1001
|
+
for (const definition of definitions) {
|
|
1002
|
+
for (const persona of definition.personas ?? []) {
|
|
1003
|
+
if (persona.aliases?.includes(name) === true) {
|
|
1004
|
+
return {
|
|
1005
|
+
agent: definition.name,
|
|
1006
|
+
persona: persona.id
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
return void 0;
|
|
1012
|
+
}
|
|
1013
|
+
__name(resolvePersonaAlias, "resolvePersonaAlias");
|
|
1014
|
+
|
|
960
1015
|
// src/history.ts
|
|
961
1016
|
function estimateMessageTokens(message) {
|
|
962
1017
|
const extras = (message.toolCalls !== void 0 ? JSON.stringify(message.toolCalls).length : 0) + (message.toolResults !== void 0 ? JSON.stringify(message.toolResults).length : 0);
|
|
@@ -2896,7 +2951,7 @@ var ToolRegistry = class {
|
|
|
2896
2951
|
* a call can reach here from a replayed durable step or an approval granted before the flag
|
|
2897
2952
|
* moved, neither of which went through `definitionsFor` again) and re-parses the input via Zod.
|
|
2898
2953
|
*/
|
|
2899
|
-
async invoke(name, input, ctx, policy) {
|
|
2954
|
+
async invoke(name, input, ctx, policy, options = {}) {
|
|
2900
2955
|
const entry = this.entries.get(name);
|
|
2901
2956
|
if (entry === void 0) {
|
|
2902
2957
|
throw new ToolNotFoundError(name);
|
|
@@ -2910,6 +2965,9 @@ var ToolRegistry = class {
|
|
|
2910
2965
|
if (!await canActorUseTool(ctx.actor, entry.handler)) {
|
|
2911
2966
|
throw new ToolForbiddenError(name);
|
|
2912
2967
|
}
|
|
2968
|
+
if (options.allowedTools !== void 0 && !options.allowedTools.includes(name)) {
|
|
2969
|
+
throw new ToolForbiddenError(name);
|
|
2970
|
+
}
|
|
2913
2971
|
const validation = await entry.spec.inputSchema["~standard"].validate(input);
|
|
2914
2972
|
if (validation.issues !== void 0) {
|
|
2915
2973
|
throw new ToolInputInvalidError(name, validation.issues);
|
|
@@ -3261,16 +3319,10 @@ async function resolvePrompt(prompt, ctx) {
|
|
|
3261
3319
|
return typeof prompt === "function" ? prompt(ctx) : prompt;
|
|
3262
3320
|
}
|
|
3263
3321
|
__name(resolvePrompt, "resolvePrompt");
|
|
3264
|
-
async function resolveSystemPrompt(deps, input) {
|
|
3265
|
-
const ctx =
|
|
3266
|
-
actor: input.actor,
|
|
3267
|
-
agentName: input.agentName ?? "default",
|
|
3268
|
-
...input.pageContext !== void 0 ? {
|
|
3269
|
-
pageContext: input.pageContext
|
|
3270
|
-
} : {}
|
|
3271
|
-
};
|
|
3322
|
+
async function resolveSystemPrompt(deps, input, persona) {
|
|
3323
|
+
const ctx = promptContext(input, persona);
|
|
3272
3324
|
const sections = [
|
|
3273
|
-
await resolvePrompt(deps.systemPrompt, ctx)
|
|
3325
|
+
persona?.prompt ?? await resolvePrompt(deps.systemPrompt, ctx)
|
|
3274
3326
|
];
|
|
3275
3327
|
for (const contribute of deps.promptContributors ?? []) {
|
|
3276
3328
|
const section = await contribute(ctx);
|
|
@@ -3281,6 +3333,67 @@ async function resolveSystemPrompt(deps, input) {
|
|
|
3281
3333
|
return sections.join("\n\n");
|
|
3282
3334
|
}
|
|
3283
3335
|
__name(resolveSystemPrompt, "resolveSystemPrompt");
|
|
3336
|
+
function withoutPersona(input) {
|
|
3337
|
+
const { persona: _dropped, ...rest } = input;
|
|
3338
|
+
return rest;
|
|
3339
|
+
}
|
|
3340
|
+
__name(withoutPersona, "withoutPersona");
|
|
3341
|
+
function promptContext(input, persona) {
|
|
3342
|
+
return {
|
|
3343
|
+
actor: input.actor,
|
|
3344
|
+
agentName: input.agentName ?? "default",
|
|
3345
|
+
...input.pageContext !== void 0 ? {
|
|
3346
|
+
pageContext: input.pageContext
|
|
3347
|
+
} : {},
|
|
3348
|
+
...persona !== void 0 ? {
|
|
3349
|
+
persona: {
|
|
3350
|
+
id: persona.id,
|
|
3351
|
+
label: persona.label
|
|
3352
|
+
}
|
|
3353
|
+
} : {}
|
|
3354
|
+
};
|
|
3355
|
+
}
|
|
3356
|
+
__name(promptContext, "promptContext");
|
|
3357
|
+
async function resolveTurnPersona(deps, input) {
|
|
3358
|
+
const persona = findPersona(deps, input.persona);
|
|
3359
|
+
if (persona === void 0) {
|
|
3360
|
+
return null;
|
|
3361
|
+
}
|
|
3362
|
+
const ref = {
|
|
3363
|
+
id: persona.id,
|
|
3364
|
+
label: persona.label
|
|
3365
|
+
};
|
|
3366
|
+
let prompt;
|
|
3367
|
+
if (persona.systemPrompt !== void 0) {
|
|
3368
|
+
const ctx = promptContext(input, ref);
|
|
3369
|
+
const basePrompt = typeof persona.systemPrompt === "function" ? await resolvePrompt(deps.systemPrompt, ctx) : void 0;
|
|
3370
|
+
prompt = await resolvePrompt(persona.systemPrompt, {
|
|
3371
|
+
...ctx,
|
|
3372
|
+
...basePrompt !== void 0 ? {
|
|
3373
|
+
basePrompt
|
|
3374
|
+
} : {}
|
|
3375
|
+
});
|
|
3376
|
+
}
|
|
3377
|
+
return {
|
|
3378
|
+
...ref,
|
|
3379
|
+
...persona.allowedTools !== void 0 ? {
|
|
3380
|
+
allowedTools: [
|
|
3381
|
+
...persona.allowedTools
|
|
3382
|
+
]
|
|
3383
|
+
} : {},
|
|
3384
|
+
...prompt !== void 0 ? {
|
|
3385
|
+
prompt
|
|
3386
|
+
} : {}
|
|
3387
|
+
};
|
|
3388
|
+
}
|
|
3389
|
+
__name(resolveTurnPersona, "resolveTurnPersona");
|
|
3390
|
+
function personaRefusal(persona, toolName) {
|
|
3391
|
+
if (persona?.allowedTools === void 0 || persona.allowedTools.includes(toolName)) {
|
|
3392
|
+
return null;
|
|
3393
|
+
}
|
|
3394
|
+
return `(tool "${toolName}" is not available to the "${persona.id}" persona)`;
|
|
3395
|
+
}
|
|
3396
|
+
__name(personaRefusal, "personaRefusal");
|
|
3284
3397
|
function extractTask(input) {
|
|
3285
3398
|
if (typeof input === "object" && input !== null && "task" in input) {
|
|
3286
3399
|
const task = input.task;
|
|
@@ -3522,6 +3635,9 @@ function processorContext(input, step) {
|
|
|
3522
3635
|
step,
|
|
3523
3636
|
...input.agentName !== void 0 ? {
|
|
3524
3637
|
agentName: input.agentName
|
|
3638
|
+
} : {},
|
|
3639
|
+
...input.persona !== void 0 ? {
|
|
3640
|
+
persona: input.persona
|
|
3525
3641
|
} : {}
|
|
3526
3642
|
};
|
|
3527
3643
|
}
|
|
@@ -3685,6 +3801,9 @@ function toolContext(deps, input, hooks) {
|
|
|
3685
3801
|
...input.agentName !== void 0 ? {
|
|
3686
3802
|
agentName: input.agentName
|
|
3687
3803
|
} : {},
|
|
3804
|
+
...input.persona !== void 0 ? {
|
|
3805
|
+
persona: input.persona
|
|
3806
|
+
} : {},
|
|
3688
3807
|
...input.pageContext !== void 0 ? {
|
|
3689
3808
|
pageContext: input.pageContext
|
|
3690
3809
|
} : {},
|
|
@@ -3732,6 +3851,9 @@ async function runIntake(intake, deps, input, hooks, writer, threadHasAssistant)
|
|
|
3732
3851
|
],
|
|
3733
3852
|
...input.agentName !== void 0 ? {
|
|
3734
3853
|
agentName: input.agentName
|
|
3854
|
+
} : {},
|
|
3855
|
+
...input.persona !== void 0 ? {
|
|
3856
|
+
persona: input.persona
|
|
3735
3857
|
} : {}
|
|
3736
3858
|
});
|
|
3737
3859
|
await deps.store.recordToolCall({
|
|
@@ -4077,6 +4199,7 @@ async function invokeClaimedTool(turn, claimed) {
|
|
|
4077
4199
|
if (claimed.toolType === "memory") {
|
|
4078
4200
|
return await rememberIntoTurn(turn, claimed, startedAt);
|
|
4079
4201
|
}
|
|
4202
|
+
const invokeAllowList = turn.persona?.allowedTools === void 0 ? void 0 : intersectAllowLists(deps.toolAllowList, turn.persona.allowedTools);
|
|
4080
4203
|
let raw;
|
|
4081
4204
|
if (hooks.dispatchTool) {
|
|
4082
4205
|
const stepCtx = {
|
|
@@ -4087,6 +4210,9 @@ async function invokeClaimedTool(turn, claimed) {
|
|
|
4087
4210
|
...input.agentName !== void 0 ? {
|
|
4088
4211
|
agentName: input.agentName
|
|
4089
4212
|
} : {},
|
|
4213
|
+
...input.persona !== void 0 ? {
|
|
4214
|
+
persona: input.persona
|
|
4215
|
+
} : {},
|
|
4090
4216
|
...input.pageContext !== void 0 ? {
|
|
4091
4217
|
pageContext: input.pageContext
|
|
4092
4218
|
} : {}
|
|
@@ -4095,6 +4221,9 @@ async function invokeClaimedTool(turn, claimed) {
|
|
|
4095
4221
|
toolName: call.name,
|
|
4096
4222
|
input: call.input,
|
|
4097
4223
|
ctx: stepCtx,
|
|
4224
|
+
...invokeAllowList !== void 0 ? {
|
|
4225
|
+
allowedTools: invokeAllowList
|
|
4226
|
+
} : {},
|
|
4098
4227
|
...deps.toolTimeoutMs !== void 0 ? {
|
|
4099
4228
|
timeoutMs: deps.toolTimeoutMs
|
|
4100
4229
|
} : {},
|
|
@@ -4117,7 +4246,9 @@ async function invokeClaimedTool(turn, claimed) {
|
|
|
4117
4246
|
return deps.registry.invoke(call.name, call.input, {
|
|
4118
4247
|
...toolCallContext(ctx, call.id),
|
|
4119
4248
|
emitUi: ui2.emit
|
|
4120
|
-
}, deps.rolesPolicy
|
|
4249
|
+
}, deps.rolesPolicy, invokeAllowList !== void 0 ? {
|
|
4250
|
+
allowedTools: invokeAllowList
|
|
4251
|
+
} : {});
|
|
4121
4252
|
}, deps.toolTransientRetry ?? {}, {
|
|
4122
4253
|
...hooks.isControlFlowError !== void 0 ? {
|
|
4123
4254
|
isControlFlowError: hooks.isControlFlowError
|
|
@@ -4248,7 +4379,7 @@ async function delegateToolCall(turn, claimed) {
|
|
|
4248
4379
|
const { deps, input, hooks } = turn;
|
|
4249
4380
|
const { call, targetAgent = call.name } = claimed;
|
|
4250
4381
|
const task = extractTask(call.input);
|
|
4251
|
-
const refusal = delegationRefusal({
|
|
4382
|
+
const refusal = personaRefusal(turn.persona, call.name) ?? delegationRefusal({
|
|
4252
4383
|
deps,
|
|
4253
4384
|
input,
|
|
4254
4385
|
targetAgent
|
|
@@ -4544,14 +4675,16 @@ async function invokeClaimedToolsTogether(turn, parallel, claimed) {
|
|
|
4544
4675
|
return results;
|
|
4545
4676
|
}
|
|
4546
4677
|
__name(invokeClaimedToolsTogether, "invokeClaimedToolsTogether");
|
|
4547
|
-
async function runAgentLoop(boundDeps,
|
|
4678
|
+
async function runAgentLoop(boundDeps, requested, hooks) {
|
|
4679
|
+
const persona = requested.persona === void 0 ? void 0 : await hooks.step("persona:resolve", () => resolveTurnPersona(boundDeps, requested)) ?? void 0;
|
|
4680
|
+
const input = persona === void 0 || persona.id !== requested.persona ? withoutPersona(requested) : requested;
|
|
4548
4681
|
const deps = input.model === void 0 ? boundDeps : {
|
|
4549
4682
|
...boundDeps,
|
|
4550
4683
|
model: withSelectedModel(boundDeps.model, input.model),
|
|
4551
4684
|
modelId: input.model
|
|
4552
4685
|
};
|
|
4553
4686
|
const maxSteps = deps.maxSteps ?? 8;
|
|
4554
|
-
let system = await resolveSystemPrompt(deps, input);
|
|
4687
|
+
let system = await resolveSystemPrompt(deps, input, persona);
|
|
4555
4688
|
const inputProcessors = deps.inputProcessors ?? [];
|
|
4556
4689
|
const outputProcessors = deps.outputProcessors ?? [];
|
|
4557
4690
|
const gateMode = resolveOutputGateMode(outputProcessors);
|
|
@@ -4592,6 +4725,9 @@ async function runAgentLoop(boundDeps, input, hooks) {
|
|
|
4592
4725
|
role: "user",
|
|
4593
4726
|
content: input.userText,
|
|
4594
4727
|
runId: hooks.runId,
|
|
4728
|
+
...input.persona !== void 0 ? {
|
|
4729
|
+
persona: input.persona
|
|
4730
|
+
} : {},
|
|
4595
4731
|
...input.attachments !== void 0 ? {
|
|
4596
4732
|
attachments: input.attachments
|
|
4597
4733
|
} : {}
|
|
@@ -4614,6 +4750,9 @@ async function runAgentLoop(boundDeps, input, hooks) {
|
|
|
4614
4750
|
actorId: input.actor.id,
|
|
4615
4751
|
...input.agentName !== void 0 ? {
|
|
4616
4752
|
agentName: input.agentName
|
|
4753
|
+
} : {},
|
|
4754
|
+
...input.persona !== void 0 ? {
|
|
4755
|
+
persona: input.persona
|
|
4617
4756
|
} : {}
|
|
4618
4757
|
});
|
|
4619
4758
|
const stages = await resolvePromptStages(deps, hooks);
|
|
@@ -4750,13 +4889,16 @@ ${block}`;
|
|
|
4750
4889
|
} : {},
|
|
4751
4890
|
...input.model !== void 0 ? {
|
|
4752
4891
|
model: input.model
|
|
4892
|
+
} : {},
|
|
4893
|
+
...persona?.allowedTools !== void 0 ? {
|
|
4894
|
+
personaAllowedTools: persona.allowedTools
|
|
4753
4895
|
} : {}
|
|
4754
4896
|
});
|
|
4755
4897
|
} else {
|
|
4756
4898
|
const tools = withMemoryTool({
|
|
4757
4899
|
tools: withSkillTool({
|
|
4758
4900
|
tools: withAskTool({
|
|
4759
|
-
tools: await deps.registry.definitionsFor(input.actor, deps.rolesPolicy, deps.toolAllowList, {
|
|
4901
|
+
tools: await deps.registry.definitionsFor(input.actor, deps.rolesPolicy, intersectAllowLists(deps.toolAllowList, persona?.allowedTools), {
|
|
4760
4902
|
threadId: input.threadId,
|
|
4761
4903
|
...input.agentName !== void 0 ? {
|
|
4762
4904
|
agentName: input.agentName
|
|
@@ -4971,6 +5113,9 @@ ${block}`;
|
|
|
4971
5113
|
...input.agentName !== void 0 ? {
|
|
4972
5114
|
agentName: input.agentName
|
|
4973
5115
|
} : {},
|
|
5116
|
+
...input.persona !== void 0 ? {
|
|
5117
|
+
persona: input.persona
|
|
5118
|
+
} : {},
|
|
4974
5119
|
...turn.reasoning !== void 0 ? {
|
|
4975
5120
|
reasoning: turn.reasoning
|
|
4976
5121
|
} : {},
|
|
@@ -5065,6 +5210,9 @@ ${block}`;
|
|
|
5065
5210
|
} : {},
|
|
5066
5211
|
...memoryDigest !== void 0 ? {
|
|
5067
5212
|
memory: memoryDigest
|
|
5213
|
+
} : {},
|
|
5214
|
+
...persona !== void 0 ? {
|
|
5215
|
+
persona
|
|
5068
5216
|
} : {}
|
|
5069
5217
|
};
|
|
5070
5218
|
const parallel = hooks.parallel;
|
|
@@ -5197,7 +5345,10 @@ var InMemoryAgentStore = class {
|
|
|
5197
5345
|
transient: input.transient ?? false,
|
|
5198
5346
|
createdAt: ts,
|
|
5199
5347
|
updatedAt: ts,
|
|
5200
|
-
messages: []
|
|
5348
|
+
messages: [],
|
|
5349
|
+
...input.persona !== void 0 ? {
|
|
5350
|
+
persona: input.persona
|
|
5351
|
+
} : {}
|
|
5201
5352
|
};
|
|
5202
5353
|
this.threads.set(id, row);
|
|
5203
5354
|
return this.toSummary(row);
|
|
@@ -5302,6 +5453,9 @@ var InMemoryAgentStore = class {
|
|
|
5302
5453
|
} : {},
|
|
5303
5454
|
...source.model != null ? {
|
|
5304
5455
|
model: source.model
|
|
5456
|
+
} : {},
|
|
5457
|
+
...source.persona != null ? {
|
|
5458
|
+
persona: source.persona
|
|
5305
5459
|
} : {}
|
|
5306
5460
|
};
|
|
5307
5461
|
this.threads.set(id, row);
|
|
@@ -5353,6 +5507,9 @@ var InMemoryAgentStore = class {
|
|
|
5353
5507
|
if (patch.model !== void 0) {
|
|
5354
5508
|
row.model = patch.model;
|
|
5355
5509
|
}
|
|
5510
|
+
if (patch.persona !== void 0) {
|
|
5511
|
+
row.persona = patch.persona;
|
|
5512
|
+
}
|
|
5356
5513
|
row.updatedAt = this.now();
|
|
5357
5514
|
}
|
|
5358
5515
|
async activeRunForThread(threadId) {
|
|
@@ -5366,6 +5523,10 @@ var InMemoryAgentStore = class {
|
|
|
5366
5523
|
async defaultAgentForThread(threadId) {
|
|
5367
5524
|
return this.threads.get(threadId)?.defaultAgent ?? null;
|
|
5368
5525
|
}
|
|
5526
|
+
/** The thread's persona, projected like {@link defaultAgentForThread}. */
|
|
5527
|
+
async personaForThread(threadId) {
|
|
5528
|
+
return this.threads.get(threadId)?.persona ?? null;
|
|
5529
|
+
}
|
|
5369
5530
|
/** The thread's pinned model, projected like {@link defaultAgentForThread}. */
|
|
5370
5531
|
async modelForThread(threadId) {
|
|
5371
5532
|
return this.threads.get(threadId)?.model ?? null;
|
|
@@ -5470,6 +5631,9 @@ var InMemoryAgentStore = class {
|
|
|
5470
5631
|
...input.agentName !== void 0 ? {
|
|
5471
5632
|
agentName: input.agentName
|
|
5472
5633
|
} : {},
|
|
5634
|
+
...input.persona !== void 0 ? {
|
|
5635
|
+
persona: input.persona
|
|
5636
|
+
} : {},
|
|
5473
5637
|
...input.model !== void 0 ? {
|
|
5474
5638
|
model: input.model
|
|
5475
5639
|
} : {},
|
|
@@ -5608,6 +5772,9 @@ var InMemoryAgentStore = class {
|
|
|
5608
5772
|
...input.agentName !== void 0 ? {
|
|
5609
5773
|
agentName: input.agentName
|
|
5610
5774
|
} : {},
|
|
5775
|
+
...input.persona !== void 0 ? {
|
|
5776
|
+
persona: input.persona
|
|
5777
|
+
} : {},
|
|
5611
5778
|
...input.runId !== void 0 ? {
|
|
5612
5779
|
runId: input.runId
|
|
5613
5780
|
} : {},
|
|
@@ -6024,7 +6191,8 @@ var InMemoryAgentStore = class {
|
|
|
6024
6191
|
defaultAgent: row.defaultAgent ?? null,
|
|
6025
6192
|
...row.model != null ? {
|
|
6026
6193
|
model: row.model
|
|
6027
|
-
} : {}
|
|
6194
|
+
} : {},
|
|
6195
|
+
persona: row.persona ?? null
|
|
6028
6196
|
};
|
|
6029
6197
|
}
|
|
6030
6198
|
};
|
|
@@ -6697,9 +6865,11 @@ var SqlTokenStreamSink = class {
|
|
|
6697
6865
|
filterToolsByEnabled,
|
|
6698
6866
|
filterToolsByRole,
|
|
6699
6867
|
findCatalogModel,
|
|
6868
|
+
findPersona,
|
|
6700
6869
|
gateFollowUps,
|
|
6701
6870
|
gateTail,
|
|
6702
6871
|
hashConfirmToken,
|
|
6872
|
+
intersectAllowLists,
|
|
6703
6873
|
invokeWithTransientRetry,
|
|
6704
6874
|
isChatQueueStore,
|
|
6705
6875
|
isControlFlowSignal,
|
|
@@ -6717,6 +6887,7 @@ var SqlTokenStreamSink = class {
|
|
|
6717
6887
|
observeTurnFrames,
|
|
6718
6888
|
offerMemories,
|
|
6719
6889
|
offerSkills,
|
|
6890
|
+
personaCatalogEntry,
|
|
6720
6891
|
publishAgentDelegated,
|
|
6721
6892
|
publishAgentMemoryResolved,
|
|
6722
6893
|
publishAgentMemoryWritten,
|
|
@@ -6746,6 +6917,7 @@ var SqlTokenStreamSink = class {
|
|
|
6746
6917
|
resolveGateLookback,
|
|
6747
6918
|
resolveMemoryDigest,
|
|
6748
6919
|
resolveOutputGateMode,
|
|
6920
|
+
resolvePersonaAlias,
|
|
6749
6921
|
resolveSkillCatalog,
|
|
6750
6922
|
resolveToolTransientRetryNumbers,
|
|
6751
6923
|
rollupThreadUsage,
|