@velum-labs/cursorkit 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.
- package/DISCLAIMER.md +12 -0
- package/README.md +157 -0
- package/dist/src/agentTools/diff.d.ts +11 -0
- package/dist/src/agentTools/diff.js +88 -0
- package/dist/src/agentTools/policy.d.ts +3 -0
- package/dist/src/agentTools/policy.js +12 -0
- package/dist/src/agentTools/registry.d.ts +114 -0
- package/dist/src/agentTools/registry.js +663 -0
- package/dist/src/agentTools/results.d.ts +14 -0
- package/dist/src/agentTools/results.js +117 -0
- package/dist/src/agentTools/schemas.d.ts +3 -0
- package/dist/src/agentTools/schemas.js +89 -0
- package/dist/src/agentTools/surface.d.ts +11 -0
- package/dist/src/agentTools/surface.js +251 -0
- package/dist/src/certs.d.ts +8 -0
- package/dist/src/certs.js +34 -0
- package/dist/src/ck.d.ts +2 -0
- package/dist/src/ck.js +6 -0
- package/dist/src/ckLauncher.d.ts +150 -0
- package/dist/src/ckLauncher.js +1496 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +265 -0
- package/dist/src/config.d.ts +52 -0
- package/dist/src/config.js +210 -0
- package/dist/src/connectEnvelope.d.ts +16 -0
- package/dist/src/connectEnvelope.js +70 -0
- package/dist/src/desktop.d.ts +19 -0
- package/dist/src/desktop.js +167 -0
- package/dist/src/desktopConnectProxy.d.ts +26 -0
- package/dist/src/desktopConnectProxy.js +175 -0
- package/dist/src/extensions/index.d.ts +2 -0
- package/dist/src/extensions/index.js +1 -0
- package/dist/src/extensions/registry.d.ts +8 -0
- package/dist/src/extensions/registry.js +52 -0
- package/dist/src/extensions/types.d.ts +42 -0
- package/dist/src/extensions/types.js +1 -0
- package/dist/src/fixtures/modelFusion.d.ts +103 -0
- package/dist/src/fixtures/modelFusion.js +404 -0
- package/dist/src/fixtures/replay.d.ts +9 -0
- package/dist/src/fixtures/replay.js +41 -0
- package/dist/src/fixtures/sanitizer.d.ts +9 -0
- package/dist/src/fixtures/sanitizer.js +43 -0
- package/dist/src/fixtures/schema.d.ts +38 -0
- package/dist/src/fixtures/schema.js +33 -0
- package/dist/src/gen/agent/v1/agent_pb.d.ts +21577 -0
- package/dist/src/gen/agent/v1/agent_pb.js +5325 -0
- package/dist/src/gen/aiserver/v1/aiserver_pb.d.ts +135242 -0
- package/dist/src/gen/aiserver/v1/aiserver_pb.js +34430 -0
- package/dist/src/gen/anyrun/v1/anyrun_pb.d.ts +1163 -0
- package/dist/src/gen/anyrun/v1/anyrun_pb.js +374 -0
- package/dist/src/gen/google/protobuf/google_pb.d.ts +142 -0
- package/dist/src/gen/google/protobuf/google_pb.js +54 -0
- package/dist/src/gen/internapi/v1/internapi_pb.d.ts +121 -0
- package/dist/src/gen/internapi/v1/internapi_pb.js +79 -0
- package/dist/src/logger.d.ts +8 -0
- package/dist/src/logger.js +37 -0
- package/dist/src/modelFusion/cursorHarness.d.ts +146 -0
- package/dist/src/modelFusion/cursorHarness.js +647 -0
- package/dist/src/modelFusion/index.d.ts +4 -0
- package/dist/src/modelFusion/index.js +2 -0
- package/dist/src/models/registry.d.ts +22 -0
- package/dist/src/models/registry.js +30 -0
- package/dist/src/proto.d.ts +13 -0
- package/dist/src/proto.js +61 -0
- package/dist/src/providers/openai.d.ts +64 -0
- package/dist/src/providers/openai.js +355 -0
- package/dist/src/redaction.d.ts +4 -0
- package/dist/src/redaction.js +65 -0
- package/dist/src/routeInventory.d.ts +16 -0
- package/dist/src/routeInventory.js +39 -0
- package/dist/src/routes.d.ts +37 -0
- package/dist/src/routes.js +227 -0
- package/dist/src/server.d.ts +50 -0
- package/dist/src/server.js +1353 -0
- package/dist/src/services/agent.d.ts +1 -0
- package/dist/src/services/agent.js +7 -0
- package/dist/src/services/agentRun.d.ts +60 -0
- package/dist/src/services/agentRun.js +391 -0
- package/dist/src/services/chat.d.ts +11 -0
- package/dist/src/services/chat.js +47 -0
- package/dist/src/services/models.d.ts +10 -0
- package/dist/src/services/models.js +216 -0
- package/dist/src/services/serverConfig.d.ts +2 -0
- package/dist/src/services/serverConfig.js +19 -0
- package/dist/src/testing/artifacts.d.ts +14 -0
- package/dist/src/testing/artifacts.js +92 -0
- package/dist/src/testing/cli.d.ts +4 -0
- package/dist/src/testing/cli.js +192 -0
- package/dist/src/testing/localBackend.d.ts +24 -0
- package/dist/src/testing/localBackend.js +310 -0
- package/dist/src/testing/processRunner.d.ts +7 -0
- package/dist/src/testing/processRunner.js +74 -0
- package/dist/src/testing/runner.d.ts +9 -0
- package/dist/src/testing/runner.js +85 -0
- package/dist/src/testing/scenarios.d.ts +3 -0
- package/dist/src/testing/scenarios.js +2535 -0
- package/dist/src/testing/types.d.ts +66 -0
- package/dist/src/testing/types.js +1 -0
- package/dist/src/tools/baselineInventory.d.ts +12 -0
- package/dist/src/tools/baselineInventory.js +680 -0
- package/dist/src/tools/checkModelFusionProtocol.d.ts +1 -0
- package/dist/src/tools/checkModelFusionProtocol.js +274 -0
- package/dist/src/tools/checkReleasePublishConfig.d.ts +1 -0
- package/dist/src/tools/checkReleasePublishConfig.js +99 -0
- package/dist/src/tools/generateProtoInventory.d.ts +1 -0
- package/dist/src/tools/generateProtoInventory.js +89 -0
- package/dist/src/tools/normalizeGeneratedCode.d.ts +1 -0
- package/dist/src/tools/normalizeGeneratedCode.js +18 -0
- package/dist/src/tools/releaseCheck.d.ts +26 -0
- package/dist/src/tools/releaseCheck.js +367 -0
- package/dist/src/trace.d.ts +39 -0
- package/dist/src/trace.js +106 -0
- package/dist/src/translation.d.ts +6 -0
- package/dist/src/translation.js +22 -0
- package/dist/src/upstream.d.ts +20 -0
- package/dist/src/upstream.js +270 -0
- package/docs/configuration.md +55 -0
- package/docs/cursor-app.md +263 -0
- package/docs/implementation-inventory.json +609 -0
- package/docs/learnings.md +363 -0
- package/docs/model-fusion-protocol-origin.json +126 -0
- package/docs/model-fusion-protocol.md +110 -0
- package/docs/plugin-authoring.md +24 -0
- package/docs/proto-inventory.md +1477 -0
- package/docs/protocol-surface-audit.md +92 -0
- package/docs/protocol.md +52 -0
- package/docs/refreshing-protos.md +78 -0
- package/docs/release-gates.md +110 -0
- package/docs/release-summary.json +86 -0
- package/docs/route-contract-manifest.json +288 -0
- package/docs/route-policy.json +133 -0
- package/docs/service-manifest.json +9490 -0
- package/docs/test-manifest.json +155 -0
- package/docs/testing-harness.md +204 -0
- package/docs/troubleshooting.md +36 -0
- package/docs/type-manifest-summary.json +28927 -0
- package/package.json +93 -0
- package/proto/agent/v1/agent.proto +5371 -0
- package/proto/aiserver/v1/aiserver.proto +32944 -0
- package/proto/anyrun/v1/anyrun.proto +294 -0
- package/proto/google/protobuf/google.proto +37 -0
- package/proto/internapi/v1/internapi.proto +32 -0
package/DISCLAIMER.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Disclaimer
|
|
2
|
+
|
|
3
|
+
This is an unofficial and unsupported interoperability research project.
|
|
4
|
+
|
|
5
|
+
It attempts to emulate enough of Cursor's backend protocol for personal,
|
|
6
|
+
experimental use with a self-hosted model. Reverse-engineering a client protocol
|
|
7
|
+
to run your own models may conflict with Cursor's Terms of Service. Do not
|
|
8
|
+
deploy this project as a hosted service, do not represent it as affiliated with
|
|
9
|
+
Cursor, and do not rely on it for production workloads.
|
|
10
|
+
|
|
11
|
+
Use it only for local research where you understand the legal, security, and
|
|
12
|
+
compatibility risks.
|
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# cursorkit
|
|
2
|
+
|
|
3
|
+
Unofficial research bridge for experimenting with Cursor's backend protocol from
|
|
4
|
+
the server side: keep Cursor's existing UX, but route model inference to a
|
|
5
|
+
self-hosted OpenAI-compatible endpoint.
|
|
6
|
+
|
|
7
|
+
This is personal interoperability research, not a supported Cursor integration.
|
|
8
|
+
Read `DISCLAIMER.md` before running it.
|
|
9
|
+
|
|
10
|
+
## First Run
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pnpm install
|
|
14
|
+
pnpm build
|
|
15
|
+
pnpm dev -- serve
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
In another terminal:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pnpm exec tsx src/cli.ts doctor
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The bridge binds to `127.0.0.1:9443` by default. Set
|
|
25
|
+
`CURSOR_UPSTREAM_BASE_URL` before expecting unknown Cursor backend traffic to
|
|
26
|
+
pass through to an upstream. See `docs/configuration.md` for all config.
|
|
27
|
+
|
|
28
|
+
## CLI
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
ck
|
|
32
|
+
ck test
|
|
33
|
+
ck --use-default-profile
|
|
34
|
+
ck --print
|
|
35
|
+
ck doctor
|
|
36
|
+
ck cert
|
|
37
|
+
ck route
|
|
38
|
+
ck route status
|
|
39
|
+
ck route rollback
|
|
40
|
+
ck stop
|
|
41
|
+
cursorkit serve
|
|
42
|
+
cursorkit doctor
|
|
43
|
+
cursorkit desktop-cert
|
|
44
|
+
cursorkit desktop-proxy
|
|
45
|
+
cursorkit desktop-doctor
|
|
46
|
+
cursorkit capture
|
|
47
|
+
cursorkit fixtures
|
|
48
|
+
cursorkit --help
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`serve` starts the local bridge. `doctor` checks proto loading, upstream config,
|
|
52
|
+
TLS status, capture status, and local model registration. The `desktop-*`
|
|
53
|
+
commands support explicit Cursor desktop app proxy experiments; see
|
|
54
|
+
`docs/cursor-app.md`.
|
|
55
|
+
|
|
56
|
+
The committed `fixtures/model-fusion-contract/` records are synthetic
|
|
57
|
+
compatibility fixtures for the model-fusion roadmap. They validate Cursor-specific
|
|
58
|
+
`cursor-run-*` records and generic `harness-run-*` records locally without adding
|
|
59
|
+
`handoffkit` as a runtime dependency or changing live Cursor routing behavior.
|
|
60
|
+
The importable `@velum-labs/cursorkit/model-fusion` subpath exposes the same fixture-backed
|
|
61
|
+
surface as a small structural API: `cursorHarness(...)` and
|
|
62
|
+
`runCursorCandidate(...)` produce Cursor-specific records plus mapped generic
|
|
63
|
+
harness results. Those records keep requested and observed model IDs separate,
|
|
64
|
+
can attach redacted route-inventory artifact refs, and record unsupported Cursor
|
|
65
|
+
capabilities explicitly. It does not own fan-out, judge synthesis, lifecycle,
|
|
66
|
+
receipts, or live Cursor tool-call replay; desktop routes remain observed-only
|
|
67
|
+
until fixture-backed evidence proves stability.
|
|
68
|
+
|
|
69
|
+
`ck` is the recommended desktop test launcher. It starts the desktop bridge plus
|
|
70
|
+
a local HTTP CONNECT proxy, opens an isolated Cursor profile with
|
|
71
|
+
`--proxy-server`, and reports whether route inventory traffic reaches the
|
|
72
|
+
bridge. For isolated desktop UI tests, it also seeds/activates local models
|
|
73
|
+
additively in Cursor's settings-backed model picker state. It does not install
|
|
74
|
+
certificates, edit `/etc/hosts`, modify `pf`, or kill your normal Cursor app.
|
|
75
|
+
Inside this repo, use `pnpm ck`; when installed or linked as a package, use
|
|
76
|
+
`ck` directly. If the isolated profile cannot complete browser login,
|
|
77
|
+
`ck --use-default-profile` reuses your current Cursor auth state while keeping
|
|
78
|
+
the same non-privileged routing attempt.
|
|
79
|
+
Use `ck test --use-default-profile` for a bounded desktop smoke test that reports
|
|
80
|
+
whether route inventory and the known model-list RPCs reached the bridge.
|
|
81
|
+
|
|
82
|
+
The project knowledge base for observed Cursor behavior is `docs/learnings.md`.
|
|
83
|
+
Read it before changing route interception, model metadata, or desktop proxy
|
|
84
|
+
behavior.
|
|
85
|
+
Use `docs/protocol-surface-audit.md` to see which parts of the full generated
|
|
86
|
+
proto are implemented, which are only pass-through, and what is missing for full
|
|
87
|
+
tool/context support.
|
|
88
|
+
|
|
89
|
+
Use `docs/testing-harness.md` for the unified test runner that orchestrates
|
|
90
|
+
static checks, bridge protocol tests, cursor-agent e2e, local backend probes,
|
|
91
|
+
real `cursor-agent` traffic discovery, ACP JSON-RPC probes, and desktop
|
|
92
|
+
route-inventory smoke tests.
|
|
93
|
+
|
|
94
|
+
For app-level evidence, run the experimental desktop UI probe:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pnpm test:harness -- \
|
|
98
|
+
--suite desktop-ui-experimental \
|
|
99
|
+
--include-experimental \
|
|
100
|
+
--base-url http://127.0.0.1:8080/v1 \
|
|
101
|
+
--model local-qwen \
|
|
102
|
+
--provider-model mlx-community/Qwen3.5-4B-8bit \
|
|
103
|
+
--display-name local-qwen \
|
|
104
|
+
--api-key local
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
It launches an isolated Cursor instance with auth seeded from the logged-in
|
|
108
|
+
default profile, waits for Cursor to initialize settings, activates the local
|
|
109
|
+
model, opens this repo, attaches to the renderer over CDP, opens the Agent model
|
|
110
|
+
picker, and fails unless both the configured local model and built-in Cursor
|
|
111
|
+
models are visible.
|
|
112
|
+
|
|
113
|
+
## Proto Extraction
|
|
114
|
+
|
|
115
|
+
The proto extraction logic is vendored in `vendor/extract-cursor-protos`.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pnpm install
|
|
119
|
+
pnpm extract:protos
|
|
120
|
+
pnpm proto:inventory
|
|
121
|
+
pnpm codegen
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
That refreshes the full default proto files under `proto/` from the installed
|
|
125
|
+
Cursor app, regenerates `docs/proto-inventory.md`,
|
|
126
|
+
`docs/service-manifest.json`, `docs/type-manifest-summary.json`, and writes
|
|
127
|
+
generated TypeScript schemas and service descriptors under `src/gen/`.
|
|
128
|
+
|
|
129
|
+
The extractor normalizes nested and foreign type references so the full
|
|
130
|
+
discovered surface is codegen-valid. It does not hand-maintain a reduced route
|
|
131
|
+
slice; runtime interception is still controlled by route policy.
|
|
132
|
+
See `docs/refreshing-protos.md` for provenance, custom app paths, and the
|
|
133
|
+
fixture workflow required after refreshing.
|
|
134
|
+
See `docs/proto-inventory.md` for the generated service inventory.
|
|
135
|
+
|
|
136
|
+
## Extension Surface
|
|
137
|
+
|
|
138
|
+
The current typed extension surface is deliberately narrow:
|
|
139
|
+
|
|
140
|
+
- Unknown routes proxy upstream by default.
|
|
141
|
+
- `AvailableModels` can append conservative local model entries.
|
|
142
|
+
- `StreamUnifiedChatWithTools` is intercepted only when the selected model is
|
|
143
|
+
registered locally; normal Cursor models pass upstream.
|
|
144
|
+
- Cursor desktop app support starts in route-inventory mode so app-specific
|
|
145
|
+
RPCs can be observed before adding typed interceptors.
|
|
146
|
+
|
|
147
|
+
See `docs/plugin-authoring.md` and the source-checkout `examples/` directory for
|
|
148
|
+
the experimental local plugin shape. Examples are typechecked by
|
|
149
|
+
`pnpm examples:check`, but they are intentionally excluded from packed tarballs.
|
|
150
|
+
|
|
151
|
+
## Release Gates
|
|
152
|
+
|
|
153
|
+
This package remains private and local-only. See `docs/release-gates.md` for the
|
|
154
|
+
checks required before sharing a tarball or changing the API stability posture.
|
|
155
|
+
Use `pnpm baseline:check` to verify generated route/config/docs drift and
|
|
156
|
+
`pnpm release:check` for the authoritative deterministic local release gate,
|
|
157
|
+
including package artifact smoke validation.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface DiffStats {
|
|
2
|
+
added: number;
|
|
3
|
+
removed: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function diffStats(before: string, after: string): DiffStats;
|
|
6
|
+
/**
|
|
7
|
+
* Produce a git-style unified diff with a single hunk covering the whole file.
|
|
8
|
+
* The bridge synthesizes apply_patch from a read + write round trip, so this is
|
|
9
|
+
* the evidence we surface back to the model (and to model-fusion artifacts).
|
|
10
|
+
*/
|
|
11
|
+
export declare function unifiedDiff(path: string, before: string, after: string): string;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
function splitLines(text) {
|
|
2
|
+
return text.length === 0 ? [] : text.split("\n");
|
|
3
|
+
}
|
|
4
|
+
function diffLines(a, b) {
|
|
5
|
+
const n = a.length;
|
|
6
|
+
const m = b.length;
|
|
7
|
+
const dp = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
|
|
8
|
+
for (let i = n - 1; i >= 0; i -= 1) {
|
|
9
|
+
for (let j = m - 1; j >= 0; j -= 1) {
|
|
10
|
+
dp[i][j] =
|
|
11
|
+
a[i] === b[j]
|
|
12
|
+
? dp[i + 1][j + 1] + 1
|
|
13
|
+
: Math.max(dp[i + 1][j], dp[i][j + 1]);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const ops = [];
|
|
17
|
+
let i = 0;
|
|
18
|
+
let j = 0;
|
|
19
|
+
while (i < n && j < m) {
|
|
20
|
+
if (a[i] === b[j]) {
|
|
21
|
+
ops.push({ type: "equal", line: a[i] });
|
|
22
|
+
i += 1;
|
|
23
|
+
j += 1;
|
|
24
|
+
}
|
|
25
|
+
else if (dp[i + 1][j] >= dp[i][j + 1]) {
|
|
26
|
+
ops.push({ type: "delete", line: a[i] });
|
|
27
|
+
i += 1;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
ops.push({ type: "insert", line: b[j] });
|
|
31
|
+
j += 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
while (i < n) {
|
|
35
|
+
ops.push({ type: "delete", line: a[i] });
|
|
36
|
+
i += 1;
|
|
37
|
+
}
|
|
38
|
+
while (j < m) {
|
|
39
|
+
ops.push({ type: "insert", line: b[j] });
|
|
40
|
+
j += 1;
|
|
41
|
+
}
|
|
42
|
+
return ops;
|
|
43
|
+
}
|
|
44
|
+
export function diffStats(before, after) {
|
|
45
|
+
let added = 0;
|
|
46
|
+
let removed = 0;
|
|
47
|
+
for (const op of diffLines(splitLines(before), splitLines(after))) {
|
|
48
|
+
if (op.type === "insert") {
|
|
49
|
+
added += 1;
|
|
50
|
+
}
|
|
51
|
+
else if (op.type === "delete") {
|
|
52
|
+
removed += 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { added, removed };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Produce a git-style unified diff with a single hunk covering the whole file.
|
|
59
|
+
* The bridge synthesizes apply_patch from a read + write round trip, so this is
|
|
60
|
+
* the evidence we surface back to the model (and to model-fusion artifacts).
|
|
61
|
+
*/
|
|
62
|
+
export function unifiedDiff(path, before, after) {
|
|
63
|
+
const a = splitLines(before);
|
|
64
|
+
const b = splitLines(after);
|
|
65
|
+
const ops = diffLines(a, b);
|
|
66
|
+
const lines = [`--- a/${path}`, `+++ b/${path}`];
|
|
67
|
+
const aStart = a.length === 0 ? 0 : 1;
|
|
68
|
+
const bStart = b.length === 0 ? 0 : 1;
|
|
69
|
+
lines.push(`@@ -${aStart},${a.length} +${bStart},${b.length} @@`);
|
|
70
|
+
for (const op of ops) {
|
|
71
|
+
switch (op.type) {
|
|
72
|
+
case "equal":
|
|
73
|
+
lines.push(` ${op.line}`);
|
|
74
|
+
break;
|
|
75
|
+
case "delete":
|
|
76
|
+
lines.push(`-${op.line}`);
|
|
77
|
+
break;
|
|
78
|
+
case "insert":
|
|
79
|
+
lines.push(`+${op.line}`);
|
|
80
|
+
break;
|
|
81
|
+
default: {
|
|
82
|
+
const exhaustive = op.type;
|
|
83
|
+
throw new Error(`unreachable diff op: ${String(exhaustive)}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return lines.join("\n");
|
|
88
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function toolEnabledByPolicy(entry, policy) {
|
|
2
|
+
if (entry.openAIToolName === undefined) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
if (entry.support === "supported") {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (entry.support === "policy-gated") {
|
|
9
|
+
return policy === "all";
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { ServerResponse } from "node:http";
|
|
2
|
+
import { create } from "@bufbuild/protobuf";
|
|
3
|
+
import type { AgentToolPolicy } from "../config.js";
|
|
4
|
+
import { ExecServerMessageSchema } from "../gen/agent/v1/agent_pb.js";
|
|
5
|
+
import type { Logger } from "../logger.js";
|
|
6
|
+
import type { OpenAIToolCall } from "../providers/openai.js";
|
|
7
|
+
import { type CursorToolError } from "./results.js";
|
|
8
|
+
export { cursorOpenAITools } from "./schemas.js";
|
|
9
|
+
export { agentExecClientMessageFields } from "./results.js";
|
|
10
|
+
export interface CursorToolRuntime {
|
|
11
|
+
logger: Logger;
|
|
12
|
+
nextAgentExecId: number;
|
|
13
|
+
config: {
|
|
14
|
+
agentToolPolicy: AgentToolPolicy;
|
|
15
|
+
toolResultTimeoutMs?: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface CursorToolExecutionOptions {
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
declare const TOOL_ARGUMENT_SCHEMAS: {
|
|
22
|
+
read_file: {
|
|
23
|
+
properties: {
|
|
24
|
+
path: "string";
|
|
25
|
+
offset: "integer";
|
|
26
|
+
limit: "integer";
|
|
27
|
+
};
|
|
28
|
+
required: string[];
|
|
29
|
+
nonEmpty: string[];
|
|
30
|
+
};
|
|
31
|
+
list_dir: {
|
|
32
|
+
properties: {
|
|
33
|
+
path: "string";
|
|
34
|
+
};
|
|
35
|
+
required: string[];
|
|
36
|
+
nonEmpty: string[];
|
|
37
|
+
};
|
|
38
|
+
grep: {
|
|
39
|
+
properties: {
|
|
40
|
+
pattern: "string";
|
|
41
|
+
path: "string";
|
|
42
|
+
glob: "string";
|
|
43
|
+
head_limit: "integer";
|
|
44
|
+
};
|
|
45
|
+
required: string[];
|
|
46
|
+
nonEmpty: string[];
|
|
47
|
+
};
|
|
48
|
+
run_shell: {
|
|
49
|
+
properties: {
|
|
50
|
+
command: "string";
|
|
51
|
+
working_directory: "string";
|
|
52
|
+
timeout: "integer";
|
|
53
|
+
description: "string";
|
|
54
|
+
};
|
|
55
|
+
required: string[];
|
|
56
|
+
nonEmpty: string[];
|
|
57
|
+
};
|
|
58
|
+
write_file: {
|
|
59
|
+
properties: {
|
|
60
|
+
path: "string";
|
|
61
|
+
content: "string";
|
|
62
|
+
return_file_content_after_write: "boolean";
|
|
63
|
+
};
|
|
64
|
+
required: string[];
|
|
65
|
+
nonEmpty: string[];
|
|
66
|
+
};
|
|
67
|
+
apply_patch: {
|
|
68
|
+
properties: {
|
|
69
|
+
path: "string";
|
|
70
|
+
old_string: "string";
|
|
71
|
+
new_string: "string";
|
|
72
|
+
replace_all: "boolean";
|
|
73
|
+
};
|
|
74
|
+
required: string[];
|
|
75
|
+
nonEmpty: string[];
|
|
76
|
+
};
|
|
77
|
+
delete_path: {
|
|
78
|
+
properties: {
|
|
79
|
+
path: "string";
|
|
80
|
+
};
|
|
81
|
+
required: string[];
|
|
82
|
+
nonEmpty: string[];
|
|
83
|
+
};
|
|
84
|
+
fetch_url: {
|
|
85
|
+
properties: {
|
|
86
|
+
url: "string";
|
|
87
|
+
};
|
|
88
|
+
required: string[];
|
|
89
|
+
nonEmpty: string[];
|
|
90
|
+
};
|
|
91
|
+
mcp_tool: {
|
|
92
|
+
properties: {
|
|
93
|
+
provider_identifier: "string";
|
|
94
|
+
tool_name: "string";
|
|
95
|
+
name: "string";
|
|
96
|
+
arguments: "object";
|
|
97
|
+
};
|
|
98
|
+
required: string[];
|
|
99
|
+
nonEmpty: string[];
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
type SupportedOpenAIToolName = keyof typeof TOOL_ARGUMENT_SCHEMAS;
|
|
103
|
+
export type CursorToolValidationResult = {
|
|
104
|
+
ok: true;
|
|
105
|
+
name: SupportedOpenAIToolName;
|
|
106
|
+
args: Record<string, unknown>;
|
|
107
|
+
} | {
|
|
108
|
+
ok: false;
|
|
109
|
+
error: CursorToolError;
|
|
110
|
+
};
|
|
111
|
+
export declare function executeCursorToolCall(response: ServerResponse, runtime: CursorToolRuntime, payloads: AsyncIterator<Buffer>, toolCall: OpenAIToolCall, options?: CursorToolExecutionOptions): Promise<string>;
|
|
112
|
+
export declare function validateCursorToolCall(toolCall: OpenAIToolCall, policy: AgentToolPolicy): CursorToolValidationResult;
|
|
113
|
+
export declare function cursorToolCallToExecServerMessage(id: number, execId: string, name: SupportedOpenAIToolName, toolCallId: string, args: Record<string, unknown>): ReturnType<typeof create<typeof ExecServerMessageSchema>> | undefined;
|
|
114
|
+
export declare function summarizeToolArgs(args: Record<string, unknown>): Record<string, unknown>;
|