diff options
| author | qer <wbxl2000@outlook.com> | 2026-06-04 18:52:29 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-04 13:52:29 +0300 |
| commit | 66b0f6b2d6e1c63c3a7aa0d26cff91cf750232aa (patch) | |
| tree | c114ee4571705357540d7df3ac94349234c77ff3 /src/integration/assets | |
| parent | cb18fe52b55f1a627387c829074e9d24b9cefb28 (diff) | |
feat: add kimi code cli integration (#463)
* feat: add kimi code cli integration
refs #431
* fix: improve kimi code screen detection
refs #431
Diffstat (limited to 'src/integration/assets')
| -rw-r--r-- | src/integration/assets/kimi/herdr-agent-state.sh | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/integration/assets/kimi/herdr-agent-state.sh b/src/integration/assets/kimi/herdr-agent-state.sh new file mode 100644 index 00000000..3e0a9c29 --- /dev/null +++ b/src/integration/assets/kimi/herdr-agent-state.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# installed by herdr +# managed by herdr; reinstalling or updating the integration overwrites this file. +# add custom hooks beside this file instead of editing it. +# HERDR_INTEGRATION_ID=kimi +# HERDR_INTEGRATION_VERSION=1 + +set -eu + +action="${1:-}" +cat >/dev/null 2>/dev/null || true + +case "$action" in + working|idle|blocked|release) ;; + *) exit 0 ;; +esac + +[ "${HERDR_ENV:-}" = "1" ] || exit 0 +[ -n "${HERDR_SOCKET_PATH:-}" ] || exit 0 +[ -n "${HERDR_PANE_ID:-}" ] || exit 0 +command -v python3 >/dev/null 2>&1 || exit 0 + +HERDR_ACTION="$action" python3 - <<'PY' +import json +import os +import random +import socket +import time + +source = "herdr:kimi" +action = os.environ.get("HERDR_ACTION", "") +pane_id = os.environ.get("HERDR_PANE_ID") +socket_path = os.environ.get("HERDR_SOCKET_PATH") + +if not pane_id or not socket_path: + raise SystemExit(0) + +request_id = f"{source}:{int(time.time() * 1000)}:{random.randrange(1_000_000):06d}" +report_seq = time.time_ns() +if action == "release": + request = { + "id": request_id, + "method": "pane.release_agent", + "params": { + "pane_id": pane_id, + "source": source, + "agent": "kimi", + "seq": report_seq, + }, + } +else: + request = { + "id": request_id, + "method": "pane.report_agent", + "params": { + "pane_id": pane_id, + "source": source, + "agent": "kimi", + "state": action, + "seq": report_seq, + }, + } + +try: + client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + client.settimeout(0.5) + client.connect(socket_path) + client.sendall((json.dumps(request) + "\n").encode()) + try: + client.recv(4096) + except Exception: + pass + client.close() +except Exception: + pass +PY |
