agents-can-communicate 0.9.1 → 0.10.1
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/README.md +46 -44
- package/bin/acc-update-worker.mjs +2 -1
- package/bin/entrypoints/hook-output.mjs +2 -0
- package/docs/ARCHITECTURE.md +26 -2
- package/docs/CLI.md +11 -1
- package/docs/GETTING_STARTED.md +4 -3
- package/docs/UPGRADING.md +62 -3
- package/docs/WHY_ACC.md +32 -9
- package/docs/index.md +7 -5
- package/node_modules/@agents-can-communicate/adapter-antigravity/package.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-antigravity/plugin/plugin.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-claude-code/package.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-claude-code/src/adapter.mjs +3 -1
- package/node_modules/@agents-can-communicate/adapter-claude-code/src/hooks.mjs +12 -0
- package/node_modules/@agents-can-communicate/adapter-codex/package.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-codex/src/adapter.mjs +2 -1
- package/node_modules/@agents-can-communicate/adapter-codex/src/hooks.mjs +11 -0
- package/node_modules/@agents-can-communicate/adapter-gemini-cli/extension/gemini-extension.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-gemini-cli/package.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-grok/package.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-kimi/package.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-sdk/package.json +1 -1
- package/node_modules/@agents-can-communicate/adapter-sdk/src/capabilities.mjs +6 -0
- package/node_modules/@agents-can-communicate/cli/package.json +1 -1
- package/node_modules/@agents-can-communicate/cli/src/args.mjs +4 -1
- package/node_modules/@agents-can-communicate/cli/src/doctor-command.mjs +14 -0
- package/node_modules/@agents-can-communicate/cli/src/help.mjs +2 -0
- package/node_modules/@agents-can-communicate/cli/src/main.mjs +12 -3
- package/node_modules/@agents-can-communicate/cli/src/managed-runtime/activation.mjs +97 -10
- package/node_modules/@agents-can-communicate/cli/src/managed-runtime/launchers.mjs +1 -1
- package/node_modules/@agents-can-communicate/cli/src/managed-runtime/portable-fs.mjs +41 -20
- package/node_modules/@agents-can-communicate/cli/src/managed-runtime/refresh.mjs +4 -0
- package/node_modules/@agents-can-communicate/cli/src/managed-runtime/schedule.mjs +17 -1
- package/node_modules/@agents-can-communicate/cli/src/managed-runtime/store-upgrade.mjs +105 -0
- package/node_modules/@agents-can-communicate/cli/src/managed-runtime/worker.mjs +5 -0
- package/node_modules/@agents-can-communicate/cli/src/store-migration-command.mjs +39 -0
- package/node_modules/@agents-can-communicate/core/package.json +1 -1
- package/node_modules/@agents-can-communicate/core/src/conversations.mjs +21 -52
- package/node_modules/@agents-can-communicate/core/src/decision-changes.mjs +16 -11
- package/node_modules/@agents-can-communicate/core/src/inbox.mjs +12 -4
- package/node_modules/@agents-can-communicate/core/src/message-retry.mjs +43 -0
- package/node_modules/@agents-can-communicate/core/src/ports.mjs +12 -1
- package/node_modules/@agents-can-communicate/core/src/receipts.mjs +20 -6
- package/node_modules/@agents-can-communicate/delivery-router/package.json +1 -1
- package/node_modules/@agents-can-communicate/hook-runner/package.json +1 -1
- package/node_modules/@agents-can-communicate/hook-runner/src/runner.mjs +23 -3
- package/node_modules/@agents-can-communicate/installer/package.json +1 -1
- package/node_modules/@agents-can-communicate/mcp-server/package.json +1 -1
- package/node_modules/@agents-can-communicate/protocol/package.json +1 -1
- package/node_modules/@agents-can-communicate/protocol/src/index.mjs +1 -0
- package/node_modules/@agents-can-communicate/protocol/src/transaction-indexes.mjs +22 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/package.json +1 -1
- package/node_modules/@agents-can-communicate/storage-filesystem/src/identity.mjs +22 -10
- package/node_modules/@agents-can-communicate/storage-filesystem/src/index-cache.mjs +144 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/index-io.mjs +65 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/index-pages.mjs +85 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/index-reclaim-progress.mjs +35 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/index-reclaim.mjs +142 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/index-tree.mjs +142 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/index.mjs +1 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/journal.mjs +2 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/portable-fs.mjs +41 -20
- package/node_modules/@agents-can-communicate/storage-filesystem/src/prune-durability.mjs +29 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/reclaim.mjs +13 -3
- package/node_modules/@agents-can-communicate/storage-filesystem/src/recovery.mjs +9 -3
- package/node_modules/@agents-can-communicate/storage-filesystem/src/session-read.mjs +6 -4
- package/node_modules/@agents-can-communicate/storage-filesystem/src/state-reads.mjs +43 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/store-migration.mjs +56 -0
- package/node_modules/@agents-can-communicate/storage-filesystem/src/store.mjs +61 -110
- package/node_modules/@agents-can-communicate/storage-filesystem/src/transaction-view.mjs +131 -0
- package/package.json +5 -4
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { AccError, EXIT, assertPortableId, validateRecord }
|
|
2
|
+
from "@agents-can-communicate/protocol";
|
|
3
|
+
|
|
4
|
+
export function transactionKinds(kinds, exactKinds = []) {
|
|
5
|
+
const wanted = kinds === undefined ? null : new Set(kinds);
|
|
6
|
+
if (!Array.isArray(exactKinds) || exactKinds.some(kind => wanted === null || !wanted.has(kind))) {
|
|
7
|
+
throw new AccError(EXIT.DATA, "exactKinds must be a subset of explicit transaction kinds",
|
|
8
|
+
{ kinds, exactKinds });
|
|
9
|
+
}
|
|
10
|
+
return { wanted, exact: new Set(exactKinds),
|
|
11
|
+
eager: wanted === null ? null : new Set([...wanted].filter(kind => !exactKinds.includes(kind))) };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createTransactionView({ kinds, exactKinds = [], loaded, loadEnvelope,
|
|
15
|
+
ids, appendEvent, lookupIndex }) {
|
|
16
|
+
const { wanted, exact } = transactionKinds(kinds, exactKinds);
|
|
17
|
+
const staged = new Map(), pending = new Map(), operations = new Set();
|
|
18
|
+
let accepting = true;
|
|
19
|
+
const declared = kind => {
|
|
20
|
+
if (wanted !== null && !wanted.has(kind)) {
|
|
21
|
+
throw new AccError(EXIT.DATA, `this transaction did not declare ${kind}, so it was never read`,
|
|
22
|
+
{ kind, declared: [...wanted] });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const loadedId = (kind, id) => {
|
|
26
|
+
declared(kind);
|
|
27
|
+
if (exact.has(kind) && !loaded.has(`${kind}:${id}`)) {
|
|
28
|
+
throw new AccError(EXIT.DATA, "an exact transaction record must be loaded before access", { kind, id });
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const active = () => {
|
|
32
|
+
if (!accepting) throw new AccError(EXIT.DATA, "transaction async reads are closed");
|
|
33
|
+
};
|
|
34
|
+
const entryFor = key => {
|
|
35
|
+
const entry = staged.get(key) ?? loaded.get(key) ?? null;
|
|
36
|
+
return entry?.removed === true ? null : entry;
|
|
37
|
+
};
|
|
38
|
+
const track = operation => {
|
|
39
|
+
operations.add(operation);
|
|
40
|
+
operation.catch(() => {}); // finish() propagates a rejected unawaited read under the lock.
|
|
41
|
+
return operation;
|
|
42
|
+
};
|
|
43
|
+
const read = async (kind, id) => {
|
|
44
|
+
declared(kind);
|
|
45
|
+
assertPortableId(kind, "record kind");
|
|
46
|
+
assertPortableId(id, "record id");
|
|
47
|
+
const key = `${kind}:${id}`;
|
|
48
|
+
if (staged.has(key) || loaded.has(key)) return entryFor(key);
|
|
49
|
+
if (!exact.has(kind)) return null;
|
|
50
|
+
if (!pending.has(key)) pending.set(key, track(Promise.resolve().then(() => loadEnvelope(kind, id))));
|
|
51
|
+
return pending.get(key);
|
|
52
|
+
};
|
|
53
|
+
const tx = Object.freeze({
|
|
54
|
+
async load(kind, id) {
|
|
55
|
+
active();
|
|
56
|
+
const key = `${kind}:${id}`;
|
|
57
|
+
if (!loaded.has(key)) {
|
|
58
|
+
const envelope = await read(kind, id);
|
|
59
|
+
loaded.set(key, envelope);
|
|
60
|
+
}
|
|
61
|
+
else declared(kind);
|
|
62
|
+
return entryFor(key)?.record ?? null;
|
|
63
|
+
},
|
|
64
|
+
async lookup(index, tuple) {
|
|
65
|
+
active();
|
|
66
|
+
if (typeof lookupIndex !== "function") {
|
|
67
|
+
throw new AccError(EXIT.USAGE, "the transaction store does not support indexed lookup");
|
|
68
|
+
}
|
|
69
|
+
return track(Promise.resolve().then(() => lookupIndex(index, tuple, { declared, loaded, staged, read })));
|
|
70
|
+
},
|
|
71
|
+
get(kind, id) {
|
|
72
|
+
loadedId(kind, id);
|
|
73
|
+
return entryFor(`${kind}:${id}`)?.record ?? null;
|
|
74
|
+
},
|
|
75
|
+
generationOf(kind, id) {
|
|
76
|
+
loadedId(kind, id);
|
|
77
|
+
return entryFor(`${kind}:${id}`)?.generation ?? null;
|
|
78
|
+
},
|
|
79
|
+
list(kind, predicate = () => true) {
|
|
80
|
+
declared(kind);
|
|
81
|
+
if (exact.has(kind)) throw new AccError(EXIT.DATA, "an exact transaction kind cannot be listed", { kind });
|
|
82
|
+
const merged = new Map();
|
|
83
|
+
for (const source of [loaded, staged]) {
|
|
84
|
+
for (const [key, entry] of source) if (entry?.kind === kind) merged.set(key, entry);
|
|
85
|
+
}
|
|
86
|
+
return [...merged.values()].filter(entry => entry.removed !== true)
|
|
87
|
+
.map(entry => entry.record).filter(predicate);
|
|
88
|
+
},
|
|
89
|
+
put(kind, id, record, expectedGeneration = null) {
|
|
90
|
+
loadedId(kind, id);
|
|
91
|
+
const key = `${kind}:${id}`, actual = entryFor(key)?.generation ?? null;
|
|
92
|
+
if (actual !== expectedGeneration) {
|
|
93
|
+
throw new AccError(EXIT.CONFLICT, `${kind} ${id} changed under this transaction`,
|
|
94
|
+
{ kind, id, expectedGeneration, actualGeneration: actual });
|
|
95
|
+
}
|
|
96
|
+
validateRecord(kind, record);
|
|
97
|
+
const generation = ids.next("generation");
|
|
98
|
+
staged.set(key, { kind, id, record, generation });
|
|
99
|
+
return generation;
|
|
100
|
+
},
|
|
101
|
+
remove(kind, id, expectedGeneration = null) {
|
|
102
|
+
loadedId(kind, id);
|
|
103
|
+
const key = `${kind}:${id}`, actual = entryFor(key)?.generation ?? null;
|
|
104
|
+
if (actual !== expectedGeneration) {
|
|
105
|
+
throw new AccError(EXIT.CONFLICT, `${kind} ${id} changed under this transaction`,
|
|
106
|
+
{ kind, id, expectedGeneration, actualGeneration: actual });
|
|
107
|
+
}
|
|
108
|
+
const persisted = loaded.get(key);
|
|
109
|
+
if (persisted == null) staged.delete(key);
|
|
110
|
+
else staged.set(key, { kind, id, generation: persisted.generation, removed: true });
|
|
111
|
+
},
|
|
112
|
+
append: appendEvent,
|
|
113
|
+
});
|
|
114
|
+
async function finish() {
|
|
115
|
+
accepting = false;
|
|
116
|
+
const drained = new Set();
|
|
117
|
+
let failed = false, reason;
|
|
118
|
+
// A rejection cannot release the writer while sibling reads still run.
|
|
119
|
+
// In-flight lookups may register further primary reads while we drain.
|
|
120
|
+
for (;;) {
|
|
121
|
+
const batch = [...operations].filter(operation => !drained.has(operation));
|
|
122
|
+
if (batch.length === 0) break;
|
|
123
|
+
for (const operation of batch) drained.add(operation);
|
|
124
|
+
for (const result of await Promise.allSettled(batch)) {
|
|
125
|
+
if (result.status === "rejected" && !failed) { failed = true; reason = result.reason; }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (failed) throw reason;
|
|
129
|
+
}
|
|
130
|
+
return { tx, staged, finish };
|
|
131
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agents-can-communicate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"accManagedUpdateProtocol": 2,
|
|
5
|
-
"accStoreVersion":
|
|
5
|
+
"accStoreVersion": 7,
|
|
6
6
|
"type": "module",
|
|
7
|
-
"description": "Local-first
|
|
7
|
+
"description": "Local-first messaging between AI coding sessions in different vendors' clients, such as Claude Code and Codex.",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"agents",
|
|
10
10
|
"coordination",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"hooks",
|
|
15
15
|
"codex",
|
|
16
16
|
"claude-code",
|
|
17
|
-
"
|
|
17
|
+
"antigravity",
|
|
18
|
+
"cross-vendor",
|
|
18
19
|
"kimi",
|
|
19
20
|
"grok",
|
|
20
21
|
"multi-agent",
|