@inixiative/archive 0.4.0 → 0.5.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/README.md +2 -2
- package/package.json +2 -2
- package/src/client.ts +3 -3
- package/src/config.ts +0 -1
- package/src/local.ts +3 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Archive
|
|
2
2
|
|
|
3
|
-
MIT-licensed, local-first session storage for Claude Code, Codex and Foundry. Run it independently or connect through Foundry and Kingdom
|
|
3
|
+
MIT-licensed, local-first session storage for Claude Code, Codex and Foundry. Run it independently or connect through Foundry and Kingdom.
|
|
4
4
|
|
|
5
5
|
## What runs today
|
|
6
6
|
|
|
@@ -82,7 +82,7 @@ Docker Compose is the alternative for the server: `docker compose up -d` bind-mo
|
|
|
82
82
|
|
|
83
83
|
## Connect through Kingdom
|
|
84
84
|
|
|
85
|
-
Pair a runtime with Kingdom (Foundry: Settings → Kingdom) and expose its `
|
|
85
|
+
Pair a runtime with Kingdom (Foundry: Settings → Kingdom) and expose its `kingdom_runtime_` credential in an environment variable, then either let Kingdom store the archives:
|
|
86
86
|
|
|
87
87
|
```sh
|
|
88
88
|
bun run archive connect --kind kingdom --url https://your-kingdom.example --project-id inixiative --token-env KINGDOM_ARCHIVE_TOKEN
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inixiative/archive",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@biomejs/biome": "2.5.2",
|
|
39
|
-
"@inixiative/config": "^0.5.
|
|
39
|
+
"@inixiative/config": "^0.5.38",
|
|
40
40
|
"@types/bun": "1.4.2",
|
|
41
41
|
"lefthook": "2.1.9",
|
|
42
42
|
"typescript": "6.0.3"
|
package/src/client.ts
CHANGED
|
@@ -28,7 +28,7 @@ export async function archiveRequest(
|
|
|
28
28
|
) {
|
|
29
29
|
const url = destinationUrl(destination.url);
|
|
30
30
|
const token = destinationToken(destination);
|
|
31
|
-
if (!token || (destination.kind === 'kingdom' && !token.startsWith('
|
|
31
|
+
if (!token || (destination.kind === 'kingdom' && !token.startsWith('kingdom_runtime_')))
|
|
32
32
|
throw new Error('Archive runtime credential unavailable');
|
|
33
33
|
const path =
|
|
34
34
|
destination.kind === 'kingdom' && destination.connectionId ? `remote/${action}` : action;
|
|
@@ -62,7 +62,7 @@ export async function publishArchive(
|
|
|
62
62
|
let pending = store.pending(id, receiptKey);
|
|
63
63
|
if (!pending) {
|
|
64
64
|
if (previousDigest === latest.digest) return { unchanged: !sent };
|
|
65
|
-
store.enqueue(id, receiptKey, { revision: latest.revision
|
|
65
|
+
store.enqueue(id, receiptKey, { revision: latest.revision });
|
|
66
66
|
pending = store.pending(id, receiptKey)!;
|
|
67
67
|
}
|
|
68
68
|
const queued = store.read(id, pending.revision);
|
|
@@ -79,7 +79,7 @@ export async function publishArchive(
|
|
|
79
79
|
transport,
|
|
80
80
|
);
|
|
81
81
|
if (body.data?.digest !== queued.digest) throw new Error('Archive acknowledgement mismatch');
|
|
82
|
-
store.delivered(id, receiptKey, queued.digest
|
|
82
|
+
store.delivered(id, receiptKey, queued.digest);
|
|
83
83
|
sent = true;
|
|
84
84
|
}
|
|
85
85
|
throw new Error('Archive changed repeatedly during publication; retry sync');
|
package/src/config.ts
CHANGED
package/src/local.ts
CHANGED
|
@@ -126,21 +126,20 @@ export class LocalArchiveStore {
|
|
|
126
126
|
)
|
|
127
127
|
.run(id, destination, hash);
|
|
128
128
|
}
|
|
129
|
-
pending(id: string, destination: string): { revision: number
|
|
129
|
+
pending(id: string, destination: string): { revision: number } | null {
|
|
130
130
|
const row = this.db
|
|
131
131
|
.query('SELECT pending FROM outbox WHERE archive_id=? AND destination=?')
|
|
132
132
|
.get(id, destination) as { pending: string } | null;
|
|
133
133
|
return row ? JSON.parse(row.pending) : null;
|
|
134
134
|
}
|
|
135
|
-
enqueue(id: string, destination: string, pending: { revision: number
|
|
135
|
+
enqueue(id: string, destination: string, pending: { revision: number }) {
|
|
136
136
|
this.db
|
|
137
137
|
.query('INSERT OR IGNORE INTO outbox VALUES (?, ?, ?)')
|
|
138
138
|
.run(id, destination, JSON.stringify(pending));
|
|
139
139
|
}
|
|
140
|
-
delivered(id: string, destination: string, hash: string
|
|
140
|
+
delivered(id: string, destination: string, hash: string) {
|
|
141
141
|
this.db.transaction(() => {
|
|
142
142
|
this.acknowledge(id, destination, hash);
|
|
143
|
-
this.acknowledge(id, `${destination}:keeps`, placement);
|
|
144
143
|
this.db.query('DELETE FROM outbox WHERE archive_id=? AND destination=?').run(id, destination);
|
|
145
144
|
})();
|
|
146
145
|
}
|