@pennixrv/trellis-paseo-adapter 0.7.2-beta.20 → 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 +15 -5
  2. package/package.json +1 -1
  3. package/src/adapter.js +44 -10
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 a running Paseo daemon 0.15.3 or 0.15.4. 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,8 +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 matrix is Paseo SDK 0.15.3 with daemon 0.15.3 or 0.15.4 and Codex;
15
- the public server-info handshake checks the daemon identity and exact version before
16
- any operation. Missing or unknown versions, other providers and remote transports
17
- are refused. Capability output distinguishes `sdk_version` from `daemon_version`.
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`.
18
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.20",
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
@@ -8,7 +8,7 @@ const operations = new Set(['capability', 'inspect', 'prepare-workspace', 'prepa
8
8
  export function refuse(category) { throw Object.assign(new Error(category), { category }); }
9
9
  export function verifyDaemonInfo(info, serverId) {
10
10
  if (info?.serverId !== serverId) refuse('identity_mismatch');
11
- if (!['0.15.3', '0.15.4'].includes(info.version)) refuse('unsupported');
11
+ if (typeof info.version !== 'string' || !info.version) refuse('unsupported');
12
12
  }
13
13
  function text(value) { if (typeof value !== 'string' || !value || value.length > 65536 || value.includes('\0')) refuse('invalid_input'); return value; }
14
14
  function keys(object, allowed) {
@@ -23,7 +23,7 @@ export function validate(request) {
23
23
  }
24
24
  if (request.binding_revision != null && !/^[a-f0-9]{64}$/.test(request.binding_revision)) refuse('invalid_input');
25
25
  const fields = {
26
- 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'],
27
27
  'prepare-workspace': ['target', 'branch', 'base_commit', 'title'],
28
28
  'prepare-agent': ['workspace_id', 'cwd', 'model', 'effort', 'role', 'context', 'prompt', 'codegraph', 'codegraph_command', 'labels'],
29
29
  execute: ['agent_id', 'cwd', 'prompt', 'client_message_id'], followup: ['agent_id', 'cwd', 'prompt', 'client_message_id'],
@@ -33,6 +33,7 @@ export function validate(request) {
33
33
  for (const [key, value] of Object.entries(request.payload ?? {})) {
34
34
  if (key === 'codegraph') { if (typeof value !== 'boolean') refuse('invalid_input'); }
35
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'); }
36
37
  else if (key === 'labels') { keys(value, ['trellis.control', 'trellis.child', 'trellis.attempt']); Object.values(value).forEach(text); }
37
38
  else text(value);
38
39
  }
@@ -52,6 +53,16 @@ function workspace(w) {
52
53
  }
53
54
  export async function perform(request, api, client, identity) {
54
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');
55
66
  async function agent() {
56
67
  const ref = api.agents.ref(text(p.agent_id));
57
68
  await ref.refresh();
@@ -101,13 +112,33 @@ export async function perform(request, api, client, identity) {
101
112
  return { identity, agent: projectAgent(ref.current()), wait_status: waitStatus, writer_stop_proven: false };
102
113
  }
103
114
  const agents = [], workspaces = [];
104
- let cursor;
105
- do {
106
- const page = await api.agents.list({ cursor, limit: 100, includeArchived: true, includeBackground: true });
107
- agents.push(...page.entries.map(e => projectAgent(e.agent ?? e)));
108
- cursor = page.pageInfo?.nextCursor;
109
- if (agents.length > 1000) refuse('unsupported');
110
- } 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
+ }
111
142
  if (p.workspace_id) {
112
143
  const ref = api.workspaces.ref(text(p.workspace_id));
113
144
  await ref.refresh();
@@ -116,7 +147,10 @@ export async function perform(request, api, client, identity) {
116
147
  const config = await api.config.get();
117
148
  // Only project lifecycle settings are projected. Provider env/keys never leave the client.
118
149
  const projects = await api.projects.list();
119
- 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;
120
154
  }
121
155
  export async function dispatch(input) {
122
156
  const request = validate(input);