@nema-project/nema 0.1.4 → 0.1.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.
@@ -32,12 +32,49 @@ var Implementation = z.object({
32
32
  });
33
33
 
34
34
  // ../../../packages/shared/dist/entry.js
35
+ import { z as z3 } from "zod";
36
+
37
+ // ../../../packages/shared/dist/sourceEvidence.js
35
38
  import { z as z2 } from "zod";
39
+ var NoControls = /^[^\x00-\x1f\x7f]*$/;
40
+ var SourceRevision = z2.string().min(1).max(256).regex(NoControls).nullable();
41
+ var SnapshotHash = z2.string().regex(/^[0-9a-f]{64}$/);
42
+ var SourceExcerpt = z2.object({
43
+ locator: z2.string().min(1).max(200),
44
+ text: z2.string().min(1).max(2e3)
45
+ });
46
+ var SourceSnapshot = z2.object({
47
+ schemaVersion: z2.literal(1),
48
+ provider: z2.string().regex(/^[a-z][a-z0-9_-]{0,63}$/),
49
+ resourceId: z2.string().min(1).max(512).regex(NoControls).refine((value) => value.trim() === value, "resourceId must not have surrounding whitespace"),
50
+ revision: SourceRevision,
51
+ fetchedAt: z2.iso.datetime({ offset: true }),
52
+ title: z2.string().min(1).max(200),
53
+ canonicalUrl: z2.string().refine((value) => {
54
+ try {
55
+ const url = new URL(value);
56
+ return (url.protocol === "http:" || url.protocol === "https:") && url.username === "" && url.password === "";
57
+ } catch {
58
+ return false;
59
+ }
60
+ }, "canonicalUrl must be http or https without user information").nullable(),
61
+ contentHash: SnapshotHash,
62
+ excerpts: z2.array(SourceExcerpt).min(1).max(20).refine((excerpts) => excerpts.reduce((total, excerpt) => total + excerpt.text.length, 0) <= 8e3, "excerpt text must total at most 8000 characters")
63
+ });
64
+ var SourceRef = z2.object({
65
+ sourceEntryId: z2.string().regex(/^S-[1-9]\d*$/),
66
+ revision: SourceRevision,
67
+ snapshotHash: SnapshotHash,
68
+ locator: z2.string().min(1).max(200).optional(),
69
+ quote: z2.string().min(1).max(500).optional()
70
+ }).refine((ref) => ref.quote === void 0 || ref.locator !== void 0, { path: ["locator"], message: "locator is required with quote" });
71
+
72
+ // ../../../packages/shared/dist/entry.js
36
73
  var ENTRY_KINDS = ["requirement", "decision", "tradeoff", "question", "source", "diagram", "workpackage"];
37
- var EntryKindSchema = z2.enum(ENTRY_KINDS);
74
+ var EntryKindSchema = z3.enum(ENTRY_KINDS);
38
75
  var BASIS_VALUES = ["stated", "decided", "inferred"];
