@myagentroam/node 0.9.3 → 0.9.5

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 (66) hide show
  1. package/dist/claude-agent-sdk.d.ts +1 -0
  2. package/dist/claude-agent-sdk.js +9 -0
  3. package/dist/codex-app-server.d.ts +25 -0
  4. package/dist/codex-app-server.js +104 -7
  5. package/dist/connector.d.ts +1 -0
  6. package/dist/connector.js +21 -12
  7. package/dist/database.d.ts +2 -0
  8. package/dist/native-session-history.d.ts +3 -2
  9. package/dist/native-session-history.js +199 -30
  10. package/dist/opencode-server.d.ts +1 -0
  11. package/dist/opencode-server.js +1 -0
  12. package/dist/runner/abstract-runner.d.ts +11 -2
  13. package/dist/runner/abstract-runner.js +4 -0
  14. package/dist/runner/claude/managed-run-controller.js +3 -0
  15. package/dist/runner/claude-code-runner.d.ts +2 -1
  16. package/dist/runner/claude-code-runner.js +4 -0
  17. package/dist/runner/codex/managed-run-controller.d.ts +9 -0
  18. package/dist/runner/codex/managed-run-controller.js +63 -17
  19. package/dist/runner/codex-runner.d.ts +3 -1
  20. package/dist/runner/codex-runner.js +23 -2
  21. package/dist/runner/opencode/managed-run-controller.js +4 -0
  22. package/dist/runner/opencode-runner.d.ts +10 -3
  23. package/dist/runner/opencode-runner.js +87 -14
  24. package/dist/runner/runner-registry.js +16 -1
  25. package/dist/runtime-command-detector.js +1 -6
  26. package/dist/runtime-state.d.ts +2 -0
  27. package/dist/runtime-state.js +12 -7
  28. package/dist/service/conversation-history-service.d.ts +10 -1
  29. package/dist/service/conversation-history-service.js +272 -42
  30. package/dist/service/conversation-segment-service.js +7 -1
  31. package/dist/service/external-session-resume-service.d.ts +2 -0
  32. package/dist/service/external-session-resume-service.js +45 -34
  33. package/dist/service/native-session-projection-service.d.ts +1 -0
  34. package/dist/service/native-session-projection-service.js +4 -0
  35. package/dist/service/native-session-watch-service.d.ts +26 -2
  36. package/dist/service/native-session-watch-service.js +258 -42
  37. package/dist/service/node-request-service.js +2 -1
  38. package/dist/service/run-event-service.js +16 -5
  39. package/dist/service/run-workbench-service.d.ts +2 -4
  40. package/dist/service/run-workbench-service.js +2 -7
  41. package/dist/service/session-command-service.js +1 -1
  42. package/dist/service/session-identity-service.d.ts +1 -1
  43. package/dist/service/session-identity-service.js +1 -1
  44. package/dist/service/session-lifecycle-service.js +7 -12
  45. package/dist/service/session-message-service.d.ts +1 -1
  46. package/dist/service/session-message-service.js +104 -83
  47. package/dist/service/skill-directory-service.d.ts +1 -0
  48. package/dist/service/skill-directory-service.js +40 -6
  49. package/dist/service/workspace-change-service.js +1 -1
  50. package/dist/service/workspace-domain-state.d.ts +3 -0
  51. package/dist/service/workspace-domain-state.js +1 -0
  52. package/dist/service/workspace-file-service.d.ts +1 -0
  53. package/dist/service/workspace-file-service.js +14 -1
  54. package/dist/service/workspace-queue-workbench-service.d.ts +29 -2
  55. package/dist/service/workspace-queue-workbench-service.js +73 -8
  56. package/dist/service/workspace-watch-service.d.ts +7 -2
  57. package/dist/service/workspace-watch-service.js +32 -6
  58. package/dist/service/workspace-workbench-service.d.ts +14 -0
  59. package/dist/service/workspace-workbench-service.js +215 -16
  60. package/dist/util/personal-instructions.d.ts +2 -0
  61. package/dist/util/personal-instructions.js +31 -0
  62. package/dist/util/runner-native-session-parsers.d.ts +3 -1
  63. package/dist/util/runner-native-session-parsers.js +35 -17
  64. package/dist/workspace.d.ts +14 -8
  65. package/dist/workspace.js +98 -50
  66. package/package.json +2 -2
