eversince 0.2.12 → 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
@@ -56,6 +56,7 @@ eversince init --agent codex connect one agent
56
56
  eversince mcp --agent codex the desktop app as a stdio MCP server (init writes this)
57
57
 
58
58
  eversince tools [name] what this workspace can do, live
59
+ eversince tools --all every tool's input fields, once
59
60
  eversince run <tool> '<json>' call any tool (--wait to follow async work; - reads stdin)
60
61
  eversince upload <files|folder> local files into the library
61
62
  eversince download <refs…> library items onto disk
@@ -128,9 +129,10 @@ eversince workspace use "Studio" # the CLI acts here from now on
128
129
  eversince workspace clear # back to the account default
129
130
  ```
130
131
 
131
- The choice is the CLI's own and travels on each request. It does not move the
132
- workspace that connected agents are using. An API key is bound to one workspace by
133
- 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>"}'`.
134
136
 
135
137
  ## Options
136
138
 
package/dist/bridge.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DoorBlocked, cacheFile as cacheFileFor, isBlocked, isRefused, probe, reachApp, readJson, readState, sandboxedWithoutNetwork, stateFile as defaultStateFile, } from './door.js';
1
+ import { DoorBlocked, cacheFile as cacheFileFor, isBlocked, isRefused, probe, reachApp, unreachedMessage, readJson, readState, sandboxedWithoutNetwork, stateFile as defaultStateFile, } from './door.js';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { isConnectFailure } from './retry.js';
4
4
  function write(message) {
@@ -49,7 +49,7 @@ export function runBridge(options) {
49
49
  if (!state) {
50
50
  if (before && !existsSync(before.app))
51
51
  throw new Error(`The Eversince app is no longer on this computer. Run \`${self} init\` to connect this agent to eversince.ai instead.`);
52
- throw new Error('The Eversince app did not open. Open it and try again.');
52
+ throw new Error(unreachedMessage(`or run \`${self} init --cloud\` to connect this agent to eversince.ai instead`));
53
53
  }
54
54
  }
55
55
  const connection = connectionFor(state);
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,
@@ -19,8 +19,10 @@ async function saveMedia(media, tool, out) {
19
19
  const safe = tool.replace(/[^\w.-]+/g, '-');
20
20
  const written = [];
21
21
  for (const [i, picture] of media.entries()) {
22
- if (typeof picture?.data !== 'string' || picture.data.length === 0)
22
+ if (typeof picture?.data !== 'string' || picture.data.length === 0) {
23
+ written.push(null);
23
24
  continue;
25
+ }
24
26
  const ext = MEDIA_EXTENSIONS[picture.mimeType ?? ''] ?? '.bin';
25
27
  const path = join(dir, `${safe}-${stamp}${media.length > 1 ? `-${i + 1}` : ''}${ext}`);
26
28
  await writeFile(path, Buffer.from(picture.data, 'base64'));
@@ -28,6 +30,18 @@ async function saveMedia(media, tool, out) {
28
30
  }
29
31
  return written;
30
32
  }
33
+ function withPicturePaths(data, saved) {
34
+ const answer = (data ?? {});
35
+ if (!Array.isArray(answer.items))
36
+ return answer;
37
+ const items = answer.items.map((item) => {
38
+ const at = item?.pictures;
39
+ if (!Array.isArray(at))
40
+ return item;
41
+ return { ...item, pictures: at.map((n) => (typeof n === 'number' ? saved[n] ?? null : n)).filter(Boolean) };
42
+ });
43
+ return { ...answer, items };
44
+ }
31
45
  async function readStdin() {
32
46
  const chunks = [];
33
47
  for await (const chunk of process.stdin)
@@ -44,6 +58,11 @@ export function jobIdsIn(result) {
44
58
  if (typeof value === 'string')
45
59
  ids.push(value);
46
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
+ }
47
66
  for (const key of ['jobs', 'items']) {
48
67
  const value = r[key];
49
68
  if (Array.isArray(value)) {
@@ -51,6 +70,8 @@ export function jobIdsIn(result) {
51
70
  ids.push(...jobIdsIn(entry));
52
71
  }
53
72
  }
73
+ if (r.prepared && typeof r.prepared === 'object')
74
+ ids.push(...jobIdsIn(r.prepared));
54
75
  return [...new Set(ids)];
55
76
  }
56
77
  export async function run(argv, connection, mode) {
@@ -69,8 +90,12 @@ export async function run(argv, connection, mode) {
69
90
  }
70
91
  const client = await Client.create(connection);
71
92
  const answered = await client.toolWithMedia(argv.name, input, { idempotencyKey: argv.idempotencyKey });
72
- const pictures = await saveMedia(answered.media, argv.name, argv.out);
73
- const result = pictures.length ? { ...answered.data, pictures } : answered.data;
93
+ const saved = await saveMedia(answered.media, argv.name, argv.out);
94
+ const pictures = saved.filter((p) => !!p);
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;
74
99
  if (!argv.wait) {
75
100
  printResult(mode, result, () => {
76
101
  line(JSON.stringify(result, null, 2));
@@ -3,7 +3,7 @@ import { line, pad, printResult } from '../output.js';
3
3
  import { hereCommand } from '../local.js';
4
4
  export async function tools(argv, connection, mode) {
5
5
  const client = await Client.create(connection);
6
- const wantSchemas = argv.schemas === true || Boolean(argv.name) || mode.json;
6
+ const wantSchemas = argv.all === true || argv.schemas === true || Boolean(argv.name) || mode.json;
7
7
  const data = (await client.get('/api/v1/tools', {
8
8
  schemas: wantSchemas ? undefined : 'false',
9
9
  annotation: argv.annotation,
@@ -15,6 +15,16 @@ export async function tools(argv, connection, mode) {
15
15
  const near = data.tools.filter((t) => t.name.includes(argv.name)).slice(0, 5);
16
16
  throw new Error(`No tool named "${argv.name}".${near.length ? ` Did you mean: ${near.map((t) => t.name).join(', ')}?` : ' Run `eversince tools` for the list.'}`);
17
17
  }
18
+ if (argv.all && !argv.name) {
19
+ const compact = list.map((t) => ({ name: t.name, input: compactSchema(t.input_schema) }));
20
+ printResult(mode, { tools: compact }, () => {
21
+ for (const t of compact)
22
+ line(`${t.name} ${t.input}`);
23
+ line();
24
+ line(hereCommand('`eversince tools <name>` for one tool in full, with descriptions.'));
25
+ });
26
+ return;
27
+ }
18
28
  printResult(mode, argv.name ? list[0] : { instructions: data.instructions, tools: list }, () => {
19
29
  if (argv.name) {
20
30
  const tool = list[0];
@@ -43,3 +53,23 @@ export async function tools(argv, connection, mode) {
43
53
  line(hereCommand(`${list.length} tools. \`eversince tools <name>\` for one in full.`));
44
54
  });
45
55
  }
56
+ function compactSchema(schema, depth = 0) {
57
+ const node = (schema ?? {});
58
+ const options = (node.anyOf ?? node.oneOf);
59
+ if (Array.isArray(node.enum))
60
+ return node.enum.map(String).join('|');
61
+ if (options)
62
+ return [...new Set(options.map((o) => compactSchema(o, depth)))].join('|');
63
+ if (node.type === 'array')
64
+ return `${compactSchema(node.items, depth)}[]`;
65
+ const props = node.properties;
66
+ if (node.type === 'object' || props) {
67
+ if (!props)
68
+ return 'object';
69
+ if (depth >= 3)
70
+ return '{…}';
71
+ const required = new Set(Array.isArray(node.required) ? node.required : []);
72
+ return `{${Object.entries(props).map(([k, v]) => `${k}${required.has(k) ? '*' : ''}: ${compactSchema(v, depth + 1)}`).join(', ')}}`;
73
+ }
74
+ return Array.isArray(node.type) ? node.type.join('|') : String(node.type ?? 'any');
75
+ }
@@ -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/door.js CHANGED
@@ -107,29 +107,42 @@ export function launch(state) {
107
107
  spawn(state.app, args, { stdio: 'ignore', detached: true, env }).on('error', () => undefined).unref();
108
108
  return true;
109
109
  }
110
- export async function reachApp(file = stateFile(), onStart) {
110
+ export async function reachApp(file, onStart) {
111
+ file ??= await answeringFile();
112
+ lastMiss = null;
111
113
  const state = readState(file);
112
- if (!state)
114
+ if (!state) {
115
+ lastMiss = 'missing';
113
116
  return null;
117
+ }
114
118
  const first = await probe(state);
115
119
  if (first === 'ours')
116
120
  return state;
117
121
  if (first === 'blocked')
118
122
  throw new DoorBlocked();
123
+ if (!existsSync(state.app)) {
124
+ lastMiss = 'missing';
125
+ return null;
126
+ }
119
127
  const devUrl = state.launch && typeof state.launch === 'object' && state.launch.env && typeof state.launch.env === 'object'
120
128
  ? state.launch.env.EVERSINCE_DEV_URL
121
129
  : undefined;
122
130
  if (typeof devUrl === 'string') {
123
131
  const up = await fetch(devUrl, { signal: AbortSignal.timeout(1500) }).then(() => true, () => false);
124
- if (!up)
132
+ if (!up) {
133
+ lastMiss = 'dev-down';
125
134
  return null;
135
+ }
126
136
  }
127
137
  onStart?.();
128
138
  try {
129
- if (!launch(state))
139
+ if (!launch(state)) {
140
+ lastMiss = 'missing';
130
141
  return null;
142
+ }
131
143
  }
132
144
  catch {
145
+ lastMiss = 'slow';
133
146
  return null;
134
147
  }
135
148
  const until = Date.now() + START_WAIT_MS;
@@ -144,5 +157,34 @@ export async function reachApp(file = stateFile(), onStart) {
144
157
  if (seen === 'blocked')
145
158
  throw new DoorBlocked();
146
159
  }
160
+ lastMiss = 'slow';
147
161
  return null;
148
162
  }
163
+ let lastMiss = null;
164
+ export function unreachedMessage(cloudHint = 'or run with --cloud') {
165
+ switch (lastMiss) {
166
+ case 'missing':
167
+ return `The Eversince app is not installed on this computer. Install it, ${cloudHint}.`;
168
+ case 'dev-down':
169
+ return `The development copy of the Eversince app is not running and its page server is down. Start it with npm run dev:desktop, ${cloudHint}.`;
170
+ case 'slow':
171
+ default:
172
+ return `The Eversince app was started but did not answer in time. Try again in a moment, ${cloudHint}.`;
173
+ }
174
+ }
175
+ export async function answeringFile() {
176
+ const first = stateFile();
177
+ if (process.env.ES_DESKTOP_STATE || !fromSource())
178
+ return first;
179
+ const firstState = readState(first);
180
+ if (firstState && (await probe(firstState).catch(() => 'closed')) === 'ours')
181
+ return first;
182
+ for (const file of stateCandidates()) {
183
+ if (file === first || !existsSync(file))
184
+ continue;
185
+ const state = readState(file);
186
+ if (state && (await probe(state).catch(() => 'closed')) === 'ours')
187
+ return file;
188
+ }
189
+ return first;
190
+ }
package/dist/index.js CHANGED
@@ -28,8 +28,10 @@ Getting set up
28
28
 
29
29
  Working
30
30
  eversince tools [name] what this workspace can do, live
31
+ eversince tools --all every tool's input fields, once
31
32
  eversince run <tool> '<json>' call any tool (--wait to follow async work)
32
- eversince run <tool> - arguments from stdin
33
+ eversince run <tool> - arguments from stdin: for JSON holding an
34
+ apostrophe, which ends a '<json>' argument
33
35
  eversince upload <files|folder> local files into the library (through the
34
36
  desktop app, media is added where it sits)
35
37
  eversince download <refs…> library items onto disk
@@ -97,6 +99,7 @@ const OPTIONS = {
97
99
  workspace: { type: 'string' },
98
100
  out: { type: 'string', short: 'o' },
99
101
  schemas: { type: 'boolean', default: false },
102
+ all: { type: 'boolean', default: false },
100
103
  annotation: { type: 'string' },
101
104
  describe: { type: 'string' },
102
105
  concurrency: { type: 'string' },
@@ -159,7 +162,7 @@ async function main() {
159
162
  case 'workspace':
160
163
  return await workspace({ action: rest[0], target: rest[1] }, connection, mode);
161
164
  case 'tools':
162
- return await tools({ name: rest[0], schemas: values.schemas, annotation: values.annotation }, connection, mode);
165
+ return await tools({ name: rest[0], all: values.all, schemas: values.schemas, annotation: values.annotation }, connection, mode);
163
166
  case 'run':
164
167
  return await run({
165
168
  name: rest[0],
@@ -208,4 +211,14 @@ async function main() {
208
211
  fail(mode, error);
209
212
  }
210
213
  }
214
+ process.stdout.on('error', (error) => {
215
+ if (error.code === 'EPIPE')
216
+ process.exit(0);
217
+ throw error;
218
+ });
219
+ process.stderr.on('error', (error) => {
220
+ if (error.code === 'EPIPE')
221
+ process.exit(0);
222
+ throw error;
223
+ });
211
224
  main().catch((error) => fail({ json: process.argv.includes('--json') }, error));
package/dist/local.js CHANGED
@@ -3,7 +3,7 @@ import { cp, mkdir, rename, rm } from 'node:fs/promises';
3
3
  import { homedir } from 'node:os';
4
4
  import { delimiter, dirname, join, sep } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { DoorBlocked, probe, reachApp, readState } from './door.js';
6
+ import { DoorBlocked, probe, reachApp, readState, unreachedMessage } from './door.js';
7
7
  import { detectHostAgent, kindForName } from './host-agent.js';
8
8
  export function desktopInstalled() {
9
9
  const state = readState();
@@ -82,7 +82,7 @@ export async function stableLauncher(dryRun) {
82
82
  export async function connectThroughApp(agent, extra = {}) {
83
83
  const state = await reachApp();
84
84
  if (!state?.connectKey)
85
- throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
85
+ throw new Error(unreachedMessage());
86
86
  const res = await fetch(`http://127.0.0.1:${state.port}/connect`, {
87
87
  method: 'POST',
88
88
  headers: { authorization: `Bearer ${state.connectKey}`, 'content-type': 'application/json' },
@@ -103,7 +103,7 @@ async function connect() {
103
103
  }
104
104
  export async function openApp(onStart) {
105
105
  if (!(await reachApp(undefined, onStart))) {
106
- throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
106
+ throw new Error(unreachedMessage());
107
107
  }
108
108
  }
109
109
  export async function localDoor(onStart) {
@@ -116,7 +116,7 @@ export async function localDoor(onStart) {
116
116
  }
117
117
  const state = await reachApp(undefined, onStart);
118
118
  if (!state)
119
- throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
119
+ throw new Error(unreachedMessage());
120
120
  const host = detectHostAgent();
121
121
  const label = host?.name ?? 'CLI agent';
122
122
  const existing = state.connections?.find((c) => c?.label === label && c?.agent === kindForName(host?.name) && typeof c.token === 'string');
@@ -134,7 +134,7 @@ export async function localDoor(onStart) {
134
134
  throw new DoorBlocked();
135
135
  const opened = await reachApp(undefined, onStart);
136
136
  if (!opened)
137
- throw new Error('The Eversince app on this computer did not open. Open it and try again, or run with --cloud.');
137
+ throw new Error(unreachedMessage());
138
138
  return `http://127.0.0.1:${opened.port}`;
139
139
  },
140
140
  };
@@ -1 +1 @@
1
- 5295aed56e667ec559dc7386a87e7c0ea8ac334c4d29823a61042ace137cbe79
1
+ 46a5074f5160dea38ecfe2a280af084305cc09cf8414e767ead8c0dc26fd5ca1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eversince",
3
- "version": "0.2.12",
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": {