@wrongstack/core 0.302.0 → 0.303.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 (74) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-status-tracker.d.ts +6 -2
  3. package/dist/chronicle/index.js +1949 -1671
  4. package/dist/chronicle/metrics-store.d.ts +14 -0
  5. package/dist/chronicle/project-server-protocol.d.ts +13 -0
  6. package/dist/chronicle/project-server.js +1756 -1573
  7. package/dist/chronicle/rollup-adapter.d.ts +2 -0
  8. package/dist/chronicle/sqlite-journal.d.ts +59 -0
  9. package/dist/coordination/agents/index.js +4313 -3516
  10. package/dist/coordination/agents/project-agent-auto-optimize.d.ts +116 -0
  11. package/dist/coordination/agents/project-agent-capture-window.d.ts +29 -0
  12. package/dist/coordination/agents/project-agent-config-io.d.ts +11 -0
  13. package/dist/coordination/agents/project-agent-consolidation.d.ts +29 -2
  14. package/dist/coordination/agents/project-agent-files.d.ts +12 -3
  15. package/dist/coordination/agents/project-agent-identity-types.d.ts +4 -0
  16. package/dist/coordination/agents/project-agent-identity.d.ts +22 -9
  17. package/dist/coordination/agents/project-agent-learning-entries.d.ts +8 -2
  18. package/dist/coordination/agents/project-agent-learning-structured.d.ts +27 -1
  19. package/dist/coordination/agents/project-agent-optimizer.d.ts +49 -0
  20. package/dist/coordination/agents/project-agent-skill-layer.d.ts +101 -0
  21. package/dist/coordination/agents/role-skills.d.ts +11 -1
  22. package/dist/coordination/index.d.ts +1 -1
  23. package/dist/coordination/index.js +4927 -3589
  24. package/dist/coordination/mail-tools.d.ts +3 -3
  25. package/dist/core/context.d.ts +4 -0
  26. package/dist/core/continue-intent.d.ts +2 -0
  27. package/dist/core/conversation-state.d.ts +5 -0
  28. package/dist/core/index.js +129 -19
  29. package/dist/defaults/index.js +1620 -768
  30. package/dist/execution/index.js +2941 -2630
  31. package/dist/goal/index.js +7 -0
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.js +12269 -9212
  34. package/dist/infrastructure/index.js +722 -672
  35. package/dist/kernel/events/agent-events.d.ts +28 -0
  36. package/dist/kernel/events/memory-events.d.ts +62 -0
  37. package/dist/plugin/index.js +2167 -1986
  38. package/dist/security/index.js +69 -3
  39. package/dist/security/kanban-boundary.d.ts +5 -1
  40. package/dist/session-catalog/client.d.ts +62 -0
  41. package/dist/session-catalog/endpoint.d.ts +6 -0
  42. package/dist/session-catalog/index.d.ts +6 -0
  43. package/dist/session-catalog/index.js +2000 -0
  44. package/dist/session-catalog/project-server.d.ts +3 -0
  45. package/dist/session-catalog/project-server.js +1861 -0
  46. package/dist/session-catalog/protocol.d.ts +284 -0
  47. package/dist/session-catalog/registry.d.ts +59 -0
  48. package/dist/session-catalog/store.d.ts +71 -0
  49. package/dist/storage/index.d.ts +42 -38
  50. package/dist/storage/index.js +13896 -12931
  51. package/dist/storage/plan-store.d.ts +1 -1
  52. package/dist/storage/session-event-bridge.d.ts +2 -2
  53. package/dist/storage/session-store.d.ts +6 -0
  54. package/dist/tasking/index.js +5 -0
  55. package/dist/tools/index.js +2832 -2606
  56. package/dist/types/config/root.d.ts +11 -1
  57. package/dist/types/config/skills-fleet-brain.d.ts +34 -0
  58. package/dist/types/config/ui.d.ts +14 -0
  59. package/dist/types/config.d.ts +1 -0
  60. package/dist/types/context-evidence.d.ts +2 -0
  61. package/dist/types/index.d.ts +2 -2
  62. package/dist/types/index.js +20 -0
  63. package/dist/types/messages.d.ts +8 -0
  64. package/dist/types/multi-agent.d.ts +7 -0
  65. package/dist/types/session.d.ts +19 -0
  66. package/dist/types/task-graph.d.ts +2 -0
  67. package/dist/types/tool-executor.d.ts +2 -0
  68. package/dist/utils/context-evidence.d.ts +13 -1
  69. package/dist/utils/index.js +29 -2
  70. package/instructions/system-lite.md +23 -8
  71. package/instructions/system-pro.md +29 -9
  72. package/instructions/system.md +29 -9
  73. package/package.json +7 -3
  74. package/skills/wrongstack-kanban/SKILL.md +39 -8
