@agentplugins/core 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/README.md +57 -0
- package/dist/hook-wrapper.d.ts +36 -0
- package/dist/hook-wrapper.d.ts.map +1 -0
- package/dist/hook-wrapper.js +207 -0
- package/dist/hook-wrapper.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/profiling-hof.d.ts +11 -0
- package/dist/profiling-hof.d.ts.map +1 -0
- package/dist/profiling-hof.js +80 -0
- package/dist/profiling-hof.js.map +1 -0
- package/dist/profiling.d.ts +64 -0
- package/dist/profiling.d.ts.map +1 -0
- package/dist/profiling.js +58 -0
- package/dist/profiling.js.map +1 -0
- package/dist/registry.d.ts +34 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +76 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +248 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +45 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +23 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +373 -0
- package/dist/validation.js.map +1 -0
- package/package.json +42 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @agentplugins/core
|
|
2
|
+
|
|
3
|
+
> Core types, validation, and plugin registry for [AgentPlugins](https://github.com/espetro/agentplugins).
|
|
4
|
+
|
|
5
|
+
`@agentplugins/core` defines the universal plugin manifest (`PluginManifest`), runs schema validation, and exposes the adapter registry that platform adapters register themselves with. It is the **Port** in AgentPlugins's Ports & Adapters (Hexagonal) architecture.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @agentplugins/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer dependency: none. Runtime: Node 20+.
|
|
14
|
+
|
|
15
|
+
## What's in the box
|
|
16
|
+
|
|
17
|
+
- **`PluginManifest`** — the universal TypeScript shape every plugin declares against.
|
|
18
|
+
- **`definePlugin(manifest)`** — identity helper that returns the manifest as-is, with type inference.
|
|
19
|
+
- **`validateManifest(manifest)`** — runs structural + semantic checks and returns a list of `ValidationIssue` (severity-tagged).
|
|
20
|
+
- **`AdapterRegistry`** — central registry where adapters self-register; consumers query it by platform name.
|
|
21
|
+
- **`wrapInlineHandlers(manifest)`** — converts inline handler strings into the format each platform expects.
|
|
22
|
+
- **`UNIVERSAL_HOOK_NAMES`**, **`ALL_TARGETS`** — canonical enums for hooks and target platforms.
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { definePlugin, validateManifest, AdapterRegistry } from '@agentplugins/core';
|
|
28
|
+
|
|
29
|
+
const manifest = definePlugin({
|
|
30
|
+
name: 'my-plugin',
|
|
31
|
+
version: '0.1.0',
|
|
32
|
+
targets: ['claude', 'opencode'],
|
|
33
|
+
hooks: {
|
|
34
|
+
sessionStart: {
|
|
35
|
+
handler: {
|
|
36
|
+
type: 'inline',
|
|
37
|
+
handler: async () => ({ additionalContext: 'Plugin loaded.' }),
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const issues = validateManifest(manifest);
|
|
44
|
+
if (issues.some(i => i.severity === 'error')) {
|
|
45
|
+
throw new Error('Invalid plugin manifest');
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Related packages
|
|
50
|
+
|
|
51
|
+
- [`@agentplugins/cli`](https://www.npmjs.com/package/@agentplugins/cli) — build, validate, and scaffold plugins.
|
|
52
|
+
- [`@agentplugins/adapter-claude`](https://www.npmjs.com/package/@agentplugins/adapter-claude) and the other 6 platform adapters.
|
|
53
|
+
- Root repo: <https://github.com/espetro/agentplugins>
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Hook Wrapper Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates Node.js scripts that wrap inline handlers for command-based platforms.
|
|
5
|
+
* These scripts communicate via JSON stdin/stdout following the Codex/Gemini protocol.
|
|
6
|
+
*/
|
|
7
|
+
import type { HookContext, HookResult } from './types.js';
|
|
8
|
+
export interface WrapperOptions {
|
|
9
|
+
/** Target platform flavor for output format */
|
|
10
|
+
platform: 'codex' | 'claude' | 'copilot' | 'gemini' | 'kimi';
|
|
11
|
+
/** Hook name */
|
|
12
|
+
hookName: string;
|
|
13
|
+
/** Unique identifier for this wrapper */
|
|
14
|
+
wrapperId: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Generate a Node.js wrapper script that:
|
|
18
|
+
* 1. Reads JSON context from stdin
|
|
19
|
+
* 2. Calls the inline handler
|
|
20
|
+
* 3. Writes JSON result to stdout
|
|
21
|
+
* 4. Exits with appropriate code (0=success, 2=block)
|
|
22
|
+
*
|
|
23
|
+
* The inline handler is serialized as a string and embedded in the script.
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateHookWrapper(_handlerSource: string, options: WrapperOptions): string;
|
|
26
|
+
/**
|
|
27
|
+
* Generate the shared handlers module that exports all inline handlers.
|
|
28
|
+
* This is imported by each individual wrapper script.
|
|
29
|
+
*/
|
|
30
|
+
export declare function generateHandlersModule(handlers: Map<string, (ctx: HookContext) => Promise<HookResult>>): string;
|
|
31
|
+
/**
|
|
32
|
+
* Serialize an inline handler to a string that can be embedded in a wrapper.
|
|
33
|
+
* Returns null if the handler cannot be serialized.
|
|
34
|
+
*/
|
|
35
|
+
export declare function serializeHandler(handler: (ctx: HookContext) => Promise<HookResult>): string | null;
|
|
36
|
+
//# sourceMappingURL=hook-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-wrapper.d.ts","sourceRoot":"","sources":["../src/hook-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC7D,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,cAAc,GACtB,MAAM,CA8IR;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,GAC/D,MAAM,CA6BR;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,IAAI,CAWlG"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Hook Wrapper Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates Node.js scripts that wrap inline handlers for command-based platforms.
|
|
5
|
+
* These scripts communicate via JSON stdin/stdout following the Codex/Gemini protocol.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Generate a Node.js wrapper script that:
|
|
9
|
+
* 1. Reads JSON context from stdin
|
|
10
|
+
* 2. Calls the inline handler
|
|
11
|
+
* 3. Writes JSON result to stdout
|
|
12
|
+
* 4. Exits with appropriate code (0=success, 2=block)
|
|
13
|
+
*
|
|
14
|
+
* The inline handler is serialized as a string and embedded in the script.
|
|
15
|
+
*/
|
|
16
|
+
export function generateHookWrapper(_handlerSource, options) {
|
|
17
|
+
const { platform, hookName, wrapperId } = options;
|
|
18
|
+
return `#!/usr/bin/env node
|
|
19
|
+
/**
|
|
20
|
+
* AgentPlugins Auto-Generated Hook Wrapper
|
|
21
|
+
* Platform: ${platform}
|
|
22
|
+
* Hook: ${hookName}
|
|
23
|
+
* ID: ${wrapperId}
|
|
24
|
+
*
|
|
25
|
+
* DO NOT EDIT — This file is regenerated on each build.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const { handler } = require('./__agentplugins_handlers__.js');
|
|
29
|
+
|
|
30
|
+
async function main() {
|
|
31
|
+
// Read JSON context from stdin
|
|
32
|
+
let input = '';
|
|
33
|
+
process.stdin.setEncoding('utf8');
|
|
34
|
+
for await (const chunk of process.stdin) {
|
|
35
|
+
input += chunk;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let ctx;
|
|
39
|
+
try {
|
|
40
|
+
ctx = JSON.parse(input || '{}');
|
|
41
|
+
} catch {
|
|
42
|
+
ctx = {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Normalize context fields across platforms
|
|
46
|
+
const normalizedCtx = normalizeContext(ctx, '${hookName}');
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const result = await handler(normalizedCtx);
|
|
50
|
+
|
|
51
|
+
if (!result) {
|
|
52
|
+
// No result = allow operation to continue
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Output result as JSON
|
|
57
|
+
const output = formatOutput(result, '${platform}', '${hookName}');
|
|
58
|
+
if (output) {
|
|
59
|
+
console.log(JSON.stringify(output));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Exit with blocking code if needed
|
|
63
|
+
if (result.block || result.continue === false) {
|
|
64
|
+
process.exit(${platform === 'gemini' || platform === 'copilot' ? 2 : 0});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process.exit(0);
|
|
68
|
+
} catch (err) {
|
|
69
|
+
// On error, output system message and exit
|
|
70
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
71
|
+
console.error(errorMsg);
|
|
72
|
+
|
|
73
|
+
${platform === 'copilot' ? `
|
|
74
|
+
// Copilot is fail-closed: errors deny the operation
|
|
75
|
+
console.log(JSON.stringify({ systemMessage: \`Hook error: \${errorMsg}\` }));
|
|
76
|
+
process.exit(2);
|
|
77
|
+
` : platform === 'gemini' ? `
|
|
78
|
+
// Gemini: non-zero exit = warning (not block)
|
|
79
|
+
process.exit(1);
|
|
80
|
+
` : `
|
|
81
|
+
// Other platforms: error is logged but doesn't block
|
|
82
|
+
process.exit(0);
|
|
83
|
+
`}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function normalizeContext(ctx, eventName) {
|
|
88
|
+
return {
|
|
89
|
+
event: eventName,
|
|
90
|
+
cwd: ctx.cwd ?? ctx.workingDirectory ?? process.cwd(),
|
|
91
|
+
sessionId: ctx.session_id ?? ctx.sessionId ?? ctx.sessionID,
|
|
92
|
+
model: ctx.model ?? ctx.model_name,
|
|
93
|
+
permissionMode: ctx.permission_mode ?? ctx.permissionMode,
|
|
94
|
+
toolName: ctx.tool_name ?? ctx.toolName ?? ctx.tool,
|
|
95
|
+
toolInput: ctx.tool_input ?? ctx.toolInput ?? ctx.args,
|
|
96
|
+
userPrompt: ctx.user_prompt ?? ctx.userPrompt ?? ctx.prompt,
|
|
97
|
+
source: ctx.source,
|
|
98
|
+
transcriptPath: ctx.transcript_path ?? ctx.transcriptPath,
|
|
99
|
+
agentId: ctx.agent_id ?? ctx.agentId,
|
|
100
|
+
agentType: ctx.agent_type ?? ctx.agentType ?? ctx.agent,
|
|
101
|
+
turnId: ctx.turn_id ?? ctx.turnId,
|
|
102
|
+
// Pass through any extra fields
|
|
103
|
+
...ctx,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function formatOutput(result, platform, hookName) {
|
|
108
|
+
if (!result) return null;
|
|
109
|
+
|
|
110
|
+
switch (platform) {
|
|
111
|
+
case 'codex':
|
|
112
|
+
// Codex format: hookSpecificOutput with additionalContext
|
|
113
|
+
if (result.additionalContext) {
|
|
114
|
+
return {
|
|
115
|
+
hookSpecificOutput: {
|
|
116
|
+
hookEventName: hookName.charAt(0).toUpperCase() + hookName.slice(1),
|
|
117
|
+
additionalContext: result.additionalContext,
|
|
118
|
+
},
|
|
119
|
+
...(result.systemMessage ? { systemMessage: result.systemMessage } : {}),
|
|
120
|
+
...(result.continue === false ? { continue: false, stopReason: result.reason } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
...(result.systemMessage ? { systemMessage: result.systemMessage } : {}),
|
|
125
|
+
...(result.continue === false ? { continue: false, stopReason: result.reason } : {}),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
case 'gemini':
|
|
129
|
+
// Gemini format: JSON output, exit 2 to block
|
|
130
|
+
return {
|
|
131
|
+
...(result.systemMessage ? { systemMessage: result.systemMessage } : {}),
|
|
132
|
+
...(result.additionalContext ? { additionalContext: result.additionalContext } : {}),
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
case 'copilot':
|
|
136
|
+
// Copilot format: similar to codex
|
|
137
|
+
return {
|
|
138
|
+
...(result.systemMessage ? { systemMessage: result.systemMessage } : {}),
|
|
139
|
+
...(result.additionalContext ? { additionalContext: result.additionalContext } : {}),
|
|
140
|
+
...(result.continue === false ? { continue: false } : {}),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
case 'claude':
|
|
144
|
+
case 'kimi':
|
|
145
|
+
default:
|
|
146
|
+
// Generic format
|
|
147
|
+
return {
|
|
148
|
+
...(result.systemMessage ? { systemMessage: result.systemMessage } : {}),
|
|
149
|
+
...(result.additionalContext ? { additionalContext: result.additionalContext } : {}),
|
|
150
|
+
...(result.continue === false ? { continue: false } : {}),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
main();
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Generate the shared handlers module that exports all inline handlers.
|
|
160
|
+
* This is imported by each individual wrapper script.
|
|
161
|
+
*/
|
|
162
|
+
export function generateHandlersModule(handlers) {
|
|
163
|
+
const entries = [];
|
|
164
|
+
for (const [id, handler] of handlers) {
|
|
165
|
+
// Serialize the handler — note: this requires the handler to be serializable
|
|
166
|
+
// For complex handlers, users should use 'command' type instead
|
|
167
|
+
entries.push(` '${id}': ${handler.toString()},`);
|
|
168
|
+
}
|
|
169
|
+
return `/**
|
|
170
|
+
* AgentPlugins Auto-Generated Handlers Module
|
|
171
|
+
*
|
|
172
|
+
* DO NOT EDIT — This file is regenerated on each build.
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
exports.handler = handler;
|
|
176
|
+
|
|
177
|
+
const handlers = {
|
|
178
|
+
${entries.join('\n')}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
async function handler(ctx) {
|
|
182
|
+
const handlerFn = handlers[process.env.AGENTPLUGINS_HOOK_ID];
|
|
183
|
+
if (!handlerFn) {
|
|
184
|
+
throw new Error(\`Unknown hook ID: \${process.env.AGENTPLUGINS_HOOK_ID}\`);
|
|
185
|
+
}
|
|
186
|
+
return handlerFn(ctx);
|
|
187
|
+
}
|
|
188
|
+
`;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Serialize an inline handler to a string that can be embedded in a wrapper.
|
|
192
|
+
* Returns null if the handler cannot be serialized.
|
|
193
|
+
*/
|
|
194
|
+
export function serializeHandler(handler) {
|
|
195
|
+
try {
|
|
196
|
+
const str = handler.toString();
|
|
197
|
+
// Basic validation: must look like a function
|
|
198
|
+
if (!str.includes('function') && !str.includes('=>')) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
return str;
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return null;
|
|
205
|
+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AC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAkD;IACjF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,8CAA8C;QAC9C,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Core
|
|
3
|
+
*
|
|
4
|
+
* The Port — universal plugin interface for AI agent harnesses.
|
|
5
|
+
*/
|
|
6
|
+
export type { PluginManifest, TargetPlatform, Skill, MCPServerConfig, ToolDefinition, ToolParameterSchema, ToolParameter, ToolContext, ToolResult, UserConfigOption, UniversalHooks, UniversalHookName, HookDefinition, HookHandler, CommandHookHandler, HttpHookHandler, InlineHookHandler, HookContext, HookResult, PlatformAdapter, HandlerType, ValidationIssue, AdapterOutput, FileOutput, BuildConfig, } from './types.js';
|
|
7
|
+
export type { FileOutput as AdapterFile } from './types.js';
|
|
8
|
+
export { Severity } from './types.js';
|
|
9
|
+
import type { PluginManifest } from './types.js';
|
|
10
|
+
export { ALL_TARGETS, UNIVERSAL_HOOK_NAMES } from './types.js';
|
|
11
|
+
export { validateUniversal, validateForPlatform, getPlatformConstraints, } from './validation.js';
|
|
12
|
+
export type { PlatformConstraints } from './validation.js';
|
|
13
|
+
export { registerAdapter, hasAdapter, loadAdapter, loadAllAdapters, getRegisteredPlatforms, registerBuiltinAdapters, } from './registry.js';
|
|
14
|
+
export { generateHookWrapper, generateHandlersModule, serializeHandler, } from './hook-wrapper.js';
|
|
15
|
+
export type { WrapperOptions } from './hook-wrapper.js';
|
|
16
|
+
/**
|
|
17
|
+
* Convenience function to define a plugin with TypeScript intellisense.
|
|
18
|
+
*/
|
|
19
|
+
export declare function definePlugin(manifest: PluginManifest): PluginManifest;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,cAAc,EACd,cAAc,EACd,KAAK,EACL,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,EACb,UAAU,EACV,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAG/D,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EACL,eAAe,EACf,UAAU,EACV,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,cAAc,CAErE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentPlugins Core
|
|
3
|
+
*
|
|
4
|
+
* The Port — universal plugin interface for AI agent harnesses.
|
|
5
|
+
*/
|
|
6
|
+
export { Severity } from './types.js';
|
|
7
|
+
// Constants
|
|
8
|
+
export { ALL_TARGETS, UNIVERSAL_HOOK_NAMES } from './types.js';
|
|
9
|
+
// Validation
|
|
10
|
+
export { validateUniversal, validateForPlatform, getPlatformConstraints, } from './validation.js';
|
|
11
|
+
// Registry
|
|
12
|
+
export { registerAdapter, hasAdapter, loadAdapter, loadAllAdapters, getRegisteredPlatforms, registerBuiltinAdapters, } from './registry.js';
|
|
13
|
+
// Hook Wrapper Generation
|
|
14
|
+
export { generateHookWrapper, generateHandlersModule, serializeHandler, } from './hook-wrapper.js';
|
|
15
|
+
/**
|
|
16
|
+
* Convenience function to define a plugin with TypeScript intellisense.
|
|
17
|
+
*/
|
|
18
|
+
export function definePlugin(manifest) {
|
|
19
|
+
return manifest;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgCH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE/D,aAAa;AACb,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAGzB,WAAW;AACX,OAAO,EACL,eAAe,EACf,UAAU,EACV,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,0BAA0B;AAC1B,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAwB;IACnD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HookContext, HookResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Higher-order function that wraps an inline hook handler with timing instrumentation.
|
|
4
|
+
*
|
|
5
|
+
* @param handler - The inline hook handler to wrap
|
|
6
|
+
* @param hookName - Name of the hook event (e.g. 'preToolUse')
|
|
7
|
+
* @param platform - Platform identifier (e.g. 'opencode', 'pimono')
|
|
8
|
+
* @returns The same handler, wrapped with timing and profiling
|
|
9
|
+
*/
|
|
10
|
+
export declare function withTiming<T extends (ctx: HookContext) => Promise<HookResult>>(handler: T, hookName: string, platform: string): T;
|
|
11
|
+
//# sourceMappingURL=profiling-hof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiling-hof.d.ts","sourceRoot":"","sources":["../src/profiling-hof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAgB1D;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,CAAC,SAAS,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,EACnD,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAqEnD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createHookId, startTimer, emitProfilingEvent, shouldProfile, getProfilingOutput, } from './profiling.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sequence counter for ordering profiling events within a session.
|
|
4
|
+
* Incremented on each withTiming call.
|
|
5
|
+
*/
|
|
6
|
+
let sequenceCounter = 0;
|
|
7
|
+
/**
|
|
8
|
+
* Higher-order function that wraps an inline hook handler with timing instrumentation.
|
|
9
|
+
*
|
|
10
|
+
* @param handler - The inline hook handler to wrap
|
|
11
|
+
* @param hookName - Name of the hook event (e.g. 'preToolUse')
|
|
12
|
+
* @param platform - Platform identifier (e.g. 'opencode', 'pimono')
|
|
13
|
+
* @returns The same handler, wrapped with timing and profiling
|
|
14
|
+
*/
|
|
15
|
+
export function withTiming(handler, hookName, platform) {
|
|
16
|
+
return (async (ctx) => {
|
|
17
|
+
// Inject timing fields into context before handler execution
|
|
18
|
+
const hookId = createHookId();
|
|
19
|
+
const timestamp = Date.now();
|
|
20
|
+
const getElapsed = startTimer();
|
|
21
|
+
ctx.timestamp = timestamp;
|
|
22
|
+
ctx.hookId = hookId;
|
|
23
|
+
let result;
|
|
24
|
+
let error;
|
|
25
|
+
try {
|
|
26
|
+
result = await handler(ctx);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
error = err instanceof Error ? err.message : String(err);
|
|
30
|
+
// Emit error profiling event when profiling is enabled
|
|
31
|
+
if (shouldProfile()) {
|
|
32
|
+
const event = {
|
|
33
|
+
type: 'hook_invocation',
|
|
34
|
+
hookName,
|
|
35
|
+
hookId,
|
|
36
|
+
sequenceId: ++sequenceCounter,
|
|
37
|
+
timestamp,
|
|
38
|
+
hookDurationMs: getElapsed(),
|
|
39
|
+
platform,
|
|
40
|
+
sessionId: ctx.sessionId,
|
|
41
|
+
toolName: ctx.toolName,
|
|
42
|
+
error,
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
emitProfilingEvent(event, getProfilingOutput());
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// profiling failure must never break the hook
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
// Record duration after handler completes
|
|
54
|
+
const hookDurationMs = getElapsed();
|
|
55
|
+
ctx.hookDurationMs = hookDurationMs;
|
|
56
|
+
// Emit profiling event when profiling is enabled
|
|
57
|
+
if (shouldProfile()) {
|
|
58
|
+
const event = {
|
|
59
|
+
type: 'hook_invocation',
|
|
60
|
+
hookName,
|
|
61
|
+
hookId,
|
|
62
|
+
sequenceId: ++sequenceCounter,
|
|
63
|
+
timestamp,
|
|
64
|
+
hookDurationMs,
|
|
65
|
+
platform,
|
|
66
|
+
sessionId: ctx.sessionId,
|
|
67
|
+
toolName: ctx.toolName,
|
|
68
|
+
result,
|
|
69
|
+
};
|
|
70
|
+
try {
|
|
71
|
+
emitProfilingEvent(event, getProfilingOutput());
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// profiling failure must never break the hook
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=profiling-hof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiling-hof.js","sourceRoot":"","sources":["../src/profiling-hof.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,kBAAkB,GAEnB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAExB,OAAU,EAAE,QAAgB,EAAE,QAAgB;IAC9C,OAAO,CAAC,KAAK,EAAE,GAAgB,EAAuB,EAAE;QACtD,6DAA6D;QAC7D,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAG,UAAU,EAAE,CAAC;QAEhC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC;QAC1B,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QAEpB,IAAI,MAAkB,CAAC;QACvB,IAAI,KAAyB,CAAC;QAE9B,IAAI,CAAC;YACH,MAAM,GAAG,MAAM,OAAO,CA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AC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAM,CAAC;AACV,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profiling event emitted as JSONL for external profiler consumption.
|
|
3
|
+
* Mirrors schemas/profiling-event.json.
|
|
4
|
+
*/
|
|
5
|
+
export interface ProfilingEvent {
|
|
6
|
+
/** Discriminator: always "hook_invocation" */
|
|
7
|
+
type: 'hook_invocation';
|
|
8
|
+
/** Name of the hook being invoked */
|
|
9
|
+
hookName: string;
|
|
10
|
+
/** Unique identifier for this hook invocation instance */
|
|
11
|
+
hookId: string;
|
|
12
|
+
/** Monotonically increasing sequence number for ordering events */
|
|
13
|
+
sequenceId: number;
|
|
14
|
+
/** Unix epoch timestamp in milliseconds when the hook was invoked */
|
|
15
|
+
timestamp: number;
|
|
16
|
+
/** Duration of the hook execution in milliseconds */
|
|
17
|
+
hookDurationMs: number;
|
|
18
|
+
/** Platform on which the hook ran (e.g. 'python', 'node', 'cli') */
|
|
19
|
+
platform: string;
|
|
20
|
+
/** Optional session identifier to correlate events */
|
|
21
|
+
sessionId?: string;
|
|
22
|
+
/** Optional name of the tool/agent associated with this hook invocation */
|
|
23
|
+
toolName?: string;
|
|
24
|
+
/** Optional result payload returned by the hook */
|
|
25
|
+
result?: object;
|
|
26
|
+
/** Optional error message if the hook invocation failed */
|
|
27
|
+
error?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generates a unique hook invocation ID using crypto.randomUUID().
|
|
31
|
+
*/
|
|
32
|
+
export declare function createHookId(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a timer. When the returned function is called, it returns
|
|
35
|
+
* the elapsed milliseconds since the timer was created (via Date.now()).
|
|
36
|
+
*/
|
|
37
|
+
export declare function startTimer(): () => number;
|
|
38
|
+
/**
|
|
39
|
+
* Writes a profiling event as a single JSONL line.
|
|
40
|
+
*
|
|
41
|
+
* - If `destination` is `'stderr'`, writes to `process.stderr` (without newline — JSONL
|
|
42
|
+
* consumers typically handle line separation; we add `\n` for readability).
|
|
43
|
+
* - If `destination` is a file path, appends a JSONL line via `fs.appendFileSync`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function emitProfilingEvent(event: ProfilingEvent, destination: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Reads the `AGENTBRIDGE_PROFILING_OUTPUT` environment variable.
|
|
48
|
+
* Returns `'stderr'` if the variable is not set.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getProfilingOutput(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Returns `true` when profiling is enabled (i.e. the
|
|
53
|
+
* `AGENTBRIDGE_PROFILING_OUTPUT` environment variable is set to a non-empty value).
|
|
54
|
+
*/
|
|
55
|
+
export declare function shouldProfile(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a session-scoped sequence ID counter.
|
|
58
|
+
* Returns `next()` which yields a monotonically increasing integer per session.
|
|
59
|
+
* Used by generated wrappers to produce `sequenceId` values in profiling events.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createSequenceId(): {
|
|
62
|
+
next: () => number;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=profiling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiling.d.ts","sourceRoot":"","sources":["../src/profiling.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,IAAI,EAAE,iBAAiB,CAAC;IACxB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,MAAM,CAGzC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,cAAc,EACrB,WAAW,EAAE,MAAM,GAClB,IAAI,CAQN;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAGvC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI;IAAE,IAAI,EAAE,MAAM,MAAM,CAAA;CAAE,CAGzD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
const PROFILING_ENV_VAR = 'AGENTBRIDGE_PROFILING_OUTPUT';
|
|
4
|
+
/**
|
|
5
|
+
* Generates a unique hook invocation ID using crypto.randomUUID().
|
|
6
|
+
*/
|
|
7
|
+
export function createHookId() {
|
|
8
|
+
return crypto.randomUUID();
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a timer. When the returned function is called, it returns
|
|
12
|
+
* the elapsed milliseconds since the timer was created (via Date.now()).
|
|
13
|
+
*/
|
|
14
|
+
export function startTimer() {
|
|
15
|
+
const start = Date.now();
|
|
16
|
+
return () => Date.now() - start;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Writes a profiling event as a single JSONL line.
|
|
20
|
+
*
|
|
21
|
+
* - If `destination` is `'stderr'`, writes to `process.stderr` (without newline — JSONL
|
|
22
|
+
* consumers typically handle line separation; we add `\n` for readability).
|
|
23
|
+
* - If `destination` is a file path, appends a JSONL line via `fs.appendFileSync`.
|
|
24
|
+
*/
|
|
25
|
+
export function emitProfilingEvent(event, destination) {
|
|
26
|
+
const line = JSON.stringify(event) + '\n';
|
|
27
|
+
if (destination === 'stderr') {
|
|
28
|
+
process.stderr.write(line);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
fs.appendFileSync(destination, line, 'utf-8');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reads the `AGENTBRIDGE_PROFILING_OUTPUT` environment variable.
|
|
36
|
+
* Returns `'stderr'` if the variable is not set.
|
|
37
|
+
*/
|
|
38
|
+
export function getProfilingOutput() {
|
|
39
|
+
return process.env[PROFILING_ENV_VAR] ?? 'stderr';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns `true` when profiling is enabled (i.e. the
|
|
43
|
+
* `AGENTBRIDGE_PROFILING_OUTPUT` environment variable is set to a non-empty value).
|
|
44
|
+
*/
|
|
45
|
+
export function shouldProfile() {
|
|
46
|
+
const value = process.env[PROFILING_ENV_VAR];
|
|
47
|
+
return value !== undefined && value !== '';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates a session-scoped sequence ID counter.
|
|
51
|
+
* Returns `next()` which yields a monotonically increasing integer per session.
|
|
52
|
+
* Used by generated wrappers to produce `sequenceId` values in profiling events.
|
|
53
|
+
*/
|
|
54
|
+
export function createSequenceId() {
|
|
55
|
+
let counter = 0;
|
|
56
|
+
return { next: () => ++counter };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=profiling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiling.js","sourceRoot":"","sources":["../src/profiling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,iBAAiB,GAAG,8BAA8B,CAA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
|
+
* Adapters register themselves; the CLI and build system look them up here.
|
|
6
|
+
*/
|
|
7
|
+
import type { PlatformAdapter, TargetPlatform } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Register a platform adapter factory.
|
|
10
|
+
* Called by each adapter package during initialization.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerAdapter(platform: TargetPlatform, factory: () => Promise<PlatformAdapter>): void;
|
|
13
|
+
/**
|
|
14
|
+
* Check if an adapter is registered for a platform.
|
|
15
|
+
*/
|
|
16
|
+
export declare function hasAdapter(platform: TargetPlatform): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Load a platform adapter asynchronously.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadAdapter(platform: TargetPlatform): Promise<PlatformAdapter>;
|
|
21
|
+
/**
|
|
22
|
+
* Load all registered adapters.
|
|
23
|
+
*/
|
|
24
|
+
export declare function loadAllAdapters(): Promise<Map<TargetPlatform, PlatformAdapter>>;
|
|
25
|
+
/**
|
|
26
|
+
* Get list of registered platforms.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getRegisteredPlatforms(): TargetPlatform[];
|
|
29
|
+
/**
|
|
30
|
+
* Import and register all built-in adapters.
|
|
31
|
+
* This is a convenience function that auto-registers all official adapters.
|
|
32
|
+
*/
|
|
33
|
+
export declare function registerBuiltinAdapters(): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIlE;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,GACtC,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAE5D;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CASpF;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,CAMrF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,cAAc,EAAE,CAEzD;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAuB7D"}
|