index.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * `@deepseek-ai/dsh-hook-protocol` — the shared core of the Claude Code / Codex
  3. * hook wire protocol. NOT a cordis plugin: it registers nothing and injects
  4. * nothing. It is a LIBRARY of dialect-neutral primitives the two bridge plugins
  5. * (`dsh-hooks-claude`, `dsh-hooks-codex`) import to avoid re-implementing the
  6. * identical halves of the protocol:
  7. *
  8. * - {@link matchesMatcher} — the matcher primitive (literal-or-regex by dialect).
  9. * - {@link runHook} + {@link parseHookOutput} — run a command hook via `ctx.bash`
  10. * (stdin payload + env) and decode its exit-code/stdout/stderr into a neutral
  11. * {@link HookOutput}.
  12. * - {@link mergeHookOutputs} — fold multiple matched hooks into one
  13. * most-restrictive {@link MergedHookOutcome} (deny > ask > allow).
  14. * - {@link appendHookInvoked} / {@link appendHookResult} — the log-only `hook/*`
  15. * session-event helpers (declaration-merged into `SessionEventMap`);
  16. * `appendHookResult` derives the durable `decision`/`stderrSummary` from the
  17. * {@link HookOutput} so the shared event's semantics live in one place.
  18. * - {@link createDetachedRuns} — quiescence tracking for the fire-and-forget
  19. * hook points: disposal aborts and drains a bridge's detached runs.
  20. *
  21. * Each bridge owns what genuinely DIFFERS: building the per-event stdin payload
  22. * (CC vs Codex field sets), the dialect's env/substitution, and mapping the
  23. * neutral outcome onto the harness's seam-specific typed Decisions.
  24. *
  25. * @module @deepseek-ai/dsh-hook-protocol
  26. */
  27. export type {
  28. CommandHook,
  29. HookDialect,
  30. HookOutput,
  31. MatcherGroup,
  32. MatcherMode,
  33. } from './types.ts'
  34. export { matchesMatcher } from './matcher.ts'
  35. export { parseHookOutput } from './codec.ts'
  36. export { DEFAULT_HOOK_TIMEOUT_MS, runHook } from './runner.ts'
  37. export type { RunHookOptions, RunHookResult } from './runner.ts'
  38. export { mergeHookOutputs } from './merge.ts'
  39. export type { MergedDecision, MergedHookOutcome } from './merge.ts'
  40. export { appendHookInvoked, appendHookResult, DEFAULT_STDERR_SUMMARY_MAX_CHARS, summarizeStderr } from './events.ts'
  41. export type { HookInvocation, HookResultRecord } from './events.ts'
  42. export { createDetachedRuns } from './detached.ts'
  43. export type { DetachedRuns } from './detached.ts'