From 000e7810296d6c0402eb3223a1ac22b3e04d4892 Mon Sep 17 00:00:00 2001 From: qin shuo Date: Fri, 4 Sep 2026 01:30:12 +0000 Subject: [PATCH] feat: declare OpenCode trace provider --- src/base/agent-plugin.ts | 5 +++++ src/main.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/base/agent-plugin.ts b/src/base/agent-plugin.ts index 4a8d686..66e1065 100644 --- a/src/base/agent-plugin.ts +++ b/src/base/agent-plugin.ts @@ -8,6 +8,7 @@ import { defineAgent, type HostProcesses, type JsonValue, + type TraceProviderDeclaration, } from "@ora-space/plugin-sdk"; /** @@ -112,6 +113,9 @@ export abstract class AgentPlugin { * handler module the same way `onStart` and friends are mounted above. */ effects: AgentEffectDefinition | undefined = undefined; + + /** Trace files this provider writes; Ora resolves these only for authorized consumers. */ + traceProviders: readonly TraceProviderDeclaration[] = []; } /** One entry of the flattened dispatch table, already bound to its plugin instance. */ @@ -150,6 +154,7 @@ export async function runAgentPlugin( | void | Promise, effects: plugin.effects, + traceProviders: plugin.traceProviders, }); const processes = createHostProcesses(definition); await plugin.onActivate({ pluginId: options.pluginId, processes }); diff --git a/src/main.ts b/src/main.ts index f042d91..4db18cc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,6 +4,7 @@ import type { AgentStartContext, HostProcesses, JsonValue, + TraceProviderDeclaration, } from "@ora-space/plugin-sdk"; import { AGENT_METHODS } from "@ora-space/plugin-sdk"; import { @@ -63,6 +64,15 @@ class OpenCodeAgentPlugin extends AgentPlugin { override readonly effects = this.#effects.definition; + /** The managed OpenCode trace logger writes one NDJSON file per provider session. */ + override readonly traceProviders: readonly TraceProviderDeclaration[] = [{ + providerId: "opencode", + format: "ora/trace.opencode-ndjson.v1", + root: "home", + directory: ".local/share/opencode/trace", + fileNameTemplate: "{provider_session_id}.ndjson", + }]; + override onActivate(context: PluginContext): void { console.info(`${context.pluginId} activated`); this.#processes = context.processes;