@a5c-ai/hooks-mux-adapter-copilot 5.0.1-staging.37ca18bd

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.
@@ -0,0 +1,14 @@
1
+ import type { AdapterCapabilities } from '@a5c-ai/hooks-mux-core';
2
+ /**
3
+ * Creates the GitHub Copilot adapter with its capability metadata.
4
+ *
5
+ * Key characteristics:
6
+ * - Shell-hook family (stdin JSON / stdout JSON)
7
+ * - Synthetic session ID (no stable native session ID exposed)
8
+ * - Pre-tool deny is the only blocking path
9
+ * - Session-start output is ignored by Copilot CLI
10
+ * - permissionDecision supports allow|deny|ask in schema but only deny is processed
11
+ * - Many hook outputs are ignored on non-preTool events
12
+ */
13
+ export declare function createAdapter(): AdapterCapabilities;
14
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,IAAI,mBAAmB,CAmBnD"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAdapter = createAdapter;
4
+ /**
5
+ * Creates the GitHub Copilot adapter with its capability metadata.
6
+ *
7
+ * Key characteristics:
8
+ * - Shell-hook family (stdin JSON / stdout JSON)
9
+ * - Synthetic session ID (no stable native session ID exposed)
10
+ * - Pre-tool deny is the only blocking path
11
+ * - Session-start output is ignored by Copilot CLI
12
+ * - permissionDecision supports allow|deny|ask in schema but only deny is processed
13
+ * - Many hook outputs are ignored on non-preTool events
14
+ */
15
+ function createAdapter() {
16
+ return {
17
+ name: 'copilot',
18
+ family: 'shell-hook',
19
+ sessionIdQuality: 'synthetic',
20
+ supportsOrderedFanout: true,
21
+ supportsNativeAdditionalContext: false,
22
+ supportsBlock: true, // pre-tool deny only
23
+ supportsAsk: false,
24
+ supportsToolInputMutation: false,
25
+ supportsToolResultMutation: false,
26
+ supportsPersistedEnv: false,
27
+ envPersistenceMode: 'wrapper_only',
28
+ toolInterceptionScope: 'all',
29
+ notes: [
30
+ 'session-start output ignored',
31
+ 'only deny processed for permissionDecision',
32
+ ],
33
+ };
34
+ }
35
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;AAaA,sCAmBC;AA9BD;;;;;;;;;;GAUG;AACH,SAAgB,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,YAAY;QACpB,gBAAgB,EAAE,WAAW;QAC7B,qBAAqB,EAAE,IAAI;QAC3B,+BAA+B,EAAE,KAAK;QACtC,aAAa,EAAE,IAAI,EAAE,qBAAqB;QAC1C,WAAW,EAAE,KAAK;QAClB,yBAAyB,EAAE,KAAK;QAChC,0BAA0B,EAAE,KAAK;QACjC,oBAAoB,EAAE,KAAK;QAC3B,kBAAkB,EAAE,cAAc;QAClC,qBAAqB,EAAE,KAAK;QAC5B,KAAK,EAAE;YACL,8BAA8B;YAC9B,4CAA4C;SAC7C;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { createAdapter } from './adapter';
2
+ export { COPILOT_PHASE_MAPPINGS, getMappingByNativeHook, getMappingByPhase } from './mappings';
3
+ export { parseStdin, normalizeCopilotEvent } from './normalizer';
4
+ export type { CopilotRawInput } from './normalizer';
5
+ export { renderCopilotOutput, serializeOutput } from './renderer';
6
+ export type { CopilotPreToolOutput, CopilotNoopOutput, CopilotNativeOutput } from './renderer';
7
+ export { resolveSyntheticSessionId } from './session-resolver';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSyntheticSessionId = exports.serializeOutput = exports.renderCopilotOutput = exports.normalizeCopilotEvent = exports.parseStdin = exports.getMappingByPhase = exports.getMappingByNativeHook = exports.COPILOT_PHASE_MAPPINGS = exports.createAdapter = void 0;
4
+ var adapter_1 = require("./adapter");
5
+ Object.defineProperty(exports, "createAdapter", { enumerable: true, get: function () { return adapter_1.createAdapter; } });
6
+ var mappings_1 = require("./mappings");
7
+ Object.defineProperty(exports, "COPILOT_PHASE_MAPPINGS", { enumerable: true, get: function () { return mappings_1.COPILOT_PHASE_MAPPINGS; } });
8
+ Object.defineProperty(exports, "getMappingByNativeHook", { enumerable: true, get: function () { return mappings_1.getMappingByNativeHook; } });
9
+ Object.defineProperty(exports, "getMappingByPhase", { enumerable: true, get: function () { return mappings_1.getMappingByPhase; } });
10
+ var normalizer_1 = require("./normalizer");
11
+ Object.defineProperty(exports, "parseStdin", { enumerable: true, get: function () { return normalizer_1.parseStdin; } });
12
+ Object.defineProperty(exports, "normalizeCopilotEvent", { enumerable: true, get: function () { return normalizer_1.normalizeCopilotEvent; } });
13
+ var renderer_1 = require("./renderer");
14
+ Object.defineProperty(exports, "renderCopilotOutput", { enumerable: true, get: function () { return renderer_1.renderCopilotOutput; } });
15
+ Object.defineProperty(exports, "serializeOutput", { enumerable: true, get: function () { return renderer_1.serializeOutput; } });
16
+ var session_resolver_1 = require("./session-resolver");
17
+ Object.defineProperty(exports, "resolveSyntheticSessionId", { enumerable: true, get: function () { return session_resolver_1.resolveSyntheticSessionId; } });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,uCAA+F;AAAtF,kHAAA,sBAAsB,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAC1E,2CAAiE;AAAxD,wGAAA,UAAU,OAAA;AAAE,mHAAA,qBAAqB,OAAA;AAE1C,uCAAkE;AAAzD,+GAAA,mBAAmB,OAAA;AAAE,2GAAA,eAAe,OAAA;AAE7C,uDAA+D;AAAtD,6HAAA,yBAAyB,OAAA"}
@@ -0,0 +1,20 @@
1
+ import type { PhaseMapping } from '@a5c-ai/hooks-mux-core';
2
+ /**
3
+ * Copilot native hook names mapped to canonical lifecycle phases.
4
+ *
5
+ * GitHub Copilot CLI exposes these hook events:
6
+ * - sessionStart / sessionEnd -> session lifecycle
7
+ * - userPromptSubmitted -> turn lifecycle
8
+ * - preToolUse / postToolUse -> tool lifecycle
9
+ * - error -> turn error
10
+ */
11
+ export declare const COPILOT_PHASE_MAPPINGS: PhaseMapping[];
12
+ /**
13
+ * Lookup a phase mapping by native hook name.
14
+ */
15
+ export declare function getMappingByNativeHook(nativeHook: string): PhaseMapping | undefined;
16
+ /**
17
+ * Lookup a phase mapping by canonical phase.
18
+ */
19
+ export declare function getMappingByPhase(phase: string): PhaseMapping | undefined;
20
+ //# sourceMappingURL=mappings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mappings.d.ts","sourceRoot":"","sources":["../src/mappings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAAY,EAsDhD,CAAC;AAEF;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEnF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEzE"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COPILOT_PHASE_MAPPINGS = void 0;
4
+ exports.getMappingByNativeHook = getMappingByNativeHook;
5
+ exports.getMappingByPhase = getMappingByPhase;
6
+ /**
7
+ * Copilot native hook names mapped to canonical lifecycle phases.
8
+ *
9
+ * GitHub Copilot CLI exposes these hook events:
10
+ * - sessionStart / sessionEnd -> session lifecycle
11
+ * - userPromptSubmitted -> turn lifecycle
12
+ * - preToolUse / postToolUse -> tool lifecycle
13
+ * - error -> turn error
14
+ */
15
+ exports.COPILOT_PHASE_MAPPINGS = [
16
+ {
17
+ canonicalPhase: 'session.start',
18
+ nativeHook: 'sessionStart',
19
+ supportLevel: 'native',
20
+ blockCapability: false, // output is ignored
21
+ mutationCapability: false,
22
+ scope: 'session',
23
+ notes: 'Session-start output is ignored by Copilot CLI; observer-only plus session-store init',
24
+ },
25
+ {
26
+ canonicalPhase: 'session.end',
27
+ nativeHook: 'sessionEnd',
28
+ supportLevel: 'native',
29
+ blockCapability: false,
30
+ mutationCapability: false,
31
+ scope: 'session',
32
+ },
33
+ {
34
+ canonicalPhase: 'turn.user_prompt_submitted',
35
+ nativeHook: 'userPromptSubmitted',
36
+ supportLevel: 'native',
37
+ blockCapability: false, // output ignored
38
+ mutationCapability: false,
39
+ scope: 'turn',
40
+ notes: 'Output ignored on this event; observer-only',
41
+ },
42
+ {
43
+ canonicalPhase: 'tool.before',
44
+ nativeHook: 'preToolUse',
45
+ supportLevel: 'native',
46
+ blockCapability: true, // deny is processed
47
+ mutationCapability: false,
48
+ scope: 'tool',
49
+ notes: 'permissionDecision supports allow|deny|ask in schema but only deny is processed',
50
+ },
51
+ {
52
+ canonicalPhase: 'tool.after',
53
+ nativeHook: 'postToolUse',
54
+ supportLevel: 'native',
55
+ blockCapability: false,
56
+ mutationCapability: false,
57
+ scope: 'tool',
58
+ notes: 'Output ignored on non-preTool events',
59
+ },
60
+ {
61
+ canonicalPhase: 'turn.error',
62
+ nativeHook: 'errorOccurred',
63
+ supportLevel: 'native',
64
+ blockCapability: false,
65
+ mutationCapability: false,
66
+ scope: 'turn',
67
+ notes: 'Error reporting; output ignored',
68
+ },
69
+ ];
70
+ /**
71
+ * Lookup a phase mapping by native hook name.
72
+ */
73
+ function getMappingByNativeHook(nativeHook) {
74
+ return exports.COPILOT_PHASE_MAPPINGS.find((m) => m.nativeHook === nativeHook);
75
+ }
76
+ /**
77
+ * Lookup a phase mapping by canonical phase.
78
+ */
79
+ function getMappingByPhase(phase) {
80
+ return exports.COPILOT_PHASE_MAPPINGS.find((m) => m.canonicalPhase === phase);
81
+ }
82
+ //# sourceMappingURL=mappings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mappings.js","sourceRoot":"","sources":["../src/mappings.ts"],"names":[],"mappings":";;;AAsEA,wDAEC;AAKD,8CAEC;AA7ED;;;;;;;;GAQG;AACU,QAAA,sBAAsB,GAAmB;IACpD;QACE,cAAc,EAAE,eAAe;QAC/B,UAAU,EAAE,cAAc;QAC1B,YAAY,EAAE,QAAQ;QACtB,eAAe,EAAE,KAAK,EAAE,oBAAoB;QAC5C,kBAAkB,EAAE,KAAK;QACzB,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,uFAAuF;KAC/F;IACD;QACE,cAAc,EAAE,aAAa;QAC7B,UAAU,EAAE,YAAY;QACxB,YAAY,EAAE,QAAQ;QACtB,eAAe,EAAE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@a5c-ai/hooks-mux-core';
2
+ /**
3
+ * Shape of raw Copilot stdin JSON for hook events.
4
+ *
5
+ * Copilot delivers JSON on stdin with at least these fields.
6
+ * Additional fields vary by event type.
7
+ */
8
+ export interface CopilotRawInput {
9
+ /** The native hook event name (e.g. 'sessionStart', 'preToolUse'). */
10
+ event?: string;
11
+ /** Working directory at time of invocation. */
12
+ cwd?: string;
13
+ /** Workspace or project root path. */
14
+ workspace?: string;
15
+ /** User prompt text (on userPromptSubmitted). */
16
+ prompt?: string;
17
+ /** Tool name (on preToolUse / postToolUse). */
18
+ toolName?: string;
19
+ /** Tool call ID (on preToolUse / postToolUse). */
20
+ toolCallId?: string;
21
+ /** Tool input data (on preToolUse). */
22
+ toolInput?: unknown;
23
+ /** Tool response data (on postToolUse). */
24
+ toolResponse?: unknown;
25
+ /** Error message (on error events). */
26
+ error?: string;
27
+ /** Arbitrary additional fields. */
28
+ [key: string]: unknown;
29
+ }
30
+ /**
31
+ * Parse raw stdin string into a CopilotRawInput.
32
+ *
33
+ * Returns null if the input is empty or unparseable.
34
+ */
35
+ export declare function parseStdin(raw: string): CopilotRawInput | null;
36
+ /**
37
+ * Normalize a raw Copilot hook input into a UnifiedHookEvent.
38
+ *
39
+ * @param rawInput - Parsed JSON from stdin
40
+ * @param nativeEventName - The native event name (from stdin or CLI flag)
41
+ * @param env - Environment variables at invocation
42
+ */
43
+ export declare function normalizeCopilotEvent(rawInput: CopilotRawInput, nativeEventName: string, env?: Record<string, string>): UnifiedHookEvent;
44
+ //# sourceMappingURL=normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../src/normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAa9D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,EACzB,eAAe,EAAE,MAAM,EACvB,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC/B,gBAAgB,CAmClB"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseStdin = parseStdin;
4
+ exports.normalizeCopilotEvent = normalizeCopilotEvent;
5
+ const hooks_mux_core_1 = require("@a5c-ai/hooks-mux-core");
6
+ const mappings_1 = require("./mappings");
7
+ const session_resolver_1 = require("./session-resolver");
8
+ /**
9
+ * Parse raw stdin string into a CopilotRawInput.
10
+ *
11
+ * Returns null if the input is empty or unparseable.
12
+ */
13
+ function parseStdin(raw) {
14
+ const trimmed = raw.trim();
15
+ if (!trimmed)
16
+ return null;
17
+ try {
18
+ const parsed = JSON.parse(trimmed);
19
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
20
+ return null;
21
+ }
22
+ return parsed;
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ }
28
+ /**
29
+ * Normalize a raw Copilot hook input into a UnifiedHookEvent.
30
+ *
31
+ * @param rawInput - Parsed JSON from stdin
32
+ * @param nativeEventName - The native event name (from stdin or CLI flag)
33
+ * @param env - Environment variables at invocation
34
+ */
35
+ function normalizeCopilotEvent(rawInput, nativeEventName, env = {}) {
36
+ // Derive session ID: check env overrides, then synthesize from cwd/workspace
37
+ const sessionId = env['AGENT_SESSION_ID'] ??
38
+ env['HOOKS_PROXY_SESSION_ID'] ??
39
+ (0, session_resolver_1.resolveSyntheticSessionId)(rawInput.cwd, rawInput.workspace);
40
+ // Build enriched env with session context
41
+ const enrichedEnv = {
42
+ ...env,
43
+ HOOKS_PROXY_SESSION_ID: sessionId,
44
+ };
45
+ if (rawInput.cwd) {
46
+ enrichedEnv['HOOKS_PROXY_CWD'] = rawInput.cwd;
47
+ }
48
+ if (rawInput.toolName) {
49
+ enrichedEnv['HOOKS_PROXY_TOOL_NAME'] = rawInput.toolName;
50
+ }
51
+ if (rawInput.toolCallId) {
52
+ enrichedEnv['HOOKS_PROXY_TOOL_CALL_ID'] = rawInput.toolCallId;
53
+ }
54
+ // Build payload from raw input, preserving native detail
55
+ const payload = { ...rawInput };
56
+ // Remove the event field from payload since it's the event name
57
+ delete payload['event'];
58
+ return (0, hooks_mux_core_1.normalizeEvent)({
59
+ adapter: 'copilot',
60
+ rawEventName: nativeEventName,
61
+ stdinPayload: payload,
62
+ env: enrichedEnv,
63
+ adapterMappings: mappings_1.COPILOT_PHASE_MAPPINGS,
64
+ });
65
+ }
66
+ //# sourceMappingURL=normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.js","sourceRoot":"","sources":["../src/normalizer.ts"],"names":[],"mappings":";;AAuCA,gCAaC;AASD,sDAuCC;AAnGD,2DAAwD;AACxD,yCAAoD;AACpD,yDAA+D;AA+B/D;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,C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CAAC;IAExB,OAAO,IAAA,+BAAc,EAAC;QACpB,OAAO,EAAE,SAAS;QAClB,YAAY,EAAE,eAAe;QAC7B,YAAY,EAAE,OAAO;QACrB,GAAG,EAAE,WAAW;QAChB,eAAe,EAAE,iCAAsB;KACxC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { MergedExecutionResult } from '@a5c-ai/hooks-mux-core';
2
+ /**
3
+ * Copilot native output shape for pre-tool-use hooks.
4
+ *
5
+ * Only the preTool event actually processes output.
6
+ * permissionDecision supports allow|deny|ask in the schema,
7
+ * but only deny is currently processed by Copilot CLI.
8
+ */
9
+ export interface CopilotPreToolOutput {
10
+ permissionDecision?: 'allow' | 'deny' | 'ask';
11
+ reason?: string;
12
+ }
13
+ /**
14
+ * Copilot native output shape for all other events.
15
+ * Output is ignored by Copilot CLI on non-preTool events,
16
+ * so we emit a minimal success object.
17
+ */
18
+ export interface CopilotNoopOutput {
19
+ ok: true;
20
+ }
21
+ export type CopilotNativeOutput = CopilotPreToolOutput | CopilotNoopOutput;
22
+ /**
23
+ * Render a merged execution result into Copilot-native JSON output.
24
+ *
25
+ * Copilot only processes output on preTool events (permissionDecision: deny).
26
+ * All other events get a no-op success response since their output is ignored.
27
+ *
28
+ * @param mergedResult - The merged result from hook handler execution
29
+ * @param nativeEventName - The original native event name
30
+ * @returns JSON-serializable native output
31
+ */
32
+ export declare function renderCopilotOutput(mergedResult: MergedExecutionResult, nativeEventName: string): CopilotNativeOutput;
33
+ /**
34
+ * Serialize Copilot native output to a stdout-ready JSON string.
35
+ */
36
+ export declare function serializeOutput(output: CopilotNativeOutput): string;
37
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGpE;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,kBAAkB,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,IAAI,CAAC;CACV;AAED,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAE3E;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,qBAAqB,EACnC,eAAe,EAAE,MAAM,GACtB,mBAAmB,CAUrB;AAuBD;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAEnE"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderCopilotOutput = renderCopilotOutput;
4
+ exports.serializeOutput = serializeOutput;
5
+ const mappings_1 = require("./mappings");
6
+ /**
7
+ * Render a merged execution result into Copilot-native JSON output.
8
+ *
9
+ * Copilot only processes output on preTool events (permissionDecision: deny).
10
+ * All other events get a no-op success response since their output is ignored.
11
+ *
12
+ * @param mergedResult - The merged result from hook handler execution
13
+ * @param nativeEventName - The original native event name
14
+ * @returns JSON-serializable native output
15
+ */
16
+ function renderCopilotOutput(mergedResult, nativeEventName) {
17
+ const mapping = (0, mappings_1.getMappingByNativeHook)(nativeEventName);
18
+ // Only preTool events can block
19
+ if (mapping?.blockCapability && nativeEventName === 'preToolUse') {
20
+ return renderPreToolOutput(mergedResult);
21
+ }
22
+ // All other events: output is ignored by Copilot
23
+ return { ok: true };
24
+ }
25
+ /**
26
+ * Render output for preTool events.
27
+ *
28
+ * Maps the unified decision to Copilot's permissionDecision field.
29
+ * Only 'deny' is actually processed by Copilot CLI.
30
+ */
31
+ function renderPreToolOutput(mergedResult) {
32
+ const output = {};
33
+ if (mergedResult.decision === 'deny') {
34
+ output.permissionDecision = 'deny';
35
+ if (mergedResult.reason) {
36
+ output.reason = mergedResult.reason;
37
+ }
38
+ }
39
+ // allow and ask are in the schema but not processed;
40
+ // omit permissionDecision to let Copilot proceed with default behavior
41
+ return output;
42
+ }
43
+ /**
44
+ * Serialize Copilot native output to a stdout-ready JSON string.
45
+ */
46
+ function serializeOutput(output) {
47
+ return JSON.stringify(output);
48
+ }
49
+ //# sourceMappingURL=renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":";;AAoCA,kDAaC;AA0BD,0CAEC;AA5ED,yCAAoD;AAyBpD;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CACjC,YAAmC,EACnC,eAAuB;IAEvB,MAAM,OAAO,GAAG,IAAA,iCAAsB,EAAC,eAAe,CAAC,CAAC;IAExD,gCAAgC;IAChC,IAAI,OAAO,EAAE,eAAe,IAAI,eAAe,KAAK,YAAY,EAAE,CAAC;QACjE,OAAO,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAC3C,CAAC;IAED,iDAAiD;IACjD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,YAAmC;IAC9D,MAAM,MAAM,GAAyB,EAAE,CAAC;IAExC,IAAI,YAAY,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QACrC,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC;QACnC,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;QACtC,CAAC;IACH,CAAC;IACD,qDAAqD;IACrD,uEAAuE;IAEvE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,MAA2B;IACzD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Resolve a synthetic session ID for GitHub Copilot.
3
+ *
4
+ * Copilot CLI does not expose a stable native session ID.
5
+ * We derive a deterministic synthetic ID from cwd + workspace,
6
+ * producing a stable session key for a given project context.
7
+ *
8
+ * Derivation strategy:
9
+ * - Primary key: workspace path (if available), else cwd
10
+ * - Hashed with SHA-256 to produce a fixed-length, filesystem-safe ID
11
+ * - Prefixed with 'copilot-' for easy identification
12
+ *
13
+ * This means all sessions in the same workspace share context,
14
+ * which is acceptable since Copilot hooks are short-lived.
15
+ * The session store handles timestamp-based staleness if needed.
16
+ *
17
+ * @param cwd - Current working directory
18
+ * @param workspace - Workspace or project root path
19
+ * @returns A deterministic synthetic session ID string
20
+ */
21
+ export declare function resolveSyntheticSessionId(cwd?: string, workspace?: string): string;
22
+ //# sourceMappingURL=session-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-resolver.d.ts","sourceRoot":"","sources":["../src/session-resolver.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,CAAC,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAKR"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSyntheticSessionId = resolveSyntheticSessionId;
4
+ const crypto_1 = require("crypto");
5
+ /**
6
+ * Resolve a synthetic session ID for GitHub Copilot.
7
+ *
8
+ * Copilot CLI does not expose a stable native session ID.
9
+ * We derive a deterministic synthetic ID from cwd + workspace,
10
+ * producing a stable session key for a given project context.
11
+ *
12
+ * Derivation strategy:
13
+ * - Primary key: workspace path (if available), else cwd
14
+ * - Hashed with SHA-256 to produce a fixed-length, filesystem-safe ID
15
+ * - Prefixed with 'copilot-' for easy identification
16
+ *
17
+ * This means all sessions in the same workspace share context,
18
+ * which is acceptable since Copilot hooks are short-lived.
19
+ * The session store handles timestamp-based staleness if needed.
20
+ *
21
+ * @param cwd - Current working directory
22
+ * @param workspace - Workspace or project root path
23
+ * @returns A deterministic synthetic session ID string
24
+ */
25
+ function resolveSyntheticSessionId(cwd, workspace) {
26
+ const key = workspace ?? cwd ?? 'unknown';
27
+ const normalized = normalizePath(key);
28
+ const hash = (0, crypto_1.createHash)('sha256').update(`copilot:${normalized}`).digest('hex').slice(0, 16);
29
+ return `copilot-${hash}`;
30
+ }
31
+ /**
32
+ * Normalize a file path for consistent hashing across platforms.
33
+ * Lowercases on Windows-style paths and normalizes separators.
34
+ */
35
+ function normalizePath(p) {
36
+ // Normalize backslashes to forward slashes
37
+ let normalized = p.replace(/\\/g, '/');
38
+ // Remove trailing slash
39
+ normalized = normalized.replace(/\/$/, '');
40
+ // Lowercase drive letter on Windows paths (e.g. C:/ -> c:/)
41
+ if (/^[A-Z]:\//.test(normalized)) {
42
+ normalized = normalized[0].toLowerCase() + normalized.slice(1);
43
+ }
44
+ return normalized;
45
+ }
46
+ //# sourceMappingURL=session-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-resolver.js","sourceRoot":"","sources":["../src/session-resolver.ts"],"names":[],"mappings":";;AAsBA,8DAQC;AA9BD,mCAAoC;AAEpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,yBAAyB,CACvC,GAAY,EACZ,SAAkB;IAElB,MAAM,GAAG,GAAG,SAAS,IAAI,GAAG,IAAI,SAAS,CAAC;IAC1C,MAAM,UAAU,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7F,OAAO,WAAW,IAAI,EAAE,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,CAAS;IAC9B,2CAA2C;IAC3C,IAAI,UAAU,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvC,wBAAwB;IACxB,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3C,4DAA4D;IAC5D,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@a5c-ai/hooks-mux-adapter-copilot",
3
+ "version": "5.0.1-staging.37ca18bd",
4
+ "description": "GitHub Copilot harness adapter for the hooks-mux system",
5
+ "license": "UNLICENSED",
6
+ "type": "commonjs",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/a5c-ai/babysitter.git",
15
+ "directory": "packages/hooks-mux/adapter-copilot"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json",
22
+ "clean": "rimraf dist",
23
+ "lint": "eslint \"src/**/*.ts\" --max-warnings=0",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest"
26
+ },
27
+ "dependencies": {
28
+ "@a5c-ai/hooks-mux-core": "5.0.1-staging.37ca18bd"
29
+ },
30
+ "devDependencies": {
31
+ "typescript": "^5.7.0",
32
+ "vitest": "^3.0.0",
33
+ "rimraf": "^6.0.0"
34
+ }
35
+ }