eversince 0.2.4 → 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,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,6 +1,6 @@
1
1
  {
2
2
  "name": "eversince",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
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": {