@clinebot/core 0.0.18 → 0.0.21
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/account/cline-account-service.d.ts +3 -2
- package/dist/account/cline-account-service.d.ts.map +1 -0
- package/dist/account/index.d.ts +1 -0
- package/dist/account/index.d.ts.map +1 -0
- package/dist/account/rpc.d.ts +1 -0
- package/dist/account/rpc.d.ts.map +1 -0
- package/dist/account/types.d.ts +1 -0
- package/dist/account/types.d.ts.map +1 -0
- package/dist/agents/agent-config-loader.d.ts +1 -0
- package/dist/agents/agent-config-loader.d.ts.map +1 -0
- package/dist/agents/agent-config-parser.d.ts +1 -0
- package/dist/agents/agent-config-parser.d.ts.map +1 -0
- package/dist/agents/hooks-config-loader.d.ts +1 -0
- package/dist/agents/hooks-config-loader.d.ts.map +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/plugin-config-loader.d.ts +1 -0
- package/dist/agents/plugin-config-loader.d.ts.map +1 -0
- package/dist/agents/plugin-loader.d.ts +1 -0
- package/dist/agents/plugin-loader.d.ts.map +1 -0
- package/dist/agents/plugin-sandbox.d.ts +1 -0
- package/dist/agents/plugin-sandbox.d.ts.map +1 -0
- package/dist/agents/unified-config-file-watcher.d.ts +1 -0
- package/dist/agents/unified-config-file-watcher.d.ts.map +1 -0
- package/dist/agents/user-instruction-config-loader.d.ts +1 -0
- package/dist/agents/user-instruction-config-loader.d.ts.map +1 -0
- package/dist/auth/client.d.ts +1 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/cline.d.ts +1 -0
- package/dist/auth/cline.d.ts.map +1 -0
- package/dist/auth/codex.d.ts +1 -0
- package/dist/auth/codex.d.ts.map +1 -0
- package/dist/auth/oca.d.ts +1 -0
- package/dist/auth/oca.d.ts.map +1 -0
- package/dist/auth/server.d.ts +1 -0
- package/dist/auth/server.d.ts.map +1 -0
- package/dist/auth/types.d.ts +1 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/utils.d.ts +1 -0
- package/dist/auth/utils.d.ts.map +1 -0
- package/dist/chat/chat-schema.d.ts +13 -12
- package/dist/chat/chat-schema.d.ts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.node.d.ts +2 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/index.node.js +303 -302
- package/dist/input/file-indexer.d.ts +1 -0
- package/dist/input/file-indexer.d.ts.map +1 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/mention-enricher.d.ts +1 -0
- package/dist/input/mention-enricher.d.ts.map +1 -0
- package/dist/mcp/config-loader.d.ts +1 -0
- package/dist/mcp/config-loader.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/manager.d.ts +1 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/types.d.ts +1 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/providers/local-provider-registry.d.ts +36 -0
- package/dist/providers/local-provider-registry.d.ts.map +1 -0
- package/dist/providers/local-provider-service.d.ts +2 -1
- package/dist/providers/local-provider-service.d.ts.map +1 -0
- package/dist/runtime/commands.d.ts +1 -0
- package/dist/runtime/commands.d.ts.map +1 -0
- package/dist/runtime/hook-file-hooks.d.ts +1 -0
- package/dist/runtime/hook-file-hooks.d.ts.map +1 -0
- package/dist/runtime/rules.d.ts +1 -0
- package/dist/runtime/rules.d.ts.map +1 -0
- package/dist/runtime/runtime-builder.d.ts +1 -0
- package/dist/runtime/runtime-builder.d.ts.map +1 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts +1 -0
- package/dist/runtime/sandbox/subprocess-sandbox.d.ts.map +1 -0
- package/dist/runtime/session-runtime.d.ts +2 -0
- package/dist/runtime/session-runtime.d.ts.map +1 -0
- package/dist/runtime/skills.d.ts +1 -0
- package/dist/runtime/skills.d.ts.map +1 -0
- package/dist/runtime/tool-approval.d.ts +1 -0
- package/dist/runtime/tool-approval.d.ts.map +1 -0
- package/dist/runtime/workflows.d.ts +1 -0
- package/dist/runtime/workflows.d.ts.map +1 -0
- package/dist/session/default-session-manager.d.ts +4 -0
- package/dist/session/default-session-manager.d.ts.map +1 -0
- package/dist/session/file-session-service.d.ts +1 -0
- package/dist/session/file-session-service.d.ts.map +1 -0
- package/dist/session/rpc-session-service.d.ts +1 -0
- package/dist/session/rpc-session-service.d.ts.map +1 -0
- package/dist/session/rpc-spawn-lease.d.ts +1 -0
- package/dist/session/rpc-spawn-lease.d.ts.map +1 -0
- package/dist/session/runtime-oauth-token-manager.d.ts +1 -0
- package/dist/session/runtime-oauth-token-manager.d.ts.map +1 -0
- package/dist/session/session-agent-events.d.ts +20 -1
- package/dist/session/session-agent-events.d.ts.map +1 -0
- package/dist/session/session-artifacts.d.ts +1 -0
- package/dist/session/session-artifacts.d.ts.map +1 -0
- package/dist/session/session-config-builder.d.ts +1 -0
- package/dist/session/session-config-builder.d.ts.map +1 -0
- package/dist/session/session-graph.d.ts +1 -0
- package/dist/session/session-graph.d.ts.map +1 -0
- package/dist/session/session-host.d.ts +1 -0
- package/dist/session/session-host.d.ts.map +1 -0
- package/dist/session/session-manager.d.ts +1 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manifest.d.ts +2 -1
- package/dist/session/session-manifest.d.ts.map +1 -0
- package/dist/session/session-service.d.ts +1 -0
- package/dist/session/session-service.d.ts.map +1 -0
- package/dist/session/session-team-coordination.d.ts +1 -0
- package/dist/session/session-team-coordination.d.ts.map +1 -0
- package/dist/session/session-telemetry.d.ts +3 -1
- package/dist/session/session-telemetry.d.ts.map +1 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts +1 -0
- package/dist/session/sqlite-rpc-session-backend.d.ts.map +1 -0
- package/dist/session/unified-session-persistence-service.d.ts +1 -0
- package/dist/session/unified-session-persistence-service.d.ts.map +1 -0
- package/dist/session/utils/helpers.d.ts +1 -0
- package/dist/session/utils/helpers.d.ts.map +1 -0
- package/dist/session/utils/types.d.ts +1 -0
- package/dist/session/utils/types.d.ts.map +1 -0
- package/dist/session/utils/usage.d.ts +1 -0
- package/dist/session/utils/usage.d.ts.map +1 -0
- package/dist/session/workspace-manager.d.ts +1 -0
- package/dist/session/workspace-manager.d.ts.map +1 -0
- package/dist/session/workspace-manifest.d.ts +1 -0
- package/dist/session/workspace-manifest.d.ts.map +1 -0
- package/dist/storage/file-team-store.d.ts +1 -0
- package/dist/storage/file-team-store.d.ts.map +1 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts +1 -0
- package/dist/storage/provider-settings-legacy-migration.d.ts.map +1 -0
- package/dist/storage/provider-settings-manager.d.ts +1 -0
- package/dist/storage/provider-settings-manager.d.ts.map +1 -0
- package/dist/storage/sqlite-session-store.d.ts +1 -0
- package/dist/storage/sqlite-session-store.d.ts.map +1 -0
- package/dist/storage/sqlite-team-store.d.ts +1 -0
- package/dist/storage/sqlite-team-store.d.ts.map +1 -0
- package/dist/storage/team-store.d.ts +1 -0
- package/dist/storage/team-store.d.ts.map +1 -0
- package/dist/team/index.d.ts +1 -0
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/projections.d.ts +1 -0
- package/dist/team/projections.d.ts.map +1 -0
- package/dist/telemetry/ITelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/ITelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/LoggerTelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/LoggerTelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/OpenTelemetryAdapter.d.ts +1 -0
- package/dist/telemetry/OpenTelemetryAdapter.d.ts.map +1 -0
- package/dist/telemetry/OpenTelemetryProvider.d.ts +1 -0
- package/dist/telemetry/OpenTelemetryProvider.d.ts.map +1 -0
- package/dist/telemetry/TelemetryService.d.ts +1 -0
- package/dist/telemetry/TelemetryService.d.ts.map +1 -0
- package/dist/telemetry/core-events.d.ts +55 -22
- package/dist/telemetry/core-events.d.ts.map +1 -0
- package/dist/telemetry/opentelemetry.d.ts +1 -0
- package/dist/telemetry/opentelemetry.d.ts.map +1 -0
- package/dist/tools/constants.d.ts +1 -0
- package/dist/tools/constants.d.ts.map +1 -0
- package/dist/tools/definitions.d.ts +8 -1
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/executors/apply-patch-parser.d.ts +1 -0
- package/dist/tools/executors/apply-patch-parser.d.ts.map +1 -0
- package/dist/tools/executors/apply-patch.d.ts +1 -0
- package/dist/tools/executors/apply-patch.d.ts.map +1 -0
- package/dist/tools/executors/bash.d.ts +2 -1
- package/dist/tools/executors/bash.d.ts.map +1 -0
- package/dist/tools/executors/editor.d.ts +1 -0
- package/dist/tools/executors/editor.d.ts.map +1 -0
- package/dist/tools/executors/file-read.d.ts +1 -0
- package/dist/tools/executors/file-read.d.ts.map +1 -0
- package/dist/tools/executors/index.d.ts +14 -7
- package/dist/tools/executors/index.d.ts.map +1 -0
- package/dist/tools/executors/search.d.ts +1 -0
- package/dist/tools/executors/search.d.ts.map +1 -0
- package/dist/tools/executors/web-fetch.d.ts +1 -0
- package/dist/tools/executors/web-fetch.d.ts.map +1 -0
- package/dist/tools/helpers.d.ts +15 -0
- package/dist/tools/helpers.d.ts.map +1 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/model-tool-routing.d.ts +1 -0
- package/dist/tools/model-tool-routing.d.ts.map +1 -0
- package/dist/tools/presets.d.ts +1 -0
- package/dist/tools/presets.d.ts.map +1 -0
- package/dist/tools/schemas.d.ts +41 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/types.d.ts +3 -2
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/types/common.d.ts +1 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/events.d.ts +1 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/provider-settings.d.ts +1 -0
- package/dist/types/provider-settings.d.ts.map +1 -0
- package/dist/types/sessions.d.ts +1 -0
- package/dist/types/sessions.d.ts.map +1 -0
- package/dist/types/storage.d.ts +1 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/workspace.d.ts +1 -0
- package/dist/types/workspace.d.ts.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +8 -6
- package/src/account/cline-account-service.test.ts +0 -101
- package/src/account/cline-account-service.ts +0 -287
- package/src/account/index.ts +0 -22
- package/src/account/rpc.test.ts +0 -62
- package/src/account/rpc.ts +0 -172
- package/src/account/types.ts +0 -98
- package/src/agents/agent-config-loader.test.ts +0 -236
- package/src/agents/agent-config-loader.ts +0 -108
- package/src/agents/agent-config-parser.ts +0 -198
- package/src/agents/hooks-config-loader.test.ts +0 -20
- package/src/agents/hooks-config-loader.ts +0 -118
- package/src/agents/index.ts +0 -85
- package/src/agents/plugin-config-loader.test.ts +0 -140
- package/src/agents/plugin-config-loader.ts +0 -97
- package/src/agents/plugin-loader.test.ts +0 -228
- package/src/agents/plugin-loader.ts +0 -172
- package/src/agents/plugin-sandbox-bootstrap.ts +0 -445
- package/src/agents/plugin-sandbox.test.ts +0 -317
- package/src/agents/plugin-sandbox.ts +0 -341
- package/src/agents/unified-config-file-watcher.test.ts +0 -196
- package/src/agents/unified-config-file-watcher.ts +0 -483
- package/src/agents/user-instruction-config-loader.test.ts +0 -158
- package/src/agents/user-instruction-config-loader.ts +0 -438
- package/src/auth/client.test.ts +0 -40
- package/src/auth/client.ts +0 -25
- package/src/auth/cline.test.ts +0 -130
- package/src/auth/cline.ts +0 -420
- package/src/auth/codex.test.ts +0 -170
- package/src/auth/codex.ts +0 -491
- package/src/auth/oca.test.ts +0 -215
- package/src/auth/oca.ts +0 -573
- package/src/auth/server.ts +0 -216
- package/src/auth/types.ts +0 -81
- package/src/auth/utils.test.ts +0 -128
- package/src/auth/utils.ts +0 -247
- package/src/chat/chat-schema.ts +0 -82
- package/src/index.node.ts +0 -285
- package/src/index.ts +0 -211
- package/src/input/file-indexer.d.ts +0 -11
- package/src/input/file-indexer.test.ts +0 -127
- package/src/input/file-indexer.ts +0 -327
- package/src/input/index.ts +0 -7
- package/src/input/mention-enricher.test.ts +0 -85
- package/src/input/mention-enricher.ts +0 -122
- package/src/mcp/config-loader.test.ts +0 -238
- package/src/mcp/config-loader.ts +0 -219
- package/src/mcp/index.ts +0 -26
- package/src/mcp/manager.test.ts +0 -106
- package/src/mcp/manager.ts +0 -262
- package/src/mcp/types.ts +0 -88
- package/src/providers/local-provider-service.ts +0 -608
- package/src/runtime/commands.test.ts +0 -98
- package/src/runtime/commands.ts +0 -83
- package/src/runtime/hook-file-hooks.test.ts +0 -237
- package/src/runtime/hook-file-hooks.ts +0 -859
- package/src/runtime/index.ts +0 -37
- package/src/runtime/rules.ts +0 -34
- package/src/runtime/runtime-builder.team-persistence.test.ts +0 -202
- package/src/runtime/runtime-builder.test.ts +0 -371
- package/src/runtime/runtime-builder.ts +0 -589
- package/src/runtime/runtime-parity.test.ts +0 -143
- package/src/runtime/sandbox/subprocess-sandbox.ts +0 -231
- package/src/runtime/session-runtime.ts +0 -46
- package/src/runtime/skills.ts +0 -44
- package/src/runtime/tool-approval.ts +0 -104
- package/src/runtime/workflows.test.ts +0 -119
- package/src/runtime/workflows.ts +0 -45
- package/src/session/default-session-manager.e2e.test.ts +0 -384
- package/src/session/default-session-manager.test.ts +0 -1741
- package/src/session/default-session-manager.ts +0 -1233
- package/src/session/file-session-service.ts +0 -280
- package/src/session/index.ts +0 -42
- package/src/session/rpc-session-service.ts +0 -107
- package/src/session/rpc-spawn-lease.test.ts +0 -49
- package/src/session/rpc-spawn-lease.ts +0 -122
- package/src/session/runtime-oauth-token-manager.test.ts +0 -137
- package/src/session/runtime-oauth-token-manager.ts +0 -272
- package/src/session/session-agent-events.ts +0 -159
- package/src/session/session-artifacts.ts +0 -106
- package/src/session/session-config-builder.ts +0 -113
- package/src/session/session-graph.ts +0 -92
- package/src/session/session-host.test.ts +0 -29
- package/src/session/session-host.ts +0 -242
- package/src/session/session-manager.ts +0 -69
- package/src/session/session-manifest.ts +0 -29
- package/src/session/session-service.team-persistence.test.ts +0 -48
- package/src/session/session-service.ts +0 -673
- package/src/session/session-team-coordination.ts +0 -229
- package/src/session/session-telemetry.ts +0 -95
- package/src/session/sqlite-rpc-session-backend.ts +0 -303
- package/src/session/unified-session-persistence-service.test.ts +0 -85
- package/src/session/unified-session-persistence-service.ts +0 -996
- package/src/session/utils/helpers.ts +0 -139
- package/src/session/utils/types.ts +0 -57
- package/src/session/utils/usage.ts +0 -32
- package/src/session/workspace-manager.ts +0 -98
- package/src/session/workspace-manifest.ts +0 -100
- package/src/storage/artifact-store.ts +0 -1
- package/src/storage/file-team-store.ts +0 -257
- package/src/storage/index.ts +0 -11
- package/src/storage/provider-settings-legacy-migration.test.ts +0 -307
- package/src/storage/provider-settings-legacy-migration.ts +0 -689
- package/src/storage/provider-settings-manager.test.ts +0 -145
- package/src/storage/provider-settings-manager.ts +0 -150
- package/src/storage/session-store.ts +0 -1
- package/src/storage/sqlite-session-store.ts +0 -275
- package/src/storage/sqlite-team-store.ts +0 -454
- package/src/storage/team-store.ts +0 -40
- package/src/team/index.ts +0 -4
- package/src/team/projections.ts +0 -285
- package/src/telemetry/ITelemetryAdapter.ts +0 -94
- package/src/telemetry/LoggerTelemetryAdapter.test.ts +0 -42
- package/src/telemetry/LoggerTelemetryAdapter.ts +0 -114
- package/src/telemetry/OpenTelemetryAdapter.test.ts +0 -157
- package/src/telemetry/OpenTelemetryAdapter.ts +0 -348
- package/src/telemetry/OpenTelemetryProvider.test.ts +0 -113
- package/src/telemetry/OpenTelemetryProvider.ts +0 -322
- package/src/telemetry/TelemetryService.test.ts +0 -134
- package/src/telemetry/TelemetryService.ts +0 -141
- package/src/telemetry/core-events.ts +0 -344
- package/src/telemetry/opentelemetry.ts +0 -20
- package/src/tools/constants.ts +0 -35
- package/src/tools/definitions.test.ts +0 -658
- package/src/tools/definitions.ts +0 -726
- package/src/tools/executors/apply-patch-parser.ts +0 -520
- package/src/tools/executors/apply-patch.ts +0 -359
- package/src/tools/executors/bash.ts +0 -205
- package/src/tools/executors/editor.test.ts +0 -35
- package/src/tools/executors/editor.ts +0 -219
- package/src/tools/executors/file-read.test.ts +0 -49
- package/src/tools/executors/file-read.ts +0 -110
- package/src/tools/executors/index.ts +0 -75
- package/src/tools/executors/search.ts +0 -278
- package/src/tools/executors/web-fetch.ts +0 -259
- package/src/tools/index.ts +0 -168
- package/src/tools/model-tool-routing.test.ts +0 -86
- package/src/tools/model-tool-routing.ts +0 -132
- package/src/tools/presets.test.ts +0 -62
- package/src/tools/presets.ts +0 -168
- package/src/tools/schemas.ts +0 -284
- package/src/tools/types.ts +0 -328
- package/src/types/common.ts +0 -14
- package/src/types/config.ts +0 -84
- package/src/types/events.ts +0 -74
- package/src/types/index.ts +0 -24
- package/src/types/provider-settings.ts +0 -43
- package/src/types/sessions.ts +0 -16
- package/src/types/storage.ts +0 -64
- package/src/types/workspace.ts +0 -7
- package/src/types.ts +0 -128
package/src/team/projections.ts
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
TeamEvent,
|
|
3
|
-
TeamOutcome,
|
|
4
|
-
TeamOutcomeFragment,
|
|
5
|
-
TeamRuntimeState,
|
|
6
|
-
} from "@clinebot/agents";
|
|
7
|
-
import type {
|
|
8
|
-
TeamProgressLifecycleEvent,
|
|
9
|
-
TeamProgressSummary,
|
|
10
|
-
} from "@clinebot/shared";
|
|
11
|
-
|
|
12
|
-
function toIsoNow(): string {
|
|
13
|
-
return new Date().toISOString();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function pct(numerator: number, denominator: number): number {
|
|
17
|
-
if (denominator <= 0) {
|
|
18
|
-
return 0;
|
|
19
|
-
}
|
|
20
|
-
return Math.round((numerator / denominator) * 100);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function collectMissingRequiredSections(
|
|
24
|
-
outcomes: TeamOutcome[],
|
|
25
|
-
fragments: TeamOutcomeFragment[],
|
|
26
|
-
): string[] {
|
|
27
|
-
const approvedSections = new Set<string>();
|
|
28
|
-
for (const fragment of fragments) {
|
|
29
|
-
if (fragment.status === "reviewed") {
|
|
30
|
-
approvedSections.add(`${fragment.outcomeId}:${fragment.section}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const missing = new Set<string>();
|
|
34
|
-
for (const outcome of outcomes) {
|
|
35
|
-
if (outcome.status === "finalized") {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
for (const section of outcome.requiredSections) {
|
|
39
|
-
if (!approvedSections.has(`${outcome.id}:${section}`)) {
|
|
40
|
-
missing.add(`${outcome.id}:${section}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return [...missing].sort((a, b) => a.localeCompare(b));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function buildTeamProgressSummary(
|
|
48
|
-
teamName: string,
|
|
49
|
-
state: TeamRuntimeState,
|
|
50
|
-
): TeamProgressSummary {
|
|
51
|
-
const membersByStatus: Record<"idle" | "running" | "stopped", number> = {
|
|
52
|
-
idle: 0,
|
|
53
|
-
running: 0,
|
|
54
|
-
stopped: 0,
|
|
55
|
-
};
|
|
56
|
-
const tasksByStatus: Record<
|
|
57
|
-
"pending" | "in_progress" | "blocked" | "completed",
|
|
58
|
-
number
|
|
59
|
-
> = {
|
|
60
|
-
pending: 0,
|
|
61
|
-
in_progress: 0,
|
|
62
|
-
blocked: 0,
|
|
63
|
-
completed: 0,
|
|
64
|
-
};
|
|
65
|
-
const runsByStatus: Record<
|
|
66
|
-
"queued" | "running" | "completed" | "failed" | "cancelled" | "interrupted",
|
|
67
|
-
number
|
|
68
|
-
> = {
|
|
69
|
-
queued: 0,
|
|
70
|
-
running: 0,
|
|
71
|
-
completed: 0,
|
|
72
|
-
failed: 0,
|
|
73
|
-
cancelled: 0,
|
|
74
|
-
interrupted: 0,
|
|
75
|
-
};
|
|
76
|
-
const outcomesByStatus: Record<"draft" | "in_review" | "finalized", number> =
|
|
77
|
-
{
|
|
78
|
-
draft: 0,
|
|
79
|
-
in_review: 0,
|
|
80
|
-
finalized: 0,
|
|
81
|
-
};
|
|
82
|
-
const fragmentsByStatus: Record<"draft" | "reviewed" | "rejected", number> = {
|
|
83
|
-
draft: 0,
|
|
84
|
-
reviewed: 0,
|
|
85
|
-
rejected: 0,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
let leadCount = 0;
|
|
89
|
-
let teammateCount = 0;
|
|
90
|
-
for (const member of state.members) {
|
|
91
|
-
membersByStatus[member.status] += 1;
|
|
92
|
-
if (member.role === "lead") {
|
|
93
|
-
leadCount += 1;
|
|
94
|
-
} else {
|
|
95
|
-
teammateCount += 1;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const blockedTaskIds: string[] = [];
|
|
100
|
-
const readyTaskIds: string[] = [];
|
|
101
|
-
const completedTaskCount = state.tasks.filter(
|
|
102
|
-
(task) => task.status === "completed",
|
|
103
|
-
).length;
|
|
104
|
-
const taskById = new Map(state.tasks.map((task) => [task.id, task] as const));
|
|
105
|
-
for (const task of state.tasks) {
|
|
106
|
-
tasksByStatus[task.status] += 1;
|
|
107
|
-
if (task.status === "blocked") {
|
|
108
|
-
blockedTaskIds.push(task.id);
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
if (task.status !== "pending") {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
const depsSatisfied = task.dependsOn.every((depId) => {
|
|
115
|
-
const dependency = taskById.get(depId);
|
|
116
|
-
return dependency?.status === "completed";
|
|
117
|
-
});
|
|
118
|
-
if (depsSatisfied) {
|
|
119
|
-
readyTaskIds.push(task.id);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const activeRunIds: string[] = [];
|
|
124
|
-
let latestRunId: string | undefined;
|
|
125
|
-
let latestRunTs = 0;
|
|
126
|
-
for (const run of state.runs) {
|
|
127
|
-
runsByStatus[run.status] += 1;
|
|
128
|
-
if (run.status === "queued" || run.status === "running") {
|
|
129
|
-
activeRunIds.push(run.id);
|
|
130
|
-
}
|
|
131
|
-
const startedAtTs = run.startedAt.getTime();
|
|
132
|
-
if (startedAtTs >= latestRunTs) {
|
|
133
|
-
latestRunTs = startedAtTs;
|
|
134
|
-
latestRunId = run.id;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
for (const outcome of state.outcomes) {
|
|
139
|
-
outcomesByStatus[outcome.status] += 1;
|
|
140
|
-
}
|
|
141
|
-
for (const fragment of state.outcomeFragments) {
|
|
142
|
-
fragmentsByStatus[fragment.status] += 1;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
teamName,
|
|
147
|
-
updatedAt: toIsoNow(),
|
|
148
|
-
members: {
|
|
149
|
-
total: state.members.length,
|
|
150
|
-
byStatus: membersByStatus,
|
|
151
|
-
leadCount,
|
|
152
|
-
teammateCount,
|
|
153
|
-
},
|
|
154
|
-
tasks: {
|
|
155
|
-
total: state.tasks.length,
|
|
156
|
-
byStatus: tasksByStatus,
|
|
157
|
-
blockedTaskIds,
|
|
158
|
-
readyTaskIds,
|
|
159
|
-
completionPct: pct(completedTaskCount, state.tasks.length),
|
|
160
|
-
},
|
|
161
|
-
runs: {
|
|
162
|
-
total: state.runs.length,
|
|
163
|
-
byStatus: runsByStatus,
|
|
164
|
-
activeRunIds,
|
|
165
|
-
latestRunId,
|
|
166
|
-
},
|
|
167
|
-
outcomes: {
|
|
168
|
-
total: state.outcomes.length,
|
|
169
|
-
byStatus: outcomesByStatus,
|
|
170
|
-
finalizedPct: pct(outcomesByStatus.finalized, state.outcomes.length),
|
|
171
|
-
missingRequiredSections: collectMissingRequiredSections(
|
|
172
|
-
state.outcomes,
|
|
173
|
-
state.outcomeFragments,
|
|
174
|
-
),
|
|
175
|
-
},
|
|
176
|
-
fragments: {
|
|
177
|
-
total: state.outcomeFragments.length,
|
|
178
|
-
byStatus: fragmentsByStatus,
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export function toTeamProgressLifecycleEvent(input: {
|
|
184
|
-
teamName: string;
|
|
185
|
-
sessionId: string;
|
|
186
|
-
event: TeamEvent;
|
|
187
|
-
}): TeamProgressLifecycleEvent {
|
|
188
|
-
const { event } = input;
|
|
189
|
-
switch (event.type) {
|
|
190
|
-
case "team_task_updated":
|
|
191
|
-
return {
|
|
192
|
-
teamName: input.teamName,
|
|
193
|
-
sessionId: input.sessionId,
|
|
194
|
-
eventType: event.type,
|
|
195
|
-
ts: toIsoNow(),
|
|
196
|
-
taskId: event.task.id,
|
|
197
|
-
agentId: event.task.assignee ?? event.task.createdBy,
|
|
198
|
-
};
|
|
199
|
-
case "run_queued":
|
|
200
|
-
case "run_started":
|
|
201
|
-
case "run_completed":
|
|
202
|
-
case "run_failed":
|
|
203
|
-
case "run_cancelled":
|
|
204
|
-
case "run_interrupted":
|
|
205
|
-
return {
|
|
206
|
-
teamName: input.teamName,
|
|
207
|
-
sessionId: input.sessionId,
|
|
208
|
-
eventType: event.type,
|
|
209
|
-
ts: toIsoNow(),
|
|
210
|
-
runId: event.run.id,
|
|
211
|
-
taskId: event.run.taskId,
|
|
212
|
-
agentId: event.run.agentId,
|
|
213
|
-
message: event.run.error,
|
|
214
|
-
};
|
|
215
|
-
case "run_progress":
|
|
216
|
-
return {
|
|
217
|
-
teamName: input.teamName,
|
|
218
|
-
sessionId: input.sessionId,
|
|
219
|
-
eventType: event.type,
|
|
220
|
-
ts: toIsoNow(),
|
|
221
|
-
runId: event.run.id,
|
|
222
|
-
taskId: event.run.taskId,
|
|
223
|
-
agentId: event.run.agentId,
|
|
224
|
-
message: event.message,
|
|
225
|
-
};
|
|
226
|
-
case "outcome_created":
|
|
227
|
-
case "outcome_finalized":
|
|
228
|
-
return {
|
|
229
|
-
teamName: input.teamName,
|
|
230
|
-
sessionId: input.sessionId,
|
|
231
|
-
eventType: event.type,
|
|
232
|
-
ts: toIsoNow(),
|
|
233
|
-
outcomeId: event.outcome.id,
|
|
234
|
-
};
|
|
235
|
-
case "outcome_fragment_attached":
|
|
236
|
-
case "outcome_fragment_reviewed":
|
|
237
|
-
return {
|
|
238
|
-
teamName: input.teamName,
|
|
239
|
-
sessionId: input.sessionId,
|
|
240
|
-
eventType: event.type,
|
|
241
|
-
ts: toIsoNow(),
|
|
242
|
-
outcomeId: event.fragment.outcomeId,
|
|
243
|
-
fragmentId: event.fragment.id,
|
|
244
|
-
agentId: event.fragment.sourceAgentId,
|
|
245
|
-
};
|
|
246
|
-
case "team_message":
|
|
247
|
-
return {
|
|
248
|
-
teamName: input.teamName,
|
|
249
|
-
sessionId: input.sessionId,
|
|
250
|
-
eventType: event.type,
|
|
251
|
-
ts: toIsoNow(),
|
|
252
|
-
taskId: event.message.taskId,
|
|
253
|
-
agentId: event.message.fromAgentId,
|
|
254
|
-
message: event.message.subject,
|
|
255
|
-
};
|
|
256
|
-
case "team_mission_log":
|
|
257
|
-
return {
|
|
258
|
-
teamName: input.teamName,
|
|
259
|
-
sessionId: input.sessionId,
|
|
260
|
-
eventType: event.type,
|
|
261
|
-
ts: toIsoNow(),
|
|
262
|
-
taskId: event.entry.taskId,
|
|
263
|
-
agentId: event.entry.agentId,
|
|
264
|
-
message: event.entry.summary,
|
|
265
|
-
};
|
|
266
|
-
case "teammate_spawned":
|
|
267
|
-
case "teammate_shutdown":
|
|
268
|
-
case "task_start":
|
|
269
|
-
case "task_end":
|
|
270
|
-
case "agent_event":
|
|
271
|
-
return {
|
|
272
|
-
teamName: input.teamName,
|
|
273
|
-
sessionId: input.sessionId,
|
|
274
|
-
eventType: event.type,
|
|
275
|
-
ts: toIsoNow(),
|
|
276
|
-
agentId: event.agentId,
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
return {
|
|
280
|
-
teamName: input.teamName,
|
|
281
|
-
sessionId: input.sessionId,
|
|
282
|
-
eventType: (event as TeamEvent).type,
|
|
283
|
-
ts: toIsoNow(),
|
|
284
|
-
};
|
|
285
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Telemetry adapter interface for the @clinebot/core SDK.
|
|
3
|
-
*
|
|
4
|
-
* This is the SDK-side counterpart to the extension's ITelemetryProvider.
|
|
5
|
-
* It is intentionally free of VS Code / host-provider dependencies so that
|
|
6
|
-
* any consumer (CLI, tests, third-party integrations) can plug in their own
|
|
7
|
-
* backend without pulling in the full extension runtime.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { TelemetryProperties } from "@clinebot/shared";
|
|
11
|
-
|
|
12
|
-
export type {
|
|
13
|
-
TelemetryArray,
|
|
14
|
-
TelemetryMetadata,
|
|
15
|
-
TelemetryObject,
|
|
16
|
-
TelemetryPrimitive,
|
|
17
|
-
TelemetryProperties,
|
|
18
|
-
TelemetryValue,
|
|
19
|
-
} from "@clinebot/shared";
|
|
20
|
-
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
// Adapter interface
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Telemetry adapter that an SDK consumer implements (or uses via the
|
|
27
|
-
* provided {@link OpenTelemetryAdapter}) to receive Cline telemetry events.
|
|
28
|
-
*
|
|
29
|
-
* The interface intentionally mirrors ITelemetryProvider from the extension
|
|
30
|
-
* so that shared logic can be re-used or compared easily.
|
|
31
|
-
*/
|
|
32
|
-
export interface ITelemetryAdapter {
|
|
33
|
-
/** Human-readable adapter name used for logging / diagnostics. */
|
|
34
|
-
readonly name: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Emit a standard telemetry event.
|
|
38
|
-
* Implementations may silently drop events when telemetry is disabled.
|
|
39
|
-
*/
|
|
40
|
-
emit(event: string, properties?: TelemetryProperties): void;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Emit a *required* telemetry event that must not be suppressed by
|
|
44
|
-
* user opt-out settings (e.g. final opt-out confirmation events).
|
|
45
|
-
*/
|
|
46
|
-
emitRequired(event: string, properties?: TelemetryProperties): void;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Record a monotonically-increasing counter metric.
|
|
50
|
-
* Implementations that do not support metrics may treat this as a no-op.
|
|
51
|
-
*/
|
|
52
|
-
recordCounter(
|
|
53
|
-
name: string,
|
|
54
|
-
value: number,
|
|
55
|
-
attributes?: TelemetryProperties,
|
|
56
|
-
description?: string,
|
|
57
|
-
required?: boolean,
|
|
58
|
-
): void;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Record a histogram (distribution) metric.
|
|
62
|
-
* Implementations that do not support metrics may treat this as a no-op.
|
|
63
|
-
*/
|
|
64
|
-
recordHistogram(
|
|
65
|
-
name: string,
|
|
66
|
-
value: number,
|
|
67
|
-
attributes?: TelemetryProperties,
|
|
68
|
-
description?: string,
|
|
69
|
-
required?: boolean,
|
|
70
|
-
): void;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Record a gauge (point-in-time) metric.
|
|
74
|
-
* Pass `null` as `value` to retire the series identified by
|
|
75
|
-
* `name + attributes` and prevent stale gauge entries.
|
|
76
|
-
* Implementations that do not support metrics may treat this as a no-op.
|
|
77
|
-
*/
|
|
78
|
-
recordGauge(
|
|
79
|
-
name: string,
|
|
80
|
-
value: number | null,
|
|
81
|
-
attributes?: TelemetryProperties,
|
|
82
|
-
description?: string,
|
|
83
|
-
required?: boolean,
|
|
84
|
-
): void;
|
|
85
|
-
|
|
86
|
-
/** Returns whether the adapter is currently accepting events. */
|
|
87
|
-
isEnabled(): boolean;
|
|
88
|
-
|
|
89
|
-
/** Flush any buffered events/metrics to the backend. */
|
|
90
|
-
flush(): Promise<void>;
|
|
91
|
-
|
|
92
|
-
/** Release all resources held by the adapter. */
|
|
93
|
-
dispose(): Promise<void>;
|
|
94
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { LoggerTelemetryAdapter } from "./LoggerTelemetryAdapter";
|
|
3
|
-
|
|
4
|
-
describe("LoggerTelemetryAdapter", () => {
|
|
5
|
-
it("logs events and metrics through the provided logger", async () => {
|
|
6
|
-
const logger = {
|
|
7
|
-
debug: vi.fn(),
|
|
8
|
-
info: vi.fn(),
|
|
9
|
-
warn: vi.fn(),
|
|
10
|
-
};
|
|
11
|
-
const adapter = new LoggerTelemetryAdapter({ logger });
|
|
12
|
-
|
|
13
|
-
adapter.emit("session.started", { sessionId: "s1" });
|
|
14
|
-
adapter.emitRequired("user.opt_out", { reason: "manual" });
|
|
15
|
-
adapter.recordCounter("cline.session.starts.total", 1, {
|
|
16
|
-
sessionId: "s1",
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
expect(logger.info).toHaveBeenCalledWith("telemetry.event", {
|
|
20
|
-
adapter: "LoggerTelemetryAdapter",
|
|
21
|
-
event: "session.started",
|
|
22
|
-
properties: { sessionId: "s1" },
|
|
23
|
-
});
|
|
24
|
-
expect(logger.warn).toHaveBeenCalledWith("telemetry.required_event", {
|
|
25
|
-
adapter: "LoggerTelemetryAdapter",
|
|
26
|
-
event: "user.opt_out",
|
|
27
|
-
properties: { reason: "manual" },
|
|
28
|
-
});
|
|
29
|
-
expect(logger.debug).toHaveBeenCalledWith("telemetry.metric", {
|
|
30
|
-
adapter: "LoggerTelemetryAdapter",
|
|
31
|
-
instrument: "counter",
|
|
32
|
-
name: "cline.session.starts.total",
|
|
33
|
-
value: 1,
|
|
34
|
-
attributes: { sessionId: "s1" },
|
|
35
|
-
description: undefined,
|
|
36
|
-
required: false,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
await adapter.flush();
|
|
40
|
-
await adapter.dispose();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import type { BasicLogger } from "@clinebot/shared";
|
|
2
|
-
import type {
|
|
3
|
-
ITelemetryAdapter,
|
|
4
|
-
TelemetryProperties,
|
|
5
|
-
} from "./ITelemetryAdapter";
|
|
6
|
-
|
|
7
|
-
export interface LoggerTelemetryAdapterOptions {
|
|
8
|
-
logger?: BasicLogger;
|
|
9
|
-
name?: string;
|
|
10
|
-
enabled?: boolean | (() => boolean);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class LoggerTelemetryAdapter implements ITelemetryAdapter {
|
|
14
|
-
readonly name: string;
|
|
15
|
-
|
|
16
|
-
private readonly logger?: BasicLogger;
|
|
17
|
-
private readonly enabled: boolean | (() => boolean);
|
|
18
|
-
|
|
19
|
-
constructor(options: LoggerTelemetryAdapterOptions = {}) {
|
|
20
|
-
this.name = options.name ?? "LoggerTelemetryAdapter";
|
|
21
|
-
this.logger = options.logger;
|
|
22
|
-
this.enabled = options.enabled ?? true;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
emit(event: string, properties?: TelemetryProperties): void {
|
|
26
|
-
if (!this.isEnabled()) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.logger?.info?.("telemetry.event", {
|
|
30
|
-
adapter: this.name,
|
|
31
|
-
event,
|
|
32
|
-
properties,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
emitRequired(event: string, properties?: TelemetryProperties): void {
|
|
37
|
-
this.logger?.warn?.("telemetry.required_event", {
|
|
38
|
-
adapter: this.name,
|
|
39
|
-
event,
|
|
40
|
-
properties,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
recordCounter(
|
|
45
|
-
name: string,
|
|
46
|
-
value: number,
|
|
47
|
-
attributes?: TelemetryProperties,
|
|
48
|
-
description?: string,
|
|
49
|
-
required?: boolean,
|
|
50
|
-
): void {
|
|
51
|
-
if (!required && !this.isEnabled()) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this.logger?.debug?.("telemetry.metric", {
|
|
55
|
-
adapter: this.name,
|
|
56
|
-
instrument: "counter",
|
|
57
|
-
name,
|
|
58
|
-
value,
|
|
59
|
-
attributes,
|
|
60
|
-
description,
|
|
61
|
-
required: required === true,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
recordHistogram(
|
|
66
|
-
name: string,
|
|
67
|
-
value: number,
|
|
68
|
-
attributes?: TelemetryProperties,
|
|
69
|
-
description?: string,
|
|
70
|
-
required?: boolean,
|
|
71
|
-
): void {
|
|
72
|
-
if (!required && !this.isEnabled()) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
this.logger?.debug?.("telemetry.metric", {
|
|
76
|
-
adapter: this.name,
|
|
77
|
-
instrument: "histogram",
|
|
78
|
-
name,
|
|
79
|
-
value,
|
|
80
|
-
attributes,
|
|
81
|
-
description,
|
|
82
|
-
required: required === true,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
recordGauge(
|
|
87
|
-
name: string,
|
|
88
|
-
value: number | null,
|
|
89
|
-
attributes?: TelemetryProperties,
|
|
90
|
-
description?: string,
|
|
91
|
-
required?: boolean,
|
|
92
|
-
): void {
|
|
93
|
-
if (!required && !this.isEnabled()) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
this.logger?.debug?.("telemetry.metric", {
|
|
97
|
-
adapter: this.name,
|
|
98
|
-
instrument: "gauge",
|
|
99
|
-
name,
|
|
100
|
-
value,
|
|
101
|
-
attributes,
|
|
102
|
-
description,
|
|
103
|
-
required: required === true,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
isEnabled(): boolean {
|
|
108
|
-
return typeof this.enabled === "function" ? this.enabled() : this.enabled;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
async flush(): Promise<void> {}
|
|
112
|
-
|
|
113
|
-
async dispose(): Promise<void> {}
|
|
114
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { LoggerProvider } from "@opentelemetry/sdk-logs";
|
|
2
|
-
import type { MeterProvider } from "@opentelemetry/sdk-metrics";
|
|
3
|
-
import { describe, expect, it, vi } from "vitest";
|
|
4
|
-
import { OpenTelemetryAdapter } from "./OpenTelemetryAdapter";
|
|
5
|
-
|
|
6
|
-
describe("OpenTelemetryAdapter", () => {
|
|
7
|
-
it("emits events in the telemetry service log format", () => {
|
|
8
|
-
const emit = vi.fn();
|
|
9
|
-
const adapter = new OpenTelemetryAdapter({
|
|
10
|
-
metadata: makeMetadata(),
|
|
11
|
-
distinctId: "user-123",
|
|
12
|
-
commonProperties: {
|
|
13
|
-
organization_id: "org-1",
|
|
14
|
-
},
|
|
15
|
-
loggerProvider: {
|
|
16
|
-
getLogger: () => ({ emit }),
|
|
17
|
-
} as unknown as LoggerProvider,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
adapter.emit("task.created", {
|
|
21
|
-
ulid: "01HXYZ",
|
|
22
|
-
nested: {
|
|
23
|
-
mode: "act",
|
|
24
|
-
},
|
|
25
|
-
items: ["a", "b"],
|
|
26
|
-
nullable: null,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
expect(emit).toHaveBeenCalledWith({
|
|
30
|
-
severityText: "INFO",
|
|
31
|
-
body: "task.created",
|
|
32
|
-
attributes: expect.objectContaining({
|
|
33
|
-
ulid: "01HXYZ",
|
|
34
|
-
"nested.mode": "act",
|
|
35
|
-
items: JSON.stringify(["a", "b"]),
|
|
36
|
-
nullable: "null",
|
|
37
|
-
distinct_id: "user-123",
|
|
38
|
-
organization_id: "org-1",
|
|
39
|
-
extension_version: "1.2.3",
|
|
40
|
-
cline_type: "cli",
|
|
41
|
-
platform: "terminal",
|
|
42
|
-
}),
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("marks required events with the expected flag", () => {
|
|
47
|
-
const emit = vi.fn();
|
|
48
|
-
const adapter = new OpenTelemetryAdapter({
|
|
49
|
-
metadata: makeMetadata(),
|
|
50
|
-
loggerProvider: {
|
|
51
|
-
getLogger: () => ({ emit }),
|
|
52
|
-
} as unknown as LoggerProvider,
|
|
53
|
-
enabled: false,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
adapter.emitRequired("user.opt_out");
|
|
57
|
-
|
|
58
|
-
expect(emit).toHaveBeenCalledWith({
|
|
59
|
-
severityText: "INFO",
|
|
60
|
-
body: "user.opt_out",
|
|
61
|
-
attributes: expect.objectContaining({
|
|
62
|
-
_required: true,
|
|
63
|
-
}),
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("records metrics with merged telemetry attributes and retires gauge series", () => {
|
|
68
|
-
const counterAdd = vi.fn();
|
|
69
|
-
const histogramRecord = vi.fn();
|
|
70
|
-
let gaugeCallback:
|
|
71
|
-
| ((result: {
|
|
72
|
-
observe: (
|
|
73
|
-
value: number,
|
|
74
|
-
attributes?: Record<string, string | number | boolean>,
|
|
75
|
-
) => void;
|
|
76
|
-
}) => void)
|
|
77
|
-
| undefined;
|
|
78
|
-
|
|
79
|
-
const forceFlush = vi.fn().mockResolvedValue(undefined);
|
|
80
|
-
const shutdown = vi.fn().mockResolvedValue(undefined);
|
|
81
|
-
|
|
82
|
-
const adapter = new OpenTelemetryAdapter({
|
|
83
|
-
metadata: makeMetadata(),
|
|
84
|
-
distinctId: "user-123",
|
|
85
|
-
meterProvider: {
|
|
86
|
-
getMeter: () =>
|
|
87
|
-
({
|
|
88
|
-
createCounter: () => ({ add: counterAdd }),
|
|
89
|
-
createHistogram: () => ({ record: histogramRecord }),
|
|
90
|
-
createObservableGauge: () => ({
|
|
91
|
-
addCallback: (callback: typeof gaugeCallback) => {
|
|
92
|
-
gaugeCallback = callback;
|
|
93
|
-
},
|
|
94
|
-
}),
|
|
95
|
-
}) as never,
|
|
96
|
-
forceFlush,
|
|
97
|
-
shutdown,
|
|
98
|
-
} as unknown as MeterProvider,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
adapter.recordCounter("cline.turns.total", 2, { ulid: "01HXYZ" });
|
|
102
|
-
adapter.recordHistogram("cline.api.duration.seconds", 1.5, {
|
|
103
|
-
ulid: "01HXYZ",
|
|
104
|
-
});
|
|
105
|
-
adapter.recordGauge("cline.workspace.active_roots", 3, { workspace: "a" });
|
|
106
|
-
|
|
107
|
-
expect(counterAdd).toHaveBeenCalledWith(
|
|
108
|
-
2,
|
|
109
|
-
expect.objectContaining({
|
|
110
|
-
ulid: "01HXYZ",
|
|
111
|
-
distinct_id: "user-123",
|
|
112
|
-
extension_version: "1.2.3",
|
|
113
|
-
}),
|
|
114
|
-
);
|
|
115
|
-
expect(histogramRecord).toHaveBeenCalledWith(
|
|
116
|
-
1.5,
|
|
117
|
-
expect.objectContaining({
|
|
118
|
-
ulid: "01HXYZ",
|
|
119
|
-
distinct_id: "user-123",
|
|
120
|
-
}),
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
const observe = vi.fn();
|
|
124
|
-
gaugeCallback?.({ observe });
|
|
125
|
-
expect(observe).toHaveBeenCalledWith(
|
|
126
|
-
3,
|
|
127
|
-
expect.objectContaining({
|
|
128
|
-
workspace: "a",
|
|
129
|
-
distinct_id: "user-123",
|
|
130
|
-
}),
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
adapter.recordGauge("cline.workspace.active_roots", null, {
|
|
134
|
-
workspace: "a",
|
|
135
|
-
});
|
|
136
|
-
const observeAfterRetire = vi.fn();
|
|
137
|
-
gaugeCallback?.({ observe: observeAfterRetire });
|
|
138
|
-
expect(observeAfterRetire).not.toHaveBeenCalled();
|
|
139
|
-
|
|
140
|
-
return Promise.all([adapter.flush(), adapter.dispose()]).then(() => {
|
|
141
|
-
expect(forceFlush).toHaveBeenCalledTimes(1);
|
|
142
|
-
expect(shutdown).toHaveBeenCalledTimes(1);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
function makeMetadata() {
|
|
148
|
-
return {
|
|
149
|
-
extension_version: "1.2.3",
|
|
150
|
-
cline_type: "cli",
|
|
151
|
-
platform: "terminal",
|
|
152
|
-
platform_version: "1.0.0",
|
|
153
|
-
os_type: "darwin",
|
|
154
|
-
os_version: "24.0.0",
|
|
155
|
-
is_dev: "true",
|
|
156
|
-
};
|
|
157
|
-
}
|