@a5c-ai/hooks-mux-core 5.0.1-staging.ceeaa92b2 → 5.0.1-staging.cf6715cee515
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/api.d.ts +2 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +10 -3
- package/dist/api.js.map +1 -1
- package/dist/handlers/agent.d.ts +12 -0
- package/dist/handlers/agent.d.ts.map +1 -0
- package/dist/handlers/agent.js +36 -0
- package/dist/handlers/agent.js.map +1 -0
- package/dist/handlers/http.d.ts +5 -0
- package/dist/handlers/http.d.ts.map +1 -0
- package/dist/handlers/http.js +128 -0
- package/dist/handlers/http.js.map +1 -0
- package/dist/handlers/mcp-tool.d.ts +11 -0
- package/dist/handlers/mcp-tool.d.ts.map +1 -0
- package/dist/handlers/mcp-tool.js +47 -0
- package/dist/handlers/mcp-tool.js.map +1 -0
- package/dist/handlers/prompt.d.ts +12 -0
- package/dist/handlers/prompt.d.ts.map +1 -0
- package/dist/handlers/prompt.js +36 -0
- package/dist/handlers/prompt.js.map +1 -0
- package/dist/handlers/shared.d.ts +12 -0
- package/dist/handlers/shared.d.ts.map +1 -0
- package/dist/handlers/shared.js +53 -0
- package/dist/handlers/shared.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/merge-engine/merge.d.ts +4 -1
- package/dist/merge-engine/merge.d.ts.map +1 -1
- package/dist/merge-engine/merge.js +45 -7
- package/dist/merge-engine/merge.js.map +1 -1
- package/dist/normalizer/index.d.ts +1 -1
- package/dist/normalizer/index.d.ts.map +1 -1
- package/dist/normalizer/plan-resolver.d.ts.map +1 -1
- package/dist/normalizer/plan-resolver.js +73 -4
- package/dist/normalizer/plan-resolver.js.map +1 -1
- package/dist/normalizer/runner.d.ts +36 -1
- package/dist/normalizer/runner.d.ts.map +1 -1
- package/dist/normalizer/runner.js +181 -13
- package/dist/normalizer/runner.js.map +1 -1
- package/dist/programmatic/engine.d.ts +1 -0
- package/dist/programmatic/engine.d.ts.map +1 -1
- package/dist/programmatic/engine.js +1 -1
- package/dist/programmatic/engine.js.map +1 -1
- package/dist/propagation/adapt-output.d.ts.map +1 -1
- package/dist/propagation/adapt-output.js +5 -0
- package/dist/propagation/adapt-output.js.map +1 -1
- package/dist/propagation/materialize.d.ts.map +1 -1
- package/dist/propagation/materialize.js +7 -0
- package/dist/propagation/materialize.js.map +1 -1
- package/dist/sdk-interface/builder.d.ts +3 -0
- package/dist/sdk-interface/builder.d.ts.map +1 -1
- package/dist/sdk-interface/builder.js +19 -0
- package/dist/sdk-interface/builder.js.map +1 -1
- package/dist/sdk-interface/parser.d.ts.map +1 -1
- package/dist/sdk-interface/parser.js +35 -4
- package/dist/sdk-interface/parser.js.map +1 -1
- package/dist/types/adapter.d.ts +10 -0
- package/dist/types/adapter.d.ts.map +1 -1
- package/dist/types/lifecycle.d.ts +4 -2
- package/dist/types/lifecycle.d.ts.map +1 -1
- package/dist/types/lifecycle.js +72 -0
- package/dist/types/lifecycle.js.map +1 -1
- package/dist/types/plan.d.ts +58 -4
- package/dist/types/plan.d.ts.map +1 -1
- package/dist/types/result.d.ts +4 -1
- package/dist/types/result.d.ts.map +1 -1
- package/package.json +10 -2
package/dist/api.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import type { UnifiedHookEvent } from './types/event';
|
|
7
7
|
import type { AdapterCapabilities } from './types/adapter';
|
|
8
8
|
import type { HookPlanEntry } from './types/plan';
|
|
9
|
+
import type { RunPlanOptions } from './normalizer/runner';
|
|
9
10
|
import { type MergedExecutionResult } from './merge-engine';
|
|
10
11
|
/**
|
|
11
12
|
* Implementation callbacks provided by an adapter.
|
|
@@ -36,7 +37,7 @@ export declare function registerHandler(planEntry: HookPlanEntry): void;
|
|
|
36
37
|
* Run the full normalized pipeline: execute all matching handlers for
|
|
37
38
|
* the event's phase and return the merged result.
|
|
38
39
|
*/
|
|
39
|
-
export declare function runNormalized(event: UnifiedHookEvent): Promise<MergedExecutionResult>;
|
|
40
|
+
export declare function runNormalized(event: UnifiedHookEvent, options?: RunPlanOptions): Promise<MergedExecutionResult>;
|
|
40
41
|
/**
|
|
41
42
|
* Get a registered adapter by name.
|
|
42
43
|
*/
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAgB,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAgB,KAAK,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAG1E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAAC;IAC/C,yDAAyD;IACzD,YAAY,CAAC,CAAC,YAAY,EAAE,qBAAqB,GAAG,OAAO,CAAC;CAC7D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,mBAAmB,CAAC;IAClC,IAAI,EAAE,WAAW,CAAC;CACnB;AAaD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,mBAAmB,EACjC,IAAI,EAAE,WAAW,GAChB,iBAAiB,CAInB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAE9D;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,gBAAgB,EACvB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,qBAAqB,CAAC,CAsChC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEtE;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAGtC"}
|
package/dist/api.js
CHANGED
|
@@ -44,6 +44,7 @@ exports.runNormalized = runNormalized;
|
|
|
44
44
|
exports.getAdapter = getAdapter;
|
|
45
45
|
exports.clearRegistries = clearRegistries;
|
|
46
46
|
const merge_engine_1 = require("./merge-engine");
|
|
47
|
+
const plan_resolver_1 = require("./normalizer/plan-resolver");
|
|
47
48
|
// ---------------------------------------------------------------------------
|
|
48
49
|
// Internal registries
|
|
49
50
|
// ---------------------------------------------------------------------------
|
|
@@ -70,7 +71,7 @@ function registerHandler(planEntry) {
|
|
|
70
71
|
* Run the full normalized pipeline: execute all matching handlers for
|
|
71
72
|
* the event's phase and return the merged result.
|
|
72
73
|
*/
|
|
73
|
-
async function runNormalized(event) {
|
|
74
|
+
async function runNormalized(event, options) {
|
|
74
75
|
const matchingEntries = handlerRegistry
|
|
75
76
|
.filter((e) => e.phase === event.phase)
|
|
76
77
|
.sort((a, b) => {
|
|
@@ -83,10 +84,16 @@ async function runNormalized(event) {
|
|
|
83
84
|
});
|
|
84
85
|
const results = [];
|
|
85
86
|
for (const entry of matchingEntries) {
|
|
86
|
-
|
|
87
|
+
if (!(0, plan_resolver_1.evaluateWhen)(entry.when, event) || !(0, plan_resolver_1.evaluateWhen)(entry.if, event)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
87
90
|
const { runHandler } = await Promise.resolve().then(() => __importStar(require('./normalizer/runner')));
|
|
88
91
|
try {
|
|
89
|
-
const result = await runHandler(event, entry.handler
|
|
92
|
+
const result = await runHandler(event, entry.handler, entry.timeoutMs ?? options?.handlerTimeoutMs, options?.capabilities, {
|
|
93
|
+
executors: options?.executors,
|
|
94
|
+
currentDepth: options?.currentDepth,
|
|
95
|
+
shell: entry.shell ?? entry.handler.shell,
|
|
96
|
+
});
|
|
90
97
|
results.push(result);
|
|
91
98
|
}
|
|
92
99
|
catch (_err) {
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CH,sCAQC;AAKD,0CAEC;AAMD,sCAyCC;AAKD,gCAEC;AAKD,0CAGC;AAjHD,iDAA0E;AAC1E,8DAA0D;AAqB1D,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,MAAM,eAAe,GAAG,IAAI,GAAG,EAA6B,CAAC;AAC7D,MAAM,eAAe,GAAoB,EAAE,CAAC;AAE5C,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;GAEG;AACH,SAAgB,aAAa,CAC3B,IAAY,EACZ,YAAiC,EACjC,IAAiB;IAEjB,MAAM,OAAO,GAAsB,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAChE,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnC,OAA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rB;gBACE,SAAS,EAAE,OAAO,EAAE,SAAS;gBAC7B,YAAY,EAAE,OAAO,EAAE,YAAY;gBACnC,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK;aAC1C,CACF,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QAAC,OAAO,IAAI,EAAE,CAAC;YACd,2CAA2C;YAC3C,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,2BAA2B,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,OAAO,IAAA,2BAAY,EAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe;IAC7B,eAAe,CAAC,KAAK,EAAE,CAAC;IACxB,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UnifiedHookResult } from '../types/result';
|
|
2
|
+
import type { AgentHandlerRef } from '../types/plan';
|
|
3
|
+
import { type HandlerRuntimeContext } from './shared';
|
|
4
|
+
export interface AgentExecutionRequest {
|
|
5
|
+
prompt: string;
|
|
6
|
+
agent?: string;
|
|
7
|
+
model?: string;
|
|
8
|
+
maxTurns: number;
|
|
9
|
+
}
|
|
10
|
+
export type AgentExecutor = (request: AgentExecutionRequest, context: HandlerRuntimeContext) => Promise<UnifiedHookResult | string | Record<string, unknown>> | UnifiedHookResult | string | Record<string, unknown>;
|
|
11
|
+
export declare function runAgentHandler(ref: AgentHandlerRef, context: HandlerRuntimeContext, executor?: AgentExecutor): Promise<UnifiedHookResult>;
|
|
12
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/handlers/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAgD,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEpG,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,CAC1B,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1H,wBAAsB,eAAe,CACnC,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,CAAC,EAAE,aAAa,GACvB,OAAO,CAAC,iBAAiB,CAAC,CAkC5B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runAgentHandler = runAgentHandler;
|
|
4
|
+
const errors_1 = require("../normalizer/errors");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
async function runAgentHandler(ref, context, executor) {
|
|
7
|
+
(0, shared_1.ensureDepth)(context.currentDepth, ref.maxDepth, 'agent', ref.agent ?? 'agent', 'AGENT_DEPTH_EXCEEDED');
|
|
8
|
+
if (!executor) {
|
|
9
|
+
throw new errors_1.HandlerError('agent handler requires an injected executor', {
|
|
10
|
+
source: ref.agent ?? 'agent',
|
|
11
|
+
handler: 'agent',
|
|
12
|
+
code: 'AGENT_EXECUTOR_MISSING',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const result = await (0, shared_1.withTimeout)(ref.agent ?? 'agent', 'agent', context.timeoutMs, (signal) => executor({
|
|
17
|
+
prompt: ref.prompt,
|
|
18
|
+
agent: ref.agent,
|
|
19
|
+
model: ref.model,
|
|
20
|
+
maxTurns: Math.max(1, Math.min(ref.maxTurns ?? 1, 10)),
|
|
21
|
+
}, { ...context, signal }));
|
|
22
|
+
return (0, shared_1.parseHandlerResult)(result);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err instanceof errors_1.HandlerError) {
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
throw new errors_1.HandlerError(err instanceof Error ? err.message : String(err), {
|
|
29
|
+
source: ref.agent ?? 'agent',
|
|
30
|
+
handler: 'agent',
|
|
31
|
+
code: 'AGENT_HANDLER_ERROR',
|
|
32
|
+
cause: err,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/handlers/agent.ts"],"names":[],"mappings":";;AAiBA,0CAsCC;AArDD,iDAAoD;AACpD,qCAAoG;AAc7F,KAAK,UAAU,eAAe,CACnC,GAAoB,EACpB,OAA8B,EAC9B,QAAwB;IAExB,IAAA,oBAAW,EAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,KAAK,IAAI,OAAO,EAAE,sBAAsB,CAAC,CAAC;IAEvG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,qBAAY,CAAC,6CAA6C,EAAE;YACpE,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,OAAO;YAC5B,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,wBAAwB;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,IAAI,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC;YACtG,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;SACvD,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAE5B,OAAO,IAAA,2BAAkB,EAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,qBAAY,EAAE,CAAC;YAChC,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,MAAM,IAAI,qBAAY,CACpB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAChD;YACE,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,OAAO;YAC5B,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,qBAAqB;YAC3B,KAAK,EAAE,GAAG;SACX,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { UnifiedHookResult } from '../types/result';
|
|
2
|
+
import type { HttpHandlerRef } from '../types/plan';
|
|
3
|
+
import { type HandlerRuntimeContext } from './shared';
|
|
4
|
+
export declare function runHttpHandler(ref: HttpHandlerRef, context: HandlerRuntimeContext): Promise<UnifiedHookResult>;
|
|
5
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/handlers/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAmC,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAgGvF,wBAAsB,cAAc,CAClC,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,iBAAiB,CAAC,CAqC5B"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runHttpHandler = runHttpHandler;
|
|
7
|
+
const net_1 = __importDefault(require("net"));
|
|
8
|
+
const errors_1 = require("../normalizer/errors");
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
11
|
+
function isPrivateIpv4(hostname) {
|
|
12
|
+
const parts = hostname.split('.').map((part) => Number(part));
|
|
13
|
+
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const [a, b] = parts;
|
|
17
|
+
return (a === 10 ||
|
|
18
|
+
a === 127 ||
|
|
19
|
+
(a === 172 && b >= 16 && b <= 31) ||
|
|
20
|
+
(a === 192 && b === 168) ||
|
|
21
|
+
(a === 169 && b === 254) ||
|
|
22
|
+
a === 0);
|
|
23
|
+
}
|
|
24
|
+
function isUnsafeHost(hostname) {
|
|
25
|
+
const host = hostname.toLowerCase();
|
|
26
|
+
if (host === 'localhost') {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (net_1.default.isIP(host) === 4) {
|
|
30
|
+
return isPrivateIpv4(host);
|
|
31
|
+
}
|
|
32
|
+
if (net_1.default.isIP(host) === 6) {
|
|
33
|
+
return host === '::1' || host.startsWith('fe80:') || host === '::';
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
function validateUrl(ref) {
|
|
38
|
+
let url;
|
|
39
|
+
try {
|
|
40
|
+
url = new URL(ref.url);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
throw new errors_1.HandlerError(`Invalid HTTP handler URL: ${ref.url}`, {
|
|
44
|
+
source: ref.url,
|
|
45
|
+
handler: 'http',
|
|
46
|
+
code: 'HTTP_URL_ERROR',
|
|
47
|
+
cause: err,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
51
|
+
throw new errors_1.HandlerError(`Unsupported HTTP handler URL protocol: ${url.protocol}`, {
|
|
52
|
+
source: ref.url,
|
|
53
|
+
handler: 'http',
|
|
54
|
+
code: 'HTTP_URL_ERROR',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (url.username || url.password) {
|
|
58
|
+
throw new errors_1.HandlerError('HTTP handler URL must not include credentials', {
|
|
59
|
+
source: ref.url,
|
|
60
|
+
handler: 'http',
|
|
61
|
+
code: 'HTTP_URL_ERROR',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (!ref.allowPrivateNetwork && isUnsafeHost(url.hostname)) {
|
|
65
|
+
throw new errors_1.HandlerError(`Unsafe HTTP handler host: ${url.hostname}`, {
|
|
66
|
+
source: ref.url,
|
|
67
|
+
handler: 'http',
|
|
68
|
+
code: 'HTTP_URL_ERROR',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return url;
|
|
72
|
+
}
|
|
73
|
+
function interpolateHeaderValue(value, allowedEnvVars) {
|
|
74
|
+
return value.replace(/\$(?:\{([A-Za-z_][A-Za-z0-9_]*)\}|([A-Za-z_][A-Za-z0-9_]*))/g, (_match, braced, bare) => {
|
|
75
|
+
const name = braced ?? bare;
|
|
76
|
+
if (!name || !allowedEnvVars.has(name)) {
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
return process.env[name] ?? '';
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function buildHeaders(ref) {
|
|
83
|
+
const allowed = new Set(ref.allowedEnvVars ?? []);
|
|
84
|
+
const headers = {
|
|
85
|
+
'content-type': 'application/json',
|
|
86
|
+
};
|
|
87
|
+
for (const [name, value] of Object.entries(ref.headers ?? {})) {
|
|
88
|
+
headers[name] = interpolateHeaderValue(value, allowed);
|
|
89
|
+
}
|
|
90
|
+
return headers;
|
|
91
|
+
}
|
|
92
|
+
async function runHttpHandler(ref, context) {
|
|
93
|
+
const url = validateUrl(ref);
|
|
94
|
+
const timeoutMs = context.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
95
|
+
const body = JSON.stringify({
|
|
96
|
+
event: context.event,
|
|
97
|
+
...(ref.body ?? {}),
|
|
98
|
+
});
|
|
99
|
+
return (0, shared_1.withTimeout)(ref.url, 'http', timeoutMs, async (signal) => {
|
|
100
|
+
const response = await fetch(url, {
|
|
101
|
+
method: ref.method ?? 'POST',
|
|
102
|
+
headers: buildHeaders(ref),
|
|
103
|
+
body,
|
|
104
|
+
signal,
|
|
105
|
+
redirect: 'error',
|
|
106
|
+
});
|
|
107
|
+
const text = await response.text();
|
|
108
|
+
if (!response.ok) {
|
|
109
|
+
throw new errors_1.HandlerError(`HTTP handler returned ${response.status}`, {
|
|
110
|
+
source: ref.url,
|
|
111
|
+
handler: 'http',
|
|
112
|
+
code: 'HTTP_STATUS_ERROR',
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
return text.trim().length === 0 ? { decision: 'noop' } : (0, shared_1.parseHandlerResult)(JSON.parse(text));
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
throw new errors_1.HandlerError('HTTP handler returned invalid JSON', {
|
|
120
|
+
source: ref.url,
|
|
121
|
+
handler: 'http',
|
|
122
|
+
code: 'HTTP_RESPONSE_ERROR',
|
|
123
|
+
cause: err,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/handlers/http.ts"],"names":[],"mappings":";;;;;AAoGA,wCAwCC;AA5ID,8CAAsB;AAGtB,iDAAoD;AACpD,qCAAuF;AAEvF,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,SAAS,aAAa,CAAC,QAAgB;IACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;QAClG,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;IACrB,OAAO,CACL,CAAC,KAAK,EAAE;QACR,CAAC,KAAK,GAAG;QACT,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;QACjC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC;QACxB,CAAC,CAAC,KAAK,GAAG,IA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AE,MAAM,EAAE,CAAC,CAAC,CAAC,IAAA,2BAAkB,EAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAChG,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,qBAAY,CAAC,oCAAoC,EAAE;gBAC3D,MAAM,EAAE,GAAG,CAAC,GAAG;gBACf,OAAO,EAAE,MAAM;gBACf,IAAI,EAAE,qBAAqB;gBAC3B,KAAK,EAAE,GAAG;aACX,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UnifiedHookResult } from '../types/result';
|
|
2
|
+
import type { McpToolHandlerRef } from '../types/plan';
|
|
3
|
+
import { type HandlerRuntimeContext } from './shared';
|
|
4
|
+
export interface McpToolExecutionRequest {
|
|
5
|
+
server: string;
|
|
6
|
+
tool: string;
|
|
7
|
+
args: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export type McpToolExecutor = (request: McpToolExecutionRequest, context: HandlerRuntimeContext) => Promise<UnifiedHookResult | string | Record<string, unknown>> | UnifiedHookResult | string | Record<string, unknown>;
|
|
10
|
+
export declare function runMcpToolHandler(ref: McpToolHandlerRef, context: HandlerRuntimeContext, executor?: McpToolExecutor): Promise<UnifiedHookResult>;
|
|
11
|
+
//# sourceMappingURL=mcp-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool.d.ts","sourceRoot":"","sources":["../../src/handlers/mcp-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAmC,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEvF,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,MAAM,eAAe,GAAG,CAC5B,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAiB1H,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,CAAC,EAAE,eAAe,GACzB,OAAO,CAAC,iBAAiB,CAAC,CA+B5B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runMcpToolHandler = runMcpToolHandler;
|
|
4
|
+
const errors_1 = require("../normalizer/errors");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
function parseMcpToolResult(value) {
|
|
7
|
+
const parsed = (0, shared_1.parseHandlerResult)(value);
|
|
8
|
+
if (parsed.decision || parsed.reason || parsed.metadata) {
|
|
9
|
+
return parsed;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
decision: 'noop',
|
|
13
|
+
metadata: {
|
|
14
|
+
handlerType: 'mcp_tool',
|
|
15
|
+
toolResult: value,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async function runMcpToolHandler(ref, context, executor) {
|
|
20
|
+
if (!executor) {
|
|
21
|
+
throw new errors_1.HandlerError('mcp_tool handler requires an injected executor', {
|
|
22
|
+
source: `${ref.server}:${ref.tool}`,
|
|
23
|
+
handler: 'mcp_tool',
|
|
24
|
+
code: 'MCP_EXECUTOR_MISSING',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const result = await (0, shared_1.withTimeout)(`${ref.server}:${ref.tool}`, 'mcp_tool', context.timeoutMs, (signal) => executor({
|
|
29
|
+
server: ref.server,
|
|
30
|
+
tool: ref.tool,
|
|
31
|
+
args: ref.args ?? {},
|
|
32
|
+
}, { ...context, signal }));
|
|
33
|
+
return parseMcpToolResult(result);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
if (err instanceof errors_1.HandlerError) {
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
throw new errors_1.HandlerError(err instanceof Error ? err.message : String(err), {
|
|
40
|
+
source: `${ref.server}:${ref.tool}`,
|
|
41
|
+
handler: 'mcp_tool',
|
|
42
|
+
code: 'MCP_TOOL_ERROR',
|
|
43
|
+
cause: err,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=mcp-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool.js","sourceRoot":"","sources":["../../src/handlers/mcp-tool.ts"],"names":[],"mappings":";;AA+BA,8CAmCC;AAhED,iDAAoD;AACpD,qCAAuF;AAavF,SAAS,kBAAkB,CAAC,KAAc;IACxC,MAAM,MAAM,GAAG,IAAA,2BAAkB,EAAC,KAAK,CAAC,CAAC;IACzC,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,MAAM;QAChB,QAAQ,EAAE;YACR,WAAW,EAAE,UAAU;YACvB,UAAU,EAAE,KAAK;SAClB;KACF,CAAC;AACJ,CAAC;AAEM,KAAK,UAAU,iBAAiB,CACrC,GAAsB,EACtB,OAA8B,EAC9B,QAA0B;IAE1B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,qBAAY,CAAC,gDAAgD,EAAE;YACvE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE;YACnC,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,sBAAsB;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAA,oBAAW,EAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC;YAChH,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE;SACrB,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAE5B,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,qBAAY,EAAE,CAAC;YAChC,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,MAAM,IAAI,qBAAY,CACpB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAChD;YACE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE;YACnC,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,GAAG;SACX,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UnifiedHookResult } from '../types/result';
|
|
2
|
+
import type { PromptHandlerRef } from '../types/plan';
|
|
3
|
+
import { type HandlerRuntimeContext } from './shared';
|
|
4
|
+
export interface PromptExecutionRequest {
|
|
5
|
+
prompt: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
systemPrompt?: string;
|
|
8
|
+
maxOutputBytes?: number;
|
|
9
|
+
}
|
|
10
|
+
export type PromptExecutor = (request: PromptExecutionRequest, context: HandlerRuntimeContext) => Promise<UnifiedHookResult | string | Record<string, unknown>> | UnifiedHookResult | string | Record<string, unknown>;
|
|
11
|
+
export declare function runPromptHandler(ref: PromptHandlerRef, context: HandlerRuntimeContext, executor?: PromptExecutor): Promise<UnifiedHookResult>;
|
|
12
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/handlers/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAgD,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEpG,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,cAAc,GAAG,CAC3B,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1H,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,gBAAgB,EACrB,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAkC5B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runPromptHandler = runPromptHandler;
|
|
4
|
+
const errors_1 = require("../normalizer/errors");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
async function runPromptHandler(ref, context, executor) {
|
|
7
|
+
(0, shared_1.ensureDepth)(context.currentDepth, ref.maxDepth, 'prompt', 'prompt', 'PROMPT_DEPTH_EXCEEDED');
|
|
8
|
+
if (!executor) {
|
|
9
|
+
throw new errors_1.HandlerError('prompt handler requires an injected executor', {
|
|
10
|
+
source: 'prompt',
|
|
11
|
+
handler: 'prompt',
|
|
12
|
+
code: 'PROMPT_EXECUTOR_MISSING',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const result = await (0, shared_1.withTimeout)('prompt', 'prompt', context.timeoutMs, (signal) => executor({
|
|
17
|
+
prompt: ref.prompt,
|
|
18
|
+
model: ref.model,
|
|
19
|
+
systemPrompt: ref.systemPrompt,
|
|
20
|
+
maxOutputBytes: ref.maxOutputBytes,
|
|
21
|
+
}, { ...context, signal }));
|
|
22
|
+
return (0, shared_1.parseHandlerResult)(result);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err instanceof errors_1.HandlerError) {
|
|
26
|
+
throw err;
|
|
27
|
+
}
|
|
28
|
+
throw new errors_1.HandlerError(err instanceof Error ? err.message : String(err), {
|
|
29
|
+
source: 'prompt',
|
|
30
|
+
handler: 'prompt',
|
|
31
|
+
code: 'PROMPT_HANDLER_ERROR',
|
|
32
|
+
cause: err,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/handlers/prompt.ts"],"names":[],"mappings":";;AAiBA,4CAsCC;AArDD,iDAAoD;AACpD,qCAAoG;AAc7F,KAAK,UAAU,gBAA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../types/event';
|
|
2
|
+
import type { UnifiedHookResult } from '../types/result';
|
|
3
|
+
export interface HandlerRuntimeContext {
|
|
4
|
+
event: UnifiedHookEvent;
|
|
5
|
+
timeoutMs: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
currentDepth: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function parseHandlerResult(value: unknown): UnifiedHookResult;
|
|
10
|
+
export declare function ensureDepth(currentDepth: number, maxDepth: number | undefined, source: string, handler: string, code: string): void;
|
|
11
|
+
export declare function withTimeout<T>(source: string, handler: string, timeoutMs: number, operation: (signal: AbortSignal) => Promise<T> | T): Promise<T>;
|
|
12
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/handlers/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAkBpE;AAED,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAQnI;AAED,wBAAsB,WAAW,CAAC,CAAC,EACjC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACjD,OAAO,CAAC,CAAC,CAAC,CAoBZ"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseHandlerResult = parseHandlerResult;
|
|
4
|
+
exports.ensureDepth = ensureDepth;
|
|
5
|
+
exports.withTimeout = withTimeout;
|
|
6
|
+
const errors_1 = require("../normalizer/errors");
|
|
7
|
+
function parseHandlerResult(value) {
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
|
+
const trimmed = value.trim();
|
|
10
|
+
if (trimmed.length === 0) {
|
|
11
|
+
return { decision: 'noop' };
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(trimmed);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return { decision: 'noop', reason: trimmed };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (value && typeof value === 'object') {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
return { decision: 'noop', reason: value == null ? undefined : String(value) };
|
|
24
|
+
}
|
|
25
|
+
function ensureDepth(currentDepth, maxDepth, source, handler, code) {
|
|
26
|
+
const limit = maxDepth ?? 1;
|
|
27
|
+
if (currentDepth >= limit) {
|
|
28
|
+
throw new errors_1.HandlerError(`Handler ${source}:${handler} exceeded maxDepth ${limit}`, { source, handler, code });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function withTimeout(source, handler, timeoutMs, operation) {
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
let timeout;
|
|
34
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
35
|
+
timeout = setTimeout(() => {
|
|
36
|
+
controller.abort();
|
|
37
|
+
reject(new errors_1.HandlerTimeoutError({ source, handler, timeoutMs }));
|
|
38
|
+
}, timeoutMs);
|
|
39
|
+
});
|
|
40
|
+
try {
|
|
41
|
+
return await Promise.race([Promise.resolve(operation(controller.signal)), timeoutPromise]);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
if (controller.signal.aborted || (err instanceof Error && err.name === 'AbortError')) {
|
|
45
|
+
throw new errors_1.HandlerTimeoutError({ source, handler, timeoutMs });
|
|
46
|
+
}
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
clearTimeout(timeout);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/handlers/shared.ts"],"names":[],"mappings":";;AAWA,gDAkBC;AAED,kCAQC;AAED,kCAyBC;AAhED,iDAAyE;AASzE,SAAgB,kBAAkB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,OAAO,KAA0B,CAAC;IACpC,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACjF,CAAC;AAED,SAAgB,WAAW,CAAC,YAAoB,EAAE,QAA4B,EAAE,MAA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Y,CAAC,OAAQ,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
export { CANONICAL_PHASES, LIFECYCLE_SCOPES } from './types/lifecycle';
|
|
1
2
|
export type { CanonicalPhase, LifecycleScope, PhaseMapping, SupportLevel } from './types/lifecycle';
|
|
2
3
|
export type { UnifiedHookEvent, UnifiedExecutionContext } from './types/event';
|
|
3
4
|
export type { UnifiedHookResult } from './types/result';
|
|
4
|
-
export type { AdapterCapabilities } from './types/adapter';
|
|
5
|
-
export type {
|
|
5
|
+
export type { AdapterCapabilities, HostToolAvailability, HostToolCategory, HostToolDescriptor, } from './types/adapter';
|
|
6
|
+
export type { AgentHandlerRef, CommandHandlerRef, HandlerRef, HandlerType, HookPlanEntry, HttpHandlerRef, McpToolHandlerRef, PromptHandlerRef, } from './types/plan';
|
|
6
7
|
export type { SessionState, ContextFragment } from './types/session';
|
|
7
8
|
export { normalizeEvent, resolvePhaseMapping, splitEnv, resolveHookPlan, sortHandlers, evaluateWhen, getNestedValue, runHandler, runPlan, HandlerError, HandlerTimeoutError, NormalizationError, } from './normalizer';
|
|
8
|
-
export type { NormalizeOptions, PlanResolverOptions,
|
|
9
|
+
export type { ErrorPolicy, HandlerExecutionOptions, HandlerExecutors, NormalizeOptions, PlanResolverOptions, RunPlanOptions, } from './normalizer';
|
|
9
10
|
export { SESSION_SCHEMA_VERSION, getSessionDir, loadSession, saveSession, deleteSession, updateSession, addContextFragment, acquireLock, releaseLock, getDefaultSessionDir, getSessionFilePath, SESSION_PID_MARKER_ENV_VAR, isSessionPidMarkerEnabled, findHarnessAncestorPid, writeSessionMarker, readSessionMarker, cleanupSessionMarker, getSessionMarkerPath, } from './session-store';
|
|
10
11
|
export { mergeResults, MergeConflictError, type MergeOptions, type MergedExecutionResult, type DecisionVerb, type MergeDiagnostics, type MergeConflict, type DegradedField, createDiagnostics, recordConflict, recordDegradedField, } from './merge-engine';
|
|
11
12
|
export { buildExportEnvFileLines, materializeExecContext, generateTempEnvFile, escapeShellValue, getTrackedTempFiles, cleanupTempFiles, adaptOutput, propagateEnv, } from './propagation';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACpG,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACpG,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC/E,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,UAAU,EACV,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,kB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Y,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EACL,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.HookOutputParseError = exports.serializeResult = exports.serializeEvent = exports.isInHooksProxyContext = exports.readExecutionContext = exports.HookResultBuilder = exports.HookEventBuilder = exports.validateHookEvent = exports.validateHookResult = exports.parseHookEvent = exports.parseHookResult = exports.createHooksEngine = exports.detectHarness = exports.runNormalized = exports.registerHandler = void 0;
|
|
3
|
+
exports.generateTraceId = exports.createTraceWriter = exports.TraceWriter = exports.createDiagnosticLogger = exports.DiagnosticLogger = exports.propagateEnv = exports.adaptOutput = exports.cleanupTempFiles = exports.getTrackedTempFiles = exports.escapeShellValue = exports.generateTempEnvFile = exports.materializeExecContext = exports.buildExportEnvFileLines = exports.recordDegradedField = exports.recordConflict = exports.createDiagnostics = exports.MergeConflictError = exports.mergeResults = exports.getSessionMarkerPath = exports.cleanupSessionMarker = exports.readSessionMarker = exports.writeSessionMarker = exports.findHarnessAncestorPid = exports.isSessionPidMarkerEnabled = exports.SESSION_PID_MARKER_ENV_VAR = exports.getSessionFilePath = exports.getDefaultSessionDir = exports.releaseLock = exports.acquireLock = exports.addContextFragment = exports.updateSession = exports.deleteSession = exports.saveSession = exports.loadSession = exports.getSessionDir = exports.SESSION_SCHEMA_VERSION = exports.NormalizationError = exports.HandlerTimeoutError = exports.HandlerError = exports.runPlan = exports.runHandler = exports.getNestedValue = exports.evaluateWhen = exports.sortHandlers = exports.resolveHookPlan = exports.splitEnv = exports.resolvePhaseMapping = exports.normalizeEvent = exports.LIFECYCLE_SCOPES = exports.CANONICAL_PHASES = void 0;
|
|
4
|
+
exports.HookOutputParseError = exports.serializeResult = exports.serializeEvent = exports.isInHooksProxyContext = exports.readExecutionContext = exports.HookResultBuilder = exports.HookEventBuilder = exports.validateHookEvent = exports.validateHookResult = exports.parseHookEvent = exports.parseHookResult = exports.createHooksEngine = exports.detectHarness = exports.runNormalized = exports.registerHandler = exports.createAdapter = exports.buildTraceRecord = void 0;
|
|
5
|
+
// Types
|
|
6
|
+
var lifecycle_1 = require("./types/lifecycle");
|
|
7
|
+
Object.defineProperty(exports, "CANONICAL_PHASES", { enumerable: true, get: function () { return lifecycle_1.CANONICAL_PHASES; } });
|
|
8
|
+
Object.defineProperty(exports, "LIFECYCLE_SCOPES", { enumerable: true, get: function () { return lifecycle_1.LIFECYCLE_SCOPES; } });
|
|
5
9
|
// Normalizer
|
|
6
10
|
var normalizer_1 = require("./normalizer");
|
|
7
11
|
Object.defineProperty(exports, "normalizeEvent", { enumerable: true, get: function () { return normalizer_1.normalizeEvent; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,QAAQ;AACR,+CAAuE;AAA9D,6GAAA,gB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AChB,0GAAA,WAAW,OAAA;AACX,2GAAA,YAAY,OAAA;AAYd,cAAc;AACd,6CAOuB;AANrB,+GAAA,gBAAgB,OAAA;AAChB,qHAAA,sBAAsB,OAAA;AACtB,0GAAA,WAAW,OAAA;AACX,gHAAA,iBAAiB,OAAA;AACjB,8GAAA,eAAe,OAAA;AACf,+GAAA,gBAAgB,OAAA;AAYlB,MAAM;AACN,6BAIe;AAHb,oGAAA,aAAa,OAAA;AACb,sGAAA,eAAe,OAAA;AACf,oGAAA,aAAa,OAAA;AAIf,YAAY;AACZ,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AAGtB,sBAAsB;AACtB,+CAEwB;AADtB,iHAAA,iBAAiB,OAAA;AAYnB,gBAAgB;AAChB,iDAYyB;AAXvB,gHAAA,eAAe,OAAA;AACf,+GAAA,cAAc,OAAA;AACd,mHAAA,kBAAkB,OAAA;AAClB,kHAAA,iBAAiB,OAAA;AACjB,iHAAA,gBAAgB,OAAA;AAChB,kHAAA,iBAAiB,OAAA;AACjB,qHAAA,oBAAoB,OAAA;AACpB,sHAAA,qBAAqB,OAAA;AACrB,+GAAA,cAAc,OAAA;AACd,gHAAA,eAAe,OAAA;AACf,qHAAA,oBAAoB,OAAA"}
|
|
@@ -12,7 +12,7 @@ export interface MergeOptions {
|
|
|
12
12
|
protectedPrefixes?: string[];
|
|
13
13
|
systemMessageStrategy?: 'concatenate' | 'keep-first';
|
|
14
14
|
}
|
|
15
|
-
export type DecisionVerb = 'deny' | 'ask' | 'allow' | 'continue' | 'noop';
|
|
15
|
+
export type DecisionVerb = 'deny' | 'block' | 'retry' | 'ask' | 'allow' | 'defer' | 'continue' | 'noop';
|
|
16
16
|
export interface MergedExecutionResult {
|
|
17
17
|
decision: DecisionVerb;
|
|
18
18
|
reason: string;
|
|
@@ -28,6 +28,9 @@ export interface MergedExecutionResult {
|
|
|
28
28
|
continueSession: boolean;
|
|
29
29
|
stopReason: string;
|
|
30
30
|
suppressOutput: boolean;
|
|
31
|
+
sessionTitle?: string;
|
|
32
|
+
reloadSkills?: boolean;
|
|
33
|
+
displayContent?: string;
|
|
31
34
|
followUpMessage: string;
|
|
32
35
|
metadata: Record<string, unknown>;
|
|
33
36
|
diagnostics: MergeDiagnostics;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/merge-engine/merge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AAMvB,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;IACvG,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,qBAAqB,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;CACtD;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/merge-engine/merge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AAMvB,MAAM,WAAW,YAAY;IAC3B,cAAc,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;IACvG,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,qBAAqB,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;CACtD;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG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