package/dist/workspace.js CHANGED
@@ -1,13 +1,12 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { watch } from 'node:fs';
3
- import { lstat, mkdir, opendir, readdir, readFile, realpath, rename, rm, stat, unlink, writeFile } from 'node:fs/promises';
3
+ import { lstat, mkdir, opendir, open, readdir, readFile, realpath, rename, rm, stat, unlink, writeFile } from 'node:fs/promises';
4
4
  import { homedir, platform as hostPlatform } from 'node:os';
5
5
  import { dirname, isAbsolute, posix, relative, resolve, sep, win32 } from 'node:path';
6
6
  import { spawn } from 'node:child_process';
7
7
  import { minimatch } from 'minimatch';
8
8
  const GIT_TIMEOUT_MS = 5_000;
9
9
  const GIT_OUTPUT_LIMIT = 512 * 1024;
10
- const GIT_BINARY_PREVIEW_LIMIT = 4 * 1024 * 1024;
11
10
  const FILE_READ_LIMIT = 512 * 1024;
12
11
  const DIRECTORY_PAGE_LIMIT = 200;
13
12
  const DIRECTORY_PICKER_LIMIT = 200;
@@ -665,6 +664,38 @@ export async function readWorkspaceTextFile(workspaceRoot, requestedPath, offset
665
664
  nextOffset
666
665
  };
667
666
  }
667
+ export async function readWorkspaceFileContentRange(workspaceRoot, requestedPath, offset = 0, limit = FILE_READ_LIMIT) {
668
+ if (!Number.isSafeInteger(offset) ||
669
+ offset < 0 ||
670
+ !Number.isSafeInteger(limit) ||
671
+ limit < 1 ||
672
+ limit > FILE_READ_LIMIT)
673
+ throw new Error('FILE_RANGE_INVALID');
674
+ const root = await realpath(workspaceRoot);
675
+ const file = await resolveWorkspaceEntry(root, requestedPath, false);
676
+ const metadata = await lstat(file);
677
+ if (!metadata.isFile())
678
+ throw new Error('FILE_NOT_REGULAR');
679
+ if (offset > metadata.size)
680
+ throw new Error('FILE_RANGE_INVALID');
681
+ const length = Math.min(limit, metadata.size - offset);
682
+ const source = Buffer.allocUnsafe(length);
683
+ const handle = await open(file, 'r');
684
+ try {
685
+ const { bytesRead } = await handle.read(source, 0, length, offset);
686
+ const end = offset + bytesRead;
687
+ return {
688
+ path: relative(root, file).split(sep).join('/'),
689
+ size: metadata.size,
690
+ offset,
691
+ contentBase64: source.subarray(0, bytesRead).toString('base64'),
692
+ nextOffset: end < metadata.size ? end : null
693
+ };
694
+ }
695
+ finally {
696
+ await handle.close();
697
+ }
698
+ }
668
699
  /** Reads one absolute file only when the resolved target remains within a Node allowed root. */
669
700
  export async function readAllowedTextFile(requestedPath, allowedRoots, offset = 0, limit = FILE_READ_LIMIT) {
670
701
  if (!isAbsolute(requestedPath))
@@ -1212,47 +1243,58 @@ export async function readGitHistoryFileDiff(repository, commit, requestedPath,
1212
1243
  ]);
1213
1244
  const binary = result.output.includes(0) || result.text.includes('Binary files ');
