@codemem/pi-extension 0.0.0-alpha.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.
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Viewer discovery + auto-start + stream backoff (opencode-plugin pattern).
3
+ *
4
+ * Factory must not start processes — call ensureViewerRunning from session_start
5
+ * (or first need). stopViewerTracking is idempotent for session_shutdown.
6
+ */
7
+ import type { PiExtensionConfig } from "./config.js";
8
+ export type ViewerRuntime = {
9
+ /** True when this runtime started the viewer (for optional stop). */
10
+ startedByUs: boolean;
11
+ streamUnavailableUntil: number;
12
+ lastStatusCheckAt: number;
13
+ lastStatusAvailable: boolean;
14
+ };
15
+ export declare function createViewerRuntime(): ViewerRuntime;
16
+ export declare function rawEventsStatusUrl(config: PiExtensionConfig): string;
17
+ export declare function piHooksUrl(config: PiExtensionConfig): string;
18
+ export declare function packUrl(config: PiExtensionConfig): string;
19
+ export declare function promptPackProfileUrl(config: PiExtensionConfig): string;
20
+ export declare function apiUrl(config: PiExtensionConfig, path: string): string;
21
+ /** Resolve CODEMEM_DB the same way the OpenCode plugin does. */
22
+ export declare function resolveViewerDbPath(cwd: string, env?: NodeJS.ProcessEnv): string;
23
+ /** Duplicate of plugin runtime.js identity keys — do not import @codemem/core. */
24
+ export declare function buildViewerIdentityTarget(env?: NodeJS.ProcessEnv, cwd?: string): {
25
+ device_id: string | null;
26
+ actor_id_present: boolean;
27
+ actor_id: string | null;
28
+ config_path: string | null;
29
+ runtime_root: string | null;
30
+ workspace_id: string | null;
31
+ home_dir: string | null;
32
+ pack_compression: string | null;
33
+ embedding_disabled: boolean;
34
+ embedding_offline: boolean;
35
+ embedding_model: string;
36
+ embedding_revision: string | null;
37
+ };
38
+ export declare function viewerRequestTarget(cwd: string, env?: NodeJS.ProcessEnv): {
39
+ db_path: string;
40
+ identity_target: {
41
+ device_id: string | null;
42
+ actor_id_present: boolean;
43
+ actor_id: string | null;
44
+ config_path: string | null;
45
+ runtime_root: string | null;
46
+ workspace_id: string | null;
47
+ home_dir: string | null;
48
+ pack_compression: string | null;
49
+ embedding_disabled: boolean;
50
+ embedding_offline: boolean;
51
+ embedding_model: string;
52
+ embedding_revision: string | null;
53
+ };
54
+ };
55
+ export declare function isViewerTargetConflict(status: number, body: unknown): boolean;
56
+ export declare function profileMatchesViewerTarget(profile: unknown, dbPath: string, identity: unknown): boolean;
57
+ /** GET /api/prompt-pack-profile, then POST /api/pack with db_path + identity_target. */
58
+ export declare function proveAndPostPack(config: PiExtensionConfig, args: {
59
+ context: string;
60
+ cwd: string;
61
+ project: string | null;
62
+ signal: AbortSignal;
63
+ limit?: number;
64
+ tokenBudget?: number;
65
+ }): Promise<string>;
66
+ /** Probe viewer with a cheap GET. Returns true when reachable. */
67
+ export declare function probeViewer(config: PiExtensionConfig, signal?: AbortSignal): Promise<boolean>;
68
+ /**
69
+ * Auto-start `codemem serve start --host --port` when enabled and not already up.
70
+ * Fire-and-forget detached spawn (matches opencode-plugin).
71
+ */
72
+ export declare function ensureViewerRunning(config: PiExtensionConfig, runtime: ViewerRuntime, opts?: {
73
+ cwd?: string;
74
+ signal?: AbortSignal;
75
+ }): Promise<boolean>;
76
+ export declare function markStreamFailure(config: PiExtensionConfig, runtime: ViewerRuntime): void;
77
+ export declare function clearStreamFailure(runtime: ViewerRuntime): void;
78
+ export declare function isStreamInBackoff(runtime: ViewerRuntime): boolean;
79
+ /**
80
+ * Optional status check with caching (CODEMEM_RAW_EVENTS_STATUS_CHECK_MS).
81
+ * Returns false when ingest is known unavailable.
82
+ */
83
+ export declare function checkIngestAvailable(config: PiExtensionConfig, runtime: ViewerRuntime, signal?: AbortSignal): Promise<boolean>;
84
+ /** Idempotent session_shutdown cleanup — no hard kill of shared viewer by default. */
85
+ export declare function stopViewerTracking(runtime: ViewerRuntime): void;
86
+ //# sourceMappingURL=viewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["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;AACtF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAK/D"}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@codemem/pi-extension",
3
+ "version": "0.0.0-alpha.0",
4
+ "description": "CodeMem extension for the pi coding agent — ingest, injection, and native memory tools",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "source": "./src/index.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
22
+ "build": "pnpm exec vite build && pnpm exec tsc --build --force",
23
+ "typecheck": "pnpm exec tsc --noEmit",
24
+ "test": "pnpm exec vitest run"
25
+ },
26
+ "peerDependencies": {
27
+ "@earendil-works/pi-coding-agent": ">=0.84.1 <1",
28
+ "typebox": "*"
29
+ },
30
+ "devDependencies": {
31
+ "@codemem/core": "workspace:^",
32
+ "@earendil-works/pi-coding-agent": "^0.84.1",
33
+ "@types/node": "^24.12.4",
34
+ "typebox": "^1.3.7",
35
+ "typescript": "catalog:",
36
+ "vite": "catalog:",
37
+ "vitest": "catalog:"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/kunickiaj/codemem.git",
42
+ "directory": "packages/pi-extension"
43
+ },
44
+ "homepage": "https://github.com/kunickiaj/codemem",
45
+ "bugs": {
46
+ "url": "https://github.com/kunickiaj/codemem/issues"
47
+ },
48
+ "engines": {
49
+ "node": ">=24"
50
+ },
51
+ "license": "MIT",
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "keywords": [
56
+ "codemem",
57
+ "memory",
58
+ "ai",
59
+ "coding",
60
+ "agent",
61
+ "pi",
62
+ "pi-package"
63
+ ],
64
+ "pi": {
65
+ "extensions": [
66
+ "./dist/index.js"
67
+ ]
68
+ }
69
+ }