@wrongstack/core 0.305.0 → 0.306.0

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 (44) hide show
  1. package/dist/chronicle/project-server.js +18 -48
  2. package/dist/coordination/agents/index.js +3 -2
  3. package/dist/coordination/agents/types.d.ts +1 -1
  4. package/dist/coordination/index.d.ts +1 -0
  5. package/dist/coordination/index.js +5 -2
  6. package/dist/coordination/mailbox-project-server.js +28 -57
  7. package/dist/core/index.d.ts +2 -1
  8. package/dist/core/index.js +2764 -2632
  9. package/dist/core/system-prompt-blocks.d.ts +1 -1
  10. package/dist/core/system-prompt-builder.d.ts +7 -1
  11. package/dist/core/system-prompt-glossary.d.ts +0 -23
  12. package/dist/defaults/index.js +3 -2
  13. package/dist/execution/index.js +3 -2
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +898 -531
  16. package/dist/observability/index.js +7 -3
  17. package/dist/plugin/index.d.ts +4 -3
  18. package/dist/plugin/index.js +589 -143
  19. package/dist/plugins/auto-review-plugin.d.ts +14 -7
  20. package/dist/plugins/chimera-plugin.d.ts +15 -1
  21. package/dist/plugins/review-finding-integration.d.ts +15 -3
  22. package/dist/plugins/review-finding-parser.d.ts +36 -0
  23. package/dist/plugins/review-finding-types.d.ts +46 -0
  24. package/dist/plugins/review-finding-verification.d.ts +53 -0
  25. package/dist/plugins/review-report-integration.d.ts +1 -0
  26. package/dist/plugins/review-report-store.d.ts +7 -0
  27. package/dist/plugins/review-report-types.d.ts +14 -0
  28. package/dist/plugins/review-types.d.ts +74 -0
  29. package/dist/replay/replay-provider-runner.d.ts +5 -4
  30. package/dist/session-catalog/project-server.js +36 -65
  31. package/dist/tools/fallback-manage-tool-options.d.ts +9 -0
  32. package/dist/tools/index.js +91 -38
  33. package/dist/tools/one-shot-llm-tool.d.ts +6 -0
  34. package/dist/types/blocks.d.ts +10 -0
  35. package/dist/types/config/ui.d.ts +7 -4
  36. package/dist/types/index.js +21 -1
  37. package/dist/utils/index.js +8 -9
  38. package/instructions/agents/browser.md +1 -0
  39. package/instructions/agents/e2e.md +2 -0
  40. package/instructions/llm/chimera-review.md +52 -1
  41. package/instructions/system-lite.md +17 -6
  42. package/instructions/system-pro.md +25 -20
  43. package/instructions/system.md +25 -12
  44. package/package.json +3 -3
@@ -2,10 +2,10 @@
2
2
 
3
3
  // src/chronicle/project-server.ts
4
4
  import { randomBytes } from "node:crypto";
5
- import * as fs10 from "node:fs";
6
5
  import * as fsp4 from "node:fs/promises";
7
6
  import * as net from "node:net";
8
7
  import * as path15 from "node:path";
8
+ import { bindProjectEndpoint } from "@wrongstack/persistence";
9
9
 
10
10
  // src/utils/atomic-write.ts
