@wrongstack/core 0.302.2 → 0.305.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 (97) hide show
  1. package/README.md +1 -1
  2. package/dist/chronicle/index.js +117 -30
  3. package/dist/chronicle/project-server.js +12 -5
  4. package/dist/coordination/agents/index.js +4645 -3448
  5. package/dist/coordination/agents/project-agent-auto-optimize.d.ts +116 -0
  6. package/dist/coordination/agents/project-agent-capture-window.d.ts +29 -0
  7. package/dist/coordination/agents/project-agent-config-io.d.ts +11 -0
  8. package/dist/coordination/agents/project-agent-consolidation.d.ts +34 -2
  9. package/dist/coordination/agents/project-agent-directive-outcome.d.ts +57 -0
  10. package/dist/coordination/agents/project-agent-files.d.ts +12 -3
  11. package/dist/coordination/agents/project-agent-identity-types.d.ts +4 -0
  12. package/dist/coordination/agents/project-agent-identity.d.ts +38 -11
  13. package/dist/coordination/agents/project-agent-learning-entries.d.ts +8 -2
  14. package/dist/coordination/agents/project-agent-learning-policy.d.ts +22 -1
  15. package/dist/coordination/agents/project-agent-learning-structured.d.ts +72 -1
  16. package/dist/coordination/agents/project-agent-optimizer.d.ts +49 -0
  17. package/dist/coordination/agents/project-agent-quarantine.d.ts +63 -0
  18. package/dist/coordination/agents/project-agent-skill-layer.d.ts +146 -0
  19. package/dist/coordination/agents/role-skills.d.ts +11 -1
  20. package/dist/coordination/agents/types.d.ts +10 -2
  21. package/dist/coordination/director-prompts.d.ts +19 -6
  22. package/dist/coordination/director-tools.d.ts +2 -2
  23. package/dist/coordination/fleet.d.ts +0 -6
  24. package/dist/coordination/index.d.ts +1 -1
  25. package/dist/coordination/index.js +5746 -4326
  26. package/dist/coordination/mail-tools.d.ts +1 -1
  27. package/dist/core/agent-types.d.ts +4 -2
  28. package/dist/core/agent.d.ts +1 -0
  29. package/dist/core/context.d.ts +19 -0
  30. package/dist/core/conversation-state.d.ts +14 -0
  31. package/dist/core/fallback-profile-manager.d.ts +70 -2
  32. package/dist/core/index.js +317 -108
  33. package/dist/core/system-prompt-blocks.d.ts +1 -1
  34. package/dist/core/system-prompt-builder.d.ts +13 -1
  35. package/dist/core/system-prompt-glossary.d.ts +73 -0
  36. package/dist/core/system-prompt-memory-skills.d.ts +2 -2
  37. package/dist/defaults/index.js +1635 -1120
  38. package/dist/execution/council-orchestrator.d.ts +3 -13
  39. package/dist/execution/index.js +3136 -2706
  40. package/dist/execution/one-shot-llm.d.ts +5 -0
  41. package/dist/goal/index.js +7 -0
  42. package/dist/hq/index.js +17 -7
  43. package/dist/hq/protocol/kanban.d.ts +21 -0
  44. package/dist/hq/protocol.js +5 -1
  45. package/dist/hq/redaction.d.ts +14 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.js +5502 -3483
  48. package/dist/infrastructure/index.js +247 -122
  49. package/dist/kernel/events/agent-events.d.ts +28 -0
  50. package/dist/plugin/index.js +111 -7
  51. package/dist/registry/index.js +11 -0
  52. package/dist/registry/tool-registry.d.ts +8 -0
  53. package/dist/replay/hash.d.ts +9 -0
  54. package/dist/replay/index.js +14 -4
  55. package/dist/replay/replay-provider-runner.d.ts +31 -1
  56. package/dist/security/index.js +92 -21
  57. package/dist/security/kanban-boundary.d.ts +5 -1
  58. package/dist/security/secret-vault.d.ts +2 -0
  59. package/dist/session-catalog/index.js +86 -10
  60. package/dist/session-catalog/project-server.js +100 -17
  61. package/dist/session-catalog/protocol.d.ts +20 -4
  62. package/dist/session-catalog/store.d.ts +19 -3
  63. package/dist/storage/index.js +305 -69
  64. package/dist/storage/memory-consolidator.d.ts +4 -2
  65. package/dist/storage/plan-store.d.ts +1 -1
  66. package/dist/storage/session-resume-validation.d.ts +24 -0
  67. package/dist/storage/session-store/directory-scan.d.ts +5 -1
  68. package/dist/storage/session-store/fork-session.d.ts +13 -1
  69. package/dist/storage/session-store/load-cache.d.ts +11 -0
  70. package/dist/storage/session-store/prune-helpers.d.ts +5 -0
  71. package/dist/storage/session-store.d.ts +18 -0
  72. package/dist/tasking/index.js +5 -0
  73. package/dist/tools/index.js +1151 -831
  74. package/dist/types/config/mcp-features.d.ts +31 -1
  75. package/dist/types/config/root.d.ts +23 -1
  76. package/dist/types/config/skills-fleet-brain.d.ts +34 -0
  77. package/dist/types/config/tools.d.ts +22 -0
  78. package/dist/types/config/ui.d.ts +14 -0
  79. package/dist/types/config.d.ts +1 -0
  80. package/dist/types/default-config.d.ts +1 -0
  81. package/dist/types/index.d.ts +2 -2
  82. package/dist/types/index.js +23 -0
  83. package/dist/types/multi-agent.d.ts +7 -0
  84. package/dist/types/session.d.ts +9 -1
  85. package/dist/types/task-graph.d.ts +2 -0
  86. package/dist/types/tool-executor.d.ts +2 -0
  87. package/dist/utils/index.d.ts +1 -0
  88. package/dist/utils/index.js +217 -76
  89. package/dist/utils/project-state-guard.d.ts +21 -0
  90. package/dist/utils/session-scoped-path.d.ts +17 -0
  91. package/dist/utils/todos-format.d.ts +20 -0
  92. package/instructions/leader-after-task.md +3 -4
  93. package/instructions/system-lite.md +17 -14
  94. package/instructions/system-pro.md +29 -30
  95. package/instructions/system.md +29 -28
  96. package/package.json +3 -3
  97. package/skills/wrongstack-kanban/SKILL.md +95 -93
