@lensagent/core 0.1.0 → 0.1.2
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/README.md +63 -4
- package/config/lens.example.jsonc +36 -13
- package/dist/adapters/executor-router.d.ts +20 -0
- package/dist/adapters/executor-router.js +86 -0
- package/dist/adapters/executor.d.ts +9 -3
- package/dist/adapters/executor.js +196 -61
- package/dist/adapters/lsp.d.ts +2 -1
- package/dist/adapters/lsp.js +98 -41
- package/dist/adapters/mcp.js +52 -17
- package/dist/adapters/revert.d.ts +5 -4
- package/dist/adapters/revert.js +6 -64
- package/dist/adapters/web.d.ts +9 -0
- package/dist/adapters/web.js +244 -0
- package/dist/config/files.d.ts +14 -0
- package/dist/config/files.js +57 -0
- package/dist/config/runtime.d.ts +3 -4
- package/dist/config/runtime.js +116 -97
- package/dist/config/schema.d.ts +56 -10
- package/dist/config/schema.js +48 -8
- package/dist/contracts/capability.d.ts +27 -1
- package/dist/contracts/domain.d.ts +1 -0
- package/dist/contracts/model.d.ts +33 -6
- package/dist/contracts/review.d.ts +17 -0
- package/dist/contracts/review.js +1 -0
- package/dist/core/access-policy.d.ts +40 -0
- package/dist/core/access-policy.js +68 -0
- package/dist/core/access.d.ts +30 -2
- package/dist/core/access.js +159 -26
- package/dist/core/context-boundaries.d.ts +25 -0
- package/dist/core/context-boundaries.js +106 -0
- package/dist/core/context.d.ts +3 -0
- package/dist/core/context.js +11 -0
- package/dist/core/host.js +261 -173
- package/dist/entry/pair.d.ts +1 -0
- package/dist/entry/pair.js +14 -0
- package/dist/entry/run.js +1 -1
- package/dist/execution/lsp-process.d.ts +3 -2
- package/dist/execution/lsp-process.js +46 -28
- package/dist/http/server.d.ts +5 -0
- package/dist/http/server.js +262 -80
- package/dist/runtime/agent.d.ts +9 -4
- package/dist/runtime/agent.js +361 -286
- package/dist/runtime/artifacts.d.ts +13 -1
- package/dist/runtime/artifacts.js +137 -10
- package/dist/runtime/cache.d.ts +59 -16
- package/dist/runtime/cache.js +124 -43
- package/dist/runtime/calls.d.ts +1 -1
- package/dist/runtime/calls.js +164 -48
- package/dist/runtime/capabilities.d.ts +2 -2
- package/dist/runtime/capabilities.js +4 -5
- package/dist/runtime/cleanup.d.ts +5 -2
- package/dist/runtime/cleanup.js +48 -17
- package/dist/runtime/compaction.d.ts +9 -0
- package/dist/runtime/compaction.js +52 -0
- package/dist/runtime/context.d.ts +8 -4
- package/dist/runtime/context.js +115 -128
- package/dist/runtime/events.d.ts +7 -0
- package/dist/runtime/events.js +83 -0
- package/dist/runtime/images.d.ts +14 -0
- package/dist/runtime/images.js +82 -0
- package/dist/runtime/kernel-capabilities.d.ts +7 -1
- package/dist/runtime/kernel-capabilities.js +146 -68
- package/dist/runtime/model-audit.d.ts +9 -0
- package/dist/runtime/model-audit.js +39 -0
- package/dist/runtime/model.d.ts +109 -4
- package/dist/runtime/model.js +368 -143
- package/dist/runtime/observability.d.ts +1 -0
- package/dist/runtime/observability.js +60 -15
- package/dist/runtime/policy.d.ts +1 -1
- package/dist/runtime/policy.js +2 -2
- package/dist/runtime/profile.d.ts +2 -1
- package/dist/runtime/profile.js +12 -15
- package/dist/runtime/projects.d.ts +3 -1
- package/dist/runtime/projects.js +38 -17
- package/dist/runtime/ptc-worker.d.ts +1 -0
- package/dist/runtime/ptc-worker.js +97 -0
- package/dist/runtime/ptc.d.ts +16 -0
- package/dist/runtime/ptc.js +128 -0
- package/dist/runtime/results.d.ts +5 -4
- package/dist/runtime/results.js +29 -51
- package/dist/runtime/review.d.ts +4 -1
- package/dist/runtime/review.js +101 -22
- package/dist/runtime/scheduler.js +1 -0
- package/dist/runtime/skills.js +34 -5
- package/dist/runtime/task-audit.d.ts +21 -0
- package/dist/runtime/task-audit.js +122 -0
- package/dist/runtime/time.d.ts +9 -0
- package/dist/runtime/time.js +18 -0
- package/dist/runtime/tokenizer.d.ts +2 -0
- package/dist/runtime/tokenizer.js +26 -1
- package/dist/store/database.js +26 -1
- package/dist/store/event-log.d.ts +1 -0
- package/dist/store/event-log.js +22 -5
- package/dist/store/schema.d.ts +1 -1
- package/dist/store/schema.js +50 -1
- package/dist/store/store.d.ts +65 -19
- package/dist/store/store.js +986 -188
- package/package.json +18 -8
- package/proto/executor.proto +69 -55
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensagent/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Lens Harness kernel and HTTP server.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"types": "./dist/launch.d.ts",
|
|
17
|
-
"import": "./dist/launch.js"
|
|
18
|
-
|
|
17
|
+
"import": "./dist/launch.js",
|
|
18
|
+
"default": "./dist/launch.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
19
21
|
},
|
|
20
22
|
"types": "./dist/launch.d.ts",
|
|
21
23
|
"bin": {
|
|
@@ -24,8 +26,8 @@
|
|
|
24
26
|
"lens": {
|
|
25
27
|
"component": "lens-core",
|
|
26
28
|
"protocols": {
|
|
27
|
-
"facet-core-api":
|
|
28
|
-
"core-executor-rpc":
|
|
29
|
+
"facet-core-api": 5,
|
|
30
|
+
"core-executor-rpc": 10
|
|
29
31
|
}
|
|
30
32
|
},
|
|
31
33
|
"files": [
|
|
@@ -48,14 +50,20 @@
|
|
|
48
50
|
"ai": "7.0.52",
|
|
49
51
|
"ajv": "8.20.0",
|
|
50
52
|
"better-sqlite3": "13.0.3",
|
|
51
|
-
"
|
|
53
|
+
"dom-serializer": "3.1.1",
|
|
54
|
+
"fastify": "5.12.5",
|
|
55
|
+
"htmlparser2": "12.0.0",
|
|
52
56
|
"json-canonicalize": "2.0.0",
|
|
53
|
-
"jsonc-parser": "3.3.1"
|
|
57
|
+
"jsonc-parser": "3.3.1",
|
|
58
|
+
"quickjs-emscripten": "0.32.0",
|
|
59
|
+
"turndown": "7.2.4",
|
|
60
|
+
"yaml": "2.9.1"
|
|
54
61
|
},
|
|
55
62
|
"devDependencies": {
|
|
56
63
|
"@eslint/js": "9.39.2",
|
|
57
64
|
"@types/better-sqlite3": "7.6.13",
|
|
58
65
|
"@types/node": "24.10.1",
|
|
66
|
+
"@types/turndown": "5.0.6",
|
|
59
67
|
"eslint": "9.39.2",
|
|
60
68
|
"tsx": "4.21.0",
|
|
61
69
|
"typescript": "5.9.3",
|
|
@@ -66,8 +74,10 @@
|
|
|
66
74
|
"dev": "tsx src/entry/node.ts",
|
|
67
75
|
"start": "node dist/entry/node.js",
|
|
68
76
|
"storage:rebuild": "tsx src/entry/rebuild.ts",
|
|
77
|
+
"pair:approve": "tsx src/entry/pair.ts",
|
|
69
78
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
70
79
|
"lint": "eslint .",
|
|
71
|
-
"
|
|
80
|
+
"test": "node scripts/run-tests.mjs",
|
|
81
|
+
"betterleaks": "node scripts/betterleaks.mjs"
|
|
72
82
|
}
|
|
73
83
|
}
|
package/proto/executor.proto
CHANGED
|
@@ -3,12 +3,14 @@ syntax = "proto3";
|
|
|
3
3
|
package lens.executor.v1;
|
|
4
4
|
|
|
5
5
|
service Executor {
|
|
6
|
+
rpc QueryTaskAudit(QueryTaskAuditRequest) returns (QueryTaskAuditResponse);
|
|
6
7
|
rpc Health(HealthRequest) returns (HealthResponse);
|
|
7
8
|
rpc Identity(IdentityRequest) returns (IdentityResponse);
|
|
8
9
|
rpc Shutdown(ShutdownRequest) returns (ShutdownResponse);
|
|
9
10
|
rpc ReadFile(ReadFileRequest) returns (ReadFileResponse);
|
|
10
|
-
rpc
|
|
11
|
-
rpc EditFile(EditFileRequest) returns (
|
|
11
|
+
rpc ViewImage(ReadFileRequest) returns (ViewImageResponse);
|
|
12
|
+
rpc EditFile(EditFileRequest) returns (FileChangeResponse);
|
|
13
|
+
rpc PatchFile(PatchFileRequest) returns (FileChangeResponse);
|
|
12
14
|
rpc RevertCall(RevertCallRequest) returns (RevertCallResponse);
|
|
13
15
|
rpc DescribeCallHistory(DescribeCallHistoryRequest) returns (DescribeCallHistoryResponse);
|
|
14
16
|
rpc DeleteCallHistory(DeleteCallHistoryRequest) returns (DeleteCallHistoryResponse);
|
|
@@ -16,8 +18,6 @@ service Executor {
|
|
|
16
18
|
rpc Grep(GrepRequest) returns (GrepResponse);
|
|
17
19
|
rpc BrowseProject(BrowseProjectRequest) returns (BrowseProjectResponse);
|
|
18
20
|
rpc RunCommand(RunCommandRequest) returns (RunCommandResponse);
|
|
19
|
-
rpc GitRun(GitRunRequest) returns (GitRunResponse);
|
|
20
|
-
rpc InternetSearch(InternetSearchRequest) returns (InternetSearchResponse);
|
|
21
21
|
rpc ListAllowedParent(ListAllowedParentRequest) returns (ListAllowedParentResponse);
|
|
22
22
|
rpc ValidateWorkspacePaths(ValidateWorkspacePathsRequest) returns (ValidateWorkspacePathsResponse);
|
|
23
23
|
rpc OpenInFileManager(OpenInFileManagerRequest) returns (OpenInFileManagerResponse);
|
|
@@ -70,44 +70,89 @@ message ReadFileRequest {
|
|
|
70
70
|
repeated string workspace_paths = 1;
|
|
71
71
|
string path = 2;
|
|
72
72
|
bool full_access = 3;
|
|
73
|
+
int64 start_line = 4; // 1-based; zero defaults to 1.
|
|
74
|
+
int32 max_lines = 5; // Zero defaults to 2000; at most 10000.
|
|
75
|
+
int32 max_bytes = 6; // Zero defaults to 65536; otherwise 4..262144.
|
|
76
|
+
int64 offset = 7; // UTF-8 byte offset for continuation; excludes start_line > 1.
|
|
73
77
|
}
|
|
74
78
|
message ReadFileResponse {
|
|
75
79
|
string content = 1;
|
|
76
80
|
bool truncated = 2;
|
|
81
|
+
int64 offset = 3;
|
|
82
|
+
int64 next_offset = 4;
|
|
83
|
+
bool eof = 5;
|
|
84
|
+
int64 size_bytes = 6;
|
|
85
|
+
string kind = 7; // file | directory; directory content lists sorted names, with / for directories.
|
|
86
|
+
int64 total_entries = 8; // Directory entry count, zero for a file.
|
|
87
|
+
EvidenceReceipt evidence = 9;
|
|
77
88
|
}
|
|
78
89
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
string
|
|
82
|
-
string
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
string
|
|
90
|
+
// Metadata only; filtered server-side to the requesting declared pairing identity.
|
|
91
|
+
message QueryTaskAuditRequest {
|
|
92
|
+
string project_id = 1;
|
|
93
|
+
string task_id = 2;
|
|
94
|
+
int32 limit = 3;
|
|
95
|
+
string cursor = 4;
|
|
96
|
+
}
|
|
97
|
+
message QueryTaskAuditResponse {
|
|
98
|
+
repeated string events_json = 1;
|
|
99
|
+
string next_cursor = 2;
|
|
100
|
+
bool incomplete_tail = 3;
|
|
101
|
+
string integrity = 4;
|
|
102
|
+
string ordering = 5;
|
|
103
|
+
string scope = 6;
|
|
104
|
+
string completeness = 7;
|
|
88
105
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
|
|
107
|
+
// Evidence for the actual returned payload. Not a hash/version of unreturned file bytes.
|
|
108
|
+
message EvidenceReceipt {
|
|
109
|
+
string evidence_id = 1;
|
|
110
|
+
string content_sha256 = 2;
|
|
111
|
+
int64 returned_bytes = 3;
|
|
112
|
+
string scope = 4;
|
|
113
|
+
int64 offset = 5;
|
|
114
|
+
int64 next_offset = 6;
|
|
115
|
+
int64 source_size_bytes = 7;
|
|
116
|
+
bool complete = 8;
|
|
92
117
|
}
|
|
93
118
|
|
|
119
|
+
message ViewImageResponse {
|
|
120
|
+
string data = 1; // Base64-encoded image bytes, at most 5 MiB before encoding.
|
|
121
|
+
string media_type = 2;
|
|
122
|
+
EvidenceReceipt evidence = 3;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
message FileEdit {
|
|
126
|
+
string old_string = 1;
|
|
127
|
+
string new_string = 2;
|
|
128
|
+
bool replace_all = 3;
|
|
129
|
+
}
|
|
94
130
|
message EditFileRequest {
|
|
95
131
|
repeated string workspace_paths = 1;
|
|
96
132
|
string path = 2;
|
|
97
|
-
string
|
|
98
|
-
string
|
|
99
|
-
|
|
133
|
+
string operation = 3; // create | edit | rewrite
|
|
134
|
+
optional string content = 4; // Required for create/rewrite, including an empty string.
|
|
135
|
+
repeated FileEdit edits = 5; // Required for edit; applied in order, then committed once.
|
|
100
136
|
bool full_access = 6;
|
|
101
137
|
string workspace_id = 7;
|
|
102
138
|
string call_id = 8;
|
|
103
139
|
}
|
|
104
|
-
message
|
|
105
|
-
string
|
|
106
|
-
|
|
107
|
-
|
|
140
|
+
message PatchFileRequest {
|
|
141
|
+
repeated string workspace_paths = 1;
|
|
142
|
+
string path = 2;
|
|
143
|
+
string patch = 3; // Update hunks only; every hunk refers to the original file.
|
|
144
|
+
bool full_access = 4;
|
|
145
|
+
string workspace_id = 5;
|
|
146
|
+
string call_id = 6;
|
|
147
|
+
}
|
|
148
|
+
message FileChangeResponse {
|
|
149
|
+
string path = 1;
|
|
150
|
+
bool changed = 2;
|
|
151
|
+
int32 units_applied = 3;
|
|
152
|
+
int64 bytes_written = 4;
|
|
108
153
|
}
|
|
109
154
|
|
|
110
|
-
// Restores the files recorded for one or more previous
|
|
155
|
+
// Restores the files recorded for one or more previous EditFile/PatchFile Calls. The Executor
|
|
111
156
|
// orders them by its own per-Workspace sequence and verifies, for every path, that the content on
|
|
112
157
|
// disk is still what the Call left behind. Any mismatch is reported in `conflicts` and nothing is
|
|
113
158
|
// written unless `force` is set.
|
|
@@ -252,37 +297,6 @@ message RunCommandResponse {
|
|
|
252
297
|
bool stderr_truncated = 7;
|
|
253
298
|
}
|
|
254
299
|
|
|
255
|
-
message GitRunRequest {
|
|
256
|
-
repeated string workspace_paths = 1;
|
|
257
|
-
repeated string args = 2;
|
|
258
|
-
string cwd = 3;
|
|
259
|
-
int32 timeout_ms = 4;
|
|
260
|
-
int32 output_limit_bytes = 5;
|
|
261
|
-
bool full_access = 6;
|
|
262
|
-
}
|
|
263
|
-
message GitRunResponse {
|
|
264
|
-
int32 exit_code = 1;
|
|
265
|
-
string stdout = 2;
|
|
266
|
-
string stderr = 3;
|
|
267
|
-
int64 duration_ms = 4;
|
|
268
|
-
bool stdout_truncated = 5;
|
|
269
|
-
bool stderr_truncated = 6;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
message InternetSearchRequest {
|
|
273
|
-
string query = 1;
|
|
274
|
-
int32 max_results = 2;
|
|
275
|
-
}
|
|
276
|
-
message SearchResult {
|
|
277
|
-
string title = 1;
|
|
278
|
-
string url = 2;
|
|
279
|
-
string snippet = 3;
|
|
280
|
-
}
|
|
281
|
-
message InternetSearchResponse {
|
|
282
|
-
repeated SearchResult results = 1;
|
|
283
|
-
string provider = 2;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
300
|
message ListAllowedParentRequest { string path = 1; }
|
|
287
301
|
message ListAllowedParentResponse {
|
|
288
302
|
string allowed_parent_dir = 1;
|