@runtimescope/collector 0.7.0 → 0.7.1
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/{chunk-6JZXAFPC.js → chunk-VZSMLTUQ.js} +70 -4
- package/dist/chunk-VZSMLTUQ.js.map +1 -0
- package/dist/index.d.ts +17 -3
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/standalone.js +30 -22
- package/dist/standalone.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6JZXAFPC.js.map +0 -1
|
@@ -583,6 +583,26 @@ var SqliteStore = class {
|
|
|
583
583
|
}
|
|
584
584
|
};
|
|
585
585
|
|
|
586
|
+
// src/sqlite-check.ts
|
|
587
|
+
import { createRequire } from "module";
|
|
588
|
+
var _checked = false;
|
|
589
|
+
var _available = false;
|
|
590
|
+
function isSqliteAvailable() {
|
|
591
|
+
if (_checked) return _available;
|
|
592
|
+
_checked = true;
|
|
593
|
+
try {
|
|
594
|
+
const require2 = createRequire(import.meta.url);
|
|
595
|
+
require2("better-sqlite3");
|
|
596
|
+
_available = true;
|
|
597
|
+
} catch {
|
|
598
|
+
_available = false;
|
|
599
|
+
console.error(
|
|
600
|
+
"[RuntimeScope] better-sqlite3 is not available \u2014 running in memory-only mode.\n[RuntimeScope] Historical data persistence is disabled. To fix this:\n[RuntimeScope] macOS: xcode-select --install\n[RuntimeScope] Ubuntu: sudo apt-get install build-essential python3\n[RuntimeScope] Windows: npm install --global windows-build-tools\n[RuntimeScope] Then run: npm rebuild better-sqlite3"
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
return _available;
|
|
604
|
+
}
|
|
605
|
+
|
|
586
606
|
// src/rate-limiter.ts
|
|
587
607
|
var SessionRateLimiter = class {
|
|
588
608
|
windows = /* @__PURE__ */ new Map();
|
|
@@ -804,6 +824,7 @@ var CollectorServer = class {
|
|
|
804
824
|
}
|
|
805
825
|
ensureSqliteStore(projectName) {
|
|
806
826
|
if (!this.projectManager) return null;
|
|
827
|
+
if (!isSqliteAvailable()) return null;
|
|
807
828
|
let sqliteStore = this.sqliteStores.get(projectName);
|
|
808
829
|
if (!sqliteStore) {
|
|
809
830
|
try {
|
|
@@ -914,6 +935,15 @@ var CollectorServer = class {
|
|
|
914
935
|
};
|
|
915
936
|
sqliteStore.saveSession(sessionInfo);
|
|
916
937
|
}
|
|
938
|
+
this.store.addEvent({
|
|
939
|
+
eventId: `session-${payload.sessionId}`,
|
|
940
|
+
sessionId: payload.sessionId,
|
|
941
|
+
timestamp: msg.timestamp,
|
|
942
|
+
eventType: "session",
|
|
943
|
+
appName: payload.appName,
|
|
944
|
+
connectedAt: msg.timestamp,
|
|
945
|
+
sdkVersion: payload.sdkVersion
|
|
946
|
+
});
|
|
917
947
|
console.error(
|
|
918
948
|
`[RuntimeScope] Session ${payload.sessionId} connected (${payload.appName} v${payload.sdkVersion})`
|
|
919
949
|
);
|
|
@@ -1732,7 +1762,7 @@ function createPmRouter(pmStore, discovery, helpers, broadcastDevServer) {
|
|
|
1732
1762
|
return;
|
|
1733
1763
|
}
|
|
1734
1764
|
try {
|
|
1735
|
-
await discovery.
|
|
1765
|
+
await discovery.indexProjectSessions(session.projectId);
|
|
1736
1766
|
const updated = pmStore.getSession(id);
|
|
1737
1767
|
helpers.json(res, updated);
|
|
1738
1768
|
} catch (err) {
|
|
@@ -2445,12 +2475,14 @@ var HttpServer = class {
|
|
|
2445
2475
|
sdkBundlePath = null;
|
|
2446
2476
|
activePort = 9091;
|
|
2447
2477
|
startedAt = Date.now();
|
|
2478
|
+
connectedSessionsGetter = null;
|
|
2448
2479
|
constructor(store, processMonitor, options) {
|
|
2449
2480
|
this.store = store;
|
|
2450
2481
|
this.processMonitor = processMonitor ?? null;
|
|
2451
2482
|
this.authManager = options?.authManager ?? null;
|
|
2452
2483
|
this.allowedOrigins = options?.allowedOrigins ?? null;
|
|
2453
2484
|
this.rateLimiter = options?.rateLimiter ?? null;
|
|
2485
|
+
this.connectedSessionsGetter = options?.getConnectedSessions ?? null;
|
|
2454
2486
|
this.registerRoutes();
|
|
2455
2487
|
if (options?.pmStore && options?.discovery) {
|
|
2456
2488
|
this.pmRouter = createPmRouter(options.pmStore, options.discovery, {
|
|
@@ -2491,6 +2523,24 @@ var HttpServer = class {
|
|
|
2491
2523
|
});
|
|
2492
2524
|
}
|
|
2493
2525
|
}
|
|
2526
|
+
if (this.connectedSessionsGetter) {
|
|
2527
|
+
for (const cs of this.connectedSessionsGetter()) {
|
|
2528
|
+
const existing = projectMap.get(cs.projectName);
|
|
2529
|
+
if (existing) {
|
|
2530
|
+
if (!existing.sessions.includes(cs.sessionId)) {
|
|
2531
|
+
existing.sessions.push(cs.sessionId);
|
|
2532
|
+
}
|
|
2533
|
+
existing.isConnected = true;
|
|
2534
|
+
} else {
|
|
2535
|
+
projectMap.set(cs.projectName, {
|
|
2536
|
+
appName: cs.projectName,
|
|
2537
|
+
sessions: [cs.sessionId],
|
|
2538
|
+
isConnected: true,
|
|
2539
|
+
eventCount: 0
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2494
2544
|
const projects = Array.from(projectMap.values());
|
|
2495
2545
|
this.json(res, { data: projects, count: projects.length });
|
|
2496
2546
|
});
|
|
@@ -3105,6 +3155,10 @@ var PmStore = class {
|
|
|
3105
3155
|
this.db.exec("ALTER TABLE pm_projects ADD COLUMN sdk_installed INTEGER DEFAULT 0");
|
|
3106
3156
|
} catch {
|
|
3107
3157
|
}
|
|
3158
|
+
try {
|
|
3159
|
+
this.db.exec("ALTER TABLE pm_projects ADD COLUMN runtime_apps TEXT DEFAULT NULL");
|
|
3160
|
+
} catch {
|
|
3161
|
+
}
|
|
3108
3162
|
}
|
|
3109
3163
|
// ============================================================
|
|
3110
3164
|
// Projects
|
|
@@ -3113,15 +3167,16 @@ var PmStore = class {
|
|
|
3113
3167
|
this.db.prepare(`
|
|
3114
3168
|
INSERT INTO pm_projects (id, name, path, claude_project_key, runtimescope_project,
|
|
3115
3169
|
phase, management_authorized, probable_to_complete, project_status,
|
|
3116
|
-
category, sdk_installed,
|
|
3170
|
+
category, sdk_installed, runtime_apps,
|
|
3117
3171
|
created_at, updated_at, metadata)
|
|
3118
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
3172
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
3119
3173
|
ON CONFLICT(id) DO UPDATE SET
|
|
3120
3174
|
name = excluded.name,
|
|
3121
3175
|
path = COALESCE(excluded.path, pm_projects.path),
|
|
3122
3176
|
claude_project_key = COALESCE(excluded.claude_project_key, pm_projects.claude_project_key),
|
|
3123
3177
|
runtimescope_project = COALESCE(excluded.runtimescope_project, pm_projects.runtimescope_project),
|
|
3124
3178
|
sdk_installed = CASE WHEN excluded.sdk_installed = 1 THEN 1 ELSE pm_projects.sdk_installed END,
|
|
3179
|
+
runtime_apps = COALESCE(excluded.runtime_apps, pm_projects.runtime_apps),
|
|
3125
3180
|
updated_at = excluded.updated_at,
|
|
3126
3181
|
metadata = COALESCE(excluded.metadata, pm_projects.metadata)
|
|
3127
3182
|
`).run(
|
|
@@ -3136,6 +3191,7 @@ var PmStore = class {
|
|
|
3136
3191
|
project.projectStatus,
|
|
3137
3192
|
project.category ?? null,
|
|
3138
3193
|
project.sdkInstalled ? 1 : 0,
|
|
3194
|
+
project.runtimeApps?.length ? JSON.stringify(project.runtimeApps) : null,
|
|
3139
3195
|
project.createdAt,
|
|
3140
3196
|
project.updatedAt,
|
|
3141
3197
|
project.metadata ? JSON.stringify(project.metadata) : null
|
|
@@ -3180,6 +3236,14 @@ var PmStore = class {
|
|
|
3180
3236
|
sets.push("sdk_installed = ?");
|
|
3181
3237
|
params.push(updates.sdkInstalled ? 1 : 0);
|
|
3182
3238
|
}
|
|
3239
|
+
if (updates.runtimeApps !== void 0) {
|
|
3240
|
+
sets.push("runtime_apps = ?");
|
|
3241
|
+
params.push(updates.runtimeApps.length ? JSON.stringify(updates.runtimeApps) : null);
|
|
3242
|
+
}
|
|
3243
|
+
if (updates.runtimescopeProject !== void 0) {
|
|
3244
|
+
sets.push("runtimescope_project = ?");
|
|
3245
|
+
params.push(updates.runtimescopeProject ?? null);
|
|
3246
|
+
}
|
|
3183
3247
|
if (updates.metadata !== void 0) {
|
|
3184
3248
|
sets.push("metadata = ?");
|
|
3185
3249
|
params.push(JSON.stringify(updates.metadata));
|
|
@@ -3201,6 +3265,7 @@ var PmStore = class {
|
|
|
3201
3265
|
path: row.path ?? void 0,
|
|
3202
3266
|
claudeProjectKey: row.claude_project_key ?? void 0,
|
|
3203
3267
|
runtimescopeProject: row.runtimescope_project ?? void 0,
|
|
3268
|
+
runtimeApps: row.runtime_apps ? JSON.parse(row.runtime_apps) : void 0,
|
|
3204
3269
|
phase: row.phase,
|
|
3205
3270
|
managementAuthorized: row.management_authorized === 1,
|
|
3206
3271
|
probableToComplete: row.probable_to_complete === 1,
|
|
@@ -4596,6 +4661,7 @@ export {
|
|
|
4596
4661
|
RingBuffer,
|
|
4597
4662
|
EventStore,
|
|
4598
4663
|
SqliteStore,
|
|
4664
|
+
isSqliteAvailable,
|
|
4599
4665
|
SessionRateLimiter,
|
|
4600
4666
|
loadTlsOptions,
|
|
4601
4667
|
resolveTlsConfig,
|
|
@@ -4613,4 +4679,4 @@ export {
|
|
|
4613
4679
|
parseSessionJsonl,
|
|
4614
4680
|
ProjectDiscovery
|
|
4615
4681
|
};
|
|
4616
|
-
//# sourceMappingURL=chunk-
|
|
4682
|
+
//# sourceMappingURL=chunk-VZSMLTUQ.js.map
|