forkit-connect 0.1.0

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.
Files changed (51) hide show
  1. package/QUICKSTART.md +55 -0
  2. package/README.md +96 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.js +4724 -0
  5. package/dist/index.d.ts +7 -0
  6. package/dist/index.js +21 -0
  7. package/dist/launcher.d.ts +33 -0
  8. package/dist/launcher.js +9344 -0
  9. package/dist/ps-list-loader.d.ts +5 -0
  10. package/dist/ps-list-loader.js +20 -0
  11. package/dist/v1/agent-observation.d.ts +42 -0
  12. package/dist/v1/agent-observation.js +499 -0
  13. package/dist/v1/api.d.ts +276 -0
  14. package/dist/v1/api.js +390 -0
  15. package/dist/v1/credential-store.d.ts +92 -0
  16. package/dist/v1/credential-store.js +797 -0
  17. package/dist/v1/currency.d.ts +41 -0
  18. package/dist/v1/currency.js +127 -0
  19. package/dist/v1/daemon.d.ts +50 -0
  20. package/dist/v1/daemon.js +265 -0
  21. package/dist/v1/discovery.d.ts +61 -0
  22. package/dist/v1/discovery.js +168 -0
  23. package/dist/v1/filesystem-models.d.ts +11 -0
  24. package/dist/v1/filesystem-models.js +261 -0
  25. package/dist/v1/heartbeat.d.ts +45 -0
  26. package/dist/v1/heartbeat.js +463 -0
  27. package/dist/v1/lifecycle-monitor.d.ts +78 -0
  28. package/dist/v1/lifecycle-monitor.js +512 -0
  29. package/dist/v1/lmstudio.d.ts +11 -0
  30. package/dist/v1/lmstudio.js +148 -0
  31. package/dist/v1/ollama.d.ts +19 -0
  32. package/dist/v1/ollama.js +164 -0
  33. package/dist/v1/openai-compatible.d.ts +12 -0
  34. package/dist/v1/openai-compatible.js +124 -0
  35. package/dist/v1/process-scout.d.ts +50 -0
  36. package/dist/v1/process-scout.js +715 -0
  37. package/dist/v1/providers.d.ts +50 -0
  38. package/dist/v1/providers.js +106 -0
  39. package/dist/v1/service.d.ts +680 -0
  40. package/dist/v1/service.js +8286 -0
  41. package/dist/v1/state.d.ts +87 -0
  42. package/dist/v1/state.js +1318 -0
  43. package/dist/v1/test-credential-backend.d.ts +19 -0
  44. package/dist/v1/test-credential-backend.js +49 -0
  45. package/dist/v1/types.d.ts +873 -0
  46. package/dist/v1/types.js +3 -0
  47. package/dist/v1/update.d.ts +38 -0
  48. package/dist/v1/update.js +184 -0
  49. package/dist/v1/vitality-pulse.d.ts +36 -0
  50. package/dist/v1/vitality-pulse.js +512 -0
  51. package/package.json +53 -0
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,38 @@
1
+ export interface ReleaseDownloadEntry {
2
+ url?: string | null;
3
+ checksumSha256?: string | null;
4
+ }
5
+ export interface ReleaseManifest {
6
+ latestVersion: string;
7
+ minimumSupportedVersion: string;
8
+ releaseDate: string;
9
+ releaseNotesUrl: string;
10
+ downloads: {
11
+ macos?: ReleaseDownloadEntry | null;
12
+ windows?: ReleaseDownloadEntry | null;
13
+ windowsMsi?: ReleaseDownloadEntry | null;
14
+ linuxAppImage?: ReleaseDownloadEntry | null;
15
+ linuxDeb?: ReleaseDownloadEntry | null;
16
+ };
17
+ updateMessage?: string | null;
18
+ }
19
+ export interface ReleaseCheckSuccess {
20
+ ok: true;
21
+ manifestUrl: string;
22
+ currentVersion: string;
23
+ manifest: ReleaseManifest;
24
+ availability: 'up-to-date' | 'update-available' | 'required-update';
25
+ downloadUrl: string | null;
26
+ }
27
+ export interface ReleaseCheckFailure {
28
+ ok: false;
29
+ manifestUrl: string;
30
+ currentVersion: string;
31
+ error: string;
32
+ }
33
+ export type ReleaseCheckResult = ReleaseCheckSuccess | ReleaseCheckFailure;
34
+ export declare function getCurrentConnectVersion(): string;
35
+ export declare function getReleaseManifestUrl(): string;
36
+ export declare function checkForUpdates(manifestUrl?: string): Promise<ReleaseCheckResult>;
37
+ export declare function formatUpdateCheckLines(result: ReleaseCheckResult): string[];
38
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getCurrentConnectVersion = getCurrentConnectVersion;
7
+ exports.getReleaseManifestUrl = getReleaseManifestUrl;
8
+ exports.checkForUpdates = checkForUpdates;
9
+ exports.formatUpdateCheckLines = formatUpdateCheckLines;
10
+ const node_fs_1 = __importDefault(require("node:fs"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const node_url_1 = require("node:url");
13
+ const DEFAULT_RELEASE_MANIFEST_URL = process.env.FORKIT_CONNECT_RELEASE_MANIFEST_URL ?? 'https://forkit.dev/connect/releases/latest.json';
14
+ function readPackageJsonVersion() {
15
+ try {
16
+ const packageJsonPath = node_path_1.default.resolve(__dirname, '..', '..', 'package.json');
17
+ const raw = node_fs_1.default.readFileSync(packageJsonPath, 'utf8');
18
+ const parsed = JSON.parse(raw);
19
+ return typeof parsed.version === 'string' && parsed.version.trim() ? parsed.version.trim() : '0.0.0';
20
+ }
21
+ catch {
22
+ return '0.0.0';
23
+ }
24
+ }
25
+ function parseVersion(version) {
26
+ const cleaned = String(version || '').trim().replace(/^v/i, '').split('-')[0] || '0.0.0';
27
+ const [major, minor, patch] = cleaned.split('.').map((value) => Number.parseInt(value || '0', 10));
28
+ return [major || 0, minor || 0, patch || 0];
29
+ }
30
+ function compareVersions(left, right) {
31
+ const [leftMajor, leftMinor, leftPatch] = parseVersion(left);
32
+ const [rightMajor, rightMinor, rightPatch] = parseVersion(right);
33
+ if (leftMajor > rightMajor)
34
+ return 1;
35
+ if (leftMajor < rightMajor)
36
+ return -1;
37
+ if (leftMinor > rightMinor)
38
+ return 1;
39
+ if (leftMinor < rightMinor)
40
+ return -1;
41
+ if (leftPatch > rightPatch)
42
+ return 1;
43
+ if (leftPatch < rightPatch)
44
+ return -1;
45
+ return 0;
46
+ }
47
+ function isReleaseManifest(value) {
48
+ if (!value || typeof value !== 'object')
49
+ return false;
50
+ const record = value;
51
+ return (typeof record.latestVersion === 'string'
52
+ && typeof record.minimumSupportedVersion === 'string'
53
+ && typeof record.releaseDate === 'string'
54
+ && typeof record.releaseNotesUrl === 'string'
55
+ && !!record.downloads
56
+ && typeof record.downloads === 'object');
57
+ }
58
+ function pickDownloadUrl(downloads) {
59
+ if (process.platform === 'darwin') {
60
+ return downloads.macos?.url || null;
61
+ }
62
+ if (process.platform === 'win32') {
63
+ return downloads.windows?.url || null;
64
+ }
65
+ return downloads.linuxAppImage?.url || downloads.linuxDeb?.url || null;
66
+ }
67
+ function getCurrentConnectVersion() {
68
+ return readPackageJsonVersion();
69
+ }
70
+ function getReleaseManifestUrl() {
71
+ return DEFAULT_RELEASE_MANIFEST_URL;
72
+ }
73
+ async function checkForUpdates(manifestUrl = getReleaseManifestUrl()) {
74
+ const currentVersion = getCurrentConnectVersion();
75
+ try {
76
+ if (manifestUrl.startsWith('file://')) {
77
+ const manifestPath = (0, node_url_1.fileURLToPath)(manifestUrl);
78
+ const raw = await node_fs_1.default.promises.readFile(manifestPath, 'utf8');
79
+ const body = JSON.parse(raw);
80
+ if (!isReleaseManifest(body)) {
81
+ return {
82
+ ok: false,
83
+ manifestUrl,
84
+ currentVersion,
85
+ error: 'invalid_manifest',
86
+ };
87
+ }
88
+ const minimumSupportedComparison = compareVersions(currentVersion, body.minimumSupportedVersion);
89
+ const latestComparison = compareVersions(currentVersion, body.latestVersion);
90
+ const availability = minimumSupportedComparison < 0
91
+ ? 'required-update'
92
+ : latestComparison < 0
93
+ ? 'update-available'
94
+ : 'up-to-date';
95
+ return {
96
+ ok: true,
97
+ manifestUrl,
98
+ currentVersion,
99
+ manifest: body,
100
+ availability,
101
+ downloadUrl: pickDownloadUrl(body.downloads),
102
+ };
103
+ }
104
+ const response = await fetch(manifestUrl, {
105
+ method: 'GET',
106
+ headers: {
107
+ Accept: 'application/json',
108
+ },
109
+ });
110
+ if (!response.ok) {
111
+ return {
112
+ ok: false,
113
+ manifestUrl,
114
+ currentVersion,
115
+ error: `manifest_http_${response.status}`,
116
+ };
117
+ }
118
+ const body = await response.json();
119
+ if (!isReleaseManifest(body)) {
120
+ return {
121
+ ok: false,
122
+ manifestUrl,
123
+ currentVersion,
124
+ error: 'invalid_manifest',
125
+ };
126
+ }
127
+ const minimumSupportedComparison = compareVersions(currentVersion, body.minimumSupportedVersion);
128
+ const latestComparison = compareVersions(currentVersion, body.latestVersion);
129
+ const availability = minimumSupportedComparison < 0
130
+ ? 'required-update'
131
+ : latestComparison < 0
132
+ ? 'update-available'
133
+ : 'up-to-date';
134
+ return {
135
+ ok: true,
136
+ manifestUrl,
137
+ currentVersion,
138
+ manifest: body,
139
+ availability,
140
+ downloadUrl: pickDownloadUrl(body.downloads),
141
+ };
142
+ }
143
+ catch (error) {
144
+ return {
145
+ ok: false,
146
+ manifestUrl,
147
+ currentVersion,
148
+ error: error instanceof Error ? error.message : 'manifest_fetch_failed',
149
+ };
150
+ }
151
+ }
152
+ function formatUpdateCheckLines(result) {
153
+ if (!result.ok) {
154
+ return [
155
+ 'Update check failed.',
156
+ `Manifest: ${result.manifestUrl}`,
157
+ `Reason: ${result.error}`,
158
+ ];
159
+ }
160
+ const lines = [];
161
+ if (result.availability === 'required-update') {
162
+ lines.push('Required update available.');
163
+ lines.push('This version is no longer supported.');
164
+ }
165
+ else if (result.availability === 'update-available') {
166
+ lines.push('Update available.');
167
+ }
168
+ else {
169
+ lines.push('Forkit Connect is up to date.');
170
+ }
171
+ lines.push(`Current version: ${result.currentVersion}`);
172
+ lines.push(`Latest version: ${result.manifest.latestVersion}`);
173
+ if (result.availability !== 'up-to-date') {
174
+ if (result.downloadUrl) {
175
+ lines.push(`Download: ${result.downloadUrl}`);
176
+ }
177
+ lines.push(`Release notes: ${result.manifest.releaseNotesUrl}`);
178
+ if (result.manifest.updateMessage) {
179
+ lines.push(`Message: ${result.manifest.updateMessage}`);
180
+ }
181
+ }
182
+ return lines;
183
+ }
184
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1,36 @@
1
+ import { type ProcessListEntry } from './process-scout';
2
+ import type { ConnectState, ProviderHealthStatus, PulseStatus, SanitizedProcessMetadata, VitalityPulseEvent, VitalityPulseSummary } from './types';
3
+ export interface RawProcessMetricsEntry extends ProcessListEntry {
4
+ cpu?: number;
5
+ memory?: number;
6
+ }
7
+ export interface GpuSample {
8
+ gpu_available: boolean;
9
+ gpu_vram_used_mb: number | null;
10
+ gpu_utilization_percent: number | null;
11
+ }
12
+ export interface VitalityPulseDependencies {
13
+ processScoutResults?: SanitizedProcessMetadata[];
14
+ processList?: () => Promise<RawProcessMetricsEntry[]>;
15
+ portChecker?: (endpoint: string) => Promise<boolean>;
16
+ gpuProbe?: () => Promise<GpuSample>;
17
+ processUptimeProbe?: (pid: number) => Promise<number | null>;
18
+ measuredAt?: string;
19
+ }
20
+ export declare function checkEndpointPortAlive(endpoint: string, timeoutMs?: number): Promise<boolean>;
21
+ export declare function probeGpuHealth(): Promise<GpuSample>;
22
+ export declare function classifyPulseStatus(input: {
23
+ inventoryOnly?: boolean;
24
+ knownRuntime: boolean;
25
+ providerStatus: ProviderHealthStatus;
26
+ portAlive: boolean | null;
27
+ processAlive: boolean | null;
28
+ cpuUsagePercent: number | null;
29
+ memoryUsageMb: number | null;
30
+ gpuAvailable: boolean;
31
+ gpuUtilizationPercent: number | null;
32
+ gpuVramUsedMb: number | null;
33
+ }): PulseStatus;
34
+ export declare function collectVitalityPulse(state: ConnectState, dependencies?: VitalityPulseDependencies): Promise<VitalityPulseSummary>;
35
+ export declare function buildPulseEvents(summary: VitalityPulseSummary): Array<Omit<VitalityPulseEvent, 'event_id'>>;
36
+ //# sourceMappingURL=vitality-pulse.d.ts.map