39
- var BasisSchema = z2.enum(BASIS_VALUES);
40
- var Quote = z2.object({ messageId: z2.string().min(1), text: z2.string().min(1).max(500) });
76
+ var BasisSchema = z3.enum(BASIS_VALUES);
77
+ var Quote = z3.object({ messageId: z3.string().min(1), text: z3.string().min(1).max(500) });
41
78
  var DIAGRAM_TYPES = [
42
79
  "architecture",
43
80
  "workflow",
@@ -50,34 +87,34 @@ var DIAGRAM_TYPES = [
50
87
  "timeline",
51
88
  "waterfall"
52
89
  ];
53
- var DiagramMeta = z2.object({
54
- repoId: z2.string().min(1),
55
- type: z2.enum(DIAGRAM_TYPES),
90
+ var DiagramMeta = z3.object({
91
+ repoId: z3.string().min(1),
92
+ type: z3.enum(DIAGRAM_TYPES),
56
93
  /** repo id -> main sha the diagram was drawn at. */
57
- sourceCommits: z2.record(z2.string(), z2.string()),
94
+ sourceCommits: z3.record(z3.string(), z3.string()),
58
95
  /** archify node id -> repo-relative paths that node stands for. */
59
- nodePaths: z2.record(z2.string(), z2.array(z2.string()))
96
+ nodePaths: z3.record(z3.string(), z3.array(z3.string()))
60
97
  });
61
98
  var MAX_WP_TASKS = 15;
62
- var WpTask = z2.object({
63
- n: z2.number().int().min(1).max(MAX_WP_TASKS),
64
- title: z2.string(),
65
- satisfies: z2.array(z2.string()),
66
- files: z2.array(z2.object({ op: z2.enum(["modify", "create"]), repo: z2.string(), path: z2.string() })),
67
- status: z2.enum(["pending", "reported", "verified", "mismatch"]),
68
- inferred: z2.boolean(),
69
- reportMessageId: z2.string().nullable(),
70
- confirmedBy: z2.literal("user").nullable()
99
+ var WpTask = z3.object({
100
+ n: z3.number().int().min(1).max(MAX_WP_TASKS),
101
+ title: z3.string(),
102
+ satisfies: z3.array(z3.string()),
103
+ files: z3.array(z3.object({ op: z3.enum(["modify", "create"]), repo: z3.string(), path: z3.string() })),
104
+ status: z3.enum(["pending", "reported", "verified", "mismatch"]),
105
+ inferred: z3.boolean(),
106
+ reportMessageId: z3.string().nullable(),
107
+ confirmedBy: z3.literal("user").nullable()
71
108
  });
72
- var WorkPackageMeta = z2.object({
73
- requirements: z2.array(z2.string()),
74
- repos: z2.array(z2.string()),
75
- approvedAt: z2.string().nullable(),
76
- approvedCommit: z2.string().nullable(),
77
- blockedOn: z2.string().nullable(),
78
- tasks: z2.array(WpTask)
109
+ var WorkPackageMeta = z3.object({
110
+ requirements: z3.array(z3.string()),
111
+ repos: z3.array(z3.string()),
112
+ approvedAt: z3.string().nullable(),
113
+ approvedCommit: z3.string().nullable(),
114
+ blockedOn: z3.string().nullable(),
115
+ tasks: z3.array(WpTask)
79
116
  });
80
- var IsoDateTime = z2.iso.datetime({ offset: true }).nullable();
117
+ var IsoDateTime = z3.iso.datetime({ offset: true }).nullable();
81
118
  var PREFIX_KIND = {
82
119
  R: "requirement",
83
120
  D: "decision",
@@ -103,9 +140,9 @@ var KIND_STATUSES = {
103
140
  workpackage: ["draft", "approved", "in_progress", "done", "dropped"]
104
141
  };
105
142
  var ALL_STATUSES = ["active", "superseded", "dropped", "open", "resolved", "draft", "approved", "in_progress", "done"];
106
- var StatusSchema = z2.enum(ALL_STATUSES);
107
- var BusinessDate = z2.string().regex(/^\d{4}-\d{2}-\d{2}$/).nullable();
108
- var HttpUrl = z2.string().refine((s) => {
143
+ var StatusSchema = z3.enum(ALL_STATUSES);
144
+ var BusinessDate = z3.string().regex(/^\d{4}-\d{2}-\d{2}$/).nullable();
145
+ var HttpUrl = z3.string().refine((s) => {
109
146
  try {
110
147
  const p = new URL(s).protocol;
111
148
  return p === "http:" || p === "https:";
@@ -113,17 +150,23 @@ var HttpUrl = z2.string().refine((s) => {
113
150
  return false;
114
151
  }
115
152
  }, "url must be http or https");
116
- var Priority = z2.union([z2.literal(1), z2.literal(2), z2.literal(3)]);
153
+ var Priority = z3.union([z3.literal(1), z3.literal(2), z3.literal(3)]);
117
154
  function refineKind(v, ctx) {
118
155
  if (v.status !== void 0 && !KIND_STATUSES[v.kind].includes(v.status)) {
119
156
  ctx.addIssue({ code: "custom", path: ["status"], message: `invalid status "${v.status}" for ${v.kind}` });
120
157
  }
121
158
  if (v.kind === "source") {
122
- if (v.url === void 0)
159
+ if (v.url === void 0 && v.sourceSnapshot === void 0)
123
160
  ctx.addIssue({ code: "custom", path: ["url"], message: "url is required for source" });
124
161
  } else if (v.url !== void 0) {
125
162
  ctx.addIssue({ code: "custom", path: ["url"], message: "url is only allowed for source" });
126
163
  }
164
+ if (v.sourceSnapshot !== void 0 && v.kind !== "source") {
165
+ ctx.addIssue({ code: "custom", path: ["sourceSnapshot"], message: "sourceSnapshot is only allowed for source" });
166
+ }
167
+ if (v.confirmedRevision != null && (v.kind !== "source" || v.sourceSnapshot === void 0)) {
168
+ ctx.addIssue({ code: "custom", path: ["confirmedRevision"], message: "confirmedRevision requires a source snapshot" });
169
+ }
127
170
  if (v.kind === "diagram") {
128
171
  if (v.diagram === void 0)
129
172
  ctx.addIssue({ code: "custom", path: ["diagram"], message: "diagram is required for diagram" });
@@ -146,14 +189,17 @@ function refineKind(v, ctx) {
146
189
  ctx.addIssue({ code: "custom", path: ["priority"], message: "priority is only allowed for question" });
147
190
  }
148
191
  }
149
- var EntryFrontmatter = z2.object({
150
- id: z2.string().regex(ID_RE),
192
+ var EntryFrontmatter = z3.object({
193
+ id: z3.string().regex(ID_RE),
151
194
  kind: EntryKindSchema,
152
- title: z2.string().min(1).max(200),
195
+ title: z3.string().min(1).max(200),
153
196
  status: StatusSchema,
154
197
  businessDate: BusinessDate,
155
- related: z2.array(z2.string()),
156
- sourceMessages: z2.array(z2.string()),
198
+ related: z3.array(z3.string()),
199
+ sourceMessages: z3.array(z3.string()),
200
+ sourceSnapshot: SourceSnapshot.optional(),
201
+ sourceRefs: z3.array(SourceRef).max(10).default([]),
202
+ confirmedRevision: SourceRevision.default(null),
157
203
  url: HttpUrl.optional(),
158
204
  priority: Priority.optional(),
159
205
  diagram: DiagramMeta.optional(),
@@ -162,30 +208,31 @@ var EntryFrontmatter = z2.object({
162
208
  basis: BasisSchema.nullable(),
163
209
  ingestedAt: IsoDateTime,
164
210
  confirmedAt: IsoDateTime,
165
- quotes: z2.array(Quote)
211
+ quotes: z3.array(Quote)
166
212
  }).superRefine((v, ctx) => {
167
213
  refineKind(v, ctx);
168
214
  if (kindFromId(v.id) !== v.kind) {
169
215
  ctx.addIssue({ code: "custom", path: ["id"], message: "id prefix does not match kind" });
170
216
  }
171
217
  });
172
- var UpsertEntryInput = z2.object({
173
- id: z2.string().regex(ID_RE).optional(),
218
+ var UpsertEntryInput = z3.object({
219
+ id: z3.string().regex(ID_RE).optional(),
174
220
  kind: EntryKindSchema,
175
- title: z2.string().min(1).max(200),
176
- body: z2.string(),
221
+ title: z3.string().min(1).max(200),
222
+ body: z3.string(),
177
223
  status: StatusSchema.optional(),
178
224
  businessDate: BusinessDate.optional(),
179
- related: z2.array(z2.string()).optional(),
180
- sourceMessages: z2.array(z2.string()).default([]),
225
+ related: z3.array(z3.string()).optional(),
226
+ sourceMessages: z3.array(z3.string()).default([]),
227
+ sourceRefs: z3.array(SourceRef).max(10).optional(),
181
228
  url: HttpUrl.optional(),
182
229
  priority: Priority.optional(),
183
230
  /** Requirements only. The Room API checks it against reports; omitted keeps the stored one. */
184
231
  implementation: Implementation.optional(),
185
232
  basis: BasisSchema.optional(),
186
- quotes: z2.array(Quote).max(10).optional(),
187
- confirmed: z2.boolean().optional(),
188
- reason: z2.string().min(1).max(500)
233
+ quotes: z3.array(Quote).max(10).optional(),
234
+ confirmed: z3.boolean().optional(),
235
+ reason: z3.string().min(1).max(500)
189
236
  }).superRefine((v, ctx) => {
190
237
  refineKind(v, ctx);
191
238
  if (v.id !== void 0 && kindFromId(v.id) !== v.kind) {
@@ -194,23 +241,23 @@ var UpsertEntryInput = z2.object({
194
241
  });
195
242
 
196
243
  // ../../../packages/shared/dist/workspace.js
197
- import { z as z3 } from "zod";
198
- var MessageQuote = z3.object({
199
- messageId: z3.string(),
200
- role: z3.enum(["user", "agent", "system", "report"]),
201
- excerpt: z3.string()
244
+ import { z as z4 } from "zod";
245
+ var MessageQuote = z4.object({
246
+ messageId: z4.string(),
247
+ role: z4.enum(["user", "agent", "system", "report"]),
248
+ excerpt: z4.string()
202
249
  });
203
- var UserMessageMeta = z3.object({
250
+ var UserMessageMeta = z4.object({
204
251
  quote: MessageQuote.optional()
205
252
  });
206
- var AgentMessageMeta = z3.object({
207
- changes: z3.array(z3.object({
208
- entryId: z3.string(),
253
+ var AgentMessageMeta = z4.object({
254
+ changes: z4.array(z4.object({
255
+ entryId: z4.string(),
209
256
  kind: EntryKindSchema,
210
- title: z3.string(),
211
- op: z3.enum(["add", "update"])
257
+ title: z4.string(),
258
+ op: z4.enum(["add", "update"])
212
259
  })),
213
- askedQuestion: z3.object({ id: z3.string(), title: z3.string(), body: z3.string() }).nullable(),
260
+ askedQuestion: z4.object({ id: z4.string(), title: z4.string(), body: z4.string() }).nullable(),
214
261
  quote: MessageQuote.optional()
215
262
  });
216
263
  function isBranchName(name) {
@@ -627,48 +674,48 @@ function bundledExtensions() {
627
674
  }
628
675
 
629
676
  // ../../../packages/shared/dist/protocol.js
630
- import { z as z4 } from "zod";
631
- var DaemonToHubSchema = z4.union([
632
- z4.object({
633
- type: z4.literal("hello"),
634
- token: z4.string(),
635
- version: z4.string(),
636
- adapters: z4.array(z4.string()),
677
+ import { z as z5 } from "zod";
678
+ var DaemonToHubSchema = z5.union([
679
+ z5.object({
680
+ type: z5.literal("hello"),
681
+ token: z5.string(),
682
+ version: z5.string(),
683
+ adapters: z5.array(z5.string()),
637
684
  /** sha256 hex of ~/.nema/report-token, sent when that file exists. */
638
- reportTokenHash: z4.string().regex(/^[0-9a-f]{64}$/).optional()
685
+ reportTokenHash: z5.string().regex(/^[0-9a-f]{64}$/).optional()
639
686
  }),
640
- z4.object({
641
- type: z4.literal("task.event"),
642
- taskId: z4.string(),
643
- event: z4.object({ type: z4.enum(["progress", "agent_message", "tool_call"]), text: z4.string() })
687
+ z5.object({
688
+ type: z5.literal("task.event"),
689
+ taskId: z5.string(),
690
+ event: z5.object({ type: z5.enum(["progress", "agent_message", "tool_call"]), text: z5.string() })
644
691
  }),
645
- z4.object({ type: z4.literal("task.finished"), taskId: z4.string(), ok: z4.literal(true), reply: z4.string() }),
646
- z4.object({ type: z4.literal("task.finished"), taskId: z4.string(), ok: z4.literal(false), error: z4.string() }),
647
- z4.object({ type: z4.literal("rpc.response"), id: z4.string(), ok: z4.literal(true), result: z4.unknown() }),
648
- z4.object({ type: z4.literal("rpc.response"), id: z4.string(), ok: z4.literal(false), error: z4.string() }),
649
- z4.object({ type: z4.literal("repo.moved"), repoId: z4.string(), mainRef: z4.string(), from: z4.string().nullable(), to: z4.string() }),
650
- z4.object({ type: z4.literal("repo.fetched"), repoId: z4.string(), ok: z4.boolean(), error: z4.string().optional(), at: z4.string() })
692
+ z5.object({ type: z5.literal("task.finished"), taskId: z5.string(), ok: z5.literal(true), reply: z5.string() }),
693
+ z5.object({ type: z5.literal("task.finished"), taskId: z5.string(), ok: z5.literal(false), error: z5.string() }),
694
+ z5.object({ type: z5.literal("rpc.response"), id: z5.string(), ok: z5.literal(true), result: z5.unknown() }),
695
+ z5.object({ type: z5.literal("rpc.response"), id: z5.string(), ok: z5.literal(false), error: z5.string() }),
696
+ z5.object({ type: z5.literal("repo.moved"), repoId: z5.string(), mainRef: z5.string(), from: z5.string().nullable(), to: z5.string() }),
697
+ z5.object({ type: z5.literal("repo.fetched"), repoId: z5.string(), ok: z5.boolean(), error: z5.string().optional(), at: z5.string() })
651
698
  ]);
652
- var HubToDaemonSchema = z4.discriminatedUnion("type", [
699
+ var HubToDaemonSchema = z5.discriminatedUnion("type", [
653
700
  // workspaceIds: every workspace that still exists, so the daemon can remove the isolation dirs
654
701
  // (`~/.nema/ws/<id>`) of workspaces deleted while it was offline. Optional for older hubs.
655
- z4.object({ type: z4.literal("welcome"), workspaceIds: z4.array(z4.string()).optional() }),
702
+ z5.object({ type: z5.literal("welcome"), workspaceIds: z5.array(z5.string()).optional() }),
656
703
  // Sent to a connected daemon when a workspace is deleted, so it removes that workspace's isolation dir.
657
- z4.object({ type: z4.literal("workspace.deleted"), workspaceId: z4.string() }),
658
- z4.object({
659
- type: z4.literal("task.assign"),
660
- taskId: z4.string(),
661
- workspaceId: z4.string(),
662
- adapter: z4.string().min(1),
663
- confidential: z4.boolean(),
664
- prompt: z4.string(),
665
- runToken: z4.string(),
666
- hubUrl: z4.string(),
667
- pluginTools: z4.array(z4.object({ name: z4.string(), description: z4.string(), parameters: z4.record(z4.string(), z4.unknown()) })),
668
- limits: z4.object({ maxModelCalls: z4.number().int().min(1), maxToolCalls: z4.number().int().min(1), timeoutMs: z4.number().int().min(1) }).optional()
704
+ z5.object({ type: z5.literal("workspace.deleted"), workspaceId: z5.string() }),
705
+ z5.object({
706
+ type: z5.literal("task.assign"),
707
+ taskId: z5.string(),
708
+ workspaceId: z5.string(),
709
+ adapter: z5.string().min(1),
710
+ confidential: z5.boolean(),
711
+ prompt: z5.string(),
712
+ runToken: z5.string(),
713
+ hubUrl: z5.string(),
714
+ pluginTools: z5.array(z5.object({ name: z5.string(), description: z5.string(), parameters: z5.record(z5.string(), z5.unknown()) })),
715
+ limits: z5.object({ maxModelCalls: z5.number().int().min(1), maxToolCalls: z5.number().int().min(1), timeoutMs: z5.number().int().min(1) }).optional()
669
716
  }),
670
- z4.object({ type: z4.literal("rpc.request"), id: z4.string(), method: z4.string(), params: z4.unknown() }),
671
- z4.object({ type: z4.literal("error"), message: z4.string() })
717
+ z5.object({ type: z5.literal("rpc.request"), id: z5.string(), method: z5.string(), params: z5.unknown() }),
718
+ z5.object({ type: z5.literal("error"), message: z5.string() })
672
719
  ]);
673
720
  function parseHubToDaemon(raw) {
674
721
  return HubToDaemonSchema.parse(raw);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseHubToDaemon
3
- } from "../chunks/chunk-HEIQINX3.js";
3
+ } from "../chunks/chunk-XDIAG2QH.js";
4
4
 
5
5
  // daemon/connection.js
6
6
  import WebSocket from "ws";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  UpsertEntryInput
3
- } from "../chunks/chunk-HEIQINX3.js";
3
+ } from "../chunks/chunk-XDIAG2QH.js";
4
4
 
5
5
  // direct/tools.js
6
6
  import { z } from "zod";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  bundledExtensions
3
- } from "../chunks/chunk-HEIQINX3.js";
3
+ } from "../chunks/chunk-XDIAG2QH.js";
4
4
 
5
5
  // extensions/store.js
6
6
  import { cpSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  GH_COMMAND_TOOLS,
6
6
  PLUGINS
7
- } from "../chunks/chunk-HEIQINX3.js";
7
+ } from "../chunks/chunk-XDIAG2QH.js";
8
8
 
9
9
  // github/client.js
10
10
  import { execFile, spawn } from "node:child_process";
package/dist/github/gh.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunks/chunk-WT3XUFWU.js";
4
4
  import {
5
5
  parseGhCommand
6
- } from "../chunks/chunk-HEIQINX3.js";
6
+ } from "../chunks/chunk-XDIAG2QH.js";
7
7
 
8
8
  // github/gh.js
9
9
  import { commandSpec, windowsRuntimeEnv } from "../platform.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HookSignal,
3
3
  ReportInput
4
- } from "../chunks/chunk-HEIQINX3.js";
4
+ } from "../chunks/chunk-XDIAG2QH.js";
5
5
 
6
6
  // report/commands.js
7
7
  import { repoInfo } from "./git.js";
package/dist/repos/git.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunks/chunk-WT3XUFWU.js";
4
4
  import {
5
5
  isBranchName
6
- } from "../chunks/chunk-HEIQINX3.js";
6
+ } from "../chunks/chunk-XDIAG2QH.js";
7
7
 
8
8
  // repos/git.js
9
9
  import { execFile } from "node:child_process";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  GH_COMMAND_TOOLS
3
- } from "../chunks/chunk-HEIQINX3.js";
3
+ } from "../chunks/chunk-XDIAG2QH.js";
4
4
 
5
5
  // repos/handlers.js
6
6
  import { lstat, rm, unlink } from "node:fs/promises";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nema-project/nema",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {