eve-hub 0.16.234 → 0.16.236

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/diff-form.d.mts +5 -0
  2. package/diff-form.mjs +133 -0
  3. package/forms/SKILL.md +16 -0
  4. package/hub/functions/.well-known/workflow/v1/flow.func/__step_registrations.mjs +46 -1
  5. package/hub/functions/.well-known/workflow/v1/flow.func/hub/hub.mjs +377 -162
  6. package/hub/functions/.well-known/workflow/v1/flow.func/index.mjs +47 -1
  7. package/hub/functions/.well-known/workflow/v1/flow.func/migrations/control/0008_control_rls.sql +74 -0
  8. package/hub/functions/.well-known/workflow/v1/flow.func/migrations/control/meta/_journal.json +7 -0
  9. package/hub/functions/.well-known/workflow/v1/flow.func/migrations/workspace/0030_upload_keys.sql +7 -0
  10. package/hub/functions/.well-known/workflow/v1/flow.func/migrations/workspace/meta/_journal.json +7 -0
  11. package/hub/functions/api/index.func/api/index.mjs +377 -162
  12. package/hub/functions/api/index.func/migrations/control/0008_control_rls.sql +74 -0
  13. package/hub/functions/api/index.func/migrations/control/meta/_journal.json +7 -0
  14. package/hub/functions/api/index.func/migrations/workspace/0030_upload_keys.sql +7 -0
  15. package/hub/functions/api/index.func/migrations/workspace/meta/_journal.json +7 -0
  16. package/hub/migrate/migrate.mjs +27 -1
  17. package/hub/migrations/control/0008_control_rls.sql +74 -0
  18. package/hub/migrations/control/meta/_journal.json +7 -0
  19. package/hub/migrations/workspace/0030_upload_keys.sql +7 -0
  20. package/hub/migrations/workspace/meta/_journal.json +7 -0
  21. package/hub-shared/functions/.well-known/workflow/v1/flow.func/__step_registrations.mjs +46 -1
  22. package/hub-shared/functions/.well-known/workflow/v1/flow.func/hub/hub.mjs +388 -168
  23. package/hub-shared/functions/.well-known/workflow/v1/flow.func/index.mjs +47 -1
  24. package/hub-shared/functions/.well-known/workflow/v1/flow.func/migrations/control/0008_control_rls.sql +74 -0
  25. package/hub-shared/functions/.well-known/workflow/v1/flow.func/migrations/control/meta/_journal.json +7 -0
  26. package/hub-shared/functions/.well-known/workflow/v1/flow.func/migrations/workspace/0030_upload_keys.sql +7 -0
  27. package/hub-shared/functions/.well-known/workflow/v1/flow.func/migrations/workspace/meta/_journal.json +7 -0
  28. package/hub-shared/functions/api/index.func/api/index.mjs +388 -168
  29. package/hub-shared/functions/api/index.func/migrations/control/0008_control_rls.sql +74 -0
  30. package/hub-shared/functions/api/index.func/migrations/control/meta/_journal.json +7 -0
  31. package/hub-shared/functions/api/index.func/migrations/workspace/0030_upload_keys.sql +7 -0
  32. package/hub-shared/functions/api/index.func/migrations/workspace/meta/_journal.json +7 -0
  33. package/hub-shared/migrations/control/0008_control_rls.sql +74 -0
  34. package/hub-shared/migrations/control/meta/_journal.json +7 -0
  35. package/hub-shared/migrations/workspace/0030_upload_keys.sql +7 -0
  36. package/hub-shared/migrations/workspace/meta/_journal.json +7 -0
  37. package/onboarding/SKILL.md +3 -1
  38. package/package.json +1 -1
  39. package/post-text.d.ts +1 -1
  40. package/post-text.js +11 -2
  41. package/skills/forms.gen.mjs +1 -1
  42. package/skills/onboarding-profile.gen.mjs +1 -1
  43. package/tenant-env.mjs +8 -3
  44. package/tools/post_message.js +1 -1
@@ -0,0 +1,5 @@
1
+ export const DIFF_KIND: "diff";
2
+ export const DIFF_LIMITS: { files: number; lines: number; bytes: number; title: number };
3
+ export function splitPreamble(text: string): { meta: Record<string, string>; body: string };
4
+ export function diffErrors(raw: unknown): string[];
5
+ export function isDiffFence(node: { type: string; lang?: string | null; meta?: string | null }): boolean;
package/diff-form.mjs ADDED
@@ -0,0 +1,133 @@
1
+ // The `diff` form: a fenced block holding a raw unified diff, with an optional `# title:` line (and `# repo:`, `# branch:`,
2
+ // `# base:`) above it, drawn inline in a chat post. One definition for the post_message tool (post-text.ts) and the hub's check
3
+ // of a post (hosted-hub/lib/forms.mjs): what a valid block is and how its preamble is read.
4
+ // Larger patches go in an uploaded `.patch` file, which the document pane draws without these ceilings.
5
+
6
+ export const DIFF_KIND = "diff";
7
+ export const DIFF_LIMITS = { files: 6, lines: 120, bytes: 16 * 1024, title: 80 };
8
+
9
+ const PREAMBLE = /^# (title|repo|branch|base): ?(.*)$/;
10
+ const HUNK = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
11
+ const FILE_HEADER = /^diff --git (?:"a\/(?:[^"\\]|\\.)+"|a\/.+?) (?:"b\/(?:[^"\\]|\\.)+"|b\/.+)$/;
12
+ const GIT_HEADER = /^(?:(?:old|new) mode \d+|deleted file mode \d+|new file mode \d+|similarity index \d+%|dissimilarity index \d+%|index [0-9a-f]+\.\.[0-9a-f]+(?: \d+)?|rename (?:from|to) .+|copy (?:from|to) .+)$/;
13
+ const METADATA_ONLY = /^(?:rename from |copy from |new file mode |deleted file mode |new mode )/;
14
+ const TOO_BIG = "upload it as a `.patch` file and link it instead";
15
+
16
+ /** A diff's `# title:`, `# repo:`, `# branch:` and `# base:` lines before its first file, and the patch without them. */
17
+ export function splitPreamble(text) {
18
+ const lines = text.split("\n");
19
+ const meta = {};
20
+ let i = 0;
21
+ for (; i < lines.length; i++) {
22
+ const m = PREAMBLE.exec(lines[i].trimEnd());
23
+ if (!m) break;
24
+ meta[m[1]] = m[2].trim();
25
+ }
26
+ return { meta, body: lines.slice(i).join("\n") };
27
+ }
28
+
29
+ /** Walks the patch by its hunk counts: the files it holds, its hunk lines, and the first thing that is not unified diff syntax. */
30
+ function walk(body, offset) {
31
+ const lines = body.split("\n");
32
+ let files = 0;
33
+ let hunkLines = 0;
34
+ let file = null;
35
+ let hunk = null;
36
+ const fail = (n, why) => ({ files, hunkLines, error: `line ${n + 1 + offset}: ${why}` });
37
+ const closeFile = () => {
38
+ if (!file) return null;
39
+ if (!file.hunks && !file.metadataOnly) return fail(file.at, "a file header with no hunk, rename, new file or deleted file after it");
40
+ return null;
41
+ };
42
+ for (let n = 0; n < lines.length; n++) {
43
+ const line = lines[n];
44
+ if (hunk && (hunk.old > 0 || hunk.new > 0)) {
45
+ const c = line[0];
46
+ if (c === "\\") continue;
47
+ if (c === "-" || c === "+" || c === " " || line === "") {
48
+ if (c === "-") {
49
+ if (hunk.old === 0) return fail(n, "more removed lines than the hunk header says");
50
+ hunk.old--;
51
+ } else if (c === "+") {
52
+ if (hunk.new === 0) return fail(n, "more added lines than the hunk header says");
53
+ hunk.new--;
54
+ } else {
55
+ if (hunk.old === 0 || hunk.new === 0) return fail(n, "more context lines than the hunk header says");
56
+ hunk.old--;
57
+ hunk.new--;
58
+ }
59
+ hunkLines++;
60
+ continue;
61
+ }
62
+ return fail(n, `the hunk "${hunk.head}" ends early: its header says ${hunk.old} more old and ${hunk.new} more new lines`);
63
+ }
64
+ if (hunk && line[0] === "\\") continue;
65
+ if (hunk && /^[-+ ]/.test(line) && !(line.startsWith("--- ") && lines[n + 1]?.startsWith("+++ "))) return fail(n, `more lines than the hunk "${hunk.head}" says`);
66
+ hunk = null;
67
+ if (line === "") {
68
+ if (lines.slice(n).every((l) => l === "")) break;
69
+ return fail(n, "a blank line between files or hunks");
70
+ }
71
+ const h = HUNK.exec(line);
72
+ if (h) {
73
+ if (!file) return fail(n, "a hunk with no file header above it");
74
+ const old = h[2] === undefined ? 1 : +h[2];
75
+ const added = h[4] === undefined ? 1 : +h[4];
76
+ if (old === 0 && added === 0) return fail(n, "an empty hunk");
77
+ file.hunks++;
78
+ hunk = { old, new: added, head: line.match(/^@@[^@]*@@/)[0] };
79
+ continue;
80
+ }
81
+ if (FILE_HEADER.test(line)) {
82
+ const bad = closeFile();
83
+ if (bad) return bad;
84
+ files++;
85
+ file = { at: n, hunks: 0, metadataOnly: false, paths: false };
86
+ continue;
87
+ }
88
+ if (line.startsWith("--- ")) {
89
+ if (!lines[n + 1]?.startsWith("+++ ")) return fail(n, "a `---` file header with no `+++` line after it");
90
+ if (!file || file.paths || file.hunks) {
91
+ const bad = closeFile();
92
+ if (bad) return bad;
93
+ files++;
94
+ file = { at: n, hunks: 0, metadataOnly: false, paths: false };
95
+ }
96
+ file.paths = true;
97
+ n++;
98
+ continue;
99
+ }
100
+ if (file && !file.hunks && GIT_HEADER.test(line)) {
101
+ if (METADATA_ONLY.test(line)) file.metadataOnly = true;
102
+ continue;
103
+ }
104
+ return fail(n, `"${line.slice(0, 60)}" is not unified diff syntax`);
105
+ }
106
+ if (hunk && (hunk.old > 0 || hunk.new > 0)) return fail(lines.length - 1, `the hunk "${hunk.head}" is cut off: its header says ${hunk.old} more old and ${hunk.new} more new lines`);
107
+ const bad = closeFile();
108
+ if (bad) return bad;
109
+ if (!files) return fail(0, "no file header (`diff --git a/x b/x`, or `--- a/x` then `+++ b/x`)");
110
+ return { files, hunkLines };
111
+ }
112
+
113
+ /** Every reason a `diff` block's body is wrong, short and specific enough to feed back to the model; empty when valid. */
114
+ export function diffErrors(raw) {
115
+ const original = String(raw ?? "");
116
+ const text = original.replace(/\r\n/g, "\n");
117
+ const { meta, body } = splitPreamble(text);
118
+ const errors = [];
119
+ if (meta.title !== undefined && (!meta.title || meta.title.length > DIFF_LIMITS.title)) errors.push(`# title: needs 1 to ${DIFF_LIMITS.title} characters`);
120
+ const bytes = new TextEncoder().encode(original).length;
121
+ if (bytes > DIFF_LIMITS.bytes) errors.push(`${Math.ceil(bytes / 1024)} KB is over the ${DIFF_LIMITS.bytes / 1024} KB inline limit: ${TOO_BIG}`);
122
+ const { files, hunkLines, error } = walk(body, text.split("\n").length - body.split("\n").length);
123
+ if (error) {
124
+ errors.push(error);
125
+ return errors;
126
+ }
127
+ if (files > DIFF_LIMITS.files) errors.push(`${files} files is over the ${DIFF_LIMITS.files} file inline limit: ${TOO_BIG}`);
128
+ if (hunkLines > DIFF_LIMITS.lines) errors.push(`${hunkLines} hunk lines is over the ${DIFF_LIMITS.lines} line inline limit: ${TOO_BIG}`);
129
+ return errors;
130
+ }
131
+
132
+ /** Whether a parsed markdown node is a top-level `diff` form: a fence tagged `diff` with no meta string. */
133
+ export const isDiffFence = (node) => node.type === "code" && node.lang === DIFF_KIND && !node.meta;
package/forms/SKILL.md CHANGED
@@ -23,6 +23,7 @@ Three candidate looks for a theme. Miss: a prose list of concepts. Instead: a re
23
23
  - A path through three or more parts: `flow`.
24
24
  - An order of events across two or more actors: `sequence`.
25
25
  - Numbers to compare: `chart`. Time split into phases or hops (a latency breakdown, a turn's timeline) is a `schedule` chart, one row per request and one segment per phase, never one `bar` per total. A `bar` compares one number across items.
26
+ - A code change small enough to read in the post: `diff`. A bigger one is a `.patch` file you upload and link.
26
27
  - A choice you need from the human: `ask`. Choosing an option sends its label back as their reply, so write labels you can act on.
27
28
  - Two or more rows of short, comparable values: a table, at most four columns, a few words per cell. A single item, or anything that needs a reason, is a sentence or bullets.
28
29
  - Anchor the picture in something the reader knows: a labeled before form, then an after form, in one message.
@@ -104,3 +105,18 @@ You need a decision, so I'm asking you to pick one. `ask`: 2–5 `options`, each
104
105
  {"id": "heron", "label": "Heron Lodge", "line": "Lake house 90 minutes north. Rooms for all 14, $5,400."},
105
106
  {"id": "pines", "label": "The Pines", "line": "In town, walkable. Sleeps 10, so 4 need a hotel."}]}
106
107
  ```
108
+
109
+ The retry loop now stops after three attempts. `diff`: a fenced block holding a raw unified diff, as `git diff` prints it, not JSON. It draws inline with the diff viewer's colors, line counts and file folding. An optional `# title:` line at the top (up to 80 characters) names it. Keep it to 6 files, 120 hunk lines (added, removed and context lines) and 16 KB; the hub rejects more, and the 700 characters of a bubble don't count the block. Every hunk header must match the lines under it. A bigger change goes in a `.patch` file you upload and link, which opens in the diff viewer. A snippet that is not a patch (a few `+` and `-` lines with no file header) is a `text` block, because every `diff` block is checked.
110
+
111
+ ```diff
112
+ # title: Cap the retry loop
113
+ diff --git a/src/retry.ts b/src/retry.ts
114
+ --- a/src/retry.ts
115
+ +++ b/src/retry.ts
116
+ @@ -10,4 +10,4 @@ export async function withRetry(run: () => Promise<void>) {
117
+ let attempt = 0;
118
+ - while (true) {
119
+ + while (attempt < MAX_ATTEMPTS) {
120
+ try {
121
+ return await run();
122
+ ```
@@ -68369,12 +68369,57 @@ init_util2();
68369
68369
  init_context_storage();
68370
68370
 
