@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,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trajectory Hooks
|
|
3
|
+
*
|
|
4
|
+
* Provides trajectory tracking hooks that integrate with the PDERO paradigm.
|
|
5
|
+
* These hooks automatically track agent work when registered with a HookRegistry.
|
|
6
|
+
*/
|
|
7
|
+
import type { LifecycleHooks } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Options for trajectory hooks
|
|
10
|
+
*/
|
|
11
|
+
export interface TrajectoryHooksOptions {
|
|
12
|
+
/** Project identifier */
|
|
13
|
+
projectId: string;
|
|
14
|
+
/** Agent name */
|
|
15
|
+
agentName: string;
|
|
16
|
+
/** Whether to auto-detect phase transitions */
|
|
17
|
+
autoDetectPhase?: boolean;
|
|
18
|
+
/** Whether to detect and record tool calls */
|
|
19
|
+
detectTools?: boolean;
|
|
20
|
+
/** Whether to detect and record errors */
|
|
21
|
+
detectErrors?: boolean;
|
|
22
|
+
/** Whether to inject trail instructions on session start */
|
|
23
|
+
injectInstructions?: boolean;
|
|
24
|
+
/** Whether to prompt for retrospective on session end */
|
|
25
|
+
promptRetrospective?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create trajectory hooks for automatic PDERO tracking
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const hooks = createTrajectoryHooks({
|
|
33
|
+
* projectId: 'my-project',
|
|
34
|
+
* agentName: 'Alice',
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* registry.registerLifecycleHooks(hooks);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function createTrajectoryHooks(options: TrajectoryHooksOptions): LifecycleHooks;
|
|
41
|
+
/**
|
|
42
|
+
* Get trajectory hooks for a project/agent combination
|
|
43
|
+
*
|
|
44
|
+
* This is a convenience function that creates trajectory hooks
|
|
45
|
+
* with default options.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getTrajectoryHooks(projectId: string, agentName: string): LifecycleHooks;
|
|
48
|
+
/**
|
|
49
|
+
* Utility to check if trajectory tracking is available
|
|
50
|
+
*/
|
|
51
|
+
export declare function isTrajectoryTrackingAvailable(projectId: string, agentName: string): boolean;
|
|
52
|
+
//# sourceMappingURL=trajectory-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trajectory-hooks.d.ts","sourceRoot":"","sources":["../src/trajectory-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EAOf,MAAM,YAAY,CAAC;AAWpB;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,8CAA8C;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4DAA4D;IAC5D,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAeD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,cAAc,CAsBrF;AA4ID;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,CAEvF;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAG3F"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trajectory Hooks
|
|
3
|
+
*
|
|
4
|
+
* Provides trajectory tracking hooks that integrate with the PDERO paradigm.
|
|
5
|
+
* These hooks automatically track agent work when registered with a HookRegistry.
|
|
6
|
+
*/
|
|
7
|
+
import { getTrajectoryIntegration, detectPhaseFromContent, detectToolCalls, detectErrors, getCompactTrailInstructions, } from '@agent-relay/trajectory';
|
|
8
|
+
/**
|
|
9
|
+
* Create trajectory hooks for automatic PDERO tracking
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const hooks = createTrajectoryHooks({
|
|
14
|
+
* projectId: 'my-project',
|
|
15
|
+
* agentName: 'Alice',
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* registry.registerLifecycleHooks(hooks);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function createTrajectoryHooks(options) {
|
|
22
|
+
const state = {
|
|
23
|
+
trajectory: getTrajectoryIntegration(options.projectId, options.agentName),
|
|
24
|
+
seenTools: new Set(),
|
|
25
|
+
seenErrors: new Set(),
|
|
26
|
+
options: {
|
|
27
|
+
autoDetectPhase: true,
|
|
28
|
+
detectTools: true,
|
|
29
|
+
detectErrors: true,
|
|
30
|
+
injectInstructions: true,
|
|
31
|
+
promptRetrospective: true,
|
|
32
|
+
...options,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
onSessionStart: createSessionStartHook(state),
|
|
37
|
+
onSessionEnd: createSessionEndHook(state),
|
|
38
|
+
onOutput: createOutputHook(state),
|
|
39
|
+
onMessageReceived: createMessageReceivedHook(state),
|
|
40
|
+
onMessageSent: createMessageSentHook(state),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Session start hook - initializes trajectory tracking
|
|
45
|
+
*/
|
|
46
|
+
function createSessionStartHook(state) {
|
|
47
|
+
return async (ctx) => {
|
|
48
|
+
const { trajectory, options } = state;
|
|
49
|
+
// Initialize trajectory with task if provided
|
|
50
|
+
if (ctx.task) {
|
|
51
|
+
const success = await trajectory.initialize(ctx.task, ctx.taskId, ctx.taskSource);
|
|
52
|
+
if (success) {
|
|
53
|
+
console.log(`[trajectory] Started tracking: ${ctx.task}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
await trajectory.initialize();
|
|
58
|
+
}
|
|
59
|
+
// Inject trail instructions if enabled and trail is available
|
|
60
|
+
if (options.injectInstructions && trajectory.isTrailInstalledSync()) {
|
|
61
|
+
const instructions = getCompactTrailInstructions();
|
|
62
|
+
return { inject: `\n${instructions}\n` };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Session end hook - completes or abandons trajectory
|
|
68
|
+
*/
|
|
69
|
+
function createSessionEndHook(state) {
|
|
70
|
+
return async (ctx) => {
|
|
71
|
+
const { trajectory, options } = state;
|
|
72
|
+
if (!trajectory.hasActiveTrajectory()) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (ctx.graceful) {
|
|
76
|
+
// Prompt for retrospective if enabled
|
|
77
|
+
if (options.promptRetrospective) {
|
|
78
|
+
const durationSeconds = Math.round(ctx.duration / 1000);
|
|
79
|
+
const result = {
|
|
80
|
+
inject: `
|
|
81
|
+
[SESSION ENDING]
|
|
82
|
+
Complete your trajectory with a summary:
|
|
83
|
+
trail complete --summary "What you accomplished" --confidence 0.9
|
|
84
|
+
|
|
85
|
+
Or if you need to document learnings:
|
|
86
|
+
trail decision "Key choice" --reasoning "Why"
|
|
87
|
+
`,
|
|
88
|
+
};
|
|
89
|
+
// Also complete the trajectory
|
|
90
|
+
await trajectory.complete({
|
|
91
|
+
summary: `Session ended after ${durationSeconds}s`,
|
|
92
|
+
});
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
await trajectory.complete({
|
|
97
|
+
summary: `Session ended gracefully`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
await trajectory.abandon('Session terminated');
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Output hook - auto-detects PDERO phase transitions, tool calls, and errors
|
|
108
|
+
*/
|
|
109
|
+
function createOutputHook(state) {
|
|
110
|
+
return async (ctx) => {
|
|
111
|
+
const { trajectory, options } = state;
|
|
112
|
+
// Detect and record phase transitions
|
|
113
|
+
if (options.autoDetectPhase) {
|
|
114
|
+
const detectedPhase = detectPhaseFromContent(ctx.content);
|
|
115
|
+
if (detectedPhase && detectedPhase !== state.lastDetectedPhase) {
|
|
116
|
+
state.lastDetectedPhase = detectedPhase;
|
|
117
|
+
await trajectory.transition(detectedPhase, 'Auto-detected from output');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Detect and record tool calls
|
|
121
|
+
// Note: We deduplicate by tool+status to record each unique tool type once per session
|
|
122
|
+
// (e.g., "Read" started, "Read" completed). This provides a summary of tools used
|
|
123
|
+
// without flooding the trajectory with every individual invocation.
|
|
124
|
+
if (options.detectTools) {
|
|
125
|
+
const tools = detectToolCalls(ctx.content);
|
|
126
|
+
for (const tool of tools) {
|
|
127
|
+
const key = `${tool.tool}:${tool.status || 'started'}`;
|
|
128
|
+
if (!state.seenTools.has(key)) {
|
|
129
|
+
state.seenTools.add(key);
|
|
130
|
+
const statusLabel = tool.status === 'completed' ? ' (completed)' : '';
|
|
131
|
+
await trajectory.event(`Tool: ${tool.tool}${statusLabel}`, 'tool_call');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Detect and record errors
|
|
136
|
+
if (options.detectErrors) {
|
|
137
|
+
const errors = detectErrors(ctx.content);
|
|
138
|
+
for (const error of errors) {
|
|
139
|
+
// Deduplicate by message content
|
|
140
|
+
if (!state.seenErrors.has(error.message)) {
|
|
141
|
+
state.seenErrors.add(error.message);
|
|
142
|
+
const prefix = error.type === 'warning' ? 'Warning' : 'Error';
|
|
143
|
+
await trajectory.event(`${prefix}: ${error.message}`, 'error');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Message received hook - records incoming messages
|
|
151
|
+
*/
|
|
152
|
+
function createMessageReceivedHook(state) {
|
|
153
|
+
return async (ctx) => {
|
|
154
|
+
const { trajectory, options } = state;
|
|
155
|
+
await trajectory.message('received', ctx.from, options.agentName, ctx.body);
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Message sent hook - records outgoing messages
|
|
160
|
+
*/
|
|
161
|
+
function createMessageSentHook(state) {
|
|
162
|
+
return async (ctx) => {
|
|
163
|
+
const { trajectory, options } = state;
|
|
164
|
+
await trajectory.message('sent', options.agentName, ctx.to, ctx.body);
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get trajectory hooks for a project/agent combination
|
|
169
|
+
*
|
|
170
|
+
* This is a convenience function that creates trajectory hooks
|
|
171
|
+
* with default options.
|
|
172
|
+
*/
|
|
173
|
+
export function getTrajectoryHooks(projectId, agentName) {
|
|
174
|
+
return createTrajectoryHooks({ projectId, agentName });
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Utility to check if trajectory tracking is available
|
|
178
|
+
*/
|
|
179
|
+
export function isTrajectoryTrackingAvailable(projectId, agentName) {
|
|
180
|
+
const trajectory = getTrajectoryIntegration(projectId, agentName);
|
|
181
|
+
return trajectory.isTrailInstalledSync();
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=trajectory-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trajectory-hooks.js","sourceRoot":"","sources":["../src/trajectory-hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAEL,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,2BAA2B,GAE5B,MAAM,yBAAyB,CAAC;AAmCjC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,MAAM,KAAK,GAAyB;QAClC,UAAU,EAAE,wBAAwB,CAAC,OAAO,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,OAAO,UAAU,CAAC,oBAAoB,EAAE,CAAC;AAC3C,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Relay Hook Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for the agent-relay hooks system. Hooks allow agents to intercept
|
|
5
|
+
* and modify behavior at various points in the agent lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
import type { SendPayload } from '@agent-relay/protocol/types';
|
|
8
|
+
/**
|
|
9
|
+
* A message in the conversation history
|
|
10
|
+
*/
|
|
11
|
+
export interface ConversationMessage {
|
|
12
|
+
/** Role of the message sender */
|
|
13
|
+
role: 'user' | 'assistant' | 'system';
|
|
14
|
+
/** Message content */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Timestamp when the message was created */
|
|
17
|
+
timestamp?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Output from the agent (tool calls, responses, etc.)
|
|
21
|
+
*/
|
|
22
|
+
export interface AgentOutput {
|
|
23
|
+
/** Type of output */
|
|
24
|
+
type: 'text' | 'tool_call' | 'tool_result';
|
|
25
|
+
/** Content of the output */
|
|
26
|
+
content: string;
|
|
27
|
+
/** Tool name if type is tool_call or tool_result */
|
|
28
|
+
tool?: string;
|
|
29
|
+
/** Timestamp of the output */
|
|
30
|
+
timestamp: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Memory interface for persisting data across hook invocations
|
|
34
|
+
*/
|
|
35
|
+
export interface HookMemory {
|
|
36
|
+
/** Get a value from memory */
|
|
37
|
+
get<T = unknown>(key: string): T | undefined;
|
|
38
|
+
/** Set a value in memory */
|
|
39
|
+
set<T = unknown>(key: string, value: T): void;
|
|
40
|
+
/** Delete a value from memory */
|
|
41
|
+
delete(key: string): boolean;
|
|
42
|
+
/** Check if a key exists */
|
|
43
|
+
has(key: string): boolean;
|
|
44
|
+
/** Clear all memory */
|
|
45
|
+
clear(): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Relay interface for sending messages to other agents
|
|
49
|
+
*/
|
|
50
|
+
export interface HookRelay {
|
|
51
|
+
/** Send a message to a specific agent or broadcast */
|
|
52
|
+
send(to: string | '*', body: string, options?: Partial<SendPayload>): Promise<void>;
|
|
53
|
+
/** Check if connected to the relay daemon */
|
|
54
|
+
isConnected(): boolean;
|
|
55
|
+
/** Get the current agent's name in the relay */
|
|
56
|
+
getAgentName(): string | undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Context provided to hooks during execution
|
|
60
|
+
*
|
|
61
|
+
* This interface provides hooks with access to the current execution context,
|
|
62
|
+
* allowing them to inspect and modify agent behavior.
|
|
63
|
+
*/
|
|
64
|
+
export interface HookContext {
|
|
65
|
+
/** Unique identifier for this agent instance */
|
|
66
|
+
agentId: string;
|
|
67
|
+
/** Session identifier for the current conversation */
|
|
68
|
+
sessionId: string;
|
|
69
|
+
/** Working directory of the agent */
|
|
70
|
+
workingDir: string;
|
|
71
|
+
/** Environment variables available to the hook */
|
|
72
|
+
env: Record<string, string | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Inject content into the agent's input stream.
|
|
75
|
+
* This content will be processed as if it came from the user.
|
|
76
|
+
* @param content - The content to inject
|
|
77
|
+
*/
|
|
78
|
+
inject(content: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* Send a message through the relay to other agents.
|
|
81
|
+
* @param to - Target agent name or '*' for broadcast
|
|
82
|
+
* @param body - Message body
|
|
83
|
+
* @param options - Optional message options
|
|
84
|
+
*/
|
|
85
|
+
send(to: string | '*', body: string, options?: Partial<SendPayload>): Promise<void>;
|
|
86
|
+
/** Persistent memory for storing data across hook invocations */
|
|
87
|
+
memory: HookMemory;
|
|
88
|
+
/** Relay interface for agent communication */
|
|
89
|
+
relay: HookRelay;
|
|
90
|
+
/** Array of outputs from the current agent turn */
|
|
91
|
+
output: AgentOutput[];
|
|
92
|
+
/** Conversation message history */
|
|
93
|
+
messages: ConversationMessage[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Result returned by a hook execution
|
|
97
|
+
*
|
|
98
|
+
* Hooks can modify agent behavior by returning specific fields:
|
|
99
|
+
* - inject: Add content to the agent's input
|
|
100
|
+
* - suppress: Prevent the triggering action from executing
|
|
101
|
+
* - stop: Halt further hook processing
|
|
102
|
+
*/
|
|
103
|
+
export interface HookResult {
|
|
104
|
+
/**
|
|
105
|
+
* Content to inject into the agent's input stream.
|
|
106
|
+
* If provided, this content will be processed as user input.
|
|
107
|
+
*/
|
|
108
|
+
inject?: string;
|
|
109
|
+
/**
|
|
110
|
+
* If true, suppress the action that triggered the hook.
|
|
111
|
+
* For example, on a Stop hook, this would prevent the agent from stopping.
|
|
112
|
+
*/
|
|
113
|
+
suppress?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* If true, stop processing any remaining hooks in the chain.
|
|
116
|
+
* The current hook's result will be the final result.
|
|
117
|
+
*/
|
|
118
|
+
stop?: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Hook event types that can trigger hook execution
|
|
122
|
+
*/
|
|
123
|
+
export type HookEventType = 'PreToolCall' | 'PostToolCall' | 'Stop' | 'Start' | 'Error' | 'Message';
|
|
124
|
+
/**
|
|
125
|
+
* Configuration for a hook
|
|
126
|
+
*/
|
|
127
|
+
export interface HookConfig {
|
|
128
|
+
/** The event type that triggers this hook */
|
|
129
|
+
event: HookEventType;
|
|
130
|
+
/** Command to execute for the hook */
|
|
131
|
+
command: string;
|
|
132
|
+
/** Optional working directory for the command */
|
|
133
|
+
workingDir?: string;
|
|
134
|
+
/** Optional timeout in milliseconds */
|
|
135
|
+
timeout?: number;
|
|
136
|
+
/** Whether this hook is enabled */
|
|
137
|
+
enabled?: boolean;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Handler function signature for programmatic hooks
|
|
141
|
+
*/
|
|
142
|
+
export type HookHandler = (context: HookContext) => HookResult | Promise<HookResult>;
|
|
143
|
+
/**
|
|
144
|
+
* Extended context for session start hooks
|
|
145
|
+
*/
|
|
146
|
+
export interface SessionStartContext extends HookContext {
|
|
147
|
+
/** Task description if agent was started with a task */
|
|
148
|
+
task?: string;
|
|
149
|
+
/** Task ID if linked to external system */
|
|
150
|
+
taskId?: string;
|
|
151
|
+
/** Task source (e.g., 'beads', 'linear', 'github') */
|
|
152
|
+
taskSource?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Extended context for session end hooks
|
|
156
|
+
*/
|
|
157
|
+
export interface SessionEndContext extends HookContext {
|
|
158
|
+
/** Exit code if available */
|
|
159
|
+
exitCode?: number;
|
|
160
|
+
/** Duration of the session in milliseconds */
|
|
161
|
+
duration: number;
|
|
162
|
+
/** Whether the session ended gracefully */
|
|
163
|
+
graceful: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Extended context for output hooks
|
|
167
|
+
*/
|
|
168
|
+
export interface OutputContext extends HookContext {
|
|
169
|
+
/** Cleaned output (ANSI codes stripped) */
|
|
170
|
+
content: string;
|
|
171
|
+
/** Raw output with ANSI codes */
|
|
172
|
+
rawContent: string;
|
|
173
|
+
/** Whether this is a complete line */
|
|
174
|
+
isComplete: boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Extended context for message received hooks
|
|
178
|
+
*/
|
|
179
|
+
export interface MessageReceivedContext extends HookContext {
|
|
180
|
+
/** Sender agent name */
|
|
181
|
+
from: string;
|
|
182
|
+
/** Message body */
|
|
183
|
+
body: string;
|
|
184
|
+
/** Message ID */
|
|
185
|
+
messageId: string;
|
|
186
|
+
/** Thread ID if threaded */
|
|
187
|
+
thread?: string;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Extended context for message sent hooks
|
|
191
|
+
*/
|
|
192
|
+
export interface MessageSentContext extends HookContext {
|
|
193
|
+
/** Target agent name */
|
|
194
|
+
to: string;
|
|
195
|
+
/** Message body */
|
|
196
|
+
body: string;
|
|
197
|
+
/** Thread ID if threaded */
|
|
198
|
+
thread?: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Extended context for idle hooks
|
|
202
|
+
*/
|
|
203
|
+
export interface IdleContext extends HookContext {
|
|
204
|
+
/** Duration of inactivity in milliseconds */
|
|
205
|
+
idleDuration: number;
|
|
206
|
+
/** Number of times idle hook has fired this session */
|
|
207
|
+
idleCount: number;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Extended context for error hooks
|
|
211
|
+
*/
|
|
212
|
+
export interface ErrorContext extends HookContext {
|
|
213
|
+
/** The error that occurred */
|
|
214
|
+
error: Error;
|
|
215
|
+
/** Phase where error occurred (e.g., 'output', 'message', 'tool') */
|
|
216
|
+
phase?: string;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Lifecycle hook handler types
|
|
220
|
+
*/
|
|
221
|
+
export type OnSessionStartHook = (ctx: SessionStartContext) => Promise<HookResult | void> | HookResult | void;
|
|
222
|
+
export type OnSessionEndHook = (ctx: SessionEndContext) => Promise<HookResult | void> | HookResult | void;
|
|
223
|
+
export type OnOutputHook = (ctx: OutputContext) => Promise<HookResult | void> | HookResult | void;
|
|
224
|
+
export type OnMessageReceivedHook = (ctx: MessageReceivedContext) => Promise<HookResult | void> | HookResult | void;
|
|
225
|
+
export type OnMessageSentHook = (ctx: MessageSentContext) => Promise<HookResult | void> | HookResult | void;
|
|
226
|
+
export type OnIdleHook = (ctx: IdleContext) => Promise<HookResult | void> | HookResult | void;
|
|
227
|
+
export type OnErrorHook = (ctx: ErrorContext) => Promise<HookResult | void> | HookResult | void;
|
|
228
|
+
/**
|
|
229
|
+
* Lifecycle hook definitions for registration
|
|
230
|
+
*/
|
|
231
|
+
export interface LifecycleHooks {
|
|
232
|
+
onSessionStart?: OnSessionStartHook | OnSessionStartHook[];
|
|
233
|
+
onSessionEnd?: OnSessionEndHook | OnSessionEndHook[];
|
|
234
|
+
onOutput?: OnOutputHook | OnOutputHook[];
|
|
235
|
+
onMessageReceived?: OnMessageReceivedHook | OnMessageReceivedHook[];
|
|
236
|
+
onMessageSent?: OnMessageSentHook | OnMessageSentHook[];
|
|
237
|
+
onIdle?: OnIdleHook | OnIdleHook[];
|
|
238
|
+
onError?: OnErrorHook | OnErrorHook[];
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Lifecycle hook event names
|
|
242
|
+
*/
|
|
243
|
+
export type LifecycleHookEvent = 'sessionStart' | 'sessionEnd' | 'output' | 'messageReceived' | 'messageSent' | 'idle' | 'error';
|
|
244
|
+
/**
|
|
245
|
+
* Pattern handler for custom namespaces (e.g., @deploy:, @notify:)
|
|
246
|
+
*/
|
|
247
|
+
export type PatternHandler = (target: string, message: string, ctx: HookContext) => Promise<HookResult | void> | HookResult | void;
|
|
248
|
+
/**
|
|
249
|
+
* Memory configuration for hooks
|
|
250
|
+
*/
|
|
251
|
+
export interface HooksMemoryConfig {
|
|
252
|
+
/** Memory adapter type: 'inmemory', 'supermemory', etc. */
|
|
253
|
+
type?: string;
|
|
254
|
+
/** API key for external memory services */
|
|
255
|
+
apiKey?: string;
|
|
256
|
+
/** Custom API endpoint */
|
|
257
|
+
endpoint?: string;
|
|
258
|
+
/** Whether to inject memories on session start */
|
|
259
|
+
injectOnStart?: boolean;
|
|
260
|
+
/** Maximum memories to inject on start */
|
|
261
|
+
maxStartMemories?: number;
|
|
262
|
+
/** Whether to prompt for memory save on session end */
|
|
263
|
+
promptOnEnd?: boolean;
|
|
264
|
+
/** Whether to auto-save detected learnings (default: true) */
|
|
265
|
+
autoSave?: boolean;
|
|
266
|
+
/** Whether to track learnings for session-end summary (default: true) */
|
|
267
|
+
autoSaveOnEnd?: boolean;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Full hooks configuration
|
|
271
|
+
*/
|
|
272
|
+
export interface HooksConfig {
|
|
273
|
+
/** Lifecycle hooks */
|
|
274
|
+
hooks?: LifecycleHooks;
|
|
275
|
+
/** Pattern handlers by namespace */
|
|
276
|
+
patterns?: Record<string, PatternHandler | 'builtin'>;
|
|
277
|
+
/** Idle timeout in milliseconds (default: 30000) */
|
|
278
|
+
idleTimeout?: number;
|
|
279
|
+
/** Whether to enable trajectory tracking hooks */
|
|
280
|
+
trajectoryTracking?: boolean;
|
|
281
|
+
/** Memory system configuration */
|
|
282
|
+
memory?: HooksMemoryConfig | boolean;
|
|
283
|
+
}
|
|
284
|
+
export declare const HOOK_ABI_VERSION = 1;
|
|
285
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qBAAqB;IACrB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC;IAC3C,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAC7C,4BAA4B;IAC5B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,E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,GAAG,UAAU,GAAG,IAAI,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sBAAsB;IACtB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC;IACtD,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kCAAkC;IAClC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC;CACtC;AAGD,eAAO,MAAM,gBAAgB,IAAmB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Relay Hook Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for the agent-relay hooks system. Hooks allow agents to intercept
|
|
5
|
+
* and modify behavior at various points in the agent lifecycle.
|
|
6
|
+
*/
|
|
7
|
+
import { PROTOCOL_VERSION } from '@agent-relay/protocol';
|
|
8
|
+
// Hook ABI version aligns with protocol wire version
|
|
9
|
+
export const HOOK_ABI_VERSION = PROTOCOL_VERSION;
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA4UzD,qDAAqD;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agent-relay/hooks",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Hook emitter, registry, and trajectory hooks for Agent Relay",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./inbox-check": {
|
|
14
|
+
"types": "./dist/inbox-check/index.d.ts",
|
|
15
|
+
"import": "./dist/inbox-check/index.js",
|
|
16
|
+
"default": "./dist/inbox-check/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./types": {
|
|
19
|
+
"types": "./dist/types.d.ts",
|
|
20
|
+
"import": "./dist/types.js",
|
|
21
|
+
"default": "./dist/types.js"
|
|
22
|
+
},
|
|
23
|
+
"./browser": {
|
|
24
|
+
"types": "./dist/browser.d.ts",
|
|
25
|
+
"import": "./dist/browser.js",
|
|
26
|
+
"default": "./dist/browser.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"clean": "rm -rf dist",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@agent-relay/protocol": "^0.1.2",
|
|
41
|
+
"@agent-relay/config": "^0.1.0",
|
|
42
|
+
"@agent-relay/trajectory": "^0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^22.19.3",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vitest": "^3.2.4"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
52
|
+
}
|