eversince 0.2.14 → 0.2.16
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/dist/bridge.js +8 -0
- package/dist/client.js +7 -4
- package/dist/commands/run.js +2 -0
- package/dist/source.sha256 +1 -1
- package/package.json +1 -1
package/dist/bridge.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
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
|
+
const EMPTY_LISTS = {
|
|
5
|
+
'resources/list': { resources: [] },
|
|
6
|
+
'resources/templates/list': { resourceTemplates: [] },
|
|
7
|
+
'prompts/list': { prompts: [] },
|
|
8
|
+
};
|
|
4
9
|
function write(message) {
|
|
5
10
|
process.stdout.write(`${typeof message === 'string' ? message : JSON.stringify(message)}\n`);
|
|
6
11
|
}
|
|
@@ -68,6 +73,9 @@ export function runBridge(options) {
|
|
|
68
73
|
return {};
|
|
69
74
|
if (message.method === 'ping')
|
|
70
75
|
return { reply: { jsonrpc: '2.0', id, result: {} } };
|
|
76
|
+
const empty = EMPTY_LISTS[message.method];
|
|
77
|
+
if (empty)
|
|
78
|
+
return { reply: { jsonrpc: '2.0', id, result: empty } };
|
|
71
79
|
const cache = readJson(cacheFile);
|
|
72
80
|
if (!cache)
|
|
73
81
|
return null;
|
package/dist/client.js
CHANGED
|
@@ -113,7 +113,7 @@ export class Client {
|
|
|
113
113
|
}
|
|
114
114
|
async ensureFreshToken() {
|
|
115
115
|
const { kind, expiresAt, refreshToken, clientId } = this.credentials;
|
|
116
|
-
if (kind !== 'oauth' ||
|
|
116
|
+
if (kind !== 'oauth' || expiresAt === undefined || Date.now() < expiresAt)
|
|
117
117
|
return;
|
|
118
118
|
if (!refreshToken || !clientId) {
|
|
119
119
|
throw new ApiError(401, {
|
|
@@ -261,12 +261,15 @@ export class Client {
|
|
|
261
261
|
}
|
|
262
262
|
const aborted = error instanceof Error && error.name === 'AbortError';
|
|
263
263
|
const connectFailure = !aborted && (isConnectFailure(error) || error instanceof RenewalUnreachable);
|
|
264
|
+
const unknownOutcome = isWrite && !connectFailure;
|
|
264
265
|
const wrapped = new ApiError(0, {
|
|
265
266
|
code: aborted ? 'timeout' : 'network_error',
|
|
266
|
-
message: aborted
|
|
267
|
-
? `Timed out after ${Math.round((options.timeoutMs ?? this.defaultTimeoutMs) / 1000)}s calling ${url.pathname}
|
|
268
|
-
: `Could not reach ${url.host}: ${error instanceof Error ? error.message : String(error)}
|
|
267
|
+
message: (aborted
|
|
268
|
+
? `Timed out after ${Math.round((options.timeoutMs ?? this.defaultTimeoutMs) / 1000)}s calling ${url.pathname}.`
|
|
269
|
+
: `Could not reach ${url.host}: ${error instanceof Error ? error.message : String(error)}.`)
|
|
270
|
+
+ (unknownOutcome ? ' The request may have been applied before the connection dropped.' : ''),
|
|
269
271
|
retryable: isWrite ? connectFailure : true,
|
|
272
|
+
...(unknownOutcome ? { suggested_action: 'Read the current state (get_timeline, get_items, get_jobs) to see whether it was applied before sending it again.' } : {}),
|
|
270
273
|
});
|
|
271
274
|
const canRetry = attempt < maxAttempts - 1 && (isWrite ? connectFailure : true);
|
|
272
275
|
if (!canRetry)
|
package/dist/commands/run.js
CHANGED
|
@@ -92,6 +92,8 @@ export async function run(argv, connection, mode) {
|
|
|
92
92
|
const answered = await client.toolWithMedia(argv.name, input, { idempotencyKey: argv.idempotencyKey });
|
|
93
93
|
const saved = await saveMedia(answered.media, argv.name, argv.out);
|
|
94
94
|
const pictures = saved.filter((p) => !!p);
|
|
95
|
+
if (argv.out && !pictures.length)
|
|
96
|
+
note('--out saves pictures; this call returned none, so nothing was written there.');
|
|
95
97
|
const drawn = pictures.length ? { ...withPicturePaths(answered.data, saved), pictures } : answered.data;
|
|
96
98
|
const result = answered.cloudProcessing && drawn && typeof drawn === 'object' && !Array.isArray(drawn)
|
|
97
99
|
? { ...drawn, cloud_processing: answered.cloudProcessing }
|
package/dist/source.sha256
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a11529fec7c8973acd0eb530c9fe9763e095386748d999d47db443dc948d877b
|
package/package.json
CHANGED