1214
1245
  if (binary) {
1215
- const [beforePreview, afterPreview] = await Promise.all([
1216
- readGitBinaryPreview(repository, `${commit}^`, previousPath ?? path),
1217
- readGitBinaryPreview(repository, commit, path)
1218
- ]);
1219
1246
  return {
1220
1247
  binary: true,
1221
1248
  summary: `binary diff sha256=${createHash('sha256').update(result.output).digest('hex')} bytes=${result.output.length}`,
1222
- truncated: result.truncated,
1223
- ...(beforePreview === undefined ? {} : { beforePreview }),
1224
- ...(afterPreview === undefined ? {} : { afterPreview })
1249
+ truncated: result.truncated
1225
1250
  };
1226
1251
  }
1227
1252
  return { binary: false, text: result.text, truncated: result.truncated };
1228
1253
  }
1254
+ export async function readGitHistoryFileContentRange(repository, commit, requestedPath, offset, limit, refs) {
1255
+ if (!Number.isSafeInteger(offset) ||
1256
+ offset < 0 ||
1257
+ !Number.isSafeInteger(limit) ||
1258
+ limit < 1 ||
1259
+ limit > 20 * 1024 * 1024 ||
1260
+ offset + limit > 20 * 1024 * 1024)
1261
+ throw new Error('FILE_RANGE_INVALID');
1262
+ await assertHistoryCommitReachable(repository, commit, refs);
1263
+ const path = safeGitWorkspacePath(requestedPath);
1264
+ const object = `${commit}:${path}`;
1265
+ const sizeResult = await runGit(repository, ['cat-file', '-s', object]);
1266
+ const size = Number(sizeResult.text.trim());
1267
+ if (!Number.isSafeInteger(size) || size < 0 || offset > size)
1268
+ throw new Error('FILE_RANGE_INVALID');
1269
+ if (offset === size)
1270
+ return { path, size, offset, contentBase64: '', nextOffset: null };
1271
+ const result = await runGitAllowFailure(repository, ['cat-file', 'blob', object], offset + limit);
1272
+ if (result.code !== 0)
1273
+ throw new GitCommandError(result.code, result.stderr);
1274
+ const content = result.output.subarray(offset, Math.min(size, offset + limit));
1275
+ const nextOffset = offset + content.length;
1276
+ return {
1277
+ path,
1278
+ size,
1279
+ offset,
1280
+ contentBase64: content.toString('base64'),
1281
+ nextOffset: nextOffset < size ? nextOffset : null
1282
+ };
1283
+ }
1229
1284
  export async function readCurrentChanges(workspacePath) {
1230
1285
  return (await readCurrentChangesSummary(workspacePath)).changes;
1231
1286
  }
