@ghl-ai/aw 0.1.42-beta.21 → 0.1.42-beta.23
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/hooks/codex-home.mjs +12 -33
- package/hooks/shared-phase-scripts.mjs +47 -0
- package/package.json +1 -1
package/hooks/codex-home.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { join } from 'node:path';
|
|
|
2
2
|
|
|
3
3
|
import { getSupportedHarnessPhaseEntries } from '../hook-manifest.mjs';
|
|
4
4
|
import {
|
|
5
|
+
buildRegistryDelegatingPhaseScriptWithTelemetry,
|
|
5
6
|
buildReservedPhaseScript,
|
|
6
7
|
} from './shared-phase-scripts.mjs';
|
|
7
8
|
|
|
@@ -17,39 +18,17 @@ const CODEX_HOME_PHASE_BLUEPRINTS = {
|
|
|
17
18
|
scriptName: 'aw-session-start.sh',
|
|
18
19
|
scriptMarker: '# aw-managed: codex-global-session-start',
|
|
19
20
|
buildScriptContent() {
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
TARGETS=(
|
|
34
|
-
"$HOME/.aw_registry/platform/core/skills/using-aw-skills/hooks/session-start.sh"
|
|
35
|
-
"$HOME/.aw/.aw_registry/platform/core/skills/using-aw-skills/hooks/session-start.sh"
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
for target in "\${TARGETS[@]}"; do
|
|
39
|
-
if [[ -f "\$target" ]]; then
|
|
40
|
-
printf '%s' "$STDIN" | bash "\$target"
|
|
41
|
-
exit $?
|
|
42
|
-
fi
|
|
43
|
-
done
|
|
44
|
-
|
|
45
|
-
CONTEXT="# AW Session Context
|
|
46
|
-
|
|
47
|
-
WARNING: AW using-aw-skills hook not found in ~/.aw_registry. Run aw init or aw pull platform."
|
|
48
|
-
|
|
49
|
-
JSON_CONTEXT=$(printf '%s' "\$CONTEXT" | python3 -c 'import json, sys; print(json.dumps(sys.stdin.read()))')
|
|
50
|
-
|
|
51
|
-
echo "{\\"hookSpecificOutput\\":{\\"hookEventName\\":\\"SessionStart\\",\\"additionalContext\\":\${JSON_CONTEXT}}}"
|
|
52
|
-
`;
|
|
21
|
+
return buildRegistryDelegatingPhaseScriptWithTelemetry({
|
|
22
|
+
marker: this.scriptMarker,
|
|
23
|
+
phase: 'SessionStart',
|
|
24
|
+
targetCandidates: [
|
|
25
|
+
'$HOME/.aw_registry/platform/core/skills/using-aw-skills/hooks/session-start.sh',
|
|
26
|
+
'$HOME/.aw/.aw_registry/platform/core/skills/using-aw-skills/hooks/session-start.sh',
|
|
27
|
+
],
|
|
28
|
+
warningMessage: 'WARNING: AW using-aw-skills hook not found in ~/.aw_registry. Run aw init or aw pull platform.',
|
|
29
|
+
telemetryHookPath: '$HOME/.aw-ecc/scripts/hooks/aw-usage-session-start.js',
|
|
30
|
+
harnessEnv: 'codex',
|
|
31
|
+
});
|
|
53
32
|
},
|
|
54
33
|
buildEntry(command) {
|
|
55
34
|
return {
|
|
@@ -37,6 +37,53 @@ echo "{\\"hookSpecificOutput\\":{\\"hookEventName\\":\\"${phase}\\",\\"additiona
|
|
|
37
37
|
`;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export function buildRegistryDelegatingPhaseScriptWithTelemetry({
|
|
41
|
+
marker,
|
|
42
|
+
phase,
|
|
43
|
+
targetCandidates,
|
|
44
|
+
warningMessage,
|
|
45
|
+
telemetryHookPath,
|
|
46
|
+
harnessEnv,
|
|
47
|
+
}) {
|
|
48
|
+
const targetsBlock = targetCandidates
|
|
49
|
+
.map(target => ` "${target}"`)
|
|
50
|
+
.join('\n');
|
|
51
|
+
const escapedWarning = escapeDoubleQuotes(warningMessage);
|
|
52
|
+
|
|
53
|
+
return `#!/usr/bin/env bash
|
|
54
|
+
${marker}
|
|
55
|
+
set -euo pipefail
|
|
56
|
+
|
|
57
|
+
# Capture stdin so we can feed it to both telemetry and the AW router delegate.
|
|
58
|
+
STDIN=$(cat)
|
|
59
|
+
|
|
60
|
+
# Fire telemetry (non-blocking, all output suppressed).
|
|
61
|
+
TELEMETRY_HOOK="${telemetryHookPath}"
|
|
62
|
+
if [[ -f "$TELEMETRY_HOOK" ]] && command -v node >/dev/null 2>&1; then
|
|
63
|
+
printf '%s' "$STDIN" | AW_HARNESS=${harnessEnv} node "$TELEMETRY_HOOK" >/dev/null 2>&1 || true
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
TARGETS=(
|
|
67
|
+
${targetsBlock}
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
for target in "\${TARGETS[@]}"; do
|
|
71
|
+
if [[ -f "\$target" ]]; then
|
|
72
|
+
printf '%s' "$STDIN" | bash "\$target"
|
|
73
|
+
exit $?
|
|
74
|
+
fi
|
|
75
|
+
done
|
|
76
|
+
|
|
77
|
+
CONTEXT="# AW Session Context
|
|
78
|
+
|
|
79
|
+
${escapedWarning}"
|
|
80
|
+
|
|
81
|
+
JSON_CONTEXT=$(printf '%s' "\$CONTEXT" | python3 -c 'import json, sys; print(json.dumps(sys.stdin.read()))')
|
|
82
|
+
|
|
83
|
+
echo "{\\"hookSpecificOutput\\":{\\"hookEventName\\":\\"${phase}\\",\\"additionalContext\\":\${JSON_CONTEXT}}}"
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
|
|
40
87
|
export function buildDelegatingPhaseScript({
|
|
41
88
|
marker,
|
|
42
89
|
targetPath,
|