wormclaude 1.0.19 → 1.0.20

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.
package/dist/api.js CHANGED
@@ -4,6 +4,7 @@
4
4
  import { loadStored, DEFAULT_BASE_URL } from './auth.js';
5
5
  import { StreamingToolCallParser } from './streamparser.js';
6
6
  import { safeJsonStringify } from './safejson.js';
7
+ import { getTrace, getSession } from './telemetry.js';
7
8
  export function loadConfig() {
8
9
  const stored = loadStored();
9
10
  return {
@@ -124,6 +125,7 @@ export async function* streamChat(messages, tools, config, signal) {
124
125
  headers: {
125
126
  'Content-Type': 'application/json',
126
127
  ...(config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}),
128
+ ...(getTrace() ? { 'X-WC-Trace': getTrace(), 'X-WC-Session': getSession() } : {}),
127
129
  },
128
130
  body: JSON.stringify(body),
129
131
  signal,
package/dist/cli.js CHANGED
@@ -5,6 +5,7 @@ import TextInput from 'ink-text-input';
5
5
  import * as path from 'node:path';
6
6
  import { theme, VERSION } from './theme.js';
7
7
  import { loadConfig, streamChat, fetchAccount } from './api.js';
8
+ import { newTrace, flushTelemetry } from './telemetry.js';
8
9
  import { tier } from './program.js';
9
10
  import { allToolSchemas, executeToolCalls, executeTool, toolLabel, setToolConfig } from './tools.js';
10
11
  import { sanitizeError, sanitizeOutput } from './errorsan.js';
@@ -518,6 +519,7 @@ function App() {
518
519
  const ac = new AbortController();
519
520
  abortRef.current = ac;
520
521
  setBusy(true);
522
+ newTrace(); // observability: bu tur için yeni dağıtık-trace id (gateway + tool span'ları birleşir)
521
523
  push({ kind: 'user', text: displayText ?? userText });
522
524
  historyRef.current = [...historyRef.current, { role: 'user', content: userText }];
523
525
  let iter = 0;
@@ -675,6 +677,8 @@ function App() {
675
677
  // Oto-hafıza: eşik geçildiyse arka planda hafızayı güncelle
676
678
  if (shouldExtract(historyRef.current))
677
679
  triggerMemory(historyRef.current, config);
680
+ // Observability: bu turun CLI span'larını (tool/skill/agent) gateway'e yolla — best-effort.
681
+ flushTelemetry(config.baseUrl, config.apiKey);
678
682
  }
679
683
  async function onSubmit(value) {
680
684
  let v = value.trim();
@@ -0,0 +1,37 @@
1
+ // Observability — istemci-tarafı dağıtık tracing. CLI kendi span'larını (tool/skill/agent/memory)
2
+ // gateway'e POST /v1/telemetry ile yollar; gateway kendi span'larını AYNI trace_id ile yazar →
3
+ // admin panelinde birleşik waterfall. trace_id ayrıca X-WC-Trace header'ı ile her isteğe gider.
4
+ let currentTrace = '';
5
+ let buffer = [];
6
+ const sessionId = 's-' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
7
+ const rid = () => Math.random().toString(36).slice(2, 8);
8
+ /** Yeni tur başında çağrılır — yeni trace_id üretir, tamponu temizler. */
9
+ export function newTrace() {
10
+ currentTrace = 't-' + Date.now().toString(36) + rid();
11
+ buffer = [];
12
+ return currentTrace;
13
+ }
14
+ export function getTrace() { return currentTrace; }
15
+ export function getSession() { return sessionId; }
16
+ /** Bir span ekle (tampona). type: tool_called/tool_failed/skill_selected/agent_spawned/memory_summary_created… */
17
+ export function emit(type, attrs = {}, duration_ms = 0, status = 'ok') {
18
+ if (!currentTrace)
19
+ return;
20
+ buffer.push({ type, span_id: rid(), duration_ms: Math.round(duration_ms), status, ts: Date.now() / 1000, attrs });
21
+ }
22
+ /** Tampondaki span'ları gateway'e gönder (tur sonunda). Hata sessizce yutulur. */
23
+ export async function flushTelemetry(baseUrl, apiKey) {
24
+ if (!currentTrace || buffer.length === 0)
25
+ return;
26
+ const events = buffer;
27
+ buffer = [];
28
+ try {
29
+ await fetch(`${baseUrl}/telemetry`, {
30
+ method: 'POST',
31
+ headers: { 'Content-Type': 'application/json', ...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}) },
32
+ body: JSON.stringify({ trace_id: currentTrace, session_id: sessionId, events }),
33
+ signal: AbortSignal.timeout(5000),
34
+ });
35
+ }
36
+ catch { /* telemetri best-effort — kullanıcıyı etkilemez */ }
37
+ }
package/dist/tools.js CHANGED
@@ -10,6 +10,7 @@ import { loadConfig } from './api.js';
10
10
  import { runAgentLoop } from './agent.js';
11
11
  import { resolveSubagent, subagentTypesHint } from './subagents.js';
12
12
  import { saveMemoryFact } from './memory.js';
13
+ import { emit as emitSpan } from './telemetry.js';
13
14
  import { tasks } from './tasks.js';
14
15
  import { getMcpToolSchemas, callMcpTool } from './mcp.js';
15
16
  import { getSkills, getSkill, buildSkillPrompt } from './skills.js';
@@ -707,7 +708,9 @@ export async function executeToolCalls(calls, hooks) {
707
708
  while (p < b.items.length) {
708
709
  const { c, i } = b.items[p++];
709
710
  hooks?.onStart?.(c, i);
711
+ const _t = Date.now();
710
712
  results[i] = await execOne(c, hooks);
713
+ emitSpan(results[i].ok ? 'tool_called' : 'tool_failed', { tool: c.name }, Date.now() - _t, results[i].ok ? 'ok' : 'error');
711
714
  hooks?.onResult?.(c, i, results[i]);
712
715
  }
713
716
  };
@@ -716,7 +719,9 @@ export async function executeToolCalls(calls, hooks) {
716
719
  else {
717
720
  for (const { c, i } of b.items) {
718
721
  hooks?.onStart?.(c, i);
722
+ const _t = Date.now();
719
723
  results[i] = await execOne(c, hooks);
724
+ emitSpan(results[i].ok ? 'tool_called' : 'tool_failed', { tool: c.name }, Date.now() - _t, results[i].ok ? 'ok' : 'error');
720
725
  hooks?.onResult?.(c, i, results[i]);
721
726
  }
722
727
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wormclaude",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "WormClaude CLI - uncensored security+code assistant (ink TUI, Claude-style)",
5
5
  "type": "module",
6
6
  "bin": {