eversince 0.2.13 → 0.2.14

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
@@ -129,9 +129,10 @@ eversince workspace use "Studio" # the CLI acts here from now on
129
129
  eversince workspace clear # back to the account default
130
130
  ```
131
131
 
132
- The choice is the CLI's own and travels on each request. It does not move the
133
- workspace that connected agents are using. An API key is bound to one workspace by
134
- the server and cannot switch.
132
+ The choice is the CLI's own and travels on each request, among the workspaces the
133
+ user allowed this sign-in. It does not move the workspace that connected agents are
134
+ using. An API key moves within its own workspaces with
135
+ `eversince run manage_settings '{"switch_workspace":"<name|id>"}'`.
135
136
 
136
137
  ## Options
137
138
 
package/dist/client.js CHANGED
@@ -64,7 +64,7 @@ export class Client {
64
64
  }
65
65
  }
66
66
  const baseUrl = await resolveBaseUrl(opts.baseUrl);
67
- const workspace = await resolveWorkspace(baseUrl, opts.workspace);
67
+ const workspace = opts.noWorkspace ? undefined : await resolveWorkspace(baseUrl, opts.workspace);
68
68
  const credentials = opts.credentials ?? (await loadCredentials(baseUrl));
69
69
  if (!credentials)
70
70
  throw new NotLoggedIn(hostOf(baseUrl));
@@ -89,7 +89,12 @@ export class Client {
89
89
  whole: true,
90
90
  }));
91
91
  const media = Array.isArray(envelope?.media) ? envelope.media : [];
92
- return { data: envelope && typeof envelope === 'object' && 'data' in envelope ? envelope.data : envelope, media };
92
+ const spent = envelope?.meta?.cloud_processing;
93
+ return {
94
+ data: envelope && typeof envelope === 'object' && 'data' in envelope ? envelope.data : envelope,
95
+ media,
96
+ ...(spent && typeof spent === 'object' ? { cloudProcessing: spent } : {}),
97
+ };
93
98
  }
94
99
  async headers(method, options) {
95
100
  await this.ensureFreshToken();
@@ -100,7 +105,7 @@ export class Client {
100
105
  };
101
106
  if (options.body !== undefined)
102
107
  headers['content-type'] = 'application/json';
103
- if (this.workspace && this.credentials.kind === 'oauth')
108
+ if (this.workspace)
104
109
  headers['x-workspace-id'] = this.workspace;
105
110
  if (method !== 'GET')
106
111
  headers['idempotency-key'] = options.idempotencyKey ?? randomUUID();
@@ -43,6 +43,7 @@ export function describe(job) {
43
43
  job.retrying ? 'retrying' : null,
44
44
  job.eta_seconds ? roughly(job.eta_seconds) : null,
45
45
  job.refunded ? 'refunded' : null,
46
+ job.status === 'cancelled' && job.cloud_minutes === 0 ? 'nothing charged' : null,
46
47
  job.note ?? null,
47
48
  job.error?.message ?? null,
48
49
  job.error?.charged ? 'charged' : null,
@@ -58,6 +58,11 @@ export function jobIdsIn(result) {
58
58
  if (typeof value === 'string')
59
59
  ids.push(value);
60
60
  }
61
+ if (Array.isArray(r.job_ids)) {
62
+ for (const id of r.job_ids)
63
+ if (typeof id === 'string')
64
+ ids.push(id);
65
+ }
61
66
  for (const key of ['jobs', 'items']) {
62
67
  const value = r[key];
63
68
  if (Array.isArray(value)) {
@@ -65,6 +70,8 @@ export function jobIdsIn(result) {
65
70
  ids.push(...jobIdsIn(entry));
66
71
  }
67
72
  }
73
+ if (r.prepared && typeof r.prepared === 'object')
74
+ ids.push(...jobIdsIn(r.prepared));
68
75
  return [...new Set(ids)];
69
76
  }
70
77
  export async function run(argv, connection, mode) {
@@ -85,7 +92,10 @@ export async function run(argv, connection, mode) {
85
92
  const answered = await client.toolWithMedia(argv.name, input, { idempotencyKey: argv.idempotencyKey });
86
93
  const saved = await saveMedia(answered.media, argv.name, argv.out);
87
94
  const pictures = saved.filter((p) => !!p);
88
- const result = pictures.length ? { ...withPicturePaths(answered.data, saved), pictures } : answered.data;
95
+ const drawn = pictures.length ? { ...withPicturePaths(answered.data, saved), pictures } : answered.data;
96
+ const result = answered.cloudProcessing && drawn && typeof drawn === 'object' && !Array.isArray(drawn)
97
+ ? { ...drawn, cloud_processing: answered.cloudProcessing }
98
+ : drawn;
89
99
  if (!argv.wait) {
90
100
  printResult(mode, result, () => {
91
101
  line(JSON.stringify(result, null, 2));
@@ -5,6 +5,10 @@ async function list(client) {
5
5
  const data = (await client.get('/api/v1/workspaces'));
6
6
  return data.workspaces ?? [];
7
7
  }
8
+ async function allowedOf(client) {
9
+ const data = (await client.tool('manage_settings', { workspaces: true }));
10
+ return data?.workspaces ?? [];
11
+ }
8
12
  export async function workspace(argv, connection, mode) {
9
13
  const baseUrl = await resolveBaseUrl(connection.baseUrl);
10
14
  const action = argv.action ?? 'list';
@@ -18,19 +22,24 @@ export async function workspace(argv, connection, mode) {
18
22
  if (!argv.target)
19
23
  throw new Error('Which workspace? `eversince workspace use <name|id>`');
20
24
  if (client.authKind === 'api_key') {
21
- throw new Error('This API key is locked to one workspace. Sign in with `eversince login` to switch, or use a key from the workspace you want.');
25
+ throw new Error('An API key moves between its workspaces with `eversince run manage_settings \'{"switch_workspace":"<name|id>"}\'`; `eversince run manage_settings \'{"workspaces":true}\'` lists them.');
22
26
  }
