refactor: cleanup shared constants and add async SDK support for isCallerOrchestrator

- Use shared OPENCODE_STORAGE, MESSAGE_STORAGE, PART_STORAGE constants
- Make isCallerOrchestrator async with SDK fallback for beta
- Fix cache implementation using Symbol sentinel
- Update atlas hooks and sisyphus-junior-notepad to use async isCallerOrchestrator
This commit is contained in:
YeonGyu-Kim
2026-02-14 19:24:30 +09:00
parent 1bb5a3a037
commit 068831f79e
8 changed files with 31 additions and 27 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ export function createAtlasHook(ctx: PluginInput, options?: AtlasHookOptions) {
return {
handler: createAtlasEventHandler({ ctx, options, sessions, getState }),
"tool.execute.before": createToolExecuteBeforeHandler({ pendingFilePaths }),
"tool.execute.before": createToolExecuteBeforeHandler({ ctx, pendingFilePaths }),
"tool.execute.after": createToolExecuteAfterHandler({ ctx, pendingFilePaths }),
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ export function createToolExecuteAfterHandler(input: {
return
}
if (!isCallerOrchestrator(toolInput.sessionID)) {
if (!(await isCallerOrchestrator(toolInput.sessionID, ctx.client))) {
return
}
+4 -2
View File
@@ -1,21 +1,23 @@
import { log } from "../../shared/logger"
import { SYSTEM_DIRECTIVE_PREFIX } from "../../shared/system-directive"
import { isCallerOrchestrator } from "../../shared/session-utils"
import type { PluginInput } from "@opencode-ai/plugin"
import { HOOK_NAME } from "./hook-name"
import { ORCHESTRATOR_DELEGATION_REQUIRED, SINGLE_TASK_DIRECTIVE } from "./system-reminder-templates"
import { isSisyphusPath } from "./sisyphus-path"
import { isWriteOrEditToolName } from "./write-edit-tool-policy"
export function createToolExecuteBeforeHandler(input: {
ctx: PluginInput
pendingFilePaths: Map<string, string>
}): (
toolInput: { tool: string; sessionID?: string; callID?: string },
toolOutput: { args: Record<string, unknown>; message?: string }
) => Promise<void> {
const { pendingFilePaths } = input
const { ctx, pendingFilePaths } = input
return async (toolInput, toolOutput): Promise<void> => {
if (!isCallerOrchestrator(toolInput.sessionID)) {
if (!(await isCallerOrchestrator(toolInput.sessionID, ctx.client))) {
return
}