superagent-skill 0.0.0-stage → 0.1.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.
package/lib/index.mjs ADDED
@@ -0,0 +1,70 @@
1
+ import { A as reached, C as USER_ERRORS, D as latestAssignment, E as isoTime, F as ticketOutcome, I as waitsForPerson, M as runningAssignment, N as settled, O as latestReport, P as threadKey, S as key, T as followupOwners, _ as REASONS, a as readSettings, b as canRetry, c as AGENT_NAMES, d as REPORT_FILE, f as readReport, g as Engine, h as readState, i as parseYaml, j as readUntil, k as liveTicket, l as installed, m as FileRepositories, n as SettingsSchema, o as stringifyYaml, p as reportInstructions, r as defaultSettings, s as writeSettings, t as SETTINGS_FILE, u as runnerFor, v as reasonText, w as UserError, x as ticketStage, y as said } from "./settings-BewLFAqT.mjs";
2
+ // src/core/memory.ts
3
+ /** In-memory repository implementation for testing and ephemeral engine instances. */
4
+ const clone = (value) => structuredClone(value);
5
+ /**
6
+ * In-memory implementation of the Repositories port backed by cloned Map entries so caller mutations do not affect stored state.
7
+ * Provides snapshot-based atomic rollback and matches the ordering semantics of the SQLite store for Engine tests.
8
+ */
9
+ var MemoryRepositories = class {
10
+ triggerRows = /* @__PURE__ */ new Map();
11
+ dispositions = /* @__PURE__ */ new Map();
12
+ threadRows = /* @__PURE__ */ new Map();
13
+ ticketRows = /* @__PURE__ */ new Map();
14
+ decisionRows = /* @__PURE__ */ new Map();
15
+ atomic(work) {
16
+ const maps = [
17
+ this.triggerRows,
18
+ this.dispositions,
19
+ this.threadRows,
20
+ this.ticketRows,
21
+ this.decisionRows
22
+ ];
23
+ const snapshot = maps.map((map) => new Map(map));
24
+ try {
25
+ return work();
26
+ } catch (error) {
27
+ maps.forEach((map, index) => {
28
+ map.clear();
29
+ for (const [id, value] of snapshot[index]) map.set(id, value);
30
+ });
31
+ throw error;
32
+ }
33
+ }
34
+ triggers = {
35
+ get: (id) => clone(this.triggerRows.get(id)),
36
+ save: (trigger) => {
37
+ this.triggerRows.set(trigger.id, clone(trigger));
38
+ },
39
+ disposition: (id) => clone(this.dispositions.get(id)),
40
+ saveDisposition: (id, value) => {
41
+ this.dispositions.set(id, clone(value));
42
+ }
43
+ };
44
+ threads = {
45
+ get: (key) => clone(this.threadRows.get(key)),
46
+ save: (thread) => {
47
+ this.threadRows.set(thread.key, clone(thread));
48
+ },
49
+ list: () => [...this.threadRows.values()].map(clone),
50
+ active: () => this.threads.list().filter((thread) => thread.pending.length > 0 || thread.evaluating !== void 0)
51
+ };
52
+ tickets = {
53
+ get: (id) => clone(this.ticketRows.get(id)),
54
+ save: (ticket) => {
55
+ this.ticketRows.set(ticket.id, clone(ticket));
56
+ },
57
+ /** Newest first, matching the SQLite Store's order. */
58
+ list: () => [...this.ticketRows.values()].reverse().map(clone),
59
+ open: () => this.tickets.list().filter((ticket) => !ticket.ended),
60
+ active: () => this.tickets.list().filter((ticket) => ticket.undelivered.length > 0 || ["pending", "running"].includes(latestAssignment(ticket)?.state ?? ""))
61
+ };
62
+ decisions = {
63
+ get: (id) => clone(this.decisionRows.get(id)),
64
+ save: (decision) => {
65
+ this.decisionRows.set(decision.id, clone(decision));
66
+ },
67
+ byThread: (key) => [...this.decisionRows.values()].filter((decision) => decision.threadKey === key).map(clone)
68
+ };
69
+ };
70
+ export { AGENT_NAMES, Engine, FileRepositories, MemoryRepositories, REASONS, REPORT_FILE, SETTINGS_FILE, SettingsSchema, USER_ERRORS, UserError, canRetry, defaultSettings, followupOwners, installed, isoTime, key, latestAssignment, latestReport, liveTicket, parseYaml, reached, readReport, readSettings, readState, readUntil, reasonText, reportInstructions, runnerFor, runningAssignment, said, settled, stringifyYaml, threadKey, ticketOutcome, ticketStage, waitsForPerson, writeSettings };