dsh-plugin-sessiongraph-native 0.1.22 → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CC ZHAO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Loader for the native Rust index kernel.
2
+ * Loader for the native Rust kernel: the index writer and the query engine.
3
3
  *
4
4
  * The kernel is a napi-rs `cdylib` (`sessiongraph-core.<platform>-<arch>.node`) built from
5
5
  * `crates/sessiongraph-core` and copied beside this module by `build-native.sh`. Nothing here may
@@ -73,6 +73,64 @@ export interface NativeIndexReport {
73
73
  /** Wall-clock duration of the run, milliseconds. */
74
74
  elapsedMs: number;
75
75
  }
76
+ /**
77
+ * One request to the native query kernel.
78
+ *
79
+ * Field names are snake_case because the Rust `QueryRequest` declares them so; the numeric fields are
80
+ * `number` (never BigInt) because napi maps `f64` to a JS number. The seam's request shape uses
81
+ * camelCase and different names (`after`/`before`), so the store's adapter translates.
82
+ */
83
+ export interface NativeQueryRequest {
84
+ /** Directory holding the index (`<indexRoot>/index.db`). */
85
+ index_root: string;
86
+ /** `search | session | event | trace | timeline | workspaces | status`. */
87
+ operation: string;
88
+ /** Search text. */
89
+ query?: string;
90
+ /** Full session id, or a prefix identifying exactly one session. */
91
+ session_id?: string;
92
+ /** Event sequence number (event; trace's event shape). */
93
+ seq?: number;
94
+ /** Page size. */
95
+ limit?: number;
96
+ /** Rows to skip. */
97
+ offset?: number;
98
+ /** Raw events before the target (event). */
99
+ window_before?: number;
100
+ /** Raw events after the target (event). */
101
+ window_after?: number;
102
+ /** Maximum descendant depth (trace's session shape). */
103
+ depth?: number;
104
+ /** Workspace filter (exact, or a prefix when it ends with `/`). */
105
+ workspace?: string;
106
+ /** Lower epoch-millisecond bound. */
107
+ since?: number;
108
+ /** Upper epoch-millisecond bound. */
109
+ until?: number;
110
+ /** Entry kinds to include (search). */
111
+ kinds?: string[];
112
+ /** One hit per session (default true). */
113
+ dedupe_by_session?: boolean;
114
+ /** Largest snippet, in UTF-16 code units (the store's `maxSnippetChars`, default 240). */
115
+ max_snippet_chars?: number;
116
+ }
117
+ /**
118
+ * One answer from the native query kernel.
119
+ *
120
+ * The result crosses as a JSON string in `payloadJson`: a raw event can be tens of kilobytes, and one
121
+ * `JSON.parse` costs less than converting every field across the napi boundary. A failure is reported
122
+ * as `ok: false` with the seam's error code rather than thrown, so the caller can fall back.
123
+ */
124
+ export interface NativeQueryResponse {
125
+ /** Whether the operation ran. */
126
+ ok: boolean;
127
+ /** Complete result JSON, or an empty string on failure. */
128
+ payload_json: string;
129
+ /** `SESSIONGRAPH_*` code when `ok` is false. */
130
+ error_code?: string;
131
+ /** Human-readable failure reason when `ok` is false. */
132
+ error_message?: string;
133
+ }
76
134
  /** The loaded native module's surface. */
77
135
  export interface NativeKernel {
78
136
  /**
@@ -86,6 +144,16 @@ export interface NativeKernel {
86
144
  * @throws when the index cannot be written; parse failures are reported, not thrown.
87
145
  */
88
146
  indexSessions(options: NativeIndexOptions): Promise<NativeIndexReport>;
147
+ /**
148
+ * Answer one query, off the JavaScript thread.
149
+ *
150
+ * Optional on the interface because a kernel built before the query export exists still loads:
151
+ * `typeof kernel.query === 'function'` is the store's probe, and a build without it falls back to
152
+ * the TypeScript store exactly as a missing binary does.
153
+ * @param request - the snake_case request the Rust side declares.
154
+ * @returns the response envelope, `ok: false` carrying any failure.
155
+ */
156
+ query?(request: NativeQueryRequest): Promise<NativeQueryResponse>;
89
157
  }
90
158
  /**
91
159
  * Load the native kernel, or report that this machine has none.
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Loader for the native Rust index kernel.
2
+ * Loader for the native Rust kernel: the index writer and the query engine.
3
3
  *
4
4
  * The kernel is a napi-rs `cdylib` (`sessiongraph-core.<platform>-<arch>.node`) built from
5
5
  * `crates/sessiongraph-core` and copied beside this module by `build-native.sh`. Nothing here may
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-sessiongraph-native",
3
- "version": "0.1.22",
3
+ "version": "0.2.0",
4
4
  "description": "Native Rust index kernel for DeepSeek Harness sessiongraph — scan, multi-frame zstd decode, JSONL parse and SQLite write, exposed to Node through napi-rs",
5
5
  "keywords": [
6
6
  "dsh",
@@ -44,18 +44,18 @@
44
44
  "access": "public",
45
45
  "provenance": false
46
46
  },
47
- "scripts": {
48
- "build": "tsc -b",
49
- "build:native": "./build-native.sh"
50
- },
51
47
  "devDependencies": {
52
48
  "@types/node": "^22.10.0"
53
49
  },
54
50
  "optionalDependencies": {
55
- "dsh-plugin-sessiongraph-indexer-darwin-arm64": "0.1.21",
56
- "dsh-plugin-sessiongraph-indexer-darwin-x64": "0.1.21",
57
- "dsh-plugin-sessiongraph-indexer-linux-x64-gnu": "0.1.21",
58
- "dsh-plugin-sessiongraph-indexer-linux-arm64-gnu": "0.1.21",
59
- "dsh-plugin-sessiongraph-indexer-win32-x64-msvc": "0.1.21"
51
+ "dsh-plugin-sessiongraph-indexer-darwin-arm64": "0.2.0",
52
+ "dsh-plugin-sessiongraph-indexer-darwin-x64": "0.2.0",
53
+ "dsh-plugin-sessiongraph-indexer-linux-x64-gnu": "0.2.0",
54
+ "dsh-plugin-sessiongraph-indexer-linux-arm64-gnu": "0.2.0",
55
+ "dsh-plugin-sessiongraph-indexer-win32-x64-msvc": "0.2.0"
56
+ },
57
+ "scripts": {
58
+ "build": "tsc -b",
59
+ "build:native": "./build-native.sh"
60
60
  }
61
- }
61
+ }