@joe-broadhead/opencode-mem 0.9.14 → 0.11.2
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 +1805 -0
- package/README.md +14 -7
- package/SECURITY.md +3 -1
- package/docs/agent-instructions.md +1 -1
- package/docs/agent-protocol.md +7 -7
- package/docs/permissions.md +16 -0
- package/package.json +7688 -339
- package/shared/page-paths.js +44 -0
- package/skills/mem.pages/SKILL.md +3 -1
- package/skills/mem.usage/SKILL.md +15 -15
- package/src/action-grant-keys.js +159 -0
- package/src/action-grant.js +439 -0
- package/src/actions.js +1690 -0
- package/src/backend/records.js +25 -2
- package/src/backend/v3.js +76 -22
- package/src/call-shapes.js +17 -16
- package/src/collector-lock.js +533 -62
- package/src/collector-service.js +153 -26
- package/src/collector.js +623 -30
- package/src/config.js +79 -6
- package/src/connect.js +106 -8
- package/src/credentials.js +123 -25
- package/src/events.js +174 -3
- package/src/forget-turn.js +141 -0
- package/src/host-refusal.js +78 -0
- package/src/index.js +209 -22
- package/src/jobs/host.js +557 -0
- package/src/ops/codes.js +110 -0
- package/src/ops/copy-lineage.js +42 -0
- package/src/ops/index.js +28 -0
- package/src/ops/space-ops.js +1936 -0
- package/src/outlinks.js +103 -0
- package/src/p2-reservation.js +151 -0
- package/src/permissions.js +30 -0
- package/src/plugins/descriptor.js +62 -0
- package/src/plugins/discovery.js +318 -0
- package/src/plugins/grants.js +178 -0
- package/src/plugins/locate.js +319 -0
- package/src/plugins/manifest.js +1162 -0
- package/src/plugins/source-contract/index.js +34 -0
- package/src/plugins/source-contract/policy.js +102 -0
- package/src/plugins/source-contract/vendor/PROVENANCE.json +17 -0
- package/src/plugins/source-contract/vendor/RELEASE-SHA256SUMS +3 -0
- package/src/plugins/source-contract/vendor/RELEASE.json +17 -0
- package/src/plugins/source-contract/vendor/SHA256SUMS +41 -0
- package/src/plugins/source-contract/vendor/THIRD-PARTY-NOTICES.md +35 -0
- package/src/plugins/source-contract/vendor/broker-client.js +93 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-3M5PAKSS.js +84 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-4ERCA4TK.js +185 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-6HDIB2SA.js +183 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-ELPJD3ND.js +10 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-HLVAKAYG.js +10 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-I2RXJJJM.js +81 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-KWEWSZ4V.js +505 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-KYWBTAF4.js +182 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-Q3RQA5J2.js +249 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-RRUAIQ4I.js +156 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-RYNKNCPP.js +165 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-W5SHR7DQ.js +9477 -0
- package/src/plugins/source-contract/vendor/chunks/chunk-ZUKF7P6U.js +653 -0
- package/src/plugins/source-contract/vendor/cursor.js +26 -0
- package/src/plugins/source-contract/vendor/descriptor.js +34 -0
- package/src/plugins/source-contract/vendor/events.js +257 -0
- package/src/plugins/source-contract/vendor/index.js +10 -0
- package/src/plugins/source-contract/vendor/params.js +22 -0
- package/src/plugins/source-contract/vendor/permission.js +28 -0
- package/src/plugins/source-contract/vendor/pick.js +22 -0
- package/src/plugins/source-contract/vendor/read.js +29 -0
- package/src/plugins/source-contract/vendor/registry.js +23 -0
- package/src/plugins/source-contract/vendor/schema.js +17 -0
- package/src/plugins/source-contract/vendor/schemas/output.agenda.json +96 -0
- package/src/plugins/source-contract/vendor/schemas/output.countdown.json +28 -0
- package/src/plugins/source-contract/vendor/schemas/output.image.json +28 -0
- package/src/plugins/source-contract/vendor/schemas/output.inbox.json +84 -0
- package/src/plugins/source-contract/vendor/schemas/output.links.json +46 -0
- package/src/plugins/source-contract/vendor/schemas/output.list.json +57 -0
- package/src/plugins/source-contract/vendor/schemas/output.metric.json +61 -0
- package/src/plugins/source-contract/vendor/schemas/output.note.json +14 -0
- package/src/plugins/source-contract/vendor/schemas/output.progress.json +50 -0
- package/src/plugins/source-contract/vendor/schemas/output.record.json +38 -0
- package/src/plugins/source-contract/vendor/schemas/output.table.json +61 -0
- package/src/plugins/source-contract/vendor/schemas/output.thread.json +62 -0
- package/src/plugins/source-contract/vendor/schemas/sources.json +819 -0
- package/src/plugins/source-contract/vendor/schemas.js +19 -0
- package/src/plugins/source-contract/vendor/tools-rpc.js +42 -0
- package/src/plugins/verify.js +56 -0
- package/src/protocol.js +11 -6
- package/src/recall.js +92 -5
- package/src/records.js +61 -2
- package/src/requests.js +216 -0
- package/src/runtime.js +89 -7
- package/src/setup-time.js +68 -0
- package/src/skills.js +230 -8
- package/src/source-ids.js +25 -0
- package/src/sources/declaration.js +365 -0
- package/src/sources/reads.js +772 -0
- package/src/sources/rpc.js +151 -0
- package/src/sources.js +389 -92
- package/src/spaces.js +283 -11
- package/src/spool.js +61 -4
- package/src/stated.js +10 -5
- package/src/storable.js +139 -0
- package/src/tools/commitments.js +37 -4
- package/src/tools/held-write.js +31 -12
- package/src/tools/index.js +27 -0
- package/src/tools/ingest.js +27 -2
- package/src/tools/memory.js +30 -7
- package/src/tools/page.js +95 -9
- package/src/tools/recall.js +208 -4
- package/src/tools/share.js +42 -3
- package/src/tools/shared.js +44 -4
- package/src/tools/space-lifecycle.js +278 -0
- package/src/tools/spaces.js +373 -29
- package/src/tools/status.js +9 -2
- package/src/tools/wiki.js +34 -4
- package/src/util.js +110 -6
- package/src/vendor/source-contract/README.md +24 -0
- package/src/vendor/source-contract/THIRD-PARTY-NOTICES.md +35 -0
- package/src/vendor/source-contract/VENDOR.json +81 -0
- package/src/vendor/source-contract/chunks/chunk-3M5PAKSS.js +84 -0
- package/src/vendor/source-contract/chunks/chunk-6HDIB2SA.js +183 -0
- package/src/vendor/source-contract/chunks/chunk-HLVAKAYG.js +10 -0
- package/src/vendor/source-contract/chunks/chunk-I2RXJJJM.js +81 -0
- package/src/vendor/source-contract/chunks/chunk-KWEWSZ4V.js +505 -0
- package/src/vendor/source-contract/chunks/chunk-W5SHR7DQ.js +9477 -0
- package/src/vendor/source-contract/chunks/chunk-ZUKF7P6U.js +653 -0
- package/src/vendor/source-contract/cursor.js +26 -0
- package/src/vendor/source-contract/events.js +257 -0
- package/src/vendor/source-contract/registry.js +23 -0
- package/src/vendor/source-contract/tools-rpc.js +42 -0
- package/src/views/access-reads.js +256 -0
- package/src/views/communities.js +77 -0
- package/src/views/contracts.js +930 -21
- package/src/views/inbox-bytes.js +103 -0
- package/src/views/profile.js +31 -0
- package/src/views/records-reads.js +355 -38
- package/src/views/rpc.js +118 -8
- package/src/views/shape.js +8 -5
- package/views/pages.html +2 -2
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// @we-the-rebel-alliance/source-contract 0.1.0. Built by scripts/build.mjs; do not edit.
|
|
2
|
+
|
|
3
|
+
// src/params.ts
|
|
4
|
+
var MAX_RELATIVE_DAYS = 366;
|
|
5
|
+
var WINDOWS = ["today", "yesterday", "tomorrow"];
|
|
6
|
+
var ME = "$me";
|
|
7
|
+
var RELATIVE = /^(?:now|([+-])(\d{1,6})([mhdw]))$/;
|
|
8
|
+
var ABSOLUTE = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2}))?$/;
|
|
9
|
+
var MINUTE = 6e4;
|
|
10
|
+
var DAY_MINUTES = 24 * 60;
|
|
11
|
+
var plain = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
+
var epoch = (now) => now instanceof Date ? now.getTime() : now;
|
|
13
|
+
function isTimeZone(timeZone) {
|
|
14
|
+
if (typeof timeZone !== "string" || timeZone.length === 0) return false;
|
|
15
|
+
try {
|
|
16
|
+
new Intl.DateTimeFormat("en-GB", { timeZone });
|
|
17
|
+
return true;
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var formatters = /* @__PURE__ */ new Map();
|
|
23
|
+
function formatter(timeZone) {
|
|
24
|
+
let found = formatters.get(timeZone);
|
|
25
|
+
if (!found) {
|
|
26
|
+
found = new Intl.DateTimeFormat("en-US", {
|
|
27
|
+
timeZone,
|
|
28
|
+
hourCycle: "h23",
|
|
29
|
+
year: "numeric",
|
|
30
|
+
month: "2-digit",
|
|
31
|
+
day: "2-digit",
|
|
32
|
+
hour: "2-digit",
|
|
33
|
+
minute: "2-digit",
|
|
34
|
+
second: "2-digit"
|
|
35
|
+
});
|
|
36
|
+
formatters.set(timeZone, found);
|
|
37
|
+
}
|
|
38
|
+
return found;
|
|
39
|
+
}
|
|
40
|
+
function wall(instant, timeZone) {
|
|
41
|
+
const parts = Object.fromEntries(formatter(timeZone).formatToParts(new Date(instant)).map((part) => [part.type, part.value]));
|
|
42
|
+
return { year: Number(parts.year), month: Number(parts.month), day: Number(parts.day), hour: Number(parts.hour), minute: Number(parts.minute) };
|
|
43
|
+
}
|
|
44
|
+
function offset(instant, timeZone) {
|
|
45
|
+
const at = wall(instant, timeZone);
|
|
46
|
+
return Date.UTC(at.year, at.month - 1, at.day, at.hour, at.minute) - Math.floor(instant / MINUTE) * MINUTE;
|
|
47
|
+
}
|
|
48
|
+
function instantOf(at, timeZone) {
|
|
49
|
+
const guess = Date.UTC(at.year, at.month - 1, at.day, at.hour, at.minute);
|
|
50
|
+
const before = guess - offset(guess - 12 * 60 * MINUTE, timeZone);
|
|
51
|
+
const after = guess - offset(guess + 12 * 60 * MINUTE, timeZone);
|
|
52
|
+
const same = (instant) => {
|
|
53
|
+
const found = wall(instant, timeZone);
|
|
54
|
+
return found.year === at.year && found.month === at.month && found.day === at.day && found.hour === at.hour && found.minute === at.minute;
|
|
55
|
+
};
|
|
56
|
+
const valid = [before, after].filter(same);
|
|
57
|
+
return valid.length > 0 ? Math.min(...valid) : before;
|
|
58
|
+
}
|
|
59
|
+
var iso = (instant) => new Date(instant).toISOString();
|
|
60
|
+
function resolveRelativeTime(value, context) {
|
|
61
|
+
const match = RELATIVE.exec(value);
|
|
62
|
+
if (!match) return void 0;
|
|
63
|
+
const now = Math.floor(epoch(context.now) / MINUTE) * MINUTE;
|
|
64
|
+
if (value === "now") return iso(now);
|
|
65
|
+
const amount = Number(match[2]) * (match[1] === "-" ? -1 : 1);
|
|
66
|
+
const unit = match[3];
|
|
67
|
+
const minutes = Math.abs(amount) * { m: 1, h: 60, d: DAY_MINUTES, w: 7 * DAY_MINUTES }[unit];
|
|
68
|
+
if (minutes > MAX_RELATIVE_DAYS * DAY_MINUTES) return void 0;
|
|
69
|
+
if (unit === "m" || unit === "h") return iso(now + amount * (unit === "m" ? 1 : 60) * MINUTE);
|
|
70
|
+
const at = wall(now, context.timeZone);
|
|
71
|
+
const days = amount * (unit === "w" ? 7 : 1);
|
|
72
|
+
const shifted = new Date(Date.UTC(at.year, at.month - 1, at.day + days));
|
|
73
|
+
return iso(instantOf({ ...at, year: shifted.getUTCFullYear(), month: shifted.getUTCMonth() + 1, day: shifted.getUTCDate() }, context.timeZone));
|
|
74
|
+
}
|
|
75
|
+
function resolveWindow(name, context) {
|
|
76
|
+
const at = wall(epoch(context.now), context.timeZone);
|
|
77
|
+
const start = { yesterday: -1, today: 0, tomorrow: 1 }[name];
|
|
78
|
+
const midnight = (days) => {
|
|
79
|
+
const date = new Date(Date.UTC(at.year, at.month - 1, at.day + days));
|
|
80
|
+
return iso(instantOf({ year: date.getUTCFullYear(), month: date.getUTCMonth() + 1, day: date.getUTCDate(), hour: 0, minute: 0 }, context.timeZone));
|
|
81
|
+
};
|
|
82
|
+
return { since: midnight(start), until: midnight(start + 1) };
|
|
83
|
+
}
|
|
84
|
+
function time(value, where, context) {
|
|
85
|
+
if (typeof value === "string") {
|
|
86
|
+
if (ABSOLUTE.test(value) && Number.isFinite(Date.parse(value.length === 10 ? `${value}T00:00:00Z` : value))) return { ok: true, value };
|
|
87
|
+
const resolved = resolveRelativeTime(value, context);
|
|
88
|
+
if (resolved !== void 0) return { ok: true, value: resolved };
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
ok: false,
|
|
92
|
+
problems: [`${where} must be "now", a relative time such as "-7d" or "+2h" (at most ${MAX_RELATIVE_DAYS} days), or an ISO date-time with Z or an offset`]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function relative(value, where, context) {
|
|
96
|
+
if (typeof value === "string" && WINDOWS.includes(value)) return { ok: true, value: resolveWindow(value, context) };
|
|
97
|
+
if (plain(value)) {
|
|
98
|
+
const keys = Object.keys(value);
|
|
99
|
+
const extra = keys.filter((key) => key !== "since" && key !== "until");
|
|
100
|
+
if (extra.length > 0 || keys.length === 0) return { ok: false, problems: [`${where} must be a window: "today", "yesterday", "tomorrow", or { since, until }`] };
|
|
101
|
+
const resolved = {};
|
|
102
|
+
const problems = [];
|
|
103
|
+
for (const key of keys) {
|
|
104
|
+
const checked = time(value[key], `${where}.${key}`, context);
|
|
105
|
+
if (checked.ok) resolved[key] = checked.value;
|
|
106
|
+
else problems.push(...checked.problems);
|
|
107
|
+
}
|
|
108
|
+
if (problems.length === 0 && resolved.since !== void 0 && resolved.until !== void 0 && Date.parse(resolved.since) > Date.parse(resolved.until)) {
|
|
109
|
+
problems.push(`${where}.since is after ${where}.until`);
|
|
110
|
+
}
|
|
111
|
+
return problems.length === 0 ? { ok: true, value: resolved } : { ok: false, problems };
|
|
112
|
+
}
|
|
113
|
+
return time(value, where, context);
|
|
114
|
+
}
|
|
115
|
+
function contextProblems(context) {
|
|
116
|
+
const problems = [];
|
|
117
|
+
if (!isTimeZone(context.timeZone)) problems.push(`the time zone "${String(context.timeZone)}" is not an IANA time zone this runtime knows`);
|
|
118
|
+
if (!Number.isFinite(epoch(context.now))) problems.push("now is not a time");
|
|
119
|
+
return problems;
|
|
120
|
+
}
|
|
121
|
+
function resolveParams(declared, given, context) {
|
|
122
|
+
if (given === void 0) return { ok: true, value: {} };
|
|
123
|
+
if (!plain(given)) return { ok: false, problems: ["params must be an object"] };
|
|
124
|
+
const problems = contextProblems(context);
|
|
125
|
+
if (problems.length > 0) return { ok: false, problems };
|
|
126
|
+
const resolved = {};
|
|
127
|
+
for (const [key, value] of Object.entries(given)) {
|
|
128
|
+
const spec = declared && Object.hasOwn(declared, key) ? declared[key] : void 0;
|
|
129
|
+
const where = `params.${key}`;
|
|
130
|
+
if (spec === void 0) {
|
|
131
|
+
problems.push(`${where} is not a param this source declares`);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (value === ME) {
|
|
135
|
+
if (spec.me !== true) problems.push(`${where} may not be ${ME}: the source does not declare it`);
|
|
136
|
+
else if (typeof context.me !== "string" || context.me.length === 0) problems.push(`${where} is ${ME}, and the signed-in account is not known: probe the source first`);
|
|
137
|
+
else resolved[key] = context.me;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (spec.relative === true) {
|
|
141
|
+
const checked = relative(value, where, context);
|
|
142
|
+
if (checked.ok) resolved[key] = checked.value;
|
|
143
|
+
else problems.push(...checked.problems);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
resolved[key] = value;
|
|
147
|
+
}
|
|
148
|
+
return problems.length === 0 ? { ok: true, value: resolved } : { ok: false, problems };
|
|
149
|
+
}
|
|
150
|
+
function resolveSince(since, context) {
|
|
151
|
+
const problems = contextProblems(context);
|
|
152
|
+
if (problems.length > 0) return { ok: false, problems };
|
|
153
|
+
return time(since, "since", context);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export {
|
|
157
|
+
MAX_RELATIVE_DAYS,
|
|
158
|
+
WINDOWS,
|
|
159
|
+
ME,
|
|
160
|
+
isTimeZone,
|
|
161
|
+
resolveRelativeTime,
|
|
162
|
+
resolveWindow,
|
|
163
|
+
resolveParams,
|
|
164
|
+
resolveSince
|
|
165
|
+
};
|