@pennixrv/trellis-paseo-adapter 0.7.2-beta.19 → 0.7.2-beta.21

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.
Files changed (3) hide show
  1. package/README.md +16 -3
  2. package/package.json +1 -1
  3. package/src/adapter.js +50 -11
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Optional Paseo adapter
2
2
 
3
3
  This package is installed explicitly through Pennix Lifecycle. It requires Node 22 or newer
4
- and Paseo 0.15.3. The ordinary Trellis CLI/core do not depend on it.
4
+ and a running local Paseo daemon with the public operations used by the request. The ordinary Trellis CLI/core do not depend on it.
5
5
 
6
6
  `trellis-paseo-adapter` accepts one version-1 JSON request on stdin and returns one bounded
7
7
  JSON response. Task commands own authorization, attempts, receipts and acceptance. The
@@ -11,5 +11,18 @@ An unknown write outcome requires native reconciliation, never automatic replay.
11
11
 
12
12
  Paseo server dependencies include native provider/PTY/voice packages. Their installation
13
13
  cost is confined to this optional package and Lifecycle's explicit script allowlist.
14
- The supported initial matrix is Paseo SDK/daemon 0.15.3 and Codex; other providers and
15
- remote transports are refused. Bottom-level approval/context settings use native defaults.
14
+ The packaged SDK is pinned for reproducible installation; daemon admission uses
15
+ the public server-info identity, operation methods and actual response contracts,
16
+ without a daemon version allowlist. Missing identity or required methods, other
17
+ providers and remote transports are refused. Capability output distinguishes
18
+ `sdk_version` from the informational `daemon_version`.
19
+ Bottom-level approval/context settings use native defaults.
20
+
21
+ `inspect` and `resource-preview` accept optional `page_size` (1–100) and `cursor`.
22
+ Paged replies include `page_info.next_cursor` and `page_info.complete`; consume
23
+ every page before concluding that a resource is absent. An `agent_id` uses an
24
+ exact native reference without reading unrelated history. Existing unpaged calls
25
+ still require a complete result and fail explicitly at the 256 KiB response
26
+ boundary. There is no historical-agent count limit; incomplete pages, cursor
27
+ cycles and excessive responses fail explicitly. Native controller consumers use
28
+ paging for writer checks and exact IDs or scoped paging for recovery.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pennixrv/trellis-paseo-adapter",
3
- "version": "0.7.2-beta.19",
3
+ "version": "0.7.2-beta.21",
4
4
  "description": "Optional local Paseo public SDK adapter for Trellis worktree delegation",
5
5
  "type": "module",
