@skrr-ai/cli 0.1.132 → 0.1.133

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,7 @@ exports.memoryNotMountedDiagnostic = memoryNotMountedDiagnostic;
7
7
  exports.parseMemoryMount = parseMemoryMount;
8
8
  exports.parseMountedMemoryStore = parseMountedMemoryStore;
9
9
  exports.parseMemoryApiError = parseMemoryApiError;
10
+ exports.uncertainMemoryMutationRecovery = uncertainMemoryMutationRecovery;
10
11
  const core_1 = require("@oclif/core");
11
12
  const node_crypto_1 = require("node:crypto");
12
13
  const base_command_1 = require("../base-command");
@@ -191,6 +192,23 @@ function parseMemoryApiError(error) {
191
192
  };
192
193
  }
193
194
  }
195
+ /** A gateway timeout can arrive after the canonical mutation committed. */
196
+ function uncertainMemoryMutationRecovery(path, options, status) {
197
+ if (status !== 504 || options.method !== 'POST' || !/\/mutations\/[^/?]+$/.test(path))
198
+ return null;
199
+ const body = options.body;
200
+ if (!body || body.dryRun === true || typeof body.idempotencyKey !== 'string' || typeof body.targetStoreId !== 'string')
201
+ return null;
202
+ return {
203
+ message: `The write may have been saved. Inspect the canonical Store with skrr memory topics list using the same --agent and --store ${body.targetStoreId}${body.spaceId ? ' and --space ' + body.spaceId : ''}. If retrying the identical operation, use --idempotency-key ${body.idempotencyKey}.`,
204
+ details: {
205
+ outcome: 'unknown',
206
+ targetStoreId: body.targetStoreId,
207
+ idempotencyKey: body.idempotencyKey,
208
+ ...(typeof body.spaceId === 'string' ? { spaceId: body.spaceId } : {}),
209
+ },
210
+ };
211
+ }
194
212
  class ScopedMemoryCommand extends base_command_1.BaseCommand {
195
213
  endpoint(agentId, suffix = '') {
196
214
  return `/api/agents/${encodeURIComponent(agentId)}/memories/workspace${suffix}`;
@@ -229,13 +247,14 @@ class ScopedMemoryCommand extends base_command_1.BaseCommand {
229
247
  catch (error) {
230
248
  if (error instanceof api_fetch_1.ApiFetchError) {
231
249
  const parsed = parseMemoryApiError(error);
250
+ const recovery = uncertainMemoryMutationRecovery(path, options, error.status);
232
251
  this.failWithCliError({
233
- message: `${parsed.code}: ${parsed.message}`,
252
+ message: `${parsed.code}: ${parsed.message}${recovery ? ` ${recovery.message}` : ''}`,
234
253
  code: parsed.code,
235
254
  status: error.status,
236
255
  exit: ERROR_EXITS[parsed.code] || (error.status === 404 ? 4 : error.status === 403 ? 5 : 2),
237
256
  retryable: parsed.retryable,
238
- details: parsed.details,
257
+ details: recovery ? { ...parsed.details, ...recovery.details } : parsed.details,
239
258
  });
240
259
  }
241
260
  this.handleApiError(error);