neatlogs 1.0.8 → 1.0.9

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.
@@ -4,34 +4,35 @@
4
4
  * opencode loads plugins from its config (`opencode.json` → `"plugin": [...]`)
5
5
  * or from local `.opencode/plugin/*.ts` files. A plugin is an async factory that
6
6
  * receives an app context and returns lifecycle hooks. This plugin instruments
7
- * opencode automatically — no per-call wiring — translating opencode's run into
7
+ * opencode automatically — no per-call wiring — turning an opencode session into
8
8
  * a neatlogs span tree:
9
9
  *
10
- * LLM assistant turn (from `message.updated` completion events)
11
- * TOOL tool execution (tool.execute.before tool.execute.after)
10
+ * AGENT opencode.session (one per user turn; parents that turn's spans)
11
+ * ↳ LLM assistant turn (per completed assistant message)
12
+ * ↳ TOOL tool execution (tool.execute.before → tool.execute.after)
12
13
  *
13
14
  * Every span carries `neatlogs.conversation.id` = the opencode session ID.
14
15
  *
16
+ * Export model (mirrors @raindrop-ai/opencode-plugin and neatlogs-claude-code):
17
+ * opencode loads the plugin in-process but `opencode run` is short-lived. Rather
18
+ * than the OpenTelemetry BatchSpanProcessor (whose async, scheduled-delay export
19
+ * + `beforeExit` shutdown races the teardown and drops spans), this plugin builds
20
+ * spans directly and ships them via AWAITED `fetch(POST /v1/traces)` — and it
21
+ * flushes after every completed assistant turn (incremental persistence) plus a
22
+ * final flush on `session.idle`. A `neatlogs.trace.complete` marker is sent so
23
+ * the backend enqueues the trace for finalization (simplification → UI).
24
+ *
15
25
  * Setup — either:
16
- * • npm package, in opencode.json: `{ "plugin": ["neatlogs"] }`, OR
17
- * • local file `.opencode/plugin/neatlogs.ts` (project) or
18
- * `~/.config/opencode/plugin/neatlogs.ts` (global):
26
+ * • npm package, in opencode.json: `{ "plugin": ["neatlogs/opencode"] }`, OR
27
+ * • local file `.opencode/plugin/neatlogs.ts`:
19
28
  * export { NeatlogsOpencodePlugin as default } from 'neatlogs/opencode';
20
29
  *
21
- * Then set NEATLOGS_API_KEY in the environment. The plugin bootstraps neatlogs
22
- * tracing on load (it runs inside opencode's own process, so it initializes the
23
- * SDK itself rather than relying on a user `init()` call).
24
- *
25
- * Optional env:
30
+ * Env:
26
31
  * NEATLOGS_API_KEY required to export
32
+ * NEATLOGS_ENDPOINT backend base URL (default https://staging-cloud.neatlogs.com)
27
33
  * NEATLOGS_WORKFLOW_NAME logical grouping (default: "opencode")
28
34
  * NEATLOGS_CAPTURE_SYSTEM_PROMPT=true capture system prompt text (default off)
29
35
  */
30
- /**
31
- * opencode Plugin factory. opencode calls this with its app context and uses the
32
- * returned hook object. Typed loosely to avoid a hard dependency on
33
- * `@opencode-ai/plugin`.
34
- */
35
36
  declare const NeatlogsOpencodePlugin: (_ctx: any) => Promise<Record<string, any>>;
36
37
  declare const neatlogsOpencodePlugin: (_ctx: any) => Promise<Record<string, any>>;
37
38