@inixiative/archive 0.4.0 → 0.5.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 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/Kastles.
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 `kastle_runtime_` credential in an environment variable, then either let Kingdom store the archives:
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.4.0",
3
+ "version": "0.5.1",
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.37",
39
+ "@inixiative/config": "^0.5.39",
40
40
  "@types/bun": "1.4.2",
41
41
  "lefthook": "2.1.9",
42
42
  "typescript": "6.0.3"
package/src/agents.ts CHANGED
@@ -357,7 +357,9 @@ function lastEntry(file: string) {
357
357
  const buffer = Buffer.alloc(Math.min(size, 65_536));
358
358
  readSync(fd, buffer, 0, buffer.length, size - buffer.length);
359
359
  const lines = buffer.toString('utf8').trimEnd().split('\n');
360
- const start = lines.findLastIndex((line) => line === '{' || line === '[');
360
+ // Source ships to consumers compiled against older libs, so no findLastIndex.
361
+ let start = lines.length - 1;
362
+ while (start >= 0 && lines[start] !== '{' && lines[start] !== '[') start--;
361
363
  if (start >= 0)
362
364
  try {
363
365
  return JSON.stringify(JSON.parse(lines.slice(start).join('\n'))).slice(0, 500);
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('kastle_runtime_')))
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, keepIds: [] });
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
@@ -34,7 +34,6 @@ export const archiveDestinationSchema = z
34
34
  z.strictObject({
35
35
  ...common,
36
36
  kind: z.literal('archive'),
37
- keepIds: z.array(z.string()).max(0).optional(),
38
37
  }),
39
38
  z.strictObject({
40
39
  ...common,
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; keepIds: string[] } | null {
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; keepIds: string[] }) {
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, placement: 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
  }