@clinebot/core 0.0.7 → 0.0.10
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/auth/cline.d.ts +2 -0
- package/dist/auth/codex.d.ts +5 -1
- package/dist/auth/oca.d.ts +7 -1
- package/dist/auth/types.d.ts +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.node.d.ts +1 -0
- package/dist/index.node.js +164 -162
- package/dist/input/mention-enricher.d.ts +1 -0
- package/dist/providers/local-provider-service.d.ts +1 -1
- package/dist/runtime/session-runtime.d.ts +1 -1
- package/dist/session/default-session-manager.d.ts +13 -17
- package/dist/session/runtime-oauth-token-manager.d.ts +4 -2
- package/dist/session/session-agent-events.d.ts +15 -0
- package/dist/session/session-config-builder.d.ts +13 -0
- package/dist/session/session-manager.d.ts +2 -2
- package/dist/session/session-team-coordination.d.ts +12 -0
- package/dist/session/session-telemetry.d.ts +9 -0
- package/dist/session/unified-session-persistence-service.d.ts +12 -16
- package/dist/session/utils/helpers.d.ts +1 -1
- package/dist/session/utils/types.d.ts +1 -1
- package/dist/telemetry/core-events.d.ts +122 -0
- package/dist/tools/definitions.d.ts +1 -1
- package/dist/tools/executors/file-read.d.ts +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/presets.d.ts +1 -1
- package/dist/tools/schemas.d.ts +46 -3
- package/dist/tools/types.d.ts +3 -3
- package/dist/types/config.d.ts +1 -1
- package/dist/types/provider-settings.d.ts +4 -4
- package/dist/types.d.ts +1 -1
- package/package.json +4 -3
- package/src/auth/cline.ts +35 -1
- package/src/auth/codex.ts +27 -2
- package/src/auth/oca.ts +31 -4
- package/src/auth/types.ts +3 -0
- package/src/index.ts +27 -0
- package/src/input/mention-enricher.test.ts +3 -0
- package/src/input/mention-enricher.ts +3 -0
- package/src/providers/local-provider-service.ts +6 -7
- package/src/runtime/hook-file-hooks.ts +11 -10
- package/src/runtime/session-runtime.ts +1 -1
- package/src/session/default-session-manager.e2e.test.ts +2 -1
- package/src/session/default-session-manager.ts +367 -601
- package/src/session/runtime-oauth-token-manager.ts +21 -14
- package/src/session/session-agent-events.ts +159 -0
- package/src/session/session-config-builder.ts +111 -0
- package/src/session/session-host.ts +13 -0
- package/src/session/session-manager.ts +2 -2
- package/src/session/session-team-coordination.ts +198 -0
- package/src/session/session-telemetry.ts +95 -0
- package/src/session/unified-session-persistence-service.test.ts +81 -0
- package/src/session/unified-session-persistence-service.ts +470 -469
- package/src/session/utils/helpers.ts +1 -1
- package/src/session/utils/types.ts +1 -1
- package/src/storage/provider-settings-legacy-migration.ts +3 -3
- package/src/telemetry/core-events.ts +344 -0
- package/src/tools/definitions.test.ts +121 -7
- package/src/tools/definitions.ts +60 -24
- package/src/tools/executors/file-read.test.ts +29 -5
- package/src/tools/executors/file-read.ts +17 -6
- package/src/tools/index.ts +2 -0
- package/src/tools/presets.ts +1 -1
- package/src/tools/schemas.ts +65 -5
- package/src/tools/types.ts +7 -3
- package/src/types/config.ts +1 -1
- package/src/types/provider-settings.ts +6 -6
- package/src/types.ts +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
5
|
+
import { SqliteSessionStore } from "../storage/sqlite-session-store";
|
|
6
|
+
import { SessionSource } from "../types/common";
|
|
7
|
+
import { CoreSessionService } from "./session-service";
|
|
8
|
+
|
|
9
|
+
describe("UnifiedSessionPersistenceService", () => {
|
|
10
|
+
const tempDirs: string[] = [];
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
for (const dir of tempDirs.splice(0)) {
|
|
14
|
+
rmSync(dir, { recursive: true, force: true });
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("reconciles dead running sessions into failed manifests with terminal markers", async () => {
|
|
19
|
+
const sessionsDir = mkdtempSync(join(tmpdir(), "stale-session-reconcile-"));
|
|
20
|
+
tempDirs.push(sessionsDir);
|
|
21
|
+
|
|
22
|
+
const service = new CoreSessionService(
|
|
23
|
+
new SqliteSessionStore({ sessionsDir }),
|
|
24
|
+
);
|
|
25
|
+
const sessionId = "stale-root-session";
|
|
26
|
+
const artifacts = await service.createRootSessionWithArtifacts({
|
|
27
|
+
sessionId,
|
|
28
|
+
source: SessionSource.CLI,
|
|
29
|
+
pid: 999_999_999,
|
|
30
|
+
interactive: false,
|
|
31
|
+
provider: "mock-provider",
|
|
32
|
+
model: "mock-model",
|
|
33
|
+
cwd: "/tmp/project",
|
|
34
|
+
workspaceRoot: "/tmp/project",
|
|
35
|
+
enableTools: true,
|
|
36
|
+
enableSpawn: true,
|
|
37
|
+
enableTeams: false,
|
|
38
|
+
prompt: "hello",
|
|
39
|
+
startedAt: "2026-01-01T00:00:00.000Z",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const reconciled = await service.reconcileDeadSessions();
|
|
43
|
+
expect(reconciled).toBe(1);
|
|
44
|
+
|
|
45
|
+
const rows = await service.listSessions(10);
|
|
46
|
+
expect(rows).toHaveLength(1);
|
|
47
|
+
expect(rows[0]).toMatchObject({
|
|
48
|
+
session_id: sessionId,
|
|
49
|
+
status: "failed",
|
|
50
|
+
exit_code: 1,
|
|
51
|
+
});
|
|
52
|
+
expect(rows[0]?.ended_at).toBeTruthy();
|
|
53
|
+
|
|
54
|
+
const manifest = JSON.parse(
|
|
55
|
+
readFileSync(artifacts.manifestPath, "utf8"),
|
|
56
|
+
) as Record<string, unknown>;
|
|
57
|
+
expect(manifest.status).toBe("failed");
|
|
58
|
+
expect(manifest.exit_code).toBe(1);
|
|
59
|
+
expect(manifest.ended_at).toBeTruthy();
|
|
60
|
+
expect(manifest.metadata).toMatchObject({
|
|
61
|
+
terminal_marker: "failed_external_process_exit",
|
|
62
|
+
terminal_marker_pid: 999_999_999,
|
|
63
|
+
terminal_marker_source: "stale_session_reconciler",
|
|
64
|
+
});
|
|
65
|
+
expect(
|
|
66
|
+
(manifest.metadata as Record<string, unknown>).terminal_marker_at,
|
|
67
|
+
).toBeTruthy();
|
|
68
|
+
|
|
69
|
+
expect(existsSync(artifacts.hookPath)).toBe(true);
|
|
70
|
+
expect(existsSync(artifacts.transcriptPath)).toBe(true);
|
|
71
|
+
expect(readFileSync(artifacts.hookPath, "utf8")).toContain(
|
|
72
|
+
'"hookName":"session_shutdown"',
|
|
73
|
+
);
|
|
74
|
+
expect(readFileSync(artifacts.hookPath, "utf8")).toContain(
|
|
75
|
+
'"reason":"failed_external_process_exit"',
|
|
76
|
+
);
|
|
77
|
+
expect(readFileSync(artifacts.transcriptPath, "utf8")).toContain(
|
|
78
|
+
"[shutdown] failed_external_process_exit",
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
});
|