@joe-broadhead/opencode-mem 0.12.4 → 0.12.6
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.
- package/CHANGELOG.md +81 -0
- package/README.md +1 -0
- package/package.json +147 -2
- package/src/actions.js +36 -1
- package/src/collector.js +176 -12
- package/src/plugins/source-contract/index.js +2 -2
- package/src/plugins/source-contract/vendor/PROVENANCE.json +9 -9
- package/src/plugins/source-contract/vendor/RELEASE-SHA256SUMS +3 -3
- package/src/plugins/source-contract/vendor/RELEASE.json +9 -9
- package/src/plugins/source-contract/vendor/SHA256SUMS +36 -29
- package/src/plugins/source-contract/vendor/broker-client.js +14 -14
- package/src/plugins/source-contract/vendor/chunks/{chunk-JUWIMDGF.js → chunk-6ZSJSJMV.js} +2 -2
- package/src/plugins/source-contract/vendor/chunks/{chunk-77MJETEE.js → chunk-A2KM6BYK.js} +13 -13
- package/src/plugins/source-contract/vendor/chunks/{chunk-HVBOAYBO.js → chunk-BEU3WWNO.js} +59 -6
- package/src/plugins/source-contract/vendor/chunks/{chunk-T4QM7B3S.js → chunk-CUITXC5J.js} +1 -1
- package/src/{vendor/source-contract/chunks/chunk-OZMX7VR7.js → plugins/source-contract/vendor/chunks/chunk-EOS4LD6F.js} +1 -1
- package/src/plugins/source-contract/vendor/chunks/{chunk-F4K2Y64D.js → chunk-EUDLXWG4.js} +1 -1
- package/src/plugins/source-contract/vendor/chunks/{chunk-BOUWB5UP.js → chunk-GDBKZBG7.js} +2 -2
- package/src/plugins/source-contract/vendor/chunks/{chunk-EHIOPXPL.js → chunk-HR22TL23.js} +14 -14
- package/src/plugins/source-contract/vendor/chunks/{chunk-X6XP7YK2.js → chunk-IGPRJ63D.js} +2 -2
- package/src/plugins/source-contract/vendor/chunks/{chunk-XVA6H6OO.js → chunk-IIUWLSGP.js} +2 -2
- package/src/plugins/source-contract/vendor/chunks/chunk-ITQZIF2U.js +191 -0
- package/src/plugins/source-contract/vendor/chunks/{chunk-IL565TRX.js → chunk-KXQYSM2Z.js} +1 -1
- package/src/plugins/source-contract/vendor/chunks/{chunk-YH323FAZ.js → chunk-LJL3EALP.js} +238 -12
- package/src/plugins/source-contract/vendor/chunks/{chunk-NUEROZNU.js → chunk-NUBUQFLH.js} +1 -1
- package/src/plugins/source-contract/vendor/cursor.js +3 -3
- package/src/plugins/source-contract/vendor/descriptor.js +11 -11
- package/src/plugins/source-contract/vendor/events.js +22 -4
- package/src/plugins/source-contract/vendor/hints.js +33 -0
- package/src/plugins/source-contract/vendor/index.js +3 -3
- package/src/plugins/source-contract/vendor/params.js +3 -3
- package/src/plugins/source-contract/vendor/permission.js +3 -3
- package/src/plugins/source-contract/vendor/pick.js +5 -5
- package/src/plugins/source-contract/vendor/read.js +14 -14
- package/src/plugins/source-contract/vendor/registry.js +4 -4
- package/src/plugins/source-contract/vendor/schema.js +14 -10
- package/src/plugins/source-contract/vendor/schemas/fact.commitment.json +57 -0
- package/src/plugins/source-contract/vendor/schemas/fact.meeting.attended.json +35 -0
- package/src/plugins/source-contract/vendor/schemas/fact.person.attribute.json +37 -0
- package/src/plugins/source-contract/vendor/schemas/hint.json +41 -0
- package/src/plugins/source-contract/vendor/schemas/routine.json +67 -0
- package/src/plugins/source-contract/vendor/schemas/sources.json +56 -0
- package/src/plugins/source-contract/vendor/schemas.js +16 -11
- package/src/plugins/source-contract/vendor/tools-rpc.js +4 -4
- package/src/records.js +5 -0
- package/src/vendor/source-contract/README.md +10 -8
- package/src/vendor/source-contract/VENDOR.json +48 -39
- package/src/vendor/source-contract/chunks/{chunk-JUWIMDGF.js → chunk-6ZSJSJMV.js} +2 -2
- package/src/vendor/source-contract/chunks/{chunk-T4QM7B3S.js → chunk-CUITXC5J.js} +1 -1
- package/src/{plugins/source-contract/vendor/chunks/chunk-OZMX7VR7.js → vendor/source-contract/chunks/chunk-EOS4LD6F.js} +1 -1
- package/src/vendor/source-contract/chunks/{chunk-BOUWB5UP.js → chunk-GDBKZBG7.js} +2 -2
- package/src/vendor/source-contract/chunks/{chunk-X6XP7YK2.js → chunk-IGPRJ63D.js} +2 -2
- package/src/vendor/source-contract/chunks/{chunk-YH323FAZ.js → chunk-LJL3EALP.js} +238 -12
- package/src/vendor/source-contract/chunks/{chunk-NUEROZNU.js → chunk-NUBUQFLH.js} +1 -1
- package/src/vendor/source-contract/cursor.js +3 -3
- package/src/vendor/source-contract/events.js +22 -4
- package/src/vendor/source-contract/registry.js +4 -4
- package/src/vendor/source-contract/tools-rpc.js +4 -4
- package/src/views/contracts.js +5 -1
- package/src/views/rpc.js +11 -0
- package/src/views/shape.js +11 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// @we-the-rebel-alliance/source-contract 0.
|
|
1
|
+
// @we-the-rebel-alliance/source-contract 0.3.0. Built by scripts/build.mjs; do not edit.
|
|
2
2
|
import {
|
|
3
3
|
MAX_CURSOR_LENGTH,
|
|
4
4
|
canonicalScope
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NUBUQFLH.js";
|
|
6
6
|
|
|
7
7
|
// src/internal/secrets.ts
|
|
8
8
|
var PRIVATE_KEY_BLOCK = /-----BEGIN (?:[A-Z0-9]+ )*PRIVATE KEY(?: BLOCK)?-----[\s\S]*?(?:-----END (?:[A-Z0-9]+ )*PRIVATE KEY(?: BLOCK)?-----|$)/g;
|
|
@@ -152,13 +152,37 @@ var EVENT_LIMITS = {
|
|
|
152
152
|
refused: 500,
|
|
153
153
|
failed: 500,
|
|
154
154
|
detail: 200,
|
|
155
|
-
costUnits: 8
|
|
155
|
+
costUnits: 8,
|
|
156
|
+
/** #45 §1: the identities one actor may carry, and the lengths of each part of one. */
|
|
157
|
+
identities: 10,
|
|
158
|
+
identityBasis: 64,
|
|
159
|
+
/** #45 §2: the metadata one event may carry. */
|
|
160
|
+
replyTo: 512,
|
|
161
|
+
domains: 20,
|
|
162
|
+
domain: 253,
|
|
163
|
+
sections: 20,
|
|
164
|
+
sectionHeading: 300,
|
|
165
|
+
parts: 50,
|
|
166
|
+
partId: 512,
|
|
167
|
+
/** #45 §3: the facts one event may carry, and the lengths of their fields. */
|
|
168
|
+
facts: 20,
|
|
169
|
+
factKey: 200,
|
|
170
|
+
factTitle: 300,
|
|
171
|
+
factAttribute: 120
|
|
156
172
|
};
|
|
157
173
|
var PAGE = { default: 100, min: 1, max: 500 };
|
|
158
174
|
var MAX_PAGE_BYTES = 65536;
|
|
159
175
|
var MAX_BYTES = { default: 65536, max: 1048576 };
|
|
160
176
|
var FIRST_RUN_HOURS = 24;
|
|
161
177
|
var TRUST = "untrusted";
|
|
178
|
+
var ACTOR_KINDS = ["person", "agent", "bot", "service"];
|
|
179
|
+
var ACTOR_ROLES = ["from", "author", "to", "cc", "bcc", "mentioned", "assignee", "creator", "reviewer", "organizer", "attendee", "owner", "speaker", "agent"];
|
|
180
|
+
var AUTHOR_ROLES = ["from", "author"];
|
|
181
|
+
var IDENTITY_STRENGTHS = ["strong", "weak"];
|
|
182
|
+
var AUDIENCES = ["dm", "group", "channel", "email", "public"];
|
|
183
|
+
var FACT_TYPES = ["commitment", "person.attribute", "meeting.attended"];
|
|
184
|
+
var COMMITMENT_STATES = ["open", "done", "cancelled"];
|
|
185
|
+
var ATTENDANCE_RESPONSES = ["accepted", "declined", "tentative", "needs_action"];
|
|
162
186
|
function ownerShapeProblems(owner, what) {
|
|
163
187
|
if (!plainObject(owner) || !line(owner["id"], EVENT_LIMITS.ownerId) || !line(owner["label"], EVENT_LIMITS.ownerLabel) || Object.keys(owner).some((key) => key !== "id" && key !== "label" && key !== "verified")) {
|
|
164
188
|
return [`${what} must be { id, label }, two non-empty lines`];
|
|
@@ -299,6 +323,20 @@ function cut(text2, max) {
|
|
|
299
323
|
if (end > 0 && code >= 55296 && code <= 56319) end--;
|
|
300
324
|
return `${text2.slice(0, end)}\u2026`;
|
|
301
325
|
}
|
|
326
|
+
function stable(value) {
|
|
327
|
+
if (Array.isArray(value)) return value.map(stable);
|
|
328
|
+
if (typeof value === "object" && value !== null) {
|
|
329
|
+
const entries = Object.keys(value).filter((key) => value[key] !== void 0);
|
|
330
|
+
return Object.fromEntries(entries.sort().map((key) => [key, stable(value[key])]));
|
|
331
|
+
}
|
|
332
|
+
return value;
|
|
333
|
+
}
|
|
334
|
+
var HASHED_EVENT_FIELDS = ["reply_to", "audience", "domains", "sections", "parts", "facts"];
|
|
335
|
+
function actorFields(actor) {
|
|
336
|
+
const base = [actor.role, actor.id, actor.name ?? null];
|
|
337
|
+
const extra = stable({ kind: actor.kind, identities: actor.identities, self: actor.self });
|
|
338
|
+
return Object.keys(extra).length === 0 ? base : [...base, extra];
|
|
339
|
+
}
|
|
302
340
|
function eventHash(event) {
|
|
303
341
|
const fields = [
|
|
304
342
|
event.source,
|
|
@@ -307,12 +345,16 @@ function eventHash(event) {
|
|
|
307
345
|
event.kind,
|
|
308
346
|
event.occurred_at,
|
|
309
347
|
event.thread,
|
|
310
|
-
event.actors.map(
|
|
348
|
+
event.actors.map(actorFields),
|
|
311
349
|
event.title,
|
|
312
350
|
event.text,
|
|
313
351
|
event.url,
|
|
314
352
|
event.labels
|
|
315
353
|
];
|
|
354
|
+
for (const key of HASHED_EVENT_FIELDS) {
|
|
355
|
+
const value = event[key];
|
|
356
|
+
if (value !== void 0) fields.push([key, stable(value)]);
|
|
357
|
+
}
|
|
316
358
|
return `sha256:${createHash("sha256").update(JSON.stringify(fields)).digest("hex")}`;
|
|
317
359
|
}
|
|
318
360
|
var clean = (text2) => text2.replaceAll("\0", "");
|
|
@@ -329,11 +371,27 @@ function makeEvent(draft) {
|
|
|
329
371
|
if (!role || !id || seen.has(key) || actors.length >= EVENT_LIMITS.actors) continue;
|
|
330
372
|
seen.add(key);
|
|
331
373
|
const name = actor.name ? cut(oneLine(actor.name), EVENT_LIMITS.actorName) : "";
|
|
332
|
-
actors.push(
|
|
374
|
+
actors.push({
|
|
375
|
+
role,
|
|
376
|
+
id,
|
|
377
|
+
...name ? { name } : {},
|
|
378
|
+
...actor.kind === void 0 ? {} : { kind: actor.kind },
|
|
379
|
+
// An empty list says nothing, and is left out so the actor hashes as if it had none.
|
|
380
|
+
...actor.identities === void 0 || actor.identities.length === 0 ? {} : { identities: [...actor.identities] },
|
|
381
|
+
...actor.self === void 0 ? {} : { self: actor.self }
|
|
382
|
+
});
|
|
333
383
|
}
|
|
334
384
|
const labels = [...new Set((draft.labels ?? []).map((label) => oneLine(label).replace(/\s/g, "-")).filter((label) => label.length > 0 && label.length <= EVENT_LIMITS.label))].slice(0, EVENT_LIMITS.labels);
|
|
335
385
|
const url = draft.url && /^https:\/\/\S+$/.test(draft.url) && draft.url.length <= EVENT_LIMITS.url ? draft.url : null;
|
|
336
386
|
const thread = draft.thread ? oneLine(draft.thread) || null : null;
|
|
387
|
+
const replyTo = draft.reply_to ? cut(oneLine(draft.reply_to), EVENT_LIMITS.replyTo) : void 0;
|
|
388
|
+
const domains = draft.domains === void 0 ? void 0 : [...new Set(draft.domains.map((domain) => oneLine(domain).toLowerCase()))].filter((domain) => domain.length > 0);
|
|
389
|
+
const sections = draft.sections?.map((section) => ({ heading: cut(oneLine(section.heading), EVENT_LIMITS.sectionHeading), text: cut(clean(section.text), EVENT_LIMITS.text) })).filter((section) => section.heading.length > 0);
|
|
390
|
+
const parts = draft.parts?.map((part) => {
|
|
391
|
+
const id = cut(oneLine(part.id), EVENT_LIMITS.partId);
|
|
392
|
+
const actor = part.actor === void 0 ? "" : oneLine(part.actor);
|
|
393
|
+
return { id, text: cut(clean(part.text), EVENT_LIMITS.text), ...actor ? { actor } : {} };
|
|
394
|
+
}).filter((part) => part.id.length > 0);
|
|
337
395
|
const event = {
|
|
338
396
|
source: draft.source,
|
|
339
397
|
account: draft.account,
|
|
@@ -345,7 +403,13 @@ function makeEvent(draft) {
|
|
|
345
403
|
title: cut(oneLine(draft.title ?? ""), EVENT_LIMITS.title),
|
|
346
404
|
text: cut(clean(draft.text ?? "").trim(), EVENT_LIMITS.text),
|
|
347
405
|
url,
|
|
348
|
-
labels
|
|
406
|
+
labels,
|
|
407
|
+
...replyTo === void 0 ? {} : { reply_to: replyTo },
|
|
408
|
+
...draft.audience === void 0 || draft.audience === null ? {} : { audience: draft.audience },
|
|
409
|
+
...domains === void 0 || domains.length === 0 ? {} : { domains },
|
|
410
|
+
...sections === void 0 || sections.length === 0 ? {} : { sections },
|
|
411
|
+
...parts === void 0 || parts.length === 0 ? {} : { parts },
|
|
412
|
+
...draft.facts === void 0 || draft.facts.length === 0 ? {} : { facts: [...draft.facts] }
|
|
349
413
|
};
|
|
350
414
|
return { ...event, hash: eventHash(event) };
|
|
351
415
|
}
|
|
@@ -460,15 +524,168 @@ var SCHEMED = /^[a-z][a-z0-9+.-]*:\S+$/;
|
|
|
460
524
|
var HASH = /^sha256:[0-9a-f]{64}$/;
|
|
461
525
|
var CODE = /^[A-Z][A-Z0-9_]*$/;
|
|
462
526
|
var UNIT = /^[a-z][a-z0-9_-]*$/;
|
|
527
|
+
var DOMAIN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/;
|
|
528
|
+
var DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
529
|
+
var listOf = (items) => items.length <= 1 ? items.join("") : `${items.slice(0, -1).join(", ")} or ${items.at(-1)}`;
|
|
463
530
|
var text = (value, max, empty = false) => typeof value === "string" && value.length <= max && (empty || value.length > 0) && !value.includes("\0");
|
|
464
531
|
var line = (value, max, empty = false) => text(value, max, empty) && !hasControl(value);
|
|
465
532
|
var isoUtc = (value) => typeof value === "string" && ISO_UTC.test(value) && Number.isFinite(Date.parse(value));
|
|
533
|
+
function actorProblems(actor, at) {
|
|
534
|
+
const problems = [];
|
|
535
|
+
for (const key of Object.keys(actor)) if (!["role", "id", "name", "kind", "identities", "self"].includes(key)) problems.push(`${at} has the field "${key}", which the contract does not define`);
|
|
536
|
+
const role = actor.role;
|
|
537
|
+
const id = actor.id;
|
|
538
|
+
if (!line(role, EVENT_LIMITS.actorRole) || !ROLE.test(role)) problems.push(`${at}.role must be a lowercase word such as from`);
|
|
539
|
+
if (!line(id, EVENT_LIMITS.actorId) || !SCHEMED.test(id)) problems.push(`${at}.id must be a scheme-qualified id such as mailto:someone@example.com`);
|
|
540
|
+
if (actor.name !== void 0 && !line(actor.name, EVENT_LIMITS.actorName)) problems.push(`${at}.name must be one non-empty line of at most ${EVENT_LIMITS.actorName} characters`);
|
|
541
|
+
if (actor.kind !== void 0 && !ACTOR_KINDS.includes(actor.kind)) problems.push(`${at}.kind must be ${listOf(ACTOR_KINDS)}`);
|
|
542
|
+
if (actor.self !== void 0 && typeof actor.self !== "boolean") problems.push(`${at}.self must be true or false`);
|
|
543
|
+
if (actor.identities !== void 0) {
|
|
544
|
+
if (!Array.isArray(actor.identities) || actor.identities.length > EVENT_LIMITS.identities) problems.push(`${at}.identities must be a list of at most ${EVENT_LIMITS.identities}`);
|
|
545
|
+
else {
|
|
546
|
+
const seen = /* @__PURE__ */ new Set();
|
|
547
|
+
for (const [index, identity] of actor.identities.entries()) {
|
|
548
|
+
const here = `${at}.identities[${index}]`;
|
|
549
|
+
if (!plainObject(identity)) {
|
|
550
|
+
problems.push(`${here} is not an object`);
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
for (const key of Object.keys(identity)) if (!["id", "strength", "basis"].includes(key)) problems.push(`${here} has the field "${key}", which the contract does not define`);
|
|
554
|
+
const own = identity.id;
|
|
555
|
+
if (!line(own, EVENT_LIMITS.actorId) || !SCHEMED.test(own)) problems.push(`${here}.id must be a scheme-qualified id such as mailto:someone@example.com`);
|
|
556
|
+
else if (own === id) problems.push(`${here}.id is the actor's own id: an identity is another id for the same actor`);
|
|
557
|
+
else if (seen.has(own)) problems.push(`${here} repeats an identity`);
|
|
558
|
+
else seen.add(own);
|
|
559
|
+
if (!IDENTITY_STRENGTHS.includes(identity.strength)) problems.push(`${here}.strength must be ${listOf(IDENTITY_STRENGTHS)}`);
|
|
560
|
+
if (!line(identity.basis, EVENT_LIMITS.identityBasis)) {
|
|
561
|
+
problems.push(`${here}.basis must be one line of at most ${EVENT_LIMITS.identityBasis} characters naming the provider field it came from`);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return problems;
|
|
567
|
+
}
|
|
568
|
+
function targetProblems(e, where) {
|
|
569
|
+
const problems = [];
|
|
570
|
+
if (e.reply_to !== void 0 && !line(e.reply_to, EVENT_LIMITS.replyTo)) {
|
|
571
|
+
problems.push(`${where}.reply_to must be a non-empty id of at most ${EVENT_LIMITS.replyTo} characters`);
|
|
572
|
+
}
|
|
573
|
+
if (e.audience !== void 0 && !AUDIENCES.includes(e.audience)) {
|
|
574
|
+
problems.push(`${where}.audience must be ${listOf(AUDIENCES)}`);
|
|
575
|
+
}
|
|
576
|
+
if (e.domains !== void 0) {
|
|
577
|
+
if (!Array.isArray(e.domains) || e.domains.length > EVENT_LIMITS.domains) problems.push(`${where}.domains must be at most ${EVENT_LIMITS.domains} lowercase domains`);
|
|
578
|
+
else {
|
|
579
|
+
const seen = /* @__PURE__ */ new Set();
|
|
580
|
+
for (const [index, domain] of e.domains.entries()) {
|
|
581
|
+
if (!line(domain, EVENT_LIMITS.domain) || !DOMAIN.test(domain)) problems.push(`${where}.domains[${index}] must be a lowercase domain such as example.com`);
|
|
582
|
+
else if (seen.has(domain)) problems.push(`${where}.domains repeats a domain`);
|
|
583
|
+
else seen.add(domain);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return problems;
|
|
588
|
+
}
|
|
589
|
+
function partProblems(e, where, actorIds) {
|
|
590
|
+
const problems = [];
|
|
591
|
+
if (e.sections !== void 0) {
|
|
592
|
+
if (!Array.isArray(e.sections) || e.sections.length > EVENT_LIMITS.sections) problems.push(`${where}.sections must be a list of at most ${EVENT_LIMITS.sections}`);
|
|
593
|
+
else {
|
|
594
|
+
for (const [index, section] of e.sections.entries()) {
|
|
595
|
+
const at = `${where}.sections[${index}]`;
|
|
596
|
+
if (!plainObject(section)) {
|
|
597
|
+
problems.push(`${at} is not an object`);
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
for (const key of Object.keys(section)) if (!["heading", "text"].includes(key)) problems.push(`${at} has the field "${key}", which the contract does not define`);
|
|
601
|
+
if (!line(section.heading, EVENT_LIMITS.sectionHeading)) problems.push(`${at}.heading must be one line of at most ${EVENT_LIMITS.sectionHeading} characters`);
|
|
602
|
+
if (!text(section.text, EVENT_LIMITS.text, true)) problems.push(`${at}.text must be at most ${EVENT_LIMITS.text} characters`);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (e.parts !== void 0) {
|
|
607
|
+
if (!Array.isArray(e.parts) || e.parts.length > EVENT_LIMITS.parts) problems.push(`${where}.parts must be a list of at most ${EVENT_LIMITS.parts}`);
|
|
608
|
+
else {
|
|
609
|
+
const seen = /* @__PURE__ */ new Set();
|
|
610
|
+
for (const [index, part] of e.parts.entries()) {
|
|
611
|
+
const at = `${where}.parts[${index}]`;
|
|
612
|
+
if (!plainObject(part)) {
|
|
613
|
+
problems.push(`${at} is not an object`);
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
for (const key of Object.keys(part)) if (!["id", "text", "actor"].includes(key)) problems.push(`${at} has the field "${key}", which the contract does not define`);
|
|
617
|
+
const id = part.id;
|
|
618
|
+
if (!line(id, EVENT_LIMITS.partId)) problems.push(`${at}.id must be a non-empty id of at most ${EVENT_LIMITS.partId} characters`);
|
|
619
|
+
else if (seen.has(id)) problems.push(`${at}.id repeats a part`);
|
|
620
|
+
else seen.add(id);
|
|
621
|
+
if (!text(part.text, EVENT_LIMITS.text, true)) problems.push(`${at}.text must be at most ${EVENT_LIMITS.text} characters`);
|
|
622
|
+
if (part.actor !== void 0) {
|
|
623
|
+
if (!line(part.actor, EVENT_LIMITS.actorId)) problems.push(`${at}.actor must be an actor id of the same event`);
|
|
624
|
+
else if (!actorIds.has(part.actor)) problems.push(`${at}.actor is not an actor of the same event`);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return problems;
|
|
630
|
+
}
|
|
631
|
+
function factProblems(fact, actors, where = "fact") {
|
|
632
|
+
if (!plainObject(fact)) return [`${where} is not an object`];
|
|
633
|
+
const type = fact.type;
|
|
634
|
+
if (!FACT_TYPES.includes(type)) return [`${where}.type must be ${listOf(FACT_TYPES)}`];
|
|
635
|
+
const allowed = {
|
|
636
|
+
commitment: ["type", "key", "title", "owner", "counterparty", "due", "state", "url"],
|
|
637
|
+
"person.attribute": ["type", "actor", "org", "team", "role"],
|
|
638
|
+
"meeting.attended": ["type", "actor", "response", "organizer"]
|
|
639
|
+
};
|
|
640
|
+
const problems = [];
|
|
641
|
+
for (const key of Object.keys(fact)) {
|
|
642
|
+
if (!allowed[type].includes(key)) problems.push(`${where} has the field "${key}", which the contract does not define`);
|
|
643
|
+
}
|
|
644
|
+
const reference = (key) => {
|
|
645
|
+
const id = fact[key];
|
|
646
|
+
if (!line(id, EVENT_LIMITS.actorId)) problems.push(`${where}.${key} must be an actor id of the same event`);
|
|
647
|
+
else if (!actors.has(id)) problems.push(`${where}.${key} is not an actor of the same event`);
|
|
648
|
+
};
|
|
649
|
+
if (type === "commitment") {
|
|
650
|
+
if (!line(fact.key, EVENT_LIMITS.factKey)) problems.push(`${where}.key must be a stable id of at most ${EVENT_LIMITS.factKey} characters`);
|
|
651
|
+
if (!line(fact.title, EVENT_LIMITS.factTitle)) problems.push(`${where}.title must be one line of at most ${EVENT_LIMITS.factTitle} characters`);
|
|
652
|
+
reference("owner");
|
|
653
|
+
if (fact.counterparty !== void 0) reference("counterparty");
|
|
654
|
+
if (fact.due !== void 0 && !(typeof fact.due === "string" && DATE.test(fact.due) && Number.isFinite(Date.parse(fact.due)))) problems.push(`${where}.due must be a date such as 2026-11-30`);
|
|
655
|
+
if (!COMMITMENT_STATES.includes(fact.state)) problems.push(`${where}.state must be ${listOf(COMMITMENT_STATES)}`);
|
|
656
|
+
if (fact.url !== void 0 && !(typeof fact.url === "string" && fact.url.length <= EVENT_LIMITS.url && /^https:\/\/\S+$/.test(fact.url))) problems.push(`${where}.url must be an https URL`);
|
|
657
|
+
}
|
|
658
|
+
if (type === "person.attribute") {
|
|
659
|
+
reference("actor");
|
|
660
|
+
if (fact.org === void 0 && fact.team === void 0 && fact.role === void 0) {
|
|
661
|
+
problems.push(`${where} must name org, team or role: a person's attribute comes from structured profile or directory data`);
|
|
662
|
+
}
|
|
663
|
+
for (const key of ["org", "team", "role"]) {
|
|
664
|
+
if (fact[key] !== void 0 && !line(fact[key], EVENT_LIMITS.factAttribute)) {
|
|
665
|
+
problems.push(`${where}.${key} must be one line of at most ${EVENT_LIMITS.factAttribute} characters`);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (type === "meeting.attended") {
|
|
670
|
+
reference("actor");
|
|
671
|
+
if (!ATTENDANCE_RESPONSES.includes(fact.response)) problems.push(`${where}.response must be ${listOf(ATTENDANCE_RESPONSES)}`);
|
|
672
|
+
if (typeof fact.organizer !== "boolean") problems.push(`${where}.organizer must be true or false`);
|
|
673
|
+
}
|
|
674
|
+
return problems;
|
|
675
|
+
}
|
|
676
|
+
function factsProblems(e, where, actorIds) {
|
|
677
|
+
if (e.facts === void 0) return [];
|
|
678
|
+
if (!Array.isArray(e.facts) || e.facts.length > EVENT_LIMITS.facts) return [`${where}.facts must be a list of at most ${EVENT_LIMITS.facts}`];
|
|
679
|
+
return e.facts.flatMap((fact, index) => factProblems(fact, actorIds, `${where}.facts[${index}]`));
|
|
680
|
+
}
|
|
681
|
+
var EVENT_KEYS = ["source", "account", "external_id", "kind", "occurred_at", "thread", "actors", "title", "text", "url", "labels", "hash"];
|
|
682
|
+
var EVENT_METADATA_KEYS = ["reply_to", "audience", "domains", "sections", "parts", "facts"];
|
|
466
683
|
function eventProblems(event, where = "event") {
|
|
467
684
|
if (!plainObject(event)) return [`${where} is not an object`];
|
|
468
685
|
const problems = [];
|
|
469
|
-
const keys = [
|
|
686
|
+
const keys = [...EVENT_KEYS, ...EVENT_METADATA_KEYS];
|
|
470
687
|
for (const key of Object.keys(event)) if (!keys.includes(key)) problems.push(`${where} has the field "${key}", which the contract does not define`);
|
|
471
|
-
for (const key of
|
|
688
|
+
for (const key of EVENT_KEYS) if (!Object.hasOwn(event, key)) problems.push(`${where} has no "${key}"`);
|
|
472
689
|
const e = event;
|
|
473
690
|
if (!line(e.source, EVENT_LIMITS.source) || !SOURCE_PATTERN.test(e.source)) problems.push(`${where}.source must be a lowercase name such as gmail`);
|
|
474
691
|
if (!line(e.account, EVENT_LIMITS.account)) problems.push(`${where}.account must be a non-empty name of at most ${EVENT_LIMITS.account} characters`);
|
|
@@ -482,6 +699,7 @@ function eventProblems(event, where = "event") {
|
|
|
482
699
|
if (!Array.isArray(e.labels) || e.labels.length > EVENT_LIMITS.labels || e.labels.some((label) => !line(label, EVENT_LIMITS.label) || /\s/.test(label))) {
|
|
483
700
|
problems.push(`${where}.labels must be at most ${EVENT_LIMITS.labels} labels of at most ${EVENT_LIMITS.label} characters without spaces`);
|
|
484
701
|
} else if (new Set(e.labels).size !== e.labels.length) problems.push(`${where}.labels repeats a label`);
|
|
702
|
+
const actorIds = /* @__PURE__ */ new Set();
|
|
485
703
|
if (!Array.isArray(e.actors) || e.actors.length > EVENT_LIMITS.actors) problems.push(`${where}.actors must be a list of at most ${EVENT_LIMITS.actors}`);
|
|
486
704
|
else {
|
|
487
705
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -491,15 +709,14 @@ function eventProblems(event, where = "event") {
|
|
|
491
709
|
problems.push(`${at} is not an object`);
|
|
492
710
|
continue;
|
|
493
711
|
}
|
|
494
|
-
|
|
495
|
-
if (
|
|
496
|
-
if (!line(actor.id, EVENT_LIMITS.actorId) || !SCHEMED.test(actor.id)) problems.push(`${at}.id must be a scheme-qualified id such as mailto:someone@example.com`);
|
|
497
|
-
if (actor.name !== void 0 && !line(actor.name, EVENT_LIMITS.actorName)) problems.push(`${at}.name must be one non-empty line of at most ${EVENT_LIMITS.actorName} characters`);
|
|
712
|
+
problems.push(...actorProblems(actor, at));
|
|
713
|
+
if (typeof actor.id === "string") actorIds.add(actor.id);
|
|
498
714
|
const key = `${String(actor.role)}\0${String(actor.id)}`;
|
|
499
715
|
if (seen.has(key)) problems.push(`${at} repeats an actor`);
|
|
500
716
|
seen.add(key);
|
|
501
717
|
}
|
|
502
718
|
}
|
|
719
|
+
problems.push(...targetProblems(e, where), ...partProblems(e, where, actorIds), ...factsProblems(e, where, actorIds));
|
|
503
720
|
if (typeof e.hash !== "string" || !HASH.test(e.hash)) problems.push(`${where}.hash must be sha256: and 64 hex digits`);
|
|
504
721
|
else if (problems.length === 0) {
|
|
505
722
|
const { hash, ...rest } = e;
|
|
@@ -659,6 +876,14 @@ export {
|
|
|
659
876
|
MAX_BYTES,
|
|
660
877
|
FIRST_RUN_HOURS,
|
|
661
878
|
TRUST,
|
|
879
|
+
ACTOR_KINDS,
|
|
880
|
+
ACTOR_ROLES,
|
|
881
|
+
AUTHOR_ROLES,
|
|
882
|
+
IDENTITY_STRENGTHS,
|
|
883
|
+
AUDIENCES,
|
|
884
|
+
FACT_TYPES,
|
|
885
|
+
COMMITMENT_STATES,
|
|
886
|
+
ATTENDANCE_RESPONSES,
|
|
662
887
|
REFUSAL_REASONS,
|
|
663
888
|
REMOVAL_REASONS,
|
|
664
889
|
GAP_REASONS,
|
|
@@ -688,6 +913,7 @@ export {
|
|
|
688
913
|
probeResult,
|
|
689
914
|
probeResultProblems,
|
|
690
915
|
eventsListResult,
|
|
916
|
+
factProblems,
|
|
691
917
|
eventProblems,
|
|
692
918
|
removalProblems,
|
|
693
919
|
resultProblems
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @we-the-rebel-alliance/source-contract 0.
|
|
1
|
+
// @we-the-rebel-alliance/source-contract 0.3.0. Built by scripts/build.mjs; do not edit.
|
|
2
2
|
import {
|
|
3
3
|
CURSOR_V1,
|
|
4
4
|
CURSOR_V2,
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
decodeCursor,
|
|
11
11
|
encodeBoundCursor,
|
|
12
12
|
encodeCursor
|
|
13
|
-
} from "./chunks/chunk-
|
|
14
|
-
import "./chunks/chunk-
|
|
13
|
+
} from "./chunks/chunk-NUBUQFLH.js";
|
|
14
|
+
import "./chunks/chunk-CUITXC5J.js";
|
|
15
15
|
export {
|
|
16
16
|
CURSOR_V1,
|
|
17
17
|
CURSOR_V2,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
// @we-the-rebel-alliance/source-contract 0.
|
|
1
|
+
// @we-the-rebel-alliance/source-contract 0.3.0. Built by scripts/build.mjs; do not edit.
|
|
2
2
|
import {
|
|
3
|
+
ACTOR_KINDS,
|
|
4
|
+
ACTOR_ROLES,
|
|
5
|
+
ATTENDANCE_RESPONSES,
|
|
6
|
+
AUDIENCES,
|
|
7
|
+
AUTHOR_ROLES,
|
|
8
|
+
COMMITMENT_STATES,
|
|
3
9
|
CONTRACT1_CODES,
|
|
4
10
|
ERROR_ALIASES,
|
|
5
11
|
ERROR_CODES,
|
|
@@ -9,8 +15,10 @@ import {
|
|
|
9
15
|
EXTENSION_KIND,
|
|
10
16
|
EXTENSION_NAME,
|
|
11
17
|
EXTENSION_SEGMENT_MAX,
|
|
18
|
+
FACT_TYPES,
|
|
12
19
|
FIRST_RUN_HOURS,
|
|
13
20
|
GAP_REASONS,
|
|
21
|
+
IDENTITY_STRENGTHS,
|
|
14
22
|
MAX_BYTES,
|
|
15
23
|
MAX_PAGE_BYTES,
|
|
16
24
|
PAGE,
|
|
@@ -30,6 +38,7 @@ import {
|
|
|
30
38
|
eventProblems,
|
|
31
39
|
eventsListResult,
|
|
32
40
|
extensionNamespace,
|
|
41
|
+
factProblems,
|
|
33
42
|
fitPage,
|
|
34
43
|
isEventKind,
|
|
35
44
|
isEventKindIn,
|
|
@@ -49,14 +58,14 @@ import {
|
|
|
49
58
|
sinceTime,
|
|
50
59
|
sourceNamespace,
|
|
51
60
|
startTime
|
|
52
|
-
} from "./chunks/chunk-
|
|
61
|
+
} from "./chunks/chunk-LJL3EALP.js";
|
|
53
62
|
import {
|
|
54
63
|
decodeBoundCursor,
|
|
55
64
|
decodeCursor,
|
|
56
65
|
encodeBoundCursor,
|
|
57
66
|
encodeCursor
|
|
58
|
-
} from "./chunks/chunk-
|
|
59
|
-
import "./chunks/chunk-
|
|
67
|
+
} from "./chunks/chunk-NUBUQFLH.js";
|
|
68
|
+
import "./chunks/chunk-CUITXC5J.js";
|
|
60
69
|
|
|
61
70
|
// src/internal/events-conformance.ts
|
|
62
71
|
var describeError = (error) => error instanceof Error ? error.message.split("\n", 1)[0] : String(error);
|
|
@@ -205,6 +214,12 @@ async function assertEventsListConformance(list, fixtures) {
|
|
|
205
214
|
- ${problems.join("\n- ")}`);
|
|
206
215
|
}
|
|
207
216
|
export {
|
|
217
|
+
ACTOR_KINDS,
|
|
218
|
+
ACTOR_ROLES,
|
|
219
|
+
ATTENDANCE_RESPONSES,
|
|
220
|
+
AUDIENCES,
|
|
221
|
+
AUTHOR_ROLES,
|
|
222
|
+
COMMITMENT_STATES,
|
|
208
223
|
CONTRACT1_CODES,
|
|
209
224
|
ERROR_ALIASES,
|
|
210
225
|
ERROR_CODES,
|
|
@@ -214,8 +229,10 @@ export {
|
|
|
214
229
|
EXTENSION_KIND,
|
|
215
230
|
EXTENSION_NAME,
|
|
216
231
|
EXTENSION_SEGMENT_MAX,
|
|
232
|
+
FACT_TYPES,
|
|
217
233
|
FIRST_RUN_HOURS,
|
|
218
234
|
GAP_REASONS,
|
|
235
|
+
IDENTITY_STRENGTHS,
|
|
219
236
|
MAX_BYTES,
|
|
220
237
|
MAX_PAGE_BYTES,
|
|
221
238
|
PAGE,
|
|
@@ -239,6 +256,7 @@ export {
|
|
|
239
256
|
eventsListConformance,
|
|
240
257
|
eventsListResult,
|
|
241
258
|
extensionNamespace,
|
|
259
|
+
factProblems,
|
|
242
260
|
fitPage,
|
|
243
261
|
isEventKind,
|
|
244
262
|
isEventKindIn,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @we-the-rebel-alliance/source-contract 0.
|
|
1
|
+
// @we-the-rebel-alliance/source-contract 0.3.0. Built by scripts/build.mjs; do not edit.
|
|
2
2
|
import {
|
|
3
3
|
EXTENSION_OUTPUT,
|
|
4
4
|
IMAGE_DATA_URI_MAX,
|
|
@@ -8,9 +8,9 @@ import {
|
|
|
8
8
|
isExtensionOutput,
|
|
9
9
|
isOutputName,
|
|
10
10
|
outputValidator
|
|
11
|
-
} from "./chunks/chunk-
|
|
12
|
-
import "./chunks/chunk-
|
|
13
|
-
import "./chunks/chunk-
|
|
11
|
+
} from "./chunks/chunk-GDBKZBG7.js";
|
|
12
|
+
import "./chunks/chunk-6ZSJSJMV.js";
|
|
13
|
+
import "./chunks/chunk-CUITXC5J.js";
|
|
14
14
|
export {
|
|
15
15
|
EXTENSION_OUTPUT,
|
|
16
16
|
IMAGE_DATA_URI_MAX,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @we-the-rebel-alliance/source-contract 0.
|
|
1
|
+
// @we-the-rebel-alliance/source-contract 0.3.0. Built by scripts/build.mjs; do not edit.
|
|
2
2
|
import {
|
|
3
3
|
CLASSES,
|
|
4
4
|
LOCATION_HEADER,
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
toolsRpcId,
|
|
17
17
|
toolsRpcIdProblems,
|
|
18
18
|
upstreamText
|
|
19
|
-
} from "./chunks/chunk-
|
|
19
|
+
} from "./chunks/chunk-IGPRJ63D.js";
|
|
20
20
|
import {
|
|
21
21
|
evaluate
|
|
22
|
-
} from "./chunks/chunk-
|
|
23
|
-
import "./chunks/chunk-
|
|
22
|
+
} from "./chunks/chunk-EOS4LD6F.js";
|
|
23
|
+
import "./chunks/chunk-CUITXC5J.js";
|
|
24
24
|
export {
|
|
25
25
|
CLASSES,
|
|
26
26
|
LOCATION_HEADER,
|
package/src/views/contracts.js
CHANGED
|
@@ -655,7 +655,7 @@ const commitmentsOutput = {
|
|
|
655
655
|
items: {
|
|
656
656
|
type: "object",
|
|
657
657
|
additionalProperties: false,
|
|
658
|
-
required: ["id", "what", "owner", "state", "when", "overdue", "dueToday"],
|
|
658
|
+
required: ["id", "what", "owner", "state", "when", "overdue", "dueToday", "space", "revision"],
|
|
659
659
|
properties: {
|
|
660
660
|
id,
|
|
661
661
|
what: line(300),
|
|
@@ -670,6 +670,10 @@ const commitmentsOutput = {
|
|
|
670
670
|
dueToday: { type: "boolean" },
|
|
671
671
|
trigger: line(200),
|
|
672
672
|
project: line(80),
|
|
673
|
+
/** The space the item is in, as its acts take it (`commitment.done` and the rest). */
|
|
674
|
+
space: line(128),
|
|
675
|
+
/** The item's version, as its acts take it: a press names the one the person saw. */
|
|
676
|
+
revision: { type: "integer", minimum: 1 },
|
|
673
677
|
/** The day it was closed, as "Tue 3 Nov"; closed items only. */
|
|
674
678
|
closed: line(40),
|
|
675
679
|
},
|
package/src/views/rpc.js
CHANGED
|
@@ -418,6 +418,10 @@ export function createViewReads({ runtime, agents = async () => [], operations =
|
|
|
418
418
|
* The person's commitments, from their personal space's records wiki: open
|
|
419
419
|
* ones overdue first, or closed ones newest first. Only the caller's own
|
|
420
420
|
* space is read; a view can change nothing (closing one opens the agent).
|
|
421
|
+
*
|
|
422
|
+
* Each item carries the two fields every commitment act takes (`space` and
|
|
423
|
+
* `revision`), so a control acts on what the list answered without reading
|
|
424
|
+
* the item again (#97).
|
|
421
425
|
*/
|
|
422
426
|
async function commitmentsList(input) {
|
|
423
427
|
await available()
|
|
@@ -426,6 +430,8 @@ export function createViewReads({ runtime, agents = async () => [], operations =
|
|
|
426
430
|
const records = (await runtime.records.read(first.scope)).records
|
|
427
431
|
const zone = runtime.clock.zone
|
|
428
432
|
const today = dayIn(runtime.clock.now(), zone)
|
|
433
|
+
// The space this list read, as the acts take it, and its name for the row.
|
|
434
|
+
const here = clip(idOf(first.context?.space_id) || "", 128)
|
|
429
435
|
let items = filterItems(records.items, { state: state === "open" ? "open" : "all" }, zone)
|
|
430
436
|
if (state === "closed") {
|
|
431
437
|
items = items
|
|
@@ -447,6 +453,11 @@ export function createViewReads({ runtime, agents = async () => [], operations =
|
|
|
447
453
|
dueToday: item.state === "open" && day === today,
|
|
448
454
|
...(item.trigger ? { trigger: clip(item.trigger, 200) } : {}),
|
|
449
455
|
...(item.project ? { project: clip(item.project, 80) } : {}),
|
|
456
|
+
space: here,
|
|
457
|
+
// The record's own revision, which its acts require: the list and the
|
|
458
|
+
// act read the same row, so a press never names a version the store
|
|
459
|
+
// does not have (0.12.6 review).
|
|
460
|
+
revision: item.revision,
|
|
450
461
|
...(item.state !== "open" && (item.closed || item.updated) ? { closed: clip(formatDay(item.closed ?? item.updated), 40) } : {}),
|
|
451
462
|
}
|
|
452
463
|
}),
|
package/src/views/shape.js
CHANGED
|
@@ -101,13 +101,23 @@ export async function mapLimit(list, limit, work) {
|
|
|
101
101
|
return out
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* A where-it-came-from line for a record's `source` ({ event, turn, session,
|
|
106
|
+
* routine, record, url }), or "". A saved line's citation (#58 A14) is the one
|
|
107
|
+
* pair: `conversation <id> line <id>`, so a memory says which conversation and
|
|
108
|
+
* which line it was taken from.
|
|
109
|
+
*/
|
|
105
110
|
export function sourceLabel(source) {
|
|
106
111
|
if (!source || typeof source !== "object") return ""
|
|
107
112
|
for (const key of ["event", "turn", "session", "routine", "record"]) {
|
|
108
113
|
const ref = typeof source[key] === "string" ? source[key].trim() : ""
|
|
109
114
|
if (ref && /^[\w.:@/-]{1,120}$/.test(ref)) return `${key} ${ref}`
|
|
110
115
|
}
|
|
116
|
+
const conversation = typeof source.conversation === "string" ? source.conversation.trim() : ""
|
|
117
|
+
const line = typeof source.line === "string" ? source.line.trim() : ""
|
|
118
|
+
const named = (value) => Boolean(value) && /^[\w.:@/-]{1,120}$/.test(value)
|
|
119
|
+
if (named(conversation)) return named(line) ? `conversation ${conversation} line ${line}` : `conversation ${conversation}`
|
|
120
|
+
if (named(line)) return `line ${line}`
|
|
111
121
|
const url = typeof source.url === "string" ? source.url.trim() : ""
|
|
112
122
|
return /^https?:\/\/[^\s<>"']{1,190}$/.test(url) ? `url ${url}` : ""
|
|
113
123
|
}
|