@@ -44,6 +44,11 @@ export declare class OneShotOrchestrator {
44
44
  private resolveSignal;
45
45
  /**
46
46
  * Build the fallback model chain from input + config + current target.
47
+ * Delegates to {@link FallbackProfileManager.resolveCandidates} — the
48
+ * shared constructor used by both the agent loop and the one-shot path,
49
+ * so both produce identical ordering, depth, and fromExplicitSource
50
+ * semantics.
51
+ *
47
52
  * The injected {@link OneShotOrchestratorOptions.fallbackProfileManager}
48
53
  * is the only allowed manager — OneShot never owns a private snapshot
49
54
  * so a live `ConfigStore` change reaches every call without rebuilding
@@ -342,6 +342,11 @@ var TaskTracker = class _TaskTracker {
342
342
  if (!this.graph) return false;
343
343
  const node = this.graph.nodes.get(id);
344
344
  if (!node) return false;
345
+ if (node.specRequirementId && this.graph.requiredRequirementIds?.includes(node.specRequirementId) && !Array.from(this.graph.nodes.values()).some(
346
+ (candidate) => candidate.id !== id && candidate.specRequirementId === node.specRequirementId
347
+ )) {
348
+ return false;
349
+ }
345
350
  this.graph.nodes.delete(id);
346
351
  this.graph.edges = this.graph.edges.filter((e) => e.from !== id && e.to !== id);
347
352
  this.graph.rootNodes = this.graph.rootNodes.filter((r) => r !== id);
@@ -2667,6 +2672,7 @@ var PhaseStore = class {
2667
2672
  return {
2668
2673
  id: graph.id,
2669
2674
  specId: graph.specId,
2675
+ requiredRequirementIds: graph.requiredRequirementIds,
2670
2676
  title: graph.title,
2671
2677
  nodes: Array.from(graph.nodes.values()).map((n) => this.serializeTaskNode(n)),
2672
2678
  edges: graph.edges,
@@ -2735,6 +2741,7 @@ var PhaseStore = class {
2735
2741
  return {
2736
2742
  id: serialized.id,
2737
2743
  specId: serialized.specId,
2744
+ requiredRequirementIds: serialized.requiredRequirementIds,
2738
2745
  title: serialized.title,
2739
2746
  nodes,
2740
2747
  edges: serialized.edges ?? [],
package/dist/hq/index.js CHANGED
@@ -86,7 +86,7 @@ var MAX_HQ_KANBAN_BOARD_BYTES = 75e4;
86
86
  function isHqKanbanSnapshotPayload(value) {
87
87
  if (typeof value !== "object" || value === null) return false;
88
88
  const payload = value;
89
- if (typeof payload.projectId !== "string" || payload.projectId.length === 0 || typeof payload.generatedAt !== "string" || !Number.isFinite(Date.parse(payload.generatedAt)) || !Array.isArray(payload.boards) || !Array.isArray(payload.tombstones) || payload.boards.length > MAX_HQ_KANBAN_BOARDS || payload.tombstones.length > MAX_HQ_KANBAN_BOARDS) {
89
+ if (typeof payload.projectId !== "string" || payload.projectId.length === 0 || typeof payload.generatedAt !== "string" || !Number.isFinite(Date.parse(payload.generatedAt)) || !Array.isArray(payload.boards) || !Array.isArray(payload.tombstones) || payload.boards.length > MAX_HQ_KANBAN_BOARDS || payload.tombstones.length > MAX_HQ_KANBAN_BOARDS || !isOptionalChunkOrdinal(payload.chunkIndex) || !isOptionalChunkOrdinal(payload.chunkCount)) {
90
90
  return false;
91
91
  }
92
92
  const seen = /* @__PURE__ */ new Set();
@@ -100,6 +100,9 @@ function isHqKanbanSnapshotPayload(value) {
100
100
  }
101
101
  return true;
102
102
  }
