feat: TypeScript SDK (agentlens-sdk) and OpenCode plugin (opencode-agentlens)
- packages/sdk-ts: BatchTransport, TraceBuilder, models, decision helpers Zero external deps, native fetch, ESM+CJS output - packages/opencode-plugin: OpenCode plugin with hooks for: - Session lifecycle (create/idle/error/delete/diff) - Tool execution capture (before/after -> TOOL_CALL spans + TOOL_SELECTION decisions) - LLM call tracking (chat.message -> LLM_CALL spans with model/provider) - Permission flow (permission.ask -> ESCALATION decisions) - File edit events - Model cost estimation (Claude, GPT-4o, o3-mini pricing)
This commit is contained in:
41
packages/opencode-plugin/src/config.ts
Normal file
41
packages/opencode-plugin/src/config.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
export interface PluginConfig {
|
||||
apiKey: string;
|
||||
endpoint: string;
|
||||
enabled: boolean;
|
||||
/** Opt-in: capture full message content in traces */
|
||||
captureContent: boolean;
|
||||
/** Maximum characters for tool output before truncation */
|
||||
maxOutputLength: number;
|
||||
/** Milliseconds between automatic flushes */
|
||||
flushInterval: number;
|
||||
/** Maximum traces per batch */
|
||||
maxBatchSize: number;
|
||||
}
|
||||
|
||||
export function loadConfig(): PluginConfig {
|
||||
const apiKey = process.env["AGENTLENS_API_KEY"] ?? "";
|
||||
|
||||
if (!apiKey) {
|
||||
console.warn(
|
||||
"[agentlens] AGENTLENS_API_KEY not set — plugin will be disabled",
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
apiKey,
|
||||
endpoint:
|
||||
process.env["AGENTLENS_ENDPOINT"] ?? "https://agentlens.vectry.tech",
|
||||
enabled: (process.env["AGENTLENS_ENABLED"] ?? "true") === "true",
|
||||
captureContent:
|
||||
(process.env["AGENTLENS_CAPTURE_CONTENT"] ?? "false") === "true",
|
||||
maxOutputLength: parseInt(
|
||||
process.env["AGENTLENS_MAX_OUTPUT_LENGTH"] ?? "2000",
|
||||
10,
|
||||
),
|
||||
flushInterval: parseInt(
|
||||
process.env["AGENTLENS_FLUSH_INTERVAL"] ?? "5000",
|
||||
10,
|
||||
),
|
||||
maxBatchSize: parseInt(process.env["AGENTLENS_BATCH_SIZE"] ?? "10", 10),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user