ftown-bridge 0.30.9 → 0.30.10

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.
@@ -6,6 +6,15 @@ import type { HookAdapter, HookKind } from './hook-contract.js';
6
6
  * inert when no ftown session owns the process, and emits no stdout.
7
7
  */
8
8
  export declare const museSessionStartAdapter: HookAdapter;
9
+ /**
10
+ * notify.sh — Claude/Codex/Cursor passthrough (and Grok's notification event).
11
+ * Stdin is forwarded unchanged with typed identity fields appended; absent,
12
+ * invalid or non-object stdin produces a `{hook_event_name}` fallback body. It
13
+ * stands down for a Grok non-notification event carrying `hookEventName`, is
14
+ * inert when no session owns the process, never drains mail and never writes
15
+ * stdout. Deliberately involves no jq or curl.
16
+ */
17
+ export declare const notifyAdapter: HookAdapter;
9
18
  /**
10
19
  * Adapter registry. The four later porting tasks add one entry each and extend
11
20
  * IMPLEMENTED_HOOK_KINDS in the contract; they do not change the runner.
@@ -1,3 +1,5 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
1
3
  /**
2
4
  * Muse SessionStart — the end-to-end proof for the shared entry point.
3
5
  * Mirrors bridge/muse-plugin/lib/ftown-hook.sh: stdin is one JSON object whose
@@ -30,11 +32,101 @@ export const museSessionStartAdapter = async ({ input, env, post }) => {
30
32
  return { status: 'ok' };
31
33
  return { status: 'error', error: { kind: result.error.kind, message: result.error.message } };
32
34
  };
35
+ /**
36
+ * Resolve a session from `~/.ftown/session-registry.json` when no env session
37
+ * owns the process: `conversation_id` first, then `workspace_roots[0]`. Both
38
+ * keys are read from the injected HOME so an isolated hook environment cannot
39
+ * be redirected to the bridge process's home. Malformed/missing registries are
40
+ * inert, matching the old jq-based lookup.
41
+ */
42
+ function resolveRegistrySession(native, home) {
43
+ if (!home)
44
+ return undefined;
45
+ let parsed;
46
+ try {
47
+ parsed = JSON.parse(readFileSync(join(home, '.ftown', 'session-registry.json'), 'utf8'));
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
53
+ return undefined;
54
+ const registry = parsed;
55
+ const conversationId = native.conversation_id;
56
+ if (typeof conversationId === 'string' && conversationId) {
57
+ const byConversation = registry.byConversation;
58
+ if (byConversation && typeof byConversation === 'object' && !Array.isArray(byConversation)) {
59
+ const id = byConversation[conversationId];
60
+ if (typeof id === 'string' && id)
61
+ return { sessionId: id, source: 'conversation' };
62
+ }
63
+ }
64
+ const roots = native.workspace_roots;
65
+ const firstRoot = Array.isArray(roots) ? roots[0] : undefined;
66
+ if (typeof firstRoot === 'string' && firstRoot) {
67
+ const byWorkspace = registry.byWorkspace;
68
+ if (byWorkspace && typeof byWorkspace === 'object' && !Array.isArray(byWorkspace)) {
69
+ const id = byWorkspace[firstRoot];
70
+ if (typeof id === 'string' && id)
71
+ return { sessionId: id, source: 'workspace' };
72
+ }
73
+ }
74
+ return undefined;
75
+ }
76
+ /**
77
+ * notify.sh — Claude/Codex/Cursor passthrough (and Grok's notification event).
78
+ * Stdin is forwarded unchanged with typed identity fields appended; absent,
79
+ * invalid or non-object stdin produces a `{hook_event_name}` fallback body. It
80
+ * stands down for a Grok non-notification event carrying `hookEventName`, is
81
+ * inert when no session owns the process, never drains mail and never writes
82
+ * stdout. Deliberately involves no jq or curl.
83
+ */
84
+ export const notifyAdapter = async ({ input, env, post }) => {
85
+ let native;
86
+ try {
87
+ const parsed = JSON.parse(input);
88
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
89
+ native = parsed;
90
+ }
91
+ catch {
92
+ // Invalid JSON is not an error here: notify.sh forwards a fallback body.
93
+ }
94
+ // Grok runs Claude-compatible hooks too; its own hook handles its events.
95
+ // An inherited GROK_HOOK_EVENT must not silence Claude/Codex/Cursor, which
96
+ // do not send the camelCase hookEventName field.
97
+ if (env.GROK_HOOK_EVENT && env.GROK_HOOK_EVENT !== 'notification'
98
+ && native && typeof native.hookEventName === 'string' && native.hookEventName.length > 0) {
99
+ return { status: 'ok' };
100
+ }
101
+ let sessionId = env.FTOWN_SESSION_ID;
102
+ let source = sessionId ? 'env' : undefined;
103
+ if (!sessionId && native) {
104
+ const resolved = resolveRegistrySession(native, env.HOME);
105
+ if (resolved) {
106
+ sessionId = resolved.sessionId;
107
+ source = resolved.source;
108
+ }
109
+ }
110
+ if (!sessionId || !source)
111
+ return { status: 'ok' };
112
+ const payload = native
113
+ ? { ...native, ftown_session_id: sessionId, ftown_session_source: source }
114
+ : {
115
+ ftown_session_id: sessionId,
116
+ ftown_session_source: source,
117
+ hook_event_name: env.HOOK_EVENT_NAME || 'hook',
118
+ };
119
+ const result = await post(payload);
120
+ if (result.ok)
121
+ return { status: 'ok' };
122
+ return { status: 'error', error: { kind: result.error.kind, message: result.error.message } };
123
+ };
33
124
  /**
34
125
  * Adapter registry. The four later porting tasks add one entry each and extend
35
126
  * IMPLEMENTED_HOOK_KINDS in the contract; they do not change the runner.
36
127
  */
37
128
  export const HOOK_ADAPTERS = Object.freeze({
38
129
  'muse-session-start': museSessionStartAdapter,
130
+ notify: notifyAdapter,
39
131
  });
40
132
  //# sourceMappingURL=hook-adapters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hook-adapters.js","sourceRoot":"","sources":["../src/hook-adapters.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAgB,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE;IACjF,IAAI,CAAC,GAAG,CAAC,gBAAgB;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAEnD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAA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C;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAqD,MAAM,CAAC,MAAM,CAAC;IAC3F,oBAAoB,EAAE,uBAAuB;IAC7C,MAAM,EAAE,aAAa;CACtB,CAAC,CAAC"}
package/hooks/notify.sh CHANGED
@@ -1,80 +1,33 @@
1
- #!/bin/bash
2
- INPUT=$(cat)
3
- # Grok runs Claude-compatible hooks too; ~/.ftown/grok-hook.sh is its channel. Stand down only
4
- # when GROK_HOOK_EVENT is set and is not "notification" (the Grok script does not forward that
5
- # event) AND the payload has a string hookEventName (Grok always sends it; Claude, Codex and
6
- # Cursor do not, so an inherited variable does not silence them).
7
- if [ -n "${GROK_HOOK_EVENT:-}" ] && [ "${GROK_HOOK_EVENT}" != "notification" ] \
8
- && printf '%s' "$INPUT" | jq -e '(.hookEventName | type) == "string" and (.hookEventName | length) > 0' >/dev/null 2>&1; then
9
- exit 0
10
- fi
11
-
12
- PORT="${FTOWN_HOOK_PORT:-}"
13
- SESSION_ID="${FTOWN_SESSION_ID:-}"
14
- TOKEN="${FTOWN_HOOK_TOKEN:-}"
15
- SOURCE=""
16
-
17
- BRIDGE_JSON="${FTOWN_BRIDGE_POINTER:-${HOME}/.ftown/bridge.json}"
18
- REGISTRY="${HOME}/.ftown/session-registry.json"
1
+ #!/usr/bin/env bash
2
+ # Compatibility shim for the installed notify hook. The real hook is the typed
3
+ # Node entry point `ftown-harness hook notify`; this file only locates it and
4
+ # execs it. No jq, curl, session lookup or network logic lives here.
5
+ set -u
6
+
7
+ # A stale install must never block its agent: report the drop on stderr and
8
+ # exit 0. Stderr is visible in the harness hook log; the event is simply lost.
9
+ stale() {
10
+ printf '%s\n' "ftown notify hook: $1 (notify event not delivered)" >&2
11
+ }
19
12
 
20
- if [ -z "$PORT" ] && [ -f "$BRIDGE_JSON" ]; then
21
- PORT=$(jq -r '.port // empty' "$BRIDGE_JSON" 2>/dev/null)
22
- if [ -z "$TOKEN" ]; then
23
- TOKEN=$(jq -r '.token // empty' "$BRIDGE_JSON" 2>/dev/null)
24
- fi
13
+ harness="${FTOWN_HARNESS:-}"
14
+ if [ -z "$harness" ] && [ -n "${HOME:-}" ] && [ -x "${HOME}/.ftown/bin/ftown-harness" ]; then
15
+ harness="${HOME}/.ftown/bin/ftown-harness"
25
16
  fi
26
-
27
- if [ -n "$SESSION_ID" ]; then
28
- SOURCE="env"
29
- elif [ -n "$INPUT" ]; then
30
- CONV=$(echo "$INPUT" | jq -r '.conversation_id // empty' 2>/dev/null)
31
- WS=$(echo "$INPUT" | jq -r '.workspace_roots[0] // empty' 2>/dev/null)
32
- if [ -f "$REGISTRY" ]; then
33
- if [ -n "$CONV" ]; then
34
- SESSION_ID=$(jq -r --arg c "$CONV" '.byConversation[$c] // empty' "$REGISTRY" 2>/dev/null)
35
- if [ -n "$SESSION_ID" ]; then
36
- SOURCE="conversation"
37
- fi
38
- fi
39
- if [ -z "$SESSION_ID" ] && [ -n "$WS" ]; then
40
- SESSION_ID=$(jq -r --arg w "$WS" '.byWorkspace[$w] // empty' "$REGISTRY" 2>/dev/null)
41
- if [ -n "$SESSION_ID" ]; then
42
- SOURCE="workspace"
43
- fi
44
- fi
45
- fi
17
+ if [ -z "$harness" ]; then
18
+ harness="$(command -v ftown-harness 2>/dev/null || true)"
46
19
  fi
47
20
 
48
- if [ -z "$PORT" ] || [ -z "$SESSION_ID" ]; then
21
+ if [ -z "$harness" ] || [ ! -x "$harness" ]; then
22
+ stale "ftown-harness is missing"
49
23
  exit 0
50
24
  fi
51
-
52
- PAYLOAD=$(echo "$INPUT" | jq -c --arg sid "$SESSION_ID" --arg src "$SOURCE" \
53
- '. + {ftown_session_id: $sid, ftown_session_source: $src}' 2>/dev/null)
54
- if [ -z "$PAYLOAD" ]; then
55
- PAYLOAD=$(jq -nc --arg sid "$SESSION_ID" --arg src "$SOURCE" --arg ev "${HOOK_EVENT_NAME:-hook}" \
56
- '{ftown_session_id: $sid, ftown_session_source: $src, hook_event_name: $ev}')
25
+ # Older ftown-harness builds have no 'hook' command; their CLI would print an
26
+ # "unknown command" error and exit non-zero. Probe first so an old install
27
+ # still exits 0 and leaves a clear, visible reason in the hook log.
28
+ if ! "$harness" hook --help >/dev/null 2>&1; then
29
+ stale "installed ftown-harness has no 'hook' command; upgrade ftown"
30
+ exit 0
57
31
  fi
58
32
 
59
- post_hook() {
60
- local port="$1" token="$2"
61
- local auth=()
62
- if [ -n "$token" ]; then
63
- auth=(-H "Authorization: Bearer ${token}")
64
- fi
65
- curl -sf -X POST "http://localhost:${port}/hook" \
66
- -H "Content-Type: application/json" \
67
- "${auth[@]}" \
68
- -d "$PAYLOAD" > /dev/null 2>&1
69
- }
70
-
71
- if ! post_hook "$PORT" "$TOKEN" && [ -f "$BRIDGE_JSON" ]; then
72
- # Env vars are stale inside tmux sessions that outlive their bridge; the
73
- # current bridge rewrites bridge.json with the live port/token on startup.
74
- BPORT=$(jq -r '.port // empty' "$BRIDGE_JSON" 2>/dev/null)
75
- BTOKEN=$(jq -r '.token // empty' "$BRIDGE_JSON" 2>/dev/null)
76
- if [ -n "$BPORT" ] && { [ "$BPORT" != "$PORT" ] || [ "$BTOKEN" != "$TOKEN" ]; }; then
77
- post_hook "$BPORT" "$BTOKEN"
78
- fi
79
- fi
80
- exit 0
33
+ exec "$harness" hook notify "$@"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ftown-bridge",
3
- "version": "0.30.9",
3
+ "version": "0.30.10",
4
4
  "description": "CLI bridge for ftown — generic PTY-over-Centrifugo relay",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -73,5 +73,5 @@
73
73
  "overrides": {
74
74
  "qs": "6.16.1"
75
75
  },
76
- "gitHead": "bdd7bea519e49874334ae2efcc136723e4de5401"
76
+ "gitHead": "4d168141763c8f7605f4c3a88c9ced235d7a69f5"
77
77
  }