@synkro-sh/cli 1.7.68 → 1.7.71

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/bootstrap.js CHANGED
@@ -132,7 +132,7 @@ function getIdentity() {
132
132
  if (cached2) return cached2;
133
133
  let cliVersion = "0.0.0";
134
134
  try {
135
- cliVersion = "1.7.68";
135
+ cliVersion = "1.7.71";
136
136
  } catch {
137
137
  }
138
138
  const creds = loadCredentialsIdentity();
@@ -795,7 +795,7 @@ var init_wire = __esm({
795
795
  BATCH_BYTES = 1024 * 1024;
796
796
  REQUEST_TIMEOUT_MS = 15e3;
797
797
  TELEMETRY_BODY_MAX = 4 * 1024 * 1024;
798
- UNRECOVERABLE_STATUSES = [400, 413, 422];
798
+ UNRECOVERABLE_STATUSES = [400, 409, 413, 422];
799
799
  }
800
800
  });
801
801
 
@@ -2755,6 +2755,7 @@ process.stdout.write('{}\\n');
2755
2755
  // cli/auth/stub.ts
2756
2756
  var stub_exports = {};
2757
2757
  __export(stub_exports, {
2758
+ authedFetch: () => authedFetch,
2758
2759
  authenticate: () => authenticate,
2759
2760
  clearCredentials: () => clearCredentials,
2760
2761
  ensureValidToken: () => ensureValidToken,
@@ -3049,8 +3050,10 @@ async function refreshToken() {
3049
3050
  }
3050
3051
  }
3051
3052
  async function ensureValidToken() {
3052
- if (!isAuthenticated()) return false;
3053
+ const creds = loadCredentials();
3054
+ if (!creds?.access_token && !creds?.refresh_token) return false;
3053
3055
  if (isTokenExpired()) {
3056
+ if (!creds.refresh_token) return false;
3054
3057
  if (!refreshPromise) {
3055
3058
  refreshPromise = refreshToken().finally(() => {
3056
3059
  refreshPromise = null;
@@ -3058,12 +3061,23 @@ async function ensureValidToken() {
3058
3061
  }
3059
3062
  const refreshed = await refreshPromise;
3060
3063
  if (!refreshed) {
3061
- clearCredentials();
3062
3064
  return false;
3063
3065
  }
3064
3066
  }
3065
3067
  return true;
3066
3068
  }
3069
+ async function authedFetch(url, init = {}) {
3070
+ const withToken = () => ({
3071
+ ...init,
3072
+ headers: { ...init.headers, Authorization: `Bearer ${getAccessToken() ?? ""}` }
3073
+ });
3074
+ await ensureValidToken();
3075
+ let res = await fetch(url, withToken());
3076
+ if (res.status === 401 && await refreshToken()) {
3077
+ res = await fetch(url, withToken());
3078
+ }
3079
+ return res;
3080
+ }
3067
3081
  function clearCredentials() {
3068
3082
  if (existsSync14(AUTH_FILE)) {
3069
3083
  unlinkSync4(AUTH_FILE);
@@ -6467,7 +6481,7 @@ function writeConfigEnv(opts) {
6467
6481
  `SYNKRO_CREDENTIALS_PATH=${shellQuoteSingle2(credsPath)}`,
6468
6482
  `SYNKRO_TIER=${shellQuoteSingle2(safeTier)}`,
6469
6483
  `SYNKRO_INFERENCE=${shellQuoteSingle2(safeInference)}`,
6470
- `SYNKRO_VERSION=${shellQuoteSingle2("1.7.68")}`
6484
+ `SYNKRO_VERSION=${shellQuoteSingle2("1.7.71")}`
6471
6485
  ];
6472
6486
  if (safeSynkroBin) lines.push(`SYNKRO_CLI_BIN=${shellQuoteSingle2(safeSynkroBin)}`);
6473
6487
  if (safeUserId) lines.push(`SYNKRO_USER_ID=${shellQuoteSingle2(safeUserId)}`);
@@ -7127,7 +7141,7 @@ async function installCommand(opts = {}) {
7127
7141
  await setTelemetryState({ enabled: true, remoteFlushEnabled: telemetryConsent });
7128
7142
  emit("install", {
7129
7143
  phase: "started",
7130
- cli_version_to: "1.7.68",
7144
+ cli_version_to: "1.7.71",
7131
7145
  agents_detected: agents.map((a) => a.kind),
7132
7146
  with_github: false,
7133
7147
  with_local_cc: false,
@@ -10203,13 +10217,20 @@ function parseSession(filePath, sessionId) {
10203
10217
  const kind = e.type === "assistant" || e.message?.role === "assistant" ? "assistant" : e.type === "user" || e.message?.role === "user" ? "user" : "";
10204
10218
  if (!kind) continue;
10205
10219
  const msgObj = e.message;
10220
+ const _cr = msgObj?.content ?? e.content;
10221
+ const isToolResult = kind === "user" && (!!e.toolUseResult || Array.isArray(_cr) && _cr.some((b) => b?.type === "tool_result" || b?.tool_use_id != null));
10222
+ const finalKind = isToolResult ? "tool" : kind;
10206
10223
  const text = extractText(msgObj?.content ?? e.content);
10207
10224
  const blocks = kind === "assistant" && Array.isArray(msgObj?.content) ? msgObj.content : [];
10208
10225
  const toolCalls = blocks.filter((b) => b?.type === "tool_use").map((b) => ({ name: b.name, input: JSON.stringify(b.input || {}).slice(0, 2e4), id: b.id }));
10209
10226
  if (!text.trim() && toolCalls.length === 0) continue;
10210
10227
  const msg = {
10211
10228
  message_index: i,
10212
- type: kind,
10229
+ type: finalKind,
10230
+ // CC's per-entry uuid is STABLE across transcript rewrites/compaction; message_index (line
10231
+ // number) is not. The server keys conversation_messages on this uuid so re-imports update in
10232
+ // place instead of orphaning/duplicating rows. Falls back to message_index server-side if absent.
10233
+ uuid: typeof e.uuid === "string" ? e.uuid : void 0,
10213
10234
  content: text.trim() ? text.slice(0, 8e3) : "\u21B3 " + toolCalls.map((t) => t.name).join(", "),
10214
10235
  timestamp: e.timestamp || null
10215
10236
  };
@@ -11016,7 +11037,7 @@ var subArgs = args.slice(1);
11016
11037
  var isDetachedChild = process.env.SYNKRO_TELEMETRY_DETACHED === "1";
11017
11038
  var FLUSH_SKIP = /* @__PURE__ */ new Set(["grade", "version", "--version", "-v", "help", "--help", "-h", ""]);
11018
11039
  function printVersion() {
11019
- console.log("1.7.68");
11040
+ console.log("1.7.71");
11020
11041
  }
11021
11042
  function printHelp2() {
11022
11043
  console.log(`Synkro CLI \u2014 runtime safety for AI coding agents