@agent-relay/hooks 0.1.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/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +3 -0
- package/dist/browser.js.map +1 -0
- package/dist/emitter.d.ts +40 -0
- package/dist/emitter.d.ts.map +1 -0
- package/dist/emitter.js +63 -0
- package/dist/emitter.js.map +1 -0
- package/dist/inbox-check/hook.d.ts +28 -0
- package/dist/inbox-check/hook.d.ts.map +1 -0
- package/dist/inbox-check/hook.js +97 -0
- package/dist/inbox-check/hook.js.map +1 -0
- package/dist/inbox-check/index.d.ts +8 -0
- package/dist/inbox-check/index.d.ts.map +1 -0
- package/dist/inbox-check/index.js +8 -0
- package/dist/inbox-check/index.js.map +1 -0
- package/dist/inbox-check/types.d.ts +31 -0
- package/dist/inbox-check/types.d.ts.map +1 -0
- package/dist/inbox-check/types.js +5 -0
- package/dist/inbox-check/types.js.map +1 -0
- package/dist/inbox-check/utils.d.ts +44 -0
- package/dist/inbox-check/utils.d.ts.map +1 -0
- package/dist/inbox-check/utils.js +107 -0
- package/dist/inbox-check/utils.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +173 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +476 -0
- package/dist/registry.js.map +1 -0
- package/dist/trajectory-hooks.d.ts +52 -0
- package/dist/trajectory-hooks.d.ts.map +1 -0
- package/dist/trajectory-hooks.js +183 -0
- package/dist/trajectory-hooks.js.map +1 -0
- package/dist/types.d.ts +285 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Registry
|
|
3
|
+
*
|
|
4
|
+
* Manages lifecycle hooks and pattern handlers for agent sessions.
|
|
5
|
+
* Provides a centralized way to register, unregister, and dispatch hooks.
|
|
6
|
+
*/
|
|
7
|
+
import type { HookResult, LifecycleHooks, PatternHandler, HooksConfig } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating a HookRegistry
|
|
10
|
+
*/
|
|
11
|
+
export interface HookRegistryOptions {
|
|
12
|
+
/** Agent identifier */
|
|
13
|
+
agentId?: string;
|
|
14
|
+
/** Agent name for relay */
|
|
15
|
+
agentName?: string;
|
|
16
|
+
/** Working directory */
|
|
17
|
+
workingDir?: string;
|
|
18
|
+
/** Project identifier */
|
|
19
|
+
projectId?: string;
|
|
20
|
+
/** Environment variables */
|
|
21
|
+
env?: Record<string, string | undefined>;
|
|
22
|
+
/** Task description */
|
|
23
|
+
task?: string;
|
|
24
|
+
/** Task ID */
|
|
25
|
+
taskId?: string;
|
|
26
|
+
/** Task source */
|
|
27
|
+
taskSource?: string;
|
|
28
|
+
/** Idle timeout in ms (default: 30000) */
|
|
29
|
+
idleTimeout?: number;
|
|
30
|
+
/** Function to inject text into agent */
|
|
31
|
+
inject?: (text: string) => void;
|
|
32
|
+
/** Function to send relay messages */
|
|
33
|
+
send?: (to: string, body: string) => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* HookRegistry manages lifecycle hooks and dispatches events
|
|
37
|
+
*/
|
|
38
|
+
export declare class HookRegistry {
|
|
39
|
+
private sessionId;
|
|
40
|
+
private agentId;
|
|
41
|
+
private agentName;
|
|
42
|
+
private workingDir;
|
|
43
|
+
private projectId;
|
|
44
|
+
private env;
|
|
45
|
+
private task?;
|
|
46
|
+
private taskId?;
|
|
47
|
+
private taskSource?;
|
|
48
|
+
private memory;
|
|
49
|
+
private relay;
|
|
50
|
+
private outputHistory;
|
|
51
|
+
private messageHistory;
|
|
52
|
+
private sessionStartHooks;
|
|
53
|
+
private sessionEndHooks;
|
|
54
|
+
private outputHooks;
|
|
55
|
+
private messageReceivedHooks;
|
|
56
|
+
private messageSentHooks;
|
|
57
|
+
private idleHooks;
|
|
58
|
+
private errorHooks;
|
|
59
|
+
private patternHandlers;
|
|
60
|
+
private idleTimeout;
|
|
61
|
+
private idleTimer?;
|
|
62
|
+
private idleCount;
|
|
63
|
+
private lastActivityTime;
|
|
64
|
+
private sessionStartTime;
|
|
65
|
+
private injectFn?;
|
|
66
|
+
private sendFn?;
|
|
67
|
+
constructor(options?: HookRegistryOptions);
|
|
68
|
+
/**
|
|
69
|
+
* Register hooks from a configuration object
|
|
70
|
+
*/
|
|
71
|
+
registerHooks(config: HooksConfig): void;
|
|
72
|
+
/**
|
|
73
|
+
* Register memory hooks from configuration
|
|
74
|
+
*/
|
|
75
|
+
private registerMemoryHooksFromConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Register memory hooks with custom options
|
|
78
|
+
*/
|
|
79
|
+
registerMemoryHooks(options?: {
|
|
80
|
+
type?: string;
|
|
81
|
+
apiKey?: string;
|
|
82
|
+
injectOnStart?: boolean;
|
|
83
|
+
promptOnEnd?: boolean;
|
|
84
|
+
autoSave?: boolean;
|
|
85
|
+
autoSaveOnEnd?: boolean;
|
|
86
|
+
}): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Register lifecycle hooks
|
|
89
|
+
*/
|
|
90
|
+
registerLifecycleHooks(hooks: LifecycleHooks): void;
|
|
91
|
+
/**
|
|
92
|
+
* Add hooks for a specific event
|
|
93
|
+
*/
|
|
94
|
+
private addHooks;
|
|
95
|
+
/**
|
|
96
|
+
* Register a pattern handler
|
|
97
|
+
*/
|
|
98
|
+
registerPattern(namespace: string, handler: PatternHandler): void;
|
|
99
|
+
/**
|
|
100
|
+
* Get the base hook context
|
|
101
|
+
*/
|
|
102
|
+
private getBaseContext;
|
|
103
|
+
/**
|
|
104
|
+
* Run hooks and collect results
|
|
105
|
+
*/
|
|
106
|
+
private runHooks;
|
|
107
|
+
/**
|
|
108
|
+
* Dispatch session start event
|
|
109
|
+
*/
|
|
110
|
+
dispatchSessionStart(): Promise<HookResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Dispatch session end event
|
|
113
|
+
*/
|
|
114
|
+
dispatchSessionEnd(exitCode?: number, graceful?: boolean): Promise<HookResult>;
|
|
115
|
+
/**
|
|
116
|
+
* Dispatch output event
|
|
117
|
+
*/
|
|
118
|
+
dispatchOutput(content: string, rawContent: string, isComplete?: boolean): Promise<HookResult>;
|
|
119
|
+
/**
|
|
120
|
+
* Dispatch message received event
|
|
121
|
+
*/
|
|
122
|
+
dispatchMessageReceived(from: string, body: string, messageId: string, thread?: string): Promise<HookResult>;
|
|
123
|
+
/**
|
|
124
|
+
* Dispatch message sent event
|
|
125
|
+
*/
|
|
126
|
+
dispatchMessageSent(to: string, body: string, thread?: string): Promise<HookResult>;
|
|
127
|
+
/**
|
|
128
|
+
* Dispatch idle event
|
|
129
|
+
*/
|
|
130
|
+
dispatchIdle(): Promise<HookResult>;
|
|
131
|
+
/**
|
|
132
|
+
* Dispatch error event
|
|
133
|
+
*/
|
|
134
|
+
dispatchError(error: Error, phase?: string): Promise<HookResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Check content for pattern matches
|
|
137
|
+
*/
|
|
138
|
+
private checkPatterns;
|
|
139
|
+
/**
|
|
140
|
+
* Start idle timer
|
|
141
|
+
*/
|
|
142
|
+
private startIdleTimer;
|
|
143
|
+
/**
|
|
144
|
+
* Stop idle timer
|
|
145
|
+
*/
|
|
146
|
+
private stopIdleTimer;
|
|
147
|
+
/**
|
|
148
|
+
* Reset idle timer on activity
|
|
149
|
+
*/
|
|
150
|
+
private resetIdleTimer;
|
|
151
|
+
/**
|
|
152
|
+
* Get session info
|
|
153
|
+
*/
|
|
154
|
+
getSessionInfo(): {
|
|
155
|
+
sessionId: string;
|
|
156
|
+
agentId: string;
|
|
157
|
+
startTime: Date;
|
|
158
|
+
duration: number;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Update inject function
|
|
162
|
+
*/
|
|
163
|
+
setInjectFn(fn: (text: string) => void): void;
|
|
164
|
+
/**
|
|
165
|
+
* Update send function
|
|
166
|
+
*/
|
|
167
|
+
setSendFn(fn: (to: string, body: string) => Promise<void>): void;
|
|
168
|
+
/**
|
|
169
|
+
* Cleanup
|
|
170
|
+
*/
|
|
171
|
+
destroy(): void;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAEV,UAAU,EAKV,cAAc,EAEd,cAAc,EACd,WAAW,EAgBZ,MAAM,YAAY,CAAC;AA6BpB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,sCAAsC;IACtC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,qBA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AAa;IAOrB;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;IACH,cAAc,IAAI;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAS3F;;OAEG;IACH,WAAW,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAI7C;;OAEG;IACH,SAAS,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIhE;;OAEG;IACH,OAAO,IAAI,IAAI;CAYhB"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Registry
|
|
3
|
+
*
|
|
4
|
+
* Manages lifecycle hooks and pattern handlers for agent sessions.
|
|
5
|
+
* Provides a centralized way to register, unregister, and dispatch hooks.
|
|
6
|
+
*/
|
|
7
|
+
import { randomUUID } from 'node:crypto';
|
|
8
|
+
/**
|
|
9
|
+
* Simple in-memory implementation of HookMemory
|
|
10
|
+
*/
|
|
11
|
+
class InMemoryHookMemory {
|
|
12
|
+
store = new Map();
|
|
13
|
+
get(key) {
|
|
14
|
+
return this.store.get(key);
|
|
15
|
+
}
|
|
16
|
+
set(key, value) {
|
|
17
|
+
this.store.set(key, value);
|
|
18
|
+
}
|
|
19
|
+
delete(key) {
|
|
20
|
+
return this.store.delete(key);
|
|
21
|
+
}
|
|
22
|
+
has(key) {
|
|
23
|
+
return this.store.has(key);
|
|
24
|
+
}
|
|
25
|
+
clear() {
|
|
26
|
+
this.store.clear();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* HookRegistry manages lifecycle hooks and dispatches events
|
|
31
|
+
*/
|
|
32
|
+
export class HookRegistry {
|
|
33
|
+
sessionId;
|
|
34
|
+
agentId;
|
|
35
|
+
agentName;
|
|
36
|
+
workingDir;
|
|
37
|
+
projectId;
|
|
38
|
+
env;
|
|
39
|
+
task;
|
|
40
|
+
taskId;
|
|
41
|
+
taskSource;
|
|
42
|
+
memory;
|
|
43
|
+
relay;
|
|
44
|
+
outputHistory = [];
|
|
45
|
+
messageHistory = [];
|
|
46
|
+
sessionStartHooks = [];
|
|
47
|
+
sessionEndHooks = [];
|
|
48
|
+
outputHooks = [];
|
|
49
|
+
messageReceivedHooks = [];
|
|
50
|
+
messageSentHooks = [];
|
|
51
|
+
idleHooks = [];
|
|
52
|
+
errorHooks = [];
|
|
53
|
+
patternHandlers = new Map();
|
|
54
|
+
idleTimeout;
|
|
55
|
+
idleTimer;
|
|
56
|
+
idleCount = 0;
|
|
57
|
+
lastActivityTime = Date.now();
|
|
58
|
+
sessionStartTime = Date.now();
|
|
59
|
+
injectFn;
|
|
60
|
+
sendFn;
|
|
61
|
+
constructor(options = {}) {
|
|
62
|
+
this.sessionId = randomUUID();
|
|
63
|
+
this.agentId = options.agentId ?? randomUUID();
|
|
64
|
+
this.agentName = options.agentName ?? 'agent';
|
|
65
|
+
this.workingDir = options.workingDir ?? process.cwd();
|
|
66
|
+
this.projectId = options.projectId ?? 'default';
|
|
67
|
+
this.env = options.env ?? {};
|
|
68
|
+
this.task = options.task;
|
|
69
|
+
this.taskId = options.taskId;
|
|
70
|
+
this.taskSource = options.taskSource;
|
|
71
|
+
this.idleTimeout = options.idleTimeout ?? 30000;
|
|
72
|
+
this.injectFn = options.inject;
|
|
73
|
+
this.sendFn = options.send;
|
|
74
|
+
this.memory = new InMemoryHookMemory();
|
|
75
|
+
// Create relay interface (using arrow functions to capture 'this')
|
|
76
|
+
this.relay = {
|
|
77
|
+
send: async (to, body) => {
|
|
78
|
+
if (this.sendFn) {
|
|
79
|
+
await this.sendFn(to, body);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
isConnected: () => {
|
|
83
|
+
return !!this.sendFn;
|
|
84
|
+
},
|
|
85
|
+
getAgentName: () => {
|
|
86
|
+
return this.agentName;
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Register hooks from a configuration object
|
|
92
|
+
*/
|
|
93
|
+
registerHooks(config) {
|
|
94
|
+
if (config.hooks) {
|
|
95
|
+
this.registerLifecycleHooks(config.hooks);
|
|
96
|
+
}
|
|
97
|
+
if (config.patterns) {
|
|
98
|
+
for (const [namespace, handler] of Object.entries(config.patterns)) {
|
|
99
|
+
if (handler !== 'builtin') {
|
|
100
|
+
this.registerPattern(namespace, handler);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (config.idleTimeout !== undefined) {
|
|
105
|
+
this.idleTimeout = config.idleTimeout;
|
|
106
|
+
}
|
|
107
|
+
// Register memory hooks if configured
|
|
108
|
+
if (config.memory) {
|
|
109
|
+
this.registerMemoryHooksFromConfig(config.memory);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Register memory hooks from configuration
|
|
114
|
+
*/
|
|
115
|
+
async registerMemoryHooksFromConfig(config) {
|
|
116
|
+
const loadMemory = async () => import('@agent-relay/memory');
|
|
117
|
+
try {
|
|
118
|
+
const { createMemoryHooks } = await loadMemory();
|
|
119
|
+
// Handle boolean config (true = use defaults)
|
|
120
|
+
if (config === true || config === false) {
|
|
121
|
+
if (!config)
|
|
122
|
+
return; // false means disabled
|
|
123
|
+
const hooks = createMemoryHooks({
|
|
124
|
+
agentId: this.agentId,
|
|
125
|
+
projectId: this.projectId,
|
|
126
|
+
});
|
|
127
|
+
this.registerLifecycleHooks(hooks);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// Handle object config
|
|
131
|
+
const hooks = createMemoryHooks({
|
|
132
|
+
config: {
|
|
133
|
+
type: config.type,
|
|
134
|
+
apiKey: config.apiKey,
|
|
135
|
+
endpoint: config.endpoint,
|
|
136
|
+
},
|
|
137
|
+
agentId: this.agentId,
|
|
138
|
+
projectId: this.projectId,
|
|
139
|
+
injectOnStart: config.injectOnStart,
|
|
140
|
+
maxStartMemories: config.maxStartMemories,
|
|
141
|
+
promptOnEnd: config.promptOnEnd,
|
|
142
|
+
autoSave: config.autoSave,
|
|
143
|
+
autoSaveOnEnd: config.autoSaveOnEnd,
|
|
144
|
+
});
|
|
145
|
+
this.registerLifecycleHooks(hooks);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.error('[hooks] Failed to register memory hooks:', error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Register memory hooks with custom options
|
|
153
|
+
*/
|
|
154
|
+
async registerMemoryHooks(options) {
|
|
155
|
+
await this.registerMemoryHooksFromConfig(options ?? {});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Register lifecycle hooks
|
|
159
|
+
*/
|
|
160
|
+
registerLifecycleHooks(hooks) {
|
|
161
|
+
if (hooks.onSessionStart) {
|
|
162
|
+
this.addHooks('sessionStart', hooks.onSessionStart);
|
|
163
|
+
}
|
|
164
|
+
if (hooks.onSessionEnd) {
|
|
165
|
+
this.addHooks('sessionEnd', hooks.onSessionEnd);
|
|
166
|
+
}
|
|
167
|
+
if (hooks.onOutput) {
|
|
168
|
+
this.addHooks('output', hooks.onOutput);
|
|
169
|
+
}
|
|
170
|
+
if (hooks.onMessageReceived) {
|
|
171
|
+
this.addHooks('messageReceived', hooks.onMessageReceived);
|
|
172
|
+
}
|
|
173
|
+
if (hooks.onMessageSent) {
|
|
174
|
+
this.addHooks('messageSent', hooks.onMessageSent);
|
|
175
|
+
}
|
|
176
|
+
if (hooks.onIdle) {
|
|
177
|
+
this.addHooks('idle', hooks.onIdle);
|
|
178
|
+
}
|
|
179
|
+
if (hooks.onError) {
|
|
180
|
+
this.addHooks('error', hooks.onError);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Add hooks for a specific event
|
|
185
|
+
*/
|
|
186
|
+
addHooks(event, hooks) {
|
|
187
|
+
const hookArray = Array.isArray(hooks) ? hooks : [hooks];
|
|
188
|
+
switch (event) {
|
|
189
|
+
case 'sessionStart':
|
|
190
|
+
this.sessionStartHooks.push(...hookArray);
|
|
191
|
+
break;
|
|
192
|
+
case 'sessionEnd':
|
|
193
|
+
this.sessionEndHooks.push(...hookArray);
|
|
194
|
+
break;
|
|
195
|
+
case 'output':
|
|
196
|
+
this.outputHooks.push(...hookArray);
|
|
197
|
+
break;
|
|
198
|
+
case 'messageReceived':
|
|
199
|
+
this.messageReceivedHooks.push(...hookArray);
|
|
200
|
+
break;
|
|
201
|
+
case 'messageSent':
|
|
202
|
+
this.messageSentHooks.push(...hookArray);
|
|
203
|
+
break;
|
|
204
|
+
case 'idle':
|
|
205
|
+
this.idleHooks.push(...hookArray);
|
|
206
|
+
break;
|
|
207
|
+
case 'error':
|
|
208
|
+
this.errorHooks.push(...hookArray);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Register a pattern handler
|
|
214
|
+
*/
|
|
215
|
+
registerPattern(namespace, handler) {
|
|
216
|
+
this.patternHandlers.set(namespace, handler);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get the base hook context
|
|
220
|
+
*/
|
|
221
|
+
getBaseContext() {
|
|
222
|
+
return {
|
|
223
|
+
agentId: this.agentId,
|
|
224
|
+
sessionId: this.sessionId,
|
|
225
|
+
workingDir: this.workingDir,
|
|
226
|
+
env: this.env,
|
|
227
|
+
inject: (content) => {
|
|
228
|
+
if (this.injectFn) {
|
|
229
|
+
this.injectFn(content);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
send: async (to, body) => {
|
|
233
|
+
if (this.sendFn) {
|
|
234
|
+
await this.sendFn(to, body);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
memory: this.memory,
|
|
238
|
+
relay: this.relay,
|
|
239
|
+
output: [...this.outputHistory],
|
|
240
|
+
messages: [...this.messageHistory],
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Run hooks and collect results
|
|
245
|
+
*/
|
|
246
|
+
async runHooks(hooks, context) {
|
|
247
|
+
const combinedResult = {};
|
|
248
|
+
for (const hook of hooks) {
|
|
249
|
+
try {
|
|
250
|
+
const result = await hook(context);
|
|
251
|
+
if (result) {
|
|
252
|
+
if (result.inject) {
|
|
253
|
+
combinedResult.inject = (combinedResult.inject ?? '') + result.inject;
|
|
254
|
+
}
|
|
255
|
+
if (result.suppress) {
|
|
256
|
+
combinedResult.suppress = true;
|
|
257
|
+
}
|
|
258
|
+
if (result.stop) {
|
|
259
|
+
combinedResult.stop = true;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
console.error('[hooks] Hook execution error:', err);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// Execute injection if any
|
|
269
|
+
if (combinedResult.inject && this.injectFn) {
|
|
270
|
+
this.injectFn(combinedResult.inject);
|
|
271
|
+
}
|
|
272
|
+
return combinedResult;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Dispatch session start event
|
|
276
|
+
*/
|
|
277
|
+
async dispatchSessionStart() {
|
|
278
|
+
this.sessionStartTime = Date.now();
|
|
279
|
+
this.startIdleTimer();
|
|
280
|
+
const context = {
|
|
281
|
+
...this.getBaseContext(),
|
|
282
|
+
task: this.task,
|
|
283
|
+
taskId: this.taskId,
|
|
284
|
+
taskSource: this.taskSource,
|
|
285
|
+
};
|
|
286
|
+
return this.runHooks(this.sessionStartHooks, context);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Dispatch session end event
|
|
290
|
+
*/
|
|
291
|
+
async dispatchSessionEnd(exitCode, graceful = true) {
|
|
292
|
+
this.stopIdleTimer();
|
|
293
|
+
const context = {
|
|
294
|
+
...this.getBaseContext(),
|
|
295
|
+
exitCode,
|
|
296
|
+
duration: Date.now() - this.sessionStartTime,
|
|
297
|
+
graceful,
|
|
298
|
+
};
|
|
299
|
+
return this.runHooks(this.sessionEndHooks, context);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Dispatch output event
|
|
303
|
+
*/
|
|
304
|
+
async dispatchOutput(content, rawContent, isComplete = true) {
|
|
305
|
+
this.resetIdleTimer();
|
|
306
|
+
// Record in history
|
|
307
|
+
this.outputHistory.push({
|
|
308
|
+
type: 'text',
|
|
309
|
+
content,
|
|
310
|
+
timestamp: Date.now(),
|
|
311
|
+
});
|
|
312
|
+
const context = {
|
|
313
|
+
...this.getBaseContext(),
|
|
314
|
+
content,
|
|
315
|
+
rawContent,
|
|
316
|
+
isComplete,
|
|
317
|
+
};
|
|
318
|
+
// Check for patterns
|
|
319
|
+
await this.checkPatterns(content, context);
|
|
320
|
+
return this.runHooks(this.outputHooks, context);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Dispatch message received event
|
|
324
|
+
*/
|
|
325
|
+
async dispatchMessageReceived(from, body, messageId, thread) {
|
|
326
|
+
this.resetIdleTimer();
|
|
327
|
+
// Record in history
|
|
328
|
+
this.messageHistory.push({
|
|
329
|
+
role: 'user',
|
|
330
|
+
content: `[${from}]: ${body}`,
|
|
331
|
+
timestamp: Date.now(),
|
|
332
|
+
});
|
|
333
|
+
const context = {
|
|
334
|
+
...this.getBaseContext(),
|
|
335
|
+
from,
|
|
336
|
+
body,
|
|
337
|
+
messageId,
|
|
338
|
+
thread,
|
|
339
|
+
};
|
|
340
|
+
return this.runHooks(this.messageReceivedHooks, context);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Dispatch message sent event
|
|
344
|
+
*/
|
|
345
|
+
async dispatchMessageSent(to, body, thread) {
|
|
346
|
+
this.resetIdleTimer();
|
|
347
|
+
// Record in history
|
|
348
|
+
this.messageHistory.push({
|
|
349
|
+
role: 'assistant',
|
|
350
|
+
content: `[to ${to}]: ${body}`,
|
|
351
|
+
timestamp: Date.now(),
|
|
352
|
+
});
|
|
353
|
+
const context = {
|
|
354
|
+
...this.getBaseContext(),
|
|
355
|
+
to,
|
|
356
|
+
body,
|
|
357
|
+
thread,
|
|
358
|
+
};
|
|
359
|
+
return this.runHooks(this.messageSentHooks, context);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Dispatch idle event
|
|
363
|
+
*/
|
|
364
|
+
async dispatchIdle() {
|
|
365
|
+
this.idleCount++;
|
|
366
|
+
const context = {
|
|
367
|
+
...this.getBaseContext(),
|
|
368
|
+
idleDuration: Date.now() - this.lastActivityTime,
|
|
369
|
+
idleCount: this.idleCount,
|
|
370
|
+
};
|
|
371
|
+
const result = await this.runHooks(this.idleHooks, context);
|
|
372
|
+
// Restart idle timer
|
|
373
|
+
this.startIdleTimer();
|
|
374
|
+
return result;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Dispatch error event
|
|
378
|
+
*/
|
|
379
|
+
async dispatchError(error, phase) {
|
|
380
|
+
const context = {
|
|
381
|
+
...this.getBaseContext(),
|
|
382
|
+
error,
|
|
383
|
+
phase,
|
|
384
|
+
};
|
|
385
|
+
return this.runHooks(this.errorHooks, context);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Check content for pattern matches
|
|
389
|
+
*/
|
|
390
|
+
async checkPatterns(content, baseContext) {
|
|
391
|
+
// Match patterns like @namespace:target message
|
|
392
|
+
const patternRegex = /@(\w+):(\S+)\s*(.*)/g;
|
|
393
|
+
let match;
|
|
394
|
+
while ((match = patternRegex.exec(content)) !== null) {
|
|
395
|
+
const [, namespace, target, message] = match;
|
|
396
|
+
const handler = this.patternHandlers.get(namespace);
|
|
397
|
+
if (handler) {
|
|
398
|
+
try {
|
|
399
|
+
const result = await handler(target, message.trim(), baseContext);
|
|
400
|
+
if (result?.inject && this.injectFn) {
|
|
401
|
+
this.injectFn(result.inject);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
catch (err) {
|
|
405
|
+
console.error(`[hooks] Pattern handler error for @${namespace}:`, err);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Start idle timer
|
|
412
|
+
*/
|
|
413
|
+
startIdleTimer() {
|
|
414
|
+
this.stopIdleTimer();
|
|
415
|
+
if (this.idleHooks.length > 0 && this.idleTimeout > 0) {
|
|
416
|
+
this.idleTimer = setTimeout(() => {
|
|
417
|
+
this.dispatchIdle().catch(console.error);
|
|
418
|
+
}, this.idleTimeout);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Stop idle timer
|
|
423
|
+
*/
|
|
424
|
+
stopIdleTimer() {
|
|
425
|
+
if (this.idleTimer) {
|
|
426
|
+
clearTimeout(this.idleTimer);
|
|
427
|
+
this.idleTimer = undefined;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Reset idle timer on activity
|
|
432
|
+
*/
|
|
433
|
+
resetIdleTimer() {
|
|
434
|
+
this.lastActivityTime = Date.now();
|
|
435
|
+
this.startIdleTimer();
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Get session info
|
|
439
|
+
*/
|
|
440
|
+
getSessionInfo() {
|
|
441
|
+
return {
|
|
442
|
+
sessionId: this.sessionId,
|
|
443
|
+
agentId: this.agentId,
|
|
444
|
+
startTime: new Date(this.sessionStartTime),
|
|
445
|
+
duration: Date.now() - this.sessionStartTime,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Update inject function
|
|
450
|
+
*/
|
|
451
|
+
setInjectFn(fn) {
|
|
452
|
+
this.injectFn = fn;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Update send function
|
|
456
|
+
*/
|
|
457
|
+
setSendFn(fn) {
|
|
458
|
+
this.sendFn = fn;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Cleanup
|
|
462
|
+
*/
|
|
463
|
+
destroy() {
|
|
464
|
+
this.stopIdleTimer();
|
|
465
|
+
this.memory.clear();
|
|
466
|
+
this.sessionStartHooks = [];
|
|
467
|
+
this.sessionEndHooks = [];
|
|
468
|
+
this.outputHooks = [];
|
|
469
|
+
this.messageReceivedHooks = [];
|
|
470
|
+
this.messageSentHooks = [];
|
|
471
|
+
this.idleHooks = [];
|
|
472
|
+
this.errorHooks = [];
|
|
473
|
+
this.patternHandlers.clear();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6BzC;;GAEG;AACH,MAAM,kBAAkB;IACd,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE3C,GAAG,CAAc,GAAW;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAkB,CAAC;IAC9C,CAAC;IAED,GAAG,CAAc,GAAW,EAAE,KAAQ;QACpC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF;AA8BD;;GAEG;A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