23
- const workspaces = await list(client);
24
- const wanted = argv.target.trim().toLowerCase();
25
- const match = workspaces.find((w) => w.id === argv.target.trim()) ??
26
- workspaces.find((w) => (w.name ?? '').trim().toLowerCase() === wanted);
27
+ const own = await Client.create({ ...connection, baseUrl, noWorkspace: true });
28
+ const [workspaces, allowed] = await Promise.all([list(client), allowedOf(own)]);
29
+ const target = argv.target.trim();
30
+ const find = (pool) => pool.find((w) => w.id === target) ?? pool.find((w) => (w.name ?? '').trim().toLowerCase() === target.toLowerCase());
31
+ const match = find(allowed);
27
32
  if (!match) {
28
- throw new Error(`No workspace called "${argv.target}". \`eversince workspace\` lists what this account can reach.`);
33
+ const elsewhere = find(workspaces);
34
+ if (elsewhere) {
35
+ throw new Error(`This connection is not allowed in ${elsewhere.name ?? elsewhere.id}. The user adds it in Eversince Settings, Agents.`);
36
+ }
37
+ throw new Error(`No workspace called "${argv.target}". \`eversince workspace\` marks the ones this sign-in may use.`);
29
38
  }
30
39
  await setWorkspaceFor(baseUrl, match.id);
31
40
  printResult(mode, { workspace: match }, () => {
32
41
  line(`Now working in ${match.name}.`);
33
- note('This applies to the CLI only. Connected agents keep the workspace they were on.');
42
+ note('This applies to the CLI only. A connected agent moves its own with manage_settings switch_workspace.');
34
43
  });
35
44
  return;
36
45
  }
@@ -41,10 +50,14 @@ export async function workspace(argv, connection, mode) {
41
50
  return;
42
51
  }
43
52
  const width = Math.max(...workspaces.map((w) => (w.name ?? '').length)) + 2;
53
+ const marked = workspaces.some((w) => w.allowed === false);
44
54
  for (const w of workspaces) {
45
55
  const marker = current === w.id ? '*' : ' ';
46
- line(`${marker} ${pad(w.name ?? '(unnamed)', width)}${pad(w.role ?? '', 8)}${w.id}`);
56
+ const scope = marked ? pad(w.allowed === false ? 'not allowed' : 'allowed', 13) : '';
57
+ line(`${marker} ${pad(w.name ?? '(unnamed)', width)}${pad(w.role ?? '', 8)}${scope}${w.id}`);
47
58
  }
59
+ if (marked)
60
+ note(`\nA workspace marked not allowed is added in Eversince Settings, ${client.authKind === 'api_key' ? 'API keys' : 'Agents'}.`);
48
61
  if (!current)
49
62
  note(`\nNo CLI workspace set for ${hostOf(baseUrl)}. Using the account default.`);
50
63
  });
package/dist/index.js CHANGED
@@ -30,7 +30,8 @@ Working
30
30
  eversince tools [name] what this workspace can do, live
31
31
  eversince tools --all every tool's input fields, once
32
32
  eversince run <tool> '<json>' call any tool (--wait to follow async work)
33
- eversince run <tool> - arguments from stdin
33
+ eversince run <tool> - arguments from stdin: for JSON holding an
34
+ apostrophe, which ends a '<json>' argument
34
35
  eversince upload <files|folder> local files into the library (through the
35
36
  desktop app, media is added where it sits)
36
37
  eversince download <refs…> library items onto disk
@@ -1 +1 @@
1
- 76558d0f394c159e4e748ea3e71c0f135e71f588067f409fb35449fff9de3a26
1
+ 46a5074f5160dea38ecfe2a280af084305cc09cf8414e767ead8c0dc26fd5ca1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eversince",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
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": {