agent-world 0.12.2 → 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
package/README.md
CHANGED
|
@@ -355,6 +355,21 @@ HITL options for skill activation:
|
|
|
355
355
|
- `yes_in_session`: approve this `skill_id` in the current world/chat session
|
|
356
356
|
- `no`: decline
|
|
357
357
|
|
|
358
|
+
### human_intervention_request (Generic Human Input)
|
|
359
|
+
|
|
360
|
+
`human_intervention_request` lets the model ask a human question, present options, and optionally require explicit confirmation.
|
|
361
|
+
The tool is options-only (no free-text mode).
|
|
362
|
+
|
|
363
|
+
Option example:
|
|
364
|
+
|
|
365
|
+
```json
|
|
366
|
+
{
|
|
367
|
+
"question": "Choose deployment strategy",
|
|
368
|
+
"options": ["Blue/Green", "Canary", "Rolling"],
|
|
369
|
+
"requireConfirmation": true
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
358
373
|
## Experimental Features
|
|
359
374
|
|
|
360
375
|
- **MCP Support** - *Currently in experiment* - Model Context Protocol integration for tools like search and code execution. e.g.,
|
package/dist/cli/hitl.d.ts
CHANGED
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Implementation Notes:
|
|
13
13
|
* - Parser accepts generic event payloads and rejects incomplete requests.
|
|
14
|
-
* -
|
|
14
|
+
* - Option fallback defaults to explicit `no` when available, otherwise first option.
|
|
15
15
|
*
|
|
16
16
|
* Recent Changes:
|
|
17
|
+
* - 2026-02-20: Enforced options-only HITL parsing in CLI helpers.
|
|
17
18
|
* - 2026-02-14: Added initial helper module for CLI HITL response flow support.
|
|
18
19
|
*/
|
|
19
20
|
export interface HitlOptionPayload {
|
|
@@ -26,8 +27,11 @@ export interface HitlOptionRequestPayload {
|
|
|
26
27
|
title: string;
|
|
27
28
|
message: string;
|
|
28
29
|
chatId: string | null;
|
|
30
|
+
mode: 'option';
|
|
29
31
|
options: HitlOptionPayload[];
|
|
30
32
|
defaultOptionId: string;
|
|
31
33
|
}
|
|
34
|
+
export type HitlPromptRequestPayload = HitlOptionRequestPayload;
|
|
35
|
+
export declare function parseHitlPromptRequest(eventData: unknown): HitlPromptRequestPayload | null;
|
|
32
36
|
export declare function parseHitlOptionRequest(eventData: unknown): HitlOptionRequestPayload | null;
|
|
33
37
|
export declare function resolveHitlOptionSelectionInput(options: HitlOptionPayload[], rawInput: string, fallbackOptionId: string): string | null;
|
package/dist/cli/hitl.js
CHANGED
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Implementation Notes:
|
|
13
13
|
* - Parser accepts generic event payloads and rejects incomplete requests.
|
|
14
|
-
* -
|
|
14
|
+
* - Option fallback defaults to explicit `no` when available, otherwise first option.
|
|
15
15
|
*
|
|
16
16
|
* Recent Changes:
|
|
17
|
+
* - 2026-02-20: Enforced options-only HITL parsing in CLI helpers.
|
|
17
18
|
* - 2026-02-14: Added initial helper module for CLI HITL response flow support.
|
|
18
19
|
*/
|
|
19
|
-
export function
|
|
20
|
+
export function parseHitlPromptRequest(eventData) {
|
|
20
21
|
if (!eventData || typeof eventData !== 'object') {
|
|
21
22
|
return null;
|
|
22
23
|
}
|
|
@@ -24,7 +25,8 @@ export function parseHitlOptionRequest(eventData) {
|
|
|
24
25
|
const content = payload.content && typeof payload.content === 'object'
|
|
25
26
|
? payload.content
|
|
26
27
|
: null;
|
|
27
|
-
|
|
28
|
+
const eventType = String(content?.eventType || '').trim();
|
|
29
|
+
if (!content || eventType !== 'hitl-option-request') {
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
const requestId = String(content.requestId || '').trim();
|
|
@@ -57,10 +59,14 @@ export function parseHitlOptionRequest(eventData) {
|
|
|
57
59
|
title: String(content.title || 'Approval required').trim() || 'Approval required',
|
|
58
60
|
message: String(content.message || '').trim(),
|
|
59
61
|
chatId: payload.chatId ? String(payload.chatId) : null,
|
|
62
|
+
mode: 'option',
|
|
60
63
|
options,
|
|
61
64
|
defaultOptionId
|
|
62
65
|
};
|
|
63
66
|
}
|
|
67
|
+
export function parseHitlOptionRequest(eventData) {
|
|
68
|
+
return parseHitlPromptRequest(eventData);
|
|
69
|
+
}
|
|
64
70
|
export function resolveHitlOptionSelectionInput(options, rawInput, fallbackOptionId) {
|
|
65
71
|
const normalizedInput = String(rawInput || '').trim();
|
|
66
72
|
if (!normalizedInput) {
|
package/dist/cli/index.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* - Work with loaded world without importing (uses external storage path)
|
|
14
14
|
*
|
|
15
15
|
* Changes:
|
|
16
|
+
* - 2026-02-20: Enforced options-only HITL handling in interactive and pipeline modes.
|
|
16
17
|
* - 2026-02-14: Added interactive + pipeline HITL option response handling for generic approval requests.
|
|
17
18
|
* - 2026-02-11: Fixed tool-stream timeout: extendTimeout() resets idle timeout on streaming data
|
|
18
19
|
* - 2026-02-11: Pipeline mode now listens for tool-stream SSE events to extend timeout
|
|
@@ -76,14 +77,14 @@ import path from 'path';
|
|
|
76
77
|
import { fileURLToPath } from 'url';
|
|
77
78
|
import { program } from 'commander';
|
|
78
79
|
import readline from 'readline';
|
|
79
|
-
import { listWorlds, subscribeWorld,
|
|
80
|
+
import { listWorlds, subscribeWorld, submitWorldHitlResponse, createCategoryLogger, LLMProvider, enableStreaming, disableStreaming } from '../core/index.js';
|
|
80
81
|
import { EventType } from '../core/types.js';
|
|
81
82
|
import { getDefaultRootPath } from '../core/storage/storage-factory.js';
|
|
82
83
|
import { processCLIInput, displayChatMessages } from './commands.js';
|
|
83
84
|
import { createStreamingState, handleWorldEventWithStreaming, handleToolEvents, } from './stream.js';
|
|
84
85
|
import { configureLLMProvider } from '../core/llm-config.js';
|
|
85
86
|
import { createStatusLineManager, log as statusLog, } from './display.js';
|
|
86
|
-
import {
|
|
87
|
+
import { parseHitlPromptRequest, resolveHitlOptionSelectionInput, } from './hitl.js';
|
|
87
88
|
// Create CLI category logger after logger auto-initialization
|
|
88
89
|
const logger = createCategoryLogger('cli');
|
|
89
90
|
function createGlobalState() {
|
|
@@ -456,18 +457,18 @@ function attachCLIListeners(world, streaming, globalState, activityMonitor, stat
|
|
|
456
457
|
}
|
|
457
458
|
// System events
|
|
458
459
|
const systemListener = (eventData) => {
|
|
459
|
-
const hitlRequest =
|
|
460
|
+
const hitlRequest = parseHitlPromptRequest(eventData);
|
|
460
461
|
if (hitlRequest) {
|
|
461
462
|
hitlPromptChain = hitlPromptChain
|
|
462
463
|
.then(async () => {
|
|
463
464
|
if (streaming && globalState && rl && statusLine) {
|
|
464
465
|
globalState.hitlPromptActive = true;
|
|
465
466
|
try {
|
|
466
|
-
const
|
|
467
|
-
const result = submitWorldOptionResponse({
|
|
467
|
+
const result = submitWorldHitlResponse({
|
|
468
468
|
worldId: world.id,
|
|
469
469
|
requestId: hitlRequest.requestId,
|
|
470
|
-
optionId:
|
|
470
|
+
optionId: await promptHitlOptionSelection(hitlRequest, statusLine, rl),
|
|
471
|
+
chatId: hitlRequest.chatId,
|
|
471
472
|
});
|
|
472
473
|
if (!result.accepted) {
|
|
473
474
|
statusLine.pause();
|
|
@@ -476,7 +477,7 @@ function attachCLIListeners(world, streaming, globalState, activityMonitor, stat
|
|
|
476
477
|
return;
|
|
477
478
|
}
|
|
478
479
|
statusLine.pause();
|
|
479
|
-
console.log(green(
|
|
480
|
+
console.log(green('Submitted HITL option response.'));
|
|
480
481
|
statusLine.resume();
|
|
481
482
|
return;
|
|
482
483
|
}
|
|
@@ -485,10 +486,11 @@ function attachCLIListeners(world, streaming, globalState, activityMonitor, stat
|
|
|
485
486
|
}
|
|
486
487
|
}
|
|
487
488
|
// Pipeline/non-interactive mode: auto-respond with default option to avoid blocking.
|
|
488
|
-
const result =
|
|
489
|
+
const result = submitWorldHitlResponse({
|
|
489
490
|
worldId: world.id,
|
|
490
491
|
requestId: hitlRequest.requestId,
|
|
491
|
-
optionId: hitlRequest.defaultOptionId
|
|
492
|
+
optionId: hitlRequest.defaultOptionId,
|
|
493
|
+
chatId: hitlRequest.chatId,
|
|
492
494
|
});
|
|
493
495
|
if (!result.accepted) {
|
|
494
496
|
console.error(boldRed(`Failed to auto-respond HITL request: ${result.reason || 'unknown error'}`));
|
|
@@ -8,8 +8,18 @@ export interface WorldActivityEventPayload {
|
|
|
8
8
|
timestamp: string;
|
|
9
9
|
source?: string;
|
|
10
10
|
activeSources: string[];
|
|
11
|
+
activeChatIds: string[];
|
|
11
12
|
queue: ReturnType<typeof getLLMQueueStatus>;
|
|
12
13
|
messageId: string;
|
|
13
14
|
}
|
|
14
|
-
export declare function beginWorldActivity(world: World, source?: string): () => void;
|
|
15
|
-
|
|
15
|
+
export declare function beginWorldActivity(world: World, source?: string, chatId?: string): () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the set of chatIds currently being actively processed in this world.
|
|
18
|
+
* Useful for parallel-chat monitoring and targeted mutation guards.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getActiveProcessingChatIds(world: World): ReadonlySet<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns true if the given chatId has at least one active processing operation.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isChatProcessing(world: World, chatId: string): boolean;
|
|
25
|
+
export declare function trackWorldActivity<T>(world: World, operation: () => Promise<T>, source?: string, chatId?: string): Promise<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-tracker.d.ts","sourceRoot":"","sources":["../../core/activity-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"activity-tracker.d.ts","sourceRoot":"","sources":["../../core/activity-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAUrD,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG,cAAc,GAAG,MAAM,CAAC;AAEhF,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAiDD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,IAAI,CAyD7F;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAI5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAItE;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,CAAC,CAAC,CAcZ"}
|
|
@@ -11,19 +11,22 @@ function getActivityState(world) {
|
|
|
11
11
|
const initial = {
|
|
12
12
|
pendingOperations: 0,
|
|
13
13
|
lastActivityId: 0,
|
|
14
|
-
activeSources: new Map()
|
|
14
|
+
activeSources: new Map(),
|
|
15
|
+
activeChatOps: new Map()
|
|
15
16
|
};
|
|
16
17
|
world[stateKey] = initial;
|
|
17
18
|
return initial;
|
|
18
19
|
}
|
|
19
20
|
function emitActivityEvent(world, type, pendingOperations, activityId, source) {
|
|
21
|
+
const activityState = getActivityState(world);
|
|
20
22
|
const payload = {
|
|
21
23
|
type,
|
|
22
24
|
pendingOperations,
|
|
23
25
|
activityId,
|
|
24
26
|
timestamp: new Date().toISOString(),
|
|
25
27
|
source,
|
|
26
|
-
activeSources: Array.from(
|
|
28
|
+
activeSources: Array.from(activityState.activeSources.keys()),
|
|
29
|
+
activeChatIds: Array.from(activityState.activeChatOps.keys()),
|
|
27
30
|
queue: getLLMQueueStatus(),
|
|
28
31
|
messageId: nanoid(10) // Generate unique ID for event persistence
|
|
29
32
|
};
|
|
@@ -33,12 +36,16 @@ function emitActivityEvent(world, type, pendingOperations, activityId, source) {
|
|
|
33
36
|
world.eventEmitter.emit('world', payload);
|
|
34
37
|
world.eventEmitter.emit(type, payload);
|
|
35
38
|
}
|
|
36
|
-
export function beginWorldActivity(world, source) {
|
|
39
|
+
export function beginWorldActivity(world, source, chatId) {
|
|
37
40
|
const activityState = getActivityState(world);
|
|
38
41
|
activityState.pendingOperations += 1;
|
|
39
42
|
if (source) {
|
|
40
43
|
activityState.activeSources.set(source, (activityState.activeSources.get(source) ?? 0) + 1);
|
|
41
44
|
}
|
|
45
|
+
// Track chat-level operation counts for parallel-chat visibility
|
|
46
|
+
if (chatId) {
|
|
47
|
+
activityState.activeChatOps.set(chatId, (activityState.activeChatOps.get(chatId) ?? 0) + 1);
|
|
48
|
+
}
|
|
42
49
|
// Increment activityId when starting first operation
|
|
43
50
|
if (activityState.pendingOperations === 1) {
|
|
44
51
|
activityState.lastActivityId += 1;
|
|
@@ -62,6 +69,16 @@ export function beginWorldActivity(world, source) {
|
|
|
62
69
|
state.activeSources.set(source, currentCount - 1);
|
|
63
70
|
}
|
|
64
71
|
}
|
|
72
|
+
// Decrement chat-level operation count
|
|
73
|
+
if (chatId) {
|
|
74
|
+
const chatCount = state.activeChatOps.get(chatId) ?? 0;
|
|
75
|
+
if (chatCount <= 1) {
|
|
76
|
+
state.activeChatOps.delete(chatId);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
state.activeChatOps.set(chatId, chatCount - 1);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
65
82
|
// Emit idle when all operations complete, otherwise response-end
|
|
66
83
|
if (state.pendingOperations === 0) {
|
|
67
84
|
emitActivityEvent(world, 'idle', 0, currentActivityId, source);
|
|
@@ -71,8 +88,27 @@ export function beginWorldActivity(world, source) {
|
|
|
71
88
|
}
|
|
72
89
|
};
|
|
73
90
|
}
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Returns the set of chatIds currently being actively processed in this world.
|
|
93
|
+
* Useful for parallel-chat monitoring and targeted mutation guards.
|
|
94
|
+
*/
|
|
95
|
+
export function getActiveProcessingChatIds(world) {
|
|
96
|
+
const state = world[stateKey];
|
|
97
|
+
if (!state)
|
|
98
|
+
return new Set();
|
|
99
|
+
return new Set(state.activeChatOps.keys());
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns true if the given chatId has at least one active processing operation.
|
|
103
|
+
*/
|
|
104
|
+
export function isChatProcessing(world, chatId) {
|
|
105
|
+
const state = world[stateKey];
|
|
106
|
+
if (!state)
|
|
107
|
+
return false;
|
|
108
|
+
return (state.activeChatOps.get(chatId) ?? 0) > 0;
|
|
109
|
+
}
|
|
110
|
+
export async function trackWorldActivity(world, operation, source, chatId) {
|
|
111
|
+
const end = beginWorldActivity(world, source, chatId);
|
|
76
112
|
try {
|
|
77
113
|
return await operation();
|
|
78
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-tracker.js","sourceRoot":"","sources":["../../core/activity-tracker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"activity-tracker.js","sourceRoot":"","sources":["../../core/activity-tracker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAuBhC,MAAM,MAAM,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;AACtD,MAAM,QAAQ,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE7D,SAAS,gBAAgB,CAAC,KAAY;IACpC,MAAM,QAAQ,GAAI,KAAa,CAAC,QAAQ,CAA8B,CAAC;IACvE,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,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AAK,CAAC;IACzB,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAY,EACZ,SAA2B,EAC3B,MAAe,EACf,MAAe;IAEf,MAAM,GAAG,GAAG,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,EAAE,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE;YAC9C,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,MAAM;YACN,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK;SACtD,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,GAAG,EAAE,CAAC;IACR,CAAC;AACH,CAAC"}
|
|
@@ -1,40 +1,38 @@
|
|
|
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
|
*/
|
|
25
|
+
import { type World } from './types.js';
|
|
26
|
+
type CreateAgentToolArgs = {
|
|
27
|
+
name?: unknown;
|
|
28
|
+
autoReply?: unknown;
|
|
29
|
+
role?: unknown;
|
|
30
|
+
nextAgent?: unknown;
|
|
31
|
+
};
|
|
22
32
|
type CreateAgentToolContext = {
|
|
23
|
-
world?:
|
|
24
|
-
id?: string;
|
|
25
|
-
currentChatId?: string | null;
|
|
26
|
-
chatLLMProvider?: string | null;
|
|
27
|
-
chatLLMModel?: string | null;
|
|
28
|
-
eventEmitter?: unknown;
|
|
29
|
-
} | null;
|
|
33
|
+
world?: World;
|
|
30
34
|
chatId?: string | null;
|
|
31
35
|
};
|
|
32
|
-
type CreateAgentToolArgs = {
|
|
33
|
-
name: string;
|
|
34
|
-
autoReply?: boolean;
|
|
35
|
-
role?: string;
|
|
36
|
-
nextAgent?: string;
|
|
37
|
-
};
|
|
38
36
|
export declare function createCreateAgentToolDefinition(): {
|
|
39
37
|
description: string;
|
|
40
38
|
parameters: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-agent-tool.d.ts","sourceRoot":"","sources":["../../core/create-agent-tool.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"create-agent-tool.d.ts","sourceRoot":"","sources":["../../core/create-agent-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAkD,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAUxF,KAAK,mBAAmB,GAAG;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAkKF,wBAAgB,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;oBA2BrB,mBAAmB,gBAAgB,MAAM,oBAAoB,MAAM,YAAY,sBAAsB;EAwJ9H"}
|