Skip to content

feat(zcode-plugin-langfuse): add Langfuse observability plugin - #11

Open
erlinerd wants to merge 13 commits into
zai-org:mainfrom
erlinerd:feat/langfuse-observability
Open

feat(zcode-plugin-langfuse): add Langfuse observability plugin#11
erlinerd wants to merge 13 commits into
zai-org:mainfrom
erlinerd:feat/langfuse-observability

Conversation

@erlinerd

@erlinerd erlinerd commented Sep 12, 2026

Copy link
Copy Markdown

Summary

Adds zcode-plugin-langfuse, a community ZCode Hook plugin that sends one
fail-open Langfuse trace named ZCode Turn per completed turn.

  • Tool calls are recorded as spans and the assistant response as a generation.
  • The plugin publishes only on Stop and reads only fields delivered by ZCode
    Hook stdin.
  • It never reads transcript files or collects hidden chain-of-thought.
  • Missing credentials, malformed input, local state errors, and Langfuse errors
    do not block ZCode.
  • Prompt, tool-input, and tool-output capture are independently switchable and
    size-bounded.

Update: official plugin template layout (2026-09-14, v0.2.3)

This head reworks the shipped plugin directory to match the official template
(zcode-plugins-official/example-plugin) layout, generated by the source
repository's unified build (npm run package:plugin) at source tag
v0.2.3
(commit 134b4fe):

  • plugins/zcode-plugin-langfuse/ now contains exactly 8 files:
    .zcode-plugin/plugin.json, .claude-plugin/plugin.json (identical copy),
    hooks/hooks.json (pointing at hooks/entry.mjs), the sealed
    hooks/entry.mjs esbuild bundle, README.md, README_CN.md, LICENSE,
    and THIRD_PARTY_NOTICES.md.
  • The payload/ nesting and the artifact package.json are gone. Verified
    with diff -r against the source build output: byte-for-byte identical.
  • Supersedes the 2026-09-13 update below: the entry point is now
    hooks/entry.mjs (official template path), not dist/hooks/entry.mjs;
    the artifacts/plugin-layout staging path no longer exists (the build now
    emits dist/plugins/<name>/ directly).

Marketplace registration (updated in this push)

  • Plugin directory: plugins/zcode-plugin-langfuse
  • Plugin version: 0.2.3
  • Category: developer-tools (moved from the proposed observability, which
    is not in the validator's allowed set)
  • The marketplace entry now carries description_i18n (en + zh-CN)
    deep-equal to .zcode-plugin/plugin.json, per the validator rule.
  • python3 scripts/validate.py on this head reports
    OK: 20 plugin(s) validated (exit 0); git diff --check is clean.

Review fixes

  • Process environment now overrides persisted plugin options, and persisted
    options are selected only for the exact ZCODE_PLUGIN_ID.
  • Langfuse endpoints are HTTPS-only; plaintext HTTP is rejected.
  • Every captured value, including truncation markers, stays within
    max_capture_chars.
  • README files document six process hooks, current-user permissions, config
    reads, local state writes, HTTPS network access, command-execution boundaries,
    and transcript/privacy boundaries.
  • THIRD_PARTY_NOTICES.md identifies langfuse 3.38.20,
    langfuse-core 3.38.20, and mustache 4.2.0, all MIT-licensed, with
    provenance links.

Provenance and side effects

  • Source repository: https://github.com/erlinerd/zcode-plugin-langfuse
  • The bundle inlines the official langfuse JavaScript SDK, so the catalog
    copy needs no runtime npm install; it talks to the same Langfuse HTTPS
    ingestion API through Node's built-in fetch.
  • Network access: HTTPS requests to the configured Langfuse endpoint, only for
    telemetry publishing.
  • Local writes: bounded per-session state under ZCODE_PLUGIN_DATA when
    available, or the ZCode plugin data fallback; state is cleaned up after a
    completed Stop.
  • Each of the six hooks runs node with the current user's permissions. The
    plugin does not spawn a shell or execute user commands.
  • License: MIT. No credentials, private prompts, transcripts, or Hook payloads
    are included.

Verification (2026-09-14, this head)

Catalog checkout:

  • python3 scripts/validate.pyOK: 20 plugin(s) validated
  • git diff --check clean; working tree clean
  • plugins/zcode-plugin-langfuse/ byte-identical to the source build output
    (diff -r)

Source repository (tag v0.2.3):

  • 29/29 tests pass, including a bundle-execution smoke (fail-open Stop hook
    returns {} and leaves zero state files) and a release-ZIP shape check
  • npm audit --omit=dev --audit-level=high → 0 vulnerabilities
  • Release workflow published the versioned ZIP + SHA-256 checksum

Runtime smoke (real ZCode session on the installed v0.2.3 build, verified via
the Langfuse API on 2026-09-14):

  • ZCode Turn traces at 11:10:52Z and 11:19:41Z, both with
    release=0.2.3, assistant GENERATION observation present, and one turn
    additionally carrying a tool SPAN; local state cleaned up after each
    Stop. No credentials, prompts, tool payloads, or transcripts were exposed
    during verification.

Earlier updates (history)

  • 2026-09-13: catalog-ready bundle layout replaced the hand-copied readable-JS
    snapshot (see below); superseded by the 2026-09-14 layout update above.
  • This push also carried the zcode-plugin-langfuse rename (v0.2.0) and later
    the v0.2.1 → v0.2.3 syncs.

Update: catalog-ready bundle layout (2026-09-13) — superseded

This section described the payload/dist/hooks/entry.mjs entry point and the
artifacts/plugin-layout staging path of the v0.2.1 build. Both are replaced
by the 2026-09-14 official-template layout above; kept for history.

Align with the source repository rename (erlinerd/zcode-plugin-langfuse):
- plugins/langfuse-observability -> plugins/zcode-plugin-langfuse
- plugin name, marketplace entry, and in-code identifiers
- version 0.1.1 -> 0.2.0 (plugin id change is breaking for installed copies)
@erlinerd erlinerd changed the title feat(langfuse-observability): add Langfuse observability plugin feat(zcode-plugin-langfuse): add Langfuse observability plugin Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant