eversince 0.2.3 → 0.2.5

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.
@@ -7,6 +7,9 @@ import { Client } from '../client.js';
7
7
  import { line, note, printResult } from '../output.js';
8
8
  import { USER_AGENT } from '../version.js';
9
9
  const GET_ITEMS_MAX = 25;
10
+ const UPLOAD_WAIT_MS = 120_000;
11
+ const JUST_MADE_MS = 10 * 60_000;
12
+ const onItsWayUp = (it) => !it.url && !!it.local_only && !!it.created_at && Date.now() - Date.parse(it.created_at) < JUST_MADE_MS;
10
13
  const EXTENSIONS = {
11
14
  image: '.png',
12
15
  video: '.mp4',
@@ -41,6 +44,22 @@ export async function download(argv, connection, mode) {
41
44
  for (const ref of page.unresolved ?? [])
42
45
  failed.push({ ref, error: 'No such item in this workspace' });
43
46
  }
47
+ if (client.local) {
48
+ const deadline = Date.now() + UPLOAD_WAIT_MS;
49
+ let pending = items.filter(onItsWayUp);
50
+ if (pending.length && !mode.json)
51
+ note(`Waiting for ${pending.length === 1 ? 'it' : `${pending.length} files`} to finish uploading from the desktop app …`);
52
+ while (pending.length && Date.now() < deadline) {
53
+ await new Promise((resolve) => setTimeout(resolve, 3000));
54
+ const page = (await client.tool('get_items', { refs: pending.map((it) => it.item_id || it.ref).filter(Boolean) }).catch(() => ({ items: [] })));
55
+ for (const fresh of page.items) {
56
+ const at = items.findIndex((it) => (it.item_id && it.item_id === fresh.item_id) || (it.ref && it.ref === fresh.ref));
57
+ if (at >= 0 && fresh.url)
58
+ items[at] = fresh;
59
+ }
60
+ pending = items.filter(onItsWayUp);
61
+ }
62
+ }
44
63
  for (const item of items) {
45
64
  const ref = item.ref || item.item_id || 'item';
46
65
  if (!item.url) {
@@ -1,5 +1,5 @@
1
1
  import { existsSync } from 'node:fs';
2
- import { readFile, writeFile, mkdir, copyFile, access, rename } from 'node:fs/promises';
2
+ import { readFile, writeFile, mkdir, copyFile, access, rename, stat } from 'node:fs/promises';
3
3
  import { join, dirname } from 'node:path';
4
4
  import { homedir } from 'node:os';
5
5
  import { discoverAuthorizationServer } from '../auth/oauth.js';
@@ -56,8 +56,9 @@ function manualFor(agent, mcpUrl) {
56
56
  }
57
57
  async function writeAtomic(path, text) {
58
58
  await mkdir(dirname(path), { recursive: true });
59
+ const mode = await stat(path).then((s) => s.mode & 0o777, () => 0o600);
59
60
  const temp = `${path}.eversince-${process.pid}.tmp`;
60
- await writeFile(temp, text);
61
+ await writeFile(temp, text, { mode });
61
62
  await rename(temp, path);
62
63
  }
63
64
  function skillTargets(scope) {
@@ -125,7 +126,18 @@ async function backup(path) {
125
126
  await copyFile(path, target);
126
127
  return target;
127
128
  }
128
- async function writeMcpEntry(target, mcpUrl, dryRun) {
129
+ function pointsHere(url, mcpUrl, baseUrl) {
130
+ const bare = (u) => u.replace(/\/+$/, '');
131
+ if (bare(url) === bare(mcpUrl))
132
+ return true;
133
+ try {
134
+ return new URL(url).origin === new URL(baseUrl).origin;
135
+ }
136
+ catch {
137
+ return false;
138
+ }
139
+ }
140
+ async function writeMcpEntry(target, mcpUrl, baseUrl, dryRun) {
129
141
  const entry = { type: 'http', url: mcpUrl };
130
142
  let current = {};
131
143
  const had = await exists(target.path);
@@ -146,16 +158,18 @@ async function writeMcpEntry(target, mcpUrl, dryRun) {
146
158
  const merged = existing && typeof existing === 'object'
147
159
  ? { ...entry, ...existing }
148
160
  : entry;
161
+ const keptUrl = merged.url;
162
+ const elsewhere = typeof keptUrl === 'string' && !pointsHere(keptUrl, mcpUrl, baseUrl) ? { points_to: keptUrl } : {};
149
163
  if (existing && JSON.stringify(existing) === JSON.stringify(merged)) {
150
- return { agent: target.agent, path: target.path, action: 'unchanged' };
164
+ return { agent: target.agent, path: target.path, action: 'unchanged', ...elsewhere };
151
165
  }
152
166
  if (dryRun) {
153
- return { agent: target.agent, path: target.path, action: had ? 'updated' : 'created' };
167
+ return { agent: target.agent, path: target.path, action: had ? 'updated' : 'created', ...elsewhere };
154
168
  }
155
169
  const saved = had ? await backup(target.path) : undefined;
156
170
  servers[SERVER_KEY] = merged;
157
171
  await writeAtomic(target.path, `${JSON.stringify({ ...current, [target.key]: servers }, null, 2)}\n`);
158
- return { agent: target.agent, path: target.path, action: had ? 'updated' : 'created', backup: saved };
172
+ return { agent: target.agent, path: target.path, action: had ? 'updated' : 'created', backup: saved, ...elsewhere };
159
173
  }
160
174
  async function writeSkill(target, body, force, dryRun) {
161
175
  if (await exists(target.path)) {
@@ -277,10 +291,12 @@ export async function init(argv, connection, mode) {
277
291
  const offerApp = !app;
278
292
  const changes = [];
279
293
  const skipped = [];
294
+ const entries = [];
280
295
  if (doMcp) {
281
296
  for (const target of jsonTargets(scope, agent)) {
282
- changes.push(await writeMcpEntry(target, mcpUrl, dryRun));
297
+ entries.push(await writeMcpEntry(target, mcpUrl, baseUrl, dryRun));
283
298
  }
299
+ changes.push(...entries);
284
300
  skipped.push(...manualFor(agent, mcpUrl));
285
301
  }
286
302
  if (doSkills) {
@@ -289,7 +305,8 @@ export async function init(argv, connection, mode) {
289
305
  changes.push(await writeSkill(target, body, argv.force === true, dryRun));
290
306
  }
291
307
  }
292
- if (!dryRun) {
308
+ const connected = !(entries.length > 0 && entries.every((entry) => entry.points_to));
309
+ if (!dryRun && connected) {
293
310
  const wrote = changes.filter((c) => c.action !== 'unchanged').map((c) => c.agent);
294
311
  const named = agent
295
312
  ? agent === 'claude-code' || agent === 'cursor' || agent === 'codex'
@@ -315,11 +332,13 @@ export async function init(argv, connection, mode) {
315
332
  }
316
333
  }
317
334
  }
318
- printResult(mode, { venue: 'cloud', scope, mcp_url: mcpUrl, dry_run: dryRun, changes, manual: skipped, ...(offerApp ? { desktop_app: GET_THE_APP } : {}) }, () => {
335
+ printResult(mode, { venue: 'cloud', scope, mcp_url: mcpUrl, dry_run: dryRun, connected, changes, manual: skipped, ...(offerApp ? { desktop_app: GET_THE_APP } : {}) }, () => {
319
336
  for (const change of changes) {
320
337
  line(`${change.action.padEnd(10)}${change.path}`);
321
338
  if (change.backup)
322
339
  note(` previous copy: ${change.backup}`);
340
+ if (change.points_to)
341
+ note(` its ${SERVER_KEY} entry points to ${change.points_to}, not ${mcpUrl}. Remove the entry and run init again to connect here.`);
323
342
  }
324
343
  for (const item of skipped) {
325
344
  line();
@@ -330,6 +349,10 @@ export async function init(argv, connection, mode) {
330
349
  line('Dry run. Nothing was written.');
331
350
  return;
332
351
  }
352
+ if (!connected) {
353
+ line(`Not connected to ${hostOf(baseUrl)}: the entry already there points elsewhere.`);
354
+ return;
355
+ }
333
356
  line(`Connected to ${hostOf(baseUrl)}. Restart any running agent to pick it up.`);
334
357
  note('The agent authorises its own MCP connection; it does not use the CLI credential.');
335
358
  if (offerApp)
@@ -1,15 +1,28 @@
1
- import { Client } from '../client.js';
1
+ import { ApiError, Client } from '../client.js';
2
2
  import { line, note, pad, printResult } from '../output.js';
3
3
  const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
4
4
  const POLL_SECONDS = 25;
5
5
  export async function waitForJobs(client, ids, opts) {
6
6
  const deadline = Date.now() + opts.timeoutMs;
7
+ let misses = 0;
7
8
  for (;;) {
8
9
  const remaining = Math.max(0, deadline - Date.now());
9
10
  const wait = Math.min(POLL_SECONDS, Math.floor(remaining / 1000));
10
- const data = (await client.tool('get_jobs', { ids, wait_seconds: wait }, {
11
- timeoutMs: (wait + 30) * 1000,
12
- }));
11
+ let data;
12
+ try {
13
+ data = (await client.tool('get_jobs', { ids, wait_seconds: wait }, {
14
+ timeoutMs: (wait + 30) * 1000,
15
+ }));
16
+ }
17
+ catch (error) {
18
+ const passing = error instanceof ApiError && (error.body.retryable === true || error.status >= 500);
19
+ misses += 1;
20
+ if (!passing || misses >= 10 || Date.now() >= deadline)
21
+ throw error;
22
+ await new Promise((resolve) => setTimeout(resolve, 3000));
23
+ continue;
24
+ }
25
+ misses = 0;
13
26
  opts.onTick?.(data.jobs);
14
27
  if (data.jobs.length === 0)
15
28
  return [];
package/dist/local.js CHANGED
@@ -57,8 +57,13 @@ export async function openApp(onStart) {
57
57
  }
58
58
  }
59
59
  export async function localDoor(onStart) {
60
- if (!desktopInstalled())
61
- return null;
60
+ if (!desktopInstalled()) {
61
+ const record = readState();
62
+ if (!record || typeof record.connectKey !== 'string')
63
+ return null;
64
+ if ((await probe(record).catch(() => 'closed')) !== 'ours')
65
+ return null;
66
+ }
62
67
  const state = await reachApp(undefined, onStart);
63
68
  if (!state)
64
69
  throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eversince",
3
- "version": "0.2.3",
4
- "description": "Agent-native access to making content",
3
+ "version": "0.2.5",
4
+ "description": "The Eversince CLI. Eversince is the media workspace for agents: connect an agent, call any tool, move files and follow jobs from a shell.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "eversince": "dist/index.js"