1232
1287
  export async function readCurrentChangeDiff(workspacePath, requestedPath) {
1233
1288
  const path = safeGitWorkspacePath(requestedPath);
1234
1289
  await assertCurrentChangePathAccessible(workspacePath, path);
1235
- const result = await runGit(workspacePath, [
1236
- 'diff',
1237
- '--no-ext-diff',
1238
- '--no-textconv',
1239
- 'HEAD',
1240
- '--',
1241
- `:(literal)${path}`
1242
- ]);
1290
+ const result = await readCurrentChangeGitDiff(workspacePath, path);
1243
1291
  const after = await readWorkingTreeText(workspacePath, path);
1244
1292
  const binary = result.output.includes(0) || result.text.includes('Binary files ') || after?.binary === true;
1245
1293
  if (binary) {
1246
- const [beforePreview, afterPreview] = await Promise.all([
1247
- readGitBinaryPreview(workspacePath, 'HEAD', path),
1248
- readWorkingTreeBinaryPreview(workspacePath, path)
1249
- ]);
1250
1294
  return {
1251
1295
  binary: true,
1252
1296
  summary: `binary diff sha256=${createHash('sha256').update(result.output).digest('hex')} bytes=${result.output.length}`,
1253
- truncated: result.truncated || after?.truncated === true,
1254
- ...(beforePreview === undefined ? {} : { beforePreview }),
1255
- ...(afterPreview === undefined ? {} : { afterPreview })
1297
+ truncated: result.truncated || after?.truncated === true
1256
1298
  };
1257
1299
  }
1258
1300
  return {
@@ -1263,6 +1305,38 @@ export async function readCurrentChangeDiff(workspacePath, requestedPath) {
1263
1305
  ...(after === undefined ? {} : { afterTruncated: after.truncated })
1264
1306
  };
1265
1307
  }
1308
+ async function readCurrentChangeGitDiff(workspacePath, path) {
1309
+ const untracked = await runGit(workspacePath, [
1310
+ 'ls-files',
1311
+ '--others',
1312
+ '--exclude-standard',
1313
+ '-z',
1314
+ '--',
1315
+ `:(literal)${path}`
1316
+ ]);
1317
+ if (untracked.text.split('\0').includes(path)) {
1318
+ const result = await runGitAllowFailure(workspacePath, [
1319
+ 'diff',
1320
+ '--no-index',
1321
+ '--no-ext-diff',
1322
+ '--no-textconv',
1323
+ '--',
1324
+ '/dev/null',
1325
+ path
1326
+ ]);
1327
+ if (result.code !== 0 && result.code !== 1)
1328
+ throw new GitCommandError(result.code, result.stderr);
1329
+ return result;
1330
+ }
1331
+ return runGit(workspacePath, [
1332
+ 'diff',
1333
+ '--no-ext-diff',
1334
+ '--no-textconv',
1335
+ 'HEAD',
1336
+ '--',
1337
+ `:(literal)${path}`
1338
+ ]);
1339
+ }
1266
1340
  /** Current Changes must not expose an external link. */
1267
1341
  export async function isWorkspaceChangeVisible(workspacePath, requestedPath) {
1268
1342
  try {
@@ -1290,32 +1364,6 @@ async function assertCurrentChangePathAccessible(workspacePath, path) {
1290
1364
  return;
1291
1365
  await resolveWorkspaceEntry(root, path, false);
1292
1366
  }
1293
- async function readGitBinaryPreview(repository, ref, path) {
1294
- const result = await runGitAllowFailure(repository, ['show', `${ref}:${path}`], GIT_BINARY_PREVIEW_LIMIT);
1295
- if (result.code !== 0)
1296
- return undefined;
1297
- return result.truncated
1298
- ? { truncated: true }
1299
- : { contentBase64: result.output.toString('base64'), truncated: false };
1300
- }
1301
- async function readWorkingTreeBinaryPreview(workspacePath, path) {
1302
- const root = await realpath(workspacePath);
1303
- let file;
1304
- try {
1305
- file = await resolveWorkspaceEntry(root, path, false);
1306
- }
1307
- catch (error) {
1308
- if (error instanceof Error && error.message === 'FILE_NOT_FOUND')
1309
- return undefined;
1310
- throw error;
1311
- }
1312
- const metadata = await lstat(file);
1313
- if (!metadata.isFile())
1314
- return undefined;
1315
- if (metadata.size > GIT_BINARY_PREVIEW_LIMIT)
1316
- return { truncated: true };
1317
- return { contentBase64: (await readFile(file)).toString('base64'), truncated: false };
1318
- }
1319
1367
  async function readWorkingTreeText(workspacePath, path) {
1320
1368
  const root = await realpath(workspacePath);
1321
1369
  let file;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/node",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "description": "MyAgentRoam Node runtime CLI.",
5
5
  "type": "module",
6
6
  "files": [
@@ -24,7 +24,7 @@
24
24
  "node-pty": "1.1.0",
25
25
  "ws": "^8.21.3",
26
26
  "zod": "4.4.3",
27
- "@myagentroam/protocol": "^0.9.3"
27
+ "@myagentroam/protocol": "^0.9.5"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/ws": "^8.18.1"