@pennixrv/trellis-paseo-adapter 0.7.2-beta.6 → 0.7.2-beta.8

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 +12 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pennixrv/trellis-paseo-adapter",
3
- "version": "0.7.2-beta.6",
3
+ "version": "0.7.2-beta.8",
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') });
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
  }