@xenosystem/agent-interface-host 0.1.178 → 0.1.180

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.
@@ -7,8 +7,8 @@ declare const receiptSchema: z.ZodObject<{
7
7
  state: z.ZodLiteral<"committed">;
8
8
  owner: z.ZodObject<{
9
9
  type: z.ZodEnum<{
10
- workspace: "workspace";
11
10
  user: "user";
11
+ workspace: "workspace";
12
12
  }>;
13
13
  id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
14
14
  }, z.core.$strict>;
@@ -28,8 +28,8 @@ declare const recordSchema: z.ZodObject<{
28
28
  operationId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
29
29
  owner: z.ZodObject<{
30
30
  type: z.ZodEnum<{
31
- workspace: "workspace";
32
31
  user: "user";
32
+ workspace: "workspace";
33
33
  }>;
34
34
  id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
35
35
  }, z.core.$strict>;
@@ -65,8 +65,8 @@ declare const recordSchema: z.ZodObject<{
65
65
  operationId: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
66
66
  owner: z.ZodObject<{
67
67
  type: z.ZodEnum<{
68
- workspace: "workspace";
69
68
  user: "user";
69
+ workspace: "workspace";
70
70
  }>;
71
71
  id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
72
72
  }, z.core.$strict>;
@@ -75,12 +75,12 @@ declare const recordSchema: z.ZodObject<{
75
75
  description: z.ZodOptional<z.ZodString>;
76
76
  }, z.core.$strict>], "kind">;
77
77
  state: z.ZodEnum<{
78
- dispatched: "dispatched";
79
- committed: "committed";
80
- uncertain: "uncertain";
81
- rejected: "rejected";
82
78
  prepared: "prepared";
79
+ committed: "committed";
83
80
  cancelled: "cancelled";
81
+ rejected: "rejected";
82
+ dispatched: "dispatched";
83
+ uncertain: "uncertain";
84
84
  }>;
85
85
  dispatchCount: z.ZodNumber;
86
86
  createdAt: z.ZodString;
@@ -92,8 +92,8 @@ declare const recordSchema: z.ZodObject<{
92
92
  state: z.ZodLiteral<"committed">;
93
93
  owner: z.ZodObject<{
94
94
  type: z.ZodEnum<{
95
- workspace: "workspace";
96
95
  user: "user";
96
+ workspace: "workspace";
97
97
  }>;
98
98
  id: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
99
99
  }, z.core.$strict>;
@@ -2,6 +2,7 @@ import type { AgentEngineeringHostMethod, AgentHostInput, AgentHostOutput, Engin
2
2
  import { type RuntimeEventStore } from '../runtime/RuntimeEventStore.js';
3
3
  export declare class EngineeringWorkbenchService {
4
4
  private activeBackgroundRuns;
5
+ private readonly devServers;
5
6
  private runtimeEventStore;
6
7
  /**
7
8
  * The landing queue, when the composition mounted one.
@@ -109,6 +110,11 @@ export declare class EngineeringWorkbenchService {
109
110
  restoreCheckpoint(request: EngineeringCheckpointRestoreRequest): EngineeringCheckpointRestoreResponse;
110
111
  listSessions(request: EngineeringRequestBase): EngineeringSessionListResponse;
111
112
  runtimeTimeline(request: EngineeringRuntimeTimelineRequest): EngineeringRuntimeTimelineResponse;
113
+ /** Both sides of one file. A file new to git has an empty original, and a deleted one an empty modified. */
114
+ private fileContents;
115
+ private gh;
116
+ private workCopies;
117
+ private workCopyCreate;
112
118
  private resolveRoot;
113
119
  private buildCheckpointSummaries;
114
120
  private buildEngineeringSessions;
@@ -1 +1 @@
1
- {"version":3,"file":"EngineeringWorkbenchService.d.ts","sourceRoot":"","sources":["../../src/engineering/EngineeringWorkbenchService.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EACV,0BAA0B,EAC1B,cAAc,EACd,eAAe,EAEf,oCAAoC,EACpC,qCAAqC,EACrC,+BAA+B,EAC/B,gCAAgC,EAEhC,mCAAmC,EACnC,oCAAoC,EAEpC,iCAAiC,EACjC,mCAAmC,EACnC,oCAAoC,EAEpC,iCAAiC,EAEjC,8BAA8B,EAE9B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,E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AA;IAC7D,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAC/D,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;CACtE"}
1
+ {"version":3,"file":"EngineeringWorkbenchService.d.ts","sourceRoot":"","sources":["../../src/engineering/EngineeringWorkbenchService.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,0BAA0B,EAC1B,cAAc,EACd,eAAe,EAEf,oCAAoC,EACpC,qCAAqC,EACrC,+BAA+B,EAC/B,gCAAgC,EAEhC,mCAAmC,EACnC,oCAAoC,EAEpC,iCAAiC,EACjC,mCAAmC,EACnC,oCAAoC,EAEpC,iCAAiC,EAEjC,8BAA8B,EAE9B,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EAEtB,iCAAiC,EACjC,kCAAkC,EAElC,8BAA8B,EAC9B,gBAAgB,EAChB,cAAc,EACd,eAAe,EAEf,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,2BAA2B,EAC3B,4BAA4B,EAE5B,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EAGrB,uBAAuB,EACvB,2BAA2B,EAE3B,2BAA2B,EAC3B,4BAA4B,EAE5B,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAiD9F,qBAAa,2BAA2B;IACtC,OAAO,CAAC,oBAAoB,CAAyC;IACrE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,OAAO,CAAC,iBAAiB,CAA+C;IAExE;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc,CAAgC;gBAE1C,OAAO,GAAE;QACnB,iBAAiB,CAAC,E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;IAS5B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,wBAAwB;IA+BhC,OAAO,CAAC,wBAAwB;YAqClB,SAAS;IAKvB,OAAO,CAAC,qBAAqB;YAef,cAAc;IA8B5B,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,oBAAoB;IA2C5B,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,oBAAoB;CAG7B;AA22BD,wBAAgB,8BAA8B,IAAI,2BAA2B,CAG5E;AA8BD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACtE,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACpE,MAAM,CAAC,OAAO,EAAE,sBAAsB,GAAG,oBAAoB,CAAA;IAC7D,IAAI,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;IAC/D,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;CACtE"}
@@ -2,8 +2,12 @@ import { randomUUID } from 'crypto';
2
2
  import { spawn } from 'child_process';
3
3
  import { commandSucceeded } from '../isolation/CommandExecution.js';
4
4
  import { LocalCommandExecutor } from '../isolation/LocalCommandExecutor.js';
5
- import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, unlinkSync, writeFileSync, } from 'fs';
6
- import { dirname, isAbsolute, join, relative, resolve } from 'path';
5
+ import { WorkCopies } from './workCopies.js';
6
+ import { DevServers } from './devServers.js';
7
+ import { enablePullRequestAutoMerge, pullRequestFeedback, pullRequestStatus } from './pullRequests.js';
8
+ import { existsSync, lstatSync, statSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, unlinkSync, writeFileSync, } from 'fs';
9
+ import { basename, dirname, isAbsolute, join, relative, resolve } from 'path';
10
+ import { createDirs } from '@xenosystem/primitives/dirs';
7
11
  import { isPathInside, hashText, resolveRootDirectory, safeReadJson, safeWriteJson, workspaceIndexDirectory, } from '../codebase/codeUtils.js';
8
12
  import { getRuntimeEventStore } from '../runtime/RuntimeEventStore.js';
9
13
  import { buildPatchReviewHunks, composePatchSnapshot, effectivePatchDecisions, } from './patchReview.js';
@@ -17,6 +21,7 @@ const MAX_TRANSACTIONAL_SNAPSHOT_BYTES = 1_000_000;
17
21
  const MAX_TRANSACTIONAL_SNAPSHOT_CHARS = 250_000;
18
22
  export class EngineeringWorkbenchService {
19
23
  activeBackgroundRuns = new Map();
24
+ devServers = new DevServers();
20
25
  runtimeEventStore;
21
26
  /**
22
27
  * The landing queue, when the composition mounted one.
@@ -39,6 +44,7 @@ export class EngineeringWorkbenchService {
39
44
  this.runtimeEventStore = runtimeEventStore;
40
45
  }
41
46
  close() {
47
+ this.devServers.close();
42
48
  for (const active of this.activeBackgroundRuns.values()) {
43
49
  active.stopRequested = true;
44
50
  killProcessTree(active.child);
@@ -61,6 +67,41 @@ export class EngineeringWorkbenchService {
61
67
  return await this.gitPush(input);
62
68
  if (method === 'engineering.git.pr.create')
63
69
  return await this.gitCreatePullRequest(input);
70
+ if (method === 'engineering.devServer.list')
71
+ return await this.devServers.list(this.resolveRoot(input));
72
+ if (method === 'engineering.devServer.start') {
73
+ const request = input;
74
+ if (request.confirmed !== true) {
75
+ return { success: false, error: 'Starting a dev server runs a command from the repository and was not confirmed. Send confirmed: true from a real click.' };
76
+ }
77
+ return this.devServers.start(this.resolveRoot(request), String(request.name));
78
+ }
79
+ if (method === 'engineering.devServer.stop') {
80
+ const request = input;
81
+ return this.devServers.stop(this.resolveRoot(request), String(request.name));
82
+ }
83
+ if (method === 'engineering.git.pr.status')
84
+ return await pullRequestStatus(this.gh(input));
85
+ if (method === 'engineering.git.pr.feedback') {
86
+ const request = input;
87
+ return await pullRequestFeedback(this.gh(request), Number(request.number));
88
+ }
89
+ if (method === 'engineering.git.pr.merge') {
90
+ const request = input;
91
+ if (request.confirmed !== true) {
92
+ return { success: false, enabled: false, error: 'Merging is outward-facing and was not confirmed. Send confirmed: true from a real click.' };
93
+ }
94
+ return await enablePullRequestAutoMerge(this.gh(request), Number(request.number));
95
+ }
96
+ if (method === 'engineering.workCopy.list')
97
+ return await this.workCopies().list(this.resolveRoot(input));
98
+ if (method === 'engineering.workCopy.create') {
99
+ return await this.workCopyCreate(input);
100
+ }
101
+ if (method === 'engineering.workCopy.remove') {
102
+ const request = input;
103
+ return await this.workCopies().remove(this.resolveRoot(request), request);
104
+ }
64
105
  if (method === 'engineering.landing.enqueue')
65
106
  return this.landing('enqueue', input);
66
107
  if (method === 'engineering.landing.remove')
@@ -170,12 +211,16 @@ export class EngineeringWorkbenchService {
170
211
  const safePaths = this.validateRelativePaths(rootDirectory, request.paths === undefined ? [] : request.paths);
171
212
  const args = ['diff', ...(request.staged ? ['--staged'] : []), '--', ...safePaths];
172
213
  const result = await runProcess('git', args, rootDirectory, 12000, request.maxBytes || MAX_GIT_OUTPUT);
214
+ const contents = request.includeContents && safePaths.length === 1
215
+ ? await this.fileContents(rootDirectory, safePaths[0])
216
+ : undefined;
173
217
  return {
174
218
  success: result.success || result.exitCode === 1 || result.exitCode === 0,
175
219
  isGitRepo: true,
176
220
  rootDirectory,
177
221
  diff: result.stdout,
178
222
  truncated: result.truncated,
223
+ ...(contents ? { contents } : {}),
179
224
  error: result.success || result.exitCode === 1 || result.exitCode === 0 ? undefined : result.error || result.stderr,
180
225
  };
181
226
  }
@@ -1257,6 +1302,38 @@ export class EngineeringWorkbenchService {
1257
1302
  };
1258
1303
  }
1259
1304
  }
1305
+ /** Both sides of one file. A file new to git has an empty original, and a deleted one an empty modified. */
1306
+ async fileContents(rootDirectory, relativePath) {
1307
+ const absolute = resolve(rootDirectory, relativePath);
1308
+ const size = existsSync(absolute) ? statSync(absolute).size : 0;
1309
+ if (size > MAX_TRANSACTIONAL_SNAPSHOT_BYTES)
1310
+ return undefined;
1311
+ const head = await runProcess('git', ['show', `HEAD:./${relativePath.replace(/\\/g, '/')}`], rootDirectory, 12000, MAX_TRANSACTIONAL_SNAPSHOT_BYTES);
1312
+ if (head.truncated)
1313
+ return undefined;
1314
+ const original = head.success ? head.stdout : '';
1315
+ const modified = size > 0 ? readFileSync(absolute, 'utf-8') : '';
1316
+ return original.includes('\0') || modified.includes('\0') ? undefined : { original, modified };
1317
+ }
1318
+ gh(request) {
1319
+ const rootDirectory = this.resolveRoot(request);
1320
+ return (args) => runProcess('gh', args, rootDirectory, 60000, MAX_GIT_OUTPUT);
1321
+ }
1322
+ workCopies() {
1323
+ return new WorkCopies(
1324
+ // State, not cache: clearing an index must never delete someone's work.
1325
+ (repository) => createDirs().path('state', 'agents/sessions', 'work-copies', basename(workspaceIndexDirectory(repository))), (args, cwd) => runProcess('git', ['-c', 'core.longpaths=true', ...args], cwd, 120000, MAX_GIT_OUTPUT));
1326
+ }
1327
+ async workCopyCreate(request) {
1328
+ const rootDirectory = this.resolveRoot(request);
1329
+ if (!await this.isGitRepo(rootDirectory))
1330
+ return { success: false, error: 'Workspace is not a git repository.' };
1331
+ const base = String(request.base || '').trim();
1332
+ const invalid = base ? validateRefName(base) : undefined;
1333
+ if (invalid)
1334
+ return { success: false, error: invalid };
1335
+ return await this.workCopies().create(rootDirectory, request);
1336
+ }
1260
1337
  resolveRoot(request) {
1261
1338
  return resolveRootDirectory(request.rootDirectory, request.allowedDirectories);
1262
1339
  }