6
6
  "bin": {
package/src/adapter.js CHANGED
@@ -6,6 +6,10 @@ import { hostname } from 'node:os';
6
6
  export const MAX_BYTES = 256 * 1024;
7
7
  const operations = new Set(['capability', 'inspect', 'prepare-workspace', 'prepare-agent', 'execute', 'followup', 'observe', 'wait', 'interrupt', 'resource-preview']);
8
8
  export function refuse(category) { throw Object.assign(new Error(category), { category }); }
9
+ export function verifyDaemonInfo(info, serverId) {
10
+ if (info?.serverId !== serverId) refuse('identity_mismatch');
11
+ if (typeof info.version !== 'string' || !info.version) refuse('unsupported');
12
+ }
9
13
  function text(value) { if (typeof value !== 'string' || !value || value.length > 65536 || value.includes('\0')) refuse('invalid_input'); return value; }
10
14
  function keys(object, allowed) {
11
15
  if (!object || typeof object !== 'object' || Array.isArray(object) || Object.keys(object).some(k => !allowed.includes(k))) refuse('invalid_input');
@@ -19,7 +23,7 @@ export function validate(request) {
19
23
  }
20
24
  if (request.binding_revision != null && !/^[a-f0-9]{64}$/.test(request.binding_revision)) refuse('invalid_input');
21
25
  const fields = {
22
- capability: ['cwd'], inspect: ['target', 'workspace_id', 'agent_id'], 'resource-preview': ['target', 'workspace_id', 'agent_id'],
26
+ capability: ['cwd'], inspect: ['target', 'workspace_id', 'agent_id', 'cursor', 'page_size'], 'resource-preview': ['target', 'workspace_id', 'agent_id', 'cursor', 'page_size'],
23
27
  'prepare-workspace': ['target', 'branch', 'base_commit', 'title'],
24
28
  'prepare-agent': ['workspace_id', 'cwd', 'model', 'effort', 'role', 'context', 'prompt', 'codegraph', 'codegraph_command', 'labels'],
25
29
  execute: ['agent_id', 'cwd', 'prompt', 'client_message_id'], followup: ['agent_id', 'cwd', 'prompt', 'client_message_id'],
@@ -29,6 +33,7 @@ export function validate(request) {
29
33
  for (const [key, value] of Object.entries(request.payload ?? {})) {
30
34
  if (key === 'codegraph') { if (typeof value !== 'boolean') refuse('invalid_input'); }
31
35
  else if (key === 'timeout_ms') { if (!Number.isInteger(value) || value < 1 || value > 3600000) refuse('invalid_input'); }
36
+ else if (key === 'page_size') { if (!Number.isInteger(value) || value < 1 || value > 100) refuse('invalid_input'); }
32
37
  else if (key === 'labels') { keys(value, ['trellis.control', 'trellis.child', 'trellis.attempt']); Object.values(value).forEach(text); }
33
38
  else text(value);
34
39
  }
@@ -48,6 +53,16 @@ function workspace(w) {
48
53
  }
49
54
  export async function perform(request, api, client, identity) {
50
55
  const p = request.payload ?? {}, op = request.operation;
56
+ const methods = {
57
+ capability: [[api.providers, 'listModels'], [api.providers, 'listModes']],
58
+ 'prepare-workspace': [[api.workspaces, 'create']],
59
+ 'prepare-agent': [[api.workspaces, 'ref']],
60
+ execute: [[api.agents, 'ref']], followup: [[api.agents, 'ref']],
61
+ observe: [[api.agents, 'ref']], wait: [[api.agents, 'ref']], interrupt: [[api.agents, 'ref'], [client, 'cancelAgent']],
62
+ inspect: [[api.agents, p.agent_id ? 'ref' : 'list'], [api.config, 'get'], [api.projects, 'list']],
63
+ 'resource-preview': [[api.agents, p.agent_id ? 'ref' : 'list'], [api.config, 'get'], [api.projects, 'list']],
64
+ };
65
+ if (methods[op]?.some(([object, key]) => typeof object?.[key] !== 'function')) refuse('unsupported');
51
66
  async function agent() {
52
67
  const ref = api.agents.ref(text(p.agent_id));
53
68
  await ref.refresh();
@@ -57,7 +72,7 @@ export async function perform(request, api, client, identity) {
57
72
  }
58
73
  if (op === 'capability') {
59
74
  const cwd = text(p.cwd);
60
- return { identity, sdk_version: '0.15.3', protocol: 1, models: await api.providers.listModels('codex', { cwd }), modes: await api.providers.listModes('codex', { cwd }) };
75
+ return { identity, sdk_version: '0.15.3', daemon_version: client.getLastServerInfoMessage().version, protocol: 1, models: await api.providers.listModels('codex', { cwd }), modes: await api.providers.listModes('codex', { cwd }) };
61
76
  }
62
77
  if (op === 'prepare-workspace') {
63
78
  const ref = await api.workspaces.create({ source: { kind: 'worktree', cwd: realpathSync(text(p.target)), action: 'branch-off', baseBranch: text(p.base_commit), branchName: text(p.branch) }, title: text(p.title), background: true });
@@ -97,13 +112,33 @@ export async function perform(request, api, client, identity) {
97
112
  return { identity, agent: projectAgent(ref.current()), wait_status: waitStatus, writer_stop_proven: false };
98
113
  }
99
114
  const agents = [], workspaces = [];
100
- let cursor;
101
- do {
102
- const page = await api.agents.list({ cursor, limit: 100, includeArchived: true, includeBackground: true });
103
- agents.push(...page.entries.map(e => projectAgent(e.agent ?? e)));
104
- cursor = page.pageInfo?.nextCursor;
105
- if (agents.length > 1000) refuse('unsupported');
106
- } while (cursor);
115
+ let cursor = p.cursor, bytes = 4096;
116
+ if (p.cursor && !p.page_size || p.agent_id && (p.cursor || p.page_size)) refuse('invalid_input');
117
+ if (p.agent_id) {
118
+ const ref = api.agents.ref(p.agent_id);
119
+ await ref.refresh();
120
+ const current = ref.current();
121
+ if (current && current.id !== p.agent_id) refuse('identity_mismatch');
122
+ if (current) agents.push(projectAgent(current));
123
+ } else {
124
+ const cursors = new Set(p.cursor ? [p.cursor] : []);
125
+ do {
126
+ const page = await api.agents.list({ cursor, limit: p.page_size ?? 100, includeArchived: true, includeBackground: true });
127
+ if (!Array.isArray(page.entries) || !page.pageInfo || !('nextCursor' in page.pageInfo)) refuse('invalid_response');
128
+ for (const entry of page.entries) {
129
+ const current = entry.agent ?? entry;
130
+ if (p.workspace_id && current.workspaceId !== p.workspace_id) continue;
131
+ const projected = projectAgent(current);
132
+ bytes += Buffer.byteLength(JSON.stringify(projected));
133
+ if (bytes > MAX_BYTES) refuse('response_limit');
134
+ agents.push(projected);
135
+ }
136
+ cursor = page.pageInfo.nextCursor;
137
+ if (cursor != null && (typeof cursor !== 'string' || !cursor || cursors.has(cursor))) refuse('invalid_response');
138
+ if (cursor != null) cursors.add(cursor);
139
+ if (p.page_size) break;
140
+ } while (cursor != null);
141
+ }
107
142
  if (p.workspace_id) {
108
143
  const ref = api.workspaces.ref(text(p.workspace_id));
109
144
  await ref.refresh();
@@ -112,7 +147,10 @@ export async function perform(request, api, client, identity) {
112
147
  const config = await api.config.get();
113
148
  // Only project lifecycle settings are projected. Provider env/keys never leave the client.
114
149
  const projects = await api.projects.list();
115
- return { identity, agents, workspaces, projects: projects.projects?.map(x => ({ id: x.projectId, path: x.projectRootPath })), lifecycle: { autoArchiveAfterMerge: config.config?.autoArchiveAfterMerge ?? null } };
150
+ const result = { identity, agents, workspaces, projects: projects.projects?.map(x => ({ id: x.projectId, path: x.projectRootPath })), lifecycle: { autoArchiveAfterMerge: config.config?.autoArchiveAfterMerge ?? null },
151
+ ...(p.page_size ? { page_info: {next_cursor:cursor ?? null,complete:cursor == null} } : {}) };
152
+ if (Buffer.byteLength(JSON.stringify(result)) > MAX_BYTES - 4096) refuse('response_limit');
153
+ return result;
116
154
  }
117
155
  export async function dispatch(input) {
118
156
  const request = validate(input);
@@ -129,7 +167,8 @@ export async function dispatch(input) {
129
167
  let api;
130
168
  try {
131
169
  await client.connect();
132
- if (client.getLastServerInfoMessage()?.serverId !== instance.serverId || !isSameDaemonInstance(instance, await readDaemonInstance(home))) refuse('identity_mismatch');
170
+ verifyDaemonInfo(client.getLastServerInfoMessage(), instance.serverId);
171
+ if (!isSameDaemonInstance(instance, await readDaemonInstance(home))) refuse('identity_mismatch');
133
172
  api = createPaseoApi(client);
134
173
  return await perform(request, api, client, { server_id: instance.serverId, home, pid: instance.pid, started_at: instance.startedAt });
135
174
  } finally { if (api) await api.dispose(); await client.close(); }