@@ -1298,11 +1298,13 @@ function windowsAccountName() {
1298
1298
  import { realpath } from "node:fs/promises";
1299
1299
  import * as path2 from "node:path";
1300
1300
  import {
1301
+ evaluateContractGraphReadiness,
1301
1302
  evaluateKanbanBoundaryOpaque,
1302
1303
  evaluateKanbanBoundaryPath,
1303
1304
  readBoard,
1304
1305
  resolveKanbanBoundaryLayers
1305
1306
  } from "@wrongstack/kanban";
1307
+ var GOVERNANCE_CONTROL_TOOLS = /* @__PURE__ */ new Set(["kanban", "plan", "task", "todo"]);
1306
1308
  var PATH_KEYS2 = /* @__PURE__ */ new Set([
1307
1309
  "path",
1308
1310
  "paths",
@@ -1327,12 +1329,60 @@ var TOOL_PATH_KEYS = {
1327
1329
  // filesystem target in language_info. Keep ambiguous names tool-specific.
1328
1330
  language_info: ["target"]
1329
1331
  };
1330
- async function evaluateToolKanbanBoundary(tool, input, ctx) {
1332
+ async function evaluateToolKanbanBoundary(tool, input, ctx, options = {}) {
1333
+ if (tool.name === "kanban") return { decision: "allow" };
1331
1334
  const identity = resolveKanbanIdentity(ctx);
1332
- if (!identity.boardId) return { decision: "allow" };
1335
+ const governanceRequired = options.requireGovernance && isGovernedMutation(tool, input);
1336
+ if (!identity.boardId) {
1337
+ return governanceRequired ? {
1338
+ decision: "block",
1339
+ reason: "Kanban governance is mandatory before product mutation. Create a managed card, add its required details and executable acceptance criteria, then call kanban start_task to bind it to this run."
1340
+ } : { decision: "allow" };
1341
+ }
1333
1342
  const board = await readBoard(identity.policyRoot ?? ctx.projectRoot, identity.boardId);
1334
- if (!board) return { decision: "allow" };
1343
+ if (!board) {
1344
+ return governanceRequired ? {
1345
+ decision: "block",
1346
+ reason: `Active Kanban board not found: ${identity.boardId}. Recreate or select a valid managed card before mutation.`,
1347
+ boardId: identity.boardId,
1348
+ ...identity.taskId ? { taskId: identity.taskId } : {}
1349
+ } : { decision: "allow" };
1350
+ }
1335
1351
  const task = identity.taskId ? board.tasks.find((candidate) => candidate.id === identity.taskId) : void 0;
1352
+ if (governanceRequired) {
1353
+ if (!identity.taskId) {
1354
+ return {
1355
+ decision: "block",
1356
+ reason: "Kanban governance requires an active task, not only a board. Complete the card details and call kanban start_task before mutation.",
1357
+ boardId: board.id
1358
+ };
1359
+ }
1360
+ if (!task) {
1361
+ return {
1362
+ decision: "block",
1363
+ reason: `Active Kanban task not found: ${identity.taskId}. Call kanban start_task with a valid card.`,
1364
+ boardId: board.id,
1365
+ taskId: identity.taskId
1366
+ };
1367
+ }
1368
+ const readiness = evaluateContractGraphReadiness(board, task.id);
1369
+ if (!readiness.ready) {
1370
+ return {
1371
+ decision: "block",
1372
+ reason: "Active card is not implementation-ready: " + readiness.issues.map((issue) => issue.message).join(" | "),
1373
+ boardId: board.id,
1374
+ taskId: task.id
1375
+ };
1376
+ }
1377
+ if (task.lifecycle?.currentStage !== "running" || task.assignment?.status !== "running") {
1378
+ return {
1379
+ decision: "block",
1380
+ reason: "Active card must be in Running with a live assignment before product mutation. Call kanban start_task after completing the required card details.",
1381
+ boardId: board.id,
1382
+ taskId: task.id
1383
+ };
1384
+ }
1385
+ }
1336
1386
  if (identity.leaseId && task?.assignment) {
1337
1387
  const caps2 = tool.capabilities ?? [];
1338
1388
  const isWrite = caps2.includes("fs.write") || caps2.includes("fs.write.outside-project") || caps2.some((c) => c.startsWith("shell."));
@@ -1368,6 +1418,19 @@ async function evaluateToolKanbanBoundary(tool, input, ctx) {
1368
1418
  ...task ? { taskId: task.id } : {}
1369
1419
  };
1370
1420
  }
1421
+ function isGovernedMutation(tool, input) {
1422
+ if (!tool.mutating || GOVERNANCE_CONTROL_TOOLS.has(tool.name)) return false;
1423
+ if (tool.capabilities?.includes("tool.meta")) return false;
1424
+ if (tool.name === "git") {
1425
+ const command = input["command"];
1426
+ if (command === "status" || command === "log" || command === "diff") return false;
1427
+ if (command === "worktree" && input["worktreeAction"] === "list") return false;
1428
+ }
1429
+ const capabilities = tool.capabilities ?? [];
1430
+ return capabilities.some(
1431
+ (capability) => capability === "fs.write" || capability === "fs.write.outside-project" || capability === "package.install" || capability === "tool.mutate.any" || capability.startsWith("shell.") || capability === "net.outbound"
1432
+ );
1433
+ }
1371
1434
  function resolveKanbanIdentity(ctx) {
1372
1435
  const metaKanban = ctx.meta["kanban"];
1373
1436
  const record = metaKanban && typeof metaKanban === "object" ? metaKanban : void 0;
@@ -1685,6 +1748,9 @@ function subjectForToolInput(toolName, input, subjectKey) {
1685
1748
  const obj = input;
1686
1749
  if (subjectKey) {
1687
1750
  const value = obj[subjectKey];
1751
+ if (Array.isArray(value)) {
1752
+ return escapeGlobSubject(JSON.stringify(value));
1753
+ }
1688
1754
  if (typeof value === "string") {
1689
1755
  if (isPathSubjectKey(subjectKey)) {
1690
1756
  const normalized = normalizePathSubject(value);
@@ -5,6 +5,10 @@ export interface ToolKanbanBoundaryEvaluation extends KanbanBoundaryEvaluation {
5
5
  boardId?: string | undefined;
6
6
  taskId?: string | undefined;
7
7
  }
8
+ export interface ToolKanbanGovernanceOptions {
9
+ /** Require every product mutation to run inside a ready, running Kanban card. */
10
+ requireGovernance?: boolean | undefined;
11
+ }
8
12
  /** Resolve the live board/task policy and gate one tool invocation. */
9
- export declare function evaluateToolKanbanBoundary(tool: Tool, input: Record<string, unknown>, ctx: Context): Promise<ToolKanbanBoundaryEvaluation>;
13
+ export declare function evaluateToolKanbanBoundary(tool: Tool, input: Record<string, unknown>, ctx: Context, options?: ToolKanbanGovernanceOptions): Promise<ToolKanbanBoundaryEvaluation>;
10
14
  //# sourceMappingURL=kanban-boundary.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { type SessionCatalogEvent, type SessionCatalogOperationName, type SessionCatalogOperations } from './protocol.js';
2
+ export interface SessionCatalogProjectClientOptions {
3
+ projectDir: string;
4
+ projectRoot: string;
5
+ }
6
+ export type SessionCatalogDaemonAvailability = {
7
+ kind: 'available';
8
+ url: URL;
9
+ } | {
10
+ kind: 'inline-requested';
11
+ } | {
12
+ kind: 'missing-build';
13
+ };
14
+ export declare function resolveSessionCatalogDaemonAvailability(moduleUrl?: string, exists?: (filePath: string) => boolean): SessionCatalogDaemonAvailability;
15
+ export declare function resolveSessionCatalogProjectServerUrl(moduleUrl?: string, exists?: (filePath: string) => boolean): URL | null;
16
+ export declare class SessionCatalogProjectClient {
17
+ readonly options: SessionCatalogProjectClientOptions;
18
+ readonly endpoint: string;
19
+ private socket;
20
+ private info;
21
+ private buffer;
22
+ private connecting;
23
+ private connectResolve;
24
+ private connectReject;
25
+ private authToken;
26
+ private nextId;
27
+ private readonly pending;
28
+ private readonly eventListeners;
29
+ private reconnectTimer;
30
+ private explicitlyClosed;
31
+ constructor(options: SessionCatalogProjectClientOptions);
32
+ call<O extends SessionCatalogOperationName>(op: O, args: SessionCatalogOperations[O]['args'], options?: {
33
+ timeoutMs?: number;
34
+ }): Promise<SessionCatalogOperations[O]['result']>;
35
+ /**
36
+ * Call an already-running project daemon without starting one.
37
+ *
38
+ * Cross-project discovery must use this path: observing another project is
39
+ * never sufficient authority to wake that project's IPC owner.
40
+ */
41
+ callExisting<O extends SessionCatalogOperationName>(op: O, args: SessionCatalogOperations[O]['args'], options?: {
42
+ timeoutMs?: number;
43
+ }): Promise<SessionCatalogOperations[O]['result']>;
44
+ ping(): Promise<SessionCatalogOperations['ping']['result']>;
45
+ subscribe(listener: (event: SessionCatalogEvent) => void): Promise<() => Promise<void>>;
46
+ shutdown(reason?: string): Promise<{
47
+ stopped: boolean;
48
+ pid?: number;
49
+ }>;
50
+ close(): Promise<void>;
51
+ private ensureConnected;
52
+ private connectWithElection;
53
+ private connectOnce;
54
+ private currentAuthToken;
55
+ private request;
56
+ private onData;
57
+ private onMessage;
58
+ private onClose;
59
+ private scheduleSubscriptionReconnect;
60
+ private spawnDetached;
61
+ }
62
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,6 @@
1
+ export declare const SESSION_CATALOG_METADATA_FILE = ".session-catalog-server.json";
2
+ export declare function sessionCatalogProjectServerKey(projectDir: string): string;
3
+ export declare function sessionCatalogProjectServerEndpoint(projectDir: string): string;
4
+ export declare function sessionCatalogProjectServerMetadataPath(projectDir: string): string;
5
+ export declare function ensureSessionCatalogSocketDirectory(endpoint: string): void;
6
+ //# sourceMappingURL=endpoint.d.ts.map
@@ -0,0 +1,6 @@
1
+ export * from './client.js';
2
+ export * from './endpoint.js';
3
+ export * from './protocol.js';
4
+ export * from './registry.js';
5
+ export * from './store.js';
6
+ //# sourceMappingURL=index.d.ts.map