@pennixrv/trellis-paseo-adapter 0.7.2-beta.5 → 0.7.2-beta.7

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/adapter.js +13 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pennixrv/trellis-paseo-adapter",
3
- "version": "0.7.2-beta.5",
3
+ "version": "0.7.2-beta.7",
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
@@ -1,4 +1,5 @@
1
- import { realpathSync } from 'node:fs';
1
+ import { accessSync, constants, realpathSync, statSync } from 'node:fs';
2
+ import { isAbsolute } from 'node:path';
2
3
  import { randomUUID, createHash } from 'node:crypto';
3
4
  import { hostname } from 'node:os';
4
5
 
@@ -20,7 +21,7 @@ export function validate(request) {
20
21
  const fields = {
21
22
  capability: ['cwd'], inspect: ['target', 'workspace_id', 'agent_id'], 'resource-preview': ['target', 'workspace_id', 'agent_id'],
22
23
  'prepare-workspace': ['target', 'branch', 'base_commit', 'title'],
23
- 'prepare-agent': ['workspace_id', 'cwd', 'model', 'effort', 'role', 'context', 'prompt', 'codegraph', 'labels'],
24
+ 'prepare-agent': ['workspace_id', 'cwd', 'model', 'effort', 'role', 'context', 'prompt', 'codegraph', 'codegraph_command', 'labels'],
24
25
  execute: ['agent_id', 'cwd', 'prompt', 'client_message_id'], followup: ['agent_id', 'cwd', 'prompt', 'client_message_id'],
25
26
  observe: ['agent_id', 'cwd'], wait: ['agent_id', 'cwd', 'timeout_ms'], interrupt: ['agent_id', 'cwd'],
26
27
  };
@@ -66,8 +67,15 @@ export async function perform(request, api, client, identity) {
66
67
  if (op === 'prepare-agent') {
67
68
  const cwd = realpathSync(text(p.cwd));
68
69
  const config = { provider: `codex/${text(p.model)}`, thinkingOptionId: text(p.effort), modeId: 'full-access', systemPrompt: text(p.role) };
69
- if (p.codegraph) config.mcpServers = { codegraph: { type: 'stdio', command: 'codegraph', args: ['serve', '--mcp', '--bound-worktree', cwd] } };
70
- const ref = await api.workspaces.ref(text(p.workspace_id)).agents.create({ config, env: { TRELLIS_DELEGATION_CONTEXT: text(p.context) }, prompt: text(p.prompt), labels: p.labels, idempotencyKey: createHash('sha256').update(request.attempt_id + request.binding_revision).digest('hex'), background: true });
70
+ if (p.codegraph) {
71
+ const command = text(p.codegraph_command);
72
+ if (!isAbsolute(command) || !statSync(command).isFile()) refuse('invalid_input');
73
+ accessSync(command, constants.X_OK);
74
+ // The daemon may have a narrower PATH than the controller that admitted the tool.
75
+ config.mcpServers = { codegraph: { type: 'stdio', command, args: ['serve', '--mcp', '--bound-worktree', cwd] } };
76
+ }
77
+ const fingerprint = JSON.stringify({ config, cwd, context: p.context, prompt: p.prompt, labels: p.labels });
78
+ const ref = await api.workspaces.ref(text(p.workspace_id)).agents.create({ config, env: { TRELLIS_DELEGATION_CONTEXT: text(p.context) }, prompt: text(p.prompt), labels: p.labels, idempotencyKey: createHash('sha256').update(request.attempt_id + request.binding_revision + fingerprint).digest('hex') });
71
79
  await ref.refresh();
72
80
  return { identity, agent: projectAgent(ref.current()) };
73
81
  }
@@ -91,7 +99,7 @@ export async function perform(request, api, client, identity) {
91
99
  const agents = [], workspaces = [];
92
100
  let cursor;
93
101
  do {
94
- const page = await api.agents.list({ cursor, limit: 100, includeArchived: true });
102
+ const page = await api.agents.list({ cursor, limit: 100, includeArchived: true, includeBackground: true });
95
103
  agents.push(...page.entries.map(e => projectAgent(e.agent ?? e)));
96
104
  cursor = page.pageInfo?.nextCursor;
97
105
  if (agents.length > 1000) refuse('unsupported');