@agentdock/wire 0.0.38 → 0.0.39
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/agentCapabilities.js +1 -195
- package/dist/agentCommonEnv.js +1 -20
- package/dist/agentInstallGuide.js +1 -81
- package/dist/checkpointSchemas.js +1 -46
- package/dist/controlLevel.js +1 -11
- package/dist/edition.d.ts +5 -0
- package/dist/edition.js +1 -0
- package/dist/envelope.js +1 -78
- package/dist/errorMessage.js +1 -6
- package/dist/events.js +1 -97
- package/dist/features.d.ts +2 -0
- package/dist/features.js +1 -112
- package/dist/feedback.js +1 -26
- package/dist/index.d.ts +13 -4
- package/dist/index.js +1 -60
- package/dist/interactionEvents.js +1 -108
- package/dist/legacyProtocol.js +1 -30
- package/dist/license.d.ts +52 -0
- package/dist/license.js +1 -0
- package/dist/machine.d.ts +34 -0
- package/dist/machine.js +1 -56
- package/dist/messageMeta.js +1 -60
- package/dist/messages.d.ts +8 -8
- package/dist/messages.js +1 -35
- package/dist/ops.js +1 -74
- package/dist/pairing.js +1 -115
- package/dist/protocol.js +1 -7
- package/dist/rpc.d.ts +7 -7
- package/dist/rpc.js +1 -230
- package/dist/scheduledTasks.js +1 -81
- package/dist/semver.js +1 -60
- package/dist/sessionResult.js +1 -23
- package/dist/socketEvents.d.ts +1 -0
- package/dist/socketEvents.js +1 -43
- package/dist/spawnError.js +1 -31
- package/dist/stats.d.ts +28 -0
- package/dist/stats.js +1 -115
- package/dist/sync.d.ts +23 -23
- package/dist/sync.js +1 -78
- package/dist/telemetry.js +1 -80
- package/dist/utils.js +1 -2
- package/package.json +1 -1
- package/dist/agentCapabilities.d.ts.map +0 -1
- package/dist/agentCapabilities.js.map +0 -1
- package/dist/agentCommonEnv.d.ts.map +0 -1
- package/dist/agentCommonEnv.js.map +0 -1
- package/dist/agentInstallGuide.d.ts.map +0 -1
- package/dist/agentInstallGuide.js.map +0 -1
- package/dist/checkpointSchemas.d.ts.map +0 -1
- package/dist/checkpointSchemas.js.map +0 -1
- package/dist/controlLevel.d.ts.map +0 -1
- package/dist/controlLevel.js.map +0 -1
- package/dist/envelope.d.ts.map +0 -1
- package/dist/envelope.js.map +0 -1
- package/dist/errorMessage.d.ts.map +0 -1
- package/dist/errorMessage.js.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/features.d.ts.map +0 -1
- package/dist/features.js.map +0 -1
- package/dist/feedback.d.ts.map +0 -1
- package/dist/feedback.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/interactionEvents.d.ts.map +0 -1
- package/dist/interactionEvents.js.map +0 -1
- package/dist/legacyProtocol.d.ts.map +0 -1
- package/dist/legacyProtocol.js.map +0 -1
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js.map +0 -1
- package/dist/messageMeta.d.ts.map +0 -1
- package/dist/messageMeta.js.map +0 -1
- package/dist/messages.d.ts.map +0 -1
- package/dist/messages.js.map +0 -1
- package/dist/ops.d.ts.map +0 -1
- package/dist/ops.js.map +0 -1
- package/dist/pairing.d.ts.map +0 -1
- package/dist/pairing.js.map +0 -1
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js.map +0 -1
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js.map +0 -1
- package/dist/scheduledTasks.d.ts.map +0 -1
- package/dist/scheduledTasks.js.map +0 -1
- package/dist/semver.d.ts.map +0 -1
- package/dist/semver.js.map +0 -1
- package/dist/sessionResult.d.ts.map +0 -1
- package/dist/sessionResult.js.map +0 -1
- package/dist/socketEvents.d.ts.map +0 -1
- package/dist/socketEvents.js.map +0 -1
- package/dist/spawnError.d.ts.map +0 -1
- package/dist/spawnError.js.map +0 -1
- package/dist/stats.d.ts.map +0 -1
- package/dist/stats.js.map +0 -1
- package/dist/sync.d.ts.map +0 -1
- package/dist/sync.js.map +0 -1
- package/dist/telemetry.d.ts.map +0 -1
- package/dist/telemetry.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
package/dist/semver.js
CHANGED
|
@@ -1,60 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Minimal semver comparison utility.
|
|
3
|
-
*
|
|
4
|
-
* Handles standard semver (major.minor.patch) plus optional pre-release
|
|
5
|
-
* suffixes like `-alpha.1`. No npm dependency needed.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Parse a version string into its components.
|
|
9
|
-
*
|
|
10
|
-
* @returns SemverParts or null if the string doesn't contain a valid version.
|
|
11
|
-
*/
|
|
12
|
-
export function parseSemver(version) {
|
|
13
|
-
const match = version.match(/(\d+)\.(\d+)\.(\d+)(?:-(.+))?/);
|
|
14
|
-
if (!match)
|
|
15
|
-
return null;
|
|
16
|
-
return {
|
|
17
|
-
major: Number(match[1]),
|
|
18
|
-
minor: Number(match[2]),
|
|
19
|
-
patch: Number(match[3]),
|
|
20
|
-
prerelease: match[4],
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Compare two semver version strings.
|
|
25
|
-
*
|
|
26
|
-
* @returns -1 if a < b, 0 if a === b, 1 if a > b.
|
|
27
|
-
* Returns 0 if either version cannot be parsed.
|
|
28
|
-
*/
|
|
29
|
-
export function compareVersions(a, b) {
|
|
30
|
-
const pa = parseSemver(a);
|
|
31
|
-
const pb = parseSemver(b);
|
|
32
|
-
if (!pa || !pb)
|
|
33
|
-
return 0;
|
|
34
|
-
if (pa.major !== pb.major)
|
|
35
|
-
return pa.major > pb.major ? 1 : -1;
|
|
36
|
-
if (pa.minor !== pb.minor)
|
|
37
|
-
return pa.minor > pb.minor ? 1 : -1;
|
|
38
|
-
if (pa.patch !== pb.patch)
|
|
39
|
-
return pa.patch > pb.patch ? 1 : -1;
|
|
40
|
-
// Pre-release versions have lower precedence than release
|
|
41
|
-
if (pa.prerelease && !pb.prerelease)
|
|
42
|
-
return -1;
|
|
43
|
-
if (!pa.prerelease && pb.prerelease)
|
|
44
|
-
return 1;
|
|
45
|
-
// Both have prerelease — lexicographic compare
|
|
46
|
-
if (pa.prerelease && pb.prerelease) {
|
|
47
|
-
if (pa.prerelease < pb.prerelease)
|
|
48
|
-
return -1;
|
|
49
|
-
if (pa.prerelease > pb.prerelease)
|
|
50
|
-
return 1;
|
|
51
|
-
}
|
|
52
|
-
return 0;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Check if version `a` satisfies `>= minVersion`.
|
|
56
|
-
*/
|
|
57
|
-
export function satisfiesMin(version, minVersion) {
|
|
58
|
-
return compareVersions(version, minVersion) >= 0;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=semver.js.map
|
|
1
|
+
"use strict";export function parseSemver(t){const n=t.match(/(\d+)\.(\d+)\.(\d+)(?:-(.+))?/);return n?{major:Number(n[1]),minor:Number(n[2]),patch:Number(n[3]),prerelease:n[4]}:null}export function compareVersions(t,n){const e=parseSemver(t),r=parseSemver(n);if(!e||!r)return 0;if(e.major!==r.major)return e.major>r.major?1:-1;if(e.minor!==r.minor)return e.minor>r.minor?1:-1;if(e.patch!==r.patch)return e.patch>r.patch?1:-1;if(e.prerelease&&!r.prerelease)return-1;if(!e.prerelease&&r.prerelease)return 1;if(e.prerelease&&r.prerelease){if(e.prerelease<r.prerelease)return-1;if(e.prerelease>r.prerelease)return 1}return 0}export function satisfiesMin(t,n){return compareVersions(t,n)>=0}
|
package/dist/sessionResult.js
CHANGED
|
@@ -1,23 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Session result schema — data from Claude's `result` event.
|
|
3
|
-
*
|
|
4
|
-
* Emitted once per conversation turn, contains token usage, cost, and timing.
|
|
5
|
-
*/
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
export const SessionResultSchema = z.object({
|
|
8
|
-
/** Total cost in USD for this turn. */
|
|
9
|
-
totalCostUsd: z.number().optional(),
|
|
10
|
-
/** Input token count. */
|
|
11
|
-
inputTokens: z.number().int().nonnegative().optional(),
|
|
12
|
-
/** Output token count. */
|
|
13
|
-
outputTokens: z.number().int().nonnegative().optional(),
|
|
14
|
-
/** Duration in milliseconds. */
|
|
15
|
-
durationMs: z.number().nonnegative().optional(),
|
|
16
|
-
/** Claude-internal session ID. */
|
|
17
|
-
cliSessionId: z.string().optional(),
|
|
18
|
-
/** Whether the result represents an error. */
|
|
19
|
-
isError: z.boolean().optional(),
|
|
20
|
-
/** Number of conversation turns. */
|
|
21
|
-
numTurns: z.number().int().nonnegative().optional(),
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=sessionResult.js.map
|
|
1
|
+
"use strict";import{z as n}from"zod";export const SessionResultSchema=n.object({totalCostUsd:n.number().optional(),inputTokens:n.number().int().nonnegative().optional(),outputTokens:n.number().int().nonnegative().optional(),durationMs:n.number().nonnegative().optional(),cliSessionId:n.string().optional(),isError:n.boolean().optional(),numTurns:n.number().int().nonnegative().optional()});
|
package/dist/socketEvents.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const SOCKET_EVENTS: Readonly<{
|
|
|
11
11
|
readonly TELEMETRY_REPORT: "telemetry-report";
|
|
12
12
|
readonly UPDATE: "update";
|
|
13
13
|
readonly EPHEMERAL: "ephemeral";
|
|
14
|
+
readonly ENTERPRISE_ALERT: "enterprise-alert";
|
|
14
15
|
readonly SESSION_CREATE: "session-create";
|
|
15
16
|
readonly LIST_SESSIONS: "list-sessions";
|
|
16
17
|
readonly UPDATE_METADATA: "update-metadata";
|
package/dist/socketEvents.js
CHANGED
|
@@ -1,43 +1 @@
|
|
|
1
|
-
export const SOCKET_EVENTS
|
|
2
|
-
// server → client
|
|
3
|
-
SESSION_STATUS: 'session-status',
|
|
4
|
-
PERMISSION_RESOLVED: 'permission-resolved',
|
|
5
|
-
CORE_UPDATE: 'core-update',
|
|
6
|
-
USAGE_REPORT: 'usage-report',
|
|
7
|
-
RPC_REQUEST: 'rpc-request',
|
|
8
|
-
HISTORY_SYNC_RESULT: 'history-sync-result',
|
|
9
|
-
BACKFILL_PROGRESS: 'backfill-progress',
|
|
10
|
-
MACHINE_STATUS_UPDATE: 'machine-status-update',
|
|
11
|
-
DYNAMIC_MODES_UPDATED: 'dynamic-modes-updated',
|
|
12
|
-
TELEMETRY_REPORT: 'telemetry-report',
|
|
13
|
-
UPDATE: 'update',
|
|
14
|
-
EPHEMERAL: 'ephemeral',
|
|
15
|
-
// client → server: sessions
|
|
16
|
-
SESSION_CREATE: 'session-create',
|
|
17
|
-
LIST_SESSIONS: 'list-sessions',
|
|
18
|
-
UPDATE_METADATA: 'update-metadata',
|
|
19
|
-
UPDATE_STATE: 'update-state',
|
|
20
|
-
SESSION_ALIVE: 'session-alive',
|
|
21
|
-
PROVISION_SESSION_DEK: 'provision-session-dek',
|
|
22
|
-
RENAME_SESSION: 'rename-session',
|
|
23
|
-
SESSION_END: 'session-end',
|
|
24
|
-
SESSION_SUMMARY: 'session-summary',
|
|
25
|
-
// client → server: messages
|
|
26
|
-
GET_MESSAGES: 'get-messages',
|
|
27
|
-
MESSAGE: 'message',
|
|
28
|
-
BATCH_MESSAGE: 'batch-message',
|
|
29
|
-
// client → server: RPC
|
|
30
|
-
RPC_REGISTER: 'rpc-register',
|
|
31
|
-
RPC_UNREGISTER: 'rpc-unregister',
|
|
32
|
-
RPC_CALL: 'rpc-call',
|
|
33
|
-
// client → server: visibility
|
|
34
|
-
CLIENT_VISIBILITY: 'client-visibility',
|
|
35
|
-
// client → server: machines
|
|
36
|
-
MACHINE_REGISTER: 'machine-register',
|
|
37
|
-
MACHINE_HEARTBEAT: 'machine-heartbeat',
|
|
38
|
-
// client → server: history
|
|
39
|
-
GET_KNOWN_CLAUDE_SESSIONS: 'get-known-claude-sessions',
|
|
40
|
-
REGISTER_HISTORY_SESSIONS: 'register-history-sessions',
|
|
41
|
-
UPDATE_SYNC_STATUS: 'update-sync-status',
|
|
42
|
-
});
|
|
43
|
-
//# sourceMappingURL=socketEvents.js.map
|
|
1
|
+
"use strict";export const SOCKET_EVENTS=Object.freeze({SESSION_STATUS:"session-status",PERMISSION_RESOLVED:"permission-resolved",CORE_UPDATE:"core-update",USAGE_REPORT:"usage-report",RPC_REQUEST:"rpc-request",HISTORY_SYNC_RESULT:"history-sync-result",BACKFILL_PROGRESS:"backfill-progress",MACHINE_STATUS_UPDATE:"machine-status-update",DYNAMIC_MODES_UPDATED:"dynamic-modes-updated",TELEMETRY_REPORT:"telemetry-report",UPDATE:"update",EPHEMERAL:"ephemeral",ENTERPRISE_ALERT:"enterprise-alert",SESSION_CREATE:"session-create",LIST_SESSIONS:"list-sessions",UPDATE_METADATA:"update-metadata",UPDATE_STATE:"update-state",SESSION_ALIVE:"session-alive",PROVISION_SESSION_DEK:"provision-session-dek",RENAME_SESSION:"rename-session",SESSION_END:"session-end",SESSION_SUMMARY:"session-summary",GET_MESSAGES:"get-messages",MESSAGE:"message",BATCH_MESSAGE:"batch-message",RPC_REGISTER:"rpc-register",RPC_UNREGISTER:"rpc-unregister",RPC_CALL:"rpc-call",CLIENT_VISIBILITY:"client-visibility",MACHINE_REGISTER:"machine-register",MACHINE_HEARTBEAT:"machine-heartbeat",GET_KNOWN_CLAUDE_SESSIONS:"get-known-claude-sessions",REGISTER_HISTORY_SESSIONS:"register-history-sessions",UPDATE_SYNC_STATUS:"update-sync-status"});
|
package/dist/spawnError.js
CHANGED
|
@@ -1,31 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Structured spawn errors for agent CLI processes.
|
|
3
|
-
*
|
|
4
|
-
* Replaces opaque stderr dumps with actionable, machine-readable errors.
|
|
5
|
-
* Lives in wire so the web UI can render structured error cards.
|
|
6
|
-
*/
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import { AgentTypeSchema } from './messageMeta.js';
|
|
9
|
-
import { PlatformSchema } from './machine.js';
|
|
10
|
-
export const SpawnErrorCodeSchema = z.enum([
|
|
11
|
-
'agent-not-found',
|
|
12
|
-
'agent-version-too-old',
|
|
13
|
-
'agent-spawn-failed',
|
|
14
|
-
'agent-spawn-timeout',
|
|
15
|
-
]);
|
|
16
|
-
export const SpawnErrorSchema = z.object({
|
|
17
|
-
code: SpawnErrorCodeSchema,
|
|
18
|
-
/** User-facing message, e.g. "Claude CLI not found". */
|
|
19
|
-
message: z.string(),
|
|
20
|
-
/** Actionable detail, e.g. "Install: npm i -g @anthropic-ai/claude-code". */
|
|
21
|
-
detail: z.string(),
|
|
22
|
-
agentType: AgentTypeSchema,
|
|
23
|
-
platform: PlatformSchema,
|
|
24
|
-
detectedVersion: z.string().optional(),
|
|
25
|
-
minVersion: z.string().optional(),
|
|
26
|
-
});
|
|
27
|
-
/** Create a SpawnError object. */
|
|
28
|
-
export function createSpawnError(fields) {
|
|
29
|
-
return SpawnErrorSchema.parse(fields);
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=spawnError.js.map
|
|
1
|
+
"use strict";import{z as e}from"zod";import{AgentTypeSchema as t}from"./messageMeta.js";import{PlatformSchema as r}from"./machine.js";export const SpawnErrorCodeSchema=e.enum(["agent-not-found","agent-version-too-old","agent-spawn-failed","agent-spawn-timeout"]),SpawnErrorSchema=e.object({code:SpawnErrorCodeSchema,message:e.string(),detail:e.string(),agentType:t,platform:r,detectedVersion:e.string().optional(),minVersion:e.string().optional()});export function createSpawnError(o){return SpawnErrorSchema.parse(o)}
|
package/dist/stats.d.ts
CHANGED
|
@@ -2154,4 +2154,32 @@ export declare const ModelBreakdownEntrySchema: z.ZodObject<{
|
|
|
2154
2154
|
cacheCreationInputTokens: number;
|
|
2155
2155
|
}>;
|
|
2156
2156
|
export type ModelBreakdownEntry = z.infer<typeof ModelBreakdownEntrySchema>;
|
|
2157
|
+
export declare const QuotaConfigSchema: z.ZodObject<{
|
|
2158
|
+
dailyTokenLimit: z.ZodNullable<z.ZodNumber>;
|
|
2159
|
+
monthlyTokenLimit: z.ZodNullable<z.ZodNumber>;
|
|
2160
|
+
}, "strip", z.ZodTypeAny, {
|
|
2161
|
+
dailyTokenLimit: number | null;
|
|
2162
|
+
monthlyTokenLimit: number | null;
|
|
2163
|
+
}, {
|
|
2164
|
+
dailyTokenLimit: number | null;
|
|
2165
|
+
monthlyTokenLimit: number | null;
|
|
2166
|
+
}>;
|
|
2167
|
+
export type QuotaConfig = z.infer<typeof QuotaConfigSchema>;
|
|
2168
|
+
export declare const QuotaStatusSchema: z.ZodObject<{
|
|
2169
|
+
dailyUsed: z.ZodNumber;
|
|
2170
|
+
dailyLimit: z.ZodNullable<z.ZodNumber>;
|
|
2171
|
+
monthlyUsed: z.ZodNumber;
|
|
2172
|
+
monthlyLimit: z.ZodNullable<z.ZodNumber>;
|
|
2173
|
+
}, "strip", z.ZodTypeAny, {
|
|
2174
|
+
dailyUsed: number;
|
|
2175
|
+
dailyLimit: number | null;
|
|
2176
|
+
monthlyUsed: number;
|
|
2177
|
+
monthlyLimit: number | null;
|
|
2178
|
+
}, {
|
|
2179
|
+
dailyUsed: number;
|
|
2180
|
+
dailyLimit: number | null;
|
|
2181
|
+
monthlyUsed: number;
|
|
2182
|
+
monthlyLimit: number | null;
|
|
2183
|
+
}>;
|
|
2184
|
+
export type QuotaStatus = z.infer<typeof QuotaStatusSchema>;
|
|
2157
2185
|
//# sourceMappingURL=stats.d.ts.map
|
package/dist/stats.js
CHANGED
|
@@ -1,115 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Stats schemas for OBS-2 Activity Dashboard.
|
|
3
|
-
*
|
|
4
|
-
* Defines Zod schemas matching daemon ingest types,
|
|
5
|
-
* enabling type-safe RPC between web and daemon.
|
|
6
|
-
*/
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import { AgentTypeSchema } from './messageMeta.js';
|
|
9
|
-
export const ModelUsageEntrySchema = z.object({
|
|
10
|
-
inputTokens: z.number(),
|
|
11
|
-
outputTokens: z.number(),
|
|
12
|
-
cacheReadInputTokens: z.number(),
|
|
13
|
-
cacheCreationInputTokens: z.number(),
|
|
14
|
-
});
|
|
15
|
-
export const DailyActivitySchema = z.object({
|
|
16
|
-
date: z.string(),
|
|
17
|
-
messageCount: z.number(),
|
|
18
|
-
sessionCount: z.number(),
|
|
19
|
-
toolCallCount: z.number(),
|
|
20
|
-
});
|
|
21
|
-
export const DailyModelTokensSchema = z.object({
|
|
22
|
-
date: z.string(),
|
|
23
|
-
tokensByModel: z.record(z.number()),
|
|
24
|
-
});
|
|
25
|
-
export const LongestSessionSchema = z.object({
|
|
26
|
-
sessionId: z.string(),
|
|
27
|
-
duration: z.number(),
|
|
28
|
-
messageCount: z.number(),
|
|
29
|
-
timestamp: z.string(),
|
|
30
|
-
});
|
|
31
|
-
export const SessionTokenSummarySchema = z.object({
|
|
32
|
-
sessionId: z.string(),
|
|
33
|
-
projectPath: z.string(),
|
|
34
|
-
totalTokens: z.number(),
|
|
35
|
-
messageCount: z.number(),
|
|
36
|
-
startDate: z.string(),
|
|
37
|
-
sessionTitle: z.string().optional(),
|
|
38
|
-
});
|
|
39
|
-
export const ClaudeStatsDataSchema = z.object({
|
|
40
|
-
version: z.number(),
|
|
41
|
-
totalSessions: z.number(),
|
|
42
|
-
totalMessages: z.number(),
|
|
43
|
-
dailyActivity: z.array(DailyActivitySchema),
|
|
44
|
-
dailyModelTokens: z.array(DailyModelTokensSchema),
|
|
45
|
-
modelUsage: z.record(ModelUsageEntrySchema),
|
|
46
|
-
longestSession: LongestSessionSchema.nullable(),
|
|
47
|
-
firstSessionDate: z.string().nullable(),
|
|
48
|
-
hourCounts: z.record(z.number()),
|
|
49
|
-
topSessions: z.array(SessionTokenSummarySchema).optional(),
|
|
50
|
-
});
|
|
51
|
-
export const ProjectSummarySchema = z.object({
|
|
52
|
-
projectPath: z.string(),
|
|
53
|
-
sessionCount: z.number(),
|
|
54
|
-
subagentSessionCount: z.number(),
|
|
55
|
-
totalTokens: z.number().optional().default(0),
|
|
56
|
-
});
|
|
57
|
-
/** Per-agent-type usage summary for multi-agent stats. */
|
|
58
|
-
export const AgentTypeUsageSchema = z.object({
|
|
59
|
-
agentType: AgentTypeSchema,
|
|
60
|
-
totalSessions: z.number(),
|
|
61
|
-
totalMessages: z.number(),
|
|
62
|
-
totalTokens: z.number(),
|
|
63
|
-
/** True when the agent cannot report token data (e.g. Copilot ACP). */
|
|
64
|
-
tokensUnavailable: z.boolean().optional(),
|
|
65
|
-
/** Full stats breakdown for this agent type (enables per-agent charts). */
|
|
66
|
-
stats: ClaudeStatsDataSchema.nullable().optional(),
|
|
67
|
-
/** Per-agent project summaries (sessions belonging to this agent only). */
|
|
68
|
-
projects: z.array(ProjectSummarySchema).optional().default([]),
|
|
69
|
-
});
|
|
70
|
-
export const StatsOverviewSchema = z.object({
|
|
71
|
-
stats: ClaudeStatsDataSchema.nullable(),
|
|
72
|
-
projects: z.array(ProjectSummarySchema),
|
|
73
|
-
costEstimates: z.record(z.number()).optional().default({}),
|
|
74
|
-
totalEstimatedCost: z.number().optional().default(0),
|
|
75
|
-
agentType: AgentTypeSchema.optional().default('claude'),
|
|
76
|
-
/** Per-agent-type breakdown (multi-agent stats). */
|
|
77
|
-
agentTypeUsage: z.array(AgentTypeUsageSchema).optional().default([]),
|
|
78
|
-
});
|
|
79
|
-
// ── Date String (local helper) ──────────────────────────────
|
|
80
|
-
/** Date string in YYYY-MM-DD format. */
|
|
81
|
-
const DateStringSchema = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
82
|
-
// ── Activity Upload (daemon → server) ───────────────────────
|
|
83
|
-
export const ActivityUploadSchema = z.object({
|
|
84
|
-
date: DateStringSchema,
|
|
85
|
-
stats: StatsOverviewSchema,
|
|
86
|
-
machineId: z.string().min(1).optional(),
|
|
87
|
-
});
|
|
88
|
-
// ── Usage Report (daemon → server, real-time per-message) ───
|
|
89
|
-
export const UsageReportSchema = z.object({
|
|
90
|
-
sessionId: z.string().min(1),
|
|
91
|
-
model: z.string().default('unknown'),
|
|
92
|
-
tokens: z.object({
|
|
93
|
-
inputTokens: z.number().int().nonnegative(),
|
|
94
|
-
outputTokens: z.number().int().nonnegative(),
|
|
95
|
-
cacheReadInputTokens: z.number().int().nonnegative().default(0),
|
|
96
|
-
cacheCreationInputTokens: z.number().int().nonnegative().default(0),
|
|
97
|
-
}),
|
|
98
|
-
});
|
|
99
|
-
// ── Token Trend Point ───────────────────────────────────────
|
|
100
|
-
export const TokenTrendPointSchema = z.object({
|
|
101
|
-
date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
102
|
-
totalTokens: z.number().nonnegative(),
|
|
103
|
-
inputTokens: z.number().nonnegative(),
|
|
104
|
-
outputTokens: z.number().nonnegative(),
|
|
105
|
-
byModel: z.record(z.number()).default({}),
|
|
106
|
-
});
|
|
107
|
-
// ── Model Breakdown Entry ───────────────────────────────────
|
|
108
|
-
export const ModelBreakdownEntrySchema = z.object({
|
|
109
|
-
model: z.string().min(1),
|
|
110
|
-
inputTokens: z.number().nonnegative(),
|
|
111
|
-
outputTokens: z.number().nonnegative(),
|
|
112
|
-
cacheReadInputTokens: z.number().nonnegative(),
|
|
113
|
-
cacheCreationInputTokens: z.number().nonnegative(),
|
|
114
|
-
});
|
|
115
|
-
//# sourceMappingURL=stats.js.map
|
|
1
|
+
"use strict";import{z as e}from"zod";import{AgentTypeSchema as n}from"./messageMeta.js";export const ModelUsageEntrySchema=e.object({inputTokens:e.number(),outputTokens:e.number(),cacheReadInputTokens:e.number(),cacheCreationInputTokens:e.number()}),DailyActivitySchema=e.object({date:e.string(),messageCount:e.number(),sessionCount:e.number(),toolCallCount:e.number()}),DailyModelTokensSchema=e.object({date:e.string(),tokensByModel:e.record(e.number())}),LongestSessionSchema=e.object({sessionId:e.string(),duration:e.number(),messageCount:e.number(),timestamp:e.string()}),SessionTokenSummarySchema=e.object({sessionId:e.string(),projectPath:e.string(),totalTokens:e.number(),messageCount:e.number(),startDate:e.string(),sessionTitle:e.string().optional()}),ClaudeStatsDataSchema=e.object({version:e.number(),totalSessions:e.number(),totalMessages:e.number(),dailyActivity:e.array(DailyActivitySchema),dailyModelTokens:e.array(DailyModelTokensSchema),modelUsage:e.record(ModelUsageEntrySchema),longestSession:LongestSessionSchema.nullable(),firstSessionDate:e.string().nullable(),hourCounts:e.record(e.number()),topSessions:e.array(SessionTokenSummarySchema).optional()}),ProjectSummarySchema=e.object({projectPath:e.string(),sessionCount:e.number(),subagentSessionCount:e.number(),totalTokens:e.number().optional().default(0)}),AgentTypeUsageSchema=e.object({agentType:n,totalSessions:e.number(),totalMessages:e.number(),totalTokens:e.number(),tokensUnavailable:e.boolean().optional(),stats:ClaudeStatsDataSchema.nullable().optional(),projects:e.array(ProjectSummarySchema).optional().default([])}),StatsOverviewSchema=e.object({stats:ClaudeStatsDataSchema.nullable(),projects:e.array(ProjectSummarySchema),costEstimates:e.record(e.number()).optional().default({}),totalEstimatedCost:e.number().optional().default(0),agentType:n.optional().default("claude"),agentTypeUsage:e.array(AgentTypeUsageSchema).optional().default([])});const t=e.string().regex(/^\d{4}-\d{2}-\d{2}$/);export const ActivityUploadSchema=e.object({date:t,stats:StatsOverviewSchema,machineId:e.string().min(1).optional()}),UsageReportSchema=e.object({sessionId:e.string().min(1),model:e.string().default("unknown"),tokens:e.object({inputTokens:e.number().int().nonnegative(),outputTokens:e.number().int().nonnegative(),cacheReadInputTokens:e.number().int().nonnegative().default(0),cacheCreationInputTokens:e.number().int().nonnegative().default(0)})}),TokenTrendPointSchema=e.object({date:e.string().regex(/^\d{4}-\d{2}-\d{2}$/),totalTokens:e.number().nonnegative(),inputTokens:e.number().nonnegative(),outputTokens:e.number().nonnegative(),byModel:e.record(e.number()).default({})}),ModelBreakdownEntrySchema=e.object({model:e.string().min(1),inputTokens:e.number().nonnegative(),outputTokens:e.number().nonnegative(),cacheReadInputTokens:e.number().nonnegative(),cacheCreationInputTokens:e.number().nonnegative()}),QuotaConfigSchema=e.object({dailyTokenLimit:e.number().int().positive().nullable(),monthlyTokenLimit:e.number().int().positive().nullable()}),QuotaStatusSchema=e.object({dailyUsed:e.number().nonnegative(),dailyLimit:e.number().int().positive().nullable(),monthlyUsed:e.number().nonnegative(),monthlyLimit:e.number().int().positive().nullable()});
|
package/dist/sync.d.ts
CHANGED
|
@@ -46,12 +46,12 @@ export declare const UpdateNewMessageBodySchema: z.ZodObject<{
|
|
|
46
46
|
localId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
47
47
|
content: z.ZodObject<{
|
|
48
48
|
c: z.ZodString;
|
|
49
|
-
t: z.
|
|
49
|
+
t: z.ZodEnum<["encrypted", "plaintext"]>;
|
|
50
50
|
}, "strip", z.ZodTypeAny, {
|
|
51
|
-
t: "encrypted";
|
|
51
|
+
t: "encrypted" | "plaintext";
|
|
52
52
|
c: string;
|
|
53
53
|
}, {
|
|
54
|
-
t: "encrypted";
|
|
54
|
+
t: "encrypted" | "plaintext";
|
|
55
55
|
c: string;
|
|
56
56
|
}>;
|
|
57
57
|
createdAt: z.ZodNumber;
|
|
@@ -59,7 +59,7 @@ export declare const UpdateNewMessageBodySchema: z.ZodObject<{
|
|
|
59
59
|
}, "strip", z.ZodTypeAny, {
|
|
60
60
|
id: string;
|
|
61
61
|
content: {
|
|
62
|
-
t: "encrypted";
|
|
62
|
+
t: "encrypted" | "plaintext";
|
|
63
63
|
c: string;
|
|
64
64
|
};
|
|
65
65
|
seq: number;
|
|
@@ -69,7 +69,7 @@ export declare const UpdateNewMessageBodySchema: z.ZodObject<{
|
|
|
69
69
|
}, {
|
|
70
70
|
id: string;
|
|
71
71
|
content: {
|
|
72
|
-
t: "encrypted";
|
|
72
|
+
t: "encrypted" | "plaintext";
|
|
73
73
|
c: string;
|
|
74
74
|
};
|
|
75
75
|
seq: number;
|
|
@@ -81,7 +81,7 @@ export declare const UpdateNewMessageBodySchema: z.ZodObject<{
|
|
|
81
81
|
message: {
|
|
82
82
|
id: string;
|
|
83
83
|
content: {
|
|
84
|
-
t: "encrypted";
|
|
84
|
+
t: "encrypted" | "plaintext";
|
|
85
85
|
c: string;
|
|
86
86
|
};
|
|
87
87
|
seq: number;
|
|
@@ -95,7 +95,7 @@ export declare const UpdateNewMessageBodySchema: z.ZodObject<{
|
|
|
95
95
|
message: {
|
|
96
96
|
id: string;
|
|
97
97
|
content: {
|
|
98
|
-
t: "encrypted";
|
|
98
|
+
t: "encrypted" | "plaintext";
|
|
99
99
|
c: string;
|
|
100
100
|
};
|
|
101
101
|
seq: number;
|
|
@@ -280,12 +280,12 @@ export declare const CoreUpdateBodySchema: z.ZodDiscriminatedUnion<"t", [z.ZodOb
|
|
|
280
280
|
localId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
281
281
|
content: z.ZodObject<{
|
|
282
282
|
c: z.ZodString;
|
|
283
|
-
t: z.
|
|
283
|
+
t: z.ZodEnum<["encrypted", "plaintext"]>;
|
|
284
284
|
}, "strip", z.ZodTypeAny, {
|
|
285
|
-
t: "encrypted";
|
|
285
|
+
t: "encrypted" | "plaintext";
|
|
286
286
|
c: string;
|
|
287
287
|
}, {
|
|
288
|
-
t: "encrypted";
|
|
288
|
+
t: "encrypted" | "plaintext";
|
|
289
289
|
c: string;
|
|
290
290
|
}>;
|
|
291
291
|
createdAt: z.ZodNumber;
|
|
@@ -293,7 +293,7 @@ export declare const CoreUpdateBodySchema: z.ZodDiscriminatedUnion<"t", [z.ZodOb
|
|
|
293
293
|
}, "strip", z.ZodTypeAny, {
|
|
294
294
|
id: string;
|
|
295
295
|
content: {
|
|
296
|
-
t: "encrypted";
|
|
296
|
+
t: "encrypted" | "plaintext";
|
|
297
297
|
c: string;
|
|
298
298
|
};
|
|
299
299
|
seq: number;
|
|
@@ -303,7 +303,7 @@ export declare const CoreUpdateBodySchema: z.ZodDiscriminatedUnion<"t", [z.ZodOb
|
|
|
303
303
|
}, {
|
|
304
304
|
id: string;
|
|
305
305
|
content: {
|
|
306
|
-
t: "encrypted";
|
|
306
|
+
t: "encrypted" | "plaintext";
|
|
307
307
|
c: string;
|
|
308
308
|
};
|
|
309
309
|
seq: number;
|
|
@@ -315,7 +315,7 @@ export declare const CoreUpdateBodySchema: z.ZodDiscriminatedUnion<"t", [z.ZodOb
|
|
|
315
315
|
message: {
|
|
316
316
|
id: string;
|
|
317
317
|
content: {
|
|
318
|
-
t: "encrypted";
|
|
318
|
+
t: "encrypted" | "plaintext";
|
|
319
319
|
c: string;
|
|
320
320
|
};
|
|
321
321
|
seq: number;
|
|
@@ -329,7 +329,7 @@ export declare const CoreUpdateBodySchema: z.ZodDiscriminatedUnion<"t", [z.ZodOb
|
|
|
329
329
|
message: {
|
|
330
330
|
id: string;
|
|
331
331
|
content: {
|
|
332
|
-
t: "encrypted";
|
|
332
|
+
t: "encrypted" | "plaintext";
|
|
333
333
|
c: string;
|
|
334
334
|
};
|
|
335
335
|
seq: number;
|
|
@@ -511,12 +511,12 @@ export declare const CoreUpdateContainerSchema: z.ZodObject<{
|
|
|
511
511
|
localId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
512
512
|
content: z.ZodObject<{
|
|
513
513
|
c: z.ZodString;
|
|
514
|
-
t: z.
|
|
514
|
+
t: z.ZodEnum<["encrypted", "plaintext"]>;
|
|
515
515
|
}, "strip", z.ZodTypeAny, {
|
|
516
|
-
t: "encrypted";
|
|
516
|
+
t: "encrypted" | "plaintext";
|
|
517
517
|
c: string;
|
|
518
518
|
}, {
|
|
519
|
-
t: "encrypted";
|
|
519
|
+
t: "encrypted" | "plaintext";
|
|
520
520
|
c: string;
|
|
521
521
|
}>;
|
|
522
522
|
createdAt: z.ZodNumber;
|
|
@@ -524,7 +524,7 @@ export declare const CoreUpdateContainerSchema: z.ZodObject<{
|
|
|
524
524
|
}, "strip", z.ZodTypeAny, {
|
|
525
525
|
id: string;
|
|
526
526
|
content: {
|
|
527
|
-
t: "encrypted";
|
|
527
|
+
t: "encrypted" | "plaintext";
|
|
528
528
|
c: string;
|
|
529
529
|
};
|
|
530
530
|
seq: number;
|
|
@@ -534,7 +534,7 @@ export declare const CoreUpdateContainerSchema: z.ZodObject<{
|
|
|
534
534
|
}, {
|
|
535
535
|
id: string;
|
|
536
536
|
content: {
|
|
537
|
-
t: "encrypted";
|
|
537
|
+
t: "encrypted" | "plaintext";
|
|
538
538
|
c: string;
|
|
539
539
|
};
|
|
540
540
|
seq: number;
|
|
@@ -546,7 +546,7 @@ export declare const CoreUpdateContainerSchema: z.ZodObject<{
|
|
|
546
546
|
message: {
|
|
547
547
|
id: string;
|
|
548
548
|
content: {
|
|
549
|
-
t: "encrypted";
|
|
549
|
+
t: "encrypted" | "plaintext";
|
|
550
550
|
c: string;
|
|
551
551
|
};
|
|
552
552
|
seq: number;
|
|
@@ -560,7 +560,7 @@ export declare const CoreUpdateContainerSchema: z.ZodObject<{
|
|
|
560
560
|
message: {
|
|
561
561
|
id: string;
|
|
562
562
|
content: {
|
|
563
|
-
t: "encrypted";
|
|
563
|
+
t: "encrypted" | "plaintext";
|
|
564
564
|
c: string;
|
|
565
565
|
};
|
|
566
566
|
seq: number;
|
|
@@ -738,7 +738,7 @@ export declare const CoreUpdateContainerSchema: z.ZodObject<{
|
|
|
738
738
|
message: {
|
|
739
739
|
id: string;
|
|
740
740
|
content: {
|
|
741
|
-
t: "encrypted";
|
|
741
|
+
t: "encrypted" | "plaintext";
|
|
742
742
|
c: string;
|
|
743
743
|
};
|
|
744
744
|
seq: number;
|
|
@@ -801,7 +801,7 @@ export declare const CoreUpdateContainerSchema: z.ZodObject<{
|
|
|
801
801
|
message: {
|
|
802
802
|
id: string;
|
|
803
803
|
content: {
|
|
804
|
-
t: "encrypted";
|
|
804
|
+
t: "encrypted" | "plaintext";
|
|
805
805
|
c: string;
|
|
806
806
|
};
|
|
807
807
|
seq: number;
|
package/dist/sync.js
CHANGED
|
@@ -1,78 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Sync update protocol — aligned with Happy messages.ts.
|
|
3
|
-
*
|
|
4
|
-
* Defines CoreUpdateContainer and its body types for real-time state sync.
|
|
5
|
-
*/
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
import { SessionMessageSchema } from './messages.js';
|
|
8
|
-
import { PlatformSchema } from './machine.js';
|
|
9
|
-
// ── Versioned encrypted values ──────────────────────────────────────
|
|
10
|
-
export const VersionedEncryptedValueSchema = z.object({
|
|
11
|
-
version: z.number(),
|
|
12
|
-
value: z.string(),
|
|
13
|
-
});
|
|
14
|
-
export const VersionedNullableEncryptedValueSchema = z.object({
|
|
15
|
-
version: z.number(),
|
|
16
|
-
value: z.string().nullable(),
|
|
17
|
-
});
|
|
18
|
-
export const VersionedMachineEncryptedValueSchema = z.object({
|
|
19
|
-
version: z.number(),
|
|
20
|
-
value: z.string(),
|
|
21
|
-
});
|
|
22
|
-
// ── Update body types ───────────────────────────────────────────────
|
|
23
|
-
export const UpdateNewMessageBodySchema = z.object({
|
|
24
|
-
t: z.literal('new-message'),
|
|
25
|
-
sid: z.string(),
|
|
26
|
-
message: SessionMessageSchema,
|
|
27
|
-
});
|
|
28
|
-
export const UpdateSessionBodySchema = z.object({
|
|
29
|
-
t: z.literal('update-session'),
|
|
30
|
-
id: z.string(),
|
|
31
|
-
tag: z.string().optional(),
|
|
32
|
-
displayName: z.string().nullish(),
|
|
33
|
-
machineId: z.string().optional(),
|
|
34
|
-
metadata: VersionedEncryptedValueSchema.nullish(),
|
|
35
|
-
agentState: VersionedNullableEncryptedValueSchema.nullish(),
|
|
36
|
-
active: z.boolean().optional(),
|
|
37
|
-
/** Session source — promoted from 'history' to 'managed' on resume. */
|
|
38
|
-
source: z.enum(['managed', 'history', 'scheduled']).optional(),
|
|
39
|
-
/** Base64-encoded wrapped DEK — only present on session-create broadcast. */
|
|
40
|
-
dataEncryptionKey: z.string().nullish(),
|
|
41
|
-
});
|
|
42
|
-
export const UpdateMachineBodySchema = z.object({
|
|
43
|
-
t: z.literal('update-machine'),
|
|
44
|
-
machineId: z.string(),
|
|
45
|
-
metadata: VersionedMachineEncryptedValueSchema.nullish(),
|
|
46
|
-
daemonState: VersionedMachineEncryptedValueSchema.nullish(),
|
|
47
|
-
active: z.boolean().optional(),
|
|
48
|
-
activeAt: z.number().optional(),
|
|
49
|
-
hostname: z.string().optional(),
|
|
50
|
-
platform: PlatformSchema.optional(),
|
|
51
|
-
arch: z.string().optional(),
|
|
52
|
-
daemonVersion: z.string().optional(),
|
|
53
|
-
displayName: z.string().optional(),
|
|
54
|
-
availableAgents: z.array(z.string()).optional(),
|
|
55
|
-
supportedMethods: z.array(z.string()).optional(),
|
|
56
|
-
disconnectReason: z.enum(['normal', 'upgrade-required']).optional(),
|
|
57
|
-
upgradeStatus: z.enum(['idle', 'preflight', 'downloading', 'switching', 'failed']).optional(),
|
|
58
|
-
upgradeError: z.string().optional(),
|
|
59
|
-
superseded: z.boolean().optional(),
|
|
60
|
-
});
|
|
61
|
-
export const UpdateSessionResetBodySchema = z.object({
|
|
62
|
-
t: z.literal('session-reset'),
|
|
63
|
-
sessionId: z.string(),
|
|
64
|
-
});
|
|
65
|
-
export const CoreUpdateBodySchema = z.discriminatedUnion('t', [
|
|
66
|
-
UpdateNewMessageBodySchema,
|
|
67
|
-
UpdateSessionBodySchema,
|
|
68
|
-
UpdateMachineBodySchema,
|
|
69
|
-
UpdateSessionResetBodySchema,
|
|
70
|
-
]);
|
|
71
|
-
// ── Update container ────────────────────────────────────────────────
|
|
72
|
-
export const CoreUpdateContainerSchema = z.object({
|
|
73
|
-
id: z.string(),
|
|
74
|
-
seq: z.number(),
|
|
75
|
-
body: CoreUpdateBodySchema,
|
|
76
|
-
createdAt: z.number(),
|
|
77
|
-
});
|
|
78
|
-
//# sourceMappingURL=sync.js.map
|
|
1
|
+
"use strict";import{z as e}from"zod";import{SessionMessageSchema as t}from"./messages.js";import{PlatformSchema as o}from"./machine.js";export const VersionedEncryptedValueSchema=e.object({version:e.number(),value:e.string()}),VersionedNullableEncryptedValueSchema=e.object({version:e.number(),value:e.string().nullable()}),VersionedMachineEncryptedValueSchema=e.object({version:e.number(),value:e.string()}),UpdateNewMessageBodySchema=e.object({t:e.literal("new-message"),sid:e.string(),message:t}),UpdateSessionBodySchema=e.object({t:e.literal("update-session"),id:e.string(),tag:e.string().optional(),displayName:e.string().nullish(),machineId:e.string().optional(),metadata:VersionedEncryptedValueSchema.nullish(),agentState:VersionedNullableEncryptedValueSchema.nullish(),active:e.boolean().optional(),source:e.enum(["managed","history","scheduled"]).optional(),dataEncryptionKey:e.string().nullish()}),UpdateMachineBodySchema=e.object({t:e.literal("update-machine"),machineId:e.string(),metadata:VersionedMachineEncryptedValueSchema.nullish(),daemonState:VersionedMachineEncryptedValueSchema.nullish(),active:e.boolean().optional(),activeAt:e.number().optional(),hostname:e.string().optional(),platform:o.optional(),arch:e.string().optional(),daemonVersion:e.string().optional(),displayName:e.string().optional(),availableAgents:e.array(e.string()).optional(),supportedMethods:e.array(e.string()).optional(),disconnectReason:e.enum(["normal","upgrade-required"]).optional(),upgradeStatus:e.enum(["idle","preflight","downloading","switching","failed"]).optional(),upgradeError:e.string().optional(),superseded:e.boolean().optional()}),UpdateSessionResetBodySchema=e.object({t:e.literal("session-reset"),sessionId:e.string()}),CoreUpdateBodySchema=e.discriminatedUnion("t",[UpdateNewMessageBodySchema,UpdateSessionBodySchema,UpdateMachineBodySchema,UpdateSessionResetBodySchema]),CoreUpdateContainerSchema=e.object({id:e.string(),seq:e.number(),body:CoreUpdateBodySchema,createdAt:e.number()});
|
package/dist/telemetry.js
CHANGED
|
@@ -1,80 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// ── Telemetry Event Types ──────────────────────────────────
|
|
3
|
-
export const TelemetryEventTypeSchema = z.enum([
|
|
4
|
-
'scanner.format_mismatch',
|
|
5
|
-
'scanner.parse_error',
|
|
6
|
-
'scanner.version_unknown',
|
|
7
|
-
'session.start_failed',
|
|
8
|
-
'session.crash',
|
|
9
|
-
'rpc.call_failed',
|
|
10
|
-
'upgrade.failed',
|
|
11
|
-
'protocol.incompatible',
|
|
12
|
-
]);
|
|
13
|
-
// ── Context Allowlist (per event type) ─────────────────────
|
|
14
|
-
const CONTEXT_ALLOWLIST = {
|
|
15
|
-
'scanner.format_mismatch': [
|
|
16
|
-
'filePath',
|
|
17
|
-
'totalLines',
|
|
18
|
-
'parsedLines',
|
|
19
|
-
'errorCount',
|
|
20
|
-
'unknownLines',
|
|
21
|
-
'samples',
|
|
22
|
-
],
|
|
23
|
-
'scanner.parse_error': ['filePath', 'totalLines', 'errorCount', 'error', 'lineNumber'],
|
|
24
|
-
'scanner.version_unknown': ['detectedVersion', 'supportedRange'],
|
|
25
|
-
'session.start_failed': ['cwd', 'agentBinary', 'exitCode', 'stderr'],
|
|
26
|
-
'session.crash': ['exitCode', 'signal', 'stderr', 'agentType'],
|
|
27
|
-
'rpc.call_failed': ['method', 'error'],
|
|
28
|
-
'upgrade.failed': ['fromVersion', 'toVersion', 'stage', 'error'],
|
|
29
|
-
'protocol.incompatible': ['clientVersion', 'serverVersion', 'minRequired'],
|
|
30
|
-
};
|
|
31
|
-
const SENSITIVE_PATTERN = /\b(?:\d{1,3}\.){3}\d{1,3}\b|[\w.+-]+@[\w.-]+\.\w+|\b(?:Bearer|token|sk-|api[_-]?key)\s*[:=]?\s*\S+/gi;
|
|
32
|
-
function sanitizeValue(val) {
|
|
33
|
-
if (typeof val === 'string') {
|
|
34
|
-
return val.replace(SENSITIVE_PATTERN, '[REDACTED]');
|
|
35
|
-
}
|
|
36
|
-
if (Array.isArray(val)) {
|
|
37
|
-
return val.map(sanitizeValue);
|
|
38
|
-
}
|
|
39
|
-
if (typeof val === 'number' || typeof val === 'boolean' || val === null) {
|
|
40
|
-
return val;
|
|
41
|
-
}
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
export function sanitizeContext(type, ctx) {
|
|
45
|
-
if (!ctx)
|
|
46
|
-
return undefined;
|
|
47
|
-
const allowed = CONTEXT_ALLOWLIST[type];
|
|
48
|
-
if (!allowed)
|
|
49
|
-
return undefined;
|
|
50
|
-
const result = {};
|
|
51
|
-
for (const key of allowed) {
|
|
52
|
-
if (key in ctx) {
|
|
53
|
-
const sanitized = sanitizeValue(ctx[key]);
|
|
54
|
-
if (sanitized !== undefined) {
|
|
55
|
-
result[key] = sanitized;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (typeof result['stderr'] === 'string' && result['stderr'].length > 500) {
|
|
60
|
-
result['stderr'] = result['stderr'].slice(0, 500);
|
|
61
|
-
}
|
|
62
|
-
return Object.keys(result).length > 0 ? result : undefined;
|
|
63
|
-
}
|
|
64
|
-
// ── Telemetry Event Schema ─────────────────────────────────
|
|
65
|
-
export const TelemetryEventSchema = z.object({
|
|
66
|
-
type: TelemetryEventTypeSchema,
|
|
67
|
-
timestamp: z.string(),
|
|
68
|
-
agentType: z.string().optional(),
|
|
69
|
-
agentVersion: z.string().optional(),
|
|
70
|
-
daemonVersion: z.string(),
|
|
71
|
-
code: z.string(),
|
|
72
|
-
message: z.string(),
|
|
73
|
-
context: z.record(z.unknown()).optional(),
|
|
74
|
-
});
|
|
75
|
-
// ── Batch Report Payload ───────────────────────────────────
|
|
76
|
-
export const TelemetryReportPayloadSchema = z.object({
|
|
77
|
-
machineId: z.string(),
|
|
78
|
-
events: z.array(TelemetryEventSchema).max(100),
|
|
79
|
-
});
|
|
80
|
-
//# sourceMappingURL=telemetry.js.map
|
|
1
|
+
"use strict";import{z as e}from"zod";export const TelemetryEventTypeSchema=e.enum(["scanner.format_mismatch","scanner.parse_error","scanner.version_unknown","session.start_failed","session.crash","rpc.call_failed","upgrade.failed","protocol.incompatible"]);const c={"scanner.format_mismatch":["filePath","totalLines","parsedLines","errorCount","unknownLines","samples"],"scanner.parse_error":["filePath","totalLines","errorCount","error","lineNumber"],"scanner.version_unknown":["detectedVersion","supportedRange"],"session.start_failed":["cwd","agentBinary","exitCode","stderr"],"session.crash":["exitCode","signal","stderr","agentType"],"rpc.call_failed":["method","error"],"upgrade.failed":["fromVersion","toVersion","stage","error"],"protocol.incompatible":["clientVersion","serverVersion","minRequired"]},d=/\b(?:\d{1,3}\.){3}\d{1,3}\b|[\w.+-]+@[\w.-]+\.\w+|\b(?:Bearer|token|sk-|api[_-]?key)\s*[:=]?\s*\S+/gi;function a(r){if(typeof r=="string")return r.replace(d,"[REDACTED]");if(Array.isArray(r))return r.map(a);if(typeof r=="number"||typeof r=="boolean"||r===null)return r}export function sanitizeContext(r,t){if(!t)return;const s=c[r];if(!s)return;const n={};for(const o of s)if(o in t){const i=a(t[o]);i!==void 0&&(n[o]=i)}return typeof n.stderr=="string"&&n.stderr.length>500&&(n.stderr=n.stderr.slice(0,500)),Object.keys(n).length>0?n:void 0}export const TelemetryEventSchema=e.object({type:TelemetryEventTypeSchema,timestamp:e.string(),agentType:e.string().optional(),agentVersion:e.string().optional(),daemonVersion:e.string(),code:e.string(),message:e.string(),context:e.record(e.unknown()).optional()}),TelemetryReportPayloadSchema=e.object({machineId:e.string(),events:e.array(TelemetryEventSchema).max(100)});
|