@creativeintelligence/abbie 0.1.5 → 0.1.7
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/bin/dev.js +1 -49
- package/bin/run.js +42 -49
- package/dist/cli/commands/login.js +26 -0
- package/dist/cli/commands/project/add.d.ts +0 -1
- package/dist/cli/commands/project/add.js +16 -52
- package/dist/cli/commands/project/list.js +13 -93
- package/dist/cli/commands/project/remove.d.ts +0 -2
- package/dist/cli/commands/project/remove.js +11 -28
- package/dist/cli/commands/session/list.js +3 -12
- package/dist/cli/commands/session/mark-done.js +1 -7
- package/dist/cli/commands/session/start.d.ts +0 -1
- package/dist/cli/commands/session/start.js +5 -7
- package/dist/lib/active-sessions.d.ts +0 -12
- package/dist/lib/active-sessions.js +6 -175
- package/dist/lib/project-path.d.ts +6 -0
- package/dist/lib/project-path.js +21 -0
- package/dist/lib.d.ts +1 -2
- package/dist/lib.js +2 -4
- package/oclif.manifest.json +2569 -6368
- package/package.json +1 -1
- package/dist/cli/commands/backlog/add.d.ts +0 -22
- package/dist/cli/commands/backlog/add.js +0 -65
- package/dist/cli/commands/backlog/claim.d.ts +0 -19
- package/dist/cli/commands/backlog/claim.js +0 -45
- package/dist/cli/commands/backlog/complete.d.ts +0 -18
- package/dist/cli/commands/backlog/complete.js +0 -42
- package/dist/cli/commands/backlog/list.d.ts +0 -20
- package/dist/cli/commands/backlog/list.js +0 -91
- package/dist/cli/commands/backlog/pick.d.ts +0 -18
- package/dist/cli/commands/backlog/pick.js +0 -42
- package/dist/cli/commands/backlog/sync.d.ts +0 -24
- package/dist/cli/commands/backlog/sync.js +0 -109
- package/dist/cli/commands/daemon.d.ts +0 -56
- package/dist/cli/commands/daemon.js +0 -1465
- package/dist/cli/commands/docs/lint.d.ts +0 -18
- package/dist/cli/commands/docs/lint.js +0 -82
- package/dist/cli/commands/docs/sync.d.ts +0 -19
- package/dist/cli/commands/docs/sync.js +0 -76
- package/dist/cli/commands/gc.d.ts +0 -29
- package/dist/cli/commands/gc.js +0 -211
- package/dist/cli/commands/index.d.ts +0 -36
- package/dist/cli/commands/index.js +0 -228
- package/dist/cli/commands/panes/broker.d.ts +0 -17
- package/dist/cli/commands/panes/broker.js +0 -57
- package/dist/cli/commands/panes/pipe-sink.d.ts +0 -17
- package/dist/cli/commands/panes/pipe-sink.js +0 -90
- package/dist/cli/commands/panes/snapshot.d.ts +0 -20
- package/dist/cli/commands/panes/snapshot.js +0 -125
- package/dist/cli/commands/preview/init.d.ts +0 -25
- package/dist/cli/commands/preview/init.js +0 -159
- package/dist/cli/commands/preview/sync.d.ts +0 -23
- package/dist/cli/commands/preview/sync.js +0 -144
- package/dist/cli/commands/preview/watch.d.ts +0 -24
- package/dist/cli/commands/preview/watch.js +0 -153
- package/dist/cli/commands/resource/acquire.d.ts +0 -21
- package/dist/cli/commands/resource/acquire.js +0 -90
- package/dist/cli/commands/resource/list.d.ts +0 -15
- package/dist/cli/commands/resource/list.js +0 -61
- package/dist/cli/commands/resource/release.d.ts +0 -18
- package/dist/cli/commands/resource/release.js +0 -50
- package/dist/cli/commands/resource/wait.d.ts +0 -21
- package/dist/cli/commands/resource/wait.js +0 -73
- package/dist/cli/commands/session/view.d.ts +0 -24
- package/dist/cli/commands/session/view.js +0 -145
- package/dist/cli/commands/start.d.ts +0 -37
- package/dist/cli/commands/start.js +0 -234
- package/dist/cli/commands/triage/claim.d.ts +0 -23
- package/dist/cli/commands/triage/claim.js +0 -186
- package/dist/cli/commands/triage/list.d.ts +0 -22
- package/dist/cli/commands/triage/list.js +0 -112
- package/dist/cli/commands/triage/next.d.ts +0 -18
- package/dist/cli/commands/triage/next.js +0 -63
- package/dist/cli/commands/triage/pull.d.ts +0 -19
- package/dist/cli/commands/triage/pull.js +0 -82
- package/dist/cli/commands/triage/stats.d.ts +0 -16
- package/dist/cli/commands/triage/stats.js +0 -69
- package/dist/cli/commands/tunnel/list.d.ts +0 -16
- package/dist/cli/commands/tunnel/list.js +0 -98
- package/dist/cli/commands/tunnel/start.d.ts +0 -24
- package/dist/cli/commands/tunnel/start.js +0 -107
- package/dist/cli/commands/tunnel/stop.d.ts +0 -20
- package/dist/cli/commands/tunnel/stop.js +0 -90
- package/dist/cli/commands/tunnel/url.d.ts +0 -21
- package/dist/cli/commands/tunnel/url.js +0 -70
- package/dist/cli/commands/windows/context.d.ts +0 -18
- package/dist/cli/commands/windows/context.js +0 -326
- package/dist/cli/commands/windows/focus.d.ts +0 -17
- package/dist/cli/commands/windows/focus.js +0 -103
- package/dist/cli/commands/windows/list.d.ts +0 -21
- package/dist/cli/commands/windows/list.js +0 -172
- package/dist/cli/commands/windows/map.d.ts +0 -17
- package/dist/cli/commands/windows/map.js +0 -168
- package/dist/cli/commands/windows/read.d.ts +0 -21
- package/dist/cli/commands/windows/read.js +0 -241
- package/dist/cli/commands/windows/search.d.ts +0 -24
- package/dist/cli/commands/windows/search.js +0 -171
- package/dist/cli/commands/windows/show.d.ts +0 -19
- package/dist/cli/commands/windows/show.js +0 -165
- package/dist/cli/commands/windows/watch.d.ts +0 -19
- package/dist/cli/commands/windows/watch.js +0 -241
- package/dist/lib/managed-session.d.ts +0 -27
- package/dist/lib/managed-session.js +0 -105
- package/dist/lib/panes/broker.d.ts +0 -130
- package/dist/lib/panes/broker.js +0 -97
- package/dist/lib/panes/index.d.ts +0 -2
- package/dist/lib/panes/index.js +0 -1
- package/dist/lib/panes/server.d.ts +0 -17
- package/dist/lib/panes/server.js +0 -308
- package/dist/lib/preview/manager.d.ts +0 -77
- package/dist/lib/preview/manager.js +0 -369
- package/dist/lib/preview/schema.d.ts +0 -2
- package/dist/lib/preview/schema.js +0 -32
- package/dist/lib/preview/sprite.d.ts +0 -85
- package/dist/lib/preview/sprite.js +0 -321
- package/dist/lib/preview/watcher.d.ts +0 -63
- package/dist/lib/preview/watcher.js +0 -185
- package/dist/lib/project-identity.d.ts +0 -16
- package/dist/lib/project-identity.js +0 -75
- package/dist/lib/tmux/bridge.d.ts +0 -133
- package/dist/lib/tmux/bridge.js +0 -315
- package/dist/lib/tmux/context.d.ts +0 -82
- package/dist/lib/tmux/context.js +0 -239
- package/dist/lib/tmux/index.d.ts +0 -8
- package/dist/lib/tmux/index.js +0 -11
- package/dist/lib/tmux/map.d.ts +0 -57
- package/dist/lib/tmux/map.js +0 -198
- package/dist/lib/tmux/panes.d.ts +0 -27
- package/dist/lib/tmux/panes.js +0 -151
- package/dist/lib/tmux/redaction.d.ts +0 -57
- package/dist/lib/tmux/redaction.js +0 -152
- package/dist/lib/web/analytics.d.ts +0 -63
- package/dist/lib/web/analytics.js +0 -168
- package/dist/lib/web/server.d.ts +0 -26
- package/dist/lib/web/server.js +0 -697
- package/dist/lib/web/tmux-bridge.d.ts +0 -7
- package/dist/lib/web/tmux-bridge.js +0 -7
- package/dist/lib/windows/index.d.ts +0 -3
- package/dist/lib/windows/index.js +0 -2
- package/dist/lib/windows/inventory.d.ts +0 -21
- package/dist/lib/windows/inventory.js +0 -263
- package/dist/lib/windows/types.d.ts +0 -46
- package/dist/lib/windows/types.js +0 -1
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redaction utilities for tmux context.
|
|
3
|
-
* Detects and redacts sensitive data like API keys, tokens, and credentials.
|
|
4
|
-
*/
|
|
5
|
-
export type RedactMode = "balanced" | "strict";
|
|
6
|
-
/**
|
|
7
|
-
* Redact sensitive tokens within a string.
|
|
8
|
-
*/
|
|
9
|
-
export declare function redactTokens(text: string): string;
|
|
10
|
-
/**
|
|
11
|
-
* Check if a line should be fully redacted.
|
|
12
|
-
*/
|
|
13
|
-
export declare function shouldRedactLine(line: string): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Redact a single line of text.
|
|
16
|
-
*/
|
|
17
|
-
export declare function redactLine(line: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Redact sensitive data from text content.
|
|
20
|
-
* In strict mode, redacts more aggressively.
|
|
21
|
-
*/
|
|
22
|
-
export declare function redactContent(text: string, _mode?: RedactMode): {
|
|
23
|
-
content: string;
|
|
24
|
-
wasRedacted: boolean;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Check if a command is considered sensitive.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isSensitiveCommand(command: string): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Filter patterns for deny/allow lists.
|
|
32
|
-
*/
|
|
33
|
-
export interface FilterConfig {
|
|
34
|
-
denySessions?: string[];
|
|
35
|
-
denyWindows?: string[];
|
|
36
|
-
denyPaths?: string[];
|
|
37
|
-
denyCommands?: string[];
|
|
38
|
-
includeSessions?: string[];
|
|
39
|
-
includeWindows?: string[];
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Check if a session should be filtered out.
|
|
43
|
-
*/
|
|
44
|
-
export declare function shouldFilterSession(sessionName: string, config: FilterConfig): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Check if a window should be filtered out.
|
|
47
|
-
*/
|
|
48
|
-
export declare function shouldFilterWindow(windowName: string, config: FilterConfig): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Check if a path should be filtered out.
|
|
51
|
-
*/
|
|
52
|
-
export declare function shouldFilterPath(path: string, config: FilterConfig): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Check if a command should be filtered out.
|
|
55
|
-
*/
|
|
56
|
-
export declare function shouldFilterCommand(command: string, config: FilterConfig): boolean;
|
|
57
|
-
//# sourceMappingURL=redaction.d.ts.map
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Redaction utilities for tmux context.
|
|
3
|
-
* Detects and redacts sensitive data like API keys, tokens, and credentials.
|
|
4
|
-
*/
|
|
5
|
-
const REDACTED_MARKER = "***REDACTED***";
|
|
6
|
-
/**
|
|
7
|
-
* Pattern definitions for sensitive data.
|
|
8
|
-
*/
|
|
9
|
-
const PATTERNS = {
|
|
10
|
-
// OpenAI/OpenRouter/Anthropic-style keys
|
|
11
|
-
openaiKey: /sk-[A-Za-z0-9_-]{16,}/g,
|
|
12
|
-
anthropicKey: /sk-ant-[A-Za-z0-9_-]{16,}/g,
|
|
13
|
-
// GitHub tokens
|
|
14
|
-
githubPat: /ghp_[A-Za-z0-9]{20,}/g,
|
|
15
|
-
githubPatNew: /github_pat_[A-Za-z0-9_]{20,}/g,
|
|
16
|
-
githubOther: /gh[ours]_[A-Za-z0-9]{20,}/g,
|
|
17
|
-
// Slack tokens
|
|
18
|
-
slackToken: /xox[baprs]-[A-Za-z0-9-]{10,}/g,
|
|
19
|
-
// URLs with user:pass
|
|
20
|
-
urlWithAuth: /https?:\/\/[^:]+:[^@]+@[^\s'"]+/g,
|
|
21
|
-
// PEM private keys (multiline)
|
|
22
|
-
pemKey: /-----BEGIN\s+(?:[A-Z\s]+)?PRIVATE\s+KEY-----[\s\S]*?-----END\s+(?:[A-Z\s]+)?PRIVATE\s+KEY-----/g,
|
|
23
|
-
// AWS keys
|
|
24
|
-
awsAccessKey: /AKIA[A-Z0-9]{16}/g,
|
|
25
|
-
// Generic secret-looking patterns (base64-ish long strings after common key names)
|
|
26
|
-
genericSecret: /(?:api[_-]?key|secret[_-]?key|access[_-]?token|auth[_-]?token)\s*[:=]\s*["']?[A-Za-z0-9+/=_-]{20,}["']?/gi,
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Line-level patterns that should cause entire line redaction.
|
|
30
|
-
*/
|
|
31
|
-
const LINE_PATTERNS = [
|
|
32
|
-
// Common secret assignments (case-insensitive)
|
|
33
|
-
// Matches: API_KEY=, SECRET=, SECRET_KEY=, PASSWORD=, AUTH_TOKEN=, PRIVATE_KEY=, etc.
|
|
34
|
-
/(?:\S*(?:API_KEY|SECRET|TOKEN|PASSWORD|PASS|PRIVATE_KEY)\S*)\s*=/i,
|
|
35
|
-
// export with secret names
|
|
36
|
-
/export\s+(?:\S*(?:KEY|TOKEN|SECRET|PASSWORD|PASS)\S*)\s*=/i,
|
|
37
|
-
];
|
|
38
|
-
/**
|
|
39
|
-
* Commands that typically contain sensitive output and should be fully redacted in strict mode.
|
|
40
|
-
*/
|
|
41
|
-
const SENSITIVE_COMMANDS = ["pass", "vault", "1password", "op", "aws configure"];
|
|
42
|
-
/**
|
|
43
|
-
* Redact sensitive tokens within a string.
|
|
44
|
-
*/
|
|
45
|
-
export function redactTokens(text) {
|
|
46
|
-
let result = text;
|
|
47
|
-
// Apply all token patterns
|
|
48
|
-
for (const pattern of Object.values(PATTERNS)) {
|
|
49
|
-
result = result.replace(pattern, REDACTED_MARKER);
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Check if a line should be fully redacted.
|
|
55
|
-
*/
|
|
56
|
-
export function shouldRedactLine(line) {
|
|
57
|
-
return LINE_PATTERNS.some((pattern) => pattern.test(line));
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Redact a single line of text.
|
|
61
|
-
*/
|
|
62
|
-
export function redactLine(line) {
|
|
63
|
-
// First check if entire line should be redacted
|
|
64
|
-
if (shouldRedactLine(line)) {
|
|
65
|
-
return REDACTED_MARKER;
|
|
66
|
-
}
|
|
67
|
-
// Otherwise, apply token-level redaction
|
|
68
|
-
return redactTokens(line);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Redact sensitive data from text content.
|
|
72
|
-
* In strict mode, redacts more aggressively.
|
|
73
|
-
*/
|
|
74
|
-
export function redactContent(text, _mode = "balanced") {
|
|
75
|
-
const lines = text.split("\n");
|
|
76
|
-
let wasRedacted = false;
|
|
77
|
-
const redactedLines = lines.map((line) => {
|
|
78
|
-
const redacted = redactLine(line);
|
|
79
|
-
if (redacted !== line) {
|
|
80
|
-
wasRedacted = true;
|
|
81
|
-
}
|
|
82
|
-
return redacted;
|
|
83
|
-
});
|
|
84
|
-
return {
|
|
85
|
-
content: redactedLines.join("\n"),
|
|
86
|
-
wasRedacted,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Check if a command is considered sensitive.
|
|
91
|
-
*/
|
|
92
|
-
export function isSensitiveCommand(command) {
|
|
93
|
-
const lowerCmd = command.toLowerCase();
|
|
94
|
-
return SENSITIVE_COMMANDS.some((sc) => lowerCmd.includes(sc));
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Check if a session should be filtered out.
|
|
98
|
-
*/
|
|
99
|
-
export function shouldFilterSession(sessionName, config) {
|
|
100
|
-
// If include list is specified, only include those
|
|
101
|
-
if (config.includeSessions?.length) {
|
|
102
|
-
return !config.includeSessions.some((pattern) => matchPattern(sessionName, pattern));
|
|
103
|
-
}
|
|
104
|
-
// Otherwise, check deny list
|
|
105
|
-
if (config.denySessions?.length) {
|
|
106
|
-
return config.denySessions.some((pattern) => matchPattern(sessionName, pattern));
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Check if a window should be filtered out.
|
|
112
|
-
*/
|
|
113
|
-
export function shouldFilterWindow(windowName, config) {
|
|
114
|
-
// If include list is specified, only include those
|
|
115
|
-
if (config.includeWindows?.length) {
|
|
116
|
-
return !config.includeWindows.some((pattern) => matchPattern(windowName, pattern));
|
|
117
|
-
}
|
|
118
|
-
// Otherwise, check deny list
|
|
119
|
-
if (config.denyWindows?.length) {
|
|
120
|
-
return config.denyWindows.some((pattern) => matchPattern(windowName, pattern));
|
|
121
|
-
}
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Check if a path should be filtered out.
|
|
126
|
-
*/
|
|
127
|
-
export function shouldFilterPath(path, config) {
|
|
128
|
-
if (config.denyPaths?.length) {
|
|
129
|
-
return config.denyPaths.some((pattern) => matchPattern(path, pattern));
|
|
130
|
-
}
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Check if a command should be filtered out.
|
|
135
|
-
*/
|
|
136
|
-
export function shouldFilterCommand(command, config) {
|
|
137
|
-
if (config.denyCommands?.length) {
|
|
138
|
-
return config.denyCommands.some((pattern) => matchPattern(command, pattern));
|
|
139
|
-
}
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Simple glob-like pattern matching (supports * wildcards).
|
|
144
|
-
*/
|
|
145
|
-
function matchPattern(value, pattern) {
|
|
146
|
-
// Convert glob pattern to regex
|
|
147
|
-
const regexPattern = pattern
|
|
148
|
-
.replace(/[.+^${}()|[\]\\]/g, "\\$&") // Escape special chars except *
|
|
149
|
-
.replace(/\*/g, ".*"); // Convert * to .*
|
|
150
|
-
const regex = new RegExp(`^${regexPattern}$`, "i");
|
|
151
|
-
return regex.test(value);
|
|
152
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web analytics integration for agents web server.
|
|
3
|
-
*
|
|
4
|
-
* Provides middleware for tracking API calls and utilities for
|
|
5
|
-
* browser-side PostHog initialization.
|
|
6
|
-
*/
|
|
7
|
-
import type { Hono as HonoApp, MiddlewareHandler } from "hono";
|
|
8
|
-
type HonoConstructor = new (...args: never[]) => HonoApp;
|
|
9
|
-
interface WebAnalyticsClient {
|
|
10
|
-
init(): Promise<void>;
|
|
11
|
-
trackPageView(path: string, properties?: Record<string, unknown>): void;
|
|
12
|
-
trackApiCall(endpoint: string, method: string, properties?: {
|
|
13
|
-
status_code?: number;
|
|
14
|
-
duration_ms?: number;
|
|
15
|
-
agent?: string;
|
|
16
|
-
session_id?: string;
|
|
17
|
-
}): void;
|
|
18
|
-
trackSessionInteraction(action: "viewed" | "started" | "stopped" | "prompted", properties?: {
|
|
19
|
-
session_id?: string;
|
|
20
|
-
agent?: string;
|
|
21
|
-
project?: string;
|
|
22
|
-
}): void;
|
|
23
|
-
trackTmuxInteraction(action: "window_selected" | "pane_viewed" | "keys_sent", properties?: {
|
|
24
|
-
window?: string;
|
|
25
|
-
pane?: number;
|
|
26
|
-
}): void;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Initialize web analytics. Safe to call multiple times.
|
|
30
|
-
*/
|
|
31
|
-
export declare function initWebAnalytics(): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Get the web analytics client.
|
|
34
|
-
*/
|
|
35
|
-
export declare function getWebAnalytics(): WebAnalyticsClient;
|
|
36
|
-
/**
|
|
37
|
-
* Convenience export for direct access.
|
|
38
|
-
*/
|
|
39
|
-
export declare const webAnalytics: WebAnalyticsClient;
|
|
40
|
-
/**
|
|
41
|
-
* Get Hono middleware for tracking API requests.
|
|
42
|
-
* Returns no-op middleware if analytics unavailable.
|
|
43
|
-
*/
|
|
44
|
-
export declare function getAnalyticsMiddleware(): MiddlewareHandler;
|
|
45
|
-
/**
|
|
46
|
-
* Create analytics API routes for Hono.
|
|
47
|
-
* Returns null if analytics unavailable.
|
|
48
|
-
*/
|
|
49
|
-
export declare function createAnalyticsRoutes(Hono: HonoConstructor): HonoApp | null;
|
|
50
|
-
/**
|
|
51
|
-
* Get PostHog configuration for browser client.
|
|
52
|
-
*/
|
|
53
|
-
export declare function getWebConfig(): Promise<{
|
|
54
|
-
enabled: boolean;
|
|
55
|
-
posthog_key: string;
|
|
56
|
-
api_host: string;
|
|
57
|
-
distinct_id: string;
|
|
58
|
-
} | null>;
|
|
59
|
-
/**
|
|
60
|
-
* Get browser-side PostHog initialization script.
|
|
61
|
-
*/
|
|
62
|
-
export declare function getBrowserScript(): Promise<string>;
|
|
63
|
-
export {};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web analytics integration for agents web server.
|
|
3
|
-
*
|
|
4
|
-
* Provides middleware for tracking API calls and utilities for
|
|
5
|
-
* browser-side PostHog initialization.
|
|
6
|
-
*/
|
|
7
|
-
import { accessSync, constants, existsSync, realpathSync } from "node:fs";
|
|
8
|
-
import { homedir } from "node:os";
|
|
9
|
-
import { delimiter, dirname, join } from "node:path";
|
|
10
|
-
import { pathToFileURL } from "node:url";
|
|
11
|
-
// No-op client when analytics unavailable
|
|
12
|
-
const noopWebAnalytics = {
|
|
13
|
-
init: async () => { },
|
|
14
|
-
trackPageView: () => { },
|
|
15
|
-
trackApiCall: () => { },
|
|
16
|
-
trackSessionInteraction: () => { },
|
|
17
|
-
trackTmuxInteraction: () => { },
|
|
18
|
-
};
|
|
19
|
-
let _webAnalytics = noopWebAnalytics;
|
|
20
|
-
let _analyticsMiddleware = null;
|
|
21
|
-
let _createAnalyticsRoutes = null;
|
|
22
|
-
let _getWebConfig = null;
|
|
23
|
-
let _getBrowserScript = null;
|
|
24
|
-
let initialized = false;
|
|
25
|
-
function findOnPath(cmd) {
|
|
26
|
-
const pathVar = process.env.PATH;
|
|
27
|
-
if (!pathVar)
|
|
28
|
-
return undefined;
|
|
29
|
-
for (const dir of pathVar.split(delimiter)) {
|
|
30
|
-
if (!dir)
|
|
31
|
-
continue;
|
|
32
|
-
const candidate = join(dir, cmd);
|
|
33
|
-
try {
|
|
34
|
-
accessSync(candidate, constants.X_OK);
|
|
35
|
-
return candidate;
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
// continue
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
function findAnalyticsWebPath() {
|
|
44
|
-
const envOverride = process.env.AGENTS_ANALYTICS_WEB_PATH;
|
|
45
|
-
if (envOverride && existsSync(envOverride)) {
|
|
46
|
-
return envOverride;
|
|
47
|
-
}
|
|
48
|
-
const analyticsBin = findOnPath("analytics");
|
|
49
|
-
if (analyticsBin) {
|
|
50
|
-
try {
|
|
51
|
-
const resolved = realpathSync(analyticsBin);
|
|
52
|
-
const root = join(dirname(resolved), "..");
|
|
53
|
-
const candidate = join(root, "dist", "lib", "web.js");
|
|
54
|
-
if (existsSync(candidate)) {
|
|
55
|
-
return candidate;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
// continue
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Common dev layout: ~/Developer/utils/analytics
|
|
63
|
-
const home = process.env.HOME || homedir();
|
|
64
|
-
const devCandidate = join(home, "Developer", "utils", "analytics", "dist", "lib", "web.js");
|
|
65
|
-
if (existsSync(devCandidate)) {
|
|
66
|
-
return devCandidate;
|
|
67
|
-
}
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Initialize web analytics. Safe to call multiple times.
|
|
72
|
-
*/
|
|
73
|
-
export async function initWebAnalytics() {
|
|
74
|
-
if (initialized)
|
|
75
|
-
return;
|
|
76
|
-
try {
|
|
77
|
-
const webPath = findAnalyticsWebPath();
|
|
78
|
-
if (!webPath) {
|
|
79
|
-
console.log("[analytics] web module not found - tracking disabled");
|
|
80
|
-
initialized = true;
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const mod = (await import(pathToFileURL(webPath).href));
|
|
84
|
-
await mod.webAnalytics.init();
|
|
85
|
-
_webAnalytics = mod.webAnalytics;
|
|
86
|
-
_analyticsMiddleware = mod.analyticsMiddleware;
|
|
87
|
-
_createAnalyticsRoutes = mod.createAnalyticsRoutes;
|
|
88
|
-
_getWebConfig = mod.getWebConfig;
|
|
89
|
-
_getBrowserScript = mod.getBrowserScript;
|
|
90
|
-
initialized = true;
|
|
91
|
-
console.log("[analytics] web tracking initialized");
|
|
92
|
-
}
|
|
93
|
-
catch (err) {
|
|
94
|
-
console.log("[analytics] failed to initialize:", err);
|
|
95
|
-
initialized = true;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get the web analytics client.
|
|
100
|
-
*/
|
|
101
|
-
export function getWebAnalytics() {
|
|
102
|
-
return _webAnalytics;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Convenience export for direct access.
|
|
106
|
-
*/
|
|
107
|
-
export const webAnalytics = new Proxy({}, {
|
|
108
|
-
get(_, prop) {
|
|
109
|
-
const record = _webAnalytics;
|
|
110
|
-
return record[prop];
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
/**
|
|
114
|
-
* Get Hono middleware for tracking API requests.
|
|
115
|
-
* Returns no-op middleware if analytics unavailable.
|
|
116
|
-
*/
|
|
117
|
-
export function getAnalyticsMiddleware() {
|
|
118
|
-
if (_analyticsMiddleware) {
|
|
119
|
-
return _analyticsMiddleware();
|
|
120
|
-
}
|
|
121
|
-
// No-op middleware
|
|
122
|
-
return async (_c, next) => {
|
|
123
|
-
await next();
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Create analytics API routes for Hono.
|
|
128
|
-
* Returns null if analytics unavailable.
|
|
129
|
-
*/
|
|
130
|
-
export function createAnalyticsRoutes(Hono) {
|
|
131
|
-
if (_createAnalyticsRoutes) {
|
|
132
|
-
return _createAnalyticsRoutes(Hono);
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Get PostHog configuration for browser client.
|
|
138
|
-
*/
|
|
139
|
-
export async function getWebConfig() {
|
|
140
|
-
if (_getWebConfig) {
|
|
141
|
-
const result = await _getWebConfig();
|
|
142
|
-
if (typeof result !== "object" || result === null)
|
|
143
|
-
return null;
|
|
144
|
-
const record = result;
|
|
145
|
-
if (typeof record.enabled !== "boolean" ||
|
|
146
|
-
typeof record.posthog_key !== "string" ||
|
|
147
|
-
typeof record.api_host !== "string" ||
|
|
148
|
-
typeof record.distinct_id !== "string") {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
enabled: record.enabled,
|
|
153
|
-
posthog_key: record.posthog_key,
|
|
154
|
-
api_host: record.api_host,
|
|
155
|
-
distinct_id: record.distinct_id,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Get browser-side PostHog initialization script.
|
|
162
|
-
*/
|
|
163
|
-
export async function getBrowserScript() {
|
|
164
|
-
if (_getBrowserScript) {
|
|
165
|
-
return _getBrowserScript();
|
|
166
|
-
}
|
|
167
|
-
return "<!-- Analytics disabled -->";
|
|
168
|
-
}
|
package/dist/lib/web/server.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Web server for agents web UI.
|
|
3
|
-
* Uses Hono for HTTP routing and Bun for WebSocket.
|
|
4
|
-
*/
|
|
5
|
-
export interface ServerOptions {
|
|
6
|
-
port: number;
|
|
7
|
-
host: string;
|
|
8
|
-
staticDir?: string;
|
|
9
|
-
}
|
|
10
|
-
/** Minimal WebSocket interface that works with Bun's ServerWebSocket */
|
|
11
|
-
interface WebSocketLike {
|
|
12
|
-
send(data: string | ArrayBufferLike | Blob | ArrayBufferView): number | undefined;
|
|
13
|
-
}
|
|
14
|
-
export interface WebSocketClient {
|
|
15
|
-
ws: WebSocketLike;
|
|
16
|
-
subscriptions: Set<string>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Broadcast a message to all subscribed clients.
|
|
20
|
-
*/
|
|
21
|
-
declare function broadcast(channel: string, data: unknown): void;
|
|
22
|
-
/**
|
|
23
|
-
* Create and start the web server.
|
|
24
|
-
*/
|
|
25
|
-
export declare function createServer(options: ServerOptions): Promise<Bun.Server<undefined>>;
|
|
26
|
-
export { broadcast };
|