68371
68371
  // src/telemetry.ts
68372
+ var MAX_DEPTH = 8;
68373
+ var SECRET_KEY = /token|secret|password|authorization|dburl|db_url|sealed/i;
68374
+ var SEALED = /^(?![0-9a-f]+$)[A-Za-z0-9+/]{40,}={0,2}$/;
68375
+ var PATTERNS = [
68376
+ [
68377
+ /Bearer\s+[^\s"']+/g,
68378
+ "Bearer [REDACTED]"
68379
+ ],
68380
+ [
68381
+ /postgres(?:ql)?:\/\/[^\s"']+/g,
68382
+ "[REDACTED_DB_URL]"
68383
+ ],
68384
+ [
68385
+ /\b(?:hub_bot_[A-Za-z0-9_-]+|hub_[A-Za-z0-9_-]{16,}|vca_[A-Za-z0-9_-]+|vercel_blob_rw_[A-Za-z0-9_-]+)/g,
68386
+ "[REDACTED_TOKEN]"
68387
+ ]
68388
+ ];
68389
+ function redactIn(value, depth, seen) {
68390
+ if (typeof value === "string") {
68391
+ if (value.length % 4 === 0 && SEALED.test(value)) return "[REDACTED_SEALED]";
68392
+ return PATTERNS.reduce((text, [pattern, replacement]) => text.replace(pattern, replacement), value);
68393
+ }
68394
+ if (typeof value !== "object" || value === null) return value;
68395
+ if (seen.has(value) || depth >= MAX_DEPTH) return "[REDACTED_DEPTH]";
68396
+ seen.add(value);
68397
+ try {
68398
+ if (value instanceof Error) return {
68399
+ name: value.name,
68400
+ message: redactIn(value.message, depth + 1, seen),
68401
+ ...value.stack ? {
68402
+ stack: redactIn(value.stack, depth + 1, seen)
68403
+ } : {}
68404
+ };
68405
+ if (typeof value.toJSON === "function") return redactIn(value.toJSON(), depth + 1, seen);
68406
+ if (Array.isArray(value)) return value.map((item) => redactIn(item, depth + 1, seen));
68407
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
68408
+ key,
68409
+ SECRET_KEY.test(key) && (typeof item === "string" || typeof item === "object" && item !== null) ? "[REDACTED]" : redactIn(item, depth + 1, seen)
68410
+ ]));
68411
+ } finally {
68412
+ seen.delete(value);
68413
+ }
68414
+ }
68415
+ __name(redactIn, "redactIn");
68416
+ var redact = /* @__PURE__ */ __name((value) => redactIn(value, 0, /* @__PURE__ */ new WeakSet()), "redact");
68372
68417
  function emit(event, fields = {}, level = "info") {
68373
68418
  const line = JSON.stringify({
68374
68419
  event,
68375
68420
  level,
68376
68421
  at: Date.now(),
68377
- ...fields
68422
+ ...redact(fields)
68378
68423
  });
68379
68424
  if (level === "error") console.error(line);
68380
68425
  else console.log(line);