@slayzone/computer 0.36.0-beta.21 → 0.36.0
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/dist/bin.cjs +6 -6
- package/dist/bin.cjs.map +2 -2
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -4778,10 +4778,10 @@ var init_agent_hooks = __esm({
|
|
|
4778
4778
|
}
|
|
4779
4779
|
});
|
|
4780
4780
|
|
|
4781
|
-
// raw-import:/tmp/slz-publish-wt.
|
|
4781
|
+
// raw-import:/tmp/slz-publish-wt.vI4qKd/packages/shared/hooks/src/notify.sh
|
|
4782
4782
|
var notify_default;
|
|
4783
4783
|
var init_notify = __esm({
|
|
4784
|
-
"raw-import:/tmp/slz-publish-wt.
|
|
4784
|
+
"raw-import:/tmp/slz-publish-wt.vI4qKd/packages/shared/hooks/src/notify.sh"() {
|
|
4785
4785
|
notify_default = `#!/bin/sh
|
|
4786
4786
|
# SlayZone agent lifecycle hook \u2014 BENIGN DUMB FORWARDER.
|
|
4787
4787
|
#
|
|
@@ -4825,7 +4825,7 @@ var init_notify = __esm({
|
|
|
4825
4825
|
#
|
|
4826
4826
|
# Required env (injected at PTY/chat spawn by buildMcpEnv):
|
|
4827
4827
|
# SLAYZONE_AGENT_HOOK_URL - target URL, e.g. http://127.0.0.1:PORT/api/agent-hook
|
|
4828
|
-
# (a remote
|
|
4828
|
+
# (a remote computer overlays its OWN loopback URL)
|
|
4829
4829
|
# SLAYZONE_AGENT_ID - claude-code | codex | gemini | antigravity | opencode
|
|
4830
4830
|
# Optional:
|
|
4831
4831
|
# SLAYZONE_AGENT_HOOK_CONTEXT - opaque identity blob (see above); sent as \`ctx\`
|
|
@@ -4918,7 +4918,7 @@ ENVELOPE="{\\"ctx\\":$CTX,\\"raw\\":$RAW_FIELD,\\"arg\\":$ARG_FIELD,\\"agentId\\
|
|
|
4918
4918
|
# curl is the primary path \u2014 present on macOS, most Linux, and bundled with
|
|
4919
4919
|
# Git for Windows (whose bash runs this script). wget is a fallback for minimal
|
|
4920
4920
|
# environments; if neither exists the POST is skipped silently. NO auth header:
|
|
4921
|
-
# the target is always loopback (local sidecar, or the
|
|
4921
|
+
# the target is always loopback (local sidecar, or the computer's own loopback),
|
|
4922
4922
|
# so no per-agent bearer is ever attached.
|
|
4923
4923
|
if command -v curl >/dev/null 2>&1; then
|
|
4924
4924
|
curl -s \\
|
|
@@ -4943,10 +4943,10 @@ exit 0
|
|
|
4943
4943
|
}
|
|
4944
4944
|
});
|
|
4945
4945
|
|
|
4946
|
-
// raw-import:/tmp/slz-publish-wt.
|
|
4946
|
+
// raw-import:/tmp/slz-publish-wt.vI4qKd/packages/shared/hooks/src/opencode-plugin.js
|
|
4947
4947
|
var opencode_plugin_default;
|
|
4948
4948
|
var init_opencode_plugin = __esm({
|
|
4949
|
-
"raw-import:/tmp/slz-publish-wt.
|
|
4949
|
+
"raw-import:/tmp/slz-publish-wt.vI4qKd/packages/shared/hooks/src/opencode-plugin.js"() {
|
|
4950
4950
|
opencode_plugin_default = "// SlayZone opencode plugin v1\n//\n// Forwards OpenCode SDK session lifecycle events to the SlayZone agent-hook\n// notify script over a local shell exec. Plugin is loaded by OpenCode from\n// ${XDG_CONFIG_HOME:-~/.config}/opencode/plugin/slayzone-notify.js\n//\n// The {{NOTIFY_PATH}} placeholder is substituted by the SlayZone installer\n// (packages/apps/app/src/main/agent-hooks/opencode-plugin-installer.ts) at\n// install time with the absolute path to `~/.slayzone/hooks/notify.sh`.\n//\n// Behavior:\n// - No-op when SLAYZONE_TASK_ID is unset (plugin only fires inside SlayZone PTYs).\n// - Subagent (child session) events are suppressed \u2014 oh-my-opencode + similar\n// tools spawn many child sessions and would otherwise flap Start/Stop.\n// - On client.session.list() error, sessions are assumed CHILD (safer to\n// suppress than emit a false-positive Start/Stop).\n// - Handles both modern (session.status w/ nested type) and legacy\n// (session.busy / session.idle) event shapes for forward compat.\n// - Singleton guard prevents double-load if OpenCode re-imports the plugin.\n\nexport const SlayzoneNotifyPlugin = async ({ $, client }) => {\n if (globalThis.__slayzoneOpencodePluginV1) return {}\n globalThis.__slayzoneOpencodePluginV1 = true\n if (!process?.env?.SLAYZONE_TASK_ID) return {}\n\n const notifyPath = '{{NOTIFY_PATH}}'\n let currentState = 'idle' // 'idle' | 'busy'\n let rootSessionID = null // first non-child session we see\n let stopSent = false // dedup Stop emits\n const childSessionCache = new Map() // sessionID -> isChild bool\n\n const notify = async (eventName) => {\n const payload = JSON.stringify({ hook_event_name: eventName })\n try {\n await $`bash ${notifyPath} ${payload}`\n } catch {\n // Hook failures must never bubble into the OpenCode TUI.\n }\n }\n\n const isChildSession = async (sessionID) => {\n if (!sessionID) return true\n if (!client?.session?.list) return true\n if (childSessionCache.has(sessionID)) return childSessionCache.get(sessionID)\n try {\n const sessions = await client.session.list()\n const session = sessions.data?.find((s) => s.id === sessionID)\n const isChild = !!session?.parentID\n childSessionCache.set(sessionID, isChild)\n return isChild\n } catch {\n // On error, assume CHILD \u2014 safer than emitting a false-positive Start/Stop.\n return true\n }\n }\n\n const handleBusy = async (sessionID) => {\n if (!rootSessionID) rootSessionID = sessionID\n if (sessionID !== rootSessionID) return\n if (currentState === 'idle') {\n currentState = 'busy'\n stopSent = false\n await notify('Start')\n }\n }\n\n const handleStop = async (sessionID) => {\n if (rootSessionID && sessionID !== rootSessionID) return\n if (currentState === 'busy' && !stopSent) {\n currentState = 'idle'\n stopSent = true\n await notify('Stop')\n rootSessionID = null // reset for next session\n }\n }\n\n return {\n event: async ({ event }) => {\n const sessionID = event.properties?.sessionID ?? event.properties?.info?.id ?? null\n\n if (event.type === 'session.created') {\n const isChild = Boolean(event.properties?.info?.parentID)\n if (sessionID) childSessionCache.set(sessionID, isChild)\n if (!isChild) await notify('SessionStart')\n return\n }\n\n if (event.type === 'session.deleted') {\n const cached = sessionID ? childSessionCache.get(sessionID) : undefined\n const isChild = cached !== undefined ? cached : await isChildSession(sessionID)\n if (!isChild) await notify('SessionEnd')\n if (sessionID) childSessionCache.delete(sessionID)\n return\n }\n\n if (await isChildSession(sessionID)) return\n\n if (event.type === 'session.status') {\n const status = event.properties?.status\n if (status?.type === 'busy') await handleBusy(sessionID)\n else if (status?.type === 'idle') await handleStop(sessionID)\n }\n // Backwards-compat: some OpenCode versions emit busy/idle as top-level events.\n if (event.type === 'session.busy') await handleBusy(sessionID)\n if (event.type === 'session.idle') await handleStop(sessionID)\n if (event.type === 'session.error') await handleStop(sessionID)\n },\n 'permission.ask': async (_permission, output) => {\n if (output.status === 'ask') await notify('PermissionRequest')\n }\n }\n}\n";
|
|
4951
4951
|
}
|
|
4952
4952
|
});
|