agent-world 0.12.3 → 0.13.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 +15 -0
- package/dist/cli/hitl.d.ts +5 -1
- package/dist/cli/hitl.js +9 -3
- package/dist/cli/index.js +11 -9
- package/dist/core/activity-tracker.d.ts +12 -2
- package/dist/core/activity-tracker.d.ts.map +1 -1
- package/dist/core/activity-tracker.js +41 -5
- package/dist/core/activity-tracker.js.map +1 -1
- package/dist/core/create-agent-tool.d.ts +23 -25
- package/dist/core/create-agent-tool.d.ts.map +1 -1
- package/dist/core/create-agent-tool.js +241 -141
- package/dist/core/create-agent-tool.js.map +1 -1
- package/dist/core/events/memory-manager.js +1 -1
- package/dist/core/events/memory-manager.js.map +1 -1
- package/dist/core/events/orchestrator.d.ts.map +1 -1
- package/dist/core/events/orchestrator.js +14 -5
- package/dist/core/events/orchestrator.js.map +1 -1
- package/dist/core/events/persistence.d.ts +1 -1
- package/dist/core/events/persistence.d.ts.map +1 -1
- package/dist/core/events/persistence.js +1 -27
- package/dist/core/events/persistence.js.map +1 -1
- package/dist/core/events/publishers.d.ts +0 -9
- package/dist/core/events/publishers.d.ts.map +1 -1
- package/dist/core/events/publishers.js +10 -27
- package/dist/core/events/publishers.js.map +1 -1
- package/dist/core/events/subscribers.d.ts +1 -1
- package/dist/core/events/subscribers.d.ts.map +1 -1
- package/dist/core/events/subscribers.js +15 -7
- package/dist/core/events/subscribers.js.map +1 -1
- package/dist/core/hitl-tool.d.ts +79 -0
- package/dist/core/hitl-tool.d.ts.map +1 -0
- package/dist/core/hitl-tool.js +306 -0
- package/dist/core/hitl-tool.js.map +1 -0
- package/dist/core/hitl.d.ts +26 -6
- package/dist/core/hitl.d.ts.map +1 -1
- package/dist/core/hitl.js +82 -32
- package/dist/core/hitl.js.map +1 -1
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/llm-manager.d.ts +2 -0
- package/dist/core/llm-manager.d.ts.map +1 -1
- package/dist/core/llm-manager.js +16 -9
- package/dist/core/llm-manager.js.map +1 -1
- package/dist/core/managers.d.ts +24 -3
- package/dist/core/managers.d.ts.map +1 -1
- package/dist/core/managers.js +103 -52
- package/dist/core/managers.js.map +1 -1
- package/dist/core/mcp-server-registry.d.ts +3 -1
- package/dist/core/mcp-server-registry.d.ts.map +1 -1
- package/dist/core/mcp-server-registry.js +7 -1
- package/dist/core/mcp-server-registry.js.map +1 -1
- package/dist/core/tool-utils.d.ts +3 -1
- package/dist/core/tool-utils.d.ts.map +1 -1
- package/dist/core/tool-utils.js +55 -25
- package/dist/core/tool-utils.js.map +1 -1
- package/dist/core/types.d.ts +2 -17
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +0 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/utils.d.ts +9 -0
- package/dist/core/utils.d.ts.map +1 -1
- package/dist/core/utils.js +28 -3
- package/dist/core/utils.js.map +1 -1
- package/dist/public/assets/index-BW41BxMy.css +1 -0
- package/dist/public/assets/index-kO6UJFwK.js +96 -0
- package/dist/public/index.html +2 -2
- package/dist/server/api.js +29 -41
- package/dist/server/sse-handler.d.ts +3 -2
- package/dist/server/sse-handler.js +19 -11
- package/package.json +1 -1
- package/dist/public/assets/index-BO20H4xt.js +0 -96
- package/dist/public/assets/index-ETY7W5_S.css +0 -1
|
@@ -1,210 +1,310 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Create Agent Tool Module - Built-in tool for approval-gated agent creation
|
|
2
|
+
* Create Agent Tool Module - Built-in tool for approval-gated agent creation
|
|
3
3
|
*
|
|
4
4
|
* Purpose:
|
|
5
|
-
* -
|
|
5
|
+
* - Expose a built-in `create_agent` tool that creates one new agent after explicit user approval.
|
|
6
6
|
*
|
|
7
7
|
* Key Features:
|
|
8
|
-
* - Requires `name` and supports optional `autoReply`, `role`, and `nextAgent`
|
|
9
|
-
* - Enforces
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* - Returns structured JSON payloads for success, denial, and error outcomes.
|
|
8
|
+
* - Requires `name` and supports optional `autoReply`, `role`, and `nextAgent` inputs.
|
|
9
|
+
* - Enforces HITL approval with deterministic deny/timeout handling before persistence.
|
|
10
|
+
* - Generates deterministic system prompt text for multi-agent routing.
|
|
11
|
+
* - Uses world-level chat provider/model settings with deterministic fallbacks.
|
|
13
12
|
*
|
|
14
|
-
* Notes
|
|
15
|
-
* - Uses `
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
13
|
+
* Implementation Notes:
|
|
14
|
+
* - Uses manager-level `createAgent` as the persistence boundary.
|
|
15
|
+
* - Returns deterministic JSON-string payloads for success, denial, and errors.
|
|
16
|
+
* - Keeps runtime contract canonical (`autoReply`, `nextAgent`) while aliases are handled upstream.
|
|
18
17
|
*
|
|
19
18
|
* Recent Changes:
|
|
20
|
-
* - 2026-02-
|
|
19
|
+
* - 2026-02-20: Added post-create HITL informational confirmation (`Agent <name> has been created`) with `refreshAfterDismiss` metadata set to true.
|
|
20
|
+
* - 2026-02-20: Pre-claim agent creation slot before approval dialog to prevent parallel-call race where both calls pass approval before either calls createAgent.
|
|
21
|
+
* - 2026-02-20: Updated tool create path to allow manager-level create during the current in-flight world processing turn.
|
|
22
|
+
* - 2026-02-20: Updated `create_agent` default behavior so omitted `autoReply` resolves to `false`.
|
|
23
|
+
* - 2026-02-20: Added initial built-in `create_agent` tool implementation with mandatory approval gate.
|
|
21
24
|
*/
|
|
22
25
|
import { requestWorldOption } from './hitl.js';
|
|
23
|
-
import { createAgent } from './managers.js';
|
|
24
|
-
import { LLMProvider } from './types.js';
|
|
25
|
-
import {
|
|
26
|
+
import { createAgent, claimAgentCreationSlot } from './managers.js';
|
|
27
|
+
import { LLMProvider, EventType } from './types.js';
|
|
28
|
+
import { publishEvent } from './events/publishers.js';
|
|
26
29
|
const APPROVAL_OPTION_YES = 'yes';
|
|
27
30
|
const APPROVAL_OPTION_NO = 'no';
|
|
31
|
+
const INFO_OPTION_DISMISS = 'dismiss';
|
|
32
|
+
const DEFAULT_NEXT_AGENT = 'human';
|
|
28
33
|
const DEFAULT_PROVIDER = LLMProvider.OPENAI;
|
|
29
34
|
const DEFAULT_MODEL = 'gpt-4';
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
function normalizeSingleLineText(value) {
|
|
33
|
-
if (typeof value !== 'string')
|
|
34
|
-
return '';
|
|
35
|
-
return value.replace(/\s+/g, ' ').trim();
|
|
35
|
+
function stringifyResult(payload) {
|
|
36
|
+
return JSON.stringify(payload);
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
if (!normalized)
|
|
40
|
-
return '';
|
|
41
|
-
return normalized.slice(0, MAX_ROLE_LENGTH);
|
|
42
|
-
}
|
|
43
|
-
function resolveNextAgent(nextAgent) {
|
|
44
|
-
const normalized = normalizeSingleLineText(nextAgent);
|
|
45
|
-
if (!normalized)
|
|
46
|
-
return DEFAULT_NEXT_AGENT;
|
|
47
|
-
const stripped = normalized.startsWith('@') ? normalized.slice(1) : normalized;
|
|
48
|
-
const token = toKebabCase(stripped);
|
|
49
|
-
return token || DEFAULT_NEXT_AGENT;
|
|
38
|
+
function normalizeWhitespace(value) {
|
|
39
|
+
return value.replace(/\s+/g, ' ').trim();
|
|
50
40
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (configured && allProviders.has(configured)) {
|
|
55
|
-
return configured;
|
|
41
|
+
function validateAndNormalizeArgs(args) {
|
|
42
|
+
if (typeof args.name !== 'string' || !args.name.trim()) {
|
|
43
|
+
return { valid: false, error: 'Missing required parameter: name' };
|
|
56
44
|
}
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
if (args.autoReply !== undefined && typeof args.autoReply !== 'boolean') {
|
|
46
|
+
return { valid: false, error: 'Parameter autoReply must be a boolean when provided' };
|
|
47
|
+
}
|
|
48
|
+
if (args.role !== undefined && typeof args.role !== 'string') {
|
|
49
|
+
return { valid: false, error: 'Parameter role must be a string when provided' };
|
|
50
|
+
}
|
|
51
|
+
if (args.nextAgent !== undefined && typeof args.nextAgent !== 'string') {
|
|
52
|
+
return { valid: false, error: 'Parameter nextAgent must be a string when provided' };
|
|
53
|
+
}
|
|
54
|
+
const name = normalizeWhitespace(args.name);
|
|
55
|
+
const autoReply = args.autoReply ?? false;
|
|
56
|
+
const role = typeof args.role === 'string' && args.role.trim()
|
|
57
|
+
? normalizeWhitespace(args.role)
|
|
58
|
+
: null;
|
|
59
|
+
const nextAgent = typeof args.nextAgent === 'string' && args.nextAgent.trim()
|
|
60
|
+
? normalizeWhitespace(args.nextAgent)
|
|
61
|
+
: DEFAULT_NEXT_AGENT;
|
|
62
|
+
return {
|
|
63
|
+
valid: true,
|
|
64
|
+
args: { name, autoReply, role, nextAgent },
|
|
65
|
+
};
|
|
62
66
|
}
|
|
63
|
-
function
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
`You are agent ${name}
|
|
67
|
-
|
|
68
|
-
'Always respond in exactly this structure:',
|
|
69
|
-
`@${nextAgent}`,
|
|
70
|
-
'{Your response}',
|
|
71
|
-
].join('\n');
|
|
67
|
+
function buildDeterministicSystemPrompt(name, role, nextAgent) {
|
|
68
|
+
const firstLine = role
|
|
69
|
+
? `You are agent ${name}. Your role is ${role}.`
|
|
70
|
+
: `You are agent ${name}.`;
|
|
71
|
+
return `${firstLine}\n\nAlways respond in exactly this structure:\n@${nextAgent}\n{Your response}`;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
73
|
+
function resolveProviderAndModel(world) {
|
|
74
|
+
const provider = typeof world?.chatLLMProvider === 'string' && world.chatLLMProvider.trim()
|
|
75
|
+
? world.chatLLMProvider
|
|
76
|
+
: DEFAULT_PROVIDER;
|
|
77
|
+
const model = typeof world?.chatLLMModel === 'string' && world.chatLLMModel.trim()
|
|
78
|
+
? world.chatLLMModel.trim()
|
|
79
|
+
: DEFAULT_MODEL;
|
|
80
|
+
return { provider: provider, model };
|
|
75
81
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
async function requestCreateAgentApproval(options) {
|
|
83
|
+
const approval = await requestWorldOption(options.world, {
|
|
84
|
+
title: `Create agent ${options.name}?`,
|
|
85
|
+
message: [
|
|
86
|
+
`Create a new agent named "${options.name}"?`,
|
|
87
|
+
`Auto reply: ${options.autoReply ? 'enabled' : 'disabled'}`,
|
|
88
|
+
`Role: ${options.role ?? '(none)'}`,
|
|
89
|
+
`Next agent: ${options.nextAgent}`,
|
|
90
|
+
].join('\n'),
|
|
91
|
+
chatId: options.chatId,
|
|
92
|
+
defaultOptionId: APPROVAL_OPTION_NO,
|
|
93
|
+
options: [
|
|
94
|
+
{ id: APPROVAL_OPTION_YES, label: 'Yes', description: 'Create the agent now.' },
|
|
95
|
+
{ id: APPROVAL_OPTION_NO, label: 'No', description: 'Do not create the agent.' },
|
|
96
|
+
],
|
|
97
|
+
metadata: {
|
|
98
|
+
tool: 'create_agent',
|
|
99
|
+
name: options.name,
|
|
100
|
+
autoReply: options.autoReply,
|
|
101
|
+
role: options.role,
|
|
102
|
+
nextAgent: options.nextAgent,
|
|
103
|
+
},
|
|
81
104
|
});
|
|
105
|
+
if (approval.optionId === APPROVAL_OPTION_YES) {
|
|
106
|
+
return { approved: true, reason: 'approved' };
|
|
107
|
+
}
|
|
108
|
+
if (approval.source === 'timeout') {
|
|
109
|
+
return { approved: false, reason: 'timeout' };
|
|
110
|
+
}
|
|
111
|
+
return { approved: false, reason: 'user_denied' };
|
|
82
112
|
}
|
|
83
|
-
function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
113
|
+
async function requestCreateAgentCreatedInfo(options) {
|
|
114
|
+
await requestWorldOption(options.world, {
|
|
115
|
+
title: `Agent ${options.name} created`,
|
|
116
|
+
message: [
|
|
117
|
+
`Agent ${options.name} has been created.`,
|
|
118
|
+
`Auto reply: ${options.autoReply ? 'enabled' : 'disabled'}`,
|
|
119
|
+
`Role: ${options.role ?? '(none)'}`,
|
|
120
|
+
`Next agent: ${options.nextAgent}`,
|
|
121
|
+
`Provider: ${options.provider}`,
|
|
122
|
+
`Model: ${options.model}`,
|
|
123
|
+
].join('\n'),
|
|
124
|
+
chatId: options.chatId,
|
|
125
|
+
defaultOptionId: INFO_OPTION_DISMISS,
|
|
126
|
+
options: [
|
|
127
|
+
{ id: INFO_OPTION_DISMISS, label: 'Dismiss', description: 'Close this confirmation.' },
|
|
128
|
+
],
|
|
129
|
+
metadata: {
|
|
130
|
+
kind: 'create_agent_created',
|
|
131
|
+
refreshAfterDismiss: true,
|
|
132
|
+
agent: {
|
|
133
|
+
name: options.name,
|
|
134
|
+
autoReply: options.autoReply,
|
|
135
|
+
role: options.role,
|
|
136
|
+
nextAgent: options.nextAgent,
|
|
137
|
+
provider: options.provider,
|
|
138
|
+
model: options.model,
|
|
139
|
+
},
|
|
91
140
|
},
|
|
92
|
-
message,
|
|
93
141
|
});
|
|
94
142
|
}
|
|
95
143
|
export function createCreateAgentToolDefinition() {
|
|
96
144
|
return {
|
|
97
|
-
description: 'Create a new agent after explicit user approval. Requires
|
|
145
|
+
description: 'Create a new agent after explicit user approval. Requires name. Optional: autoReply (alias auto-reply), role, nextAgent (alias next agent).',
|
|
98
146
|
parameters: {
|
|
99
147
|
type: 'object',
|
|
100
148
|
properties: {
|
|
101
149
|
name: {
|
|
102
150
|
type: 'string',
|
|
103
|
-
description: '
|
|
151
|
+
description: 'Required agent display name.',
|
|
104
152
|
},
|
|
105
153
|
autoReply: {
|
|
106
154
|
type: 'boolean',
|
|
107
|
-
description: 'Optional auto-reply
|
|
155
|
+
description: 'Optional auto-reply toggle. Alias forms like "auto-reply" are accepted.',
|
|
108
156
|
},
|
|
109
157
|
role: {
|
|
110
158
|
type: 'string',
|
|
111
|
-
description: 'Optional role sentence
|
|
159
|
+
description: 'Optional role sentence fragment for deterministic system prompt generation.',
|
|
112
160
|
},
|
|
113
161
|
nextAgent: {
|
|
114
162
|
type: 'string',
|
|
115
|
-
description: 'Optional mention target
|
|
163
|
+
description: 'Optional next agent mention target. Alias forms like "next agent" are accepted.',
|
|
116
164
|
},
|
|
117
165
|
},
|
|
118
166
|
required: ['name'],
|
|
119
167
|
additionalProperties: false,
|
|
120
168
|
},
|
|
121
169
|
execute: async (args, _sequenceId, _parentToolCall, context) => {
|
|
170
|
+
const normalized = validateAndNormalizeArgs(args || {});
|
|
171
|
+
if (!normalized.valid) {
|
|
172
|
+
return stringifyResult({
|
|
173
|
+
ok: false,
|
|
174
|
+
status: 'error',
|
|
175
|
+
code: 'validation_error',
|
|
176
|
+
created: false,
|
|
177
|
+
message: normalized.error,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const world = context?.world;
|
|
181
|
+
const worldId = String(world?.id || '').trim();
|
|
182
|
+
const chatId = context?.chatId ?? world?.currentChatId ?? null;
|
|
183
|
+
if (!world || !worldId) {
|
|
184
|
+
return stringifyResult({
|
|
185
|
+
ok: false,
|
|
186
|
+
status: 'error',
|
|
187
|
+
code: 'approval_unavailable',
|
|
188
|
+
created: false,
|
|
189
|
+
message: 'create_agent requires a valid world context to request approval.',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
// Claim the creation slot BEFORE showing the approval dialog.
|
|
193
|
+
// This prevents a race where two parallel create_agent calls both pass approval
|
|
194
|
+
// before either calls createAgent — the second call would then find the agent
|
|
195
|
+
// already exists and fail with a confusing post-approval error.
|
|
196
|
+
const slot = await claimAgentCreationSlot(worldId, normalized.args.name);
|
|
197
|
+
if (!slot.claimed) {
|
|
198
|
+
return stringifyResult({
|
|
199
|
+
ok: false,
|
|
200
|
+
status: 'error',
|
|
201
|
+
code: 'agent_exists',
|
|
202
|
+
created: false,
|
|
203
|
+
name: normalized.args.name,
|
|
204
|
+
message: slot.reason === 'already_pending'
|
|
205
|
+
? `Agent '${normalized.args.name}' is already being created.`
|
|
206
|
+
: `Agent '${normalized.args.name}' already exists.`,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// Track whether createAgent was called so the finally block knows whether
|
|
210
|
+
// to release the slot manually (createAgent's own finally handles it otherwise).
|
|
211
|
+
let createAgentCalled = false;
|
|
122
212
|
try {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
return formatErrorResult('Missing required parameter: name');
|
|
126
|
-
}
|
|
127
|
-
const world = context?.world;
|
|
128
|
-
const worldId = normalizeSingleLineText(world?.id);
|
|
129
|
-
if (!world || !worldId || !world.eventEmitter) {
|
|
130
|
-
return formatErrorResult('Approval context unavailable: world runtime is required for create_agent.');
|
|
131
|
-
}
|
|
132
|
-
const autoReply = args?.autoReply !== undefined ? !!args.autoReply : true;
|
|
133
|
-
const role = resolveRole(args?.role);
|
|
134
|
-
const nextAgent = resolveNextAgent(args?.nextAgent);
|
|
135
|
-
const provider = resolveProvider(world);
|
|
136
|
-
const model = resolveModel(world);
|
|
137
|
-
const systemPrompt = buildSystemPrompt(name, role, nextAgent);
|
|
138
|
-
const chatId = context?.chatId ?? world.currentChatId ?? null;
|
|
139
|
-
const approval = await requestWorldOption(world, {
|
|
140
|
-
title: `Create agent ${name}?`,
|
|
141
|
-
message: [
|
|
142
|
-
`Create a new agent with name "${name}"?`,
|
|
143
|
-
`autoReply: ${String(autoReply)}`,
|
|
144
|
-
`role: ${role || '(not specified)'}`,
|
|
145
|
-
`nextAgent: ${nextAgent}`,
|
|
146
|
-
`provider: ${provider}`,
|
|
147
|
-
`model: ${model}`,
|
|
148
|
-
].join('\n'),
|
|
213
|
+
const approval = await requestCreateAgentApproval({
|
|
214
|
+
world,
|
|
149
215
|
chatId,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
label: 'Yes',
|
|
155
|
-
description: 'Create this agent now.',
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
id: APPROVAL_OPTION_NO,
|
|
159
|
-
label: 'No',
|
|
160
|
-
description: 'Do not create this agent.',
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
metadata: {
|
|
164
|
-
tool: 'create_agent',
|
|
165
|
-
name,
|
|
166
|
-
autoReply,
|
|
167
|
-
role,
|
|
168
|
-
nextAgent,
|
|
169
|
-
provider,
|
|
170
|
-
model,
|
|
171
|
-
},
|
|
216
|
+
name: normalized.args.name,
|
|
217
|
+
autoReply: normalized.args.autoReply,
|
|
218
|
+
role: normalized.args.role,
|
|
219
|
+
nextAgent: normalized.args.nextAgent,
|
|
172
220
|
});
|
|
173
|
-
if (approval.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
: '
|
|
177
|
-
|
|
221
|
+
if (!approval.approved) {
|
|
222
|
+
return stringifyResult({
|
|
223
|
+
ok: false,
|
|
224
|
+
status: 'denied',
|
|
225
|
+
created: false,
|
|
226
|
+
reason: approval.reason,
|
|
227
|
+
name: normalized.args.name,
|
|
228
|
+
});
|
|
178
229
|
}
|
|
179
|
-
const
|
|
180
|
-
|
|
230
|
+
const { provider, model } = resolveProviderAndModel(world);
|
|
231
|
+
const systemPrompt = buildDeterministicSystemPrompt(normalized.args.name, normalized.args.role, normalized.args.nextAgent);
|
|
232
|
+
const createParams = {
|
|
233
|
+
name: normalized.args.name,
|
|
181
234
|
type: 'default',
|
|
182
|
-
autoReply,
|
|
235
|
+
autoReply: normalized.args.autoReply,
|
|
183
236
|
provider,
|
|
184
237
|
model,
|
|
185
238
|
systemPrompt,
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
239
|
+
};
|
|
240
|
+
createAgentCalled = true;
|
|
241
|
+
const createdAgent = await createAgent(worldId, createParams, {
|
|
242
|
+
allowWhileWorldProcessing: true,
|
|
243
|
+
slotAlreadyClaimed: true,
|
|
244
|
+
});
|
|
245
|
+
// Notify UI to refresh the agent list
|
|
246
|
+
publishEvent(world, EventType.SYSTEM, {
|
|
247
|
+
eventType: 'agent-created',
|
|
248
|
+
agent: {
|
|
249
|
+
id: createdAgent.id,
|
|
250
|
+
name: createdAgent.name,
|
|
251
|
+
type: createdAgent.type,
|
|
252
|
+
autoReply: createdAgent.autoReply ?? false,
|
|
253
|
+
},
|
|
254
|
+
}, chatId);
|
|
255
|
+
try {
|
|
256
|
+
await requestCreateAgentCreatedInfo({
|
|
257
|
+
world,
|
|
258
|
+
chatId,
|
|
259
|
+
name: createdAgent.name,
|
|
260
|
+
autoReply: createdAgent.autoReply ?? false,
|
|
261
|
+
role: normalized.args.role,
|
|
262
|
+
nextAgent: normalized.args.nextAgent,
|
|
263
|
+
provider: createdAgent.provider,
|
|
264
|
+
model: createdAgent.model,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// Agent creation already succeeded. Failure to show a follow-up info
|
|
269
|
+
// prompt must not turn a successful create into an error result.
|
|
270
|
+
}
|
|
271
|
+
return stringifyResult({
|
|
272
|
+
ok: true,
|
|
273
|
+
status: 'created',
|
|
189
274
|
created: true,
|
|
190
275
|
agent: {
|
|
191
276
|
id: createdAgent.id,
|
|
192
277
|
name: createdAgent.name,
|
|
193
|
-
|
|
278
|
+
type: createdAgent.type,
|
|
279
|
+
autoReply: createdAgent.autoReply ?? false,
|
|
194
280
|
provider: createdAgent.provider,
|
|
195
281
|
model: createdAgent.model,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
282
|
+
},
|
|
283
|
+
effective: {
|
|
284
|
+
role: normalized.args.role,
|
|
285
|
+
nextAgent: normalized.args.nextAgent,
|
|
286
|
+
systemPrompt,
|
|
199
287
|
},
|
|
200
288
|
});
|
|
201
289
|
}
|
|
202
290
|
catch (error) {
|
|
203
|
-
if (error instanceof Error && error.name === 'AbortError') {
|
|
204
|
-
throw error;
|
|
205
|
-
}
|
|
206
291
|
const message = error instanceof Error ? error.message : String(error);
|
|
207
|
-
return
|
|
292
|
+
return stringifyResult({
|
|
293
|
+
ok: false,
|
|
294
|
+
status: 'error',
|
|
295
|
+
code: 'create_failed',
|
|
296
|
+
created: false,
|
|
297
|
+
name: normalized.args.name,
|
|
298
|
+
message,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
finally {
|
|
302
|
+
// Release the slot if createAgent was never called (denial, timeout, or
|
|
303
|
+
// pre-creation error). If createAgent was called, its own finally already
|
|
304
|
+
// cleaned up — calling release() again is safe (idempotent Set.delete).
|
|
305
|
+
if (!createAgentCalled) {
|
|
306
|
+
slot.release();
|
|
307
|
+
}
|
|
208
308
|
}
|
|
209
309
|
},
|
|
210
310
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-agent-tool.js","sourceRoot":"","sources":["../../core/create-agent-tool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"create-agent-tool.js","sourceRoot":"","sources":["../../core/create-agent-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAsC,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAClC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AACtC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AACnC,MAAM,gBAAgB,GAAgB,WAAW,CAAC,MAAM,CAAC;AACzD,MAAM,aAAa,GAAG,OAAO,CAAC;AAqB9B,SAAS,eAAe,CAAC,OAAgC;IACvD,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAA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,EAAE,IAAI;oBACb,KAAK,EAAE;wBACL,EAAE,EAAE,YAAY,CAAC,EAAE;wBACnB,IAAI,EAAE,YAAY,CAAC,IAAI;wBACvB,IAAI,EAAE,YAAY,CAAC,IAAI;wBACvB,SAAS,EAAE,YAAY,CAAC,SAAS,IAAI,KAAK;wBAC1C,QAAQ,EAAE,YAAY,CAAC,QAAQ;wBAC/B,KAAK,EAAE,YAAY,CAAC,KAAK;qBAC1B;oBACD,SAAS,EAAE;wBACT,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI;wBAC1B,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,SAAS;wBACpC,YAAY;qBACb;iBACF,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,OAAO,eAAe,CAAC;oBACrB,EAAE,EAAE,KAAK;oBACT,MAAM,EAAE,OAAO;oBACf,IAAI,EAAE,eAAe;oBACrB,OAAO,EAAE,KAAK;oBACd,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI;oBAC1B,OAAO;iBACR,CAAC,CAAC;YACL,CAAC;oBAAS,CAAC;gBACT,wEAAwE;gBACxE,0EAA0E;gBAC1E,wEAAwE;gBACxE,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBACvB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -382,7 +382,7 @@ export async function saveIncomingMessageToMemory(world, agent, messageEvent) {
|
|
|
382
382
|
* Used for auto-execution flow where tools are executed automatically
|
|
383
383
|
*/
|
|
384
384
|
export async function continueLLMAfterToolExecution(world, agent, chatId, options) {
|
|
385
|
-
const completeActivity = beginWorldActivity(world, `agent:${agent.id}
|
|
385
|
+
const completeActivity = beginWorldActivity(world, `agent:${agent.id}`, chatId ?? undefined);
|
|
386
386
|
try {
|
|
387
387
|
let hopCount = options?.hopCount ?? 0;
|
|
388
388
|
const maxToolHops = 50;
|