MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / hook

Function hook

packages/opencode-atomic-hooks/src/index.ts:88–115  ·  view source on GitHub ↗
(
    sessionID: string,
    verb: string,
    extra: Record<string, unknown> = {},
  )

Source from the content-addressed store, hash-verified

86 };
87
88 const hook = async (
89 sessionID: string,
90 verb: string,
91 extra: Record<string, unknown> = {},
92 ) => {
93 const payload = JSON.stringify({
94 session_id: sessionID,
95 cwd: directory,
96 timestamp: new Date().toISOString(),
97 ...extra,
98 });
99 try {
100 const result =
101 await $`echo ${payload} | ${ATOMIC} agent hooks opencode ${verb}`
102 .cwd(directory)
103 .quiet()
104 .nothrow();
105 const ok = result.exitCode === 0;
106 const stderr = result.stderr.toString().trim();
107 log(
108 `${verb} session=${sessionID} exit=${result.exitCode}${stderr ? " stderr=" + stderr : ""}`,
109 );
110 return ok;
111 } catch (err) {
112 log(`${verb} session=${sessionID} error=${err}`);
113 return false;
114 }
115 };
116
117 // Per-session state within this process lifetime
118 const sessions = new Map<

Callers 3

recordTurnFunction · 0.70
AtomicHooksPluginFunction · 0.70

Calls 2

$Function · 0.85
logFunction · 0.70

Tested by

no test coverage detected