@treestructuredplanning/gateway 0.1.2 → 0.1.3

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 CHANGED
@@ -1,18 +1,19 @@
1
1
  # TSP gateway
2
2
 
3
3
  The TSP gateway lets the [Tree-Structured Planning](https://treestructuredplanning.com)
4
- (TSP) canvas start, stop and resume Claude Code and Codex sessions on your computer, in the
4
+ (TSP) canvas start, stop and resume Claude Code, Codex and Cursor sessions on your computer, in the
5
5
  repository folders you register. It runs in the background under your own user account and
6
6
  only connects outward to TSP.
7
7
 
8
8
  ## Requirements
9
9
 
10
10
  - Node.js **22 or newer**.
11
- - Claude Code, or Codex **0.162.1 or newer**, installed separately and signed in with its
12
- own login (`codex login` for Codex). The gateway never signs in for you.
11
+ - Claude Code, Codex **0.162.1 or newer**, or the Cursor CLI **2026.10.19 or newer**,
12
+ installed separately and signed in with its own login (`codex login` for Codex,
13
+ `agent login` for Cursor). The gateway never signs in for you.
13
14
  - Each folder you register must be a local clone with a GitHub remote, and the harness must
14
- trust it: run `claude` or `codex` in the folder once and accept its trust prompt. Codex
15
- sessions never start in a folder Codex has not trusted, and trusting a parent folder does not
15
+ trust it: run `claude`, `codex` or `agent` in the folder once and accept its trust prompt.
16
+ Codex and Cursor sessions never start in a folder they have not trusted, and trusting a parent folder does not
16
17
  count for a repository inside it.
17
18
  - On Linux, a running Secret Service such as GNOME Keyring or KWallet. The gateway will not
18
19
  run without an OS credential store.
@@ -94,7 +95,7 @@ Registering or removing a folder takes effect in the running gateway without a r
94
95
 
95
96
  TSP can ask the gateway for exactly four things, and only in folders you registered:
96
97
 
97
- - **Launch** a Claude Code or Codex session, with a prompt describing the TSP work you
98
+ - **Launch** a Claude Code, Codex or Cursor session, with a prompt describing the TSP work you
98
99
  started from the canvas.
99
100
  - **Stop** that session.
100
101
  - **Resume** that session, with the text you typed. With no text, a stopped session gets the
@@ -103,17 +104,20 @@ TSP can ask the gateway for exactly four things, and only in folders you registe
103
104
  - **Report status**: which harnesses are installed, signed in and trust each registered
104
105
  folder, and how each launched session is doing.
105
106
 
106
- Only your own clicks in TSP send a prompt. Sessions keep running if the gateway stops. A
107
+ Only your own clicks in TSP send a prompt. Claude Code and Codex sessions keep running if the
108
+ gateway stops; a Cursor session ends with the gateway, and Resume reopens its chat. A
107
109
  session that finishes does not mean TSP has reviewed or accepted its work. Keep the
108
110
  [TSP plugin](https://github.com/WebifyServices/tsp-plugin) installed so launched sessions
109
111
  have TSP's tools.
110
112
 
111
113
  The gateway never:
112
114
 
113
- - changes your Claude Code or Codex settings, permissions or configuration, or passes any
115
+ - changes your Claude Code, Codex or Cursor settings, permissions or configuration, or passes any
114
116
  flag that bypasses them. Your own settings govern every session.
115
117
  - answers an approval prompt or question inside a session. When a session needs you, TSP
116
- shows the command to open it yourself (`claude attach <id>` or `codex resume <id>`).
118
+ shows the command to open it yourself (`claude attach <id>` or `codex resume <id>`). A Cursor
119
+ session waiting on a prompt stays waiting until you Stop it, which answers the prompt
120
+ "cancelled"; the gateway never selects an option.
117
121
  - signs in, accepts a trust prompt, or approves pairing for you.
118
122
  - accepts a shell command, program, folder, file path or environment variable from TSP.
119
123
  - runs anything in a folder you have not registered, or starts Codex in a folder Codex does
@@ -122,14 +126,22 @@ The gateway never:
122
126
  For Codex, sessions run in Codex's own background service, which the gateway starts when
123
127
  needed and never stops.
124
128
 
129
+ For Cursor, the gateway runs `agent --version` and `agent status` to read the installed version
130
+ and whether you are signed in, and `agent acp` (Cursor's Agent Client Protocol mode) as its own
131
+ child process for each running turn. It sends no mode, model, permission or sign-in request.
132
+ Cursor applies your own settings and permission rules, and the gateway starts a session only in a
133
+ folder you have already trusted.
134
+
125
135
  ## What leaves your computer
126
136
 
127
137
  The gateway sends TSP only repository names (`owner/name`), which harnesses are available,
128
138
  signed in and trusted per folder, and session status, including any waiting message with
129
139
  folder paths removed. For each launched session it also sends what the session is doing
130
140
  (reading, editing, running a command), when it was last active, and counts of files edited
131
- and commands run; never file names, commands or transcript text. Folder paths, environment
132
- variables, command lines, transcripts and raw error output stay on your computer. Run
141
+ and commands run; never file names or commands. When a Cursor turn finishes it also sends what
142
+ Cursor last said, trimmed to 240 characters with folder paths removed, so TSP can show it; no
143
+ other transcript text is sent. Folder paths, environment variables, command lines, transcripts
144
+ and raw error output stay on your computer. Run
133
145
  `tsp-gateway configure-reporting off` to stop sending activity (`activity` turns it back on).
134
146
 
135
147
  The gateway only connects outward, to TSP, and accepts no inbound connections. The only
package/dist/cli.js CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  validSlug,
39
39
  validateOrigin,
40
40
  watchConfig
41
- } from "./shared-M7CEELPK.js";
41
+ } from "./shared-RM5C4AZN.js";
42
42
 
43
43
  // src/cli.ts
44
44
  import { readFile } from "node:fs/promises";
@@ -50,7 +50,7 @@ import { parseArgs } from "node:util";
50
50
  // package.json
51
51
  var package_default = {
52
52
  name: "@treestructuredplanning/gateway",
53
- version: "0.1.2",
53
+ version: "0.1.3",
54
54
  description: "Outbound local harness gateway for Tree-Structured Planning",
55
55
  type: "module",
56
56
  engines: {
@@ -109,6 +109,7 @@ async function runLocal(loginPath, paths, config, version) {
109
109
  const stop = () => abort.abort();
110
110
  process.once("SIGINT", stop);
111
111
  process.once("SIGTERM", stop);
112
+ let drivers;
112
113
  try {
113
114
  const journal = new Journal(join(paths.state, `${pairing.machine_id}-receipts.jsonl`));
114
115
  await journal.load();
@@ -124,17 +125,19 @@ async function runLocal(loginPath, paths, config, version) {
124
125
  }
125
126
  });
126
127
  const status = new GatewayStatus(join(paths.state, "status.json"), executor);
127
- const drivers = builtinHarnesses(environment, executor);
128
- const commands = new Commands(journal, drivers, repositories, {
128
+ drivers = builtinHarnesses(environment, executor, join(paths.state, "acp-groups.json"));
129
+ await drivers.reap();
130
+ const registry = drivers;
131
+ const commands = new Commands(journal, registry, repositories, {
129
132
  activity: new ActivityReporter(async () => (await readConfig(paths.config)).reporting)
130
133
  });
131
134
  await runDaemon({
132
135
  pairing,
133
136
  version,
134
- drivers,
137
+ drivers: registry,
135
138
  commands,
136
139
  tokens: new OAuthTokens(pairing, keychain(pairing.origin)),
137
- repositories: async () => drivers.repositories(await repositories()),
140
+ repositories: async () => registry.repositories(await repositories()),
138
141
  watchFacts: (changed) => watchConfig(paths.config, () => {
139
142
  executor.invalidate();
140
143
  changed();
@@ -146,6 +149,7 @@ async function runLocal(loginPath, paths, config, version) {
146
149
  } finally {
147
150
  process.removeListener("SIGINT", stop);
148
151
  process.removeListener("SIGTERM", stop);
152
+ await drivers?.dispose();
149
153
  await release();
150
154
  }
151
155
  }
@@ -102,7 +102,8 @@
102
102
  "type": "string",
103
103
  "enum": [
104
104
  "claude_code",
105
- "codex"
105
+ "codex",
106
+ "cursor"
106
107
  ],
107
108
  "title": "HarnessKind"
108
109
  },
@@ -137,18 +138,26 @@
137
138
  "type": "string"
138
139
  },
139
140
  "session_ref": {
140
- "maxLength": 128,
141
- "minLength": 1,
142
- "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
143
- "title": "Session Ref",
144
- "type": "string"
141
+ "anyOf": [
142
+ {
143
+ "maxLength": 128,
144
+ "minLength": 1,
145
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
146
+ "type": "string"
147
+ },
148
+ {
149
+ "type": "null"
150
+ }
151
+ ],
152
+ "default": null,
153
+ "description": "The observed session to stop. None while the gateway is still starting the action's launch or resume: it withdraws that start, or stops the session it produced. Sent only to a gateway whose harness advertises stop_starting.",
154
+ "title": "Session Ref"
145
155
  }
146
156
  },
147
157
  "required": [
148
158
  "ttl_ms",
149
159
  "command_id",
150
- "action_id",
151
- "session_ref"
160
+ "action_id"
152
161
  ],
153
162
  "title": "GatewayStopOffer",
154
163
  "type": "object"
@@ -587,6 +596,12 @@
587
596
  "answer_input": {
588
597
  "type": "boolean",
589
598
  "title": "Answer Input"
599
+ },
600
+ "stop_starting": {
601
+ "type": "boolean",
602
+ "title": "Stop Starting",
603
+ "description": "Stop reaches a launch or resume the gateway is still starting: it withdraws it before any prompt is sent, or stops the session it produced. Gateways before 0.1.3 omit it and are stopped only once a session is observed.",
604
+ "default": false
590
605
  }
591
606
  },
592
607
  "additionalProperties": false,
@@ -772,6 +787,21 @@
772
787
  "default": null,
773
788
  "title": "Waiting For"
774
789
  },
790
+ "last_message": {
791
+ "anyOf": [
792
+ {
793
+ "maxLength": 240,
794
+ "minLength": 1,
795
+ "type": "string"
796
+ },
797
+ {
798
+ "type": "null"
799
+ }
800
+ ],
801
+ "default": null,
802
+ "description": "What the agent last said when its turn finished, trimmed and with folder paths removed; absent from gateways that predate it and when its reporting level is off.",
803
+ "title": "Last Message"
804
+ },
775
805
  "attach_hint": {
776
806
  "anyOf": [
777
807
  {