103
+ function isOptionalChunkOrdinal(value) {
104
+ return value === void 0 || Number.isSafeInteger(value) && value >= 0;
105
+ }
103
106
  function isBoardRecord(value) {
104
107
  if (typeof value !== "object" || value === null) return false;
105
108
  const record = value;
@@ -1140,12 +1143,11 @@ function redactHqValueInternal(value, options, preserveRawContentKeys) {
1140
1143
  function redactHqValue(value, options = {}) {
1141
1144
  return redactHqValueInternal(value, options, false);
1142
1145
  }
1146
+ function redactHqEventPayload(type, payload, options = {}) {
1147
+ return redactHqValueInternal(payload, options, HQ_PROJECT_STATE_EVENT_TYPES.has(type));
1148
+ }
1143
1149
  function redactHqEvent(event, options = {}) {
1144
- const payload = redactHqValueInternal(
1145
- event.payload,
1146
- options,
1147
- HQ_PROJECT_STATE_EVENT_TYPES.has(event.type)
1148
- );
1150
+ const payload = redactHqEventPayload(event.type, event.payload, options);
1149
1151
  const nextEvent = {
1150
1152
  ...event,
1151
1153
  payload: payload.value
@@ -1322,7 +1324,9 @@ function queuedFrameCoalesceKey(frame) {
1322
1324
  if (frame.type !== "client.event" || !frame.event.type.endsWith(".snapshot")) {
1323
1325
  return void 0;
1324
1326
  }
1325
- return [frame.event.type, frame.event.sessionId ?? "", frame.event.runId ?? ""].join("|");
1327
+ const payload = frame.event.payload;
1328
+ const chunk = typeof payload?.chunkIndex === "number" && Number.isFinite(payload.chunkIndex) ? String(payload.chunkIndex) : "";
1329
+ return [frame.event.type, frame.event.sessionId ?? "", frame.event.runId ?? "", chunk].join("|");
1326
1330
  }
1327
1331
  function defaultSocketFactory(url) {
1328
1332
  const WebSocketCtor = globalThis.WebSocket;
@@ -1655,6 +1659,10 @@ var HqPublisher = class {
1655
1659
  if (bytes > this.maxQueuedBytes) {
1656
1660
  this.droppedFrames += 1;
1657
1661
  this.droppedBytes += bytes;
1662
+ process.emitWarning(
1663
+ `HQ telemetry frame of ${bytes} bytes exceeds the ${this.maxQueuedBytes}-byte offline queue cap and was dropped.`,
1664
+ { code: "WRONGSTACK_HQ_FRAME_TOO_LARGE" }
1665
+ );
1658
1666
  return;
1659
1667
  }
1660
1668
  if (coalesceKey !== void 0) {
@@ -5086,6 +5094,7 @@ export {
5086
5094
  HqSimpleLog,
5087
5095
  HqSnapshotStore,
5088
5096
  HqTimeseriesStore,
5097
+ MAX_HQ_KANBAN_BOARD_BYTES,
5089
5098
  appendHqAuthAudit,
5090
5099
  assessHqExposure,
5091
5100
  buildTranscriptFromEvents,
@@ -5134,6 +5143,7 @@ export {
5134
5143
  readHqAuthFile,
5135
5144
  readHqRuntimeFileSync,
5136
5145
  redactHqEvent,
5146
+ redactHqEventPayload,
5137
5147
  redactHqValue,
5138
5148
  resolveHqConfig,
5139
5149
  resolveHqConfigFromEnv,
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Largest single board record HQ will accept, in bytes of serialized board JSON.
3
+ *
4
+ * Exported because the sender has to know it. `isHqKanbanSnapshotPayload`
5
+ * rejects the *whole* snapshot when one board is over the limit, and the
6
+ * rejection is silent from the sender's point of view — so a publisher that
7
+ * does not check this first can lose every board in the chunk, permanently.
8
+ */
9
+ export declare const MAX_HQ_KANBAN_BOARD_BYTES = 750000;
1
10
  export interface HqKanbanBoardRecord {
2
11
  boardId: string;
3
12
  revision: number;
@@ -16,6 +25,18 @@ export interface HqKanbanSnapshotPayload {
16
25
  generatedAt: string;
17
26
  boards: HqKanbanBoardRecord[];
18
27
  tombstones: HqKanbanTombstone[];
28
+ /**
29
+ * Position of this payload within a multi-part publish, present only when the
30
+ * publish was split. It exists so the offline frame queue can tell chunks of
31
+ * one snapshot apart from successive versions of the same snapshot — coalesce
32
+ * on `chunkIndex`, not on the event type alone, or every chunk but the last
33
+ * is evicted before the socket reconnects.
34
+ *
35
+ * Receivers do not need it: chunks are independent record sets, and each
36
+ * record carries its own revision.
37
+ */
38
+ chunkIndex?: number | undefined;
39
+ chunkCount?: number | undefined;
19
40
  }
20
41
  /** Server-to-client snapshot after HQ has merged all known project writers. */
21
42
  export interface HqServerKanbanSnapshotMessage {
@@ -86,7 +86,7 @@ var MAX_HQ_KANBAN_BOARD_BYTES = 75e4;
86
86
  function isHqKanbanSnapshotPayload(value) {
87
87
  if (typeof value !== "object" || value === null) return false;
88
88
  const payload = value;
89
- if (typeof payload.projectId !== "string" || payload.projectId.length === 0 || typeof payload.generatedAt !== "string" || !Number.isFinite(Date.parse(payload.generatedAt)) || !Array.isArray(payload.boards) || !Array.isArray(payload.tombstones) || payload.boards.length > MAX_HQ_KANBAN_BOARDS || payload.tombstones.length > MAX_HQ_KANBAN_BOARDS) {
89
+ if (typeof payload.projectId !== "string" || payload.projectId.length === 0 || typeof payload.generatedAt !== "string" || !Number.isFinite(Date.parse(payload.generatedAt)) || !Array.isArray(payload.boards) || !Array.isArray(payload.tombstones) || payload.boards.length > MAX_HQ_KANBAN_BOARDS || payload.tombstones.length > MAX_HQ_KANBAN_BOARDS || !isOptionalChunkOrdinal(payload.chunkIndex) || !isOptionalChunkOrdinal(payload.chunkCount)) {
90
90
  return false;
91
91
  }
92
92
  const seen = /* @__PURE__ */ new Set();
@@ -100,6 +100,9 @@ function isHqKanbanSnapshotPayload(value) {
100
100
  }
101
101
  return true;
102
102
  }
103
+ function isOptionalChunkOrdinal(value) {
104
+ return value === void 0 || Number.isSafeInteger(value) && value >= 0;
105
+ }
103
106
  function isBoardRecord(value) {
104
107
  if (typeof value !== "object" || value === null) return false;
105
108
  const record = value;
@@ -673,6 +676,7 @@ export {
673
676
  HQ_RESUME_GAP_MAX_ENVELOPES,
674
677
  HQ_RESUME_GAP_MAX_STALE_MS,
675
678
  HQ_TRANSCRIPT_TEXT_CAP,
679
+ MAX_HQ_KANBAN_BOARD_BYTES,
676
680
  createHqEventEnvelope,
677
681
  isHqGovernanceSnapshotPayload,
678
682
  isHqKanbanSnapshotPayload,
@@ -25,6 +25,20 @@ export declare function tightenHqRedactionPolicy(publisherPolicy: HqRedactionPol
25
25
  */
26
26
  export declare function scrubAndTruncateHqPreview(value: unknown, maxLength?: number): string | undefined;
27
27
  export declare function redactHqValue<T>(value: T, options?: HqRedactOptions): HqRedactionResult<T>;
28
+ /**
29
+ * Redact a payload exactly as it would be redacted when published under `type`.
30
+ *
31
+ * Exported because a sender sometimes needs to know what will go on the wire
32
+ * before it commits to sending — the Kanban→HQ sync measures a board against
33
+ * HQ's per-board byte limit, and HQ drops an over-limit frame without a reply.
34
+ * That measurement has to run the SAME transform as the send, because the
35
+ * event type decides whether raw-content keys survive: `kanban.snapshot` is a
36
+ * project-state event and keeps them, while the generic `redactHqValue` path
37
+ * replaces them with a short marker. Measuring through the generic path made
38
+ * the estimate smaller than reality, so an oversized board could pass the check
39
+ * and still be rejected — the exact silent loss the check exists to prevent.
40
+ */
41
+ export declare function redactHqEventPayload<TPayload>(type: string, payload: TPayload, options?: HqRedactOptions): HqRedactionResult<TPayload>;
28
42
  export declare function redactHqEvent<TPayload>(event: HqEventEnvelope<TPayload>, options?: HqRedactOptions): HqRedactionResult<HqEventEnvelope<TPayload>>;
29
43
  export declare function summarizeHqToolArgs(value: unknown, options?: HqRedactOptions): unknown;
30
44
  //# sourceMappingURL=redaction.d.ts.map
package/dist/index.d.ts CHANGED
@@ -60,6 +60,7 @@ export { runProviderWithRetry } from './core/provider-runner.js';
60
60
  export { buildQueuedMessagesBlock, consumeQueuedMessagesUpdate, peekQueuedMessages, setQueuedMessagesSnapshot, } from './core/queued-messages.js';
61
61
  export { extractRunEnv, type RunEnv } from './core/run-env.js';
62
62
  export { DefaultSystemPromptBuilder, type DefaultSystemPromptBuilderOptions, LAYER_1_IDENTITY, SYSTEM_BLOCK_SOURCE, type SystemBlockSource, } from './core/system-prompt-builder.js';
63
+ export { type DomainGlossary, type DomainGlossaryOptions, makeDomainGlossaryContributor, renderDomainGlossary, } from './core/system-prompt-glossary.js';
63
64
  export * from './defaults/index.js';
64
65
  export { AutoCompactionMiddleware, type CompactorOptions, type CompactorStrategy, createStrategyCompactor, HybridCompactor, IntelligentCompactor, type IntelligentCompactorOptions, installSubagentAutoCompaction, SelectiveCompactor, type SelectiveCompactorOptions, type StrategyCompactorOptions, } from './defaults/index.js';
65
66
  export { type AutonomyBrainOptions, type BrainAutoRisk, type BrainLlmTarget, buildBrainUserMessage, completeBrainLlm, createAutonomyBrain, createTieredBrainArbiter, formatDecisionSummary, parseOptionDecision, type TieredBrainArbiterOptions, } from './execution/autonomy-brain.js';