11
11
  import {
@@ -2923,13 +2923,6 @@ import * as fs7 from "node:fs";
2923
2923
  import { createRequire } from "node:module";
2924
2924
  import * as path12 from "node:path";
2925
2925
 
2926
- // src/utils/socket-path.ts
2927
- import {
2928
- assertUnixSocketPathWithinLimit,
2929
- checkUnixSocketPath,
2930
- unixSocketPathLimit
2931
- } from "@wrongstack/persistence";
2932
-
2933
2926
  // src/chronicle/sqlite-query.ts
2934
2927
  var MAX_LIMIT = 1e4;
2935
2928
  function encodeCursor2(cursor) {
@@ -4766,7 +4759,6 @@ function normalizePathKey(value) {
4766
4759
 
4767
4760
  // src/chronicle/project-server-endpoint.ts
4768
4761
  import { createHash as createHash5 } from "node:crypto";
4769
- import * as fs9 from "node:fs";
4770
4762
  import * as os3 from "node:os";
4771
4763
  import * as path14 from "node:path";
4772
4764
 
@@ -4802,12 +4794,6 @@ function chronicleProjectServerEndpoint(projectDir) {
4802
4794
  function chronicleProjectServerMetadataPath(projectDir) {
4803
4795
  return path14.join(projectDir, "chronicle", CHRONICLE_PROJECT_SERVER_METADATA_FILE);
4804
4796
  }
4805
- function ensureChronicleProjectServerSocketDirectory(endpoint2) {
4806
- if (process.platform !== "win32") {
4807
- assertUnixSocketPathWithinLimit(endpoint2, "chronicle");
4808
- fs9.mkdirSync(path14.dirname(endpoint2), { recursive: true, mode: 448 });
4809
- }
4810
- }
4811
4797
 
4812
4798
  // src/chronicle/project-server.ts
4813
4799
  var DEFAULT_IDLE_MS = 5 * 6e4;
@@ -5264,7 +5250,6 @@ async function stop(_reason) {
5264
5250
  });
5265
5251
  await stopMemoryWatchdog();
5266
5252
  }
5267
- ensureChronicleProjectServerSocketDirectory(endpoint);
5268
5253
  var server = net.createServer((socket) => {
5269
5254
  if (stopping) {
5270
5255
  socket.destroy();
@@ -5284,42 +5269,28 @@ var server = net.createServer((socket) => {
5284
5269
  scheduleIdleStop();
5285
5270
  });
5286
5271
  });
5287
- var probingExistingEndpoint = false;
5288
- function listenForOwnership() {
5289
- server.listen(endpoint);
5290
- }
5291
- server.on("error", (error) => {
5292
- if (error.code === "EADDRINUSE" && process.platform === "win32") {
5272
+ void (async () => {
5273
+ const bind = await bindProjectEndpoint({ server, endpoint, service: "chronicle" });
5274
+ if (bind.outcome === "already-owned") {
5293
5275
  process.exitCode = 0;
5294
5276
  return;
5295
5277
  }
5296
- if (error.code === "EADDRINUSE" && !probingExistingEndpoint) {
5297
- probingExistingEndpoint = true;
5298
- const probe = net.createConnection(endpoint);
5299
- probe.once("connect", () => {
5300
- probe.destroy();
5301
- process.exitCode = 0;
5302
- });
5303
- probe.once("error", () => {
5304
- probe.destroy();
5305
- try {
5306
- fs10.rmSync(endpoint, { force: true });
5307
- } catch {
5308
- }
5309
- probingExistingEndpoint = false;
5310
- listenForOwnership();
5311
- });
5278
+ if (bind.outcome === "failed") {
5279
+ process.stderr.write(`chronicle project server failed: ${bind.error.message}
5280
+ `);
5281
+ process.exitCode = 1;
5312
5282
  return;
5313
5283
  }
5314
- process.exitCode = 1;
5315
- });
5316
- server.on("listening", () => {
5317
- if (process.platform !== "win32") {
5318
- try {
5319
- fs10.chmodSync(endpoint, 384);
5320
- } catch {
5321
- }
5284
+ if (bind.reclaimedStaleEndpoint) {
5285
+ process.stderr.write(`chronicle project server reclaimed stale endpoint ${endpoint}
5286
+ `);
5322
5287
  }
5288
+ server.on("error", (error) => {
5289
+ if (stopping) return;
5290
+ process.stderr.write(`chronicle project server error: ${error.message}
5291
+ `);
5292
+ process.exitCode = 1;
5293
+ });
5323
5294
  void writeMetadata().then(() => markMetadataWritten?.());
5324
5295
  void startChronicleFileObserver({
5325
5296
  projectRoot: parsed.projectRoot,
@@ -5337,8 +5308,7 @@ server.on("listening", () => {
5337
5308
  watcherLastError = error instanceof Error ? error.message : String(error);
5338
5309
  });
5339
5310
  scheduleIdleStop();
5340
- });
5311
+ })();
5341
5312
  process.once("SIGINT", () => void stop("SIGINT"));
5342
5313
  process.once("SIGTERM", () => void stop("SIGTERM"));
5343
- listenForOwnership();
5344
5314
  //# sourceMappingURL=project-server.js.map
@@ -3650,6 +3650,7 @@ var TOOLS = {
3650
3650
  "glob",
3651
3651
  "search",
3652
3652
  "tree",
3653
+ "diff",
3653
3654
  "write",
3654
3655
  "edit",
3655
3656
  "replace",
@@ -4681,7 +4682,7 @@ var VERIFY_AGENTS = [
4681
4682
  id: "e2e",
4682
4683
  name: "E2E",
4683
4684
  role: "e2e",
4684
- tools: [...TOOLS.build, "fetch", ...SPECIALIST_TOOLS.browser],
4685
+ tools: [...TOOLS.build, "fetch", "e2e_plan", ...SPECIALIST_TOOLS.browser],
4685
4686
  prompt: agentPrompt("e2e")
4686
4687
  },
4687
4688
  budget: HEAVY_BUDGET,
@@ -5194,7 +5195,7 @@ var DOMAIN_AGENTS = [
5194
5195
  id: "designer",
5195
5196
  name: "Designer",
5196
5197
  role: "designer",
5197
- tools: [...TOOLS.docs],
5198
+ tools: [...TOOLS.docs, "design"],
5198
5199
  prompt: agentPrompt("designer")
5199
5200
  },
5200
5201
  budget: MEDIUM_BUDGET,
@@ -90,7 +90,7 @@ export declare const TOOLS: {
90
90
  /** Read + edit (no shell). For agents that write code/docs but don't run it. */
91
91
  readonly write: readonly ["read", "grep", "glob", "search", "tree", "write", "edit", "replace", "patch", "mailbox"];
92
92
  /** Full build loop: edit + run (lint/format/typecheck/test/bash). */
93
- readonly build: readonly ["read", "grep", "glob", "search", "tree", "write", "edit", "replace", "patch", "bash", "exec", "lint", "format", "typecheck", "test", "mailbox"];
93
+ readonly build: readonly ["read", "grep", "glob", "search", "tree", "diff", "write", "edit", "replace", "patch", "bash", "exec", "lint", "format", "typecheck", "test", "mailbox"];
94
94
  /**
95
95
  * Version control.
96
96
  *
@@ -34,6 +34,7 @@ export type { MailboxCredentialVerifier, RedactedMailboxCredential, } from './ma
34
34
  export { redactMailboxCredential } from './mailbox-credential-store.js';
35
35
  export { CREDENTIAL_VERIFY_COOLDOWN_MS, CREDENTIAL_VERIFY_MAX_FAILURES, CREDENTIAL_VERIFY_WINDOW_MS, CredentialVerifyThrottle, credentialVerifyThrottle, } from './mailbox-credential-throttle.js';
36
36
  export { MailboxEventEmitter } from './mailbox-events.js';
37
+ export { mailboxProjectServerEndpoint, mailboxProjectServerMetadataPath, } from './mailbox-project-server-endpoint.js';
37
38
  export { buildDownAlert, buildRecoveryAlert, type DownAlertInput, MAILBOX_HEALTH_DEFAULT_FAILURE_THRESHOLD, MAILBOX_HEALTH_DEFAULT_FROM, MAILBOX_HEALTH_DEFAULT_INTERVAL_MS, MAILBOX_HEALTH_DEFAULT_TIMEOUT_MS, type MailboxHealthEvent, MailboxHealthWatchdog, type MailboxHealthWatchdogOptions, type RecoveryAlertInput, validateWatchdogOptions, type WatchdogConfig, } from './mailbox-health.js';
38
39
  export { createMailboxHooks, type MailboxHooksOptions, } from './mailbox-hooks.js';
39
40
  export { authorizeMailboxBearerToken, authorizePersistedMailboxCredential, createMailboxHttpRouter, MAILBOX_HTTP_DEFAULT_MAX_AGE_MS, MAILBOX_HTTP_MAX_AGE_CEILING_MS, MAILBOX_HTTP_MAX_BODY_BYTES, MAILBOX_HTTP_RATE_LIMIT_PER_MINUTE, MAILBOX_HTTP_RATE_LIMIT_WINDOW_MS, type MailboxHttpAccessDecision, MailboxHttpRateLimiter, type MailboxHttpRouter, type MailboxHttpRouterOptions, } from './mailbox-http-router.js';
@@ -4748,6 +4748,7 @@ var TOOLS = {
4748
4748
  "glob",
4749
4749
  "search",
4750
4750
  "tree",
4751
+ "diff",
4751
4752
  "write",
4752
4753
  "edit",
4753
4754
  "replace",
@@ -5779,7 +5780,7 @@ var VERIFY_AGENTS = [
5779
5780
  id: "e2e",
5780
5781
  name: "E2E",
5781
5782
  role: "e2e",
5782
- tools: [...TOOLS.build, "fetch", ...SPECIALIST_TOOLS.browser],
5783
+ tools: [...TOOLS.build, "fetch", "e2e_plan", ...SPECIALIST_TOOLS.browser],
5783
5784
  prompt: agentPrompt("e2e")
5784
5785
  },
5785
5786
  budget: HEAVY_BUDGET,
@@ -6292,7 +6293,7 @@ var DOMAIN_AGENTS = [
6292
6293
  id: "designer",
6293
6294
  name: "Designer",
6294
6295
  role: "designer",
6295
- tools: [...TOOLS.docs],
6296
+ tools: [...TOOLS.docs, "design"],
6296
6297
  prompt: agentPrompt("designer")
6297
6298
  },
6298
6299
  budget: MEDIUM_BUDGET,
@@ -31042,6 +31043,8 @@ export {
31042
31043
  loadRoleKnowledgeManifest,
31043
31044
  loadSkillAffinity,
31044
31045
  mailboxIdentityBase,
31046
+ mailboxProjectServerEndpoint,
31047
+ mailboxProjectServerMetadataPath,
31045
31048
  mailboxSessionTag,
31046
31049
  makeAgentSubagentRunner,
31047
31050
  makeAskResultTool,
@@ -2,10 +2,10 @@
2
2
 
3
3
  // src/coordination/mailbox-project-server.ts
4
4
  import { randomBytes as randomBytes2 } from "node:crypto";
5
- import * as fs5 from "node:fs";
6
5
  import * as fsPromises from "node:fs/promises";
7
6
  import * as net from "node:net";
8
7
  import * as path7 from "node:path";
8
+ import { bindProjectEndpoint } from "@wrongstack/persistence";
9
9
 
10
10
  // src/kernel/events.ts
11
11
  var MAX_WILDCARDS = 500;
@@ -1173,17 +1173,9 @@ var MailboxEventEmitter = class {
1173
1173
 
1174
1174
  // src/coordination/mailbox-project-server-endpoint.ts
1175
1175
  import { createHash as createHash2 } from "node:crypto";
1176
- import * as fs2 from "node:fs";
1177
1176
  import * as os2 from "node:os";
1178
1177
  import * as path4 from "node:path";
1179
1178
 
1180
- // src/utils/socket-path.ts
1181
- import {
1182
- assertUnixSocketPathWithinLimit,
1183
- checkUnixSocketPath,
1184
- unixSocketPathLimit
1185
- } from "@wrongstack/persistence";
1186
-
1187
1179
  // src/coordination/mailbox-project-server-protocol.ts
1188
1180
  var MAILBOX_PROJECT_SERVER_PROTOCOL_VERSION = 4;
1189
1181
  var MAILBOX_PROJECT_SERVER_MAX_FRAME_CHARS = 16 * 1024 * 1024;
@@ -1317,16 +1309,10 @@ function mailboxProjectServerEndpoint(projectDir2) {
1317
1309
  function mailboxProjectServerMetadataPath(projectDir2) {
1318
1310
  return path4.join(path4.resolve(projectDir2), MAILBOX_PROJECT_SERVER_METADATA_FILE);
1319
1311
  }
1320
- function ensureMailboxProjectServerSocketDirectory(endpoint2) {
1321
- if (process.platform !== "win32") {
1322
- assertUnixSocketPathWithinLimit(endpoint2, "mailbox");
1323
- fs2.mkdirSync(path4.dirname(endpoint2), { recursive: true, mode: 448 });
1324
- }
1325
- }
1326
1312
 
1327
1313
  // src/coordination/sqlite-mailbox.ts
1328
1314
  import { randomUUID as randomUUID2 } from "node:crypto";
1329
- import * as fs4 from "node:fs";
1315
+ import * as fs3 from "node:fs";
1330
1316
  import * as path6 from "node:path";
1331
1317
 
1332
1318
  // src/coordination/global-mailbox-completion.ts
@@ -2218,7 +2204,7 @@ function credentialRotate(db, transaction, credentialId, options) {
2218
2204
  }
2219
2205
 
2220
2206
  // src/coordination/sqlite-mailbox-schema.ts
2221
- import * as fs3 from "node:fs";
2207
+ import * as fs2 from "node:fs";
2222
2208
  import { createRequire } from "node:module";
2223
2209
  import * as path5 from "node:path";
2224
2210
 
@@ -2473,7 +2459,7 @@ function migrateLegacyCredentials(ctx) {
2473
2459
  const legacyPath = path5.join(ctx.projectDir, CREDENTIAL_STORE_FILE);
2474
2460
  const credentials = [];
2475
2461
  try {
2476
- for (const line of fs3.readFileSync(legacyPath, "utf8").split(/\r?\n/u)) {
2462
+ for (const line of fs2.readFileSync(legacyPath, "utf8").split(/\r?\n/u)) {
2477
2463
  if (!line.trim()) continue;
2478
2464
  try {
2479
2465
  const credential = JSON.parse(line);
@@ -2526,7 +2512,7 @@ function migrateLegacyFiles(ctx) {
2526
2512
  function readLegacyMessages(projectDir2) {
2527
2513
  try {
2528
2514
  return parseMailboxFile(
2529
- fs3.readFileSync(path5.join(projectDir2, GLOBAL_MAILBOX_FILE), "utf8")
2515
+ fs2.readFileSync(path5.join(projectDir2, GLOBAL_MAILBOX_FILE), "utf8")
2530
2516
  );
2531
2517
  } catch (error) {
2532
2518
  if (error.code === "ENOENT") return [];
@@ -2535,7 +2521,7 @@ function readLegacyMessages(projectDir2) {
2535
2521
  }
2536
2522
  function readLegacyRegistry(filePath, parseEntry) {
2537
2523
  try {
2538
- const raw = JSON.parse(fs3.readFileSync(filePath, "utf8"));
2524
+ const raw = JSON.parse(fs2.readFileSync(filePath, "utf8"));
2539
2525
  const result = /* @__PURE__ */ new Map();
2540
2526
  for (const [id, value] of Object.entries(raw)) {
2541
2527
  const parsed = parseEntry(value);
@@ -2555,7 +2541,7 @@ var HEARTBEAT_TRACKING_TTL_MS = 30 * 6e4;
2555
2541
  var SqliteMailbox = class {
2556
2542
  constructor(projectDir2, events2, eventEmitter2) {
2557
2543
  this.projectDir = projectDir2;
2558
- fs4.mkdirSync(projectDir2, { recursive: true });
2544
+ fs3.mkdirSync(projectDir2, { recursive: true });
2559
2545
  this.databasePath = path6.join(projectDir2, SQLITE_MAILBOX_FILE);
2560
2546
  this.messagePath = this.databasePath;
2561
2547
  this.events = events2;
@@ -3451,7 +3437,6 @@ async function stop(_reason) {
3451
3437
  }
3452
3438
  await stopMemoryWatchdog();
3453
3439
  }
3454
- ensureMailboxProjectServerSocketDirectory(endpoint);
3455
3440
  var server = net.createServer((socket) => {
3456
3441
  if (stopping) {
3457
3442
  socket.destroy();
@@ -3481,42 +3466,28 @@ var leaseSweep = setInterval(() => {
3481
3466
  scheduleIdleStop();
3482
3467
  }, leaseSweepMs);
3483
3468
  leaseSweep.unref?.();
3484
- var probingExistingEndpoint = false;
3485
- function listenForOwnership() {
3486
- server.listen(endpoint);
3487
- }
3488
- server.on("error", (error) => {
3489
- if (error.code === "EADDRINUSE" && process.platform === "win32") {
3469
+ void (async () => {
3470
+ const bind = await bindProjectEndpoint({ server, endpoint, service: "mailbox" });
3471
+ if (bind.outcome === "already-owned") {
3490
3472
  process.exitCode = 0;
3491
3473
  return;
3492
3474
  }
3493
- if (error.code === "EADDRINUSE" && !probingExistingEndpoint) {
3494
- probingExistingEndpoint = true;
3495
- const probe = net.createConnection(endpoint);
3496
- probe.once("connect", () => {
3497
- probe.destroy();
3498
- process.exitCode = 0;
3499
- });
3500
- probe.once("error", () => {
3501
- probe.destroy();
3502
- try {
3503
- fs5.rmSync(endpoint, { force: true });
3504
- } catch {
3505
- }
3506
- probingExistingEndpoint = false;
3507
- listenForOwnership();
3508
- });
3475
+ if (bind.outcome === "failed") {
3476
+ process.stderr.write(`mailbox project server failed: ${bind.error.message}
3477
+ `);
3478
+ process.exitCode = 1;
3509
3479
  return;
3510
3480
  }
3511
- process.exitCode = 1;
3512
- });
3513
- server.on("listening", () => {
3514
- if (process.platform !== "win32") {
3515
- try {
3516
- fs5.chmodSync(endpoint, 384);
3517
- } catch {
3518
- }
3481
+ if (bind.reclaimedStaleEndpoint) {
3482
+ process.stderr.write(`mailbox project server reclaimed stale endpoint ${endpoint}
3483
+ `);
3519
3484
  }
3485
+ server.on("error", (error) => {
3486
+ if (stopping) return;
3487
+ process.stderr.write(`mailbox project server error: ${error.message}
3488
+ `);
3489
+ process.exitCode = 1;
3490
+ });
3520
3491
  try {
3521
3492
  mailbox = new SqliteMailbox(projectDir, events, eventEmitter);
3522
3493
  } catch {
@@ -3526,16 +3497,16 @@ server.on("listening", () => {
3526
3497
  return;
3527
3498
  }
3528
3499
  stopAutoCompact = mailbox.startAutoCompactTimer();
3529
- void writeMetadata().then(() => {
3500
+ try {
3501
+ await writeMetadata();
3530
3502
  markMetadataWritten?.();
3531
3503
  scheduleIdleStop();
3532
- }).catch(() => {
3504
+ } catch {
3533
3505
  void stop("metadata-write-failed").finally(() => {
3534
3506
  process.exitCode = 1;
3535
3507
  });
3536
- });
3537
- });
3538
- listenForOwnership();
3508
+ }
3509
+ })();
3539
3510
  for (const signal of ["SIGINT", "SIGTERM"]) {
3540
3511
  process.once(signal, () => {
3541
3512
  void stop(signal).finally(() => {
@@ -13,5 +13,6 @@ export { formatModelRef, type ModelRef, normalizeModelRef, parseModelRef, } from
13
13
  export { clearPendingNextSteps, hasNextStepsTag, MAX_PENDING_NEXT_STEPS, maybeAppendPendingNextSteps, type PendingNextStep, readPendingNextSteps, renderNextStepsBlock, writePendingNextSteps, } from './next-steps-slot.js';
14
14
  export { runProviderWithRetry } from './provider-runner.js';
15
15
  export { setQueuedMessagesSnapshot } from './queued-messages.js';
16
- export { DefaultSystemPromptBuilder, type DefaultSystemPromptBuilderOptions, type SystemBlockSource, } from './system-prompt-builder.js';
16
+ export { buildIdentityLayer, DefaultSystemPromptBuilder, type DefaultSystemPromptBuilderOptions, type SystemBlockSource, } from './system-prompt-builder.js';
17
+ export { type DomainGlossaryOptions, renderDomainGlossary, } from './system-prompt-glossary.js';
17
18
  //# sourceMappingURL=index.d.ts.map