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

Function hook

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

Source from the content-addressed store, hash-verified

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

Callers 2

recordTurnFunction · 0.85
AtomicHooksPluginFunction · 0.85

Calls 1

logFunction · 0.70

Tested by

no test coverage detected